Re: =?windows-1256?q?Ratmenu_keyboard_shortcuts=FE?=
Gillian Seed <[email protected]>
| Newsgroups | gmane.comp.window-managers.ratpoison.devel |
|---|---|
| Message-ID | <[email protected]> |
Hi,
Sorry about HTML post, haven't used the mailing lists a lot. I wasn't able to find the original patch. I even contacted to author but he didn't neither had it archived, so I made one of my own. To use this patch, format of the ratmenu should be as follows,
#!/bin/bash
#
./ratmenu \
-label Menu \
"vi v" "vim" -shortcut v \
"nano n" "nano" -shortcut n \
"hex " "hexedit"
where v now will be shortcut to vim and n shortcut to nano. If you find any bugs, please let me know.
--- ratmenu.c 2010-03-18 05:43:03.000000000 +0200
+++ ratmenu_shortcut.c 2013-04-07 12:23:55.000000000 +0300
@@ -107,6 +107,7 @@
char **labels; /* list of labels and commands */
char **commands;
+char *shortcuts; /* list of shortcuts */
int numitems;
int startitem; /* which item to highlight first */
int curitem;
@@ -229,20 +230,30 @@
usage();
numitems = (argc-i) / 2;
-
+
labels = (char **) malloc(numitems * sizeof(char *));
commands = (char **) malloc(numitems * sizeof(char *));
+ shortcuts = malloc(numitems * sizeof(char *));
- if (commands == NULL || labels == NULL) {
+ if (commands == NULL || labels == NULL || shortcuts == NULL) {
fprintf(stderr, "%s: no memory!\n", progname);
exit(1);
}
-
+
for (j=0; i < argc; j++) {
labels[j] = argv[i++];
commands[j] = argv[i++];
+ if(i < argc) {
+ if(strcmp(argv[i], "-shortcut") == 0) {
+ shortcuts[j] = argv[i+1][0];
+ numitems--;
+ i=i+2;
+ } else {
+ shortcuts[j] = '\0';
+ }
+ }
}
-
+
dpy = XOpenDisplay(displayname);
if (dpy == NULL) {
fprintf(stderr, "%s: cannot open display", progname);
@@ -406,6 +417,13 @@
case CTL('b'):
key = XK_Left;
break;
+ default:
+ for(i = 0; i < numitems; i++){
+ if(keystr[0] == shortcuts[i]) {
+ spawn(commands[i]);
+ }
+ }
+ break;
}
}
BR,
Gillian
_______________________________________________
Ratpoison-devel mailing list
[email protected]
https://lists.nongnu.org/mailman/listinfo/ratpoison-devel
ratmenu_shortcut.patch
(application/octet-stream, 1.3 KB)
--- ratmenu.c 2010-03-18 05:43:03.000000000 +0200
+++ ratmenu_shortcut.c 2013-04-07 12:23:55.000000000 +0300
@@ -107,6 +107,7 @@
char **labels; /* list of labels and commands */
char **commands;
+char *shortcuts; /* list of shortcuts */
int numitems;
int startitem; /* which item to highlight first */
int curitem;
@@ -229,20 +230,30 @@
usage();
numitems = (argc-i) / 2;
-
+
labels = (char **) malloc(numitems * sizeof(char *));
commands = (char **) malloc(numitems * sizeof(char *));
+ shortcuts = malloc(numitems * sizeof(char *));
- if (commands == NULL || labels == NULL) {
+ if (commands == NULL || labels == NULL || shortcuts == NULL) {
fprintf(stderr, "%s: no memory!\n", progname);
exit(1);
}
-
+
for (j=0; i < argc; j++) {
labels[j] = argv[i++];
commands[j] = argv[i++];
+ if(i < argc) {
+ if(strcmp(argv[i], "-shortcut") == 0) {
+ shortcuts[j] = argv[i+1][0];
+ numitems--;
+ i=i+2;
+ } else {
+ shortcuts[j] = '\0';
+ }
+ }
}
-
+
dpy = XOpenDisplay(displayname);
if (dpy == NULL) {
fprintf(stderr, "%s: cannot open display", progname);
@@ -406,6 +417,13 @@
case CTL('b'):
key = XK_Left;
break;
+ default:
+ for(i = 0; i < numitems; i++){
+ if(keystr[0] == shortcuts[i]) {
+ spawn(commands[i]);
+ }
+ }
+ break;
}
}