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 f3333bff authored by rswindell's avatar rswindell

Create a use new sbbs_t method: term_type(), returns the auto-generated

terminal "type" string (ANSI, RIP, PETSCII, or DUMB).
Expose this value in JS via the new console.type read-only property.
The TERM @-code now expands to this string rather than the (often
client-supplied) sbbs_t.terminal string value.
parent 0cef0d39
......@@ -268,8 +268,11 @@ const char* sbbs_t::atcode(char* sp, char* str, size_t maxlen)
safe_snprintf(str,maxlen,"%lu",rows);
return(str);
}
if(!strcmp(sp,"TERM"))
return(terminal);
if(strcmp(sp,"TERM") == 0)
return term_type();
if(strcmp(sp,"CHARSET") == 0)
return term_charset();
if(!strcmp(sp,"CONN"))
return(connection);
......
......@@ -384,6 +384,38 @@ long sbbs_t::term_supports(long cmp_flags)
return(cmp_flags ? ((flags&cmp_flags)==cmp_flags) : (flags&TERM_FLAGS));
}
/****************************************************************************/
/* Returns description of the terminal type */
/****************************************************************************/
const char* sbbs_t::term_type(long term)
{
if(term == -1)
term = term_supports();
if(term&PETSCII)
return "PETSCII";
if(term&RIP)
return "RIP";
if(term&ANSI)
return "ANSI";
return "DUMB";
}
/****************************************************************************/
/* Returns description of the terminal supported character set (charset) */
/****************************************************************************/
const char* sbbs_t::term_charset(long term)
{
if(term == -1)
term = term_supports();
if(term&PETSCII)
return "CBM-ASCII";
if(term&UTF8)
return "UTF-8";
if(term&NO_EXASCII)
return "US-ASCII";
return "CP437";
}
/****************************************************************************/
/* Outputs character */
/* Performs terminal translations (e.g. EXASCII-to-ASCII, FF->ESC[2J) */
......
......@@ -55,6 +55,8 @@ enum {
,CON_PROP_TABSTOP
,CON_PROP_AUTOTERM
,CON_PROP_TERMINAL
,CON_PROP_TERM_TYPE
,CON_PROP_CHARSET
,CON_PROP_CTERM_VERSION
,CON_PROP_WORDWRAP
,CON_PROP_QUESTION
......@@ -125,6 +127,16 @@ static JSBool js_console_get(JSContext *cx, JSObject *obj, jsid id, jsval *vp)
return(JS_FALSE);
*vp = STRING_TO_JSVAL(js_str);
return(JS_TRUE);
case CON_PROP_TERM_TYPE:
if((js_str=JS_NewStringCopyZ(cx, sbbs->term_type()))==NULL)
return(JS_FALSE);
*vp = STRING_TO_JSVAL(js_str);
return(JS_TRUE);
case CON_PROP_CHARSET:
if((js_str=JS_NewStringCopyZ(cx, sbbs->term_charset()))==NULL)
return(JS_FALSE);
*vp = STRING_TO_JSVAL(js_str);
return(JS_TRUE);
case CON_PROP_CTERM_VERSION:
val=sbbs->cterm_version;
break;
......@@ -334,6 +346,8 @@ static jsSyncPropertySpec js_console_properties[] = {
{ "tabstop" ,CON_PROP_TABSTOP ,CON_PROP_FLAGS ,31700},
{ "autoterm" ,CON_PROP_AUTOTERM ,CON_PROP_FLAGS ,310},
{ "terminal" ,CON_PROP_TERMINAL ,CON_PROP_FLAGS ,311},
{ "type" ,CON_PROP_TERM_TYPE ,JSPROP_ENUMERATE|JSPROP_READONLY ,31702},
{ "charset" ,CON_PROP_CHARSET ,JSPROP_ENUMERATE|JSPROP_READONLY ,31702},
{ "cterm_version" ,CON_PROP_CTERM_VERSION ,CON_PROP_FLAGS ,317},
{ "inactivity_warning",CON_PROP_INACTIV_WARN ,CON_PROP_FLAGS, 31401},
{ "inactivity_hangup" ,CON_PROP_INACTIV_HANGUP ,CON_PROP_FLAGS, 31401},
......@@ -366,7 +380,9 @@ static const char* con_prop_desc[] = {
,"current tab stop interval (tab size), in columns"
,"bit-field of automatically detected terminal settings "
"(see <tt>USER_*</tt> in <tt>sbbsdefs.js</tt> for bit definitions)"
,"terminal type description (e.g. 'ANSI')"
,"terminal type description, possibly supplied by client (e.g. 'ANSI')"
,"terminal type (i.e. 'ANSI', 'RIP', 'PETSCII', or 'DUMB')"
,"terminal character set (i.e. 'UTF-8', 'CP437', 'CBM-ASCII', or 'US-ASCII')"
,"detected CTerm (SyncTERM) version as an integer > 1000 where major version is cterm_version / 1000 and minor version is cterm_version % 1000"
,"number of seconds before displaying warning (Are you really there?) due to user/keyboard inactivity"
,"number of seconds before disconnection due to user/keyboard inactivity"
......@@ -1983,7 +1999,7 @@ static jsSyncMethodSpec js_console_functions[] = {
},
{"wide", js_wide, 1, JSTYPE_VOID, JSDOCSTR("text")
,JSDOCSTR("display a string double-wide on the screen (sending \"fullwidth\" Unicode characters when possible)")
,0x317c
,31702
},
{"strlen", js_strlen, 1, JSTYPE_NUMBER, JSDOCSTR("text")
,JSDOCSTR("returns the number of characters in text, excluding Ctrl-A codes")
......
......@@ -732,6 +732,8 @@ public:
void line_feed(void);
void newline(void);
long term_supports(long cmp_flags=0);
const char* term_type(long term_supports = -1);
const char* term_charset(long term_supports = -1);
int backfill(const char* str, float pct, int full_attr, int empty_attr);
void progress(const char* str, int count, int total, int interval=1);
bool saveline(void);
......
......@@ -816,13 +816,12 @@ void sbbs_t::maindflts(user_t* user)
,user->misc&AUTOTERM ? text[TerminalAutoDetect]:nulstr
,cols, text[TerminalColumns]);
else
safe_snprintf(str,sizeof(str),"%s%s%s%s%s%s"
safe_snprintf(str,sizeof(str),"%s%s / %s %s%s"
,user->misc&AUTOTERM ? text[TerminalAutoDetect]:nulstr
,term&ANSI ? "ANSI ":"TTY "
,term_charset(term)
,term_type(term)
,term&COLOR ? (term&ICE_COLOR ? text[TerminalIceColor] : text[TerminalColor]) : text[TerminalMonochrome]
,term&RIP ? "RIP " : nulstr
,term&UTF8 ? "UTF-8 " : (term&NO_EXASCII ? "ASCII ":"CP437 ")
,term&SWAP_DELETE ? "DEL=BS " : nulstr);
,term&SWAP_DELETE ? "DEL=BS" : nulstr);
bprintf(text[UserDefaultsTerminal], truncsp(str));
if(user->rows)
ultoa(user->rows,tmp,10);
......
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