calculator 0.2.0.2 → 0.2.0.3
raw patch · 3 files changed
+30/−5 lines, 3 files
Files
- calculator.cabal +2/−1
- src/Calculator/Color.hs +26/−0
- src/Calculator/Help.hs +2/−4
calculator.cabal view
@@ -1,5 +1,5 @@ name: calculator-version: 0.2.0.2+version: 0.2.0.3 synopsis: A calculator repl. description: A calculator repl that processes mathematical expressions. Does basic arithmetic, and provides pre-defined basic mathematical functions.@@ -23,6 +23,7 @@ , Calculator.Evaluator.Func , Calculator.Evaluator.Statement , Calculator.Help+ , Calculator.Color , Calculator.Parser.Base , Calculator.Parser.Cmd , Calculator.Parser.Expr
+ src/Calculator/Color.hs view
@@ -0,0 +1,26 @@+module Calculator.Color+ ( Color (..)+ , color+ , bold+ ) where++--------------------------------------------------------------------------------++data Color = Black | Red | Green | Yellow+ | Blue | Magenta | Cyan | White+ | Reset+ deriving Enum++--------------------------------------------------------------------------------++color :: Color -> Bool -> String -> String+color c b s = let col = show (fromEnum c)+ bol = if b then "1" else "22"+ in "\ESC[" ++ bol ++ ";3" ++ col ++ "m" ++ s ++ "\ESC[0;m"++--------------------------------------------------------------------------------++bold :: String -> String+bold = color Reset True++--------------------------------------------------------------------------------
src/Calculator/Help.hs view
@@ -3,8 +3,7 @@ -------------------------------------------------------------------------------- import Calculator.Color (bold)-import Calculator.Prim.Definitions (binaryOps, defFuns, defVars,- unaryOps)+import Calculator.Prim.Definitions (binaryOps, defFuns, defVars) -------------------------------------------------------------------------------- @@ -20,8 +19,7 @@ , " :reset -- Reset variable and function bindings" , " :show -- Display all variable bindings" , " :? or :help -- Display this help message"- , bold "Unary Operators: " ++ intersperse ' ' (map fst unaryOps)- , bold "Binary Operators: " ++ intersperse ' ' (map fst binaryOps)+ , bold "Supported Operations: " ++ intersperse ' ' (map fst binaryOps) , bold "Pre-defined variables: " ++ intercalate ", " (map fst defVars) , bold "Provided Functions: " , " " ++ intercalate ", " (map fst defFuns)