diff --git a/ChangeLog b/ChangeLog index d03ad29ca949cd2898f68cfcad5eb4013e9aa88c..804329033d996098fa175391a8e30d174586dec2 100644 --- a/ChangeLog +++ b/ChangeLog @@ -6,9 +6,9 @@ CVS code - do_scroll_up() and do_scroll_down(); changes to shortcut_init(). (DLR, suggested by Mike Frysinger) - Properly handle mouse clicks on the statusbar prompt text. - New function get_statusbar_page_start(); changes to - do_statusbar_mouse(), nanoget_repaint(), nanogetstr(), and - statusq(). (DLR) + New functions statusbar_xplustabs() and + get_statusbar_page_start(); changes to do_statusbar_mouse(), + nanoget_repaint(), nanogetstr(), and statusq(). (DLR) - Since the statusbar prompt code needs at least 4 columns in order to work properly, make that the minimum number of columns nano requires to run, and remove assertions and code diff --git a/src/proto.h b/src/proto.h index 4265426464fd2c13ede22e24cdd08acadea5c76b..0a73aec4eb61e27d53d33853251d2eb2464cd9fe 100644 --- a/src/proto.h +++ b/src/proto.h @@ -632,6 +632,7 @@ bool do_statusbar_next_word(bool allow_punct); bool do_statusbar_prev_word(bool allow_punct); #endif void do_statusbar_verbatim_input(bool *got_enter); +size_t statusbar_xplustabs(void); size_t get_statusbar_page_start(size_t start_col, size_t column); size_t xplustabs(void); size_t actual_x(const char *str, size_t xplus); diff --git a/src/winio.c b/src/winio.c index 76d86eb972045ac613c4ba61917987182d308b47..e59570f78a7a9e2c8caf895b7411f04dd55e7bc0 100644 --- a/src/winio.c +++ b/src/winio.c @@ -1876,11 +1876,10 @@ bool do_statusbar_mouse(void) /* Move to where the click occurred. */ if (mouse_x > start_col && mouse_y == 0) { - size_t xpt = strnlenpt(answer, statusbar_x); - statusbar_x = actual_x(answer, get_statusbar_page_start(start_col, start_col + - xpt) + mouse_x - start_col - 1); + statusbar_xplustabs()) + mouse_x - start_col - + 1); nanoget_repaint(answer, statusbar_x); } } @@ -2199,6 +2198,14 @@ void do_statusbar_verbatim_input(bool *got_enter) free(output); } +/* Return the placewewant associated with statusbar_x, i.e, the + * zero-based column position of the cursor. The value will be no + * smaller than statusbar_x. */ +size_t statusbar_xplustabs(void) +{ + return strnlenpt(answer, statusbar_x); +} + /* nano scrolls horizontally within a line in chunks. This function * returns the column number of the first character displayed in the * statusbar prompt when the cursor is at the given column with the