diff options
author | Jeffrey Armstrong <jeff@approximatrix.com> | 2021-09-09 11:51:23 -0400 |
---|---|---|
committer | Jeffrey Armstrong <jeff@approximatrix.com> | 2021-09-09 11:51:23 -0400 |
commit | 6921c5c7332dc2c2ddf1dd2415901d138ec48600 (patch) | |
tree | c1af245bdf1bc3cb185615b562c3baaf015b3232 /driver.f90 | |
parent | 69c3ce609d1e8df3956cba6db3d296a7cf3af3de (diff) | |
download | filo-6921c5c7332dc2c2ddf1dd2415901d138ec48600.tar.gz filo-6921c5c7332dc2c2ddf1dd2415901d138ec48600.zip |
Initial Fortran code porting kilo to appgraphics in Fortran
Diffstat (limited to 'driver.f90')
-rw-r--r-- | driver.f90 | 82 |
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 |