From f3ebef8119973bcb906f2a597e041ef7d5afab0c Mon Sep 17 00:00:00 2001 From: Jeffrey Armstrong Date: Wed, 29 Dec 2021 13:04:40 -0500 Subject: Additional changes to debug 1-indexing. Cursor now appears on correct line. Strange behavior at line end insert. --- apfilo.f90 | 22 +++++++++++++++------- 1 file changed, 15 insertions(+), 7 deletions(-) (limited to 'apfilo.f90') diff --git a/apfilo.f90 b/apfilo.f90 index c933b91..2efbe1c 100644 --- a/apfilo.f90 +++ b/apfilo.f90 @@ -81,6 +81,9 @@ contains call setviewport(E%x, E%y, E%x+E%w, E%y+E%h, .TRUE.) call clearviewport() + ! We used to compute this per line, but the text height calcs are way off + rh = textheight('XXXyy') + y = 0 do irow = 1+E%rowoff, E%rowoff + E%screenrows x = 0 @@ -94,8 +97,8 @@ contains if(E%coloff+1 > len(row_text)) then rh = textheight('XXX') else - icol = 1 + E%coloff - icollast = min(E%coloff+E%screencols, len(row_text)) + icol = 1 - E%coloff + icollast = min(icol+E%screencols, len(row_text)) call outtextxy(x, y, row_text(icol:icollast)) rh = textheight(row_text(icol:icollast)) end if @@ -106,23 +109,28 @@ contains end if ! Cursor - if(irow - E%rowoff - 1 == E%cy) then + if(irow - E%rowoff == E%cy) then if(.not. associated(row_text) .or. E%cx == 1) then x = 0 else ! Width calculations are all messed up by trimming ! being performed in textwidth - x = index(row_text(icol:icol+E%cx-2), ' ') + if(len(row_text) < icol+E%cx-2) then + E%cx = len(row_text) - icol + 2 + end if + icollast = icol+E%cx-2 + x = index(row_text(icol:icollast), ' ') do while(x > 0) x = x + icol - 1 + row_text(x:x) = '_' - x = index(row_text(icol:icol+E%cx-2), ' ') + x = index(row_text(icol:icollast), ' ') end do - x = textwidth(row_text(icol:icol+E%cx-2)) + x = textwidth(row_text(icol:icollast)) end if - call bar(x, y-rh-1, x+3, y+1) + call bar(x, y+rh-1, x+3, y+1) end if if(associated(row_text)) then -- cgit v1.2.3