Minor changes to edit

This commit is contained in:
Deon George 2020-07-26 09:34:45 +10:00
parent 5293c8cb33
commit a52bda670d

View File

@ -6,13 +6,6 @@ load('scrollbar.js');
load('event-timer.js'); load('event-timer.js');
load('graphic.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'; var CONTROL_EDIT = '1';
function edit(fo) { function edit(fo) {
@ -31,17 +24,12 @@ function edit(fo) {
} }
}); });
const frames = {
parent : null,
container : null,
highlight : null,
scrollbar : null
};
log(LOG_DEBUG,' - Owner: '+JSON.stringify(fo.owner)); log(LOG_DEBUG,' - Owner: '+JSON.stringify(fo.owner));
const frame = new Frame(1,1,console.screen_columns,console.screen_rows,BG_BLACK|LIGHTGRAY); const frame = new Frame(1,1,console.screen_columns,console.screen_rows,BG_BLACK|LIGHTGRAY);
frame.gotoxy(1,1); frame.gotoxy(1,1);
header = '\1n'+fo.owner+' '.repeat(FRAME_HEADER-console.strlen(fo.owner))+'\1n '+
header = '\1n'+fo.pageownerlogo+' '.repeat(FRAME_HEADER-console.strlen(fo.pageownerlogo))+'\1n '+
'\1W\1H'+fo.page+' '.repeat(FRAME_PAGENUM-fo.page.length)+' '+ '\1W\1H'+fo.page+' '.repeat(FRAME_PAGENUM-fo.page.length)+' '+
'\1G\1H'+' Edit'; '\1G\1H'+' Edit';
frame.putmsg(header); frame.putmsg(header);
@ -59,13 +47,13 @@ function edit(fo) {
}); });
editor.open(); editor.open();
editor.menu.addItem('Save', _save); editor.menu.addItem('Properties',properties);
editor.menu.addItem('Exit', on_exit); editor.menu.addItem('Exit',onexit);
editor.menu.addItem('Save & Exit', save_and_exit); editor.menu.addItem('Save & Exit',saveexit);
x = new Graphic; var x = new Graphic;
x.ANSI = base64_decode(fo.content); x.ANSI = fo.parse(base64_decode(fo.content));
log(LOG_DEBUG,JSON.stringify(x)); log(LOG_DEBUG,' - Fields: '+JSON.stringify(fo.frame_fields));
const bin = x.BIN; const bin = x.BIN;
var o = 0; // offset into 'bin' var o = 0; // offset into 'bin'
@ -91,33 +79,39 @@ function edit(fo) {
editor.cycle(); editor.cycle();
frame.cycle(); frame.cycle();
if (! complete)
return '';
// Ignore esc
} else if (ascii(read) == 27) {
return ''; return '';
} }
editor.close(); editor.close();
frame.close(); frame.close();
complete = true;
console.clear(LIGHTGRAY); console.clear(LIGHTGRAY);
fo.content = base64_encode(editor.exportAnsi().join(''));
fo.save();
console.putmsg(fo.render()); console.putmsg(fo.render());
return ''; return '';
} }
function _save() { function properties() {
log(LOG_DEBUG, '+ FrameEdit save()'); log(LOG_DEBUG, '+ FrameEdit properties()');
} }
function on_exit() { function save() {
log(LOG_DEBUG, '+ FrameEdit on_exit()'); fo.content = base64_encode(editor.exportAnsi().join(''));
fo.save();
}
function onexit() {
complete = true; complete = true;
console.clear(LIGHTGRAY);
console.putmsg(fo.render());
} }
function save_and_exit() { function saveexit() {
_save(); save();
on_exit(); onexit();
} }
} }