about summary refs log tree commit diff stats
path: root/src/buffer
diff options
context:
space:
mode:
authorbptato <nincsnevem662@gmail.com>2022-12-11 02:14:33 +0100
committerbptato <nincsnevem662@gmail.com>2022-12-11 02:16:13 +0100
commit087227028f85db2fd5878caf87e3032302c95a30 (patch)
tree9ed59704bdb157d662a6f69db71894a4cd9827e5 /src/buffer
parentc4b421daf0a516852fc670826dceffb5c0d38ea8 (diff)
downloadchawan-087227028f85db2fd5878caf87e3032302c95a30.tar.gz
Fixes & QOL improvements
* fix infinite loop after closing buffer
* fix setx not triggering hover updates
* fix D not going back to PREV but to parent
* add M-d, M-,, M-., M-/ for old D behavior, cycle through siblings,
  back to parent
Diffstat (limited to 'src/buffer')
-rw-r--r--src/buffer/buffer.nim40
-rw-r--r--src/buffer/container.nim2
2 files changed, 19 insertions, 23 deletions
diff --git a/src/buffer/buffer.nim b/src/buffer/buffer.nim
index 0f425ecc..9f699ca3 100644
--- a/src/buffer/buffer.nim
+++ b/src/buffer/buffer.nim
@@ -75,8 +75,7 @@ type
     istream: Stream
     sstream: Stream
     available: int
-    pistream: Stream # for input pipe
-    postream: Stream # for output pipe
+    pstream: Stream # pipe stream
     srenderer: StreamRenderer
     streamclosed: bool
     loaded: bool
@@ -994,7 +993,7 @@ proc getLines*(buffer: Buffer, w: Slice[int]): tuple[numLines: int, lines: seq[S
   result.numLines = buffer.lines.len
 
 proc passFd*(buffer: Buffer) {.proxy.} =
-  let fd = SocketStream(buffer.pistream).recvFileHandle()
+  let fd = SocketStream(buffer.pstream).recvFileHandle()
   buffer.source.fd = fd
 
 proc getSource*(buffer: Buffer) {.proxy.} =
@@ -1021,7 +1020,7 @@ macro bufferDispatcher(funs: static ProxyMap, buffer: Buffer, cmd: BufferCommand
         let typ = param[^2]
         stmts.add(quote do:
           var `id`: `typ`
-          `buffer`.pistream.sread(`id`))
+          `buffer`.pstream.sread(`id`))
         call.add(id)
     var rval: NimNode
     if v.params[0].kind == nnkEmpty:
@@ -1036,35 +1035,34 @@ macro bufferDispatcher(funs: static ProxyMap, buffer: Buffer, cmd: BufferCommand
           let fdi = buffer.selector.registerTimer(buffer.timeout, true, 0)
           buffer.timeouts[fdi] = (proc() =
             let len = slen(`packetid`) + slen(`rval`)
-            buffer.postream.swrite(len)
-            buffer.postream.swrite(`packetid`)
-            buffer.postream.swrite(`rval`)
-            buffer.postream.flush())
+            buffer.pstream.swrite(len)
+            buffer.pstream.swrite(`packetid`)
+            buffer.pstream.swrite(`rval`)
+            buffer.pstream.flush())
           buffer.timeout = 0
           return)
     if rval == nil:
       stmts.add(quote do:
         let len = slen(`packetid`)
-        buffer.postream.swrite(len)
-        buffer.postream.swrite(`packetid`)
-        buffer.postream.flush())
+        buffer.pstream.swrite(len)
+        buffer.pstream.swrite(`packetid`)
+        buffer.pstream.flush())
     else:
       stmts.add(quote do:
         let len = slen(`packetid`) + slen(`rval`)
-        buffer.postream.swrite(len)
-        buffer.postream.swrite(`packetid`)
-        buffer.postream.swrite(`rval`)
-        buffer.postream.flush())
+        buffer.pstream.swrite(len)
+        buffer.pstream.swrite(`packetid`)
+        buffer.pstream.swrite(`rval`)
+        buffer.pstream.flush())
     ofbranch.add(stmts)
     switch.add(ofbranch)
   return switch
 
 proc readCommand(buffer: Buffer) =
-  let istream = buffer.pistream
   var cmd: BufferCommand
-  istream.sread(cmd)
+  buffer.pstream.sread(cmd)
   var packetid: int
-  istream.sread(packetid)
+  buffer.pstream.sread(packetid)
   bufferDispatcher(ProxyFunctions, buffer, cmd, packetid)
 
 proc runBuffer(buffer: Buffer, rfd: int) =
@@ -1095,8 +1093,7 @@ proc runBuffer(buffer: Buffer, rfd: int) =
             break loop
           else:
             assert false
-  buffer.pistream.close()
-  buffer.postream.close()
+  buffer.pstream.close()
   buffer.loader.quit()
   quit(0)
 
@@ -1121,8 +1118,7 @@ proc launchBuffer*(config: BufferConfig, source: BufferSource,
   buffer.srenderer = newStreamRenderer(buffer.sstream)
   let socks = connectSocketStream(mainproc, false)
   socks.swrite(getpid())
-  buffer.pistream = socks
-  buffer.postream = socks
+  buffer.pstream = socks
   let rfd = int(socks.source.getFd())
   buffer.selector.registerHandle(rfd, {Read}, 0)
   buffer.runBuffer(rfd)
diff --git a/src/buffer/container.nim b/src/buffer/container.nim
index 2a68a24b..691be89e 100644
--- a/src/buffer/container.nim
+++ b/src/buffer/container.nim
@@ -347,8 +347,8 @@ proc setCursorY*(container: Container, y: int) {.jsfunc.} =
     else:
       container.setFromY(y)
     container.pos.cursory = y
-  container.sendCursorPosition()
   container.restoreCursorX()
+  container.sendCursorPosition()
 
 proc centerLine*(container: Container) {.jsfunc.} =
   container.setFromY(container.cursory - container.height div 2)