* view.c (display): Splitted up into view_display_hex() and

view_display_text().
This commit is contained in:
Roland Illig 2005-06-28 13:21:42 +00:00
parent 868c55faa6
commit dfbc2522aa
2 changed files with 232 additions and 197 deletions

View File

@ -5,6 +5,8 @@
(do_regexp_search): Removed unnecessary type cast.
(do_normal_search): Likewise.
* view.c (display): Changed return type to void.
* view.c (display): Splitted up into view_display_hex() and
view_display_text().
2005-06-27 Roland Illig <roland.illig@gmx.de>

View File

@ -1555,47 +1555,36 @@ view_display_ruler (WView *view)
attrset (NORMAL_COLOR);
}
/* Displays as much data from view->dpy_topleft as fits on the screen */
static void
display (WView *view)
view_display_hex (WView *view)
{
const int left = view_get_left (view);
const int top = view_get_top (view);
const int right = view_get_right (view);
int col = left;
int row = view_get_top (view);
int bottom, right;
int bottom;
offset_type from;
int c;
mark_t boldflag = MARK_NORMAL;
struct hexedit_change_node *curr = view->change_list;
bottom = view_get_bottom (view);
right = view_get_right (view);
from = view->dpy_topleft;
attrset (NORMAL_COLOR);
view_display_clean (view, bottom, right);
/* Optionally, display a ruler */
if ((!view->hex_mode) && (ruler)) {
view_display_ruler (view);
if (ruler == 1)
row += 2;
else
bottom -= 2;
}
/* Find the first displayable changed byte */
while (curr && (curr->offset < from)) {
curr = curr->next;
}
if (view->hex_mode) {
char hex_buff[10]; /* A temporary buffer for sprintf and mvwaddstr */
int bytes; /* Number of bytes already printed on the line */
/* Start of text column */
int text_start = right - view->bytes_per_line;
bottom = view_get_bottom (view);
from = view->dpy_topleft;
attrset (NORMAL_COLOR);
view_display_clean (view, bottom, right);
/* Find the first displayable changed byte */
while (curr && (curr->offset < from)) {
curr = curr->next;
}
for (; get_byte (view, from) != -1 && row < bottom; row++) {
/* Print the hex offset */
attrset (MARKED_COLOR);
@ -1671,7 +1660,6 @@ display (WView *view)
&& from ==
view->search_start + view->found_len - 1)
attrset (MARKED_COLOR);
}
if (boldflag != MARK_NORMAL
&& from < view->search_start + view->found_len - 1
@ -1717,7 +1705,42 @@ display (WView *view)
}
}
view_place_cursor (view);
} else {
view->dpy_complete = (get_byte (view, from) == -1);
}
static void
view_display_text (WView * view)
{
const int left = view_get_left (view);
const int top = view_get_top (view);
int col = left;
int row = view_get_top (view);
int bottom, right;
offset_type from;
int c;
mark_t boldflag = MARK_NORMAL;
struct hexedit_change_node *curr = view->change_list;
bottom = view_get_bottom (view);
right = view_get_right (view);
from = view->dpy_topleft;
attrset (NORMAL_COLOR);
view_display_clean (view, bottom, right);
/* Find the first displayable changed byte */
while (curr && (curr->offset < from)) {
curr = curr->next;
}
/* Optionally, display a ruler */
if (ruler) {
view_display_ruler (view);
if (ruler == 1)
row += 2;
else
bottom -= 2;
}
for (; row < bottom && (c = get_byte (view, from)) != -1; from++) {
if (view->text_nroff_mode && c == '\b') {
int c_prev;
@ -1787,10 +1810,20 @@ display (WView *view)
attrset (NORMAL_COLOR);
}
}
}
view->dpy_complete = (get_byte (view, from) == -1);
}
/* Displays as much data from view->dpy_topleft as fits on the screen */
static void
display (WView *view)
{
if (view->hex_mode) {
view_display_hex (view);
} else {
view_display_text (view);
}
}
static void
view_place_cursor (WView *view)
{