use the cursor-moved event to fix visual mode
This commit is contained in:
parent
124979d812
commit
7b1760d1ad
|
@ -76,8 +76,8 @@ void window_title_cb(VteTerminal *vte, GtkWindow *window) {
|
||||||
gtk_window_set_title(window, t ? t : "termite");
|
gtk_window_set_title(window, t ? t : "termite");
|
||||||
}
|
}
|
||||||
|
|
||||||
static void update_selection(VteTerminal *vte, select_info *select) {
|
static void cursor_moved_cb(VteTerminal *vte, select_info *select) {
|
||||||
if (select->mode == SELECT_ON) {
|
if (select->mode != SELECT_VISUAL) {
|
||||||
return; // not in visual mode
|
return; // not in visual mode
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -120,22 +120,18 @@ gboolean key_press_cb(VteTerminal *vte, GdkEventKey *event, search_panel_info *i
|
||||||
case GDK_KEY_Left:
|
case GDK_KEY_Left:
|
||||||
case GDK_KEY_h:
|
case GDK_KEY_h:
|
||||||
vte_terminal_feed(vte, CSI "1D", strlen(CSI "1D"));
|
vte_terminal_feed(vte, CSI "1D", strlen(CSI "1D"));
|
||||||
update_selection(vte, &info->select);
|
|
||||||
break;
|
break;
|
||||||
case GDK_KEY_Down:
|
case GDK_KEY_Down:
|
||||||
case GDK_KEY_j:
|
case GDK_KEY_j:
|
||||||
vte_terminal_feed(vte, CSI "1B", strlen(CSI "1B"));
|
vte_terminal_feed(vte, CSI "1B", strlen(CSI "1B"));
|
||||||
update_selection(vte, &info->select);
|
|
||||||
break;
|
break;
|
||||||
case GDK_KEY_Up:
|
case GDK_KEY_Up:
|
||||||
case GDK_KEY_k:
|
case GDK_KEY_k:
|
||||||
vte_terminal_feed(vte, CSI "1A", strlen(CSI "1A"));
|
vte_terminal_feed(vte, CSI "1A", strlen(CSI "1A"));
|
||||||
update_selection(vte, &info->select);
|
|
||||||
break;
|
break;
|
||||||
case GDK_KEY_Right:
|
case GDK_KEY_Right:
|
||||||
case GDK_KEY_l:
|
case GDK_KEY_l:
|
||||||
vte_terminal_feed(vte, CSI "1C", strlen(CSI "1C"));
|
vte_terminal_feed(vte, CSI "1C", strlen(CSI "1C"));
|
||||||
update_selection(vte, &info->select);
|
|
||||||
break;
|
break;
|
||||||
case GDK_KEY_v:
|
case GDK_KEY_v:
|
||||||
toggle_visual(vte, &info->select);
|
toggle_visual(vte, &info->select);
|
||||||
|
@ -653,6 +649,7 @@ int main(int argc, char **argv) {
|
||||||
g_signal_connect(vte, "key-press-event", G_CALLBACK(key_press_cb), &info);
|
g_signal_connect(vte, "key-press-event", G_CALLBACK(key_press_cb), &info);
|
||||||
g_signal_connect(entry, "key-press-event", G_CALLBACK(entry_key_press_cb), &info);
|
g_signal_connect(entry, "key-press-event", G_CALLBACK(entry_key_press_cb), &info);
|
||||||
g_signal_connect(overlay, "get-child-position", G_CALLBACK(position_overlay_cb), NULL);
|
g_signal_connect(overlay, "get-child-position", G_CALLBACK(position_overlay_cb), NULL);
|
||||||
|
g_signal_connect(vte, "cursor-moved", G_CALLBACK(cursor_moved_cb), &info.select);
|
||||||
|
|
||||||
if (clickable_url) {
|
if (clickable_url) {
|
||||||
int tag = vte_terminal_match_add_gregex(VTE_TERMINAL(vte),
|
int tag = vte_terminal_match_add_gregex(VTE_TERMINAL(vte),
|
||||||
|
|
Loading…
Reference in New Issue