Skip to content

Commit 55a0565

Browse files
author
udhos
committed
CLS.
1 parent 353e334 commit 55a0565

File tree

4 files changed

+53
-12
lines changed

4 files changed

+53
-12
lines changed

baslib/screen.go

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,14 @@ func Screen(mode int) {
4141
stdin = inkey.New(&scr) // replace inkey(os.Stdin) with inkey(tcell)
4242
}
4343

44+
func Cls() {
45+
if screenMode0() {
46+
scr.s.Clear()
47+
}
48+
screenPos = 1
49+
screenRow = 1
50+
}
51+
4452
type screen struct {
4553
s tcell.Screen
4654
keys chan tcell.EventKey

basparser/parser.y

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1008,7 +1008,11 @@ stmt: /* empty */
10081008
| TkKeywordKey TkKeywordList { $$ = unsupportedEmpty("KEY") }
10091009
| TkKeywordKey exp TkComma exp { $$ = unsupportedEmpty("KEY") }
10101010
| TkKeywordBeep { $$ = unsupportedEmpty("BEEP") }
1011-
| TkKeywordCls { $$ = unsupportedEmpty("CLS") }
1011+
| TkKeywordCls
1012+
{
1013+
Result.Baslib = true
1014+
$$ = &node.NodeCls{}
1015+
}
10121016
| TkKeywordWidth exp { $$ = unsupportedEmpty("WIDTH") }
10131017
| TkKeywordDefdbl letter_range_list
10141018
{

examples/screen.bas

Lines changed: 14 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,19 @@
11
110 print "hit ENTER to initialize screen 0"
22
120 print input$(1)
33
130 screen 0
4-
140 print "screen 0 initialized. hit key to see term width test "
4+
140 print "screen 0 initialized": print "hit key to see CLS test"
55
150 print input$(1)
6-
160 for i=1 to 200:print chr$((i mod 10)+asc("0"));:next
7-
170 print:print "width test done. hit key to see term scroll test"
6+
160 cls
7+
170 print "CLS tested. hit key to see term width test"
88
180 print input$(1)
9-
190 for i=1 to 30:print i:next
10-
200 print "scroll test done. hit key to test keyboard input"
11-
210 i$=input$(1)
12-
220 while i$<>"q"
13-
230 print "key:";i$;" asc:";asc(i$)
14-
240 print "hit any other key, or q to exit"
15-
250 i$=input$(1)
16-
260 wend
9+
190 for i=1 to 200:print chr$((i mod 10)+asc("0"));:next
10+
200 print:print "width test done. hit key to see term scroll test"
11+
210 print input$(1)
12+
220 for i=1 to 30:print i:next
13+
230 print "scroll test done. hit key to test keyboard input"
14+
240 i$=input$(1)
15+
250 while i$<>"q"
16+
260 print "key:";i$;" asc:";asc(i$)
17+
270 print "hit any other key, or q to exit"
18+
280 i$=input$(1)
19+
290 wend

node/node.go

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1806,3 +1806,29 @@ func (n *NodeScreen) Build(options *BuildOptions, outputf FuncPrintf) {
18061806
// FindUsedVars finds used vars
18071807
func (n *NodeScreen) FindUsedVars(options *BuildOptions) {
18081808
}
1809+
1810+
// NodeCls is cls
1811+
type NodeCls struct{}
1812+
1813+
// Name returns the name of the node
1814+
func (n *NodeCls) Name() string {
1815+
return "CLS"
1816+
}
1817+
1818+
// Show displays the node
1819+
func (n *NodeCls) Show(printf FuncPrintf) {
1820+
printf("[" + n.Name() + "]")
1821+
}
1822+
1823+
// Build generates code
1824+
func (n *NodeCls) Build(options *BuildOptions, outputf FuncPrintf) {
1825+
outputf("// ")
1826+
n.Show(outputf)
1827+
outputf("\n")
1828+
1829+
outputf("baslib.Cls()\n")
1830+
}
1831+
1832+
// FindUsedVars finds used vars
1833+
func (n *NodeCls) FindUsedVars(options *BuildOptions) {
1834+
}

0 commit comments

Comments
 (0)