From 66f5193a70c2ef0598fde50fa104be08040d9efb Mon Sep 17 00:00:00 2001 From: Petros Pateros Date: Wed, 8 Dec 2021 12:11:18 +0200 Subject: [PATCH] ui-terminal: fix/extend terminal's cursor positioning for all window layouts --- ui-terminal.c | 20 ++++++++++++++------ 1 file changed, 14 insertions(+), 6 deletions(-) diff --git a/ui-terminal.c b/ui-terminal.c index ae5234476..89fa4345b 100644 --- a/ui-terminal.c +++ b/ui-terminal.c @@ -352,17 +352,25 @@ static void ui_draw(Ui *ui) { debug("ui-draw\n"); UiTerm *tui = (UiTerm*)ui; ui_arrange(ui, tui->layout); - int dy = 0; + int dx = 0, dy = 0; for (UiTermWin *win = tui->windows; win; win = win->next) { ui_window_draw((UiWin*)win); - if (win == tui->selwin || win->win == tui->vis->win) { + if (win == tui->selwin || win->win->parent) { View *view = win->win->view; - size_t pos = view_cursor_get(view); - view_coord_get(view, pos, NULL, &tui->row, &tui->col); - tui->row += dy; + view_coord_get(view, view_cursor_get(view), NULL, &tui->row, &tui->col); tui->col += win->sidebar_width; + tui->row += dy; + if (!win->win->parent) + tui->col += dx; + else if (tui->layout == UI_LAYOUT_VERTICAL) + tui->row += win->prev->height; } - dy += win->height; + if (tui->layout == UI_LAYOUT_HORIZONTAL) + dy += win->height; + else if (win->win->parent) + dy += win->prev->height; + else + dx += win->width + 1; /* +1 for the |'s */ } if (tui->info[0]) ui_draw_string(tui, 0, tui->height-1, tui->info, NULL, UI_STYLE_INFO);