diff --git a/Changes b/Changes index 49824ce..f598ada 100644 --- a/Changes +++ b/Changes @@ -1,3 +1,12 @@ +may 2019 + - Added selection begin, end and size in status line. + - Added char '>' at end of status line when the file name doesn't fit. + - Moved file name at end of status line, so when the file name is too long doesn't hide position, size, percentage and selection. + - Added clrtoeol after displayLine to clear to end of line because if you load with F3 and file name have chars beyond ASCII, + it leaves these chars as garbage. + - Also updated to use clrtoeol to cleanup the line. + - fix core dump when file size is 0 (trying to show percentage). + september 2017 - 1.4.2 - fix spelling errors in manpage diff --git a/display.c b/display.c index b3e7cca..b5f6ca8 100644 --- a/display.c +++ b/display.c @@ -183,31 +183,57 @@ void exitCurses(void) void display(void) { int i; + char buf[BUFLEN]; + int len_line; for (i = 0; i < nbBytes; i += lineLength) { move(i / lineLength, 0); displayLine(i, nbBytes); + clrtoeol(); } + for (; i < page; i += lineLength) { - int j; - move(i / lineLength, 0); - for (j = 0; j < colsUsed; j++) printw(" "); /* cleanup the line */ move(i / lineLength, 0); PRINTW(("%08lX", (int) (base + i))); + clrtoeol(); } - attrset(NORMAL); move(LINES - 1, 0); for (i = 0; i < colsUsed; i++) printw("-"); + clrtoeol(); move(LINES - 1, 0); if (isReadOnly) i = '%'; else if (edited) i = '*'; else i = '-'; - printw("-%c%c %s --0x%llX", i, i, baseName, base + cursor); - if (MAX(fileSize, lastEditedLoc)) printw("/0x%llX", getfilesize()); - printw("--%i%%", 100 * (base + cursor + getfilesize()/200) / getfilesize() ); - if (mode == bySector) printw("--sector %lld", (base + cursor) / SECTOR_SIZE); - + len_line = snprintf(buf, BUFLEN, "-%c%c 0x%llX", i, i, base + cursor); + printw(buf); + if (MAX(fileSize, lastEditedLoc)) { + len_line += snprintf(buf, BUFLEN, "/0x%llX", getfilesize()); + printw(buf); + } + if (getfilesize() > 0) { + len_line += snprintf(buf, BUFLEN, "--%i%%%%", 100 * (base + cursor + getfilesize() / 200) / getfilesize() ); + printw(buf); + } else { + len_line += snprintf(buf, BUFLEN, "-- 0%%%%"); + printw(buf); + } + if (mode == bySector) { + len_line += snprintf(buf, BUFLEN, "--sector %lld", (base + cursor) / SECTOR_SIZE); + printw(buf); + } + if (mark_set) { + len_line += snprintf(buf, BUFLEN, "--sel 0x%llX/0x%llX--size 0x%llX", mark_min, mark_max, mark_max - mark_min + 1); + printw(buf); + } + len_line += snprintf(buf, BUFLEN, " %s", baseName); + printw(buf); + // Print space after file name if it fits in the status line. Don't need to be added to length of line. + if (len_line < COLS) printw(" "); + if (len_line > COLS + 1) { + move(LINES - 1, COLS - 1); + printw(">"); + } move(cursor / lineLength, computeCursorXCurrentPos()); } diff --git a/hexedit.h b/hexedit.h index fc57aa9..6b64028 100644 --- a/hexedit.h +++ b/hexedit.h @@ -235,4 +235,6 @@ char *strdup(const char *str) #define memcmp(s1, s2, n) bcmp(s2, s1, n) #endif +#define BUFLEN 1024 + #endif /* HEXEDIT_H */