rendered paste bodystatic voide_text_command(ETextEventProcessor *tep, ETextEventProcessorCommand *command, gpointer data){ EText *text = E_TEXT(data); gboolean scroll = TRUE; gboolean use_start = TRUE; switch (command->action) { case E_TEP_MOVE: text->selection_start = _get_position(text, command); text->selection_end = text->selection_start; if (text->timer) { g_timer_reset(text->timer); } use_start = TRUE; break; case E_TEP_SELECT: text->selection_start = e_text_model_validate_position (text->model, text->selection_start); /* paranoia */ text->selection_end = _get_position(text, command); e_text_update_primary_selection (text); use_start = FALSE; break; case E_TEP_DELETE: if (text->selection_end == text->selection_start) { text->selection_end = _get_position(text, command); } e_text_delete_selection(text); if (text->timer) { g_timer_reset(text->timer); } use_start = FALSE; break; case E_TEP_INSERT: if (g_utf8_validate (command->string, command->value, NULL)) { if (text->selection_end != text->selection_start) { e_text_delete_selection(text); } e_text_insert(text, command->string); if (text->timer) { g_timer_reset(text->timer); } } break; case E_TEP_COPY: e_text_copy_clipboard (text); if (text->timer) { g_timer_reset(text->timer); } scroll = FALSE; break; case E_TEP_PASTE: e_text_paste (text, GDK_NONE); if (text->timer) { g_timer_reset(text->timer); } break; case E_TEP_GET_SELECTION: e_text_paste (text, GDK_SELECTION_PRIMARY); break; case E_TEP_ACTIVATE: g_signal_emit (text, e_text_signals[E_TEXT_ACTIVATE], 0); if (text->timer) { g_timer_reset(text->timer); } break; case E_TEP_SET_SELECT_BY_WORD: text->select_by_word = command->value; break; case E_TEP_GRAB: e_canvas_item_grab (E_CANVAS (GNOME_CANVAS_ITEM(text)->canvas), GNOME_CANVAS_ITEM(text), GDK_BUTTON_RELEASE_MASK | GDK_POINTER_MOTION_MASK, text->i_cursor, command->time, NULL, NULL); scroll = FALSE; break; case E_TEP_UNGRAB: e_canvas_item_ungrab (E_CANVAS (GNOME_CANVAS_ITEM(text)->canvas), GNOME_CANVAS_ITEM(text), command->time); scroll = FALSE; break; case E_TEP_CAPS: if (text->selection_start == text->selection_end) { capitalize (text, text->selection_start, next_word (text, text->selection_start), command->value); } else { int selection_start = MIN (text->selection_start, text->selection_end); int selection_end = MAX (text->selection_start, text->selection_end); capitalize (text, selection_start, selection_end, command->value); } break; case E_TEP_NOP: scroll = FALSE; break; } /* it's possible to get here without ever having been realized by our canvas (if the e-text started completely obscured.) so let's create our layout object if we don't already have one. */ if (!text->layout) create_layout (text); if (scroll && !text->button_down) { /* XXX do we really need the @trailing logic here? if we don't we can scrap the loop and just use pango_layout_index_to_pos */ PangoLayoutLine *cur_line = NULL; int selection_index; PangoLayoutIter *iter = pango_layout_get_iter (text->layout); selection_index = use_start ? text->selection_start : text->selection_end; /* convert to a byte index */ selection_index = g_utf8_offset_to_pointer (text->text, selection_index) - text->text; g_print("%s/%d -->> selection_index = %d\n", __FILE__, __LINE__, selection_index); do { PangoLayoutLine *line = pango_layout_iter_get_line (iter); if (selection_index >= line->start_index && selection_index <= line->start_index + line->length) { /* found the line with the start of the selection */ cur_line = line; break; } } while (pango_layout_iter_next_line (iter)); if (cur_line) { int xpos, ypos; double clip_width, clip_height; /* gboolean trailing = FALSE; */ PangoRectangle pango_pos; if (selection_index > 0 && selection_index == cur_line->start_index + cur_line->length) { selection_index--; /* trailing = TRUE; */ } pango_layout_index_to_pos (text->layout, selection_index, &pango_pos); pango_pos.x = PANGO_PIXELS (pango_pos.x); pango_pos.y = PANGO_PIXELS (pango_pos.y); pango_pos.width = (pango_pos.width + PANGO_SCALE / 2) / PANGO_SCALE; pango_pos.height = (pango_pos.height + PANGO_SCALE / 2) / PANGO_SCALE; /* scroll for X */ xpos = pango_pos.x; /* + (trailing ? 0 : pango_pos.width);*/ if (xpos + 2 < text->xofs_edit) { text->xofs_edit = xpos; } clip_width = text->clip_width; if (clip_width >= 0 && text->draw_borders) { clip_width -= 6; if (clip_width < 0) clip_width = 0; } if (xpos + pango_pos.width - clip_width > text->xofs_edit) { text->xofs_edit = xpos + pango_pos.width - clip_width; } /* scroll for Y */ if (pango_pos.y + 2 < text->yofs_edit) { ypos = pango_pos.y; text->yofs_edit = ypos; } else { ypos = pango_pos.y + pango_pos.height; } if ( text->clip_height < 0 ) clip_height = text->height; else clip_height = text->clip_height; if (clip_height >= 0 && text->draw_borders) { clip_height -= 6; if (clip_height < 0) clip_height = 0; } if (ypos - clip_height > text->yofs_edit) { text->yofs_edit = ypos - clip_height; } } pango_layout_iter_free (iter); } text->needs_redraw = 1; gnome_canvas_item_request_update (GNOME_CANVAS_ITEM(text));}