aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJeffrey Armstrong <jeff@approximatrix.com>2020-05-18 09:25:16 -0400
committerJeffrey Armstrong <jeff@approximatrix.com>2020-05-18 09:25:16 -0400
commit9061cceae5cd9b2a1b17cd895ba92729987e4803 (patch)
tree2a0ef48b0361f37fa706457a285f62791eed4f19
parenta4de5b27c2ce9aca1516b13ad9c70a51f9bd06ff (diff)
downloadLR-87-9061cceae5cd9b2a1b17cd895ba92729987e4803.tar.gz
LR-87-9061cceae5cd9b2a1b17cd895ba92729987e4803.zip
Fixed rendering when an error occurs in GUI client. GUI client window title now set to first encountered level 1 heading.
-rw-r--r--ag_render.f9077
-rw-r--r--gemini-windows.prj2
-rw-r--r--protocol.f902
3 files changed, 66 insertions, 15 deletions
diff --git a/ag_render.f90 b/ag_render.f90
index 888a83c..071f261 100644
--- a/ag_render.f90
+++ b/ag_render.f90
@@ -77,6 +77,12 @@ implicit none
! Needed to compute document height
integer::initial_y
+ ! An error has occurred, so render blank
+ logical::render_blank
+
+ ! A title was guessed and set
+ logical::title_guessed
+
contains
procedure :: initialize => ag_initialize
@@ -175,6 +181,21 @@ contains
end subroutine resize_callback
+ subroutine set_window_title(self, text)
+ use appgraphics, only: setwindowtitle
+ implicit none
+
+ type(appgraphics_renderer)::self
+ character(*), intent(in)::text
+
+ if(len_trim(text) > 0) then
+ call setwindowtitle("LR-87 :: "//trim(text))
+ else
+ call setwindowtitle("LR-87")
+ end if
+
+ end subroutine set_window_title
+
subroutine draw_address_bar(self)
use appgraphics
implicit none
@@ -182,6 +203,14 @@ contains
type(appgraphics_renderer)::self
integer::x, address_width, label_x
+
+ ! See below where this is used...
+ interface
+ function switch_to_thread() bind(c, name="SwitchToThread")
+ use iso_c_binding
+ integer(kind=c_int)::switch_to_thread
+ end function switch_to_thread
+ end interface
self%address_bar_height = 24
@@ -193,7 +222,7 @@ contains
! Draw the buttons first
x = getmaxx()/4 - 40
- if(self%back_button_id == 0) then
+ if(self%back_button_id < 0) then
self%back_button_id = createbutton(x, 2, 40, 20, "Back", back_button_callback)
else
call setbuttonposition(self%back_button_id, x, 2, 40, 20)
@@ -204,20 +233,23 @@ contains
x = x + textwidth("Address:") + 5
address_width = getmaxx()/2 - textwidth("Address:") - 5
- if(self%address_id == 0) then
+ if(self%address_id < 0) then
self%address_id = createtextbox(x, 2, address_width, 20)
else
call settextboxposition(self%address_id, x, 2, address_width, 20)
end if
x = x + 10 + address_width
- if(self%go_button_id == 0) then
+ if(self%go_button_id < 0) then
self%go_button_id = createbutton(x, 2, 40, 20, "Go!", go_button_callback)
else
call setbuttonposition(self%go_button_id, x, 2, 40, 20)
end if
- call setviewport(0, 0, getmaxx(), self%address_bar_height, .true.)
+ ! Clears any drawing operations for controls quickly
+ x = switch_to_thread()
+
+ call setviewport(0, 0, getmaxx()+1, self%address_bar_height+1, .true.)
call clearviewport()
call outtextxy(label_x, 5, "Address:")
call resetviewport()
@@ -255,8 +287,8 @@ contains
self%scroll_bar_width = 15
h = getmaxy()-self%address_bar_height-self%status_bar_height - 1
- if(self%scroll_id == 0) then
- self%scroll_id = createscrollbar(getmaxx()-self%scroll_bar_width, &
+ if(self%scroll_id < 0) then
+ self%scroll_id = createscrollbar(getmaxx() - self%scroll_bar_width + 1, &
self%address_bar_height+1, &
self%scroll_bar_width, &
h, &
@@ -266,7 +298,7 @@ contains
call setscrollrange(self%scroll_id, 0, 100)
else
call setscrollbarposition(self%scroll_id, &
- getmaxx()-self%scroll_bar_width, &
+ getmaxx() - self%scroll_bar_width + 1, &
self%address_bar_height+1, &
self%scroll_bar_width, &
h)
@@ -303,10 +335,10 @@ contains
call setbkcolor(LIGHTGRAY)
call clearviewport()
- self%address_id = 0
- self%go_button_id = 0
- self%back_button_id = 0
- self%scroll_id = 0
+ self%address_id = -1
+ self%go_button_id = -1
+ self%back_button_id = -1
+ self%scroll_id = -1
call draw_address_bar(self)
call draw_status_bar(self, "Welcome to the LR-87 Gemini Client")
@@ -324,6 +356,10 @@ contains
self%right_border = 5
self%bullet_margin = 5
+ self%render_blank = .false.
+
+ self%title_guessed = .false.
+
end subroutine ag_initialize
function get_clicked_link(self)
@@ -361,7 +397,7 @@ contains
call setviewport(0, &
self%address_bar_height+1, &
- getmaxx() - self%scroll_bar_width - 1, &
+ getmaxx() - self%scroll_bar_width + 1, &
getmaxy() - self%status_bar_height, &
.true.)
@@ -483,6 +519,12 @@ contains
font_size = self%font_size
if(present(heading)) then
font_size = get_font_size(self, heading)
+
+ ! The first level 1 heading can be guessed as the page title
+ if(heading == 1 .and. .not. self%title_guessed) then
+ call set_window_title(self, text)
+ self%title_guessed = .true.
+ end if
end if
x = self%left_border
@@ -627,6 +669,10 @@ contains
class(appgraphics_renderer)::self
character(*), intent(in)::text
+ ! Force blank draw
+ self%render_blank = .true.
+ ag_render_event = ag_render_event_resize
+
call dlgmessage(0, text)
end subroutine ag_draw_error
@@ -708,6 +754,11 @@ contains
end select
+ ! if a layout was requested, but we're blank...
+ if(ag_action == render_action_layout .and. self%render_blank) then
+ call ag_prepare_for_layout(self) ! This clears the screen fine
+ end if
+
! We've handled the event here, reset to none
ag_render_event = ag_render_event_none
@@ -734,7 +785,7 @@ contains
class(appgraphics_renderer)::self
character(*), intent(in)::text
- call setwindowtitle("LR-87 :: "//trim(text))
+ call set_window_title(self, text)
if(index(text, "gemini://") > 0) then
call settextboxcontents(self%address_id, trim(text))
diff --git a/gemini-windows.prj b/gemini-windows.prj
index 12f6e87..da3c717 100644
--- a/gemini-windows.prj
+++ b/gemini-windows.prj
@@ -106,7 +106,7 @@
"Launch Using MPI":"false",
"Keep Console":"true",
"External Console":"true",
- "Command Line Arguments":"",
+ "Command Line Arguments":"gemini.conman.org",
"Build Before Launch":"true"
},
"Build Options":{
diff --git a/protocol.f90 b/protocol.f90
index e8039d3..c25441c 100644
--- a/protocol.f90
+++ b/protocol.f90
@@ -135,7 +135,7 @@ contains
returncode = -1
write(unit_number, *) "Send Error: Could Not Send Request"
- write(*, *) "Send Error: Could Not Send Request"
+
end if
else