2011-12-26 21:35:57 +00:00
|
|
|
/*
|
|
|
|
htop - DisplayOptionsPanel.c
|
|
|
|
(C) 2004-2011 Hisham H. Muhammad
|
2020-10-05 07:51:32 +00:00
|
|
|
Released under the GNU GPLv2, see the COPYING file
|
2011-12-26 21:35:57 +00:00
|
|
|
in the source distribution for its full text.
|
|
|
|
*/
|
2006-03-04 18:16:49 +00:00
|
|
|
|
2020-09-19 11:55:23 +00:00
|
|
|
#include "config.h" // IWYU pragma: keep
|
|
|
|
|
2006-05-30 13:47:28 +00:00
|
|
|
#include "DisplayOptionsPanel.h"
|
2006-03-04 18:16:49 +00:00
|
|
|
|
2020-09-19 11:55:23 +00:00
|
|
|
#include <stdbool.h>
|
2011-12-26 21:35:57 +00:00
|
|
|
#include <stdlib.h>
|
2006-03-04 18:16:49 +00:00
|
|
|
|
2020-09-19 18:22:34 +00:00
|
|
|
#include "CRT.h"
|
2020-09-19 11:55:23 +00:00
|
|
|
#include "FunctionBar.h"
|
|
|
|
#include "Header.h"
|
|
|
|
#include "Object.h"
|
2020-11-21 20:40:08 +00:00
|
|
|
#include "OptionItem.h"
|
2020-09-19 11:55:23 +00:00
|
|
|
#include "ProvideCurses.h"
|
2020-10-14 18:21:09 +00:00
|
|
|
#include "XUtils.h"
|
2020-09-19 18:22:34 +00:00
|
|
|
|
2006-03-04 18:16:49 +00:00
|
|
|
|
2017-07-23 02:41:19 +00:00
|
|
|
static const char* const DisplayOptionsFunctions[] = {" ", " ", " ", " ", " ", " ", " ", " ", " ", "Done ", NULL};
|
2015-03-23 18:26:56 +00:00
|
|
|
|
2008-03-09 08:58:38 +00:00
|
|
|
static void DisplayOptionsPanel_delete(Object* object) {
|
2006-05-30 13:47:28 +00:00
|
|
|
Panel* super = (Panel*) object;
|
|
|
|
DisplayOptionsPanel* this = (DisplayOptionsPanel*) object;
|
|
|
|
Panel_done(super);
|
2006-03-04 18:16:49 +00:00
|
|
|
free(this);
|
|
|
|
}
|
|
|
|
|
2008-03-09 08:58:38 +00:00
|
|
|
static HandlerResult DisplayOptionsPanel_eventHandler(Panel* super, int ch) {
|
2006-05-30 13:47:28 +00:00
|
|
|
DisplayOptionsPanel* this = (DisplayOptionsPanel*) super;
|
2019-07-12 20:01:29 +00:00
|
|
|
|
2006-03-04 18:16:49 +00:00
|
|
|
HandlerResult result = IGNORED;
|
2020-11-21 20:40:08 +00:00
|
|
|
OptionItem* selected = (OptionItem*) Panel_getSelected(super);
|
2006-03-04 18:16:49 +00:00
|
|
|
|
2020-11-21 20:40:08 +00:00
|
|
|
switch (ch) {
|
|
|
|
case '\n':
|
|
|
|
case '\r':
|
2006-03-04 18:16:49 +00:00
|
|
|
case KEY_ENTER:
|
2008-05-07 23:01:45 +00:00
|
|
|
case KEY_MOUSE:
|
2015-08-27 21:42:35 +00:00
|
|
|
case KEY_RECLICK:
|
2006-03-04 18:16:49 +00:00
|
|
|
case ' ':
|
2020-11-21 20:40:08 +00:00
|
|
|
switch (OptionItem_kind(selected)) {
|
|
|
|
case OPTION_ITEM_CHECK:
|
|
|
|
CheckItem_toggle((CheckItem*)selected);
|
|
|
|
result = HANDLED;
|
|
|
|
break;
|
|
|
|
case OPTION_ITEM_NUMBER:
|
|
|
|
NumberItem_toggle((NumberItem*)selected);
|
|
|
|
result = HANDLED;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
case '-':
|
|
|
|
if (OptionItem_kind(selected) == OPTION_ITEM_NUMBER) {
|
|
|
|
NumberItem_decrease((NumberItem*)selected);
|
|
|
|
result = HANDLED;
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
case '+':
|
|
|
|
if (OptionItem_kind(selected) == OPTION_ITEM_NUMBER) {
|
|
|
|
NumberItem_increase((NumberItem*)selected);
|
|
|
|
result = HANDLED;
|
|
|
|
}
|
|
|
|
break;
|
2006-03-04 18:16:49 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
if (result == HANDLED) {
|
|
|
|
this->settings->changed = true;
|
2020-09-23 12:15:51 +00:00
|
|
|
Header* header = this->scr->header;
|
|
|
|
Header_calculateHeight(header);
|
|
|
|
Header_reinit(header);
|
2006-03-04 18:16:49 +00:00
|
|
|
Header_draw(header);
|
|
|
|
ScreenManager_resize(this->scr, this->scr->x1, header->height, this->scr->x2, this->scr->y2);
|
|
|
|
}
|
|
|
|
return result;
|
|
|
|
}
|
|
|
|
|
2020-10-05 11:19:50 +00:00
|
|
|
const PanelClass DisplayOptionsPanel_class = {
|
2012-12-05 15:12:20 +00:00
|
|
|
.super = {
|
|
|
|
.extends = Class(Panel),
|
|
|
|
.delete = DisplayOptionsPanel_delete
|
|
|
|
},
|
|
|
|
.eventHandler = DisplayOptionsPanel_eventHandler
|
|
|
|
};
|
|
|
|
|
2008-03-09 08:58:38 +00:00
|
|
|
DisplayOptionsPanel* DisplayOptionsPanel_new(Settings* settings, ScreenManager* scr) {
|
2012-12-05 15:12:20 +00:00
|
|
|
DisplayOptionsPanel* this = AllocThis(DisplayOptionsPanel);
|
2008-03-09 08:58:38 +00:00
|
|
|
Panel* super = (Panel*) this;
|
2015-03-23 18:26:56 +00:00
|
|
|
FunctionBar* fuBar = FunctionBar_new(DisplayOptionsFunctions, NULL, NULL);
|
2020-11-21 20:40:08 +00:00
|
|
|
Panel_init(super, 1, 1, 1, 1, Class(OptionItem), true, fuBar);
|
2008-03-09 08:58:38 +00:00
|
|
|
|
|
|
|
this->settings = settings;
|
|
|
|
this->scr = scr;
|
|
|
|
|
|
|
|
Panel_setHeader(super, "Display options");
|
2020-11-21 20:40:08 +00:00
|
|
|
Panel_add(super, (Object*) CheckItem_newByRef("Tree view", &(settings->treeView)));
|
|
|
|
Panel_add(super, (Object*) CheckItem_newByRef("Shadow other users' processes", &(settings->shadowOtherUsers)));
|
|
|
|
Panel_add(super, (Object*) CheckItem_newByRef("Hide kernel threads", &(settings->hideKernelThreads)));
|
|
|
|
Panel_add(super, (Object*) CheckItem_newByRef("Hide userland process threads", &(settings->hideUserlandThreads)));
|
|
|
|
Panel_add(super, (Object*) CheckItem_newByRef("Display threads in a different color", &(settings->highlightThreads)));
|
|
|
|
Panel_add(super, (Object*) CheckItem_newByRef("Show custom thread names", &(settings->showThreadNames)));
|
|
|
|
Panel_add(super, (Object*) CheckItem_newByRef("Show program path", &(settings->showProgramPath)));
|
|
|
|
Panel_add(super, (Object*) CheckItem_newByRef("Highlight program \"basename\"", &(settings->highlightBaseName)));
|
|
|
|
Panel_add(super, (Object*) CheckItem_newByRef("Merge exe, comm and cmdline in Command", &(settings->showMergedCommand)));
|
|
|
|
Panel_add(super, (Object*) CheckItem_newByRef("- Try to find comm in cmdline (when Command is merged)", &(settings->findCommInCmdline)));
|
|
|
|
Panel_add(super, (Object*) CheckItem_newByRef("- Try to strip exe from cmdline (when Command is merged)", &(settings->stripExeFromCmdline)));
|
|
|
|
Panel_add(super, (Object*) CheckItem_newByRef("Highlight large numbers in memory counters", &(settings->highlightMegabytes)));
|
|
|
|
Panel_add(super, (Object*) CheckItem_newByRef("Leave a margin around header", &(settings->headerMargin)));
|
|
|
|
Panel_add(super, (Object*) CheckItem_newByRef("Detailed CPU time (System/IO-Wait/Hard-IRQ/Soft-IRQ/Steal/Guest)", &(settings->detailedCPUTime)));
|
|
|
|
Panel_add(super, (Object*) CheckItem_newByRef("Count CPUs from 1 instead of 0", &(settings->countCPUsFromOne)));
|
|
|
|
Panel_add(super, (Object*) CheckItem_newByRef("Update process names on every refresh", &(settings->updateProcessNames)));
|
|
|
|
Panel_add(super, (Object*) CheckItem_newByRef("Add guest time in CPU meter percentage", &(settings->accountGuestInCPUMeter)));
|
|
|
|
Panel_add(super, (Object*) CheckItem_newByRef("Also show CPU percentage numerically", &(settings->showCPUUsage)));
|
|
|
|
Panel_add(super, (Object*) CheckItem_newByRef("Also show CPU frequency", &(settings->showCPUFrequency)));
|
2020-09-10 17:56:33 +00:00
|
|
|
#ifdef HAVE_LIBSENSORS
|
2020-11-21 20:40:08 +00:00
|
|
|
Panel_add(super, (Object*) CheckItem_newByRef("Also show CPU temperature", &(settings->showCPUTemperature)));
|
|
|
|
Panel_add(super, (Object*) CheckItem_newByRef("- Show temperature in degree Fahrenheit instead of Celsius", &(settings->degreeFahrenheit)));
|
2020-09-10 17:56:33 +00:00
|
|
|
#endif
|
2020-11-21 20:40:08 +00:00
|
|
|
Panel_add(super, (Object*) CheckItem_newByRef("Enable the mouse", &(settings->enableMouse)));
|
|
|
|
Panel_add(super, (Object*) NumberItem_newByRef("Update interval (in seconds)", &(settings->delay), -1, 1, 255));
|
|
|
|
Panel_add(super, (Object*) CheckItem_newByRef("Highlight new and old processes", &(settings->highlightChanges)));
|
|
|
|
Panel_add(super, (Object*) NumberItem_newByRef("- Highlight time (in seconds)", &(settings->highlightDelaySecs), 0, 1, 24*60*60));
|
2020-08-26 00:15:00 +00:00
|
|
|
#ifdef HAVE_LIBHWLOC
|
2020-11-21 20:40:08 +00:00
|
|
|
Panel_add(super, (Object*) CheckItem_newByRef("Show topology when selecting affinity by default", &(settings->topologyAffinity)));
|
2020-08-26 00:15:00 +00:00
|
|
|
#endif
|
2008-03-09 08:58:38 +00:00
|
|
|
return this;
|
|
|
|
}
|