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:
parent
1573dd8425
commit
3ec8019cc0
3
main.lua
3
main.lua
|
@ -47,6 +47,8 @@ Cursor_x, Cursor_y = 0, 0 -- in pixels
|
||||||
-- scrolling support
|
-- scrolling support
|
||||||
Screen_top_line = 1
|
Screen_top_line = 1
|
||||||
Screen_bottom_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'
|
Current_drawing_mode = 'line'
|
||||||
Previous_drawing_mode = nil
|
Previous_drawing_mode = nil
|
||||||
|
@ -66,6 +68,7 @@ function love.load(arg)
|
||||||
Screen_height = Screen_height-100
|
Screen_height = Screen_height-100
|
||||||
love.window.setMode(Screen_width, Screen_height)
|
love.window.setMode(Screen_width, Screen_height)
|
||||||
love.window.setTitle('Text with Lines')
|
love.window.setTitle('Text with Lines')
|
||||||
|
--? Line_width = 100
|
||||||
Line_width = math.floor(Screen_width/2/40)*40
|
Line_width = math.floor(Screen_width/2/40)*40
|
||||||
love.keyboard.setTextInput(true) -- bring up keyboard on touch screen
|
love.keyboard.setTextInput(true) -- bring up keyboard on touch screen
|
||||||
love.keyboard.setKeyRepeat(true)
|
love.keyboard.setKeyRepeat(true)
|
||||||
|
|
8
text.lua
8
text.lua
|
@ -19,7 +19,9 @@ function Text.draw(line, line_width, line_index)
|
||||||
local frag_width = math.floor(frag_text:getWidth()*Zoom)
|
local frag_width = math.floor(frag_text:getWidth()*Zoom)
|
||||||
if x + frag_width > line_width then
|
if x + frag_width > line_width then
|
||||||
assert(x > 25) -- no overfull lines
|
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
|
x = 25
|
||||||
if line.screen_line_starting_pos == nil then
|
if line.screen_line_starting_pos == nil then
|
||||||
line.screen_line_starting_pos = {1, pos}
|
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)
|
table.insert(line.screen_line_starting_pos, pos)
|
||||||
end
|
end
|
||||||
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
|
-- render cursor if necessary
|
||||||
local frag_len = utf8.len(frag)
|
local frag_len = utf8.len(frag)
|
||||||
if line_index == Cursor_line then
|
if line_index == Cursor_line then
|
||||||
|
|
Loading…
Reference in New Issue