Better drawing, supposedly no more eating 100% cpu time

This commit is contained in:
Yevgen Muntyan 2006-03-24 17:27:31 -06:00
parent 4076786bd7
commit cae601a0d7
6 changed files with 310 additions and 350 deletions

View File

@ -270,16 +270,16 @@
</kdevdoctreeview>
<kdevfilecreate>
<filetypes>
<type icon="source" ext="g" create="template" name="GAP source" >
<type icon="source" ext="g" name="GAP source" create="template" >
<descr>A new empty GAP source file</descr>
</type>
<type icon="source_cpp" ext="cpp" create="template" name="C++ Source" >
<type icon="source_cpp" ext="cpp" name="C++ Source" create="template" >
<descr>A new empty C++ file.</descr>
</type>
<type icon="source_h" ext="h" create="template" name="C/C++ Header" >
<type icon="source_h" ext="h" name="C/C++ Header" create="template" >
<descr>A new empty header file for C/C++.</descr>
</type>
<type icon="source_c" ext="c" create="template" name="C Source" >
<type icon="source_c" ext="c" name="C Source" create="template" >
<descr>A new empty C file.</descr>
</type>
</filetypes>

View File

@ -31,11 +31,6 @@
#define HOW_MANY(x__,y__) (((x__) + (y__) - 1) / (y__))
static void moo_term_invalidate_content_all (MooTerm *term);
static void moo_term_invalidate_content_rect(MooTerm *term,
GdkRectangle *rect);
static void
font_calculate (MooTermFont *font)
{
@ -150,49 +145,17 @@ _moo_term_font_free (MooTermFont *font)
}
static gboolean
process_updates (MooTerm *term)
{
gdk_window_process_updates (GTK_WIDGET(term)->window, FALSE);
term->priv->pending_expose = 0;
return FALSE;
}
static void
add_update_timeout (MooTerm *term)
{
if (!term->priv->pending_expose)
{
term->priv->pending_expose =
g_timeout_add_full (EXPOSE_PRIORITY,
EXPOSE_TIMEOUT,
(GSourceFunc) process_updates,
term,
NULL);
}
}
static void
remove_update_timeout (MooTerm *term)
{
if (term->priv->pending_expose)
g_source_remove (term->priv->pending_expose);
term->priv->pending_expose = 0;
}
void
_moo_term_invalidate_all (MooTerm *term)
_moo_term_invalidate (MooTerm *term)
{
GdkRectangle rec = {0, 0, term->priv->width, term->priv->height};
_moo_term_invalidate_rect (term, &rec);
_moo_term_invalidate_screen_rect (term, &rec);
}
void
_moo_term_invalidate_rect (MooTerm *term,
GdkRectangle *rect)
_moo_term_invalidate_screen_rect (MooTerm *term,
GdkRectangle *rect)
{
if (GTK_WIDGET_REALIZED (term))
{
@ -205,8 +168,6 @@ _moo_term_invalidate_rect (MooTerm *term,
gdk_window_invalidate_rect (GTK_WIDGET(term)->window,
&r, FALSE);
moo_term_invalidate_content_rect (term, rect);
add_update_timeout (term);
}
}
@ -278,7 +239,7 @@ moo_term_update_text_colors (MooTerm *term)
gdk_window_set_background (widget->window, &term->priv->bg_color);
_moo_term_invalidate_all (term);
_moo_term_invalidate (term);
}
@ -407,7 +368,7 @@ invalidate_screen_cell (MooTerm *term,
small_rect.x = column;
small_rect.y = row + scrollback - top_line;
_moo_term_invalidate_rect (term, &small_rect);
_moo_term_invalidate_screen_rect (term, &small_rect);
}
@ -415,117 +376,10 @@ void
_moo_term_cursor_moved (MooTerm *term,
MooTermBuffer *buf)
{
int new_row, new_col;
if (buf != term->priv->buffer)
return;
new_row = buf_cursor_row (buf);
new_col = buf_cursor_col_display (buf);
if (new_row != (int) term->priv->cursor_row ||
new_col != (int) term->priv->cursor_col)
if (buf == term->priv->buffer)
{
if (term->priv->cursor_visible && term->priv->blink_cursor_visible)
{
invalidate_screen_cell (term,
term->priv->cursor_row,
term->priv->cursor_col);
invalidate_screen_cell (term, new_row, new_col);
}
term->priv->cursor_col = new_col;
term->priv->cursor_row = new_row;
}
}
void
_moo_term_init_back_pixmap (MooTerm *term)
{
if (term->priv->back_pixmap)
return;
term->priv->back_pixmap =
gdk_pixmap_new (GTK_WIDGET(term)->window,
PIXEL_WIDTH(term), PIXEL_HEIGHT(term), -1);
term->priv->clip = gdk_gc_new (term->priv->back_pixmap);
gdk_gc_set_clip_origin (term->priv->clip, 0, 0);
moo_term_invalidate_content_all (term);
}
void
_moo_term_resize_back_pixmap (MooTerm *term)
{
if (term->priv->font_changed)
{
GdkPixmap *pix;
term->priv->font_changed = FALSE;
pix = gdk_pixmap_new (term->priv->back_pixmap,
PIXEL_WIDTH(term), PIXEL_HEIGHT(term), -1);
g_object_unref (term->priv->back_pixmap);
term->priv->back_pixmap = pix;
moo_term_invalidate_content_all (term);
}
else
{
GdkPixmap *pix;
GdkRegion *region;
int old_width, old_height;
int width = PIXEL_WIDTH(term);
int height = PIXEL_HEIGHT(term);
GdkRectangle rec = {0, 0, width, height};
pix = gdk_pixmap_new (term->priv->back_pixmap,
width, height, -1);
gdk_drawable_get_size (term->priv->back_pixmap,
&old_width, &old_height);
gdk_gc_set_clip_rectangle (term->priv->clip, &rec);
gdk_draw_drawable (pix, term->priv->clip,
term->priv->back_pixmap,
0, 0, 0, 0,
MIN (width, old_width),
MIN (height, old_height));
if (width > old_width)
{
rec.x = old_width / CHAR_WIDTH(term);
rec.width = (width - old_width) / CHAR_WIDTH(term);
rec.y = 0;
rec.height = height / CHAR_HEIGHT(term);
moo_term_invalidate_content_rect (term, &rec);
}
if (height > old_height)
{
rec.x = 0;
rec.width = width / CHAR_WIDTH(term);
rec.y = old_height / CHAR_HEIGHT(term);
rec.height = (height - old_height) / CHAR_HEIGHT(term);
moo_term_invalidate_content_rect (term, &rec);
}
rec.x = rec.y = 0;
rec.width = width / CHAR_WIDTH(term);
rec.height = height / CHAR_HEIGHT(term);
if (term->priv->changed_content)
{
region = gdk_region_rectangle (&rec);
gdk_region_intersect (term->priv->changed_content, region);
gdk_region_destroy (region);
}
g_object_unref (term->priv->back_pixmap);
term->priv->back_pixmap = pix;
term->priv->cursor_row = buf_cursor_row (buf);
term->priv->cursor_col = buf_cursor_col_display (buf);
}
}
@ -537,8 +391,36 @@ static void term_draw_range (MooTerm *term,
guint start,
guint len);
void
_moo_term_update_back_pixmap (MooTerm *term)
inline static void
rect_window_to_screen (MooTerm *term,
GdkRectangle *window,
GdkRectangle *screen)
{
int cw = CHAR_WIDTH (term);
int ch = CHAR_HEIGHT (term);
screen->width = (window->x + window->width -1)/cw - window->x/cw + 1;
screen->x = window->x/cw;
screen->height = (window->y + window->height -1)/ch - window->y/ch + 1;
screen->y = window->y/ch;
}
inline static void
region_destroy (GdkRegion **region)
{
if (*region)
{
gdk_region_destroy (*region);
*region = NULL;
}
}
static void
moo_term_draw (MooTerm *term,
GdkDrawable *drawable,
GdkRegion *region)
{
GdkRectangle *rects = NULL;
int n_rects;
@ -547,46 +429,180 @@ _moo_term_update_back_pixmap (MooTerm *term)
int width = term->priv->width;
int height = term->priv->height;
GdkRectangle clip = {0, 0, width, height};
GdkRegion *screen_region = NULL;
if (!term->priv->changed_content)
return;
g_return_if_fail (region != NULL);
gdk_region_get_rectangles (term->priv->changed_content,
&rects, &n_rects);
gdk_region_get_rectangles (region, &rects, &n_rects);
if (term->priv->changed)
screen_region = gdk_region_new ();
for (i = 0; i < n_rects; ++i)
{
if (gdk_rectangle_intersect (&rects[i], &clip, &rects[i]))
GdkRectangle *r = &rects[i];
rect_window_to_screen (term, r, r);
if (gdk_rectangle_intersect (r, &clip, r))
{
for (j = 0; j < rects[i].height; ++j)
term_draw_range (term, term->priv->back_pixmap,
top_line + rects[i].y + j,
rects[i].x, rects[i].width);
for (j = 0; j < r->height; ++j)
term_draw_range (term, drawable,
top_line + r->y + j,
r->x, r->width);
if (screen_region)
gdk_region_union_with_rect (screen_region, r);
}
}
if (term->priv->changed && !gdk_region_empty (screen_region))
{
gdk_region_subtract (term->priv->changed,
screen_region);
if (gdk_region_empty (term->priv->changed))
region_destroy (&term->priv->changed);
}
if (screen_region)
gdk_region_destroy (screen_region);
g_free (rects);
gdk_region_destroy (term->priv->changed_content);
term->priv->changed_content = NULL;
}
static void
moo_term_invalidate_content_all (MooTerm *term)
inline static void
rect_screen_to_window (MooTerm *term,
GdkRectangle *screen,
GdkRectangle *window)
{
GdkRectangle rect = {0, 0, term->priv->width, term->priv->height};
moo_term_invalidate_content_rect (term, &rect);
int cw = CHAR_WIDTH (term);
int ch = CHAR_HEIGHT (term);
window->x = screen->x * cw;
window->width = screen->width * cw;
window->y = screen->y * ch;
window->height = screen->height * ch;
}
static void
moo_term_invalidate_content_rect (MooTerm *term,
GdkRectangle *rect)
static gboolean
update_timeout (MooTerm *term)
{
if (term->priv->changed_content)
gdk_region_union_with_rect (term->priv->changed_content, rect);
GdkRegion *region, *changed;
GdkRectangle *rectangles;
int n_rectangles, i;
int top_line = term_top_line (term);
int scrollback = buf_scrollback (term->priv->buffer);
int char_height = CHAR_HEIGHT (term);
int char_width = CHAR_WIDTH (term);
GdkWindow *window = GTK_WIDGET(term)->window;
if (!GTK_WIDGET_DRAWABLE (term))
return TRUE;
gdk_window_freeze_updates (window);
if (term->priv->scroll >= (int) term->priv->height)
{
GdkRectangle all = {
0, 0, term->priv->width * char_width,
term->priv->height * char_height
};
region_destroy (&term->priv->changed);
gdk_window_invalidate_rect (window, &all, FALSE);
goto out;
};
if (!term->priv->changed && !term->priv->scroll &&
term->priv->cursor_col == term->priv->cursor_col_old &&
term->priv->cursor_row == term->priv->cursor_row_old)
goto out;
if (term->priv->changed)
{
changed = term->priv->changed;
term->priv->changed = NULL;
}
else
term->priv->changed_content = gdk_region_rectangle (rect);
{
changed = gdk_region_new ();
}
if (term->priv->scroll)
{
int cursor_row;
GdkRectangle bottom = {0, 0, term->priv->width, 0};
gdk_window_scroll (window, 0, -term->priv->scroll * char_height);
term->priv->cursor_row_old -= term->priv->scroll;
cursor_row = term->priv->cursor_row_old + scrollback - top_line;
if (0 <= cursor_row && cursor_row < (int) term->priv->height)
{
GdkRectangle cursor_rect = {term->priv->cursor_col_old, cursor_row, 1, 1};
gdk_region_union_with_rect (changed, &cursor_rect);
}
bottom.y = term->priv->height - term->priv->scroll;
bottom.height = term->priv->scroll;
gdk_region_union_with_rect (changed, &bottom);
}
if (term->priv->cursor_col != term->priv->cursor_col_old ||
term->priv->cursor_row != term->priv->cursor_row_old)
{
int row;
row = scrollback + term->priv->cursor_row - top_line;
if (term->priv->cursor_col < term->priv->width &&
row >= 0 && row < (int) term->priv->height)
{
GdkRectangle rect = {term->priv->cursor_col, row, 1, 1};
gdk_region_union_with_rect (changed, &rect);
}
row = scrollback + term->priv->cursor_row_old - top_line;
if (term->priv->cursor_col_old < term->priv->width &&
row >= 0 && row < (int) term->priv->height)
{
GdkRectangle rect = {term->priv->cursor_col_old, row, 1, 1};
gdk_region_union_with_rect (changed, &rect);
}
}
if (gdk_region_empty (changed))
{
gdk_region_destroy (changed);
goto out;
}
gdk_region_get_rectangles (changed, &rectangles, &n_rectangles);
g_return_val_if_fail (n_rectangles > 0, TRUE);
for (i = 0; i < n_rectangles; ++i)
{
rect_screen_to_window (term, &rectangles[i], &rectangles[i]);
}
region = gdk_region_rectangle (&rectangles[0]);
for (i = 1; i < n_rectangles; ++i)
gdk_region_union_with_rect (region, &rectangles[i]);
gdk_window_invalidate_region (window, region, FALSE);
gdk_region_destroy (region);
gdk_region_destroy (changed);
out:
term->priv->scroll = 0;
term->priv->cursor_col_old = term->priv->cursor_col;
term->priv->cursor_row_old = term->priv->cursor_row;
gdk_window_thaw_updates (window);
return TRUE;
}
@ -595,13 +611,15 @@ _moo_term_expose_event (GtkWidget *widget,
GdkEventExpose *event)
{
GdkRectangle text_rec = {0, 0, 0, 0};
GdkRegion *text_reg;
GdkRegion *text_region;
MooTerm *term = MOO_TERM (widget);
g_assert (term_top_line (term) <= buf_scrollback (term->priv->buffer));
remove_update_timeout (term);
if (!term->priv->update_timeout)
term->priv->update_timeout =
g_timeout_add_full (UPDATE_PRIORITY, UPDATE_TIMEOUT,
(GSourceFunc) update_timeout, term, NULL);
text_rec.width = PIXEL_WIDTH(term);
text_rec.height = PIXEL_HEIGHT(term);
@ -624,23 +642,13 @@ _moo_term_expose_event (GtkWidget *widget,
CHAR_HEIGHT(term));
}
text_reg = gdk_region_rectangle (&text_rec);
gdk_region_intersect (event->region, text_reg);
gdk_region_destroy (text_reg);
text_region = gdk_region_rectangle (&text_rec);
gdk_region_intersect (text_region, event->region);
if (!gdk_region_empty (event->region))
{
_moo_term_update_back_pixmap (term);
gdk_gc_set_clip_region (term->priv->clip,
event->region);
gdk_draw_drawable (event->window,
term->priv->clip,
term->priv->back_pixmap,
0, 0, 0, 0,
text_rec.width,
text_rec.height);
}
if (!gdk_region_empty (text_region))
moo_term_draw (term, event->window, text_region);
gdk_region_destroy (text_region);
return TRUE;
}
@ -1003,23 +1011,19 @@ void
_moo_term_buf_content_changed (MooTerm *term,
MooTermBuffer *buf)
{
GdkRectangle *rect = NULL;
GdkRegion *dirty, *changed;
int n_rect, i;
GdkRegion *changed;
guint top_line, scrollback;
int height;
if (!GTK_WIDGET_DRAWABLE (term))
return;
changed = buf_get_changed (buf);
changed = buf->priv->changed;
if (buf != term->priv->buffer || !changed || gdk_region_empty (changed))
return;
/* TODO TODO TODO*/
buf->priv->changed = NULL;
buf->priv->changed_all = FALSE;
top_line = term_top_line (term);
scrollback = buf_scrollback (buf);
@ -1045,50 +1049,31 @@ _moo_term_buf_content_changed (MooTerm *term,
return;
}
gdk_region_get_rectangles (changed, &rect, &n_rect);
g_return_if_fail (rect != NULL);
dirty = gdk_region_new ();
for (i = 0; i < n_rect; ++i)
if (term->priv->changed)
{
moo_term_invalidate_content_rect (term, &rect[i]);
rect[i].x *= CHAR_WIDTH(term);
rect[i].y *= CHAR_HEIGHT(term);
rect[i].width *= CHAR_WIDTH(term);
rect[i].height *= CHAR_HEIGHT(term);
gdk_region_union_with_rect (dirty, &rect[i]);
gdk_region_union (term->priv->changed, changed);
gdk_region_destroy (changed);
}
else
{
term->priv->changed = changed;
}
gdk_window_invalidate_region (GTK_WIDGET(term)->window,
dirty, FALSE);
add_update_timeout (term);
g_free (rect);
gdk_region_destroy (changed);
gdk_region_destroy (dirty);
}
void
_moo_term_force_update (MooTerm *term)
_moo_term_buffer_scrolled (MooTermBuffer *buf,
guint lines,
MooTerm *term)
{
GdkRegion *region;
GdkWindow *window = GTK_WIDGET (term)->window;
region = gdk_window_get_update_area (window);
if (region)
if (term->priv->buffer == buf && GTK_WIDGET_DRAWABLE (term))
{
GdkEvent *event = gdk_event_new (GDK_EXPOSE);
event->expose.window = g_object_ref (window);
event->expose.send_event = TRUE;
gdk_region_get_clipbox (region, &event->expose.area);
event->expose.region = region;
gtk_main_do_event (event);
gdk_event_free (event);
_moo_term_buf_content_changed (term, buf);
if (term->priv->changed)
gdk_region_offset (term->priv->changed, 0, -lines);
term->priv->scroll += lines;
}
}
@ -1099,7 +1084,7 @@ _moo_term_invert_colors (MooTerm *term,
{
if (invert != term->priv->colors_inverted)
{
_moo_term_invalidate_all (term);
_moo_term_invalidate (term);
term->priv->colors_inverted = invert;
}
}

View File

@ -37,8 +37,8 @@ G_BEGIN_DECLS
#define ADJUSTMENT_PRIORITY G_PRIORITY_HIGH_IDLE
#define ADJUSTMENT_DELTA 30.0
#define EXPOSE_PRIORITY G_PRIORITY_DEFAULT
#define EXPOSE_TIMEOUT 2
#define UPDATE_PRIORITY G_PRIORITY_DEFAULT
#define UPDATE_TIMEOUT 30
#define PT_WRITER_PRIORITY G_PRIORITY_DEFAULT
#define PT_READER_PRIORITY G_PRIORITY_DEFAULT
@ -109,12 +109,15 @@ struct _MooTermPrivate {
MooTermFont *font;
GdkPixmap *back_pixmap;
GdkRegion *changed_content; /* buffer coordinates, relative to top_line */
GdkRegion *changed; /* screen coordinates */
guint update_timeout;
guint cursor_row_old; /* cursor has been here, and it's been invalidated */
guint cursor_col_old;
int scroll;
GdkGC *clip;
gboolean font_changed;
PangoLayout *layout;
guint pending_expose;
gboolean colors_inverted;
gboolean cursor_visible;
@ -179,6 +182,9 @@ void _moo_term_buf_content_changed (MooTerm *term,
MooTermBuffer *buf);
void _moo_term_cursor_moved (MooTerm *term,
MooTermBuffer *buf);
void _moo_term_buffer_scrolled (MooTermBuffer *buf,
guint lines,
MooTerm *term);
void _moo_term_size_changed (MooTerm *term);
@ -208,16 +214,16 @@ void _moo_term_im_commit (GtkIMContext *imcontext,
gchar *arg,
MooTerm *term);
void _moo_term_init_back_pixmap (MooTerm *term);
void _moo_term_resize_back_pixmap (MooTerm *term);
void _moo_term_update_back_pixmap (MooTerm *term);
gboolean _moo_term_expose_event (GtkWidget *widget,
GdkEventExpose *event);
void _moo_term_invalidate_rect (MooTerm *term,
/* (row, col) coordinates relative to visible part of buffer,
i.e. _moo_term_invalidate is equivalent to
_moo_term_invalidate_screen_rect ({0, 0, width, height}) */
void _moo_term_invalidate_screen_rect(MooTerm *term,
GdkRectangle *rect);
void _moo_term_invalidate_all (MooTerm *term);
void _moo_term_force_update (MooTerm *term);
/* invalidate whole window */
void _moo_term_invalidate (MooTerm *term);
void _moo_term_release_selection (MooTerm *term);
void _moo_term_grab_selection (MooTerm *term);

View File

@ -37,6 +37,7 @@ static void moo_term_get_property (GObject *object,
GParamSpec *pspec);
static void moo_term_realize (GtkWidget *widget);
static void moo_term_unrealize (GtkWidget *widget);
static void moo_term_size_allocate (GtkWidget *widget,
GtkAllocation *allocation);
@ -121,6 +122,7 @@ static void moo_term_class_init (MooTermClass *klass)
gobject_class->get_property = moo_term_get_property;
widget_class->realize = moo_term_realize;
widget_class->unrealize = moo_term_unrealize;
widget_class->size_allocate = moo_term_size_allocate;
widget_class->expose_event = _moo_term_expose_event;
widget_class->key_press_event = _moo_term_key_press;
@ -300,6 +302,15 @@ moo_term_init (MooTerm *term)
G_CALLBACK (scrollback_changed),
term);
g_signal_connect (term->priv->primary_buffer,
"scrolled",
G_CALLBACK (_moo_term_buffer_scrolled),
term);
g_signal_connect (term->priv->alternate_buffer,
"scrolled",
G_CALLBACK (_moo_term_buffer_scrolled),
term);
g_signal_connect_swapped (term->priv->primary_buffer,
"screen-size-changed",
G_CALLBACK (buf_size_changed),
@ -359,15 +370,9 @@ static void moo_term_finalize (GObject *object)
g_free (term->priv->selection);
_moo_term_font_free (term->priv->font);
OBJECT_UNREF (term->priv->back_pixmap);
if (term->priv->changed)
gdk_region_destroy (term->priv->changed);
if (term->priv->changed_content)
gdk_region_destroy (term->priv->changed_content);
if (term->priv->pending_expose)
g_source_remove (term->priv->pending_expose);
OBJECT_UNREF (term->priv->clip);
OBJECT_UNREF (term->priv->layout);
OBJECT_UNREF (term->priv->im);
@ -469,7 +474,8 @@ static void moo_term_size_allocate (GtkWidget *widget,
}
static void moo_term_realize (GtkWidget *widget)
static void
moo_term_realize (GtkWidget *widget)
{
MooTerm *term;
GdkWindowAttr attributes;
@ -521,10 +527,7 @@ static void moo_term_realize (GtkWidget *widget)
widget->style = gtk_style_attach (widget->style, widget->window);
gtk_widget_set_double_buffered (widget, FALSE);
_moo_term_update_palette (term);
_moo_term_init_back_pixmap (term);
_moo_term_size_changed (term);
_moo_term_apply_settings (term);
@ -542,6 +545,19 @@ static void moo_term_realize (GtkWidget *widget)
}
static void
moo_term_unrealize (GtkWidget *widget)
{
MooTerm *term = MOO_TERM (widget);
if (term->priv->update_timeout)
g_source_remove (term->priv->update_timeout);
term->priv->update_timeout = 0;
GTK_WIDGET_CLASS(moo_term_parent_class)->unrealize (widget);
}
static void im_preedit_start (MooTerm *term)
{
term->priv->im_preedit_active = TRUE;
@ -598,9 +614,10 @@ void moo_term_set_adjustment (MooTerm *term,
}
static void scrollback_changed (MooTerm *term,
G_GNUC_UNUSED GParamSpec *pspec,
MooTermBuffer *buf)
static void
scrollback_changed (MooTerm *term,
G_GNUC_UNUSED GParamSpec *pspec,
MooTermBuffer *buf)
{
g_assert (!strcmp (pspec->name, "scrollback"));
@ -631,9 +648,6 @@ static void buf_size_changed (MooTerm *term,
term->priv->width = buf_screen_width (buf);
term->priv->height = buf_screen_height (buf);
if (GTK_WIDGET_REALIZED (term))
_moo_term_resize_back_pixmap (term);
if (!term->priv->scrolled || term->priv->top_line > scrollback)
scroll_to_bottom (term, TRUE);
else
@ -799,7 +813,7 @@ static void scroll_abs (MooTerm *term,
term->priv->top_line = line;
term->priv->scrolled = TRUE;
_moo_term_invalidate_all (term);
_moo_term_invalidate (term);
if (update_adj)
update_adjustment_value (term);
@ -827,7 +841,7 @@ static void scroll_to_bottom (MooTerm *term,
term->priv->scrolled = FALSE;
_moo_term_invalidate_all (term);
_moo_term_invalidate (term);
if (update_full)
update_adjustment (term);
@ -1430,7 +1444,7 @@ moo_term_set_alternate_buffer (MooTerm *term,
else
term->priv->buffer = term->priv->primary_buffer;
_moo_term_invalidate_all (term);
_moo_term_invalidate (term);
_moo_term_buffer_scrollback_changed (term->priv->buffer);
}

View File

@ -24,7 +24,7 @@
</ignoreparts>
<projectdirectory>.</projectdirectory>
<absoluteprojectpath>false</absoluteprojectpath>
<description></description>
<description/>
<secondaryLanguages>
<language>C</language>
</secondaryLanguages>
@ -54,13 +54,13 @@
<cflags>-O0 -g3</cflags>
<cxxflags>-O0 -g3</cxxflags>
<envvars/>
<topsourcedir></topsourcedir>
<cppflags></cppflags>
<ldflags></ldflags>
<ccompilerbinary></ccompilerbinary>
<cxxcompilerbinary></cxxcompilerbinary>
<f77compilerbinary></f77compilerbinary>
<f77flags></f77flags>
<topsourcedir/>
<cppflags/>
<ldflags/>
<ccompilerbinary/>
<cxxcompilerbinary/>
<f77compilerbinary/>
<f77flags/>
</debug>
<gcc-4.0>
<configargs>--enable-debug=full --enable-all-gcc-warnings=fatal --enable-developer-mode --without-mooedit --without-mooapp --without-python</configargs>
@ -166,12 +166,12 @@
</kdevautoproject>
<kdevdebugger>
<general>
<dbgshell>/usr/local/gnu-autotools/bin/libtool</dbgshell>
<programargs>bash</programargs>
<gdbpath></gdbpath>
<configGdbScript></configGdbScript>
<runShellScript></runShellScript>
<runGdbScript></runGdbScript>
<dbgshell/>
<programargs>--g-fatal-warnings bash</programargs>
<gdbpath/>
<configGdbScript/>
<runShellScript/>
<runGdbScript/>
<breakonloadinglibs>true</breakonloadinglibs>
<separatetty>false</separatetty>
<floatingtoolbar>true</floatingtoolbar>
@ -236,16 +236,16 @@
</kdevdoctreeview>
<kdevfilecreate>
<filetypes>
<type icon="source" ext="g" create="template" name="GAP source" >
<type icon="source" ext="g" name="GAP source" create="template" >
<descr>A new empty GAP source file</descr>
</type>
<type icon="source_cpp" ext="cpp" create="template" name="C++ Source" >
<type icon="source_cpp" ext="cpp" name="C++ Source" create="template" >
<descr>A new empty C++ file.</descr>
</type>
<type icon="source_h" ext="h" create="template" name="C/C++ Header" >
<type icon="source_h" ext="h" name="C/C++ Header" create="template" >
<descr>A new empty header file for C/C++.</descr>
</type>
<type icon="source_c" ext="c" create="template" name="C Source" >
<type icon="source_c" ext="c" name="C Source" create="template" >
<descr>A new empty C file.</descr>
</type>
</filetypes>
@ -272,7 +272,7 @@
</codecompletion>
<references/>
<creategettersetter>
<prefixGet></prefixGet>
<prefixGet/>
<prefixSet>set</prefixSet>
<prefixVariable>m_,_</prefixVariable>
<parameterName>theValue</parameterName>

View File

@ -1,5 +1,5 @@
/*
* tests/markup.c
* tests/mterm.c
*
* Copyright (C) 2004-2006 by Yevgen Muntyan <muntyan@math.tamu.edu>
*
@ -12,33 +12,17 @@
*/
#include <gtk/gtk.h>
#define MOOTERM_COMPILATION
#include "mooterm/mooterm-private.h"
#include "mooterm/mootermbuffer-private.h"
#include "mooterm/mooterm.h"
#include "mooutils/mooutils-misc.h"
#include <string.h>
#include <stdlib.h>
static void breakpoint_log_handler (const gchar *log_domain,
GLogLevelFlags log_level,
const gchar *message,
gpointer user_data)
{
g_log_default_handler (log_domain, log_level, message, user_data);
if (log_level &
(G_LOG_LEVEL_ERROR | G_LOG_LEVEL_WARNING | G_LOG_LEVEL_CRITICAL))
{
G_BREAKPOINT ();
}
}
static void init (int *argc, char ***argv, const char **cmd)
static void
init (int *argc, char ***argv, const char **cmd)
{
int i;
gboolean gdk_debug = FALSE;
gboolean set_breakpoint = FALSE;
gtk_init (argc, argv);
@ -46,8 +30,6 @@ static void init (int *argc, char ***argv, const char **cmd)
{
if (!strcmp ((*argv)[i], "--gdk-debug"))
gdk_debug = TRUE;
else if (!strcmp ((*argv)[i], "--set-breakpoint"))
set_breakpoint = TRUE;
else
*cmd = (*argv)[i];
}
@ -55,33 +37,16 @@ static void init (int *argc, char ***argv, const char **cmd)
if (gdk_debug)
gdk_window_set_debug_updates (TRUE);
if (set_breakpoint)
{
#if GLIB_CHECK_VERSION(2,6,0)
g_log_set_default_handler (breakpoint_log_handler, NULL);
#else
g_log_set_handler ("Gtk", G_LOG_LEVEL_MASK | G_LOG_FLAG_FATAL
| G_LOG_FLAG_RECURSION, breakpoint_log_handler, NULL);
g_log_set_handler ("Glib", G_LOG_LEVEL_MASK | G_LOG_FLAG_FATAL
| G_LOG_FLAG_RECURSION, breakpoint_log_handler, NULL);
g_log_set_handler ("Pango", G_LOG_LEVEL_MASK | G_LOG_FLAG_FATAL
| G_LOG_FLAG_RECURSION, breakpoint_log_handler, NULL);
g_log_set_handler ("Gdk", G_LOG_LEVEL_MASK | G_LOG_FLAG_FATAL
| G_LOG_FLAG_RECURSION, breakpoint_log_handler, NULL);
g_log_set_handler ("Moo", G_LOG_LEVEL_MASK | G_LOG_FLAG_FATAL
| G_LOG_FLAG_RECURSION, breakpoint_log_handler, NULL);
g_log_set_handler (NULL, G_LOG_LEVEL_MASK | G_LOG_FLAG_FATAL
| G_LOG_FLAG_RECURSION, breakpoint_log_handler, NULL);
#endif
}
moo_set_log_func_file ("/tmp/mterm");
}
static void set_width (MooTerm *term, guint width, GtkWindow *window)
static void
set_width (MooTerm *term, guint width, GtkWindow *window)
{
guint height;
height = term_char_height (term) * 25;
width *= term_char_width (term);
height = moo_term_char_height (term) * 25;
width *= moo_term_char_width (term);
gtk_widget_set_size_request (GTK_WIDGET (term), width, height);
gtk_window_resize (window, 10, 10);
gtk_container_check_resize (GTK_CONTAINER (window));
@ -89,14 +54,6 @@ static void set_width (MooTerm *term, guint width, GtkWindow *window)
}
static gboolean
invalidate (gpointer term)
{
_moo_term_invalidate_all (term);
return TRUE;
}
int main (int argc, char *argv[])
{
const char *cmd = NULL;
@ -126,8 +83,6 @@ int main (int argc, char *argv[])
"font-name", "Courier New 11",
NULL));
// g_timeout_add (1000, invalidate, term);
gtk_container_add (GTK_CONTAINER (swin), term);
gtk_widget_show_all (win);