diff options
author | Hisham Muhammad <hisham@gobolinux.org> | 2014-11-24 19:22:50 -0200 |
---|---|---|
committer | Hisham Muhammad <hisham@gobolinux.org> | 2014-11-24 19:22:50 -0200 |
commit | aaaaf063a17f420634632ec9f9fdd1bd48755c4e (patch) | |
tree | da90651c71f343a85404bb8aad087d0857ba5b31 /Action.c | |
parent | 26422af6088129b99864b75ed4ce5395aa578f2b (diff) |
Builds on Linux again!
Diffstat (limited to 'Action.c')
-rw-r--r-- | Action.c | 41 |
1 files changed, 41 insertions, 0 deletions
@@ -8,6 +8,7 @@ in the source distribution for its full text. #include "Process.h" #include "Panel.h" #include "Action.h" +#include "ScreenManager.h" /*{ @@ -38,6 +39,14 @@ typedef bool(*Action_ForeachProcessFn)(Process*, size_t); }*/ +int Action_selectedPid(Panel* panel) { + Process* p = (Process*) Panel_getSelected(panel); + if (p) { + return p->pid; + } + return -1; +} + bool Action_foreachProcess(Panel* panel, Action_ForeachProcessFn fn, int arg, bool* wasAnyTagged) { bool ok = true; bool anyTagged = false; @@ -57,3 +66,35 @@ bool Action_foreachProcess(Panel* panel, Action_ForeachProcessFn fn, int arg, bo return ok; } +Object* Action_pickFromVector(Panel* panel, Panel* list, int x, const char** keyLabels, Header* header) { + int y = panel->y; + const char* fuKeys[] = {"Enter", "Esc", NULL}; + int fuEvents[] = {13, 27}; + ScreenManager* scr = ScreenManager_new(0, y, 0, -1, HORIZONTAL, header, false); + scr->allowFocusChange = false; + ScreenManager_add(scr, list, FunctionBar_new(keyLabels, fuKeys, fuEvents), x - 1); + ScreenManager_add(scr, panel, NULL, -1); + Panel* panelFocus; + int ch; + bool unfollow = false; + int pid = Action_selectedPid(panel); + if (header->pl->following == -1) { + header->pl->following = pid; + unfollow = true; + } + ScreenManager_run(scr, &panelFocus, &ch); + if (unfollow) { + header->pl->following = -1; + } + ScreenManager_delete(scr); + Panel_move(panel, 0, y); + Panel_resize(panel, COLS, LINES-y-1); + if (panelFocus == list && ch == 13) { + Process* selected = (Process*)Panel_getSelected(panel); + if (selected && selected->pid == pid) + return Panel_getSelected(list); + else + beep(); + } + return NULL; +} |