summaryrefslogtreecommitdiffstats
path: root/test4.hs
diff options
context:
space:
mode:
Diffstat (limited to 'test4.hs')
-rw-r--r--test4.hs10
1 files changed, 10 insertions, 0 deletions
diff --git a/test4.hs b/test4.hs
index f493e6a..b9990a0 100644
--- a/test4.hs
+++ b/test4.hs
@@ -160,6 +160,7 @@ keymap "\ESC[b" = Just $ moveTreeUp 1
keymap "\ESC[5~" = Just $ \q -> moveTreeDown (screenHeight q `div` 2) q -- PgUp
keymap "\ESC[6~" = Just $ \q -> moveTreeUp (screenHeight q `div` 2) q -- PgDn
keymap "\n" = Just toggleFold
+keymap "\DEL" = Just moveToParent -- backspace
keymap ('\ESC':'[':'9':';':xs) = Just $ \q@State{..} -> do
let (h,';':w) = break (==';') (take (length xs - 1) xs) -- ^ drop (assumed) trailing 't'
@@ -213,6 +214,15 @@ moveTreeDown n q@State{..} =
i -> moveCursorUp i q'
+moveToParent q@State{..} =
+ case Z.parent cursor of
+ Nothing -> return q { flashMessage = "cannot go further up" }
+ Just cursor' ->
+ let q' = q { cursor = cursor' }
+ in case topOverrun q' of
+ 0 -> return q'
+ i -> moveTreeDown i q'
+
toggleFold :: State -> IO State
toggleFold q@State{..} = case Z.label cursor of