about summary refs log tree commit diff stats
path: root/src
diff options
context:
space:
mode:
authorbptato <nincsnevem662@gmail.com>2021-12-21 22:44:55 +0100
committerbptato <nincsnevem662@gmail.com>2021-12-21 22:44:55 +0100
commit7c5241b8dc4c59e602976a80740281b5673ac65e (patch)
tree90aa3377d16d18dc9a7be9cb180a9312128976fa /src
parent8ea2c50b0d869228a28e132a6a053c52a8222fec (diff)
downloadchawan-7c5241b8dc4c59e602976a80740281b5673ac65e.tar.gz
More efficient pipe output
Diffstat (limited to 'src')
-rw-r--r--src/io/buffer.nim16
1 files changed, 13 insertions, 3 deletions
diff --git a/src/io/buffer.nim b/src/io/buffer.nim
index 3adaf985..98b20091 100644
--- a/src/io/buffer.nim
+++ b/src/io/buffer.nim
@@ -940,8 +940,17 @@ proc click*(buffer: Buffer): string =
   return ""
 
 proc drawBuffer*(buffer: Buffer) =
-  buffer.refreshDisplay()
-  buffer.displayBuffer()
+  var formatting = newFormatting()
+  for line in buffer.lines:
+    if line.formats.len == 0:
+      print(line.str & '\n')
+    else:
+      var x = 0
+      for format in line.formats:
+        print(line.str.substr(x, format.pos - 1))
+        print(formatting.processFormatting(format.formatting))
+        x = format.pos
+      print(line.str.substr(x, line.str.len) & '\n')
 
 proc refreshBuffer*(buffer: Buffer) =
   buffer.title = $buffer.location
@@ -952,7 +961,8 @@ proc refreshBuffer*(buffer: Buffer) =
     buffer.reshape = true
 
   if buffer.redraw:
-    buffer.drawBuffer()
+    buffer.refreshDisplay()
+    buffer.displayBuffer()
     buffer.redraw = false
 
   buffer.updateHover()