update stale source X-(
This commit is contained in:
parent
eae5c9505c
commit
a3e5a1f22d
|
@ -123,8 +123,10 @@ function edit.check_locs(State)
|
|||
end
|
||||
|
||||
function edit.invalid1(State, loc1)
|
||||
return loc1.line > #State.lines
|
||||
or loc1.pos > #State.lines[loc1.line].data
|
||||
if loc1.line > #State.lines then return true end
|
||||
local l = State.lines[loc1.line]
|
||||
if l.mode ~= 'text' then return false end -- pos is irrelevant to validity for a drawing line
|
||||
return loc1.pos > #State.lines[loc1.line].data
|
||||
end
|
||||
|
||||
function edit.cursor_on_text(State)
|
||||
|
@ -169,7 +171,7 @@ function edit.draw(State, hide_cursor)
|
|||
end
|
||||
if line.data == '' then
|
||||
-- button to insert new drawing
|
||||
button(State, 'draw', {x=4,y=y+4, w=12,h=12, color={1,1,0},
|
||||
button(State, 'draw', {x=State.left-Margin_left+4, y=y+4, w=12,h=12, color={1,1,0},
|
||||
icon = icon.insert_drawing,
|
||||
onpress1 = function()
|
||||
Drawing.before = snapshot(State, line_index-1, line_index)
|
||||
|
@ -225,7 +227,7 @@ end
|
|||
|
||||
function edit.mouse_press(State, x,y, mouse_button)
|
||||
if State.search_term then return end
|
||||
--? print('press', State.selection1.line, State.selection1.pos)
|
||||
--? print('press', State.cursor1.line)
|
||||
if mouse_press_consumed_by_any_button_handler(State, x,y, mouse_button) then
|
||||
-- press on a button and it returned 'true' to short-circuit
|
||||
return
|
||||
|
@ -268,7 +270,7 @@ end
|
|||
|
||||
function edit.mouse_release(State, x,y, mouse_button)
|
||||
if State.search_term then return end
|
||||
--? print('release')
|
||||
--? print('release', State.cursor1.line)
|
||||
if State.lines.current_drawing then
|
||||
Drawing.mouse_release(State, x,y, mouse_button)
|
||||
schedule_save(State)
|
||||
|
@ -320,11 +322,12 @@ function edit.mouse_wheel_move(State, dx,dy)
|
|||
end
|
||||
|
||||
function edit.text_input(State, t)
|
||||
--? print('text input', t)
|
||||
if State.search_term then
|
||||
State.search_term = State.search_term..t
|
||||
State.search_text = nil
|
||||
Text.search_next(State)
|
||||
elseif State.current_drawing_mode == 'name' then
|
||||
elseif State.lines.current_drawing and State.current_drawing_mode == 'name' then
|
||||
local before = snapshot(State, State.lines.current_drawing_index)
|
||||
local drawing = State.lines.current_drawing
|
||||
local p = drawing.points[drawing.pending.target_point]
|
||||
|
@ -477,7 +480,7 @@ function edit.keychord_press(State, chord, key)
|
|||
line.show_help = false
|
||||
end
|
||||
end
|
||||
elseif State.current_drawing_mode == 'name' then
|
||||
elseif State.lines.current_drawing and State.current_drawing_mode == 'name' then
|
||||
if chord == 'return' then
|
||||
State.current_drawing_mode = State.previous_drawing_mode
|
||||
State.previous_drawing_mode = nil
|
||||
|
@ -490,10 +493,12 @@ function edit.keychord_press(State, chord, key)
|
|||
record_undo_event(State, {before=before, after=snapshot(State, State.lines.current_drawing_index)})
|
||||
elseif chord == 'backspace' then
|
||||
local len = utf8.len(p.name)
|
||||
local byte_offset = Text.offset(p.name, len-1)
|
||||
if len == 1 then byte_offset = 0 end
|
||||
p.name = string.sub(p.name, 1, byte_offset)
|
||||
record_undo_event(State, {before=before, after=snapshot(State, State.lines.current_drawing_index)})
|
||||
if len > 0 then
|
||||
local byte_offset = Text.offset(p.name, len-1)
|
||||
if len == 1 then byte_offset = 0 end
|
||||
p.name = string.sub(p.name, 1, byte_offset)
|
||||
record_undo_event(State, {before=before, after=snapshot(State, State.lines.current_drawing_index)})
|
||||
end
|
||||
end
|
||||
end
|
||||
schedule_save(State)
|
||||
|
|
|
@ -178,6 +178,7 @@ function Text.text_input(State, t)
|
|||
end
|
||||
|
||||
function Text.insert_at_cursor(State, t)
|
||||
assert(State.lines[State.cursor1.line].mode == 'text')
|
||||
local byte_offset = Text.offset(State.lines[State.cursor1.line].data, State.cursor1.pos)
|
||||
State.lines[State.cursor1.line].data = string.sub(State.lines[State.cursor1.line].data, 1, byte_offset-1)..t..string.sub(State.lines[State.cursor1.line].data, byte_offset)
|
||||
Text.clear_screen_line_cache(State, State.cursor1.line)
|
||||
|
|
Loading…
Reference in New Issue