Skip to content

Commit

Permalink
* shoes/ruby.c: optimized highlighting strategy didn't work, have to…
Browse files Browse the repository at this point in the history
… uncache the textblock everytime the highlight changes. i might need to write a pango hack to get this to go.
  • Loading branch information
_why committed Mar 2, 2009
1 parent 8c0fcee commit 71bb825
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 14 deletions.
1 change: 0 additions & 1 deletion shoes/canvas.h
Expand Up @@ -150,7 +150,6 @@ typedef struct {
//
typedef struct {
int pos, x, y, hi;
PangoAttribute *attr;
} shoes_textcursor;

//
Expand Down
21 changes: 8 additions & 13 deletions shoes/ruby.c
Expand Up @@ -2438,8 +2438,6 @@ shoes_textblock_uncache(shoes_textblock *text, unsigned char all)
{
if (text->pattr != NULL)
pango_attr_list_unref(text->pattr);
if (text->cursor != NULL)
text->cursor->attr = NULL;
text->pattr = NULL;
if (all)
{
Expand Down Expand Up @@ -2523,6 +2521,7 @@ shoes_textblock_set_cursor(VALUE self, VALUE pos)
}
}
else self_t->cursor->pos = NUM2INT(pos);
shoes_textblock_uncache(self_t, FALSE);
shoes_canvas_repaint_all(self_t->parent);
return pos;
}
Expand Down Expand Up @@ -2563,6 +2562,7 @@ shoes_textblock_set_marker(VALUE self, VALUE pos)

if (NIL_P(pos)) self_t->cursor->hi = INT_MAX;
else self_t->cursor->hi = NUM2INT(pos);
shoes_textblock_uncache(self_t, FALSE);
shoes_canvas_repaint_all(self_t->parent);
return pos;
}
Expand Down Expand Up @@ -2970,12 +2970,13 @@ shoes_textblock_make_pango(shoes_app *app, VALUE klass, shoes_textblock *block)
shoes_textblock_iter_pango(block->texts, block, app);
shoes_app_style_for(block, app, klass, block->attr, 0, block->len);

if (block->cursor != NULL)
if (block->cursor != NULL && block->cursor->pos != INT_MAX &&
block->cursor->hi != INT_MAX && block->cursor->pos != block->cursor->hi)
{
block->cursor->attr = pango_attr_background_new(255 * 255, 255 * 255, 0);
block->cursor->attr->start_index = 0;
block->cursor->attr->end_index = 0;
pango_attr_list_insert(block->pattr, block->cursor->attr);
PangoAttribute *attr = pango_attr_background_new(255 * 255, 255 * 255, 0);
attr->start_index = min(block->cursor->pos, block->cursor->hi);
attr->end_index = max(block->cursor->pos, block->cursor->hi);
pango_attr_list_insert(block->pattr, attr);
}

block->cached = 1;
Expand All @@ -2994,12 +2995,6 @@ shoes_textblock_on_layout(shoes_app *app, VALUE klass, shoes_textblock *block)

if (!block->cached || block->pattr == NULL)
shoes_textblock_make_pango(app, klass, block);
if (block->cursor != NULL && block->cursor->pos != INT_MAX &&
block->cursor->hi != INT_MAX && block->cursor->pos != block->cursor->hi)
{
block->cursor->attr->start_index = min(block->cursor->pos, block->cursor->hi);
block->cursor->attr->end_index = max(block->cursor->pos, block->cursor->hi);
}
pango_layout_set_text(block->layout, block->text->str, -1);
pango_layout_set_attributes(block->layout, block->pattr);

Expand Down

0 comments on commit 71bb825

Please sign in to comment.