|
13 | 13 | from mathics.core.attributes import attribute_string_to_number |
14 | 14 | from mathics.core.expression import Expression, from_python |
15 | 15 | from mathics.core.rules import Rule |
16 | | -from mathics.core.symbols import SymbolNull |
| 16 | +from mathics.core.symbols import SymbolNull, SymbolFalse, SymbolTrue |
17 | 17 | from mathics.core.systemsymbols import SymbolMessageName |
18 | 18 | from mathics_pygments.lexer import MathematicaLexer, MToken |
19 | 19 | from mathics_scanner.location import ContainerKind |
|
35 | 35 | from mathicsscript.bindkeys import bindings, read_init_file, read_inputrc |
36 | 36 | from mathicsscript.completion import MathicsCompleter |
37 | 37 | from mathicsscript.termshell import ( |
| 38 | + ALL_PYGMENTS_STYLES, |
38 | 39 | CONFIGDIR, |
39 | 40 | HISTSIZE, |
40 | 41 | USER_INPUTRC, |
|
47 | 48 |
|
48 | 49 | mma_lexer = MathematicaLexer() |
49 | 50 |
|
50 | | -ALL_PYGMENTS_STYLES = list(get_all_styles()) |
51 | | - |
52 | 51 | color_scheme = TERMINAL_COLORS.copy() |
53 | 52 | color_scheme[MToken.SYMBOL] = ("yellow", "ansibrightyellow") |
54 | 53 | color_scheme[MToken.BUILTIN] = ("ansigreen", "ansibrightgreen") |
@@ -163,16 +162,43 @@ def bottom_toolbar(self): |
163 | 162 | app = get_app() |
164 | 163 | edit_mode = "Vi" if app.editing_mode == EditingMode.VI else "Emacs" |
165 | 164 |
|
166 | | - app.group_autocomplete = True |
167 | | - |
168 | | - if self.definitions.get_ownvalue("Settings`$GroupAutocomplete"): |
| 165 | + # The first time around, app.group_autocomplete has not been set, |
| 166 | + # so use the value from Settings`GroupAutocomplete. |
| 167 | + # However, after that we may have changed this value internally using |
| 168 | + # function key f3, so update Settings`GroupAutocomplete from that. |
| 169 | + if hasattr(app, "group_autocomplete"): |
| 170 | + self.definitions.set_ownvalue( |
| 171 | + "Settings`$GroupAutocomplete", |
| 172 | + SymbolTrue if app.group_autocomplete else SymbolFalse, |
| 173 | + ) |
| 174 | + elif self.definitions.get_ownvalue("Settings`$GroupAutocomplete"): |
169 | 175 | app.group_autocomplete = self.definitions.get_ownvalue( |
170 | 176 | "Settings`$GroupAutocomplete" |
171 | 177 | ).to_python() |
| 178 | + else: |
| 179 | + # First time around and there is no value set via |
| 180 | + # Settings`GroupAutocomplete. |
| 181 | + app.group_autocomplete = True |
| 182 | + self.definitions.set_ownvalue("Settings`$GroupAutocomplete", SymbolTrue) |
| 183 | + |
| 184 | + if hasattr(app, "pygments_style"): |
| 185 | + self.definitions.set_ownvalue( |
| 186 | + "Settings`$PygmentsStyle", String(app.pygments_style) |
| 187 | + ) |
| 188 | + elif self.definitions.get_ownvalue("Settings`$PygmentsStyle") is not SymbolNull: |
| 189 | + app.pygments_style = self.definitions.get_ownvalue( |
| 190 | + "Settings`$PygmentsStyle" |
| 191 | + ) |
| 192 | + else: |
| 193 | + # First time around and there is no value set via |
| 194 | + app.pygments_style = self.pygments_style |
| 195 | + self.definitions.set_ownvalue( |
| 196 | + "Settings`$PygmentsStyle", String(app.pygments_style) |
| 197 | + ) |
172 | 198 |
|
173 | 199 | edit_mode = "Vi" if app.editing_mode == EditingMode.VI else "Emacs" |
174 | 200 | return HTML( |
175 | | - f" mathicsscript: {__version__}, Style: {self.pygments_style}, Mode: {edit_mode}, Autobrace: {app.group_autocomplete}" |
| 201 | + f" mathicsscript: {__version__}, Style: {app.pygments_style}, Mode: {edit_mode}, Autobrace: {app.group_autocomplete}" |
176 | 202 | ) |
177 | 203 |
|
178 | 204 | def get_in_prompt(self): |
|
0 commit comments