diff options
author | Denys Vlasenko <vda.linux@googlemail.com> | 2017-09-13 23:02:51 +0200 |
---|---|---|
committer | Denys Vlasenko <vda.linux@googlemail.com> | 2017-09-13 23:02:51 +0200 |
commit | 62643017c3d5bc1bb9fff91553e52a47e7730a01 (patch) | |
tree | 142224bb30ff225f09c0454cf14585a66d302788 /miscutils | |
parent | 8187e0143874e1bf0412263e716cf8c782a5aa16 (diff) | |
download | busybox-w32-62643017c3d5bc1bb9fff91553e52a47e7730a01.tar.gz busybox-w32-62643017c3d5bc1bb9fff91553e52a47e7730a01.tar.bz2 busybox-w32-62643017c3d5bc1bb9fff91553e52a47e7730a01.zip |
hexedit: implement page up/down
function old new delta
hexedit_main 924 970 +46
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
Diffstat (limited to 'miscutils')
-rw-r--r-- | miscutils/hexedit.c | 14 |
1 files changed, 13 insertions, 1 deletions
diff --git a/miscutils/hexedit.c b/miscutils/hexedit.c index ac38978fd..a99569706 100644 --- a/miscutils/hexedit.c +++ b/miscutils/hexedit.c | |||
@@ -236,7 +236,7 @@ int hexedit_main(int argc UNUSED_PARAM, char **argv) | |||
236 | redraw(); | 236 | redraw(); |
237 | printf(ESC"[1;10H"); /* position on 1st hex byte in first line */ | 237 | printf(ESC"[1;10H"); /* position on 1st hex byte in first line */ |
238 | 238 | ||
239 | //TODO: //PgUp/PgDown; Home/End: start/end of line; '<'/'>': start/end of file | 239 | //TODO: //Home/End: start/end of line; '<'/'>': start/end of file |
240 | //Backspace: undo | 240 | //Backspace: undo |
241 | //Enter: goto specified position | 241 | //Enter: goto specified position |
242 | //Ctrl-L: redraw | 242 | //Ctrl-L: redraw |
@@ -249,12 +249,14 @@ int hexedit_main(int argc UNUSED_PARAM, char **argv) | |||
249 | 249 | ||
250 | for (;;) { | 250 | for (;;) { |
251 | char read_key_buffer[KEYCODE_BUFFER_SIZE]; | 251 | char read_key_buffer[KEYCODE_BUFFER_SIZE]; |
252 | unsigned cnt; | ||
252 | int32_t key; | 253 | int32_t key; |
253 | uint8_t byte; | 254 | uint8_t byte; |
254 | 255 | ||
255 | fflush_all(); | 256 | fflush_all(); |
256 | key = read_key(STDIN_FILENO, read_key_buffer, -1); | 257 | key = read_key(STDIN_FILENO, read_key_buffer, -1); |
257 | 258 | ||
259 | cnt = 1; | ||
258 | switch (key) { | 260 | switch (key) { |
259 | case 'A': case 'B': case 'C': case 'D': case 'E': case 'F': | 261 | case 'A': case 'B': case 'C': case 'D': case 'E': case 'F': |
260 | case 'a': case 'b': case 'c': case 'd': case 'e': case 'f': | 262 | case 'a': case 'b': case 'c': case 'd': case 'e': case 'f': |
@@ -307,7 +309,10 @@ int hexedit_main(int argc UNUSED_PARAM, char **argv) | |||
307 | putchar(' '); | 309 | putchar(' '); |
308 | } | 310 | } |
309 | break; | 311 | break; |
312 | case KEYCODE_PAGEDOWN: | ||
313 | cnt = G.height; | ||
310 | case KEYCODE_DOWN: | 314 | case KEYCODE_DOWN: |
315 | k_down: | ||
311 | G.current_byte += 16; | 316 | G.current_byte += 16; |
312 | if (G.current_byte >= G.eof_byte) { | 317 | if (G.current_byte >= G.eof_byte) { |
313 | move_mapping_further(); | 318 | move_mapping_further(); |
@@ -324,6 +329,8 @@ int hexedit_main(int argc UNUSED_PARAM, char **argv) | |||
324 | row--; | 329 | row--; |
325 | redraw_cur_line(); | 330 | redraw_cur_line(); |
326 | } | 331 | } |
332 | if (--cnt) | ||
333 | goto k_down; | ||
327 | break; | 334 | break; |
328 | 335 | ||
329 | case KEYCODE_LEFT: | 336 | case KEYCODE_LEFT: |
@@ -348,7 +355,10 @@ int hexedit_main(int argc UNUSED_PARAM, char **argv) | |||
348 | G.current_byte--; | 355 | G.current_byte--; |
349 | printf(ESC"[2D"); | 356 | printf(ESC"[2D"); |
350 | break; | 357 | break; |
358 | case KEYCODE_PAGEUP: | ||
359 | cnt = G.height; | ||
351 | case KEYCODE_UP: | 360 | case KEYCODE_UP: |
361 | k_up: | ||
352 | if ((G.current_byte - G.addr) < 16) { | 362 | if ((G.current_byte - G.addr) < 16) { |
353 | move_mapping_lower(); | 363 | move_mapping_lower(); |
354 | if ((G.current_byte - G.addr) < 16) | 364 | if ((G.current_byte - G.addr) < 16) |
@@ -364,6 +374,8 @@ int hexedit_main(int argc UNUSED_PARAM, char **argv) | |||
364 | printf(ESC"M"); /* scroll up */ | 374 | printf(ESC"M"); /* scroll up */ |
365 | redraw_cur_line(); | 375 | redraw_cur_line(); |
366 | } | 376 | } |
377 | if (--cnt) | ||
378 | goto k_up; | ||
367 | break; | 379 | break; |
368 | } | 380 | } |
369 | } | 381 | } |