aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/interface-curses
diff options
context:
space:
mode:
authorRobin Haberkorn <robin.haberkorn@googlemail.com>2023-06-18 18:50:39 +0300
committerRobin Haberkorn <robin.haberkorn@googlemail.com>2023-06-18 18:50:39 +0300
commit493504f12f79990dae7791efa27366b560151f2c (patch)
tree263ff3fefd2746ceae8a21e28dcc6fea6397b4eb /src/interface-curses
parent517ae85027f088615026fad6b880647dac5abf0a (diff)
downloadsciteco-493504f12f79990dae7791efa27366b560151f2c.tar.gz
fixed caret scrolling on startup
* Since Scintilla no longer automatically scrolls the caret (see 941f48da6dde691a7800290cc729aaaacd051392), the caret wouldn't always end up in the view on startup. * Added teco_interface_refresh() which includes SCI_SCROLLCARET and is invoked on startup. This helps with the Curses backend. It also reduces code redundancies. * On Gtk, the caret cannot be easily scrolled on startup as long as no size is allocated to the window, so we also added a size-allocate callback to the window's event box. Sizes are less often allocated to the event box than to the window itself for some strange reason.
Diffstat (limited to 'src/interface-curses')
-rw-r--r--src/interface-curses/interface.c59
1 files changed, 29 insertions, 30 deletions
diff --git a/src/interface-curses/interface.c b/src/interface-curses/interface.c
index e056333..ef3f0c7 100644
--- a/src/interface-curses/interface.c
+++ b/src/interface-curses/interface.c
@@ -1507,6 +1507,31 @@ teco_interface_is_interrupted(void)
#endif
+static void
+teco_interface_refresh(void)
+{
+ /*
+ * Scintilla has been patched to avoid any automatic scrolling since that
+ * has been benchmarked to be a very costly operation.
+ * Instead we do it only once after every keypress.
+ */
+ teco_interface_ssm(SCI_SCROLLCARET, 0, 0);
+
+ /*
+ * Info window is updated very often which is very
+ * costly, especially when using PDC_set_title(),
+ * so we redraw it here, where the overhead does
+ * not matter much.
+ */
+ teco_interface_draw_info();
+ wnoutrefresh(teco_interface.info_window);
+ teco_view_noutrefresh(teco_interface_current_view);
+ wnoutrefresh(teco_interface.msg_window);
+ wnoutrefresh(teco_interface.cmdline_window);
+ teco_curses_info_popup_noutrefresh(&teco_interface.popup);
+ doupdate();
+}
+
static gint
teco_interface_blocking_getch(void)
{
@@ -1640,48 +1665,22 @@ teco_interface_event_loop_iter(void)
return;
}
- /*
- * Scintilla has been patched to avoid any automatic scrolling since that
- * has been benchmarked to be a very costly operation.
- * Instead we do it only once after every keypress.
- */
- teco_interface_ssm(SCI_SCROLLCARET, 0, 0);
-
- /*
- * Info window is updated very often which is very
- * costly, especially when using PDC_set_title(),
- * so we redraw it here, where the overhead does
- * not matter much.
- */
- teco_interface_draw_info();
- wnoutrefresh(teco_interface.info_window);
- teco_view_noutrefresh(teco_interface_current_view);
- wnoutrefresh(teco_interface.msg_window);
- wnoutrefresh(teco_interface.cmdline_window);
- teco_curses_info_popup_noutrefresh(&teco_interface.popup);
- doupdate();
+ teco_interface_refresh();
}
gboolean
teco_interface_event_loop(GError **error)
{
- static const teco_cmdline_t empty_cmdline; // FIXME
-
/*
* Initialize Curses for interactive mode
*/
if (!teco_interface_init_interactive(error))
return FALSE;
- /* initial refresh */
- teco_interface_draw_info();
- wnoutrefresh(teco_interface.info_window);
- teco_view_noutrefresh(teco_interface_current_view);
- teco_interface_msg_clear();
- wnoutrefresh(teco_interface.msg_window);
+ static const teco_cmdline_t empty_cmdline; // FIXME
teco_interface_cmdline_update(&empty_cmdline);
- wnoutrefresh(teco_interface.cmdline_window);
- doupdate();
+ teco_interface_msg_clear();
+ teco_interface_refresh();
#ifdef EMCURSES
PDC_emscripten_set_handler(teco_interface_event_loop_iter, TRUE);