Compare commits
8 Commits
Author | SHA1 | Date | |
---|---|---|---|
23051d78dd | |||
e2a280541e | |||
889512811d | |||
84a1bc5d0d | |||
f0a5b75d6a | |||
1cabeda550 | |||
41379f7c39 | |||
64ab2801fb |
@ -1,5 +1,5 @@
|
|||||||
# dmenu version
|
# dmenu version
|
||||||
VERSION = 4.7
|
VERSION = 4.8
|
||||||
|
|
||||||
# paths
|
# paths
|
||||||
PREFIX = /usr/local
|
PREFIX = /usr/local
|
||||||
|
12
dmenu.1
12
dmenu.1
@ -100,6 +100,12 @@ Confirm input. Prints the input text to stdout and exits, returning success.
|
|||||||
.B Escape
|
.B Escape
|
||||||
Exit without selecting an item, returning failure.
|
Exit without selecting an item, returning failure.
|
||||||
.TP
|
.TP
|
||||||
|
.B Ctrl-Left
|
||||||
|
Move cursor to the start of the current word
|
||||||
|
.TP
|
||||||
|
.B Ctrl-Right
|
||||||
|
Move cursor to the end of the current word
|
||||||
|
.TP
|
||||||
C\-a
|
C\-a
|
||||||
Home
|
Home
|
||||||
.TP
|
.TP
|
||||||
@ -160,6 +166,12 @@ Paste from primary X selection
|
|||||||
C\-Y
|
C\-Y
|
||||||
Paste from X clipboard
|
Paste from X clipboard
|
||||||
.TP
|
.TP
|
||||||
|
M\-b
|
||||||
|
Move cursor to the start of the current word
|
||||||
|
.TP
|
||||||
|
M\-f
|
||||||
|
Move cursor to the end of the current word
|
||||||
|
.TP
|
||||||
M\-g
|
M\-g
|
||||||
Home
|
Home
|
||||||
.TP
|
.TP
|
||||||
|
53
dmenu.c
53
dmenu.c
@ -287,6 +287,22 @@ nextrune(int inc)
|
|||||||
return n;
|
return n;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static void
|
||||||
|
movewordedge(int dir)
|
||||||
|
{
|
||||||
|
if (dir < 0) { /* move cursor to the start of the word*/
|
||||||
|
while (cursor > 0 && strchr(worddelimiters, text[nextrune(-1)]))
|
||||||
|
cursor = nextrune(-1);
|
||||||
|
while (cursor > 0 && !strchr(worddelimiters, text[nextrune(-1)]))
|
||||||
|
cursor = nextrune(-1);
|
||||||
|
} else { /* move cursor to the end of the word */
|
||||||
|
while (text[cursor] && strchr(worddelimiters, text[cursor]))
|
||||||
|
cursor = nextrune(+1);
|
||||||
|
while (text[cursor] && !strchr(worddelimiters, text[cursor]))
|
||||||
|
cursor = nextrune(+1);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
keypress(XKeyEvent *ev)
|
keypress(XKeyEvent *ev)
|
||||||
{
|
{
|
||||||
@ -334,6 +350,14 @@ keypress(XKeyEvent *ev)
|
|||||||
XConvertSelection(dpy, (ev->state & ShiftMask) ? clip : XA_PRIMARY,
|
XConvertSelection(dpy, (ev->state & ShiftMask) ? clip : XA_PRIMARY,
|
||||||
utf8, utf8, win, CurrentTime);
|
utf8, utf8, win, CurrentTime);
|
||||||
return;
|
return;
|
||||||
|
case XK_Left:
|
||||||
|
movewordedge(-1);
|
||||||
|
ksym = NoSymbol;
|
||||||
|
break;
|
||||||
|
case XK_Right:
|
||||||
|
movewordedge(+1);
|
||||||
|
ksym = NoSymbol;
|
||||||
|
break;
|
||||||
case XK_Return:
|
case XK_Return:
|
||||||
case XK_KP_Enter:
|
case XK_KP_Enter:
|
||||||
break;
|
break;
|
||||||
@ -345,6 +369,14 @@ keypress(XKeyEvent *ev)
|
|||||||
}
|
}
|
||||||
else if (ev->state & Mod1Mask)
|
else if (ev->state & Mod1Mask)
|
||||||
switch(ksym) {
|
switch(ksym) {
|
||||||
|
case XK_b:
|
||||||
|
movewordedge(-1);
|
||||||
|
ksym = NoSymbol;
|
||||||
|
break;
|
||||||
|
case XK_f:
|
||||||
|
movewordedge(+1);
|
||||||
|
ksym = NoSymbol;
|
||||||
|
break;
|
||||||
case XK_g: ksym = XK_Home; break;
|
case XK_g: ksym = XK_Home; break;
|
||||||
case XK_G: ksym = XK_End; break;
|
case XK_G: ksym = XK_End; break;
|
||||||
case XK_h: ksym = XK_Up; break;
|
case XK_h: ksym = XK_Up; break;
|
||||||
@ -359,6 +391,8 @@ keypress(XKeyEvent *ev)
|
|||||||
if (!iscntrl(*buf))
|
if (!iscntrl(*buf))
|
||||||
insert(buf, len);
|
insert(buf, len);
|
||||||
break;
|
break;
|
||||||
|
case NoSymbol:
|
||||||
|
break;
|
||||||
case XK_Delete:
|
case XK_Delete:
|
||||||
if (text[cursor] == '\0')
|
if (text[cursor] == '\0')
|
||||||
return;
|
return;
|
||||||
@ -467,10 +501,12 @@ paste(void)
|
|||||||
Atom da;
|
Atom da;
|
||||||
|
|
||||||
/* we have been given the current selection, now insert it into input */
|
/* we have been given the current selection, now insert it into input */
|
||||||
XGetWindowProperty(dpy, win, utf8, 0, (sizeof text / 4) + 1, False,
|
if (XGetWindowProperty(dpy, win, utf8, 0, (sizeof text / 4) + 1, False,
|
||||||
utf8, &da, &di, &dl, &dl, (unsigned char **)&p);
|
utf8, &da, &di, &dl, &dl, (unsigned char **)&p)
|
||||||
|
== Success && p) {
|
||||||
insert(p, (q = strchr(p, '\n')) ? q - p : (ssize_t)strlen(p));
|
insert(p, (q = strchr(p, '\n')) ? q - p : (ssize_t)strlen(p));
|
||||||
XFree(p);
|
XFree(p);
|
||||||
|
}
|
||||||
drawmenu();
|
drawmenu();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -539,22 +575,21 @@ run(void)
|
|||||||
static void
|
static void
|
||||||
setup(void)
|
setup(void)
|
||||||
{
|
{
|
||||||
int x, y, i = 0;
|
int x, y, i, j;
|
||||||
unsigned int du;
|
unsigned int du;
|
||||||
XSetWindowAttributes swa;
|
XSetWindowAttributes swa;
|
||||||
XIM xim;
|
XIM xim;
|
||||||
Window w, dw, *dws;
|
Window w, dw, *dws;
|
||||||
XWindowAttributes wa;
|
XWindowAttributes wa;
|
||||||
|
XClassHint ch = {"dmenu", "dmenu"};
|
||||||
#ifdef XINERAMA
|
#ifdef XINERAMA
|
||||||
XineramaScreenInfo *info;
|
XineramaScreenInfo *info;
|
||||||
Window pw;
|
Window pw;
|
||||||
int a, j, di, n, area = 0;
|
int a, di, n, area = 0;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
/* init appearance */
|
/* init appearance */
|
||||||
scheme[SchemeNorm] = drw_scm_create(drw, colors[SchemeNorm], 2);
|
for (j = 0; j < SchemeLast; j++)
|
||||||
scheme[SchemeSel] = drw_scm_create(drw, colors[SchemeSel], 2);
|
scheme[j] = drw_scm_create(drw, colors[j], 2);
|
||||||
scheme[SchemeOut] = drw_scm_create(drw, colors[SchemeOut], 2);
|
|
||||||
|
|
||||||
clip = XInternAtom(dpy, "CLIPBOARD", False);
|
clip = XInternAtom(dpy, "CLIPBOARD", False);
|
||||||
utf8 = XInternAtom(dpy, "UTF8_STRING", False);
|
utf8 = XInternAtom(dpy, "UTF8_STRING", False);
|
||||||
@ -564,6 +599,7 @@ setup(void)
|
|||||||
lines = MAX(lines, 0);
|
lines = MAX(lines, 0);
|
||||||
mh = (lines + 1) * bh;
|
mh = (lines + 1) * bh;
|
||||||
#ifdef XINERAMA
|
#ifdef XINERAMA
|
||||||
|
i = 0;
|
||||||
if (parentwin == root && (info = XineramaQueryScreens(dpy, &n))) {
|
if (parentwin == root && (info = XineramaQueryScreens(dpy, &n))) {
|
||||||
XGetInputFocus(dpy, &w, &di);
|
XGetInputFocus(dpy, &w, &di);
|
||||||
if (mon >= 0 && mon < n)
|
if (mon >= 0 && mon < n)
|
||||||
@ -613,6 +649,7 @@ setup(void)
|
|||||||
win = XCreateWindow(dpy, parentwin, x, y, mw, mh, 0,
|
win = XCreateWindow(dpy, parentwin, x, y, mw, mh, 0,
|
||||||
CopyFromParent, CopyFromParent, CopyFromParent,
|
CopyFromParent, CopyFromParent, CopyFromParent,
|
||||||
CWOverrideRedirect | CWBackPixel | CWEventMask, &swa);
|
CWOverrideRedirect | CWBackPixel | CWEventMask, &swa);
|
||||||
|
XSetClassHint(dpy, win, &ch);
|
||||||
|
|
||||||
/* open input methods */
|
/* open input methods */
|
||||||
xim = XOpenIM(dpy, NULL, NULL, NULL);
|
xim = XOpenIM(dpy, NULL, NULL, NULL);
|
||||||
|
2
drw.c
2
drw.c
@ -200,7 +200,7 @@ drw_scm_create(Drw *drw, const char *clrnames[], size_t clrcount)
|
|||||||
Clr *ret;
|
Clr *ret;
|
||||||
|
|
||||||
/* need at least two colors for a scheme */
|
/* need at least two colors for a scheme */
|
||||||
if (!drw || !clrnames || clrcount < 2 || !(ret = ecalloc(clrcount, sizeof(XftColor))))
|
if (!drw || !clrnames || clrcount < 2 || !(ret = ecalloc(clrcount, sizeof(Clr))))
|
||||||
return NULL;
|
return NULL;
|
||||||
|
|
||||||
for (i = 0; i < clrcount; i++)
|
for (i = 0; i < clrcount; i++)
|
||||||
|
Reference in New Issue
Block a user