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

Use Graphic().draw() to solve the problem of viewing 80 col ANSIs on

terminals > 80 columns in width (can't depend on line-wrapl).
Still using console.printfile() for ANSIs that scroll.
For SyncTERM, hide the cursor while viewing the ANSI.
Change the calls to console.pause() to just console.getkey() as the
[Hit a Key] prompt would interfere with the display of some art.
parent 1346a86e
No related branches found
No related tags found
No related merge requests found
...@@ -6,6 +6,7 @@ load("funclib.js"); ...@@ -6,6 +6,7 @@ load("funclib.js");
load("filebrowser.js"); load("filebrowser.js");
var Ansi = load({}, "ansiterm_lib.js"); var Ansi = load({}, "ansiterm_lib.js");
var Sauce = load({}, "sauce_lib.js"); var Sauce = load({}, "sauce_lib.js");
var Graphic = load({}, "graphic.js");
Frame.prototype.drawBorder = function(color) { Frame.prototype.drawBorder = function(color) {
var theColor = color; var theColor = color;
...@@ -61,6 +62,7 @@ var state = { ...@@ -61,6 +62,7 @@ var state = {
syncTerm : false, syncTerm : false,
fileList : [], fileList : [],
pausing : false, pausing : false,
drawfx : false,
speed : 0, speed : 0,
browser : null browser : null
}; };
...@@ -80,30 +82,52 @@ var speedMap = [ ...@@ -80,30 +82,52 @@ var speedMap = [
115200 // 11 115200 // 11
]; ];
function draw(file, cols, rows)
{
if(rows > console.screen_rows && cols <= console.screen_columns)
return console.printfile(file, (state.pausing ? P_NONE : P_NOPAUSE) |P_CPM_EOF);
// Use graphic when the entire image fits on the screen
var graphic = new Graphic(cols, rows);
try {
if(!graphic.load(file))
alert("Graphic.load failure: " + file);
else {
if(state.drawfx) // Check this shit out
graphic.drawfx();
else
graphic.draw();
}
} catch(e) {
alert(e);
};
}
function printFile(file) { function printFile(file) {
console.clear(BG_BLACK|LIGHTGRAY); console.clear(BG_BLACK|LIGHTGRAY);
frame.invalidate(); frame.invalidate();
var sauce = Sauce.read(file);
if (state.syncTerm) { if (state.syncTerm) {
Ansi.send("speed", "set", state.speed); Ansi.send("speed", "set", state.speed);
var sauce = Sauce.read(file); Ansi.send("ext_mode", "clear", "cursor");
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); draw(file, sauce.cols, sauce.rows);
console.pause(); console.getkey();
Ansi.send("ext_mode", "clear", "bg_bright_intensity"); Ansi.send("ext_mode", "clear", "bg_bright_intensity");
Ansi.send("ext_mode", "set", "cursor");
Ansi.send("speed", "clear"); Ansi.send("speed", "clear");
} else if (state.speed == 0) { } else if (state.speed == 0) {
console.printfile(file, (state.pausing ? P_NONE : P_NOPAUSE) |P_CPM_EOF); draw(file, sauce.cols, sauce.rows);
console.pause(); console.getkey();
} else { // TODO: terminate on Ctrl-Z char (CPM EOF) } else { // TODO: terminate on Ctrl-Z char (CPM EOF) in the file
var f = new File(file); var f = new File(file);
f.open("r"); f.open("r");
...@@ -121,7 +145,7 @@ function printFile(file) { ...@@ -121,7 +145,7 @@ function printFile(file) {
console.write(contents.splice(0, buf).join("")); console.write(contents.splice(0, buf).join(""));
if (console.inkey(K_NONE, 1) != "") break; if (console.inkey(K_NONE, 1) != "") break;
} }
console.pause(); console.getkey();
bbs.sys_status|=SS_PAUSEON; bbs.sys_status|=SS_PAUSEON;
bbs.sys_status&=(~SS_PAUSEOFF); bbs.sys_status&=(~SS_PAUSEOFF);
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment