From 65357c8c46154de4e4eca14075bfe5523bb5fc14 Mon Sep 17 00:00:00 2001 From: Daniel Lange Date: Mon, 7 Dec 2020 10:26:01 +0100 Subject: New upstream version 3.0.3 --- AvailableColumnsPanel.c | 30 +++++++++++++++++++----------- 1 file changed, 19 insertions(+), 11 deletions(-) (limited to 'AvailableColumnsPanel.c') diff --git a/AvailableColumnsPanel.c b/AvailableColumnsPanel.c index 8aedde2..8945bd2 100644 --- a/AvailableColumnsPanel.c +++ b/AvailableColumnsPanel.c @@ -1,20 +1,24 @@ /* htop - AvailableColumnsPanel.c (C) 2004-2011 Hisham H. Muhammad -Released under the GNU GPL, see the COPYING file +Released under the GNU GPLv2, see the COPYING file in the source distribution for its full text. */ #include "AvailableColumnsPanel.h" -#include "Platform.h" - -#include "Header.h" -#include "ColumnsPanel.h" -#include -#include #include -#include +#include +#include + +#include "ColumnsPanel.h" +#include "FunctionBar.h" +#include "ListItem.h" +#include "Object.h" +#include "Platform.h" +#include "Process.h" +#include "ProvideCurses.h" +#include "XUtils.h" static const char* const AvailableColumnsFunctions[] = {" ", " ", " ", " ", "Add ", " ", " ", " ", " ", "Done ", NULL}; @@ -28,7 +32,6 @@ static void AvailableColumnsPanel_delete(Object* object) { static HandlerResult AvailableColumnsPanel_eventHandler(Panel* super, int ch) { AvailableColumnsPanel* this = (AvailableColumnsPanel*) super; - int key = ((ListItem*) Panel_getSelected(super))->key; HandlerResult result = IGNORED; switch(ch) { @@ -36,6 +39,11 @@ static HandlerResult AvailableColumnsPanel_eventHandler(Panel* super, int ch) { case KEY_ENTER: case KEY_F(5): { + const ListItem* selected = (ListItem*) Panel_getSelected(super); + if (!selected) + break; + + int key = selected->key; int at = Panel_getSelectedIndex(this->columns); Panel_insert(this->columns, at, (Object*) ListItem_new(Process_fields[key].name, key)); Panel_setSelected(this->columns, at+1); @@ -45,7 +53,7 @@ static HandlerResult AvailableColumnsPanel_eventHandler(Panel* super, int ch) { } default: { - if (ch < 255 && isalpha(ch)) + if (0 < ch && ch < 255 && isgraph((unsigned char)ch)) result = Panel_selectByTyping(super, ch); break; } @@ -53,7 +61,7 @@ static HandlerResult AvailableColumnsPanel_eventHandler(Panel* super, int ch) { return result; } -PanelClass AvailableColumnsPanel_class = { +const PanelClass AvailableColumnsPanel_class = { .super = { .extends = Class(Panel), .delete = AvailableColumnsPanel_delete -- cgit v1.2.3