summaryrefslogtreecommitdiff
path: root/driver.f90
diff options
context:
space:
mode:
Diffstat (limited to 'driver.f90')
-rw-r--r--driver.f9082
1 files changed, 82 insertions, 0 deletions
diff --git a/driver.f90 b/driver.f90
new file mode 100644
index 0000000..8008e81
--- /dev/null
+++ b/driver.f90
@@ -0,0 +1,82 @@
+program driver
+use appgraphics
+use appgraphics_filo
+use filo
+implicit none
+
+ type(apEditorConfig)::E
+ integer::mywindow
+ integer::key, delta, rowoff
+ logical::cursor_moved
+
+ mywindow = initwindow(640, 480, dbflag=.true., closeflag=.true.)
+
+ call settextstyle(MONOSPACE_FONT, HORIZ_DIR, 20)
+ call setfillstyle(SOLID_FILL, WHITE)
+
+ E = initApEditor(mywindow)
+
+ if(.not. editorOpen(E, "kilo.c")) then
+ Print *, "Error opening file..."
+ stop
+ end if
+
+ call drawApEditor(E)
+ call swapbuffers()
+
+ do while(.true.)
+ call startidle(50)
+ do while(kbhit())
+ cursor_moved = .false.
+ rowoff = E%rowoff
+
+ key = getch()
+ ! Special character
+ if(key == 0) then
+ key = getch()
+ delta = 0
+ select case(key)
+ case(KEY_UP)
+ E%cy = max(E%cy - 1, 1)
+ cursor_moved = .true.
+ case(KEY_DOWN)
+ E%cy = min(E%cy + 1, E%screenrows)
+ cursor_moved = .true.
+ case(KEY_LEFT)
+ E%cx = max(E%cx - 1, 0)
+ cursor_moved = .true.
+ case(KEY_RIGHT)
+ E%cx = min(E%cx + 1, E%screencols)
+ cursor_moved = .true.
+ case(KEY_PGUP)
+ delta = -1*E%screenrows
+ case(KEY_PGDN)
+ delta = E%screenrows
+ end select
+
+ rowoff = rowoff + delta
+ rowoff = max(rowoff, 0)
+ rowoff = min(rowoff, E%numrows - E%screenrows)
+ else
+
+ select case(key)
+ case(8) ! Backspace
+ call editorDelChar(E)
+ case default
+ call editorInsertChar(E, char(key))
+ end select
+
+ cursor_moved = .TRUE.
+
+ end if
+
+ if(rowoff /= E%rowoff .or. cursor_moved) then
+ e%rowoff = rowoff
+ call drawApEditor(E)
+ call swapbuffers()
+ end if
+
+ end do
+ end do
+
+end program driver \ No newline at end of file