summarylogtreecommitdiffstats
path: root/0001-Change-navigation-bindings-to-vi-standards.patch
blob: cd06dbe8390cd37188bf52123943ca6073f91953 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
From 6daf5764d7027c5be9beb1fde8b68308db86cb17 Mon Sep 17 00:00:00 2001
From: KoffeinFlummi <koffeinflummi@gmail.com>
Date: Thu, 7 May 2015 14:00:57 +0200
Subject: [PATCH 1/3] Change navigation bindings to vi standards

---
 Action.c        | 13 ++++++-------
 MainPanel.c     |  4 ++--
 Panel.c         | 22 +++++++++++++++++++---
 Panel.h         |  2 ++
 ScreenManager.c |  4 ++--
 5 files changed, 31 insertions(+), 14 deletions(-)

diff --git a/Action.c b/Action.c
index af6f2be..03eb3dc 100644
--- a/Action.c
+++ b/Action.c
@@ -373,7 +373,7 @@ static Htop_Reaction actionRedraw() {
 }
 
 static struct { const char* key; const char* info; } helpLeft[] = {
-   { .key = " Arrows: ", .info = "scroll process list" },
+   { .key = "   hjkl: ", .info = "scroll process list" },
    { .key = " Digits: ", .info = "incremental PID search" },
    { .key = "   F3 /: ", .info = "incremental name search" },
    { .key = "   F4 \\: ",.info = "incremental name filtering" },
@@ -393,18 +393,18 @@ static struct { const char* key; const char* info; } helpRight[] = {
    { .key = "  Space: ", .info = "tag process" },
    { .key = "      c: ", .info = "tag process and its children" },
    { .key = "      U: ", .info = "untag all processes" },
-   { .key = "   F9 k: ", .info = "kill process/tagged processes" },
+   { .key = "   F9 x: ", .info = "kill process/tagged processes" },
    { .key = "   F7 ]: ", .info = "higher priority (root only)" },
    { .key = "   F8 [: ", .info = "lower priority (+ nice)" },
 #if (HAVE_LIBHWLOC || HAVE_NATIVE_AFFINITY)
    { .key = "      a: ", .info = "set CPU affinity" },
 #endif
    { .key = "      i: ", .info = "set IO prority" },
-   { .key = "      l: ", .info = "list open files with lsof" },
+   { .key = "      L: ", .info = "list open files with lsof" },
    { .key = "      s: ", .info = "trace syscalls with strace" },
    { .key = "         ", .info = "" },
    { .key = "   F2 S: ", .info = "setup" },
-   { .key = "   F1 h: ", .info = "show this help screen" },
+   { .key = "   F1 ?: ", .info = "show this help screen" },
    { .key = "  F10 q: ", .info = "quit" },
    { .key = NULL, .info = NULL }
 };
@@ -523,7 +523,7 @@ void Action_setBindings(Htop_Action* keys) {
    keys['q'] = actionQuit;
    keys['a'] = actionSetAffinity;
    keys[KEY_F(9)] = actionKill;
-   keys['k'] = actionKill;
+   keys['x'] = actionKill;
    keys['+'] = actionExpandOrCollapse;
    keys['='] = actionExpandOrCollapse;
    keys['-'] = actionExpandOrCollapse;
@@ -532,12 +532,11 @@ void Action_setBindings(Htop_Action* keys) {
    keys['S'] = actionSetup;
    keys['C'] = actionSetup;
    keys[KEY_F(2)] = actionSetup;
-   keys['l'] = actionLsof;
+   keys['L'] = actionLsof;
    keys['s'] = actionStrace;
    keys[' '] = actionTag;
    keys['\014'] = actionRedraw; // Ctrl+L
    keys[KEY_F(1)] = actionHelp;
-   keys['h'] = actionHelp;
    keys['?'] = actionHelp;
    keys['U'] = actionUntagAll;
    keys['c'] = actionTagAllChildren;
diff --git a/MainPanel.c b/MainPanel.c
index be51c10..afd2430 100644
--- a/MainPanel.c
+++ b/MainPanel.c
@@ -104,14 +104,14 @@ static HandlerResult MainPanel_eventHandler(Panel* super, int ch) {
       }
       switch (ch) {
       case KEY_LEFT:
-      case KEY_CTRLB:
+      case 'h':
          if (super->scrollH > 0) {
             super->scrollH -= CRT_scrollHAmount;
             super->needsRedraw = true;
          }
          return HANDLED;
       case KEY_RIGHT:
-      case KEY_CTRLF:
+      case 'l':
          super->scrollH += CRT_scrollHAmount;
          super->needsRedraw = true;
          return HANDLED;
diff --git a/Panel.c b/Panel.c
index c426526..da0a2b2 100644
--- a/Panel.c
+++ b/Panel.c
@@ -86,6 +86,8 @@ struct Panel_ {
 #define KEY_CTRLP      0020            /* control-p key */
 #define KEY_CTRLF      0006            /* control-f key */
 #define KEY_CTRLB      0002            /* control-b key */
+#define KEY_CTRLU      0025            /* control-u key */
+#define KEY_CTRLD      0004            /* control-d key */
 
 PanelClass Panel_class = {
    .super = {
@@ -369,14 +371,16 @@ void Panel_draw(Panel* this, bool focus) {
 
 bool Panel_onKey(Panel* this, int key) {
    assert (this != NULL);
-   
+
    int size = Vector_size(this->items);
    switch (key) {
    case KEY_DOWN:
+   case 'j':
    case KEY_CTRLN:
       this->selected++;
       break;
    case KEY_UP:
+   case 'k':
    case KEY_CTRLP:
       this->selected--;
       break;
@@ -391,31 +395,43 @@ bool Panel_onKey(Panel* this, int key) {
       break;
    #endif
    case KEY_LEFT:
-   case KEY_CTRLB:
+   case 'h':
       if (this->scrollH > 0) {
          this->scrollH -= CRT_scrollHAmount;
          this->needsRedraw = true;
       }
       break;
    case KEY_RIGHT:
-   case KEY_CTRLF:
+   case 'l':
       this->scrollH += CRT_scrollHAmount;
       this->needsRedraw = true;
       break;
+   case KEY_CTRLU:
+      this->selected -= (this->h - 1) / 2;
+      this->needsRedraw = true;
+      break;
+   case KEY_CTRLD:
+      this->selected += (this->h - 1) / 2;
+      this->needsRedraw = true;
+      break;
    case KEY_PPAGE:
+   case KEY_CTRLB:
       this->selected -= (this->h - 1);
       this->scrollV -= (this->h - 1);
       this->needsRedraw = true;
       break;
    case KEY_NPAGE:
+   case KEY_CTRLF:
       this->selected += (this->h - 1);
       this->scrollV += (this->h - 1);
       this->needsRedraw = true;
       break;
    case KEY_HOME:
+   case 'g':
       this->selected = 0;
       break;
    case KEY_END:
+   case 'G':
       this->selected = size - 1;
       break;
    default:
diff --git a/Panel.h b/Panel.h
index 6789770..22a0f3f 100644
--- a/Panel.h
+++ b/Panel.h
@@ -74,6 +74,8 @@ struct Panel_ {
 #define KEY_CTRLP      0020            /* control-p key */
 #define KEY_CTRLF      0006            /* control-f key */
 #define KEY_CTRLB      0002            /* control-b key */
+#define KEY_CTRLU      0025            /* control-u key */
+#define KEY_CTRLD      0004            /* control-d key */
 
 extern PanelClass Panel_class;
 
diff --git a/ScreenManager.c b/ScreenManager.c
index c9253c3..0b20b58 100644
--- a/ScreenManager.c
+++ b/ScreenManager.c
@@ -259,7 +259,7 @@ void ScreenManager_run(ScreenManager* this, Panel** lastFocus, int* lastKey) {
          continue;
       }
       case KEY_LEFT:
-      case KEY_CTRLB:
+      case 'h':
          if (!this->allowFocusChange)
             break;
          tryLeft:
@@ -270,7 +270,7 @@ void ScreenManager_run(ScreenManager* this, Panel** lastFocus, int* lastKey) {
             goto tryLeft;
          break;
       case KEY_RIGHT:
-      case KEY_CTRLF:
+      case 'l':
       case 9:
          if (!this->allowFocusChange)
             break;
-- 
2.5.0