starlight-cli 1.0.12 → 1.0.14
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.js +23558 -145
- package/dist/ter-u14b.json +17826 -0
- package/dist/ter-u14n.json +17826 -0
- package/dist/usr/fonts/AUTHORS +1 -0
- package/dist/usr/fonts/LICENSE +94 -0
- package/dist/usr/fonts/README +340 -0
- package/dist/usr/fonts/ter-u14b.json +17826 -0
- package/dist/usr/fonts/ter-u14n.json +17826 -0
- package/dist/usr/linux +0 -0
- package/dist/usr/windows-ansi +0 -0
- package/dist/usr/xterm +0 -0
- package/dist/usr/xterm-256color +0 -0
- package/dist/usr/xterm.termcap +243 -0
- package/dist/usr/xterm.terminfo +1977 -0
- package/dist/xterm +0 -0
- package/dist/xterm.termcap +243 -0
- package/package.json +2 -1
- package/src/starlight.js +137 -125
package/dist/xterm
ADDED
|
Binary file
|
|
@@ -0,0 +1,243 @@
|
|
|
1
|
+
# $XTermId: termcap,v 1.80 2012/06/10 14:30:37 tom Exp $
|
|
2
|
+
#
|
|
3
|
+
# These are termcap entries that correspond to xterm's terminfo file.
|
|
4
|
+
# The file is formatted using ncurses' "tic -CNx", but is not mechanically
|
|
5
|
+
# derived from the terminfo.
|
|
6
|
+
#
|
|
7
|
+
#------------------------------------------------------------------------------
|
|
8
|
+
# Copyright 1996-2011,2012 by Thomas E. Dickey
|
|
9
|
+
#
|
|
10
|
+
# All Rights Reserved
|
|
11
|
+
#
|
|
12
|
+
# Permission is hereby granted, free of charge, to any person obtaining a
|
|
13
|
+
# copy of this software and associated documentation files (the
|
|
14
|
+
# "Software"), to deal in the Software without restriction, including
|
|
15
|
+
# without limitation the rights to use, copy, modify, merge, publish,
|
|
16
|
+
# distribute, sublicense, and/or sell copies of the Software, and to
|
|
17
|
+
# permit persons to whom the Software is furnished to do so, subject to
|
|
18
|
+
# the following conditions:
|
|
19
|
+
#
|
|
20
|
+
# The above copyright notice and this permission notice shall be included
|
|
21
|
+
# in all copies or substantial portions of the Software.
|
|
22
|
+
#
|
|
23
|
+
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
|
|
24
|
+
# OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
|
25
|
+
# MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
|
|
26
|
+
# IN NO EVENT SHALL THE ABOVE LISTED COPYRIGHT HOLDER(S) BE LIABLE FOR ANY
|
|
27
|
+
# CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
|
|
28
|
+
# TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
|
|
29
|
+
# SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
|
30
|
+
#
|
|
31
|
+
# Except as contained in this notice, the name(s) of the above copyright
|
|
32
|
+
# holders shall not be used in advertising or otherwise to promote the
|
|
33
|
+
# sale, use or other dealings in this Software without prior written
|
|
34
|
+
# authorization.
|
|
35
|
+
#------------------------------------------------------------------------------
|
|
36
|
+
#
|
|
37
|
+
# Note:
|
|
38
|
+
# termcap format is limited to 1023 characters. This set of descriptions
|
|
39
|
+
# is a subset of the terminfo, since not all features can be fit into
|
|
40
|
+
# that limit. The 'xterm' description supports color. The monochrome
|
|
41
|
+
# 'xterm-mono' drops color in favor of additional function keys. If you
|
|
42
|
+
# need both, use terminfo.
|
|
43
|
+
#
|
|
44
|
+
# The 1023-character limit applies to each entry after resolving the
|
|
45
|
+
# "tc=" strings. Some implementations may discount all or part of the
|
|
46
|
+
# formatting characters in the entry (i.e., the backslash newline tab
|
|
47
|
+
# colon). GNU termcap does not have this limit.
|
|
48
|
+
#
|
|
49
|
+
# I checked the limits using ncurses "captoinfo -CrTUvx", which prints
|
|
50
|
+
# the resolved length of each entry in a comment at the end - T.Dickey
|
|
51
|
+
#
|
|
52
|
+
xf|xterm-new|modern xterm:\
|
|
53
|
+
:*6=\EOF:@7=\EOF:F1=\E[23~:F2=\E[24~:K2=\EOE:Km=\E[M:\
|
|
54
|
+
:k1=\EOP:k2=\EOQ:k3=\EOR:k4=\EOS:k5=\E[15~:k6=\E[17~:\
|
|
55
|
+
:k7=\E[18~:k8=\E[19~:k9=\E[20~:k;=\E[21~:kB=\E[Z:kH=\EOF:\
|
|
56
|
+
:kI=\E[2~:kN=\E[6~:kP=\E[5~:kd=\EOB:kh=\EOH:kl=\EOD:\
|
|
57
|
+
:kr=\EOC:ku=\EOA:tc=xterm-basic:
|
|
58
|
+
#
|
|
59
|
+
# This chunk is used for building the VT220/Sun/PC keyboard variants.
|
|
60
|
+
xb|xterm-basic|modern xterm common:\
|
|
61
|
+
:am:bs:km:mi:ms:ut:xn:AX:\
|
|
62
|
+
:Co#8:co#80:kn#12:li#24:pa#64:\
|
|
63
|
+
:AB=\E[4%dm:AF=\E[3%dm:AL=\E[%dL:DC=\E[%dP:DL=\E[%dM:\
|
|
64
|
+
:DO=\E[%dB:LE=\E[%dD:RI=\E[%dC:UP=\E[%dA:ae=\E(B:al=\E[L:\
|
|
65
|
+
:as=\E(0:bl=^G:cd=\E[J:ce=\E[K:cl=\E[H\E[2J:\
|
|
66
|
+
:cm=\E[%i%d;%dH:cs=\E[%i%d;%dr:ct=\E[3g:dc=\E[P:dl=\E[M:\
|
|
67
|
+
:ei=\E[4l:ho=\E[H:im=\E[4h:is=\E[!p\E[?3;4l\E[4l\E>:\
|
|
68
|
+
:kD=\E[3~:ke=\E[?1l\E>:ks=\E[?1h\E=:le=^H:md=\E[1m:\
|
|
69
|
+
:me=\E[m:ml=\El:mr=\E[7m:mu=\Em:nd=\E[C:op=\E[39;49m:\
|
|
70
|
+
:rc=\E8:rs=\E[!p\E[?3;4l\E[4l\E>:sc=\E7:se=\E[27m:sf=^J:\
|
|
71
|
+
:so=\E[7m:sr=\EM:st=\EH:te=\E[?1049l:ti=\E[?1049h:\
|
|
72
|
+
:ue=\E[24m:up=\E[A:us=\E[4m:ve=\E[?12l\E[?25h:vi=\E[?25l:\
|
|
73
|
+
:vs=\E[?12;25h:tc=xterm+kbs:
|
|
74
|
+
|
|
75
|
+
# The xterm-new description has all of the features, but is not completely
|
|
76
|
+
# compatible with vt220. If you are using a Sun or PC keyboard, set the
|
|
77
|
+
# sunKeyboard resource to true:
|
|
78
|
+
# + maps the editing keypad
|
|
79
|
+
# + interprets control-function-key as a second array of keys, so a
|
|
80
|
+
# 12-fkey keyboard can support vt220's 20-fkeys.
|
|
81
|
+
# + maps numeric keypad "+" to ",".
|
|
82
|
+
# + uses DEC-style control sequences for the application keypad.
|
|
83
|
+
#
|
|
84
|
+
vt|xterm-vt220|xterm emulating vt220:\
|
|
85
|
+
:*6=\E[4~:@7=\E[4~:K2=\EOu:Km=\E[M:kB=\E[Z:kH=\E[4~:\
|
|
86
|
+
:kh=\E[1~:tc=xterm-basic:
|
|
87
|
+
|
|
88
|
+
v1|xterm-24|xterms|vs100|24x80 xterm:\
|
|
89
|
+
:li#24:tc=xterm-old:
|
|
90
|
+
v2|xterm-65|65x80 xterm:\
|
|
91
|
+
:li#65:tc=xterm-old:
|
|
92
|
+
vb|xterm-bold|xterm with bold for underline:\
|
|
93
|
+
:so=\E[7m:us=\E[1m:tc=xterm-old:
|
|
94
|
+
vB|xterm-boldso|xterm with bold for standout:\
|
|
95
|
+
:se=\E[m:so=\E[1m:tc=xterm-old:
|
|
96
|
+
vm|xterm-mono|monochrome xterm:\
|
|
97
|
+
:ut@:\
|
|
98
|
+
:Co@:NC@:kn#20:pa@:\
|
|
99
|
+
:AB@:AF@:Sb@:Sf@:op@:st@:tc=xterm-old:
|
|
100
|
+
#
|
|
101
|
+
# Alternate terminal description that "works" for interactive shells such as
|
|
102
|
+
# tcsh and bash.
|
|
103
|
+
xn|xterm-noapp|xterm with cursor keys in normal mode:\
|
|
104
|
+
:kd=\E[B:ke=\E>:kl=\E[D:kr=\E[C:ks=\E=:ku=\E[A:te@:ti@:\
|
|
105
|
+
:tc=xterm:
|
|
106
|
+
#
|
|
107
|
+
# This should work for the commonly used "color xterm" variations (XFree86
|
|
108
|
+
# xterm, color_xterm, nxterm, rxvt). Note that it does not set 'bce', so for
|
|
109
|
+
# XFree86 and rxvt, some applications that use colors will be less efficient,
|
|
110
|
+
# and in a few special cases (with "smart" optimization) the wrong color will
|
|
111
|
+
# be painted in spots.
|
|
112
|
+
vc|xterm-color|generic "ANSI" color xterm:\
|
|
113
|
+
:Co#8:NC@:pa#64:\
|
|
114
|
+
:AB=\E[4%dm:AF=\E[3%dm:ac=:op=\E[m:tc=xterm-r6:
|
|
115
|
+
#
|
|
116
|
+
# These aliases are for compatibility with the terminfo; termcap cannot provide
|
|
117
|
+
# the extra features such as color initialization, but termcap applications
|
|
118
|
+
# still want the names.
|
|
119
|
+
x1|xterm-16color|xterm alias:\
|
|
120
|
+
:tc=xterm-new:
|
|
121
|
+
|
|
122
|
+
x2|xterm-88color|xterm alias:\
|
|
123
|
+
:Co#88:pa#7744:tc=xterm-256color:
|
|
124
|
+
|
|
125
|
+
x3|xterm-256color|xterm alias:\
|
|
126
|
+
:Co#256:pa#32767:\
|
|
127
|
+
:AB=\E[48;5;%dm:AF=\E[38;5;%dm:tc=xterm-new:
|
|
128
|
+
|
|
129
|
+
xi|xterm-nrc|xterm alias:\
|
|
130
|
+
:tc=xterm:
|
|
131
|
+
xr|xterm-rep|xterm alias:\
|
|
132
|
+
:tc=xterm:
|
|
133
|
+
xx|xterm-xmc|xterm alias:\
|
|
134
|
+
:sg#1:tc=xterm:
|
|
135
|
+
#
|
|
136
|
+
# An 8-bit description is doable with termcap, but there are probably no
|
|
137
|
+
# termcap (or BSD curses) applications that are able to use it.
|
|
138
|
+
x8|xterm-8bit|xterm terminal emulator 8-bit controls (X Window System):\
|
|
139
|
+
:am:km:mi:ms:xn:\
|
|
140
|
+
:co#80:it#8:li#24:\
|
|
141
|
+
:AL=\233%dL:DC=\233%dP:DL=\233%dM:DO=\233%dB:IC=\233%d@:\
|
|
142
|
+
:K2=\217y:Km=\233M:LE=\233%dD:RI=\233%dC:UP=\233%dA:\
|
|
143
|
+
:ae=\E(B:al=\233L:as=\E(0:bl=^G:bt=\233Z:cd=\233J:ce=\233K:\
|
|
144
|
+
:cl=\233H\2332J:cm=\233%i%d;%dH:cr=^M:cs=\233%i%d;%dr:\
|
|
145
|
+
:ct=\2333g:dc=\233P:dl=\233M:do=^J:ei=\2334l:ho=\233H:\
|
|
146
|
+
:im=\2334h:\
|
|
147
|
+
:is=\E[62"p\E G\233m\233?7h\E>\E7\233?1;3;4;6l\2334l\233r\E8:\
|
|
148
|
+
:k1=\23311~:k2=\23312~:k3=\23313~:k4=\23314~:k5=\23315~:\
|
|
149
|
+
:k6=\23317~:k7=\23318~:k8=\23319~:k9=\23320~:kD=\2333~:\
|
|
150
|
+
:kI=\2332~:kN=\2336~:kP=\2335~:kd=\217B:ke=\233?1l\E>:\
|
|
151
|
+
:kh=\2331~:kl=\217D:kr=\217C:ks=\233?1h\E=:ku=\217A:le=^H:\
|
|
152
|
+
:mb=\2335m:md=\2331m:me=\233m:mr=\2337m:nd=\233C:rc=\E8:\
|
|
153
|
+
:sc=\E7:se=\23327m:sf=^J:so=\2337m:sr=\215:st=\210:ta=^I:\
|
|
154
|
+
:te=\233?1049l:ti=\233?1049h:ue=\23324m:up=\233A:\
|
|
155
|
+
:us=\2334m:vb=\233?5h\233?5l:ve=\233?25l\233?25h:\
|
|
156
|
+
:vi=\233?25l:vs=\233?12;25h:tc=xterm+kbs:
|
|
157
|
+
#
|
|
158
|
+
hp|xterm-hp|xterm with hpterm function keys:\
|
|
159
|
+
:@7=\EF:k1=\Ep:k2=\Eq:k3=\Er:k4=\Es:k5=\Et:k6=\Eu:k7=\Ev:\
|
|
160
|
+
:k8=\Ew:kC=\EJ:kD=\EP:kI=\EQ:kN=\ES:kP=\ET:kd=\EB:kh=\Eh:\
|
|
161
|
+
:kl=\ED:kr=\EC:ku=\EA:tc=xterm-basic:
|
|
162
|
+
#
|
|
163
|
+
xS|xterm-sco|xterm with SCO function keys:\
|
|
164
|
+
:@7=\E[F:F1=\E[W:F2=\E[X:F3=\E[Y:F5=\E[a:F6=\E[b:F7=\E[c:\
|
|
165
|
+
:F8=\E[d:F9=\E[e:FA=\E[f:FB=\E[g:FC=\E[h:FD=\E[i:FE=\E[j:\
|
|
166
|
+
:FF=\E[k:ac=:k1=\E[M:k2=\E[N:k3=\E[O:k4=\E[P:k5=\E[Q:\
|
|
167
|
+
:k6=\E[R:k7=\E[S:k8=\E[T:k9=\E[U:k;=\E[V:kD=\177:kI=\E[L:\
|
|
168
|
+
:kN=\E[G:kP=\E[I:kd=\E[B:kh=\E[H:kl=\E[D:kr=\E[C:ku=\E[A:\
|
|
169
|
+
:tc=xterm-basic:
|
|
170
|
+
#
|
|
171
|
+
v5|xterm-vt52|xterm emulating vt52:\
|
|
172
|
+
:bs:\
|
|
173
|
+
:co#80:it#8:li#24:\
|
|
174
|
+
:ae=\EG:as=\EF:bl=^G:cd=\EJ:ce=\EK:cl=\EH\EJ:cm=\EY%+ %+ :\
|
|
175
|
+
:cr=^M:do=\EB:ho=\EH:kd=\EB:kl=\ED:kr=\EC:ku=\EA:le=\ED:\
|
|
176
|
+
:nd=\EC:nw=^M^J:sf=^J:sr=\EI:ta=^I:up=\EA:tc=xterm+kbs:
|
|
177
|
+
#
|
|
178
|
+
xs|xterm-sun|xterm with Sun functionkeys:\
|
|
179
|
+
:%1=\E[196z:&8=\E[195z:@0=\E[200z:@5=\E[197z:@7=\E[220z:\
|
|
180
|
+
:F1=\E[192z:F2=\E[193z:K2=\E[218z:Km=\E[M:k1=\E[224z:\
|
|
181
|
+
:k2=\E[225z:k3=\E[226z:k4=\E[227z:k5=\E[228z:k6=\E[229z:\
|
|
182
|
+
:k7=\E[230z:k8=\E[231z:k9=\E[232z:k;=\E[233z:kD=\E[3z:\
|
|
183
|
+
:kI=\E[2z:kN=\E[222z:kP=\E[216z:kh=\E[214z:\
|
|
184
|
+
:tc=xterm-basic:
|
|
185
|
+
#
|
|
186
|
+
# vi may work better with this entry, because vi doesn't use insert mode much.
|
|
187
|
+
# |xterm-ic|xterm-vi|xterm with insert character instead of insert mode:\
|
|
188
|
+
vi|xterm-ic|xterm-vi|xterm with insert char:\
|
|
189
|
+
:mi@:\
|
|
190
|
+
:IC=\E[%d@:ei@:ic=\E[@:im@:tc=xterm:
|
|
191
|
+
#
|
|
192
|
+
# Compatible with the X11R6.3 xterm
|
|
193
|
+
r6|xterm-r6|xterm-old|X11R6 xterm:\
|
|
194
|
+
:am:bs:km:mi:ms:pt:xn:\
|
|
195
|
+
:co#80:kn#20:li#24:\
|
|
196
|
+
:*6=\E[4~:@0=\E[1~:@7=\E[4~:AL=\E[%dL:DC=\E[%dP:DL=\E[%dM:\
|
|
197
|
+
:DO=\E[%dB:F1=\E[23~:F2=\E[24~:F3=\E[25~:F4=\E[26~:\
|
|
198
|
+
:F5=\E[28~:F6=\E[29~:F7=\E[31~:F8=\E[32~:F9=\E[33~:\
|
|
199
|
+
:FA=\E[34~:LE=\E[%dD:RI=\E[%dC:UP=\E[%dA:ae=^O:al=\E[L:\
|
|
200
|
+
:as=^N:bl=^G:cd=\E[J:ce=\E[K:cl=\E[H\E[2J:cm=\E[%i%d;%dH:\
|
|
201
|
+
:cs=\E[%i%d;%dr:ct=\E[3g:dc=\E[P:dl=\E[M:eA=\E)0:ei=\E[4l:\
|
|
202
|
+
:ho=\E[H:im=\E[4h:\
|
|
203
|
+
:is=\E[m\E[?7h\E[4l\E>\E7\E[r\E[?1;3;4;6l\E8:\
|
|
204
|
+
:k1=\E[11~:k2=\E[12~:k3=\E[13~:k4=\E[14~:k5=\E[15~:\
|
|
205
|
+
:k6=\E[17~:k7=\E[18~:k8=\E[19~:k9=\E[20~:k;=\E[21~:\
|
|
206
|
+
:kD=\E[3~:kI=\E[2~:kN=\E[6~:kP=\E[5~:kd=\EOB:ke=\E[?1l\E>:\
|
|
207
|
+
:kh=\E[1~:kl=\EOD:kr=\EOC:ks=\E[?1h\E=:ku=\EOA:md=\E[1m:\
|
|
208
|
+
:me=\E[m:ml=\El:mr=\E[7m:mu=\Em:nd=\E[C:rc=\E8:\
|
|
209
|
+
:rs=\E[m\E[?7h\E[4l\E>\E7\E[r\E[?1;3;4;6l\E8:sc=\E7:\
|
|
210
|
+
:se=\E[m:sf=^J:so=\E[7m:sr=\EM:te=\E[2J\E[?47l\E8:\
|
|
211
|
+
:ti=\E7\E[?47h:ue=\E[m:up=\E[A:us=\E[4m:tc=xterm+kbs:
|
|
212
|
+
#
|
|
213
|
+
# Compatible with the R5 xterm
|
|
214
|
+
r5|xterm-r5|X11R5 xterm X11R5:\
|
|
215
|
+
:am:bs:km:mi:ms:pt:xn:\
|
|
216
|
+
:co#80:kn#4:li#24:\
|
|
217
|
+
:@7=\E[4~:AL=\E[%dL:DC=\E[%dP:DL=\E[%dM:DO=\E[%dB:\
|
|
218
|
+
:IC=\E[%d@:UP=\E[%dA:al=\E[L:cd=\E[J:ce=\E[K:cl=\E[H\E[2J:\
|
|
219
|
+
:cm=\E[%i%d;%dH:cs=\E[%i%d;%dr:ct=\E[3g:dc=\E[P:dl=\E[M:\
|
|
220
|
+
:ei=\E[4l:ho=\E[H:im=\E[4h:\
|
|
221
|
+
:is=\E[r\E[m\E[2J\E[H\E[?7h\E[?1;3;4;6l\E[4l:\
|
|
222
|
+
:k1=\E[11~:k2=\E[12~:k3=\E[13~:k4=\E[14~:kd=\EOB:\
|
|
223
|
+
:ke=\E[?1l\E>:kh=\E[1~:kl=\EOD:kr=\EOC:ks=\E[?1h\E=:\
|
|
224
|
+
:ku=\EOA:md=\E[1m:me=\E[m:mr=\E[7m:nd=\E[C:rc=\E8:\
|
|
225
|
+
:rs=\E>\E[?1;3;4;5;6l\E[4l\E[?7h\E[m\E[r\E[2J\E[H:\
|
|
226
|
+
:sc=\E7:se=\E[m:sf=^J:so=\E[7m:sr=\EM:te=\E[2J\E[?47l\E8:\
|
|
227
|
+
:ti=\E7\E[?47h:ue=\E[m:up=\E[A:us=\E[4m:tc=xterm+kbs:
|
|
228
|
+
#
|
|
229
|
+
# Customization begins here.
|
|
230
|
+
x0|xterm-xfree86|xterm terminal emulator (XFree86):\
|
|
231
|
+
:tc=xterm-new:
|
|
232
|
+
#
|
|
233
|
+
# This is the only entry which you should have to customize, since "xterm"
|
|
234
|
+
# is widely used for a variety of incompatible terminal emulations including
|
|
235
|
+
# color_xterm and rxvt.
|
|
236
|
+
v0|xterm|X11 terminal emulator:\
|
|
237
|
+
:tc=xterm-new:
|
|
238
|
+
# :tc=xterm-r6:
|
|
239
|
+
|
|
240
|
+
# This fragment is for people who cannot agree on what the backspace key
|
|
241
|
+
# should send.
|
|
242
|
+
xterm+kbs|fragment for backspace key:\
|
|
243
|
+
:kb=^H:
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "starlight-cli",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.14",
|
|
4
4
|
"description": "Starlight Programming Language CLI",
|
|
5
5
|
"bin": {
|
|
6
6
|
"starlight": "index.js"
|
|
@@ -15,6 +15,7 @@
|
|
|
15
15
|
"win32"
|
|
16
16
|
],
|
|
17
17
|
"dependencies": {
|
|
18
|
+
"blessed": "^0.1.81",
|
|
18
19
|
"readline-sync": "^1.4.10"
|
|
19
20
|
},
|
|
20
21
|
"devDependencies": {
|
package/src/starlight.js
CHANGED
|
@@ -2,12 +2,14 @@ const fs = require('fs');
|
|
|
2
2
|
const path = require('path');
|
|
3
3
|
const os = require('os');
|
|
4
4
|
const { exec } = require('child_process');
|
|
5
|
-
|
|
5
|
+
const readline = require('readline');
|
|
6
|
+
const readlineSync = require('readline-sync');
|
|
7
|
+
const blessed = require('blessed');
|
|
6
8
|
const Lexer = require('./lexer');
|
|
7
9
|
const Parser = require('./parser');
|
|
8
10
|
const Evaluator = require('./evaluator');
|
|
9
11
|
|
|
10
|
-
const VERSION = '1.0.
|
|
12
|
+
const VERSION = '1.0.14';
|
|
11
13
|
|
|
12
14
|
const COLOR = {
|
|
13
15
|
reset: '\x1b[0m',
|
|
@@ -17,30 +19,38 @@ const COLOR = {
|
|
|
17
19
|
blue: '\x1b[34m',
|
|
18
20
|
cyan: '\x1b[36m',
|
|
19
21
|
gray: '\x1b[90m',
|
|
20
|
-
green: '\x1b[32m'
|
|
22
|
+
green: '\x1b[32m',
|
|
23
|
+
magenta: '\x1b[35m'
|
|
21
24
|
};
|
|
22
25
|
|
|
26
|
+
|
|
23
27
|
function waitAndExit(code = 0) {
|
|
28
|
+
try { process.stdin.setRawMode(true); } catch {}
|
|
24
29
|
console.error(COLOR.gray + '\nPress any key to exit...' + COLOR.reset);
|
|
25
|
-
process.stdin.setRawMode(true);
|
|
26
30
|
process.stdin.resume();
|
|
27
31
|
process.stdin.once('data', () => process.exit(code));
|
|
28
32
|
}
|
|
29
33
|
|
|
30
34
|
function fatal(msg) {
|
|
31
35
|
console.error(COLOR.red + msg + COLOR.reset);
|
|
32
|
-
|
|
36
|
+
waitAndExit(1);
|
|
33
37
|
}
|
|
34
38
|
|
|
35
|
-
function printSourceContext(code, line, column) {
|
|
36
|
-
const lines = code.split('\n');
|
|
37
|
-
const srcLine = lines[line - 1];
|
|
38
|
-
if (!srcLine) return;
|
|
39
39
|
|
|
40
|
-
|
|
41
|
-
|
|
40
|
+
function highlightCode(line) {
|
|
41
|
+
return line
|
|
42
|
+
// strings
|
|
43
|
+
.replace(/"(?:\\.|[^"])*"/g, m => COLOR.yellow + m + COLOR.reset)
|
|
44
|
+
// numbers
|
|
45
|
+
.replace(/\b\d+(\.\d+)?\b/g, m => COLOR.magenta + m + COLOR.reset)
|
|
46
|
+
// keywords
|
|
47
|
+
.replace(
|
|
48
|
+
/\b(sldeploy|import|from|const|let|var|if|else|for|while|func|return|break|continue|define|ask)\b/g,
|
|
49
|
+
m => COLOR.blue + m + COLOR.reset
|
|
50
|
+
);
|
|
42
51
|
}
|
|
43
52
|
|
|
53
|
+
|
|
44
54
|
const args = process.argv.slice(2);
|
|
45
55
|
|
|
46
56
|
if (args.length === 0) {
|
|
@@ -48,12 +58,11 @@ if (args.length === 0) {
|
|
|
48
58
|
Starlight Programming Language
|
|
49
59
|
|
|
50
60
|
Usage:
|
|
51
|
-
starlight <file.sl>
|
|
52
|
-
starlight -v
|
|
53
|
-
starlight --help
|
|
54
|
-
starlight --learn
|
|
55
|
-
starlight --writedirectly
|
|
56
|
-
starlight --viewfilelist View SL files in a folder
|
|
61
|
+
starlight <file.sl>
|
|
62
|
+
starlight -v
|
|
63
|
+
starlight --help
|
|
64
|
+
starlight --learn
|
|
65
|
+
starlight --writedirectly
|
|
57
66
|
`);
|
|
58
67
|
process.exit(0);
|
|
59
68
|
}
|
|
@@ -65,153 +74,156 @@ if (args[0] === '-v' || args[0] === '--version') {
|
|
|
65
74
|
|
|
66
75
|
if (args[0] === '--help') {
|
|
67
76
|
console.log(`
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
starlight file.sl Run a Starlight program
|
|
72
|
-
starlight -v Show version
|
|
73
|
-
starlight --learn Open learning guide
|
|
74
|
-
starlight --writedirectly Write & run temporary code
|
|
75
|
-
starlight --viewfilelist View SL files in a folder
|
|
77
|
+
starlight <file.sl> Run file
|
|
78
|
+
starlight --writedirectly Interactive editor
|
|
79
|
+
starlight --learn Learning guide
|
|
76
80
|
`);
|
|
77
81
|
process.exit(0);
|
|
78
82
|
}
|
|
79
83
|
|
|
80
84
|
if (args[0] === '--learn') {
|
|
81
|
-
console.log(COLOR.cyan + 'Opening Starlight Learning Guide...' + COLOR.reset);
|
|
82
85
|
exec('start https://programming-lang.pages.dev/learning-guide');
|
|
83
86
|
process.exit(0);
|
|
84
87
|
}
|
|
85
88
|
|
|
86
|
-
if (args[0] === '--viewfilelist') {
|
|
87
|
-
const readlineSync = require('readline-sync');
|
|
88
|
-
const folderPath = readlineSync.question(COLOR.cyan + 'Paste folder path to search .sl files: ' + COLOR.reset).trim();
|
|
89
|
-
if (!folderPath) return waitAndExit(0);
|
|
90
|
-
if (!fs.existsSync(folderPath) || !fs.lstatSync(folderPath).isDirectory()) return fatal('Invalid folder path.');
|
|
91
|
-
const files = fs.readdirSync(folderPath).filter(f => f.endsWith('.sl'));
|
|
92
|
-
if (files.length === 0) console.log(COLOR.yellow + 'No .sl files found in folder.' + COLOR.reset);
|
|
93
|
-
else {
|
|
94
|
-
console.log(COLOR.green + `Found ${files.length} .sl files:` + COLOR.reset);
|
|
95
|
-
files.forEach(f => console.log(' ' + f));
|
|
96
|
-
}
|
|
97
|
-
return waitAndExit(0);
|
|
98
|
-
}
|
|
99
89
|
|
|
100
90
|
if (args[0] === '--writedirectly') {
|
|
101
|
-
const
|
|
102
|
-
const tempFile = path.join(os.tmpdir(), `starlight
|
|
91
|
+
const blessed = require('blessed');
|
|
92
|
+
const tempFile = path.join(os.tmpdir(), `starlight-${Date.now()}.sl`);
|
|
103
93
|
|
|
104
|
-
|
|
105
|
-
|
|
94
|
+
const screen = blessed.screen({
|
|
95
|
+
smartCSR: true,
|
|
96
|
+
title: 'Starlight Editor'
|
|
97
|
+
});
|
|
98
|
+
|
|
99
|
+
const statusBar = blessed.box({
|
|
100
|
+
top: 0,
|
|
101
|
+
left: 0,
|
|
102
|
+
height: 1,
|
|
103
|
+
width: '100%',
|
|
104
|
+
content: 'Starlight Editor | Ctrl+S Save | Ctrl+R Run | Ctrl+Q Quit',
|
|
105
|
+
style: { fg: 'black', bg: 'green' }
|
|
106
|
+
});
|
|
106
107
|
|
|
107
|
-
const
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
108
|
+
const editor = blessed.textarea({
|
|
109
|
+
top: 1,
|
|
110
|
+
left: 0,
|
|
111
|
+
width: '100%',
|
|
112
|
+
height: '100%-2',
|
|
113
|
+
keys: true,
|
|
114
|
+
mouse: true,
|
|
115
|
+
scrollbar: { bg: 'gray' },
|
|
116
|
+
style: { fg: 'white', bg: 'black' },
|
|
117
|
+
inputOnFocus: true
|
|
111
118
|
});
|
|
112
119
|
|
|
113
|
-
|
|
120
|
+
const output = blessed.box({
|
|
121
|
+
bottom: 0,
|
|
122
|
+
left: 0,
|
|
123
|
+
height: 1,
|
|
124
|
+
width: '100%',
|
|
125
|
+
content: ' Ready ',
|
|
126
|
+
style: { fg: 'white', bg: 'blue' }
|
|
127
|
+
});
|
|
114
128
|
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
129
|
+
screen.append(statusBar);
|
|
130
|
+
screen.append(editor);
|
|
131
|
+
screen.append(output);
|
|
132
|
+
|
|
133
|
+
if (fs.existsSync(tempFile)) {
|
|
134
|
+
editor.setValue(fs.readFileSync(tempFile, 'utf8'));
|
|
135
|
+
}
|
|
136
|
+
|
|
137
|
+
editor.focus();
|
|
138
|
+
screen.render();
|
|
139
|
+
|
|
140
|
+
function highlightCode(text) {
|
|
141
|
+
return text
|
|
142
|
+
.replace(/"(.*?)"/g, '{yellow-fg}"$1"{/}')
|
|
143
|
+
.replace(/\b\d+(\.\d+)?\b/g, '{magenta-fg}$&{/}')
|
|
144
|
+
.replace(/\b(sldeploy|import|from|const|let|var|if|else|for|while|func|return|break|continue|define|ask)\b/g, '{blue-fg}$1{/}');
|
|
121
145
|
}
|
|
122
146
|
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
147
|
+
screen.key(['C-q'], () => screen.destroy());
|
|
148
|
+
screen.key(['C-s'], () => {
|
|
149
|
+
fs.writeFileSync(tempFile, editor.getValue());
|
|
150
|
+
output.setContent(' Saved ');
|
|
151
|
+
screen.render();
|
|
152
|
+
});
|
|
153
|
+
screen.key(['C-r'], () => {
|
|
154
|
+
fs.writeFileSync(tempFile, editor.getValue());
|
|
155
|
+
output.setContent(' Running... ');
|
|
156
|
+
screen.render();
|
|
157
|
+
|
|
158
|
+
runFile(tempFile, true, () => {
|
|
159
|
+
output.setContent(' Program finished ');
|
|
160
|
+
screen.render();
|
|
161
|
+
});
|
|
162
|
+
});
|
|
163
|
+
|
|
164
|
+
editor.on('keypress', () => {
|
|
165
|
+
const cursor = editor.getCursor();
|
|
166
|
+
editor.setValue(highlightCode(editor.getValue()));
|
|
167
|
+
editor.move(cursor.y, cursor.x);
|
|
168
|
+
screen.render();
|
|
135
169
|
});
|
|
136
170
|
|
|
171
|
+
screen.render();
|
|
137
172
|
return;
|
|
138
173
|
}
|
|
139
174
|
|
|
140
|
-
function saveTempFilePrompt(lines) {
|
|
141
|
-
const readlineSync = require('readline-sync');
|
|
142
|
-
const saveChoice = readlineSync.question(COLOR.cyan + 'Do you want to save this code? (y/n): ' + COLOR.reset).trim().toLowerCase();
|
|
143
|
-
if (saveChoice !== 'y') return waitAndExit(0);
|
|
144
175
|
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
176
|
+
function savePrompt(lines) {
|
|
177
|
+
try { process.stdin.setRawMode(false); } catch {}
|
|
178
|
+
|
|
179
|
+
const save = readlineSync
|
|
180
|
+
.question(COLOR.cyan + 'Do you want to save this code? (y/n): ' + COLOR.reset)
|
|
181
|
+
.trim()
|
|
182
|
+
.toLowerCase();
|
|
183
|
+
|
|
184
|
+
if (save !== 'y') return waitAndExit(0);
|
|
185
|
+
|
|
186
|
+
const dir = readlineSync.question(
|
|
187
|
+
COLOR.cyan + 'Folder path: ' + COLOR.reset
|
|
188
|
+
).trim();
|
|
189
|
+
|
|
190
|
+
if (!fs.existsSync(dir)) {
|
|
191
|
+
console.log(COLOR.yellow + 'Invalid folder.' + COLOR.reset);
|
|
148
192
|
return waitAndExit(0);
|
|
149
193
|
}
|
|
150
194
|
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
fileName = readlineSync.question(COLOR.red + 'File exists! Enter a new name (or leave blank to cancel): ' + COLOR.reset).trim();
|
|
157
|
-
if (!fileName) {
|
|
158
|
-
console.log(COLOR.yellow + 'Skipping save.' + COLOR.reset);
|
|
159
|
-
return waitAndExit(0);
|
|
160
|
-
}
|
|
161
|
-
fullPath = path.join(folderPath, fileName.endsWith('.sl') ? fileName : fileName + '.sl');
|
|
162
|
-
}
|
|
195
|
+
const name = readlineSync.question(
|
|
196
|
+
COLOR.cyan + 'File name: ' + COLOR.reset
|
|
197
|
+
).trim();
|
|
198
|
+
|
|
199
|
+
if (!name) return waitAndExit(0);
|
|
163
200
|
|
|
164
|
-
|
|
165
|
-
|
|
201
|
+
const file = path.join(dir, name.endsWith('.sl') ? name : name + '.sl');
|
|
202
|
+
fs.writeFileSync(file, lines.join('\n'), 'utf8');
|
|
203
|
+
|
|
204
|
+
console.log(COLOR.green + `Saved to ${file}` + COLOR.reset);
|
|
166
205
|
waitAndExit(0);
|
|
167
206
|
}
|
|
168
207
|
|
|
169
|
-
function runFile(filePath, isTemp = false, callback
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
let code;
|
|
173
|
-
try { code = fs.readFileSync(filePath, 'utf-8'); }
|
|
174
|
-
catch (err) { return fatal(`Failed to read file: ${err.message}`); }
|
|
208
|
+
function runFile(filePath, isTemp = false, callback) {
|
|
209
|
+
const code = fs.readFileSync(filePath, 'utf8');
|
|
175
210
|
|
|
176
|
-
let tokens;
|
|
177
211
|
try {
|
|
178
212
|
const lexer = new Lexer(code);
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
console.error(COLOR.
|
|
184
|
-
if (err.line && err.column) printSourceContext(code, err.line, err.column);
|
|
185
|
-
return waitAndExit(1);
|
|
186
|
-
}
|
|
187
|
-
|
|
188
|
-
let ast;
|
|
189
|
-
try {
|
|
190
|
-
const parser = new Parser(tokens);
|
|
191
|
-
ast = parser.parse();
|
|
192
|
-
} catch (err) {
|
|
193
|
-
console.error(COLOR.red + COLOR.bold + 'Starlight Parser Error' + COLOR.reset);
|
|
194
|
-
console.error(COLOR.cyan + `File: ${filePath}` + COLOR.reset);
|
|
195
|
-
console.error(COLOR.yellow + `Message: ${err.message}` + COLOR.reset);
|
|
196
|
-
if (err.token && err.token.line && err.token.column) printSourceContext(code, err.token.line, err.token.column);
|
|
197
|
-
return waitAndExit(1);
|
|
198
|
-
}
|
|
199
|
-
|
|
200
|
-
try {
|
|
201
|
-
const evaluator = new Evaluator();
|
|
202
|
-
evaluator.evaluate(ast);
|
|
203
|
-
} catch (err) {
|
|
204
|
-
console.error(COLOR.red + COLOR.bold + 'Starlight Runtime Error' + COLOR.reset);
|
|
205
|
-
console.error(COLOR.cyan + `File: ${filePath}` + COLOR.reset);
|
|
206
|
-
console.error(COLOR.yellow + `Message: ${err.message}` + COLOR.reset);
|
|
207
|
-
if (err.line && err.column) printSourceContext(code, err.line, err.column);
|
|
213
|
+
const parser = new Parser(lexer.getTokens());
|
|
214
|
+
const ast = parser.parse();
|
|
215
|
+
new Evaluator().evaluate(ast);
|
|
216
|
+
} catch (e) {
|
|
217
|
+
console.error(COLOR.red + e.message + COLOR.reset);
|
|
208
218
|
return waitAndExit(1);
|
|
209
219
|
}
|
|
210
220
|
|
|
211
221
|
console.log(COLOR.green + '\nProgram finished successfully.' + COLOR.reset);
|
|
222
|
+
|
|
212
223
|
if (callback) callback();
|
|
213
|
-
if (isTemp)
|
|
224
|
+
if (isTemp) try { fs.unlinkSync(filePath); } catch {}
|
|
214
225
|
}
|
|
215
|
-
|
|
226
|
+
|
|
227
|
+
if (!args[0].startsWith('--')) {
|
|
216
228
|
runFile(path.resolve(args[0]));
|
|
217
229
|
}
|