mirror of
https://github.com/irssi/irssi.git
synced 2026-08-09 20:00:23 +02:00
added format_get_length() for getting length of text part in a format
string. gui_printtext() now works like printtext_string() so %s won't accidentally crash it. /SET prompt can now have %formats. git-svn-id: http://svn.irssi.org/repos/irssi/trunk@1273 dbcabf3a-b0e7-0310-adc4-f8d773084564
This commit is contained in:
parent
c8893c61ee
commit
4718edf055
8 changed files with 44 additions and 27 deletions
|
|
@ -216,6 +216,34 @@ void format_create_dest(TEXT_DEST_REC *dest,
|
|||
dest->hilight_bg_color = 0;
|
||||
}
|
||||
|
||||
int format_get_length(const char *str)
|
||||
{
|
||||
GString *tmp;
|
||||
int len;
|
||||
|
||||
tmp = g_string_new(NULL);
|
||||
len = 0;
|
||||
while (*str != '\0') {
|
||||
if (*str == '%' && str[1] != '\0') {
|
||||
str++;
|
||||
if (*str != '%' && format_expand_styles(tmp, *str)) {
|
||||
str++;
|
||||
continue;
|
||||
}
|
||||
|
||||
/* %% or unknown %code, written as-is */
|
||||
if (*str != '%')
|
||||
len++;
|
||||
}
|
||||
|
||||
len++;
|
||||
str++;
|
||||
}
|
||||
|
||||
g_string_free(tmp, TRUE);
|
||||
return len;
|
||||
}
|
||||
|
||||
static char *format_get_text_args(TEXT_DEST_REC *dest,
|
||||
const char *text, char **arglist)
|
||||
{
|
||||
|
|
|
|||
|
|
@ -43,6 +43,9 @@ typedef struct {
|
|||
|
||||
int format_find_tag(const char *module, const char *tag);
|
||||
|
||||
/* Return length of text part in string (ie. without % codes) */
|
||||
int format_get_length(const char *str);
|
||||
|
||||
char *format_get_text(const char *module, WINDOW_REC *window,
|
||||
void *server, const char *target,
|
||||
int formatnum, ...);
|
||||
|
|
|
|||
|
|
@ -348,7 +348,7 @@ void printtext_window(WINDOW_REC *window, int level, const char *text, ...)
|
|||
va_end(va);
|
||||
}
|
||||
|
||||
void printtext_gui_args(const char *text, va_list va)
|
||||
void printtext_gui(const char *text)
|
||||
{
|
||||
TEXT_DEST_REC dest;
|
||||
char *str;
|
||||
|
|
@ -357,20 +357,11 @@ void printtext_gui_args(const char *text, va_list va)
|
|||
|
||||
memset(&dest, 0, sizeof(dest));
|
||||
|
||||
str = printtext_get_args(&dest, text, va);
|
||||
str = printtext_expand_formats(text);
|
||||
format_send_to_gui(&dest, str);
|
||||
g_free(str);
|
||||
}
|
||||
|
||||
void printtext_gui(const char *text, ...)
|
||||
{
|
||||
va_list va;
|
||||
|
||||
va_start(va, text);
|
||||
printtext_gui_args(text, va);
|
||||
va_end(va);
|
||||
}
|
||||
|
||||
static void msg_beep_check(SERVER_REC *server, int level)
|
||||
{
|
||||
if (level != 0 && (level & MSGLEVEL_NOHILIGHT) == 0 &&
|
||||
|
|
|
|||
|
|
@ -17,8 +17,7 @@ void printbeep(void);
|
|||
|
||||
/* only GUI should call these - used for printing text to somewhere else
|
||||
than windows */
|
||||
void printtext_gui(const char *text, ...);
|
||||
void printtext_gui_args(const char *text, va_list va);
|
||||
void printtext_gui(const char *text);
|
||||
void printformat_module_gui(const char *module, int formatnum, ...);
|
||||
void printformat_module_gui_args(const char *module, int formatnum, va_list va);
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue