about summary refs log tree commit diff stats
path: root/src/main.nim
diff options
context:
space:
mode:
authorbptato <nincsnevem662@gmail.com>2021-08-05 22:57:38 +0200
committerbptato <nincsnevem662@gmail.com>2021-08-05 23:13:55 +0200
commitb94597a68eb8572cf8f521ee9c39cc7d9d310827 (patch)
treea487471466f80a4e95cfefb4d7084f29a840eacc /src/main.nim
parent087f830528b41b00d0bf7a501f7b0472f75ffb18 (diff)
downloadchawan-b94597a68eb8572cf8f521ee9c39cc7d9d310827.tar.gz
Implement new buffer model which supports X coords
...also, one can kinda use this as a file viewer now I guess
Diffstat (limited to 'src/main.nim')
-rw-r--r--src/main.nim20
1 files changed, 11 insertions, 9 deletions
diff --git a/src/main.nim b/src/main.nim
index 7912a431..78d24e8d 100644
--- a/src/main.nim
+++ b/src/main.nim
@@ -3,14 +3,14 @@ import uri
 import os
 import streams
 
-import utils/termattrs
+import utils/eprint
 
 import html/dom
 import html/htmlparser
 
 import io/display
-import io/twtio
 import io/buffer
+import io/term
 
 import config
 
@@ -43,19 +43,21 @@ proc main*() =
     eprint "Invalid parameters. Usage:\ntwt <url>"
     quit(1)
   if not readConfig("res/config"):
-    eprint "Failed to read keymap, fallback to default"
+    #eprint "Failed to read keymap, fallback to default"
+    discard
   let attrs = getTermAttributes()
   let buffer = newBuffer(attrs)
   let uri = parseUri(paramStr(1))
   buffers.add(buffer)
-  buffer.document = parseHtml(getPageUri(uri))
-  buffer.document.applyDefaultStylesheet()
-  buffer.setLocation(uri)
-  buffer.renderHtml()
+  buffer.renderPlainText(getPageUri(uri).readAll())
+  #buffer.document = parseHtml(getPageUri(uri))
+  #buffer.setLocation(uri)
+  #buffer.document.applyDefaultStylesheet()
+  #buffer.renderHtml()
   var lastUri = uri
   while displayPage(attrs, buffer):
     statusMsg("Loading...", buffer.height)
-    var newUri = buffer.document.location
+    var newUri = buffer.location
     lastUri.anchor = ""
     newUri.anchor = ""
     if $lastUri != $newUri:
@@ -63,7 +65,7 @@ proc main*() =
       if uri.scheme == "" and uri.path == "" and uri.anchor != "":
         discard
       else:
-        buffer.document = parseHtml(getPageUri(buffer.document.location))
+        buffer.document = parseHtml(getPageUri(buffer.location))
       buffer.renderHtml()
     lastUri = newUri
 main()