diff options
author | bptato <nincsnevem662@gmail.com> | 2022-11-25 01:17:36 +0100 |
---|---|---|
committer | bptato <nincsnevem662@gmail.com> | 2022-11-25 01:17:36 +0100 |
commit | 2d3b4faaffb62b6f449bd3dcb59f5ac4fbb16415 (patch) | |
tree | a07a1970757322e367c66a813a0a2eeafba23f18 /src/config | |
parent | b086e346afeded51c94c9b77280dcea6f6b3ce8a (diff) | |
download | chawan-2d3b4faaffb62b6f449bd3dcb59f5ac4fbb16415.tar.gz |
Fix user style regression, add minimum-contrast
Diffstat (limited to 'src/config')
-rw-r--r-- | src/config/config.nim | 6 | ||||
-rw-r--r-- | src/config/toml.nim | 7 |
2 files changed, 10 insertions, 3 deletions
diff --git a/src/config/config.nim b/src/config/config.nim index 131571cb..c8002289 100644 --- a/src/config/config.nim +++ b/src/config/config.nim @@ -25,6 +25,7 @@ type colormode*: Option[ColorMode] formatmode*: Option[FormatMode] altscreen*: Option[bool] + mincontrast*: float func getRealKey(key: string): string = var realk: string @@ -156,6 +157,11 @@ proc parseConfig(config: Config, dir: string, t: TomlValue) = config.hlcolor = parseRGBAColor(v.s).get of "double-width-ambiguous": config.ambiguous_double = v.b + of "minimum-contrast": + if v.vt == VALUE_INTEGER: + config.mincontrast = float(v.i) + else: + config.mincontrast = float(v.f) proc parseConfig(config: Config, dir: string, stream: Stream) = config.parseConfig(dir, parseToml(stream)) diff --git a/src/config/toml.nim b/src/config/toml.nim index 03c17af5..7f743f09 100644 --- a/src/config/toml.nim +++ b/src/config/toml.nim @@ -299,8 +299,8 @@ proc consumeNoState(state: var TomlParser): bool = else: state.syntaxError(fmt"invalid character before key: {c}") state.syntaxError("unexpected end of file") -proc consumeNumber(state: var TomlParser): TomlValue = - var repr: string +proc consumeNumber(state: var TomlParser, c: char): TomlValue = + var repr = $c var isfloat = false if state.has(): if state.peek(0) == '+' or state.peek(0) == '-': @@ -334,6 +334,7 @@ proc consumeNumber(state: var TomlParser): TomlValue = let val = parseFloat64(repr) return TomlValue(vt: VALUE_FLOAT, f: val) + eprint repr let val = parseInt64(repr) return TomlValue(vt: VALUE_INTEGER, i: val) @@ -370,7 +371,7 @@ proc consumeValue(state: var TomlParser): TomlValue = of '#': state.syntaxError("comment without value") of '+', '-', '0'..'9': - return state.consumeNumber() + return state.consumeNumber(c) #TODO date-time of '[': return state.consumeArray() |