If joined channel had some low-ascii (color codes), they were displayed

wrong in statusbar and prompt. Also, if you're invited to some channel,
print the lowascii so that you can see them (^B, etc.)


git-svn-id: http://svn.irssi.org/repos/irssi/trunk@400 dbcabf3a-b0e7-0310-adc4-f8d773084564
This commit is contained in:
Timo Sirainen 2000-06-30 19:54:34 +00:00 committed by cras
parent 58397c1ca9
commit 39282a342f
6 changed files with 40 additions and 14 deletions

View File

@ -506,3 +506,24 @@ int dec2octal(int decimal)
return octal; return octal;
} }
/* convert all low-ascii (<32) to ^<A..> combinations */
char *show_lowascii(const char *channel)
{
char *str, *p;
str = p = g_malloc(strlen(channel)*2+1);
while (*channel != '\0') {
if ((unsigned char) *channel >= 32)
*p++ = *channel;
else {
*p++ = '^';
*p++ = *channel + 'A'-1;
}
channel++;
}
*p = '\0';
return str;
}

View File

@ -65,4 +65,7 @@ char *replace_chars(char *str, char from, char to);
int octal2dec(int octal); int octal2dec(int octal);
int dec2octal(int decimal); int dec2octal(int decimal);
/* convert all low-ascii (<32) to ^<A..> combinations */
char *show_lowascii(const char *channel);
#endif #endif

View File

@ -447,19 +447,11 @@ static void event_whois_channels(const char *data, IRC_SERVER_REC *server)
colors, bolds, etc. are mostly just to fool people, I think we colors, bolds, etc. are mostly just to fool people, I think we
should show the channel names as they REALLY are so they could should show the channel names as they REALLY are so they could
even be joined without any extra tricks. */ even be joined without any extra tricks. */
str = g_string_new(NULL); chans = show_lowascii(chans);
for (; *chans != '\0'; chans++) { printformat(server, nick, MSGLEVEL_CRAP, IRCTXT_WHOIS_CHANNELS, nick, chans);
if ((unsigned char) *chans >= 32) g_free(chans);
g_string_append_c(str, *chans);
else {
g_string_append_c(str, '^');
g_string_append_c(str, *chans+'A'-1);
}
}
printformat(server, nick, MSGLEVEL_CRAP, IRCTXT_WHOIS_CHANNELS, nick, str->str);
g_free(params); g_free(params);
g_string_free(str, TRUE);
} }
static void event_whois_away(const char *data, IRC_SERVER_REC *server) static void event_whois_away(const char *data, IRC_SERVER_REC *server)

View File

@ -21,6 +21,7 @@
#include "module.h" #include "module.h"
#include "module-formats.h" #include "module-formats.h"
#include "signals.h" #include "signals.h"
#include "misc.h"
#include "settings.h" #include "settings.h"
#include "irc.h" #include "irc.h"
@ -388,8 +389,11 @@ static void event_invite(const char *data, IRC_SERVER_REC *server, const char *n
g_return_if_fail(data != NULL); g_return_if_fail(data != NULL);
params = event_get_params(data, 2, NULL, &channel); params = event_get_params(data, 2, NULL, &channel);
if (*channel != '\0' && !ignore_check(server, nick, addr, channel, NULL, MSGLEVEL_INVITES)) if (*channel != '\0' && !ignore_check(server, nick, addr, channel, NULL, MSGLEVEL_INVITES)) {
channel = show_lowascii(channel);
printformat(server, NULL, MSGLEVEL_INVITES, IRCTXT_INVITE, nick, channel); printformat(server, NULL, MSGLEVEL_INVITES, IRCTXT_INVITE, nick, channel);
g_free(channel);
}
g_free(params); g_free(params);
} }

View File

@ -627,7 +627,10 @@ void window_update_prompt(WINDOW_REC *window)
} }
/* set prompt */ /* set prompt */
text = show_lowascii(text);
str = g_strdup_printf("[%1.17s] ", text); str = g_strdup_printf("[%1.17s] ", text);
g_free(text);
gui_entry_set_prompt(str); gui_entry_set_prompt(str);
if (*str != '\0') g_free(str); if (*str != '\0') g_free(str);
} }

View File

@ -37,6 +37,7 @@
#include "printtext.h" #include "printtext.h"
#include "statusbar.h" #include "statusbar.h"
#include "gui-windows.h" #include "gui-windows.h"
#include "gui-printtext.h"
/* how often to redraw lagging time (seconds) */ /* how often to redraw lagging time (seconds) */
#define LAG_REFRESH_TIME 10 #define LAG_REFRESH_TIME 10
@ -215,7 +216,7 @@ static void statusbar_channel(SBAR_ITEM_REC *item, int ypos)
WI_ITEM_REC *witem; WI_ITEM_REC *witem;
CHANNEL_REC *channel; CHANNEL_REC *channel;
SERVER_REC *server; SERVER_REC *server;
gchar channame[21], winnum[MAX_INT_STRLEN], *mode; gchar channame[21], winnum[MAX_INT_STRLEN], *mode, *tmpname;
int size_needed; int size_needed;
int mode_size; int mode_size;
@ -239,7 +240,9 @@ static void statusbar_channel(SBAR_ITEM_REC *item, int ypos)
else else
{ {
/* display channel + mode */ /* display channel + mode */
strncpy(channame, witem->name, 20); channame[20] = '\0'; tmpname = show_lowascii(witem->name);
strncpy(channame, tmpname, 20); channame[20] = '\0';
g_free(tmpname);
channel = irc_item_channel(witem); channel = irc_item_channel(witem);
if (channel == NULL) { if (channel == NULL) {