about summary refs log tree commit diff stats
path: root/src/config
diff options
context:
space:
mode:
authorbptato <nincsnevem662@gmail.com>2021-12-19 12:26:25 +0100
committerbptato <nincsnevem662@gmail.com>2021-12-19 12:26:57 +0100
commit9a3cd69ea8b99b04cb64800b75f4d2aa3e81fc84 (patch)
tree0a5d2dd69a4435ea64cabc4eb638e0e0ad09d586 /src/config
parent3360c8b7d3ca98712e7440d5f8d73705afc03dc9 (diff)
downloadchawan-9a3cd69ea8b99b04cb64800b75f4d2aa3e81fc84.tar.gz
More configuration options
Diffstat (limited to 'src/config')
-rw-r--r--src/config/config.nim20
-rw-r--r--src/config/toml.nim8
2 files changed, 23 insertions, 5 deletions
diff --git a/src/config/config.nim b/src/config/config.nim
index 68ddd353..63fcb7eb 100644
--- a/src/config/config.nim
+++ b/src/config/config.nim
@@ -38,6 +38,7 @@ type
     nmap*: ActionMap
     lemap*: ActionMap
     stylesheet*: string
+    ambiguous_double*: bool
 
 func getRealKey(key: string): string =
   var realk: string
@@ -124,13 +125,28 @@ proc readUserStylesheet(dir, file: string): string =
       f.close()
 
 proc parseConfig(config: var Config, dir: string, t: TomlValue) =
+  if "general" in t:
+    let general = t["general"]
+    if "double-width-ambiguous" in general:
+      config.ambiguous_double = general["double-width-ambiguous"].b
   if "page" in t:
     for k, v in t["page"].pairs:
       config.nmap[getRealKey(k)] = getAction(v.s)
     for k, v in t["line"].pairs:
       config.lemap[getRealKey(k)] = getLineAction(v.s)
-  if "stylesheet" in t:
-    config.stylesheet = readUserStylesheet(dir, t["stylesheet"].s)
+  if "css" in t:
+    let css = t["css"]
+    if "include" in css:
+      let val = css["include"]
+      case val.vt
+      of VALUE_STRING:
+        config.stylesheet &= readUserStylesheet(dir, val.s)
+      of VALUE_ARRAY:
+        for child in val.a:
+          config.stylesheet &= readUserStylesheet(dir, child.s)
+      else: discard
+    if "inline" in css:
+      config.stylesheet &= css["inline"].s
 
 proc staticReadConfig(): Config =
   result.parseConfig("res", parseToml(newStringStream(staticRead"res/config.toml")))
diff --git a/src/config/toml.nim b/src/config/toml.nim
index cfdb7763..03c17af5 100644
--- a/src/config/toml.nim
+++ b/src/config/toml.nim
@@ -8,7 +8,7 @@ import unicode
 import utils/twtstr
 
 type
-  ValueType = enum
+  ValueType* = enum
     VALUE_STRING, VALUE_INTEGER, VALUE_FLOAT, VALUE_BOOLEAN, VALUE_DATE_TIME,
     VALUE_TABLE, VALUE_ARRAY VALUE_TABLE_ARRAY
 
@@ -121,12 +121,12 @@ proc consumeString(state: var TomlParser, first: char): string =
 
   if first == '"':
     if state.has(1):
-      let s = state.peek(0, 2)
+      let s = state.peek(0, 1)
       if s == "\"\"":
         multiline = true
   elif first == '\'':
     if state.has(1):
-      let s = state.peek(0, 2)
+      let s = state.peek(0, 1)
       if s == "''":
         multiline = true
 
@@ -146,6 +146,8 @@ proc consumeString(state: var TomlParser, first: char): string =
         let c2 = state.peek(0)
         let c3 = state.peek(1)
         if c2 == first and c3 == first:
+          discard state.consume()
+          discard state.consume()
           break
       else:
         break