From d41301c1b79124e3dc7ef5551d8bd7b5dd553b17 Mon Sep 17 00:00:00 2001 From: "Kartik K. Agaram" Date: Wed, 20 Jul 2022 06:53:58 -0700 Subject: more clearly skip prints before screen top --- text.lua | 40 +++++++++++++++++++--------------------- 1 file changed, 19 insertions(+), 21 deletions(-) diff --git a/text.lua b/text.lua index 1f31d60..a1d9ce6 100644 --- a/text.lua +++ b/text.lua @@ -31,10 +31,12 @@ function Text.draw(State, line_index, y, startpos) local frag_len = utf8.len(frag) --? local s=tostring --? print('('..s(x)..','..s(y)..') '..frag..'('..s(frag_width)..' vs '..s(right)..') '..s(line_index)..' vs '..s(State.screen_top1.line)..'; '..s(pos)..' vs '..s(State.screen_top1.pos)..'; bottom: '..s(State.screen_bottom1.line)..'/'..s(State.screen_bottom1.pos)) - if x + frag_width > State.right then - assert(x > State.left) -- no overfull lines - -- update y only after drawing the first screen line of screen top - if Text.lt1(State.screen_top1, {line=line_index, pos=pos}) then + if Text.lt1({line=line_index, pos=pos}, State.screen_top1) then + -- render nothing +--? print('skipping', frag) + else + if x + frag_width > State.right then + assert(x > State.left) -- no overfull lines y = y + State.line_height if y + State.line_height > App.screen.height then --? print('b', y, App.screen.height, '=>', screen_line_starting_pos) @@ -42,34 +44,30 @@ function Text.draw(State, line_index, y, startpos) end screen_line_starting_pos = pos --? print('text: new screen line', y, App.screen.height, screen_line_starting_pos) + x = State.left end - x = State.left - end ---? print('checking to draw', pos, State.screen_top1.pos) - -- don't draw text above screen top - if Text.le1(State.screen_top1, {line=line_index, pos=pos}) then if State.selection1.line then local lo, hi = Text.clip_selection(State, line_index, pos, pos+frag_len) Text.draw_highlight(State, line, x,y, pos, lo,hi) end --? print('drawing '..frag) App.screen.draw(frag_text, x,y) - end - -- render cursor if necessary - if line_index == State.cursor1.line then - if pos <= State.cursor1.pos and pos + frag_len > State.cursor1.pos then - if State.search_term then - if State.lines[State.cursor1.line].data:sub(State.cursor1.pos, State.cursor1.pos+utf8.len(State.search_term)-1) == State.search_term then - local lo_px = Text.draw_highlight(line, x,y, pos, State.cursor1.pos, State.cursor1.pos+utf8.len(State.search_term)) - App.color(Text_color) - love.graphics.print(State.search_term, x+lo_px,y) + -- render cursor if necessary + if line_index == State.cursor1.line then + if pos <= State.cursor1.pos and pos + frag_len > State.cursor1.pos then + if State.search_term then + if State.lines[State.cursor1.line].data:sub(State.cursor1.pos, State.cursor1.pos+utf8.len(State.search_term)-1) == State.search_term then + local lo_px = Text.draw_highlight(line, x,y, pos, State.cursor1.pos, State.cursor1.pos+utf8.len(State.search_term)) + App.color(Text_color) + love.graphics.print(State.search_term, x+lo_px,y) + end + else + Text.draw_cursor(State, x+Text.x(frag, State.cursor1.pos-pos+1), y) end - else - Text.draw_cursor(State, x+Text.x(frag, State.cursor1.pos-pos+1), y) end end + x = x + frag_width end - x = x + frag_width pos = pos + frag_len end if State.search_term == nil then -- cgit 1.4.1-2-gfad0 lt;vc@akkartik.com> 2016-06-24 18:17:11 -0700 committer Kartik K. Agaram <vc@akkartik.com> 2016-06-24 18:17:11 -0700 3066' href='/akkartik/mu/commit/exuberant-ctags-rc?h=main&id=4ec5d8513c7c8651a08308047d2b9d765e32a042'>4ec5d851 ^
37e0a431 ^
4ec5d851 ^
d2e606f4 ^
6c52e24e ^

42f08f13 ^
7be07a6b ^
1
2
3
4
5
6
7
8
9
10
11