Skip to content

Commit 0cbb77e

Browse files
committed
Note keyboard bindings in README.rst...
Add preamble to (tempoary?) asy file written to disk
1 parent 9bb2381 commit 0cbb77e

File tree

2 files changed

+43
-8
lines changed

2 files changed

+43
-8
lines changed

README.rst

Lines changed: 32 additions & 2 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

@@ -94,6 +94,36 @@ 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+
```
105+
h: home
106+
f: toggle fitscreen
107+
x: spin about the X axis
108+
y: spin about the Y axis
109+
z: spin about the Z axis
110+
s: stop spinning
111+
m: rendering mode (solid/patch/mesh)
112+
e: export
113+
c: show camera parameters
114+
p: play animation
115+
r: reverse animation
116+
: step animation
117+
+: expand
118+
=: expand
119+
>: expand
120+
-: shrink
121+
_: shrink
122+
<: shrink
123+
q: exit
124+
Ctrl-q: exit
125+
```
126+
97127
Why not IPython via Jupyter?
98128
----------------------------
99129

@@ -114,7 +144,7 @@ the core Mathic3 package.
114144
.. |screenshot| image:: https://mathics.org/images/mathicsscript1.gif
115145
.. |Latest Version| image:: https://badge.fury.io/py/mathicsscript.svg
116146
:target: https://badge.fury.io/py/mathicsscript
117-
.. |Pypi Installs| image:: https://pepy.tech/badge/mathicsscript
147+
.. |PyPI Installs| image:: https://pepy.tech/badge/mathicsscript
118148
.. |Supported Python Versions| image:: https://img.shields.io/pypi/pyversions/mathicsscript.svg
119149
.. |CI status| image:: https://github.com/Mathics3/mathicsscript/workflows/mathicsscript%20(ubuntu)/badge.svg
120150
: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)