From c58819a7d69c981732305d47a896b77e57bbb250 Mon Sep 17 00:00:00 2001 From: Mark Date: Sat, 29 Oct 2022 15:43:59 -0700 Subject: [PATCH] Cleaned up style --- lamb/commands.py | 32 +++++++++++++++++--------------- lamb/utils.py | 5 +---- 2 files changed, 18 insertions(+), 19 deletions(-) diff --git a/lamb/commands.py b/lamb/commands.py index c3bf146..949943a 100644 --- a/lamb/commands.py +++ b/lamb/commands.py @@ -36,7 +36,7 @@ def cmd_save(command, runner) -> None: if len(command.args) != 1: printf( HTML( - f"Command :{command.name} takes exactly one argument." + f"Command :{command.name} takes exactly one argument." ), style = lamb.utils.style ) @@ -67,7 +67,7 @@ def cmd_save(command, runner) -> None: printf( HTML( - f"Wrote {len(runner.macro_table)} macros to {target}" + f"Wrote {len(runner.macro_table)} macros to {target}" ), style = lamb.utils.style ) @@ -81,7 +81,7 @@ def cmd_load(command, runner): if len(command.args) != 1: printf( HTML( - f"Command :{command.name} takes exactly one argument." + f"Command :{command.name} takes exactly one argument." ), style = lamb.utils.style ) @@ -108,9 +108,9 @@ def cmd_load(command, runner): printf( FormattedText([ ("class:warn", f"Syntax error on line {i+1:02}: "), - ("class:cmd_code", l[:e.loc]), + ("class:code", l[:e.loc]), ("class:err", l[e.loc]), - ("class:cmd_code", l[e.loc+1:]) + ("class:code", l[e.loc+1:]) ]), style = lamb.utils.style ) @@ -120,7 +120,7 @@ def cmd_load(command, runner): printf( FormattedText([ ("class:warn", f"Skipping line {i+1:02}: "), - ("class:cmd_code", l), + ("class:code", l), ("class:warn", f" is not a macro definition.") ]), style = lamb.utils.style @@ -132,7 +132,7 @@ def cmd_load(command, runner): printf( FormattedText([ ("class:ok", f"Loaded {x.label}: "), - ("class:cmd_code", str(x.expr)) + ("class:code", str(x.expr)) ]), style = lamb.utils.style ) @@ -145,7 +145,7 @@ def mdel(command, runner) -> None: if len(command.args) != 1: printf( HTML( - f"Command :{command.name} takes exactly one argument." + f"Command :{command.name} takes exactly one argument." ), style = lamb.utils.style ) @@ -172,7 +172,7 @@ def macros(command, runner) -> None: ("class:cmd_h", "\nDefined Macros:\n"), ] + [ - ("class:cmd_text", f"\t{name} \t {exp}\n") + ("class:text", f"\t{name} \t {exp}\n") for name, exp in runner.macro_table.items() ]), style = lamb.utils.style @@ -209,7 +209,7 @@ def rlimit(command, runner) -> None: elif len(command.args) != 1: printf( HTML( - f"Command :{command.name} takes exactly one argument." + f"Command :{command.name} takes exactly one argument." ), style = lamb.utils.style ) @@ -262,25 +262,27 @@ def rlimit(command, runner) -> None: def help(command, runner) -> None: printf( HTML( - "\n" + + "\n" + "Usage:" + "\n" + "\tWrite lambda expressions using your \\ key." + "\n" + - "\tMacros can be defined using =, as in T = λab.a" + + "\tMacros can be defined using =, as in T = λab.a" + "\n" + - "\tRun commands using :, for example :help" + + "\tRun commands using :, for example :help" + + "\n" + + "\tHistory can be accessed with $, which will expand to the result of the last successful reduction." + "\n\n" + "Commands:"+ "\n" + "\n".join([ - f"\t{name} \t {text}" + f"\t{name} \t {text}" for name, text in help_texts.items() ]) + "\n\n" "Detailed documentation can be found on this project's git page." + - "" + "" ), style = lamb.utils.style ) \ No newline at end of file diff --git a/lamb/utils.py b/lamb/utils.py index 722bd56..9a0f84e 100644 --- a/lamb/utils.py +++ b/lamb/utils.py @@ -11,6 +11,7 @@ style = Style.from_dict({ # type: ignore "err": "#FF0000", "prompt": "#00FFFF", "ok": "#B4EC85", + "code": "#AAAAAA italic", "muted": "#AAAAAA", # Syntax @@ -23,12 +24,8 @@ style = Style.from_dict({ # type: ignore # Command formatting # cmd_h: section titles - # cmd_code: example snippets - # cmd_text: regular text # cmd_key: keyboard keys, usually one character "cmd_h": "#FF6600 bold", - "cmd_code": "#AAAAAA italic", - "cmd_text": "#FFFFFF", "cmd_key": "#B4EC85 bold", # Only used in greeting