hide line numbers from log browser

This commit is contained in:
Kartik K. Agaram 2023-09-15 13:30:42 -07:00
parent ab5ba3f3e5
commit 76f119b7b9
3 changed files with 14 additions and 8 deletions

View File

@ -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)

View File

@ -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

View File

@ -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