Merge driver.love

This commit is contained in:
Kartik K. Agaram 2023-10-22 20:04:41 -07:00
commit 72698c4204
8 changed files with 31 additions and 5 deletions

View File

@ -26,7 +26,9 @@ on.mouse_press = function(x,y, mouse_button)
if node then
-- position cursor in node
Cursor_node = node
print('within node')
edit.mouse_press(node.editor, x,y, mouse_button)
print('cursor at', node.editor.cursor_x, node.editor.cursor_y)
return
end
local button = on_button(x,y)

View File

@ -1,5 +1,5 @@
on.keychord_press = function(chord, key)
print('key', chord)
print('key press', chord)
if Global_state.thread and chord == 'C-o' then
quit_all_editors(Global_state.thread)
Global_state.thread = nil
@ -73,6 +73,12 @@ on.keychord_press = function(chord, key)
Viewport_bounds.xmax - App.screen.width/Viewport.zoom),
Viewport.x + App.screen.width/Viewport.zoom)
B()
elseif chord == 'M-1' then
if Debug_draw_fn ~= draw_debug_ui1 then
Debug_draw_fn = draw_debug_ui1
else
Debug_draw_fn = nil
end
end
end
end

View File

@ -24,4 +24,4 @@ on.draw = function()
if Global_state.thread then
draw_menu_bar()
end
end
end

View File

@ -1,14 +1,14 @@
update_editor_box = function(node)
if node.editor == nil then return end
-- Compute screen_top1 in viewport coordinates because the editor's font takes scaling into account.
if vy(node.y) > 0 then
if node.y > Viewport.y then
if node ~= Cursor_node then
node.editor.screen_top1.line = 1
node.editor.screen_top1.pos = 1
end
node.editor.top = vy(node.y)
else
node.editor.screen_top1, node.editor.top = schema1_of_y(node.editor, -vy(node.y))
node.editor.screen_top1, node.editor.top = schema1_of_y(node.editor, scale(Viewport.y-node.y)) -- scale y because editor's font is scaled
node.editor.top = node.editor.top + Menu_bar_height
end
if node.editor.font_height ~= scale(20) then
edit.update_font_settings(node.editor, scale(20))

View File

@ -1 +1,3 @@
Spawn_point = {x=0, y=0}
-- idea: command to move the spawn point around
-- but we don't have a command palette yet

8
0113-draw_debug_ui1 Normal file
View File

@ -0,0 +1,8 @@
draw_debug_ui1 = function()
local x, y = App.screen.width/3, App.screen.height/3
local w, h = App.screen.width/3, App.screen.height/3
App.color{r=1, g=1, b=1}
love.graphics.rectangle('fill', x,y, w, h)
App.color{r=0, g=0, b=0}
love.graphics.rectangle('line', x+10, y+10, w-20, h-20, 5,5)
end

1
0114-Debug_draw_fn Normal file
View File

@ -0,0 +1 @@
Debug_draw_fn = nil

View File

@ -14,6 +14,13 @@ Initializing settings:
- where exactly the cursor is drawn to highlight a given character
- analogously, how a shape precisely looks as you draw it
Panning (test these at multiple zoom levels):
* When no node has cursor, arrow keys and pageup/pagedown pan surface around, preserving relative positions of nodes
* When a node has cursor in viewport, arrow keys move the cursor within the node, keeping cursor visible, panning surface if scrolling is needed
* Pageup/pagedown scroll a whole viewport height at a time if possible, but keep cursor visible if not possible.
* When a node has cursor, pageup/pagedown pan surface around
* Position a node with some area above viewport. Position cursor at topmost row on screen. Hit up arrow. Surface pans. Cursor doesn't hide behind menu bar.
### Protocol with driver; error-handling
* clone this repo to a new client app, clear its save dir[1], run it, run the