aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--macros/garret.chapters.lua15
-rw-r--r--macros/garret.restyler.lua13
-rw-r--r--modules/garret/README.simpleconf.md51
-rw-r--r--modules/garret/simpleconf.lua46
4 files changed, 8 insertions, 117 deletions
diff --git a/macros/garret.chapters.lua b/macros/garret.chapters.lua
index 826ca93..bcb78b9 100644
--- a/macros/garret.chapters.lua
+++ b/macros/garret.chapters.lua
@@ -5,24 +5,16 @@ script_version = "2.1.0"
script_namespace = "garret.chapters"
local haveDepCtrl, DependencyControl, depctrl = pcall(require, "l0.DependencyControl")
-local simpleconf, config_dir
if haveDepCtrl then
depctrl = DependencyControl {
--feed="TODO",
- {
- {"garret.simpleconf", url="https://github.com/garret1317/aegisub-scripts",}
- --feed="TODO"},
- }
}
- simpleconf = depctrl:requireModules()
- config_dir = depctrl.configDir
-else
- simpleconf = require 'garret.simpleconf'
- config_dir = "?user/config"
end
-local config = simpleconf.get_config(aegisub.decode_path(config_dir.."/"..script_namespace..".conf"), {language = "eng", language_ietf = "en"})
+--local config = simpleconf.get_config(aegisub.decode_path(config_dir.."/"..script_namespace..".conf"), {language = "eng", language_ietf = "en"})
+local config = {language = "eng", language_ietf = "en"}
+
function ms_to_human(start) -- From Significance
local timecode=math.floor(start/1000)
@@ -62,7 +54,6 @@ function get_user_path(default_dir)
end
function main(sub)
- aegisub.log(config_dir)
local times = {}
local names = {}
for i=1,#sub do
diff --git a/macros/garret.restyler.lua b/macros/garret.restyler.lua
index 1c5dc9f..043ee1e 100644
--- a/macros/garret.restyler.lua
+++ b/macros/garret.restyler.lua
@@ -5,22 +5,19 @@ script_version = "2.1.0"
script_namespace = "garret.restyler"
local haveDepCtrl, DependencyControl, depctrl = pcall(require, "l0.DependencyControl")
-local simpleconf
+local karaskel, cleantags
if haveDepCtrl then
depctrl = DependencyControl {
--feed="TODO",
- {"karaskel", "cleantags", {"garret.simpleconf", url="https://github.com/garret1317/aegisub-scripts"}, }
+ {"karaskel", "cleantags"}
}
- kara, clean, simpleconf = depctrl:requireModules()
- config_dir = depctrl.configDir
+ kara, clean = depctrl:requireModules()
else
include("karaskel.lua")
include("cleantags.lua")
- simpleconf = require 'garret.simpleconf'
- config_dir = "?user/config"
end
-local config = simpleconf.get_config(aegisub.decode_path(config_dir.."/"..script_namespace..".conf"), {new_style = "Default"})
+-- local config = simpleconf.get_config(aegisub.decode_path(config_dir.."/"..script_namespace..".conf"), {new_style = "Default"})
-- TODO: detect pre-existing inline tags
-- probably need some kind of ass parsing, or a hack with match()
@@ -52,7 +49,7 @@ end
function main(sub, sel)
local _, styles = karaskel.collect_head(sub, false)
- --local config.new_style = "Default" -- the one we'll be changing stuff to - TODO: configurable
+ local config.new_style = "Default"
local new_style = styles[config.new_style]
for h, i in ipairs(sel) do
-- TODO: automatically exclude styles (also configurable)
diff --git a/modules/garret/README.simpleconf.md b/modules/garret/README.simpleconf.md
deleted file mode 100644
index 8e0569c..0000000
--- a/modules/garret/README.simpleconf.md
+++ /dev/null
@@ -1,51 +0,0 @@
----
-title: simpleconf.lua's Fine Manual
-lang: en-GB
-...
-
-# simpleconf.lua's Fine Manual
-
-read it
-## Usage
-### Loading config files
-
-Synopsis: `config = simpleconf.get_config([config_file, defaults])`
-
-`@config_file` (`string`)
-
- Path of the file to load.
-
-`@defaults` (`table`)
-
- A table containing your default settings.
-
-`config` (table)
-
- Contains config values.
-
-Both values are optional.
-
-If the file and the defaults are present, it loads the defaults, then overwrites their values with those of the file.
-
-If the file is present, but not the defaults, it just loads the contents of the file.
-
-If the file isn't present, but the defaults are, it just loads the defaults, and you're using it wrong.
-
-If nothing is present, it returns an empty table.
-
-| File | Defaults | Result |
-| ---- | -------- | ------ |
-| 1 | 1 | file overwrites defaults |
-| 1 | 0 | just the file |
-| 0 | 1 | just the defaults |
-| 0 | 0 | nothing |
-
-## Config file format
-
-```
-bool = true
-number = 123
-string = the quick brown fox jumps over the lazy dog
-I am a comment!
-```
-(don't tell anyone, but it's all just a pattern nicked from Programming in Lua (page 82, 4th edition))
diff --git a/modules/garret/simpleconf.lua b/modules/garret/simpleconf.lua
deleted file mode 100644
index 6d5f1a8..0000000
--- a/modules/garret/simpleconf.lua
+++ /dev/null
@@ -1,46 +0,0 @@
--- primitive config handler
-
-local function tobool(value)
- if value == "true" then
- return true
- elseif value == "false" then
- return false
- else
- return nil
- end
-end
-
-local function cast(value)
- return tonumber(value) or tobool(value) or value
-end
-
-local function get_config(config_file, defaults)
- local conf = defaults or {}
- local ok, lines = pcall(io.lines, config_file)
- if ok then
- for line in lines do
- local key, value = string.match(line, "(%a+)%s*=%s*(.+)")
- conf[key] = cast(value)
- end
- end
- return conf
-end
-
-local simpleconf = {get_config = get_config}
-
-
-local have_depctrl, depctrl = pcall(require, "l0.DependencyControl")
-
-if have_depctrl then
- local version = depctrl{
- name = "Simple (bad) Config",
- version = "0.1.0",
- description = "primitive config handler",
- author = "garret",
- url = "http://github.com/garret1317/aegisub-scripts",
- moduleName = "garret.simpleconf"}
- simpleconf.version = version
- return version:register(simpleconf)
-else
- return simpleconf
-end