Lines Matching defs:tc
63 static void sp_text_context_validate_cursor_iterators(TextTool *tc);
64 static void sp_text_context_update_cursor(TextTool *tc, bool scroll_to_see = true);
65 static void sp_text_context_update_text_selection(TextTool *tc);
66 static gint sp_text_context_timeout(TextTool *tc);
67 static void sp_text_context_forget_text(TextTool *tc);
69 static gint sptc_focus_in(GtkWidget *widget, GdkEventFocus *event, TextTool *tc);
70 static gint sptc_focus_out(GtkWidget *widget, GdkEventFocus *event, TextTool *tc);
71 static void sptc_commit(GtkIMContext *imc, gchar *string, TextTool *tc);
391 static void sp_text_context_setup_text(TextTool *tc)
393 ToolBase *ec = SP_EVENT_CONTEXT(tc);
403 sp_repr_set_svg_double(rtext, "x", tc->pdoc[Geom::X]);
404 sp_repr_set_svg_double(rtext, "y", tc->pdoc[Geom::Y]);
430 * Insert the character indicated by tc.uni to replace the current selection,
431 * and reset tc.uni/tc.unipos to empty string.
433 * \pre tc.uni/tc.unipos non-empty.
435 static void insert_uni_char(TextTool *const tc)
437 g_return_if_fail(tc->unipos
438 && tc->unipos < sizeof(tc->uni)
439 && tc->uni[tc->unipos] == '\0');
442 ss << std::hex << tc->uni;
444 tc->unipos = 0;
445 tc->uni[tc->unipos] = '\0';
450 tc->desktop->messageStack()->flash(Inkscape::ERROR_MESSAGE,
453 if (!tc->text) { // printable key; create text if none (i.e. if nascent_object)
454 sp_text_context_setup_text(tc);
455 tc->nascent_object = 0; // we don't need it anymore, having created a real <text>
462 tc->text_sel_start = tc->text_sel_end = sp_te_replace(tc->text, tc->text_sel_start, tc->text_sel_end, u);
463 sp_text_context_update_cursor(tc);
464 sp_text_context_update_text_selection(tc);
465 DocumentUndo::done(tc->desktop->getDocument(), SP_VERB_DIALOG_TRANSFORM,
483 static void show_curr_uni_char(TextTool *const tc)
485 g_return_if_fail(tc->unipos < sizeof(tc->uni)
486 && tc->uni[tc->unipos] == '\0');
487 if (tc->unipos) {
489 hex_to_printable_utf8_buf(tc->uni, utf8);
500 tc->defaultMessageContext()->setF(Inkscape::NORMAL_MESSAGE,
501 _("Unicode (<b>Enter</b> to finish): %s: %s"), tc->uni, utf8);
503 tc->defaultMessageContext()->set(Inkscape::NORMAL_MESSAGE, _("Unicode (<b>Enter</b> to finish): "));
741 use a fixed-length buffer for tc->uni. Reason for
1268 TextTool *tc = SP_TEXT_CONTEXT(ec);
1270 if ((tc->text) || (tc->nascent_object)) {
1304 if (!tc->text) { // create text if none (i.e. if nascent_object)
1305 sp_text_context_setup_text(tc);
1306 tc->nascent_object = 0; // we don't need it anymore, having created a real <text>
1315 tc->text_sel_start = tc->text_sel_end = sp_te_replace(tc->text, tc->text_sel_start, tc->text_sel_end, text.substr(begin).c_str());
1318 tc->text_sel_start = tc->text_sel_end = sp_te_replace(tc->text, tc->text_sel_start, tc->text_sel_end, text.substr(begin, end - begin).c_str());
1319 tc->text_sel_start = tc->text_sel_end = sp_te_insert_line(tc->text, tc->text_sel_start);
1340 TextTool const *tc = SP_TEXT_CONTEXT(ec);
1341 if (tc->text == NULL)
1344 return sp_te_get_string_multiline(tc->text, tc->text_sel_start, tc->text_sel_end);
1351 TextTool const *tc = SP_TEXT_CONTEXT(ec);
1352 if (tc->text == NULL)
1355 SPObject const *obj = sp_te_object_at_position(tc->text, tc->text_sel_end);
1372 TextTool *tc = SP_TEXT_CONTEXT(ec);
1373 if (tc->text == NULL)
1376 if (tc->text_sel_start == tc->text_sel_end)
1380 bool success = sp_te_delete(tc->text, tc->text_sel_start, tc->text_sel_end, pair);
1384 tc->text_sel_start = tc->text_sel_end = pair.first;
1386 tc->text_sel_start = pair.first;
1387 tc->text_sel_end = pair.second;
1390 sp_text_context_update_cursor(tc);
1391 sp_text_context_update_text_selection(tc);
1498 static void sp_text_context_validate_cursor_iterators(TextTool *tc)
1500 if (tc->text == NULL)
1502 Inkscape::Text::Layout const *layout = te_get_layout(tc->text);
1504 layout->validateIterator(&tc->text_sel_start);
1505 layout->validateIterator(&tc->text_sel_end);
1509 static void sp_text_context_update_cursor(TextTool *tc, bool scroll_to_see)
1511 // due to interruptible display, tc may already be destroyed during a display update before
1513 if (!tc->desktop) return;
1515 if (tc->text) {
1517 sp_te_get_cursor_coords(tc->text, tc->text_sel_end, p0, p1);
1518 Geom::Point const d0 = p0 * tc->text->i2dt_affine();
1519 Geom::Point const d1 = p1 * tc->text->i2dt_affine();
1523 Geom::Point const center = SP_EVENT_CONTEXT(tc)->desktop->get_display_area().midpoint();
1526 SP_EVENT_CONTEXT(tc)->desktop->scroll_to_point(d0, 1.0);
1528 SP_EVENT_CONTEXT(tc)->desktop->scroll_to_point(d1, 1.0);
1531 sp_canvas_item_show(tc->cursor);
1532 tc->cursor->setCoords(d0, d1);
1535 if (tc->imc) {
1537 Geom::Point const top_left = SP_EVENT_CONTEXT(tc)->desktop->get_display_area().corner(3);
1538 Geom::Point const im_d0 = SP_EVENT_CONTEXT(tc)->desktop->d2w(d0 - top_left);
1539 Geom::Point const im_d1 = SP_EVENT_CONTEXT(tc)->desktop->d2w(d1 - top_left);
1544 gtk_im_context_set_cursor_location(tc->imc, &im_cursor);
1547 tc->show = TRUE;
1548 tc->phase = 1;
1550 Inkscape::Text::Layout const *layout = te_get_layout(tc->text);
1558 if (SP_IS_FLOWTEXT(tc->text)) {
1559 SPItem *frame = SP_FLOWTEXT(tc->text)->get_frame (NULL); // first frame only
1562 SP_CTRLRECT(tc->frame)->setColor(0xff0000ff, false, 0);
1564 SP_CTRLRECT(tc->frame)->setColor(0x0000ff7f, false, 0);
1566 sp_canvas_item_show(tc->frame);
1569 SP_CTRLRECT(tc->frame)->setRectangle(*frame_bbox);
1573 SP_EVENT_CONTEXT(tc)->message_context->setF(Inkscape::NORMAL_MESSAGE, ngettext("Type or edit flowed text (%d character%s); <b>Enter</b> to start new paragraph.", "Type or edit flowed text (%d characters%s); <b>Enter</b> to start new paragraph.", nChars), nChars, trunc);
1575 SP_EVENT_CONTEXT(tc)->message_context->setF(Inkscape::NORMAL_MESSAGE, ngettext("Type or edit text (%d character%s); <b>Enter</b> to start new line.", "Type or edit text (%d characters%s); <b>Enter</b> to start new line.", nChars), nChars, trunc);
1579 sp_canvas_item_hide(tc->cursor);
1580 sp_canvas_item_hide(tc->frame);
1581 tc->show = FALSE;
1582 if (!tc->nascent_object) {
1583 SP_EVENT_CONTEXT(tc)->message_context->set(Inkscape::NORMAL_MESSAGE, _("<b>Click</b> to select or create text, <b>drag</b> to create flowed text; then type.")); // FIXME: this is a copy of string from tools-switch, do not desync
1587 SP_EVENT_CONTEXT(tc)->desktop->emitToolSubselectionChanged((gpointer)tc);
1590 static void sp_text_context_update_text_selection(TextTool *tc)
1592 // due to interruptible display, tc may already be destroyed during a display update before
1594 if (!tc->desktop) return;
1596 for (std::vector<SPCanvasItem*>::iterator it = tc->text_selection_quads.begin() ; it != tc->text_selection_quads.end() ; ++it) {
1600 tc->text_selection_quads.clear();
1603 if (tc->text != NULL)
1604 quads = sp_te_create_selection_quads(tc->text, tc->text_sel_start, tc->text_sel_end, (tc->text)->i2dt_affine());
1607 quad_canvasitem = sp_canvas_item_new(tc->desktop->getControls(), SP_TYPE_CTRLQUADR, NULL);
1613 tc->text_selection_quads.push_back(quad_canvasitem);
1617 static gint sp_text_context_timeout(TextTool *tc)
1619 if (tc->show) {
1620 sp_canvas_item_show(tc->cursor);
1621 if (tc->phase) {
1622 tc->phase = 0;
1623 tc->cursor->setRgba32(0x000000ff);
1625 tc->phase = 1;
1626 tc->cursor->setRgba32(0xffffffff);
1633 static void sp_text_context_forget_text(TextTool *tc)
1635 if (! tc->text) return;
1636 SPItem *ti = tc->text;
1640 tc->text = NULL;
1654 SPDocumentUndo::done(tc->desktop->getDocument(), SP_VERB_CONTEXT_TEXT,
1661 gint sptc_focus_in(GtkWidget */*widget*/, GdkEventFocus */*event*/, TextTool *tc)
1663 gtk_im_context_focus_in(tc->imc);
1667 gint sptc_focus_out(GtkWidget */*widget*/, GdkEventFocus */*event*/, TextTool *tc)
1669 gtk_im_context_focus_out(tc->imc);
1673 static void sptc_commit(GtkIMContext */*imc*/, gchar *string, TextTool *tc)
1675 if (!tc->text) {
1676 sp_text_context_setup_text(tc);
1677 tc->nascent_object = 0; // we don't need it anymore, having created a real <text>
1680 tc->text_sel_start = tc->text_sel_end = sp_te_replace(tc->text, tc->text_sel_start, tc->text_sel_end, string);
1681 sp_text_context_update_cursor(tc);
1682 sp_text_context_update_text_selection(tc);
1684 DocumentUndo::done(tc->text->document, SP_VERB_CONTEXT_TEXT,
1688 void sp_text_context_place_cursor (TextTool *tc, SPObject *text, Inkscape::Text::Layout::iterator where)
1690 tc->desktop->selection->set (text);
1691 tc->text_sel_start = tc->text_sel_end = where;
1692 sp_text_context_update_cursor(tc);
1693 sp_text_context_update_text_selection(tc);
1696 void sp_text_context_place_cursor_at (TextTool *tc, SPObject *text, Geom::Point const p)
1698 tc->desktop->selection->set (text);
1699 sp_text_context_place_cursor (tc, text, sp_te_get_position_by_coords(tc->text, p));
1702 Inkscape::Text::Layout::iterator *sp_text_context_get_cursor_position(TextTool *tc, SPObject *text)
1704 if (text != tc->text)
1706 return &(tc->text_sel_end);