Merge lines.love

This commit is contained in:
Kartik K. Agaram 2023-06-08 01:08:07 -07:00
commit 62a395598c
3 changed files with 22 additions and 1 deletions

View File

@ -5,6 +5,10 @@ record those here.
Initializing settings:
- delete app settings, start; window opens running the text editor
- run with a filename on commandline, scroll around, quit; restart without a filename; window opens running the text editor in same position+dimensions
- run with a filename on commandline, scroll around, quit; restart with same filename; window opens running the text editor in same position+dimensions
- run with a filename on commandline, scroll around, quit; restart with new filename; window opens new filename with cursor up top
- run editor, scroll around, move cursor to end of some line, quit; restart with new filename; window opens running the text editor in same position+dimensions
- quit while running the text editor, restart; window opens running the text editor in same position+dimensions
- quit while editing source (color; no drawings; no selection), restart; window opens editing source in same position+dimensions
- start out running the text editor, move window, press ctrl+e twice; window is running text editor in same position+dimensions

View File

@ -111,7 +111,7 @@ function edit.check_locs(State)
-- if State is inconsistent (i.e. file changed by some other program),
-- throw away all cursor state entirely
if edit.invalid1(State, State.screen_top1)
or edit.invalid1(State, State.cursor1)
or edit.invalid_cursor1(State)
or not edit.cursor_on_text(State)
or not Text.le1(State.screen_top1, State.cursor1) then
State.screen_top1 = {line=1, pos=1}
@ -126,6 +126,16 @@ function edit.invalid1(State, loc1)
return loc1.pos > #State.lines[loc1.line].data
end
-- cursor loc in particular differs from other locs in one way:
-- pos might occur just after end of line
function edit.invalid_cursor1(State)
local cursor1 = State.cursor1
if cursor1.line > #State.lines then return true end
local l = State.lines[cursor1.line]
if l.mode ~= 'text' then return false end -- pos is irrelevant to validity for a drawing line
return cursor1.pos > #State.lines[cursor1.line].data + 1
end
function edit.cursor_on_text(State)
return State.cursor1.line <= #State.lines
and State.lines[State.cursor1.line].mode == 'text'

View File

@ -134,6 +134,13 @@ function run.settings()
}
end
function absolutize(path)
if is_relative_path(path) then
return love.filesystem.getWorkingDirectory()..'/'..path -- '/' should work even on Windows
end
return path
end
function run.mouse_press(x,y, mouse_button)
Cursor_time = 0 -- ensure cursor is visible immediately after it moves
return edit.mouse_press(Editor_state, x,y, mouse_button)