diff options
| -rw-r--r-- | src/cmdline.c | 52 | ||||
| -rw-r--r-- | src/cmdline.h | 2 | ||||
| -rw-r--r-- | src/interface-curses/interface.c | 1 | ||||
| -rw-r--r-- | src/interface-gtk/interface.c | 1 |
4 files changed, 33 insertions, 23 deletions
diff --git a/src/cmdline.c b/src/cmdline.c index fc2a531..e1a4628 100644 --- a/src/cmdline.c +++ b/src/cmdline.c @@ -104,29 +104,6 @@ teco_cmdline_init(void) teco_cmdline_ssm(SCI_MARGINSETTEXT, 0, (sptr_t)"*"); } -static void -teco_cmdline_update(void) -{ - /* - * Update the command line indicators. - * FIXME: Perhaps this can be avoided completely by updating the - * indicators in teco_cmdline_insert(). - */ - gsize effective_len = teco_cmdline_ssm(SCI_GETCURRENTPOS, 0, 0); - gsize macro_len = teco_cmdline_ssm(SCI_GETLENGTH, 0, 0); - teco_cmdline_ssm(SCI_SETINDICATORCURRENT, INDICATOR_RUBBEDOUT, 0); - teco_cmdline_ssm(SCI_INDICATORCLEARRANGE, 0, macro_len); - teco_cmdline_ssm(SCI_INDICATORFILLRANGE, effective_len, macro_len - effective_len); - teco_cmdline_ssm(SCI_SCROLLCARET, 0, 0); - - /* - * FIXME: This gets reset repeatedly. - * Setting it once per keypress however means you can no longer customize - * the margin text. - */ - teco_cmdline_ssm(SCI_MARGINSETTEXT, 0, (sptr_t)"*"); -} - /** * Insert string into command line and execute * it immediately. @@ -480,6 +457,35 @@ teco_cmdline_rubout(void) } } +/** + * Update the command line, i.e. prepare it for displaying. + * + * This updates the indicators and scrolls the caret, which isn't done every time + * we touch the command line itself. + */ +void +teco_cmdline_update(void) +{ + /* + * FIXME: Perhaps this can be avoided completely by updating the + * indicators in teco_cmdline_insert(). + */ + gsize effective_len = teco_cmdline_ssm(SCI_GETCURRENTPOS, 0, 0); + gsize macro_len = teco_cmdline_ssm(SCI_GETLENGTH, 0, 0); + teco_cmdline_ssm(SCI_SETINDICATORCURRENT, INDICATOR_RUBBEDOUT, 0); + teco_cmdline_ssm(SCI_INDICATORCLEARRANGE, 0, macro_len); + teco_cmdline_ssm(SCI_INDICATORFILLRANGE, effective_len, macro_len - effective_len); + + teco_cmdline_ssm(SCI_SCROLLCARET, 0, 0); + + /* + * FIXME: This gets reset repeatedly. + * Setting it once per keypress however means you can no longer customize + * the margin text. + */ + teco_cmdline_ssm(SCI_MARGINSETTEXT, 0, (sptr_t)"*"); +} + void teco_cmdline_cleanup(void) { diff --git a/src/cmdline.h b/src/cmdline.h index bd3158d..9123358 100644 --- a/src/cmdline.h +++ b/src/cmdline.h @@ -112,6 +112,8 @@ teco_cmdline_keymacro_c(gchar key, GError **error) return TRUE; } +void teco_cmdline_update(void); + void teco_cmdline_cleanup(void); /* diff --git a/src/interface-curses/interface.c b/src/interface-curses/interface.c index a57b19c..8f41f2a 100644 --- a/src/interface-curses/interface.c +++ b/src/interface-curses/interface.c @@ -1870,6 +1870,7 @@ teco_interface_process_mevent(MEVENT *event, GError **error) teco_interface_popup_clear(); teco_interface_msg_clear(); + teco_cmdline_update(); } return TRUE; diff --git a/src/interface-gtk/interface.c b/src/interface-gtk/interface.c index 98c7266..7aa9797 100644 --- a/src/interface-gtk/interface.c +++ b/src/interface-gtk/interface.c @@ -1466,6 +1466,7 @@ teco_interface_popup_clicked_cb(GtkWidget *popup, gchar *str, gulong len, gpoint !machine->current->insert_completion_cb(machine, &insert, NULL)) return; teco_interface_popup_clear(); + teco_cmdline_update(); teco_interface_update(teco_interface_current_view != last_view); } |
