about summary refs log tree commit diff stats
path: root/src/local
diff options
context:
space:
mode:
authorbptato <nincsnevem662@gmail.com>2024-01-29 13:25:23 +0100
committerbptato <nincsnevem662@gmail.com>2024-01-29 13:26:15 +0100
commit9318ad33229d3c2f96dd766b38b8748f77487c5a (patch)
tree34dc6cbfd0a52d521d9d125fea626895ec3548c8 /src/local
parent619d5296dbfc77c37c13b86e4e96c356f1c3f61a (diff)
downloadchawan-9318ad33229d3c2f96dd766b38b8748f77487c5a.tar.gz
forkserver: clean up
Move forkBuffer into forkserver (why was it in container anyway), remove
unused mainproc variable, etc.
Diffstat (limited to 'src/local')
-rw-r--r--src/local/client.nim6
-rw-r--r--src/local/container.nim14
-rw-r--r--src/local/pager.nim7
3 files changed, 6 insertions, 21 deletions
diff --git a/src/local/client.nim b/src/local/client.nim
index efc838f4..ae838360 100644
--- a/src/local/client.nim
+++ b/src/local/client.nim
@@ -65,7 +65,6 @@ type
     jsctx: JSContext
     jsrt: JSRuntime
     loader: FileLoader
-    mainproc: Pid
     pager {.jsget.}: Pager
     selector: Selector[int]
     timeouts: TimeoutState
@@ -676,17 +675,16 @@ proc addJSModules(client: Client, ctx: JSContext) =
 func getClient(client: Client): Client {.jsfget: "client".} =
   return client
 
-proc newClient*(config: Config, forkserver: ForkServer, mainproc: Pid): Client =
+proc newClient*(config: Config, forkserver: ForkServer): Client =
   setControlCHook(proc() {.noconv.} = quit(1))
   let jsrt = newJSRuntime()
   JS_SetModuleLoaderFunc(jsrt, normalizeModuleName, clientLoadJSModule, nil)
   let jsctx = jsrt.newJSContext()
   let attrs = getWindowAttributes(stdout)
-  let pager = newPager(config, attrs, forkserver, mainproc, jsctx)
+  let pager = newPager(config, attrs, forkserver, jsctx)
   let client = Client(
     config: config,
     forkserver: forkserver,
-    mainproc: mainproc,
     loader: forkserver.newFileLoader(
       defaultHeaders = config.getDefaultHeaders(),
       proxy = config.getProxy(),
diff --git a/src/local/container.nim b/src/local/container.nim
index 1c91a41e..73dfba49 100644
--- a/src/local/container.nim
+++ b/src/local/container.nim
@@ -127,28 +127,18 @@ type
 jsDestructor(Highlight)
 jsDestructor(Container)
 
-proc newBuffer*(forkserver: ForkServer, mainproc: Pid, config: BufferConfig,
+proc newBuffer*(forkserver: ForkServer, config: BufferConfig,
     source: BufferSource, title = "", redirectdepth = 0,
     canreinterpret = true): Container =
   let attrs = getWindowAttributes(stdout)
-  let ostream = forkserver.ostream
-  let istream = forkserver.istream
-  ostream.swrite(FORK_BUFFER)
-  ostream.swrite(source)
-  ostream.swrite(config)
-  ostream.swrite(attrs)
-  ostream.swrite(mainproc)
-  ostream.flush()
-  var process: Pid
-  istream.sread(process)
   return Container(
+    process: forkserver.forkBuffer(source, config, attrs),
     source: source,
     width: attrs.width,
     height: attrs.height - 1,
     title: title,
     config: config,
     redirectdepth: redirectdepth,
-    process: process,
     pos: CursorPosition(
       setx: -1
     ),
diff --git a/src/local/pager.nim b/src/local/pager.nim
index 9275a5d3..61614eef 100644
--- a/src/local/pager.nim
+++ b/src/local/pager.nim
@@ -69,7 +69,6 @@ type
     linehist: array[LineMode, LineHistory]
     linemode: LineMode
     mailcap: Mailcap
-    mainproc: Pid
     mimeTypes: MimeTypes
     notnum*: bool # has a non-numeric character been input already?
     numload*: int
@@ -230,15 +229,14 @@ proc setPaths(pager: Pager): Err[string] =
   pager.cgiDir = cgiDir
   return ok()
 
-proc newPager*(config: Config, attrs: WindowAttributes,
-    forkserver: ForkServer, mainproc: Pid, ctx: JSContext): Pager =
+proc newPager*(config: Config, attrs: WindowAttributes, forkserver: ForkServer,
+    ctx: JSContext): Pager =
   let (mailcap, errs) = config.getMailcap()
   let pager = Pager(
     config: config,
     display: newFixedGrid(attrs.width, attrs.height - 1),
     forkserver: forkserver,
     mailcap: mailcap,
-    mainproc: mainproc,
     mimeTypes: config.getMimeTypes(),
     omnirules: config.getOmniRules(ctx),
     proxy: config.getProxy(),
@@ -451,7 +449,6 @@ proc newBuffer(pager: Pager, bufferConfig: BufferConfig, source: BufferSource,
     title = "", redirectdepth = 0, canreinterpret = true): Container =
   return newBuffer(
     pager.forkserver,
-    pager.mainproc,
     bufferConfig,
     source,
     title,