mirror of
https://github.com/profanity-im/profanity.git
synced 2025-01-03 14:57:42 -05:00
Added ctrl-w support (with debug)
This commit is contained in:
parent
71ed9ac2d1
commit
fe021a226c
@ -72,6 +72,7 @@ static void _handle_backspace(int display_size, int inp_x, int *size, char *inpu
|
|||||||
static int _printable(const wint_t ch);
|
static int _printable(const wint_t ch);
|
||||||
static void _clear_input(void);
|
static void _clear_input(void);
|
||||||
static void _go_to_end(int display_size);
|
static void _go_to_end(int display_size);
|
||||||
|
static void _delete_previous_word(char *input, int *size);
|
||||||
|
|
||||||
void
|
void
|
||||||
create_input_window(void)
|
create_input_window(void)
|
||||||
@ -134,6 +135,14 @@ inp_get_char(char *input, int *size, int *result)
|
|||||||
noecho();
|
noecho();
|
||||||
*result = wget_wch(inp_win, &ch);
|
*result = wget_wch(inp_win, &ch);
|
||||||
|
|
||||||
|
if (*result != ERR) {
|
||||||
|
if (*result == KEY_CODE_YES) {
|
||||||
|
cons_debug("KEY %d, KEY_CODE_YES", ch);
|
||||||
|
} else {
|
||||||
|
cons_debug("KEY %d", ch);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
gboolean in_command = FALSE;
|
gboolean in_command = FALSE;
|
||||||
if ((display_size > 0 && input[0] == '/') ||
|
if ((display_size > 0 && input[0] == '/') ||
|
||||||
(display_size == 0 && ch == '/')) {
|
(display_size == 0 && ch == '/')) {
|
||||||
@ -534,6 +543,10 @@ _handle_edit(int result, const wint_t ch, char *input, int *size)
|
|||||||
}
|
}
|
||||||
return 1;
|
return 1;
|
||||||
|
|
||||||
|
case 23: // ctrl-w
|
||||||
|
_delete_previous_word(input, size);
|
||||||
|
return 1;
|
||||||
|
break;
|
||||||
default:
|
default:
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
@ -597,8 +610,7 @@ _handle_backspace(int display_size, int inp_x, int *size, char *input)
|
|||||||
static int
|
static int
|
||||||
_handle_alt_key(char *input, int *size, int key)
|
_handle_alt_key(char *input, int *size, int key)
|
||||||
{
|
{
|
||||||
int end_del = getcurx(inp_win);
|
cons_debug("ALT %d", key);
|
||||||
int start_del = end_del;
|
|
||||||
|
|
||||||
switch (key)
|
switch (key)
|
||||||
{
|
{
|
||||||
@ -640,6 +652,20 @@ _handle_alt_key(char *input, int *size, int key)
|
|||||||
break;
|
break;
|
||||||
case 263:
|
case 263:
|
||||||
case 127:
|
case 127:
|
||||||
|
_delete_previous_word(input, size);
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
static void
|
||||||
|
_delete_previous_word(char *input, int *size)
|
||||||
|
{
|
||||||
|
int end_del = getcurx(inp_win);
|
||||||
|
int start_del = end_del;
|
||||||
|
|
||||||
input[*size] = '\0';
|
input[*size] = '\0';
|
||||||
gchar *curr_ch = g_utf8_offset_to_pointer(input, end_del);
|
gchar *curr_ch = g_utf8_offset_to_pointer(input, end_del);
|
||||||
curr_ch = g_utf8_find_prev_char(input, curr_ch);
|
curr_ch = g_utf8_find_prev_char(input, curr_ch);
|
||||||
@ -702,13 +728,6 @@ _handle_alt_key(char *input, int *size, int key)
|
|||||||
|
|
||||||
_inp_win_update_virtual();
|
_inp_win_update_virtual();
|
||||||
}
|
}
|
||||||
|
|
||||||
return 1;
|
|
||||||
break;
|
|
||||||
default:
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
return 1;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
|
Loading…
Reference in New Issue
Block a user