clean up the setFont gotcha
Now that editors know their fonts..
This commit is contained in:
parent
c1bc2b9616
commit
78228796fc
|
@ -2,6 +2,5 @@ print_to_output = function(...)
|
|||
local line = table.concat(map({...}, tostring), ' ')
|
||||
table.insert(Current_pane.output_editor_state.lines,
|
||||
{data=line})
|
||||
love.graphics.setFont(Font)
|
||||
Text.redraw_all(Current_pane.output_editor_state)
|
||||
end
|
|
@ -3,7 +3,6 @@ send_errors_to_output = function(err)
|
|||
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}
|
||||
love.graphics.setFont(Font)
|
||||
Text.redraw_all(Current_pane.output_editor_state)
|
||||
Text.insert_text(Current_pane.output_editor_state, error_with_callstack)
|
||||
clear_handlers()
|
||||
|
|
|
@ -253,11 +253,10 @@ early warning if you break something.
|
|||
* `Text.redraw_all(state)` -- call this to clear and recompute any cached
|
||||
state as the cursor moves and the buffer scrolls. You shouldn't need to do
|
||||
this for the most part, just run it after loading or modifying
|
||||
`state.lines`. (Gotcha: Don't forget to `love.graphics.setFont` the right
|
||||
font before you call it.)
|
||||
`state.lines`.
|
||||
|
||||
* `edit.update_font_height(state, font_height)` -- updates all state dependent
|
||||
on font height. (Gotcha: but not the font.)
|
||||
on font height.
|
||||
|
||||
* `edit.update(state, dt)` -- call this from `on.update` to periodically
|
||||
auto-save editor contents to disk.
|
||||
|
|
3
text.lua
3
text.lua
|
@ -945,6 +945,7 @@ function Text.redraw_all(State)
|
|||
assert(false, ('Right margin %d must be to the right of the left margin %d'):format(State.right, State.left))
|
||||
end
|
||||
|
||||
love.graphics.setFont(State.font)
|
||||
State.line_cache = {}
|
||||
local curr_screen_line_index = 1
|
||||
for i=1,#State.lines do
|
||||
|
@ -958,6 +959,7 @@ end
|
|||
|
||||
function Text.refresh_scrollbar_data(State)
|
||||
--? print('clearing fragments')
|
||||
love.graphics.setFont(State.font)
|
||||
local curr_screen_line_index = 1
|
||||
local npopulated = 0
|
||||
for i=1,#State.lines do
|
||||
|
@ -979,6 +981,7 @@ function Text.refresh_scrollbar_data(State)
|
|||
end
|
||||
|
||||
function Text.refresh_screen_line_cache(State, line_index)
|
||||
love.graphics.setFont(State.font)
|
||||
State.line_cache[line_index].screen_line_starting_pos = nil
|
||||
Text.populate_screen_line_starting_pos(State, line_index)
|
||||
Text.refresh_scrollbar_data(State)
|
||||
|
|
Loading…
Reference in New Issue