summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorChristian Göttsche <cgzones@googlemail.com>2020-11-23 16:23:18 +0100
committerBenBE <BenBE@geshi.org>2020-11-28 19:49:38 +0100
commit19b514168553c75a3d5a012b781efbfd00fccc08 (patch)
treee74918f4b1dad2b83b67e16cb235fc5c8b23b208
parentea4f33409a978140493a43567fa3a3454ab03479 (diff)
Hide process selection on ESC
Do not highlight the current process line after pressing ESC in the main screen. Restore after pressing any key.
-rw-r--r--Action.c2
-rw-r--r--Action.h1
-rw-r--r--InfoScreen.c4
-rw-r--r--MainPanel.c4
-rw-r--r--Panel.c4
-rw-r--r--Panel.h2
-rw-r--r--ScreenManager.c2
-rw-r--r--htop.c1
8 files changed, 13 insertions, 7 deletions
diff --git a/Action.c b/Action.c
index dc57974d..47fa6f17 100644
--- a/Action.c
+++ b/Action.c
@@ -341,7 +341,7 @@ static Htop_Reaction actionKill(State* st) {
if (sgn) {
if (sgn->key != 0) {
Panel_setHeader(st->panel, "Sending...");
- Panel_draw(st->panel, true);
+ Panel_draw(st->panel, true, true);
refresh();
MainPanel_foreachProcess((MainPanel*)st->panel, Process_sendSignal, (Arg) { .i = sgn->key }, NULL);
napms(500);
diff --git a/Action.h b/Action.h
index 68aa2e2e..12519119 100644
--- a/Action.h
+++ b/Action.h
@@ -38,6 +38,7 @@ typedef struct State_ {
Panel* panel;
Header* header;
bool pauseProcessUpdate;
+ bool hideProcessSelection;
} State;
typedef Htop_Reaction (*Htop_Action)(State* st);
diff --git a/InfoScreen.c b/InfoScreen.c
index b7cbd4c6..eaf351d3 100644
--- a/InfoScreen.c
+++ b/InfoScreen.c
@@ -55,7 +55,7 @@ void InfoScreen_drawTitled(InfoScreen* this, const char* fmt, ...) {
mvwprintw(stdscr, 0, 0, title);
attrset(CRT_colors[DEFAULT_COLOR]);
this->display->needsRedraw = true;
- Panel_draw(this->display, true);
+ Panel_draw(this->display, true, true);
IncSet_drawBar(this->inc);
free(title);
va_end(ap);
@@ -89,7 +89,7 @@ void InfoScreen_run(InfoScreen* this) {
bool looping = true;
while (looping) {
- Panel_draw(panel, true);
+ Panel_draw(panel, true, true);
if (this->inc->active) {
(void) move(LINES - 1, CRT_cursorX);
diff --git a/MainPanel.c b/MainPanel.c
index 6a9d6303..848deae9 100644
--- a/MainPanel.c
+++ b/MainPanel.c
@@ -57,6 +57,9 @@ static HandlerResult MainPanel_eventHandler(Panel* super, int ch) {
Htop_Reaction reaction = HTOP_OK;
+ if (ch != ERR)
+ this->state->hideProcessSelection = false;
+
if (EVENT_IS_HEADER_CLICK(ch)) {
int x = EVENT_HEADER_CLICK_GET_X(ch);
const ProcessList* pl = this->state->pl;
@@ -83,6 +86,7 @@ static HandlerResult MainPanel_eventHandler(Panel* super, int ch) {
}
result = HANDLED;
} else if (ch == 27) {
+ this->state->hideProcessSelection = true;
return HANDLED;
} else if (ch != ERR && ch > 0 && ch < KEY_MAX && this->keys[ch]) {
reaction |= (this->keys[ch])(this->state);
diff --git a/Panel.c b/Panel.c
index fd9de2b1..68a245e3 100644
--- a/Panel.c
+++ b/Panel.c
@@ -217,7 +217,7 @@ void Panel_splice(Panel* this, Vector* from) {
this->needsRedraw = true;
}
-void Panel_draw(Panel* this, bool focus) {
+void Panel_draw(Panel* this, bool focus, bool highlightSelected) {
assert (this != NULL);
int size = Vector_size(this->items);
@@ -273,7 +273,7 @@ void Panel_draw(Panel* this, bool focus) {
Object_display(itemObj, &item);
int itemLen = RichString_sizeVal(item);
int amt = MINIMUM(itemLen - scrollH, this->w);
- if (i == this->selected) {
+ if (highlightSelected && i == this->selected) {
item.highlightAttr = selectionColor;
}
if (item.highlightAttr) {
diff --git a/Panel.h b/Panel.h
index 1ea5c7b8..86c134e0 100644
--- a/Panel.h
+++ b/Panel.h
@@ -109,7 +109,7 @@ int Panel_size(Panel* this);
void Panel_setSelected(Panel* this, int selected);
-void Panel_draw(Panel* this, bool focus);
+void Panel_draw(Panel* this, bool focus, bool highlightSelected);
void Panel_splice(Panel* this, Vector* from);
diff --git a/ScreenManager.c b/ScreenManager.c
index 51ca155f..87746c7e 100644
--- a/ScreenManager.c
+++ b/ScreenManager.c
@@ -123,7 +123,7 @@ static void ScreenManager_drawPanels(ScreenManager* this, int focus) {
const int nPanels = this->panelCount;
for (int i = 0; i < nPanels; i++) {
Panel* panel = (Panel*) Vector_get(this->panels, i);
- Panel_draw(panel, i == focus);
+ Panel_draw(panel, i == focus, !((panel == this->state->panel) && this->state->hideProcessSelection));
mvvline(panel->y, panel->x + panel->w, ' ', panel->h + 1);
}
}
diff --git a/htop.c b/htop.c
index 2c22b14f..41ef155e 100644
--- a/htop.c
+++ b/htop.c
@@ -320,6 +320,7 @@ int main(int argc, char** argv) {
.panel = (Panel*) panel,
.header = header,
.pauseProcessUpdate = false,
+ .hideProcessSelection = false,
};
MainPanel_setState(panel, &state);

© 2014-2024 Faster IT GmbH | imprint | privacy policy