Add option to hide join/part hostmasks

This commit is contained in:
2026-06-10 15:05:00 -06:00
parent 62672ade04
commit 97534b0670
4 changed files with 89 additions and 1 deletions

View File

@@ -518,6 +518,7 @@ const struct prefs vars[] =
{"irc_conf_mode", P_OFFINT (hex_irc_conf_mode), TYPE_BOOL}, {"irc_conf_mode", P_OFFINT (hex_irc_conf_mode), TYPE_BOOL},
{"irc_extra_hilight", P_OFFSET (hex_irc_extra_hilight), TYPE_STR}, {"irc_extra_hilight", P_OFFSET (hex_irc_extra_hilight), TYPE_STR},
{"irc_hide_nickchange", P_OFFINT (hex_irc_hide_nickchange), TYPE_BOOL}, {"irc_hide_nickchange", P_OFFINT (hex_irc_hide_nickchange), TYPE_BOOL},
{"irc_hide_join_part_hostmask", P_OFFINT (hex_irc_hide_join_part_hostmask), TYPE_BOOL},
{"irc_hide_version", P_OFFINT (hex_irc_hide_version), TYPE_BOOL}, {"irc_hide_version", P_OFFINT (hex_irc_hide_version), TYPE_BOOL},
{"irc_hidehost", P_OFFINT (hex_irc_hidehost), TYPE_BOOL}, {"irc_hidehost", P_OFFINT (hex_irc_hidehost), TYPE_BOOL},
{"irc_id_ntext", P_OFFSET (hex_irc_id_ntext), TYPE_STR}, {"irc_id_ntext", P_OFFSET (hex_irc_id_ntext), TYPE_STR},

View File

@@ -1809,12 +1809,97 @@ format_event (session *sess, int index, char **args, char *o, gsize sizeofo, uns
o[0] = 0; o[0] = 0;
} }
static char *
text_event_without_hostmask_format (const char *format, int host_arg)
{
char token[3];
const char *arg;
const char *open;
const char *close;
const char *start;
char *out;
gsize prefix_len;
g_snprintf (token, sizeof (token), "$%d", host_arg);
arg = strstr (format, token);
if (!arg)
return NULL;
open = arg;
while (open > format && *open != '(' && *open != '\n')
open--;
close = arg + strlen (token);
while (*close && *close != ')' && *close != '\n')
close++;
if (*open != '(' || *close != ')')
return NULL;
start = open;
if (start > format && start[-1] == ' ')
start--;
prefix_len = start - format;
out = g_malloc (prefix_len + strlen (close + 1) + 1);
memcpy (out, format, prefix_len);
strcpy (out + prefix_len, close + 1);
return out;
}
static void
display_event_string (session *sess, int event, char **args, char *format,
unsigned int stripcolor_args, time_t timestamp)
{
char *compiled;
char *saved;
char o[4096];
int max_arg;
if (pevt_build_string (format, &compiled, &max_arg) != 0)
return;
saved = pntevts[event];
pntevts[event] = compiled;
format_event (sess, event, args, o, sizeof (o), stripcolor_args);
pntevts[event] = saved;
g_free (compiled);
if (o[0])
PrintTextTimeStamp (sess, o, timestamp);
}
static void static void
display_event (session *sess, int event, char **args, display_event (session *sess, int event, char **args,
unsigned int stripcolor_args, time_t timestamp) unsigned int stripcolor_args, time_t timestamp)
{ {
char o[4096]; char o[4096];
char *format;
char *host;
int host_arg;
if (prefs.hex_irc_hide_join_part_hostmask &&
(event == XP_TE_JOIN || event == XP_TE_PART || event == XP_TE_PARTREASON))
{
host_arg = event == XP_TE_JOIN ? 3 : 2;
format = text_event_without_hostmask_format (pntevts_text[event], host_arg);
if (format)
{
display_event_string (sess, event, args, format, stripcolor_args, timestamp);
g_free (format);
return;
}
host = args[host_arg];
args[host_arg] = "";
format_event (sess, event, args, o, sizeof (o), stripcolor_args); format_event (sess, event, args, o, sizeof (o), stripcolor_args);
args[host_arg] = host;
}
else
{
format_event (sess, event, args, o, sizeof (o), stripcolor_args);
}
if (o[0]) if (o[0])
PrintTextTimeStamp (sess, o, timestamp); PrintTextTimeStamp (sess, o, timestamp);
} }

View File

@@ -188,6 +188,7 @@ struct zoitechatprefs
unsigned int hex_irc_conf_mode; unsigned int hex_irc_conf_mode;
unsigned int hex_irc_hidehost; unsigned int hex_irc_hidehost;
unsigned int hex_irc_hide_nickchange; unsigned int hex_irc_hide_nickchange;
unsigned int hex_irc_hide_join_part_hostmask;
unsigned int hex_irc_hide_version; unsigned int hex_irc_hide_version;
unsigned int hex_irc_invisible; unsigned int hex_irc_invisible;
unsigned int hex_irc_logging; unsigned int hex_irc_logging;

View File

@@ -546,6 +546,7 @@ static const setting general_settings[] =
{ST_TOGGLE, N_("WHOIS on notify"), P_OFFINTNL(hex_notify_whois_online), N_("Sends a /WHOIS when a user comes online in your notify list."), 0, 0}, {ST_TOGGLE, N_("WHOIS on notify"), P_OFFINTNL(hex_notify_whois_online), N_("Sends a /WHOIS when a user comes online in your notify list."), 0, 0},
{ST_TOGGLE, N_("Hide join and part messages"), P_OFFINTNL(hex_irc_conf_mode), N_("Hide channel join/part messages by default."), 0, 0}, {ST_TOGGLE, N_("Hide join and part messages"), P_OFFINTNL(hex_irc_conf_mode), N_("Hide channel join/part messages by default."), 0, 0},
{ST_TOGGLE, N_("Hide nick change messages"), P_OFFINTNL(hex_irc_hide_nickchange), 0, 0, 0}, {ST_TOGGLE, N_("Hide nick change messages"), P_OFFINTNL(hex_irc_hide_nickchange), 0, 0, 0},
{ST_TOGGLE, N_("Hide hostmasks in join and part messages"), P_OFFINTNL(hex_irc_hide_join_part_hostmask), 0, 0, 0},
{ST_TOGGLE, N_("Enable Ctrl+Q to quit"), P_OFFINTNL(hex_gui_ctrlq_quit), 0, 0, 0}, {ST_TOGGLE, N_("Enable Ctrl+Q to quit"), P_OFFINTNL(hex_gui_ctrlq_quit), 0, 0, 0},
{ST_END, 0, 0, 0, 0, 0} {ST_END, 0, 0, 0, 0, 0}