mirror of
https://github.com/profanity-im/profanity.git
synced 2024-12-04 14:46:46 -05:00
Temp fix for checking printable chars
Use result of wget_wch to check for special keys
This commit is contained in:
parent
268a2f553b
commit
e6d016e640
@ -51,7 +51,6 @@ static int rows, cols;
|
|||||||
|
|
||||||
static int _handle_edit(const wint_t ch, char *input, int *size);
|
static int _handle_edit(const wint_t ch, char *input, int *size);
|
||||||
static int _printable(const wint_t ch);
|
static int _printable(const wint_t ch);
|
||||||
static gboolean _special_key(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);
|
||||||
|
|
||||||
@ -115,7 +114,7 @@ inp_get_char(char *input, int *size)
|
|||||||
|
|
||||||
// echo off, and get some more input
|
// echo off, and get some more input
|
||||||
noecho();
|
noecho();
|
||||||
wget_wch(inp_win, &ch);
|
int result = wget_wch(inp_win, &ch);
|
||||||
|
|
||||||
gboolean in_command = FALSE;
|
gboolean in_command = FALSE;
|
||||||
if ((display_size > 0 && input[0] == '/') ||
|
if ((display_size > 0 && input[0] == '/') ||
|
||||||
@ -124,10 +123,10 @@ inp_get_char(char *input, int *size)
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (prefs_get_states()) {
|
if (prefs_get_states()) {
|
||||||
if (ch == ERR) {
|
if (result == ERR) {
|
||||||
prof_handle_idle();
|
prof_handle_idle();
|
||||||
}
|
}
|
||||||
if (prefs_get_outtype() && (ch != ERR) && !in_command
|
if (prefs_get_outtype() && (result != ERR) && !in_command
|
||||||
&& _printable(ch)) {
|
&& _printable(ch)) {
|
||||||
prof_handle_activity();
|
prof_handle_activity();
|
||||||
}
|
}
|
||||||
@ -135,7 +134,7 @@ inp_get_char(char *input, int *size)
|
|||||||
|
|
||||||
// if it wasn't an arrow key etc
|
// if it wasn't an arrow key etc
|
||||||
if (!_handle_edit(ch, input, size)) {
|
if (!_handle_edit(ch, input, size)) {
|
||||||
if (_printable(ch)) {
|
if (_printable(ch) && result != KEY_CODE_YES) {
|
||||||
inp_x = getcurx(inp_win);
|
inp_x = getcurx(inp_win);
|
||||||
|
|
||||||
// handle insert if not at end of input
|
// handle insert if not at end of input
|
||||||
@ -465,19 +464,11 @@ _go_to_end(int display_size)
|
|||||||
static int
|
static int
|
||||||
_printable(const wint_t ch)
|
_printable(const wint_t ch)
|
||||||
{
|
{
|
||||||
return (ch != ERR && ch != '\n' &&
|
char bytes[MB_CUR_MAX+1];
|
||||||
ch != KEY_PPAGE && ch != KEY_NPAGE && ch != KEY_MOUSE &&
|
size_t utf_len = wcrtomb(bytes, ch, NULL);
|
||||||
ch != KEY_F(1) && ch != KEY_F(2) && ch != KEY_F(3) &&
|
bytes[utf_len] = '\0';
|
||||||
ch != KEY_F(4) && ch != KEY_F(5) && ch != KEY_F(6) &&
|
|
||||||
ch != KEY_F(7) && ch != KEY_F(8) && ch != KEY_F(9) &&
|
gunichar unichar = g_utf8_get_char(bytes);
|
||||||
ch != KEY_F(10) && ch!= KEY_F(11) && ch != KEY_F(12) &&
|
return g_unichar_isprint(unichar) && (ch != KEY_MOUSE);
|
||||||
ch != KEY_IC && ch != KEY_EIC && ch != KEY_RESIZE &&
|
|
||||||
!_special_key(ch));
|
|
||||||
}
|
|
||||||
|
|
||||||
static gboolean
|
|
||||||
_special_key(const wint_t ch)
|
|
||||||
{
|
|
||||||
char *str = unctrl(ch);
|
|
||||||
return ((strlen(str) > 1) && g_str_has_prefix(str, "^"));
|
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user