hascard 0.5.0.1 → 0.5.0.2
raw patch · 7 files changed
+36/−13 lines, 7 filesPVP: major bump suggested
API removals or changes: PVP suggests a major version bump
API changes (from Hackage documentation)
+ Settings: getCaseSensitive :: IO Bool
+ States: CaseSensitiveField :: Name
+ States: [_caseSensitive] :: Settings -> Bool
+ States: [_isCaseSensitive] :: CS -> Bool
+ States: caseSensitive :: Lens' Settings Bool
+ States: isCaseSensitive :: Lens' CS Bool
- States: CS :: [Card] -> Int -> Int -> Card -> CardState -> Bool -> Bool -> Bool -> [Int] -> Maybe (Popup CS) -> FilePath -> CS
+ States: CS :: [Card] -> Int -> Int -> Card -> CardState -> Bool -> Bool -> Bool -> Bool -> [Int] -> Maybe (Popup CS) -> FilePath -> CS
- States: FormState :: Bool -> Bool -> Bool -> Int -> Settings
+ States: FormState :: Bool -> Bool -> Bool -> Bool -> Int -> Settings
- States: popupState :: forall s_aeEk. Lens' (Popup s_aeEk) PopupState
+ States: popupState :: forall s_aeGD. Lens' (Popup s_aeGD) PopupState
Files
- ChangeLog.md +7/−0
- README.md +7/−7
- hascard.cabal +2/−2
- src/Runners.hs +2/−0
- src/Settings.hs +7/−1
- src/States.hs +3/−0
- src/UI/Cards.hs +8/−3
ChangeLog.md view
@@ -1,4 +1,11 @@ # Changelog for hascard+##+New:+- Setting for changing case sensitivity of open questions. Default behaviour is case sensitive, which was also the functionality before this setting was added.++Fixed bug:+- When the open question was gotten right after the first try, it was still counted as correct in review mode+ ## 0.5.0.1 Fixed bugs: - When generating new decks from correct or incorrect cards, 'Nothing' was added as the first line
README.md view
@@ -20,7 +20,7 @@ - [Open question](#open-question) - [Reorder question](#reorder-question) - [Including files](#including-files)- - [LaTeX](#latex)+ - [LaTeX (experimental)](#latex-experimental) - [Miscellaneous info](#miscellaneous-info) @@ -59,9 +59,9 @@ After finishing a deck, there is an option to create new decks from the correctly answered or incorrectly answered cards, or both. The correct cards of a file named `deck.txt` are stored in `deck+.txt` in the same folder, and the incorrect ones in the file `deck-.txt`. Make sure you do not have files of those names that you want to keep since these _will_ be overwritten. ### CLI-The CLI provides two commands, `run` and `import`. The `hascard run` is essentially the same as just `hascard`, but the `run` command can be given a file to run the application on directly. Instead of specifying the parameters in a menu, they are CLI options.+The CLI provides two commands, `run` and `import`. The `hascard run` is essentially the same as just `hascard`, but the `run` command can be given a file to run the application on directly. When run on a file directly, parameters like whether to shuffle the deck are specified via CLI options instead of in a menu. -As an example, say you have a file `deck.txt` with lots of cards in it and you want to review 5 random ones, you can use `hascard run deck -s -a 5`. Here `-s` shuffles the deck and `-a 5` specifies we only want to look at 5 of them.+As an example, say you have a file `deck.txt` with lots of cards in it and you want to review 5 random ones, you can use `hascard run deck -s -a 5`. Here `-s` shuffles the deck and `-a 5` specifies we only want to look at 5 of them. For more info, see `hascard run --help`. #### Importing decks If you have decks in a different format, you might want to convert them into files compatible with hascard. Currently tab-seperated files can be converted to definition or open question cards. For example [Quizlet](https://quizlet.com/) decks can be exported to this format. As an example, the following file@@ -84,7 +84,7 @@ with the command `hascard import input.txt output.txt -r`. More info can be found in the help text at `hascard import --help`. ## Cards-Decks of cards are written in `.txt` or `.md` files. Cards are seperated with a line containing three dashes `---`. For examples, see the [`/cards`](https://github.com/Yvee1/hascard/tree/master/cards) directory. +Decks of cards are written in `.txt` or `.md` files. A deck contains multiple cards which are seperated with a line containing three dashes `---`. For examples, see the [`/cards`](https://github.com/Yvee1/hascard/tree/master/cards) directory. ### Card Types In this section the 5 different types of cards are listed, first the text representation is given and after a gif of it is represented in the application.@@ -117,7 +117,7 @@ </p> #### Multiple answer-Multiple choice questions with multiple possible answers is also possible. Here again the question starts with `#` and the options follow. Preceding each option is a box `[ ]` that is filled with a `*` or a `x` if it is correct. For example+Multiple choice questions with multiple possible answers are also available. Here again the question starts with `#` and the options follow. Preceding each option is a box `[ ]` that is filled with a `*` or a `x` if it is correct. For example ``` # Multiple answer question@@ -170,9 +170,9 @@ - Orange - Banana ```-references the image `pear.jpeg` in the directory of the text file containing the cards. Files can be added to any of the previously listed card types.+references the image `pear.jpeg` in the directory of the text file containing the cards. Files can be added to any of the previously listed card types. Text in the square brackets which in markdown is used for providing alt-text has no function at the moment. -#### LaTeX+#### LaTeX (experimental) For reviewing content with mathematical symbols, functionality is included such that LaTeX can be used. Because LaTeX cannot be rendered in the terminal directly, it is first converted to a pdf file with the `pdflatex` command (the pdf is placed in a temporary directory), and then opened in the default pdf viewer application as if the pdf were included directly like mentioned above. LaTeX can be written between three backticks, and should be placed right below the header. For example, the card `````` # The l^p metric space
hascard.cabal view
@@ -4,10 +4,10 @@ -- -- see: https://github.com/sol/hpack ----- hash: 1d4e635de828a7e15a8bd625beef9e07cce44188802eeaeece13d342c4d94a2b+-- hash: 37031709ac5e49c9833f7bc7e63a8db75834eda98879221fc1968c2e15fb231d name: hascard-version: 0.5.0.1+version: 0.5.0.2 synopsis: A TUI for reviewing notes using 'flashcards' written with markdown-like syntax. description: Hascard is a text-based user interface for reviewing notes using flashcards. Cards are written in markdown-like syntax. Please see the README file on GitHub at <https://github.com/Yvee1/hascard#readme> for more information. category: Application
src/Runners.hs view
@@ -46,6 +46,7 @@ cardsState doReview fp deck = do hints <- getShowHints controls <- getShowControls+ caseSensitive <- getCaseSensitive let mFirstCard = safeHead deck firstCard = fromMaybe (Definition "Empty deck" Nothing "Click enter to go back.") mFirstCard@@ -59,6 +60,7 @@ , _nCards = length deck' , _showHints = hints , _showControls = controls+ , _isCaseSensitive = caseSensitive , _reviewMode = maybe False (const doReview) mFirstCard , _correctCards = [] , _popup = Nothing
src/Settings.hs view
@@ -24,6 +24,11 @@ settings <- getSettings return $ settings ^. controls +getCaseSensitive :: IO Bool+getCaseSensitive = do+ settings <- getSettings+ return $ settings ^. caseSensitive+ getUseEscapeCode :: IO Bool getUseEscapeCode = do settings <- getSettings@@ -60,7 +65,7 @@ return (dir </> "settings") defaultSettings :: Settings-defaultSettings = FormState { _hints=False, _controls=True, _escapeCode=False, _maxRecents=5}+defaultSettings = FormState { _hints=False, _controls=True, _caseSensitive=True, _escapeCode=False, _maxRecents=5} setSettings :: Settings -> IO () setSettings settings = do@@ -77,6 +82,7 @@ in newForm [ label "Draw hints using underscores for definition cards" @@= yesnoField False hints HintsField "" , label "Show controls at the bottom of screen" @@= yesnoField False controls ControlsField ""+ , label "Open questions are case sensitive" @@= yesnoField False caseSensitive CaseSensitiveField "" , label "Use the '-n \\e[5 q' escape code to change the cursor to a blinking line on start" @@= yesnoField False escapeCode EscapeCodeField "" , label "Maximum number of recently selected files stored" @@= naturalNumberField 999 maxRecents MaxRecentsField "" ]
src/States.hs view
@@ -19,6 +19,7 @@ -- Settings HintsField | ControlsField+ | CaseSensitiveField | EscapeCodeField | MaxRecentsField @@ -135,6 +136,7 @@ , _cardState :: CardState , _showHints :: Bool , _showControls :: Bool+ , _isCaseSensitive :: Bool , _reviewMode :: Bool , _correctCards :: [Int] -- list of indices of correct cards , _popup :: Maybe (Popup CS)@@ -172,6 +174,7 @@ data Settings = FormState { _hints :: Bool , _controls :: Bool+ , _caseSensitive :: Bool , _escapeCode :: Bool , _maxRecents :: Int } deriving (Read, Show)
src/UI/Cards.hs view
@@ -7,7 +7,7 @@ import Types import States import StateManagement-import Data.Char (isSpace)+import Data.Char (isSpace, toLower) import Data.List.NonEmpty (NonEmpty) import Data.Map.Strict (Map) import Data.Maybe@@ -359,11 +359,16 @@ then if fail then next gs s else next gs (s & correctCards %~ (s^.index:))- else continue' s'+ else continue' s'' where sentence = perforatedToSentence perforated gaps = sentenceToGaps sentence - s' = s & (cardState.correctGaps) %~ M.mapWithKey (\j _ -> M.findWithDefault "" j kvs `elem` gaps !! j)+ wordIsCorrect :: String -> NonEmpty String -> Bool+ wordIsCorrect = if s^.isCaseSensitive+ then elem+ else (\word possibilites -> map toLower word `elem` NE.map (map toLower) possibilites)++ s' = s & (cardState.correctGaps) %~ M.mapWithKey (\j _ -> M.findWithDefault "" j kvs `wordIsCorrect` (gaps !! j)) & (cardState.entered) .~ True s'' = if M.foldr (&&) True (s' ^. cardState.correctGaps)