changeset: 602:84b4ce1a6621
tag: tip
user: Connor Lane Smith <cls_AT_lubutu.com>
date: Tue Aug 03 18:08:59 2010 +0100
files: tools.suckless.org/dmenu/dmenu-tip-cursor.diff tools.suckless.org/dmenu/index.md tools.suckless.org/dmenu/patches/cursor.md tools.suckless.org/dmenu/patches/dmenu-tip-cursor.diff tools.suckless.org/dmenu/patches/dmenu-tip-paste.diff tools.suckless.org/dmenu/patches/paste.md tools.suckless.org/dmenu/patches/vertical.md
description:
updated dmenu description & cleaned tip patches
diff -r 275796b5093a -r 84b4ce1a6621 tools.suckless.org/dmenu/dmenu-tip-cursor.diff
--- a/tools.suckless.org/dmenu/dmenu-tip-cursor.diff Sat Jul 31 11:37:42 2010 -0700
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
_AT_@ -1,159 +0,0 @@
-diff -r 9b203c5c180d dmenu.c
---- a/dmenu.c Sat Apr 18 12:50:12 2009 +0100
-+++ b/dmenu.c Sun Nov 08 12:58:13 2009 +0100
-_AT_@ -18,6 +18,7 @@
- #define CLEANMASK(mask) (mask & ~(numlockmask | LockMask))
- #define INRECT(X,Y,RX,RY,RW,RH) ((X) >= (RX) && (X) < (RX) + (RW) && (Y) >= (RY) && (Y) < (RY) + (RH))
- #define MIN(a, b) ((a) < (b) ? (a) : (b))
-+#define MAX(a, b) ((a) > (b) ? (a) : (b))
-
- /* enums */
- enum { ColFG, ColBG, ColLast };
-_AT_@ -73,6 +74,7 @@
- static int cmdw = 0;
- static int promptw = 0;
- static int ret = 0;
-+static int cursor = 0;
- static int screen;
- static unsigned int mw, mh;
- static unsigned int numlockmask = 0;
-_AT_@ -171,6 +173,16 @@
- }
-
- void
-+drawcursor(void) {
-+ XRectangle r = { dc.x, dc.y + 2, 1, dc.h - 4 };
-+
-+ r.x += textnw(text, cursor) + dc.font.height / 2;
-+
-+ XSetForeground(dpy, dc.gc, dc.norm[ColFG]);
-+ XFillRectangles(dpy, dc.drawable, dc.gc, &r, 1);
-+}
-+
-+void
- drawmenu(void) {
- Item *i;
-
-_AT_@ -190,6 +202,7 @@
- if(cmdw && item)
- dc.w = cmdw;
- drawtext(text[0] ? text : NULL, dc.norm);
-+ drawcursor();
- dc.x += cmdw;
- if(curr) {
- dc.w = spaceitem;
-_AT_@ -331,8 +344,6 @@
- /* first check if a control mask is omitted */
- if(e->state & ControlMask) {
- switch (ksym) {
-- default: /* ignore other control sequences */
-- return;
- case XK_bracketleft:
- ksym = XK_Escape;
- break;
-_AT_@ -353,7 +364,7 @@
- text[0] = 0;
- match(text);
- drawmenu();
-- return;
-+ break;
- case XK_w:
- case XK_W:
- if(len) {
-_AT_@ -365,12 +376,11 @@
- match(text);
- drawmenu();
- }
-- return;
-+ break;
- }
- }
- if(CLEANMASK(e->state) & Mod1Mask) {
- switch(ksym) {
-- default: return;
- case XK_h:
- ksym = XK_Left;
- break;
-_AT_@ -393,15 +403,17 @@
- }
- switch(ksym) {
- default:
-- if(num && !iscntrl((int) buf[0])) {
-- buf[num] = 0;
-- strncpy(text + len, buf, sizeof text - len);
-+ if(num && !iscntrl((int) buf[0]) && num + strlen(text) < sizeof text) {
-+ memmove(text + cursor + num, text + cursor, sizeof text - cursor);
-+ memcpy(text + cursor, buf, num);
-+ cursor+=num;
- match(text);
- }
- break;
- case XK_BackSpace:
-- if(len) {
-- text[--len] = 0;
-+ if(cursor > 0) {
-+ memmove(text + cursor + -1, text + cursor, sizeof text - cursor);
-+ cursor--;
- match(text);
- }
- break;
-_AT_@ -426,13 +438,17 @@
- calcoffsets();
- break;
- case XK_Left:
-- if(!(sel && sel->left))
-+ if(sel && sel->left){
-+ sel=sel->left;
-+ if(sel->right == curr) {
-+ curr = prev;
-+ calcoffsets();
-+ }
-+ }
-+ else if(cursor > 0)
-+ cursor--;
-+ else
- return;
-- sel=sel->left;
-- if(sel->right == curr) {
-- curr = prev;
-- calcoffsets();
-- }
- break;
- case XK_Next:
- if(!next)
-_AT_@ -457,21 +473,29 @@
- running = False;
- break;
- case XK_Right:
-- if(!(sel && sel->right))
-+ if(cursor < len)
-+ cursor++;
-+ else if(sel && sel->right) {
-+ sel=sel->right;
-+ if(sel == next) {
-+ curr = next;
-+ calcoffsets();
-+ }
-+ }
-+ else
- return;
-- sel=sel->right;
-- if(sel == next) {
-- curr = next;
-- calcoffsets();
-- }
- break;
- case XK_Tab:
- if(!sel)
- return;
- strncpy(text, sel->text, sizeof text);
-+ cursor = strlen(text);
- match(text);
- break;
- }
-+ len = strlen(text);
-+ cursor = MIN(cursor, len);
-+ cursor = MAX(cursor, 0);
- drawmenu();
- }
-
diff -r 275796b5093a -r 84b4ce1a6621 tools.suckless.org/dmenu/index.md
--- a/tools.suckless.org/dmenu/index.md Sat Jul 31 11:37:42 2010 -0700
+++ b/tools.suckless.org/dmenu/index.md Tue Aug 03 18:08:59 2010 +0100
_AT_@ -1,8 +1,9 @@
DMENU
=====
-dynamic menu is a generic menu for X, originally designed for [dwm](
http://dwm.suckless.org/).
-It manages huge amounts (up to 10,000 and more) of user defined menu items efficiently.
+dmenu is a dynamic menu for X, originally designed for
+[dwm](
http://dwm.suckless.org/). It manages large numbers of user-defined menu
+items efficiently.
Download
diff -r 275796b5093a -r 84b4ce1a6621 tools.suckless.org/dmenu/patches/cursor.md
--- a/tools.suckless.org/dmenu/patches/cursor.md Sat Jul 31 11:37:42 2010 -0700
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
_AT_@ -1,11 +0,0 @@
-CURSOR HANDLING
-===============
-
-This patch implements extended text editing.
-
-Download
---------
-
-* [dmenu-tip-cursor.diff](dmenu-tip-cursor.diff)
-
-***Note, this patch is being accepted for mainstream dmenu and in hg tip.***
diff -r 275796b5093a -r 84b4ce1a6621 tools.suckless.org/dmenu/patches/dmenu-tip-cursor.diff
--- a/tools.suckless.org/dmenu/patches/dmenu-tip-cursor.diff Sat Jul 31 11:37:42 2010 -0700
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
_AT_@ -1,142 +0,0 @@
-diff -r 9b203c5c180d dmenu.c
---- a/dmenu.c Sat Apr 18 12:50:12 2009 +0100
-+++ b/dmenu.c Sun Nov 08 12:48:53 2009 +0100
-_AT_@ -18,6 +18,7 @@
- #define CLEANMASK(mask) (mask & ~(numlockmask | LockMask))
- #define INRECT(X,Y,RX,RY,RW,RH) ((X) >= (RX) && (X) < (RX) + (RW) && (Y) >= (RY) && (Y) < (RY) + (RH))
- #define MIN(a, b) ((a) < (b) ? (a) : (b))
-+#define MAX(a, b) ((a) > (b) ? (a) : (b))
-
- /* enums */
- enum { ColFG, ColBG, ColLast };
-_AT_@ -73,6 +74,7 @@
- static int cmdw = 0;
- static int promptw = 0;
- static int ret = 0;
-+static int cursor = 0;
- static int screen;
- static unsigned int mw, mh;
- static unsigned int numlockmask = 0;
-_AT_@ -171,6 +173,16 @@
- }
-
- void
-+drawcursor(void) {
-+ XRectangle r = { dc.x, dc.y + 2, 1, dc.h - 4 };
-+
-+ r.x += textnw(text, cursor) + dc.font.height / 2;
-+
-+ XSetForeground(dpy, dc.gc, dc.norm[ColFG]);
-+ XFillRectangles(dpy, dc.drawable, dc.gc, &r, 1);
-+}
-+
-+void
- drawmenu(void) {
- Item *i;
-
-_AT_@ -190,6 +202,7 @@
- if(cmdw && item)
- dc.w = cmdw;
- drawtext(text[0] ? text : NULL, dc.norm);
-+ drawcursor();
- dc.x += cmdw;
- if(curr) {
- dc.w = spaceitem;
-_AT_@ -353,7 +366,7 @@
- text[0] = 0;
- match(text);
- drawmenu();
-- return;
-+ break;
- case XK_w:
- case XK_W:
- if(len) {
-_AT_@ -365,7 +378,7 @@
- match(text);
- drawmenu();
- }
-- return;
-+ break;
- }
- }
- if(CLEANMASK(e->state) & Mod1Mask) {
-_AT_@ -395,13 +408,16 @@
- default:
- if(num && !iscntrl((int) buf[0])) {
- buf[num] = 0;
-- strncpy(text + len, buf, sizeof text - len);
-+ memmove(text + cursor + num, text + cursor, sizeof text - cursor);
-+ strncpy(text + cursor, buf, sizeof text - cursor);
-+ cursor+=num;
- match(text);
- }
- break;
- case XK_BackSpace:
-- if(len) {
-- text[--len] = 0;
-+ if(cursor > 0) {
-+ memmove(text + cursor + -1, text + cursor, sizeof text - cursor);
-+ cursor--;
- match(text);
- }
- break;
-_AT_@ -426,13 +442,17 @@
- calcoffsets();
- break;
- case XK_Left:
-- if(!(sel && sel->left))
-+ if(sel && sel->left){
-+ sel=sel->left;
-+ if(sel->right == curr) {
-+ curr = prev;
-+ calcoffsets();
-+ }
-+ }
-+ else if(cursor > 0)
-+ cursor--;
-+ else
- return;
-- sel=sel->left;
-- if(sel->right == curr) {
-- curr = prev;
-- calcoffsets();
-- }
- break;
- case XK_Next:
- if(!next)
-_AT_@ -457,21 +477,29 @@
- running = False;
- break;
- case XK_Right:
-- if(!(sel && sel->right))
-+ if(cursor < len)
-+ cursor++;
-+ else if(sel && sel->right) {
-+ sel=sel->right;
-+ if(sel == next) {
-+ curr = next;
-+ calcoffsets();
-+ }
-+ }
-+ else
- return;
-- sel=sel->right;
-- if(sel == next) {
-- curr = next;
-- calcoffsets();
-- }
- break;
- case XK_Tab:
- if(!sel)
- return;
- strncpy(text, sel->text, sizeof text);
-+ cursor = strlen(text);
- match(text);
- break;
- }
-+ len = strlen(text);
-+ cursor = MIN(cursor, len);
-+ cursor = MAX(cursor, 0);
- drawmenu();
- }
-
diff -r 275796b5093a -r 84b4ce1a6621 tools.suckless.org/dmenu/patches/dmenu-tip-paste.diff
--- a/tools.suckless.org/dmenu/patches/dmenu-tip-paste.diff Sat Jul 31 11:37:42 2010 -0700
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
_AT_@ -1,27 +0,0 @@
-diff -r 67d8f41d51d7 dmenu.c
---- a/dmenu.c Fri Jul 02 06:49:05 2010 +0100
-+++ b/dmenu.c Tue Jul 06 18:38:42 2010 -0500
-_AT_@ -254,6 +254,23 @@
- text[++i] = '\0';
- match();
- break;
-+ case XK_p:
-+ {
-+ FILE *fp;
-+ char *c;
-+ if(!(fp = (FILE*)popen("sselp", "r")))
-+ fprintf(stderr, "dmenu: Could not popen sselp\n");
-+ c = fgets(text + len, sizeof(text) - len, fp);
-+ pclose(fp);
-+ if(c == NULL)
-+ return;
-+ }
-+ len = strlen(text);
-+ if(len && text[len-1] == '\n')
-+ text[--len] = '\0';
-+ match();
-+ drawbar();
-+ return;
- }
- }
- switch(ksym) {
diff -r 275796b5093a -r 84b4ce1a6621 tools.suckless.org/dmenu/patches/paste.md
--- a/tools.suckless.org/dmenu/patches/paste.md Sat Jul 31 11:37:42 2010 -0700
+++ b/tools.suckless.org/dmenu/patches/paste.md Tue Aug 03 18:08:59 2010 +0100
_AT_@ -13,7 +13,6 @@
--------
* [dmenu-4.0-paste.diff](dmenu-4.0-paste.diff) (597) (20091029)
-* [dmenu-tip-paste.diff](dmenu-tip-paste.diff) (594) (20100706)
Author
------
_AT_@ -21,4 +20,4 @@
* Evan Gates (emg) <[evan.gates_AT_gmail.com](mailto:evan.gates_AT_gmail.com)>
-***Note, this patch is being accepted for mainstream dmenu and in hg tip.***
+***Note, this patch is present in dmenu-4.1.1.***
diff -r 275796b5093a -r 84b4ce1a6621 tools.suckless.org/dmenu/patches/vertical.md
--- a/tools.suckless.org/dmenu/patches/vertical.md Sat Jul 31 11:37:42 2010 -0700
+++ b/tools.suckless.org/dmenu/patches/vertical.md Tue Aug 03 18:08:59 2010 +0100
_AT_@ -11,4 +11,4 @@
* [dmenu-4.0-vertical_meillo.diff](dmenu-4.0-vertical_meillo.diff)
-***Note, this patch is being accepted for mainstream dmenu and in hg tip.***
+***Note, this patch is present in dmenu-4.1.1.***
Received on Tue Aug 03 2010 - 19:09:01 CEST