dmenu-noinputlinesbelowpromptfullwidth-5.2.diff - sites - public wiki contents … | |
git clone git://git.suckless.org/sites | |
Log | |
Files | |
Refs | |
--- | |
dmenu-noinputlinesbelowpromptfullwidth-5.2.diff (5287B) | |
--- | |
1 diff -up dmenu/config.def.h dmenu-noinputlinesbelowpromptfullwidth/confi… | |
2 --- dmenu/config.def.h 2024-03-03 12:59:00.545293913 -0600 | |
3 +++ dmenu-noinputlinesbelowpromptfullwidth/config.def.h 2024-03-0… | |
4 @@ -2,6 +2,7 @@ | |
5 /* Default settings; can be overriden by command line. */ | |
6 | |
7 static int topbar = 1; /* -b option; if 0, dmenu … | |
8 +static int draw_input = 1; /* -noi option; if 0, the i… | |
9 /* -fn option overrides fonts[0]; default X11 font or font set */ | |
10 static const char *fonts[] = { | |
11 "monospace:size=10" | |
12 diff -up dmenu/dmenu.c dmenu-noinputlinesbelowpromptfullwidth/dmenu.c | |
13 --- dmenu/dmenu.c 2024-03-03 12:59:00.545293913 -0600 | |
14 +++ dmenu-noinputlinesbelowpromptfullwidth/dmenu.c 2024-03-03 15:… | |
15 @@ -147,30 +147,32 @@ drawmenu(void) | |
16 { | |
17 unsigned int curpos; | |
18 struct item *item; | |
19 - int x = 0, y = 0, w; | |
20 + int x = 0, y = 0, w = 0; | |
21 | |
22 drw_setscheme(drw, scheme[SchemeNorm]); | |
23 drw_rect(drw, 0, 0, mw, mh, 1, 1); | |
24 | |
25 if (prompt && *prompt) { | |
26 drw_setscheme(drw, scheme[SchemeSel]); | |
27 - x = drw_text(drw, x, 0, promptw, bh, lrpad / 2, prompt,… | |
28 + x = drw_text(drw, x, 0, !draw_input ? mw : promptw, bh,… | |
29 } | |
30 - /* draw input field */ | |
31 - w = (lines > 0 || !matches) ? mw - x : inputw; | |
32 - drw_setscheme(drw, scheme[SchemeNorm]); | |
33 - drw_text(drw, x, 0, w, bh, lrpad / 2, text, 0); | |
34 | |
35 - curpos = TEXTW(text) - TEXTW(&text[cursor]); | |
36 - if ((curpos += lrpad / 2 - 1) < w) { | |
37 + if (draw_input) { | |
38 + w = (lines > 0 || !matches) ? mw - x : inputw; | |
39 drw_setscheme(drw, scheme[SchemeNorm]); | |
40 - drw_rect(drw, x + curpos, 2, 2, bh - 4, 1, 0); | |
41 + drw_text(drw, x, 0, w, bh, lrpad / 2, text, 0); | |
42 + | |
43 + curpos = TEXTW(text) - TEXTW(&text[cursor]); | |
44 + if ((curpos += lrpad / 2 - 1) < w) { | |
45 + drw_setscheme(drw, scheme[SchemeNorm]); | |
46 + drw_rect(drw, x + curpos, 2, 2, bh - 4, 1, 0); | |
47 + } | |
48 } | |
49 | |
50 if (lines > 0) { | |
51 /* draw vertical list */ | |
52 for (item = curr; item != next; item = item->right) | |
53 - drawitem(item, x, y += bh, mw - x); | |
54 + drawitem(item, (!draw_input && prompt && *promp… | |
55 } else if (matches) { | |
56 /* draw horizontal list */ | |
57 x += inputw; | |
58 @@ -178,8 +180,8 @@ drawmenu(void) | |
59 if (curr->left) { | |
60 drw_setscheme(drw, scheme[SchemeNorm]); | |
61 drw_text(drw, x, 0, w, bh, lrpad / 2, "<", 0); | |
62 + x += w; | |
63 } | |
64 - x += w; | |
65 for (item = curr; item != next; item = item->right) | |
66 x = drawitem(item, x, 0, textw_clamp(item->text… | |
67 if (next) { | |
68 @@ -358,16 +360,19 @@ keypress(XKeyEvent *ev) | |
69 case XK_p: ksym = XK_Up; break; | |
70 | |
71 case XK_k: /* delete right */ | |
72 - text[cursor] = '\0'; | |
73 - match(); | |
74 + if (draw_input) { | |
75 + text[cursor] = '\0'; | |
76 + match(); | |
77 + } | |
78 break; | |
79 case XK_u: /* delete left */ | |
80 - insert(NULL, 0 - cursor); | |
81 + if (draw_input) | |
82 + insert(NULL, 0 - cursor); | |
83 break; | |
84 case XK_w: /* delete word */ | |
85 - while (cursor > 0 && strchr(worddelimiters, tex… | |
86 + while (cursor > 0 && strchr(worddelimiters, tex… | |
87 insert(NULL, nextrune(-1) - cursor); | |
88 - while (cursor > 0 && !strchr(worddelimiters, te… | |
89 + while (cursor > 0 && !strchr(worddelimiters, te… | |
90 insert(NULL, nextrune(-1) - cursor); | |
91 break; | |
92 case XK_y: /* paste selection */ | |
93 @@ -414,23 +419,23 @@ keypress(XKeyEvent *ev) | |
94 switch(ksym) { | |
95 default: | |
96 insert: | |
97 - if (!iscntrl((unsigned char)*buf)) | |
98 + if (!iscntrl((unsigned char)*buf) && draw_input) | |
99 insert(buf, len); | |
100 break; | |
101 case XK_Delete: | |
102 case XK_KP_Delete: | |
103 - if (text[cursor] == '\0') | |
104 + if (text[cursor] == '\0' || !draw_input) | |
105 return; | |
106 cursor = nextrune(+1); | |
107 /* fallthrough */ | |
108 case XK_BackSpace: | |
109 - if (cursor == 0) | |
110 + if (cursor == 0 || !draw_input) | |
111 return; | |
112 insert(NULL, nextrune(-1) - cursor); | |
113 break; | |
114 case XK_End: | |
115 case XK_KP_End: | |
116 - if (text[cursor] != '\0') { | |
117 + if (text[cursor] != '\0' && draw_input) { | |
118 cursor = strlen(text); | |
119 break; | |
120 } | |
121 @@ -514,7 +519,7 @@ insert: | |
122 } | |
123 break; | |
124 case XK_Tab: | |
125 - if (!sel) | |
126 + if (!sel || !draw_input) | |
127 return; | |
128 cursor = strnlen(sel->text, sizeof text - 1); | |
129 memcpy(text, sel->text, cursor); | |
130 @@ -677,7 +682,7 @@ setup(void) | |
131 mw = wa.width; | |
132 } | |
133 promptw = (prompt && *prompt) ? TEXTW(prompt) - lrpad / 4 : 0; | |
134 - inputw = mw / 3; /* input width: ~33% of monitor width */ | |
135 + inputw = !draw_input ? 0 : mw / 3; /* input width: ~33% of moni… | |
136 match(); | |
137 | |
138 /* create menu window */ | |
139 @@ -715,7 +720,7 @@ setup(void) | |
140 static void | |
141 usage(void) | |
142 { | |
143 - die("usage: dmenu [-bfiv] [-l lines] [-p prompt] [-fn font] [-m… | |
144 + die("usage: dmenu [-bfiv] [-noi] [-l lines] [-p prompt] [-fn fo… | |
145 " [-nb color] [-nf color] [-sb color] [-sf colo… | |
146 } | |
147 | |
148 @@ -734,6 +739,8 @@ main(int argc, char *argv[]) | |
149 topbar = 0; | |
150 else if (!strcmp(argv[i], "-f")) /* grabs keyboard be… | |
151 fast = 1; | |
152 + else if (!strcmp(argv[i], "-noi")) /* no input field. i… | |
153 + draw_input = 0; | |
154 else if (!strcmp(argv[i], "-i")) { /* case-insensitive … | |
155 fstrncmp = strncasecmp; | |
156 fstrstr = cistrstr; |