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

at long last, properly handle mouse clicks on the statusbar prompt text

git-svn-id: svn://svn.savannah.gnu.org/nano/trunk/nano@3053 35c25a1d-7b9e-4130-9fde-d3aeb78583b8
No related merge requests found
Showing with 44 additions and 24 deletions
+44 -24
...@@ -5,6 +5,10 @@ CVS code - ...@@ -5,6 +5,10 @@ CVS code -
is disabled when NANO_SMALL is defined. New functions is disabled when NANO_SMALL is defined. New functions
do_scroll_up() and do_scroll_down(); changes to do_scroll_up() and do_scroll_down(); changes to
shortcut_init(). (DLR, suggested by Mike Frysinger) 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 - Since the statusbar prompt code needs at least 4 columns in
order to work properly, make that the minimum number of order to work properly, make that the minimum number of
columns nano requires to run, and remove assertions and code columns nano requires to run, and remove assertions and code
...@@ -13,11 +17,6 @@ CVS code - ...@@ -13,11 +17,6 @@ CVS code -
get_page_start(). (DLR) get_page_start(). (DLR)
- nano.h: - nano.h:
- Readd MIN_EDITOR_COLS #define. (DLR) - 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 GNU nano 1.3.9 - 2005.10.23
- General: - General:
......
...@@ -85,7 +85,10 @@ size_t quotelen; /* strlen(quotestr) */ ...@@ -85,7 +85,10 @@ size_t quotelen; /* strlen(quotestr) */
char *backup_dir = NULL; /* Backup directory. */ char *backup_dir = NULL; /* Backup directory. */
#endif #endif
char *answer = NULL; /* Answer str to many questions */ char *prompt = NULL; /* Answer string for statusbar
* questions. */
char *answer = NULL; /* Answer string for statusbar
* questions. */
ssize_t tabsize = -1; /* Our internal tabsize variable. The ssize_t tabsize = -1; /* Our internal tabsize variable. The
default value is set in main(). */ default value is set in main(). */
......
...@@ -58,7 +58,7 @@ extern char *backup_dir; ...@@ -58,7 +58,7 @@ extern char *backup_dir;
#endif #endif
extern WINDOW *topwin, *edit, *bottomwin; extern WINDOW *topwin, *edit, *bottomwin;
extern char *answer; extern char *prompt, *answer;
#ifndef DISABLE_HELP #ifndef DISABLE_HELP
extern char *help_text; extern char *help_text;
#endif #endif
...@@ -646,8 +646,8 @@ void blank_bottombars(void); ...@@ -646,8 +646,8 @@ void blank_bottombars(void);
void check_statusblank(void); void check_statusblank(void);
char *display_string(const char *buf, size_t start_col, size_t len, bool char *display_string(const char *buf, size_t start_col, size_t len, bool
dollars); dollars);
void nanoget_repaint(const char *buf, const char *inputbuf, size_t x); void nanoget_repaint(const char *inputbuf, size_t x);
int nanogetstr(bool allow_tabs, const char *buf, const char *curranswer, int nanogetstr(bool allow_tabs, const char *curranswer,
#ifndef NANO_SMALL #ifndef NANO_SMALL
filestruct **history_list, filestruct **history_list,
#endif #endif
......
...@@ -1857,11 +1857,28 @@ int do_statusbar_input(bool *meta_key, bool *func_key, bool *s_or_t, ...@@ -1857,11 +1857,28 @@ int do_statusbar_input(bool *meta_key, bool *func_key, bool *s_or_t,
#ifndef DISABLE_MOUSE #ifndef DISABLE_MOUSE
bool do_statusbar_mouse(void) 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; 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 #endif
...@@ -2469,14 +2486,14 @@ char *display_string(const char *buf, size_t start_col, size_t len, bool ...@@ -2469,14 +2486,14 @@ char *display_string(const char *buf, size_t start_col, size_t len, bool
/* Repaint the statusbar when getting a character in nanogetstr(). Note /* Repaint the statusbar when getting a character in nanogetstr(). Note
* that we must turn on A_REVERSE here, since do_help() turns it off! */ * 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; size_t start_col, xpt, page_start;
char *expanded; char *expanded;
assert(x <= strlen(inputbuf)); assert(x <= strlen(inputbuf));
start_col = strlenpt(buf) + 1; start_col = strlenpt(prompt) + 1;
xpt = strnlenpt(inputbuf, x); xpt = strnlenpt(inputbuf, x);
page_start = get_statusbar_page_start(start_col, start_col + xpt); page_start = get_statusbar_page_start(start_col, start_col + xpt);
...@@ -2484,7 +2501,7 @@ void nanoget_repaint(const char *buf, const char *inputbuf, size_t x) ...@@ -2484,7 +2501,7 @@ void nanoget_repaint(const char *buf, const char *inputbuf, size_t x)
blank_statusbar(); 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, ':');
waddch(bottomwin, (page_start == 0) ? ' ' : '$'); waddch(bottomwin, (page_start == 0) ? ' ' : '$');
...@@ -2500,7 +2517,7 @@ void nanoget_repaint(const char *buf, const char *inputbuf, size_t x) ...@@ -2500,7 +2517,7 @@ void nanoget_repaint(const char *buf, const char *inputbuf, size_t x)
/* Get the input from the keyboard; this should only be called from /* Get the input from the keyboard; this should only be called from
* statusq(). */ * statusq(). */
int nanogetstr(bool allow_tabs, const char *buf, const char *curranswer, int nanogetstr(bool allow_tabs, const char *curranswer,
#ifndef NANO_SMALL #ifndef NANO_SMALL
filestruct **history_list, filestruct **history_list,
#endif #endif
...@@ -2546,7 +2563,7 @@ int nanogetstr(bool allow_tabs, const char *buf, const char *curranswer, ...@@ -2546,7 +2563,7 @@ int nanogetstr(bool allow_tabs, const char *buf, const char *curranswer,
currshortcut = s; currshortcut = s;
nanoget_repaint(buf, answer, statusbar_x); nanoget_repaint(answer, statusbar_x);
/* Refresh the edit window and the statusbar before getting /* Refresh the edit window and the statusbar before getting
* input. */ * input. */
...@@ -2655,7 +2672,7 @@ int nanogetstr(bool allow_tabs, const char *buf, const char *curranswer, ...@@ -2655,7 +2672,7 @@ int nanogetstr(bool allow_tabs, const char *buf, const char *curranswer,
last_kbinput = kbinput; last_kbinput = kbinput;
#endif #endif
nanoget_repaint(buf, answer, statusbar_x); nanoget_repaint(answer, statusbar_x);
wnoutrefresh(bottomwin); wnoutrefresh(bottomwin);
} }
...@@ -2693,20 +2710,21 @@ int statusq(bool allow_tabs, const shortcut *s, const char *curranswer, ...@@ -2693,20 +2710,21 @@ int statusq(bool allow_tabs, const shortcut *s, const char *curranswer,
const char *msg, ...) const char *msg, ...)
{ {
va_list ap; va_list ap;
char *foo = charalloc(((COLS - 4) * mb_cur_max()) + 1);
int retval; int retval;
#ifndef DISABLE_TABCOMP #ifndef DISABLE_TABCOMP
bool list = FALSE; bool list = FALSE;
#endif #endif
prompt = charealloc(prompt, ((COLS - 4) * mb_cur_max()) + 1);
bottombars(s); bottombars(s);
va_start(ap, msg); 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); 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 #ifndef NANO_SMALL
history_list, history_list,
#endif #endif
...@@ -2715,7 +2733,7 @@ int statusq(bool allow_tabs, const shortcut *s, const char *curranswer, ...@@ -2715,7 +2733,7 @@ int statusq(bool allow_tabs, const shortcut *s, const char *curranswer,
, &list , &list
#endif #endif
); );
free(foo);
resetstatuspos = FALSE; resetstatuspos = FALSE;
switch (retval) { switch (retval) {
......
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