Commit 597546e4 authored by Andreas J. Guelzow 's avatar Andreas J. Guelzow

Colour the range expressions to match the range cursor.

2011-11-28  Andreas J. Guelzow <aguelzow@pyrshep.ca>

	* gnumeric-expr-entry.c (gnm_expr_entry_colour_ranges): add arg
	and use the attached attribute list rather than the list from the entry
	(gee_scan_for_range): attach an attribute list as data to the entry

2011-11-28  Andreas J. Guelzow <aguelzow@pyrshep.ca>

	* src/item-edit.c (item_edit_draw): use the attr list attached as
	data
parent 63d85243
2011-11-28 Andreas J. Guelzow <aguelzow@pyrshep.ca>
* src/item-edit.c (item_edit_draw): use the attr list attached as
data
2011-11-28 Andreas J. Guelzow <aguelzow@pyrshep.ca>
* src/item-edit.c (gnm_apply_attribute_list_cb): new
......
Gnumeric 1.11.2
Andreas:
* Colour the range expressions to match the range cursor.
--------------------------------------------------------------------------
Gnumeric 1.11.1
......
......@@ -125,21 +125,15 @@ item_edit_draw (GocItem const *item, cairo_t *cr)
char const *text = gtk_entry_get_text (ie->entry);
PangoDirection dir = pango_find_base_dir (text, -1);
PangoLayout *layout = gtk_entry_get_layout (ie->entry);
PangoAttrList *entry_attributes = pango_layout_get_attributes (layout);
int len;
PangoAttrList *entry_attributes
= g_object_get_data(G_OBJECT (ie->entry),
"gnm:range-attributes");
if (go_pango_attr_list_is_empty (entry_attributes))
entry_attributes = NULL;
else if (0 == (len = gtk_entry_text_index_to_layout_index (ie->entry, 0))) {
entry_attributes = pango_attr_list_copy (entry_attributes);
} else {
PangoAttrList *attributes = pango_attr_list_copy (entry_attributes);
go_pango_attr_list_erase (attributes, 0, len);
if (go_pango_attr_list_is_empty (attributes)) {
pango_attr_list_unref (attributes);
if (entry_attributes != NULL) {
if (go_pango_attr_list_is_empty (entry_attributes))
entry_attributes = NULL;
} else
entry_attributes = attributes;
else
entry_attributes = pango_attr_list_ref (entry_attributes);
}
get_top_left (ie, &top, &left, dir);
......@@ -215,6 +209,8 @@ item_edit_draw (GocItem const *item, cairo_t *cr)
} else {
pango_cairo_show_layout (cr, ie->layout);
}
pango_attr_list_unref (entry_attributes);
if (ie->cursor_visible) {
int cursor_pos = gtk_editable_get_position (GTK_EDITABLE (ie->entry));
double incr = (dir == PANGO_DIRECTION_RTL)? -.5: .5, x, ytop, ybottom;
......
2011-11-28 Andreas J. Guelzow <aguelzow@pyrshep.ca>
* gnumeric-expr-entry.c (gnm_expr_entry_colour_ranges): add arg
and use the attached attribute list rather than the list from the entry
(gee_scan_for_range): attach an attribute list as data to the entry
2011-11-27 Morten Welinder <terra@gnome.org>
* Release 1.11.1
......
......@@ -592,7 +592,8 @@ gee_destroy_feedback_range (GnmExprEntry *gee)
}
static void
gnm_expr_entry_colour_ranges (GnmExprEntry *gee, int start, int end, GnmRangeRef *rr, int colour)
gnm_expr_entry_colour_ranges (GnmExprEntry *gee, int start, int end, GnmRangeRef *rr, int colour,
PangoAttrList **attrs)
{
static struct {
guint16 red;
......@@ -605,16 +606,16 @@ gnm_expr_entry_colour_ranges (GnmExprEntry *gee, int start, int end, GnmRangeRef
{0x0, 0x80FF, 0x80FF, "00:80:80:ff"},
{0xA0FF, 0xA0FF, 0x0, "a0:a0:00:ff"},
{0xA0FF, 0x0, 0xA0FF, "a0:00:a0:ff"}};
GtkEntry *entry = gee->entry;
PangoLayout *layout = gtk_entry_get_layout (entry);
PangoAttribute *at;
PangoAttrList *list = pango_layout_get_attributes (layout);
GnmRange r;
GnmRange const *merge; /*[#127415]*/
Sheet *start_sheet, *end_sheet;
Sheet *sheet = scg_sheet (gee->scg);
SheetControlGUI *scg = NULL;
if (*attrs == NULL)
*attrs = pango_attr_list_new ();
colour = colour % G_N_ELEMENTS (colours);
gnm_rangeref_normalize_pp (rr, &gee->pp,
......@@ -637,10 +638,10 @@ gnm_expr_entry_colour_ranges (GnmExprEntry *gee, int start, int end, GnmRangeRef
SCG_FOREACH_PANE (scg, pane, gnm_pane_expr_cursor_bound_set (pane, &r, colours[colour].name););
at = pango_attr_foreground_new (colours[colour].red, colours[colour].green, colours[colour].blue);
at->start_index = gtk_entry_text_index_to_layout_index (entry, start);
at->end_index = gtk_entry_text_index_to_layout_index (entry, end);
at->start_index = start;
at->end_index = end;
pango_attr_list_change (list, at);
pango_attr_list_change (*attrs, at);
}
/* WARNING : DO NOT CALL THIS FROM FROM UPDATE. It may create another
......@@ -650,6 +651,8 @@ gnm_expr_entry_colour_ranges (GnmExprEntry *gee, int start, int end, GnmRangeRef
static void
gee_scan_for_range (GnmExprEntry *gee)
{
PangoAttrList *attrs = NULL;
parse_pos_init_editpos (&gee->pp, scg_view (gee->scg));
gee_destroy_feedback_range (gee);
if (!gee->feedback_disabled && gee_is_editing (gee) && gee->lexer_items != NULL) {
......@@ -666,11 +669,16 @@ gee_scan_for_range (GnmExprEntry *gee)
&gee->pp, gee_convs (gee));
if (tmp != rtext)
gnm_expr_entry_colour_ranges (gee, gli->start, gli->end, &rr,
colour++);
colour++, &attrs);
g_free (rtext);
}
} while (gli++->token != 0);
}
if (attrs)
g_object_set_data_full (G_OBJECT (gee->entry), "gnm:range-attributes", attrs,
(GDestroyNotify) pango_attr_list_unref);
else
g_object_set_data (G_OBJECT (gee->entry), "gnm:range-attributes", NULL);
}
static void
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment