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

Fun with Unicode!

Create a sbbs_t method: wide(), which displays a string using "fullwidth"
Unicode characters, when possible, otherwise, double-spaced.
Exposed in JS via console.wide() and a new @-code: WIDE:<string>
parent 173e3be6
......@@ -166,6 +166,11 @@ const char* sbbs_t::atcode(char* sp, char* str, size_t maxlen)
return nulstr;
}
if(strncmp(sp, "WIDE:", 5) == 0) {
wide(sp + 5);
return(nulstr);
}
if(!strcmp(sp,"VER"))
return(VERSION);
......
......@@ -603,6 +603,21 @@ void sbbs_t::center(char *instr)
newline();
}
void sbbs_t::wide(const char* str)
{
long term = term_supports();
while(*str != '\0') {
if((term&UTF8) && *str >= '!' && *str <= '~')
outchar((enum unicode_codepoint)(UNICODE_FULLWIDTH_EXCLAMATION_MARK + (*str - '!')));
else {
outchar(*str);
outchar(' ');
}
str++;
}
}
// Send a bare carriage return, hopefully moving the cursor to the far left, current row
void sbbs_t::carriage_return(void)
{
......
......@@ -1420,6 +1420,34 @@ js_center(JSContext *cx, uintN argc, jsval *arglist)
return(JS_TRUE);
}
static JSBool
js_wide(JSContext *cx, uintN argc, jsval *arglist)
{
jsval *argv=JS_ARGV(cx, arglist);
JSString* str;
sbbs_t* sbbs;
char* cstr;
jsrefcount rc;
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);
str = JS_ValueToString(cx, argv[0]);
if (str == NULL)
return(JS_FALSE);
JSSTRING_TO_MSTRING(cx, str, cstr, NULL);
if(cstr==NULL)
return JS_FALSE;
rc=JS_SUSPENDREQUEST(cx);
sbbs->wide(cstr);
free(cstr);
JS_RESUMEREQUEST(cx, rc);
return(JS_TRUE);
}
static JSBool
js_saveline(JSContext *cx, uintN argc, jsval *arglist)
{
......@@ -1953,6 +1981,10 @@ static jsSyncMethodSpec js_console_functions[] = {
,JSDOCSTR("display a string centered on the screen")
,310
},
{"wide", js_wide, 1, JSTYPE_VOID, JSDOCSTR("text")
,JSDOCSTR("display a string double-wide on the screen (sending \"fullwidth\" Unicode characters when possible)")
,0x317c
},
{"strlen", js_strlen, 1, JSTYPE_NUMBER, JSDOCSTR("text")
,JSDOCSTR("returns the number of characters in text, excluding Ctrl-A codes")
,310
......
......@@ -718,6 +718,7 @@ public:
int outchar(enum unicode_codepoint, char cp437_fallback = 0);
void inc_column(int count);
void center(char *str);
void wide(const char*);
void clearline(void);
void cleartoeol(void);
void cleartoeos(void);
......
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