diff options
author | Kartik K. Agaram <vc@akkartik.com> | 2023-09-15 13:30:42 -0700 |
---|---|---|
committer | Kartik K. Agaram <vc@akkartik.com> | 2023-09-15 13:30:42 -0700 |
commit | 76f119b7b996c5751a42bf09b1a234b98aa6d48b (patch) | |
tree | 0d6180c0de87bd8221c7d6b64b23c2ad4b6edde8 | |
parent | ab5ba3f3e5f4f1f1583d798ace26683cb572ed18 (diff) | |
download | lines.love-76f119b7b996c5751a42bf09b1a234b98aa6d48b.tar.gz |
hide line numbers from log browser
-rw-r--r-- | source.lua | 2 | ||||
-rw-r--r-- | source_edit.lua | 12 | ||||
-rw-r--r-- | source_text.lua | 8 |
3 files changed, 14 insertions, 8 deletions
diff --git a/source.lua b/source.lua index 4a8bb48..e8dd7cc 100644 --- a/source.lua +++ b/source.lua @@ -237,7 +237,7 @@ function source.switch_to_file(filename) end function source.draw() - edit.draw(Editor_state, --[[hide cursor?]] Show_file_navigator) + edit.draw(Editor_state, --[[hide cursor?]] Show_file_navigator, --[[show line numbers]] true) if Show_log_browser_side then -- divider App.color(Divider_color) 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 diff --git a/source_text.lua b/source_text.lua index 68b560e..df36266 100644 --- a/source_text.lua +++ b/source_text.lua @@ -3,7 +3,7 @@ Text = {} -- draw a line starting from startpos to screen at y between State.left and State.right -- return y for the next line, and position of start of final screen line drawn -function Text.draw(State, line_index, y, startpos, hide_cursor) +function Text.draw(State, line_index, y, startpos, hide_cursor, show_line_numbers) local line = State.lines[line_index] local line_cache = State.line_cache[line_index] line_cache.starty = y @@ -12,8 +12,10 @@ function Text.draw(State, line_index, y, startpos, hide_cursor) local final_screen_line_starting_pos = startpos -- track value to return Text.populate_screen_line_starting_pos(State, line_index) Text.populate_link_offsets(State, line_index) - App.color(Line_number_color) - love.graphics.print(line_index, State.left-Line_number_width*App.width('m')+10,y) + if show_line_numbers then + App.color(Line_number_color) + love.graphics.print(line_index, State.left-Line_number_width*App.width('m')+10,y) + end initialize_color() assert(#line_cache.screen_line_starting_pos >= 1) for i=1,#line_cache.screen_line_starting_pos do |