diff options
author | Timo Sirainen <cras@irssi.org> | 2001-04-14 22:24:56 +0000 |
---|---|---|
committer | cras <cras@dbcabf3a-b0e7-0310-adc4-f8d773084564> | 2001-04-14 22:24:56 +0000 |
commit | adb7eced395ba88816a365768fee56e04a0a0ec5 (patch) | |
tree | d4eedd91f292418468acf3eb68aef9bdfe4d3563 /src/fe-text/textbuffer-view.h | |
parent | d98fddd79647e9387ecbf674f317b02f4b78d7e2 (diff) | |
download | irssi-adb7eced395ba88816a365768fee56e04a0a0ec5.zip |
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
Diffstat (limited to 'src/fe-text/textbuffer-view.h')
-rw-r--r-- | src/fe-text/textbuffer-view.h | 131 |
1 files changed, 131 insertions, 0 deletions
diff --git a/src/fe-text/textbuffer-view.h b/src/fe-text/textbuffer-view.h new file mode 100644 index 00000000..cdb55b7f --- /dev/null +++ b/src/fe-text/textbuffer-view.h @@ -0,0 +1,131 @@ +#ifndef __TEXTBUFFER_VIEW_H +#define __TEXTBUFFER_VIEW_H + +#include "textbuffer.h" +#include "screen.h" + +typedef struct { + unsigned char *start; + int indent; + int color; + + /* first word in line belong to the end of the last word in + previous line */ + unsigned int continues:1; +} LINE_CACHE_SUB_REC; + +typedef struct { + time_t last_access; + + int count; /* number of real lines */ + + /* variable sized array, actually. starts from the second line, + so size of it is count-1 */ + LINE_CACHE_SUB_REC lines[1]; +} LINE_CACHE_REC; + +typedef struct { + int refcount; + int width; + + GHashTable *line_cache; + + /* should contain the same value for each cache that uses the + same buffer */ + unsigned char update_counter; + /* number of real lines used by the last line in buffer */ + int last_linecount; +} TEXT_BUFFER_CACHE_REC; + +typedef struct { + TEXT_BUFFER_REC *buffer; + GSList *siblings; /* other views that use the same buffer */ + + WINDOW *window; + int width, height; + int default_indent; + + TEXT_BUFFER_CACHE_REC *cache; + GList *startline; /* line at the top of the screen */ + int subline; /* number of "real lines" to skip from `startline' */ + + /* marks the bottom of the text buffer */ + GList *bottom_startline; + int bottom_subline; + + /* how many empty lines are in screen. a screenful when started + or used /CLEAR */ + int empty_linecount; + /* window is at the bottom of the text buffer */ + unsigned int bottom:1; + + /* info how to efficiently refresh window buffer */ + //unsigned int redraw:1; + int ypos; /* cursor position - visible area is 0..height-1 */ + /*GList *drawn_startline; + int drawn_subline;*/ + + /* Bookmarks to the lines in the buffer - removed automatically + when the line gets removed from buffer */ + GHashTable *bookmarks; +} TEXT_BUFFER_VIEW_REC; + +/* Create new view. */ +TEXT_BUFFER_VIEW_REC *textbuffer_view_create(TEXT_BUFFER_REC *buffer, + int width, int height, + int default_indent); +/* Destroy the view. */ +void textbuffer_view_destroy(TEXT_BUFFER_VIEW_REC *view); +/* Change the default indent position */ +void textbuffer_view_set_default_indent(TEXT_BUFFER_VIEW_REC *view, + int default_indent); + +/* Resize the view. */ +void textbuffer_view_resize(TEXT_BUFFER_VIEW_REC *view, int width, int height); +/* Clear the view, don't actually remove any lines from buffer. */ +void textbuffer_view_clear(TEXT_BUFFER_VIEW_REC *view); + +#define textbuffer_view_get_lines(view) \ + ((view)->buffer->lines) + +/* Scroll the view up/down */ +void textbuffer_view_scroll(TEXT_BUFFER_VIEW_REC *view, int lines); +/* Scroll to specified line */ +void textbuffer_view_scroll_line(TEXT_BUFFER_VIEW_REC *view, LINE_REC *line); +/* Return line cache */ +LINE_CACHE_REC *textbuffer_view_get_line_cache(TEXT_BUFFER_VIEW_REC *view, + LINE_REC *line); + +/* + Functions for manipulating the text buffer, using these commands update + all views that use the buffer. +*/ + +/* Update some line in the buffer which has been modified using + textbuffer_append() or textbuffer_insert(). */ +void textbuffer_view_insert_line(TEXT_BUFFER_VIEW_REC *view, LINE_REC *line); +/* Remove one line from buffer. */ +void textbuffer_view_remove_line(TEXT_BUFFER_VIEW_REC *view, LINE_REC *line); +/* Remove all lines from buffer. */ +void textbuffer_view_remove_all_lines(TEXT_BUFFER_VIEW_REC *view); + +/* Set a bookmark in view */ +void textbuffer_view_set_bookmark(TEXT_BUFFER_VIEW_REC *view, + const char *name, LINE_REC *line); +/* Set a bookmark in view to the bottom line */ +void textbuffer_view_set_bookmark_bottom(TEXT_BUFFER_VIEW_REC *view, + const char *name); +/* Return the line for bookmark */ +LINE_REC *textbuffer_view_get_bookmark(TEXT_BUFFER_VIEW_REC *view, + const char *name); + +/* Specify window where the changes in view should be drawn, + NULL disables it. */ +void textbuffer_view_set_window(TEXT_BUFFER_VIEW_REC *view, WINDOW *window); +/* Redraw the view */ +void textbuffer_view_redraw(TEXT_BUFFER_VIEW_REC *view); + +void textbuffer_view_init(void); +void textbuffer_view_deinit(void); + +#endif |