mirror of git://git.sv.gnu.org/nano.git
add more miscellaneous mouse support-related fixes, and move
do_statusbar_output() after do_statusbar_mouse(), to match do_output()'s being after do_mouse() in nano.c git-svn-id: svn://svn.savannah.gnu.org/nano/trunk/nano@2929 35c25a1d-7b9e-4130-9fde-d3aeb78583b8
This commit is contained in:
parent
3d5e94560d
commit
22ae034f2d
|
@ -224,6 +224,8 @@ CVS code -
|
|||
do_statusbar_next_word()
|
||||
- Rework to be more like do_statusbar_prev_word(), to avoid a
|
||||
potential problem if we start at the end of a line. (DLR)
|
||||
do_statusbar_input()
|
||||
- Call do_statusbar_mouse() instead of do_mouse(). (DLR)
|
||||
do_statusbar_output()
|
||||
- When adding a character, just add its length in bytes to
|
||||
statusbar_x instead of calling do_statusbar_right(). (DLR)
|
||||
|
|
|
@ -1718,9 +1718,7 @@ int do_input(bool *meta_key, bool *func_key, bool *s_or_t, bool
|
|||
bool do_mouse(void)
|
||||
{
|
||||
int mouse_x, mouse_y;
|
||||
bool retval;
|
||||
|
||||
retval = get_mouseinput(&mouse_x, &mouse_y, TRUE);
|
||||
bool retval = get_mouseinput(&mouse_x, &mouse_y, TRUE);
|
||||
|
||||
if (!retval) {
|
||||
/* We can click in the edit window to move the cursor. */
|
||||
|
@ -1745,9 +1743,9 @@ bool do_mouse(void)
|
|||
openfile->current->prev != NULL; openfile->current_y--)
|
||||
openfile->current = openfile->current->prev;
|
||||
|
||||
openfile->current_x = actual_x(openfile->current->data,
|
||||
get_page_start(xplustabs()) + mouse_x);
|
||||
openfile->placewewant = xplustabs();
|
||||
openfile->current_x = actual_x(openfile->current->data,
|
||||
get_page_start(openfile->placewewant + mouse_x));
|
||||
|
||||
#ifndef NANO_SMALL
|
||||
/* Clicking where the cursor is toggles the mark, as does
|
||||
|
|
|
@ -618,6 +618,8 @@ int do_statusbar_input(bool *meta_key, bool *func_key, bool *s_or_t,
|
|||
#ifndef DISABLE_MOUSE
|
||||
bool do_statusbar_mouse(void);
|
||||
#endif
|
||||
void do_statusbar_output(char *output, size_t output_len, bool
|
||||
*got_enter, bool allow_cntrls);
|
||||
void do_statusbar_home(void);
|
||||
void do_statusbar_end(void);
|
||||
void do_statusbar_right(void);
|
||||
|
@ -630,8 +632,6 @@ 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);
|
||||
void do_statusbar_output(char *output, size_t output_len, bool
|
||||
*got_enter, bool allow_cntrls);
|
||||
size_t xplustabs(void);
|
||||
size_t actual_x(const char *str, size_t xplus);
|
||||
size_t strnlenpt(const char *buf, size_t size);
|
||||
|
|
126
src/winio.c
126
src/winio.c
|
@ -1648,7 +1648,7 @@ int do_statusbar_input(bool *meta_key, bool *func_key, bool *s_or_t,
|
|||
/* If we got a mouse click and it was on a shortcut, read in the
|
||||
* shortcut character. */
|
||||
if (allow_funcs && *func_key == TRUE && input == KEY_MOUSE) {
|
||||
if (do_mouse())
|
||||
if (do_statusbar_mouse())
|
||||
input = get_kbinput(bottomwin, meta_key, func_key);
|
||||
else
|
||||
input = ERR;
|
||||
|
@ -1828,6 +1828,68 @@ bool do_statusbar_mouse(void)
|
|||
}
|
||||
#endif
|
||||
|
||||
/* The user typed ouuput_len multibyte characters. Add them to the
|
||||
* statusbar prompt, setting got_enter to TRUE if we get a newline, and
|
||||
* filtering out all control characters if allow_cntrls is TRUE. */
|
||||
void do_statusbar_output(char *output, size_t output_len, bool
|
||||
*got_enter, bool allow_cntrls)
|
||||
{
|
||||
size_t answer_len, i = 0;
|
||||
char *char_buf = charalloc(mb_cur_max());
|
||||
int char_buf_len;
|
||||
|
||||
assert(answer != NULL);
|
||||
|
||||
answer_len = strlen(answer);
|
||||
*got_enter = FALSE;
|
||||
|
||||
while (i < output_len) {
|
||||
/* If allow_cntrls is FALSE, filter out nulls and newlines,
|
||||
* since they're control characters. */
|
||||
if (allow_cntrls) {
|
||||
/* Null to newline, if needed. */
|
||||
if (output[i] == '\0')
|
||||
output[i] = '\n';
|
||||
/* Newline to Enter, if needed. */
|
||||
else if (output[i] == '\n') {
|
||||
/* Set got_enter to TRUE to indicate that we got the
|
||||
* Enter key, put back the rest of the characters in
|
||||
* output so that they can be parsed and output again,
|
||||
* and get out. */
|
||||
*got_enter = TRUE;
|
||||
unparse_kbinput(output + i, output_len - i);
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
/* Interpret the next multibyte character. If it's an invalid
|
||||
* multibyte character, interpret it as though it's a byte
|
||||
* character. */
|
||||
char_buf_len = parse_mbchar(output + i, char_buf, NULL, NULL);
|
||||
|
||||
i += char_buf_len;
|
||||
|
||||
/* If allow_cntrls is FALSE, filter out a control character. */
|
||||
if (!allow_cntrls && is_cntrl_mbchar(output + i - char_buf_len))
|
||||
continue;
|
||||
|
||||
/* More dangerousness fun =) */
|
||||
answer = charealloc(answer, answer_len + (char_buf_len * 2));
|
||||
|
||||
assert(statusbar_x <= answer_len);
|
||||
|
||||
charmove(&answer[statusbar_x + char_buf_len],
|
||||
&answer[statusbar_x], answer_len - statusbar_x +
|
||||
char_buf_len);
|
||||
strncpy(&answer[statusbar_x], char_buf, char_buf_len);
|
||||
answer_len += char_buf_len;
|
||||
|
||||
statusbar_x += char_buf_len;
|
||||
}
|
||||
|
||||
free(char_buf);
|
||||
}
|
||||
|
||||
void do_statusbar_home(void)
|
||||
{
|
||||
#ifndef NANO_SMALL
|
||||
|
@ -2081,68 +2143,6 @@ void do_statusbar_verbatim_input(bool *got_enter)
|
|||
free(output);
|
||||
}
|
||||
|
||||
/* The user typed ouuput_len multibyte characters. Add them to the
|
||||
* statusbar prompt, setting got_enter to TRUE if we get a newline, and
|
||||
* filtering out all control characters if allow_cntrls is TRUE. */
|
||||
void do_statusbar_output(char *output, size_t output_len, bool
|
||||
*got_enter, bool allow_cntrls)
|
||||
{
|
||||
size_t answer_len, i = 0;
|
||||
char *char_buf = charalloc(mb_cur_max());
|
||||
int char_buf_len;
|
||||
|
||||
assert(answer != NULL);
|
||||
|
||||
answer_len = strlen(answer);
|
||||
*got_enter = FALSE;
|
||||
|
||||
while (i < output_len) {
|
||||
/* If allow_cntrls is FALSE, filter out nulls and newlines,
|
||||
* since they're control characters. */
|
||||
if (allow_cntrls) {
|
||||
/* Null to newline, if needed. */
|
||||
if (output[i] == '\0')
|
||||
output[i] = '\n';
|
||||
/* Newline to Enter, if needed. */
|
||||
else if (output[i] == '\n') {
|
||||
/* Set got_enter to TRUE to indicate that we got the
|
||||
* Enter key, put back the rest of the characters in
|
||||
* output so that they can be parsed and output again,
|
||||
* and get out. */
|
||||
*got_enter = TRUE;
|
||||
unparse_kbinput(output + i, output_len - i);
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
/* Interpret the next multibyte character. If it's an invalid
|
||||
* multibyte character, interpret it as though it's a byte
|
||||
* character. */
|
||||
char_buf_len = parse_mbchar(output + i, char_buf, NULL, NULL);
|
||||
|
||||
i += char_buf_len;
|
||||
|
||||
/* If allow_cntrls is FALSE, filter out a control character. */
|
||||
if (!allow_cntrls && is_cntrl_mbchar(output + i - char_buf_len))
|
||||
continue;
|
||||
|
||||
/* More dangerousness fun =) */
|
||||
answer = charealloc(answer, answer_len + (char_buf_len * 2));
|
||||
|
||||
assert(statusbar_x <= answer_len);
|
||||
|
||||
charmove(&answer[statusbar_x + char_buf_len],
|
||||
&answer[statusbar_x], answer_len - statusbar_x +
|
||||
char_buf_len);
|
||||
strncpy(&answer[statusbar_x], char_buf, char_buf_len);
|
||||
answer_len += char_buf_len;
|
||||
|
||||
statusbar_x += char_buf_len;
|
||||
}
|
||||
|
||||
free(char_buf);
|
||||
}
|
||||
|
||||
/* 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. */
|
||||
|
|
Loading…
Reference in New Issue