From 21577557bc0480880ef9ad0dc23cb5bd587393d9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bernd=20B=C3=B6ckmann?= Date: Sat, 25 May 2024 20:49:19 +0200 Subject: [PATCH] fix #98 broken command line editing --- docs/html/build48.html | 2 -- include/misc.h | 1 - lib/clrline.c | 68 ------------------------------------------ lib/cmdinput.c | 34 ++++++++++++++++++--- lib/lib.mak | 1 - lib/makefile | 7 ++--- 6 files changed, 32 insertions(+), 81 deletions(-) delete mode 100644 lib/clrline.c diff --git a/docs/html/build48.html b/docs/html/build48.html index 7849f909..83d9a358 100644 --- a/docs/html/build48.html +++ b/docs/html/build48.html @@ -550,7 +550,6 @@

Appendix A: Description of settings

chgenv.c: chgenvc.c: chgenvr.c: -clrline.c: cmdinput.c: comfile.c: Turbo C++ Version 1.01 Copyright (c) 1990 Borland International @@ -790,7 +789,6 @@

Appendix A: Description of settings

+chgenv.obj & +chgenvc.obj & +chgenvr.obj & -+clrline.obj & +cmdinput.obj & +comfile.obj & +compfile.obj & diff --git a/include/misc.h b/include/misc.h index d8be2a46..b70735f7 100644 --- a/include/misc.h +++ b/include/misc.h @@ -148,7 +148,6 @@ int set_readcommandType(int enhanced); void convert(unsigned long num, unsigned int billions, char * const des); void goxy(const unsigned char x, const unsigned char y); -void clrcmdline(char * const str, const int maxlen, int x, int y); void setErrorLevel(int rc); void execute(char *first, char *rest, int lh_lf); diff --git a/lib/clrline.c b/lib/clrline.c deleted file mode 100644 index eb510601..00000000 --- a/lib/clrline.c +++ /dev/null @@ -1,68 +0,0 @@ -/* $Id$ - - * clrcmdline - Clear a line, may use more than one physical line on screen - - This file bases on ENVIRON.C of FreeCOM v0.81 beta 1. - - $Log$ - Revision 1.2 2004/02/01 13:52:17 skaus - add/upd: CVS $id$ keywords to/of files - - Revision 1.1 2001/04/12 00:33:52 skaus - chg: new structure - chg: If DEBUG enabled, no available commands are displayed on startup - fix: PTCHSIZE also patches min extra size to force to have this amount - of memory available on start - bugfix: CALL doesn't reset options - add: PTCHSIZE to patch heap size - add: VSPAWN, /SWAP switch, .SWP resource handling - bugfix: COMMAND.COM A:\ - bugfix: CALL: if swapOnExec == ERROR, no change of swapOnExec allowed - add: command MEMORY - bugfix: runExtension(): destroys command[-2] - add: clean.bat - add: localized CRITER strings - chg: use LNG files for hard-coded strings (hangForEver(), init.c) - via STRINGS.LIB - add: DEL.C, COPY.C, CBREAK.C: STRINGS-based prompts - add: fixstrs.c: prompts & symbolic keys - add: fixstrs.c: backslash escape sequences - add: version IDs to DEFAULT.LNG and validation to FIXSTRS.C - chg: splitted code apart into LIB\*.c and CMD\*.c - bugfix: IF is now using error system & STRINGS to report errors - add: CALL: /N - - */ - -#include "../config.h" - -#include -#include -#include - -#include "../include/misc.h" - -void clrcmdline(char * const str, const int maxlen, int x, int y) -{ - size_t len = strlen(str); - - if(len > 0) { - int step; - - for(step = len; step > 0; step--) { - x--; - if(x<0) { - y--; - x=SCREEN_COLS-1; - } - } - - assert(str); - goxy(x, y); - memset(str, ' ', len); - dos_write(1, str, len); - goxy(x, y); - memset(str, 0, maxlen); - } -} diff --git a/lib/cmdinput.c b/lib/cmdinput.c index 69532f82..99a84aa6 100644 --- a/lib/cmdinput.c +++ b/lib/cmdinput.c @@ -111,6 +111,32 @@ static void outsblank(const char * const s) outblank(); } +static void clrcmdline(char * const str, const unsigned pos, const int maxlen) +{ + size_t len = strlen(str); + int x = wherex(); + int y = wherey(); + + if(len > 0) { + unsigned step; + + for(step = pos; step > 0; step--) { + x--; + if(x<0) { + y--; + x=SCREEN_COLS-1; + } + } + + assert(str); + goxy(x, y); + memset(str, ' ', len); + dos_write(1, str, len); + goxy(x, y); + memset(str, 0, maxlen); + } +} + /* read in a command line */ void readcommandEnhanced(char * const str, const int maxlen) { @@ -266,7 +292,7 @@ void readcommandEnhanced(char * const str, const int maxlen) case KEY_CTL_C: /* ^C */ case KEY_ESC: /* clear str Make this callable! */ - clrcmdline(str, maxlen, wherex(), wherey()); + clrcmdline(str, current, maxlen); current = charcount = 0; if(ch == KEY_CTL_C && !echo) { @@ -313,7 +339,7 @@ void readcommandEnhanced(char * const str, const int maxlen) if(!histGet(--histLevel, prvLine, sizeof(prvLine))) ++histLevel; /* failed -> keep current command line */ else { - clrcmdline(str, maxlen, wherex(), wherey()); + clrcmdline(str, current, maxlen); strcpy(str, prvLine); current = charcount = strlen(str); outs(str); @@ -323,7 +349,7 @@ void readcommandEnhanced(char * const str, const int maxlen) case KEY_DOWN: /* get next command from buffer */ if(histLevel) { - clrcmdline(str, maxlen, wherex(), wherey()); + clrcmdline(str, current, maxlen); strcpy(prvLine, str); histGet(++histLevel, str, maxlen); current = charcount = strlen(str); @@ -333,7 +359,7 @@ void readcommandEnhanced(char * const str, const int maxlen) case KEY_F5: /* keep cmdline in F3/UP buffer and move to next line */ strcpy(prvLine, str); - clrcmdline(str, maxlen, wherex(), wherey()); + clrcmdline(str, current, maxlen); outc('@'); if(orgy >= MAX_Y) { outc('\n'); /* Force scroll */ diff --git a/lib/lib.mak b/lib/lib.mak index fe21c5d9..56bf727b 100644 --- a/lib/lib.mak +++ b/lib/lib.mak @@ -27,7 +27,6 @@ OBJ3 = chgdrv.obj\ chgenv.obj\ chgenvc.obj\ chgenvr.obj\ - clrline.obj\ cmdinput.obj\ comfile.obj\ compfile.obj diff --git a/lib/makefile b/lib/makefile index e2072450..83a70456 100644 --- a/lib/makefile +++ b/lib/makefile @@ -90,7 +90,7 @@ MAXLINELENGTH !:= 4096 # Sources of this make target SRC = absfile.c almemblk.c alprmblk.c alsysblk.c app_get.c app_set.c \ beep_l.c beep_n.c brk_get.c brk_set.c cbreak.c cbs.c cd_dir.c cgetch.c \ - cgettime.c chgctxt.c chgdrv.c chgenv.c chgenvc.c chgenvr.c clrline.c \ + cgettime.c chgctxt.c chgdrv.c chgenv.c chgenvc.c chgenvr.c \ cmdinput.c comfile.c compfile.c critend.c critrchk.c ctxt.c ctxt_adr.c \ ctxt_as.c ctxt_chg.c ctxt_clr.c ctxt_get.c ctxt_inf.c ctxt_mk.c \ ctxt_mkb.c ctxt_mkn.c ctxt_pop.c ctxt_psh.c ctxt_rnu.c ctxt_set.c \ @@ -114,7 +114,7 @@ SRC = absfile.c almemblk.c alprmblk.c alsysblk.c app_get.c app_set.c \ OBJ = absfile.obj almemblk.obj alprmblk.obj alsysblk.obj app_get.obj \ app_set.obj beep_l.obj beep_n.obj brk_get.obj brk_set.obj cbreak.obj \ cbs.obj cd_dir.obj cgetch.obj cgettime.obj chgctxt.obj chgdrv.obj \ - chgenv.obj chgenvc.obj chgenvr.obj clrline.obj cmdinput.obj comfile.obj \ + chgenv.obj chgenvc.obj chgenvr.obj cmdinput.obj comfile.obj \ compfile.obj critend.obj critrchk.obj ctxt.obj ctxt_adr.obj ctxt_as.obj \ ctxt_chg.obj ctxt_clr.obj ctxt_get.obj ctxt_inf.obj ctxt_mk.obj \ ctxt_mkb.obj ctxt_mkn.obj ctxt_pop.obj ctxt_psh.obj ctxt_rnu.obj \ @@ -249,9 +249,6 @@ chgenvc.obj : chgenvc.c \ chgenvr.obj : chgenvr.c \ ../config.h ../include/command.h ../include/datefunc.h \ ../include/debug.h ../include/misc.h ../include/timefunc.h ../strings.h -clrline.obj : clrline.c \ - ../config.h ../include/datefunc.h ../include/debug.h \ - ../include/misc.h ../include/timefunc.h cmdinput.obj : cmdinput.c \ ../config.h ../include/command.h ../include/datefunc.h \ ../include/debug.h ../include/keys.h ../include/misc.h \