julia, termcap, ANSI control sequences

136 views
Skip to first unread message

Tamas Papp

unread,
Oct 26, 2016, 4:46:40 AM10/26/16
to julia-dev
I am working on an Emacs extension for using the Julia REPL inside
Emacs. Since debugging with Gallium needs more terminal capabilities
than ESS allows, I am basing it on term.el.

By default, term in Emacs sends cursor keys as \eOA, \eOB, ... for up,
down, ... . I found that I need to change them to \e[A and \e[B to make
the Julia REPL recall history correctly.

I don't know much about terminals, so mostly I found this out by
experiment. I am wondering though if either term.el, Julia's readline,
or something in between is behaving incorrectly. As far as I understand,
term.el advertises keys correctly:


_ _ _(_)_ | A fresh approach to technical computing
(_) | (_) (_) | Documentation: http://docs.julialang.org
_ _ _| |_ __ _ | Type "?help" for help.
| | | | | | |/ _` | |
| | |_| | | | (_| | | Version 0.5.0 (2016-09-19 18:14 UTC)
_/ |\__'_|_|_|\__'_| | Official http://julialang.org/ release
|__/ | x86_64-pc-linux-gnu

julia> ENV["TERMCAP"]
"eterm-color:li#44:co#83:cl=\\E[H\\E[J:cd=\\E[J:bs:am:xn:cm=\\E[%i%d;%dH:nd=\\E[C:u
p=\\E[A:ce=\\E[K:ho=\\E[H:pt:al=\\E[L:dl=\\E[M:DL=\\E[%dM:AL=\\E[%dL:cs=\\E[%i%d;%d
r:sf=^J:dc=\\E[P:DC=\\E[%dP:IC=\\E[%d@:im=\\E[4h:ei=\\E[4l:mi::so=\\E[7m:se=\\E[m:u
s=\\E[4m:ue=\\E[m:md=\\E[1m:mr=\\E[7m:me=\\E[m:UP=\\E[%dA:DO=\\E[%dB:LE=\\E[%dD:RI=
\\E[%dC:kl=\\EOD:kd=\\EOB:kr=\\EOC:ku=\\EOA:kN=\\E[6~:kP=\\E[5~:@7=\\E[4~:kh=\\E[1~
:mk=\\E[8m:cb=\\E[1K:op=\\E[39;49m:Co#8:pa#64:AB=\\E[4%dm:AF=\\E[3%dm:cr=^M:bl=^G:d
o=^J:le=^H:ta=^I:se=\\E[27m:ue=\\E[24m:kb=^?:kD=^[[3~:sc=\\E7:rc=\\E8:r1=\\Ec:"

If anyone is interested, preliminary code for the minor mode is here:
https://github.com/tpapp/julia-repl/
Can be used in with julia-emacs.

Any help or advice would be appreciated (again, I know little about how
these things are supposed to work).

Best,

Tamas

Isaiah Norton

unread,
Oct 26, 2016, 9:32:31 AM10/26/16
to juli...@googlegroups.com
If you want to see the default keymap definitions, look in `base/LineEdit.jl`. As far as I can tell, Julia's REPL is using the correct raw key codes, so I'm not really sure what Emacs is doing.

Tamas Papp

unread,
Oct 26, 2016, 9:41:34 AM10/26/16
to juli...@googlegroups.com
Please forgive my ignorance about this, but I was under the impression
that there is no single set of codes, instead, they are described by the
TERMCAP. It appears that some terminals use \eOA etc, some \e[A. See
http://invisible-island.net/xterm/xterm-function-keys.html
Reply all
Reply to author
Forward
0 new messages