summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJeffrey Armstrong <jeff@approximatrix.com>2021-12-29 13:04:40 -0500
committerJeffrey Armstrong <jeff@approximatrix.com>2021-12-29 13:04:40 -0500
commitf3ebef8119973bcb906f2a597e041ef7d5afab0c (patch)
tree20b3d40564bcbb594b4a8a56d74113c302388d89
parent6921c5c7332dc2c2ddf1dd2415901d138ec48600 (diff)
downloadfilo-f3ebef8119973bcb906f2a597e041ef7d5afab0c.tar.gz
filo-f3ebef8119973bcb906f2a597e041ef7d5afab0c.zip
Additional changes to debug 1-indexing. Cursor now appears on correct line. Strange behavior at line end insert.
-rw-r--r--ap_kilo.prj2
-rw-r--r--apfilo.f9022
-rw-r--r--driver.f9015
-rw-r--r--filo.f904
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",
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
diff --git a/driver.f90 b/driver.f90
index 8008e81..f6841ce 100644
--- a/driver.f90
+++ b/driver.f90
@@ -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
diff --git a/filo.f90 b/filo.f90
index 3918d8e..c358aa6 100644
--- a/filo.f90
+++ b/filo.f90
@@ -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)