repo: dmenu action: commit revision: path_from: revision_from: 6d0211448b20d120e0546e236f14db90a5c64dec: path_to: revision_to:
commit 6d0211448b20d120e0546e236f14db90a5c64dec Author: epochDate: Sun Oct 16 16:17:38 2022 -0500 wider spinner and Prior and Next keys do sensible things when there is less than a whole page of choices. diff --git a/dmenu.c b/dmenu.c
--- a/dmenu.c
+++ b/dmenu.c
@@ -468,33 +468,9 @@ insert:
return;
insert(NULL, nextrune(-1) - cursor);
break;
- case XK_End:
- if (text[cursor] != '\0') {
- cursor = strlen(text);
- break;
- }
- if (next) {
- /* jump to end of list and position items in reverse */
- curr = matchend;
- calcoffsets();
- curr = prev;
- calcoffsets();
- while (next && (curr = curr->right))
- calcoffsets();
- }
- sel = matchend;
- break;
case XK_Escape:
cleanup();
exit(1);
- case XK_Home:
- if (sel == matches) {
- cursor = 0;
- break;
- }
- sel = curr = matches;
- calcoffsets();
- break;
case XK_Left:
if (cursor > 0 && (!sel || !sel->left || lines > 0)) {
cursor = nextrune(-1);
@@ -511,16 +487,45 @@ insert:
break;
case XK_Next:
if (!next)
- return;
- sel = curr = next;
+ while(sel->right) sel=sel->right;
+ else
+ sel = curr = next;
calcoffsets();
break;
+ case XK_End:
+ if (text[cursor] != '\0') {
+ cursor = strlen(text);
+ break;
+ }
+ if (next) {
+ /* jump to end of list and position items in reverse */
+ curr = matchend;
+ calcoffsets();
+ curr = prev;
+ calcoffsets();
+ while (next && (curr = curr->right))
+ calcoffsets();
+ }
+ sel = curr = matchend;
+ break;
case XK_Prior:
- if (!prev)
- return;
- sel = curr = prev;
+ if (prev) {
+ sel = curr = prev;
+ calcoffsets();
+ break;
+ }
+ sel = curr = matches;
calcoffsets();
break;
+ case XK_Home:
+ if (sel == matches) {
+ cursor = 0;
+ break;
+ }
+ sel = curr = matches;
+ calcoffsets();
+ break;
+
case XK_Return:
case XK_KP_Enter:
puts((sel && !(ev->state & ShiftMask)) ? sel->text : text);
@@ -648,14 +653,18 @@ readstdin(void)
static void update_prompt(char *orig_prompt,int lines_read,int done_reading) {
static int spin=0;
+ //char spinner[]="/-\\|!";
+ //wchar_t spinner[]=L"⠏⠛⠹⢸⣰⣤⣆⡇-"; //each of these is actually three bytes.
+ wchar_t spinner[]=L"⠏⠀⠋⠁⠉⠉⠈⠙⠀⠹⠀⢸⠀⣰⢀⣠⣀⣀⣄⡀⣆⠀⡇⠀/\\";
if(done_reading) {
- spin=4;
+ spin=24;
} else {
- spin++;
- spin%=4;
+ spin+=2;
+ spin%=24;
}
- char spinner[]="/-\\|!";
- snprintf(prompt,1024,"%s %c %d",orig_prompt,spinner[spin],lines_read);
+ //snprintf(prompt,1024,"%s %c %d",orig_prompt,spinner[spin],lines_read);
+ snprintf(prompt,1024,"%s %lc %d",orig_prompt,spinner[spin],lines_read);
+ snprintf(prompt,1024,"%s %lc%lc %d",orig_prompt,spinner[spin],spinner[spin+1],lines_read);
promptw = (prompt && *prompt) ? TEXTW(prompt) - lrpad / 4 : 0;
}
-----END OF PAGE-----