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(),
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);
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);
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. */
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;
}
}
-/* 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