Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
93 changes: 59 additions & 34 deletions NEWS.md → CHANGES.rst
Original file line number Diff line number Diff line change
@@ -1,12 +1,37 @@
CHANGES
=======

9.0.0
-----

Supports Python 3.13. Python 3.8 support dropped.

Track API changes in Mathics3 Scanner 9.0.0

Make CLI options more like wolframscript. This is an incompatible change. Single-dash long options like ``-help``, ``-file``
are now accepted. Short option ``-f`` is associated with ``-file`` rather than ``--fullform``; ``-F`` is is now used for Fullform.
Option ``--read`` with alias ``-r`` is now ``-code`` and short option `-c`.

Toggling Autobrace using f4 was fixed.
You can cycle now through pygments styles up using f5 (next style) and f6 (previous style). f1 (help) now show function key
bindings in bottom bar.


Bugs
++++

Fixed #82


8.0.0
-----

Jan 26, 2025

This release tracks the API changes in the Mathics Kernel, and to support enhanged debugging
This release tracks the API changes in the Mathics3 Kernel, and to support enhanged debugging

* `--edit-mode [emacs|vi]` or was added to `mathicsscript` to specify which initial edit mode for prompt-toolkit to start in
* `--post-mortem` was added `mathicsscript` to go into a trepan3k debugger on error
* ``--edit-mode [emacs|vi]`` or was added to ``mathicsscript`` to specify which initial edit mode for prompt-toolkit to start in
* ``--post-mortem`` was added ``mathicsscript`` to go into a trepan3k debugger on error
* Add aliases for all of the 100 or so "no-meaning" operators
* Allow 2D rendering from asymptote
* Add/update material in README's and screencast
Expand Down Expand Up @@ -52,7 +77,7 @@ Aug 10, 2025
* Packaging: include matplotlib in full install
* Customize Asymptote configuration and add a psviewer that removes eps trash
* Bump minimum Mathics core version to 4.0.0
* Bug fix: Check if `self` has `session` attribute in `asy.__del__`
* Bug fix: Check if ``self`` has ``session`` attribute in ``asy.__del__``

3.3.1
-----
Expand All @@ -64,7 +89,7 @@ Aug 10, 2025
-----

* 3D Graphics is now handled if Asymptote is installed.
* ``Settings`$UseMatplotlib`` and ``Settings`$UseAsymptote`` were added. The can disable the use of matplotlib and Asymptote when those are available.
* ```Settings`$UseMatplotlib``` and ```Settings`$UseAsymptote``` were added. The can disable the use of matplotlib and Asymptote when those are available.

3.2.1
-----
Expand All @@ -76,16 +101,16 @@ Fix packaging issues and be more tolerant matplotlib errors.

* Many 2D plots and graphs can now be viewed via a matplotlib shell! PR #40.
* In prompt-toolkit:
- Better word-boundary detection for `NamedCharacters`, `Symbols`
- Better word-boundary detection for ``NamedCharacters``, ``Symbols``
- Include grouping start symbols "(", "{", "[" in detection

3.1.0
-----

Word completion detection was improved slightly. Previously, a grouping opener like "[", "(", or "{" would prevent word completion.

ASCII to unicode conversion was disabled since it was flaky and turned `===` into
garbage upon seeing `==`. Issue #38
ASCII to unicode conversion was disabled since it was flaky and turned ``===`` into
garbage upon seeing ``==`. Issue #38

In prompt-readline by default, inserting a "[", "(", or "{" will automatically insert the corresponding closing "]", ")", and "}".
Use f3 to toggle this behavior.
Expand All @@ -102,7 +127,7 @@ We've separated prompt_readline functions into its own module separate from the
The primary readline interface has been redone using the excellent [prompt-toolkit](https://pypi.org/project/prompt-toolkit/).
This is pure Python code so it should be available everywhere.
We still include GNU-Readline for those situations where prompt-toolkit doesn't work. Select the readline style now with the
`--choice` option which can be one of `GNU`, `Prompt`, or `None`.
`--choice`` option which can be one of ``GNU``, ``Prompt``, or ``None``.

Prompt toolkit allows us to color input as it is getting typed. It also has nicer completion facilities, and sports a bottom modeline status bar.

Expand All @@ -116,14 +141,14 @@ Independent of prompt-toolkit, there better pygments colorization using [mathics

* There are now system setting and user settings. User settings take precedence over system settings.
* String output is now shown in quotes to make it more distinguishable from symbol and unexpanded
expressssion output. This does not follow how `wolframscript` works. Option `strict-wl-output` will disable this.
expressssion output. This does not follow how ``wolframscript`` works. Option ``strict-wl-output`` will disable this.
* Syntax and Highlighting is now done via the Python
[mathics-pygments](https://pypi.org/project/mathics-pygments/)
package. I think you'll find colorization more complete and
useful. Expect more improvements as mathics-pygments improves.
* Flag `--initfile` is now `--run` to have better conformance with `wolframscript`. In the future we hope
to support support conformance with `wolfram` if the` mathicsscript` (or code underneath) is called
using the name `mathics3`.
* Flag ``--initfile`` is now ``--run`` to have better conformance with ``wolframscript``. In the future we hope
to support support conformance with ``wolfram`` if the`` mathicsscript`` (or code underneath) is called
using the name ``mathics3``.

2.1.2
-----
Expand All @@ -143,15 +168,15 @@ the GNU Readline inputrc files from getting created properly.
2.1.0
-----

* Allow command-line flag `-c` as an alias for `--execute` (along with `-e` to be compatible with wolframscript
* Allow command-line flag ``-c`` as an alias for ``--execute`` (along with ``-e`` to be compatible with wolframscript
* Better compliance on Windows which are GNU readline-starved
* Better unicode detection
* Accept newer mathics-scanner and Mathics3 versions

2.0.1
-----

* Fix `mathicsscript -f FILE` argument. See PR #26
* Fix ``mathicsscript -f FILE`` argument. See PR #26

2.0.0
-----
Expand All @@ -163,55 +188,55 @@ the GNU Readline inputrc files from getting created properly.
1.1.2
-----

* Fix ``Settings`$ShowFullForm`` now that we use Mathics supports Booleans better
* Fix ```Settings`$ShowFullForm``` now that we use Mathics supports Booleans better
* Show mathicsscript version on startup
* Add ``Settings`MathicsScriptVersion``
* Add ```Settings`MathicsScriptVersion``
* Add all of the WL escape sequences
* Add conversions from WL Unicode to standard Unicode
* Shell escapes `!` and `!!` added
* Shell escapes ``!`` and ``!!`` added

Incompatible changes:

* `-e` `--execute` is better suited for embedded use. It adds `--quiet` and shows just evaluation output as text
* ``-e`` ``--execute`` is better suited for embedded use. It adds ``--quiet`` and shows just evaluation output as text

1.1.1
-----

* We require Mathics3 1.1.1 for features added in that to support unicode and user-formatting
* Start to support Unicode as a CLI option: `--unicode/--no-unicode`. The setting name is ``Settings`$UseUnicode``.
* Start to support Unicode as a CLI option: ``--unicode/--no-unicode``. The setting name is ```Settings`$UseUnicode``.
* Add a lot of Unicode symbols and the WL esc sequences. For example letters with dots under them. These are the "Formal" parameters/letters.
* Handle Unicode versus WL character code mismatches, , in particular Unicode directed and undirected edges.
* Support for ``PyMathics`Graph`` (to be released on PyPI soon).
* Support for ```PyMathics`Graph``` (to be released on PyPI soon).
* Some XDG compatibility
* Toleratte MS/Windows pyreadline which doesn't handle `remove_history_item`
* Toleratte MS/Windows pyreadline which doesn't handle ``remove_history_item``
* Show pygments styles when an invalid one is given
* Use "inkpot" for dark backgrounds and "colorful" for light backgrounds.
* Add ``Settings`PygementsStylesAvailable``
* Add settings.m to holds `mathicsscript`-specific definitions `Settings` and their default values. Settings include
- ``Settings`$ShowFullFormInput``
- ``Settings`$PygmentsStyle``
- ``Settings`$PygmentsShowTokens``
- ``Settings`$UseUnicode`` (also mentioned above)
* Add ```Settings`PygementsStylesAvailable``
* Add settings.m to holds ``mathicsscript`a`-specific definitions ``Settings`` and their default values. Settings include
- ```Settings`$ShowFullFormInput``
- ```Settings`$PygmentsStyle``
- ```Settings`$PygmentsShowTokens``
- ```Settings`$UseUnicode``` (also mentioned above)

A lot of code for handling graph formating is here but will eventually be moved to a backend formattting module which hasn't been written yet.
A lot of code for handling graph formatting is here but will eventually be moved to a backend formatting module which hasn't been written yet.


1.1.0
-----

Now that Mathic3 1.1.0 is released depend on that.
Now that Mathics3 1.1.0 is released depend on that.

Some internal preparation work was done to support changing settings inside the REPL.
Not ready for release yet.

1.1.0 rc1
---------

Split off from plain `mathics` script.
Split off from plain ``mathics`` script.

* GNU Readline terminal interaction. This includes
- saving command history between sessions.
- variable completion, even for symbol names like `\\[Sigma]`
- limited ESC keyboard input; for example *esc* ``p`` *esc* is π
* Syntax highlighting using `pygments`.
- variable completion, even for symbol names like ``\\[Sigma]``
- limited ESC keyboard input; for example *esc* ```p``` *esc* is π
* Syntax highlighting using ``pygments``.
* Automatic detection of light or dark terminal background color.
32 changes: 28 additions & 4 deletions mathicsscript/bindkeys.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,8 @@
from prompt_toolkit.enums import EditingMode
from prompt_toolkit.key_binding import KeyBindings
from prompt_toolkit.filters import Condition
from prompt_toolkit.layout import Float, FloatContainer
from prompt_toolkit.widgets import Dialog, Button, Label
from sys import version_info
import contextlib
import pathlib
Expand Down Expand Up @@ -120,7 +122,7 @@ def double_quotation(event):
b.insert_text('"', move_cursor=False)


# Add an additional key binding for toggling this flag.
# Add an additional key binding for toggling the Edit mode flag.
@bindings.add("f4")
def _editor_toggle(event):
"""Toggle between Emacs and Vi mode."""
Expand All @@ -132,7 +134,14 @@ def _editor_toggle(event):
app.editing_mode = EditingMode.VI


# Add an additional key binding for toggling this flag.
@bindings.add("f1")
def _toggle_help(event):
"""Toggles bottom bar from showing help or showing information"""
app = event.app
app.help_mode = not app.help_mode


# Add an additional key binding for toggling the braces completion flag.
@bindings.add("f3")
def _group_autocomplete_toggle(event):
"""Complete braces."""
Expand All @@ -141,8 +150,8 @@ def _group_autocomplete_toggle(event):


# Add an additional key binding for toggling this flag.
@bindings.add("f2")
def _next_pygements_style(event):
@bindings.add("f5")
def _next_pygments_style(event):
"""Set Pygments style to the next sytle in ALL_PYGMENTS_STYLE."""
app = event.app

Expand All @@ -155,6 +164,21 @@ def _next_pygements_style(event):
app.pygments_style = ALL_PYGMENTS_STYLES[i]


# Add an additional key binding for toggling this flag.
@bindings.add("f6")
def _prev_pygments_style(event):
"""Set Pygments style to the previous sytle in ALL_PYGMENTS_STYLE."""
app = event.app

try:
i = ALL_PYGMENTS_STYLES.index(app.pygments_style)
except ValueError:
pass
else:
i = (i - 1) % len(ALL_PYGMENTS_STYLES)
app.pygments_style = ALL_PYGMENTS_STYLES[i]


def read_inputrc(read_init_file_fn: Callable, use_unicode: bool) -> None:
"""
Read GNU Readline style inputrc
Expand Down
9 changes: 8 additions & 1 deletion mathicsscript/termshell_prompt.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@
from pygments import format, highlight, lex
from pygments.formatters import Terminal256Formatter
from pygments.formatters.terminal import TERMINAL_COLORS
from pygments.styles import get_all_styles, get_style_by_name
from pygments.styles import get_style_by_name
from pygments.util import ClassNotFound

# FIXME: __main__ shouldn't be needed. Fix term_background
Expand Down Expand Up @@ -161,6 +161,13 @@ def bottom_toolbar(self):
# TODO: Figure out how allow user-customization
app = get_app()
edit_mode = "Vi" if app.editing_mode == EditingMode.VI else "Emacs"
if not hasattr(app, "help_mode"):
app.help_mode = False

if app.help_mode:
return HTML(
"f1: help, f3: toggle autocomplete, f4: toggle edit mode, f5: next style, f6: previous style"
)

# The first time around, app.group_autocomplete has not been set,
# so use the value from Settings`GroupAutocomplete.
Expand Down
Loading