From f6a2bd488ca74881855f74f5302078526cfbd81c Mon Sep 17 00:00:00 2001 From: Jeffrey Armstrong Date: Sat, 8 Aug 2020 09:18:45 -0400 Subject: Initial work on favorites added. Probably flat-out wrong... --- main.F90 | 55 +++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 55 insertions(+) (limited to 'main.F90') diff --git a/main.F90 b/main.F90 index 7021195..fd618c3 100644 --- a/main.F90 +++ b/main.F90 @@ -42,6 +42,8 @@ use history use wsa_network, only: windows_network_startup => startup #endif +use favorite_handling + implicit none character(256)::initial_site @@ -69,6 +71,8 @@ implicit none type(line), pointer::first_line type(location), pointer::locations_visited + type(favorite), dimension(:), allocatable::faves + #ifdef WINDOWS call windows_network_startup() #endif @@ -101,6 +105,9 @@ implicit none redo_layout = .false. call r%initialize() + ! Load in any favorites + faves = load_favorites() + locations_visited => null() desired_url = initial_site current_url = " " @@ -231,6 +238,10 @@ implicit none loaded = .false. + case (render_action_favorite) + call add_favorite(faves, current_url, current_url) + call save_favorites(faves) + end select end do @@ -286,4 +297,48 @@ contains end subroutine update_status + function load_favorites() result(faves) + use platform, only: get_favorites_file + use favorite_handling, only: read_favorites, favorite + implicit none + + type(favorite), dimension(:), allocatable::faves + + character(260)::filename + integer::ios, loadunit + + call get_favorites_file(filename) + + open(newunit=loadunit, file=filename, status='old', action='read', iostat=ios) + if(ios == 0) then + + faves = read_favorites(loadunit) + close(loadunit) + + end if + + end function load_favorites + + subroutine save_favorites(faves) + use platform, only: get_favorites_file + use favorite_handling, only: write_favorites, favorite + implicit none + + type(favorite), dimension(:), allocatable::faves + + character(260)::filename + integer::ios, loadunit + + call get_favorites_file(filename) + + open(newunit=loadunit, file=filename, status='unknown', action='write', iostat=ios) + if(ios == 0) then + + call write_favorites(loadunit, faves) + close(loadunit) + + end if + + end subroutine save_favorites + end program gemini -- cgit v1.2.3