diff options
Diffstat (limited to 'generic')
-rw-r--r-- | generic/Item.c | 1 | ||||
-rw-r--r-- | generic/Text.c | 50 | ||||
-rw-r--r-- | generic/tkZinc.c | 14 |
3 files changed, 30 insertions, 35 deletions
diff --git a/generic/Item.c b/generic/Item.c index 31d747e..6739e0e 100644 --- a/generic/Item.c +++ b/generic/Item.c @@ -2404,6 +2404,7 @@ Invalidate(ZnItem item, if (ISSET(item->flags, ZN_VISIBLE_BIT)) { /*printf("invalidate graphics for item %d\n", item->id);*/ ZnDamage(item->wi, &item->item_bounding_box); + ZnNeedRedisplay(item->wi); #ifdef GL #ifdef GL_LIST /* diff --git a/generic/Text.c b/generic/Text.c index 5b378bc..67ef520 100644 --- a/generic/Text.c +++ b/generic/Text.c @@ -57,8 +57,8 @@ static const char compile_id[] = "$Compile: " __FILE__ " " __DATE__ " " __TIME__ */ typedef struct _TextLineInfo { - char *start; /* Index of first char in line */ - unsigned short num_bytes; /* Number of displayed bytes in line (NOT chars)*/ + char *start; /* Index of first char in line */ + unsigned short num_bytes; /* Number of displayed bytes in line (NOT chars)*/ unsigned short width; /* Line width in pixels */ unsigned short origin_x; /* X pos for drawing the line */ unsigned short origin_y; @@ -444,37 +444,37 @@ ComputeCursor(ZnItem item, TextLineInfo lines, lines_ptr; unsigned int i, line_index, insert_index, num_lines; + if ((wi->focus_item != item) || ISCLEAR(wi->flags, ZN_GOT_FOCUS) || !ti->cursor_on) { + return; + } num_lines = ZnListSize(text->text_info); if (num_lines == 0) { *cursor_line = 0; + *cursor_offset = 0; + return; } lines = ZnListArray(text->text_info); - if ((wi->focus_item == item) && ISSET(wi->flags, ZN_GOT_FOCUS) && ti->cursor_on) { - insert_index = Tcl_UtfAtIndex(text->text, (int) text->insert_index)-text->text; - for (i = 0, lines_ptr = lines; i < num_lines; i++, lines_ptr++) { - /* - * Mark the line with the cursor and compute its - * position along the X axis. - */ - line_index = lines_ptr->start - text->text; - if ((insert_index >= line_index) && - (insert_index <= line_index + lines_ptr->num_bytes)) { - *cursor_line = i; - *cursor_offset = Tk_TextWidth(text->font, (char *) lines_ptr->start, - insert_index - line_index); - } + insert_index = Tcl_UtfAtIndex(text->text, (int) text->insert_index) - text->text; + for (i = 0, lines_ptr = lines; i < num_lines; i++, lines_ptr++) { + /* + * Mark the line with the cursor and compute its + * position along the X axis. + */ + line_index = lines_ptr->start - text->text; + if ((insert_index >= line_index) && (insert_index <= line_index + lines_ptr->num_bytes)) { + *cursor_line = i; + *cursor_offset = Tk_TextWidth(text->font, (char *) lines_ptr->start, insert_index - line_index); } } - } static void -ComputeSelection(ZnItem item, - int *sel_first_line, - int *sel_last_line, - unsigned int *sel_start_offset, - unsigned int *sel_stop_offset) +ComputeSelection(ZnItem item, + int *sel_first_line, + int *sel_last_line, + unsigned int *sel_start_offset, + unsigned int *sel_stop_offset) { TextItem text = (TextItem) item; ZnWInfo *wi = item->wi; @@ -929,8 +929,7 @@ Draw(ZnItem item) /* * Setup the gc for the cursor and draw it. */ - if (cursor_line >= 0 && - (wi->focus_item == item) && ti->cursor_on) { + if (cursor_line >= 0) { values.fill_style = FillSolid; values.line_width = ti->insert_width; values.foreground = ZnGetGradientPixel(ti->insert_color, 0.0); @@ -1206,8 +1205,7 @@ Render(ZnItem item) /* * Render the cursor. */ - if ((cursor_line >= 0) && - (wi->focus_item == item) && ti->cursor_on) { + if (cursor_line >= 0) { color = ZnGetGradientColor(ti->insert_color, 0.0, &alpha); alpha = ZnComposeAlpha(alpha, wi->alpha); glColor4us(color->red, color->green, color->blue, alpha); diff --git a/generic/tkZinc.c b/generic/tkZinc.c index e7d6851..df3aeb6 100644 --- a/generic/tkZinc.c +++ b/generic/tkZinc.c @@ -336,7 +336,7 @@ static Tk_ConfigSpec config_specs[] = { {TK_CONFIG_BOOLEAN, "-confine", "confine", "Confine", "1", Tk_Offset(ZnWInfo, confine), 0, NULL}, {TK_CONFIG_ACTIVE_CURSOR, "-cursor", "cursor", "Cursor", - "", Tk_Offset(ZnWInfo, cursor), TK_CONFIG_NULL_OK, NULL}, + "arrow", Tk_Offset(ZnWInfo, cursor), TK_CONFIG_NULL_OK, NULL}, {TK_CONFIG_FONT, "-font", "font", "Font", "-adobe-helvetica-bold-r-normal--*-120-*-*-*-*-*-*", Tk_Offset(ZnWInfo, font), 0, NULL}, @@ -7277,16 +7277,13 @@ Blink(ClientData client_data) } if (wi->text_info.cursor_on) { wi->text_info.cursor_on = 0; - wi->blink_handler = Tcl_CreateTimerHandler(wi->insert_off_time, - Blink, client_data); + wi->blink_handler = Tcl_CreateTimerHandler(wi->insert_off_time, Blink, client_data); } else { wi->text_info.cursor_on = 1; - wi->blink_handler = Tcl_CreateTimerHandler(wi->insert_on_time, - Blink, client_data); + wi->blink_handler = Tcl_CreateTimerHandler(wi->insert_on_time, Blink, client_data); } - if ((wi->focus_item != ZN_NO_ITEM) && - (wi->focus_item->class->Cursor != NULL)) { + if ((wi->focus_item != ZN_NO_ITEM) && (wi->focus_item->class->Cursor != NULL)) { ZnITEM.Invalidate(wi->focus_item, ZN_DRAW_FLAG); } } @@ -7300,8 +7297,7 @@ Focus(ZnWInfo *wi, SET(wi->flags, ZN_GOT_FOCUS); wi->text_info.cursor_on = 1; if (wi->insert_off_time != 0) { - wi->blink_handler = Tcl_CreateTimerHandler(wi->insert_off_time, - Blink, (ClientData) wi); + wi->blink_handler = Tcl_CreateTimerHandler(wi->insert_off_time, Blink, (ClientData) wi); } } else { |