projects
/
unix-history
/ blob
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
tags
|
clone url
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
blame
|
history
|
raw
|
HEAD
date and time created 83/08/05 13:34:37 by sam
[unix-history]
/
usr
/
src
/
old
/
lib2648
/
readline.c
/* readline.c 4.1 83/03/09 */
/*
* Read a line from the keyboard in the message line. The line
* goes into caller provided buffer msg, whos size is maxlen bytes.
*/
#include
"2648.h"
readline
(
prompt
,
msg
,
maxlen
)
char
*
prompt
;
char
*
msg
;
int
maxlen
;
{
register
char
c
;
register
char
*
cp
;
int
oldx
,
oldy
;
int
oldcuron
;
int
oldquiet
;
extern
int
QUIET
;
oldx
=
_curx
;
oldy
=
_cury
;
oldcuron
=
_cursoron
;
areaclear
(
4
,
4
,
4
+
8
,
719
);
setset
();
zoomout
();
curon
();
movecurs
(
4
,
4
);
texton
();
oldquiet
=
QUIET
;
QUIET
=
0
;
outstr
(
prompt
);
if
(
oldquiet
)
outstr
(
"
\r\n
"
);
QUIET
=
oldquiet
;
for
(
cp
=
msg
; ;
cp
) {
fflush
(
stdout
);
c
=
getchar
();
switch
(
c
) {
case
'
\n
'
:
case
'
\r
'
:
case
ESC
:
*
cp
++ =
0
;
textoff
();
movecurs
(
oldx
,
oldy
);
if
(
oldcuron
==
0
)
curoff
();
return
;
case
'
\b
'
:
if
(--
cp
>=
msg
)
outchar
(
c
);
else
cp
=
msg
;
break
;
default
:
*
cp
++ =
c
;
outstr
(
rdchar
(
c
));
if
(
cp
-
msg
>=
maxlen
)
error
(
"line too long"
);
}
}
}