Synchronet now requires the libarchive development package (e.g. libarchive-dev on Debian-based Linux distros, libarchive.org for more info) to build successfully.

Commit 3944d046 authored by rswindell's avatar rswindell

sbbs_t methods: backspace(), carriage_return(), line_feed(), and newline()

now accept an optional "count" argument (default: 1).
JS console.backspace() and carrage_return() methods now accept an optional
"count" argumnet (default: 1).
parent 36013131
......@@ -449,18 +449,22 @@ int sbbs_t::rprintf(const char *fmt, ...)
/****************************************************************************/
/* Outputs destructive backspace */
/****************************************************************************/
void sbbs_t::backspace(void)
void sbbs_t::backspace(int count)
{
if(count < 1)
return;
if(!(console&CON_ECHO_OFF)) {
if(term_supports(PETSCII))
outcom(PETSCII_DELETE);
else {
outcom('\b');
outcom(' ');
outcom('\b');
for(int i = 0; i < count; i++) {
if(term_supports(PETSCII))
outcom(PETSCII_DELETE);
else {
outcom('\b');
outcom(' ');
outcom('\b');
}
if(column)
column--;
}
if(column)
column--;
}
}
......@@ -752,28 +756,40 @@ void sbbs_t::wide(const char* str)
// Send a bare carriage return, hopefully moving the cursor to the far left, current row
void sbbs_t::carriage_return(void)
void sbbs_t::carriage_return(int count)
{
if(term_supports(PETSCII))
cursor_left(column);
else
outcom('\r');
column = 0;
if(count < 1)
return;
for(int i = 0; i < count; i++) {
if(term_supports(PETSCII))
cursor_left(column);
else
outcom('\r');
column = 0;
}
}
// Send a bare line_feed, hopefully moving the cursor down one row, current column
void sbbs_t::line_feed(void)
void sbbs_t::line_feed(int count)
{
if(term_supports(PETSCII))
outcom(PETSCII_DOWN);
else
outcom('\n');
if(count < 1)
return;
for(int i = 0; i < count; i++) {
if(term_supports(PETSCII))
outcom(PETSCII_DOWN);
else
outcom('\n');
}
}
void sbbs_t::newline(void)
void sbbs_t::newline(int count)
{
outchar('\r');
outchar('\n');
if(count < 1)
return;
for(int i = 0; i < count; i++) {
outchar('\r');
outchar('\n');
}
}
void sbbs_t::clearline(void)
......
......@@ -526,16 +526,16 @@ void sbbs_t::pause()
{
char ch;
uint tempattrs=curatr; /* was lclatr(-1) */
int i,j;
long l=K_UPPER;
size_t len;
if(sys_status&SS_ABORT)
if(sys_status&SS_ABORT)
return;
lncntr=0;
if(online==ON_REMOTE)
rioctl(IOFI);
bputs(text[Pause]);
j=bstrlen(text[Pause]);
len = bstrlen(text[Pause]);
if(sys_status&SS_USERON && !(useron.misc&(HTML|WIP|NOPAUSESPIN))
&& !(cfg.node_misc&NM_NOPAUSESPIN))
l|=K_SPIN;
......@@ -545,8 +545,7 @@ void sbbs_t::pause()
else if(ch==LF) // down arrow == display one more line
lncntr=rows-2;
if(text[Pause][0]!='@')
for(i=0;i<j;i++)
backspace();
backspace(len);
getnodedat(cfg.node_num,&thisnode,0);
nodesync();
attr(tempattrs);
......
......@@ -1754,16 +1754,21 @@ js_cursor_left(JSContext *cx, uintN argc, jsval *arglist)
static JSBool
js_backspace(JSContext *cx, uintN argc, jsval *arglist)
{
jsval *argv=JS_ARGV(cx, arglist);
sbbs_t* sbbs;
jsrefcount rc;
int32 val=1;
if((sbbs=(sbbs_t*)js_GetClassPrivate(cx, JS_THIS_OBJECT(cx, arglist), &js_console_class))==NULL)
return(JS_FALSE);
JS_SET_RVAL(cx, arglist, JSVAL_VOID);
if(argc) {
if(!JS_ValueToInt32(cx, argv[0], &val))
return JS_FALSE;
}
rc=JS_SUSPENDREQUEST(cx);
sbbs->backspace();
sbbs->backspace(val);
JS_RESUMEREQUEST(cx, rc);
return(JS_TRUE);
}
......@@ -1771,16 +1776,21 @@ js_backspace(JSContext *cx, uintN argc, jsval *arglist)
static JSBool
js_creturn(JSContext *cx, uintN argc, jsval *arglist)
{
jsval *argv=JS_ARGV(cx, arglist);
sbbs_t* sbbs;
jsrefcount rc;
int32 val=1;
if((sbbs=(sbbs_t*)js_GetClassPrivate(cx, JS_THIS_OBJECT(cx, arglist), &js_console_class))==NULL)
return(JS_FALSE);
JS_SET_RVAL(cx, arglist, JSVAL_VOID);
if(argc) {
if(!JS_ValueToInt32(cx, argv[0], &val))
return JS_FALSE;
}
rc=JS_SUSPENDREQUEST(cx);
sbbs->carriage_return();
sbbs->carriage_return(val);
JS_RESUMEREQUEST(cx, rc);
return(JS_TRUE);
}
......@@ -2128,11 +2138,11 @@ static jsSyncMethodSpec js_console_functions[] = {
"<i>terminal_flags</i> (numeric bit-field) if no <i>terminal_flags</i> were specified")
,314
},
{"backspace", js_backspace, 0, JSTYPE_VOID, JSDOCSTR("")
{"backspace", js_backspace, 0, JSTYPE_VOID, JSDOCSTR("[count=<tt>1</tt>]")
,JSDOCSTR("send a destructive backspace sequence")
,315
},
{"creturn", js_creturn, 0, JSTYPE_VOID, JSDOCSTR("")
{"creturn", js_creturn, 0, JSTYPE_VOID, JSDOCSTR("[count=<tt>1</tt>]")
,JSDOCSTR("send a carriage return sequence")
,31700
},
......
......@@ -725,7 +725,7 @@ public:
__attribute__ ((format (printf, 2, 3))); // 1 is 'this'
#endif
;
void backspace(void); /* Output a destructive backspace via outchar */
void backspace(int count=1); /* Output destructive backspace(s) via outchar */
int outchar(char ch); /* Output a char - check echo and emu. */
int outchar(enum unicode_codepoint, char cp437_fallback);
int outchar(enum unicode_codepoint, const char* cp437_fallback = NULL);
......@@ -740,9 +740,9 @@ public:
void cursor_down(int count=1);
void cursor_left(int count=1);
void cursor_right(int count=1);
void carriage_return(void);
void line_feed(void);
void newline(void);
void carriage_return(int count=1);
void line_feed(int count=1);
void newline(int count=1);
long term_supports(long cmp_flags=0);
const char* term_type(long term_supports = -1);
const char* term_charset(long term_supports = -1);
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment