Merge text.love

This commit is contained in:
Kartik K. Agaram 2023-04-03 09:28:46 -07:00
commit 542f0f261b
2 changed files with 3 additions and 6 deletions

View File

@ -120,7 +120,6 @@ function edit.draw(State)
startpos = State.screen_top1.pos
end
y, State.screen_bottom1.pos = Text.draw(State, line_index, y, startpos)
y = y + State.line_height
--? print('=> y', y)
end
--? print('screen bottom: '..tostring(State.screen_bottom1.pos)..' in '..tostring(State.lines[State.screen_bottom1.line].data))
@ -358,7 +357,6 @@ function edit.update_font_settings(State, font_height)
State.font_height = font_height
love.graphics.setFont(love.graphics.newFont(State.font_height))
State.line_height = math.floor(font_height*1.3)
Text_cache = {}
end
--== some methods for tests

View File

@ -7,7 +7,7 @@ require 'undo'
require 'text_tests'
-- draw a line starting from startpos to screen at y between State.left and State.right
-- return the final y, and position of start of final screen line drawn
-- return y for the next line, and position of start of final screen line drawn
function Text.draw(State, line_index, y, startpos)
--? print('text.draw', line_index, y)
local line = State.lines[line_index]
@ -55,7 +55,7 @@ function Text.draw(State, line_index, y, startpos)
end
end
end
return y - State.line_height, final_screen_line_starting_pos
return y, final_screen_line_starting_pos
end
function Text.screen_line(line, line_cache, i)
@ -74,7 +74,6 @@ function Text.draw_cursor(State, x, y)
if math.floor(Cursor_time*2)%2 == 0 then
App.color(Cursor_color)
love.graphics.rectangle('fill', x,y, 3,State.line_height)
App.color(Text_color)
end
State.cursor_x = x
State.cursor_y = y+State.line_height
@ -866,7 +865,7 @@ end
-- slightly expensive since it redraws the screen
function Text.cursor_out_of_screen(State)
App.draw()
edit.draw(State)
return State.cursor_y == nil
-- this approach is cheaper and almost works, except on the final screen
-- where file ends above bottom of screen