diff options
Diffstat (limited to 'src')
| -rw-r--r-- | src/cmdline.c | 4 | ||||
| -rw-r--r-- | src/cmdline.h | 5 | ||||
| -rw-r--r-- | src/core-commands.c | 25 | ||||
| -rw-r--r-- | src/interface-curses/interface.c | 27 | ||||
| -rw-r--r-- | src/interface-gtk/interface.c | 11 |
5 files changed, 51 insertions, 21 deletions
diff --git a/src/cmdline.c b/src/cmdline.c index 53436fe..54f5cd1 100644 --- a/src/cmdline.c +++ b/src/cmdline.c @@ -65,7 +65,9 @@ int malloc_trim(size_t pad); /** Style used for the asterisk at the beginning of the command line */ #define STYLE_ASTERISK 64 -teco_cmdline_t teco_cmdline = {}; +teco_cmdline_t teco_cmdline = { + .height = 1 +}; /* * FIXME: Should perhaps be in doc.h. diff --git a/src/cmdline.h b/src/cmdline.h index 1ec891b..bd3158d 100644 --- a/src/cmdline.h +++ b/src/cmdline.h @@ -46,6 +46,9 @@ typedef struct { */ teco_view_t *view; + /** Height of the command line view in lines */ + guint height; + /** Program counter within the command-line macro */ gsize pc; @@ -80,7 +83,7 @@ teco_cmdline_ssm(unsigned int iMessage, uptr_t wParam, sptr_t lParam) * On the other hand this limits how you can customize the scroll behavior. */ static inline void -teco_cmdline_resize(guint width) +teco_cmdline_resized(guint width) { teco_cmdline_ssm(SCI_SETXCARETPOLICY, CARET_SLOP | CARET_EVEN, width/2); } diff --git a/src/core-commands.c b/src/core-commands.c index e0141c3..e0b2f89 100644 --- a/src/core-commands.c +++ b/src/core-commands.c @@ -2146,8 +2146,11 @@ teco_state_ecommand_flags(teco_machine_main_t *ctx, GError **error) * The column after the last horizontal movement. * This is only used by \fBfnkeys.tes\fP and is similar to the Scintilla-internal * setting \fBSCI_CHOOSECARETX\fP. - * Unless most other settings, this is on purpose not restored on rubout, - * so it "survives" command line replacements. + * Unlike most other settings, this is on purpose not restored on rubout, + * so it \(lqsurvives\(rq command line replacements. + * .IP 5: + * Height of the command line view in lines. + * Must not be smaller than 1. * . * .IP -1: * Type of the last mouse event (\fBread-only\fP). @@ -2200,7 +2203,8 @@ teco_state_ecommand_properties(teco_machine_main_t *ctx, GError **error) EJ_BUFFERS, EJ_MEMORY_LIMIT, EJ_INIT_COLOR, - EJ_CARETX + EJ_CARETX, + EJ_CMDLINE_HEIGHT }; static teco_int_t caret_x = 0; @@ -2237,9 +2241,20 @@ teco_state_ecommand_properties(teco_machine_main_t *ctx, GError **error) break; case EJ_CARETX: + /* DON'T undo on rubout */ caret_x = value; break; + case EJ_CMDLINE_HEIGHT: + if (value < 1 || value > G_MAXUINT) { + g_set_error(error, TECO_ERROR, TECO_ERROR_FAILED, + "Invalid command line height %" TECO_INT_FORMAT " " + "for <EJ>", value); + return; + } + teco_undo_guint(teco_cmdline.height) = value; + break; + default: g_set_error(error, TECO_ERROR, TECO_ERROR_FAILED, "Cannot set property %" TECO_INT_FORMAT " " @@ -2295,6 +2310,10 @@ teco_state_ecommand_properties(teco_machine_main_t *ctx, GError **error) teco_expressions_push(caret_x); break; + case EJ_CMDLINE_HEIGHT: + teco_expressions_push(teco_cmdline.height); + break; + default: g_set_error(error, TECO_ERROR, TECO_ERROR_FAILED, "Invalid property %" TECO_INT_FORMAT " " diff --git a/src/interface-curses/interface.c b/src/interface-curses/interface.c index 2effdb6..ed376c2 100644 --- a/src/interface-curses/interface.c +++ b/src/interface-curses/interface.c @@ -772,11 +772,12 @@ teco_interface_init_interactive(GError **error) leaveok(stdscr, TRUE); teco_interface.info_window = newwin(1, 0, 0, 0); - teco_interface.msg_window = newwin(1, 0, LINES - 2, 0); + teco_interface.msg_window = newwin(1, 0, LINES - teco_cmdline.height - 1, 0); - wresize(teco_view_get_window(teco_cmdline.view), 1, COLS); - mvwin(teco_view_get_window(teco_cmdline.view), LINES - 1, 0); - teco_cmdline_resize(COLS); + WINDOW *cmdline_win = teco_view_get_window(teco_cmdline.view); + wresize(cmdline_win, teco_cmdline.height, COLS); + mvwin(cmdline_win, LINES - teco_cmdline.height, 0); + teco_cmdline_resized(COLS); teco_interface.input_pad = newpad(1, 1); /* @@ -881,13 +882,14 @@ teco_interface_resize_all_windows(void) { wresize(teco_interface.info_window, 1, COLS); wresize(teco_view_get_window(teco_interface_current_view), - LINES - 3, COLS); + LINES - 2 - teco_cmdline.height, COLS); wresize(teco_interface.msg_window, 1, COLS); - mvwin(teco_interface.msg_window, LINES - 2, 0); + mvwin(teco_interface.msg_window, LINES - 1 - teco_cmdline.height, 0); - wresize(teco_view_get_window(teco_cmdline.view), 1, COLS); - mvwin(teco_view_get_window(teco_cmdline.view), LINES - 1, 0); - teco_cmdline_resize(COLS); + WINDOW *cmdline_win = teco_view_get_window(teco_cmdline.view); + wresize(cmdline_win, teco_cmdline.height, COLS); + mvwin(cmdline_win, LINES - teco_cmdline.height, 0); + teco_cmdline_resized(COLS); teco_interface_draw_info(); teco_interface_msg_clear(); /* FIXME: use saved message */ @@ -1009,7 +1011,7 @@ teco_interface_show_view(teco_view_t *view) * screen size might have changed since * this view's WINDOW was last active */ - wresize(current_view_win, LINES - 3, COLS); + wresize(current_view_win, LINES - 2 - teco_cmdline.height, COLS); /* Set up window position: never changes */ mvwin(current_view_win, 1, 0); } @@ -2027,6 +2029,7 @@ teco_interface_event_loop_iter(void) const teco_view_t *last_view = teco_interface_current_view; sptr_t last_vpos = teco_interface_ssm(SCI_GETFIRSTVISIBLELINE, 0, 0); + guint last_cmdline_height = teco_cmdline.height; switch (key) { case ERR: @@ -2153,6 +2156,10 @@ teco_interface_event_loop_iter(void) } } + if (G_UNLIKELY(teco_cmdline.height != last_cmdline_height)) + /* command line height was changed with h,5EJ */ + teco_interface_resize_all_windows(); + /* * Scintilla has been patched to avoid any automatic scrolling since that * has been benchmarked to be a very costly operation. diff --git a/src/interface-gtk/interface.c b/src/interface-gtk/interface.c index 665a635..c09feb2 100644 --- a/src/interface-gtk/interface.c +++ b/src/interface-gtk/interface.c @@ -782,8 +782,6 @@ teco_interface_set_css_variables(teco_view_t *view) guint32 calltip_fg_color = teco_view_ssm(view, SCI_STYLEGETFORE, STYLE_CALLTIP, 0); guint32 calltip_bg_color = teco_view_ssm(view, SCI_STYLEGETBACK, STYLE_CALLTIP, 0); - guint text_height = teco_cmdline_ssm(SCI_TEXTHEIGHT, 0, 0); - /* * Generates a CSS that sets some predefined color variables. * This effectively "exports" Scintilla styles into the CSS @@ -810,12 +808,13 @@ teco_interface_set_css_variables(teco_view_t *view) gtk_css_provider_load_from_data(teco_interface.css_var_provider, css, -1, NULL); /* - * The font and size of the commandline view might have changed, + * The font and size and height of the command-line view might have changed, * so we resize it. * This cannot be done via CSS or Scintilla messages. - * Currently, it is always exactly one line high in order to mimic the Curses UI. */ - gtk_widget_set_size_request(GTK_WIDGET(teco_cmdline.view), -1, text_height); + g_assert(teco_cmdline.height > 0); + gtk_widget_set_size_request(GTK_WIDGET(teco_cmdline.view), -1, + teco_cmdline.height*teco_cmdline_ssm(SCI_TEXTHEIGHT, 0, 0)); } static void @@ -1291,7 +1290,7 @@ static void teco_interface_cmdline_size_allocate_cb(GtkWidget *widget, GdkRectangle *allocation, gpointer user_data) { - teco_cmdline_resize(allocation->width); + teco_cmdline_resized(allocation->width); } static gboolean |
