Skip to content
Snippets Groups Projects
Commit a37339d3 authored by echicken's avatar echicken
Browse files

Just some formatting changes that I made

while perusing this earlier.
parent 4984ef41
No related branches found
No related tags found
No related merge requests found
...@@ -9,35 +9,37 @@ var Sauce = load({}, "sauce_lib.js"); ...@@ -9,35 +9,37 @@ var Sauce = load({}, "sauce_lib.js");
Frame.prototype.drawBorder = function(color) { Frame.prototype.drawBorder = function(color) {
var theColor = color; var theColor = color;
if(Array.isArray(color)); if (Array.isArray(color)) {
var sectionLength = Math.round(this.width / color.length); var sectionLength = Math.round(this.width / color.length);
}
this.pushxy(); this.pushxy();
for (var y = 1; y <= this.height; y++) { for (var y = 1; y <= this.height; y++) {
for (var x = 1; x <= this.width; x++) { for (var x = 1; x <= this.width; x++) {
if(x > 1 && x < this.width && y > 1 && y < this.height) if (x > 1 && x < this.width && y > 1 && y < this.height) continue;
continue;
var msg; var msg;
this.gotoxy(x, y); this.gotoxy(x, y);
if(y == 1 && x == 1) if (y == 1 && x == 1) {
msg = ascii(218); msg = ascii(218);
else if(y == 1 && x == this.width) } else if (y == 1 && x == this.width) {
msg = ascii(191); msg = ascii(191);
else if(y == this.height && x == 1) } else if (y == this.height && x == 1) {
msg = ascii(192); msg = ascii(192);
else if(y == this.height && x == this.width) } else if (y == this.height && x == this.width) {
msg = ascii(217); msg = ascii(217);
else if(x == 1 || x == this.width) } else if (x == 1 || x == this.width) {
msg = ascii(179); msg = ascii(179);
else } else {
msg = ascii(196); msg = ascii(196);
}
if (Array.isArray(color)) { if (Array.isArray(color)) {
if(x == 1) if (x == 1) {
theColor = color[0]; theColor = color[0];
else if(x % sectionLength == 0 && x < this.width) } else if (x % sectionLength == 0 && x < this.width) {
theColor = color[x / sectionLength]; theColor = color[x / sectionLength];
else if(x == this.width) } else if (x == this.width) {
theColor = color[color.length - 1]; theColor = color[color.length - 1];
} }
}
this.putmsg(msg, theColor); this.putmsg(msg, theColor);
} }
} }
...@@ -54,13 +56,13 @@ var root = js.exec_dir, ...@@ -54,13 +56,13 @@ var root = js.exec_dir,
pauseFrame; pauseFrame;
var state = { var state = {
'status' : bbs.sys_status, status : bbs.sys_status,
'attr' : console.attributes, attr : console.attributes,
'syncTerm' : false, syncTerm : false,
'fileList' : [], fileList : [],
'pausing' : false, pausing : false,
'speed' : 0, speed : 0,
'browser' : null browser : null
}; };
var speedMap = [ var speedMap = [
...@@ -78,7 +80,7 @@ var speedMap = [ ...@@ -78,7 +80,7 @@ var speedMap = [
115200 // 11 115200 // 11
]; ];
var printFile = function(file) { function printFile(file) {
console.clear(BG_BLACK|LIGHTGRAY); console.clear(BG_BLACK|LIGHTGRAY);
frame.invalidate(); frame.invalidate();
...@@ -87,8 +89,9 @@ var printFile = function(file) { ...@@ -87,8 +89,9 @@ var printFile = function(file) {
Ansi.send("speed", "set", state.speed); Ansi.send("speed", "set", state.speed);
var sauce = Sauce.read(file); var sauce = Sauce.read(file);
if(sauce.ice_color) if (sauce.ice_color) {
Ansi.send("ext_mode", "set", "bg_bright_intensity"); Ansi.send("ext_mode", "set", "bg_bright_intensity");
}
mswait(500); mswait(500);
console.printfile(file, (state.pausing ? P_NONE : P_NOPAUSE) |P_CPM_EOF); console.printfile(file, (state.pausing ? P_NONE : P_NOPAUSE) |P_CPM_EOF);
console.pause(); console.pause();
...@@ -116,8 +119,7 @@ var printFile = function(file) { ...@@ -116,8 +119,7 @@ var printFile = function(file) {
while (contents.length > 0) { while (contents.length > 0) {
console.write(contents.splice(0, buf).join("")); console.write(contents.splice(0, buf).join(""));
if(console.inkey(K_NONE, 1) != "") if (console.inkey(K_NONE, 1) != "") break;
break;
} }
console.pause(); console.pause();
...@@ -131,7 +133,7 @@ var printFile = function(file) { ...@@ -131,7 +133,7 @@ var printFile = function(file) {
} }
// Basic check for SyncTERM; we don't really care which version it is // Basic check for SyncTERM; we don't really care which version it is
var isSyncTerm = function() { function isSyncTerm() {
console.clear(BG_BLACK|LIGHTGRAY); console.clear(BG_BLACK|LIGHTGRAY);
console.write("Checking for SyncTERM ..."); console.write("Checking for SyncTERM ...");
...@@ -144,8 +146,7 @@ var isSyncTerm = function() { ...@@ -144,8 +146,7 @@ var isSyncTerm = function() {
console.write("\x1B[0c"); console.write("\x1B[0c");
while (cTerm.length > 0) { while (cTerm.length > 0) {
if(console.inkey(K_NONE, 5000) == cTerm.shift()) if (console.inkey(K_NONE, 5000) == cTerm.shift()) continue;
continue;
ret = false; ret = false;
break; break;
} }
...@@ -156,14 +157,14 @@ var isSyncTerm = function() { ...@@ -156,14 +157,14 @@ var isSyncTerm = function() {
} }
var showSpeed = function() { function showSpeed() {
speedFrame.clear(); speedFrame.clear();
speedFrame.putmsg( speedFrame.putmsg(
(state.speed == 0) ? "Full" : speedMap[state.speed] (state.speed == 0) ? "Full" : speedMap[state.speed]
); );
} }
var showPause = function() { function showPause() {
pauseFrame.clear(); pauseFrame.clear();
pauseFrame.putmsg((state.pausing) ? "On" : "Off"); pauseFrame.putmsg((state.pausing) ? "On" : "Off");
} }
...@@ -171,12 +172,12 @@ var showPause = function() { ...@@ -171,12 +172,12 @@ var showPause = function() {
var GalleryChooser = function() { var GalleryChooser = function() {
var frames = { var frames = {
'frame' : null, frame : null,
'tree' : null, tree : null,
'scrollBar' : null scrollBar : null
}; };
var getList = function() { function getList() {
var f = new File(root + "settings.ini"); var f = new File(root + "settings.ini");
f.open("r"); f.open("r");
var galleries = f.iniGetAllObjects(); var galleries = f.iniGetAllObjects();
...@@ -243,7 +244,7 @@ var GalleryChooser = function() { ...@@ -243,7 +244,7 @@ var GalleryChooser = function() {
} }
var initDisplay = function() { function initDisplay() {
console.clear(BG_BLACK|LIGHTGRAY); console.clear(BG_BLACK|LIGHTGRAY);
...@@ -273,10 +274,7 @@ var initDisplay = function() { ...@@ -273,10 +274,7 @@ var initDisplay = function() {
frame frame
); );
statusBarFrame.putmsg( statusBarFrame.putmsg(
format( format("%-41s%-16s%-13s", "Area:","S)peed:","P)ause:")
"%-41s%-16s%-13s",
"Area:","S)peed:","P)ause:"
)
); );
statusBarFrame.gotoxy(statusBarFrame.width - 4, 1); statusBarFrame.gotoxy(statusBarFrame.width - 4, 1);
statusBarFrame.putmsg("Q)uit"); statusBarFrame.putmsg("Q)uit");
...@@ -318,7 +316,7 @@ var initDisplay = function() { ...@@ -318,7 +316,7 @@ var initDisplay = function() {
} }
var initSettings = function() { function initSettings() {
var f = new File(js.exec_dir + "settings.ini"); var f = new File(js.exec_dir + "settings.ini");
f.open("r"); f.open("r");
settings = f.iniGetObject(); settings = f.iniGetObject();
...@@ -330,29 +328,20 @@ var initSettings = function() { ...@@ -330,29 +328,20 @@ var initSettings = function() {
settings.sfg = getColor(settings.sfg); settings.sfg = getColor(settings.sfg);
settings.sbg = getColor(settings.sbg); settings.sbg = getColor(settings.sbg);
settings.border = settings.border.split(","); settings.border = settings.border.split(",");
settings.border.forEach( settings.border.forEach(function (e, i, a) { a[i] = getColor(e); });
function(e, i, a) {
a[i] = getColor(e);
}
);
} }
var init = function() { function init() {
bbs.sys_status|=(SS_MOFF|SS_PAUSEON); bbs.sys_status|=(SS_MOFF|SS_PAUSEON);
bbs.sys_status&=(~SS_PAUSEOFF); bbs.sys_status&=(~SS_PAUSEOFF);
state.syncTerm = isSyncTerm(); state.syncTerm = isSyncTerm();
initSettings(); initSettings();
initDisplay(); initDisplay();
state.browser = new GalleryChooser(); state.browser = new GalleryChooser();
state.browser.open(); state.browser.open();
} }
var cleanUp = function() { function cleanUp() {
frame.close(); frame.close();
bbs.sys_status = state.status; bbs.sys_status = state.status;
console.attributes = state.attr; console.attributes = state.attr;
...@@ -360,7 +349,7 @@ var cleanUp = function() { ...@@ -360,7 +349,7 @@ var cleanUp = function() {
exit(0); exit(0);
} }
var handleInput = function(userInput) { function handleInput(userInput) {
switch (userInput) { switch (userInput) {
case "P": case "P":
state.pausing = (state.pausing) ? false : true; state.pausing = (state.pausing) ? false : true;
...@@ -386,15 +375,14 @@ var handleInput = function(userInput) { ...@@ -386,15 +375,14 @@ var handleInput = function(userInput) {
} }
} }
var main = function() { function main() {
while (!js.terminated) { while (!js.terminated) {
handleInput(console.inkey(K_NONE, 5).toUpperCase()); handleInput(console.inkey(K_NONE, 5).toUpperCase());
state.browser.cycle(); state.browser.cycle();
if(frame.cycle()) if (frame.cycle()) {
console.gotoxy(console.screen_columns, console.screen_rows); console.gotoxy(console.screen_columns, console.screen_rows);
} }
}
} }
init(); init();
......
(function() { (function() {
var onLoad = function(files) { function onLoad(files) {
if(files.length < 1) if (files.length < 1) return;
return;
files = files.filter( files = files.filter(
function (file) { function (file) {
var ext = file_getext(file); var ext = file_getext(file);
if(typeof ext != "undefined" && ext.toLowerCase() == ".zip" && file_isdir(file.replace(ext, ""))) if (typeof ext != "undefined" &&
ext.toLowerCase() == ".zip" &&
file_isdir(file.replace(ext, ""))
) {
return false; return false;
} else {
return true; return true;
} }
}
); );
var path = files[0].replace(file_getname(files[0]), ""); var path = files[0].replace(file_getname(files[0]), "");
...@@ -27,30 +31,31 @@ ...@@ -27,30 +31,31 @@
} }
var onFile = function(file) { function onFile(file) {
var fn = file_getname(file); var fn = file_getname(file);
if (typeof this.descriptions == "undefined") this.descriptions = {};
if(typeof this.descriptions == "undefined")
this.descriptions = {};
var ret = format( var ret = format(
"%-25s%s", "%-25s%s",
file_isdir(file) ? ("[" + fn + "]") : fn, file_isdir(file) ? ("[" + fn + "]") : fn,
typeof this.descriptions[fn.toLowerCase()] == "undefined" ? "" : (" " + this.descriptions[fn.toLowerCase()]) typeof this.descriptions[fn.toLowerCase()] == "undefined"
? ""
: (" " + this.descriptions[fn.toLowerCase()])
); );
return ret; return ret;
} }
var onSelect = function(file) { function onSelect(file) {
var ext = file_getext(file); var ext = file_getext(file);
if (typeof ext != "undefined" && ext.toLowerCase() == ".zip") { if (typeof ext != "undefined" && ext.toLowerCase() == ".zip") {
var destDir = file.replace(ext, ""); var destDir = file.replace(ext, "");
if(!file_isdir(destDir)) if (!file_isdir(destDir)) {
system.exec(system.exec_dir + 'unzip -o -qq "' + file + '" -d "' + destDir + '"'); system.exec(
if(file_isdir(destDir)) system.exec_dir + 'unzip -o -qq "' + file + '" -d "' + destDir + '"'
this.path = destDir; );
}
if (file_isdir(destDir)) this.path = destDir;
} else { } else {
printFile(file); printFile(file);
} }
...@@ -61,18 +66,22 @@ ...@@ -61,18 +66,22 @@
var hide = [".", "ansiview.ini", "ANSIVIEW.INI"]; var hide = [".", "ansiview.ini", "ANSIVIEW.INI"];
var fileBrowser = new FileBrowser( var fileBrowser = new FileBrowser(
{ 'path' : args.path, { path : args.path,
'top' : args.path, top : args.path,
'frame' : browserFrame, frame : browserFrame,
'colors' : { colors : {
'lfg' : args.colors.lfg, lfg : args.colors.lfg,
'lbg' : args.colors.lbg, lbg : args.colors.lbg,
'fg' : args.colors.fg, fg : args.colors.fg,
'bg' : args.colors.bg, bg : args.colors.bg,
'sfg' : args.colors.sfg, sfg : args.colors.sfg,
'sbg' : args.colors.sbg sbg : args.colors.sbg
}, },
'hide' : (typeof args.hide == "undefined") ? hide : hide.concat(args.hide.split(",")) hide : (
typeof args.hide == "undefined")
? hide
: hide.concat(args.hide.split(",")
)
} }
); );
fileBrowser.on("load", onLoad); fileBrowser.on("load", onLoad);
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment