mirror of
https://github.com/vale981/tridactyl
synced 2025-03-06 01:51:40 -05:00
Add rudimentary tab completion from history to CLI
This commit is contained in:
parent
c2e744ec11
commit
15b6ec76cd
1 changed files with 24 additions and 0 deletions
|
@ -42,6 +42,23 @@ clInput.addEventListener("keydown", function (keyevent) {
|
|||
// should probably just defer to another library
|
||||
case "c":
|
||||
if (keyevent.ctrlKey) hide_and_clear()
|
||||
break
|
||||
|
||||
case "f":
|
||||
if (keyevent.ctrlKey){
|
||||
// Stop ctrl+f from doing find
|
||||
keyevent.preventDefault()
|
||||
keyevent.stopPropagation()
|
||||
tabcomplete()
|
||||
}
|
||||
break
|
||||
|
||||
case "Tab":
|
||||
// Stop tab from losing focus
|
||||
keyevent.preventDefault()
|
||||
keyevent.stopPropagation()
|
||||
tabcomplete()
|
||||
break
|
||||
|
||||
}
|
||||
})
|
||||
|
@ -59,6 +76,13 @@ function hide_and_clear(){
|
|||
sendExstr("hidecmdline")
|
||||
}
|
||||
|
||||
function tabcomplete(){
|
||||
let fragment = clInput.value
|
||||
let matches = state.cmdHistory.filter((key)=>key.startsWith(fragment))
|
||||
let mostrecent = matches[matches.length - 1]
|
||||
if (mostrecent != undefined) clInput.value = mostrecent
|
||||
}
|
||||
|
||||
function history(n){
|
||||
completions.innerHTML = ""
|
||||
if (cmdline_history_position == 0){
|
||||
|
|
Loading…
Add table
Reference in a new issue