diff --git a/README.rst b/README.rst index fe98d4d..ffbb770 100644 --- a/README.rst +++ b/README.rst @@ -1,4 +1,4 @@ -|CI status| |Pypi Installs| |Latest Version| |Supported Python Versions| +|CI status| |PyPI Installs| |Latest Version| |Supported Python Versions| |Packaging status| @@ -18,7 +18,7 @@ Features - limited ESC keyboard input; for example *esc* ``p`` *esc* is π * Syntax highlighting using `mathics-pygments `_ which includes dynamically created variables and functions. * Automatic detection of light or dark `terminal background color `_. -* Optional Graphics rendering via `matplotlib `_ for 2D graphics, and `Asymptote `_ for 3D graphcs. +* Optional Graphics rendering via `matplotlib `_ for 2D graphics, and `Asymptote `_ for 3D and 2D graphics. * Entering and displaying Unicode symbols such as used for Pi or Rule arrows * Provision for running in non-interactive batch mode which an be used inside POSIX shells @@ -94,6 +94,35 @@ Feeding this into ``mathicsscript``: For a full list of options, type ``mathicsscript --help``. +Asymptote key bindings +---------------------- + +In asymptote graphs keyboard bindings are (copied from the asymptote +doc under `8.29 three +`_:: + + h: home + f: toggle fitscreen + x: spin about the X axis + y: spin about the Y axis + z: spin about the Z axis + s: stop spinning + m: rendering mode (solid/patch/mesh) + e: export + c: show camera parameters + p: play animation + r: reverse animation + : step animation + +: expand + =: expand + >: expand + -: shrink + _: shrink + <: shrink + q: exit + Ctrl-q: exit + + Why not IPython via Jupyter? ---------------------------- @@ -114,7 +143,7 @@ the core Mathic3 package. .. |screenshot| image:: https://mathics.org/images/mathicsscript1.gif .. |Latest Version| image:: https://badge.fury.io/py/mathicsscript.svg :target: https://badge.fury.io/py/mathicsscript -.. |Pypi Installs| image:: https://pepy.tech/badge/mathicsscript +.. |PyPI Installs| image:: https://pepy.tech/badge/mathicsscript .. |Supported Python Versions| image:: https://img.shields.io/pypi/pyversions/mathicsscript.svg .. |CI status| image:: https://github.com/Mathics3/mathicsscript/workflows/mathicsscript%20(ubuntu)/badge.svg :target: https://github.com/Mathics3/mathicsscript/actions diff --git a/mathicsscript/asymptote.py b/mathicsscript/asymptote.py index 24c515f..fa042d2 100644 --- a/mathicsscript/asymptote.py +++ b/mathicsscript/asymptote.py @@ -12,7 +12,12 @@ from tempfile import NamedTemporaryFile from typing import Optional -asy_program = os.environ.get("ASY_PROG", "asy") +# An aysmptote string to +INTEACTIVE_PREAMBLE = """ +// Generated by Mathics3 mathicsscript. +""" + +ASY_PROGRAM = os.environ.get("ASY_PROG", "asy") # Add asymptote directory to AYMPTOTE_DIR asymptote_dir = os.environ.get("ASYMPTOTE_DIR", "") @@ -23,7 +28,7 @@ asymptote_version: Optional[str] = None try: result = run( - [asy_program, "--version"], + [ASY_PROGRAM, "--version"], timeout=0.5, stdout=PIPE, stderr=PIPE, @@ -46,10 +51,10 @@ def get_srcdir(): asy_config = os.path.join(mydir, "config.asy") -class Asy(object): +class Asy: def __init__(self, show_help=True): self.session = Popen( - [asy_program, f"-config={asy_config}", "-quiet", "-inpipe=0", "-outpipe=2"], + [ASY_PROGRAM, f"-config={asy_config}", "-quiet", "-inpipe=0", "-outpipe=2"], stdin=PIPE, ) if show_help: @@ -103,8 +108,8 @@ def write_asy_and_view(asy_string: str): with NamedTemporaryFile( mode="w", prefix="Mathics3-Graph-", suffix=".asy", delete=False ) as asy_fp: - asy_fp.write(asy_string + "\n") - subprocess.run(args=[asy_program, "-View", asy_fp.name]) + asy_fp.write(INTEACTIVE_PREAMBLE + asy_string + "\n") + subprocess.run(args=[ASY_PROGRAM, "-View", asy_fp.name]) if __name__ == "__main__":