new globals: draw partial screen line up top

I'm not setting these yet. Rendering seems to be working after manually
setting them.
This commit is contained in:
Kartik K. Agaram 2022-05-20 06:58:17 -07:00
parent 1573dd8425
commit 3ec8019cc0
2 changed files with 9 additions and 2 deletions

View File

@ -47,6 +47,8 @@ Cursor_x, Cursor_y = 0, 0 -- in pixels
-- scrolling support
Screen_top_line = 1
Screen_bottom_line = 1
Top_screen_line_starting_pos = 1 -- when top of screen starts in between a wrapped line
Bottom_screen_line_starting_pos = 1 -- when bottom of screen starts in between a wrapped line
Current_drawing_mode = 'line'
Previous_drawing_mode = nil
@ -66,6 +68,7 @@ function love.load(arg)
Screen_height = Screen_height-100
love.window.setMode(Screen_width, Screen_height)
love.window.setTitle('Text with Lines')
--? Line_width = 100
Line_width = math.floor(Screen_width/2/40)*40
love.keyboard.setTextInput(true) -- bring up keyboard on touch screen
love.keyboard.setKeyRepeat(true)

View File

@ -19,7 +19,9 @@ function Text.draw(line, line_width, line_index)
local frag_width = math.floor(frag_text:getWidth()*Zoom)
if x + frag_width > line_width then
assert(x > 25) -- no overfull lines
y = y + math.floor(15*Zoom)
if line_index > Screen_top_line or pos >= Top_screen_line_starting_pos then
y = y + math.floor(15*Zoom)
end
x = 25
if line.screen_line_starting_pos == nil then
line.screen_line_starting_pos = {1, pos}
@ -27,7 +29,9 @@ function Text.draw(line, line_width, line_index)
table.insert(line.screen_line_starting_pos, pos)
end
end
love.graphics.draw(frag_text, x,y, 0, Zoom)
if line_index > Screen_top_line or pos >= Top_screen_line_starting_pos then
love.graphics.draw(frag_text, x,y, 0, Zoom)
end
-- render cursor if necessary
local frag_len = utf8.len(frag)
if line_index == Cursor_line then