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

This change allow with an upcoming change to text.dat allows > 25 chars

of external program names to be displayed:
32 chars in multicolumn mode
40 chars in singlecolumn mode

New modopts.ini [xtrn_sec] keys:
- multicolumn_separator (default: " ")
- singlecolumn_margin (default: 7)
- singlecolumn_height (default: screen rows - singlecolumn_margin)
- singlecolumn_lstfmt (default: "\x01h\x01c%3u \xb3 \x01n\x01c%s\x01h ")
parent 9de5492a
No related branches found
No related tags found
No related merge requests found
...@@ -32,15 +32,24 @@ if((options=load({}, "modopts.js","xtrn_sec")) == null) ...@@ -32,15 +32,24 @@ if((options=load({}, "modopts.js","xtrn_sec")) == null)
if(options.multicolumn == undefined) if(options.multicolumn == undefined)
options.multicolumn = true; options.multicolumn = true;
if(options.multicolumn_separator == undefined)
options.multicolumn_separator = " ";
if(options.singlecolumn_margin == undefined)
options.singlecolumn_margin = 7;
if(options.singlecolumn_height == undefined)
options.singlecolumn_height = console.screen_rows - options.singlecolumn_margin;
if(console.screen_columns < 80) if(console.screen_columns < 80)
options.multicolumn = false; options.multicolumn = false;
function sort_by_name(a, b) function sort_by_name(a, b)
{ {
if(a.name.toLowerCase()>b.name.toLowerCase()) return 1; if(a.name.toLowerCase()>b.name.toLowerCase()) return 1;
if(a.name.toLowerCase()<b.name.toLowerCase()) return -1; if(a.name.toLowerCase()<b.name.toLowerCase()) return -1;
return 0; return 0;
} }
function exec_xtrn(prog) function exec_xtrn(prog)
{ {
...@@ -49,7 +58,7 @@ function exec_xtrn(prog) ...@@ -49,7 +58,7 @@ function exec_xtrn(prog)
if(options.eval_before_exec) if(options.eval_before_exec)
eval(options.eval_before_exec); eval(options.eval_before_exec);
load('fonts.js', 'xtrn:' + prog.code); load('fonts.js', 'xtrn:' + prog.code);
bbs.exec_xtrn(prog.code); bbs.exec_xtrn(prog.code);
console.attributes = 0; console.attributes = 0;
console.attributes = LIGHTGRAY; console.attributes = LIGHTGRAY;
load('fonts.js', 'default'); load('fonts.js', 'default');
...@@ -79,60 +88,63 @@ function external_program_menu(xsec) ...@@ -79,60 +88,63 @@ function external_program_menu(xsec)
if(!prog_list.length) { if(!prog_list.length) {
write(bbs.text(NoXtrnPrograms)); write(bbs.text(NoXtrnPrograms));
console.pause(); console.pause();
break; break;
} }
// If there's only one program available to the user in the section, just run it (or try to) // If there's only one program available to the user in the section, just run it (or try to)
if(options.autoexec && prog_list.length == 1) { if(options.autoexec && prog_list.length == 1) {
exec_xtrn(prog_list[0]); exec_xtrn(prog_list[0]);
break; break;
} }
if(bbs.menu_exists("xtrn" + (xtrn_area.sec_list[xsec].number+1))) { if(bbs.menu_exists("xtrn" + (xtrn_area.sec_list[xsec].number+1))) {
bbs.menu("xtrn" + (xtrn_area.sec_list[xsec].number+1)); bbs.menu("xtrn" + (xtrn_area.sec_list[xsec].number+1));
} }
else { else {
var multicolumn = options.multicolumn && prog_list.length > options.singlecolumn_height;
if(options.sort) if(options.sort)
prog_list.sort(sort_by_name); prog_list.sort(sort_by_name);
printf(bbs.text(XtrnProgLstHdr),xtrn_area.sec_list[xsec].name); printf(bbs.text(XtrnProgLstHdr),xtrn_area.sec_list[xsec].name);
write(bbs.text(XtrnProgLstTitles)); write(bbs.text(XtrnProgLstTitles));
if(options.multicolumn && prog_list.length >= 10) { if(multicolumn) {
write(" "); write(options.multicolumn_separator);
write(bbs.text(XtrnProgLstTitles)); write(bbs.text(XtrnProgLstTitles));
} }
console.crlf(); console.crlf();
write(bbs.text(XtrnProgLstUnderline)); write(bbs.text(XtrnProgLstUnderline));
if(options.multicolumn && prog_list.length >= 10) { if(multicolumn) {
write(" "); write(options.multicolumn_separator);
write(bbs.text(XtrnProgLstUnderline)); write(bbs.text(XtrnProgLstUnderline));
} }
console.crlf(); console.crlf();
var n; var n;
if(options.multicolumn && prog_list.length >= 10) if(multicolumn)
n=Math.floor(prog_list.length/2)+(prog_list.length&1); n=Math.floor(prog_list.length/2)+(prog_list.length&1);
else else
n=prog_list.length; n=prog_list.length;
for(i=0;i<n && !console.aborted;i++) { for(i=0;i<n && !console.aborted;i++) {
printf(bbs.text(XtrnProgLstFmt),i+1 printf(multicolumn ? bbs.text(XtrnProgLstFmt)
: (options.singlecolumn_lstfmt
|| "\x01h\x01c%3u \xb3 \x01n\x01c%s\x01h ")
,i+1
,prog_list[i].name ,prog_list[i].name
,prog_list[i].cost); ,prog_list[i].cost);
if(options.multicolumn if(multicolumn) {
&& prog_list.length>=10) {
j=Math.floor(prog_list.length/2)+i+(prog_list.length&1); j=Math.floor(prog_list.length/2)+i+(prog_list.length&1);
if(j<prog_list.length) { if(j<prog_list.length) {
write(" "); write(options.multicolumn_separator);
printf(bbs.text(XtrnProgLstFmt),j+1 printf(bbs.text(XtrnProgLstFmt),j+1
,prog_list[j].name ,prog_list[j].name
,prog_list[j].cost); ,prog_list[j].cost);
} }
} }
console.crlf(); console.crlf();
} }
bbs.node_sync(); bbs.node_sync();
console.mnemonics(bbs.text(WhichXtrnProg)); console.mnemonics(bbs.text(WhichXtrnProg));
} }
system.node_list[bbs.node_num-1].aux=0; /* aux is 0, only if at menu */ system.node_list[bbs.node_num-1].aux=0; /* aux is 0, only if at menu */
bbs.node_action=NODE_XTRN; bbs.node_action=NODE_XTRN;
...@@ -144,7 +156,7 @@ function external_program_menu(xsec) ...@@ -144,7 +156,7 @@ function external_program_menu(xsec)
bbs.menu("xtrn/" + prog_list[i].code); bbs.menu("xtrn/" + prog_list[i].code);
console.line_counter=0; console.line_counter=0;
} }
exec_xtrn(prog_list[i]); exec_xtrn(prog_list[i]);
} }
} }
...@@ -162,7 +174,7 @@ function external_section_menu() ...@@ -162,7 +174,7 @@ function external_section_menu()
if(!xtrn_area.sec_list.length) { if(!xtrn_area.sec_list.length) {
write(bbs.text(NoXtrnPrograms)); write(bbs.text(NoXtrnPrograms));
break; break;
} }
var xsec=0; var xsec=0;
...@@ -180,13 +192,13 @@ function external_section_menu() ...@@ -180,13 +192,13 @@ function external_section_menu()
xsec--; xsec--;
} }
else { else {
if(options.sort) if(options.sort)
sec_list.sort(sort_by_name); sec_list.sort(sort_by_name);
for(i in sec_list) for(i in sec_list)
console.uselect(Number(i),"External Program Section" console.uselect(Number(i),"External Program Section"
,sec_list[i].name); ,sec_list[i].name);
xsec=console.uselect(); xsec=console.uselect();
} }
if(xsec<0) if(xsec<0)
break; break;
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment