slate 0.2.0.0 → 0.3.0.0
raw patch · 4 files changed
+40/−7 lines, 4 filesPVP ok
version bump matches the API change (PVP)
API changes (from Hackage documentation)
+ AnsiStyle: instance GHC.Show.Show AnsiStyle.Style
+ AnsiStyle: instance GHC.Show.Show AnsiStyle.Text
+ AnsiStyle: toAnsi :: String -> String
Files
- README.md +3/−3
- slate.cabal +3/−2
- src/AnsiStyle.hs +30/−0
- src/Lib.hs +4/−2
README.md view
@@ -9,7 +9,7 @@ ## Install ```shell-$ stack install+$ stack install slate ``` ## Usage@@ -34,10 +34,10 @@ rename Rename a slate. wipe Wipe a slate. -$ slate add "My first note."+$ slate add "My *first* note." $ slate add "New note!" $ slate display-00 - My first note.+00 - My <b>first</b> note. 01 - New note! $ slate done 0
slate.cabal view
@@ -2,10 +2,10 @@ -- -- see: https://github.com/sol/hpack ----- hash: 0c4dd43c3f2d0caa98d5db89c38d2085527502780a7656087a24d835af4321e8+-- hash: 0ed91232973ab0351a59fb06271930c070cbac5157ada7dacfc9a1f51bb3e185 name: slate-version: 0.2.0.0+version: 0.3.0.0 synopsis: A note taking CLI tool. description: Please see the README on Github at <https://github.com/evuez/slate#readme> homepage: https://github.com/evuez/slate#readme@@ -35,6 +35,7 @@ , filepath >=1.4 , optparse-applicative >=0.14 exposed-modules:+ AnsiStyle Lib other-modules: Paths_slate
+ src/AnsiStyle.hs view
@@ -0,0 +1,30 @@+module AnsiStyle+ ( toAnsi+ ) where++data Style+ = Normal+ | Emphasized+ deriving (Show)++data Text = Text+ { style :: Style+ , parsed :: String+ , rest :: String+ } deriving (Show)++getStyle :: Style -> Char -> (Style, String)+getStyle Normal '*' = (Emphasized, "\x1B[1m")+getStyle Normal '_' = (Emphasized, "\x1B[1m")+getStyle Emphasized '*' = (Normal, "\x1B[0m")+getStyle Emphasized '_' = (Normal, "\x1B[0m")+getStyle s c = (s, [c])++toAnsi :: String -> String+toAnsi s = parsed $ parseNote $ Text Normal [] s++parseNote :: Text -> Text+parseNote (Text s p (c:t)) = do+ let (s1, c1) = getStyle s c+ parseNote $ Text s1 (p ++ c1) t+parseNote (Text s p ([])) = Text s p []
src/Lib.hs view
@@ -4,6 +4,7 @@ , parser ) where +import AnsiStyle (toAnsi) import Data.Semigroup ((<>)) import Options.Applicative import System.Directory@@ -144,9 +145,10 @@ displaySlate _ f = putStr $ "\"" ++ f ++ "\" is not a valid filter." displayNote :: Int -> String -> String-displayNote line (' ':'-':' ':'[':' ':']':note) = padInt line 2 ++ " -" ++ note+displayNote line (' ':'-':' ':'[':' ':']':note) =+ padInt line 2 ++ " -" ++ (toAnsi note) displayNote line (' ':'-':' ':'[':'x':']':note) =- "\x1B[9m" ++ padInt line 2 ++ " -" ++ note ++ "\x1B[0m"+ "\x1B[9m" ++ padInt line 2 ++ " -" ++ (toAnsi note) ++ "\x1B[0m" displayNote line _ = "\x1B[31m" ++ padInt line 2 ++ " - Parsing error: line is malformed" ++ "\x1B[0m"