status info now updates correctly

master
Alessandro Mauri 4 years ago
parent 580e2fa5be
commit 091a63a679
  1. 5
      src/config.h
  2. 15
      src/ste.c

@ -18,4 +18,9 @@
#define KEY_MOVE_DOWN KEY_DOWN #define KEY_MOVE_DOWN KEY_DOWN
#define KEY_FILE_FIND CTRL('f') #define KEY_FILE_FIND CTRL('f')
/* Modify ONLY if you know what you are doing */
#define FILENAME_MAX_LENGTH 128
#define STAT_SIZE 256
/*--------------------------------------------*/
#endif #endif

@ -14,7 +14,6 @@
/* defines */ /* defines */
#define CTRL(k) ((k) & 0x1f) // Control mask modifier #define CTRL(k) ((k) & 0x1f) // Control mask modifier
#define STAT_SIZE 128
#define CBUF_SIZE 2048 #define CBUF_SIZE 2048
#define MODE_MASK 0x1 #define MODE_MASK 0x1
@ -59,6 +58,7 @@ struct term {
int pad; int pad;
char mode_b; char mode_b;
CharBuffer search_buffer; CharBuffer search_buffer;
char filename[FILENAME_MAX_LENGTH];
} t; } t;
FileBuffer rows; FileBuffer rows;
@ -106,18 +106,14 @@ int main (int argc, char *argv[])
bufInit(&rows); bufInit(&rows);
/* Try to open the file */ /* Try to open the file */
if (argc < 2) { if (argc < 2) die("File not found", BAD_FILE);
perror("File not found"); fileOpen(argv[1]);
exit(1); snprintf(t.filename, FILENAME_MAX_LENGTH, "%s", argv[1]);
} else fileOpen(argv[1]);
/* Initialize the terminal in raw mode, /* Initialize the terminal in raw mode,
* start curses and initialize the term struct */ * start curses and initialize the term struct */
termInit(); termInit();
/* Set the statusbar left (static) message */
snprintf(t.statusbar, STAT_SIZE, "%s %d lines %dx%d", argv[1], rows.rownum, t.dim.y, t.dim.x);
/* Main event loop */ /* Main event loop */
while (1) { while (1) {
static int c; static int c;
@ -574,6 +570,9 @@ void handleDel (int select)
void updateInfo (void) void updateInfo (void)
{ {
/* Set the statusbar left message */
snprintf(t.statusbar, STAT_SIZE, "%s %d lines %dx%d", t.filename, rows.rownum, t.dim.y, t.dim.x);
getmaxyx(stdscr, t.dim.y, t.dim.x); getmaxyx(stdscr, t.dim.y, t.dim.x);
t.dim.y -= 1; t.dim.y -= 1;
t.pad = decimalSize(rows.rownum - 1); t.pad = decimalSize(rows.rownum - 1);

Loading…
Cancel
Save