diff --git a/ChangeLog b/ChangeLog index afb744a19197356b0c511357a5bec3a00beded20..08aa4aebf7016a59c3e8e0d50ab271b9058330c4 100644 --- a/ChangeLog +++ b/ChangeLog @@ -15,8 +15,9 @@ CVS code - that make use of a smaller number. Changes to window_init(), nanoget_repaint(), titlebar(), statusbar(), and get_page_start(). (DLR) - - Move xplustabs(), actual_x(), strnlenpt(), and strlenpt() from - winio.c to utils.c, as they're really utility functions. (DLR) + - Move get_page_start(), xplustabs(), actual_x(), strnlenpt(), + and strlenpt() from winio.c to utils.c, as they're really + utility functions. (DLR) - Move functions specific to the statusbar prompt to their own source file, and adjust related variables accordingly. New file prompt.c; changes to do_statusbar_input(), diff --git a/src/proto.h b/src/proto.h index 3ca6f77abc3d3499933cedbfd4f6014d3bb48c57..5322f3a7bc95388ed49b58026464e368806cc4db 100644 --- a/src/proto.h +++ b/src/proto.h @@ -604,6 +604,7 @@ void *nrealloc(void *ptr, size_t howmuch); char *mallocstrncpy(char *dest, const char *src, size_t n); char *mallocstrcpy(char *dest, const char *src); char *mallocstrassn(char *dest, char *src); +size_t get_page_start(size_t column); size_t xplustabs(void); size_t actual_x(const char *s, size_t column); size_t strnlenpt(const char *s, size_t maxlen); @@ -670,7 +671,6 @@ void set_modified(void); void statusbar(const char *msg, ...); void bottombars(const shortcut *s); void onekey(const char *keystroke, const char *desc, size_t len); -size_t get_page_start(size_t column); void reset_cursor(void); void edit_draw(const filestruct *fileptr, const char *converted, int line, size_t start); diff --git a/src/utils.c b/src/utils.c index ff97788b18ad7e5dade28d99dd2c9daeecafc742..169a908e5e1bf98c033010744ecfb7b930bd1826 100644 --- a/src/utils.c +++ b/src/utils.c @@ -395,6 +395,20 @@ char *mallocstrassn(char *dest, char *src) return src; } +/* nano scrolls horizontally within a line in chunks. Return the column + * number of the first character displayed in the edit window when the + * cursor is at the given column. Note that (0 <= column - + * get_page_start(column) < COLS). */ +size_t get_page_start(size_t column) +{ + if (column == 0 || column < COLS - 1) + return 0; + else if (COLS > 9) + return column - 7 - (column - 7) % (COLS - 8); + else + return column - (COLS - 2); +} + /* Return the placewewant associated with current_x, i.e, the zero-based * column position of the cursor. The value will be no smaller than * current_x. */ @@ -403,9 +417,9 @@ size_t xplustabs(void) return strnlenpt(openfile->current->data, openfile->current_x); } -/* actual_x() gives the index in s of the character displayed at the - * given column. That is, actual_x() is the largest value such that - * strnlenpt(s, actual_x(s, column)) <= column. */ +/* Return the index in s of the character displayed at the given column, + * i.e, the largest value such that strnlenpt(s, actual_x(s, column)) <= + * column. */ size_t actual_x(const char *s, size_t column) { size_t i = 0; diff --git a/src/winio.c b/src/winio.c index 91abf7b62901ed29f7e19a23d152a8e9f7f96d07..b763b86dd24e963bd594217a4668b1997d668f01 100644 --- a/src/winio.c +++ b/src/winio.c @@ -2185,22 +2185,8 @@ void onekey(const char *keystroke, const char *desc, size_t len) } } -/* nano scrolls horizontally within a line in chunks. This function - * returns the column number of the first character displayed in the - * edit window when the cursor is at the given column. Note that (0 <= - * column - get_page_start(column) < COLS). */ -size_t get_page_start(size_t column) -{ - if (column == 0 || column < COLS - 1) - return 0; - else if (COLS > 9) - return column - 7 - (column - 7) % (COLS - 8); - else - return column - (COLS - 2); -} - -/* Resets current_y, based on the position of current, and puts the - * cursor in the edit window at (current_y, current_x). */ +/* Reset current_y, based on the position of current, and put the cursor + * in the edit window at (current_y, current_x). */ void reset_cursor(void) { /* If we haven't opened any files yet, put the cursor in the top