Commit 8afac993 authored by Rob Swindell's avatar Rob Swindell

Support manual terminal columns setting per user

The default terminal columns (still 0/auto) can be overridden with the 'L' command from the user defaults menu. 

Also increased maximum manual terminal rows setting from 99 to 999 - this involved moving the record in user.dat, though the old record value is auto-migrated.
parent 9a2bb7d2
Pipeline #421 passed with stage
in 18 minutes and 55 seconds
......@@ -210,7 +210,8 @@ char* sbbs_t::ansi(int atr, int curatr, char* str)
void sbbs_t::ansi_getlines()
{
if(sys_status&SS_USERON && useron.misc&ANSI && !useron.rows /* Auto-detect rows */
if(sys_status&SS_USERON && useron.misc&ANSI
&& (useron.rows == TERM_ROWS_AUTO || useron.cols == TERM_COLS_AUTO)
&& online==ON_REMOTE) { /* Remote */
SYNC;
putcom("\x1b[s\x1b[255B\x1b[255C\x1b[6n\x1b[u");
......
......@@ -533,15 +533,15 @@ char sbbs_t::handle_ctrlkey(char ch, long mode)
return(ESC);
}
if(ch=='R') { /* cursor position report */
if(mode&K_ANSI_CPR && i && !(useron.rows)) { /* auto-detect rows */
if(mode&K_ANSI_CPR && i) { /* auto-detect rows */
int x,y;
str[i]=0;
if(sscanf(str,"%u;%u",&y,&x)==2) {
lprintf(LOG_DEBUG,"received ANSI cursor position report: %ux%u"
,x, y);
/* Sanity check the coordinates in the response: */
if(x >= TERM_COLS_MIN && x <= TERM_COLS_MAX) cols=x;
if(y >= TERM_ROWS_MIN && y <= TERM_ROWS_MAX) rows=y;
if(useron.cols == TERM_COLS_AUTO && x >= TERM_COLS_MIN && x <= TERM_COLS_MAX) cols=x;
if(useron.rows == TERM_ROWS_AUTO && y >= TERM_ROWS_MIN && y <= TERM_ROWS_MAX) rows=y;
}
}
return(0);
......
......@@ -102,7 +102,8 @@ enum {
,USER_PROP_FLAGS4
,USER_PROP_EXEMPT
,USER_PROP_REST
,USER_PROP_ROWS
,USER_PROP_ROWS
,USER_PROP_COLS
,USER_PROP_SEX
,USER_PROP_MISC
,USER_PROP_LEECH
......@@ -314,6 +315,9 @@ static JSBool js_user_get(JSContext *cx, JSObject *obj, jsid id, jsval *vp)
case USER_PROP_ROWS:
val=p->user->rows;
break;
case USER_PROP_COLS:
val=p->user->cols;
break;
case USER_PROP_SEX:
sprintf(tmp,"%c",p->user->sex);
s=tmp;
......@@ -538,6 +542,10 @@ static JSBool js_user_set(JSContext *cx, JSObject *obj, jsid id, JSBool strict,
p->user->rows=atoi(str);
putuserrec(scfg,p->user->number,U_ROWS,0,str); /* base 10 */
break;
case USER_PROP_COLS:
p->user->cols=atoi(str);
putuserrec(scfg,p->user->number,U_COLS,0,str); /* base 10 */
break;
case USER_PROP_SEX:
p->user->sex=toupper(str[0]);
putuserrec(scfg,p->user->number,U_SEX,0,strupr(str)); /* single char */
......@@ -785,6 +793,7 @@ static jsSyncPropertySpec js_user_properties[] = {
{ "connection" ,USER_PROP_MODEM ,USER_PROP_FLAGS, 310},
{ "modem" ,USER_PROP_MODEM ,USER_PROP_FLAGS, 310},
{ "screen_rows" ,USER_PROP_ROWS ,USER_PROP_FLAGS, 310},
{ "screen_columns" ,USER_PROP_COLS ,USER_PROP_FLAGS, 31802},
{ "gender" ,USER_PROP_SEX ,USER_PROP_FLAGS, 310},
{ "cursub" ,USER_PROP_CURSUB ,USER_PROP_FLAGS, 310},
{ "curdir" ,USER_PROP_CURDIR ,USER_PROP_FLAGS, 310},
......@@ -829,8 +838,9 @@ static char* user_prop_desc[] = {
,"calculated age in years - <small>READ ONLY</small>"
,"connection type (protocol)"
,"AKA connection"
,"terminal rows (lines)"
,"gender type (e.g. M or F)"
,"terminal rows (0 = auto-detect)"
,"terminal columns (0 = auto-detect)"
,"gender type (e.g. M or F or any single-character)"
,"current/last message sub-board (internal code)"
,"current/last file directory (internal code)"
,"current/last external program (internal code) run"
......
......@@ -79,7 +79,8 @@ bool sbbs_t::logon()
if(useron.rest&FLAG('G')) { /* Guest account */
useron.misc=(cfg.new_misc&(~ASK_NSCAN));
useron.rows=0;
useron.rows = TERM_ROWS_AUTO;
useron.cols = TERM_COLS_AUTO;
useron.misc &= ~TERM_FLAGS;
useron.misc|=autoterm;
if(!(useron.misc&(ANSI|PETSCII)) && text[AnsiTerminalQ][0] && yesno(text[AnsiTerminalQ]))
......@@ -215,8 +216,10 @@ bool sbbs_t::logon()
}
bputs(text[LoggingOn]);
if(useron.rows)
rows=useron.rows;
if(useron.rows != TERM_ROWS_AUTO)
rows = useron.rows;
if(useron.cols != TERM_COLS_AUTO)
cols = useron.cols;
if(tm.tm_mon + 1 == getbirthmonth(&cfg, useron.birth) && tm.tm_mday == getbirthday(&cfg, useron.birth)
&& !(useron.rest&FLAG('Q'))) {
if(text[HappyBirthday][0]) {
......
......@@ -179,7 +179,8 @@ BOOL sbbs_t::newuser()
}
if(useron.misc&ANSI) {
useron.rows=0; /* Auto-rows */
useron.rows = TERM_ROWS_AUTO;
useron.cols = TERM_COLS_AUTO;
if(!(cfg.uq&UQ_COLORTERM) || useron.misc&(RIP|WIP|HTML) || yesno(text[ColorTerminalQ]))
useron.misc|=COLOR;
else
......
......@@ -530,7 +530,9 @@ typedef enum { /* Values for xtrn_t.event */
#define LEN_FDESC 58 /* File description */
#define LEN_FCDT 9 /* 9 digits for file credit values */
#define LEN_TITLE 70 /* Message title */
#define LEN_MAIN_CMD 34 /* Storage in user.dat for custom commands */
#define LEN_MAIN_CMD 28 /* Unused Storage in user.dat */
#define LEN_COLS 3
#define LEN_ROWS 3
#define LEN_PASS 40
#define MIN_PASS_LEN 4
#define RAND_PASS_LEN 8
......@@ -592,14 +594,16 @@ typedef enum { /* Values for xtrn_t.event */
#define U_FLAGS2 U_TL+2
#define U_EXEMPT U_FLAGS2+8
#define U_REST U_EXEMPT+8
#define U_ROWS U_REST+8+2 /* Number of Rows on user's monitor */
#define U_SEX U_ROWS+2 /* Sex, Del, ANSI, color etc. */
#define U_OLDROWS U_REST+8+2 /* Number of Rows on user's monitor */
#define U_SEX U_OLDROWS+2 /* Sex, Del, ANSI, color etc. */
#define U_MISC U_SEX+1 /* Miscellaneous flags in 8byte hex */
#define U_OLDXEDIT U_MISC+8 /* External editor (Version 1 method */
#define U_LEECH U_OLDXEDIT+2 /* two hex digits - leech attempt count */
#define U_CURSUB U_LEECH+2 /* Current sub (internal code) */
#define U_CURXTRN U_CURSUB+16 /* Current xtrn (internal code) */
#define U_MAIN_CMD U_CURXTRN+8+2 /* unused */
#define U_ROWS U_CURXTRN+8+2
#define U_COLS U_ROWS+LEN_ROWS
#define U_MAIN_CMD U_COLS+LEN_COLS /* unused */
#define U_PASS U_MAIN_CMD+LEN_MAIN_CMD
#define U_SCAN_CMD U_PASS+LEN_PASS+2 /* unused */
#define U_IPADDR U_SCAN_CMD+LEN_SCAN_CMD /* unused */
......@@ -690,11 +694,13 @@ typedef enum { /* Values for xtrn_t.event */
#define TERM_KEY_PAGEUP CTRL_P
#define TERM_KEY_PAGEDN CTRL_N
#define TERM_COLS_AUTO 0
#define TERM_COLS_MIN 40
#define TERM_COLS_MAX 255
#define TERM_COLS_MAX 999
#define TERM_COLS_DEFAULT 80
#define TERM_ROWS_AUTO 0
#define TERM_ROWS_MIN 8 // Amstrad NC100 has an 8-line display
#define TERM_ROWS_MAX 255
#define TERM_ROWS_MAX 999
#define TERM_ROWS_DEFAULT 24
/* Online status (online) */
......@@ -1026,10 +1032,12 @@ typedef struct { /* Users information */
uchar level, /* Security level */
sex, /* Sex - M or F */
rows, /* Rows of text */
prot, /* Default transfer protocol */
leech; /* Leech attempt counter */
int rows, /* Rows on terminal (0 = auto-detect) */
cols; /* Columns on terminal (0 = auto-detect) */
ulong misc, /* Misc. bits - ANSI, Deleted etc. */
qwk, /* QWK settings */
chat, /* Chat defaults */
......
......@@ -853,6 +853,7 @@ enum {
,SpinningCursor7
,SpinningCursor8
,SpinningCursor9
,HowManyColumns
,TOTAL_TEXT
};
......
......@@ -779,8 +779,8 @@ const char * const text_defaults[TOTAL_TEXT]={
"\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x01\x6e\x01\x62\x01\x5c\x3a\x20\x01\x63\x25\x73\x0d\x0a" // 475 UserDefaultsTerminal
,"\x01\x6e\x01\x62\x5b\x01\x68\x01\x77\x45\x01\x6e\x01\x62\x5d\x20\x01\x68\x45\x78\x74\x65\x72\x6e\x61\x6c\x20\x45\x64\x69\x74\x6f"
"\x72\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x01\x6e\x01\x62\x01\x5c\x3a\x20\x01\x63\x25\x73\x0d\x0a" // 476 UserDefaultsXeditor
,"\x01\x6e\x01\x62\x5b\x01\x68\x01\x77\x4c\x01\x6e\x01\x62\x5d\x20\x01\x68\x53\x63\x72\x65\x65\x6e\x20\x4c\x65\x6e\x67\x74\x68\x20"
"\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x01\x6e\x01\x62\x01\x5c\x3a\x20\x01\x63\x25\x73\x20\x25\x73\x0d\x0a"
,"\x01\x6e\x01\x62\x5b\x01\x68\x01\x77\x4c\x01\x6e\x01\x62\x5d\x20\x01\x68\x54\x65\x72\x6d\x69\x6e\x61\x6c\x20\x44\x69\x6d\x65\x6e"
"\x73\x69\x6f\x6e\x73\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x01\x6e\x01\x62\x01\x5c\x3a\x20\x01\x63\x25\x73\x20\x25\x73\x0d\x0a"
"" // 477 UserDefaultsRows
,"\x01\x6e\x01\x62\x5b\x01\x68\x01\x77\x58\x01\x6e\x01\x62\x5d\x20\x01\x68\x45\x78\x70\x65\x72\x74\x20\x4d\x65\x6e\x75\x20\x4d\x6f"
"\x64\x65\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x01\x6e\x01\x62\x3a\x20\x01\x63\x25\x73\x0d\x0a" // 478 UserDefaultsMenuMode
......@@ -819,9 +819,8 @@ const char * const text_defaults[TOTAL_TEXT]={
,"\x0d\x0a\x01\x6e\x01\x68\x01\x62\x57\x68\x69\x63\x68\x20\x6f\x72\x20\x5b\x01\x77\x51\x01\x62\x5d\x75\x69\x74\x3a\x20\x01\x63" // 494 UserDefaultsWhich
,"\x4f\x6e" // 495 On
,"\x4f\x66\x66" // 496 Off
,"\x0d\x0a\x01\x5f\x01\x62\x01\x68\x5b\x01\x63\x40\x43\x48\x45\x43\x4b\x4d\x41\x52\x4b\x40\x01\x62\x5d\x20\x01\x79\x48\x6f\x77\x20"
"\x6d\x61\x6e\x79\x20\x72\x6f\x77\x73\x20\x6f\x6e\x20\x79\x6f\x75\x72\x20\x6d\x6f\x6e\x69\x74\x6f\x72\x20\x5b\x01\x77\x41\x75\x74"
"\x6f\x20\x44\x65\x74\x65\x63\x74\x01\x79\x5d\x3a\x20" // 497 HowManyRows
,"\x01\x5f\x01\x62\x01\x68\x5b\x01\x63\x40\x43\x48\x45\x43\x4b\x4d\x41\x52\x4b\x40\x01\x62\x5d\x20\x01\x79\x54\x65\x72\x6d\x69\x6e"
"\x61\x6c\x20\x72\x6f\x77\x73\x20\x5b\x01\x77\x41\x75\x74\x6f\x01\x79\x5d\x3a\x20\x01\x6e" // 497 HowManyRows
,"\x0d\x0a\x01\x5f\x01\x79\x01\x68\x43\x75\x72\x72\x65\x6e\x74\x20\x50\x61\x73\x73\x77\x6f\x72\x64\x3a\x20\x01\x77" // 498 CurrentPassword
,"\x46\x6f\x72\x77\x61\x72\x64\x20\x70\x65\x72\x73\x6f\x6e\x61\x6c\x20\x65\x2d\x6d\x61\x69\x6c\x20\x74\x6f\x20\x6e\x65\x74\x77\x6f"
"\x72\x6b\x20\x6d\x61\x69\x6c\x20\x61\x64\x64\x72\x65\x73\x73" // 499 ForwardMailQ
......@@ -1384,4 +1383,6 @@ const char * const text_defaults[TOTAL_TEXT]={
,"\xdc\xde\xdf\xdd" // 840 SpinningCursor7
,"\xdc\xdd\xdf\xde" // 841 SpinningCursor8
,"\xfa\xf9\xfe\xf9" // 842 SpinningCursor9
,"\x01\x5f\x01\x62\x01\x68\x5b\x01\x63\x40\x43\x48\x45\x43\x4b\x4d\x41\x52\x4b\x40\x01\x62\x5d\x20\x01\x79\x54\x65\x72\x6d\x69\x6e"
"\x61\x6c\x20\x63\x6f\x6c\x75\x6d\x6e\x73\x20\x5b\x01\x77\x41\x75\x74\x6f\x01\x79\x5d\x3a\x20\x01\x6e" // 843 HowManyColumns
};
......@@ -254,8 +254,10 @@ int edit_terminal(scfg_t *cfg, user_t *user)
sprintf(opt[i++],"Pause %s",user->misc & UPAUSE?"Yes":"No");
sprintf(opt[i++],"Hot Keys %s",user->misc & COLDKEYS?"No":"Yes");
sprintf(opt[i++],"Spinning Cursor %s",user->misc & SPIN?"Yes":"No");
sprintf(str,"%u",user->cols);
sprintf(opt[i++],"Screen Columns %s",user->cols?str:"Auto");
sprintf(str,"%u",user->rows);
sprintf(opt[i++],"Number of Rows %s",user->rows?str:"Auto");
sprintf(opt[i++],"Screen Rows %s",user->rows?str:"Auto");
opt[i][0]=0;
switch(uifc.list(WIN_MID|WIN_ACT|WIN_SAV,0,0,0,&j,0,"Terminal Settings",opt)) {
case -1:
......@@ -307,12 +309,21 @@ int edit_terminal(scfg_t *cfg, user_t *user)
putuserrec(cfg,user->number,U_MISC,8,ultoa(user->misc,str,16));
break;
case 9:
/* Columns */
SAFEPRINTF(str,"%u",user->cols);
uifc.input(WIN_MID|WIN_ACT|WIN_SAV,0,0, "Columns (0=auto-detect)", str, LEN_COLS, K_EDIT|K_NUMBER);
if(uifc.changes) {
user->cols=strtoul(str,NULL,10);
putuserrec(cfg,user->number,U_COLS,0,ultoa(user->cols,str,10));
}
break;
case 10:
/* Rows */
sprintf(str,"%u",user->rows);
uifc.input(WIN_MID|WIN_ACT|WIN_SAV,0,0,"Rows",str,2,K_EDIT|K_NUMBER);
SAFEPRINTF(str,"%u",user->rows);
uifc.input(WIN_MID|WIN_ACT|WIN_SAV,0,0, "Rows (0=auto-detect)", str, LEN_ROWS, K_EDIT|K_NUMBER);
if(uifc.changes) {
user->rows=strtoul(str,NULL,10);
putuserrec(cfg,user->number,U_ROWS,2,ultoa(user->rows,str,10));
putuserrec(cfg,user->number,U_ROWS,0,ultoa(user->rows,str,10));
}
break;
}
......
......@@ -338,9 +338,15 @@ int parseuserdat(scfg_t* cfg, char *userdat, user_t *user)
getrec(userdat,U_FLAGS4,8,str); user->flags4=ahtoul(str);
getrec(userdat,U_EXEMPT,8,str); user->exempt=ahtoul(str);
getrec(userdat,U_REST,8,str); user->rest=ahtoul(str);
getrec(userdat,U_ROWS,2,str); user->rows=atoi(str);
if(user->rows && user->rows<10)
user->rows=10;
if(getrec(userdat,U_OLDROWS,2,str) <= 0) // Moved to new location
getrec(userdat, U_ROWS, LEN_ROWS, str);
user->rows = atoi(str);
if(user->rows && user->rows < TERM_ROWS_MIN)
user->rows = TERM_ROWS_MIN;
getrec(userdat, U_COLS, LEN_COLS, str);
user->cols = atoi(str);
if(user->cols && user->cols < TERM_COLS_MIN)
user->cols = TERM_COLS_MIN;
user->sex=userdat[U_SEX];
if(!user->sex)
user->sex=' '; /* fix for v1b04 that could save as 0 */
......@@ -574,7 +580,8 @@ int putuserdat(scfg_t* cfg, user_t* user)
putrec(userdat,U_REST,8,ultoa(user->rest,str,16));
putrec(userdat,U_REST+8,2,crlf);
putrec(userdat,U_ROWS,2,ultoa(user->rows,str,10));
putrec(userdat, U_ROWS, LEN_ROWS, ultoa(user->rows,str,10));
putrec(userdat, U_COLS, LEN_COLS, ultoa(user->cols,str,10));
userdat[U_SEX]=user->sex;
userdat[U_PROT]=user->prot;
putrec(userdat,U_MISC,8,ultoa(user->misc,str,16));
......@@ -2868,12 +2875,15 @@ int user_rec_len(int offset)
/* 3 char strings */
case U_TMPEXT:
return(3);
case U_ROWS:
return LEN_ROWS;
case U_COLS:
return LEN_COLS;
/* 2 digits integers (0-99) */
/* 2 digit integers (0-99 or 00-FF) */
case U_LEVEL:
case U_TL:
case U_ROWS:
case U_LEECH: /* actually, 2 hex digits */
case U_LEECH:
return(2);
/* Single digits chars */
......
......@@ -336,7 +336,7 @@ void sbbs_t::useredit(int usernumber)
putuserrec(&cfg,user.number,U_FLAGS4,8
,ultoa(user.flags4,tmp,16));
break;
}
}
}
break;
case 'G':
......@@ -597,7 +597,7 @@ void sbbs_t::useredit(int usernumber)
user.min+=l;
putuserrec(&cfg,user.number,U_MIN,10,ultoa(user.min,tmp,10));
break;
case '#': /* read new user questionaire */
case '#': /* read new user questionnaire */
SAFEPRINTF2(str,"%suser/%4.4u.dat", cfg.data_dir,user.number);
if(!cfg.new_sof[0] || !fexist(str))
break;
......@@ -805,14 +805,15 @@ void sbbs_t::maindflts(user_t* user)
while(online) {
CLS;
getuserdat(&cfg,user);
if(user->rows)
rows=user->rows;
if(user->rows != TERM_ROWS_AUTO)
rows = user->rows;
if(user->cols != TERM_COLS_AUTO)
cols = user->cols;
bprintf(text[UserDefaultsHdr],user->alias,user->number);
long term = (user == &useron) ? term_supports() : user->misc;
if(term&PETSCII)
safe_snprintf(str,sizeof(str),"%sPETSCII %lu %s"
,user->misc&AUTOTERM ? text[TerminalAutoDetect]:nulstr
,cols, text[TerminalColumns]);
safe_snprintf(str,sizeof(str),"%sCBM/PETSCII"
,user->misc&AUTOTERM ? text[TerminalAutoDetect]:nulstr);
else
safe_snprintf(str,sizeof(str),"%s%s / %s %s%s%s"
,user->misc&AUTOTERM ? text[TerminalAutoDetect]:nulstr
......@@ -823,12 +824,10 @@ void sbbs_t::maindflts(user_t* user)
,term&SWAP_DELETE ? "DEL=BS" : nulstr);
add_hotspot('T');
bprintf(text[UserDefaultsTerminal], truncsp(str));
if(user->rows)
ultoa(user->rows,tmp,10);
else
SAFEPRINTF2(tmp,"%s%ld", text[TerminalAutoDetect], rows);
safe_snprintf(str, sizeof(str), "%s%ld %s,", user->cols ? nulstr:text[TerminalAutoDetect], cols, text[TerminalColumns]);
safe_snprintf(tmp, sizeof(tmp), "%s%ld %s", user->rows ? nulstr:text[TerminalAutoDetect], rows, text[TerminalRows]);
add_hotspot('L');
bprintf(text[UserDefaultsRows], tmp, text[TerminalRows]);
bprintf(text[UserDefaultsRows], str, tmp);
if(cfg.total_shells>1) {
add_hotspot('K');
bprintf(text[UserDefaultsCommandSet]
......@@ -1030,13 +1029,21 @@ void sbbs_t::maindflts(user_t* user)
putuserrec(&cfg,user->number,U_TMPEXT,3,cfg.fcomp[i]->ext);
break;
case 'L':
bputs(text[HowManyColumns]);
if((i = getnum(TERM_COLS_MAX)) < 0)
break;
putuserrec(&cfg,user->number,U_COLS,0,ultoa(i,tmp,10));
if(user==&useron) {
useron.cols = i;
ansi_getlines();
}
bputs(text[HowManyRows]);
if((ch=(char)getnum(99))!=-1) {
putuserrec(&cfg,user->number,U_ROWS,2,ultoa(ch,tmp,10));
if(user==&useron) {
useron.rows=ch;
ansi_getlines();
}
if((i = getnum(TERM_ROWS_MAX)) < 0)
break;
putuserrec(&cfg,user->number,U_ROWS,0,ultoa(i,tmp,10));
if(user==&useron) {
useron.rows = i;
ansi_getlines();
}
break;
case 'P':
......
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