a few last missing minor bits of DB's refactored display code

git-svn-id: svn://svn.savannah.gnu.org/nano/trunk/nano@1561 35c25a1d-7b9e-4130-9fde-d3aeb78583b8
master
David Lawrence Ramsey 2003-09-29 05:15:24 +00:00
parent f03c78b382
commit 2dd7ed14bc
3 changed files with 25 additions and 15 deletions

View File

@ -46,12 +46,13 @@ CVS code -
instead of several; and do some other minor refactoring of instead of several; and do some other minor refactoring of
related display functions to simplify them. New functions related display functions to simplify them. New functions
mark_order() and display_string(); changes to actual_x(), mark_order() and display_string(); changes to actual_x(),
strnlenpt(), blank_bottombars(), edit_add(), update_line(), strnlenpt(), blank_bottombars(), blank_edit(),
statusbar(), and do_replace_highlight(). (David Benbennick) get_page_start(), edit_add(), update_line(), statusbar(), and
DLR: Add minor cosmetic tweaks, add missing NANO_SMALL #ifdef do_replace_highlight(). (David Benbennick) DLR: Add minor
around the text for a backwards search in the refactored code, cosmetic tweaks, add missing NANO_SMALL #ifdef around the text
and enclose dump_buffer() and dump_buffer_reverse() in one for a backwards search in the refactored code, and enclose
ENABLE_DEBUG #ifdef instead of two. dump_buffer() and dump_buffer_reverse() in one ENABLE_DEBUG
#ifdef instead of two.
- Convert memmove() function calls to charmove() macro calls, as - Convert memmove() function calls to charmove() macro calls, as
the former all work on char*'s. (DLR) the former all work on char*'s. (DLR)
- files.c: - files.c:

View File

@ -473,7 +473,7 @@ void onekey(const char *keystroke, const char *desc, int len);
#ifndef NDEBUG #ifndef NDEBUG
int check_linenumbers(const filestruct *fileptr); int check_linenumbers(const filestruct *fileptr);
#endif #endif
int get_page_start(int column); size_t get_page_start(size_t column);
void reset_cursor(void); void reset_cursor(void);
void add_marked_sameline(int begin, int end, filestruct *fileptr, int y, void add_marked_sameline(int begin, int end, filestruct *fileptr, int y,
int virt_cur_x, int this_page); int virt_cur_x, int this_page);

View File

@ -411,7 +411,7 @@ void blank_bottomwin(void)
void blank_edit(void) void blank_edit(void)
{ {
int i; int i;
for (i = 0; i <= editwinrows - 1; i++) for (i = 0; i < editwinrows; i++)
mvwaddstr(edit, i, 0, hblank); mvwaddstr(edit, i, 0, hblank);
} }
@ -963,13 +963,22 @@ int check_linenumbers(const filestruct *fileptr)
} }
#endif #endif
/* nano scrolls horizontally within a line in chunks. This function /* nano scrolls horizontally within a line in chunks. This function
* returns the column number of the first character displayed in the * returns the column number of the first character displayed in the
* window when the cursor is at the given column. */ * window when the cursor is at the given column. Note that
int get_page_start(int column) * 0 <= column - get_page_start(column) < COLS. */
size_t get_page_start(size_t column)
{ {
assert(COLS > 9); assert(COLS > 0);
return column < COLS - 1 ? 0 : column - 7 - (column - 8) % (COLS - 9); if (column == 0 || column < COLS - 1)
return 0;
else if (COLS > 9)
return column - 7 - (column - 8) % (COLS - 9);
else if (COLS > 2)
return column - (COLS - 2);
else
return column - (COLS - 1);
/* The parentheses are necessary to avoid overflow. */
} }
/* Resets current_y, based on the position of current, and puts the /* Resets current_y, based on the position of current, and puts the
@ -1318,7 +1327,7 @@ void update_line(const filestruct *fileptr, size_t index)
/* Next, convert variables that index the line to their equivalent /* Next, convert variables that index the line to their equivalent
* positions in the expanded line. */ * positions in the expanded line. */
index = fileptr == current ? strnlenpt(fileptr->data, index) : 0; index = (fileptr == current) ? strnlenpt(fileptr->data, index) : 0;
page_start = get_page_start(index); page_start = get_page_start(index);
/* Expand the line, replacing Tab by spaces, and control characters /* Expand the line, replacing Tab by spaces, and control characters