mirror of
https://github.com/irssi/irssi.git
synced 2026-08-10 20:33:46 +02:00
Text printing changes. Formats are now optionally saved to each line so
later if you used /format it would change the old lines too. However the actual line changing doesn't work yet :) git-svn-id: http://svn.irssi.org/repos/irssi/trunk@836 dbcabf3a-b0e7-0310-adc4-f8d773084564
This commit is contained in:
parent
61f33a6bb2
commit
d1330fff6d
14 changed files with 515 additions and 391 deletions
|
|
@ -23,8 +23,9 @@
|
|||
#include "commands.h"
|
||||
#include "settings.h"
|
||||
|
||||
#include "printtext.h"
|
||||
#include "windows.h"
|
||||
#include "formats.h"
|
||||
#include "printtext.h"
|
||||
#include "themes.h"
|
||||
|
||||
#include "screen.h"
|
||||
|
|
@ -35,6 +36,9 @@
|
|||
int mirc_colors[] = { 15, 0, 1, 2, 12, 6, 5, 4, 14, 10, 3, 11, 9, 13, 8, 7, 15 };
|
||||
static int scrollback_lines, scrollback_hours;
|
||||
|
||||
static int scrollback_save_formats;
|
||||
static GString *format;
|
||||
|
||||
#define mark_temp_eol(text) \
|
||||
memcpy((text)->buffer + (text)->pos, "\0\200", 2);
|
||||
|
||||
|
|
@ -256,7 +260,8 @@ static void line_add_colors(GUI_WINDOW_REC *gui, int fg, int bg, int flags)
|
|||
gui->last_color = fg | (bg << 4);
|
||||
}
|
||||
|
||||
static void gui_printtext(WINDOW_REC *window, gpointer fgcolor, gpointer bgcolor, gpointer pflags, char *str, gpointer level)
|
||||
static void gui_printtext(WINDOW_REC *window, void *fgcolor, void *bgcolor,
|
||||
void *pflags, char *str, void *level)
|
||||
{
|
||||
GUI_WINDOW_REC *gui;
|
||||
LINE_REC *line;
|
||||
|
|
@ -275,9 +280,8 @@ static void gui_printtext(WINDOW_REC *window, gpointer fgcolor, gpointer bgcolor
|
|||
if (gui->cur_text == NULL)
|
||||
create_text_chunk(gui);
|
||||
|
||||
/* \n can be only at the start of the line.. */
|
||||
if (*str == '\n') {
|
||||
str++;
|
||||
/* newline can be only at the start of the line.. */
|
||||
if (flags & PRINTFLAG_NEWLINE) {
|
||||
linebuf_add(gui, "\0\200", 2); /* mark EOL */
|
||||
|
||||
line = create_line(gui, 0);
|
||||
|
|
@ -368,6 +372,15 @@ static void sig_printtext_finished(WINDOW_REC *window)
|
|||
GUI_WINDOW_REC *gui;
|
||||
|
||||
gui = WINDOW_GUI(window);
|
||||
|
||||
if (format->len > 0) {
|
||||
/* save format of the line */
|
||||
linebuf_add(gui, format->str, format->len);
|
||||
mark_temp_eol(gui->cur_text);
|
||||
|
||||
g_string_truncate(format, 0);
|
||||
}
|
||||
|
||||
if (is_window_visible(window)) {
|
||||
#ifdef USE_CURSES_WINDOWS
|
||||
screen_refresh(gui->parent->curses_win);
|
||||
|
|
@ -377,19 +390,57 @@ static void sig_printtext_finished(WINDOW_REC *window)
|
|||
}
|
||||
}
|
||||
|
||||
static void sig_print_format(THEME_REC *theme, const char *module,
|
||||
TEXT_DEST_REC *dest, void *formatnump,
|
||||
char **args)
|
||||
{
|
||||
FORMAT_REC *formats;
|
||||
int formatnum, n;
|
||||
|
||||
if (!scrollback_save_formats)
|
||||
return;
|
||||
|
||||
formatnum = GPOINTER_TO_INT(formatnump);
|
||||
formats = g_hash_table_lookup(default_formats, module);
|
||||
|
||||
/* <module><format_name><arg...> */
|
||||
g_string_truncate(format, 0);
|
||||
|
||||
g_string_append_c(format, '\0');
|
||||
g_string_append_c(format, (char)LINE_CMD_FORMAT);
|
||||
|
||||
g_string_append(format, module);
|
||||
g_string_append_c(format, '\0');
|
||||
|
||||
g_string_append_c(format, (char)LINE_CMD_FORMAT);
|
||||
g_string_append(format, formats[formatnum].tag);
|
||||
|
||||
for (n = 0; n < formats[formatnum].params; n++) {
|
||||
g_string_append_c(format, '\0');
|
||||
g_string_append_c(format, (char)LINE_CMD_FORMAT);
|
||||
|
||||
g_string_append(format, args[n]);
|
||||
}
|
||||
}
|
||||
|
||||
static void read_settings(void)
|
||||
{
|
||||
scrollback_lines = settings_get_int("scrollback_lines");
|
||||
scrollback_hours = settings_get_int("scrollback_hours");
|
||||
scrollback_save_formats = settings_get_bool("scrollback_save_formats");
|
||||
}
|
||||
|
||||
void gui_printtext_init(void)
|
||||
{
|
||||
format = g_string_new(NULL);
|
||||
|
||||
settings_add_int("history", "scrollback_lines", 500);
|
||||
settings_add_int("history", "scrollback_hours", 24);
|
||||
settings_add_bool("history", "scrollback_save_formats", FALSE);
|
||||
|
||||
signal_add("gui print text", (SIGNAL_FUNC) gui_printtext);
|
||||
signal_add("print text finished", (SIGNAL_FUNC) sig_printtext_finished);
|
||||
signal_add("print format", (SIGNAL_FUNC) sig_print_format);
|
||||
signal_add("setup changed", (SIGNAL_FUNC) read_settings);
|
||||
command_bind("clear", NULL, (SIGNAL_FUNC) cmd_clear);
|
||||
|
||||
|
|
@ -398,8 +449,11 @@ void gui_printtext_init(void)
|
|||
|
||||
void gui_printtext_deinit(void)
|
||||
{
|
||||
g_string_free(format, TRUE);
|
||||
|
||||
signal_remove("gui print text", (SIGNAL_FUNC) gui_printtext);
|
||||
signal_remove("print text finished", (SIGNAL_FUNC) sig_printtext_finished);
|
||||
signal_remove("print format", (SIGNAL_FUNC) sig_print_format);
|
||||
signal_remove("setup changed", (SIGNAL_FUNC) read_settings);
|
||||
command_unbind("clear", (SIGNAL_FUNC) cmd_clear);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -63,6 +63,7 @@ static gchar *gui_window_line2text(LINE_REC *line)
|
|||
else switch ((guchar) *ptr)
|
||||
{
|
||||
case LINE_CMD_EOL:
|
||||
case LINE_CMD_FORMAT:
|
||||
ret = str->str;
|
||||
g_string_free(str, FALSE);
|
||||
return ret;
|
||||
|
|
|
|||
|
|
@ -277,7 +277,7 @@ static LINE_CACHE_REC *gui_window_line_cache(GUI_WINDOW_REC *gui,
|
|||
if (*ptr == '\0') {
|
||||
/* command */
|
||||
ptr++;
|
||||
if (*ptr == LINE_CMD_EOL)
|
||||
if (*ptr == LINE_CMD_EOL || *ptr == LINE_CMD_FORMAT)
|
||||
break;
|
||||
|
||||
if (*ptr == LINE_CMD_CONTINUE) {
|
||||
|
|
@ -445,6 +445,7 @@ static void single_line_draw(GUI_WINDOW_REC *gui, int ypos,
|
|||
case LINE_CMD_OVERFLOW:
|
||||
g_error("buffer overflow! (draw)");
|
||||
case LINE_CMD_EOL:
|
||||
case LINE_CMD_FORMAT:
|
||||
return;
|
||||
case LINE_CMD_UNDERLINE:
|
||||
color ^= ATTR_UNDERLINE;
|
||||
|
|
@ -780,7 +781,8 @@ GList *gui_window_find_text(WINDOW_REC *window, gchar *text, GList *startline, i
|
|||
memcpy(&tmp, ptr+1, sizeof(gchar *));
|
||||
ptr = tmp-1;
|
||||
}
|
||||
else if ((guchar) *ptr == LINE_CMD_EOL)
|
||||
else if ((guchar) *ptr == LINE_CMD_EOL ||
|
||||
(guchar) *ptr == LINE_CMD_FORMAT)
|
||||
break;
|
||||
else if ((guchar) *ptr == LINE_CMD_OVERFLOW)
|
||||
g_error("buffer overflow! (find)");
|
||||
|
|
|
|||
|
|
@ -19,8 +19,12 @@ enum {
|
|||
LINE_CMD_COLOR0, /* change to black, would be same as \0\0 but it breaks things.. */
|
||||
LINE_CMD_COLOR8, /* change to dark grey, normally 8 = bold black */
|
||||
LINE_CMD_UNDERLINE, /* enable/disable underlining */
|
||||
LINE_CMD_INDENT, /* if line is split, indent it at this position */
|
||||
LINE_CMD_BLINK /* blinking background */
|
||||
LINE_CMD_INDENT, /* if line is split, indent it at this position */
|
||||
LINE_CMD_BLINK, /* blinking background */
|
||||
LINE_CMD_FORMAT /* end of line, but next will come the format that was used to create the
|
||||
text in format <module><format_name><arg><arg2...> - fields are separated
|
||||
with \0<format> and last argument ends with \0<eol>. \0<continue> is allowed
|
||||
anywhere */
|
||||
};
|
||||
|
||||
typedef struct {
|
||||
|
|
|
|||
|
|
@ -32,9 +32,10 @@
|
|||
|
||||
#include "windows.h"
|
||||
#include "window-items.h"
|
||||
#include "printtext.h"
|
||||
#include "formats.h"
|
||||
|
||||
#include "screen.h"
|
||||
#include "printtext.h"
|
||||
#include "statusbar.h"
|
||||
#include "gui-windows.h"
|
||||
#include "gui-printtext.h"
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue