2020-07-17 12:05:33 +00:00
|
|
|
load('ansiedit.js');
|
|
|
|
|
2020-07-13 13:08:37 +00:00
|
|
|
load('frame.js');
|
|
|
|
load('tree.js');
|
|
|
|
load('scrollbar.js');
|
|
|
|
load('event-timer.js');
|
|
|
|
load('graphic.js');
|
|
|
|
|
|
|
|
const sauce_lib = load({}, 'sauce_lib.js');
|
|
|
|
if (bbs.mods.avatar_lib) {
|
|
|
|
avatar_lib = bbs.mods.avatar_lib;
|
|
|
|
} else {
|
|
|
|
avatar_lib = load({}, 'avatar_lib.js');
|
|
|
|
}
|
|
|
|
|
|
|
|
var CONTROL_EDIT = '1';
|
|
|
|
|
|
|
|
function edit(fo) {
|
|
|
|
log(LOG_DEBUG,'+ Control EDIT loaded');
|
|
|
|
var complete = false;
|
|
|
|
|
|
|
|
Object.defineProperty(this,'getName', {
|
|
|
|
get: function() {
|
|
|
|
return 'Frame Edit';
|
|
|
|
}
|
|
|
|
});
|
|
|
|
|
|
|
|
Object.defineProperty(this,'isComplete', {
|
|
|
|
get: function() {
|
|
|
|
return complete;
|
|
|
|
}
|
|
|
|
});
|
|
|
|
|
|
|
|
const frames = {
|
|
|
|
parent : null,
|
|
|
|
container : null,
|
|
|
|
highlight : null,
|
|
|
|
scrollbar : null
|
|
|
|
};
|
|
|
|
|
|
|
|
owner = '\1h\1RA\1GN\1BS\1YI\1n\1'+'7\1ktex\1'+'0\1n';
|
|
|
|
|
|
|
|
const frame = new Frame(1,1,console.screen_columns,console.screen_rows,BG_BLACK|LIGHTGRAY);
|
|
|
|
frame.gotoxy(1,1);
|
|
|
|
header = '\1n'+owner+' '.repeat(FRAME_HEADER-console.strlen(owner))+'\1n '+
|
|
|
|
'\1W\1H'+fo.page+' '.repeat(FRAME_PAGENUM-fo.page.length)+' '+
|
|
|
|
'\1G\1H'+' Edit';
|
|
|
|
frame.putmsg(header);
|
|
|
|
frame.open();
|
|
|
|
|
2020-07-17 12:05:33 +00:00
|
|
|
var editor = new ANSIEdit({
|
2020-07-13 13:08:37 +00:00
|
|
|
x: 1,
|
|
|
|
y: 2,
|
|
|
|
width: 80,
|
|
|
|
height: 23,
|
|
|
|
attr: WHITE,
|
|
|
|
//showPosition: true,
|
|
|
|
menuHeading: 'Frame Edit '+fo.page,
|
|
|
|
parentFrame: frame,
|
|
|
|
});
|
|
|
|
|
2020-07-17 12:05:33 +00:00
|
|
|
editor.open();
|
|
|
|
editor.menu.addItem('Save', _save);
|
|
|
|
editor.menu.addItem('Exit', on_exit);
|
|
|
|
editor.menu.addItem('Save & Exit', save_and_exit);
|
2020-07-13 13:08:37 +00:00
|
|
|
|
|
|
|
x = new Graphic;
|
2020-07-17 14:30:49 +00:00
|
|
|
x.ANSI = base64_decode(fo.content);
|
2020-07-13 13:08:37 +00:00
|
|
|
log(LOG_DEBUG,JSON.stringify(x));
|
|
|
|
|
|
|
|
const bin = x.BIN;
|
|
|
|
var o = 0; // offset into 'bin'
|
|
|
|
for (var yy = 0; yy < 22; yy++) {
|
|
|
|
for (var xx = 0; xx < 80; xx++) {
|
2020-07-17 12:05:33 +00:00
|
|
|
editor.putChar({
|
2020-07-13 13:08:37 +00:00
|
|
|
x : xx,
|
|
|
|
y : yy,
|
|
|
|
ch : bin.substr(o, 1),
|
|
|
|
attr : bin.substr(o + 1, 1).charCodeAt(0) || BG_BLACK
|
|
|
|
});
|
|
|
|
o = o + 2;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2020-07-17 12:05:33 +00:00
|
|
|
editor.cycle();
|
2020-07-13 13:08:37 +00:00
|
|
|
frame.cycle();
|
|
|
|
|
|
|
|
this.handle=function(read) {
|
|
|
|
if (! js.terminated && ascii(read) != 27) {
|
|
|
|
|
2020-07-17 12:05:33 +00:00
|
|
|
editor.getcmd(read);
|
|
|
|
editor.cycle();
|
2020-07-13 13:08:37 +00:00
|
|
|
frame.cycle();
|
|
|
|
|
|
|
|
return '';
|
|
|
|
}
|
|
|
|
|
2020-07-17 12:05:33 +00:00
|
|
|
editor.close();
|
2020-07-13 13:08:37 +00:00
|
|
|
frame.close();
|
|
|
|
complete = true;
|
|
|
|
console.clear(LIGHTGRAY);
|
2020-07-17 14:30:49 +00:00
|
|
|
fo.content = base64_encode(editor.exportAnsi().join(''));
|
|
|
|
fo.save();
|
2020-07-13 13:08:37 +00:00
|
|
|
console.putmsg(fo.render());
|
|
|
|
return '';
|
|
|
|
}
|
|
|
|
|
|
|
|
function _save() {
|
|
|
|
log(LOG_DEBUG, '+ FrameEdit save()');
|
|
|
|
}
|
|
|
|
|
|
|
|
function on_exit() {
|
|
|
|
log(LOG_DEBUG, '+ FrameEdit on_exit()');
|
|
|
|
complete = true;
|
|
|
|
console.clear(LIGHTGRAY);
|
|
|
|
console.putmsg(fo.render());
|
|
|
|
}
|
|
|
|
|
|
|
|
function save_and_exit() {
|
|
|
|
_save();
|
|
|
|
on_exit();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
this;
|