aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--ag_render.f90101
-rw-r--r--dumb_render.f9012
-rw-r--r--gemini-windows.prj2
-rw-r--r--main.F903
-rw-r--r--render.f9012
5 files changed, 121 insertions, 9 deletions
diff --git a/ag_render.f90 b/ag_render.f90
index 34883e4..be21112 100644
--- a/ag_render.f90
+++ b/ag_render.f90
@@ -33,12 +33,14 @@ implicit none
integer, parameter::max_links_displayed = 64
integer, volatile::ag_render_event
+ integer, volatile::scroll_position
integer, parameter::ag_render_event_none = 0
integer, parameter::ag_render_event_closed = 1
integer, parameter::ag_render_event_mouse = 2
integer, parameter::ag_render_event_back = 3
integer, parameter::ag_render_event_go = 4
+ integer, parameter::ag_render_event_scroll = 5
type :: link
integer, dimension(4)::location
@@ -51,6 +53,7 @@ implicit none
integer::address_id
integer::go_button_id
integer::back_button_id
+ integer::scroll_id
integer::font_size
integer::default_font
@@ -64,10 +67,15 @@ implicit none
integer::background_color
integer::address_bar_height
+ integer::scroll_bar_width
+ integer::status_bar_height
integer::link_count
type(link), dimension(max_links_displayed)::links
+ ! Needed to compute document height
+ integer::initial_y
+
contains
procedure :: initialize => ag_initialize
@@ -146,6 +154,17 @@ contains
end subroutine mouse_button_callback
+ subroutine scrolled_callback(x)
+ use appgraphics, only: stopidle
+ implicit none
+
+ integer::x
+ scroll_position = x
+ ag_render_event = ag_render_event_scroll
+ call stopidle()
+
+ end subroutine scrolled_callback
+
subroutine draw_address_bar(self)
use appgraphics
implicit none
@@ -191,6 +210,56 @@ contains
end subroutine draw_address_bar
+ subroutine draw_status_bar(self, text)
+ use appgraphics
+ implicit none
+
+ type(appgraphics_renderer)::self
+ character(*), intent(in)::text
+
+ self%status_bar_height = 16
+
+ call resetviewport()
+
+ call setfillstyle(SOLID_FILL, LIGHTGRAY)
+ call setbkcolor(LIGHTGRAY)
+ call setcolor(BLACK)
+ call settextstyle(WINDOWS_FONT, HORIZ_DIR, 12)
+
+ call bar(0, getmaxy()-self%status_bar_height, getmaxx(), getmaxy())
+ call outtextxy(self%left_border+2, getmaxy()-self%status_bar_height+2, trim(text))
+
+ end subroutine draw_status_bar
+
+ subroutine draw_scroll_bar(self)
+ use appgraphics
+ implicit none
+
+ type(appgraphics_renderer)::self
+
+ integer::h
+
+ self%scroll_bar_width = 15
+ h = getmaxy()-self%address_bar_height-self%status_bar_height
+ if(self%scroll_id == 0) then
+ self%scroll_id = createscrollbar(getmaxx()-self%scroll_bar_width, &
+ self%address_bar_height, &
+ self%scroll_bar_width, &
+ h, &
+ SCROLL_VERTICAL, &
+ scrolled_callback)
+
+ call setscrollrange(self%scroll_id, 0, 100)
+ else
+ call setscrollbarposition(self%scroll_id, &
+ getmaxx()-self%scroll_bar_width, &
+ self%address_bar_height, &
+ self%scroll_bar_width, &
+ h)
+ end if
+
+ end subroutine draw_scroll_bar
+
subroutine ag_initialize(self)
use appgraphics
implicit none
@@ -207,8 +276,11 @@ contains
self%address_id = 0
self%go_button_id = 0
self%back_button_id = 0
+ self%scroll_id = 0
call draw_address_bar(self)
+ call draw_status_bar(self, "Welcome to the LR-87 Gemini Client")
+ call draw_scroll_bar(self)
self%background_color = WHITE
self%text_color = BLACK
@@ -236,7 +308,7 @@ contains
get_clicked_link = -1
mx = mousex()
my = mousey()
-
+ my = my - self%address_bar_height
do i = 1, self%link_count
if(my >= self%links(i)%location(2) .and. my <= self%links(i)%location(4) .and. &
mx >= self%links(i)%location(1) .and. mx <= self%links(i)%location(3)) then
@@ -257,11 +329,16 @@ contains
call setbkcolor(self%background_color)
call resetviewport()
- call setviewport(0, self%address_bar_height+1, getmaxx(), getmaxy(), .true.)
+ call setviewport(0, &
+ self%address_bar_height+1, &
+ getmaxx() - self%scroll_bar_width - 1, &
+ getmaxy() - self%status_bar_height, &
+ .true.)
call clearviewport()
self%link_count = 0
+ self%initial_y = self%y
end subroutine ag_prepare_for_layout
@@ -271,6 +348,8 @@ contains
class(appgraphics_renderer)::self
self%y = 0
+ call setscrollposition(self%scroll_id, 0)
+ ag_render_event = ag_render_event_none
end subroutine ag_new_page
@@ -528,7 +607,7 @@ contains
class(appgraphics_renderer)::self
character(*), intent(in)::text
- ! Pass for now...
+ call draw_status_bar(self, text)
end subroutine ag_draw_status
@@ -543,10 +622,12 @@ contains
integer::link_clicked
integer::ignored
- ag_render_event = ag_render_event_none
+ ! For scrolling
+ integer::doclength
- ! Pass for now...
- call startidle(10000)
+ if(ag_render_event == ag_render_event_none) then
+ call startidle(10000)
+ end if
ag_action = render_action_none
select case (ag_render_event)
@@ -570,8 +651,16 @@ contains
call clearmouseclick(MOUSE_LB_UP)
+ case(ag_render_event_scroll)
+ doclength = self%y - self%initial_y
+ self%y = (doclength * scroll_position) / (-100)
+ ag_action = render_action_layout
+
end select
+ ! We've handled the event here, reset to none
+ ag_render_event = ag_render_event_none
+
end function ag_action
function ag_request_save_filename(self, url, mimetype, filename)
diff --git a/dumb_render.f90 b/dumb_render.f90
index 666a7b0..23b991b 100644
--- a/dumb_render.f90
+++ b/dumb_render.f90
@@ -65,6 +65,7 @@ implicit none
procedure :: draw_error => dumb_draw_error
procedure :: report_status => dumb_draw_status
+ procedure :: status_ready => dumb_ready_status
procedure :: request_action => dumb_action
@@ -111,7 +112,7 @@ contains
self%y = 0
end subroutine prepare_for_dumb_layout
-
+
function store_link(self, url)
implicit none
@@ -368,6 +369,15 @@ contains
end subroutine dumb_draw_status
+ subroutine dumb_ready_status(self)
+ implicit none
+
+ class(dumb_renderer)::self
+
+ ! Override to do nothing
+
+ end subroutine dumb_ready_status
+
subroutine prompt_user(input)
implicit none
diff --git a/gemini-windows.prj b/gemini-windows.prj
index c53c8ea..12f6e87 100644
--- a/gemini-windows.prj
+++ b/gemini-windows.prj
@@ -76,7 +76,7 @@
"Architecture":1,
"Type":0,
"Revision":2,
- "Windows GUI":0,
+ "Windows GUI":1,
"File Options":{
"Library Directories":["Default Add-On Directory","../../Workspace/git/libvncserver/openssl-1.1.1f-win64-mingw/lib"],
"Build Directory":"build",
diff --git a/main.F90 b/main.F90
index 16da056..6d6b78d 100644
--- a/main.F90
+++ b/main.F90
@@ -146,7 +146,7 @@ implicit none
call r%new_page()
call r%report_status("Performing Layout")
call layout_lines(first_line, r)
-
+ call r%status_ready()
else
call r%draw_error("Cannot display file of type "//return_type)
@@ -173,6 +173,7 @@ implicit none
if(associated(first_line)) then
call r%report_status("Performing Layout")
call layout_lines(first_line, r)
+ call r%status_ready()
end if
case (render_action_goto)
diff --git a/render.f90 b/render.f90
index 80de58b..c8f1333 100644
--- a/render.f90
+++ b/render.f90
@@ -33,6 +33,8 @@ implicit none
["text/plain ", &
"text/gemini" ]
+ character(*), parameter::idle_status = "LR-87 Ready"
+
type, abstract :: renderer
integer::y
@@ -42,6 +44,7 @@ implicit none
procedure::render_proportional
procedure::type_supported
+ procedure::status_ready
procedure(initialize), deferred::initialize
procedure(prepare_for_layout), deferred::prepare_for_layout
@@ -227,6 +230,15 @@ contains
end function type_supported
+ subroutine status_ready(self)
+ implicit none
+
+ class(renderer)::self
+
+ call self%report_status(idle_status)
+
+ end subroutine status_ready
+
function width_of_line(r, text, startpos, endpos, heading_level, list_item)
implicit none