about summary refs log tree commit diff stats
path: root/baremetal
diff options
context:
space:
mode:
Diffstat (limited to 'baremetal')
-rw-r--r--baremetal/shell/sandbox.mu21
-rw-r--r--baremetal/shell/trace.mu124
2 files changed, 140 insertions, 5 deletions
diff --git a/baremetal/shell/sandbox.mu b/baremetal/shell/sandbox.mu
index 3e37eac9..18bc1b09 100644
--- a/baremetal/shell/sandbox.mu
+++ b/baremetal/shell/sandbox.mu
@@ -158,6 +158,27 @@ fn edit-sandbox _self: (addr sandbox), key: byte {
     edit-gap-buffer data, g
     return
   }
+  {
+    compare g, 0x15/ctrl-u
+    break-if-!=
+    # ctrl-u: cursor up
+    var cursor-in-trace?/eax: (addr boolean) <- get self, cursor-in-trace?
+    # if cursor in trace, check if we need to switch to trace
+    # if cursor in trace, send cursor to trace
+    {
+      compare cursor-in-trace?, 0/false
+      break-if-=
+      var trace-ah/eax: (addr handle trace) <- get self, trace
+      var trace/eax: (addr trace) <- lookup *trace-ah
+      edit-trace trace, g
+      return
+    }
+    # otherwise send cursor to input
+    var data-ah/eax: (addr handle gap-buffer) <- get self, data
+    var data/eax: (addr gap-buffer) <- lookup *data-ah
+    edit-gap-buffer data, g
+    return
+  }
   # default: insert character
   add-grapheme-to-sandbox self, g
 }
diff --git a/baremetal/shell/trace.mu b/baremetal/shell/trace.mu
index b3a4666a..605ab36a 100644
--- a/baremetal/shell/trace.mu
+++ b/baremetal/shell/trace.mu
@@ -99,14 +99,17 @@ fn trace-higher _self: (addr trace) {
 
 fn render-trace screen: (addr screen), _self: (addr trace), xmin: int, ymin: int, xmax: int, ymax: int, show-cursor?: boolean -> _/ecx: int {
   var already-hiding-lines?/ebx: boolean <- copy 0/false
-  var bg/edi: int <- copy 0/black
+  var y/ecx: int <- copy ymin
+  var self/eax: (addr trace) <- copy _self
+  # initialize cursor-y if necessary
   compare show-cursor?, 0/false
   {
     break-if-=
-    bg <- copy 7/grey
+    var cursor-y/eax: (addr int) <- get self, cursor-y
+    compare *cursor-y, y
+    break-if->=
+    copy-to *cursor-y, y
   }
-  var y/ecx: int <- copy ymin
-  var self/eax: (addr trace) <- copy _self
   var trace-ah/eax: (addr handle stream trace-line) <- get self, data
   var _trace/eax: (addr stream trace-line) <- lookup *trace-ah
   var trace/esi: (addr stream trace-line) <- copy _trace
@@ -120,6 +123,16 @@ fn render-trace screen: (addr screen), _self: (addr trace), xmin: int, ymin: int
     read-from-stream trace, curr
     var curr-label-ah/eax: (addr handle array byte) <- get curr, label
     var curr-label/eax: (addr array byte) <- lookup *curr-label-ah
+    var bg/edi: int <- copy 0/black
+    compare show-cursor?, 0/false
+    {
+      break-if-=
+      var self/eax: (addr trace) <- copy _self
+      var cursor-y/eax: (addr int) <- get self, cursor-y
+      compare *cursor-y, y
+      break-if-!=
+      bg <- copy 7/grey
+    }
     # always display errors
     var is-error?/eax: boolean <- string-equal? curr-label, "error"
     {
@@ -145,6 +158,14 @@ fn render-trace screen: (addr screen), _self: (addr trace), xmin: int, ymin: int
     }
     loop
   }
+  # prevent cursor from going too far down
+  {
+    var self/eax: (addr trace) <- copy _self
+    var cursor-y/eax: (addr int) <- get self, cursor-y
+    compare *cursor-y, y
+    break-if-<=
+    copy-to *cursor-y, y
+  }
   return y
 }
 
@@ -270,5 +291,98 @@ fn test-render-trace-error-in-the-middle {
   check-screen-row screen, 2/y, "...  ", "F - test-render-trace-error-in-the-middle/2"
 }
 
-fn edit-trace self: (addr trace), key: grapheme {
+fn test-render-trace-cursor-in-single-line {
+  var t-storage: trace
+  var t/esi: (addr trace) <- address t-storage
+  initialize-trace t, 0x10
+  # line 1
+  var contents-storage: (stream byte 0x10)
+  var contents/ecx: (addr stream byte) <- address contents-storage
+  write contents, "data"
+  trace t, "l", contents
+  # line 2
+  error t, "error"
+  # line 3
+  trace t, "l", contents
+  # setup: screen
+  var screen-on-stack: screen
+  var screen/edi: (addr screen) <- address screen-on-stack
+  initialize-screen screen, 0xa, 4
+  #
+  var y/ecx: int <- render-trace screen, t, 0/xmin, 0/ymin, 0xa/xmax, 4/ymax, 1/show-cursor
+  #
+  check-screen-row screen,                                  0/y, "...   ", "F - test-render-trace-cursor-in-single-line/0"
+  check-background-color-in-screen-row screen, 7/bg=cursor, 0/y, "|||   ", "F - test-render-trace-cursor-in-single-line/0/cursor"
+  check-screen-row screen,                                  1/y, "error ", "F - test-render-trace-cursor-in-single-line/1"
+  check-background-color-in-screen-row screen, 7/bg=cursor, 1/y, "      ", "F - test-render-trace-cursor-in-single-line/1/cursor"
+  check-screen-row screen,                                  2/y, "...   ", "F - test-render-trace-cursor-in-single-line/2"
+  check-background-color-in-screen-row screen, 7/bg=cursor, 2/y, "      ", "F - test-render-trace-cursor-in-single-line/2/cursor"
+}
+
+fn edit-trace _self: (addr trace), key: grapheme {
+  var self/esi: (addr trace) <- copy _self
+  # cursor down
+  {
+    compare key, 4/ctrl-d
+    break-if-!=
+    var cursor-y/eax: (addr int) <- get self, cursor-y
+    increment *cursor-y
+    return
+  }
+  # cursor up
+  {
+    compare key, 0x15/ctrl-u
+    break-if-!=
+    var cursor-y/eax: (addr int) <- get self, cursor-y
+    decrement *cursor-y
+    return
+  }
+}
+
+fn test-cursor-down-and-up-within-trace {
+  var t-storage: trace
+  var t/esi: (addr trace) <- address t-storage
+  initialize-trace t, 0x10
+  # line 1
+  var contents-storage: (stream byte 0x10)
+  var contents/ecx: (addr stream byte) <- address contents-storage
+  write contents, "data"
+  trace t, "l", contents
+  # line 2
+  error t, "error"
+  # line 3
+  trace t, "l", contents
+  # setup: screen
+  var screen-on-stack: screen
+  var screen/edi: (addr screen) <- address screen-on-stack
+  initialize-screen screen, 0xa, 4
+  #
+  var y/ecx: int <- render-trace screen, t, 0/xmin, 0/ymin, 0xa/xmax, 4/ymax, 1/show-cursor
+  #
+  check-screen-row screen,                                  0/y, "...   ", "F - test-cursor-down-and-up-within-trace/pre-0"
+  check-background-color-in-screen-row screen, 7/bg=cursor, 0/y, "|||   ", "F - test-cursor-down-and-up-within-trace/pre-0/cursor"
+  check-screen-row screen,                                  1/y, "error ", "F - test-cursor-down-and-up-within-trace/pre-1"
+  check-background-color-in-screen-row screen, 7/bg=cursor, 1/y, "      ", "F - test-cursor-down-and-up-within-trace/pre-1/cursor"
+  check-screen-row screen,                                  2/y, "...   ", "F - test-cursor-down-and-up-within-trace/pre-2"
+  check-background-color-in-screen-row screen, 7/bg=cursor, 2/y, "      ", "F - test-cursor-down-and-up-within-trace/pre-2/cursor"
+  # cursor down
+  edit-trace t, 4/ctrl-d
+  var y/ecx: int <- render-trace screen, t, 0/xmin, 0/ymin, 0xa/xmax, 4/ymax, 1/show-cursor
+  #
+  check-screen-row screen,                                  0/y, "...   ", "F - test-cursor-down-and-up-within-trace/down-0"
+  check-background-color-in-screen-row screen, 7/bg=cursor, 0/y, "      ", "F - test-cursor-down-and-up-within-trace/down-0/cursor"
+  check-screen-row screen,                                  1/y, "error ", "F - test-cursor-down-and-up-within-trace/down-1"
+  check-background-color-in-screen-row screen, 7/bg=cursor, 1/y, "||||| ", "F - test-cursor-down-and-up-within-trace/down-1/cursor"
+  check-screen-row screen,                                  2/y, "...   ", "F - test-cursor-down-and-up-within-trace/down-2"
+  check-background-color-in-screen-row screen, 7/bg=cursor, 2/y, "      ", "F - test-cursor-down-and-up-within-trace/down-2/cursor"
+  # cursor up
+  edit-trace t, 0x15/ctrl-u
+  var y/ecx: int <- render-trace screen, t, 0/xmin, 0/ymin, 0xa/xmax, 4/ymax, 1/show-cursor
+  #
+  check-screen-row screen,                                  0/y, "...   ", "F - test-cursor-down-and-up-within-trace/up-0"
+  check-background-color-in-screen-row screen, 7/bg=cursor, 0/y, "|||   ", "F - test-cursor-down-and-up-within-trace/up-0/cursor"
+  check-screen-row screen,                                  1/y, "error ", "F - test-cursor-down-and-up-within-trace/up-1"
+  check-background-color-in-screen-row screen, 7/bg=cursor, 1/y, "      ", "F - test-cursor-down-and-up-within-trace/up-1/cursor"
+  check-screen-row screen,                                  2/y, "...   ", "F - test-cursor-down-and-up-within-trace/up-2"
+  check-background-color-in-screen-row screen, 7/bg=cursor, 2/y, "      ", "F - test-cursor-down-and-up-within-trace/up-2/cursor"
 }
committer Thomas E. Dickey <dickey@invisible-island.net> 1997-11-17 14:36:49 -0500 snapshot of project "lynx", label v2-7-1ac_0-95' href='/ingrix/lynx-snapshots/commit/src/chrtrans/cp1256_uni.tbl?id=e47cfd5646f55de9688ff42df3055fd9c09b503f'>e47cfd56 ^
479f8d01 ^
d3f9d547 ^
479f8d01 ^
d3f9d547 ^

e47cfd56 ^

479f8d01 ^
d3f9d547 ^
e47cfd56 ^




d3f9d547 ^
e47cfd56 ^
d3f9d547 ^
e47cfd56 ^
479f8d01 ^
d3f9d547 ^
e47cfd56 ^

d3f9d547 ^

e47cfd56 ^
d3f9d547 ^



e47cfd56 ^
d3f9d547 ^
e47cfd56 ^
d3f9d547 ^

e47cfd56 ^
d3f9d547 ^



e47cfd56 ^
479f8d01 ^
d3f9d547 ^





e47cfd56 ^
d3f9d547 ^



e47cfd56 ^
d3f9d547 ^

e47cfd56 ^

d3f9d547 ^
e47cfd56 ^






d3f9d547 ^
e47cfd56 ^


d3f9d547 ^
e47cfd56 ^
d3f9d547 ^

e47cfd56 ^
d3f9d547 ^
e47cfd56 ^

d3f9d547 ^
e47cfd56 ^
d3f9d547 ^








e47cfd56 ^


d3f9d547 ^



e47cfd56 ^
d3f9d547 ^

e47cfd56 ^
d3f9d547 ^

e47cfd56 ^

479f8d01 ^
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