mirror of
https://github.com/moparisthebest/hexchat
synced 2024-11-26 03:02:17 -05:00
xtext: Use cairo to draw everything
This commit is contained in:
parent
c1d9aad546
commit
7769de4018
@ -57,7 +57,7 @@
|
|||||||
#include <canberra.h>
|
#include <canberra.h>
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
GdkPixmap *channelwin_pix;
|
GdkPixbuf *channelwin_pix;
|
||||||
|
|
||||||
#ifdef USE_LIBCANBERRA
|
#ifdef USE_LIBCANBERRA
|
||||||
static ca_context *ca_con;
|
static ca_context *ca_con;
|
||||||
@ -296,7 +296,7 @@ fe_init (void)
|
|||||||
#ifdef HAVE_GTK_MAC
|
#ifdef HAVE_GTK_MAC
|
||||||
gtkosx_application_set_dock_icon_pixbuf (osx_app, pix_hexchat);
|
gtkosx_application_set_dock_icon_pixbuf (osx_app, pix_hexchat);
|
||||||
#endif
|
#endif
|
||||||
channelwin_pix = pixmap_load_from_file (prefs.hex_text_background);
|
channelwin_pix = gdk_pixbuf_new_from_file (prefs.hex_text_background, NULL);
|
||||||
input_style = create_input_style (gtk_style_new ());
|
input_style = create_input_style (gtk_style_new ());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -193,7 +193,7 @@ typedef struct session_gui
|
|||||||
|
|
||||||
} session_gui;
|
} session_gui;
|
||||||
|
|
||||||
extern GdkPixmap *channelwin_pix;
|
extern GdkPixbuf *channelwin_pix;
|
||||||
extern GdkPixmap *dialogwin_pix;
|
extern GdkPixmap *dialogwin_pix;
|
||||||
|
|
||||||
#define SPELL_ENTRY_GET_TEXT(e) ((char *)(gtk_entry_get_text (GTK_ENTRY(e))))
|
#define SPELL_ENTRY_GET_TEXT(e) ((char *)(gtk_entry_get_text (GTK_ENTRY(e))))
|
||||||
|
@ -2032,7 +2032,7 @@ setup_apply_real (int new_pix, int do_ulist, int do_layout)
|
|||||||
{
|
{
|
||||||
if (channelwin_pix)
|
if (channelwin_pix)
|
||||||
g_object_unref (channelwin_pix);
|
g_object_unref (channelwin_pix);
|
||||||
channelwin_pix = pixmap_load_from_file (prefs.hex_text_background);
|
channelwin_pix = gdk_pixbuf_new_from_file (prefs.hex_text_background, NULL);
|
||||||
}
|
}
|
||||||
|
|
||||||
input_style = create_input_style (input_style);
|
input_style = create_input_style (input_style);
|
||||||
|
@ -18,6 +18,7 @@
|
|||||||
*
|
*
|
||||||
* xtext, the text widget used by X-Chat.
|
* xtext, the text widget used by X-Chat.
|
||||||
* By Peter Zelezny <zed@xchat.org>.
|
* By Peter Zelezny <zed@xchat.org>.
|
||||||
|
* Includes work from Conspire and xchat-gnome
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
|
|
||||||
@ -139,27 +140,54 @@ static void gtk_xtext_search_textentry_fini (gpointer, gpointer);
|
|||||||
static void gtk_xtext_search_fini (xtext_buffer *);
|
static void gtk_xtext_search_fini (xtext_buffer *);
|
||||||
static gboolean gtk_xtext_search_init (xtext_buffer *buf, const gchar *text, gtk_xtext_search_flags flags, GError **perr);
|
static gboolean gtk_xtext_search_init (xtext_buffer *buf, const gchar *text, gtk_xtext_search_flags flags, GError **perr);
|
||||||
|
|
||||||
/* Avoid warning messages for this unused function */
|
static inline void
|
||||||
#if 0
|
xtext_set_source_color (cairo_t *cr, GdkColor *color, gdouble alpha)
|
||||||
/* gives width of a 8bit string - with no mIRC codes in it */
|
|
||||||
|
|
||||||
static int
|
|
||||||
gtk_xtext_text_width_8bit (GtkXText *xtext, unsigned char *str, int len)
|
|
||||||
{
|
{
|
||||||
int width = 0;
|
cairo_set_source_rgba (cr, color->red / 65535.0, color->green / 65535.0,
|
||||||
|
color->blue / 65535.0, alpha);
|
||||||
while (len)
|
|
||||||
{
|
|
||||||
width += xtext->fontwidth[*str];
|
|
||||||
str++;
|
|
||||||
len--;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return width;
|
static inline void
|
||||||
}
|
xtext_draw_rectangle (GtkXText *xtext, cairo_t *cr, GdkColor *color, int x, int y, int width, int height)
|
||||||
#endif
|
{
|
||||||
|
cairo_save (cr);
|
||||||
|
|
||||||
#define xtext_draw_bg(xt,x,y,w,h) gdk_draw_rectangle(xt->draw_buf, xt->bgc, 1, x, y, w, h);
|
xtext_set_source_color (cr, color, 1.0);
|
||||||
|
cairo_set_operator (cr, CAIRO_OPERATOR_SOURCE);
|
||||||
|
cairo_rectangle (cr, (double)x, (double)y, (double)width, (double)height);
|
||||||
|
cairo_fill (cr);
|
||||||
|
|
||||||
|
cairo_restore (cr);
|
||||||
|
}
|
||||||
|
|
||||||
|
static inline void
|
||||||
|
xtext_draw_line (GtkXText *xtext, cairo_t *cr, GdkColor *color, int x1, int y1, int x2, int y2)
|
||||||
|
{
|
||||||
|
cairo_save (cr);
|
||||||
|
|
||||||
|
/* Disable antialiasing for crispy 1-pixel lines */
|
||||||
|
cairo_set_antialias (cr, CAIRO_ANTIALIAS_NONE);
|
||||||
|
gdk_cairo_set_source_color (cr, color);
|
||||||
|
cairo_set_line_cap (cr, CAIRO_LINE_CAP_SQUARE);
|
||||||
|
cairo_set_operator (cr, CAIRO_OPERATOR_SOURCE);
|
||||||
|
cairo_set_line_width (cr, 1.0);
|
||||||
|
cairo_move_to (cr, x1, y1);
|
||||||
|
cairo_line_to (cr, x2, y2);
|
||||||
|
cairo_stroke (cr);
|
||||||
|
|
||||||
|
cairo_restore (cr);
|
||||||
|
}
|
||||||
|
|
||||||
|
static inline void
|
||||||
|
xtext_draw_bg (GtkXText *xtext, int x, int y, int width, int height)
|
||||||
|
{
|
||||||
|
cairo_t *cr;
|
||||||
|
cr = gdk_cairo_create (gtk_widget_get_window (&xtext->widget));
|
||||||
|
|
||||||
|
xtext_draw_rectangle (xtext, cr, &xtext->palette[XTEXT_BG], x, y, width, height);
|
||||||
|
|
||||||
|
cairo_destroy (cr);
|
||||||
|
}
|
||||||
|
|
||||||
/* ======================================= */
|
/* ======================================= */
|
||||||
/* ============ PANGO BACKEND ============ */
|
/* ============ PANGO BACKEND ============ */
|
||||||
@ -349,77 +377,50 @@ backend_get_text_width_slp (GtkXText *xtext, guchar *str, GSList *slp)
|
|||||||
return width;
|
return width;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* simplified version of gdk_draw_layout_line_with_colors() */
|
|
||||||
|
|
||||||
static void
|
static void
|
||||||
xtext_draw_layout_line (GdkDrawable *drawable,
|
backend_draw_text_emph (GtkXText *xtext, gboolean dofill, int x, int y, char *str, int len, int str_width, int emphasis)
|
||||||
GdkGC *gc,
|
|
||||||
gint x,
|
|
||||||
gint y,
|
|
||||||
PangoLayoutLine *line)
|
|
||||||
{
|
{
|
||||||
GSList *tmp_list = line->runs;
|
cairo_t *cr;
|
||||||
PangoRectangle logical_rect;
|
|
||||||
gint x_off = 0;
|
|
||||||
|
|
||||||
while (tmp_list)
|
|
||||||
{
|
|
||||||
PangoLayoutRun *run = tmp_list->data;
|
|
||||||
|
|
||||||
pango_glyph_string_extents (run->glyphs, run->item->analysis.font,
|
|
||||||
NULL, &logical_rect);
|
|
||||||
|
|
||||||
gdk_draw_glyphs (drawable, gc, run->item->analysis.font,
|
|
||||||
x + x_off / PANGO_SCALE, y, run->glyphs);
|
|
||||||
|
|
||||||
x_off += logical_rect.width;
|
|
||||||
tmp_list = tmp_list->next;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
static void
|
|
||||||
backend_draw_text_emph (GtkXText *xtext, int dofill, GdkGC *gc, int x, int y,
|
|
||||||
char *str, int len, int str_width, int emphasis)
|
|
||||||
{
|
|
||||||
GdkGCValues val;
|
|
||||||
GdkColor col;
|
|
||||||
PangoLayoutLine *line;
|
PangoLayoutLine *line;
|
||||||
|
|
||||||
|
cr = gdk_cairo_create (gtk_widget_get_window (&xtext->widget));
|
||||||
|
|
||||||
pango_layout_set_attributes (xtext->layout, attr_lists[emphasis]);
|
pango_layout_set_attributes (xtext->layout, attr_lists[emphasis]);
|
||||||
pango_layout_set_text (xtext->layout, str, len);
|
pango_layout_set_text (xtext->layout, str, len);
|
||||||
|
|
||||||
if (dofill)
|
if (dofill)
|
||||||
{
|
{
|
||||||
gdk_gc_get_values (gc, &val);
|
xtext_draw_rectangle (xtext, cr, &xtext->bgc, x, y - xtext->font->ascent,
|
||||||
col.pixel = val.background.pixel;
|
str_width, xtext->fontsize);
|
||||||
gdk_gc_set_foreground (gc, &col);
|
|
||||||
gdk_draw_rectangle (xtext->draw_buf, gc, 1, x, y -
|
|
||||||
xtext->font->ascent, str_width, xtext->fontsize);
|
|
||||||
col.pixel = val.foreground.pixel;
|
|
||||||
gdk_gc_set_foreground (gc, &col);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
line = pango_layout_get_lines (xtext->layout)->data;
|
gdk_cairo_set_source_color (cr, &xtext->fgc);
|
||||||
|
line = pango_layout_get_line_readonly (xtext->layout, 0);
|
||||||
|
|
||||||
xtext_draw_layout_line (xtext->draw_buf, gc, x, y, line);
|
cairo_save (cr);
|
||||||
|
cairo_move_to (cr, x, y);
|
||||||
|
pango_cairo_show_layout_line (cr, line);
|
||||||
|
cairo_restore (cr);
|
||||||
|
|
||||||
|
cairo_destroy (cr);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static inline void
|
||||||
xtext_set_fg (GtkXText *xtext, GdkGC *gc, int index)
|
xtext_set_fg (GtkXText *xtext, int index)
|
||||||
{
|
{
|
||||||
gdk_gc_set_foreground (gc, &xtext->palette[index]);
|
xtext->fgc = xtext->palette[index];
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static inline void
|
||||||
xtext_set_bg (GtkXText *xtext, GdkGC *gc, int index)
|
xtext_set_bg (GtkXText *xtext, int index)
|
||||||
{
|
{
|
||||||
gdk_gc_set_background (gc, &xtext->palette[index]);
|
xtext->bgc = xtext->palette[index];
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
gtk_xtext_init (GtkXText * xtext)
|
gtk_xtext_init (GtkXText * xtext)
|
||||||
{
|
{
|
||||||
xtext->pixmap = NULL;
|
xtext->pixbuf = NULL;
|
||||||
xtext->io_tag = 0;
|
xtext->io_tag = 0;
|
||||||
xtext->add_io_tag = 0;
|
xtext->add_io_tag = 0;
|
||||||
xtext->scroll_tag = 0;
|
xtext->scroll_tag = 0;
|
||||||
@ -434,8 +435,6 @@ gtk_xtext_init (GtkXText * xtext)
|
|||||||
xtext->layout = NULL;
|
xtext->layout = NULL;
|
||||||
xtext->jump_out_offset = 0;
|
xtext->jump_out_offset = 0;
|
||||||
xtext->jump_in_offset = 0;
|
xtext->jump_in_offset = 0;
|
||||||
xtext->ts_x = 0;
|
|
||||||
xtext->ts_y = 0;
|
|
||||||
xtext->clip_x = 0;
|
xtext->clip_x = 0;
|
||||||
xtext->clip_x2 = 1000000;
|
xtext->clip_x2 = 1000000;
|
||||||
xtext->clip_y = 0;
|
xtext->clip_y = 0;
|
||||||
@ -575,10 +574,10 @@ gtk_xtext_destroy (GtkObject * object)
|
|||||||
xtext->io_tag = 0;
|
xtext->io_tag = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (xtext->pixmap)
|
if (xtext->pixbuf)
|
||||||
{
|
{
|
||||||
g_object_unref (xtext->pixmap);
|
g_object_unref (xtext->pixbuf);
|
||||||
xtext->pixmap = NULL;
|
xtext->pixbuf = NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (xtext->font)
|
if (xtext->font)
|
||||||
@ -596,42 +595,6 @@ gtk_xtext_destroy (GtkObject * object)
|
|||||||
xtext->adj = NULL;
|
xtext->adj = NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (xtext->bgc)
|
|
||||||
{
|
|
||||||
g_object_unref (xtext->bgc);
|
|
||||||
xtext->bgc = NULL;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (xtext->fgc)
|
|
||||||
{
|
|
||||||
g_object_unref (xtext->fgc);
|
|
||||||
xtext->fgc = NULL;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (xtext->light_gc)
|
|
||||||
{
|
|
||||||
g_object_unref (xtext->light_gc);
|
|
||||||
xtext->light_gc = NULL;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (xtext->dark_gc)
|
|
||||||
{
|
|
||||||
g_object_unref (xtext->dark_gc);
|
|
||||||
xtext->dark_gc = NULL;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (xtext->thin_gc)
|
|
||||||
{
|
|
||||||
g_object_unref (xtext->thin_gc);
|
|
||||||
xtext->thin_gc = NULL;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (xtext->marker_gc)
|
|
||||||
{
|
|
||||||
g_object_unref (xtext->marker_gc);
|
|
||||||
xtext->marker_gc = NULL;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (xtext->hand_cursor)
|
if (xtext->hand_cursor)
|
||||||
{
|
{
|
||||||
gdk_cursor_unref (xtext->hand_cursor);
|
gdk_cursor_unref (xtext->hand_cursor);
|
||||||
@ -671,8 +634,6 @@ gtk_xtext_realize (GtkWidget * widget)
|
|||||||
{
|
{
|
||||||
GtkXText *xtext;
|
GtkXText *xtext;
|
||||||
GdkWindowAttr attributes;
|
GdkWindowAttr attributes;
|
||||||
GdkGCValues val;
|
|
||||||
GdkColor col;
|
|
||||||
GdkColormap *cmap;
|
GdkColormap *cmap;
|
||||||
|
|
||||||
gtk_widget_set_realized (widget, TRUE);
|
gtk_widget_set_realized (widget, TRUE);
|
||||||
@ -700,59 +661,12 @@ gtk_xtext_realize (GtkWidget * widget)
|
|||||||
|
|
||||||
xtext->depth = gdk_window_get_visual (widget->window)->depth;
|
xtext->depth = gdk_window_get_visual (widget->window)->depth;
|
||||||
|
|
||||||
val.subwindow_mode = GDK_INCLUDE_INFERIORS;
|
xtext_set_fg (xtext, XTEXT_FG);
|
||||||
val.graphics_exposures = 0;
|
xtext_set_bg (xtext, XTEXT_BG);
|
||||||
|
|
||||||
xtext->bgc = gdk_gc_new_with_values (widget->window, &val,
|
|
||||||
GDK_GC_EXPOSURES | GDK_GC_SUBWINDOW);
|
|
||||||
xtext->fgc = gdk_gc_new_with_values (widget->window, &val,
|
|
||||||
GDK_GC_EXPOSURES | GDK_GC_SUBWINDOW);
|
|
||||||
xtext->light_gc = gdk_gc_new_with_values (widget->window, &val,
|
|
||||||
GDK_GC_EXPOSURES | GDK_GC_SUBWINDOW);
|
|
||||||
xtext->dark_gc = gdk_gc_new_with_values (widget->window, &val,
|
|
||||||
GDK_GC_EXPOSURES | GDK_GC_SUBWINDOW);
|
|
||||||
xtext->thin_gc = gdk_gc_new_with_values (widget->window, &val,
|
|
||||||
GDK_GC_EXPOSURES | GDK_GC_SUBWINDOW);
|
|
||||||
xtext->marker_gc = gdk_gc_new_with_values (widget->window, &val,
|
|
||||||
GDK_GC_EXPOSURES | GDK_GC_SUBWINDOW);
|
|
||||||
|
|
||||||
/* for the separator bar (light) */
|
|
||||||
col.red = 0xffff; col.green = 0xffff; col.blue = 0xffff;
|
|
||||||
gdk_colormap_alloc_color (cmap, &col, FALSE, TRUE);
|
|
||||||
gdk_gc_set_foreground (xtext->light_gc, &col);
|
|
||||||
|
|
||||||
/* for the separator bar (dark) */
|
|
||||||
col.red = 0x1111; col.green = 0x1111; col.blue = 0x1111;
|
|
||||||
gdk_colormap_alloc_color (cmap, &col, FALSE, TRUE);
|
|
||||||
gdk_gc_set_foreground (xtext->dark_gc, &col);
|
|
||||||
|
|
||||||
/* for the separator bar (thinline) */
|
|
||||||
col.red = 0x8e38; col.green = 0x8e38; col.blue = 0x9f38;
|
|
||||||
gdk_colormap_alloc_color (cmap, &col, FALSE, TRUE);
|
|
||||||
gdk_gc_set_foreground (xtext->thin_gc, &col);
|
|
||||||
|
|
||||||
/* for the marker bar (marker) */
|
|
||||||
gdk_gc_set_foreground (xtext->marker_gc, &xtext->palette[XTEXT_MARKER]);
|
|
||||||
|
|
||||||
xtext_set_fg (xtext, xtext->fgc, XTEXT_FG);
|
|
||||||
xtext_set_bg (xtext, xtext->fgc, XTEXT_BG);
|
|
||||||
xtext_set_fg (xtext, xtext->bgc, XTEXT_BG);
|
|
||||||
|
|
||||||
/* draw directly to window */
|
|
||||||
xtext->draw_buf = widget->window;
|
|
||||||
|
|
||||||
if (xtext->pixmap)
|
|
||||||
{
|
|
||||||
gdk_gc_set_tile (xtext->bgc, xtext->pixmap);
|
|
||||||
gdk_gc_set_ts_origin (xtext->bgc, 0, 0);
|
|
||||||
xtext->ts_x = xtext->ts_y = 0;
|
|
||||||
gdk_gc_set_fill (xtext->bgc, GDK_TILED);
|
|
||||||
}
|
|
||||||
|
|
||||||
xtext->hand_cursor = gdk_cursor_new_for_display (gdk_window_get_display (widget->window), GDK_HAND1);
|
xtext->hand_cursor = gdk_cursor_new_for_display (gdk_window_get_display (widget->window), GDK_HAND1);
|
||||||
xtext->resize_cursor = gdk_cursor_new_for_display (gdk_window_get_display (widget->window), GDK_LEFT_SIDE);
|
xtext->resize_cursor = gdk_cursor_new_for_display (gdk_window_get_display (widget->window), GDK_LEFT_SIDE);
|
||||||
|
|
||||||
gdk_window_set_back_pixmap (widget->window, NULL, FALSE);
|
|
||||||
widget->style = gtk_style_attach (widget->style, widget->window);
|
widget->style = gtk_style_attach (widget->style, widget->window);
|
||||||
|
|
||||||
backend_init (xtext);
|
backend_init (xtext);
|
||||||
@ -959,13 +873,17 @@ static void
|
|||||||
gtk_xtext_draw_sep (GtkXText * xtext, int y)
|
gtk_xtext_draw_sep (GtkXText * xtext, int y)
|
||||||
{
|
{
|
||||||
int x, height;
|
int x, height;
|
||||||
GdkGC *light, *dark;
|
GdkColor light, dark, thin;
|
||||||
|
GtkAllocation allocation;
|
||||||
|
cairo_t *cr;
|
||||||
|
|
||||||
if (y == -1)
|
if (y == -1)
|
||||||
{
|
{
|
||||||
y = 0;
|
y = 0;
|
||||||
height = GTK_WIDGET (xtext)->allocation.height;
|
gtk_widget_get_allocation (GTK_WIDGET (xtext), &allocation);
|
||||||
} else
|
height = allocation.height;
|
||||||
|
}
|
||||||
|
else
|
||||||
{
|
{
|
||||||
height = xtext->fontsize;
|
height = xtext->fontsize;
|
||||||
}
|
}
|
||||||
@ -973,31 +891,38 @@ gtk_xtext_draw_sep (GtkXText * xtext, int y)
|
|||||||
/* draw the separator line */
|
/* draw the separator line */
|
||||||
if (xtext->separator && xtext->buffer->indent)
|
if (xtext->separator && xtext->buffer->indent)
|
||||||
{
|
{
|
||||||
light = xtext->light_gc;
|
thin.red = 0x8e38; thin.green = 0x8e38; thin.blue = 0x9f38;
|
||||||
dark = xtext->dark_gc;
|
dark.red = 0x1111; dark.green = 0x1111; dark.blue = 0x1111;
|
||||||
|
light.red = 0xffff; light.green = 0xffff; light.blue = 0xffff;
|
||||||
|
|
||||||
x = xtext->buffer->indent - ((xtext->space_width + 1) / 2);
|
x = xtext->buffer->indent - ((xtext->space_width + 1) / 2);
|
||||||
if (x < 1)
|
if (x < 1)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
|
cr = gdk_cairo_create (gtk_widget_get_window (&xtext->widget));
|
||||||
|
|
||||||
if (xtext->thinline)
|
if (xtext->thinline)
|
||||||
{
|
{
|
||||||
if (xtext->moving_separator)
|
if (xtext->moving_separator)
|
||||||
gdk_draw_line (xtext->draw_buf, light, x, y, x, y + height);
|
xtext_draw_line (xtext, cr, &light, x, y, x, y + height);
|
||||||
|
else
|
||||||
|
xtext_draw_line (xtext, cr, &thin, x, y, x, y + height);
|
||||||
|
}
|
||||||
else
|
else
|
||||||
gdk_draw_line (xtext->draw_buf, xtext->thin_gc, x, y, x, y + height);
|
|
||||||
} else
|
|
||||||
{
|
{
|
||||||
if (xtext->moving_separator)
|
if (xtext->moving_separator)
|
||||||
{
|
{
|
||||||
gdk_draw_line (xtext->draw_buf, light, x - 1, y, x - 1, y + height);
|
xtext_draw_line (xtext, cr, &light, x - 1, y, x - 1, y + height);
|
||||||
gdk_draw_line (xtext->draw_buf, dark, x, y, x, y + height);
|
xtext_draw_line (xtext, cr, &dark, x, y, x, y + height);
|
||||||
} else
|
}
|
||||||
|
else
|
||||||
{
|
{
|
||||||
gdk_draw_line (xtext->draw_buf, dark, x - 1, y, x - 1, y + height);
|
xtext_draw_line (xtext, cr, &dark, x - 1, y, x - 1, y + height);
|
||||||
gdk_draw_line (xtext->draw_buf, light, x, y, x, y + height);
|
xtext_draw_line (xtext, cr, &light, x, y, x, y + height);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
cairo_destroy (cr);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1005,6 +930,8 @@ static void
|
|||||||
gtk_xtext_draw_marker (GtkXText * xtext, textentry * ent, int y)
|
gtk_xtext_draw_marker (GtkXText * xtext, textentry * ent, int y)
|
||||||
{
|
{
|
||||||
int x, width, render_y;
|
int x, width, render_y;
|
||||||
|
GtkAllocation allocation;
|
||||||
|
cairo_t *cr;
|
||||||
|
|
||||||
if (!xtext->marker) return;
|
if (!xtext->marker) return;
|
||||||
|
|
||||||
@ -1018,15 +945,21 @@ gtk_xtext_draw_marker (GtkXText * xtext, textentry * ent, int y)
|
|||||||
}
|
}
|
||||||
else return;
|
else return;
|
||||||
|
|
||||||
x = 0;
|
cr = gdk_cairo_create (gtk_widget_get_window (&xtext->widget));
|
||||||
width = GTK_WIDGET (xtext)->allocation.width;
|
|
||||||
|
|
||||||
gdk_draw_line (xtext->draw_buf, xtext->marker_gc, x, render_y, x + width, render_y);
|
gtk_widget_get_allocation (GTK_WIDGET (xtext), &allocation);
|
||||||
|
|
||||||
|
x = 0;
|
||||||
|
width = allocation.width;
|
||||||
|
|
||||||
|
xtext_draw_line (xtext, cr, &xtext->palette[XTEXT_MARKER], x, render_y, x + width, render_y);
|
||||||
|
|
||||||
if (gtk_window_has_toplevel_focus (GTK_WINDOW (gtk_widget_get_toplevel (GTK_WIDGET (xtext)))))
|
if (gtk_window_has_toplevel_focus (GTK_WINDOW (gtk_widget_get_toplevel (GTK_WIDGET (xtext)))))
|
||||||
{
|
{
|
||||||
xtext->buffer->marker_seen = TRUE;
|
xtext->buffer->marker_seen = TRUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
cairo_destroy (cr);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
@ -1403,6 +1336,7 @@ gtk_xtext_timeout_ms (GtkXText *xtext, int pixes)
|
|||||||
if (apixes < 20) return 20;
|
if (apixes < 20) return 20;
|
||||||
return 10;
|
return 10;
|
||||||
}
|
}
|
||||||
|
|
||||||
static gint
|
static gint
|
||||||
gtk_xtext_scrolldown_timeout (GtkXText * xtext)
|
gtk_xtext_scrolldown_timeout (GtkXText * xtext)
|
||||||
{
|
{
|
||||||
@ -2217,14 +2151,14 @@ gtk_xtext_scroll (GtkWidget *widget, GdkEventScroll *event)
|
|||||||
new_value = xtext->adj->value - (xtext->adj->page_increment / 10);
|
new_value = xtext->adj->value - (xtext->adj->page_increment / 10);
|
||||||
if (new_value < xtext->adj->lower)
|
if (new_value < xtext->adj->lower)
|
||||||
new_value = xtext->adj->lower;
|
new_value = xtext->adj->lower;
|
||||||
gtk_adjustment_set_value (xtext->adj, new_value);
|
gtk_adjustment_set_value (xtext->adj, (int)new_value);
|
||||||
}
|
}
|
||||||
else if (event->direction == GDK_SCROLL_DOWN) /* mouse wheel pageDn */
|
else if (event->direction == GDK_SCROLL_DOWN) /* mouse wheel pageDn */
|
||||||
{
|
{
|
||||||
new_value = xtext->adj->value + (xtext->adj->page_increment / 10);
|
new_value = xtext->adj->value + (xtext->adj->page_increment / 10);
|
||||||
if (new_value > (xtext->adj->upper - xtext->adj->page_size))
|
if (new_value > (xtext->adj->upper - xtext->adj->page_size))
|
||||||
new_value = xtext->adj->upper - xtext->adj->page_size;
|
new_value = xtext->adj->upper - xtext->adj->page_size;
|
||||||
gtk_adjustment_set_value (xtext->adj, new_value);
|
gtk_adjustment_set_value (xtext->adj, (int)new_value);
|
||||||
}
|
}
|
||||||
|
|
||||||
return FALSE;
|
return FALSE;
|
||||||
@ -2514,11 +2448,14 @@ gtk_xtext_text_width (GtkXText *xtext, unsigned char *text, int len)
|
|||||||
|
|
||||||
static int
|
static int
|
||||||
gtk_xtext_render_flush (GtkXText * xtext, int x, int y, unsigned char *str,
|
gtk_xtext_render_flush (GtkXText * xtext, int x, int y, unsigned char *str,
|
||||||
int len, GdkGC *gc, int *emphasis)
|
int len, int *emphasis)
|
||||||
{
|
{
|
||||||
int str_width, dofill;
|
int dest_x, dest_y;
|
||||||
GdkDrawable *pix = NULL;
|
int str_width;
|
||||||
int dest_x = 0, dest_y = 0;
|
gboolean dofill = TRUE;
|
||||||
|
cairo_t *cr;
|
||||||
|
|
||||||
|
dest_x = dest_y = 0;
|
||||||
|
|
||||||
if (xtext->dont_render || len < 1 || xtext->hidden)
|
if (xtext->dont_render || len < 1 || xtext->hidden)
|
||||||
return 0;
|
return 0;
|
||||||
@ -2528,7 +2465,7 @@ gtk_xtext_render_flush (GtkXText * xtext, int x, int y, unsigned char *str,
|
|||||||
if (xtext->dont_render2)
|
if (xtext->dont_render2)
|
||||||
return str_width;
|
return str_width;
|
||||||
|
|
||||||
/* roll-your-own clipping (avoiding XftDrawString is always good!) */
|
/* roll-your-own clipping */
|
||||||
if (x > xtext->clip_x2 || x + str_width < xtext->clip_x)
|
if (x > xtext->clip_x2 || x + str_width < xtext->clip_x)
|
||||||
return str_width;
|
return str_width;
|
||||||
if (y - xtext->font->ascent > xtext->clip_y2 || (y - xtext->font->ascent) + xtext->fontsize < xtext->clip_y)
|
if (y - xtext->font->ascent > xtext->clip_y2 || (y - xtext->font->ascent) + xtext->fontsize < xtext->clip_y)
|
||||||
@ -2539,75 +2476,66 @@ gtk_xtext_render_flush (GtkXText * xtext, int x, int y, unsigned char *str,
|
|||||||
if (!xtext->in_hilight) /* is it a hilight prefix? */
|
if (!xtext->in_hilight) /* is it a hilight prefix? */
|
||||||
return str_width;
|
return str_width;
|
||||||
if (!xtext->un_hilight) /* doing a hilight? no need to draw the text */
|
if (!xtext->un_hilight) /* doing a hilight? no need to draw the text */
|
||||||
goto dounder;
|
|
||||||
}
|
|
||||||
|
|
||||||
pix = gdk_pixmap_new (xtext->draw_buf, str_width, xtext->fontsize, xtext->depth);
|
|
||||||
if (pix)
|
|
||||||
{
|
{
|
||||||
dest_x = x;
|
cr = gdk_cairo_create (gtk_widget_get_window (&xtext->widget));
|
||||||
dest_y = y - xtext->font->ascent;
|
|
||||||
|
|
||||||
gdk_gc_set_ts_origin (xtext->bgc, xtext->ts_x - x, xtext->ts_y - dest_y);
|
|
||||||
|
|
||||||
x = 0;
|
|
||||||
y = xtext->font->ascent;
|
|
||||||
xtext->draw_buf = pix;
|
|
||||||
}
|
|
||||||
|
|
||||||
dofill = TRUE;
|
|
||||||
|
|
||||||
/* backcolor is always handled by XDrawImageString */
|
|
||||||
if (!xtext->backcolor && xtext->pixmap)
|
|
||||||
{
|
|
||||||
/* draw the background pixmap behind the text - CAUSES FLICKER HERE!! */
|
|
||||||
xtext_draw_bg (xtext, x, y - xtext->font->ascent, str_width,
|
|
||||||
xtext->fontsize);
|
|
||||||
dofill = FALSE; /* already drawn the background */
|
|
||||||
}
|
|
||||||
|
|
||||||
backend_draw_text_emph (xtext, dofill, gc, x, y, str, len, str_width, *emphasis);
|
|
||||||
|
|
||||||
if (pix)
|
|
||||||
{
|
|
||||||
GdkRectangle clip;
|
|
||||||
GdkRectangle dest;
|
|
||||||
|
|
||||||
gdk_gc_set_ts_origin (xtext->bgc, xtext->ts_x, xtext->ts_y);
|
|
||||||
xtext->draw_buf = GTK_WIDGET (xtext)->window;
|
|
||||||
clip.x = xtext->clip_x;
|
|
||||||
clip.y = xtext->clip_y;
|
|
||||||
clip.width = xtext->clip_x2 - xtext->clip_x;
|
|
||||||
clip.height = xtext->clip_y2 - xtext->clip_y;
|
|
||||||
|
|
||||||
dest.x = dest_x;
|
|
||||||
dest.y = dest_y;
|
|
||||||
dest.width = str_width;
|
|
||||||
dest.height = xtext->fontsize;
|
|
||||||
|
|
||||||
if (gdk_rectangle_intersect (&clip, &dest, &dest))
|
|
||||||
/* dump the DB to window, but only within the clip_x/x2/y/y2 */
|
|
||||||
gdk_draw_drawable (xtext->draw_buf, xtext->bgc, pix,
|
|
||||||
dest.x - dest_x, dest.y - dest_y,
|
|
||||||
dest.x, dest.y, dest.width, dest.height);
|
|
||||||
g_object_unref (pix);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (xtext->underline)
|
|
||||||
{
|
|
||||||
dounder:
|
|
||||||
|
|
||||||
if (pix)
|
|
||||||
y = dest_y + xtext->font->ascent + 1;
|
|
||||||
else
|
|
||||||
{
|
|
||||||
y++;
|
y++;
|
||||||
dest_x = x;
|
dest_x = x;
|
||||||
|
|
||||||
|
xtext_draw_line (xtext, cr, &xtext->fgc, dest_x + 1, y + 1, dest_x + str_width - 1, y + 1);
|
||||||
|
cairo_destroy (cr);
|
||||||
|
|
||||||
|
return str_width;
|
||||||
}
|
}
|
||||||
/* draw directly to window, it's out of the range of our DB */
|
|
||||||
gdk_draw_line (xtext->draw_buf, gc, dest_x, y, dest_x + str_width - 1, y);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (!xtext->backcolor && xtext->pixbuf)
|
||||||
|
{
|
||||||
|
cr = gdk_cairo_create (gtk_widget_get_window (&xtext->widget));
|
||||||
|
gdk_cairo_set_source_pixbuf (cr, xtext->pixbuf, 0, 0);
|
||||||
|
cairo_pattern_set_extend (cairo_get_source (cr), CAIRO_EXTEND_REPEAT);
|
||||||
|
cairo_rectangle (cr, x, y - xtext->font->ascent, str_width, xtext->fontsize);
|
||||||
|
cairo_fill (cr);
|
||||||
|
cairo_destroy (cr);
|
||||||
|
|
||||||
|
dofill = FALSE;
|
||||||
|
}
|
||||||
|
|
||||||
|
//if (xtext->pixbuf)
|
||||||
|
//{
|
||||||
|
// GdkRectangle clip, dest;
|
||||||
|
// cairo_t *cr = gdk_cairo_create (gtk_widget_get_window (&xtext->widget));
|
||||||
|
|
||||||
|
//backend_draw_text_emph (xtext, dofill, gc, x, y, str, len, str_width, *emphasis);
|
||||||
|
|
||||||
|
|
||||||
|
// gdk_cairo_set_source_pixbuf (cr, xtext->pixbuf, 0, 0);
|
||||||
|
|
||||||
|
// /* Only redraw what is required */
|
||||||
|
// clip.x = xtext->clip_x;
|
||||||
|
// clip.y = xtext->clip_y;
|
||||||
|
// clip.width = xtext->clip_x2 - xtext->clip_x;
|
||||||
|
// clip.height = xtext->clip_y2 - xtext->clip_y;
|
||||||
|
|
||||||
|
// dest.x = dest_x;
|
||||||
|
// dest.y = dest_y;
|
||||||
|
// dest.width = str_width;
|
||||||
|
// dest.height = xtext->fontsize;
|
||||||
|
|
||||||
|
// if (gdk_rectangle_intersect (&clip, &dest, &dest))
|
||||||
|
// {
|
||||||
|
// gdk_cairo_rectangle (cr, &dest);
|
||||||
|
|
||||||
|
// cairo_clip (cr);
|
||||||
|
// }
|
||||||
|
// cairo_paint (cr);
|
||||||
|
// cairo_destroy (cr);
|
||||||
|
|
||||||
|
// dofill = FALSE;
|
||||||
|
//}
|
||||||
|
|
||||||
|
backend_draw_text_emph (xtext, dofill, x, y, (char *)str, len, str_width, *emphasis);
|
||||||
|
|
||||||
return str_width;
|
return str_width;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -2623,9 +2551,9 @@ gtk_xtext_reset (GtkXText * xtext, int mark, int attribs)
|
|||||||
{
|
{
|
||||||
xtext->backcolor = FALSE;
|
xtext->backcolor = FALSE;
|
||||||
if (xtext->col_fore != XTEXT_FG)
|
if (xtext->col_fore != XTEXT_FG)
|
||||||
xtext_set_fg (xtext, xtext->fgc, XTEXT_FG);
|
xtext_set_fg (xtext, XTEXT_FG);
|
||||||
if (xtext->col_back != XTEXT_BG)
|
if (xtext->col_back != XTEXT_BG)
|
||||||
xtext_set_bg (xtext, xtext->fgc, XTEXT_BG);
|
xtext_set_bg (xtext, XTEXT_BG);
|
||||||
}
|
}
|
||||||
xtext->col_fore = XTEXT_FG;
|
xtext->col_fore = XTEXT_FG;
|
||||||
xtext->col_back = XTEXT_BG;
|
xtext->col_back = XTEXT_BG;
|
||||||
@ -2693,14 +2621,13 @@ gtk_xtext_search_offset (xtext_buffer *buf, textentry *ent, unsigned int off)
|
|||||||
|
|
||||||
/* render a single line, which WONT wrap, and parse mIRC colors */
|
/* render a single line, which WONT wrap, and parse mIRC colors */
|
||||||
|
|
||||||
#define RENDER_FLUSH x += gtk_xtext_render_flush (xtext, x, y, pstr, j, gc, emphasis)
|
#define RENDER_FLUSH x += gtk_xtext_render_flush (xtext, x, y, pstr, j, emphasis)
|
||||||
|
|
||||||
static int
|
static int
|
||||||
gtk_xtext_render_str (GtkXText * xtext, int y, textentry * ent,
|
gtk_xtext_render_str (GtkXText * xtext, int y, textentry * ent,
|
||||||
unsigned char *str, int len, int win_width, int indent,
|
unsigned char *str, int len, int win_width, int indent,
|
||||||
int line, int left_only, int *x_size_ret, int *emphasis)
|
int line, int left_only, int *x_size_ret, int *emphasis)
|
||||||
{
|
{
|
||||||
GdkGC *gc;
|
|
||||||
int i = 0, x = indent, j = 0;
|
int i = 0, x = indent, j = 0;
|
||||||
unsigned char *pstr = str;
|
unsigned char *pstr = str;
|
||||||
int col_num, tmp;
|
int col_num, tmp;
|
||||||
@ -2715,13 +2642,11 @@ gtk_xtext_render_str (GtkXText * xtext, int y, textentry * ent,
|
|||||||
|
|
||||||
offset = str - ent->str;
|
offset = str - ent->str;
|
||||||
|
|
||||||
gc = xtext->fgc; /* our foreground GC */
|
|
||||||
|
|
||||||
if (ent->mark_start != -1 &&
|
if (ent->mark_start != -1 &&
|
||||||
ent->mark_start <= i + offset && ent->mark_end > i + offset)
|
ent->mark_start <= i + offset && ent->mark_end > i + offset)
|
||||||
{
|
{
|
||||||
xtext_set_bg (xtext, gc, XTEXT_MARK_BG);
|
xtext_set_bg (xtext, XTEXT_MARK_BG);
|
||||||
xtext_set_fg (xtext, gc, XTEXT_MARK_FG);
|
xtext_set_fg (xtext, XTEXT_MARK_FG);
|
||||||
xtext->backcolor = TRUE;
|
xtext->backcolor = TRUE;
|
||||||
mark = TRUE;
|
mark = TRUE;
|
||||||
}
|
}
|
||||||
@ -2795,7 +2720,7 @@ gtk_xtext_render_str (GtkXText * xtext, int y, textentry * ent,
|
|||||||
col_num = col_num % XTEXT_MIRC_COLS;
|
col_num = col_num % XTEXT_MIRC_COLS;
|
||||||
xtext->col_fore = col_num;
|
xtext->col_fore = col_num;
|
||||||
if (!mark)
|
if (!mark)
|
||||||
xtext_set_fg (xtext, gc, col_num);
|
xtext_set_fg (xtext, col_num);
|
||||||
}
|
}
|
||||||
} else
|
} else
|
||||||
{
|
{
|
||||||
@ -2825,7 +2750,7 @@ gtk_xtext_render_str (GtkXText * xtext, int y, textentry * ent,
|
|||||||
else
|
else
|
||||||
xtext->backcolor = TRUE;
|
xtext->backcolor = TRUE;
|
||||||
if (!mark)
|
if (!mark)
|
||||||
xtext_set_bg (xtext, gc, col_num);
|
xtext_set_bg (xtext, col_num);
|
||||||
xtext->col_back = col_num;
|
xtext->col_back = col_num;
|
||||||
} else
|
} else
|
||||||
{
|
{
|
||||||
@ -2835,11 +2760,12 @@ gtk_xtext_render_str (GtkXText * xtext, int y, textentry * ent,
|
|||||||
if (col_num > XTEXT_MAX_COLOR)
|
if (col_num > XTEXT_MAX_COLOR)
|
||||||
col_num = col_num % XTEXT_MIRC_COLS;
|
col_num = col_num % XTEXT_MIRC_COLS;
|
||||||
if (!mark)
|
if (!mark)
|
||||||
xtext_set_fg (xtext, gc, col_num);
|
xtext_set_fg (xtext, col_num);
|
||||||
xtext->col_fore = col_num;
|
xtext->col_fore = col_num;
|
||||||
}
|
}
|
||||||
xtext->parsing_backcolor = FALSE;
|
xtext->parsing_backcolor = FALSE;
|
||||||
} else
|
}
|
||||||
|
else
|
||||||
{
|
{
|
||||||
/* got a \003<non-digit>... i.e. reset colors */
|
/* got a \003<non-digit>... i.e. reset colors */
|
||||||
RENDER_FLUSH;
|
RENDER_FLUSH;
|
||||||
@ -2859,14 +2785,14 @@ gtk_xtext_render_str (GtkXText * xtext, int y, textentry * ent,
|
|||||||
{
|
{
|
||||||
if (k & GTK_MATCH_CUR)
|
if (k & GTK_MATCH_CUR)
|
||||||
{
|
{
|
||||||
xtext_set_bg (xtext, gc, XTEXT_MARK_BG);
|
xtext_set_bg (xtext, XTEXT_MARK_BG);
|
||||||
xtext_set_fg (xtext, gc, XTEXT_MARK_FG);
|
xtext_set_fg (xtext, XTEXT_MARK_FG);
|
||||||
xtext->backcolor = TRUE;
|
xtext->backcolor = TRUE;
|
||||||
srch_mark = TRUE;
|
srch_mark = TRUE;
|
||||||
} else
|
} else
|
||||||
{
|
{
|
||||||
xtext_set_bg (xtext, gc, xtext->col_back);
|
xtext_set_bg (xtext, xtext->col_back);
|
||||||
xtext_set_fg (xtext, gc, xtext->col_fore);
|
xtext_set_fg (xtext, xtext->col_fore);
|
||||||
xtext->backcolor = (xtext->col_back != XTEXT_BG)? TRUE: FALSE;
|
xtext->backcolor = (xtext->col_back != XTEXT_BG)? TRUE: FALSE;
|
||||||
srch_mark = FALSE;
|
srch_mark = FALSE;
|
||||||
}
|
}
|
||||||
@ -2876,15 +2802,15 @@ gtk_xtext_render_str (GtkXText * xtext, int y, textentry * ent,
|
|||||||
xtext->underline = (k & GTK_MATCH_CUR)? TRUE: FALSE;
|
xtext->underline = (k & GTK_MATCH_CUR)? TRUE: FALSE;
|
||||||
if (k & (GTK_MATCH_START | GTK_MATCH_MID))
|
if (k & (GTK_MATCH_START | GTK_MATCH_MID))
|
||||||
{
|
{
|
||||||
xtext_set_bg (xtext, gc, XTEXT_MARK_BG);
|
xtext_set_bg (xtext, XTEXT_MARK_BG);
|
||||||
xtext_set_fg (xtext, gc, XTEXT_MARK_FG);
|
xtext_set_fg (xtext, XTEXT_MARK_FG);
|
||||||
xtext->backcolor = TRUE;
|
xtext->backcolor = TRUE;
|
||||||
srch_mark = TRUE;
|
srch_mark = TRUE;
|
||||||
}
|
}
|
||||||
if (k & GTK_MATCH_END)
|
if (k & GTK_MATCH_END)
|
||||||
{
|
{
|
||||||
xtext_set_bg (xtext, gc, xtext->col_back);
|
xtext_set_bg (xtext, xtext->col_back);
|
||||||
xtext_set_fg (xtext, gc, xtext->col_fore);
|
xtext_set_fg (xtext, xtext->col_fore);
|
||||||
xtext->backcolor = (xtext->col_back != XTEXT_BG)? TRUE: FALSE;
|
xtext->backcolor = (xtext->col_back != XTEXT_BG)? TRUE: FALSE;
|
||||||
srch_mark = FALSE;
|
srch_mark = FALSE;
|
||||||
xtext->underline = FALSE;
|
xtext->underline = FALSE;
|
||||||
@ -2907,8 +2833,8 @@ gtk_xtext_render_str (GtkXText * xtext, int y, textentry * ent,
|
|||||||
xtext->col_back = tmp;
|
xtext->col_back = tmp;
|
||||||
if (!mark)
|
if (!mark)
|
||||||
{
|
{
|
||||||
xtext_set_fg (xtext, gc, xtext->col_fore);
|
xtext_set_fg (xtext, xtext->col_fore);
|
||||||
xtext_set_bg (xtext, gc, xtext->col_back);
|
xtext_set_bg (xtext, xtext->col_back);
|
||||||
}
|
}
|
||||||
if (xtext->col_back != XTEXT_BG)
|
if (xtext->col_back != XTEXT_BG)
|
||||||
xtext->backcolor = TRUE;
|
xtext->backcolor = TRUE;
|
||||||
@ -2989,7 +2915,7 @@ gtk_xtext_render_str (GtkXText * xtext, int y, textentry * ent,
|
|||||||
/* have we been told to stop rendering at this point? */
|
/* have we been told to stop rendering at this point? */
|
||||||
if (xtext->jump_out_offset > 0 && xtext->jump_out_offset <= (i + offset))
|
if (xtext->jump_out_offset > 0 && xtext->jump_out_offset <= (i + offset))
|
||||||
{
|
{
|
||||||
gtk_xtext_render_flush (xtext, x, y, pstr, j, gc, emphasis);
|
gtk_xtext_render_flush (xtext, x, y, pstr, j, emphasis);
|
||||||
ret = 0; /* skip the rest of the lines, we're done. */
|
ret = 0; /* skip the rest of the lines, we're done. */
|
||||||
j = 0;
|
j = 0;
|
||||||
break;
|
break;
|
||||||
@ -3023,8 +2949,8 @@ gtk_xtext_render_str (GtkXText * xtext, int y, textentry * ent,
|
|||||||
RENDER_FLUSH;
|
RENDER_FLUSH;
|
||||||
pstr += j;
|
pstr += j;
|
||||||
j = 0;
|
j = 0;
|
||||||
xtext_set_bg (xtext, gc, XTEXT_MARK_BG);
|
xtext_set_bg (xtext, XTEXT_MARK_BG);
|
||||||
xtext_set_fg (xtext, gc, XTEXT_MARK_FG);
|
xtext_set_fg (xtext, XTEXT_MARK_FG);
|
||||||
xtext->backcolor = TRUE;
|
xtext->backcolor = TRUE;
|
||||||
if (srch_underline)
|
if (srch_underline)
|
||||||
{
|
{
|
||||||
@ -3039,8 +2965,8 @@ gtk_xtext_render_str (GtkXText * xtext, int y, textentry * ent,
|
|||||||
RENDER_FLUSH;
|
RENDER_FLUSH;
|
||||||
pstr += j;
|
pstr += j;
|
||||||
j = 0;
|
j = 0;
|
||||||
xtext_set_bg (xtext, gc, xtext->col_back);
|
xtext_set_bg (xtext, xtext->col_back);
|
||||||
xtext_set_fg (xtext, gc, xtext->col_fore);
|
xtext_set_fg (xtext, xtext->col_fore);
|
||||||
if (xtext->col_back != XTEXT_BG)
|
if (xtext->col_back != XTEXT_BG)
|
||||||
xtext->backcolor = TRUE;
|
xtext->backcolor = TRUE;
|
||||||
else
|
else
|
||||||
@ -3055,8 +2981,8 @@ gtk_xtext_render_str (GtkXText * xtext, int y, textentry * ent,
|
|||||||
|
|
||||||
if (mark || srch_mark)
|
if (mark || srch_mark)
|
||||||
{
|
{
|
||||||
xtext_set_bg (xtext, gc, xtext->col_back);
|
xtext_set_bg (xtext, xtext->col_back);
|
||||||
xtext_set_fg (xtext, gc, xtext->col_fore);
|
xtext_set_fg (xtext, xtext->col_fore);
|
||||||
if (xtext->col_back != XTEXT_BG)
|
if (xtext->col_back != XTEXT_BG)
|
||||||
xtext->backcolor = TRUE;
|
xtext->backcolor = TRUE;
|
||||||
else
|
else
|
||||||
@ -3390,11 +3316,9 @@ gtk_xtext_set_palette (GtkXText * xtext, GdkColor palette[])
|
|||||||
|
|
||||||
if (gtk_widget_get_realized (GTK_WIDGET(xtext)))
|
if (gtk_widget_get_realized (GTK_WIDGET(xtext)))
|
||||||
{
|
{
|
||||||
xtext_set_fg (xtext, xtext->fgc, XTEXT_FG);
|
xtext_set_fg (xtext, XTEXT_FG);
|
||||||
xtext_set_bg (xtext, xtext->fgc, XTEXT_BG);
|
xtext_set_bg (xtext, XTEXT_BG);
|
||||||
xtext_set_fg (xtext, xtext->bgc, XTEXT_BG);
|
xtext_set_fg (xtext, XTEXT_BG);
|
||||||
|
|
||||||
gdk_gc_set_foreground (xtext->marker_gc, &xtext->palette[XTEXT_MARKER]);
|
|
||||||
}
|
}
|
||||||
xtext->col_fore = XTEXT_FG;
|
xtext->col_fore = XTEXT_FG;
|
||||||
xtext->col_back = XTEXT_BG;
|
xtext->col_back = XTEXT_BG;
|
||||||
@ -3480,38 +3404,14 @@ gtk_xtext_set_font (GtkXText *xtext, char *name)
|
|||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
gtk_xtext_set_background (GtkXText * xtext, GdkPixmap * pixmap)
|
gtk_xtext_set_background (GtkXText *xtext, GdkPixbuf *pixbuf)
|
||||||
{
|
{
|
||||||
GdkGCValues val;
|
if (xtext->pixbuf && (xtext->pixbuf != pixbuf))
|
||||||
|
g_object_unref (xtext->pixbuf);
|
||||||
|
|
||||||
if (xtext->pixmap)
|
xtext->pixbuf = pixbuf;
|
||||||
{
|
|
||||||
g_object_unref (xtext->pixmap);
|
|
||||||
xtext->pixmap = NULL;
|
|
||||||
}
|
|
||||||
|
|
||||||
dontscroll (xtext->buffer);
|
/* TODO: redraw */
|
||||||
xtext->pixmap = pixmap;
|
|
||||||
|
|
||||||
if (pixmap != 0)
|
|
||||||
{
|
|
||||||
g_object_ref (pixmap);
|
|
||||||
if (gtk_widget_get_realized (GTK_WIDGET(xtext)))
|
|
||||||
{
|
|
||||||
gdk_gc_set_tile (xtext->bgc, pixmap);
|
|
||||||
gdk_gc_set_ts_origin (xtext->bgc, 0, 0);
|
|
||||||
xtext->ts_x = xtext->ts_y = 0;
|
|
||||||
gdk_gc_set_fill (xtext->bgc, GDK_TILED);
|
|
||||||
}
|
|
||||||
} else if (gtk_widget_get_realized (GTK_WIDGET(xtext)))
|
|
||||||
{
|
|
||||||
g_object_unref (xtext->bgc);
|
|
||||||
val.subwindow_mode = GDK_INCLUDE_INFERIORS;
|
|
||||||
val.graphics_exposures = 0;
|
|
||||||
xtext->bgc = gdk_gc_new_with_values (GTK_WIDGET (xtext)->window,
|
|
||||||
&val, GDK_GC_EXPOSURES | GDK_GC_SUBWINDOW);
|
|
||||||
xtext_set_fg (xtext, xtext->bgc, XTEXT_BG);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
@ -3754,7 +3654,6 @@ gtk_xtext_render_page (GtkXText * xtext)
|
|||||||
int height;
|
int height;
|
||||||
int subline;
|
int subline;
|
||||||
int startline = xtext->adj->value;
|
int startline = xtext->adj->value;
|
||||||
int pos, overlap;
|
|
||||||
|
|
||||||
if (!gtk_widget_get_realized (GTK_WIDGET (xtext)))
|
if (!gtk_widget_get_realized (GTK_WIDGET (xtext)))
|
||||||
return;
|
return;
|
||||||
@ -3762,12 +3661,13 @@ gtk_xtext_render_page (GtkXText * xtext)
|
|||||||
if (xtext->buffer->indent < MARGIN)
|
if (xtext->buffer->indent < MARGIN)
|
||||||
xtext->buffer->indent = MARGIN; /* 2 pixels is our left margin */
|
xtext->buffer->indent = MARGIN; /* 2 pixels is our left margin */
|
||||||
|
|
||||||
gdk_drawable_get_size (GTK_WIDGET (xtext)->window, &width, &height);
|
width = gdk_window_get_width (gtk_widget_get_window (GTK_WIDGET (xtext)));
|
||||||
|
height = gdk_window_get_height (gtk_widget_get_window (GTK_WIDGET (xtext)));
|
||||||
|
|
||||||
if (width < 34 || height < xtext->fontsize || width < xtext->buffer->indent + 32)
|
if (width < 34 || height < xtext->fontsize || width < xtext->buffer->indent + 32)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
xtext->pixel_offset = (xtext->adj->value - startline) * xtext->fontsize;
|
xtext->pixel_offset = (gtk_adjustment_get_value (xtext->adj) - startline) * xtext->fontsize;
|
||||||
|
|
||||||
subline = line = 0;
|
subline = line = 0;
|
||||||
ent = xtext->buffer->text_first;
|
ent = xtext->buffer->text_first;
|
||||||
@ -3779,50 +3679,6 @@ gtk_xtext_render_page (GtkXText * xtext)
|
|||||||
xtext->buffer->pagetop_subline = subline;
|
xtext->buffer->pagetop_subline = subline;
|
||||||
xtext->buffer->pagetop_line = startline;
|
xtext->buffer->pagetop_line = startline;
|
||||||
|
|
||||||
if (xtext->buffer->num_lines <= xtext->adj->page_size)
|
|
||||||
dontscroll (xtext->buffer);
|
|
||||||
|
|
||||||
pos = xtext->adj->value * xtext->fontsize;
|
|
||||||
overlap = xtext->buffer->last_pixel_pos - pos;
|
|
||||||
xtext->buffer->last_pixel_pos = pos;
|
|
||||||
|
|
||||||
#ifndef __APPLE__
|
|
||||||
if (!xtext->pixmap && abs (overlap) < height)
|
|
||||||
{
|
|
||||||
GdkRectangle area;
|
|
||||||
|
|
||||||
/* so the obscured regions are exposed */
|
|
||||||
gdk_gc_set_exposures (xtext->fgc, TRUE);
|
|
||||||
if (overlap < 1) /* DOWN */
|
|
||||||
{
|
|
||||||
int remainder;
|
|
||||||
|
|
||||||
gdk_draw_drawable (xtext->draw_buf, xtext->fgc, xtext->draw_buf,
|
|
||||||
0, -overlap, 0, 0, width, height + overlap);
|
|
||||||
remainder = ((height - xtext->font->descent) % xtext->fontsize) +
|
|
||||||
xtext->font->descent;
|
|
||||||
area.y = (height + overlap) - remainder;
|
|
||||||
area.height = remainder - overlap;
|
|
||||||
} else
|
|
||||||
{
|
|
||||||
gdk_draw_drawable (xtext->draw_buf, xtext->fgc, xtext->draw_buf,
|
|
||||||
0, 0, 0, overlap, width, height - overlap);
|
|
||||||
area.y = 0;
|
|
||||||
area.height = overlap;
|
|
||||||
}
|
|
||||||
gdk_gc_set_exposures (xtext->fgc, FALSE);
|
|
||||||
|
|
||||||
if (area.height > 0)
|
|
||||||
{
|
|
||||||
area.x = 0;
|
|
||||||
area.width = width;
|
|
||||||
gtk_xtext_paint (GTK_WIDGET (xtext), &area);
|
|
||||||
}
|
|
||||||
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
|
|
||||||
width -= MARGIN;
|
width -= MARGIN;
|
||||||
lines_max = ((height + xtext->pixel_offset) / xtext->fontsize) + 1;
|
lines_max = ((height + xtext->pixel_offset) / xtext->fontsize) + 1;
|
||||||
|
|
||||||
@ -3840,7 +3696,7 @@ gtk_xtext_render_page (GtkXText * xtext)
|
|||||||
}
|
}
|
||||||
|
|
||||||
line = (xtext->fontsize * line) - xtext->pixel_offset;
|
line = (xtext->fontsize * line) - xtext->pixel_offset;
|
||||||
/* fill any space below the last line with our background GC */
|
/* fill any space below the last line with our background */
|
||||||
xtext_draw_bg (xtext, 0, line, width + MARGIN, height - line);
|
xtext_draw_bg (xtext, 0, line, width + MARGIN, height - line);
|
||||||
|
|
||||||
/* draw the separator line */
|
/* draw the separator line */
|
||||||
|
@ -129,8 +129,7 @@ struct _GtkXText
|
|||||||
xtext_buffer *selection_buffer;
|
xtext_buffer *selection_buffer;
|
||||||
|
|
||||||
GtkAdjustment *adj;
|
GtkAdjustment *adj;
|
||||||
GdkPixmap *pixmap; /* 0 = use palette[19] */
|
GdkPixbuf *pixbuf; /* 0 = use palette[19] */
|
||||||
GdkDrawable *draw_buf; /* points to ->window */
|
|
||||||
GdkCursor *hand_cursor;
|
GdkCursor *hand_cursor;
|
||||||
GdkCursor *resize_cursor;
|
GdkCursor *resize_cursor;
|
||||||
|
|
||||||
@ -141,12 +140,8 @@ struct _GtkXText
|
|||||||
int last_win_h;
|
int last_win_h;
|
||||||
int last_win_w;
|
int last_win_w;
|
||||||
|
|
||||||
GdkGC *bgc; /* backing pixmap */
|
GdkColor bgc; /* text background color */
|
||||||
GdkGC *fgc; /* text foreground color */
|
GdkColor fgc; /* text foreground color */
|
||||||
GdkGC *light_gc; /* sep bar */
|
|
||||||
GdkGC *dark_gc;
|
|
||||||
GdkGC *thin_gc;
|
|
||||||
GdkGC *marker_gc;
|
|
||||||
GdkColor palette[XTEXT_COLS];
|
GdkColor palette[XTEXT_COLS];
|
||||||
|
|
||||||
gint io_tag; /* for delayed refresh events */
|
gint io_tag; /* for delayed refresh events */
|
||||||
@ -196,9 +191,6 @@ struct _GtkXText
|
|||||||
int jump_out_offset; /* point at which to stop rendering */
|
int jump_out_offset; /* point at which to stop rendering */
|
||||||
int jump_in_offset; /* "" start rendering */
|
int jump_in_offset; /* "" start rendering */
|
||||||
|
|
||||||
int ts_x; /* ts origin for ->bgc GC */
|
|
||||||
int ts_y;
|
|
||||||
|
|
||||||
int clip_x; /* clipping (x directions) */
|
int clip_x; /* clipping (x directions) */
|
||||||
int clip_x2; /* from x to x2 */
|
int clip_x2; /* from x to x2 */
|
||||||
|
|
||||||
@ -257,7 +249,7 @@ void gtk_xtext_append_indent (xtext_buffer *buf,
|
|||||||
unsigned char *right_text, int right_len,
|
unsigned char *right_text, int right_len,
|
||||||
time_t stamp);
|
time_t stamp);
|
||||||
int gtk_xtext_set_font (GtkXText *xtext, char *name);
|
int gtk_xtext_set_font (GtkXText *xtext, char *name);
|
||||||
void gtk_xtext_set_background (GtkXText * xtext, GdkPixmap * pixmap);
|
void gtk_xtext_set_background (GtkXText * xtext, GdkPixbuf * pixbuf);
|
||||||
void gtk_xtext_set_palette (GtkXText * xtext, GdkColor palette[]);
|
void gtk_xtext_set_palette (GtkXText * xtext, GdkColor palette[]);
|
||||||
void gtk_xtext_clear (xtext_buffer *buf, int lines);
|
void gtk_xtext_clear (xtext_buffer *buf, int lines);
|
||||||
void gtk_xtext_save (GtkXText * xtext, int fh);
|
void gtk_xtext_save (GtkXText * xtext, int fh);
|
||||||
|
Loading…
Reference in New Issue
Block a user