1
+ # The architecture that seems to be crystallizing : the environment has two
2
+ # areas : functions and sandbox .
3
+ #
4
+ # Rendering the environment requires rendering all areas .
5
+ # Displaying the cursor requires displaying cursor for the area controlling the cursor .
6
+ # Processing events for the environment requires processing events for the area controlling the cursor .
7
+ #
8
+ # Areas can have dialogs .
9
+ # There can also be global dialogs (currently just one : goto function ).
10
+ # Areas are responsible for rendering their dialogs .
11
+ # In practice this results in dialogs encapsulating the state they need to
12
+ # decide whether to render .
13
+ #
14
+ # This will be useful if we add more areas in the future .
15
+
1
16
type environment {
2
17
screen : (handle screen )
3
18
functions : (handle function )
@@ -1085,6 +1100,17 @@ fn render _env: (addr environment) {
1085
1100
#? print - string 0 , "render-sandbox }\n "
1086
1101
# dialogs
1087
1102
render - goto - dialog screen , env
1103
+ #
1104
+ position - cursor screen , env
1105
+ }
1106
+
1107
+ fn position - cursor screen : (addr screen ), _env : (addr environment ) {
1108
+ var env / eax : (addr environment ) < - copy _env
1109
+ var cursor - sandbox - ah / eax : (addr handle sandbox ) < - get env , cursor - sandbox
1110
+ var cursor - sandbox / eax : (addr sandbox ) < - lookup * cursor - sandbox - ah
1111
+ var cursor - row / ecx : (addr int ) < - get cursor - sandbox , cursor - row
1112
+ var cursor - col / eax : (addr int ) < - get cursor - sandbox , cursor - col
1113
+ move - cursor screen , * cursor - row , * cursor - col
1088
1114
}
1089
1115
1090
1116
fn render - goto - dialog screen : (addr screen ), _env : (addr environment ) {
@@ -1135,13 +1161,11 @@ fn render-sandbox screen: (addr screen), functions: (addr handle function), bind
1135
1161
#
1136
1162
var curr - row / edx : int < - copy top - row
1137
1163
# cursor row , col
1138
- var cursor - row : int
1139
1164
var cursor - row - addr : (addr int )
1140
- var tmp / eax : (addr int ) < - address cursor - row
1165
+ var tmp / eax : (addr int ) < - get sandbox , cursor - row
1141
1166
copy - to cursor - row - addr , tmp
1142
- var cursor - col : int
1143
1167
var cursor - col - addr : (addr int )
1144
- tmp < - address cursor - col
1168
+ tmp < - get sandbox , cursor - col
1145
1169
copy - to cursor - col - addr , tmp
1146
1170
# render all but final line without stack
1147
1171
#? print - string 0 , "render all but final line\n "
@@ -1165,9 +1189,8 @@ fn render-sandbox screen: (addr screen), functions: (addr handle function), bind
1165
1189
#
1166
1190
render - final - line - with - stack screen , functions , bindings , sandbox , curr - row , left - col , cursor - row - addr , cursor - col - addr
1167
1191
# at most one of the following dialogs will be rendered
1168
- render - rename - dialog screen , sandbox , cursor - row , cursor - col
1169
- render - define - dialog screen , sandbox , cursor - row , cursor - col
1170
- move - cursor screen , cursor - row , cursor - col
1192
+ render - rename - dialog screen , sandbox
1193
+ render - define - dialog screen , sandbox
1171
1194
}
1172
1195
1173
1196
fn render - final - line - with - stack screen : (addr screen ), functions : (addr handle function ), bindings : (addr table ), _sandbox : (addr sandbox ), top - row : int , left - col : int , cursor - row - addr : (addr int ), cursor - col - addr : (addr int ) {
@@ -1222,20 +1245,22 @@ fn final-line _sandbox: (addr sandbox), out: (addr handle line) {
1222
1245
copy - object curr - line - ah , out
1223
1246
}
1224
1247
1225
- fn render - rename - dialog screen : (addr screen ), _sandbox : (addr sandbox ), cursor - row : int , cursor - col : int {
1248
+ fn render - rename - dialog screen : (addr screen ), _sandbox : (addr sandbox ) {
1226
1249
var sandbox / edi : (addr sandbox ) < - copy _sandbox
1227
1250
var rename - word - mode - ah ?/ ecx : (addr handle word ) < - get sandbox , partial - name - for - cursor - word
1228
1251
var rename - word - mode ?/ eax : (addr word ) < - lookup * rename - word - mode - ah ?
1229
1252
compare rename - word - mode ?, 0 # false
1230
1253
break - if - =
1231
1254
# clear a space for the dialog
1232
- var top - row / eax : int < - copy cursor - row
1255
+ var cursor - row / ebx : (addr int ) < - get sandbox , cursor - row
1256
+ var top - row / eax : int < - copy * cursor - row
1233
1257
top - row < - subtract 3
1234
- var bottom - row / ecx : int < - copy cursor - row
1258
+ var bottom - row / ecx : int < - copy * cursor - row
1235
1259
bottom - row < - add 3
1236
- var left - col / edx : int < - copy cursor - col
1260
+ var cursor - col / ebx : (addr int ) < - get sandbox , cursor - col
1261
+ var left - col / edx : int < - copy * cursor - col
1237
1262
left - col < - subtract 0x10
1238
- var right - col / ebx : int < - copy cursor - col
1263
+ var right - col / ebx : int < - copy * cursor - col
1239
1264
right - col < - add 0x10
1240
1265
clear - rect screen , top - row , left - col , bottom - row , right - col
1241
1266
draw - box screen , top - row , left - col , bottom - row , right - col
@@ -1254,30 +1279,34 @@ fn render-rename-dialog screen: (addr screen), _sandbox: (addr sandbox), cursor-
1254
1279
reset - formatting screen
1255
1280
print - string screen , " rename "
1256
1281
# draw the word , positioned appropriately around the cursor
1257
- var start - col / ecx : int < - copy cursor - col
1282
+ var cursor - col / ebx : (addr int ) < - get sandbox , cursor - col
1283
+ var start - col / ecx : int < - copy * cursor - col
1258
1284
var word - ah ?/ edx : (addr handle word ) < - get sandbox , partial - name - for - cursor - word
1259
1285
var word / eax : (addr word ) < - lookup * word - ah ?
1260
1286
var cursor - index / eax : int < - cursor - index word
1261
1287
start - col < - subtract cursor - index
1262
- move - cursor screen , cursor - row , start - col
1288
+ var cursor - row / ebx : (addr int ) < - get sandbox , cursor - row
1289
+ move - cursor screen , * cursor - row , start - col
1263
1290
var word / eax : (addr word ) < - lookup * word - ah ?
1264
1291
print - word screen , word
1265
1292
}
1266
1293
1267
- fn render - define - dialog screen : (addr screen ), _sandbox : (addr sandbox ), cursor - row : int , cursor - col : int {
1294
+ fn render - define - dialog screen : (addr screen ), _sandbox : (addr sandbox ) {
1268
1295
var sandbox / edi : (addr sandbox ) < - copy _sandbox
1269
1296
var define - function - mode - ah ?/ ecx : (addr handle word ) < - get sandbox , partial - name - for - function
1270
1297
var define - function - mode ?/ eax : (addr word ) < - lookup * define - function - mode - ah ?
1271
1298
compare define - function - mode ?, 0 # false
1272
1299
break - if - =
1273
1300
# clear a space for the dialog
1274
- var top - row / eax : int < - copy cursor - row
1301
+ var cursor - row / ebx : (addr int ) < - get sandbox , cursor - row
1302
+ var top - row / eax : int < - copy * cursor - row
1275
1303
top - row < - subtract 3
1276
- var bottom - row / ecx : int < - copy cursor - row
1304
+ var bottom - row / ecx : int < - copy * cursor - row
1277
1305
bottom - row < - add 3
1278
- var left - col / edx : int < - copy cursor - col
1306
+ var cursor - col / ebx : (addr int ) < - get sandbox , cursor - col
1307
+ var left - col / edx : int < - copy * cursor - col
1279
1308
left - col < - subtract 0x10
1280
- var right - col / ebx : int < - copy cursor - col
1309
+ var right - col / ebx : int < - copy * cursor - col
1281
1310
right - col < - add 0x10
1282
1311
clear - rect screen , top - row , left - col , bottom - row , right - col
1283
1312
draw - box screen , top - row , left - col , bottom - row , right - col
@@ -1296,12 +1325,14 @@ fn render-define-dialog screen: (addr screen), _sandbox: (addr sandbox), cursor-
1296
1325
reset - formatting screen
1297
1326
print - string screen , " define "
1298
1327
# draw the word , positioned appropriately around the cursor
1299
- var start - col / ecx : int < - copy cursor - col
1328
+ var cursor - col / ebx : (addr int ) < - get sandbox , cursor - col
1329
+ var start - col / ecx : int < - copy * cursor - col
1300
1330
var word - ah ?/ edx : (addr handle word ) < - get sandbox , partial - name - for - function
1301
1331
var word / eax : (addr word ) < - lookup * word - ah ?
1302
1332
var cursor - index / eax : int < - cursor - index word
1303
1333
start - col < - subtract cursor - index
1304
- move - cursor screen , cursor - row , start - col
1334
+ var cursor - row / ebx : (addr int ) < - get sandbox , cursor - row
1335
+ move - cursor screen , * cursor - row , start - col
1305
1336
var word / eax : (addr word ) < - lookup * word - ah ?
1306
1337
print - word screen , word
1307
1338
}
0 commit comments