Skip to content

Commit 5c5a599

Browse files
committed
Merge branch 'hishamhm-pull-959'
2 parents e25ac85 + 9ed47a2 commit 5c5a599

File tree

3 files changed

+21
-0
lines changed

3 files changed

+21
-0
lines changed

‎ScreenManager.c‎

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -190,6 +190,22 @@ void ScreenManager_run(ScreenManager* this, Panel** lastFocus, int* lastKey) {
190190
set_escdelay(25);
191191
ch = getch();
192192

193+
if (this->settings->vimMode) {
194+
switch (ch) {
195+
case 'h': ch = KEY_LEFT; break;
196+
case 'j': ch = KEY_DOWN; break;
197+
case 'k': ch = KEY_UP; break;
198+
case 'l': ch = KEY_RIGHT; break;
199+
case KEY_LEFT: ch = 'h'; break;
200+
case KEY_DOWN: ch = 'j'; break;
201+
case KEY_UP: ch = 'k'; break;
202+
case KEY_RIGHT: ch = 'l'; break;
203+
case 'K': ch = 'k'; break;
204+
case 'J': ch = 'K'; break;
205+
case 'L': ch = 'l'; break;
206+
}
207+
}
208+
193209
HandlerResult result = IGNORED;
194210
if (ch == KEY_MOUSE && this->settings->enableMouse) {
195211
ch = ERR;

‎Settings.c‎

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -61,6 +61,7 @@ typedef struct Settings_ {
6161
bool accountGuestInCPUMeter;
6262
bool headerMargin;
6363
bool enableMouse;
64+
bool vimMode;
6465
6566
bool changed;
6667
} Settings;
@@ -253,6 +254,8 @@ static bool Settings_read(Settings* this, const char* fileName) {
253254
} else if (String_eq(option[0], "right_meter_modes")) {
254255
Settings_readMeterModes(this, option[1], 1);
255256
didReadMeters = true;
257+
} else if (String_eq(option[0], "vim_mode")) {
258+
this->vimMode = atoi(option[1]);
256259
}
257260
String_freeArray(option);
258261
}
@@ -332,6 +335,7 @@ bool Settings_write(Settings* this) {
332335
fprintf(fd, "left_meter_modes="); writeMeterModes(this, fd, 0);
333336
fprintf(fd, "right_meters="); writeMeters(this, fd, 1);
334337
fprintf(fd, "right_meter_modes="); writeMeterModes(this, fd, 1);
338+
fprintf(fd, "vim_mode=%d\n", (int) this->vimMode);
335339
fclose(fd);
336340
return true;
337341
}

‎Settings.h‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,7 @@ typedef struct Settings_ {
5252
bool accountGuestInCPUMeter;
5353
bool headerMargin;
5454
bool enableMouse;
55+
bool vimMode;
5556

5657
bool changed;
5758
} Settings;

0 commit comments

Comments
 (0)