From 3ec8019cc0c1b212cc84ad69c0d8024f1b4c9eb5 Mon Sep 17 00:00:00 2001 From: "Kartik K. Agaram" Date: Fri, 20 May 2022 06:58:17 -0700 Subject: new globals: draw partial screen line up top I'm not setting these yet. Rendering seems to be working after manually setting them. --- main.lua | 3 +++ text.lua | 8 ++++++-- 2 files changed, 9 insertions(+), 2 deletions(-) diff --git a/main.lua b/main.lua index 014f8b4..f53f990 100644 --- a/main.lua +++ b/main.lua @@ -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) diff --git a/text.lua b/text.lua index b6423b8..12f1b5d 100644 --- a/text.lua +++ b/text.lua @@ -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 -- cgit 1.4.1-2-gfad0