diff options
author | C. McEnroe | 2020-02-08 02:26:00 -0500 |
---|---|---|
committer | C. McEnroe | 2020-02-08 02:26:00 -0500 |
commit | 943502ea82b3965b4f652146ca03262ac6390f83 (patch) | |
tree | 74880a218a8cf4ec0c5ddb0396364897619c0fc2 /ui.c | |
parent | 55e721da42bb57833e9c99e2b87cf50d6c035f07 (diff) |
Add /close
Diffstat (limited to 'ui.c')
-rw-r--r-- | ui.c | 28 |
1 files changed, 28 insertions, 0 deletions
diff --git a/ui.c b/ui.c index 6d1338b..c738617 100644 --- a/ui.c +++ b/ui.c @@ -573,6 +573,34 @@ void uiShowNum(size_t num) { windowShow(window); } +static void windowClose(struct Window *window) { + if (window->id == Network) return; + if (windows.active == window) { + windowShow(window->prev ? window->prev : window->next); + } + if (windows.other == window) windows.other = NULL; + windowRemove(window); + for (size_t i = 0; i < BufferCap; ++i) { + free(window->buffer.lines[i]); + } + delwin(window->pad); + free(window); + statusUpdate(); +} + +void uiCloseID(size_t id) { + windowClose(windowFor(id)); +} + +void uiCloseNum(size_t num) { + struct Window *window = windows.head; + for (size_t i = 0; i < num; ++i) { + window = window->next; + if (!window) return; + } + windowClose(window); +} + static void keyCode(int code) { size_t id = windows.active->id; switch (code) { |