diff options
author | bptato <nincsnevem662@gmail.com> | 2023-12-03 01:17:03 +0100 |
---|---|---|
committer | bptato <nincsnevem662@gmail.com> | 2023-12-03 01:31:07 +0100 |
commit | 7728bad57be566bd86327dc843f8b950d538a2f0 (patch) | |
tree | f60c5dfa2eacf5db556d9f15c218ae438a42b19f /res | |
parent | b91b64a2d54404c4ead09093c25e0002fbab1881 (diff) | |
download | chawan-7728bad57be566bd86327dc843f8b950d538a2f0.tar.gz |
pager, container: add text selection/copying
* Add select & copy selection functionality to container * Fix bug in generateSwapOutput where output could be misplaced because of zero-width cells * Add fromJSPromise, call runJSJobs in every iteration of the headed event loop * "await" pager actions that output a promise * Change default view source keybinding to `\'
Diffstat (limited to 'res')
-rw-r--r-- | res/chawan.html | 5 | ||||
-rw-r--r-- | res/config.toml | 19 |
2 files changed, 22 insertions, 2 deletions
diff --git a/res/chawan.html b/res/chawan.html index fcd054ff..271e3e6b 100644 --- a/res/chawan.html +++ b/res/chawan.html @@ -50,6 +50,9 @@ on your environment, the <kbd>Meta</kbd> key may be called <kbd>Alt</kbd> or up/down by one row <li><kbd>C-l</kbd>: location bar (to enter a URL, etc.) <li><kbd>C-k</kbd>: web search +<li><kbd>v</kbd>, <kbd>V</kbd>, <kbd>C-v</kbd>: select (normal), select +(line), select (block) +<li><kbd>y</kbd>: yank (copy) current selection to system clipboard (needs xsel) <li><kbd>U</kbd>: reload page <li><kbd>,</kbd> (comma), <kbd>.</kbd> (period): previous/next buffer <li><kbd>D</kbd>: discard current buffer @@ -75,7 +78,7 @@ beginning) <li><kbd>zb</kbd>, <kbd>zC-m</kbd>: center on current line (and move to beginning) <li><kbd>w</kbd>, <kbd>b</kbd>: move cursor to next/previous word -<li><kbd>v</kbd>: toggle page source view +<li><kbd>\</kbd>: toggle page source view <li><kbd>0</kbd>: cursor to first cell on line <li><kbd>^</kbd>: cursor to first non-whitespace on line <li><kbd>$</kbd>: cursor to last character on line diff --git a/res/config.toml b/res/config.toml index f821d694..a263fcb7 100644 --- a/res/config.toml +++ b/res/config.toml @@ -132,7 +132,24 @@ zz = 'n => pager.centerLine(n)' 'z+' = 'n => pager.nextPageBegin(n)' 'z^' = 'n => pager.previousPageBegin(n)' C-g = 'pager.lineInfo()' -v = 'pager.toggleSource()' +v = 'n => pager.cursorToggleSelection(n)' +V = 'n => pager.cursorToggleSelection(n, {selectionType: "line"})' +C-v = 'n => pager.cursorToggleSelection(n, {selectionType: "block"})' +y = ''' +async () => { + if (!pager.currentSelection) { + pager.alert("No selection to yank."); + return; + } + const text = await pager.getSelectionText(pager.currentSelection); + if (pager.externInto('xsel -bi', text)) + pager.alert("Copied selection to clipboard."); + else + pager.alert("Failed to copy selection to clipboard. (Is xsel installed?)"); + pager.cursorToggleSelection(); +} +''' +'\' = 'pager.toggleSource()' D = 'pager.discardBuffer()' M-d = 'pager.discardTree()' ',' = 'pager.prevBuffer()' |