From 50811cfab235b1b75df635b1facf9a86223fd8fa Mon Sep 17 00:00:00 2001 From: mickey Date: Tue, 1 Apr 1997 04:50:33 +0000 Subject: [PATCH] ^U hotkey in readline sample regs command to show the registers --- sys/arch/i386/stand/boot/cmd.c | 32 ++++++++++++++++++++++++++------ sys/arch/i386/stand/boot/cmd.h | 3 ++- sys/stand/boot/cmd.c | 32 ++++++++++++++++++++++++++------ sys/stand/boot/cmd.h | 3 ++- 4 files changed, 56 insertions(+), 14 deletions(-) diff --git a/sys/arch/i386/stand/boot/cmd.c b/sys/arch/i386/stand/boot/cmd.c index 0b14120a626..d203ba59ce9 100644 --- a/sys/arch/i386/stand/boot/cmd.c +++ b/sys/arch/i386/stand/boot/cmd.c @@ -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 #include #include +#include #include "cmd.h" #ifndef _TEST #include @@ -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)); diff --git a/sys/arch/i386/stand/boot/cmd.h b/sys/arch/i386/stand/boot/cmd.h index 25ac7d981fb..3a5d168f4bb 100644 --- a/sys/arch/i386/stand/boot/cmd.h +++ b/sys/arch/i386/stand/boot/cmd.h @@ -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; diff --git a/sys/stand/boot/cmd.c b/sys/stand/boot/cmd.c index 0b14120a626..d203ba59ce9 100644 --- a/sys/stand/boot/cmd.c +++ b/sys/stand/boot/cmd.c @@ -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 #include #include +#include #include "cmd.h" #ifndef _TEST #include @@ -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)); diff --git a/sys/stand/boot/cmd.h b/sys/stand/boot/cmd.h index 25ac7d981fb..3a5d168f4bb 100644 --- a/sys/stand/boot/cmd.h +++ b/sys/stand/boot/cmd.h @@ -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; -- 2.20.1