Skip to content
Snippets Groups Projects
Commit f2d63612 authored by Craig Hendricks's avatar Craig Hendricks
Browse files

Merge branch sbbs:master into massive-mrc-update-20250303

parents c4c6bdb1 69adca05
No related branches found
No related tags found
No related merge requests found
Pipeline #8608 failed
require("sbbsdefs.js", "K_NUL");
function SyncTERMCache() { function SyncTERMCache() {
this.supported = this.supports_syncterm_cache(); this.supported = this.supports_syncterm_cache();
}; };
...@@ -14,7 +16,7 @@ SyncTERMCache.prototype.read_apc = function (timeout) ...@@ -14,7 +16,7 @@ SyncTERMCache.prototype.read_apc = function (timeout)
if (timeout === undefined) if (timeout === undefined)
timeout = 1000; timeout = 1000;
while((ch = console.inkey(timeout)) !== '') { while((ch = console.inkey(K_NUL, timeout)) !== null) {
switch(state) { switch(state) {
case 0: case 0:
if (ch == '\x1b') { if (ch == '\x1b') {
......
...@@ -11,6 +11,7 @@ var msglens = []; ...@@ -11,6 +11,7 @@ var msglens = [];
var displaywith = 0; var displaywith = 0;
var inprow = (console.screen_columns < 80) ? 18 : 17; var inprow = (console.screen_columns < 80) ? 18 : 17;
var ch; var ch;
var modified = {};
// TODO: This should be in a separate (JSON) file... // TODO: This should be in a separate (JSON) file...
var details = { var details = {
...@@ -139,8 +140,6 @@ console.cleartoeos = function(attr) ...@@ -139,8 +140,6 @@ console.cleartoeos = function(attr)
function format_entry(str) function format_entry(str)
{ {
// bbs.command_str = '@';
// .replace(/@/g, "@U+40:@@")
return str.replace(/[\x00-\x1F\x80-\x9F\\]/g, function(match) { return str.replace(/[\x00-\x1F\x80-\x9F\\]/g, function(match) {
switch(match) { switch(match) {
case '\n': case '\n':
...@@ -345,8 +344,7 @@ function get_tvals() { ...@@ -345,8 +344,7 @@ function get_tvals() {
for (i in tvals) { for (i in tvals) {
tnames[tvals[i]] = i; tnames[tvals[i]] = i;
} }
// TODO: Why is this one higher than the last? last_entry = tvals.TOTAL_TEXT;
last_entry = tvals.TOTAL_TEXT - 1;
} }
function newmsg(updpos) function newmsg(updpos)
...@@ -408,12 +406,43 @@ function get_msgnum() ...@@ -408,12 +406,43 @@ function get_msgnum()
console.attributes = 7; 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];
}
}
function load_saved()
{
var sfile = new File("textedit.ini");
if (!sfile.open('r'))
return;
var keys = sfile.iniGetKeys();
var key;
var str;
for (key in keys) {
str = sfile.iniGetValue(null, keys[key]);
bbs.replace_text(keys[key], str);
}
sfile.close();
}
get_tvals(); get_tvals();
newmsg(); newmsg();
load_saved();
var done = false; var done = false;
var skip_redraw = false; var skip_redraw = false;
var forcectrl = false; var forcectrl = false;
var tmp; var tmp;
var sfile;
while (!done) { while (!done) {
if (!skip_redraw) if (!skip_redraw)
redraw(msgstr, msg); redraw(msgstr, msg);
...@@ -465,15 +494,27 @@ while (!done) { ...@@ -465,15 +494,27 @@ while (!done) {
break; break;
case ctrl('Z'): case ctrl('Z'):
bbs.revert_text(msg); bbs.revert_text(msg);
if (modified[msg] !== undefined)
delete modified[msg];
newmsg(); newmsg();
break; break;
case ctrl('Q'): case ctrl('Q'):
done = true; done = true;
break; 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': case '\b':
if (pos) { if (pos) {
track_mod();
msgstr = msgstr.slice(0, pos - 1) + msgstr.slice(pos); msgstr = msgstr.slice(0, pos - 1) + msgstr.slice(pos);
bbs.replace_text(msg, msgstr); bbs.replace_text(msg, msgstr);
check_undone();
pos--; pos--;
newmsg(false); newmsg(false);
} }
...@@ -544,8 +585,10 @@ while (!done) { ...@@ -544,8 +585,10 @@ while (!done) {
default: default:
if (ch < ' ' && !forcectrl) if (ch < ' ' && !forcectrl)
break; break;
track_mod();
msgstr = msgstr.slice(0, pos) + ch + msgstr.slice(pos); msgstr = msgstr.slice(0, pos) + ch + msgstr.slice(pos);
bbs.replace_text(msg, msgstr); bbs.replace_text(msg, msgstr);
check_undone();
pos++; pos++;
newmsg(false); newmsg(false);
break; break;
......
...@@ -100,8 +100,7 @@ int sbbs_t::bputs(const char *str, int mode) ...@@ -100,8 +100,7 @@ int sbbs_t::bputs(const char *str, int mode)
if (!(mode & P_NOATCODES) && str[l] == '@') { if (!(mode & P_NOATCODES) && str[l] == '@') {
if (str == mnestr /* Mnemonic string or */ if (str == mnestr /* Mnemonic string or */
|| (mode & P_ATCODES) /* trusted parameters to formatted string */ || (mode & P_ATCODES) /* trusted parameters to formatted string */
|| (str >= text[0] /* Straight out of TEXT.DAT */ ) {
&& str <= text[TOTAL_TEXT - 1])) {
i = show_atcode(str + l); /* return 0 if not valid @ code */ i = show_atcode(str + l); /* return 0 if not valid @ code */
l += i; /* i is length of code string */ l += i; /* i is length of code string */
if (i) /* if valid string, go to top */ if (i) /* if valid string, go to top */
......
...@@ -269,7 +269,7 @@ int main(int argc, char **argv) ...@@ -269,7 +269,7 @@ int main(int argc, char **argv)
fputs("#endif\n", text_h); fputs("#endif\n", text_h);
fclose(text_h); fclose(text_h);
fputs("\n", text_js); fputs("\n", text_js);
fprintf(text_js, "var TOTAL_TEXT=%d;\n", i); fprintf(text_js, "var TOTAL_TEXT=%d;\n", i - 1);
fprintf(text_js, "\nthis;\n"); fprintf(text_js, "\nthis;\n");
fclose(text_js); fclose(text_js);
fputs("};\n", text_defaults_c); fputs("};\n", text_defaults_c);
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment