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