Re: How to create options for modopt
By: martylake to All on Tue Dec 07 2021 01:31 am
Did you read this: http://wiki.synchro.net/config:modopts.ini ?
Not yet ! Thank you very much for the link.
Here is a patch for fixing irc.js encoding scrambling, it consists of two parts:
* convert incoming UTF8 to CP437 when communicating with a server, but the client is not UTF8
* convert to UTF8 when sending messages to the client, if supported
Not sure if it's the optimal way of implementing this, I had the expected behavior with thes two test setup:
* synchronet's irc server:
* syncterm
* ubuntu terminal utf8 ssh
* irc client via znc utf8
* inspircd server
* syncterm
* ubuntu terminal utf8 ssh
* irc client via znc utf8
Best,
martylake
From 1414ee4803d1e71749a160a56d783df68668b4a5 Mon Sep 17 00:00:00 2001
From: martylake <
redactedmail@example.com>
Date: Wed, 8 Dec 2021 08:15:12 +0100
Subject: [PATCH 1/2] When the user console is not UTF8, encode and decode
from/to CP437
---
exec/irc.js | 9 +++++++++
1 file changed, 9 insertions(+)
diff --git a/exec/irc.js b/exec/irc.js
index 233bbef77..ad1afd246 100644
--- a/exec/irc.js
+++ b/exec/irc.js
@@ -34,6 +34,8 @@ var real_names=true;
js.on_exit("console.ctrlkey_passthru = " + console.ctrlkey_passthru);
console.ctrlkey_passthru=~(134217728);
+var options = load('modopts.js', 'fseditor');
+var utf8_support = ((options && options.utf8_support) || true) && console.term_supports(USER_UTF8); //default to true
// Commands to send...
var client_cmds = {
'PASS':{minparam:1,maxparam:1}, // Must be sent before NICK/USER
@@ -223,6 +225,10 @@ function send_cmd(command, params)
screen.print_line("\x01H\x01R!! \x01N\x01R"+command+" requires at least "+cmd.minparam+" parameters\x01N\x01W");
return;
}
+ if(!utf8_support)
+ {
+ snd = utf8_encode(snd);
+ }
sock.send(snd+"\r\n");
}
@@ -566,6 +572,9 @@ function get_command()
line=sock.recvline();
if(!line)
return;
+ if(!utf8_support){
+ line=utf8_decode(line);
+ }
if (line[0] == '@') {
tag = line.slice(1, line.indexOf(" "));
--
2.32.0
From aa423963801089e80dfb0a7fb8fe89385e4f3ff2 Mon Sep 17 00:00:00 2001
From: martylake <
redactedmail@example.com>
Date: Wed, 8 Dec 2021 08:16:29 +0100
Subject: [PATCH 2/2] When the user console is UTF8, use UTF8 pmode for console
prints.
---
exec/irc.js | 27 ++++++++++++++++-----------
1 file changed, 16 insertions(+), 11 deletions(-)
diff --git a/exec/irc.js b/exec/irc.js
index ad1afd246..672dc73c0 100644
--- a/exec/irc.js
+++ b/exec/irc.js
@@ -33,9 +33,14 @@ var loading=true;
var real_names=true;
js.on_exit("console.ctrlkey_passthru = " + console.ctrlkey_passthru);
console.ctrlkey_passthru=~(134217728);
+var pmode = 0;
var options = load('modopts.js', 'fseditor');
var utf8_support = ((options && options.utf8_support) || true) && console.term_supports(USER_UTF8); //default to true
+if(utf8_support)
+{
+ pmode |= P_UTF8;
+}
// Commands to send...
var client_cmds = {
'PASS':{minparam:1,maxparam:1}, // Must be sent before NICK/USER
@@ -1072,9 +1077,9 @@ function Screen_update_statline() {
cname=channels.current.display;
topic=channels.current.topic;
}
- console.print(this.topicline);
+ console.print(this.topicline, pmode);
console.crlf();
- console.print(this.statusline);
+ console.print(this.statusline, pmode);
console.crlf();
this.update_input_line();
}
@@ -1225,12 +1230,12 @@ function Screen_print_line(line) {
if(lastspace==linestart-1) {
lastspace=j;
}
-
console.print(prev_colour+line.substring(linestart,lastspace+1));
+
console.print(prev_colour+line.substring(linestart,lastspace+1), pmode);
prev_colour=last_colour;
console.cleartoeol();
console.crlf();
this.line.shift();
-
this.line.push(prev_colour+line.substring(linestart,lastspace+1));
+
this.line.push(prev_colour+line.substring(linestart,lastspace+1), pmode);
linestart=lastspace+1;
j=lastspace;
i=0;
@@ -1240,10 +1245,10 @@ function Screen_print_line(line) {
}
}
if(i<=78) {
- console.print(prev_colour+line.substr(linestart));
+ console.print(prev_colour+line.substr(linestart), pmode);
console.cleartoeol();
this.line.shift();
- this.line.push(prev_colour+line.substr(linestart));
+ this.line.push(prev_colour+line.substr(linestart), pmode);
console.crlf();
}
if(!connected) {
@@ -1262,9 +1267,9 @@ function Screen_print_line(line) {
cname=channels.current.display;
topic=channels.current.topic;
}
- console.print(this.topicline);
+ console.print(this.topicline, pmode);
console.crlf();
- console.print(this.statusline);
+ console.print(this.statusline, pmode);
console.crlf();
this.update_input_line();
}
@@ -1299,7 +1304,7 @@ function Screen_update_input_line() {
console.line_counter=0; // defeat pause
console.ansi_gotoxy(1,console.screen_rows);
console.clearline();
- printf("%s",line_str);
+ console.print(line_str, pmode);
console.ansi_gotoxy(line_pos+1,console.screen_rows);
}
@@ -1431,9 +1436,9 @@ function Screen_handle_key(key) {
console.ansi_gotoxy(1,console.screen_rows-2);
console.clearline();
console.handle_ctrlkey(key,0); // for now
- console.print(this.topicline);
+ console.print(this.topicline, pmode);
console.crlf();
- console.print(this.statusline);
+ console.print(this.statusline, pmode);
console.crlf();
this.update_input_line();
}
--
2.32.0
---
þ Synchronet þ Vertrauen þ Home of Synchronet þ [vert/cvs/bbs].synchro.net