switch to a single global output editor

This commit is contained in:
Kartik K. Agaram 2023-12-31 22:51:04 -08:00
parent 242a7e9676
commit dd7e6e395d
16 changed files with 38 additions and 52 deletions

View File

@ -12,8 +12,8 @@ on.update = function(dt)
-- == main area
if Current_pane.editor_state.scrollbar_drag then
adjust_scrollbar(Current_pane.editor_state, App.mouse_y())
elseif Current_pane.output_editor_state.scrollbar_drag then
adjust_scrollbar(Current_pane.output_editor_state, App.mouse_y())
elseif Output_editor_state.scrollbar_drag then
adjust_scrollbar(Output_editor_state, App.mouse_y())
end
end
end

View File

@ -19,5 +19,6 @@ on.initialize = function()
Current_pane_index = 1
Current_pane = Panes[Current_pane_index]
end
Output_editor_state = output_editor_state(Current_pane.editor_state)
run_app()
end

View File

@ -21,8 +21,8 @@ on.draw = function()
draw_scrollbar(Current_pane.editor_state)
-- output
draw_output_border()
edit.draw(Current_pane.output_editor_state, Foreground_color, --[[hide cursor]] true)
draw_scrollbar(Current_pane.output_editor_state)
edit.draw(Output_editor_state, Foreground_color, --[[hide cursor]] true)
draw_scrollbar(Output_editor_state)
-- menu and debug UI
draw_menu()
draw_next_frames_of_animations()

View File

@ -40,11 +40,11 @@ on.mouse_press = function(x,y, mouse_button)
elseif x < Current_pane.editor_state.right + 15 - 5 and y < Current_pane.editor_state.bottom + 5 + 10 - 5 then
love.keyboard.setTextInput(true)
edit.mouse_press(Current_pane.editor_state, x,y, mouse_button)
elseif on_editor_scrollbar(Current_pane.output_editor_state, x,y) then
Current_pane.output_editor_state.scrollbar_drag = true
local sbtopy = compute_scrollbar_topy(Current_pane.output_editor_state)
Current_pane.output_editor_state.scrollbar_offset = y - sbtopy
elseif on_editor_scrollbar_area(Current_pane.output_editor_state, x,y) then
elseif on_editor_scrollbar(Output_editor_state, x,y) then
Output_editor_state.scrollbar_drag = true
local sbtopy = compute_scrollbar_topy(Output_editor_state)
Output_editor_state.scrollbar_offset = y - sbtopy
elseif on_editor_scrollbar_area(Output_editor_state, x,y) then
-- nothing
end
end

View File

@ -28,12 +28,12 @@ on.mouse_release = function(x,y, mouse_button)
adjust_scrollbar(Current_pane.editor_state, y)
elseif x < Current_pane.editor_state.right + 15 - 5 and y < Current_pane.editor_state.bottom + 5 + 10 - 5 then
edit.mouse_release(Current_pane.editor_state, x,y, mouse_button)
elseif Current_pane.output_editor_state.scrollbar_drag then
adjust_scrollbar(Current_pane.output_editor_state, y)
Current_pane.output_editor_state.scrollbar_drag = nil
Current_pane.output_editor_state.scrollbar_offset = nil
elseif on_editor_scrollbar_area(Current_pane.output_editor_state, x,y) then
adjust_scrollbar(Current_pane.output_editor_state, y)
elseif Output_editor_state.scrollbar_drag then
adjust_scrollbar(Output_editor_state, y)
Output_editor_state.scrollbar_drag = nil
Output_editor_state.scrollbar_offset = nil
elseif on_editor_scrollbar_area(Output_editor_state, x,y) then
adjust_scrollbar(Output_editor_state, y)
end
end
end

View File

@ -16,7 +16,7 @@ update_font_settings = function(font_height)
pane.editor_state.width = pane.editor_state.right - pane.editor_state.left
edit.update_font_settings(pane.editor_state, Font_height)
Text.redraw_all(pane.editor_state)
edit.update_font_settings(pane.output_editor_state, Font_height)
update_output_editor(pane)
end
edit.update_font_settings(Output_editor_state, Font_height)
update_output_editor()
end

View File

@ -1,4 +1,3 @@
Current_pane = {
editor_state = nil,
output_editor_state = nil,
}

View File

@ -1,6 +1,3 @@
new_pane = function()
local result = {}
result.editor_state = code_editor_state()
result.output_editor_state = output_editor_state(result.editor_state)
return result
return {editor_state = code_editor_state()}
end

View File

@ -1,6 +1,6 @@
print_to_output = function(...)
local line = table.concat(map({...}, tostring), ' ')
table.insert(Current_pane.output_editor_state.lines,
table.insert(Output_editor_state.lines,
{data=line})
Text.redraw_all(Current_pane.output_editor_state)
Text.redraw_all(Output_editor_state)
end

View File

@ -1,7 +0,0 @@
clear_pane_button = function(x, y, r)
return overflowable_button('clear', x, y, r,
function()
Show_menu = nil
clear_pane()
end)
end

View File

@ -1,4 +0,0 @@
clear_pane = function()
edit.clear(Current_pane.editor_state)
edit.clear(Current_pane.output_editor_state)
end

View File

@ -10,7 +10,7 @@ on.mouse_wheel_move = function(dx,dy)
if App.mouse_y() < Current_pane.editor_state.bottom then
edit.mouse_wheel_move(Current_pane.editor_state, dx,dy)
else
edit.mouse_wheel_move(Current_pane.output_editor_state, dx,dy)
edit.mouse_wheel_move(Output_editor_state, dx,dy)
end
end
end

View File

@ -1,9 +1,9 @@
send_errors_to_output = function(err)
local callstack = debug.traceback('', 3)
local error_with_callstack = cleaned_up_frame(tostring(err))..'\n'..cleaned_up_callstack(callstack)
table.insert(Current_pane.output_editor_state.lines, {data=''})
Current_pane.output_editor_state.cursor1 = {line=#Current_pane.output_editor_state.lines, pos=1}
Text.redraw_all(Current_pane.output_editor_state)
Text.insert_text(Current_pane.output_editor_state, error_with_callstack)
table.insert(Output_editor_state.lines, {data=''})
Output_editor_state.cursor1 = {line=#Output_editor_state.lines, pos=1}
Text.redraw_all(Output_editor_state)
Text.insert_text(Output_editor_state, error_with_callstack)
stop_app()
end

View File

@ -1,7 +1,7 @@
update_output_editor = function(pane)
pane.output_editor_state.top = pane.editor_state.bottom+5+10+5
pane.output_editor_state.right = pane.editor_state.right
pane.output_editor_state.width = pane.editor_state.width
pane.output_editor_state.bottom = Safe_height - 5
Text.redraw_all(pane.output_editor_state)
update_output_editor = function()
Output_editor_state.top = Current_pane.editor_state.bottom+5+10+5
Output_editor_state.right = Current_pane.editor_state.right
Output_editor_state.width = Current_pane.editor_state.width
Output_editor_state.bottom = Safe_height - 5
Text.redraw_all(Output_editor_state)
end

View File

@ -1,7 +1,7 @@
run_app = function()
-- ## run: initialize
clear_handlers()
edit.clear(Current_pane.output_editor_state)
edit.clear(Output_editor_state)
print = print_to_output
-- ## run
local error = eval_all()
@ -11,11 +11,10 @@ run_app = function()
else
print = Real_print
clear_handlers()
-- could be either output or error
table.insert(Current_pane.output_editor_state.lines, {data=tostring(error)})
table.insert(Output_editor_state.lines, {data=tostring(error)})
end
if #Current_pane.output_editor_state.lines == 0 then
table.insert(Current_pane.output_editor_state.lines, {data=''})
if #Output_editor_state.lines == 0 then
table.insert(Output_editor_state.lines, {data=''})
end
Text.redraw_all(Current_pane.output_editor_state)
Text.redraw_all(Output_editor_state)
end

1
0162-Output_editor_state Normal file
View File

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