-
Notifications
You must be signed in to change notification settings - Fork 2
/
command.go
63 lines (52 loc) · 1.06 KB
/
command.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
package beebui
import (
"fmt"
"runtime"
"strings"
"time"
"fyne.io/fyne/v2"
"fyne.io/fyne/v2/canvas"
"github.com/skx/gobasic/builtin"
"github.com/skx/gobasic/object"
)
func (b *beeb) CLS(env builtin.Environment, args []object.Object) object.Object {
for i := 0; i < len(b.content); i++ {
text := b.content[i].(*canvas.Text)
text.Text = ""
canvas.Refresh(text)
}
b.current = 0
return &object.NumberObject{Value: 0}
}
func (b *beeb) LIST() {
lines := strings.Split(b.program, "\n")
for i, line := range lines {
if i == len(lines)-1 {
break
}
b.appendLine(line)
}
}
func (b *beeb) NEW() {
b.program = ""
}
func (b *beeb) QUIT(app fyne.App) {
time.Sleep(lineDelay)
app.Quit()
}
func (b *beeb) RESTART() {
b.NEW()
b.CLS(nil, nil)
var m runtime.MemStats
runtime.ReadMemStats(&m)
b.appendLine(fmt.Sprintf("BBC Computer %dK", int(m.HeapSys/1024)))
b.appendLine("")
b.appendLine(strings.Title(runtime.GOOS) + " DFS")
b.appendLine("")
b.appendLine("BASIC")
b.appendLine("")
b.append(">")
}
func (b *beeb) RUN() {
b.runProg(b.program)
}