Commit: 90af7fa37b87236d81c97dbc1e29544862dedeee
Parent: 2ce1cb1a87052429e18a165d7662b4741fbf263d
Author: Ren Tatsumoto
Date: Tue, 3 Aug 2021 18:11:04 +0300
move profile management
Diffstat:
M | subs2srs.lua | | | 67 | +++++++++++++++++++++++++++++++++++-------------------------------- |
1 file changed, 35 insertions(+), 32 deletions(-)
diff --git a/subs2srs.lua b/subs2srs.lua
@@ -500,38 +500,6 @@ local function update_sentence(new_data, stored_data)
return new_data
end
-local function load_profile(profile_name)
- if is_empty(profile_name) then
- profile_name = profiles.active
- if is_empty(profile_name) then
- profile_name = 'subs2srs'
- end
- end
- mpopt.read_options(config, profile_name)
-end
-
-local function next_profile()
- local first, next, new
- for profile in string.gmatch(profiles.profiles, '[^,]+') do
- if not first then
- first = profile
- end
- if profile == profiles.active then
- next = true
- elseif next then
- next = false
- new = profile
- end
- end
- if next == true or not new then
- new = first
- end
- profiles.active = new
- load_profile(profiles.active)
- validate_config()
- notify("Loaded profile " .. profiles.active)
-end
-
------------------------------------------------------------
-- utility classes
@@ -687,6 +655,41 @@ local filename_factory = (function()
end)()
------------------------------------------------------------
+-- profiles management
+
+local function load_profile(profile_name)
+ if is_empty(profile_name) then
+ profile_name = profiles.active
+ if is_empty(profile_name) then
+ profile_name = 'subs2srs'
+ end
+ end
+ mpopt.read_options(config, profile_name)
+end
+
+local function next_profile()
+ local first, next, new
+ for profile in string.gmatch(profiles.profiles, '[^,]+') do
+ if not first then
+ first = profile
+ end
+ if profile == profiles.active then
+ next = true
+ elseif next then
+ next = false
+ new = profile
+ end
+ end
+ if next == true or not new then
+ new = first
+ end
+ profiles.active = new
+ load_profile(profiles.active)
+ validate_config()
+ notify("Loaded profile " .. profiles.active)
+end
+
+------------------------------------------------------------
-- front for adding and updating notes
local function export_to_anki(gui)