diff --git a/src/components/client/keys.ts b/src/components/client/keys.ts index 10b1291..5e41727 100644 --- a/src/components/client/keys.ts +++ b/src/components/client/keys.ts @@ -8,8 +8,8 @@ interface EnterArgs { readonly closure: InputClosure } interface Keys { - enter: (input: EnterArgs) => void, - up_arrow: (ps1input: HTMLInputElement) => void, + enter: (input: EnterArgs) => void, + up_arrow: (ps1input: HTMLInputElement) => void, down_arrow: (ps1input: HTMLInputElement) => void, } diff --git a/src/components/client/shell/command/list.ts b/src/components/client/shell/command/list.ts index 7a90e46..c249740 100644 --- a/src/components/client/shell/command/list.ts +++ b/src/components/client/shell/command/list.ts @@ -1,4 +1,4 @@ -import history_cmd from "./builtin/history" +import history from "./builtin/history" import clear from "./builtin/clear" import pwd from "./builtin/pwd" import cat from "./builtin/cat" @@ -8,12 +8,13 @@ import ls from "./builtin/ls" type Term = HTMLElement type Args = string[] type Command = (term: Term, args: Args) => boolean + interface CommandsList { [index: string]: Command, } const commands: CommandsList = { - ["history"]: history_cmd, + ["history"]: history, ["clear"]: clear, ["pwd"]: pwd, ["cat"]: cat, diff --git a/src/components/client/shell/history.ts b/src/components/client/shell/history.ts index 1a50eaa..95a383b 100644 --- a/src/components/client/shell/history.ts +++ b/src/components/client/shell/history.ts @@ -4,9 +4,9 @@ interface HistoryFile { cursor_reset: () => void } interface History { - file: HistoryFile - add: (cmd: string) => void, - index_up: (ps1input: HTMLInputElement) => void, + file: HistoryFile + add: (cmd: string) => void, + index_up: (ps1input: HTMLInputElement) => void, index_down: (ps1input: HTMLInputElement) => void } @@ -36,7 +36,7 @@ history.index_down = function(ps1input: HTMLInputElement) { if (this.file.cursor!==0) { this.file.cursor-=1 if (this.file.cursor!==0) { - const item = this.file.inner[this.file.cursor] + const item = this.file.inner[this.file.cursor-1] if (item) { ps1input.value = item } } else { this.file.cursor_reset()