Skip to content

Commit f737101

Browse files
authored
Note keyboard bindings in README.rst... (#91)
Add preamble to (tempoary?) asy file written to disk
1 parent f96ca42 commit f737101

File tree

2 files changed

+43
-9
lines changed

2 files changed

+43
-9
lines changed

README.rst

Lines changed: 32 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
|CI status| |Pypi Installs| |Latest Version| |Supported Python Versions|
1+
|CI status| |PyPI Installs| |Latest Version| |Supported Python Versions|
22

33
|Packaging status|
44

@@ -18,7 +18,7 @@ Features
1818
- limited ESC keyboard input; for example *esc* ``p`` *esc* is π
1919
* Syntax highlighting using `mathics-pygments <https://pypi.org/project/mathics-pygments/>`_ which includes dynamically created variables and functions.
2020
* Automatic detection of light or dark `terminal background color <https://pypi.org/project/term-background/>`_.
21-
* Optional Graphics rendering via `matplotlib <https://matplotlib.org/>`_ for 2D graphics, and `Asymptote <https://asymptote.sourceforge.io>`_ for 3D graphcs.
21+
* Optional Graphics rendering via `matplotlib <https://matplotlib.org/>`_ for 2D graphics, and `Asymptote <https://asymptote.sourceforge.io>`_ for 3D and 2D graphics.
2222
* Entering and displaying Unicode symbols such as used for Pi or Rule arrows
2323
* Provision for running in non-interactive batch mode which an be used inside POSIX shells
2424

@@ -94,6 +94,35 @@ Feeding this into ``mathicsscript``:
9494
For a full list of options, type ``mathicsscript --help``.
9595

9696

97+
Asymptote key bindings
98+
----------------------
99+
100+
In asymptote graphs keyboard bindings are (copied from the asymptote
101+
doc under `8.29 three
102+
<https://asymptote.sourceforge.io/doc/three.html#index-keyboard-bindings_003a>`_::
103+
104+
h: home
105+
f: toggle fitscreen
106+
x: spin about the X axis
107+
y: spin about the Y axis
108+
z: spin about the Z axis
109+
s: stop spinning
110+
m: rendering mode (solid/patch/mesh)
111+
e: export
112+
c: show camera parameters
113+
p: play animation
114+
r: reverse animation
115+
: step animation
116+
+: expand
117+
=: expand
118+
>: expand
119+
-: shrink
120+
_: shrink
121+
<: shrink
122+
q: exit
123+
Ctrl-q: exit
124+
125+
97126
Why not IPython via Jupyter?
98127
----------------------------
99128

@@ -114,7 +143,7 @@ the core Mathic3 package.
114143
.. |screenshot| image:: https://mathics.org/images/mathicsscript1.gif
115144
.. |Latest Version| image:: https://badge.fury.io/py/mathicsscript.svg
116145
:target: https://badge.fury.io/py/mathicsscript
117-
.. |Pypi Installs| image:: https://pepy.tech/badge/mathicsscript
146+
.. |PyPI Installs| image:: https://pepy.tech/badge/mathicsscript
118147
.. |Supported Python Versions| image:: https://img.shields.io/pypi/pyversions/mathicsscript.svg
119148
.. |CI status| image:: https://github.com/Mathics3/mathicsscript/workflows/mathicsscript%20(ubuntu)/badge.svg
120149
:target: https://github.com/Mathics3/mathicsscript/actions

mathicsscript/asymptote.py

Lines changed: 11 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,12 @@
1212
from tempfile import NamedTemporaryFile
1313
from typing import Optional
1414

15-
asy_program = os.environ.get("ASY_PROG", "asy")
15+
# An aysmptote string to
16+
INTEACTIVE_PREAMBLE = """
17+
// Generated by Mathics3 mathicsscript.
18+
"""
19+
20+
ASY_PROGRAM = os.environ.get("ASY_PROG", "asy")
1621

1722
# Add asymptote directory to AYMPTOTE_DIR
1823
asymptote_dir = os.environ.get("ASYMPTOTE_DIR", "")
@@ -23,7 +28,7 @@
2328
asymptote_version: Optional[str] = None
2429
try:
2530
result = run(
26-
[asy_program, "--version"],
31+
[ASY_PROGRAM, "--version"],
2732
timeout=0.5,
2833
stdout=PIPE,
2934
stderr=PIPE,
@@ -46,10 +51,10 @@ def get_srcdir():
4651
asy_config = os.path.join(mydir, "config.asy")
4752

4853

49-
class Asy(object):
54+
class Asy:
5055
def __init__(self, show_help=True):
5156
self.session = Popen(
52-
[asy_program, f"-config={asy_config}", "-quiet", "-inpipe=0", "-outpipe=2"],
57+
[ASY_PROGRAM, f"-config={asy_config}", "-quiet", "-inpipe=0", "-outpipe=2"],
5358
stdin=PIPE,
5459
)
5560
if show_help:
@@ -103,8 +108,8 @@ def write_asy_and_view(asy_string: str):
103108
with NamedTemporaryFile(
104109
mode="w", prefix="Mathics3-Graph-", suffix=".asy", delete=False
105110
) as asy_fp:
106-
asy_fp.write(asy_string + "\n")
107-
subprocess.run(args=[asy_program, "-View", asy_fp.name])
111+
asy_fp.write(INTEACTIVE_PREAMBLE + asy_string + "\n")
112+
subprocess.run(args=[ASY_PROGRAM, "-View", asy_fp.name])
108113

109114

110115
if __name__ == "__main__":

0 commit comments

Comments
 (0)