mirror of
https://github.com/Yvee1/hascard.git
synced 2024-11-22 12:51:58 +03:00
Fix selection after parse error
This commit is contained in:
parent
faaf372441
commit
f5a7d2d844
@ -64,14 +64,14 @@ drawUI State{_fb=b, _exception=exc} = [center $ ui <=> help]
|
||||
borderWithLabel (txt "Choose a file") $
|
||||
renderFileBrowser True b
|
||||
help = padTop (Pad 1) $
|
||||
vBox [ case exc of
|
||||
Nothing -> emptyWidget
|
||||
Just e -> hCenter $ withDefAttr errorAttr $
|
||||
str e
|
||||
, hCenter $ txt "Up/Down: select"
|
||||
vBox [ hCenter $ txt "Up/Down: select"
|
||||
, hCenter $ txt "/: search, Ctrl-C or Esc: cancel search"
|
||||
, hCenter $ txt "Enter: change directory or select file"
|
||||
, hCenter $ txt "Esc: quit"
|
||||
, case exc of
|
||||
Nothing -> emptyWidget
|
||||
Just e -> hCenter $ withDefAttr errorAttr $
|
||||
str e
|
||||
]
|
||||
|
||||
handleEvent :: State -> BrickEvent Name Event -> EventM Name (Next State)
|
||||
@ -96,7 +96,7 @@ handleEvent s@State{_fb=b} (VtyEvent ev) =
|
||||
case fileOrExc of
|
||||
Left exc -> continue (s' & exception ?~ displayException exc)
|
||||
Right file -> case parseCards file of
|
||||
Left parseError -> continue (s' & exception ?~ show parseError)
|
||||
Left parseError -> continue (s & exception ?~ show parseError)
|
||||
Right result -> halt (s' & cards .~ result & filePath ?~ fp)
|
||||
_ -> halt s'
|
||||
|
||||
|
@ -28,7 +28,7 @@ uncurry3 f (a, b, c) = f a b c
|
||||
parseCards :: String -> Either ParseError [Card]
|
||||
parseCards = parse pCards "failed when parsing cards"
|
||||
|
||||
pCards = pCard `sepEndBy` seperator
|
||||
pCards = pCard `sepEndBy1` seperator
|
||||
pCard = uncurry3 MultipleChoice<$> try pMultChoice
|
||||
<|> uncurry MultipleAnswer <$> try pMultAnswer
|
||||
<|> uncurry OpenQuestion <$> try pOpen
|
||||
|
Loading…
Reference in New Issue
Block a user