2000-04-26 04:03:38 -04:00
|
|
|
/*
|
|
|
|
printtext.c : irssi
|
|
|
|
|
2000-05-04 06:32:42 -04:00
|
|
|
Copyright (C) 1999-2000 Timo Sirainen
|
2000-04-26 04:03:38 -04:00
|
|
|
|
|
|
|
This program is free software; you can redistribute it and/or modify
|
|
|
|
it under the terms of the GNU General Public License as published by
|
|
|
|
the Free Software Foundation; either version 2 of the License, or
|
|
|
|
(at your option) any later version.
|
|
|
|
|
|
|
|
This program is distributed in the hope that it will be useful,
|
|
|
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
GNU General Public License for more details.
|
|
|
|
|
|
|
|
You should have received a copy of the GNU General Public License
|
|
|
|
along with this program; if not, write to the Free Software
|
|
|
|
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
|
|
|
*/
|
|
|
|
|
|
|
|
#include "module.h"
|
|
|
|
#include "module-formats.h"
|
|
|
|
#include "modules.h"
|
|
|
|
#include "signals.h"
|
|
|
|
#include "commands.h"
|
|
|
|
#include "settings.h"
|
|
|
|
|
|
|
|
#include "levels.h"
|
2000-08-26 11:39:44 -04:00
|
|
|
#include "servers.h"
|
2000-04-26 04:03:38 -04:00
|
|
|
|
|
|
|
#include "themes.h"
|
2000-11-17 11:27:14 -05:00
|
|
|
#include "fe-windows.h"
|
2000-10-28 16:14:19 -04:00
|
|
|
#include "printtext.h"
|
2000-04-26 04:03:38 -04:00
|
|
|
|
2000-07-30 13:32:55 -04:00
|
|
|
static int beep_msg_level, beep_when_away;
|
2000-05-15 04:25:45 -04:00
|
|
|
|
|
|
|
static int signal_gui_print_text;
|
|
|
|
static int signal_print_text_stripped;
|
|
|
|
static int signal_print_text;
|
|
|
|
static int signal_print_text_finished;
|
2000-10-27 23:01:11 -04:00
|
|
|
static int signal_print_format;
|
2000-11-29 20:41:11 -05:00
|
|
|
static int signal_print_starting;
|
|
|
|
|
|
|
|
static int sending_print_starting;
|
2000-05-15 04:25:45 -04:00
|
|
|
|
2000-10-28 16:14:19 -04:00
|
|
|
static void print_line(TEXT_DEST_REC *dest, const char *text);
|
2000-04-26 04:03:38 -04:00
|
|
|
|
2000-11-12 15:20:05 -05:00
|
|
|
static void printformat_module_dest(const char *module, TEXT_DEST_REC *dest,
|
|
|
|
int formatnum, va_list va)
|
2000-04-26 04:03:38 -04:00
|
|
|
{
|
2000-11-12 15:20:05 -05:00
|
|
|
char *arglist[MAX_FORMAT_PARAMS];
|
|
|
|
char buffer[DEFAULT_FORMAT_ARGLIST_SIZE];
|
|
|
|
FORMAT_REC *formats;
|
|
|
|
THEME_REC *theme;
|
|
|
|
char *str;
|
2000-04-26 04:03:38 -04:00
|
|
|
|
2000-11-12 15:20:05 -05:00
|
|
|
theme = dest->window->theme == NULL ? current_theme :
|
|
|
|
dest->window->theme;
|
2000-05-15 04:25:45 -04:00
|
|
|
|
2000-11-12 15:20:05 -05:00
|
|
|
formats = g_hash_table_lookup(default_formats, module);
|
|
|
|
format_read_arglist(va, &formats[formatnum],
|
|
|
|
arglist, sizeof(arglist)/sizeof(char *),
|
|
|
|
buffer, sizeof(buffer));
|
2000-10-28 16:14:19 -04:00
|
|
|
|
2000-11-29 20:41:11 -05:00
|
|
|
if (!sending_print_starting) {
|
|
|
|
sending_print_starting = TRUE;
|
|
|
|
signal_emit_id(signal_print_starting, 1, dest);
|
|
|
|
sending_print_starting = FALSE;
|
|
|
|
}
|
|
|
|
|
2000-11-12 15:20:05 -05:00
|
|
|
signal_emit_id(signal_print_format, 5, theme, module,
|
|
|
|
dest, GINT_TO_POINTER(formatnum), arglist);
|
2000-04-26 04:03:38 -04:00
|
|
|
|
2001-02-03 14:29:38 -05:00
|
|
|
str = format_get_text_theme_charargs(theme, module, dest,
|
|
|
|
formatnum, arglist);
|
2000-11-12 15:20:05 -05:00
|
|
|
if (*str != '\0') print_line(dest, str);
|
|
|
|
g_free(str);
|
2000-04-26 04:03:38 -04:00
|
|
|
}
|
|
|
|
|
2000-07-31 17:16:09 -04:00
|
|
|
void printformat_module_args(const char *module, void *server,
|
2000-10-27 23:01:11 -04:00
|
|
|
const char *target, int level,
|
2000-07-31 17:16:09 -04:00
|
|
|
int formatnum, va_list va)
|
2000-04-26 04:03:38 -04:00
|
|
|
{
|
2000-05-15 04:25:45 -04:00
|
|
|
TEXT_DEST_REC dest;
|
2000-04-26 04:03:38 -04:00
|
|
|
|
2000-10-28 16:14:19 -04:00
|
|
|
format_create_dest(&dest, server, target, level, NULL);
|
2000-11-12 15:20:05 -05:00
|
|
|
printformat_module_dest(module, &dest, formatnum, va);
|
2000-05-15 04:25:45 -04:00
|
|
|
}
|
2000-04-26 04:03:38 -04:00
|
|
|
|
2001-02-03 14:29:38 -05:00
|
|
|
void printformat_module(const char *module, void *server, const char *target,
|
|
|
|
int level, int formatnum, ...)
|
2000-05-15 04:25:45 -04:00
|
|
|
{
|
|
|
|
va_list va;
|
2000-04-26 04:03:38 -04:00
|
|
|
|
2000-05-15 04:25:45 -04:00
|
|
|
va_start(va, formatnum);
|
2000-10-27 23:01:11 -04:00
|
|
|
printformat_module_args(module, server, target, level, formatnum, va);
|
2000-05-15 04:25:45 -04:00
|
|
|
va_end(va);
|
2000-04-26 04:03:38 -04:00
|
|
|
}
|
|
|
|
|
2000-10-27 23:01:11 -04:00
|
|
|
void printformat_module_window_args(const char *module, WINDOW_REC *window,
|
|
|
|
int level, int formatnum, va_list va)
|
2000-04-26 04:03:38 -04:00
|
|
|
{
|
2000-05-15 04:25:45 -04:00
|
|
|
TEXT_DEST_REC dest;
|
|
|
|
|
2000-10-28 16:14:19 -04:00
|
|
|
format_create_dest(&dest, NULL, NULL, level, window);
|
2000-11-12 15:20:05 -05:00
|
|
|
printformat_module_dest(module, &dest, formatnum, va);
|
2000-04-26 04:03:38 -04:00
|
|
|
}
|
|
|
|
|
2000-10-27 23:01:11 -04:00
|
|
|
void printformat_module_window(const char *module, WINDOW_REC *window,
|
|
|
|
int level, int formatnum, ...)
|
2000-05-15 04:25:45 -04:00
|
|
|
{
|
|
|
|
va_list va;
|
|
|
|
|
|
|
|
va_start(va, formatnum);
|
|
|
|
printformat_module_window_args(module, window, level, formatnum, va);
|
|
|
|
va_end(va);
|
|
|
|
}
|
|
|
|
|
2001-02-03 14:29:38 -05:00
|
|
|
void printformat_module_gui_args(const char *module, int formatnum, va_list va)
|
|
|
|
{
|
|
|
|
TEXT_DEST_REC dest;
|
|
|
|
char *arglist[MAX_FORMAT_PARAMS];
|
|
|
|
char buffer[DEFAULT_FORMAT_ARGLIST_SIZE];
|
|
|
|
FORMAT_REC *formats;
|
|
|
|
char *str;
|
|
|
|
|
|
|
|
g_return_if_fail(module != NULL);
|
|
|
|
|
|
|
|
memset(&dest, 0, sizeof(dest));
|
|
|
|
|
|
|
|
formats = g_hash_table_lookup(default_formats, module);
|
|
|
|
format_read_arglist(va, &formats[formatnum],
|
|
|
|
arglist, sizeof(arglist)/sizeof(char *),
|
|
|
|
buffer, sizeof(buffer));
|
|
|
|
|
|
|
|
str = format_get_text_theme_charargs(current_theme, module, &dest,
|
|
|
|
formatnum, arglist);
|
|
|
|
if (*str != '\0') format_send_to_gui(&dest, str);
|
|
|
|
g_free(str);
|
|
|
|
}
|
|
|
|
|
|
|
|
void printformat_module_gui(const char *module, int formatnum, ...)
|
|
|
|
{
|
|
|
|
va_list va;
|
|
|
|
|
|
|
|
va_start(va, formatnum);
|
|
|
|
printformat_module_gui_args(module, formatnum, va);
|
|
|
|
va_end(va);
|
|
|
|
}
|
|
|
|
|
2000-10-28 16:14:19 -04:00
|
|
|
static void print_line(TEXT_DEST_REC *dest, const char *text)
|
2000-04-26 04:03:38 -04:00
|
|
|
{
|
2000-05-15 04:25:45 -04:00
|
|
|
char *str, *tmp;
|
2000-04-26 04:03:38 -04:00
|
|
|
|
2000-05-15 04:25:45 -04:00
|
|
|
g_return_if_fail(dest != NULL);
|
|
|
|
g_return_if_fail(text != NULL);
|
2000-04-26 04:03:38 -04:00
|
|
|
|
2000-11-20 22:00:05 -05:00
|
|
|
tmp = format_get_level_tag(current_theme, dest);
|
2000-10-28 16:14:19 -04:00
|
|
|
str = format_add_linestart(text, tmp);
|
2000-05-15 04:25:45 -04:00
|
|
|
g_free_not_null(tmp);
|
2000-04-26 04:03:38 -04:00
|
|
|
|
2000-05-15 04:25:45 -04:00
|
|
|
/* send the plain text version for logging etc.. */
|
|
|
|
tmp = strip_codes(str);
|
2000-11-12 15:20:05 -05:00
|
|
|
signal_emit_id(signal_print_text_stripped, 2, dest, tmp);
|
2000-05-15 04:25:45 -04:00
|
|
|
g_free(tmp);
|
2000-04-26 04:03:38 -04:00
|
|
|
|
2000-11-12 15:20:05 -05:00
|
|
|
signal_emit_id(signal_print_text, 2, dest, str);
|
2000-10-28 16:14:19 -04:00
|
|
|
g_free(str);
|
2000-04-26 04:03:38 -04:00
|
|
|
}
|
|
|
|
|
2000-06-11 18:58:17 -04:00
|
|
|
/* append string to `out', expand newlines. */
|
2001-02-03 14:29:38 -05:00
|
|
|
static void printtext_append_str(TEXT_DEST_REC *dest, GString *out,
|
|
|
|
const char *str)
|
2000-06-11 18:58:17 -04:00
|
|
|
{
|
|
|
|
while (*str != '\0') {
|
|
|
|
if (*str != '\n')
|
|
|
|
g_string_append_c(out, *str);
|
|
|
|
else {
|
2000-10-28 16:14:19 -04:00
|
|
|
print_line(dest, out->str);
|
2000-06-11 18:58:17 -04:00
|
|
|
g_string_truncate(out, 0);
|
|
|
|
}
|
|
|
|
str++;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2001-02-03 14:29:38 -05:00
|
|
|
static char *printtext_get_args(TEXT_DEST_REC *dest, const char *str,
|
|
|
|
va_list va)
|
2000-04-26 04:03:38 -04:00
|
|
|
{
|
|
|
|
GString *out;
|
2000-05-15 04:25:45 -04:00
|
|
|
char *ret;
|
2000-04-26 04:03:38 -04:00
|
|
|
|
|
|
|
out = g_string_new(NULL);
|
2000-05-15 04:25:45 -04:00
|
|
|
for (; *str != '\0'; str++) {
|
|
|
|
if (*str != '%') {
|
|
|
|
g_string_append_c(out, *str);
|
|
|
|
continue;
|
|
|
|
}
|
2000-04-26 04:03:38 -04:00
|
|
|
|
2000-05-15 04:25:45 -04:00
|
|
|
if (*++str == '\0')
|
|
|
|
break;
|
2000-04-26 04:03:38 -04:00
|
|
|
|
2000-05-15 04:25:45 -04:00
|
|
|
/* standard parameters */
|
|
|
|
switch (*str) {
|
|
|
|
case 's': {
|
|
|
|
char *s = (char *) va_arg(va, char *);
|
2000-06-11 18:58:17 -04:00
|
|
|
if (s && *s) printtext_append_str(dest, out, s);
|
2000-05-15 04:25:45 -04:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
case 'd': {
|
|
|
|
int d = (int) va_arg(va, int);
|
|
|
|
g_string_sprintfa(out, "%d", d);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
case 'f': {
|
|
|
|
double f = (double) va_arg(va, double);
|
|
|
|
g_string_sprintfa(out, "%0.2f", f);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
case 'u': {
|
2001-02-03 14:29:38 -05:00
|
|
|
unsigned int d =
|
|
|
|
(unsigned int) va_arg(va, unsigned int);
|
2000-05-15 04:25:45 -04:00
|
|
|
g_string_sprintfa(out, "%u", d);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
case 'l': {
|
|
|
|
long d = (long) va_arg(va, long);
|
|
|
|
|
|
|
|
if (*++str != 'd' && *str != 'u') {
|
|
|
|
g_string_sprintfa(out, "%ld", d);
|
|
|
|
str--;
|
|
|
|
} else {
|
|
|
|
if (*str == 'd')
|
|
|
|
g_string_sprintfa(out, "%ld", d);
|
|
|
|
else
|
|
|
|
g_string_sprintfa(out, "%lu", d);
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
default:
|
2001-02-03 14:29:38 -05:00
|
|
|
if (!format_expand_styles(out, *str)) {
|
2000-05-15 04:25:45 -04:00
|
|
|
g_string_append_c(out, '%');
|
|
|
|
g_string_append_c(out, *str);
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
2000-04-26 04:03:38 -04:00
|
|
|
|
2000-05-15 04:25:45 -04:00
|
|
|
ret = out->str;
|
|
|
|
g_string_free(out, FALSE);
|
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
2001-02-03 14:29:38 -05:00
|
|
|
static char *printtext_expand_formats(const char *str)
|
2001-01-05 03:34:39 -05:00
|
|
|
{
|
|
|
|
GString *out;
|
|
|
|
char *ret;
|
|
|
|
|
|
|
|
out = g_string_new(NULL);
|
|
|
|
for (; *str != '\0'; str++) {
|
|
|
|
if (*str != '%') {
|
|
|
|
g_string_append_c(out, *str);
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (*++str == '\0')
|
|
|
|
break;
|
|
|
|
|
2001-02-03 14:29:38 -05:00
|
|
|
if (!format_expand_styles(out, *str)) {
|
2001-01-05 03:34:39 -05:00
|
|
|
g_string_append_c(out, '%');
|
|
|
|
g_string_append_c(out, *str);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
ret = out->str;
|
|
|
|
g_string_free(out, FALSE);
|
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
2000-11-29 20:41:11 -05:00
|
|
|
void printtext_dest(TEXT_DEST_REC *dest, const char *text, va_list va)
|
|
|
|
{
|
|
|
|
char *str;
|
|
|
|
|
|
|
|
if (!sending_print_starting) {
|
|
|
|
sending_print_starting = TRUE;
|
|
|
|
signal_emit_id(signal_print_starting, 1, dest);
|
|
|
|
sending_print_starting = FALSE;
|
|
|
|
}
|
|
|
|
|
|
|
|
str = printtext_get_args(dest, text, va);
|
|
|
|
print_line(dest, str);
|
|
|
|
g_free(str);
|
|
|
|
}
|
|
|
|
|
2000-10-27 23:01:11 -04:00
|
|
|
/* Write text to target - convert color codes */
|
|
|
|
void printtext(void *server, const char *target, int level, const char *text, ...)
|
2000-05-15 04:25:45 -04:00
|
|
|
{
|
|
|
|
TEXT_DEST_REC dest;
|
|
|
|
va_list va;
|
|
|
|
|
|
|
|
g_return_if_fail(text != NULL);
|
|
|
|
|
2000-10-28 16:14:19 -04:00
|
|
|
format_create_dest(&dest, server, target, level, NULL);
|
2000-05-15 04:25:45 -04:00
|
|
|
|
|
|
|
va_start(va, text);
|
2000-11-29 20:41:11 -05:00
|
|
|
printtext_dest(&dest, text, va);
|
2000-05-15 04:25:45 -04:00
|
|
|
va_end(va);
|
|
|
|
}
|
|
|
|
|
2001-01-05 03:30:01 -05:00
|
|
|
/* 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;
|
2001-01-05 03:34:39 -05:00
|
|
|
char *str;
|
2001-01-05 03:30:01 -05:00
|
|
|
|
|
|
|
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;
|
|
|
|
}
|
|
|
|
|
2001-02-03 14:29:38 -05:00
|
|
|
str = printtext_expand_formats(text);
|
2001-01-05 03:34:39 -05:00
|
|
|
print_line(&dest, str);
|
|
|
|
g_free(str);
|
2001-01-05 03:30:01 -05:00
|
|
|
}
|
|
|
|
|
2000-05-15 04:25:45 -04:00
|
|
|
void printtext_window(WINDOW_REC *window, int level, const char *text, ...)
|
|
|
|
{
|
|
|
|
TEXT_DEST_REC dest;
|
|
|
|
va_list va;
|
|
|
|
|
|
|
|
g_return_if_fail(text != NULL);
|
|
|
|
|
2000-10-28 16:14:19 -04:00
|
|
|
format_create_dest(&dest, NULL, NULL, level,
|
|
|
|
window != NULL ? window : active_win);
|
2000-05-15 04:25:45 -04:00
|
|
|
|
|
|
|
va_start(va, text);
|
2000-11-29 20:41:11 -05:00
|
|
|
printtext_dest(&dest, text, va);
|
2000-05-15 04:25:45 -04:00
|
|
|
va_end(va);
|
2000-04-26 04:03:38 -04:00
|
|
|
}
|
|
|
|
|
2001-02-20 23:21:15 -05:00
|
|
|
void printtext_gui(const char *text)
|
2001-02-03 14:29:38 -05:00
|
|
|
{
|
|
|
|
TEXT_DEST_REC dest;
|
|
|
|
char *str;
|
|
|
|
|
|
|
|
g_return_if_fail(text != NULL);
|
|
|
|
|
|
|
|
memset(&dest, 0, sizeof(dest));
|
|
|
|
|
2001-02-20 23:21:15 -05:00
|
|
|
str = printtext_expand_formats(text);
|
2001-02-03 14:29:38 -05:00
|
|
|
format_send_to_gui(&dest, str);
|
|
|
|
g_free(str);
|
|
|
|
}
|
|
|
|
|
2000-07-30 13:32:55 -04:00
|
|
|
static void msg_beep_check(SERVER_REC *server, int level)
|
|
|
|
{
|
2000-07-31 11:36:40 -04:00
|
|
|
if (level != 0 && (level & MSGLEVEL_NOHILIGHT) == 0 &&
|
|
|
|
(beep_msg_level & level) &&
|
2000-07-30 13:32:55 -04:00
|
|
|
(beep_when_away || (server != NULL && !server->usermode_away))) {
|
2001-03-03 13:22:09 -05:00
|
|
|
signal_emit("beep", 0);
|
2000-07-30 13:32:55 -04:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2000-11-12 15:20:05 -05:00
|
|
|
static void sig_print_text(TEXT_DEST_REC *dest, const char *text)
|
2000-05-15 04:25:45 -04:00
|
|
|
{
|
2000-11-20 22:00:05 -05:00
|
|
|
char *str, *tmp;
|
2000-04-26 04:03:38 -04:00
|
|
|
|
2000-11-12 15:20:05 -05:00
|
|
|
g_return_if_fail(dest != NULL);
|
2000-10-28 16:14:19 -04:00
|
|
|
g_return_if_fail(text != NULL);
|
|
|
|
|
2000-11-12 15:20:05 -05:00
|
|
|
msg_beep_check(dest->server, dest->level);
|
2000-04-26 04:03:38 -04:00
|
|
|
|
2000-11-12 15:20:05 -05:00
|
|
|
dest->window->last_line = time(NULL);
|
|
|
|
format_newline(dest->window);
|
2000-10-28 16:14:19 -04:00
|
|
|
|
2000-11-20 22:00:05 -05:00
|
|
|
/* add timestamp/server tag here - if it's done in print_line()
|
|
|
|
it would be written to log files too */
|
2000-12-02 17:08:07 -05:00
|
|
|
tmp = format_get_line_start(current_theme, dest, time(NULL));
|
2000-11-20 22:00:05 -05:00
|
|
|
str = format_add_linestart(text, tmp);
|
2000-11-22 14:46:43 -05:00
|
|
|
g_free_not_null(tmp);
|
2000-11-20 22:00:05 -05:00
|
|
|
|
2000-11-12 15:20:05 -05:00
|
|
|
format_send_to_gui(dest, str);
|
|
|
|
g_free(str);
|
2000-04-26 04:03:38 -04:00
|
|
|
|
2000-11-12 15:20:05 -05:00
|
|
|
signal_emit_id(signal_print_text_finished, 1, dest->window);
|
2000-04-26 04:03:38 -04:00
|
|
|
}
|
|
|
|
|
2000-10-28 16:14:19 -04:00
|
|
|
void printtext_multiline(void *server, const char *target, int level,
|
|
|
|
const char *format, const char *text)
|
2000-04-26 04:03:38 -04:00
|
|
|
{
|
|
|
|
char **lines, **tmp;
|
|
|
|
|
2000-09-29 19:57:30 -04:00
|
|
|
g_return_if_fail(format != NULL);
|
|
|
|
g_return_if_fail(text != NULL);
|
|
|
|
|
2000-04-28 04:07:42 -04:00
|
|
|
lines = g_strsplit(text, "\n", -1);
|
|
|
|
for (tmp = lines; *tmp != NULL; tmp++)
|
2000-12-03 01:22:35 -05:00
|
|
|
printtext(NULL, NULL, level, format, *tmp);
|
2000-04-28 04:07:42 -04:00
|
|
|
g_strfreev(lines);
|
|
|
|
}
|
|
|
|
|
|
|
|
static void sig_gui_dialog(const char *type, const char *text)
|
|
|
|
{
|
|
|
|
char *format;
|
|
|
|
|
2000-04-26 04:03:38 -04:00
|
|
|
if (g_strcasecmp(type, "warning") == 0)
|
2000-04-28 04:07:42 -04:00
|
|
|
format = _("%_Warning:%_ %s");
|
2000-04-26 04:03:38 -04:00
|
|
|
else if (g_strcasecmp(type, "error") == 0)
|
2000-04-28 04:07:42 -04:00
|
|
|
format = _("%_Error:%_ %s");
|
2000-04-26 04:03:38 -04:00
|
|
|
else
|
2000-04-28 04:07:42 -04:00
|
|
|
format = "%s";
|
2000-04-26 04:03:38 -04:00
|
|
|
|
2000-04-28 04:07:42 -04:00
|
|
|
printtext_multiline(NULL, NULL, MSGLEVEL_NEVER, format, text);
|
2000-04-26 04:03:38 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
static void read_settings(void)
|
|
|
|
{
|
2001-01-27 22:19:06 -05:00
|
|
|
beep_msg_level = level2bits(settings_get_str("beep_msg_level"));
|
2000-07-30 13:32:55 -04:00
|
|
|
beep_when_away = settings_get_bool("beep_when_away");
|
2000-04-26 04:03:38 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
void printtext_init(void)
|
|
|
|
{
|
2000-05-15 04:25:45 -04:00
|
|
|
settings_add_int("misc", "timestamp_timeout", 0);
|
2001-01-27 22:19:06 -05:00
|
|
|
settings_add_str("lookandfeel", "beep_msg_level", "");
|
2000-05-15 04:25:45 -04:00
|
|
|
|
2000-11-29 20:41:11 -05:00
|
|
|
sending_print_starting = FALSE;
|
2000-06-25 19:39:23 -04:00
|
|
|
signal_gui_print_text = signal_get_uniq_id("gui print text");
|
|
|
|
signal_print_text_stripped = signal_get_uniq_id("print text stripped");
|
|
|
|
signal_print_text = signal_get_uniq_id("print text");
|
|
|
|
signal_print_text_finished = signal_get_uniq_id("print text finished");
|
2000-10-27 23:01:11 -04:00
|
|
|
signal_print_format = signal_get_uniq_id("print format");
|
2000-11-29 20:41:11 -05:00
|
|
|
signal_print_starting = signal_get_uniq_id("print starting");
|
2000-05-15 04:25:45 -04:00
|
|
|
|
|
|
|
read_settings();
|
|
|
|
signal_add("print text", (SIGNAL_FUNC) sig_print_text);
|
|
|
|
signal_add("gui dialog", (SIGNAL_FUNC) sig_gui_dialog);
|
|
|
|
signal_add("setup changed", (SIGNAL_FUNC) read_settings);
|
2000-04-26 04:03:38 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
void printtext_deinit(void)
|
|
|
|
{
|
2000-05-15 04:25:45 -04:00
|
|
|
signal_remove("print text", (SIGNAL_FUNC) sig_print_text);
|
|
|
|
signal_remove("gui dialog", (SIGNAL_FUNC) sig_gui_dialog);
|
|
|
|
signal_remove("setup changed", (SIGNAL_FUNC) read_settings);
|
2000-04-26 04:03:38 -04:00
|
|
|
}
|