mirror of
https://github.com/profanity-im/profanity.git
synced 2025-07-26 12:14:28 -04:00
Finished ctrl-left, started ctrl-right
This commit is contained in:
parent
0214acb662
commit
78d11d362d
@ -131,23 +131,7 @@ inp_get_char(char *input, int *size)
|
|||||||
prof_handle_activity();
|
prof_handle_activity();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
/*
|
|
||||||
if (ch != 0) {
|
|
||||||
char *res = "?";
|
|
||||||
if (result == ERR) {
|
|
||||||
res = "ERR";
|
|
||||||
}
|
|
||||||
if (result == OK) {
|
|
||||||
res = "OK";
|
|
||||||
}
|
|
||||||
if (result == KEY_CODE_YES) {
|
|
||||||
res = "KEY_CODE_YES";
|
|
||||||
}
|
|
||||||
|
|
||||||
cons_show("KEY CODE: %d, RESULT = %s", ch, res);
|
|
||||||
win_current_page_off();
|
|
||||||
}
|
|
||||||
*/
|
|
||||||
// if it wasn't an arrow key etc
|
// if it wasn't an arrow key etc
|
||||||
if (!_handle_edit(result, ch, input, size)) {
|
if (!_handle_edit(result, ch, input, size)) {
|
||||||
if (_printable(ch) && result != KEY_CODE_YES) {
|
if (_printable(ch) && result != KEY_CODE_YES) {
|
||||||
@ -282,35 +266,41 @@ _handle_edit(int result, const wint_t ch, char *input, int *size)
|
|||||||
if ((result == KEY_CODE_YES) && (ch == 540) && (inp_x > 0)) {
|
if ((result == KEY_CODE_YES) && (ch == 540) && (inp_x > 0)) {
|
||||||
input[*size] = '\0';
|
input[*size] = '\0';
|
||||||
gchar *curr_ch = g_utf8_offset_to_pointer(input, inp_x);
|
gchar *curr_ch = g_utf8_offset_to_pointer(input, inp_x);
|
||||||
gchar *prev_ch = g_utf8_find_prev_char(input, curr_ch);
|
curr_ch = g_utf8_find_prev_char(input, curr_ch);
|
||||||
|
gchar *prev_ch;
|
||||||
|
gunichar curr_uni;
|
||||||
|
gunichar prev_uni;
|
||||||
|
|
||||||
// no more chars to left, set to beginning
|
while (curr_ch != NULL) {
|
||||||
if (prev_ch == NULL) {
|
curr_uni = g_utf8_get_char(curr_ch);
|
||||||
inp_x = 0;
|
|
||||||
wmove(inp_win, 0, inp_x);
|
|
||||||
|
|
||||||
// otherwise, go back to start of previous word
|
if (g_unichar_isspace(curr_uni)) {
|
||||||
} else {
|
curr_ch = g_utf8_find_prev_char(input, curr_ch);
|
||||||
gunichar prev_uni = g_utf8_get_char(prev_ch);
|
} else {
|
||||||
while (!g_unichar_isspace(prev_uni)) {
|
prev_ch = g_utf8_find_prev_char(input, curr_ch);
|
||||||
prev_ch = g_utf8_find_prev_char(input, prev_ch);
|
if (prev_ch == NULL) {
|
||||||
if (prev_ch != NULL) {
|
curr_ch = NULL;
|
||||||
prev_uni = g_utf8_get_char(prev_ch);
|
|
||||||
} else {
|
|
||||||
break;
|
break;
|
||||||
|
} else {
|
||||||
|
prev_uni = g_utf8_get_char(prev_ch);
|
||||||
|
if (g_unichar_isspace(prev_uni)) {
|
||||||
|
break;
|
||||||
|
} else {
|
||||||
|
curr_ch = prev_ch;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (prev_ch == NULL) {
|
|
||||||
inp_x = 0;
|
|
||||||
wmove(inp_win, 0, inp_x);
|
|
||||||
} else {
|
|
||||||
glong offset = g_utf8_pointer_to_offset(input, prev_ch);
|
|
||||||
inp_x = offset;
|
|
||||||
wmove(inp_win, 0, inp_x);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (curr_ch == NULL) {
|
||||||
|
inp_x = 0;
|
||||||
|
wmove(inp_win, 0, inp_x);
|
||||||
|
} else {
|
||||||
|
glong offset = g_utf8_pointer_to_offset(input, curr_ch);
|
||||||
|
inp_x = offset;
|
||||||
|
wmove(inp_win, 0, inp_x);
|
||||||
|
}
|
||||||
|
|
||||||
// if gone off screen to left, jump left (half a screen worth)
|
// if gone off screen to left, jump left (half a screen worth)
|
||||||
if (inp_x <= pad_start) {
|
if (inp_x <= pad_start) {
|
||||||
pad_start = pad_start - (cols / 2);
|
pad_start = pad_start - (cols / 2);
|
||||||
@ -321,10 +311,19 @@ _handle_edit(int result, const wint_t ch, char *input, int *size)
|
|||||||
_inp_win_refresh();
|
_inp_win_refresh();
|
||||||
}
|
}
|
||||||
return 1;
|
return 1;
|
||||||
} else if ((result == KEY_CODE_YES) && (ch == 555)) { // CTRL-RIGHT
|
|
||||||
cons_show("CTRL-RIGHT");
|
// CTRL-RIGHT
|
||||||
win_current_page_off();
|
} else if ((result == KEY_CODE_YES) && (ch == 555) && (inp_x < display_size)) {
|
||||||
|
wmove(inp_win, 0, inp_x+1);
|
||||||
|
|
||||||
|
// current position off screen to right
|
||||||
|
if ((inp_x + 1 - pad_start) >= cols) {
|
||||||
|
pad_start++;
|
||||||
|
_inp_win_refresh();
|
||||||
|
}
|
||||||
return 1;
|
return 1;
|
||||||
|
|
||||||
|
// other editing keys
|
||||||
} else {
|
} else {
|
||||||
switch(ch) {
|
switch(ch) {
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user