From f3147ea2d1598914c2db53e8cfb34c8ff81e2ff4 Mon Sep 17 00:00:00 2001 From: Daniel Lange Date: Thu, 27 Aug 2020 07:48:10 +0200 Subject: New upstream version 3.0.0 --- ScreenManager.c | 32 +++++++++++++++++++++++--------- 1 file changed, 23 insertions(+), 9 deletions(-) (limited to 'ScreenManager.c') diff --git a/ScreenManager.c b/ScreenManager.c index 05e1c02..8e5f697 100644 --- a/ScreenManager.c +++ b/ScreenManager.c @@ -145,14 +145,12 @@ static void checkRecalculation(ScreenManager* this, double* oldTime, int* sortTi } static void ScreenManager_drawPanels(ScreenManager* this, int focus) { - int nPanels = this->panelCount; + const int nPanels = this->panelCount; for (int i = 0; i < nPanels; i++) { Panel* panel = (Panel*) Vector_get(this->panels, i); Panel_draw(panel, i == focus); - if (i < nPanels) { - if (this->orientation == HORIZONTAL) { - mvvline(panel->y, panel->x+panel->w, ' ', panel->h+1); - } + if (this->orientation == HORIZONTAL) { + mvvline(panel->y, panel->x+panel->w, ' ', panel->h+1); } } } @@ -165,7 +163,7 @@ static Panel* setCurrentPanel(Panel* panel) { void ScreenManager_run(ScreenManager* this, Panel** lastFocus, int* lastKey) { bool quit = false; int focus = 0; - + Panel* panelFocus = setCurrentPanel((Panel*) Vector_get(this->panels, focus)); double oldTime = 0.0; @@ -183,7 +181,7 @@ void ScreenManager_run(ScreenManager* this, Panel** lastFocus, int* lastKey) { if (this->header) { checkRecalculation(this, &oldTime, &sortTimeout, &redraw, &rescan, &timedOut); } - + if (redraw) { ScreenManager_drawPanels(this, focus); } @@ -192,8 +190,24 @@ void ScreenManager_run(ScreenManager* this, Panel** lastFocus, int* lastKey) { set_escdelay(25); ch = getch(); + if (this->settings->vimMode) { + switch (ch) { + case 'h': ch = KEY_LEFT; break; + case 'j': ch = KEY_DOWN; break; + case 'k': ch = KEY_UP; break; + case 'l': ch = KEY_RIGHT; break; + case KEY_LEFT: ch = 'h'; break; + case KEY_DOWN: ch = 'j'; break; + case KEY_UP: ch = 'k'; break; + case KEY_RIGHT: ch = 'l'; break; + case 'K': ch = 'k'; break; + case 'J': ch = 'K'; break; + case 'L': ch = 'l'; break; + } + } + HandlerResult result = IGNORED; - if (ch == KEY_MOUSE) { + if (ch == KEY_MOUSE && this->settings->enableMouse) { ch = ERR; MEVENT mevent; int ok = getmouse(&mevent); @@ -271,7 +285,7 @@ void ScreenManager_run(ScreenManager* this, Panel** lastFocus, int* lastKey) { quit = true; continue; } - + switch (ch) { case KEY_RESIZE: { -- cgit v1.2.3