aboutsummaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authorElliott Hughes <enh@google.com>2021-04-19 13:57:10 -0700
committerRob Landley <rob@landley.net>2021-04-20 03:36:20 -0500
commit76479c3ed071f1e4d985694ad86a144e8a716f5c (patch)
tree7ddf561804abf5169c3712ccf39cc7a1eee003a4 /lib
parent9cacde056ce7f6bd4b3a2f181017a33c6dff3e5a (diff)
downloadtoybox-76479c3ed071f1e4d985694ad86a144e8a716f5c.tar.gz
hexedit: various improvements.
I've been using hexedit quite a lot, mainly for _corrupting_ files, and have been meaning to send this collection of changes for far too long now. I saw a bug requesting editing in the ASCII pane (which this patch _doesn't_ add), and wanted to get this sent in before it has to undergo the third massive merge conflict of its existence... The main "TODO" in this is that I never got round to implementing searching for an arbitrary byte sequence. It seems like we ought to have that feature, but personally I'm far more likely to jump to an offset or to search for some ASCII. I haven't needed to search for arbitrary byte sequences in all this time, so I'll fix this if/when I actually need it... * Enter (new) read-only mode rather than refusing to open read-only files. * More keys: page up/page down, home/end, and ctrl-home/ctrl-end for beginning/end of file. * Jump with ^J (or vi-like :). Enter absolute address or +12 or -40 for relative jumps. * Find with ^F (or vi-like /). No support for bytes, but useful for finding text. (^G or n for next match, ^D or p for previous match.) * Support all the usual suspects for "quit": vi-like q, desktop-like ^Q, panic ^C, or even plain old Esc. * The ASCII pane is made more readable by (hopefully) reasonable use of color. Regular control characters are shown in red using the appropriate letter (so a red A is 0x01, etc), printable characters are shown normally, and top-bit set characters are just shown as a purple question mark (since I couldn't come up with a better representation that had any obvious value --- in my experience top-bit set characters are either meaningless in ASCII, part of a UTF-8 sequence in modern files, or in some random code page in ancient files). The choice of red and purple was to deliberately make these not-actually-ASCII characters slide into the background; before this patch they have so many bright pixels (especially with the use of reverse video) that I couldn't clearly see the *actual* ASCII content in the ASCII pane. * Addresses are now shown in yellow. No real justification other than "it looks nice". * NUL bytes in the hex pane are shown dimmed. I find this helpful especially when there's a lot of padding, and it can actually be a useful clue when reverse engineering (you can "see" repeated patterns more easily), but I can understand if this one's controversial. * Errors are shown "vim style" in bold white text on a red background, waiting briefly to ensure they're seen. * The status bar shows the filename, whether the file is opened read-only, the current offset into the file, and the total length of the file. * SIGWINCH handling has been added.
Diffstat (limited to 'lib')
-rw-r--r--lib/tty.c4
1 files changed, 4 insertions, 0 deletions
diff --git a/lib/tty.c b/lib/tty.c
index b0d0c5d5..d7e0f47f 100644
--- a/lib/tty.c
+++ b/lib/tty.c
@@ -150,9 +150,11 @@ struct scan_key_list {
// VT102/VT220 escapes.
{KEY_HOME, "\033[1~"},
+ {KEY_HOME|KEY_CTRL, "\033[1;5~"},
{KEY_INSERT, "\033[2~"},
{KEY_DELETE, "\033[3~"},
{KEY_END, "\033[4~"},
+ {KEY_END|KEY_CTRL, "\033[4;5~"},
{KEY_PGUP, "\033[5~"},
{KEY_PGDN, "\033[6~"},
// "Normal" "PC" escapes (xterm).
@@ -161,6 +163,8 @@ struct scan_key_list {
// "Application" "PC" escapes (gnome-terminal).
{KEY_HOME, "\033[H"},
{KEY_END, "\033[F"},
+ {KEY_HOME|KEY_CTRL, "\033[1;5H"},
+ {KEY_END|KEY_CTRL, "\033[1;5F"},
{KEY_FN+1, "\033OP"}, {KEY_FN+2, "\033OQ"}, {KEY_FN+3, "\033OR"},
{KEY_FN+4, "\033OS"}, {KEY_FN+5, "\033[15~"}, {KEY_FN+6, "\033[17~"},