summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorChristian Göttsche <cgzones@googlemail.com>2021-12-05 19:30:32 +0100
committerBenBE <BenBE@geshi.org>2021-12-05 19:36:36 +0100
commitff4f44b22ae8d6522ee22599174a6cdd41bc0314 (patch)
tree26e9955df773dfae0e92f751a645c69d996c9280
parenta38f48481edeb696b2973c8a1bb2107658108a41 (diff)
Pre-select the last sent signal in SignalsPanel
Instead of pre-selecting SIGTERM every time, select the signal last send in the same htop session. Closes: #862
-rw-r--r--Action.c5
-rw-r--r--SignalsPanel.c5
-rw-r--r--SignalsPanel.h6
3 files changed, 11 insertions, 5 deletions
diff --git a/Action.c b/Action.c
index 07e21dca..92145330 100644
--- a/Action.c
+++ b/Action.c
@@ -344,9 +344,12 @@ static Htop_Reaction actionKill(State* st) {
if (Settings_isReadonly())
return HTOP_OK;
- Panel* signalsPanel = SignalsPanel_new();
+ static int preSelectedSignal = SIGNALSPANEL_INITSELECTEDSIGNAL;
+
+ Panel* signalsPanel = SignalsPanel_new(preSelectedSignal);
const ListItem* sgn = (ListItem*) Action_pickFromVector(st, signalsPanel, 14, true);
if (sgn && sgn->key != 0) {
+ preSelectedSignal = sgn->key;
Panel_setHeader((Panel*)st->mainPanel, "Sending...");
Panel_draw((Panel*)st->mainPanel, false, true, true, State_hideFunctionBar(st));
refresh();
diff --git a/SignalsPanel.c b/SignalsPanel.c
index f1c53795..cb71130f 100644
--- a/SignalsPanel.c
+++ b/SignalsPanel.c
@@ -18,15 +18,14 @@ in the source distribution for its full text.
#include "XUtils.h"
-Panel* SignalsPanel_new() {
+Panel* SignalsPanel_new(int preSelectedSignal) {
Panel* this = Panel_new(1, 1, 1, 1, Class(ListItem), true, FunctionBar_newEnterEsc("Send ", "Cancel "));
- const int defaultSignal = SIGTERM;
int defaultPosition = 15;
unsigned int i;
for (i = 0; i < Platform_numberOfSignals; i++) {
Panel_set(this, i, (Object*) ListItem_new(Platform_signals[i].name, Platform_signals[i].number));
// signal 15 is not always the 15th signal in the table
- if (Platform_signals[i].number == defaultSignal) {
+ if (Platform_signals[i].number == preSelectedSignal) {
defaultPosition = i;
}
}
diff --git a/SignalsPanel.h b/SignalsPanel.h
index da9711a1..7b9303fe 100644
--- a/SignalsPanel.h
+++ b/SignalsPanel.h
@@ -7,6 +7,8 @@ Released under the GNU GPLv2+, see the COPYING file
in the source distribution for its full text.
*/
+#include <signal.h>
+
#include "Panel.h"
@@ -15,6 +17,8 @@ typedef struct SignalItem_ {
int number;
} SignalItem;
-Panel* SignalsPanel_new(void);
+#define SIGNALSPANEL_INITSELECTEDSIGNAL SIGTERM
+
+Panel* SignalsPanel_new(int preSelectedSignal);
#endif

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