is disabled when NANO_SMALL is defined. New functions
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)
- 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
get_page_start(). (DLR)
- nano.h:
- Readd MIN_EDITOR_COLS #define. (DLR)
-- winio.c:
- nanoget_repaint()
- - Move the code to determine the statusbar equivalent of
- get_page_start() into the new function
- get_statusbar_page_start(). (DLR)
GNU nano 1.3.9 - 2005.10.23
- General:
#endif
extern WINDOW *topwin, *edit, *bottomwin;
-extern char *answer;
+extern char *prompt, *answer;
#ifndef DISABLE_HELP
extern char *help_text;
#endif
void check_statusblank(void);
char *display_string(const char *buf, size_t start_col, size_t len, bool
dollars);
-void nanoget_repaint(const char *buf, const char *inputbuf, size_t x);
-int nanogetstr(bool allow_tabs, const char *buf, const char *curranswer,
+void nanoget_repaint(const char *inputbuf, size_t x);
+int nanogetstr(bool allow_tabs, const char *curranswer,
#ifndef NANO_SMALL
filestruct **history_list,
#endif
#ifndef DISABLE_MOUSE
bool do_statusbar_mouse(void)
{
- /* FIXME: If we clicked on a location in the statusbar, the cursor
- * should move to the location we clicked on. This functionality
- * should be in this function. */
int mouse_x, mouse_y;
- return get_mouseinput(&mouse_x, &mouse_y, TRUE);
+ bool retval = get_mouseinput(&mouse_x, &mouse_y, TRUE);
+
+ if (!retval) {
+ /* We can click in the statusbar window text to move the
+ * cursor. */
+ if (wenclose(bottomwin, mouse_y, mouse_x)) {
+ size_t start_col = strlenpt(prompt) + 1;
+
+ /* Move to where the click occurred. */
+ if (mouse_x > start_col) {
+ 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);
+ nanoget_repaint(answer, statusbar_x);
+ }
+ }
+ }
+
+ return retval;
}
#endif
/* Repaint the statusbar when getting a character in nanogetstr(). Note
* that we must turn on A_REVERSE here, since do_help() turns it off! */
-void nanoget_repaint(const char *buf, const char *inputbuf, size_t x)
+void nanoget_repaint(const char *inputbuf, size_t x)
{
size_t start_col, xpt, page_start;
char *expanded;
assert(x <= strlen(inputbuf));
- start_col = strlenpt(buf) + 1;
+ start_col = strlenpt(prompt) + 1;
xpt = strnlenpt(inputbuf, x);
page_start = get_statusbar_page_start(start_col, start_col + xpt);
blank_statusbar();
- mvwaddnstr(bottomwin, 0, 0, buf, actual_x(buf, COLS - 2));
+ mvwaddnstr(bottomwin, 0, 0, prompt, actual_x(prompt, COLS - 2));
waddch(bottomwin, ':');
waddch(bottomwin, (page_start == 0) ? ' ' : '$');
/* Get the input from the keyboard; this should only be called from
* statusq(). */
-int nanogetstr(bool allow_tabs, const char *buf, const char *curranswer,
+int nanogetstr(bool allow_tabs, const char *curranswer,
#ifndef NANO_SMALL
filestruct **history_list,
#endif
currshortcut = s;
- nanoget_repaint(buf, answer, statusbar_x);
+ nanoget_repaint(answer, statusbar_x);
/* Refresh the edit window and the statusbar before getting
* input. */
last_kbinput = kbinput;
#endif
- nanoget_repaint(buf, answer, statusbar_x);
+ nanoget_repaint(answer, statusbar_x);
wnoutrefresh(bottomwin);
}
const char *msg, ...)
{
va_list ap;
- char *foo = charalloc(((COLS - 4) * mb_cur_max()) + 1);
int retval;
#ifndef DISABLE_TABCOMP
bool list = FALSE;
#endif
+ prompt = charealloc(prompt, ((COLS - 4) * mb_cur_max()) + 1);
+
bottombars(s);
va_start(ap, msg);
- vsnprintf(foo, (COLS - 4) * mb_cur_max(), msg, ap);
+ vsnprintf(prompt, (COLS - 4) * mb_cur_max(), msg, ap);
va_end(ap);
- null_at(&foo, actual_x(foo, COLS - 4));
+ null_at(&prompt, actual_x(prompt, COLS - 4));
- retval = nanogetstr(allow_tabs, foo, curranswer,
+ retval = nanogetstr(allow_tabs, curranswer,
#ifndef NANO_SMALL
history_list,
#endif
, &list
#endif
);
- free(foo);
+
resetstatuspos = FALSE;
switch (retval) {