1 #ifndef __TEXTBUFFER_VIEW_H
2 #define __TEXTBUFFER_VIEW_H
4 #include "textbuffer.h"
12 /* first word in line belong to the end of the last word in
14 unsigned int continues:1;
20 int count; /* number of real lines */
22 /* variable sized array, actually. starts from the second line,
23 so size of it is count-1 */
24 LINE_CACHE_SUB_REC lines[1];
31 GHashTable *line_cache;
33 /* should contain the same value for each cache that uses the
35 unsigned char update_counter;
36 /* number of real lines used by the last line in buffer */
38 } TEXT_BUFFER_CACHE_REC;
41 TEXT_BUFFER_REC *buffer;
42 GSList *siblings; /* other views that use the same buffer */
48 int longword_noindent:1;
50 TEXT_BUFFER_CACHE_REC *cache;
51 int ypos; /* cursor position - visible area is 0..height-1 */
53 GList *startline; /* line at the top of the screen */
54 int subline; /* number of "real lines" to skip from `startline' */
56 /* marks the bottom of the text buffer */
57 GList *bottom_startline;
60 /* how many empty lines are in screen. a screenful when started
63 /* window is at the bottom of the text buffer */
64 unsigned int bottom:1;
66 /* Bookmarks to the lines in the buffer - removed automatically
67 when the line gets removed from buffer */
68 GHashTable *bookmarks;
69 } TEXT_BUFFER_VIEW_REC;
71 /* Create new view. */
72 TEXT_BUFFER_VIEW_REC *textbuffer_view_create(TEXT_BUFFER_REC *buffer,
73 int width, int height,
75 int longword_noindent);
76 /* Destroy the view. */
77 void textbuffer_view_destroy(TEXT_BUFFER_VIEW_REC *view);
78 /* Change the default indent position */
79 void textbuffer_view_set_default_indent(TEXT_BUFFER_VIEW_REC *view,
81 int longword_noindent);
83 /* Resize the view. */
84 void textbuffer_view_resize(TEXT_BUFFER_VIEW_REC *view, int width, int height);
85 /* Clear the view, don't actually remove any lines from buffer. */
86 void textbuffer_view_clear(TEXT_BUFFER_VIEW_REC *view);
88 #define textbuffer_view_get_lines(view) \
89 ((view)->buffer->lines)
91 /* Scroll the view up/down */
92 void textbuffer_view_scroll(TEXT_BUFFER_VIEW_REC *view, int lines);
93 /* Scroll to specified line */
94 void textbuffer_view_scroll_line(TEXT_BUFFER_VIEW_REC *view, LINE_REC *line);
95 /* Return line cache */
96 LINE_CACHE_REC *textbuffer_view_get_line_cache(TEXT_BUFFER_VIEW_REC *view,
100 Functions for manipulating the text buffer, using these commands update
101 all views that use the buffer.
104 /* Update some line in the buffer which has been modified using
105 textbuffer_append() or textbuffer_insert(). */
106 void textbuffer_view_insert_line(TEXT_BUFFER_VIEW_REC *view, LINE_REC *line);
107 /* Remove one line from buffer. */
108 void textbuffer_view_remove_line(TEXT_BUFFER_VIEW_REC *view, LINE_REC *line);
109 /* Remove all lines from buffer. */
110 void textbuffer_view_remove_all_lines(TEXT_BUFFER_VIEW_REC *view);
112 /* Set a bookmark in view */
113 void textbuffer_view_set_bookmark(TEXT_BUFFER_VIEW_REC *view,
114 const char *name, LINE_REC *line);
115 /* Set a bookmark in view to the bottom line */
116 void textbuffer_view_set_bookmark_bottom(TEXT_BUFFER_VIEW_REC *view,
118 /* Return the line for bookmark */
119 LINE_REC *textbuffer_view_get_bookmark(TEXT_BUFFER_VIEW_REC *view,
122 /* Specify window where the changes in view should be drawn,
124 void textbuffer_view_set_window(TEXT_BUFFER_VIEW_REC *view, WINDOW *window);
125 /* Redraw the view */
126 void textbuffer_view_redraw(TEXT_BUFFER_VIEW_REC *view);
128 void textbuffer_view_init(void);
129 void textbuffer_view_deinit(void);