mirror of
https://github.com/irssi/irssi.git
synced 2026-08-10 04:13:32 +02:00
Rewrote text buffer handling in windows - try #3.
/SET scrollback_save_formats + /SB REDRAW is broken currently. There's some other minor things that might need to be changed. This time it allows the same window to be visible multiple times in screen, like you could make a new split window where to scroll back and find something while still seeing the new messages at the other window, this however doesn't work yet but it should be quite easy to make it :) I've tested that pretty much everything should work with this, new lines can be added at any position and lines can be removed from any position and screen should be updated properly. Screen resizing should also work perfectly now (maybe it did previously too, not sure) and hopefully now we won't see any of those ugly strange bugs some people were having. Also this time the same code isn't written 2-3 times to do some specific thing, like scrolling has now only one view_scroll() function instead of the 3 separate functions it used to have :) git-svn-id: http://svn.irssi.org/repos/irssi/trunk@1442 dbcabf3a-b0e7-0310-adc4-f8d773084564
This commit is contained in:
parent
d98fddd796
commit
adb7eced39
20 changed files with 2424 additions and 1925 deletions
90
src/fe-text/textbuffer.h
Normal file
90
src/fe-text/textbuffer.h
Normal file
|
|
@ -0,0 +1,90 @@
|
|||
#ifndef __TEXTBUFFER_H
|
||||
#define __TEXTBUFFER_H
|
||||
|
||||
/* FIXME: Textbuffer code gets a lot faster in some points when I get rid of
|
||||
GList and make prev/next pointers directly in LINE_REC. However, this
|
||||
can still wait for a while until I get rid of GList entirely everywhere. */
|
||||
|
||||
#define LINE_TEXT_CHUNK_SIZE 16384
|
||||
|
||||
enum {
|
||||
LINE_CMD_EOL=0x80, /* line ends here */
|
||||
LINE_CMD_CONTINUE, /* line continues in next block */
|
||||
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_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 */
|
||||
};
|
||||
|
||||
typedef struct {
|
||||
int level;
|
||||
time_t time;
|
||||
} LINE_INFO_REC;
|
||||
|
||||
typedef struct {
|
||||
/* text in the line. \0 means that the next char will be a
|
||||
color or command. <= 127 = color or if 8. bit is set, the
|
||||
first 7 bits are the command. See LINE_CMD_xxxx.
|
||||
|
||||
DO NOT ADD BLACK WITH \0\0 - this will break things. Use
|
||||
LINE_CMD_COLOR0 instead. */
|
||||
unsigned char *text;
|
||||
unsigned char refcount;
|
||||
LINE_INFO_REC info;
|
||||
} LINE_REC;
|
||||
|
||||
typedef struct {
|
||||
unsigned char buffer[LINE_TEXT_CHUNK_SIZE];
|
||||
int pos;
|
||||
int refcount;
|
||||
} TEXT_CHUNK_REC;
|
||||
|
||||
typedef struct {
|
||||
GSList *text_chunks;
|
||||
GList *lines;
|
||||
int lines_count;
|
||||
|
||||
LINE_REC *cur_line;
|
||||
TEXT_CHUNK_REC *cur_text;
|
||||
|
||||
unsigned int last_eol:1;
|
||||
} TEXT_BUFFER_REC;
|
||||
|
||||
/* Create new buffer */
|
||||
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);
|
||||
|
||||
/* 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. */
|
||||
LINE_REC *textbuffer_append(TEXT_BUFFER_REC *buffer,
|
||||
const unsigned char *data, int len,
|
||||
LINE_INFO_REC *info);
|
||||
LINE_REC *textbuffer_insert(TEXT_BUFFER_REC *buffer, LINE_REC *insert_after,
|
||||
const unsigned char *data, int len,
|
||||
LINE_INFO_REC *info);
|
||||
|
||||
void textbuffer_remove(TEXT_BUFFER_REC *buffer, LINE_REC *line);
|
||||
/* Removes all lines from buffer, ignoring reference counters */
|
||||
void textbuffer_remove_all_lines(TEXT_BUFFER_REC *buffer);
|
||||
|
||||
void textbuffer_line2text(LINE_REC *line, int coloring, GString *str);
|
||||
GList *textbuffer_find_text(TEXT_BUFFER_REC *buffer, LINE_REC *startline,
|
||||
int level, int nolevel, const char *text,
|
||||
int regexp, int fullword, int case_sensitive);
|
||||
|
||||
void textbuffer_init(void);
|
||||
void textbuffer_deinit(void);
|
||||
|
||||
#endif
|
||||
Loading…
Add table
Add a link
Reference in a new issue