From 32abf37be768dd8dc831c5226bb974420c24ffd5 Mon Sep 17 00:00:00 2001 From: bptato Date: Wed, 26 Jul 2023 00:00:54 +0200 Subject: Add suspend() function (bound to C-z) --- doc/config.md | 22 ++++++++++++++++++++-- res/config.toml | 1 + src/display/client.nim | 5 +++++ 3 files changed, 26 insertions(+), 2 deletions(-) diff --git a/doc/config.md b/doc/config.md index ccaa64ab..15b5a071 100644 --- a/doc/config.md +++ b/doc/config.md @@ -498,7 +498,7 @@ escape to the keybinding respectively (essentially making `M-` the same as An action is a JavaScript function called by Chawan every time the keybinding is typed in. A list of built-in pager functions can be found below. -### Pager actions +### Browser actions @@ -508,10 +508,28 @@ is typed in. A list of built-in pager functions can be found below. - + + + + + +
`pager.quit()``quit()` Exit the browser.
`suspend()`Temporarily suspend the browser (by delivering the client process a +SIGSTOP signal.)
+Note: this does not suspend buffer processes. +
+ +### Pager actions + + + + + + + + diff --git a/res/config.toml b/res/config.toml index ae1d5984..4e319652 100644 --- a/res/config.toml +++ b/res/config.toml @@ -37,6 +37,7 @@ substitute-url = '(x) => "https://lite.duckduckgo.com/lite/?kp=-1&kd=-1&q=" + en [page] q = 'quit()' +C-z = 'suspend()' h = 'pager.cursorLeft()' j = 'pager.cursorDown()' k = 'pager.cursorUp()' diff --git a/src/display/client.nim b/src/display/client.nim index a292bf0a..5b961841 100644 --- a/src/display/client.nim +++ b/src/display/client.nim @@ -154,6 +154,11 @@ proc command(client: Client, src: string) = client.console.container.requestLines().then(proc() = client.console.container.cursorLastLine()) +proc suspend(client: Client) {.jsfunc.} = + client.pager.term.quit() + discard kill(getpid(), cint(SIGSTOP)) + client.pager.term.restart() + proc quit(client: Client, code = 0) {.jsfunc.} = if client.alive: client.alive = false -- cgit 1.4.1-2-gfad0
**Name****Function**
`pager.cursorUp()` Move the cursor to the previous line.