about summary refs log tree commit diff stats
path: root/src/local
diff options
context:
space:
mode:
authorbptato <nincsnevem662@gmail.com>2024-03-19 16:37:50 +0100
committerbptato <nincsnevem662@gmail.com>2024-03-19 16:52:31 +0100
commit572aa39ffa06042a3c0ff5c5607a44cf0d30d9f2 (patch)
treee5b0d259db69f3e89b74aa60d7eac6784d3f14ec /src/local
parent75a56860eeddab2776b0e9c04861787694ef298c (diff)
downloadchawan-572aa39ffa06042a3c0ff5c5607a44cf0d30d9f2.tar.gz
buffer: add markURL
Useful when browsing plaintext files; w3m has it too.
Diffstat (limited to 'src/local')
-rw-r--r--src/local/container.nim14
-rw-r--r--src/local/pager.nim3
2 files changed, 14 insertions, 3 deletions
diff --git a/src/local/container.nim b/src/local/container.nim
index e722ccfd..d706b77c 100644
--- a/src/local/container.nim
+++ b/src/local/container.nim
@@ -149,6 +149,7 @@ type
     tailOnLoad*: bool
     cacheFile* {.jsget.}: string
     userRequested*: bool
+    mainConfig*: Config
 
 jsDestructor(Highlight)
 jsDestructor(Container)
@@ -157,7 +158,7 @@ proc newContainer*(config: BufferConfig; loaderConfig: LoaderClientConfig;
     url: URL; request: Request; attrs: WindowAttributes; title: string;
     redirectDepth: int; canReinterpret: bool; contentType: Option[string];
     charsetStack: seq[Charset]; cacheId: int; cacheFile: string;
-    userRequested: bool): Container =
+    userRequested: bool; mainConfig: Config): Container =
   return Container(
     url: url,
     request: request,
@@ -176,7 +177,8 @@ proc newContainer*(config: BufferConfig; loaderConfig: LoaderClientConfig;
     cacheId: cacheId,
     cacheFile: cacheFile,
     process: -1,
-    userRequested: userRequested
+    userRequested: userRequested,
+    mainConfig: mainConfig
   )
 
 func location(container: Container): URL {.jsfget.} =
@@ -1344,6 +1346,14 @@ proc getSelectionText(container: Container, hl: Highlight = nil):
     return s
   )
 
+proc markURL(container: Container) {.jsfunc.} =
+  var schemes: seq[string] = @[]
+  for key in container.mainConfig.external.urimethodmap.map.keys:
+    schemes.add(key.until(':'))
+  container.iface.markURL(schemes).then(proc() =
+    container.needslines = true
+  )
+
 proc setLoadInfo(container: Container, msg: string) =
   container.loadinfo = msg
   container.triggerEvent(cetSetLoadInfo)
diff --git a/src/local/pager.nim b/src/local/pager.nim
index 627a7b08..e7d771c0 100644
--- a/src/local/pager.nim
+++ b/src/local/pager.nim
@@ -533,7 +533,8 @@ proc newContainer(pager: Pager; bufferConfig: BufferConfig;
     charsetStack,
     cacheId,
     cacheFile,
-    userRequested
+    userRequested,
+    pager.config
   )
   pager.connectingContainers.add(ConnectingContainerItem(
     state: ccsBeforeResult,