* view.c (display): Use only declared color pairs to fix hex

editor appearance with ncurses.  Eliminate some useless defines.
This commit is contained in:
Pavel Roskin 2002-08-14 07:41:01 +00:00
parent 62a7a04fe5
commit 7ea7ec49ab
2 changed files with 26 additions and 31 deletions

View File

@ -1,3 +1,8 @@
2002-08-14 Pavel Roskin <proski@gnu.org>
* view.c (display): Use only declared color pairs to fix hex
editor appearance with ncurses. Eliminate some useless defines.
2002-08-10 Pavel Roskin <proski@gnu.org> 2002-08-10 Pavel Roskin <proski@gnu.org>
* key.c (delete_select_channel): Avoid using freed memory. * key.c (delete_select_channel): Avoid using freed memory.

View File

@ -739,8 +739,6 @@ view_status (WView *view, gboolean update_gui)
attrset (SELECTED_COLOR); attrset (SELECTED_COLOR);
} }
#define view_set_color(view,font) attrset (font)
static inline void static inline void
view_display_clean (WView *view, int height, int width) view_display_clean (WView *view, int height, int width)
{ {
@ -763,15 +761,9 @@ view_display_clean (WView *view, int height, int width)
#define view_add_string(view,s) addstr (s) #define view_add_string(view,s) addstr (s)
#define view_gotoyx(v,r,c) widget_move (v,r,c) #define view_gotoyx(v,r,c) widget_move (v,r,c)
#define BOLD_COLOR MARKED_COLOR
#define UNDERLINE_COLOR VIEW_UNDERLINED_COLOR
#define MARK_COLOR SELECTED_COLOR
#define DEF_COLOR NORMAL_COLOR
#define view_freeze(view) #define view_freeze(view)
#define view_thaw(view) #define view_thaw(view)
#define PICK_COLOR(a,b) a : b
#define STATUS_LINES 1 #define STATUS_LINES 1
/* Shows the file pointed to by *start_display on view_win */ /* Shows the file pointed to by *start_display on view_win */
@ -790,7 +782,7 @@ display (WView * view)
height = view->widget.lines - frame_shift; height = view->widget.lines - frame_shift;
width = view->widget.cols - frame_shift; width = view->widget.cols - frame_shift;
from = view->start_display; from = view->start_display;
view_set_color (view, DEF_COLOR); attrset (NORMAL_COLOR);
view_freeze (view); view_freeze (view);
view_display_clean (view, height, width); view_display_clean (view, height, width);
@ -800,7 +792,7 @@ display (WView * view)
char r_buff[10]; char r_buff[10];
int cl; int cl;
view_set_color (view, BOLD_COLOR); attrset (MARKED_COLOR);
for (c = frame_shift; c < width; c++) { for (c = frame_shift; c < width; c++) {
cl = c - view->start_col; cl = c - view->start_col;
if (ruler == 1) if (ruler == 1)
@ -823,7 +815,7 @@ display (WView * view)
view_add_string (view, r_buff); view_add_string (view, r_buff);
} }
} }
view_set_color (view, DEF_COLOR); attrset (NORMAL_COLOR);
if (ruler == 1) if (ruler == 1)
row += 2; row += 2;
else else
@ -843,12 +835,12 @@ display (WView * view)
for (; row < height && from < view->last_byte; row++) { for (; row < height && from < view->last_byte; row++) {
/* Print the hex offset */ /* Print the hex offset */
view_set_color (view, BOLD_COLOR); attrset (MARKED_COLOR);
g_snprintf (hex_buff, sizeof (hex_buff), "%08X", g_snprintf (hex_buff, sizeof (hex_buff), "%08X",
(int) (from - view->first)); (int) (from - view->first));
view_gotoyx (view, row, frame_shift); view_gotoyx (view, row, frame_shift);
view_add_string (view, hex_buff); view_add_string (view, hex_buff);
view_set_color (view, DEF_COLOR); attrset (NORMAL_COLOR);
/* Hex dump starts from column nine */ /* Hex dump starts from column nine */
col = 9; col = 9;
@ -863,14 +855,14 @@ display (WView * view)
c = curr->value; c = curr->value;
curr = curr->next; curr = curr->next;
boldflag = 3; boldflag = 3;
view_set_color (view, 7); attrset (VIEW_UNDERLINED_COLOR);
} else } else
c = (unsigned char) get_byte (view, from); c = (unsigned char) get_byte (view, from);
if (view->found_len && from >= view->search_start if (view->found_len && from >= view->search_start
&& from < view->search_start + view->found_len) { && from < view->search_start + view->found_len) {
boldflag = 1; boldflag = 1;
view_set_color (view, BOLD_COLOR); attrset (MARKED_COLOR);
} }
/* Display the navigation cursor */ /* Display the navigation cursor */
if (from == view->edit_cursor) { if (from == view->edit_cursor) {
@ -879,9 +871,9 @@ display (WView * view)
view->cursor_col = col; view->cursor_col = col;
} }
boldflag = 2; boldflag = 2;
view_set_color (view, attrset (view->view_side ==
view->view_side == view_side_left ? VIEW_UNDERLINED_COLOR :
view_side_left ? PICK_COLOR (15, 33)); MARKED_SELECTED_COLOR);
} }
/* Print a hex number (sprintf is too slow) */ /* Print a hex number (sprintf is too slow) */
@ -892,13 +884,13 @@ display (WView * view)
col += 3; col += 3;
/* Turn off the cursor or changed byte highlighting here */ /* Turn off the cursor or changed byte highlighting here */
if (boldflag > 1) if (boldflag > 1)
view_set_color (view, DEF_COLOR); attrset (NORMAL_COLOR);
if ((bytes & 3) == 3 && bytes + 1 < view->bytes_per_line) { if ((bytes & 3) == 3 && bytes + 1 < view->bytes_per_line) {
/* Turn off the search highlighting */ /* Turn off the search highlighting */
if (boldflag == 1 if (boldflag == 1
&& from == && from ==
view->search_start + view->found_len - 1) view->search_start + view->found_len - 1)
view_set_color (view, DEF_COLOR); attrset (NORMAL_COLOR);
/* Hex numbers are printed in the groups of four */ /* Hex numbers are printed in the groups of four */
/* Groups are separated by a vline */ /* Groups are separated by a vline */
@ -912,7 +904,7 @@ display (WView * view)
if (boldflag if (boldflag
&& from == && from ==
view->search_start + view->found_len - 1) view->search_start + view->found_len - 1)
view_set_color (view, BOLD_COLOR); attrset (MARKED_COLOR);
} }
if (boldflag if (boldflag
@ -935,15 +927,13 @@ display (WView * view)
default: default:
break; break;
case 1: case 1:
view_set_color (view, BOLD_COLOR); attrset (MARKED_COLOR);
goto setcursor; goto setcursor;
case 2: case 2:
view_set_color (view, attrset (MARKED_SELECTED_COLOR);
view->view_side ==
view_side_left ? PICK_COLOR (33, 15));
goto setcursor; goto setcursor;
case 3: case 3:
view_set_color (view, 7); attrset (VIEW_UNDERLINED_COLOR);
setcursor: setcursor:
if (view->view_side == view_side_right) { if (view->view_side == view_side_right) {
@ -955,7 +945,7 @@ display (WView * view)
if (boldflag) { if (boldflag) {
boldflag = 0; boldflag = 0;
view_set_color (view, DEF_COLOR); attrset (NORMAL_COLOR);
} }
} }
} }
@ -998,16 +988,16 @@ display (WView * view)
col--; col--;
boldflag = 1; boldflag = 1;
if (c_prev == '_' && c_next != '_') if (c_prev == '_' && c_next != '_')
view_set_color (view, UNDERLINE_COLOR); attrset (VIEW_UNDERLINED_COLOR);
else else
view_set_color (view, BOLD_COLOR); attrset (MARKED_COLOR);
continue; continue;
} }
} }
if (view->found_len && from >= view->search_start if (view->found_len && from >= view->search_start
&& from < view->search_start + view->found_len) { && from < view->search_start + view->found_len) {
boldflag = 1; boldflag = 1;
view_set_color (view, MARK_COLOR); attrset (SELECTED_COLOR);
} }
if (col >= frame_shift - view->start_col if (col >= frame_shift - view->start_col
&& col < width - view->start_col) { && col < width - view->start_col) {
@ -1025,7 +1015,7 @@ display (WView * view)
col++; col++;
if (boldflag) { if (boldflag) {
boldflag = 0; boldflag = 0;
view_set_color (view, DEF_COLOR); attrset (NORMAL_COLOR);
} }
/* Very last thing */ /* Very last thing */