4 #include <gtk/gtkadjustment.h>
6 #include <X11/Xft/Xft.h>
13 #include <X11/extensions/XShm.h>
16 #define GTK_TYPE_XTEXT (gtk_xtext_get_type ())
17 #define GTK_XTEXT(object) (G_TYPE_CHECK_INSTANCE_CAST ((object), GTK_TYPE_XTEXT, GtkXText))
18 #define GTK_XTEXT_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), GTK_TYPE_XTEXT, GtkXTextClass))
19 #define GTK_IS_XTEXT(object) (G_TYPE_CHECK_INSTANCE_TYPE ((object), GTK_TYPE_XTEXT))
20 #define GTK_IS_XTEXT_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), GTK_TYPE_XTEXT))
21 #define GTK_XTEXT_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), GTK_TYPE_XTEXT, GtkXTextClass))
23 #define ATTR_BOLD '\002'
24 #define ATTR_COLOR '\003'
25 #define ATTR_BLINK '\006'
26 #define ATTR_BEEP '\007'
27 #define ATTR_HIDDEN '\010'
28 #define ATTR_ITALICS2 '\011'
29 #define ATTR_RESET '\017'
30 #define ATTR_REVERSE '\026'
31 #define ATTR_ITALICS '\035'
32 #define ATTR_UNDERLINE '\037'
34 /* these match palette.h */
35 #define XTEXT_MIRC_COLS 32
36 #define XTEXT_COLS 37 /* 32 plus 5 for extra stuff below */
37 #define XTEXT_MARK_FG 32 /* for marking text */
38 #define XTEXT_MARK_BG 33
41 #define XTEXT_MARKER 36 /* for marker line */
43 typedef struct _GtkXText GtkXText
;
44 typedef struct _GtkXTextClass GtkXTextClass
;
45 typedef struct textentry textentry
;
48 GtkXText
*xtext
; /* attached to this widget */
50 gfloat old_value
; /* last known adj->value */
51 textentry
*text_first
;
53 guint16 grid_offset
[256];
55 textentry
*last_ent_start
; /* this basically describes the last rendered */
56 textentry
*last_ent_end
; /* selection. */
57 int last_offset_start
;
64 textentry
*pagetop_ent
; /* what's at xtext->adj->value */
67 int indent
; /* position of separator (pixels) from left */
69 textentry
*marker_pos
;
71 int window_width
; /* window size when last rendered. */
74 unsigned int time_stamp
:1;
75 unsigned int scrollbar_down
:1;
76 unsigned int needs_recalc
:1;
77 unsigned int grid_dirty
:1;
78 unsigned int marker_seen
:1;
79 unsigned int reset_marker_pos
:1;
87 xtext_buffer
*orig_buffer
;
88 xtext_buffer
*selection_buffer
;
91 XShmSegmentInfo shminfo
;
95 GdkPixmap
*pixmap
; /* 0 = use palette[19] */
96 GdkDrawable
*draw_buf
; /* points to ->window */
97 GdkCursor
*hand_cursor
;
98 GdkCursor
*resize_cursor
;
100 int pixel_offset
; /* amount of pixels the top line is chopped by */
111 GdkGC
*bgc
; /* backing pixmap */
112 GdkGC
*fgc
; /* text foreground color */
113 GdkGC
*light_gc
; /* sep bar */
117 gulong palette
[XTEXT_COLS
];
119 gint io_tag
; /* for delayed refresh events */
120 gint add_io_tag
; /* "" when adding new text */
121 gint scroll_tag
; /* marking-scroll timeout */
122 gulong vc_signal_tag
; /* signal handler for "value_changed" adj */
124 int select_start_adj
; /* the adj->value when the selection started */
135 int depth
; /* gdk window depth */
137 char num
[8]; /* for parsing mirc color */
138 int nc
; /* offset into xtext->num */
140 textentry
*hilight_ent
;
144 guint16 fontwidth
[128]; /* each char's width, only the ASCII ones */
147 XftColor color
[XTEXT_COLS
];
149 XftColor
*xft_bg
; /* both point into color[20] */
152 XftFont
*ifont
; /* italics */
156 PangoFontDescription
*font
;
157 PangoFontDescription
*ifont
; /* italics */
165 int space_width
; /* width (pixels) of the space " " character */
166 int stamp_width
; /* width of "[88:88:88]" */
169 unsigned char scratch_buffer
[4096];
171 void (*error_function
) (int type
);
172 int (*urlcheck_function
) (GtkWidget
* xtext
, char *word
, int len
);
174 int jump_out_offset
; /* point at which to stop rendering */
175 int jump_in_offset
; /* "" start rendering */
177 int ts_x
; /* ts origin for ->bgc GC */
180 int clip_x
; /* clipping (x directions) */
181 int clip_x2
; /* from x to x2 */
183 int clip_y
; /* clipping (y directions) */
184 int clip_y2
; /* from y to y2 */
186 /* current text states */
188 unsigned int underline
:1;
189 unsigned int italics
:1;
190 unsigned int hidden
:1;
192 /* text parsing states */
193 unsigned int parsing_backcolor
:1;
194 unsigned int parsing_color
:1;
195 unsigned int backcolor
:1;
197 /* various state information */
198 unsigned int moving_separator
:1;
199 unsigned int word_or_line_select
:1;
200 unsigned int button_down
:1;
201 unsigned int hilighting
:1;
202 unsigned int dont_render
:1;
203 unsigned int dont_render2
:1;
204 unsigned int cursor_hand
:1;
205 unsigned int cursor_resize
:1;
206 unsigned int skip_border_fills
:1;
207 unsigned int skip_stamp
:1;
208 unsigned int mark_stamp
:1; /* Cut&Paste with stamps? */
209 unsigned int force_stamp
:1; /* force redrawing it */
210 unsigned int render_hilights_only
:1;
211 unsigned int in_hilight
:1;
212 unsigned int un_hilight
:1;
213 unsigned int recycle
:1;
214 unsigned int avoid_trans
:1;
215 unsigned int force_render
:1;
217 unsigned int color_paste
:1; /* CTRL was pressed when selection finished */
220 unsigned int auto_indent
:1;
221 unsigned int thinline
:1;
222 unsigned int transparent
:1;
223 unsigned int shaded
:1;
224 unsigned int marker
:1;
225 unsigned int separator
:1;
226 unsigned int wordwrap
:1;
227 unsigned int overdraw
:1;
228 unsigned int ignore_hidden
:1; /* rawlog uses this */
231 struct _GtkXTextClass
233 GtkWidgetClass parent_class
;
234 void (*word_click
) (GtkXText
* xtext
, char *word
, GdkEventButton
* event
);
237 GtkWidget
*gtk_xtext_new (GdkColor palette
[], int separator
);
238 void gtk_xtext_append (xtext_buffer
*buf
, unsigned char *text
, int len
);
239 void gtk_xtext_append_indent (xtext_buffer
*buf
,
240 unsigned char *left_text
, int left_len
,
241 unsigned char *right_text
, int right_len
,
243 int gtk_xtext_set_font (GtkXText
*xtext
, char *name
);
244 void gtk_xtext_set_background (GtkXText
* xtext
, GdkPixmap
* pixmap
, gboolean trans
);
245 void gtk_xtext_set_palette (GtkXText
* xtext
, GdkColor palette
[]);
246 void gtk_xtext_clear (xtext_buffer
*buf
, int lines
);
247 void gtk_xtext_save (GtkXText
* xtext
, int fh
);
248 void gtk_xtext_refresh (GtkXText
* xtext
, int do_trans
);
249 int gtk_xtext_lastlog (xtext_buffer
*out
, xtext_buffer
*search_area
, int (*cmp_func
) (char *, void *userdata
), void *userdata
);
250 textentry
*gtk_xtext_search (GtkXText
* xtext
, const gchar
*text
, textentry
*start
, gboolean case_match
, gboolean backward
);
251 void gtk_xtext_reset_marker_pos (GtkXText
*xtext
);
252 void gtk_xtext_check_marker_visibility(GtkXText
*xtext
);
254 gboolean
gtk_xtext_is_empty (xtext_buffer
*buf
);
255 typedef void (*GtkXTextForeach
) (GtkXText
*xtext
, unsigned char *text
, void *data
);
256 void gtk_xtext_foreach (xtext_buffer
*buf
, GtkXTextForeach func
, void *data
);
258 void gtk_xtext_set_error_function (GtkXText
*xtext
, void (*error_function
) (int));
259 void gtk_xtext_set_indent (GtkXText
*xtext
, gboolean indent
);
260 void gtk_xtext_set_max_indent (GtkXText
*xtext
, int max_auto_indent
);
261 void gtk_xtext_set_max_lines (GtkXText
*xtext
, int max_lines
);
262 void gtk_xtext_set_show_marker (GtkXText
*xtext
, gboolean show_marker
);
263 void gtk_xtext_set_show_separator (GtkXText
*xtext
, gboolean show_separator
);
264 void gtk_xtext_set_thin_separator (GtkXText
*xtext
, gboolean thin_separator
);
265 void gtk_xtext_set_time_stamp (xtext_buffer
*buf
, gboolean timestamp
);
266 void gtk_xtext_set_tint (GtkXText
*xtext
, int tint_red
, int tint_green
, int tint_blue
);
267 void gtk_xtext_set_urlcheck_function (GtkXText
*xtext
, int (*urlcheck_function
) (GtkWidget
*, char *, int));
268 void gtk_xtext_set_wordwrap (GtkXText
*xtext
, gboolean word_wrap
);
270 xtext_buffer
*gtk_xtext_buffer_new (GtkXText
*xtext
);
271 void gtk_xtext_buffer_free (xtext_buffer
*buf
);
272 void gtk_xtext_buffer_show (GtkXText
*xtext
, xtext_buffer
*buf
, int render
);
273 GType
gtk_xtext_get_type (void);