about summary refs log tree commit diff stats
path: root/source_edit.lua
diff options
context:
space:
mode:
authorKartik K. Agaram <vc@akkartik.com>2023-09-15 13:30:42 -0700
committerKartik K. Agaram <vc@akkartik.com>2023-09-15 13:30:42 -0700
commit76f119b7b996c5751a42bf09b1a234b98aa6d48b (patch)
tree0d6180c0de87bd8221c7d6b64b23c2ad4b6edde8 /source_edit.lua
parentab5ba3f3e5f4f1f1583d798ace26683cb572ed18 (diff)
downloadlines.love-76f119b7b996c5751a42bf09b1a234b98aa6d48b.tar.gz
hide line numbers from log browser
Diffstat (limited to 'source_edit.lua')
-rw-r--r--source_edit.lua12
1 files changed, 8 insertions, 4 deletions
diff --git a/source_edit.lua b/source_edit.lua
index 6dbf883..506aa41 100644
--- a/source_edit.lua
+++ b/source_edit.lua
@@ -89,7 +89,7 @@ function edit.initialize_state(top, left, right, font_height, line_height)  -- c
     line_height = line_height,
 
     top = top,
-    left = math.floor(left),
+    left = math.floor(left),  -- left margin for text; line numbers go to the left of this
     right = math.floor(right),
     width = right-left,
 
@@ -144,7 +144,7 @@ function edit.put_cursor_on_next_text_line(State)
   end
 end
 
-function edit.draw(State, hide_cursor)
+function edit.draw(State, hide_cursor, show_line_numbers)
   State.button_handlers = {}
   App.color(Text_color)
   if #State.lines ~= #State.line_cache then
@@ -173,7 +173,11 @@ function edit.draw(State, hide_cursor)
       end
       if line.data == '' then
         -- button to insert new drawing
-        button(State, 'draw', {x=4, y=y+4, w=12,h=12, color={1,1,0},
+        local buttonx = State.left-Margin_left+4
+        if show_line_numbers then
+          buttonx = 4  -- HACK: position draw buttons at a fixed x on screen
+        end
+        button(State, 'draw', {x=buttonx, y=y+4, w=12,h=12, color={1,1,0},
           icon = icon.insert_drawing,
           onpress1 = function()
                        Drawing.before = snapshot(State, line_index-1, line_index)
@@ -187,7 +191,7 @@ function edit.draw(State, hide_cursor)
                      end,
         })
       end
-      y, screen_bottom1.pos = Text.draw(State, line_index, y, startpos, hide_cursor)
+      y, screen_bottom1.pos = Text.draw(State, line_index, y, startpos, hide_cursor, show_line_numbers)
 --?       print('=> y', y)
     elseif line.mode == 'drawing' then
       y = y+Drawing_padding_top