aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorbptato <nincsnevem662@gmail.com>2022-07-29 22:54:51 +0200
committerbptato <nincsnevem662@gmail.com>2022-07-29 22:54:51 +0200
commit0dfe2a310db3fb7492ed448235e0757042f0f5ca (patch)
tree676aaa8d37eeaf530a53224e4463976f6b6151bb /src
parent54f4d71325c4f12b23113c945625796bda78e3c6 (diff)
downloadchawan-0dfe2a310db3fb7492ed448235e0757042f0f5ca.tar.gz
Increase tokenizer buffer size, add mark color option
Diffstat (limited to 'src')
-rw-r--r--src/client.nim1
-rw-r--r--src/config/config.nim15
-rw-r--r--src/html/htmltokenizer.nim2
-rw-r--r--src/io/buffer.nim3
4 files changed, 19 insertions, 2 deletions
diff --git a/src/client.nim b/src/client.nim
index 5d033458..6d729572 100644
--- a/src/client.nim
+++ b/src/client.nim
@@ -122,6 +122,7 @@ proc discardBuffer(client: Client) =
proc setupBuffer(client: Client) =
let buffer = client.buffer
buffer.userstyle = client.userstyle
+ buffer.markcolor = gconfig.markcolor
buffer.load()
buffer.render()
buffer.gotoAnchor()
diff --git a/src/config/config.nim b/src/config/config.nim
index 97b344e2..b35b03f5 100644
--- a/src/config/config.nim
+++ b/src/config/config.nim
@@ -4,6 +4,7 @@ import strutils
import streams
import config/toml
+import types/color
import utils/twtstr
type
@@ -44,6 +45,7 @@ type
lemap*: ActionMap
stylesheet*: string
ambiguous_double*: bool
+ markcolor*: CellColor
func getRealKey(key: string): string =
var realk: string
@@ -153,6 +155,19 @@ proc parseConfig(config: var Config, dir: string, t: TomlValue) =
else: discard
if "inline" in css:
config.stylesheet &= css["inline"].s
+ if "display" in t:
+ let display = t["display"]
+ if "mark-color" in display:
+ case display["mark-color"].s
+ of "black": config.markcolor = CellColor(rgb: false, color: 40u8)
+ of "red": config.markcolor = CellColor(rgb: false, color: 41u8)
+ of "green": config.markcolor = CellColor(rgb: false, color: 42u8)
+ of "yellow": config.markcolor = CellColor(rgb: false, color: 43u8)
+ of "blue": config.markcolor = CellColor(rgb: false, color: 44u8)
+ of "magenta": config.markcolor = CellColor(rgb: false, color: 45u8)
+ of "cyan": config.markcolor = CellColor(rgb: false, color: 46u8)
+ of "white": config.markcolor = CellColor(rgb: false, color: 47u8)
+ of "terminal": config.markcolor = defaultColor
proc parseConfig(config: var Config, dir: string, stream: Stream) =
config.parseConfig(dir, parseToml(stream))
diff --git a/src/html/htmltokenizer.nim b/src/html/htmltokenizer.nim
index 4f81f6a6..a1c894c8 100644
--- a/src/html/htmltokenizer.nim
+++ b/src/html/htmltokenizer.nim
@@ -97,7 +97,7 @@ func `$`*(tok: Token): string =
of COMMENT: fmt"{tok.t} {tok.data}"
of EOF: fmt"{tok.t}"
-const bufSize = 512
+const bufSize = 4096
const copyBufSize = 16
proc newTokenizer*(s: Stream): Tokenizer =
result.sbuf = newString(bufSize)
diff --git a/src/io/buffer.nim b/src/io/buffer.nim
index dc8df009..7bc181a5 100644
--- a/src/io/buffer.nim
+++ b/src/io/buffer.nim
@@ -66,6 +66,7 @@ type
next*: Buffer
userstyle*: CSSStylesheet
loader*: FileLoader
+ markcolor*: CellColor
proc newBuffer*(): Buffer =
new(result)
@@ -704,7 +705,7 @@ proc gotoAnchor*(buffer: Buffer) =
proc addMark*(buffer: Buffer, x, y, width: int): Mark =
assert y < buffer.lines.len
var format = newFormat()
- format.reverse = true
+ format.bgcolor = buffer.markcolor
result = Mark(x: x, width: width, format: format)
buffer.lines[y].marks.add(result)