Skip to content
Snippets Groups Projects
Commit a42f6a8e authored by Deucе's avatar Deucе :ok_hand_tone4:
Browse files

Add CTRL-S to "save"

This simply writes changed values to ctrl/textedit.ini, you can
copy these into the appropriate text.ini or text.dat.

I haven't dug in to see if text.dat has different encoding than ini
or anything, and I think that if you want to use this to build a
full text.dat, you would want to do it a bit at a time, so a follow-
on utility to convert text.ini to text.dat is likely the easiest way
to do this stuff.
parent 079898d4
No related branches found
No related tags found
No related merge requests found
......@@ -11,6 +11,7 @@ var msglens = [];
var displaywith = 0;
var inprow = (console.screen_columns < 80) ? 18 : 17;
var ch;
var modified = {};
// TODO: This should be in a separate (JSON) file...
var details = {
......@@ -139,8 +140,6 @@ console.cleartoeos = function(attr)
function format_entry(str)
{
// bbs.command_str = '@';
// .replace(/@/g, "@U+40:@@")
return str.replace(/[\x00-\x1F\x80-\x9F\\]/g, function(match) {
switch(match) {
case '\n':
......@@ -407,12 +406,27 @@ function get_msgnum()
console.attributes = 7;
}
function track_mod()
{
if (modified[msg] === undefined) {
modified[msg] = {original: bbs.text(msg), modified: true};
}
}
function check_undone()
{
if (modified[msg] !== undefined && msgstr === modified[msg].original) {
delete modified[msg];
}
}
get_tvals();
newmsg();
var done = false;
var skip_redraw = false;
var forcectrl = false;
var tmp;
var sfile;
while (!done) {
if (!skip_redraw)
redraw(msgstr, msg);
......@@ -464,15 +478,28 @@ while (!done) {
break;
case ctrl('Z'):
bbs.revert_text(msg);
if (modified[msg] !== undefined)
delete modified[msg];
newmsg();
break;
case ctrl('Q'):
done = true;
break;
case ctrl('S'):
sfile = new File("textedit.ini");
if (!sfile.open(sfile.exists ? 'r+':'w+'))
break;
for (tmp in modified) {
sfile.iniSetValue(null, tnames[tmp], bbs.text(tmp));
}
sfile.close();
break;
case '\b':
if (pos) {
track_mod();
msgstr = msgstr.slice(0, pos - 1) + msgstr.slice(pos);
bbs.replace_text(msg, msgstr);
check_undone();
pos--;
newmsg(false);
}
......@@ -543,8 +570,10 @@ while (!done) {
default:
if (ch < ' ' && !forcectrl)
break;
track_mod();
msgstr = msgstr.slice(0, pos) + ch + msgstr.slice(pos);
bbs.replace_text(msg, msgstr);
check_undone();
pos++;
newmsg(false);
break;
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment