Skip to content
Snippets Groups Projects
Commit d5d60752 authored by rswindell's avatar rswindell
Browse files

Using new console properties and method names.

Turns on pass-thru of ctrl keys that interfer with full-screen display
(e.g. Ctrl-P, Ctrl-U, Ctrl-K, Ctrl-T).
Beautified tab line display.
New bail() method (restores original ctrlkey_passthru mask).
Mimized use of ANSI getxy().
parent e536e2c4
No related branches found
No related tags found
No related merge requests found
// sbbsedit.js
// Full-screen message editor for Synchronet v3.10+
// Full-screen message editor for Synchronet v3.10m+
// $Id$
......@@ -10,11 +10,10 @@ const debug=false;
// Message header display format
var hdr_fmt = "\1b\1h%-4s\1n\1b: \1h\1c%.60s\1>\r\n";
var stat_fmt = "\1h\1w\0014 SBBSedit " + REVISION + " - Type \1y/?\1w for help";
var stat_fmt = "\1h\1w\0014 SBBSedit v" + REVISION + " - Type \1y/?\1w for help";
if(debug)
stat_fmt += " row=%d l=%d ";
stat_fmt+="\1>\1n";
var columns = 80;
var tab_size = 4;
load("sbbsdefs.js");
......@@ -29,6 +28,12 @@ var row = 0;
var rows = console.screen_rows;
var fname = argv[0];
var line = new Array();
var ctrlkey_passthru=console.ctrlkey_passthru;
console.ctrlkey_passthru|=(1<<3); // Ctrl-C
console.ctrlkey_passthru|=(1<<11); // Ctrl-K
console.ctrlkey_passthru|=(1<<16); // Ctrl-P
console.ctrlkey_passthru|=(1<<20); // Ctrl-T
console.ctrlkey_passthru|=(1<<21); // Ctrl-U
f = new File(fname);
if(f.open("r")) {
......@@ -54,7 +59,7 @@ show_header();
show_tabline();
home = console.ansi_getxy();
home = console.getxy();
row = home.y;
var l=0;
......@@ -73,18 +78,19 @@ while(bbs.online) {
str=line[l];
if(str==undefined)
str="";
str = console.getstr(str,columns-1,getstr_mode);
str = console.getstr(str,console.screen_columns-1,getstr_mode);
/* Allow "inline" cursor up/down movement using getstr_offset */
if(console.status&(CON_UPARROW|CON_DOWNARROW) && console.getstr_offset!=str.length) {
getstr_mode|=K_USEOFFSET;
console.beep();
} else
getstr_mode&=~K_USEOFFSET;
if(str.length) {
if(console.status&(CON_UPARROW|CON_DOWNARROW) && console.getstr_offset!=str.length)
getstr_mode|=K_USEOFFSET;
else
getstr_mode&=~K_USEOFFSET;
}
/* Commands */
switch(str.toLowerCase()) {
case "/s":
case "/s": /* SAVE */
if(!f.open("w"))
alert("Error " + errno + " opening " + f.name);
else {
......@@ -92,22 +98,21 @@ while(bbs.online) {
f.close();
}
/* fall-through */
case "/abt":
console.clear();
exit();
case "/abt": /* ABORT */
bail();
break;
case "/clr":
case "/clr": /* CLEAR */
line = new Array();
console.ansi_gotoxy(home);
console.gotoxy(home);
show_text(0);
continue;
case "/?":
case "/?": /* HELP */
case "/help":
console.clear();
bbs.menu("editor");
redraw(l);
continue;
case "/attr":
case "/attr": /* ATTRIBUTES */
console.clear();
bbs.menu("attr");
redraw(l);
......@@ -129,7 +134,7 @@ while(bbs.online) {
line.splice(l,1);
if(l) l--;
if(row>home.y) {
console.ansi_up();
console.up();
row--;
}
continue;
......@@ -137,7 +142,7 @@ while(bbs.online) {
if(l) {
l--;
if(row>home.y) {
console.ansi_up();
console.up();
row--;
} else
show_text(l);
......@@ -148,42 +153,49 @@ while(bbs.online) {
if(row+1>=rows)
l=show_text(first_line(l,row));
else {
if(!console.wordwrap.length)
console.crlf();
console.crlf();
row++;
}
}
}
console.clear();
exit();
bail();
function bail()
{
console.clear();
console.ctrlkey_passthru|=(1<<19); // Ctrl-T
exit();
}
function show_text(begin)
{
var save_pos = console.ansi_getxy();
var save_row=row;
console.ansi_gotoxy(home);
console.pushxy();
console.gotoxy(home);
row=home.y;
for(var l=begin; row<rows; l++,row++) {
console.clearline();
if(l < line.length)
console.write(line[l]);
console.putmsg(line[l]);
if(row<rows-1)
console.crlf();
}
console.ansi_gotoxy(save_pos.x, row=save_pos.y);
console.popxy();
row=save_row;
return(l-1);
}
function update_status()
{
console.ansi_save();
console.ansi_gotoxy(1,rows);
console.pushxy();
console.gotoxy(1,rows);
printf(stat_fmt,row,l);
console.ansi_restore();
console.popxy();
}
function show_header()
......@@ -199,14 +211,17 @@ function show_header()
function show_tabline()
{
/* Display tab line */
for(i=0;i<(columns-1);i++)
for(i=0;i<(console.screen_columns-1);i++)
if(i && (i%tab_size)==0) {
if((i%(tab_size*2))==0)
if((i%(tab_size*2))==0) {
console.attributes=CYAN|HIGH;
console.print('|');
else
} else
console.print(ascii(254));
} else
} else {
console.attributes=YELLOW|HIGH;
console.print(ascii(250));
}
console.crlf();
}
......@@ -219,7 +234,7 @@ function redraw(l)
show_tabline();
console.attributes=LIGHTGRAY;
show_text(first_line(l,row));
console.ansi_gotoxy(1,row=save_row);
console.gotoxy(1,row=save_row);
}
function first_line(l,row)
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment