added ^O to commands

This commit is contained in:
Armin Friedl 2016-08-09 00:44:32 +02:00
parent 3abab0ec68
commit 21567d6a15

View file

@ -99,6 +99,7 @@ drawUI st = vBox [titleBar, title, titleBar, commands] : [editWidget]
where editWidget = padTop (Pad 4) $ EditWidget.renderEditor True (st^.hedit) where editWidget = padTop (Pad 4) $ EditWidget.renderEditor True (st^.hedit)
hBorder = BorderWidgets.hBorder hBorder = BorderWidgets.hBorder
commands = withAttr (attrName "commands") $ padLeft Max $ hBox [ str "^O...Open" commands = withAttr (attrName "commands") $ padLeft Max $ hBox [ str "^O...Open"
, str ""
, str "^S...Save" , str "^S...Save"
, str "" , str ""
, str "^C/Esc...Quit " , str "^C/Esc...Quit "
@ -127,7 +128,7 @@ appEvent st ev
forwardToWidget = handleEventLensed st hedit EditWidget.handleEditorEvent ev forwardToWidget = handleEventLensed st hedit EditWidget.handleEditorEvent ev
tab = Vty.EvKey (Vty.KChar '\t') [] tab = Vty.EvKey (Vty.KChar '\t') []
insertFourSpaces = return $ insertString (replicate 4 ' ') st insertFourSpaces = return $ insertString (replicate 4 ' ') st
askForFileAndOpen = suspendAndResume $ do askForFileAndOpen = BrickMain.suspendAndResume $ do
putStrLn "Please enter file path: " putStrLn "Please enter file path: "
f <- getLine f <- getLine
exists <- doesFileExist f exists <- doesFileExist f
@ -135,7 +136,6 @@ appEvent st ev
return $ st & file .~ f return $ st & file .~ f
& hedit .~ EditWidget.editor Hedit drawHeditText Nothing content & hedit .~ EditWidget.editor Hedit drawHeditText Nothing content
-- just don't ask what this does --- inserts a string, returns the state. end of story. -- just don't ask what this does --- inserts a string, returns the state. end of story.
insertString :: String -> HeditState -> HeditState insertString :: String -> HeditState -> HeditState
insertString string st = st & hedit %~ insertString' string -- uses some fancy lense magic insertString string st = st & hedit %~ insertString' string -- uses some fancy lense magic