^U hotkey in readline
authormickey <mickey@openbsd.org>
Tue, 1 Apr 1997 04:50:33 +0000 (04:50 +0000)
committermickey <mickey@openbsd.org>
Tue, 1 Apr 1997 04:50:33 +0000 (04:50 +0000)
sample regs command to show the registers

sys/arch/i386/stand/boot/cmd.c
sys/arch/i386/stand/boot/cmd.h
sys/stand/boot/cmd.c
sys/stand/boot/cmd.h

index 0b14120..d203ba5 100644 (file)
@@ -1,4 +1,4 @@
-/*     $OpenBSD: cmd.c,v 1.2 1997/03/31 23:06:21 mickey Exp $  */
+/*     $OpenBSD: cmd.c,v 1.3 1997/04/01 04:50:33 mickey Exp $  */
 
 /*
  * Copyright (c) 1997 Michael Shalayeff
@@ -35,6 +35,7 @@
 #include <sys/param.h>
 #include <string.h>
 #include <libsa.h>
+#include <debug.h>
 #include "cmd.h"
 #ifndef _TEST
 #include <biosdev.h>
@@ -42,6 +43,8 @@
 
 extern int debug;
 
+#define CTRL(c)        ((c)&0x1f)
+
 const struct cmd_table {
        char *cmd_name;
        int cmd_id;
@@ -58,6 +61,7 @@ const struct cmd_table {
        {"ls",     CMD_LS},
        {"nope",   CMD_NOPE},
        {"reboot", CMD_REBOOT},
+       {"regs",   CMD_REGS},
        {"set",    CMD_SET},
        {NULL, 0},
 };
@@ -119,11 +123,11 @@ getcmd(cmd)
 }
 
 static int
-readline(p, to)
-       register char *p;
+readline(buf, to)
+       register char *buf;
        int     to;
 {
-       char *buf = p, ch;
+       char *p = buf, *pe = buf, ch;
        int i;
 
        for (i = to; i-- && !ischar(); )
@@ -137,8 +141,17 @@ readline(p, to)
 
        while (1) {
                switch (ch = getchar()) {
+               case CTRL('u'):
+                       while (pe > buf) {
+                               pe--;
+                               putchar('\b');
+                               putchar(' ');
+                               putchar('\b');
+                       }
+                       p = pe = buf;
+                       continue;
                case '\n':
-                       p[1] = *p = '\0';
+                       pe[1] = *pe = '\0';
                        break;
                case '\b':
                        if (p > buf) {
@@ -146,15 +159,18 @@ readline(p, to)
                                putchar(' ');
                                putchar('\b');
                                p--;
+                               pe--;
                        }
                        continue;
                default:
+                       pe++;
                        *p++ = ch;
                        continue;
                }
                break;
        }
-       return p - buf;
+
+       return pe - buf;
 }
 
 char *
@@ -332,6 +348,10 @@ execmd(cmd)
                cmd->rc = -1;
                break;
 
+       case CMD_REGS:
+               DUMP_REGS;
+               break;
+
        case CMD_BOOT:
                if (cmd->argc > 1)
                        strncpy(cmd->path, cmd->argv[1], sizeof(cmd->path));
index 25ac7d9..3a5d168 100644 (file)
@@ -1,4 +1,4 @@
-/*     $OpenBSD: cmd.h,v 1.2 1997/03/31 23:06:21 mickey Exp $  */
+/*     $OpenBSD: cmd.h,v 1.3 1997/04/01 04:50:33 mickey Exp $  */
 
 /*
  * Copyright (c) 1997 Michael Shalayeff
@@ -42,6 +42,7 @@ struct cmd_state {
 
        enum { CMD_ADDR, CMD_BOOT, CMD_CD, CMD_DEVICE, CMD_DEBUG, CMD_HELP,
               CMD_IMAGE, CMD_LS, CMD_NOPE, CMD_REBOOT, CMD_SET,
+              CMD_REGS,
               CMD_ERROR /* last !!! */
        }       cmd;
        int argc;
index 0b14120..d203ba5 100644 (file)
@@ -1,4 +1,4 @@
-/*     $OpenBSD: cmd.c,v 1.2 1997/03/31 23:06:21 mickey Exp $  */
+/*     $OpenBSD: cmd.c,v 1.3 1997/04/01 04:50:33 mickey Exp $  */
 
 /*
  * Copyright (c) 1997 Michael Shalayeff
@@ -35,6 +35,7 @@
 #include <sys/param.h>
 #include <string.h>
 #include <libsa.h>
+#include <debug.h>
 #include "cmd.h"
 #ifndef _TEST
 #include <biosdev.h>
@@ -42,6 +43,8 @@
 
 extern int debug;
 
+#define CTRL(c)        ((c)&0x1f)
+
 const struct cmd_table {
        char *cmd_name;
        int cmd_id;
@@ -58,6 +61,7 @@ const struct cmd_table {
        {"ls",     CMD_LS},
        {"nope",   CMD_NOPE},
        {"reboot", CMD_REBOOT},
+       {"regs",   CMD_REGS},
        {"set",    CMD_SET},
        {NULL, 0},
 };
@@ -119,11 +123,11 @@ getcmd(cmd)
 }
 
 static int
-readline(p, to)
-       register char *p;
+readline(buf, to)
+       register char *buf;
        int     to;
 {
-       char *buf = p, ch;
+       char *p = buf, *pe = buf, ch;
        int i;
 
        for (i = to; i-- && !ischar(); )
@@ -137,8 +141,17 @@ readline(p, to)
 
        while (1) {
                switch (ch = getchar()) {
+               case CTRL('u'):
+                       while (pe > buf) {
+                               pe--;
+                               putchar('\b');
+                               putchar(' ');
+                               putchar('\b');
+                       }
+                       p = pe = buf;
+                       continue;
                case '\n':
-                       p[1] = *p = '\0';
+                       pe[1] = *pe = '\0';
                        break;
                case '\b':
                        if (p > buf) {
@@ -146,15 +159,18 @@ readline(p, to)
                                putchar(' ');
                                putchar('\b');
                                p--;
+                               pe--;
                        }
                        continue;
                default:
+                       pe++;
                        *p++ = ch;
                        continue;
                }
                break;
        }
-       return p - buf;
+
+       return pe - buf;
 }
 
 char *
@@ -332,6 +348,10 @@ execmd(cmd)
                cmd->rc = -1;
                break;
 
+       case CMD_REGS:
+               DUMP_REGS;
+               break;
+
        case CMD_BOOT:
                if (cmd->argc > 1)
                        strncpy(cmd->path, cmd->argv[1], sizeof(cmd->path));
index 25ac7d9..3a5d168 100644 (file)
@@ -1,4 +1,4 @@
-/*     $OpenBSD: cmd.h,v 1.2 1997/03/31 23:06:21 mickey Exp $  */
+/*     $OpenBSD: cmd.h,v 1.3 1997/04/01 04:50:33 mickey Exp $  */
 
 /*
  * Copyright (c) 1997 Michael Shalayeff
@@ -42,6 +42,7 @@ struct cmd_state {
 
        enum { CMD_ADDR, CMD_BOOT, CMD_CD, CMD_DEVICE, CMD_DEBUG, CMD_HELP,
               CMD_IMAGE, CMD_LS, CMD_NOPE, CMD_REBOOT, CMD_SET,
+              CMD_REGS,
               CMD_ERROR /* last !!! */
        }       cmd;
        int argc;