about summary refs log tree commit diff stats
path: root/src/local
diff options
context:
space:
mode:
authorbptato <nincsnevem662@gmail.com>2024-04-16 15:08:44 +0200
committerbptato <nincsnevem662@gmail.com>2024-04-17 23:19:09 +0200
commit66b9574b165be62e76c7397cf0eaa8d229d42675 (patch)
treeadb8a9719cc70f2b577706aaa4e30bb0d5d629a6 /src/local
parentd86f1939204eee771a30f47e4cbe71fd8d9a4f5f (diff)
downloadchawan-66b9574b165be62e76c7397cf0eaa8d229d42675.tar.gz
Update code style
* separate params with ; (semicolon) instead of , (colon)
* reduce screaming snake case use
* wrap long lines
Diffstat (limited to 'src/local')
-rw-r--r--src/local/client.nim54
-rw-r--r--src/local/container.nim181
-rw-r--r--src/local/lineedit.nim12
-rw-r--r--src/local/pager.nim90
-rw-r--r--src/local/select.nim18
-rw-r--r--src/local/term.nim55
6 files changed, 207 insertions, 203 deletions
diff --git a/src/local/client.nim b/src/local/client.nim
index c4aad504..92fa4660 100644
--- a/src/local/client.nim
+++ b/src/local/client.nim
@@ -3,15 +3,13 @@ import std/nativesockets
 import std/net
 import std/options
 import std/os
+import std/posix
 import std/selectors
 import std/streams
 import std/strutils
 import std/tables
 import std/unicode
 
-when defined(posix):
-  import std/posix
-
 import bindings/constcharp
 import bindings/quickjs
 import config/config
@@ -67,7 +65,7 @@ type
     jsrt: JSRuntime
     pager {.jsget.}: Pager
     timeouts: TimeoutState
-    pressed: tuple[col: int, row: int]
+    pressed: tuple[col: int; row: int]
 
   ConsoleWrapper = object
     console: Console
@@ -97,12 +95,12 @@ proc finalize(client: Client) {.jsfin.} =
   if client.jsrt != nil:
     free(client.jsrt)
 
-proc fetch[T: Request|string](client: Client, req: T,
+proc fetch[T: Request|string](client: Client; req: T;
     init = none(RequestInit)): JSResult[FetchPromise] {.jsfunc.} =
   let req = ?newRequest(client.jsctx, req, init)
   return ok(client.loader.fetch(req))
 
-proc interruptHandler(rt: JSRuntime, opaque: pointer): cint {.cdecl.} =
+proc interruptHandler(rt: JSRuntime; opaque: pointer): cint {.cdecl.} =
   let client = cast[Client](opaque)
   if client.console == nil or client.pager.term.istream == nil:
     return 0
@@ -120,7 +118,7 @@ proc interruptHandler(rt: JSRuntime, opaque: pointer): cint {.cdecl.} =
 proc runJSJobs(client: Client) =
   client.jsrt.runJSJobs(client.console.err)
 
-proc evalJS(client: Client, src, filename: string, module = false): JSValue =
+proc evalJS(client: Client; src, filename: string; module = false): JSValue =
   client.pager.term.unblockStdin()
   let flags = if module:
     JS_EVAL_TYPE_MODULE
@@ -130,11 +128,11 @@ proc evalJS(client: Client, src, filename: string, module = false): JSValue =
   client.runJSJobs()
   client.pager.term.restoreStdin()
 
-proc evalJSFree(client: Client, src, filename: string) =
+proc evalJSFree(client: Client; src, filename: string) =
   JS_FreeValue(client.jsctx, client.evalJS(src, filename))
 
-proc command0(client: Client, src: string, filename = "<command>",
-    silence = false, module = false) =
+proc command0(client: Client; src: string; filename = "<command>";
+    silence = false; module = false) =
   let ret = client.evalJS(src, filename, module = module)
   if JS_IsException(ret):
     client.jsctx.writeException(client.console.err)
@@ -145,7 +143,7 @@ proc command0(client: Client, src: string, filename = "<command>",
         client.console.log(str.get)
   JS_FreeValue(client.jsctx, ret)
 
-proc command(client: Client, src: string) =
+proc command(client: Client; src: string) =
   client.command0(src)
   let container = client.consoleWrapper.container
   if container != nil:
@@ -156,7 +154,7 @@ proc suspend(client: Client) {.jsfunc.} =
   discard kill(0, cint(SIGTSTP))
   client.pager.term.restart()
 
-proc quit(client: Client, code = 0) {.jsfunc.} =
+proc quit(client: Client; code = 0) {.jsfunc.} =
   if client.alive:
     client.alive = false
     client.pager.quit()
@@ -173,7 +171,7 @@ proc quit(client: Client, code = 0) {.jsfunc.} =
 proc feedNext(client: Client) {.jsfunc.} =
   client.feednext = true
 
-proc alert(client: Client, msg: string) {.jsfunc.} =
+proc alert(client: Client; msg: string) {.jsfunc.} =
   client.pager.alert(msg)
 
 proc handlePagerEvents(client: Client) =
@@ -218,7 +216,7 @@ proc evalAction(client: Client; action: string; arg0: int32): EmptyPromise =
 # it proves to be too low.
 const MaxPrecNum = 100000000
 
-proc handleCommandInput(client: Client, c: char): EmptyPromise =
+proc handleCommandInput(client: Client; c: char): EmptyPromise =
   if client.config.input.vi_numeric_prefix and not client.pager.notnum:
     if client.pager.precnum != 0 and c == '0' or c in '1' .. '9':
       if client.pager.precnum < MaxPrecNum: # better ignore than eval...
@@ -354,18 +352,18 @@ proc input(client: Client): EmptyPromise =
     p.resolve()
   return p
 
-proc setTimeout[T: JSValue|string](client: Client, handler: T,
+proc setTimeout[T: JSValue|string](client: Client; handler: T;
     timeout = 0i32): int32 {.jsfunc.} =
   return client.timeouts.setTimeout(handler, timeout)
 
-proc setInterval[T: JSValue|string](client: Client, handler: T,
+proc setInterval[T: JSValue|string](client: Client; handler: T;
     interval = 0i32): int32 {.jsfunc.} =
   return client.timeouts.setInterval(handler, interval)
 
-proc clearTimeout(client: Client, id: int32) {.jsfunc.} =
+proc clearTimeout(client: Client; id: int32) {.jsfunc.} =
   client.timeouts.clearTimeout(id)
 
-proc clearInterval(client: Client, id: int32) {.jsfunc.} =
+proc clearInterval(client: Client; id: int32) {.jsfunc.} =
   client.timeouts.clearInterval(id)
 
 let SIGWINCH {.importc, header: "<signal.h>", nodecl.}: cint
@@ -494,7 +492,7 @@ proc handleRead(client: Client; fd: int) =
     let container = client.fdmap[fd]
     client.pager.handleEvent(container)
 
-proc handleWrite(client: Client, fd: int) =
+proc handleWrite(client: Client; fd: int) =
   let container = client.fdmap[fd]
   if container.iface.stream.flushWrite():
     client.selector.unregister(fd)
@@ -508,7 +506,7 @@ proc flushConsole*(client: Client) {.jsfunc.} =
     )
   client.handleRead(client.forkserver.estream.fd)
 
-proc handleError(client: Client, fd: int) =
+proc handleError(client: Client; fd: int) =
   if client.pager.term.istream != nil and fd == client.pager.term.istream.fd:
     #TODO do something here...
     stderr.write("Error in tty\n")
@@ -612,7 +610,7 @@ proc headlessLoop(client: Client) =
     client.loader.unregistered.setLen(0)
     client.acceptBuffers()
 
-proc clientLoadJSModule(ctx: JSContext, module_name: cstringConst,
+proc clientLoadJSModule(ctx: JSContext; module_name: cstringConst;
     opaque: pointer): JSModuleDef {.cdecl.} =
   let global = JS_GetGlobalObject(ctx)
   JS_FreeValue(ctx, global)
@@ -634,21 +632,21 @@ proc clientLoadJSModule(ctx: JSContext, module_name: cstringConst,
     JS_ThrowTypeError(ctx, "Failed to open file %s", module_name)
     return nil
 
-proc readBlob(client: Client, path: string): Option[WebFile] {.jsfunc.} =
+proc readBlob(client: Client; path: string): Option[WebFile] {.jsfunc.} =
   try:
     return some(newWebFile(path))
   except IOError:
     discard
 
 #TODO this is dumb
-proc readFile(client: Client, path: string): string {.jsfunc.} =
+proc readFile(client: Client; path: string): string {.jsfunc.} =
   try:
     return readFile(path)
   except IOError:
     discard
 
 #TODO ditto
-proc writeFile(client: Client, path: string, content: string) {.jsfunc.} =
+proc writeFile(client: Client; path, content: string) {.jsfunc.} =
   writeFile(path, content)
 
 const ConsoleTitle = "Browser Console"
@@ -770,20 +768,20 @@ proc nimCollect(client: Client) {.jsfunc.} =
 proc jsCollect(client: Client) {.jsfunc.} =
   JS_RunGC(client.jsrt)
 
-proc sleep(client: Client, millis: int) {.jsfunc.} =
+proc sleep(client: Client; millis: int) {.jsfunc.} =
   sleep millis
 
-proc atob(client: Client, data: string): DOMResult[NarrowString] {.jsfunc.} =
+proc atob(client: Client; data: string): DOMResult[NarrowString] {.jsfunc.} =
   return atob(data)
 
-proc btoa(ctx: JSContext, client: Client, data: JSValue): DOMResult[string]
+proc btoa(ctx: JSContext; client: Client; data: JSValue): DOMResult[string]
     {.jsfunc.} =
   return btoa(ctx, data)
 
 func line(client: Client): LineEdit {.jsfget.} =
   return client.pager.lineedit.get(nil)
 
-proc addJSModules(client: Client, ctx: JSContext) =
+proc addJSModules(client: Client; ctx: JSContext) =
   ctx.addDOMExceptionModule()
   ctx.addConsoleModule()
   ctx.addCookieModule()
diff --git a/src/local/container.nim b/src/local/container.nim
index 022c40f2..e93bf610 100644
--- a/src/local/container.nim
+++ b/src/local/container.nim
@@ -203,14 +203,15 @@ proc clone*(container: Container; newurl: URL): Promise[Container] =
     return nc
   )
 
-func lineLoaded(container: Container, y: int): bool =
+func lineLoaded(container: Container; y: int): bool =
   return y - container.lineshift in 0..container.lines.high
 
-func getLine(container: Container, y: int): SimpleFlexibleLine =
+func getLine(container: Container; y: int): SimpleFlexibleLine =
   if container.lineLoaded(y):
     return container.lines[y - container.lineshift]
 
-iterator ilines*(container: Container, slice: Slice[int]): SimpleFlexibleLine {.inline.} =
+iterator ilines*(container: Container; slice: Slice[int]): SimpleFlexibleLine
+    {.inline.} =
   for y in slice:
     yield container.getLine(y)
 
@@ -235,7 +236,7 @@ func lastVisibleLine(container: Container): int =
 func currentLine(container: Container): string =
   return container.getLine(container.cursory).str
 
-func findColBytes(s: string, endx: int, startx = 0, starti = 0): int =
+func findColBytes(s: string; endx: int; startx = 0; starti = 0): int =
   var w = startx
   var i = starti
   while i < s.len and w < endx:
@@ -244,10 +245,10 @@ func findColBytes(s: string, endx: int, startx = 0, starti = 0): int =
     w += r.twidth(w)
   return i
 
-func cursorBytes(container: Container, y: int, cc = container.cursorx): int =
+func cursorBytes(container: Container; y: int; cc = container.cursorx): int =
   return container.getLine(y).str.findColBytes(cc, 0, 0)
 
-func currentCursorBytes(container: Container, cc = container.cursorx): int =
+func currentCursorBytes(container: Container; cc = container.cursorx): int =
   return container.cursorBytes(container.cursory, cc)
 
 # Returns the X position of the first cell occupied by the character the cursor
@@ -362,7 +363,7 @@ func endx(hl: Highlight): int =
     max(hl.x1, hl.x2)
 func endy(hl: Highlight): int = max(hl.y1, hl.y2)
 
-func colorNormal(container: Container, hl: Highlight, y: int,
+func colorNormal(container: Container; hl: Highlight; y: int;
     limitx: Slice[int]): Slice[int] =
   let starty = hl.starty
   let endy = hl.endy
@@ -378,7 +379,7 @@ func colorNormal(container: Container, hl: Highlight, y: int,
     let w = container.getLine(y).str.width()
     return min(limitx.a, w) .. min(hl.endx, limitx.b)
 
-func colorArea(container: Container, hl: Highlight, y: int,
+func colorArea(container: Container; hl: Highlight; y: int;
     limitx: Slice[int]): Slice[int] =
   case hl.t
   of hltSelect:
@@ -399,7 +400,7 @@ func colorArea(container: Container, hl: Highlight, y: int,
   else:
     return container.colorNormal(hl, y, limitx)
 
-func findHighlights*(container: Container, y: int): seq[Highlight] =
+func findHighlights*(container: Container; y: int): seq[Highlight] =
   for hl in container.highlights:
     if y in hl.starty .. hl.endy:
       result.add(hl)
@@ -410,19 +411,19 @@ func getHoverText*(container: Container): string =
       return container.hoverText[t]
   ""
 
-func isHoverURL*(container: Container, url: URL): bool =
+func isHoverURL*(container: Container; url: URL): bool =
   let hoverurl = parseURL(container.hoverText[htLink])
   return hoverurl.isSome and url.host == hoverurl.get.host
 
-proc triggerEvent(container: Container, event: ContainerEvent) =
+proc triggerEvent(container: Container; event: ContainerEvent) =
   container.events.addLast(event)
 
-proc triggerEvent(container: Container, t: ContainerEventType) =
+proc triggerEvent(container: Container; t: ContainerEventType) =
   container.triggerEvent(ContainerEvent(t: t))
 
 proc updateCursor(container: Container)
 
-proc setNumLines(container: Container, lines: int, finish = false) =
+proc setNumLines(container: Container; lines: int; finish = false) =
   if container.numLines != lines:
     container.numLines = lines
     if container.startpos.isSome and finish:
@@ -476,22 +477,23 @@ proc sendCursorPosition*(container: Container) =
       container.needslines = true
   )
 
-proc setFromY(container: Container, y: int) {.jsfunc.} =
+proc setFromY(container: Container; y: int) {.jsfunc.} =
   if container.pos.fromy != y:
     container.pos.fromy = max(min(y, container.maxfromy), 0)
     container.needslines = true
     container.triggerEvent(cetUpdate)
 
-proc setFromX(container: Container, x: int, refresh = true) {.jsfunc.} =
+proc setFromX(container: Container; x: int; refresh = true) {.jsfunc.} =
   if container.pos.fromx != x:
     container.pos.fromx = max(min(x, container.maxfromx), 0)
     if container.pos.fromx > container.cursorx:
-      container.pos.cursorx = min(container.pos.fromx, container.currentLineWidth())
+      container.pos.cursorx = min(container.pos.fromx,
+        container.currentLineWidth())
       if refresh:
         container.sendCursorPosition()
     container.triggerEvent(cetUpdate)
 
-proc setFromXY(container: Container, x, y: int) {.jsfunc.} =
+proc setFromXY(container: Container; x, y: int) {.jsfunc.} =
   container.setFromY(y)
   container.setFromX(x)
 
@@ -500,7 +502,7 @@ proc setFromXY(container: Container, x, y: int) {.jsfunc.} =
 # * `save = false' inhibits cursor movement if it is currently outside the
 #   screen, and makes it so cursorx is not saved for restoration on cursory
 #   movement.
-proc setCursorX(container: Container, x: int, refresh = true, save = true)
+proc setCursorX(container: Container; x: int; refresh = true; save = true)
     {.jsfunc.} =
   if not container.lineLoaded(container.cursory):
     container.pos.setx = x
@@ -550,7 +552,7 @@ proc restoreCursorX(container: Container) {.jsfunc.} =
   let x = clamp(container.currentLineWidth() - 1, 0, container.xend)
   container.setCursorX(x, false, false)
 
-proc setCursorY(container: Container, y: int, refresh = true) {.jsfunc.} =
+proc setCursorY(container: Container; y: int; refresh = true) {.jsfunc.} =
   let y = max(min(y, container.numLines - 1), 0)
   if container.cursory == y: return
   if y - container.fromy >= 0 and y - container.height < container.fromy:
@@ -568,7 +570,7 @@ proc setCursorY(container: Container, y: int, refresh = true) {.jsfunc.} =
   if refresh:
     container.sendCursorPosition()
 
-proc setCursorXY*(container: Container, x, y: int, refresh = true) {.jsfunc.} =
+proc setCursorXY*(container: Container; x, y: int; refresh = true) {.jsfunc.} =
   container.setCursorY(y, refresh)
   container.setCursorX(x, refresh)
 
@@ -584,40 +586,40 @@ proc cursorLineTextStart(container: Container) {.jsfunc.} =
   container.setCursorX(x)
 
 # zb
-proc lowerPage(container: Container, n = 0) {.jsfunc.} =
+proc lowerPage(container: Container; n = 0) {.jsfunc.} =
   if n != 0:
     container.setCursorY(n - 1)
   container.setFromY(container.cursory - container.height + 1)
 
 # z-
-proc lowerPageBegin(container: Container, n = 0) {.jsfunc.} =
+proc lowerPageBegin(container: Container; n = 0) {.jsfunc.} =
   container.lowerPage(n)
   container.cursorLineTextStart()
 
 # zz
-proc centerLine(container: Container, n = 0) {.jsfunc.} =
+proc centerLine(container: Container; n = 0) {.jsfunc.} =
   if n != 0:
     container.setCursorY(n - 1)
   container.setFromY(container.cursory - container.height div 2)
 
 # z.
-proc centerLineBegin(container: Container, n = 0) {.jsfunc.} =
+proc centerLineBegin(container: Container; n = 0) {.jsfunc.} =
   container.centerLine(n)
   container.cursorLineTextStart()
 
 # zt
-proc raisePage(container: Container, n = 0) {.jsfunc.} =
+proc raisePage(container: Container; n = 0) {.jsfunc.} =
   if n != 0:
     container.setCursorY(n - 1)
   container.setFromY(container.cursory)
 
 # z^M
-proc raisePageBegin(container: Container, n = 0) {.jsfunc.} =
+proc raisePageBegin(container: Container; n = 0) {.jsfunc.} =
   container.raisePage(n)
   container.cursorLineTextStart()
 
 # z+
-proc nextPageBegin(container: Container, n = 0) {.jsfunc.} =
+proc nextPageBegin(container: Container; n = 0) {.jsfunc.} =
   if n == 0:
     container.setCursorY(container.fromy + container.height)
   else:
@@ -626,7 +628,7 @@ proc nextPageBegin(container: Container, n = 0) {.jsfunc.} =
   container.raisePage()
 
 # z^
-proc previousPageBegin(container: Container, n = 0) {.jsfunc.} =
+proc previousPageBegin(container: Container; n = 0) {.jsfunc.} =
   if n == 0:
     container.setCursorY(container.fromy - 1)
   else:
@@ -637,14 +639,15 @@ proc previousPageBegin(container: Container, n = 0) {.jsfunc.} =
 proc centerColumn(container: Container) {.jsfunc.} =
   container.setFromX(container.cursorx - container.width div 2)
 
-proc setCursorYCenter(container: Container, y: int, refresh = true)
+proc setCursorYCenter(container: Container; y: int; refresh = true)
     {.jsfunc.} =
   let fy = container.fromy
   container.setCursorY(y, refresh)
   if fy != container.fromy:
     container.centerLine()
 
-proc setCursorXYCenter(container: Container, x, y: int, refresh = true) {.jsfunc.} =
+proc setCursorXYCenter(container: Container; x, y: int; refresh = true)
+    {.jsfunc.} =
   let fy = container.fromy
   let fx = container.fromx
   container.setCursorXY(x, y, refresh)
@@ -653,25 +656,25 @@ proc setCursorXYCenter(container: Container, x, y: int, refresh = true) {.jsfunc
   if fx != container.fromx:
     container.centerColumn()
 
-proc cursorDown(container: Container, n = 1) {.jsfunc.} =
+proc cursorDown(container: Container; n = 1) {.jsfunc.} =
   if container.select.open:
     container.select.cursorDown()
   else:
     container.setCursorY(container.cursory + n)
 
-proc cursorUp(container: Container, n = 1) {.jsfunc.} =
+proc cursorUp(container: Container; n = 1) {.jsfunc.} =
   if container.select.open:
     container.select.cursorUp()
   else:
     container.setCursorY(container.cursory - n)
 
-proc cursorLeft(container: Container, n = 1) {.jsfunc.} =
+proc cursorLeft(container: Container; n = 1) {.jsfunc.} =
   if container.select.open:
     container.select.cursorLeft()
   else:
     container.setCursorX(container.cursorFirstX() - n)
 
-proc cursorRight(container: Container, n = 1) {.jsfunc.} =
+proc cursorRight(container: Container; n = 1) {.jsfunc.} =
   if container.select.open:
     container.select.cursorRight()
   else:
@@ -685,7 +688,7 @@ proc cursorLineEnd(container: Container) {.jsfunc.} =
 
 type BreakFunc = proc(r: Rune): BreakCategory {.nimcall.}
 
-proc cursorNextWord(container: Container, breakFunc: BreakFunc) =
+proc cursorNextWord(container: Container; breakFunc: BreakFunc) =
   if container.numLines == 0: return
   var r: Rune
   var b = container.currentCursorBytes()
@@ -694,8 +697,8 @@ proc cursorNextWord(container: Container, breakFunc: BreakFunc) =
   let currentCat = if b < container.currentLine.len:
     container.currentLine.runeAt(b).breakFunc()
   else:
-    BREAK_SPACE
-  if currentCat != BREAK_SPACE:
+    bcSpace
+  if currentCat != bcSpace:
     # not in space, skip chars that have the same category
     while b < container.currentLine.len:
       let pb = b
@@ -709,7 +712,7 @@ proc cursorNextWord(container: Container, breakFunc: BreakFunc) =
   while b < container.currentLine.len:
     let pb = b
     fastRuneAt(container.currentLine, b, r)
-    if r.breakFunc() != BREAK_SPACE:
+    if r.breakFunc() != bcSpace:
       b = pb
       break
     x += r.twidth(x)
@@ -732,7 +735,7 @@ proc cursorNextViWord(container: Container) {.jsfunc.} =
 proc cursorNextBigWord(container: Container) {.jsfunc.} =
   container.cursorNextWord(breaksBigWordCat)
 
-proc cursorPrevWord(container: Container, breakFunc: BreakFunc) =
+proc cursorPrevWord(container: Container; breakFunc: BreakFunc) =
   if container.numLines == 0: return
   var b = container.currentCursorBytes()
   var x = container.cursorx
@@ -741,8 +744,8 @@ proc cursorPrevWord(container: Container, breakFunc: BreakFunc) =
     let currentCat = if b >= 0:
       container.currentLine.runeAt(b).breakFunc()
     else:
-      BREAK_SPACE
-    if currentCat != BREAK_SPACE:
+      bcSpace
+    if currentCat != bcSpace:
       # not in space, skip chars that have the same category
       while b >= 0:
         let (r, o) = lastRune(container.currentLine, b)
@@ -754,7 +757,7 @@ proc cursorPrevWord(container: Container, breakFunc: BreakFunc) =
     # skip space
     while b >= 0:
       let (r, o) = lastRune(container.currentLine, b)
-      if r.breakFunc() != BREAK_SPACE:
+      if r.breakFunc() != bcSpace:
         break
       b -= o
       x -= r.twidth(x)
@@ -779,7 +782,7 @@ proc cursorPrevViWord(container: Container) {.jsfunc.} =
 proc cursorPrevBigWord(container: Container) {.jsfunc.} =
   container.cursorPrevWord(breaksBigWordCat)
 
-proc cursorWordEnd(container: Container, breakFunc: BreakFunc) =
+proc cursorWordEnd(container: Container; breakFunc: BreakFunc) =
   if container.numLines == 0: return
   var r: Rune
   var b = container.currentCursorBytes()
@@ -789,7 +792,7 @@ proc cursorWordEnd(container: Container, breakFunc: BreakFunc) =
   if b < container.currentLine.len:
     let pb = b
     fastRuneAt(container.currentLine, b, r)
-    if r.breakFunc() == BREAK_SPACE:
+    if r.breakFunc() == bcSpace:
       b = pb
     else:
       px = x
@@ -799,7 +802,7 @@ proc cursorWordEnd(container: Container, breakFunc: BreakFunc) =
   while b < container.currentLine.len:
     let pb = b
     fastRuneAt(container.currentLine, b, r)
-    if r.breakFunc() != BREAK_SPACE:
+    if r.breakFunc() != bcSpace:
       b = pb
       break
     x += r.twidth(x)
@@ -836,7 +839,7 @@ proc cursorViWordEnd(container: Container) {.jsfunc.} =
 proc cursorBigWordEnd(container: Container) {.jsfunc.} =
   container.cursorWordEnd(breaksBigWordCat)
 
-proc cursorWordBegin(container: Container, breakFunc: BreakFunc) =
+proc cursorWordBegin(container: Container; breakFunc: BreakFunc) =
   if container.numLines == 0: return
   var b = container.currentCursorBytes()
   var x = container.cursorx
@@ -847,7 +850,7 @@ proc cursorWordBegin(container: Container, breakFunc: BreakFunc) =
     if b >= 0:
       let (r, o) = lastRune(container.currentLine, b)
       # if not in space, move to the left by one
-      if r.breakFunc() != BREAK_SPACE:
+      if r.breakFunc() != bcSpace:
         b -= o
         px = x
         x -= r.twidth(x)
@@ -855,7 +858,7 @@ proc cursorWordBegin(container: Container, breakFunc: BreakFunc) =
     # skip space
     while b >= 0:
       let (r, o) = lastRune(container.currentLine, b)
-      if r.breakFunc() != BREAK_SPACE:
+      if r.breakFunc() != bcSpace:
         break
       b -= o
       x -= r.twidth(x)
@@ -895,40 +898,40 @@ proc cursorViWordBegin(container: Container) {.jsfunc.} =
 proc cursorBigWordBegin(container: Container) {.jsfunc.} =
   container.cursorWordBegin(breaksBigWordCat)
 
-proc pageDown(container: Container, n = 1) {.jsfunc.} =
+proc pageDown(container: Container; n = 1) {.jsfunc.} =
   container.setFromY(container.fromy + container.height * n)
   container.setCursorY(container.cursory + container.height * n)
   container.restoreCursorX()
 
-proc pageUp(container: Container, n = 1) {.jsfunc.} =
+proc pageUp(container: Container; n = 1) {.jsfunc.} =
   container.setFromY(container.fromy - container.height * n)
   container.setCursorY(container.cursory - container.height * n)
   container.restoreCursorX()
 
-proc pageLeft(container: Container, n = 1) {.jsfunc.} =
+proc pageLeft(container: Container; n = 1) {.jsfunc.} =
   container.setFromX(container.fromx - container.width * n)
 
-proc pageRight(container: Container, n = 1) {.jsfunc.} =
+proc pageRight(container: Container; n = 1) {.jsfunc.} =
   container.setFromX(container.fromx + container.width * n)
 
 # I am not cloning the vi behavior here because it is counter-intuitive
 # and annoying.
 # Users who disagree are free to implement it themselves. (It is about
 # 5 lines of JS.)
-proc halfPageUp(container: Container, n = 1) {.jsfunc.} =
+proc halfPageUp(container: Container; n = 1) {.jsfunc.} =
   container.setFromY(container.fromy - (container.height + 1) div 2 * n)
   container.setCursorY(container.cursory - (container.height + 1) div 2 * n)
   container.restoreCursorX()
 
-proc halfPageDown(container: Container, n = 1) {.jsfunc.} =
+proc halfPageDown(container: Container; n = 1) {.jsfunc.} =
   container.setFromY(container.fromy + (container.height + 1) div 2 * n)
   container.setCursorY(container.cursory + (container.height + 1) div 2 * n)
   container.restoreCursorX()
 
-proc halfPageLeft(container: Container, n = 1) {.jsfunc.} =
+proc halfPageLeft(container: Container; n = 1) {.jsfunc.} =
   container.setFromX(container.fromx - (container.width + 1) div 2 * n)
 
-proc halfPageRight(container: Container, n = 1) {.jsfunc.} =
+proc halfPageRight(container: Container; n = 1) {.jsfunc.} =
   container.setFromX(container.fromx + (container.width + 1) div 2 * n)
 
 proc markPos0*(container: Container) =
@@ -955,7 +958,7 @@ proc cursorLastLine*(container: Container) {.jsfunc.} =
     container.setCursorY(container.numLines - 1)
     container.markPos()
 
-proc cursorTop(container: Container, i = 1) {.jsfunc.} =
+proc cursorTop(container: Container; i = 1) {.jsfunc.} =
   container.markPos0()
   let i = clamp(i - 1, 0, container.height - 1)
   container.setCursorY(container.fromy + i)
@@ -966,7 +969,7 @@ proc cursorMiddle(container: Container) {.jsfunc.} =
   container.setCursorY(container.fromy + (container.height - 2) div 2)
   container.markPos()
 
-proc cursorBottom(container: Container, i = 1) {.jsfunc.} =
+proc cursorBottom(container: Container; i = 1) {.jsfunc.} =
   container.markPos0()
   let i = clamp(i, 0, container.height)
   container.setCursorY(container.fromy + container.height - i)
@@ -981,7 +984,7 @@ proc cursorMiddleColumn(container: Container) {.jsfunc.} =
 proc cursorRightEdge(container: Container) {.jsfunc.} =
   container.setCursorX(container.fromx + container.width - 1)
 
-proc scrollDown*(container: Container, n = 1) {.jsfunc.} =
+proc scrollDown*(container: Container; n = 1) {.jsfunc.} =
   let H = container.numLines
   let y = min(container.fromy + container.height + n, H) - container.height
   if y > container.fromy:
@@ -991,7 +994,7 @@ proc scrollDown*(container: Container, n = 1) {.jsfunc.} =
   else:
     container.cursorDown(n)
 
-proc scrollUp*(container: Container, n = 1) {.jsfunc.} =
+proc scrollUp*(container: Container; n = 1) {.jsfunc.} =
   let y = max(container.fromy - n, 0)
   if y < container.fromy:
     container.setFromY(y)
@@ -1001,18 +1004,18 @@ proc scrollUp*(container: Container, n = 1) {.jsfunc.} =
   else:
     container.cursorUp(n)
 
-proc scrollRight*(container: Container, n = 1) {.jsfunc.} =
+proc scrollRight*(container: Container; n = 1) {.jsfunc.} =
   let msw = container.maxScreenWidth()
   let x = min(container.fromx + container.width + n, msw) - container.width
   if x > container.fromx:
     container.setFromX(x)
 
-proc scrollLeft*(container: Container, n = 1) {.jsfunc.} =
+proc scrollLeft*(container: Container; n = 1) {.jsfunc.} =
   let x = max(container.fromx - n, 0)
   if x < container.fromx:
     container.setFromX(x)
 
-proc alert(container: Container, msg: string) =
+proc alert(container: Container; msg: string) =
   container.triggerEvent(ContainerEvent(t: cetAlert, msg: msg))
 
 proc lineInfo(container: Container) {.jsfunc.} =
@@ -1031,7 +1034,7 @@ proc updateCursor(container: Container) =
     container.setCursorY(container.lastVisibleLine)
     container.alert("Last line is #" & $container.numLines)
 
-proc gotoLine*[T: string|int](container: Container, s: T) =
+proc gotoLine*[T: string|int](container: Container; s: T) =
   when s is string:
     if s == "":
       redraw(container)
@@ -1058,7 +1061,7 @@ proc pushCursorPos*(container: Container) =
   else:
     container.bpos.add(container.pos)
 
-proc popCursorPos*(container: Container, nojump = false) =
+proc popCursorPos*(container: Container; nojump = false) =
   if container.select.open:
     container.select.popCursorPos(nojump)
   else:
@@ -1072,7 +1075,7 @@ proc copyCursorPos*(container, c2: Container) =
   container.startpos = some(c2.pos)
   container.flags.incl(cfHasStart)
 
-proc cursorNextLink*(container: Container, n = 1) {.jsfunc.} =
+proc cursorNextLink*(container: Container; n = 1) {.jsfunc.} =
   if container.iface == nil:
     return
   container.markPos0()
@@ -1084,7 +1087,7 @@ proc cursorNextLink*(container: Container, n = 1) {.jsfunc.} =
         container.markPos()
     )
 
-proc cursorPrevLink*(container: Container, n = 1) {.jsfunc.} =
+proc cursorPrevLink*(container: Container; n = 1) {.jsfunc.} =
   if container.iface == nil:
     return
   container.markPos0()
@@ -1096,7 +1099,7 @@ proc cursorPrevLink*(container: Container, n = 1) {.jsfunc.} =
         container.markPos()
     )
 
-proc cursorNextParagraph*(container: Container, n = 1) {.jsfunc.} =
+proc cursorNextParagraph*(container: Container; n = 1) {.jsfunc.} =
   if container.iface == nil:
     return
   container.markPos0()
@@ -1107,7 +1110,7 @@ proc cursorNextParagraph*(container: Container, n = 1) {.jsfunc.} =
       container.markPos()
     )
 
-proc cursorPrevParagraph*(container: Container, n = 1) {.jsfunc.} =
+proc cursorPrevParagraph*(container: Container; n = 1) {.jsfunc.} =
   if container.iface == nil:
     return
   container.markPos0()
@@ -1118,7 +1121,7 @@ proc cursorPrevParagraph*(container: Container, n = 1) {.jsfunc.} =
       container.markPos()
     )
 
-proc setMark*(container: Container, id: string, x = none(int),
+proc setMark*(container: Container; id: string; x = none(int);
     y = none(int)): bool {.jsfunc.} =
   let x = x.get(container.cursorx)
   let y = y.get(container.cursory)
@@ -1131,19 +1134,19 @@ proc setMark*(container: Container, id: string, x = none(int),
     container.triggerEvent(cetUpdate)
     return true
 
-proc clearMark*(container: Container, id: string): bool {.jsfunc.} =
+proc clearMark*(container: Container; id: string): bool {.jsfunc.} =
   result = id in container.marks
   container.marks.del(id)
   container.triggerEvent(cetUpdate)
 
-proc getMarkPos(container: Container, id: string): Opt[PagePos] {.jsfunc.} =
+proc getMarkPos(container: Container; id: string): Opt[PagePos] {.jsfunc.} =
   if id == "`" or id == "'":
     return ok(container.jumpMark)
   container.marks.withValue(id, p):
     return ok(p[])
   return err()
 
-proc gotoMark*(container: Container, id: string): bool {.jsfunc.} =
+proc gotoMark*(container: Container; id: string): bool {.jsfunc.} =
   container.markPos0()
   let mark = container.getMarkPos(id)
   if mark.isSome:
@@ -1153,7 +1156,7 @@ proc gotoMark*(container: Container, id: string): bool {.jsfunc.} =
     return true
   return false
 
-proc gotoMarkY*(container: Container, id: string): bool {.jsfunc.} =
+proc gotoMarkY*(container: Container; id: string): bool {.jsfunc.} =
   container.markPos0()
   let mark = container.getMarkPos(id)
   if mark.isSome:
@@ -1163,7 +1166,7 @@ proc gotoMarkY*(container: Container, id: string): bool {.jsfunc.} =
     return true
   return false
 
-proc findNextMark*(container: Container, x = none(int), y = none(int)):
+proc findNextMark*(container: Container; x = none(int), y = none(int)):
     Option[string] {.jsfunc.} =
   #TODO optimize (maybe store marks in an OrderedTable and sort on insert?)
   let x = x.get(container.cursorx)
@@ -1178,7 +1181,7 @@ proc findNextMark*(container: Container, x = none(int), y = none(int)):
       bestid = some(id)
   return bestid
 
-proc findPrevMark*(container: Container, x = none(int), y = none(int)):
+proc findPrevMark*(container: Container; x = none(int), y = none(int)):
     Option[string] {.jsfunc.} =
   #TODO optimize (maybe store marks in an OrderedTable and sort on insert?)
   let x = x.get(container.cursorx)
@@ -1193,7 +1196,7 @@ proc findPrevMark*(container: Container, x = none(int), y = none(int)):
       bestid = some(id)
   return bestid
 
-proc cursorNthLink*(container: Container, n = 1) {.jsfunc.} =
+proc cursorNthLink*(container: Container; n = 1) {.jsfunc.} =
   if container.iface == nil:
     return
   container.iface
@@ -1202,7 +1205,7 @@ proc cursorNthLink*(container: Container, n = 1) {.jsfunc.} =
       if res.x > -1 and res.y != -1:
         container.setCursorXYCenter(res.x, res.y))
 
-proc cursorRevNthLink*(container: Container, n = 1) {.jsfunc.} =
+proc cursorRevNthLink*(container: Container; n = 1) {.jsfunc.} =
   if container.iface == nil:
     return
   container.iface
@@ -1216,7 +1219,7 @@ proc clearSearchHighlights*(container: Container) =
     if container.highlights[i].t == hltSearch:
       container.highlights.del(i)
 
-proc onMatch(container: Container, res: BufferMatch, refresh: bool) =
+proc onMatch(container: Container; res: BufferMatch; refresh: bool) =
   if res.success:
     container.setCursorXYCenter(res.x, res.y, refresh)
     if container.hlon:
@@ -1239,7 +1242,7 @@ proc onMatch(container: Container, res: BufferMatch, refresh: bool) =
     container.needslines = true
     container.hlon = false
 
-proc cursorNextMatch*(container: Container, regex: Regex, wrap, refresh: bool,
+proc cursorNextMatch*(container: Container; regex: Regex; wrap, refresh: bool;
     n: int): EmptyPromise {.discardable.} =
   if container.select.open:
     #TODO
@@ -1254,7 +1257,7 @@ proc cursorNextMatch*(container: Container, regex: Regex, wrap, refresh: bool,
       .then(proc(res: BufferMatch) =
         container.onMatch(res, refresh))
 
-proc cursorPrevMatch*(container: Container, regex: Regex, wrap, refresh: bool,
+proc cursorPrevMatch*(container: Container; regex: Regex; wrap, refresh: bool;
     n: int): EmptyPromise {.discardable.} =
   if container.select.open:
     #TODO
@@ -1276,7 +1279,7 @@ type
   SelectionOptions = object of JSDict
     selectionType: SelectionType
 
-proc cursorToggleSelection(container: Container, n = 1,
+proc cursorToggleSelection(container: Container; n = 1;
     opts = SelectionOptions()): Highlight {.jsfunc.} =
   if container.currentSelection != nil:
     let i = container.highlights.find(container.currentSelection)
@@ -1302,7 +1305,7 @@ proc cursorToggleSelection(container: Container, n = 1,
 
 #TODO I don't like this API
 # maybe make selection a subclass of highlight?
-proc getSelectionText(container: Container, hl: Highlight = nil):
+proc getSelectionText(container: Container; hl: Highlight = nil):
     Promise[string] {.jsfunc.} =
   if container.iface == nil:
     return
@@ -1354,7 +1357,7 @@ proc markURL(container: Container) {.jsfunc.} =
     container.needslines = true
   )
 
-proc setLoadInfo(container: Container, msg: string) =
+proc setLoadInfo(container: Container; msg: string) =
   container.loadinfo = msg
   container.triggerEvent(cetSetLoadInfo)
 
@@ -1614,8 +1617,8 @@ proc setCloneStream*(container: Container; stream: SocketStream;
   # Maybe we have to resume loading. Let's try.
   container.startLoad()
 
-proc onreadline(container: Container, w: Slice[int],
-    handle: (proc(line: SimpleFlexibleLine)), res: GetLinesResult) =
+proc onreadline(container: Container; w: Slice[int];
+    handle: (proc(line: SimpleFlexibleLine)); res: GetLinesResult) =
   for line in res.lines:
     handle(line)
   if res.numLines > w.b + 1:
@@ -1628,7 +1631,7 @@ proc onreadline(container: Container, w: Slice[int],
     container.setNumLines(res.numLines, true)
 
 # Synchronously read all lines in the buffer.
-proc readLines*(container: Container, handle: proc(line: SimpleFlexibleLine)) =
+proc readLines*(container: Container; handle: proc(line: SimpleFlexibleLine)) =
   if container.code == 0:
     # load succeded
     let w = 0 .. 23
@@ -1638,7 +1641,7 @@ proc readLines*(container: Container, handle: proc(line: SimpleFlexibleLine)) =
       # fulfill all promises
       container.handleCommand()
 
-proc drawLines*(container: Container, display: var FixedGrid,
+proc drawLines*(container: Container; display: var FixedGrid;
     hlcolor: CellColor) =
   let bgcolor = container.bgcolor
   template set_fmt(cell, cf: typed) =
@@ -1709,7 +1712,7 @@ proc drawLines*(container: Container, display: var FixedGrid,
         display[dls + i - startw].format = hlformat
     inc by
 
-proc highlightMarks*(container: Container, display: var FixedGrid,
+proc highlightMarks*(container: Container; display: var FixedGrid;
     hlcolor: CellColor) =
   for mark in container.marks.values:
     if mark.x in container.fromx ..< container.fromx + display.width and
diff --git a/src/local/lineedit.nim b/src/local/lineedit.nim
index 42543d46..2db59e7b 100644
--- a/src/local/lineedit.nim
+++ b/src/local/lineedit.nim
@@ -120,7 +120,7 @@ proc generateOutput*(edit: LineEdit): FixedGrid =
 proc getCursorX*(edit: LineEdit): int =
   return edit.promptw + edit.cursorx + edit.padding - edit.shiftx
 
-proc insertCharseq(edit: LineEdit, s: string) =
+proc insertCharseq(edit: LineEdit; s: string) =
   let s = if edit.escNext:
     s
   else:
@@ -152,7 +152,7 @@ proc backspace(edit: LineEdit) {.jsfunc.} =
     edit.cursorx -= r.width()
     edit.invalid = true
 
-proc write*(edit: LineEdit, s: string, cs: Charset): bool =
+proc write*(edit: LineEdit; s: string; cs: Charset): bool =
   if cs == CHARSET_UTF_8:
     if s.validateUTF8Surr() != -1:
       return false
@@ -166,7 +166,7 @@ proc write*(edit: LineEdit, s: string, cs: Charset): bool =
     edit.insertCharseq(s)
   return true
 
-proc write(edit: LineEdit, s: string): bool {.jsfunc.} =
+proc write(edit: LineEdit; s: string): bool {.jsfunc.} =
   edit.write(s, CHARSET_UTF_8)
 
 proc delete(edit: LineEdit) {.jsfunc.} =
@@ -304,11 +304,11 @@ proc nextHist(edit: LineEdit) {.jsfunc.} =
     edit.end()
     edit.histtmp = ""
 
-proc windowChange*(edit: LineEdit, attrs: WindowAttributes) =
+proc windowChange*(edit: LineEdit; attrs: WindowAttributes) =
   edit.maxwidth = attrs.width - edit.promptw - 1
 
-proc readLine*(prompt: string, termwidth: int, current = "",
-    disallowed: set[char] = {}, hide = false, hist: LineHistory): LineEdit =
+proc readLine*(prompt, current: string; termwidth: int;
+    disallowed: set[char]; hide: bool; hist: LineHistory): LineEdit =
   result = LineEdit(
     prompt: prompt,
     promptw: prompt.width(),
diff --git a/src/local/pager.nim b/src/local/pager.nim
index 624a4867..99a1ba1c 100644
--- a/src/local/pager.nim
+++ b/src/local/pager.nim
@@ -168,13 +168,13 @@ iterator containers*(pager: Pager): Container {.inline.} =
     for c in root.descendants:
       yield c
 
-proc setContainer*(pager: Pager, c: Container) {.jsfunc.} =
+proc setContainer*(pager: Pager; c: Container) {.jsfunc.} =
   pager.container = c
   pager.redraw = true
   if c != nil:
     pager.term.setTitle(c.getTitle())
 
-proc hasprop(ctx: JSContext, pager: Pager, s: string): bool {.jshasprop.} =
+proc hasprop(ctx: JSContext; pager: Pager; s: string): bool {.jshasprop.} =
   if pager.container != nil:
     let cval = toJS(ctx, pager.container)
     let val = JS_GetPropertyStr(ctx, cval, s)
@@ -182,12 +182,12 @@ proc hasprop(ctx: JSContext, pager: Pager, s: string): bool {.jshasprop.} =
       result = true
     JS_FreeValue(ctx, val)
 
-proc reflect(ctx: JSContext, this_val: JSValue, argc: cint, argv: ptr JSValue,
-             magic: cint, func_data: ptr JSValue): JSValue {.cdecl.} =
+proc reflect(ctx: JSContext; this_val: JSValue; argc: cint; argv: ptr JSValue;
+    magic: cint; func_data: ptr JSValue): JSValue {.cdecl.} =
   let fun = cast[ptr JSValue](cast[int](func_data) + sizeof(JSValue))[]
   return JS_Call(ctx, fun, func_data[], argc, argv)
 
-proc getter(ctx: JSContext, pager: Pager, s: string): Option[JSValue]
+proc getter(ctx: JSContext; pager: Pager; s: string): Option[JSValue]
     {.jsgetprop.} =
   if pager.container != nil:
     let cval = toJS(ctx, pager.container)
@@ -199,7 +199,7 @@ proc getter(ctx: JSContext, pager: Pager, s: string): Option[JSValue]
         return some(fun)
       return some(val)
 
-proc searchNext(pager: Pager, n = 1) {.jsfunc.} =
+proc searchNext(pager: Pager; n = 1) {.jsfunc.} =
   if pager.regex.isSome:
     let wrap = pager.config.search.wrap
     pager.container.markPos0()
@@ -211,7 +211,7 @@ proc searchNext(pager: Pager, n = 1) {.jsfunc.} =
   else:
     pager.alert("No previous regular expression")
 
-proc searchPrev(pager: Pager, n = 1) {.jsfunc.} =
+proc searchPrev(pager: Pager; n = 1) {.jsfunc.} =
   if pager.regex.isSome:
     let wrap = pager.config.search.wrap
     pager.container.markPos0()
@@ -233,7 +233,7 @@ proc setLineEdit(pager: Pager; mode: LineMode; current = ""; hide = false;
   let hist = pager.getLineHist(mode)
   if pager.term.isatty() and pager.config.input.use_mouse:
     pager.term.disableMouse()
-  let edit = readLine($mode & extraPrompt, pager.attrs.width, current, {}, hide,
+  let edit = readLine($mode & extraPrompt, current, pager.attrs.width, {}, hide,
     hist)
   pager.lineedit = some(edit)
   pager.linemode = mode
@@ -261,7 +261,7 @@ proc isearchBackward(pager: Pager) {.jsfunc.} =
   pager.container.markPos0()
   pager.setLineEdit(lmISearchB)
 
-proc gotoLine[T: string|int](pager: Pager, s: T = "") {.jsfunc.} =
+proc gotoLine[T: string|int](pager: Pager; s: T = "") {.jsfunc.} =
   when s is string:
     if s == "":
       pager.setLineEdit(lmGotoLine)
@@ -272,7 +272,7 @@ proc dumpAlerts*(pager: Pager) =
   for msg in pager.alerts:
     stderr.write("cha: " & msg & '\n')
 
-proc quit*(pager: Pager, code = 0) =
+proc quit*(pager: Pager; code = 0) =
   pager.term.quit()
   pager.dumpAlerts()
 
@@ -292,14 +292,14 @@ proc genClientKey(pager: Pager): ClientKey =
   doAssert n == key.len
   return key
 
-proc addLoaderClient*(pager: Pager, pid: int, config: LoaderClientConfig):
+proc addLoaderClient*(pager: Pager; pid: int; config: LoaderClientConfig):
     ClientKey =
   var key = pager.genClientKey()
   while unlikely(not pager.loader.addClient(key, pid, config)):
     key = pager.genClientKey()
   return key
 
-proc setLoader*(pager: Pager, loader: FileLoader) =
+proc setLoader*(pager: Pager; loader: FileLoader) =
   pager.devRandom = newPosixStream("/dev/urandom", O_RDONLY, 0)
   pager.loader = loader
   let config = LoaderClientConfig(
@@ -323,7 +323,7 @@ proc clearDisplay(pager: Pager) =
 
 proc buffer(pager: Pager): Container {.jsfget, inline.} = pager.container
 
-proc refreshDisplay(pager: Pager, container = pager.container) =
+proc refreshDisplay(pager: Pager; container = pager.container) =
   pager.clearDisplay()
   let hlcolor = cellColor(pager.config.display.highlight_color)
   container.drawLines(pager.display, hlcolor)
@@ -331,8 +331,8 @@ proc refreshDisplay(pager: Pager, container = pager.container) =
     container.highlightMarks(pager.display, hlcolor)
 
 # Note: this function does not work correctly if start < i of last written char
-proc writeStatusMessage(pager: Pager, str: string, format = Format(),
-    start = 0, maxwidth = -1, clip = '$'): int {.discardable.} =
+proc writeStatusMessage(pager: Pager; str: string; format = Format();
+    start = 0; maxwidth = -1; clip = '$'): int {.discardable.} =
   var maxwidth = maxwidth
   if maxwidth == -1:
     maxwidth = pager.statusgrid.len
@@ -401,7 +401,7 @@ proc showAlerts*(pager: Pager) =
       pager.inputBuffer == "" and pager.precnum == 0:
     pager.refreshStatusMsg()
 
-proc drawBuffer*(pager: Pager, container: Container, ostream: Stream) =
+proc drawBuffer*(pager: Pager; container: Container; ostream: Stream) =
   var format = Format()
   container.readLines(proc(line: SimpleFlexibleLine) =
     if line.formats.len == 0:
@@ -452,7 +452,8 @@ proc draw*(pager: Pager) =
   if pager.askpromise != nil:
     pager.term.setCursor(pager.askcursor, pager.attrs.height - 1)
   elif pager.lineedit.isSome:
-    pager.term.setCursor(pager.lineedit.get.getCursorX(), pager.attrs.height - 1)
+    pager.term.setCursor(pager.lineedit.get.getCursorX(),
+      pager.attrs.height - 1)
   elif container != nil:
     if container.select.open:
       pager.term.setCursor(container.select.getCursorX(),
@@ -463,35 +464,35 @@ proc draw*(pager: Pager) =
   pager.term.flush()
   pager.redraw = false
 
-proc writeAskPrompt(pager: Pager, s = "") =
+proc writeAskPrompt(pager: Pager; s = "") =
   let maxwidth = pager.statusgrid.width - s.len
   let i = pager.writeStatusMessage(pager.askprompt, maxwidth = maxwidth)
   pager.askcursor = pager.writeStatusMessage(s, start = i)
   pager.term.writeGrid(pager.statusgrid, 0, pager.attrs.height - 1)
 
-proc ask(pager: Pager, prompt: string): Promise[bool] {.jsfunc.} =
+proc ask(pager: Pager; prompt: string): Promise[bool] {.jsfunc.} =
   pager.askprompt = prompt
   pager.writeAskPrompt(" (y/n)")
   pager.askpromise = Promise[bool]()
   return pager.askpromise
 
-proc askChar(pager: Pager, prompt: string): Promise[string] {.jsfunc.} =
+proc askChar(pager: Pager; prompt: string): Promise[string] {.jsfunc.} =
   pager.askprompt = prompt
   pager.writeAskPrompt()
   pager.askcharpromise = Promise[string]()
   return pager.askcharpromise
 
-proc fulfillAsk*(pager: Pager, y: bool) =
+proc fulfillAsk*(pager: Pager; y: bool) =
   pager.askpromise.resolve(y)
   pager.askpromise = nil
   pager.askprompt = ""
 
-proc fulfillCharAsk*(pager: Pager, s: string) =
+proc fulfillCharAsk*(pager: Pager; s: string) =
   pager.askcharpromise.resolve(s)
   pager.askcharpromise = nil
   pager.askprompt = ""
 
-proc addContainer*(pager: Pager, container: Container) =
+proc addContainer*(pager: Pager; container: Container) =
   container.parent = pager.container
   if pager.container != nil:
     pager.container.children.insert(container, 0)
@@ -569,7 +570,7 @@ func findProcMapItem*(pager: Pager; pid: int): int =
       return i
   -1
 
-proc dupeBuffer(pager: Pager, container: Container, url: URL) =
+proc dupeBuffer(pager: Pager; container: Container; url: URL) =
   container.clone(url).then(proc(container: Container) =
     if container == nil:
       pager.alert("Failed to duplicate buffer.")
@@ -653,7 +654,7 @@ proc nextSiblingBuffer(pager: Pager): bool {.jsfunc.} =
   pager.setContainer(pager.container.parent.children[n + 1])
   return true
 
-proc alert*(pager: Pager, msg: string) {.jsfunc.} =
+proc alert*(pager: Pager; msg: string) {.jsfunc.} =
   pager.alerts.add(msg)
 
 # replace target with container in the tree
@@ -721,14 +722,14 @@ proc deleteContainer(pager: Pager; container: Container) =
     pager.forkserver.removeChild(container.process)
     pager.loader.removeClient(container.process)
 
-proc discardBuffer*(pager: Pager, container = none(Container)) {.jsfunc.} =
+proc discardBuffer*(pager: Pager; container = none(Container)) {.jsfunc.} =
   let c = container.get(pager.container)
   if c == nil or c.parent == nil and c.children.len == 0:
     pager.alert("Cannot discard last buffer!")
   else:
     pager.deleteContainer(c)
 
-proc discardTree(pager: Pager, container = none(Container)) {.jsfunc.} =
+proc discardTree(pager: Pager; container = none(Container)) {.jsfunc.} =
   let container = container.get(pager.container)
   if container != nil:
     for c in container.descendants:
@@ -754,7 +755,7 @@ proc runProcess(cmd: string): bool =
       result = WIFSIGNALED(wstatus) and WTERMSIG(wstatus) == SIGINT
 
 # Run process (and suspend the terminal controller).
-proc runProcess(term: Terminal, cmd: string, wait = false): bool =
+proc runProcess(term: Terminal; cmd: string; wait = false): bool =
   term.quit()
   result = runProcess(cmd)
   if wait:
@@ -762,7 +763,7 @@ proc runProcess(term: Terminal, cmd: string, wait = false): bool =
   term.restart()
 
 # Run process, and capture its output.
-proc runProcessCapture(cmd: string, outs: var string): bool =
+proc runProcessCapture(cmd: string; outs: var string): bool =
   let file = popen(cmd, "r")
   if file == nil:
     return false
@@ -972,7 +973,7 @@ proc gotoURL(pager: Pager; request: Request; prevurl = none(URL);
   else:
     pager.container.findAnchor(request.url.anchor)
 
-proc omniRewrite(pager: Pager, s: string): string =
+proc omniRewrite(pager: Pager; s: string): string =
   for rule in pager.config.omnirule:
     if rule.match.match(s):
       let fun = rule.substitute_url.get
@@ -991,7 +992,7 @@ proc omniRewrite(pager: Pager, s: string): string =
 # * file://$PWD/<file>
 # * https://<url>
 # So we attempt to load both, and see what works.
-proc loadURL*(pager: Pager, url: string, ctype = none(string),
+proc loadURL*(pager: Pager; url: string; ctype = none(string);
     cs = CHARSET_UNKNOWN) =
   let url0 = pager.omniRewrite(url)
   let url = if url[0] == '~': expandPath(url0) else: url0
@@ -1009,7 +1010,8 @@ proc loadURL*(pager: Pager, url: string, ctype = none(string),
     let pageurl = parseURL(pager.config.network.prepend_scheme & url)
     if pageurl.isSome: # attempt to load remote page
       urls.add(pageurl.get)
-  let cdir = parseURL("file://" & percentEncode(getCurrentDir(), LocalPathPercentEncodeSet) & DirSep)
+  let cdir = parseURL("file://" & percentEncode(getCurrentDir(),
+    LocalPathPercentEncodeSet) & DirSep)
   let localurl = percentEncode(url, LocalPathPercentEncodeSet)
   let newurl = parseURL(localurl, cdir)
   if newurl.isSome:
@@ -1039,7 +1041,7 @@ proc readPipe0*(pager: Pager; contentType: string; cs: Charset;
     contentType = some(contentType)
   )
 
-proc readPipe*(pager: Pager, contentType: string, cs: Charset, fd: FileHandle,
+proc readPipe*(pager: Pager; contentType: string; cs: Charset; fd: FileHandle;
     title: string) =
   let url = newURL("stream:-").get
   let container = pager.readPipe0(contentType, cs, fd, url, title,
@@ -1050,24 +1052,24 @@ proc readPipe*(pager: Pager, contentType: string, cs: Charset, fd: FileHandle,
 proc command(pager: Pager) {.jsfunc.} =
   pager.setLineEdit(lmCommand)
 
-proc commandMode(pager: Pager, val: bool) {.jsfset.} =
+proc commandMode(pager: Pager; val: bool) {.jsfset.} =
   pager.commandMode = val
   if val:
     pager.command()
 
-proc checkRegex(pager: Pager, regex: Result[Regex, string]): Opt[Regex] =
+proc checkRegex(pager: Pager; regex: Result[Regex, string]): Opt[Regex] =
   if regex.isErr:
     pager.alert("Invalid regex: " & regex.error)
     return err()
   return ok(regex.get)
 
-proc compileSearchRegex(pager: Pager, s: string): Result[Regex, string] =
+proc compileSearchRegex(pager: Pager; s: string): Result[Regex, string] =
   var flags = {LRE_FLAG_UNICODE}
   if pager.config.search.ignore_case:
     flags.incl(LRE_FLAG_IGNORECASE)
   return compileSearchRegex(s, flags)
 
-proc updateReadLineISearch(pager: Pager, linemode: LineMode) =
+proc updateReadLineISearch(pager: Pager; linemode: LineMode) =
   let lineedit = pager.lineedit.get
   pager.isearchpromise = pager.isearchpromise.then(proc(): EmptyPromise =
     case lineedit.state
@@ -1183,11 +1185,11 @@ proc updateReadLine*(pager: Pager) =
     pager.clearLineEdit()
 
 # Same as load(s + '\n')
-proc loadSubmit(pager: Pager, s: string) {.jsfunc.} =
+proc loadSubmit(pager: Pager; s: string) {.jsfunc.} =
   pager.loadURL(s)
 
 # Open a URL prompt and visit the specified URL.
-proc load(pager: Pager, s = "") {.jsfunc.} =
+proc load(pager: Pager; s = "") {.jsfunc.} =
   if s.len > 0 and s[^1] == '\n':
     if s.len > 1:
       pager.loadURL(s[0..^2])
@@ -1197,7 +1199,7 @@ proc load(pager: Pager, s = "") {.jsfunc.} =
     pager.setLineEdit(lmLocation, s)
 
 # Go to specific URL (for JS)
-proc jsGotoURL(pager: Pager, s: string): JSResult[void] {.jsfunc: "gotoURL".} =
+proc jsGotoURL(pager: Pager; s: string): JSResult[void] {.jsfunc: "gotoURL".} =
   pager.gotoURL(newRequest(?newURL(s)))
   ok()
 
@@ -1228,14 +1230,14 @@ proc extern(pager: Pager; cmd: string; t = ExternDict()): bool {.jsfunc.} =
   else:
     return runProcess(cmd)
 
-proc externCapture(pager: Pager, cmd: string): Opt[string] {.jsfunc.} =
+proc externCapture(pager: Pager; cmd: string): Opt[string] {.jsfunc.} =
   pager.setEnvVars()
   var s: string
   if not runProcessCapture(cmd, s):
     return err()
   return ok(s)
 
-proc externInto(pager: Pager, cmd, ins: string): bool {.jsfunc.} =
+proc externInto(pager: Pager; cmd, ins: string): bool {.jsfunc.} =
   pager.setEnvVars()
   return runProcessInto(cmd, ins)
 
@@ -1784,13 +1786,13 @@ proc handleEvent0(pager: Pager; container: Container; event: ContainerEvent):
       item.stream.sclose()
   return true
 
-proc handleEvents*(pager: Pager, container: Container) =
+proc handleEvents*(pager: Pager; container: Container) =
   while container.events.len > 0:
     let event = container.events.popFirst()
     if not pager.handleEvent0(container, event):
       break
 
-proc handleEvent*(pager: Pager, container: Container) =
+proc handleEvent*(pager: Pager; container: Container) =
   try:
     container.handleEvent()
     pager.handleEvents(container)
diff --git a/src/local/select.nim b/src/local/select.nim
index a02aa1a4..cbefea5a 100644
--- a/src/local/select.nim
+++ b/src/local/select.nim
@@ -33,7 +33,7 @@ type
     submitFun: SubmitSelect
     bpos: seq[int]
 
-proc windowChange*(select: var Select, height: int) =
+proc windowChange*(select: var Select; height: int) =
   select.maxh = height - 2
   if select.y + select.options.len >= select.maxh:
     select.y = height - select.options.len
@@ -48,8 +48,8 @@ proc windowChange*(select: var Select, height: int) =
       select.si = max(i - select.maxh, 0)
   select.redraw = true
 
-proc initSelect*(select: var Select, selectResult: SelectResult,
-    x, y, height: int, submitFun: SubmitSelect) =
+proc initSelect*(select: var Select; selectResult: SelectResult;
+    x, y, height: int; submitFun: SubmitSelect) =
   select.open = true
   select.multiple = selectResult.multiple
   select.options = selectResult.options
@@ -70,7 +70,7 @@ func hover(select: Select): int =
 func dispheight(select: Select): int =
   return select.maxh - select.y
 
-proc `hover=`(select: var Select, i: int) =
+proc `hover=`(select: var Select; i: int) =
   let i = clamp(i, 0, select.options.high)
   if i >= select.si + select.dispheight:
     select.si = i - select.dispheight + 1
@@ -156,7 +156,7 @@ proc cursorLastLine*(select: var Select) =
     select.si = max(select.options.len - select.maxh, 0)
     select.redraw = true
 
-proc cursorNextMatch*(select: var Select, regex: Regex, wrap: bool) =
+proc cursorNextMatch*(select: var Select; regex: Regex; wrap: bool) =
   var j = -1
   for i in select.hover + 1 ..< select.options.len:
     if regex.exec(select.options[i]).success:
@@ -174,7 +174,7 @@ proc cursorNextMatch*(select: var Select, regex: Regex, wrap: bool) =
       select.hover = j
       select.redraw = true
 
-proc cursorPrevMatch*(select: var Select, regex: Regex, wrap: bool) =
+proc cursorPrevMatch*(select: var Select; regex: Regex; wrap: bool) =
   var j = -1
   for i in countdown(select.hover - 1, 0):
     if regex.exec(select.options[i]).success:
@@ -195,7 +195,7 @@ proc cursorPrevMatch*(select: var Select, regex: Regex, wrap: bool) =
 proc pushCursorPos*(select: var Select) =
   select.bpos.add(select.hover)
 
-proc popCursorPos*(select: var Select, nojump = false) =
+proc popCursorPos*(select: var Select; nojump = false) =
   select.hover = select.bpos.pop()
   if not nojump:
     select.redraw = true
@@ -207,7 +207,7 @@ const CornerTopRight = $Rune(0x2510)
 const CornerBottomLeft = $Rune(0x2514)
 const CornerBottomRight = $Rune(0x2518)
 
-proc drawBorders(display: var FixedGrid, sx, ex, sy, ey: int,
+proc drawBorders(display: var FixedGrid; sx, ex, sy, ey: int;
     upmore, downmore: bool) =
   for y in sy .. ey:
     var x = 0
@@ -251,7 +251,7 @@ proc drawBorders(display: var FixedGrid, sx, ex, sy, ey: int,
     display[y * display.width + sx].format = fmt
     display[y * display.width + ex].format = fmt
 
-proc drawSelect*(select: Select, display: var FixedGrid) =
+proc drawSelect*(select: Select; display: var FixedGrid) =
   if display.width < 2 or display.height < 2:
     return # border does not fit...
   # Max width, height with one row/column on the sides.
diff --git a/src/local/term.nim b/src/local/term.nim
index cda376aa..eee53039 100644
--- a/src/local/term.nim
+++ b/src/local/term.nim
@@ -96,7 +96,7 @@ const GEOMCELL = CSI(18, "t")
 const XTSHIFTESCAPE = CSI(">0s")
 
 # device control string
-template DCS(a, b: char, s: varargs[string]): string =
+template DCS(a, b: char; s: varargs[string]): string =
   "\eP" & a & b & s.join(';') & "\e\\"
 
 template XTGETTCAP(s: varargs[string, `$`]): string =
@@ -138,21 +138,21 @@ when not termcap_found:
   template ED(): string =
     CSI() & "J"
 
-  proc write(term: Terminal, s: string) =
+  proc write(term: Terminal; s: string) =
     term.outfile.write(s)
 else:
-  func hascap(term: Terminal, c: TermcapCap): bool = term.tc.caps[c] != nil
-  func cap(term: Terminal, c: TermcapCap): string = $term.tc.caps[c]
-  func ccap(term: Terminal, c: TermcapCap): cstring = term.tc.caps[c]
+  func hascap(term: Terminal; c: TermcapCap): bool = term.tc.caps[c] != nil
+  func cap(term: Terminal; c: TermcapCap): string = $term.tc.caps[c]
+  func ccap(term: Terminal; c: TermcapCap): cstring = term.tc.caps[c]
 
   var goutfile: File
   proc putc(c: char): cint {.cdecl.} =
     goutfile.write(c)
 
-  proc write(term: Terminal, s: cstring) =
+  proc write(term: Terminal; s: cstring) =
     discard tputs(s, 1, putc)
 
-  proc write(term: Terminal, s: string) =
+  proc write(term: Terminal; s: string) =
     term.write(cstring(s))
 
 proc readChar*(term: Terminal): char =
@@ -188,7 +188,7 @@ const ANSIColorMap = [
 proc flush*(term: Terminal) =
   term.outfile.flushFile()
 
-proc cursorGoto(term: Terminal, x, y: int): string =
+proc cursorGoto(term: Terminal; x, y: int): string =
   when termcap_found:
     return $tgoto(term.ccap cm, cint(x), cint(y))
   else:
@@ -225,7 +225,7 @@ proc resetFormat(term: Terminal): string =
       return term.cap me
   return SGR()
 
-proc startFormat(term: Terminal, flag: FormatFlags): string =
+proc startFormat(term: Terminal; flag: FormatFlags): string =
   when termcap_found:
     if term.isatty():
       case flag
@@ -237,7 +237,7 @@ proc startFormat(term: Terminal, flag: FormatFlags): string =
       else: discard
   return SGR(FormatCodes[flag].s)
 
-proc endFormat(term: Terminal, flag: FormatFlags): string =
+proc endFormat(term: Terminal; flag: FormatFlags): string =
   when termcap_found:
     if term.isatty():
       case flag
@@ -246,7 +246,7 @@ proc endFormat(term: Terminal, flag: FormatFlags): string =
       else: discard
   return SGR(FormatCodes[flag].e)
 
-proc setCursor*(term: Terminal, x, y: int) =
+proc setCursor*(term: Terminal; x, y: int) =
   term.write(term.cursorGoto(x, y))
 
 proc enableAltScreen(term: Terminal): string =
@@ -264,7 +264,7 @@ proc disableAltScreen(term: Terminal): string =
 func mincontrast(term: Terminal): int32 =
   return term.config.display.minimum_contrast
 
-proc getRGB(a: CellColor, termDefault: RGBColor): RGBColor =
+proc getRGB(a: CellColor; termDefault: RGBColor): RGBColor =
   case a.t
   of ctNone:
     return termDefault
@@ -299,7 +299,7 @@ proc approximateANSIColor(rgb, termDefault: RGBColor): CellColor =
   return if n == -1: defaultColor else: ANSIColor(n).cellColor()
 
 # Return a fgcolor contrasted to the background by term.mincontrast.
-proc correctContrast(term: Terminal, bgcolor, fgcolor: CellColor): CellColor =
+proc correctContrast(term: Terminal; bgcolor, fgcolor: CellColor): CellColor =
   let contrast = term.mincontrast
   let cfgcolor = fgcolor
   let bgcolor = getRGB(bgcolor, term.defaultBackground)
@@ -344,10 +344,10 @@ template eightBitSGR(n: uint8, bgmod: int): string =
   else:
     SGR(38 + bgmod, 5, n)
 
-template rgbSGR(rgb: RGBColor, bgmod: int): string =
+template rgbSGR(rgb: RGBColor; bgmod: int): string =
   SGR(38 + bgmod, 2, rgb.r, rgb.g, rgb.b)
 
-proc processFormat*(term: Terminal, format: var Format, cellf: Format): string =
+proc processFormat*(term: Terminal; format: var Format; cellf: Format): string =
   for flag in FormatFlags:
     if flag in term.formatmode:
       if flag in format.flags and flag notin cellf.flags:
@@ -418,7 +418,7 @@ proc processFormat*(term: Terminal, format: var Format, cellf: Format): string =
     discard # nothing to do
   format = cellf
 
-proc setTitle*(term: Terminal, title: string) =
+proc setTitle*(term: Terminal; title: string) =
   if term.set_title:
     term.outfile.write(XTSETTITLE(title.replaceControls()))
 
@@ -428,7 +428,7 @@ proc enableMouse*(term: Terminal) =
 proc disableMouse*(term: Terminal) =
   term.write(SGRMOUSEBTNOFF)
 
-proc processOutputString*(term: Terminal, str: string, w: var int): string =
+proc processOutputString*(term: Terminal; str: string; w: var int): string =
   if str.validateUTF8Surr() != -1:
     return "?"
   # twidth wouldn't work here, the view may start at the nth character.
@@ -446,7 +446,7 @@ proc processOutputString*(term: Terminal, str: string, w: var int): string =
     var success = false
     return newTextEncoder(term.cs).encodeAll(str, success)
 
-proc generateFullOutput(term: Terminal, grid: FixedGrid): string =
+proc generateFullOutput(term: Terminal; grid: FixedGrid): string =
   var format = Format()
   result &= term.cursorGoto(0, 0)
   result &= term.resetFormat()
@@ -463,7 +463,7 @@ proc generateFullOutput(term: Terminal, grid: FixedGrid): string =
       result &= term.processFormat(format, cell.format)
       result &= term.processOutputString(cell.str, w)
 
-proc generateSwapOutput(term: Terminal, grid, prev: FixedGrid): string =
+proc generateSwapOutput(term: Terminal; grid, prev: FixedGrid): string =
   var vy = -1
   for y in 0 ..< grid.height:
     var w = 0
@@ -518,7 +518,7 @@ func emulateOverline(term: Terminal): bool =
   term.config.display.emulate_overline and
     ffOverline notin term.formatmode and ffUnderline in term.formatmode
 
-proc writeGrid*(term: Terminal, grid: FixedGrid, x = 0, y = 0) =
+proc writeGrid*(term: Terminal; grid: FixedGrid; x = 0, y = 0) =
   for ly in y ..< y + grid.height:
     for lx in x ..< x + grid.width:
       let i = ly * term.canvas.width + lx
@@ -660,7 +660,8 @@ when termcap_found:
       for id in TermcapCapNumeric:
         tc.numCaps[id] = tgetnum(cstring($id))
     else:
-      raise newException(Defect, "Failed to load termcap description for terminal " & term.tname)
+      raise newException(Defect,
+        "Failed to load termcap description for terminal " & term.tname)
 
 type
   QueryAttrs = enum
@@ -676,7 +677,7 @@ type
     width: int
     height: int
 
-proc queryAttrs(term: Terminal, windowOnly: bool): QueryResult =
+proc queryAttrs(term: Terminal; windowOnly: bool): QueryResult =
   const tcapRGB = 0x524742 # RGB supported?
   if not windowOnly:
     const outs =
@@ -698,13 +699,13 @@ proc queryAttrs(term: Terminal, windowOnly: bool): QueryResult =
   while true:
     template consume(term: Terminal): char = term.readChar()
     template fail = return
-    template expect(term: Terminal, c: char) =
+    template expect(term: Terminal; c: char) =
       if term.consume != c:
         fail
-    template expect(term: Terminal, s: string) =
+    template expect(term: Terminal; s: string) =
       for c in s:
         term.expect c
-    template skip_until(term: Terminal, c: char) =
+    template skip_until(term: Terminal; c: char) =
       while (let cc = term.consume; cc != c):
         discard
     term.expect '\e'
@@ -813,7 +814,7 @@ type TermStartResult* = enum
   tsrSuccess, tsrDA1Fail
 
 # when windowOnly, only refresh window size.
-proc detectTermAttributes(term: Terminal, windowOnly: bool): TermStartResult =
+proc detectTermAttributes(term: Terminal; windowOnly: bool): TermStartResult =
   result = tsrSuccess
   term.tname = getEnv("TERM")
   if term.tname == "":
@@ -994,7 +995,7 @@ proc restart*(term: Terminal) =
   if term.set_title:
     term.write(XTPUSHTITLE)
 
-proc newTerminal*(outfile: File, config: Config): Terminal =
+proc newTerminal*(outfile: File; config: Config): Terminal =
   return Terminal(
     outfile: outfile,
     config: config,