Skip to content

Commit

Permalink
Merge pull request #7 from Mathics3/unicode-option
Browse files Browse the repository at this point in the history
Start to suport Unicode as a CLI option
  • Loading branch information
rocky authored Dec 22, 2020
2 parents 56e3708 + 00e9f2e commit fea6162
Show file tree
Hide file tree
Showing 9 changed files with 310 additions and 191 deletions.
12 changes: 9 additions & 3 deletions mathicsscript/__main__.py
Original file line number Diff line number Diff line change
Expand Up @@ -144,6 +144,11 @@ def out(self, out):
default=True,
help="GNU Readline line editing. enable tab completion",
)
@click.option(
"--unicode/--no-unicode",
default=True,
help="GNU Readline line editing. If this is off completion and command history are also turned off",
)
@click.option(
"--pyextensions",
"-l",
Expand Down Expand Up @@ -188,6 +193,7 @@ def main(
quiet,
readline,
completion,
unicode,
pyextensions,
execute,
initfile,
Expand All @@ -214,13 +220,13 @@ def main(
# Then, it can be changed by the settings file (in WL)
# and overwritten by the command line parameter.
definitions.set_ownvalue(
"Settings`$ShowFullFormInput", from_python(1 if full_form else 0)
"Settings`$ShowFullFormInput", from_python(True if full_form else False)
)
definitions.set_ownvalue(
"Settings`$PygmentsShowTokens", from_python(1 if pygments_tokens else 0)
"Settings`$PygmentsShowTokens", from_python(True if pygments_tokens else False)
)

shell = TerminalShell(definitions, style, readline, completion)
shell = TerminalShell(definitions, style, readline, completion, unicode)
load_settings(shell)
if initfile:
with open(initfile, "r") as ifile:
Expand Down
5 changes: 2 additions & 3 deletions mathicsscript/format.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,8 +29,8 @@ def format_output(obj, expr, format=None):
expr = leaves[0]
elif expr_type in ("System`Graphics", "System`Plot"):
result = "-System Graphics-"
# result = Expression("StandardForm", expr).format(obj, "System`MathMLForm")
# ml_str = result.leaves[0].leaves[0]
result = Expression("StandardForm", expr).format(obj, "System`MathMLForm")
ml_str = result.leaves[0].leaves[0]
# FIXME: not quite right. Need to parse out strings
# display_svg(str(ml_str))

Expand Down Expand Up @@ -379,7 +379,6 @@ def format_graph(G):
if graph_layout in ["circular", "spiral", "spiral_equidistant"]:
plt.axes().set_aspect("equal")


harmonize_parameters(G, draw_options)

if layout_fn:
Expand Down
177 changes: 1 addition & 176 deletions mathicsscript/inputrc
Original file line number Diff line number Diff line change
@@ -1,153 +1,4 @@
# GNU Readline input translations

# Lowercase TeX Greek characters
"\e\\alpha\e": "α"
"\e\\beta\e": "β"
"\e\\gamma\e": "γ"
"\e\\delta\e": "δ"
"\e\\epsilon\e": "ε"
"\e\\zeta\e": "ζ"
"\e\\eta\e": "η"
"\e\\theta\e": "θ"
"\e\\iota\e": "ι"
"\e\\kappa\e": "κ"
"\e\\lambda\e": "λ"
"\e\\mu\e": "μ"
"\e\\nu\e": "ν"
"\e\\xi\e": "ξ"
"\e\\omicron\e": "ο"
"\e\\pi\e": "π"
"\e\\rho\e": "ρ"
"\e\\varsigma\e": "ς"
"\e\\sigma\e": "σ"
"\e\\tau\e": "τ"
"\e\\upsilon\e": "υ"
"\e\\phi\e": "φ"
"\e\\chi\e": "χ"
"\e\\psi\e": "ψ"
"\e\\omega\e": "ω"

# Lowercase named Greek characters
"\ea\e": "α"
"\eb\e": "β"
"\eg\e": "γ"
"\ed\e": "δ"
"\ee\e": "ε"
"\ez\e": "ζ"
"\ee\e": "η"
"\et\e": "θ"
"\ei\e": "ι"
"\ek\e": "κ"
"\el\e": "λ"
"\em\e": "μ"
"\en\e": "ν"
"\ex\e": "ξ"
"\eo\e": "ω"
"\ep\e": "π"
"\er\e": "ρ"
"\ev\e": "ς"
"\es\e": "σ"
"\et\e": "τ"
"\eu\e": "υ"
# "\e\\phi\e": "φ" # ?
# "\e\\chi\e": "χ" # ?
# "\e\\psi\e": "ψ" # ?

# Uppercase TeX Greek symbols
"\e\\Gamma\e": "Γ"
"\e\\Delta\e": "Δ"
"\e\\Theta\e": "Θ"
"\e\\Lambda\e": "Λ"
"\e\\Xi\e": "Ξ"
"\e\\Pi\e": "Π"
"\e\\Sigma\e": "Σ"
"\e\\Upsilon\e": "Υ"
"\e\\Phi\e": "Φ"
"\e\\Psi\e": "Ψ"
"\e\\Omega\e": "Ω"

# Things we have Unicode symbols for
"\e.a\e": ""
"\e$a\e": ""
"\e.A\e": ""
"\e$A\e": ""
"\e.B\e": ""
"\e$B\e": ""
"\e.b\e": ""
"\e$b\e": ""
"\e.D\e": ""
"\e$D\e": ""
"\e.d\e": ""
"\e$d\e": ""
"\e.E\e": ""
"\e$E\e": ""
"\e.e\e": ""
"\e$e\e": ""
"\e.H\e": ""
"\e$H\e": ""
"\e.h\e": ""
"\e$h\e": ""
"\e.I\e": ""
"\e$I\e": ""
"\e.i\e": ""
"\e$i\e": ""
"\e.K\e": ""
"\e$K\e": ""
"\e.k\e": ""
"\e$k\e": ""
"\e.L\e": ""
"\e$L\e": ""
"\e.l\e": ""
"\e$l\e": ""
"\e.M\e": ""
"\e$M\e": ""
"\e.m\e": ""
"\e$m\e": ""
"\e.N\e": ""
"\e$N\e": ""
"\e.n\e": ""
"\e$n\e": ""
"\e.O\e": ""
"\e$O\e": ""
"\e.o\e": ""
"\e$o\e": ""
"\e.R\e": ""
"\e$R\e": ""
"\e.r\e": ""
"\e$r\e": ""
"\e.S\e": ""
"\e$S\e": ""
"\e.s\e": ""
"\e$s\e": ""
"\e.T\e": ""
"\e$T\e": ""
"\e.t\e": ""
"\e$t\e": ""
"\e.U\e": ""
"\e$U\e": ""
"\e.u\e": ""
"\e$u\e": ""
"\e$V\e": ""
"\e.V\e": ""
"\e.v\e": "ṿ"
"\e$v\e": "ṿ"
"\e.W\e": ""
"\e$W\e": ""
"\e.w\e": ""
"\e$w\e": ""
"\e.Y\e": ""
"\e$Y\e": ""
"\e.y\e": ""
"\e$y\e": ""
"\e.Z\e": ""
"\e$Z\e": ""
"\e.Z\e": ""
"\e$Z\e": ""
"\einf\e": ""
"\edeg\e": "°"
"\e&&\e": ""
"\eue\e": ""
"\ede\e": ""
# GNU Readline input translations (no unicode here)

# Things we have don't have Unicode symbols in terminal.
# So we use the Mathics name
Expand Down Expand Up @@ -187,30 +38,4 @@
"\escx\e": "\\[ScriptX]"
"\escy\e": "\\[ScriptY]"
"\escz\e": "\\[ScriptZ]"
"\escA\e": "\\[ScriptCapitalA]"
"\escB\e": "\\[ScriptCapitalB]"
"\escC\e": "\\[ScriptCapitalC]"
"\escD\e": "\\[ScriptCapitalD]"
"\escE\e": "\\[ScriptCapitalE]"
"\escF\e": "\\[ScriptCapitalF]"
"\escG\e": "\\[ScriptCapitalG]"
"\escH\e": "\\[ScriptCapitalH]"
"\escI\e": "\\[ScriptCapitalI]"
"\escJ\e": "\\[ScriptCapitalJ]"
"\escK\e": "\\[ScriptCapitalK]"
"\escL\e": "\\[ScriptCapitalL]"
"\escM\e": "\\[ScriptCapitalM]"
"\escN\e": "\\[ScriptCapitalN]"
"\escO\e": "\\[ScriptCapitalO]"
"\escP\e": "\\[ScriptCapitalP]"
"\escQ\e": "\\[ScriptCapitalQ]"
"\escR\e": "\\[ScriptCapitalR]"
"\escS\e": "\\[ScriptCapitalS]"
"\escT\e": "\\[ScriptCapitalT]"
"\escU\e": "\\[ScriptCapitalU]"
"\escV\e": "\\[ScriptCapitalV]"
"\escW\e": "\\[ScriptCapitalW]"
"\escX\e": "\\[ScriptCapitalX]"
"\esCy\e": "\\[ScriptCapitalY]"
"\esCz\e": "\\[ScriptCapitalZ]"
tab: complete
83 changes: 83 additions & 0 deletions mathicsscript/inputrc-no-unicode
Original file line number Diff line number Diff line change
@@ -0,0 +1,83 @@
# GNU Readline input translations

# Note: the reader will insure that the current working directory is this
# one before reading this file. Therefore we can omit path directories.
$include "inputrc"

# Lowercase TeX Greek characters
"\e\\alpha\e": "\\[Alpha]"
"\e\\beta\e": "\\[Beta]"
"\e\\gamma\e": "\\[Gama]"
"\e\\delta\e": "\\[Delta]"
"\e\\epsilon\e": "\\[Epsilon]"
"\e\\zeta\e": "\\[Zeta]"
"\e\\eta\e": "\\[Eta]"
"\e\\theta\e": "\\[Theta]"
"\e\\iota\e": "\\[Iota]"
"\e\\kappa\e": "\\[Kappa]"
"\e\\lambda\e": "\\[Lambda]"
"\e\\mu\e": "\\[Mu]"
"\e\\nu\e": "\\[Nu]"
"\e\\xi\e": "\\[Xi]"
"\e\\omicron\e": "\\[Omicron]"
"\e\\pi\e": "\\[Pi]"
"\e\\rho\e": "\\[Rho]"
"\e\\sigma\e": "\\[Sigma]"
"\e\\tau\e": "\\[Tau]"
"\e\\upsilon\e": "\\[Upsilon\]"
"\e\\phi\e": "\\[Phi]"
"\e\\chi\e": "\\[Chi]"
"\e\\psi\e": "\\Psi]"
"\e\\omega\e": "\\[Omega]"

# Lowercase named Greek characters
"\ea\e": "\\[Alpha]""
"\eb\e": "\\[Beta]"
"\eg\e": "\\[Gama]"
"\ed\e": "\\[Delta]"
"\ee\e": "\\[Epsilon]"
"\ez\e": "\\[Zeta]"
"\ee\e": "\\[Nu]"
"\et\e": "\\[Theta]"
"\ei\e": "\\[Iota]"
"\ek\e": "\\[Kappa]"
"\el\e": "\\[Lambda]"
"\em\e": "\\[Mu]"
"\en\e": "\\[Nu]"
"\ex\e": "\\[Eta]"
"\eo\e": "\\[Omega]"
"\ep\e": ""\\[Pi]"
"\er\e": "\\[Rho]"
"\es\e": "\\[Sigma]"
"\et\e": "\\[Tau]"
"\eu\e": "υ"
# "\e\\phi\e": "φ" # ?
# "\e\\chi\e": "χ" # ?
# "\e\\psi\e": "ψ" # ?

"\escA\e": "\\[ScriptCapitalA]"
"\escB\e": "\\[ScriptCapitalB]"
"\escC\e": "\\[ScriptCapitalC]"
"\escD\e": "\\[ScriptCapitalD]"
"\escE\e": "\\[ScriptCapitalE]"
"\escF\e": "\\[ScriptCapitalF]"
"\escG\e": "\\[ScriptCapitalG]"
"\escH\e": "\\[ScriptCapitalH]"
"\escI\e": "\\[ScriptCapitalI]"
"\escJ\e": "\\[ScriptCapitalJ]"
"\escK\e": "\\[ScriptCapitalK]"
"\escL\e": "\\[ScriptCapitalL]"
"\escM\e": "\\[ScriptCapitalM]"
"\escN\e": "\\[ScriptCapitalN]"
"\escO\e": "\\[ScriptCapitalO]"
"\escP\e": "\\[ScriptCapitalP]"
"\escQ\e": "\\[ScriptCapitalQ]"
"\escR\e": "\\[ScriptCapitalR]"
"\escS\e": "\\[ScriptCapitalS]"
"\escT\e": "\\[ScriptCapitalT]"
"\escU\e": "\\[ScriptCapitalU]"
"\escV\e": "\\[ScriptCapitalV]"
"\escW\e": "\\[ScriptCapitalW]"
"\escX\e": "\\[ScriptCapitalX]"
"\esCy\e": "\\[ScriptCapitalY]"
"\esCz\e": "\\[ScriptCapitalZ]"
Loading

0 comments on commit fea6162

Please sign in to comment.