3880
This commit is contained in:
parent
b7fc9d3b5c
commit
aac76bca12
|
@ -510,6 +510,28 @@ def splice in:&:duplex-list:_elem, start:&:duplex-list:_elem/contained-in:in ->
|
|||
*start <- put *start, prev:offset, in
|
||||
]
|
||||
|
||||
# insert contents of 'new' after 'in'
|
||||
def insert in:&:duplex-list:_elem, new:&:@:_elem -> in:&:duplex-list:_elem [
|
||||
local-scope
|
||||
load-ingredients
|
||||
return-unless in
|
||||
return-unless new
|
||||
len:num <- length *new
|
||||
return-unless len
|
||||
curr:&:duplex-list:_elem <- copy in
|
||||
idx:num <- copy 0
|
||||
{
|
||||
done?:bool <- greater-or-equal idx, len
|
||||
break-if done?
|
||||
c:_elem <- index *new, idx
|
||||
insert c, curr
|
||||
# next iter
|
||||
curr <- next curr
|
||||
idx <- add idx, 1
|
||||
loop
|
||||
}
|
||||
]
|
||||
|
||||
def append in:&:duplex-list:_elem, new:&:duplex-list:_elem/contained-in:in -> in:&:duplex-list:_elem [
|
||||
local-scope
|
||||
load-ingredients
|
||||
|
|
|
@ -72,23 +72,8 @@ def new-editor s:text, left:num, right:num -> result:&:editor [
|
|||
def insert-text editor:&:editor, text:text -> editor:&:editor [
|
||||
local-scope
|
||||
load-ingredients
|
||||
# early exit if text is empty
|
||||
return-unless text
|
||||
len:num <- length *text
|
||||
return-unless len
|
||||
idx:num <- copy 0
|
||||
# now we can start appending the rest, character by character
|
||||
curr:&:duplex-list:char <- get *editor, data:offset
|
||||
{
|
||||
done?:bool <- greater-or-equal idx, len
|
||||
break-if done?
|
||||
c:char <- index *text, idx
|
||||
insert c, curr
|
||||
# next iter
|
||||
curr <- next curr
|
||||
idx <- add idx, 1
|
||||
loop
|
||||
}
|
||||
insert curr, text
|
||||
]
|
||||
|
||||
scenario editor-initializes-without-data [
|
||||
|
|
|
@ -72,23 +72,8 @@ def new-editor s:text, left:num, right:num -> result:&:editor [
|
|||
def insert-text editor:&:editor, text:text -> editor:&:editor [
|
||||
local-scope
|
||||
load-ingredients
|
||||
# early exit if text is empty
|
||||
return-unless text
|
||||
len:num <- length *text
|
||||
return-unless len
|
||||
idx:num <- copy 0
|
||||
# now we can start appending the rest, character by character
|
||||
curr:&:duplex-list:char <- get *editor, data:offset
|
||||
{
|
||||
done?:bool <- greater-or-equal idx, len
|
||||
break-if done?
|
||||
c:char <- index *text, idx
|
||||
insert c, curr
|
||||
# next iter
|
||||
curr <- next curr
|
||||
idx <- add idx, 1
|
||||
loop
|
||||
}
|
||||
insert curr, text
|
||||
]
|
||||
|
||||
scenario editor-initializes-without-data [
|
||||
|
|
Loading…
Reference in New Issue
Block a user