mirror of
https://github.com/jtdaugherty/brick.git
synced 2024-12-28 00:12:02 +03:00
CustomKeybindingDemo: improve comments
This commit is contained in:
parent
1ba4c0974d
commit
b0fbd7f638
@ -141,22 +141,31 @@ main :: IO ()
|
|||||||
main = do
|
main = do
|
||||||
args <- getArgs
|
args <- getArgs
|
||||||
|
|
||||||
|
-- If the command line specified the path to an INI file with custom
|
||||||
|
-- bindings, attempt to load it.
|
||||||
(customBindings, customFile) <- case args of
|
(customBindings, customFile) <- case args of
|
||||||
[iniFilePath] -> do
|
[iniFilePath] -> do
|
||||||
result <- K.keybindingsFromFile allKeyEvents sectionName iniFilePath
|
result <- K.keybindingsFromFile allKeyEvents sectionName iniFilePath
|
||||||
case result of
|
case result of
|
||||||
|
-- A section was found and had zero more bindings.
|
||||||
Right (Just bindings) ->
|
Right (Just bindings) ->
|
||||||
return (bindings, Just iniFilePath)
|
return (bindings, Just iniFilePath)
|
||||||
|
|
||||||
|
-- No section was found at all.
|
||||||
Right Nothing -> do
|
Right Nothing -> do
|
||||||
putStrLn $ "Error: found no section " <> show sectionName <> " in " <> show iniFilePath
|
putStrLn $ "Error: found no section " <> show sectionName <> " in " <> show iniFilePath
|
||||||
exitFailure
|
exitFailure
|
||||||
|
|
||||||
|
-- There was some problem parsing the file as an INI
|
||||||
|
-- file.
|
||||||
Left e -> do
|
Left e -> do
|
||||||
putStrLn $ "Error reading keybindings file " <> show iniFilePath <> ": " <> e
|
putStrLn $ "Error reading keybindings file " <> show iniFilePath <> ": " <> e
|
||||||
exitFailure
|
exitFailure
|
||||||
|
|
||||||
_ -> return ([], Nothing)
|
_ -> return ([], Nothing)
|
||||||
|
|
||||||
-- Create a key config that has no customized bindings overriding
|
-- Create a key config that includes the default bindings as well as
|
||||||
-- the default ones.
|
-- the custom bindings we loaded from the INI file, if any.
|
||||||
let kc = K.newKeyConfig allKeyEvents defaultBindings customBindings
|
let kc = K.newKeyConfig allKeyEvents defaultBindings customBindings
|
||||||
|
|
||||||
void $ M.defaultMain app $ St { _keyConfig = kc
|
void $ M.defaultMain app $ St { _keyConfig = kc
|
||||||
|
Loading…
Reference in New Issue
Block a user