summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorBenny Baumann <BenBE@geshi.org>2020-11-01 01:09:51 +0100
committerBenny Baumann <BenBE@geshi.org>2020-11-02 22:15:01 +0100
commit45869513bfebba80cc2ab42e4218f68b34b1e6ac (patch)
treef064631dbff141bf1c945db8cff40b7bb82fd169
parent61e14d4bb25268593019e6df3eb02264b4ac8e0e (diff)
Embracing branches
-rw-r--r--Action.c64
-rw-r--r--Affinity.c7
-rw-r--r--AffinityPanel.c33
-rw-r--r--CPUMeter.c3
-rw-r--r--CRT.c16
-rw-r--r--CategoriesPanel.c1
-rw-r--r--CheckItem.c15
-rw-r--r--ColorsPanel.c1
-rw-r--r--CommandScreen.c4
-rw-r--r--FunctionBar.c10
-rw-r--r--Hashtable.c9
-rw-r--r--Header.c9
-rw-r--r--IncSet.c37
-rw-r--r--InfoScreen.c11
-rw-r--r--MainPanel.c9
-rw-r--r--Meter.c29
-rw-r--r--Object.c6
-rw-r--r--OpenFilesScreen.c14
-rw-r--r--Panel.c22
-rw-r--r--Process.c43
-rw-r--r--ProcessList.c46
-rw-r--r--RichString.c4
-rw-r--r--ScreenManager.c52
-rw-r--r--Settings.c16
-rw-r--r--TraceScreen.c12
-rw-r--r--Vector.c32
-rw-r--r--darwin/DarwinProcessList.c9
-rw-r--r--dragonflybsd/Battery.c10
-rw-r--r--dragonflybsd/DragonFlyBSDProcess.c5
-rw-r--r--dragonflybsd/DragonFlyBSDProcessList.c14
-rw-r--r--dragonflybsd/Platform.c4
-rw-r--r--freebsd/Battery.c10
-rw-r--r--freebsd/FreeBSDProcess.c5
-rw-r--r--freebsd/FreeBSDProcessList.c36
-rw-r--r--htop.c19
-rw-r--r--linux/Battery.c43
-rw-r--r--linux/IOPriorityPanel.c14
-rw-r--r--linux/LinuxProcess.c6
-rw-r--r--linux/LinuxProcessList.c146
-rw-r--r--linux/Platform.c21
-rw-r--r--linux/SELinuxMeter.c21
-rw-r--r--openbsd/OpenBSDProcessList.c3
-rw-r--r--openbsd/Platform.c7
-rw-r--r--solaris/Platform.c25
-rw-r--r--solaris/SolarisProcessList.c27
-rw-r--r--unsupported/UnsupportedProcessList.c3
46 files changed, 656 insertions, 277 deletions
diff --git a/Action.c b/Action.c
index 87901432..8a6e2cbe 100644
--- a/Action.c
+++ b/Action.c
@@ -65,13 +65,13 @@ Object* Action_pickFromVector(State* st, Panel* list, int x, bool followProcess)
Process* selected = (Process*)Panel_getSelected(panel);
if (selected && selected->pid == pid)
return Panel_getSelected(list);
- else
- beep();
+
+ beep();
} else {
return Panel_getSelected(list);
}
-
}
+
return NULL;
}
@@ -93,7 +93,7 @@ static void Action_runSetup(State* st) {
static bool changePriority(MainPanel* panel, int delta) {
bool anyTagged;
- bool ok = MainPanel_foreachProcess(panel, Process_changePriorityBy, (Arg){ .i = delta }, &anyTagged);
+ bool ok = MainPanel_foreachProcess(panel, Process_changePriorityBy, (Arg) { .i = delta }, &anyTagged);
if (!ok)
beep();
return anyTagged;
@@ -128,14 +128,18 @@ static void tagAllChildren(Panel* panel, Process* parent) {
static bool expandCollapse(Panel* panel) {
Process* p = (Process*) Panel_getSelected(panel);
- if (!p) return false;
+ if (!p)
+ return false;
+
p->showChildren = !p->showChildren;
return true;
}
static bool collapseIntoParent(Panel* panel) {
Process* p = (Process*) Panel_getSelected(panel);
- if (!p) return false;
+ if (!p)
+ return false;
+
pid_t ppid = Process_getParentPid(p);
for (int i = 0; i < Panel_size(panel); i++) {
Process* q = (Process*) Panel_get(panel, i);
@@ -165,6 +169,7 @@ static Htop_Reaction sortBy(State* st) {
Panel_add(sortPanel, (Object*) ListItem_new(name, fields[i]));
if (fields[i] == st->settings->sortKey)
Panel_setSelected(sortPanel, i);
+
free(name);
}
ListItem* field = (ListItem*) Action_pickFromVector(st, sortPanel, 15, false);
@@ -172,8 +177,10 @@ static Htop_Reaction sortBy(State* st) {
reaction |= Action_setSortKey(st->settings, field->key);
}
Object_delete(sortPanel);
+
if (st->pauseProcessUpdate)
ProcessList_sort(st->pl);
+
return reaction | HTOP_REFRESH | HTOP_REDRAW_BAR | HTOP_UPDATE_PANELHDR;
}
@@ -215,7 +222,10 @@ static Htop_Reaction actionToggleProgramPath(State* st) {
static Htop_Reaction actionToggleTreeView(State* st) {
st->settings->treeView = !st->settings->treeView;
- if (st->settings->treeView) st->settings->direction = 1;
+ if (st->settings->treeView) {
+ st->settings->direction = 1;
+ }
+
ProcessList_expandTree(st->pl);
return HTOP_REFRESH | HTOP_SAVE_SETTINGS | HTOP_KEEP_FOLLOWING | HTOP_REDRAW_BAR | HTOP_UPDATE_PANELHDR;
}
@@ -286,13 +296,18 @@ static Htop_Reaction actionQuit(ATTR_UNUSED State* st) {
static Htop_Reaction actionSetAffinity(State* st) {
if (st->pl->cpuCount == 1)
return HTOP_OK;
+
#if (defined(HAVE_LIBHWLOC) || defined(HAVE_LINUX_AFFINITY))
Panel* panel = st->panel;
Process* p = (Process*) Panel_getSelected(panel);
- if (!p) return HTOP_OK;
+ if (!p)
+ return HTOP_OK;
+
Affinity* affinity1 = Affinity_get(p, st->pl);
- if (!affinity1) return HTOP_OK;
+ if (!affinity1)
+ return HTOP_OK;
+
int width;
Panel* affinityPanel = AffinityPanel_new(st->pl, affinity1, &width);
width += 1; /* we add a gap between the panels */
@@ -301,8 +316,9 @@ static Htop_Reaction actionSetAffinity(State* st) {
void* set = Action_pickFromVector(st, affinityPanel, width, true);
if (set) {
Affinity* affinity2 = AffinityPanel_getAffinity(affinityPanel, st->pl);
- bool ok = MainPanel_foreachProcess((MainPanel*)panel, Affinity_set, (Arg){ .v = affinity2 }, NULL);
- if (!ok) beep();
+ bool ok = MainPanel_foreachProcess((MainPanel*)panel, Affinity_set, (Arg) { .v = affinity2 }, NULL);
+ if (!ok)
+ beep();
Affinity_delete(affinity2);
}
Object_delete(affinityPanel);
@@ -318,7 +334,7 @@ static Htop_Reaction actionKill(State* st) {
Panel_setHeader(st->panel, "Sending...");
Panel_draw(st->panel, true);
refresh();
- MainPanel_foreachProcess((MainPanel*)st->panel, Process_sendSignal, (Arg){ .i = sgn->key }, NULL);
+ MainPanel_foreachProcess((MainPanel*)st->panel, Process_sendSignal, (Arg) { .i = sgn->key }, NULL);
napms(500);
}
}
@@ -362,7 +378,9 @@ static Htop_Reaction actionSetup(State* st) {
static Htop_Reaction actionLsof(State* st) {
Process* p = (Process*) Panel_getSelected(st->panel);
- if (!p) return HTOP_OK;
+ if (!p)
+ return HTOP_OK;
+
OpenFilesScreen* ofs = OpenFilesScreen_new(p);
InfoScreen_run((InfoScreen*)ofs);
OpenFilesScreen_delete((Object*)ofs);
@@ -373,7 +391,9 @@ static Htop_Reaction actionLsof(State* st) {
static Htop_Reaction actionStrace(State* st) {
Process* p = (Process*) Panel_getSelected(st->panel);
- if (!p) return HTOP_OK;
+ if (!p)
+ return HTOP_OK;
+
TraceScreen* ts = TraceScreen_new(p);
bool ok = TraceScreen_forkTracer(ts);
if (ok) {
@@ -387,7 +407,9 @@ static Htop_Reaction actionStrace(State* st) {
static Htop_Reaction actionTag(State* st) {
Process* p = (Process*) Panel_getSelected(st->panel);
- if (!p) return HTOP_OK;
+ if (!p)
+ return HTOP_OK;
+
Process_toggleTag(p);
Panel_onKey(st->panel, KEY_DOWN);
return HTOP_OK;
@@ -555,14 +577,18 @@ static Htop_Reaction actionUntagAll(State* st) {
static Htop_Reaction actionTagAllChildren(State* st) {
Process* p = (Process*) Panel_getSelected(st->panel);
- if (!p) return HTOP_OK;
+ if (!p)
+ return HTOP_OK;
+
tagAllChildren(st->panel, p);
return HTOP_OK;
}
static Htop_Reaction actionShowEnvScreen(State* st) {
Process* p = (Process*) Panel_getSelected(st->panel);
- if (!p) return HTOP_OK;
+ if (!p)
+ return HTOP_OK;
+
EnvScreen* es = EnvScreen_new(p);
InfoScreen_run((InfoScreen*)es);
EnvScreen_delete((Object*)es);
@@ -573,7 +599,9 @@ static Htop_Reaction actionShowEnvScreen(State* st) {
static Htop_Reaction actionShowCommandScreen(State* st) {
Process* p = (Process*) Panel_getSelected(st->panel);
- if (!p) return HTOP_OK;
+ if (!p)
+ return HTOP_OK;
+
CommandScreen* cmdScr = CommandScreen_new(p);
InfoScreen_run((InfoScreen*)cmdScr);
CommandScreen_delete((Object*)cmdScr);
diff --git a/Affinity.c b/Affinity.c
index bfa7ceb5..6fb5846c 100644
--- a/Affinity.c
+++ b/Affinity.c
@@ -89,11 +89,14 @@ bool Affinity_set(Process* proc, Arg arg) {
Affinity* Affinity_get(Process* proc, ProcessList* pl) {
cpu_set_t cpuset;
bool ok = (sched_getaffinity(proc->pid, sizeof(cpu_set_t), &cpuset) == 0);
- if (!ok) return NULL;
+ if (!ok)
+ return NULL;
+
Affinity* affinity = Affinity_new(pl);
for (int i = 0; i < pl->cpuCount; i++) {
- if (CPU_ISSET(i, &cpuset))
+ if (CPU_ISSET(i, &cpuset)) {
Affinity_add(affinity, i);
+ }
}
return affinity;
}
diff --git a/AffinityPanel.c b/AffinityPanel.c
index 85094b4c..9c2a6e7c 100644
--- a/AffinityPanel.c
+++ b/AffinityPanel.c
@@ -60,12 +60,13 @@ static void MaskItem_display(const Object* cast, RichString* out) {
const MaskItem* this = (const MaskItem*)cast;
assert (this != NULL);
RichString_append(out, CRT_colors[CHECK_BOX], "[");
- if (this->value == 2)
+ if (this->value == 2) {
RichString_append(out, CRT_colors[CHECK_MARK], "x");
- else if (this->value == 1)
+ } else if (this->value == 1) {
RichString_append(out, CRT_colors[CHECK_MARK], "o");
- else
+ } else {
RichString_append(out, CRT_colors[CHECK_MARK], " ");
+ }
RichString_append(out, CRT_colors[CHECK_BOX], "]");
RichString_append(out, CRT_colors[CHECK_TEXT], " ");
if (this->indent) {
@@ -178,11 +179,12 @@ static void AffinityPanel_update(AffinityPanel* this, bool keepSelected) {
Panel_prune(super);
#ifdef HAVE_LIBHWLOC
- if (this->topoView)
+ if (this->topoView) {
AffinityPanel_updateTopo(this, this->topoRoot);
- else {
- for (int i = 0; i < Vector_size(this->cpuids); i++)
+ } else {
+ for (int i = 0; i < Vector_size(this->cpuids); i++) {
AffinityPanel_updateItem(this, (MaskItem*) Vector_get(this->cpuids, i));
+ }
}
#else
Panel_splice(super, this->cpuids);
@@ -304,14 +306,16 @@ static MaskItem* AffinityPanel_addObject(AffinityPanel* this, hwloc_obj_t obj, u
hwloc_bitmap_and(result, obj->complete_cpuset, this->workCpuset);
int weight = hwloc_bitmap_weight(result);
hwloc_bitmap_free(result);
- if (weight == 0 || weight == (hwloc_bitmap_weight(this->workCpuset) + hwloc_bitmap_weight(obj->complete_cpuset)))
+ if (weight == 0 || weight == (hwloc_bitmap_weight(this->workCpuset) + hwloc_bitmap_weight(obj->complete_cpuset))) {
item->sub_tree = 2;
+ }
}
/* "[x] " + "|- " * depth + ("- ")?(if root node) + name */
unsigned width = 4 + 3 * depth + (2 * !depth) + strlen(buf);
- if (width > this->width)
+ if (width > this->width) {
this->width = width;
+ }
return item;
}
@@ -323,8 +327,10 @@ static MaskItem* AffinityPanel_buildTopology(AffinityPanel* this, hwloc_obj_t ob
} else {
indent &= ~(1u << obj->depth);
}
- for (unsigned i = 0; i < obj->arity; i++)
+
+ for (unsigned i = 0; i < obj->arity; i++) {
AffinityPanel_buildTopology(this, obj->children[i], indent, item);
+ }
return parent == NULL ? item : NULL;
}
@@ -382,8 +388,9 @@ Panel* AffinityPanel_new(ProcessList* pl, Affinity* affinity, int* width) {
char number[16];
xSnprintf(number, 9, "CPU %d", Settings_cpuId(pl->settings, i));
unsigned cpu_width = 4 + strlen(number);
- if (cpu_width > this->width)
+ if (cpu_width > this->width) {
this->width = cpu_width;
+ }
bool isSet = false;
if (curCpu < affinity->used && affinity->cpus[curCpu] == i) {
@@ -402,8 +409,9 @@ Panel* AffinityPanel_new(ProcessList* pl, Affinity* affinity, int* width) {
this->topoRoot = AffinityPanel_buildTopology(this, hwloc_get_root_obj(pl->topology), 0, NULL);
#endif
- if (width)
+ if (width) {
*width = this->width;
+ }
AffinityPanel_update(this, false);
@@ -422,8 +430,9 @@ Affinity* AffinityPanel_getAffinity(Panel* super, ProcessList* pl) {
#else
for (int i = 0; i < this->pl->cpuCount; i++) {
MaskItem* item = (MaskItem*)Vector_get(this->cpuids, i);
- if (item->value)
+ if (item->value) {
Affinity_add(affinity, item->cpu);
+ }
}
#endif
diff --git a/CPUMeter.c b/CPUMeter.c
index b1bb8f45..ff129cd2 100644
--- a/CPUMeter.c
+++ b/CPUMeter.c
@@ -163,10 +163,13 @@ static void CPUMeterCommonInit(Meter* this, int ncol) {
for (int i = 0; i < count; i++) {
if (!meters[i])
meters[i] = Meter_new(this->pl, start + i + 1, (const MeterClass*) Class(CPUMeter));
+
Meter_init(meters[i]);
}
+
if (this->mode == 0)
this->mode = BAR_METERMODE;
+
int h = Meter_modes[this->mode]->h;
this->h = h * ((count + ncol - 1) / ncol);
}
diff --git a/CRT.c b/CRT.c
index 38ba9da3..08f1cef3 100644
--- a/CRT.c
+++ b/CRT.c
@@ -619,13 +619,18 @@ void CRT_init(int delay, int colorScheme, bool allowUnicode) {
keypad(stdscr, true);
mouseinterval(0);
curs_set(0);
- if (has_colors())
+
+ if (has_colors()) {
start_color();
+ }
+
CRT_termType = getenv("TERM");
- if (String_eq(CRT_termType, "linux"))
+ if (String_eq(CRT_termType, "linux")) {
CRT_scrollHAmount = 20;
- else
+ } else {
CRT_scrollHAmount = 5;
+ }
+
if (String_startsWith(CRT_termType, "xterm") || String_eq(CRT_termType, "vt220")) {
define_key("\033[H", KEY_HOME);
define_key("\033[F", KEY_END);
@@ -670,10 +675,11 @@ void CRT_init(int delay, int colorScheme, bool allowUnicode) {
setlocale(LC_CTYPE, "");
#ifdef HAVE_LIBNCURSESW
- if (allowUnicode && String_eq(nl_langinfo(CODESET), "UTF-8"))
+ if (allowUnicode && String_eq(nl_langinfo(CODESET), "UTF-8")) {
CRT_utf8 = true;
- else
+ } else {
CRT_utf8 = false;
+ }
#else
(void) allowUnicode;
#endif
diff --git a/CategoriesPanel.c b/CategoriesPanel.c
index d6c25a69..2dc1c3bf 100644
--- a/CategoriesPanel.c
+++ b/CategoriesPanel.c
@@ -97,6 +97,7 @@ static HandlerResult CategoriesPanel_eventHandler(Panel* super, int ch) {
int size = ScreenManager_size(this->scr);
for (int i = 1; i < size; i++)
ScreenManager_remove(this->scr, 1);
+
switch (selected) {
case 0:
CategoriesPanel_makeMetersPage(this);
diff --git a/CheckItem.c b/CheckItem.c
index 5c79ab13..5fcae96b 100644
--- a/CheckItem.c
+++ b/CheckItem.c
@@ -26,10 +26,11 @@ static void CheckItem_display(const Object* cast, RichString* out) {
const CheckItem* this = (const CheckItem*)cast;
assert (this != NULL);
RichString_write(out, CRT_colors[CHECK_BOX], "[");
- if (CheckItem_get(this))
+ if (CheckItem_get(this)) {
RichString_append(out, CRT_colors[CHECK_MARK], "x");
- else
+ } else {
RichString_append(out, CRT_colors[CHECK_MARK], " ");
+ }
RichString_append(out, CRT_colors[CHECK_BOX], "] ");
RichString_append(out, CRT_colors[CHECK_TEXT], this->text);
}
@@ -56,15 +57,17 @@ CheckItem* CheckItem_newByVal(char* text, bool value) {
}
void CheckItem_set(CheckItem* this, bool value) {
- if (this->ref)
+ if (this->ref) {
*(this->ref) = value;
- else
+ } else {
this->value = value;
+ }
}
bool CheckItem_get(const CheckItem* this) {
- if (this->ref)
+ if (this->ref) {
return *(this->ref);
- else
+ } else {
return this->value;
+ }
}
diff --git a/ColorsPanel.c b/ColorsPanel.c
index 24e63b0e..9da71545 100644
--- a/ColorsPanel.c
+++ b/ColorsPanel.c
@@ -64,6 +64,7 @@ static HandlerResult ColorsPanel_eventHandler(Panel* super, int ch) {
for (int i = 0; ColorSchemeNames[i] != NULL; i++)
CheckItem_set((CheckItem*)Panel_get(super, i), false);
CheckItem_set((CheckItem*)Panel_get(super, mark), true);
+
this->settings->colorScheme = mark;
result = HANDLED;
}
diff --git a/CommandScreen.c b/CommandScreen.c
index 7997a64a..578b3ae1 100644
--- a/CommandScreen.c
+++ b/CommandScreen.c
@@ -21,7 +21,9 @@ static void CommandScreen_scan(InfoScreen* this) {
int line_offset = 0, last_spc = -1, len;
for (; *p != '\0'; p++, line_offset++) {
line[line_offset] = *p;
- if (*p == ' ') last_spc = line_offset;
+ if (*p == ' ') {
+ last_spc = line_offset;
+ }
if (line_offset == COLS) {
len = (last_spc == -1) ? line_offset : last_spc;
diff --git a/FunctionBar.c b/FunctionBar.c
index 93456583..627bc777 100644
--- a/FunctionBar.c
+++ b/FunctionBar.c
@@ -106,10 +106,11 @@ void FunctionBar_drawExtra(const FunctionBar* this, const char* buffer, int attr
}
if (buffer) {
- if (attr == -1)
+ if (attr == -1) {
attrset(CRT_colors[FUNCTION_BAR]);
- else
+ } else {
attrset(attr);
+ }
mvaddstr(LINES - 1, x, buffer);
attrset(CRT_colors[RESET_COLOR]);
x += strlen(buffer);
@@ -126,10 +127,11 @@ void FunctionBar_drawExtra(const FunctionBar* this, const char* buffer, int attr
}
void FunctionBar_append(const char* buffer, int attr) {
- if (attr == -1)
+ if (attr == -1) {
attrset(CRT_colors[FUNCTION_BAR]);
- else
+ } else {
attrset(attr);
+ }
mvaddstr(LINES - 1, currentLen, buffer);
attrset(CRT_colors[RESET_COLOR]);
diff --git a/Hashtable.c b/Hashtable.c
index a086227c..92337822 100644
--- a/Hashtable.c
+++ b/Hashtable.c
@@ -70,6 +70,7 @@ void Hashtable_delete(Hashtable* this) {
while (walk != NULL) {
if (this->owner)
free(walk->value);
+
HashtableItem* savedWalk = walk;
walk = savedWalk->next;
free(savedWalk);
@@ -90,10 +91,13 @@ void Hashtable_put(Hashtable* this, unsigned int key, void* value) {
} else if ((*bucketPtr)->key == key) {
if (this->owner && (*bucketPtr)->value != value)
free((*bucketPtr)->value);
+
(*bucketPtr)->value = value;
break;
- } else
+ } else {
bucketPtr = &((*bucketPtr)->next);
+ }
+
assert(Hashtable_isConsistent(this));
}
@@ -134,8 +138,9 @@ void* Hashtable_get(Hashtable* this, unsigned int key) {
} else if (bucketPtr->key == key) {
assert(Hashtable_isConsistent(this));
return bucketPtr->value;
- } else
+ } else {
bucketPtr = bucketPtr->next;
+ }
}
}
diff --git a/Header.c b/Header.c
index 4448baa6..0b522f54 100644
--- a/Header.c
+++ b/Header.c
@@ -88,7 +88,8 @@ MeterModeId Header_addMeterByName(Header* this, char* name, int column) {
int param = 0;
if (paren) {
int ok = sscanf(paren, "(%10d)", &param);
- if (!ok) param = 0;
+ if (!ok)
+ param = 0;
*paren = '\0';
}
MeterModeId mode = TEXT_METERMODE;
@@ -100,8 +101,10 @@ MeterModeId Header_addMeterByName(Header* this, char* name, int column) {
break;
}
}
+
if (paren)
*paren = '(';
+
return mode;
}
@@ -110,6 +113,7 @@ void Header_setMode(Header* this, int i, MeterModeId mode, int column) {
if (i >= Vector_size(meters))
return;
+
Meter* meter = (Meter*) Vector_get(meters, i);
Meter_setMode(meter, mode);
}
@@ -153,8 +157,9 @@ void Header_reinit(Header* this) {
Header_forEachColumn(this, col) {
for (int i = 0; i < Vector_size(this->columns[col]); i++) {
Meter* meter = (Meter*) Vector_get(this->columns[col], i);
- if (Meter_initFn(meter))
+ if (Meter_initFn(meter)) {
Meter_init(meter);
+ }
}
}
}
diff --git a/IncSet.c b/IncSet.c
index 3deda737..d280caf4 100644
--- a/IncSet.c
+++ b/IncSet.c
@@ -79,7 +79,10 @@ static void updateWeakPanel(IncSet* this, Panel* panel, Vector* lines) {
ListItem* line = (ListItem*)Vector_get(lines, i);
if (String_contains_i(line->value, incFilter)) {
Panel_add(panel, (Object*)line);
- if (selected == (Object*)line) Panel_setSelected(panel, n);
+ if (selected == (Object*)line) {
+ Panel_setSelected(panel, n);
+ }
+
n++;
}
}
@@ -87,7 +90,9 @@ static void updateWeakPanel(IncSet* this, Panel* panel, Vector* lines) {
for (int i = 0; i < Vector_size(lines); i++) {
Object* line = Vector_get(lines, i);
Panel_add(panel, line);
- if (selected == line) Panel_setSelected(panel, i);
+ if (selected == line) {
+ Panel_setSelected(panel, i);
+ }
}
}
}
@@ -115,10 +120,17 @@ static bool IncMode_find(IncMode* mode, Panel* panel, IncMode_GetPanelValue getP
int here = Panel_getSelectedIndex(panel);
int i = here;
for (;;) {
- i+=step;
- if (i == size) i = 0;
- if (i == -1) i = size - 1;
- if (i == here) return false;
+ i += step;
+ if (i == size) {
+ i = 0;
+ }
+ if (i == -1) {
+ i = size - 1;
+ }
+ if (i == here) {
+ return false;
+ }
+
if (String_contains_i(getPanelValue(panel, i), mode->buffer)) {
Panel_setSelected(panel, i);
return true;
@@ -137,12 +149,15 @@ bool IncSet_prev(IncSet* this, IncType type, Panel* panel, IncMode_GetPanelValue
bool IncSet_handleKey(IncSet* this, int ch, Panel* panel, IncMode_GetPanelValue getPanelValue, Vector* lines) {
if (ch == ERR)
return true;
+
IncMode* mode = this->active;
int size = Panel_size(panel);
bool filterChanged = false;
bool doSearch = true;
if (ch == KEY_F(3)) {
- if (size == 0) return true;
+ if (size == 0)
+ return true;
+
IncMode_find(mode, panel, getPanelValue, 1);
doSearch = false;
} else if (0 < ch && ch < 255 && isprint((unsigned char)ch)) {
@@ -152,7 +167,9 @@ bool IncSet_handleKey(IncSet* this, int ch, Panel* panel, IncMode_GetPanelValue
mode->buffer[mode->index] = 0;
if (mode->isFilter) {
filterChanged = true;
- if (mode->index == 1) this->filtering = true;
+ if (mode->index == 1) {
+ this->filtering = true;
+ }
}
}
} else if ((ch == KEY_BACKSPACE || ch == 127)) {
@@ -199,9 +216,7 @@ bool IncSet_handleKey(IncSet* this, int ch, Panel* panel, IncMode_GetPanelValue
const char* IncSet_getListItemValue(Panel* panel, int i) {
ListItem* l = (ListItem*) Panel_get(panel, i);
- if (l)
- return l->value;
- return "";
+ return l ? l->value : "";
}
void IncSet_activate(IncSet* this, IncType type, Panel* panel) {
diff --git a/InfoScreen.c b/InfoScreen.c
index 102f0ba7..b7cbd4c6 100644
--- a/InfoScreen.c
+++ b/InfoScreen.c
@@ -64,16 +64,18 @@ void InfoScreen_drawTitled(InfoScreen* this, const char* fmt, ...) {
void InfoScreen_addLine(InfoScreen* this, const char* line) {
Vector_add(this->lines, (Object*) ListItem_new(line, 0));
const char* incFilter = IncSet_filter(this->inc);
- if (!incFilter || String_contains_i(line, incFilter))
+ if (!incFilter || String_contains_i(line, incFilter)) {
Panel_add(this->display, Vector_get(this->lines, Vector_size(this->lines) - 1));
+ }
}
void InfoScreen_appendLine(InfoScreen* this, const char* line) {
ListItem* last = (ListItem*)Vector_get(this->lines, Vector_size(this->lines) - 1);
ListItem_append(last, line);
const char* incFilter = IncSet_filter(this->inc);
- if (incFilter && Panel_get(this->display, Panel_size(this->display) - 1) != (Object*)last && String_contains_i(line, incFilter))
+ if (incFilter && Panel_get(this->display, Panel_size(this->display) - 1) != (Object*)last && String_contains_i(line, incFilter)) {
Panel_add(this->display, (Object*)last);
+ }
}
void InfoScreen_run(InfoScreen* this) {
@@ -133,7 +135,9 @@ void InfoScreen_run(InfoScreen* this) {
break;
case KEY_F(5):
clear();
- if (As_InfoScreen(this)->scan) InfoScreen_scan(this);
+ if (As_InfoScreen(this)->scan)
+ InfoScreen_scan(this);
+
InfoScreen_draw(this);
break;
case '\014': // Ctrl+L
@@ -149,6 +153,7 @@ void InfoScreen_run(InfoScreen* this) {
Panel_resize(panel, COLS, LINES - 2);
if (As_InfoScreen(this)->scan)
InfoScreen_scan(this);
+
InfoScreen_draw(this);
break;
default:
diff --git a/MainPanel.c b/MainPanel.c
index 9322fe02..be59abd3 100644
--- a/MainPanel.c
+++ b/MainPanel.c
@@ -100,8 +100,9 @@ static HandlerResult MainPanel_eventHandler(Panel* super, int ch) {
if (reaction & HTOP_REDRAW_BAR) {
MainPanel_updateTreeFunctions(this, this->state->settings->treeView);
IncSet_drawBar(this->inc);
- if (this->state->pauseProcessUpdate)
+ if (this->state->pauseProcessUpdate) {
FunctionBar_append("PAUSED", CRT_colors[PAUSED]);
+ }
}
if (reaction & HTOP_UPDATE_PANELHDR) {
ProcessList_printHeader(this->state->pl, Panel_ge