diff options
-rw-r--r-- | ap_kilo.prj | 2 | ||||
-rw-r--r-- | apfilo.f90 | 22 | ||||
-rw-r--r-- | driver.f90 | 15 | ||||
-rw-r--r-- | filo.f90 | 4 |
4 files changed, 31 insertions, 12 deletions
diff --git a/ap_kilo.prj b/ap_kilo.prj index 1d989da..e08456e 100644 --- a/ap_kilo.prj +++ b/ap_kilo.prj @@ -36,7 +36,7 @@ "Target":"apkilo.exe", "Fortran Options":{ "Use C Preprocessor":"false", - "Runtime Diagnostics":"false", + "Runtime Diagnostics":"true", "Floating Point Exception Trap":0, "Cray Pointers":"false", "Enable Coarrays":"false", @@ -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 @@ -43,10 +43,21 @@ implicit none E%cy = min(E%cy + 1, E%screenrows) cursor_moved = .true. case(KEY_LEFT) - E%cx = max(E%cx - 1, 0) + E%cx = E%cx - 1 + if(E%cx < 0) then + E%cx = 0 + E%coloff = min(E%coloff + 1, 0) + end if cursor_moved = .true. case(KEY_RIGHT) - E%cx = min(E%cx + 1, E%screencols) + E%cx = E%cx + 1 + + Print *, E%cx, E%cy, E%rowoff, E%coloff + + if(E%cx > E%screencols) then + E%coloff = E%coloff - 1 + E%cx = E%cx - 1 + end if cursor_moved = .true. case(KEY_PGUP) delta = -1*E%screenrows @@ -250,8 +250,7 @@ contains character, dimension(:), intent(in)::arr character, dimension(:), allocatable::ctmp - integer::i - + allocate(ctmp(er%size()+size(arr))) ctmp(1:er%size()) = er%chars ctmp(er%size()+1:er%size()+size(arr)) = arr @@ -415,6 +414,7 @@ contains deltax = E%screencols - E%cx + 1 E%cx = E%cx - deltax E%coloff = E%coloff + deltax + Print *, "new offset: ", E%coloff, "->", E%screencols, E%cx end if else call editorRowDelChar(E%row(filerow), filecol - 1) |