about summary refs log tree commit diff stats
diff options
context:
space:
mode:
-rw-r--r--main.lua8
-rw-r--r--text.lua6
-rw-r--r--text_tests.lua2
3 files changed, 10 insertions, 6 deletions
diff --git a/main.lua b/main.lua
index e7f7aa4..dab3881 100644
--- a/main.lua
+++ b/main.lua
@@ -70,6 +70,10 @@ Line_height = 15
 Margin_top = 15
 Margin_left = 25
 
+Drawing_padding_top = 10
+Drawing_padding_bottom = 10
+Drawing_padding_height = Drawing_padding_top + Drawing_padding_bottom
+
 Filename = love.filesystem.getUserDirectory()..'/lines.txt'
 
 -- undo
@@ -240,10 +244,10 @@ function App.draw()
         Screen_bottom1.pos = Screen_top1.pos
         y = y + Line_height
       elseif line.mode == 'drawing' then
-        y = y+10 -- padding
+        y = y+Drawing_padding_top
         line.y = y
         Drawing.draw(line)
-        y = y + Drawing.pixels(line.h) + 10 -- padding
+        y = y + Drawing.pixels(line.h) + Drawing_padding_bottom
       else
 --?         print('text')
         line.y = y
diff --git a/text.lua b/text.lua
index a85a490..1ab6303 100644
--- a/text.lua
+++ b/text.lua
@@ -402,7 +402,7 @@ function Text.pageup()
     if Lines[Screen_top1.line].mode == 'text' then
       y = y - Line_height
     elseif Lines[Screen_top1.line].mode == 'drawing' then
-      y = y - 20 - Drawing.pixels(Lines[Screen_top1.line].h)
+      y = y - Drawing_padding_height - Drawing.pixels(Lines[Screen_top1.line].h)
     end
     top2 = Text.previous_screen_line(top2)
   end
@@ -627,7 +627,7 @@ function Text.move_cursor_down_to_next_text_line_while_scrolling_again_if_necess
       break
     end
 --?     print('cursor skips', Cursor1.line)
-    y = y + 20 + Drawing.pixels(Lines[Cursor1.line].h)
+    y = y + Drawing_padding_height + Drawing.pixels(Lines[Cursor1.line].h)
     Cursor1.line = Cursor1.line + 1
   end
   -- hack: insert a text line at bottom of file if necessary
@@ -662,7 +662,7 @@ function Text.snap_cursor_to_bottom_of_screen()
       assert(Lines[top2.line-1].mode == 'drawing')
       -- We currently can't draw partial drawings, so either skip it entirely
       -- or not at all.
-      local h = 20 + Drawing.pixels(Lines[top2.line-1].h)
+      local h = Drawing_padding_height + Drawing.pixels(Lines[top2.line-1].h)
       if y - h < Margin_top then
         break
       end
diff --git a/text_tests.lua b/text_tests.lua
index 4398252..221d969 100644
--- a/text_tests.lua
+++ b/text_tests.lua
@@ -427,7 +427,7 @@ function test_pagedown_skips_drawings()
   Cursor1 = {line=1, pos=1}
   Screen_top1 = {line=1, pos=1}
   Screen_bottom1 = {}
-  local drawing_height = 20 + App.screen.width / 2  -- default
+  local drawing_height = Drawing_padding_height + App.screen.width / 2  -- default
   -- initially the screen displays the first line and the drawing
   -- 15px margin + 15px line1 + 10px margin + 25px drawing + 10px margin = 75px < screen height 80px
   App.draw()