diff options
Diffstat (limited to 'edit')
-rw-r--r-- | edit/001-editor.mu | 22 | ||||
-rw-r--r-- | edit/002-typing.mu | 4 | ||||
-rw-r--r-- | edit/003-shortcuts.mu | 23 |
3 files changed, 10 insertions, 39 deletions
diff --git a/edit/001-editor.mu b/edit/001-editor.mu index 036ef07a..8855395a 100644 --- a/edit/001-editor.mu +++ b/edit/001-editor.mu @@ -81,20 +81,18 @@ scenario editor-initializes-without-data [ assume-screen 5/width, 3/height run [ e:&:editor <- new-editor 0/data, 2/left, 5/right - 1:editor/raw <- copy *e + 2:editor/raw <- copy *e ] memory-should-contain [ - # 1,2 (data) <- just the § sentinel - # 3,4 (top of screen) <- the § sentinel - # 5 (bottom of screen) <- null since text fits on screen - 5 <- 0 - 6 <- 0 - # 7,8 (before cursor) <- the § sentinel - 9 <- 2 # left - 10 <- 4 # right (inclusive) - 11 <- 0 # bottom (not set until render) - 12 <- 1 # cursor row - 13 <- 2 # cursor column + # 2 (data) <- just the § sentinel + # 3 (top of screen) <- the § sentinel + 4 <- 0 # bottom-of-screen; null since text fits on screen + # 5 (before cursor) <- the § sentinel + 6 <- 2 # left + 7 <- 4 # right (inclusive) + 8 <- 0 # bottom (not set until render) + 9 <- 1 # cursor row + 10 <- 2 # cursor column ] screen-should-contain [ . . diff --git a/edit/002-typing.mu b/edit/002-typing.mu index 67fe76a0..47885c4f 100644 --- a/edit/002-typing.mu +++ b/edit/002-typing.mu @@ -280,11 +280,7 @@ scenario editor-handles-empty-event-queue [ assume-screen 10/width, 5/height e:&:editor <- new-editor [abc], 0/left, 10/right editor-render screen, e -#? x:num <- get *screen, num-rows:offset -#? $print [a: ] x 10/newline assume-console [] -#? x:num <- get *screen, num-rows:offset -#? $print [z: ] x 10/newline run [ editor-event-loop screen, console, e ] diff --git a/edit/003-shortcuts.mu b/edit/003-shortcuts.mu index 78c6e49f..02ea77d0 100644 --- a/edit/003-shortcuts.mu +++ b/edit/003-shortcuts.mu @@ -2006,13 +2006,7 @@ after <handle-special-character> [ delete-to-start-of-line?:bool <- equal c, 21/ctrl-u break-unless delete-to-start-of-line? <begin-delete-to-start-of-line> - $print [before: ] cursor-row [ ] cursor-column 10/newline deleted-cells:&:duplex-list:char <- delete-to-start-of-line editor - x:text <- to-text deleted-cells - $print x 10/newline - cursor-row <- get *editor, cursor-row:offset - cursor-column <- get *editor, cursor-column:offset - $print [after: ] cursor-row [ ] cursor-column 10/newline <end-delete-to-start-of-line> go-render?:bool <- minimal-render-for-ctrl-u screen, editor, deleted-cells return @@ -2022,7 +2016,6 @@ after <handle-special-character> [ def minimal-render-for-ctrl-u screen:&:screen, editor:&:editor, deleted-cells:&:duplex-list:char -> go-render?:bool, screen:&:screen [ local-scope load-inputs - $print [minimal render for ctrl-u] 10/newline curr-column:num <- get *editor, cursor-column:offset # accumulate the current line as text and render it buf:&:buffer:char <- new-buffer 30 # accumulator for the text we need to render @@ -2032,7 +2025,6 @@ def minimal-render-for-ctrl-u screen:&:screen, editor:&:editor, deleted-cells:&: { # if we have a wrapped line, give up and render the whole screen wrap?:bool <- greater-or-equal i, right - $print [wrap? ] wrap? 10/newline return-if wrap?, 1/go-render curr <- next curr break-unless curr @@ -2069,7 +2061,6 @@ def delete-to-start-of-line editor:&:editor -> result:&:duplex-list:char, editor { at-start-of-text?:bool <- equal start, init break-if at-start-of-text? - $print [0] 10/newline curr:char <- get *start, value:offset at-start-of-line?:bool <- equal curr, 10/newline break-if at-start-of-line? @@ -2080,23 +2071,14 @@ def delete-to-start-of-line editor:&:editor -> result:&:duplex-list:char, editor assert start, [delete-to-start-of-line tried to move before start of text] loop } - $print [1] 10/newline # snip it out result:&:duplex-list:char <- next start - x:text <- to-text start - $print [start: ] x 10/newline - x:text <- to-text end - $print [end: ] x 10/newline remove-between start, end - x:text <- to-text result - $print [snip: ] x 10/newline # update top-of-screen if it's just been invalidated { break-unless update-top-of-screen? - $print [2] 10/newline put *editor, top-of-screen:offset, start } - $print [3] 10/newline # adjust cursor before-cursor <- copy start *editor <- put *editor, before-cursor:offset, before-cursor @@ -2107,22 +2089,17 @@ def delete-to-start-of-line editor:&:editor -> result:&:duplex-list:char, editor width:num <- subtract right, left num-deleted:num <- length result cursor-row-adjustment:num <- divide-with-remainder num-deleted, width - $print [adj ] num-deleted [/] width [=] cursor-row-adjustment 10/newline return-unless cursor-row-adjustment - $print [4] 10/newline cursor-row:num <- get *editor, cursor-row:offset cursor-row-in-editor:num <- subtract cursor-row, 1 # ignore menubar at-top?:bool <- lesser-or-equal cursor-row-in-editor, cursor-row-adjustment { break-unless at-top? - $print [5] 10/newline cursor-row <- copy 1 # top of editor, below menubar } { break-if at-top? - $print [6] 10/newline cursor-row <- subtract cursor-row, cursor-row-adjustment - $print cursor-row 10/newline } put *editor, cursor-row:offset, cursor-row ] |