summaryrefslogtreecommitdiff
path: root/bootblocks/help.c
diff options
context:
space:
mode:
authorRobert de Bath <rdebath@poboxes.com>1997-02-25 20:42:19 +0100
committerLubomir Rintel <lkundrak@v3.sk>2013-10-23 23:38:07 +0200
commit4c36e9a0c125ccfff37aa440dab2cf58c4152fff (patch)
treea5d9c84ba2661029ddb2223dacd50529a361c3d5 /bootblocks/help.c
parentf8de35da65c5d93bb733073cf40da154bc1c0748 (diff)
parent9696d7b0e1f3a1b0f5fd4a0428eb75afe8ad4ed6 (diff)
downloaddev86-0.0.11.tar.gz
Import Dev86src-0.0.11.tar.gzv0.0.11
Diffstat (limited to 'bootblocks/help.c')
-rw-r--r--bootblocks/help.c93
1 files changed, 93 insertions, 0 deletions
diff --git a/bootblocks/help.c b/bootblocks/help.c
new file mode 100644
index 0000000..5083fdc
--- /dev/null
+++ b/bootblocks/help.c
@@ -0,0 +1,93 @@
+
+/*
+ * Display a page from help.txt, the argument is the scan code of a function
+ * key. F1..F10 display pages 1..10, HOME is page zero, PGUP and PGDN are
+ * previous and next page.
+ */
+
+#include <stdio.h>
+#include "readfs.h"
+
+struct keys {
+ int key;
+ int rel;
+ int abs;
+} keys[] = {
+ {0xC7, 0, 0}, /* HOME page 0*/
+ {0xBB, 0, 1}, /* F1 page 1 */
+ {0xBC, 0, 2}, /* F2 page 2 */
+ {0xBD, 0, 3}, /* F3 page 3 */
+ {0xBE, 0, 4}, /* F4 page 4 */
+ {0xBF, 0, 5}, /* F5 page 5 */
+ {0xC0, 0, 6}, /* F6 page 6 */
+ {0xC1, 0, 7}, /* F7 page 7 */
+ {0xC2, 0, 8}, /* F8 page 8 */
+ {0xC3, 0, 9}, /* F9 page 9 */
+ {0xC4, 0, 10}, /* F10 page 10 */
+
+ {0xC9, -1,0}, /* PGUP page-- */
+ {0xD1, 1,0}, /* PGDN page++ */
+
+ {0,0,1}
+};
+
+cmd_help(ptr)
+char * ptr;
+{
+static int lastpage = 0;
+ int helpkey = 1;
+ int i;
+
+ getnum(&ptr, &helpkey);
+
+ for(i=0; keys[i].key; i++)
+ if( keys[i].key == helpkey || i == helpkey )
+ break;
+
+ if( keys[i].key == 0 )
+ {
+ printf("Unbound key, press F1 for general help\n");
+ return -1;
+ }
+
+ if( keys[i].rel ) lastpage += keys[i].rel;
+ else lastpage = keys[i].abs;
+
+ if( lastpage < 0 ) { lastpage=0; return 0; }
+
+ return display_help(lastpage);
+}
+
+display_help(page)
+int page;
+{
+ char buffer[1024];
+ long length= -1;
+ int left = 0;
+ int ch,lastch = '\n';
+ int flg = 0;
+
+ if( open_file("help.txt") < 0 )
+ {
+ if( page == 1 )
+ printf("Help file 'help.txt' is not available, sorry.\n");
+ return -1;
+ }
+
+ for(length = file_length(); length>0; length--)
+ {
+ if( left==0 )
+ {
+ if( read_block(buffer) < 0 ) break;
+ left = 1024;
+ }
+ ch = buffer[1024-left]; left--;
+ if( ch == '%' && lastch == '\n' ) { flg = 1; page--; }
+ if( page < 0 ) break;
+ if( page == 0 && flg == 0 ) putchar(ch);
+ if( ch == '\n' ) flg = 0;
+ lastch = ch;
+ }
+ return 0;
+}
+