Skip to content

Commit e93ded6

Browse files
committed
feat(keys): add pgdown, pgup, home & end
1 parent f399c4d commit e93ded6

4 files changed

Lines changed: 28 additions & 2 deletions

File tree

src/constants/cli.constants.ts

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -74,8 +74,9 @@ export const HELP_HEADER = `This tool allows you to list any node_modules direct
7474
| SPACE: delete selected result
7575
| Cursor UP, k: move up
7676
| Cursor DOWN, j: move down
77-
| h, d, Ctrl+d: move one page down
78-
| l, u, Ctrl+u: move one page up`;
77+
| h, d, Ctrl+d, PgUp: move one page down
78+
| l, u, Ctrl+u, PgDown: move one page up
79+
| home, end: move to the first and last result`;
7980

8081
export const HELP_FOOTER =
8182
'Not all node_modules are bad! Some applications (like vscode, Discord, etc) need those dependencies to work. If their directory is deleted, the application will probably break (until the dependencies are reinstalled). NPKILL will show you these directories by highlighting them ⚠️';

src/constants/main.constants.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,10 @@ export const VALID_KEYS: string[] = [
5353
'l', // Move page up
5454
'u', // Move page up
5555
'd', // Move page down
56+
'pageup',
57+
'pagedown',
58+
'home', // Move to the first result
59+
'end', // Move to the last result
5660
];
5761

5862
export const BANNER = `----- __ .__.__ .__

src/controller.ts

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -78,6 +78,10 @@ export class Controller {
7878
l: this.moveCursorPageUp.bind(this),
7979
d: this.moveCursorPageDown.bind(this),
8080
u: this.moveCursorPageUp.bind(this),
81+
pageup: this.moveCursorPageUp.bind(this),
82+
pagedown: this.moveCursorPageDown.bind(this),
83+
home: this.moveCursorFirstResult.bind(this),
84+
end: this.moveCursorLastResult.bind(this),
8185

8286
execute(command: string, params: string[]) {
8387
return this[command](params);
@@ -667,6 +671,19 @@ export class Controller {
667671
this.fitScroll();
668672
}
669673

674+
private moveCursorFirstResult(): void {
675+
this.previusCursorPosY = this.getRealCursorPosY();
676+
this.cursorPosY = MARGINS.ROW_RESULTS_START;
677+
this.fitScroll();
678+
}
679+
680+
private moveCursorLastResult(): void {
681+
this.previusCursorPosY = this.getRealCursorPosY();
682+
this.cursorPosY =
683+
MARGINS.ROW_RESULTS_START + this.resultsService.results.length - 1;
684+
this.fitScroll();
685+
}
686+
670687
private fitScroll(): void {
671688
const shouldScrollUp =
672689
this.cursorPosY < MARGINS.ROW_RESULTS_START + this.scroll;

src/interfaces/command-keys.interface.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,5 +8,9 @@ export interface IKeysCommand {
88
l: () => void;
99
d: () => void;
1010
u: () => void;
11+
pageup: () => void;
12+
pagedown: () => void;
13+
home: () => void;
14+
end: () => void;
1115
execute: (command: string, params?: string[]) => number;
1216
}

0 commit comments

Comments
 (0)