Skip to content

Commit

Permalink
latest commits added
Browse files Browse the repository at this point in the history
  • Loading branch information
mrdotx committed Aug 13, 2021
1 parent 0c78239 commit 6876ed2
Show file tree
Hide file tree
Showing 4 changed files with 18 additions and 4 deletions.
2 changes: 1 addition & 1 deletion README
Original file line number Diff line number Diff line change
Expand Up @@ -47,4 +47,4 @@ Options

Last implemented commit
-----------------------
2020-09-02 16:30 bump version to 5.0 Hiltjo Posthuma
2021-08-09 16:39 add support for more keypad keys Hiltjo Posthuma
11 changes: 11 additions & 0 deletions dmenu.c
Original file line number Diff line number Diff line change
Expand Up @@ -468,9 +468,11 @@ keypress(XKeyEvent *ev)
utf8, utf8, win, CurrentTime);
return;
case XK_Left:
case XK_KP_Left:
movewordedge(-1);
goto draw;
case XK_Right:
case XK_KP_Right:
movewordedge(+1);
goto draw;
case XK_Return:
Expand Down Expand Up @@ -508,6 +510,7 @@ keypress(XKeyEvent *ev)
insert(buf, len);
break;
case XK_Delete:
case XK_KP_Delete:
if (text[cursor] == '\0')
return;
cursor = nextrune(+1);
Expand All @@ -518,6 +521,7 @@ keypress(XKeyEvent *ev)
insert(NULL, nextrune(-1) - cursor);
break;
case XK_End:
case XK_KP_End:
if (text[cursor] != '\0') {
cursor = strlen(text);
break;
Expand All @@ -537,6 +541,7 @@ keypress(XKeyEvent *ev)
cleanup();
exit(1);
case XK_Home:
case XK_KP_Home:
if (sel == matches) {
cursor = 0;
break;
Expand All @@ -545,6 +550,7 @@ keypress(XKeyEvent *ev)
calcoffsets();
break;
case XK_Left:
case XK_KP_Left:
if (cursor > 0 && (!sel || !sel->left || lines > 0)) {
cursor = nextrune(-1);
break;
Expand All @@ -553,18 +559,21 @@ keypress(XKeyEvent *ev)
return;
/* fallthrough */
case XK_Up:
case XK_KP_Up:
if (sel && sel->left && (sel = sel->left)->right == curr) {
curr = prev;
calcoffsets();
}
break;
case XK_Next:
case XK_KP_Next:
if (!next)
return;
sel = curr = next;
calcoffsets();
break;
case XK_Prior:
case XK_KP_Prior:
if (!prev)
return;
sel = curr = prev;
Expand All @@ -581,6 +590,7 @@ keypress(XKeyEvent *ev)
sel->out = 1;
break;
case XK_Right:
case XK_KP_Right:
if (text[cursor] != '\0') {
cursor = nextrune(+1);
break;
Expand All @@ -589,6 +599,7 @@ keypress(XKeyEvent *ev)
return;
/* fallthrough */
case XK_Down:
case XK_KP_Down:
if (sel && sel->right && (sel = sel->right) == next) {
curr = next;
calcoffsets();
Expand Down
7 changes: 5 additions & 2 deletions drw.c
Original file line number Diff line number Diff line change
Expand Up @@ -299,8 +299,11 @@ drw_text(Drw *drw, int x, int y, unsigned int w, unsigned int h, unsigned int lp
if (utf8strlen) {
drw_font_getexts(usedfont, utf8str, utf8strlen, &ew, NULL);
/* shorten text if necessary */
for (len = MIN(utf8strlen, sizeof(buf) - 1); len && ew > w; len--)
drw_font_getexts(usedfont, utf8str, len, &ew, NULL);
if (ew > w)
for (ew = 0, len = 0; ew < w - lpad * 2 && len < MIN(utf8strlen, sizeof(buf) - 1); len++)
drw_font_getexts(usedfont, utf8str, len, &ew, NULL);
else
len = MIN(utf8strlen, sizeof(buf) - 1);

if (len) {
memcpy(buf, utf8str, len);
Expand Down
2 changes: 1 addition & 1 deletion stest.c
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ main(int argc, char *argv[])
if (!argc) {
/* read list from stdin */
while ((n = getline(&line, &linesiz, stdin)) > 0) {
if (n && line[n - 1] == '\n')
if (line[n - 1] == '\n')
line[n - 1] = '\0';
test(line, line);
}
Expand Down

0 comments on commit 6876ed2

Please sign in to comment.