rewrite-inspector 0.1.0.2 → 0.1.0.3
raw patch · 5 files changed
+43/−18 lines, 5 filesPVP: major bump suggested
API removals or changes: PVP suggests a major version bump
API changes (from Hackage documentation)
- Gen: annStyles :: Diff term => [(String, Attr)]
+ Gen: Custom :: String -> Syntax
+ Gen: Keyword :: Syntax
+ Gen: Literal :: Syntax
+ Gen: Qualifier :: Syntax
+ Gen: Type :: Syntax
+ Gen: Unique :: Syntax
+ Gen: data Syntax
+ Gen: instance GHC.Show.Show Gen.Syntax
+ Gen: userStyles :: Diff term => [(String, Attr)]
- Gen: after :: forall term_addE ctx_addF. Lens' (HStep term_addE ctx_addF) term_addE
+ Gen: after :: forall term_adqT ctx_adqU. Lens' (HStep term_adqT ctx_adqU) term_adqT
- Gen: before :: forall term_addE ctx_addF. Lens' (HStep term_addE ctx_addF) term_addE
+ Gen: before :: forall term_adqT ctx_adqU. Lens' (HStep term_adqT ctx_adqU) term_adqT
- Gen: bndrS :: forall term_addE ctx_addF. Lens' (HStep term_addE ctx_addF) String
+ Gen: bndrS :: forall term_adqT ctx_adqU. Lens' (HStep term_adqT ctx_adqU) String
- Gen: ctx :: forall term_addE ctx_addF ctx_ajCS. Lens (HStep term_addE ctx_addF) (HStep term_addE ctx_ajCS) [ctx_addF] [ctx_ajCS]
+ Gen: ctx :: forall term_adqT ctx_adqU ctx_ajEd. Lens (HStep term_adqT ctx_adqU) (HStep term_adqT ctx_ajEd) [ctx_adqU] [ctx_ajEd]
- Gen: handleAnn :: (Diff term, Ann term ~ Ctx term) => Ann term -> Either String (Ctx term)
+ Gen: handleAnn :: (Diff term, Ann term ~ Ctx term) => Ann term -> Either Syntax (Ctx term)
- Gen: name :: forall term_addE ctx_addF. Lens' (HStep term_addE ctx_addF) String
+ Gen: name :: forall term_adqT ctx_adqU. Lens' (HStep term_adqT ctx_adqU) String
- Types: binders :: forall term_ao48. Lens' (VizStates term_ao48) [Binder]
+ Types: binders :: forall term_aobI. Lens' (VizStates term_aobI) [Binder]
- Types: curBinder :: forall term_ao48. Lens' (VizStates term_ao48) Binder
+ Types: curBinder :: forall term_aobI. Lens' (VizStates term_aobI) Binder
- Types: curExpr :: forall term_ao1N. Lens' (VizState term_ao1N) term_ao1N
+ Types: curExpr :: forall term_ao9n. Lens' (VizState term_ao9n) term_ao9n
- Types: curStep :: forall term_ao1N. Lens' (VizState term_ao1N) Int
+ Types: curStep :: forall term_ao9n. Lens' (VizState term_ao9n) Int
- Types: form :: forall term_ao48. Lens' (VizStates term_ao48) (Form (OptionsUI term_ao48) NoCustomEvent Name)
+ Types: form :: forall term_aobI. Lens' (VizStates term_aobI) (Form (OptionsUI term_aobI) NoCustomEvent Name)
- Types: height :: forall term_ao48. Lens' (VizStates term_ao48) Int
+ Types: height :: forall term_aobI. Lens' (VizStates term_aobI) Int
- Types: opts :: forall term_anTG term_ao1w. Lens (OptionsUI term_anTG) (OptionsUI term_ao1w) (Options term_anTG) (Options term_ao1w)
+ Types: opts :: forall term_ao1g term_ao96. Lens (OptionsUI term_ao1g) (OptionsUI term_ao96) (Options term_ao1g) (Options term_ao96)
- Types: prevState :: forall term_ao1N. Lens' (VizState term_ao1N) (Maybe (VizState term_ao1N))
+ Types: prevState :: forall term_ao9n. Lens' (VizState term_ao9n) (Maybe (VizState term_ao9n))
- Types: scroll :: forall term_ao48. Lens' (VizStates term_ao48) Bool
+ Types: scroll :: forall term_aobI. Lens' (VizStates term_aobI) Bool
- Types: showBot :: forall term_ao48. Lens' (VizStates term_ao48) Bool
+ Types: showBot :: forall term_aobI. Lens' (VizStates term_aobI) Bool
- Types: states :: forall term_ao48. Lens' (VizStates term_ao48) (Map Binder (VizState term_ao48))
+ Types: states :: forall term_aobI. Lens' (VizStates term_aobI) (Map Binder (VizState term_aobI))
- Types: steps :: forall term_ao1N. Lens' (VizState term_ao1N) (History term_ao1N (Ctx term_ao1N))
+ Types: steps :: forall term_ao9n. Lens' (VizState term_ao9n) (History term_ao9n (Ctx term_ao9n))
- Types: trans :: forall term_anTG. Lens' (OptionsUI term_anTG) Trans
+ Types: trans :: forall term_ao1g. Lens' (OptionsUI term_ao1g) Trans
- Types: width :: forall term_ao48. Lens' (VizStates term_ao48) Int
+ Types: width :: forall term_aobI. Lens' (VizStates term_aobI) Int
Files
- README.md +1/−1
- rewrite-inspector.cabal +1/−1
- src/BrickUI.hs +1/−1
- src/Gen.hs +26/−7
- src/Pretty.hs +14/−8
README.md view
@@ -8,4 +8,4 @@ must be an instance of the `Diff` typeclass (see `app/Main.hs` for an example). -+Available on [](http://hackage.haskell.org/package/rewrite-inspector)
rewrite-inspector.cabal view
@@ -1,5 +1,5 @@ name: rewrite-inspector-version: 0.1.0.2+version: 0.1.0.3 cabal-version: >=1.10 build-type: Simple license: BSD3
src/BrickUI.hs view
@@ -32,7 +32,7 @@ -- | Entry point. runTerminal :: forall term. Diff term => FilePath -> IO () runTerminal ftheme = do- res <- loadCustomizations ftheme (defaultTheme $ annStyles @term)+ res <- loadCustomizations ftheme (defaultTheme $ userStyles @term) case res of Left err -> error $ "[theme.ini] Configuration file is malformed: " ++ err
src/Gen.hs view
@@ -18,7 +18,27 @@ import qualified Graphics.Vty as V --------------------------------+--------------------------------------------------+-- Syntactic annotations used for highlighting.++data Syntax+ = Type -- ^ type information+ | Keyword -- ^ standard keywords of the language+ | Literal -- ^ literal values (e.g. strings, numbers)+ | Unique -- ^ unique identifiers+ | Qualifier -- ^ qualifiers for modules+ | Custom String -- ^ used for user-supplied styling++instance Show Syntax where+ show = \case+ Type -> "type"+ Keyword -> "keyword"+ Literal -> "literal"+ Unique -> "unique"+ Qualifier -> "qualifier"+ Custom s -> s++-------------------------------------------------- -- Generic interface. class Eq (Ctx term) => Diff term where@@ -38,13 +58,13 @@ topEntity :: String topEntity = "top" - handleAnn :: Ann term -> Either String (Ctx term)+ handleAnn :: Ann term -> Either Syntax (Ctx term) - default handleAnn :: Ann term ~ Ctx term => Ann term -> Either String (Ctx term)+ default handleAnn :: Ann term ~ Ctx term => Ann term -> Either Syntax (Ctx term) handleAnn = Right - annStyles :: [(String, V.Attr)]- annStyles = []+ userStyles :: [(String, V.Attr)]+ userStyles = [] initOptions :: Options term @@ -61,8 +81,7 @@ patch :: term -> [Ctx term] -> term -> term ----------------------------------+-------------------------------------------------- -- History datatype. type History term ctx = [HStep term ctx]
src/Pretty.hs view
@@ -49,6 +49,11 @@ . ppr' @term opts -- Convert a stream into our simpler data type.+data MyDoc = MChar Char+ | MString String+ | MLine Int+ | MMod [String] MyDoc+ data Item = Stx | Ctx myForm :: forall term. Diff term@@ -61,7 +66,7 @@ SText _ s rest -> mark (MString (unpack s)) : continueWith rest SLine i rest -> MLine i : continueWith rest SAnnPush a rest -> case handleAnn @term a of- Left s -> myForm @term ctx0 ctx' (Stx:stack) (s:attrs) rest+ Left s -> myForm @term ctx0 ctx' (Stx:stack) (show s:attrs) rest Right c -> myForm @term ctx0 (ctx' ++ [c]) (Ctx:stack) attrs rest SAnnPop rest -> case top of Stx -> myForm @term ctx0 ctx' stack' (tail attrs) rest@@ -70,11 +75,6 @@ where continueWith = myForm @term ctx0 ctx' stack attrs mark = MMod $ ["focus" | ctx0 `isPrefixOf` ctx'] ++ attrs -data MyDoc = MChar Char- | MString String- | MLine Int- | MMod [String] MyDoc- -- Split into individual lines (of some indendation). split :: [MyDoc] -> [(Int, [MyDoc])] split [] = []@@ -96,7 +96,7 @@ -- UI Styling. defaultTheme :: [(String, V.Attr)] -> Bt.Theme-defaultTheme userStyles = Bt.newTheme V.defAttr $+defaultTheme userTheme = Bt.newTheme V.defAttr $ [ ("focus", B.bg $ V.rgbColor 47 79 79) , ("title", V.defAttr `V.withStyle` V.bold) , ("emph", V.defAttr `V.withStyle` V.bold)@@ -106,7 +106,13 @@ , (E.editFocusedAttr, V.black `B.on` V.yellow) , (Bf.invalidFormInputAttr, V.white `B.on` V.red) , (Bf.focusedFormInputAttr, V.black `B.on` V.yellow)- ] ++ map (\(s, a) -> (B.attrName s, a)) userStyles+ -- syntax highlighting+ , ("type", V.defAttr `V.withForeColor` V.brightYellow)+ , ("keyword", V.defAttr `V.withForeColor` V.rgbColor 255 165 0)+ , ("literal", V.defAttr `V.withForeColor` V.brightCyan)+ , ("unique", V.defAttr `V.withStyle` V.dim)+ , ("qualifier", V.defAttr `V.withStyle` V.italic)+ ] ++ map (\(s, a) -> (B.attrName s, a)) userTheme modify :: Bool -> [String] -> Widget n -> Widget n modify scroll = foldr (.) id . fmap mod1 . sortOn (\case "Type" -> 1; _ -> 0)