Skip to content

Commit

Permalink
Definitions.get_ownvalue now returns a BaseElement. (#88)
Browse files Browse the repository at this point in the history
* Definitions.get_ownvalue now returns a BaseElement.

* Changes to make --prompt={GNU,none} work again (#89)

---------

Co-authored-by: R. Bernstein <[email protected]>
  • Loading branch information
mmatera and rocky authored Jan 10, 2025
1 parent a7d0cc3 commit 9bbf934
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 14 deletions.
4 changes: 2 additions & 2 deletions mathicsscript/__main__.py
Original file line number Diff line number Diff line change
Expand Up @@ -162,11 +162,11 @@ def fmt_fun(query: Any) -> Any:

full_form = definitions.get_ownvalue(
"Settings`$ShowFullFormInput"
).replace.to_python()
).to_python()
style = definitions.get_ownvalue("Settings`$PygmentsStyle")
fmt = identity
if style:
style = style.replace.get_string_value()
style = style.get_string_value()
if shell.terminal_formatter:
fmt = fmt_fun

Expand Down
16 changes: 7 additions & 9 deletions mathicsscript/termshell.py
Original file line number Diff line number Diff line change
Expand Up @@ -119,17 +119,15 @@ def __init__(

self.pygments_style = style
self.definitions = definitions
set_settings_value(
self.definitions, "Settings`$PygmentsShowTokens", from_python(False)
self.definitions.set_ownvalue(
"Settings`$PygmentsShowTokens", from_python(False)
)
set_settings_value(
self.definitions, "Settings`$UseUnicode", from_python(use_unicode)
)
set_settings_value(
self.definitions,
"Settings`PygmentsStylesAvailable",
from_python(ALL_PYGMENTS_STYLES),
self.definitions.set_ownvalue("Settings`$PygmentsStyle", from_python(style))
self.definitions.set_ownvalue("Settings`$UseUnicode", from_python(use_unicode))
self.definitions.set_ownvalue(
"Settings`PygmentsStylesAvailable", from_python(ALL_PYGMENTS_STYLES)
)

self.definitions.add_message(
"Settings`PygmentsStylesAvailable",
Rule(
Expand Down
6 changes: 3 additions & 3 deletions mathicsscript/termshell_prompt.py
Original file line number Diff line number Diff line change
Expand Up @@ -167,7 +167,7 @@ def bottom_toolbar(self):
if self.definitions.get_ownvalue("Settings`$GroupAutocomplete"):
app.group_autocomplete = self.definitions.get_ownvalue(
"Settings`$GroupAutocomplete"
).replace.to_python()
).to_python()

edit_mode = "Vi" if app.editing_mode == EditingMode.VI else "Emacs"
return HTML(
Expand Down Expand Up @@ -224,10 +224,10 @@ def print_result(
elif self.terminal_formatter: # pygmentize
show_pygments_tokens = self.definitions.get_ownvalue(
"Settings`$PygmentsShowTokens"
).replace.to_python()
).to_python()
pygments_style = self.definitions.get_ownvalue(
"Settings`$PygmentsStyle"
).replace.get_string_value()
).get_string_value()
if pygments_style != self.pygments_style:
if not self.change_pygments_style(pygments_style):
self.definitions.set_ownvalue(
Expand Down

0 comments on commit 9bbf934

Please sign in to comment.