Skip to content

Feature add selection begin, end and size. Some changes. #38

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 9 additions & 0 deletions Changes
Original file line number Diff line number Diff line change
@@ -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
Expand Down
44 changes: 35 additions & 9 deletions display.c
Original file line number Diff line number Diff line change
Expand Up @@ -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());
}

Expand Down
2 changes: 2 additions & 0 deletions hexedit.h
Original file line number Diff line number Diff line change
Expand Up @@ -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 */