about summary refs log tree commit diff stats
path: root/src/local/container.nim
diff options
context:
space:
mode:
authorbptato <nincsnevem662@gmail.com>2024-04-25 01:06:43 +0200
committerbptato <nincsnevem662@gmail.com>2024-04-25 01:20:58 +0200
commit14b871eb7eaf329b67b71385597f114f8782318a (patch)
treeac7b4655124b4579ad27d56116d9a2dee63cd31e /src/local/container.nim
parent62944ac7abc6e37475739a1667ed5a0240fedf66 (diff)
downloadchawan-14b871eb7eaf329b67b71385597f114f8782318a.tar.gz
Initial image support
* png: add missing filters, various decoder fixes
* term: fix kitty response interpretation, add support for kitty image
  detection
* buffer, pager: initial image display support

Emphasis on "initial"; it only "works" with kitty output and PNG input.
Also, it's excruciatingly slow, and repaints images way too often.

Left undocumented intentionally it for now, until it actually becomes
useful.  In the meantime, adventurous users can find out themselves why:

[[siteconf]]
url = "https://.*"
images = true
Diffstat (limited to 'src/local/container.nim')
-rw-r--r--src/local/container.nim9
1 files changed, 5 insertions, 4 deletions
diff --git a/src/local/container.nim b/src/local/container.nim
index b88161b8..3a0f1daf 100644
--- a/src/local/container.nim
+++ b/src/local/container.nim
@@ -14,6 +14,7 @@ import io/socketstream
 import js/javascript
 import js/jstypes
 import js/regex
+import layout/renderdocument
 import loader/headers
 import loader/loader
 import loader/request
@@ -25,7 +26,6 @@ import types/cookie
 import types/referrer
 import types/url
 import types/winattrs
-import utils/luwrap
 import utils/mimeguess
 import utils/strwidth
 import utils/twtstr
@@ -152,6 +152,7 @@ type
     cacheFile* {.jsget.}: string
     mainConfig*: Config
     flags*: set[ContainerFlag]
+    images*: seq[PosBitmap]
 
 jsDestructor(Highlight)
 jsDestructor(Container)
@@ -458,7 +459,6 @@ proc requestLines(container: Container): EmptyPromise {.discardable.} =
     container.lineshift = w.a
     for y in 0 ..< min(res.lines.len, w.len):
       container.lines[y] = res.lines[y]
-      container.lines[y].str.mnormalize()
     var isBgNew = container.bgcolor != res.bgcolor
     if isBgNew:
       container.bgcolor = res.bgcolor
@@ -474,6 +474,7 @@ proc requestLines(container: Container): EmptyPromise {.discardable.} =
     let cw = container.fromy ..< container.fromy + container.height
     if w.a in cw or w.b in cw or cw.a in w or cw.b in w or isBgNew:
       container.triggerEvent(cetUpdate)
+    container.images = res.images
   )
 
 proc redraw(container: Container) {.jsfunc.} =
@@ -1387,9 +1388,9 @@ proc onload(container: Container; res: int) =
     container.triggerEvent(cetStatus)
     container.triggerEvent(cetLoaded)
     if cfHasStart notin container.flags and container.url.anchor != "":
-      container.requestLines().then(proc(): Promise[Opt[tuple[x, y: int]]] =
+      container.requestLines().then(proc(): Promise[GotoAnchorResult] =
         return container.iface.gotoAnchor()
-      ).then(proc(res: Opt[tuple[x, y: int]]) =
+      ).then(proc(res: GotoAnchorResult) =
         if res.isSome:
           let res = res.get
           container.setCursorXYCenter(res.x, res.y)