4 /* FIXME: Textbuffer code gets a lot faster in some points when I get rid of
5 GList and make prev/next pointers directly in LINE_REC. However, this
6 can still wait for a while until I get rid of GList entirely everywhere. */
8 #define LINE_TEXT_CHUNK_SIZE 16384
11 LINE_CMD_EOL=0x80, /* line ends here */
12 LINE_CMD_CONTINUE, /* line continues in next block */
13 LINE_CMD_COLOR0, /* change to black, would be same as \0\0 but it breaks things.. */
14 LINE_CMD_COLOR8, /* change to dark grey, normally 8 = bold black */
15 LINE_CMD_UNDERLINE, /* enable/disable underlining */
16 LINE_CMD_INDENT, /* if line is split, indent it at this position */
17 LINE_CMD_BLINK, /* blinking background */
18 LINE_CMD_FORMAT, /* end of line, but next will come the format that was used to create the
19 text in format <module><format_name><arg><arg2...> - fields are separated
20 with \0<format> and last argument ends with \0<eol>. \0<continue> is allowed
22 LINE_CMD_FORMAT_CONT /* multiline format, continues to next line */
31 /* text in the line. \0 means that the next char will be a
32 color or command. <= 127 = color or if 8. bit is set, the
33 first 7 bits are the command. See LINE_CMD_xxxx.
35 DO NOT ADD BLACK WITH \0\0 - this will break things. Use
36 LINE_CMD_COLOR0 instead. */
38 unsigned char refcount;
43 unsigned char buffer[LINE_TEXT_CHUNK_SIZE];
54 TEXT_CHUNK_REC *cur_text;
56 unsigned int last_eol:1;
59 /* Create new buffer */
60 TEXT_BUFFER_REC *textbuffer_create(void);
61 /* Destroy the buffer */
62 void textbuffer_destroy(TEXT_BUFFER_REC *buffer);
64 void textbuffer_line_ref(LINE_REC *line);
65 void textbuffer_line_unref(TEXT_BUFFER_REC *buffer, LINE_REC *line);
66 void textbuffer_line_unref_list(TEXT_BUFFER_REC *buffer, GList *list);
68 /* Append text to buffer. When \0<EOL> is found at the END OF DATA, a new
69 line is created. You must send the EOL command before you can do anything
70 else with the buffer. */
71 LINE_REC *textbuffer_append(TEXT_BUFFER_REC *buffer,
72 const unsigned char *data, int len,
74 LINE_REC *textbuffer_insert(TEXT_BUFFER_REC *buffer, LINE_REC *insert_after,
75 const unsigned char *data, int len,
78 void textbuffer_remove(TEXT_BUFFER_REC *buffer, LINE_REC *line);
79 /* Removes all lines from buffer, ignoring reference counters */
80 void textbuffer_remove_all_lines(TEXT_BUFFER_REC *buffer);
82 void textbuffer_line2text(LINE_REC *line, int coloring, GString *str);
83 GList *textbuffer_find_text(TEXT_BUFFER_REC *buffer, LINE_REC *startline,
84 int level, int nolevel, const char *text,
85 int regexp, int fullword, int case_sensitive);
87 void textbuffer_init(void);
88 void textbuffer_deinit(void);