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');
|
|
|
|
|
2022-04-16 06:06:33 +00:00
|
|
|
var CONTROL_FRAMEEDIT = '1';
|
2020-07-13 13:08:37 +00:00
|
|
|
|
2024-01-01 06:03:25 +00:00
|
|
|
function edit(session) {
|
2020-07-13 13:08:37 +00:00
|
|
|
log(LOG_DEBUG,'+ Control EDIT loaded');
|
|
|
|
var complete = false;
|
2020-07-29 11:56:01 +00:00
|
|
|
var inProperty = false;
|
2020-07-13 13:08:37 +00:00
|
|
|
|
2024-01-01 06:03:25 +00:00
|
|
|
function init(session) {
|
|
|
|
log(LOG_DEBUG,' - Edit init()');
|
|
|
|
}
|
|
|
|
|
2020-07-13 13:08:37 +00:00
|
|
|
Object.defineProperty(this,'getName', {
|
|
|
|
get: function() {
|
|
|
|
return 'Frame Edit';
|
|
|
|
}
|
|
|
|
});
|
|
|
|
|
|
|
|
Object.defineProperty(this,'isComplete', {
|
|
|
|
get: function() {
|
|
|
|
return complete;
|
|
|
|
}
|
|
|
|
});
|
|
|
|
|
2020-07-22 12:37:00 +00:00
|
|
|
log(LOG_DEBUG,' - Owner: '+JSON.stringify(fo.owner));
|
2020-07-25 23:34:45 +00:00
|
|
|
|
2020-07-13 13:08:37 +00:00
|
|
|
const frame = new Frame(1,1,console.screen_columns,console.screen_rows,BG_BLACK|LIGHTGRAY);
|
|
|
|
frame.gotoxy(1,1);
|
2020-07-25 23:34:45 +00:00
|
|
|
|
2022-04-16 05:36:17 +00:00
|
|
|
header = '\1n'+fo.pageownerlogo+' '.repeat(fo.settings.FRAME_HEADER-console.strlen(fo.pageownerlogo))+'\1n '+
|
|
|
|
'\1W\1H'+fo.page+' '.repeat(fo.settings.FRAME_PAGENUM-fo.page.length)+' '+
|
2020-07-13 13:08:37 +00:00
|
|
|
'\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();
|
2020-07-25 23:34:45 +00:00
|
|
|
editor.menu.addItem('Properties',properties);
|
|
|
|
editor.menu.addItem('Exit',onexit);
|
|
|
|
editor.menu.addItem('Save & Exit',saveexit);
|
2020-07-13 13:08:37 +00:00
|
|
|
|
2020-07-25 23:34:45 +00:00
|
|
|
var x = new Graphic;
|
|
|
|
x.ANSI = fo.parse(base64_decode(fo.content));
|
|
|
|
log(LOG_DEBUG,' - Fields: '+JSON.stringify(fo.frame_fields));
|
2020-07-13 13:08:37 +00:00
|
|
|
|
|
|
|
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) {
|
2022-04-16 05:36:17 +00:00
|
|
|
if (! js.terminated) {
|
|
|
|
switch (ascii(read)) {
|
|
|
|
case 26:
|
|
|
|
if (inProperty) {
|
|
|
|
propFrame.close();
|
|
|
|
frame.top();
|
|
|
|
frame.cycle();
|
|
|
|
inProperty = false;
|
|
|
|
|
|
|
|
} else {
|
|
|
|
properties();
|
|
|
|
}
|
|
|
|
|
|
|
|
return '';
|
|
|
|
|
|
|
|
case 27:
|
|
|
|
if (inProperty) {
|
|
|
|
log(LOG_DEBUG, ' + FrameEdit properties(): ESC');
|
|
|
|
propFrame.close();
|
|
|
|
frame.top();
|
|
|
|
frame.cycle();
|
|
|
|
inProperty = false;
|
|
|
|
}
|
|
|
|
|
|
|
|
return '';
|
|
|
|
|
|
|
|
default:
|
|
|
|
if (inProperty) {
|
|
|
|
log(LOG_DEBUG, ' + FrameEdit properties(): read');
|
|
|
|
propFrame.putmsg(read);
|
|
|
|
propFrame.cycle();
|
|
|
|
|
|
|
|
} else {
|
|
|
|
editor.getcmd(read);
|
|
|
|
editor.cycle();
|
|
|
|
frame.cycle();
|
|
|
|
}
|
|
|
|
|
|
|
|
if (! complete)
|
|
|
|
return '';
|
2020-07-29 11:56:01 +00:00
|
|
|
}
|
2020-07-13 13:08:37 +00:00
|
|
|
}
|
|
|
|
|
2020-07-17 12:05:33 +00:00
|
|
|
editor.close();
|
2020-07-13 13:08:37 +00:00
|
|
|
frame.close();
|
2022-04-16 05:36:17 +00:00
|
|
|
fo.render();
|
2020-07-25 23:34:45 +00:00
|
|
|
|
2020-07-13 13:08:37 +00:00
|
|
|
return '';
|
|
|
|
}
|
|
|
|
|
2020-07-25 23:34:45 +00:00
|
|
|
function properties() {
|
2020-07-29 11:56:01 +00:00
|
|
|
inProperty = true;
|
2020-07-25 23:34:45 +00:00
|
|
|
log(LOG_DEBUG, '+ FrameEdit properties()');
|
2020-07-29 11:56:01 +00:00
|
|
|
frame.bottom();
|
|
|
|
propFrame = new Frame(1,2,40,14,BG_BLUE|WHITE,frame);
|
|
|
|
propFrame.gotoxy(1,1);
|
|
|
|
propFrame.putmsg('Properties!');
|
|
|
|
propFrame.open();
|
|
|
|
propFrame.cycle();
|
2020-07-25 23:34:45 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
function save() {
|
|
|
|
fo.content = base64_encode(editor.exportAnsi().join(''));
|
|
|
|
fo.save();
|
2020-07-13 13:08:37 +00:00
|
|
|
}
|
|
|
|
|
2020-07-25 23:34:45 +00:00
|
|
|
function onexit() {
|
2020-07-13 13:08:37 +00:00
|
|
|
complete = true;
|
|
|
|
}
|
|
|
|
|
2020-07-25 23:34:45 +00:00
|
|
|
function saveexit() {
|
|
|
|
save();
|
|
|
|
onexit();
|
2020-07-13 13:08:37 +00:00
|
|
|
}
|
|
|
|
|
2024-01-01 06:03:25 +00:00
|
|
|
init.apply(this,arguments);
|
|
|
|
}
|