Merge Irssi 0.8.16-rc1
[silc.git] / apps / irssi / src / fe-text / textbuffer.h
index adea3604c3a84613c71181235758e6fe1c40c9b2..e5d784870f79e729a6cf37a900e178a98e83cba8 100644 (file)
@@ -1,12 +1,12 @@
 #ifndef __TEXTBUFFER_H
 #define __TEXTBUFFER_H
 
-#define LINE_TEXT_CHUNK_SIZE 16384
+/* Make sure TEXT_CHUNK_REC is not slightly more than a page, as that
+   wastes a lot of memory. */
+#define LINE_TEXT_CHUNK_SIZE (16384 - 16)
 
 #define LINE_COLOR_BG          0x20
 #define LINE_COLOR_DEFAULT     0x10
-#define LINE_COLOR_BOLD                0x08
-#define LINE_COLOR_BLINK               0x08
 
 enum {
        LINE_CMD_EOL=0x80,      /* line ends here */
@@ -15,12 +15,8 @@ enum {
        LINE_CMD_UNDERLINE,     /* enable/disable underlining */
        LINE_CMD_REVERSE,       /* enable/disable reversed text */
        LINE_CMD_INDENT,        /* if line is split, indent it at this position */
-       LINE_CMD_INDENT_FUNC,   /* if line is split, use the specified indentation function */
-       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 */
-       LINE_CMD_FORMAT_CONT    /* multiline format, continues to next line */
+       LINE_CMD_BLINK,         /* enable/disable blink */
+       LINE_CMD_BOLD,          /* enable/disable bold */
 };
 
 typedef struct {
@@ -38,15 +34,13 @@ typedef struct _LINE_REC {
           Bit:
             5 - Setting a background color
             4 - Use "default terminal color"
-            3 - Bold (fg) / blink (bg) - can be used with 4th bit
-            0-2 - Color
+            0-3 - Color
 
           DO NOT ADD BLACK WITH \0\0 - this will break things. Use
           LINE_CMD_COLOR0 instead. */
        struct _LINE_REC *prev, *next;
 
        unsigned char *text;
-        unsigned char refcount;
         LINE_INFO_REC info;
 } LINE_REC;
 
@@ -65,6 +59,9 @@ typedef struct {
        TEXT_CHUNK_REC *cur_text;
 
        unsigned int last_eol:1;
+       int last_fg;
+       int last_bg;
+       int last_flags;
 } TEXT_BUFFER_REC;
 
 /* Create new buffer */
@@ -72,13 +69,12 @@ TEXT_BUFFER_REC *textbuffer_create(void);
 /* Destroy the buffer */
 void textbuffer_destroy(TEXT_BUFFER_REC *buffer);
 
-void textbuffer_line_ref(LINE_REC *line);
-void textbuffer_line_unref(TEXT_BUFFER_REC *buffer, LINE_REC *line);
-void textbuffer_line_unref_list(TEXT_BUFFER_REC *buffer, GList *list);
-
 LINE_REC *textbuffer_line_last(TEXT_BUFFER_REC *buffer);
 int textbuffer_line_exists_after(LINE_REC *line, LINE_REC *search);
 
+void textbuffer_line_add_colors(TEXT_BUFFER_REC *buffer, LINE_REC **line,
+                               int fg, int bg, int flags);
+
 /* Append text to buffer. When \0<EOL> is found at the END OF DATA, a new
    line is created. You must send the EOL command before you can do anything
    else with the buffer. */