diff options
author | Matt Fleming <matt.fleming@linux.intel.com> | 2011-03-31 14:50:19 +0100 |
---|---|---|
committer | Matt Fleming <matt.fleming@linux.intel.com> | 2011-04-01 09:58:02 +0100 |
commit | f97510383b700984948ad4a1c961b67501a2ac48 (patch) | |
tree | 00c8993ea296a5a26d47671da7f50339950fc8b3 /com32/elflink/ldlinux | |
parent | f8d263e69d65c4257a49bc1a70428e89d492e361 (diff) | |
download | syslinux-f97510383b700984948ad4a1c961b67501a2ac48.tar.gz syslinux-f97510383b700984948ad4a1c961b67501a2ac48.tar.xz syslinux-f97510383b700984948ad4a1c961b67501a2ac48.zip |
ldlinux, cli: Add support for F-keys
The old asm command-line interface had support for printing files
containing help messages when the F-keys (F1-F10) were pressed. Add
this support to ldlinux.
The config parser already had support for parsing config files with
F-key directives and the cli code already had support for executing
callbacks when one of the F-keys was hit, so this patch simply glues
all the pieces together and provides a function to cat the help file.
Signed-off-by: Matt Fleming <matt.fleming@linux.intel.com>
Diffstat (limited to 'com32/elflink/ldlinux')
-rw-r--r-- | com32/elflink/ldlinux/config.h | 2 | ||||
-rw-r--r-- | com32/elflink/ldlinux/ldlinux.c | 2 | ||||
-rw-r--r-- | com32/elflink/ldlinux/readconfig.c | 73 |
3 files changed, 76 insertions, 1 deletions
diff --git a/com32/elflink/ldlinux/config.h b/com32/elflink/ldlinux/config.h index 37c57da1..8f708f14 100644 --- a/com32/elflink/ldlinux/config.h +++ b/com32/elflink/ldlinux/config.h @@ -36,4 +36,6 @@ extern short nohalt; //idle.inc extern const char *default_cmd; //"default" command line extern const char *onerror; //"onerror" command line +extern void cat_help_file(int key); + #endif /* __CONFIG_H__ */ diff --git a/com32/elflink/ldlinux/ldlinux.c b/com32/elflink/ldlinux/ldlinux.c index 85066b19..1177ef59 100644 --- a/com32/elflink/ldlinux/ldlinux.c +++ b/com32/elflink/ldlinux/ldlinux.c @@ -17,7 +17,7 @@ static void enter_cmdline(void) /* Enter endless command line prompt, should support "exit" */ while (1) { - cmdline = edit_cmdline("syslinux$", 1, NULL, NULL); + cmdline = edit_cmdline("syslinux$", 1, NULL, cat_help_file); if (!cmdline) continue; /* feng: give up the aux check here */ diff --git a/com32/elflink/ldlinux/readconfig.c b/com32/elflink/ldlinux/readconfig.c index a29c6c60..66e84dfb 100644 --- a/com32/elflink/ldlinux/readconfig.c +++ b/com32/elflink/ldlinux/readconfig.c @@ -27,6 +27,7 @@ #include "menu.h" #include "config.h" +#include "getkey.h" const struct menu_parameter mparm[NPARAMS] = { [P_WIDTH] = {"width", 0}, @@ -617,6 +618,78 @@ static char *is_message_name(char *cmdstr, enum message_number *msgnr) return NULL; } +static int cat_file(const char *filename) +{ + FILE *f; + char line[2048]; + + f = fopen(filename, "r"); + if (!f) + return -1; + + while (fgets(line, sizeof(line), f) != NULL) + printf("%s", line); + + fclose(f); + return 0; +} + +void cat_help_file(int key) +{ + struct menu *cm = current_menu; + int fkey; + + switch (key) { + case KEY_F1: + fkey = 0; + break; + case KEY_F2: + fkey = 1; + break; + case KEY_F3: + fkey = 2; + break; + case KEY_F4: + fkey = 3; + break; + case KEY_F5: + fkey = 4; + break; + case KEY_F6: + fkey = 5; + break; + case KEY_F7: + fkey = 6; + break; + case KEY_F8: + fkey = 7; + break; + case KEY_F9: + fkey = 8; + break; + case KEY_F10: + fkey = 9; + break; + case KEY_F11: + fkey = 10; + break; + case KEY_F12: + fkey = 11; + break; + default: + fkey = -1; + break; + } + + if (fkey == -1) + return; + + if (cm->fkeyhelp[fkey].textname) { + printf("\n"); + cat_file(cm->fkeyhelp[fkey].textname); + } +} + static char *is_fkey(char *cmdstr, int *fkeyno) { char *q; |