4 #define LINE_TEXT_CHUNK_SIZE 16384
6 #define LINE_COLOR_BG 0x20
7 #define LINE_COLOR_DEFAULT 0x10
8 #define LINE_COLOR_BOLD 0x08
9 #define LINE_COLOR_BLINK 0x08
12 LINE_CMD_EOL=0x80, /* line ends here */
13 LINE_CMD_CONTINUE, /* line continues in next block */
14 LINE_CMD_COLOR0, /* change to black, would be same as \0\0 but it breaks things.. */
15 LINE_CMD_UNDERLINE, /* enable/disable underlining */
16 LINE_CMD_REVERSE, /* enable/disable reversed text */
17 LINE_CMD_INDENT, /* if line is split, indent it at this position */
18 LINE_CMD_INDENT_FUNC, /* if line is split, use the specified indentation function */
19 LINE_CMD_FORMAT, /* end of line, but next will come the format that was used to create the
20 text in format <module><format_name><arg><arg2...> - fields are separated
21 with \0<format> and last argument ends with \0<eol>. \0<continue> is allowed
23 LINE_CMD_FORMAT_CONT /* multiline format, continues to next line */
31 typedef struct _LINE_REC {
32 /* Text in the line. \0 means that the next char will be a
35 If the 7th bit is set, the lowest 7 bits are the command
36 (see LINE_CMD_xxxx). Otherwise they specify a color change:
39 5 - Setting a background color
40 4 - Use "default terminal color"
41 3 - Bold (fg) / blink (bg) - can be used with 4th bit
44 DO NOT ADD BLACK WITH \0\0 - this will break things. Use
45 LINE_CMD_COLOR0 instead. */
46 struct _LINE_REC *prev, *next;
49 unsigned char refcount;
54 unsigned char buffer[LINE_TEXT_CHUNK_SIZE];
65 TEXT_CHUNK_REC *cur_text;
67 unsigned int last_eol:1;
70 /* Create new buffer */
71 TEXT_BUFFER_REC *textbuffer_create(void);
72 /* Destroy the buffer */
73 void textbuffer_destroy(TEXT_BUFFER_REC *buffer);
75 void textbuffer_line_ref(LINE_REC *line);
76 void textbuffer_line_unref(TEXT_BUFFER_REC *buffer, LINE_REC *line);
77 void textbuffer_line_unref_list(TEXT_BUFFER_REC *buffer, GList *list);
79 LINE_REC *textbuffer_line_last(TEXT_BUFFER_REC *buffer);
80 int textbuffer_line_exists_after(LINE_REC *line, LINE_REC *search);
82 /* Append text to buffer. When \0<EOL> is found at the END OF DATA, a new
83 line is created. You must send the EOL command before you can do anything
84 else with the buffer. */
85 LINE_REC *textbuffer_append(TEXT_BUFFER_REC *buffer,
86 const unsigned char *data, int len,
88 LINE_REC *textbuffer_insert(TEXT_BUFFER_REC *buffer, LINE_REC *insert_after,
89 const unsigned char *data, int len,
92 void textbuffer_remove(TEXT_BUFFER_REC *buffer, LINE_REC *line);
93 /* Removes all lines from buffer, ignoring reference counters */
94 void textbuffer_remove_all_lines(TEXT_BUFFER_REC *buffer);
96 void textbuffer_line2text(LINE_REC *line, int coloring, GString *str);
97 GList *textbuffer_find_text(TEXT_BUFFER_REC *buffer, LINE_REC *startline,
98 int level, int nolevel, const char *text,
99 int before, int after,
100 int regexp, int fullword, int case_sensitive);
102 void textbuffer_init(void);
103 void textbuffer_deinit(void);