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 --- ColumnsPanel.c | 37 ++++++++++++++++--------------------- 1 file changed, 16 insertions(+), 21 deletions(-) (limited to 'ColumnsPanel.c') diff --git a/ColumnsPanel.c b/ColumnsPanel.c index 587175c..b2a8246 100644 --- a/ColumnsPanel.c +++ b/ColumnsPanel.c @@ -1,20 +1,22 @@ /* htop - ColumnsPanel.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 "ColumnsPanel.h" -#include "Platform.h" -#include "StringUtils.h" -#include "ListItem.h" -#include "CRT.h" - -#include -#include #include +#include + +#include "CRT.h" +#include "FunctionBar.h" +#include "ListItem.h" +#include "Object.h" +#include "Process.h" +#include "ProvideCurses.h" +#include "XUtils.h" static const char* const ColumnsFunctions[] = {" ", " ", " ", " ", " ", " ", "MoveUp", "MoveDn", "Remove", "Done ", NULL}; @@ -43,7 +45,9 @@ static HandlerResult ColumnsPanel_eventHandler(Panel* super, int ch) { if (selected < size - 1) { this->moving = !(this->moving); Panel_setSelectionColor(super, this->moving ? CRT_colors[PANEL_SELECTION_FOLLOW] : CRT_colors[PANEL_SELECTION_FOCUS]); - ((ListItem*)Panel_getSelected(super))->moving = this->moving; + ListItem* selectedItem = (ListItem*) Panel_getSelected(super); + if (selectedItem) + selectedItem->moving = this->moving; result = HANDLED; } break; @@ -91,7 +95,7 @@ static HandlerResult ColumnsPanel_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); if (result == BREAK_LOOP) result = IGNORED; @@ -103,7 +107,7 @@ static HandlerResult ColumnsPanel_eventHandler(Panel* super, int ch) { return result; } -PanelClass ColumnsPanel_class = { +const PanelClass ColumnsPanel_class = { .super = { .extends = Class(Panel), .delete = ColumnsPanel_delete @@ -130,20 +134,11 @@ ColumnsPanel* ColumnsPanel_new(Settings* settings) { return this; } -int ColumnsPanel_fieldNameToIndex(const char* name) { - for (int j = 1; j <= Platform_numberOfFields; j++) { - if (String_eq(name, Process_fields[j].name)) { - return j; - } - } - return -1; -} - void ColumnsPanel_update(Panel* super) { ColumnsPanel* this = (ColumnsPanel*) super; int size = Panel_size(super); this->settings->changed = true; - this->settings->fields = xRealloc(this->settings->fields, sizeof(ProcessField) * (size+1)); + this->settings->fields = xRealloc(this->settings->fields, sizeof(ProcessField) * (size + 1)); this->settings->flags = 0; for (int i = 0; i < size; i++) { int key = ((ListItem*) Panel_get(super, i))->key; -- cgit v1.2.3