aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJeffrey Armstrong <jeff@approximatrix.com>2020-05-23 09:38:28 -0400
committerJeffrey Armstrong <jeff@approximatrix.com>2020-05-23 09:38:28 -0400
commit8088abdfae2f18520b9135221885479ae37a5dae (patch)
tree0b5bdb6c1759ad71e771f35781f36bc1fff0ddb4
parent60eddf90062aa72529a5a6baa6fd1983eed4c3a8 (diff)
downloadLR-87-8088abdfae2f18520b9135221885479ae37a5dae.zip
LR-87-8088abdfae2f18520b9135221885479ae37a5dae.tar.gz
Introduced new handling of other protocols under windows. Likely broke dumb renderer for the moment.
-rw-r--r--ag_render.f9041
-rw-r--r--main.F9029
-rw-r--r--render.f907
3 files changed, 68 insertions, 9 deletions
diff --git a/ag_render.f90 b/ag_render.f90
index c357318..576d34d 100644
--- a/ag_render.f90
+++ b/ag_render.f90
@@ -119,6 +119,8 @@ implicit none
procedure :: report_displayed_page => ag_report_page
+ procedure :: report_unsupported_protocol => ag_report_unsupported_protocol
+
end type appgraphics_renderer
contains
@@ -798,4 +800,43 @@ contains
end subroutine ag_report_page
+ function ag_report_unsupported_protocol(self, url)
+ use iso_c_binding, only: c_null_char, c_null_ptr
+ use appgraphics, only: dlgyesno
+ implicit none
+
+ class(appgraphics_renderer)::self
+ character(*), intent(in)::url
+ logical::ag_report_unsupported_protocol
+
+ type(c_ptr)::ret
+
+ interface
+ function ShellExecute(h, verb, filename, params, dir, showcmd) bind(c, name="ShellExecuteA")
+ use iso_c_binding
+ type(c_ptr)::h
+ character(kind=c_char)::verb
+ character(kind=c_char)::filename
+ type(c_ptr)::params
+ type(c_ptr)::dir
+ integer(kind=c_int)::showcmd
+ type(c_ptr)::ShellExecute
+ end function ShellExecute
+ end interface
+
+ if(dlgyesno(DIALOG_WARN, "Ask Windows to open "//trim(url)//" in another program?")) then
+
+ ret = ShellExecute(c_null_ptr, &
+ "open"//c_null_char, &
+ trim(url)//c_null_char, &
+ c_null_ptr, &
+ c_null_ptr, &
+ 5) ! 5 is SW_SHOW
+
+ end if
+
+ ag_report_unsupported_protocol = .true.
+
+ end function ag_report_unsupported_protocol
+
end module ag_render
diff --git a/main.F90 b/main.F90
index 24cecfc..9055664 100644
--- a/main.F90
+++ b/main.F90
@@ -59,6 +59,7 @@ implicit none
logical::running
logical::loaded
logical::populated
+ logical::redo_layout
integer::return_code
character(256)::return_type
@@ -101,13 +102,14 @@ implicit none
locations_visited => null()
current_url = initial_site
+ first_line => null()
open(unit=io, form="formatted", status="scratch", access='stream')
do while(running)
if(index(current_url, "gemini://") /= 1) then
- call r%report_unsupported_protocol(trim(current_url))
+ redo_layout = r%report_unsupported_protocol(trim(current_url))
populated = .false.
loaded = .true.
return_code = STATUS_LOCALFAIL
@@ -145,12 +147,18 @@ implicit none
if(r%type_supported(return_type)) then
+ ! Only erase if we're loading new lines!
+ if(associated(first_line)) then
+ call free_lines(first_line)
+ end if
+
first_line => load_unit(io, file_type_gemini)
loaded = .true.
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)
@@ -158,6 +166,16 @@ implicit none
end if
+ else if(redo_layout) then
+
+ if(associated(first_line)) then
+ call r%report_status("Performing Layout")
+ call layout_lines(first_line, r)
+ call r%status_ready()
+ end if
+
+ redo_layout = .false.
+
end if
do while(loaded .and. running)
@@ -168,9 +186,6 @@ implicit none
case (render_action_back)
call back_location(locations_visited, current_url)
- if(associated(first_line)) then
- call free_lines(first_line)
- end if
loaded = .false.
case (render_action_layout)
@@ -188,9 +203,9 @@ implicit none
call handle_relative_url(current_url, input)
end if
- if(associated(first_line)) then
- call free_lines(first_line)
- end if
+ !if(associated(first_line)) then
+ ! call free_lines(first_line)
+ !end if
loaded = .false.
end select
diff --git a/render.f90 b/render.f90
index 97458e0..ff9ed7f 100644
--- a/render.f90
+++ b/render.f90
@@ -240,15 +240,18 @@ contains
end subroutine status_ready
- subroutine report_unsupported_protocol(self, url)
+ function report_unsupported_protocol(self, url)
implicit none
class(renderer)::self
character(*), intent(in)::url
+ logical::report_unsupported_protocol
call self%draw_error("Only gemini:// URLs supported ("//url//")")
- end subroutine report_unsupported_protocol
+ report_unsupported_protocol = .false.
+
+ end function report_unsupported_protocol
function width_of_line(r, text, startpos, endpos, heading_level, list_item)
implicit none