Skip to content
Snippets Groups Projects
Commit 8da3806b authored by Craig Hendricks's avatar Craig Hendricks Committed by Rob Swindell
Browse files

MRC enhancements: Nicklist toggle, timestamps, and improved default alias

parent a655cb6c
No related branches found
No related tags found
2 merge requests!463MRC mods by Codefenix (2024-10-20),!280MRC enhancements: Nicklist toggle, timestamps, and improved default alias
...@@ -15,6 +15,8 @@ load(js.startup_dir + 'mrc-session.js'); ...@@ -15,6 +15,8 @@ load(js.startup_dir + 'mrc-session.js');
var input_state = 'chat'; var input_state = 'chat';
var show_nicks = false;
var f = new File(js.startup_dir + 'mrc-client.ini'); var f = new File(js.startup_dir + 'mrc-client.ini');
f.open('r'); f.open('r');
const settings = { const settings = {
...@@ -73,9 +75,9 @@ function pipe_to_ctrl_a(str) { ...@@ -73,9 +75,9 @@ function pipe_to_ctrl_a(str) {
} }
function resize_nicklist(frames, nicks) { function resize_nicklist(frames, nicks) {
const maxlen = Math.max(1, nicks.reduce(function (a, c) { const maxlen = show_nicks ? Math.max(1, nicks.reduce(function (a, c) {
return c.length > a ? c.length : a; return c.length > a ? c.length : a;
}, 0)); }, 0)) : 0;
frames.nicklist.moveTo(frames.top.x + frames.top.width - 1 - maxlen - 1, 2); frames.nicklist.moveTo(frames.top.x + frames.top.width - 1 - maxlen - 1, 2);
frames.nicklist_divider.moveTo(frames.nicklist.x, 2); frames.nicklist_divider.moveTo(frames.nicklist.x, 2);
frames.nicks.moveTo(frames.nicklist.x + 1, 2); frames.nicks.moveTo(frames.nicklist.x + 1, 2);
...@@ -86,11 +88,13 @@ function resize_nicklist(frames, nicks) { ...@@ -86,11 +88,13 @@ function resize_nicklist(frames, nicks) {
function redraw_nicklist(frames, nicks, colours) { function redraw_nicklist(frames, nicks, colours) {
frames.nicks.clear(); frames.nicks.clear();
if (show_nicks) {
nicks.forEach(function (e, i) { nicks.forEach(function (e, i) {
frames.nicks.gotoxy(1, i + 1); frames.nicks.gotoxy(1, i + 1);
frames.nicks.putmsg(colours[e] + e + '\1n\1w'); frames.nicks.putmsg(colours[e] + e + '\1n\1w');
}); });
} }
}
function init_display() { function init_display() {
const w = console.screen_columns; const w = console.screen_columns;
...@@ -124,7 +128,7 @@ function append_message(frames, msg) { ...@@ -124,7 +128,7 @@ function append_message(frames, msg) {
} }
frames.output.gotoxy(1, frames.output.height); frames.output.gotoxy(1, frames.output.height);
} }
frames.output.putmsg(msg + '\r\n'); frames.output.putmsg("\1k\1h" + (new Date()).toLocaleTimeString() + "\1k\1h " + msg + '\r\n');
frames.output.scroll(0, -1); frames.output.scroll(0, -1);
if (input_state == 'scroll') frames.output.scrollTo(0, top); if (input_state == 'scroll') frames.output.scrollTo(0, top);
} }
...@@ -151,11 +155,13 @@ function set_alias(alias) { ...@@ -151,11 +155,13 @@ function set_alias(alias) {
} }
function new_alias() { function new_alias() {
const alias = format( const prefix = format("|03%s", "<");
const suffix = format("|03%s", ">");
const alias = prefix + format(
'|%02d%s', '|%02d%s',
PIPE_COLOURS[Math.floor(Math.random() * PIPE_COLOURS.length)], PIPE_COLOURS[Math.floor(Math.random() * PIPE_COLOURS.length)],
user.alias.replace(/\s/g, '_') user.alias.replace(/\s/g, '_')
); ) + suffix;
set_alias(alias); set_alias(alias);
settings.aliases[user.alias] = alias; settings.aliases[user.alias] = alias;
} }
...@@ -211,6 +217,7 @@ function main() { ...@@ -211,6 +217,7 @@ function main() {
+ ', eg. /nick_color 11' + ', eg. /nick_color 11'
); );
display_server_message(frames, '\1h\1w/\1h\1cnick_suffix \1h\1w- \1n\1wSet an eight-character suffix for your handle, eg. /nick_suffix <poop>'); display_server_message(frames, '\1h\1w/\1h\1cnick_suffix \1h\1w- \1n\1wSet an eight-character suffix for your handle, eg. /nick_suffix <poop>');
display_server_message(frames, '\1h\1w/\1h\1ctoggle_nicks \1h\1w- \1n\1wShow/hide the nicklist');
display_server_message(frames, '\1h\1w/\1h\1cquit \1n\1w- \1h\1wExit the program'); display_server_message(frames, '\1h\1w/\1h\1cquit \1n\1w- \1h\1wExit the program');
}); });
session.on('message', function (msg) { session.on('message', function (msg) {
...@@ -306,6 +313,11 @@ function main() { ...@@ -306,6 +313,11 @@ function main() {
session.alias = settings.aliases[user.alias]; session.alias = settings.aliases[user.alias];
} }
break; break;
case 'toggle_nicks':
show_nicks = !show_nicks;
resize_nicklist(frames, session.nicks);
redraw_nicklist(frames, session.nicks, nick_colours);
break;
default: default:
if (typeof session[cmd[0]] == 'function') { if (typeof session[cmd[0]] == 'function') {
session[cmd[0]](cmd.slice(1).join(' ')); session[cmd[0]](cmd.slice(1).join(' '));
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment