Skip to content

Commit

Permalink
fix #98 broken command line editing
Browse files Browse the repository at this point in the history
  • Loading branch information
boeckmann authored and PerditionC committed May 25, 2024
1 parent 622bff7 commit c85401e
Show file tree
Hide file tree
Showing 6 changed files with 32 additions and 81 deletions.
2 changes: 0 additions & 2 deletions docs/html/build48.html
Original file line number Diff line number Diff line change
Expand Up @@ -550,7 +550,6 @@ <H1>Appendix A: Description of settings</H1>
chgenv.c:
chgenvc.c:
chgenvr.c:
clrline.c:
cmdinput.c:
comfile.c:
Turbo C++ Version 1.01 Copyright (c) 1990 Borland International
Expand Down Expand Up @@ -790,7 +789,6 @@ <H1>Appendix A: Description of settings</H1>
+chgenv.obj &amp;
+chgenvc.obj &amp;
+chgenvr.obj &amp;
+clrline.obj &amp;
+cmdinput.obj &amp;
+comfile.obj &amp;
+compfile.obj &amp;
Expand Down
1 change: 0 additions & 1 deletion include/misc.h
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
68 changes: 0 additions & 68 deletions lib/clrline.c

This file was deleted.

34 changes: 30 additions & 4 deletions lib/cmdinput.c
Original file line number Diff line number Diff line change
Expand Up @@ -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)
{
Expand Down Expand Up @@ -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) {
Expand Down Expand Up @@ -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);
Expand All @@ -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);
Expand All @@ -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 */
Expand Down
1 change: 0 additions & 1 deletion lib/lib.mak
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,6 @@ OBJ3 = chgdrv.obj\
chgenv.obj\
chgenvc.obj\
chgenvr.obj\
clrline.obj\
cmdinput.obj\
comfile.obj\
compfile.obj
Expand Down
7 changes: 2 additions & 5 deletions lib/makefile
Original file line number Diff line number Diff line change
Expand Up @@ -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 \
Expand All @@ -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 \
Expand Down Expand Up @@ -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 \
Expand Down

0 comments on commit c85401e

Please sign in to comment.