diff options
author | bptato <nincsnevem662@gmail.com> | 2022-01-25 22:30:52 +0100 |
---|---|---|
committer | bptato <nincsnevem662@gmail.com> | 2022-01-25 22:38:08 +0100 |
commit | 0cdcb6b2646e6753b99e66a974040fc6d71d7dfd (patch) | |
tree | 64e115f99c9aaf69aded03c112881e68db042cd3 /src/config | |
parent | aaf1ff614298a64cf0be1adf1a3d5d28882318e7 (diff) | |
download | chawan-0cdcb6b2646e6753b99e66a974040fc6d71d7dfd.tar.gz |
Add some command line fixes, fix related bugs
Diffstat (limited to 'src/config')
-rw-r--r-- | src/config/config.nim | 13 |
1 files changed, 9 insertions, 4 deletions
diff --git a/src/config/config.nim b/src/config/config.nim index 6a3fcd62..43e661c3 100644 --- a/src/config/config.nim +++ b/src/config/config.nim @@ -134,6 +134,7 @@ proc parseConfig(config: var Config, dir: string, t: TomlValue) = if "page" in t: for k, v in t["page"].pairs: config.nmap[getRealKey(k)] = getAction(v.s) + if "line" in t: for k, v in t["line"].pairs: config.lemap[getRealKey(k)] = getLineAction(v.s) if "css" in t: @@ -150,8 +151,14 @@ proc parseConfig(config: var Config, dir: string, t: TomlValue) = if "inline" in css: config.stylesheet &= css["inline"].s +proc parseConfig(config: var Config, dir: string, stream: Stream) = + config.parseConfig(dir, parseToml(stream)) + +proc parseConfig*(config: var Config, dir: string, s: string) = + config.parseConfig(dir, newStringStream(s)) + proc staticReadConfig(): Config = - result.parseConfig("res", parseToml(newStringStream(staticRead"res/config.toml"))) + result.parseConfig("res", staticRead"res/config.toml") const defaultConfig = staticReadConfig() var gconfig* = defaultConfig @@ -159,7 +166,7 @@ var gconfig* = defaultConfig proc readConfig(dir: string) = let fs = newFileStream(dir / "config.toml") if fs != nil: - gconfig.parseConfig(dir, parseToml(fs)) + gconfig.parseConfig(dir, fs) proc getNormalAction*(s: string): TwtAction = if gconfig.nmap.hasKey(s): @@ -175,5 +182,3 @@ proc readConfig*() = when defined(debug): readConfig(getCurrentDir() / "res") readConfig(getConfigDir() / "chawan") - gconfig.nmap = constructActionTable(gconfig.nmap) - gconfig.lemap = constructActionTable(gconfig.lemap) |