From 22ade886d56c3336c7104ca54d86fa3625275a44 Mon Sep 17 00:00:00 2001 From: Kartik Agaram Date: Mon, 26 Oct 2020 22:46:17 -0700 Subject: 7121 Starting to polish 'line-count' demo: filename line-count = filename open lines len --- apps/tile/environment.mu | 16 +++++++++++----- 1 file changed, 11 insertions(+), 5 deletions(-) diff --git a/apps/tile/environment.mu b/apps/tile/environment.mu index 971e8d9f..f483367f 100644 --- a/apps/tile/environment.mu +++ b/apps/tile/environment.mu @@ -1555,7 +1555,7 @@ fn clear-canvas _env: (addr environment) { print-string screen, " define function " # primitives var start-col/ecx: int <- copy repl-col - start-col <- subtract 0x18 + start-col <- subtract 0x20 move-cursor screen, 1, start-col print-string screen, "primitives:" start-col <- add 2 @@ -1576,8 +1576,7 @@ fn clear-canvas _env: (addr environment) { var curr/eax: (addr function) <- lookup *functions compare curr, 0 break-if-= - move-cursor screen, row, start-col - render-function screen, curr + row <- render-function screen, row, start-col, curr functions <- get curr, next row <- increment loop @@ -1585,18 +1584,25 @@ fn clear-canvas _env: (addr environment) { } # only single-line functions supported for now -fn render-function screen: (addr screen), _f: (addr function) { +fn render-function screen: (addr screen), row: int, col: int, _f: (addr function) -> out-row/ebx: int { var f/esi: (addr function) <- copy _f var args/ecx: (addr handle word) <- get f, args + move-cursor screen, row, col print-words-in-reverse screen, args var name-ah/eax: (addr handle array byte) <- get f, name var name/eax: (addr array byte) <- lookup *name-ah + start-bold screen print-string screen, name - print-string screen, " = " + reset-formatting screen + increment row + add-to col, 2 + move-cursor screen, row, col + print-string screen, "= " var body-ah/eax: (addr handle line) <- get f, body var body/eax: (addr line) <- lookup *body-ah var body-words-ah/eax: (addr handle word) <- get body, data print-words screen, body-words-ah + out-row <- copy row } fn real-grapheme? g: grapheme -> result/eax: boolean { -- cgit 1.4.1-2-gfad0 '>committer
path: root/026call.cc
blob: 113e71bba5e0ad3970b78a8aa2c67c04de0b62d3 (plain) (blame)
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
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173