mirror of
https://github.com/irssi/irssi.git
synced 2025-01-03 14:56:47 -05:00
Added printtext_string() which works like printtext(), except it prints
text from a string, so that %s, %d, etc. don't work. Changed perl's Irssi::print() use this instead as well as /HELP printer. git-svn-id: http://svn.irssi.org/repos/irssi/trunk@1072 dbcabf3a-b0e7-0310-adc4-f8d773084564
This commit is contained in:
parent
3654085b14
commit
86aa2d514d
@ -96,14 +96,14 @@ static void help_category(GSList *cmdlist, gint items, gint max)
|
||||
|
||||
if (col == cols || tmp->next == NULL)
|
||||
{
|
||||
printtext(NULL, NULL, MSGLEVEL_CLIENTCRAP, "%s", str->str);
|
||||
printtext_string(NULL, NULL, MSGLEVEL_CLIENTCRAP, str->str);
|
||||
g_string_truncate(str, 0);
|
||||
col = 0; line++;
|
||||
tmp = g_slist_nth(cmdlist, line-1); skip = 1;
|
||||
}
|
||||
}
|
||||
if (str->len != 0)
|
||||
printtext(NULL, NULL, MSGLEVEL_CLIENTCRAP, "%s", str->str);
|
||||
printtext_string(NULL, NULL, MSGLEVEL_CLIENTCRAP, str->str);
|
||||
g_string_free(str, TRUE);
|
||||
g_free(cmdbuf);
|
||||
}
|
||||
@ -131,7 +131,7 @@ static int show_help_rec(COMMAND_REC *cmd)
|
||||
recvlen = read(f, tmpbuf, sizeof(tmpbuf));
|
||||
|
||||
ret = line_split(tmpbuf, recvlen, &str, &buffer);
|
||||
if (ret > 0) printtext(NULL, NULL, MSGLEVEL_CLIENTCRAP, "%s", str);
|
||||
if (ret > 0) printtext_string(NULL, NULL, MSGLEVEL_CLIENTCRAP, str);
|
||||
}
|
||||
while (ret > 0);
|
||||
line_split_free(buffer);
|
||||
|
@ -249,6 +249,24 @@ void printtext(void *server, const char *target, int level, const char *text, ..
|
||||
va_end(va);
|
||||
}
|
||||
|
||||
/* Like printtext(), but don't handle %s etc. */
|
||||
void printtext_string(void *server, const char *target, int level, const char *text)
|
||||
{
|
||||
TEXT_DEST_REC dest;
|
||||
|
||||
g_return_if_fail(text != NULL);
|
||||
|
||||
format_create_dest(&dest, server, target, level, NULL);
|
||||
|
||||
if (!sending_print_starting) {
|
||||
sending_print_starting = TRUE;
|
||||
signal_emit_id(signal_print_starting, 1, dest);
|
||||
sending_print_starting = FALSE;
|
||||
}
|
||||
|
||||
print_line(&dest, text);
|
||||
}
|
||||
|
||||
void printtext_window(WINDOW_REC *window, int level, const char *text, ...)
|
||||
{
|
||||
TEXT_DEST_REC dest;
|
||||
|
@ -10,6 +10,7 @@ void printformat_module_args(const char *module, void *server, const char *targe
|
||||
void printformat_module_window_args(const char *module, WINDOW_REC *window, int level, int formatnum, va_list va);
|
||||
|
||||
void printtext(void *server, const char *target, int level, const char *text, ...);
|
||||
void printtext_string(void *server, const char *target, int level, const char *text);
|
||||
void printtext_window(WINDOW_REC *window, int level, const char *text, ...);
|
||||
void printtext_multiline(void *server, const char *target, int level, const char *format, const char *text);
|
||||
void printbeep(void);
|
||||
|
@ -30,23 +30,15 @@ void
|
||||
print(str, level=MSGLEVEL_CLIENTNOTICE)
|
||||
char *str
|
||||
int level;
|
||||
PREINIT:
|
||||
char *fixed;
|
||||
CODE:
|
||||
fixed = perl_fix_formats(str);
|
||||
printtext(NULL, NULL, level, fixed);
|
||||
g_free(fixed);
|
||||
printtext_string(NULL, NULL, level, str);
|
||||
|
||||
void
|
||||
print_window(str, level=MSGLEVEL_CLIENTNOTICE)
|
||||
char *str
|
||||
int level;
|
||||
PREINIT:
|
||||
char *fixed;
|
||||
CODE:
|
||||
fixed = perl_fix_formats(str);
|
||||
printtext_window(active_win, level, fixed);
|
||||
g_free(fixed);
|
||||
printtext_window(active_win, level, str);
|
||||
|
||||
void
|
||||
command(cmd, server=active_win->active_server, item=active_win->active)
|
||||
|
@ -426,41 +426,6 @@ void printformat_perl(TEXT_DEST_REC *dest, char *format, char **arglist)
|
||||
g_free(module);
|
||||
}
|
||||
|
||||
/* change all %s strings to %%s */
|
||||
char *perl_fix_formats(char *str)
|
||||
{
|
||||
char *ret, *out;
|
||||
|
||||
out = ret = g_malloc(strlen(str)*2+1);
|
||||
while (*str != '\0') {
|
||||
if (*str == '%') {
|
||||
str++;
|
||||
switch (*str) {
|
||||
case 's':
|
||||
case 'd':
|
||||
case 'f':
|
||||
case 'u':
|
||||
case 'l':
|
||||
case '%':
|
||||
*out++ = '%';
|
||||
*out++ = '%';
|
||||
if (*str == '%')
|
||||
str += 2;
|
||||
break;
|
||||
default:
|
||||
*out++ = '%';
|
||||
break;
|
||||
}
|
||||
|
||||
continue;
|
||||
}
|
||||
|
||||
*out++ = *str++;
|
||||
}
|
||||
*out = '\0';
|
||||
return ret;
|
||||
}
|
||||
|
||||
void perl_command(const char *cmd, SERVER_REC *server, WI_ITEM_REC *item)
|
||||
{
|
||||
const char *cmdchars;
|
||||
|
@ -42,9 +42,6 @@ void irssi_add_plains(PLAIN_OBJECT_INIT_REC *objects);
|
||||
|
||||
char *perl_get_use_list(void);
|
||||
|
||||
/* change all %s strings to %%s */
|
||||
char *perl_fix_formats(char *str);
|
||||
|
||||
void perl_common_init(void);
|
||||
void perl_common_deinit(void);
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user