@@ -45,8 +45,6 @@ declare -ri THEME_SET_DEF_ACTIVE=30
4545declare -ri THEME_SET_SLI_INACTIVE=40
4646declare -ri THEME_SET_SLI_ACTIVE=50
4747
48- # file for persisting theme
49- declare -r BIW_SETTINGS_FILE=$HOME /.biw_settings
5048
5149# initialize the default theme
5250declare -i theme_active_idx=-1
@@ -60,31 +58,39 @@ declare -i theme_saved_idx=-1
6058# reference of theme names
6159declare -a theme_name_list
6260
61+ # settings param name
62+ declare -r theme_param_name=' theme-name'
63+
6364fn_theme_init ()
6465{
6566 fn_theme_set_desc_list
6667
6768 if [ ! -r $BIW_SETTINGS_FILE ]
6869 then
6970 # nothing to load so set default
70- fn_theme_set_idx_active -1
71+ fn_theme_set_idx_active 0
7172 return
7273 fi
7374
74- local _saved_name= $( cat $BIW_SETTINGS_FILE )
75-
75+ local _saved_name
76+ fn_settings_get_param ' _saved_name ' $theme_param_name
7677 fn_theme_idx_from_name $_saved_name
7778 theme_saved_idx=$?
79+
80+ # init the theme
81+ fn_theme_set_idx_active $theme_saved_idx
82+ }
83+
84+ function fn_theme_save()
85+ {
86+ theme_saved_idx=$theme_active_idx
87+ local _saved_theme=${THEME_LIST[$theme_saved_idx]}
88+ fn_settings_set_param $theme_param_name $_saved_theme
7889}
7990
8091function fn_theme_set_idx_active()
8192{
8293 local -i _selected_idx=$1
83- if (( _selected_idx == - 1 ))
84- then
85- # use the default
86- _selected_idx=0
87- fi
8894
8995 if(( _selected_idx == theme_active_idx))
9096 then
@@ -178,13 +184,6 @@ function fn_theme_parse_color()
178184 printf -v $_result_ref ' %d' $_color_result
179185}
180186
181- fn_theme_save ()
182- {
183- theme_saved_idx=$theme_active_idx
184- local _saved_theme=${THEME_LIST[$theme_saved_idx]}
185- echo ${_saved_theme} > $BIW_SETTINGS_FILE
186- }
187-
188187fn_theme_idx_from_name ()
189188{
190189 local -r _theme_name=$1
@@ -290,6 +289,3 @@ function fn_theme_set_color()
290289 fn_sgr_color16_set $_mode $_theme_color
291290 fi
292291}
293-
294- # always init theme
295- fn_theme_init
0 commit comments