I've agonized over conflicts between editor and script handlers for a while, but finally the solution occurred to me: to use the script's handlers, hide the editor. To use the editor's handlers, show the editor. The menu and settings are always active. This seems nice and consistent, easy to explain.
Mike Stein would prefer we just supported love.* handlers in scripts to minimize special cases and cognitive load for people. But I'd rather err on the side of being transparent about what's going on inside. As a compromise I'm supporting love.* names at least in addition to my rephrasings (which came about mostly because love.keychordpressed is just too much of a mouthful)
6DJMOJKEO5DIOEDV655SPA7C7HN2HXWMDJ7UF2CRDRBAF5YO3UEAC OZ42YLXGXAQC3WJ7624AY7YOY4SWS7I62SA6NZS2KXWNNCBFF5EQC FYX6DG22PU3RPDFXMTBBSNEEHG4USSW7QXBTKSRYMUOVW3LGQHCAC ZOLCTAGUUMQQ4MOZNVUANNOGEHWS7BYDTIMP3ZABLYKWUSAAMMPQC JV27LDDKKY57IEBWGBFPSHEARMOEGLBYGBJD27PDPTNWWYXA4T6AC R5QXEHUIZLELJGGCZAE7ATNS3CLRJ7JFRENMGH4XXH24C5WABZDQC VAVXKWZVOFJGWHCWYLTPDKSKKMSJEBKXNKXUW3T6IZAC3HE6HOIQC ZM7NOBRMD5HHA35Y4JDC76EOA2RD4KQOQCPURXYKXA6ABMKOJIGQC IP4LD33DQFWQ4654YPNJRKQ3CNYSHRZPX6U6ZPY7OLE744XX3MEQC 5RUFNRJOK3PXQKJTPDEN5K5PI67MGB25QUA44WOCCH2O5KHXT45QC Z5M23NTKKGEACSQJT27DRNS7NEK6OSLR2IOWVAH2C2PRAIU46BIQC PRE6XPRNICDCHMF7C45A6DRPVT47IPAIWW6Q7AHNGW3D2PBGOPNAC WR2WMEPEKNFAB4CAUBVFBACAJJSX2VX5B2VHKKSNTJSJBIIXFVZQC RK2ASPN7A55RCEG2YRFZLFXNPSME2VKBE2ZXO257DYZPS5TPXC5QC UEG224LHBOPWSKOVXTKVAUEL47HET566LJF7ZSWVKMMLBSJWUHFAC on.mouse_wheel_move = function(dx,dy)if Show_code then-- nothing yetelse-- editors hiddenif car.mouse_wheel_move then car.mouse_wheel_move(dx,dy) endif car.wheelmoved then car.wheelmoved(dx,dy) endendend
-- Table where any handlers for the current pane will live.car = {}
if Current_pane.editor_state.scrollbar_drag thenadjust_scrollbar(Current_pane.editor_state, y)Current_pane.editor_state.scrollbar_drag = nilelseif on_editor_scrollbar_area(Current_pane.editor_state, x,y) thenadjust_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 thenedit.mouse_release(Current_pane.editor_state, x,y, mouse_button)elseif Current_pane.output_editor_state.scrollbar_drag thenadjust_scrollbar(Current_pane.output_editor_state, y)Current_pane.output_editor_state.scrollbar_drag = nilelseif on_editor_scrollbar_area(Current_pane.output_editor_state, x,y) thenadjust_scrollbar(Current_pane.output_editor_state, y)
if Show_code thenif Current_pane.editor_state.scrollbar_drag thenadjust_scrollbar(Current_pane.editor_state, y)Current_pane.editor_state.scrollbar_drag = nilelseif on_editor_scrollbar_area(Current_pane.editor_state, x,y) thenadjust_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 thenedit.mouse_release(Current_pane.editor_state, x,y, mouse_button)elseif Current_pane.output_editor_state.scrollbar_drag thenadjust_scrollbar(Current_pane.output_editor_state, y)Current_pane.output_editor_state.scrollbar_drag = nilelseif on_editor_scrollbar_area(Current_pane.output_editor_state, x,y) thenadjust_scrollbar(Current_pane.output_editor_state, y)endelse-- editors hiddenif car.mouse_release then car.mouse_release(x,y, mouse_button) endif car.mousereleased then car.mousereleased(x,y, mouse_button) end
if on_editor_scrollbar(Current_pane.editor_state, x,y) thenCurrent_pane.editor_state.scrollbar_drag = trueelseif on_editor_scrollbar_area(Current_pane.editor_state, x,y) then-- nothingelseif x < Current_pane.editor_state.right + 15 - 5 and y < Current_pane.editor_state.bottom + 5 + 10 - 5 thenlove.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) thenCurrent_pane.output_editor_state.scrollbar_drag = trueelseif on_editor_scrollbar_area(Current_pane.output_editor_state, x,y) then-- nothing
if Show_code thenif on_editor_scrollbar(Current_pane.editor_state, x,y) thenCurrent_pane.editor_state.scrollbar_drag = trueelseif on_editor_scrollbar_area(Current_pane.editor_state, x,y) then-- nothingelseif x < Current_pane.editor_state.right + 15 - 5 and y < Current_pane.editor_state.bottom + 5 + 10 - 5 thenlove.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) thenCurrent_pane.output_editor_state.scrollbar_drag = trueelseif on_editor_scrollbar_area(Current_pane.output_editor_state, x,y) then-- nothingendelse-- editors hiddenif car.mouse_press then car.mouse_press(x,y, mouse_button) endif car.mousepressed then car.mousepressed(x,y, mouse_button) end
if Current_pane.editor_state.cursor_x thenedit.key_release(Current_pane.editor_state, key, scancode)
if Show_code thenif Current_pane.editor_state.cursor_x thenedit.key_release(Current_pane.editor_state, key, scancode)endelse-- editors hiddenif car.key_release then car.key_release(key, scancode) endif car.keyreleased then car.keyreleased(key, scancode) end
if Current_pane.editor_state.cursor_x thenedit.text_input(Current_pane.editor_state, t)
if Show_code thenif Current_pane.editor_state.cursor_x thenedit.text_input(Current_pane.editor_state, t)endelse-- editors hiddenif car.text_input then car.text_input(t) endif car.textinput then car.textinput(t) end
elseif Current_pane.editor_state.cursor_x then-- send keys to editor if cursor is visibleedit.keychord_press(Current_pane.editor_state, chord, key)
elseif Show_code thenif Current_pane.editor_state.cursor_x then-- send keys to editor if cursor is visibleedit.keychord_press(Current_pane.editor_state, chord, key)endelse-- editors hiddenif car.keychord_press then car.keychord_press(chord, key) endif car.keypressed then car.keypressed(key) end