about summary refs log tree commit diff stats
diff options
context:
space:
mode:
-rw-r--r--makefile8
-rw-r--r--nim.cfg3
-rw-r--r--readme.md1
-rw-r--r--src/css/style.nim2
-rw-r--r--src/html/parser.nim6
-rw-r--r--src/html/renderer.nim35
-rw-r--r--src/io/buffer.nim1
7 files changed, 32 insertions, 24 deletions
diff --git a/makefile b/makefile
index b639f06c..5d6e99c6 100644
--- a/makefile
+++ b/makefile
@@ -1,12 +1,10 @@
-NIMC = nim compile
-FLAGS = -o:twt -p:src/ -p:. --import:utils/eprint
+NIMC = nim c
+FLAGS = -o:twt
 FILES = src/main.nim
 
 debug:
 	$(NIMC) $(FLAGS) $(FILES)
 release:
-	$(NIMC) $(FLAGS) -d:release -d:strip $(FILES)
-danger:
-	$(NIMC) $(FLAGS) -d:danger -d:strip $(FILES)
+	$(NIMC) $(FLAGS) -d:release -d:strip -d:lto $(FILES)
 clean:
 	rm ./twt
diff --git a/nim.cfg b/nim.cfg
new file mode 100644
index 00000000..5fb94fee
--- /dev/null
+++ b/nim.cfg
@@ -0,0 +1,3 @@
+-p:"."
+-p:"src/"
+--import:"utils/eprint"
diff --git a/readme.md b/readme.md
index ebcbd7d4..4263656b 100644
--- a/readme.md
+++ b/readme.md
@@ -51,6 +51,7 @@ Planned features (roughly in order of importance):
 * image (sixel/kitty)
 * audio
 * video (sixel/kitty)
+* user style sheet w/ editor
 * frame?
 * extension API?
 * non-unicode charsets?
diff --git a/src/css/style.nim b/src/css/style.nim
index 3ef38bea..6d6935d3 100644
--- a/src/css/style.nim
+++ b/src/css/style.nim
@@ -330,5 +330,7 @@ func getInitialProperties*(): array[low(CSSRuleType)..high(CSSRuleType), CSSComp
     case v
     of VALUE_COLOR:
       result[i] = CSSComputedValue(t: t, v: v, color: getInitialColor(t))
+    of VALUE_DISPLAY:
+      result[i] = CSSComputedValue(t: t, v: v, display: DISPLAY_INLINE)
     else:
       result[i] = CSSComputedValue(t: t, v: v)
diff --git a/src/html/parser.nim b/src/html/parser.nim
index 6868ec52..8d9c0b6f 100644
--- a/src/html/parser.nim
+++ b/src/html/parser.nim
@@ -13,12 +13,6 @@ import html/entity
 
 type
   HTMLParseState = object
-    closed: bool
-    parents: seq[Node]
-    parsedNode: Node
-    a: string
-    b: string
-    attrs: seq[string]
     in_comment: bool
     in_script: bool
     in_style: bool
diff --git a/src/html/renderer.nim b/src/html/renderer.nim
index 1f4deadd..50eac169 100644
--- a/src/html/renderer.nim
+++ b/src/html/renderer.nim
@@ -13,6 +13,7 @@ func boxesForText*(text: seq[Rune], width: int, height: int, lx: int, x: int, y:
   var sx = x
   var sy = y
   var i = 0
+  var whitespace = false
   while i < text.len and sy < height:
     let cw = text[i].width()
     if w + cw > width:
@@ -27,7 +28,13 @@ func boxesForText*(text: seq[Rune], width: int, height: int, lx: int, x: int, y:
       result[^1].innerEdge.x1 = sx
       result[^1].innerEdge.y1 = sy
 
-    result[^1].content &= text[i]
+    if text[i].isWhitespace():
+      if not whitespace:
+        whitespace = true
+        result[^1].content &= text[i]
+    else:
+      whitespace = false
+      result[^1].content &= text[i]
     w += cw
     inc i
 
@@ -40,19 +47,18 @@ func boxesForText*(text: seq[Rune], width: int, height: int, lx: int, x: int, y:
     result[^1].innerEdge.x2 = sx + w
     result[^1].innerEdge.y2 = sy + 1
 
+#func insertText(text: seq[Rune], 
+
 proc generateBox(elem: Element, x: int, y: int, w: int, h: int, fromx: int = x): CSSBox =
-  let display = elem.cssvalues[RULE_DISPLAY]
-  if display.t == RULE_DISPLAY:
-    if display.display == DISPLAY_NONE:
-      return nil
+  if elem.cssvalues[RULE_DISPLAY].display == DISPLAY_NONE:
+    return nil
   new(result)
   result.innerEdge.x1 = x
   result.innerEdge.y1 = y
 
   var anonBoxes = false
   for child in elem.children:
-    let rule = child.cssvalues[RULE_DISPLAY]
-    if rule.t == RULE_DISPLAY and rule.display == DISPLAY_BLOCK:
+    if child.cssvalues[RULE_DISPLAY].display == DISPLAY_BLOCK:
       anonBoxes = true
       break
   var lx = fromx
@@ -71,12 +77,15 @@ proc generateBox(elem: Element, x: int, y: int, w: int, h: int, fromx: int = x):
     elif child.nodeType == TEXT_NODE:
       let text = Text(child)
       let runes = text.data.toRunes()
-      let boxes = boxesForText(runes, w, h, lx, rx, ry)
-      for child in boxes:
-        result.children.add(child)
-        result.innerEdge.y2 += child.size().h
-        ry += child.size().h
-      lx = boxes[^1].innerEdge.x2
+      if anonBoxes:
+        let boxes = boxesForText(runes, w, h, lx, rx, ry)
+        for child in boxes:
+          result.children.add(child)
+          result.innerEdge.y2 += child.size().h
+          ry += child.size().h
+        lx = boxes[^1].innerEdge.x2
+      else:
+        discard #TODO TODO TODO
 
 proc alignBoxes*(buffer: Buffer) =
   buffer.rootbox = buffer.document.root.generateBox(0, 0, buffer.width, buffer.height)
diff --git a/src/io/buffer.nim b/src/io/buffer.nim
index 65bece1f..c299e79c 100644
--- a/src/io/buffer.nim
+++ b/src/io/buffer.nim
@@ -545,6 +545,7 @@ proc refreshDisplay*(buffer: Buffer) =
     inc y
 
 proc renderPlainText*(buffer: Buffer, text: string) =
+  buffer.clearText()
   var i = 0
   var y = 0
   var line = ""