diff options
author | Kartik K. Agaram <vc@akkartik.com> | 2022-05-21 22:08:13 -0700 |
---|---|---|
committer | Kartik K. Agaram <vc@akkartik.com> | 2022-05-21 22:32:43 -0700 |
commit | 84898ed43a80f00f3df5acd069f808e45d85f24d (patch) | |
tree | a3d7db9dc9ddfd0008ca02225313a1382a844398 /main.lua | |
parent | 96dfe4f669eca35c77f4f2b4458bac8038a0bd84 (diff) | |
download | lines.love-84898ed43a80f00f3df5acd069f808e45d85f24d.tar.gz |
bugfix: printing the first part of a line at the bottom made it seem non-wrapping
Still lots wrong here.
Diffstat (limited to 'main.lua')
-rw-r--r-- | main.lua | 26 |
1 files changed, 17 insertions, 9 deletions
diff --git a/main.lua b/main.lua index f6f5cfe..fc27611 100644 --- a/main.lua +++ b/main.lua @@ -64,20 +64,22 @@ Zoom = 1.5 Filename = love.filesystem.getUserDirectory()..'/lines.txt' +New_foo = true + function love.load(arg) -- maximize window - love.window.setMode(0, 0) -- maximize - Screen_width, Screen_height, Screen_flags = love.window.getMode() - -- shrink slightly to account for window decoration - Screen_width = Screen_width-100 - Screen_height = Screen_height-100 +--? love.window.setMode(0, 0) -- maximize +--? Screen_width, Screen_height, Screen_flags = love.window.getMode() +--? -- shrink slightly to account for window decoration +--? Screen_width = Screen_width-100 +--? Screen_height = Screen_height-100 -- for testing line wrap ---? Screen_width = 120 ---? Screen_height = 200 + Screen_width = 120 + Screen_height = 200 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 + 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) if #arg > 0 then @@ -116,7 +118,9 @@ function love.draw() line.y = nil end local y = 15 + if New_foo then print('== draw') end for line_index,line in ipairs(Lines) do + if New_foo then print('draw:', line_index, y) end if y + math.floor(15*Zoom) > Screen_height then break end if line_index >= Screen_top1.line then Screen_bottom1.line = line_index @@ -140,12 +144,15 @@ function love.draw() Drawing.draw(line) y = y + Drawing.pixels(line.h) + 10 -- padding else + if New_foo then print('text') end line.y = y y, Screen_bottom1.pos = Text.draw(line, Line_width, line_index) y = y + math.floor(15*Zoom) -- text height + if New_foo then print('aa', y) end end end end + New_foo = false --? print('screen bottom: '..tostring(Screen_bottom1.pos)..' in '..tostring(Lines[Screen_bottom1.line].data)) --? os.exit(1) end @@ -186,6 +193,7 @@ function love.textinput(t) end function keychord_pressed(chord) + New_foo = true if love.mouse.isDown('1') or chord:sub(1,2) == 'C-' then Drawing.keychord_pressed(chord) elseif chord == 'escape' and love.mouse.isDown('1') then |