diff options
author | Connor Lane Smith <cls@lubutu.com> | 2010-08-20 13:50:44 +0100 |
---|---|---|
committer | Connor Lane Smith <cls@lubutu.com> | 2010-08-20 13:50:44 +0100 |
commit | b81c1e88cdf637e184c5733c87a728df8471fe4e (patch) | |
tree | 69828a1a2efa9f3c49592836e68e3feb9b4f70aa | |
parent | 53761130390f517a9d750759fc80b9148b1b176f (diff) |
rebound paste, removed useless max widths
-rw-r--r-- | dmenu.1 | 4 | ||||
-rw-r--r-- | dmenu.c | 15 |
2 files changed, 10 insertions, 9 deletions
@@ -55,7 +55,7 @@ dmenu lists items vertically, with the given number of lines. | |||
55 | defines the prompt to be displayed to the left of the input field. | 55 | defines the prompt to be displayed to the left of the input field. |
56 | .TP | 56 | .TP |
57 | .BI \-fn " font" | 57 | .BI \-fn " font" |
58 | defines the font set used. | 58 | defines the font or font set used. |
59 | .TP | 59 | .TP |
60 | .BI \-nb " color" | 60 | .BI \-nb " color" |
61 | defines the normal background color. | 61 | defines the normal background color. |
@@ -93,7 +93,7 @@ success. | |||
93 | .B Escape (Control\-c) | 93 | .B Escape (Control\-c) |
94 | Exit without selecting an item, returning failure. | 94 | Exit without selecting an item, returning failure. |
95 | .TP | 95 | .TP |
96 | .B Control\-y | 96 | .B Shift\-Insert |
97 | Paste the current X selection into the input field. | 97 | Paste the current X selection into the input field. |
98 | .SH SEE ALSO | 98 | .SH SEE ALSO |
99 | .BR dwm (1) | 99 | .BR dwm (1) |
@@ -83,10 +83,10 @@ calcoffsets(void) { | |||
83 | n = mw - (promptw + inputw + dc_textw(dc, "<") + dc_textw(dc, ">")); | 83 | n = mw - (promptw + inputw + dc_textw(dc, "<") + dc_textw(dc, ">")); |
84 | 84 | ||
85 | for(i = 0, next = curr; next; next = next->right) | 85 | for(i = 0, next = curr; next; next = next->right) |
86 | if((i += (lines > 0) ? bh : MIN(dc_textw(dc, next->text), mw/3)) > n) | 86 | if((i += (lines > 0) ? bh : dc_textw(dc, next->text)) > n) |
87 | break; | 87 | break; |
88 | for(i = 0, prev = curr; prev && prev->left; prev = prev->left) | 88 | for(i = 0, prev = curr; prev && prev->left; prev = prev->left) |
89 | if((i += (lines > 0) ? bh : MIN(dc_textw(dc, prev->left->text), mw/3)) > n) | 89 | if((i += (lines > 0) ? bh : dc_textw(dc, prev->left->text)) > n) |
90 | break; | 90 | break; |
91 | } | 91 | } |
92 | 92 | ||
@@ -124,7 +124,7 @@ drawmenu(void) { | |||
124 | dc_drawtext(dc, "<", normcol); | 124 | dc_drawtext(dc, "<", normcol); |
125 | for(item = curr; item != next; item = item->right) { | 125 | for(item = curr; item != next; item = item->right) { |
126 | dc->x += dc->w; | 126 | dc->x += dc->w; |
127 | dc->w = MIN(dc_textw(dc, item->text), mw/3); | 127 | dc->w = dc_textw(dc, item->text); |
128 | dc_drawtext(dc, item->text, (item == sel) ? selcol : normcol); | 128 | dc_drawtext(dc, item->text, (item == sel) ? selcol : normcol); |
129 | } | 129 | } |
130 | dc->w = dc_textw(dc, ">"); | 130 | dc->w = dc_textw(dc, ">"); |
@@ -226,9 +226,6 @@ keypress(XKeyEvent *ev) { | |||
226 | while(cursor > 0 && text[nextrune(-1)] != ' ') | 226 | while(cursor > 0 && text[nextrune(-1)] != ' ') |
227 | insert(NULL, nextrune(-1) - cursor); | 227 | insert(NULL, nextrune(-1) - cursor); |
228 | break; | 228 | break; |
229 | case XK_y: /* paste selection */ | ||
230 | XConvertSelection(dc->dpy, XA_PRIMARY, utf8, utf8, win, CurrentTime); | ||
231 | return; | ||
232 | } | 229 | } |
233 | } | 230 | } |
234 | switch(ksym) { | 231 | switch(ksym) { |
@@ -266,6 +263,10 @@ keypress(XKeyEvent *ev) { | |||
266 | sel = curr = matches; | 263 | sel = curr = matches; |
267 | calcoffsets(); | 264 | calcoffsets(); |
268 | break; | 265 | break; |
266 | case XK_Insert: /* paste selection */ | ||
267 | if(ev->state & ShiftMask) | ||
268 | XConvertSelection(dc->dpy, XA_PRIMARY, utf8, utf8, win, CurrentTime); | ||
269 | return; | ||
269 | case XK_Left: | 270 | case XK_Left: |
270 | if(cursor > 0 && (!sel || !sel->left || lines > 0)) { | 271 | if(cursor > 0 && (!sel || !sel->left || lines > 0)) { |
271 | cursor = nextrune(-1); | 272 | cursor = nextrune(-1); |
@@ -480,7 +481,7 @@ setup(void) { | |||
480 | grabkeyboard(); | 481 | grabkeyboard(); |
481 | dc_resize(dc, mw, mh); | 482 | dc_resize(dc, mw, mh); |
482 | inputw = MIN(inputw, mw/3); | 483 | inputw = MIN(inputw, mw/3); |
483 | promptw = prompt ? MIN(dc_textw(dc, prompt), mw/5) : 0; | 484 | promptw = prompt ? dc_textw(dc, prompt) : 0; |
484 | XMapRaised(dc->dpy, win); | 485 | XMapRaised(dc->dpy, win); |
485 | text[0] = '\0'; | 486 | text[0] = '\0'; |
486 | match(); | 487 | match(); |