summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorbt <bt@rctt.net>2026-02-20 16:04:44 +0100
committerbt <bt@rctt.net>2026-02-24 22:55:48 +0100
commite14493abb20ab0c808f109bb56aaf141ad08d178 (patch)
treefbfed0aae4d4cca733a2ecbcb7fa92c2a35cfeb2
parentcb7001c8d27f22f7229be302f53012bb1db52418 (diff)
downloadplan9port-e14493abb20ab0c808f109bb56aaf141ad08d178.tar.gz
plan9port-e14493abb20ab0c808f109bb56aaf141ad08d178.zip
Custom shortcuts and other minor changespatch
-rw-r--r--include/keyboard-extras.h25
-rw-r--r--src/cmd/acme/cols.c5
-rw-r--r--src/cmd/acme/mkfile2
-rw-r--r--src/cmd/acme/text.c103
-rw-r--r--src/cmd/devdraw/mac-screen.m10
-rw-r--r--src/cmd/devdraw/x11-screen.c23
6 files changed, 153 insertions, 15 deletions
diff --git a/include/keyboard-extras.h b/include/keyboard-extras.h
new file mode 100644
index 00000000..1d99961d
--- /dev/null
+++ b/include/keyboard-extras.h
@@ -0,0 +1,25 @@
+#ifndef _KEYBOARD_EXTRAS_H_
+#define _KEYBOARD_EXTRAS_H_ 1
+
+#if defined(__cplusplus)
+extern "C" {
+#endif
+
+enum {
+ Ketx = 0x03, /* ^C, end of text */
+ Kdc3 = 0x13, /* ^S, device control 3 */
+ Ksyn = 0x16, /* ^V, synchronous idle */
+ Kcan = 0x18, /* ^X, cancel */
+ Keom = 0x19, /* ^Y, end of medium */
+ Ksub = 0x1A, /* ^Z, substitute */
+
+ Kmod4 = 0xF200, /* Mod4 bindings */
+ Ksh = 0xF300, /* Shift modified bindings */
+ Kcret = 0xF400, /* Control + Return */
+};
+
+#if defined(__cplusplus)
+}
+#endif
+
+#endif /* _KEYBOARD_EXTRAS_H_ */ \ No newline at end of file
diff --git a/src/cmd/acme/cols.c b/src/cmd/acme/cols.c
index a53280c4..e28df245 100644
--- a/src/cmd/acme/cols.c
+++ b/src/cmd/acme/cols.c
@@ -14,9 +14,6 @@
static Rune Lheader[] = {
'N', 'e', 'w', ' ',
- 'C', 'u', 't', ' ',
- 'P', 'a', 's', 't', 'e', ' ',
- 'S', 'n', 'a', 'r', 'f', ' ',
'S', 'o', 'r', 't', ' ',
'Z', 'e', 'r', 'o', 'x', ' ',
'D', 'e', 'l', 'c', 'o', 'l', ' ',
@@ -43,7 +40,7 @@ colinit(Column *c, Rectangle r)
r1.min.y = r1.max.y;
r1.max.y += Border;
draw(screen, r1, display->black, nil, ZP);
- textinsert(t, 0, Lheader, 38, TRUE);
+ textinsert(t, 0, Lheader, 22, TRUE);
textsetselect(t, t->file->b.nc, t->file->b.nc);
draw(screen, t->scrollr, colbutton, nil, colbutton->r.min);
c->safe = TRUE;
diff --git a/src/cmd/acme/mkfile b/src/cmd/acme/mkfile
index ba5877c2..85b0d001 100644
--- a/src/cmd/acme/mkfile
+++ b/src/cmd/acme/mkfile
@@ -31,6 +31,8 @@ HFILES=dat.h\
edit.h\
fns.h\
+CFLAGS=$CFLAGS -I../../../include
+
<$PLAN9/src/mkone
<$PLAN9/src/mkdirs
diff --git a/src/cmd/acme/text.c b/src/cmd/acme/text.c
index 09422dda..220dcdf7 100644
--- a/src/cmd/acme/text.c
+++ b/src/cmd/acme/text.c
@@ -12,6 +12,7 @@
#include <complete.h>
#include "dat.h"
#include "fns.h"
+#include "keyboard-extras.h"
Image *tagcols[NCOL];
Image *textcols[NCOL];
@@ -540,7 +541,7 @@ textbswidth(Text *t, Rune c)
int skipping;
/* there is known to be at least one character to erase */
- if(c == 0x08) /* ^H: erase character */
+ if(c == 0x08 || c == Kdel) /* ^H or ^?: erase character */
return 1;
q = t->q0;
skipping = TRUE;
@@ -686,16 +687,44 @@ texttype(Text *t, Rune r)
if(t->q0 > 0)
textshow(t, t->q0-1, t->q0-1, TRUE);
return;
+ case Ksh + Kleft: /* Shift + Left */
+ typecommit(t);
+ if(t->q0 > 0)
+ textshow(t, t->q0-1, t->q1, TRUE);
+ return;
case Kright:
typecommit(t);
if(t->q1 < t->file->b.nc)
textshow(t, t->q1+1, t->q1+1, TRUE);
return;
+ case Ksh + Kright: /* Shift + Right */
+ typecommit(t);
+ if(t->q1 < t->file->b.nc)
+ textshow(t, t->q0, t->q1+1, TRUE);
+ return;
case Kdown:
+ case Ksh + Kdown:
if(t->what == Tag)
goto Tagdown;
- n = t->fr.maxlines/3;
- goto case_Down;
+ typecommit(t);
+ nnb = 0;
+ if(t->q0>0 && textreadc(t, t->q0-1)!='\n')
+ nnb = textbswidth(t, 0x15);
+ q1 = t->q1;
+ while(q1<t->file->b.nc && textreadc(t, q1)!='\n')
+ q1++;
+ if(q1<t->file->b.nc){
+ q1++;
+ while(q1<t->file->b.nc && nnb > 0 && textreadc(t, q1)!='\n') {
+ nnb--;
+ q1++;
+ }
+ if(r == Kdown)
+ textshow(t, q1, q1, TRUE);
+ else /* Shift + Down */
+ textshow(t, t->q0, q1, TRUE);
+ }
+ return;
case Kscrollonedown:
if(t->what == Tag)
goto Tagdown;
@@ -712,8 +741,23 @@ texttype(Text *t, Rune r)
case Kup:
if(t->what == Tag)
goto Tagup;
- n = t->fr.maxlines/3;
- goto case_Up;
+ typecommit(t);
+ nnb = 0;
+ if(t->q0>0 && textreadc(t, t->q0-1)!='\n')
+ nnb = textbswidth(t, 0x15);
+ q0 = t->q0 - nnb;
+ if(q0 > 0){
+ nb = q0;
+ q0--;
+ while(q0 > 0 && textreadc(t, q0-1)!='\n')
+ q0--;
+ q1 = (q0 + nnb >= nb) ? nb - 1 : q0 + nnb;
+ if(r == Kup)
+ textshow(t, q1, q1, TRUE);
+ else /* Shift + Up */
+ textshow(t, q1, t->q1, TRUE);
+ }
+ return;
case Kscrolloneup:
if(t->what == Tag)
goto Tagup;
@@ -753,6 +797,13 @@ texttype(Text *t, Rune r)
nnb = textbswidth(t, 0x15);
textshow(t, t->q0-nnb, t->q0-nnb, TRUE);
return;
+ case Ksh + (Kleft&0x9f): /* Ctrl + Shift + Left */
+ typecommit(t);
+ nnb = 0;
+ if(t->q0>0 && textreadc(t, t->q0-1)!='\n')
+ nnb = textbswidth(t, 0x15);
+ textshow(t, t->q0-nnb, t->q1, TRUE);
+ return;
case 0x05: /* ^E: end of line */
typecommit(t);
q0 = t->q0;
@@ -760,18 +811,41 @@ texttype(Text *t, Rune r)
q0++;
textshow(t, q0, q0, TRUE);
return;
+ case Ksh + (Kright&0x9f): /* Ctrl + Shift + Right */
+ typecommit(t);
+ q1 = t->q1;
+ while(q1<t->file->b.nc && textreadc(t, q1)!='\n')
+ q1++;
+ textshow(t, t->q0, q1, TRUE);
+ return;
case Kcmd+'c': /* %C: copy */
+ case Ketx:
typecommit(t);
cut(t, t, nil, TRUE, FALSE, nil, 0);
return;
case Kcmd+'z': /* %Z: undo */
+ case Ksub:
typecommit(t);
undo(t, nil, nil, TRUE, 0, nil, 0);
return;
case Kcmd+'Z': /* %-shift-Z: redo */
+ case Keom:
typecommit(t);
undo(t, nil, nil, FALSE, 0, nil, 0);
return;
+ case Kdc3: /* ^S: put */
+ case Kcmd+'s':
+ typecommit(t);
+ put(t, nil, nil, XXX, XXX, nil, 0);
+ return;
+ case Kcret: /* Ctrl + Return */
+ typecommit(t);
+ execute(t, t->q0, t->q1, FALSE, nil);
+ return;
+ case Ksh + Kcret: /* Ctrl + Shift + Return */
+ typecommit(t);
+ look3(t, t->q0, t->q1, 0, FALSE);
+ return;
Tagdown:
/* expand tag to show all text */
@@ -797,6 +871,7 @@ texttype(Text *t, Rune r)
/* cut/paste must be done after the seq++/filemark */
switch(r){
case Kcmd+'x': /* %X: cut */
+ case Kcan: /* ^X: cut */
typecommit(t);
if(t->what == Body){
seq++;
@@ -807,6 +882,7 @@ texttype(Text *t, Rune r)
t->iq1 = t->q0;
return;
case Kcmd+'v': /* %V: paste */
+ case Ksyn:
typecommit(t);
if(t->what == Body){
seq++;
@@ -844,6 +920,13 @@ texttype(Text *t, Rune r)
typecommit(t);
t->iq1 = t->q0;
return;
+ case Kdel: /* ^? erase forwards */
+ if(t->q1 == t->file->b.nc) /* nothing to erase */
+ return;
+ nnb = textbswidth(t, r);
+ q0 = t->q1;
+ q1 = q0+nnb;
+ goto Erase;
case 0x08: /* ^H: erase character */
case 0x15: /* ^U: erase line */
case 0x17: /* ^W: erase word */
@@ -859,6 +942,7 @@ texttype(Text *t, Rune r)
}
if(nnb <= 0)
return;
+ Erase:
for(i=0; i<t->file->ntext; i++){
u = t->file->text[i];
u->nofill = TRUE;
@@ -887,6 +971,15 @@ texttype(Text *t, Rune r)
textfill(t->file->text[i]);
t->iq1 = t->q0;
return;
+ case Ksh + Ketx:
+ case Ksh + Kdc3:
+ case Ksh + Ksyn:
+ case Ksh + Kcan:
+ case Ksh + Keom:
+ case Ksh + Ksub:
+ case Ksh + Kdel:
+ r -= Ksh; /* Send control codes without shift modifier */
+ break; /* fall through to insertion */
case '\n':
if(t->w->autoindent){
/* find beginning of previous line using backspace code */
diff --git a/src/cmd/devdraw/mac-screen.m b/src/cmd/devdraw/mac-screen.m
index 6abdee11..c5760ddc 100644
--- a/src/cmd/devdraw/mac-screen.m
+++ b/src/cmd/devdraw/mac-screen.m
@@ -635,15 +635,15 @@ rpc_resizewindow(Client *c, Rectangle r)
x = 0;
if(m & ~omod & NSEventModifierFlagControl)
x = 1;
- if(m & ~omod & NSEventModifierFlagOption)
- x = 2;
if(m & ~omod & NSEventModifierFlagCommand)
+ x = 2;
+ if(m & ~omod & NSEventModifierFlagOption)
x = 4;
b |= x;
if(m & NSEventModifierFlagShift)
b <<= 5;
[self sendmouse:b];
- }else if(m & ~omod & NSEventModifierFlagOption)
+ }else if(m & ~omod & NSEventModifierFlagCommand)
gfx_keystroke(self.client, Kalt);
omod = m;
@@ -700,11 +700,11 @@ rpc_resizewindow(Client *c, Rectangle r)
m = [e modifierFlags];
if(b == 1){
- if(m & NSEventModifierFlagOption){
+ if(m & NSEventModifierFlagCommand){
gfx_abortcompose(self.client);
b = 2;
}else
- if(m & NSEventModifierFlagCommand)
+ if(m & NSEventModifierFlagOption)
b = 4;
}
if(m & NSEventModifierFlagShift)
diff --git a/src/cmd/devdraw/x11-screen.c b/src/cmd/devdraw/x11-screen.c
index 7fa86ddf..8475690b 100644
--- a/src/cmd/devdraw/x11-screen.c
+++ b/src/cmd/devdraw/x11-screen.c
@@ -12,6 +12,7 @@
#include <thread.h>
#include "x11-memdraw.h"
#include "devdraw.h"
+#include "keyboard-extras.h"
#undef time
@@ -1277,12 +1278,32 @@ _xtoplan9kbd(XEvent *e)
if(k == XK_hyphen)
k = XK_minus;
/* Do control mapping ourselves if translator doesn't */
- if(e->xkey.state&ControlMask)
+ if(e->xkey.state&ControlMask) {
k &= 0x9f;
+ if (k == '\n')
+ k = Kcret;
+ }
if(k == NoSymbol) {
return -1;
}
+ /* Mod4 + key */
+ if(e->xkey.state&Mod4Mask)
+ k += Kmod4;
+
+ /* Shift modified bindings */
+ if(e->xkey.state&ShiftMask) {
+ /* Ctrl + Shift + Key, Shift + Left/Right/Delete */
+ if(k == Kleft
+ || k == Kright
+ || k == Kdel
+ || k == Kup
+ || k == Kdown
+ || k == Kcret
+ || e->xkey.state&ControlMask)
+ k += Ksh;
+ }
+
return k+0;
}