diff options
author | Kartik K. Agaram <vc@akkartik.com> | 2023-12-29 14:29:18 -0800 |
---|---|---|
committer | Kartik K. Agaram <vc@akkartik.com> | 2023-12-29 14:29:18 -0800 |
commit | 6bd2086b51251ee469b4c9d937624e3be4d97410 (patch) | |
tree | e5a73641ef7ad6b7329c5f63fec1ab08cf74546f /source_edit.lua | |
parent | 2b1c48c08e55247cac35c9cb4cdbd1ae10b91fd9 (diff) | |
parent | aa6bfb4b15ea75fa289b78cacc7de38f41daf69a (diff) | |
download | text.love-6bd2086b51251ee469b4c9d937624e3be4d97410.tar.gz |
Merge lines.love
Diffstat (limited to 'source_edit.lua')
-rw-r--r-- | source_edit.lua | 11 |
1 files changed, 7 insertions, 4 deletions
diff --git a/source_edit.lua b/source_edit.lua index 0af9949..f58d7e3 100644 --- a/source_edit.lua +++ b/source_edit.lua @@ -25,7 +25,7 @@ Same_point_distance = 4 -- pixel distance at which two points are considered th edit = {} -- run in both tests and a real run -function edit.initialize_state(top, left, right, font_height, line_height) -- currently always draws to bottom of screen +function edit.initialize_state(top, left, right, font, font_height, line_height) -- currently always draws to bottom of screen local result = { -- a line is either text or a drawing -- a text is a table with: @@ -85,6 +85,7 @@ function edit.initialize_state(top, left, right, font_height, line_height) -- c current_drawing_mode = 'line', previous_drawing_mode = nil, -- extra state for some ephemeral modes like moving/deleting/naming points + font = font, font_height = font_height, line_height = line_height, @@ -105,7 +106,7 @@ function edit.initialize_state(top, left, right, font_height, line_height) -- c search_backup = nil, -- stuff to restore when cancelling search } return result -end -- App.initialize_state +end -- edit.initialize_state function edit.check_locs(State) -- if State is inconsistent (i.e. file changed by some other program), @@ -157,6 +158,7 @@ end function edit.draw(State, hide_cursor, show_line_numbers) State.button_handlers = {} + love.graphics.setFont(State.font) App.color(Text_color) assert(#State.lines == #State.line_cache, ('line_cache is out of date; %d elements when it should be %d'):format(#State.line_cache, #State.lines)) assert(Text.le1(State.screen_top1, State.cursor1), ('screen_top (line=%d,pos=%d) is below cursor (line=%d,pos=%d)'):format(State.screen_top1.line, State.screen_top1.pos, State.cursor1.line, State.cursor1.pos)) @@ -552,7 +554,7 @@ end function edit.update_font_settings(State, font_height) State.font_height = font_height - love.graphics.setFont(love.graphics.newFont(State.font_height)) + State.font = love.graphics.newFont(State.font_height) State.line_height = math.floor(font_height*1.3) end @@ -569,7 +571,8 @@ function edit.initialize_test_state() 15, -- top margin Test_margin_left, App.screen.width - Test_margin_right, - 14, -- font height assuming default LÖVE font + love.graphics.getFont(), + 14, 15) -- line height end |