diff options
author | Hisham Muhammad <hisham@gobolinux.org> | 2018-08-24 22:45:55 -0300 |
---|---|---|
committer | Hisham Muhammad <hisham@gobolinux.org> | 2018-08-24 22:53:07 -0300 |
commit | 8c43218aa07014040a1076352060d58c240a7f70 (patch) | |
tree | e5406bcac354e79b5c4257ef025270dea50899d8 /Action.c | |
parent | e77a16f4ae473441ea922baeb6a98de165677442 (diff) |
Introduce screen tabs
Diffstat (limited to 'Action.c')
-rw-r--r-- | Action.c | 28 |
1 files changed, 24 insertions, 4 deletions
@@ -26,6 +26,7 @@ in the source distribution for its full text. #include <math.h> #include <pwd.h> #include <stdlib.h> +#include <string.h> #include <stdbool.h> #include <sys/param.h> #include <sys/time.h> @@ -80,7 +81,7 @@ Object* Action_pickFromVector(State* st, Panel* list, int x) { header->pl->following = pid; unfollow = true; } - ScreenManager_run(scr, &panelFocus, &ch); + ScreenManager_run(scr, &panelFocus, &ch, NULL); if (unfollow) { header->pl->following = -1; } @@ -106,7 +107,7 @@ static void Action_runSetup(Settings* settings, const Header* header, ProcessLis CategoriesPanel_makeMetersPage(panelCategories); Panel* panelFocus; int ch; - ScreenManager_run(scr, &panelFocus, &ch); + ScreenManager_run(scr, &panelFocus, &ch, "Setup"); ScreenManager_delete(scr); if (settings->changed) { Header_writeBackToSettings(header); @@ -307,14 +308,33 @@ static Htop_Reaction actionNextScreen(State* st) { static Htop_Reaction actionPrevScreen(State* st) { Settings* settings = st->settings; - settings->ssIndex--; - if (settings->ssIndex == -1) { + if (settings->ssIndex == 0) { settings->ssIndex = settings->nScreens - 1; + } else { + settings->ssIndex--; } settings->ss = settings->screens[settings->ssIndex]; return HTOP_REFRESH; } +Htop_Reaction Action_setScreenTab(Settings* settings, int x) { + int s = 2; + for (unsigned int i = 0; i < settings->nScreens; i++) { + if (x < s) { + return 0; + } + const char* name = settings->screens[i]->name; + int len = strlen(name); + if (x <= s + len + 1) { + settings->ssIndex = i; + settings->ss = settings->screens[i]; + return HTOP_REFRESH; + } + s += len + 3; + } + return 0; +} + static Htop_Reaction actionSetAffinity(State* st) { if (st->pl->cpuCount == 1) return HTOP_OK; |