Implement shift+tab to move up a level
This commit is contained in:
parent
3e4e64c2b6
commit
cb477bfcfc
1 changed files with 19 additions and 0 deletions
|
|
@ -55,6 +55,11 @@ func (s *State) SetSearchText(val string) {
|
|||
}
|
||||
}
|
||||
func (s *State) SetCurrentDir(val string) {
|
||||
if val == "." {
|
||||
if q, err := os.Getwd(); err == nil {
|
||||
val = q
|
||||
}
|
||||
}
|
||||
if s.CurrentDir() != val {
|
||||
s.search_text = ""
|
||||
s.current_idx = 0
|
||||
|
|
@ -152,6 +157,20 @@ func (h *Handler) OnKeyEvent(ev *loop.KeyEvent) (err error) {
|
|||
}
|
||||
}
|
||||
h.lp.Beep()
|
||||
case ev.MatchesPressOrRepeat("shift+tab"):
|
||||
curr := h.state.CurrentDir()
|
||||
switch curr {
|
||||
case "/":
|
||||
case ".":
|
||||
if curr, err = os.Getwd(); err == nil && curr != "/" {
|
||||
h.state.SetCurrentDir(filepath.Dir(curr))
|
||||
return h.draw_screen()
|
||||
}
|
||||
default:
|
||||
h.state.SetCurrentDir(filepath.Dir(curr))
|
||||
return h.draw_screen()
|
||||
}
|
||||
h.lp.Beep()
|
||||
}
|
||||
return
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in a new issue