* view.c (view_handle_editkey): Code cleanup.

* view.c (view_percent): Likewise.
This commit is contained in:
Roland Illig 2004-12-02 20:36:31 +00:00
parent 2a9f3b6ce3
commit 1438faeaca

View File

@ -396,13 +396,14 @@ view_handle_editkey (WView *view, int key)
if (!view->hexedit_text) { if (!view->hexedit_text) {
/* Hex editing */ /* Hex editing */
unsigned int hexvalue = 0;
if (key >= '0' && key <= '9') if (key >= '0' && key <= '9')
key -= '0'; hexvalue = 0 + (key - '0');
else if (key >= 'A' && key <= 'F') else if (key >= 'A' && key <= 'F')
key -= '7'; hexvalue = 10 + (key - 'A');
else if (key >= 'a' && key <= 'f') else if (key >= 'a' && key <= 'f')
key -= 'W'; hexvalue = 10 + (key - 'a');
else else
return MSG_NOT_HANDLED; return MSG_NOT_HANDLED;
@ -412,9 +413,9 @@ view_handle_editkey (WView *view, int key)
byte_val = get_byte (view, view->edit_cursor); byte_val = get_byte (view, view->edit_cursor);
if (!view->nib_shift) { if (!view->nib_shift) {
byte_val = (byte_val & 0x0f) | (key << 4); byte_val = (byte_val & 0x0f) | (hexvalue << 4);
} else { } else {
byte_val = (byte_val & 0xf0) | (key); byte_val = (byte_val & 0xf0) | (hexvalue);
} }
} else { } else {
/* Text editing */ /* Text editing */
@ -804,12 +805,6 @@ view_percent (WView *view, int p, int w, gboolean update_gui)
else else
percent = p * 100 / view->last_byte; percent = p * 100 / view->last_byte;
#if 0
percent = view->s.st_size == 0 ? 100 :
(view->last_byte == view->last ? 100 :
(p) * 100 / view->s.st_size);
#endif
widget_move (view, view->have_frame, w - 5); widget_move (view, view->have_frame, w - 5);
printw ("%3d%%", percent); printw ("%3d%%", percent);
} }