Commit 2b9d6a0e authored by David Lawrence Ramsey's avatar David Lawrence Ramsey
Browse files

move get_page_start() from winio.c to utils.c too, and fix a few

comments


git-svn-id: svn://svn.savannah.gnu.org/nano/trunk/nano@3066 35c25a1d-7b9e-4130-9fde-d3aeb78583b8
No related merge requests found
Showing with 23 additions and 22 deletions
+23 -22
...@@ -15,8 +15,9 @@ CVS code - ...@@ -15,8 +15,9 @@ CVS code -
that make use of a smaller number. Changes to window_init(), that make use of a smaller number. Changes to window_init(),
nanoget_repaint(), titlebar(), statusbar(), and nanoget_repaint(), titlebar(), statusbar(), and
get_page_start(). (DLR) get_page_start(). (DLR)
- Move xplustabs(), actual_x(), strnlenpt(), and strlenpt() from - Move get_page_start(), xplustabs(), actual_x(), strnlenpt(),
winio.c to utils.c, as they're really utility functions. (DLR) 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 - Move functions specific to the statusbar prompt to their own
source file, and adjust related variables accordingly. New source file, and adjust related variables accordingly. New
file prompt.c; changes to do_statusbar_input(), file prompt.c; changes to do_statusbar_input(),
......
...@@ -604,6 +604,7 @@ void *nrealloc(void *ptr, size_t howmuch); ...@@ -604,6 +604,7 @@ void *nrealloc(void *ptr, size_t howmuch);
char *mallocstrncpy(char *dest, const char *src, size_t n); char *mallocstrncpy(char *dest, const char *src, size_t n);
char *mallocstrcpy(char *dest, const char *src); char *mallocstrcpy(char *dest, const char *src);
char *mallocstrassn(char *dest, char *src); char *mallocstrassn(char *dest, char *src);
size_t get_page_start(size_t column);
size_t xplustabs(void); size_t xplustabs(void);
size_t actual_x(const char *s, size_t column); size_t actual_x(const char *s, size_t column);
size_t strnlenpt(const char *s, size_t maxlen); size_t strnlenpt(const char *s, size_t maxlen);
...@@ -670,7 +671,6 @@ void set_modified(void); ...@@ -670,7 +671,6 @@ void set_modified(void);
void statusbar(const char *msg, ...); void statusbar(const char *msg, ...);
void bottombars(const shortcut *s); void bottombars(const shortcut *s);
void onekey(const char *keystroke, const char *desc, size_t len); void onekey(const char *keystroke, const char *desc, size_t len);
size_t get_page_start(size_t column);
void reset_cursor(void); void reset_cursor(void);
void edit_draw(const filestruct *fileptr, const char *converted, int void edit_draw(const filestruct *fileptr, const char *converted, int
line, size_t start); line, size_t start);
......
...@@ -395,6 +395,20 @@ char *mallocstrassn(char *dest, char *src) ...@@ -395,6 +395,20 @@ char *mallocstrassn(char *dest, char *src)
return 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 /* Return the placewewant associated with current_x, i.e, the zero-based
* column position of the cursor. The value will be no smaller than * column position of the cursor. The value will be no smaller than
* current_x. */ * current_x. */
...@@ -403,9 +417,9 @@ size_t xplustabs(void) ...@@ -403,9 +417,9 @@ size_t xplustabs(void)
return strnlenpt(openfile->current->data, openfile->current_x); return strnlenpt(openfile->current->data, openfile->current_x);
} }
/* actual_x() gives the index in s of the character displayed at the /* Return the index in s of the character displayed at the given column,
* given column. That is, actual_x() is the largest value such that * i.e, the largest value such that strnlenpt(s, actual_x(s, column)) <=
* strnlenpt(s, actual_x(s, column)) <= column. */ * column. */
size_t actual_x(const char *s, size_t column) size_t actual_x(const char *s, size_t column)
{ {
size_t i = 0; size_t i = 0;
......
...@@ -2185,22 +2185,8 @@ void onekey(const char *keystroke, const char *desc, size_t len) ...@@ -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 /* Reset current_y, based on the position of current, and put the cursor
* returns the column number of the first character displayed in the * in the edit window at (current_y, current_x). */
* 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). */
void reset_cursor(void) void reset_cursor(void)
{ {
/* If we haven't opened any files yet, put the cursor in the top /* If we haven't opened any files yet, put the cursor in the top
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment