4 /* Make sure TEXT_CHUNK_REC is not slightly more than a page, as that
5 wastes a lot of memory. */
6 #define LINE_TEXT_CHUNK_SIZE (16384 - 16)
8 #define LINE_COLOR_BG 0x20
9 #define LINE_COLOR_DEFAULT 0x10
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_BLINK, /* enable/disable blink */
19 LINE_CMD_BOLD, /* enable/disable bold */
27 typedef struct _LINE_REC {
28 /* Text in the line. \0 means that the next char will be a
31 If the 7th bit is set, the lowest 7 bits are the command
32 (see LINE_CMD_xxxx). Otherwise they specify a color change:
35 5 - Setting a background color
36 4 - Use "default terminal color"
39 DO NOT ADD BLACK WITH \0\0 - this will break things. Use
40 LINE_CMD_COLOR0 instead. */
41 struct _LINE_REC *prev, *next;
48 unsigned char buffer[LINE_TEXT_CHUNK_SIZE];
59 TEXT_CHUNK_REC *cur_text;
61 unsigned int last_eol:1;
67 /* Create new buffer */
68 TEXT_BUFFER_REC *textbuffer_create(void);
69 /* Destroy the buffer */
70 void textbuffer_destroy(TEXT_BUFFER_REC *buffer);
72 LINE_REC *textbuffer_line_last(TEXT_BUFFER_REC *buffer);
73 int textbuffer_line_exists_after(LINE_REC *line, LINE_REC *search);
75 void textbuffer_line_add_colors(TEXT_BUFFER_REC *buffer, LINE_REC **line,
76 int fg, int bg, int flags);
78 /* Append text to buffer. When \0<EOL> is found at the END OF DATA, a new
79 line is created. You must send the EOL command before you can do anything
80 else with the buffer. */
81 LINE_REC *textbuffer_append(TEXT_BUFFER_REC *buffer,
82 const unsigned char *data, int len,
84 LINE_REC *textbuffer_insert(TEXT_BUFFER_REC *buffer, LINE_REC *insert_after,
85 const unsigned char *data, int len,
88 void textbuffer_remove(TEXT_BUFFER_REC *buffer, LINE_REC *line);
89 /* Removes all lines from buffer, ignoring reference counters */
90 void textbuffer_remove_all_lines(TEXT_BUFFER_REC *buffer);
92 void textbuffer_line2text(LINE_REC *line, int coloring, GString *str);
93 GList *textbuffer_find_text(TEXT_BUFFER_REC *buffer, LINE_REC *startline,
94 int level, int nolevel, const char *text,
95 int before, int after,
96 int regexp, int fullword, int case_sensitive);
98 void textbuffer_init(void);
99 void textbuffer_deinit(void);