diff options
author | bptato <nincsnevem662@gmail.com> | 2022-10-04 12:13:27 +0200 |
---|---|---|
committer | bptato <nincsnevem662@gmail.com> | 2022-10-04 12:13:27 +0200 |
commit | c4e2de9cd8cad7e28b33e68b1b76f9044fe510be (patch) | |
tree | 92930e716d3c1ffca8614c030a35c5008655bca4 /src/io | |
parent | 10d3154eff79ce53b82fa946556f52f3e10eac90 (diff) | |
download | chawan-c4e2de9cd8cad7e28b33e68b1b76f9044fe510be.tar.gz |
WIP pager
Diffstat (limited to 'src/io')
-rw-r--r-- | src/io/buffer.nim | 11 | ||||
-rw-r--r-- | src/io/lineedit.nim | 10 |
2 files changed, 12 insertions, 9 deletions
diff --git a/src/io/buffer.nim b/src/io/buffer.nim index 8b1268ef..b5e46297 100644 --- a/src/io/buffer.nim +++ b/src/io/buffer.nim @@ -8,6 +8,7 @@ import unicode import css/sheet import css/stylednode +import config/config import html/dom import html/tags import html/htmlparser @@ -67,8 +68,8 @@ type next*: Buffer userstyle*: CSSStylesheet loader*: FileLoader - markcolor*: CellColor marks*: seq[Mark] + config*: Config proc newBuffer*(): Buffer = new(result) @@ -713,7 +714,7 @@ proc gotoAnchor*(buffer: Buffer) = proc addMark*(buffer: Buffer, x, y, width: int): Mark = assert y < buffer.lines.len var format = newFormat() - format.bgcolor = buffer.markcolor + format.bgcolor = buffer.config.markcolor result = Mark(x: x, y: y, width: width, format: format) let previ = upperBound(buffer.marks, y, (proc(a: Mark, b: int): int = cmp(a.y, b))) buffer.marks.insert(result, previ) @@ -1139,7 +1140,7 @@ proc click*(buffer: Buffer): Option[Request] = var value = input.value print(HVP(buffer.height + 1, 1)) print(EL()) - let status = readLine("SEARCH: ", value, buffer.width, {'\r', '\n'}) + let status = readLine("SEARCH: ", value, buffer.width, {'\r', '\n'}, config = buffer.config) if status: input.value = value input.invalid = true @@ -1151,7 +1152,7 @@ proc click*(buffer: Buffer): Option[Request] = var value = input.value print(HVP(buffer.height + 1, 1)) print(EL()) - let status = readLine("TEXT: ", value, buffer.width, {'\r', '\n'}, input.inputType == INPUT_PASSWORD) + let status = readLine("TEXT: ", value, buffer.width, {'\r', '\n'}, input.inputType == INPUT_PASSWORD, config = buffer.config) if status: input.value = value input.invalid = true @@ -1163,7 +1164,7 @@ proc click*(buffer: Buffer): Option[Request] = "" print(HVP(buffer.height + 1, 1)) print(EL()) - let status = readLine("Filename: ", path, buffer.width, {'\r', '\n'}) + let status = readLine("Filename: ", path, buffer.width, {'\r', '\n'}, config = buffer.config) if status: let cdir = parseUrl("file://" & getCurrentDir() & DirSep) let path = parseUrl(path, cdir) diff --git a/src/io/lineedit.nim b/src/io/lineedit.nim index 3f9034bf..3d91ea80 100644 --- a/src/io/lineedit.nim +++ b/src/io/lineedit.nim @@ -22,6 +22,7 @@ type LineState* = object displen: int disallowed: set[char] hide: bool + config: Config #TODO get rid of this callback: proc(state: var LineState): bool func lwidth(r: Rune): int = @@ -148,7 +149,7 @@ proc readLine(state: var LineState): bool = let c = stdin.readChar() state.s &= c - var action = getLinedAction(state.s) + var action = getLinedAction(state.config, state.s) if state.escNext: action = NO_ACTION case action @@ -271,7 +272,7 @@ proc readLine(state: var LineState): bool = state.feedNext = true proc readLine*(prompt: string, current: var string, termwidth: int, - disallowed: set[char], hide: bool, + disallowed: set[char], hide: bool, config: Config, callback: proc(state: var LineState): bool): bool = var state: LineState @@ -285,6 +286,7 @@ proc readLine*(prompt: string, current: var string, termwidth: int, state.disallowed = disallowed state.callback = callback state.hide = hide + state.config = config if state.readLine(): current = $state.news @@ -292,5 +294,5 @@ proc readLine*(prompt: string, current: var string, termwidth: int, return false proc readLine*(prompt: string, current: var string, termwidth: int, - disallowed: set[char] = {}, hide = false): bool = - readLine(prompt, current, termwidth, disallowed, hide, (proc(state: var LineState): bool = false)) + disallowed: set[char] = {}, hide = false, config: Config): bool = + readLine(prompt, current, termwidth, disallowed, hide, config, (proc(state: var LineState): bool = false)) |