aboutsummaryrefslogtreecommitdiff
path: root/xP
diff options
context:
space:
mode:
Diffstat (limited to 'xP')
-rw-r--r--xP/public/xP.js29
1 files changed, 29 insertions, 0 deletions
diff --git a/xP/public/xP.js b/xP/public/xP.js
index 71c1b6e..aa2c39a 100644
--- a/xP/public/xP.js
+++ b/xP/public/xP.js
@@ -742,6 +742,33 @@ let Input = {
return true
},
+ backward: (b, textarea) => {
+ if (textarea.selectionStart !== textarea.selectionEnd)
+ return false
+
+ let point = textarea.selectionStart
+ if (point < 1)
+ return false
+ while (point && /\s/.test(textarea.value.charAt(--point))) {}
+ while (point-- && !/\s/.test(textarea.value.charAt(point))) {}
+ point++
+ textarea.setSelectionRange(point, point)
+ return true
+ },
+
+ forward: (b, textarea) => {
+ if (textarea.selectionStart !== textarea.selectionEnd)
+ return false
+
+ let point = textarea.selectionStart, len = textarea.value.length
+ if (point + 1 > len)
+ return false
+ while (point < len && /\s/.test(textarea.value.charAt(point))) point++
+ while (point < len && !/\s/.test(textarea.value.charAt(point))) point++
+ textarea.setSelectionRange(point, point)
+ return true
+ },
+
first: (b, textarea) => {
if (b.historyAt <= 0)
return false
@@ -796,6 +823,8 @@ let Input = {
if (hasShortcutModifiers(event)) {
handled = true
switch (event.key) {
+ case 'b': success = Input.backward(b, textarea); break
+ case 'f': success = Input.forward(b, textarea); break
case '<': success = Input.first(b, textarea); break
case '>': success = Input.last(b, textarea); break
case 'p': success = Input.previous(b, textarea); break