aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJeffrey Armstrong <jeff@approximatrix.com>2020-08-11 11:18:40 -0400
committerJeffrey Armstrong <jeff@approximatrix.com>2020-08-11 11:18:40 -0400
commitc4e6d5f47a876ac7e6446531005665d6547fafb5 (patch)
tree2e4ba14484a37da3e1f9ed1b10d1aab193356cde
parente9dfc0a04d1bdb018ae77f1d914bf0e77f3370b6 (diff)
downloadLR-87-c4e6d5f47a876ac7e6446531005665d6547fafb5.tar.gz
LR-87-c4e6d5f47a876ac7e6446531005665d6547fafb5.zip
Favorites can be removed too. Added some robustness to loading favorites, especially when there are none remaining.
-rw-r--r--dumb_render.f905
-rw-r--r--favorites.f9036
-rw-r--r--gemini.prj9
-rw-r--r--main.F9010
4 files changed, 51 insertions, 9 deletions
diff --git a/dumb_render.f90 b/dumb_render.f90
index 2f2f2b8..02a6e2a 100644
--- a/dumb_render.f90
+++ b/dumb_render.f90
@@ -396,7 +396,7 @@ contains
character(*), intent(out)::input
- write(*, '(A66)', advance='no') "*** [U] URL | [!] Save/Remove Fave | [F] Goto Faves | [Q] Quit => "
+ write(*, '(A60)', advance='no') "*** [U] URL | [!] Save/Remove Fave | [L] Menu | [Q] Quit => "
read(*, *) input
end subroutine prompt_user_more
@@ -430,6 +430,9 @@ contains
dumb_action = render_action_back
else if(trim(input) == "q" .or. trim(input) == "Q") then
dumb_action = render_action_quit
+ else if(trim(input) == "l" .or. trim(input) == "L") then
+ dumb_action = render_action_goto
+ text = "lr87://menu"
else if(trim(input) == "u" .or. trim(input) == "U") then
write(*, '(A5)', advance='no') "URL: "
read(*,'(A75)') text
diff --git a/favorites.f90 b/favorites.f90
index 90cd2d1..425930d 100644
--- a/favorites.f90
+++ b/favorites.f90
@@ -4,7 +4,8 @@ implicit none
private
public :: favorite, sort_added, sort_alpha, read_favorites, &
- write_favorites, add_favorite, remove_favorite
+ write_favorites, add_favorite, remove_favorite, &
+ is_favorite
type :: favorite
@@ -195,14 +196,22 @@ contains
character(80)::temp
integer::n, i, ios
+ faves => null()
+
! Title
- read(unit_number, *) temp
+ read(unit_number, *, iostat=ios) temp
+ if(ios /= 0) then
+ return
+ end if
! Blank
!read(unit_number, *) temp
! Count
- read(unit_number, *) n
+ read(unit_number, *, iostat=ios) n
+ if(ios /= 0) then
+ return
+ end if
! Blank
!read(unit_number, *) temp
@@ -234,7 +243,7 @@ contains
implicit none
integer, intent(in)::unit_number
- type(favorite), dimension(:), intent(in)::faves
+ type(favorite), dimension(:), intent(in), pointer::faves
logical, intent(in), optional::skip_heading
integer::i
@@ -250,6 +259,10 @@ contains
write(unit_number, *)
end if
+ if(.not.associated(faves)) then
+ return
+ end if
+
write(n_text, '(I8)') size(faves)
write(unit_number, *) trim(adjustl(n_text))//" Links Are Marked As Favorites"
@@ -367,4 +380,19 @@ contains
end subroutine remove_favorite
+ function is_favorite(faves, link)
+ implicit none
+
+ type(favorite), dimension(:), intent(in), pointer::faves
+ character(*), intent(in)::link
+ logical::is_favorite
+
+ is_favorite = .false.
+
+ if(associated(faves)) then
+ is_favorite = (find_favorite(faves, link) > 0)
+ end if
+
+ end function is_favorite
+
end module favorite_handling \ No newline at end of file
diff --git a/gemini.prj b/gemini.prj
index 4c739ed..1f044b4 100644
--- a/gemini.prj
+++ b/gemini.prj
@@ -44,6 +44,9 @@
"filename":"history.f90",
"enabled":"1"
},{
+ "filename":"internal.f90",
+ "enabled":"1"
+ },{
"filename":"layout.f90",
"enabled":"1"
},{
@@ -98,10 +101,11 @@
"Target":"lr87",
"Fortran Options":{
"Use C Preprocessor":"false",
- "Runtime Diagnostics":"true",
+ "Runtime Diagnostics":"false",
"Cray Pointers":"false",
- "Enable OpenMP":"false",
"Enable Coarrays":"false",
+ "Enable OpenMP":"false",
+ "Initialize Variables to Zero":"false",
"Default Double for Real":"false"
},
"Code Generation Options":{
@@ -110,6 +114,7 @@
"Aggressive Loops":"false",
"Debugging":"true",
"Optimization Mode":0,
+ "Floating Point Trap":"false",
"Profiling":"false"
},
"Build Dependencies":1,
diff --git a/main.F90 b/main.F90
index 9af9708..0926192 100644
--- a/main.F90
+++ b/main.F90
@@ -256,7 +256,13 @@ implicit none
loaded = .false.
case (render_action_favorite)
- call add_favorite(faves, current_url, current_url)
+ if(is_favorite(faves, current_url)) then
+ call remove_favorite(faves, current_url)
+ call r%report_status(trim(current_url)//" removed as favorite")
+ else
+ call add_favorite(faves, current_url, current_url)
+ call r%report_status("Added favorite: "//trim(current_url))
+ end if
call save_favorites(faves)
end select
@@ -345,7 +351,7 @@ contains
use favorite_handling, only: write_favorites, favorite
implicit none
- type(favorite), dimension(:)::faves
+ type(favorite), dimension(:), intent(in), pointer::faves
character(260)::filename
integer::ios, loadunit