| Flutter Linux Embedder |

Classes | Typedefs | Functions | Variables
fl_accessible_text_field.cc File Reference
`#include "flutter/shell/platform/linux/fl_accessible_text_field.h"`
`#include "flutter/shell/platform/linux/public/flutter_linux/fl_standard_message_codec.h"`
`#include "flutter/shell/platform/linux/public/flutter_linux/fl_value.h"`

Go to the source code of this file.

## Classes
struct | _FlAccessibleTextField

## Typedefs
typedef bool(* | FlTextBoundaryCallback) (const PangoLogAttr *attr)

## Functions
static void | fl_accessible_text_iface_init (AtkTextIface *iface)
static void | fl_accessible_editable_text_iface_init (AtkEditableTextIface *iface)
| G_DEFINE_TYPE_WITH_CODE (FlAccessibleTextField, fl_accessible_text_field, fl_accessible_node_get_type(), G_IMPLEMENT_INTERFACE(ATK_TYPE_EDITABLE_TEXT, fl_accessible_editable_text_iface_init)) static gchar *get_substring(FlAccessibleTextField *self
| if (end==-1)
return | g_utf8_substring (value, start, end)
static PangoContext * | get_pango_context (FlAccessibleTextField *self)
static PangoLayout * | create_pango_layout (FlAccessibleTextField *self)
static gchar * | get_string_at_offset (FlAccessibleTextField *self, gint start, gint end, FlTextBoundaryCallback is_start, FlTextBoundaryCallback is_end, gint *start_offset, gint *end_offset)
static gchar * | get_char_at_offset (FlAccessibleTextField *self, gint offset, gint *start_offset, gint *end_offset)
static gchar * | get_word_at_offset (FlAccessibleTextField *self, gint offset, gint *start_offset, gint *end_offset)
static gchar * | get_sentence_at_offset (FlAccessibleTextField *self, gint offset, gint *start_offset, gint *end_offset)
static gchar * | get_line_at_offset (FlAccessibleTextField *self, gint offset, gint *start_offset, gint *end_offset)
static gchar * | get_paragraph_at_offset (FlAccessibleTextField *self, gint offset, gint *start_offset, gint *end_offset)
static void | perform_set_text_action (FlAccessibleTextField *self, const char *text)
static void | perform_set_selection_action (FlAccessibleTextField *self, gint base, gint extent)
static void | fl_accessible_text_field_dispose (GObject *object)
static void | fl_accessible_text_field_set_value (FlAccessibleNode *node, const gchar *value)
static void | fl_accessible_text_field_set_text_selection (FlAccessibleNode *node, gint base, gint extent)
static void | fl_accessible_text_field_set_text_direction (FlAccessibleNode *node, FlutterTextDirection direction)
void | fl_accessible_text_field_perform_action (FlAccessibleNode *self, FlutterSemanticsAction action, GBytes *data)
static gint | fl_accessible_text_field_get_character_count (AtkText *text)
static gchar * | fl_accessible_text_field_get_text (AtkText *text, gint start_offset, gint end_offset)
static gchar * | fl_accessible_text_field_get_string_at_offset (AtkText *text, gint offset, AtkTextGranularity granularity, gint *start_offset, gint *end_offset)
static gchar * | fl_accessible_text_field_get_text_at_offset (AtkText *text, gint offset, AtkTextBoundary boundary_type, gint *start_offset, gint *end_offset)
static gint | fl_accessible_text_field_get_caret_offset (AtkText *text)
static gboolean | fl_accessible_text_field_set_caret_offset (AtkText *text, gint offset)
static gint | fl_accessible_text_field_get_n_selections (AtkText *text)
static gchar * | fl_accessible_text_field_get_selection (AtkText *text, gint selection_num, gint *start_offset, gint *end_offset)
static gboolean | fl_accessible_text_field_add_selection (AtkText *text, gint start_offset, gint end_offset)
static gboolean | fl_accessible_text_field_remove_selection (AtkText *text, gint selection_num)
static gboolean | fl_accessible_text_field_set_selection (AtkText *text, gint selection_num, gint start_offset, gint end_offset)
static void | fl_accessible_text_field_set_text_contents (AtkEditableText *editable_text, const gchar *string)
static void | fl_accessible_text_field_insert_text (AtkEditableText *editable_text, const gchar *string, gint length, gint *position)
static void | fl_accessible_node_delete_text (AtkEditableText *editable_text, gint start_pos, gint end_pos)
static void | fl_accessible_text_field_copy_text (AtkEditableText *editable_text, gint start_pos, gint end_pos)
static void | fl_accessible_text_field_cut_text (AtkEditableText *editable_text, gint start_pos, gint end_pos)
static void | fl_accessible_text_field_paste_text (AtkEditableText *editable_text, gint position)
static void | fl_accessible_text_field_class_init (FlAccessibleTextFieldClass *klass)
static void | fl_accessible_text_field_init (FlAccessibleTextField *self)
FlAccessibleNode * | fl_accessible_text_field_new (FlEngine *engine, FlutterViewId view_id, int32_t id)

## Variables
glong | start
glong glong | end

## Typedef Documentation

## ◆ FlTextBoundaryCallback

typedef bool(* FlTextBoundaryCallback) (const PangoLogAttr *attr)

Definition at line 16 of file fl_accessible_text_field.cc.

## Function Documentation

## ◆ create_pango_layout()

static PangoLayout* create_pango_layout | ( | FlAccessibleTextField * | self | ) |
| static

Definition at line 59 of file fl_accessible_text_field.cc.

59 {
60 g_autoptr(PangoContext) context = get_pango_context(self);
61 PangoLayout* layout = pango_layout_new(context);
62 pango_layout_set_text(layout, gtk_entry_buffer_get_text(self->buffer), -1);
63 return layout;
64 }
get_pango_context
static PangoContext * get_pango_context(FlAccessibleTextField *self)
Definition: fl_accessible_text_field.cc:49
g_autoptr
g_autoptr(GMutexLocker) locker

References g_autoptr(), and get_pango_context().

Referenced by get_line_at_offset(), get_paragraph_at_offset(), and get_string_at_offset().

## ◆ fl_accessible_editable_text_iface_init()

static void fl_accessible_editable_text_iface_init | ( | AtkEditableTextIface * | iface | ) |
| static

Definition at line 581 of file fl_accessible_text_field.cc.

582 {
583 iface->set_text_contents = fl_accessible_text_field_set_text_contents;
584 iface->insert_text = fl_accessible_text_field_insert_text;
585 iface->delete_text = fl_accessible_node_delete_text;
586
587 iface->copy_text = fl_accessible_text_field_copy_text;
588 iface->cut_text = fl_accessible_text_field_cut_text;
589 iface->paste_text = fl_accessible_text_field_paste_text;
590 }
fl_accessible_text_field_insert_text
static void fl_accessible_text_field_insert_text(AtkEditableText *editable_text, const gchar *string, gint length, gint *position)
Definition: fl_accessible_text_field.cc:487
fl_accessible_text_field_paste_text
static void fl_accessible_text_field_paste_text(AtkEditableText *editable_text, gint position)
Definition: fl_accessible_text_field.cc:541
fl_accessible_text_field_set_text_contents
static void fl_accessible_text_field_set_text_contents(AtkEditableText *editable_text, const gchar *string)
Definition: fl_accessible_text_field.cc:477
fl_accessible_text_field_copy_text
static void fl_accessible_text_field_copy_text(AtkEditableText *editable_text, gint start_pos, gint end_pos)
Definition: fl_accessible_text_field.cc:515
fl_accessible_node_delete_text
static void fl_accessible_node_delete_text(AtkEditableText *editable_text, gint start_pos, gint end_pos)
Definition: fl_accessible_text_field.cc:502
fl_accessible_text_field_cut_text
static void fl_accessible_text_field_cut_text(AtkEditableText *editable_text, gint start_pos, gint end_pos)
Definition: fl_accessible_text_field.cc:528

References fl_accessible_node_delete_text(), fl_accessible_text_field_copy_text(), fl_accessible_text_field_cut_text(), fl_accessible_text_field_insert_text(), fl_accessible_text_field_paste_text(), and fl_accessible_text_field_set_text_contents().

## ◆ fl_accessible_node_delete_text()

static void fl_accessible_node_delete_text | ( | AtkEditableText * | editable_text,
|  | gint | start_pos,
|  | gint | end_pos
| ) |  |
| static

Definition at line 502 of file fl_accessible_text_field.cc.

504 {
505 g_return_if_fail(FL_IS_ACCESSIBLE_TEXT_FIELD(editable_text));
506 FlAccessibleTextField* self = FL_ACCESSIBLE_TEXT_FIELD(editable_text);
507
508 gtk_entry_buffer_delete_text(self->buffer, start_pos, end_pos - start_pos);
509
510 perform_set_text_action(self, gtk_entry_buffer_get_text(self->buffer));
511 perform_set_selection_action(self, start_pos, start_pos);
512 }
perform_set_selection_action
static void perform_set_selection_action(FlAccessibleTextField *self, gint base, gint extent)
Definition: fl_accessible_text_field.cc:199
perform_set_text_action
static void perform_set_text_action(FlAccessibleTextField *self, const char *text)
Definition: fl_accessible_text_field.cc:188

References perform_set_selection_action(), and perform_set_text_action().

Referenced by fl_accessible_editable_text_iface_init().

## ◆ fl_accessible_text_field_add_selection()

static gboolean fl_accessible_text_field_add_selection | ( | AtkText * | text,
|  | gint | start_offset,
|  | gint | end_offset
| ) |  |
| static

Definition at line 431 of file fl_accessible_text_field.cc.

433 {
434 g_return_val_if_fail(FL_IS_ACCESSIBLE_TEXT_FIELD(text), false);
435 FlAccessibleTextField* self = FL_ACCESSIBLE_TEXT_FIELD(text);
436
437 if (self->selection_base != self->selection_extent) {
438 return FALSE;
439 }
440
441 perform_set_selection_action(self, start_offset, end_offset);
442 return TRUE;
443 }
TRUE
return TRUE
Definition: fl_compositor_software.cc:68

References perform_set_selection_action(), and TRUE.

Referenced by fl_accessible_text_iface_init().

## ◆ fl_accessible_text_field_class_init()

static void fl_accessible_text_field_class_init | ( | FlAccessibleTextFieldClass * | klass | ) |
| static

Definition at line 552 of file fl_accessible_text_field.cc.

553 {
554 G_OBJECT_CLASS(klass)->dispose = fl_accessible_text_field_dispose;
555 FL_ACCESSIBLE_NODE_CLASS(klass)->set_value =
556 fl_accessible_text_field_set_value;
557 FL_ACCESSIBLE_NODE_CLASS(klass)->set_text_selection =
558 fl_accessible_text_field_set_text_selection;
559 FL_ACCESSIBLE_NODE_CLASS(klass)->set_text_direction =
560 fl_accessible_text_field_set_text_direction;
561 FL_ACCESSIBLE_NODE_CLASS(klass)->perform_action =
562 fl_accessible_text_field_perform_action;
563 }
fl_accessible_text_field_dispose
static void fl_accessible_text_field_dispose(GObject *object)
Definition: fl_accessible_text_field.cc:215
fl_accessible_text_field_set_text_direction
static void fl_accessible_text_field_set_text_direction(FlAccessibleNode *node, FlutterTextDirection direction)
Definition: fl_accessible_text_field.cc:262
fl_accessible_text_field_set_text_selection
static void fl_accessible_text_field_set_text_selection(FlAccessibleNode *node, gint base, gint extent)
Definition: fl_accessible_text_field.cc:237
fl_accessible_text_field_set_value
static void fl_accessible_text_field_set_value(FlAccessibleNode *node, const gchar *value)
Definition: fl_accessible_text_field.cc:224
fl_accessible_text_field_perform_action
void fl_accessible_text_field_perform_action(FlAccessibleNode *self, FlutterSemanticsAction action, GBytes *data)
Definition: fl_accessible_text_field.cc:272

References fl_accessible_text_field_dispose(), fl_accessible_text_field_perform_action(), fl_accessible_text_field_set_text_direction(), fl_accessible_text_field_set_text_selection(), and fl_accessible_text_field_set_value().

## ◆ fl_accessible_text_field_copy_text()

static void fl_accessible_text_field_copy_text | ( | AtkEditableText * | editable_text,
|  | gint | start_pos,
|  | gint | end_pos
| ) |  |
| static

Definition at line 515 of file fl_accessible_text_field.cc.

517 {
518 g_return_if_fail(FL_IS_ACCESSIBLE_TEXT_FIELD(editable_text));
519 FlAccessibleTextField* self = FL_ACCESSIBLE_TEXT_FIELD(editable_text);
520
521 perform_set_selection_action(self, start_pos, end_pos);
522
523 fl_accessible_node_perform_action(FL_ACCESSIBLE_NODE(editable_text),
524 kFlutterSemanticsActionCopy, nullptr);
525 }
fl_accessible_node_perform_action
void fl_accessible_node_perform_action(FlAccessibleNode *self, FlutterSemanticsAction action, GBytes *data)
Definition: fl_accessible_node.cc:661

References fl_accessible_node_perform_action(), and perform_set_selection_action().

Referenced by fl_accessible_editable_text_iface_init().

## ◆ fl_accessible_text_field_cut_text()

static void fl_accessible_text_field_cut_text | ( | AtkEditableText * | editable_text,
|  | gint | start_pos,
|  | gint | end_pos
| ) |  |
| static

Definition at line 528 of file fl_accessible_text_field.cc.

530 {
531 g_return_if_fail(FL_IS_ACCESSIBLE_TEXT_FIELD(editable_text));
532 FlAccessibleTextField* self = FL_ACCESSIBLE_TEXT_FIELD(editable_text);
533
534 perform_set_selection_action(self, start_pos, end_pos);
535
536 fl_accessible_node_perform_action(FL_ACCESSIBLE_NODE(editable_text),
537 kFlutterSemanticsActionCut, nullptr);
538 }

References fl_accessible_node_perform_action(), and perform_set_selection_action().

Referenced by fl_accessible_editable_text_iface_init().

## ◆ fl_accessible_text_field_dispose()

static void fl_accessible_text_field_dispose | ( | GObject * | object | ) |
| static

Definition at line 215 of file fl_accessible_text_field.cc.

215 {
216 FlAccessibleTextField* self = FL_ACCESSIBLE_TEXT_FIELD(object);
217
218 g_clear_object(&self->buffer);
219
220 G_OBJECT_CLASS(fl_accessible_text_field_parent_class)->dispose(object);
221 }

Referenced by fl_accessible_text_field_class_init().

## ◆ fl_accessible_text_field_get_caret_offset()

static gint fl_accessible_text_field_get_caret_offset | ( | AtkText * | text | ) |
| static

Definition at line 376 of file fl_accessible_text_field.cc.

376 {
377 g_return_val_if_fail(FL_IS_ACCESSIBLE_TEXT_FIELD(text), -1);
378 FlAccessibleTextField* self = FL_ACCESSIBLE_TEXT_FIELD(text);
379
380 return self->selection_extent;
381 }

Referenced by fl_accessible_text_iface_init().

## ◆ fl_accessible_text_field_get_character_count()

static gint fl_accessible_text_field_get_character_count | ( | AtkText * | text | ) |
| static

Definition at line 299 of file fl_accessible_text_field.cc.

299 {
300 g_return_val_if_fail(FL_IS_ACCESSIBLE_TEXT_FIELD(text), 0);
301 FlAccessibleTextField* self = FL_ACCESSIBLE_TEXT_FIELD(text);
302
303 return gtk_entry_buffer_get_length(self->buffer);
304 }

Referenced by fl_accessible_text_iface_init().

## ◆ fl_accessible_text_field_get_n_selections()

static gint fl_accessible_text_field_get_n_selections | ( | AtkText * | text | ) |
| static

Definition at line 394 of file fl_accessible_text_field.cc.

394 {
395 g_return_val_if_fail(FL_IS_ACCESSIBLE_TEXT_FIELD(text), 0);
396 FlAccessibleTextField* self = FL_ACCESSIBLE_TEXT_FIELD(text);
397
398 if (self->selection_base == self->selection_extent) {
399 return 0;
400 }
401
402 return 1;
403 }

Referenced by fl_accessible_text_iface_init().

## ◆ fl_accessible_text_field_get_selection()

static gchar* fl_accessible_text_field_get_selection | ( | AtkText * | text,
|  | gint | selection_num,
|  | gint * | start_offset,
|  | gint * | end_offset
| ) |  |
| static

Definition at line 406 of file fl_accessible_text_field.cc.

409 {
410 g_return_val_if_fail(FL_IS_ACCESSIBLE_TEXT_FIELD(text), nullptr);
411 FlAccessibleTextField* self = FL_ACCESSIBLE_TEXT_FIELD(text);
412
413 if (selection_num != 0 || self->selection_base == self->selection_extent) {
414 return nullptr;
415 }
416
417 gint start = MIN(self->selection_base, self->selection_extent);
418 gint end = MAX(self->selection_base, self->selection_extent);
419
420 if (start_offset != nullptr) {
421 *start_offset = start;
422 }
423 if (end_offset != nullptr) {
424 *end_offset = end;
425 }
426
427 return get_substring(self, start, end);
428 }
start
glong start
Definition: fl_accessible_text_field.cc:39
end
glong glong end
Definition: fl_accessible_text_field.cc:40

References end, and start.

Referenced by fl_accessible_text_iface_init().

## ◆ fl_accessible_text_field_get_string_at_offset()

static gchar* fl_accessible_text_field_get_string_at_offset | ( | AtkText * | text,
|  | gint | offset,
|  | AtkTextGranularity | granularity,
|  | gint * | start_offset,
|  | gint * | end_offset
| ) |  |
| static

Definition at line 317 of file fl_accessible_text_field.cc.

322 {
323 g_return_val_if_fail(FL_IS_ACCESSIBLE_TEXT_FIELD(text), nullptr);
324 FlAccessibleTextField* self = FL_ACCESSIBLE_TEXT_FIELD(text);
325
326 switch (granularity) {
327 case ATK_TEXT_GRANULARITY_CHAR:
328 return get_char_at_offset(self, offset, start_offset, end_offset);
329 case ATK_TEXT_GRANULARITY_WORD:
330 return get_word_at_offset(self, offset, start_offset, end_offset);
331 case ATK_TEXT_GRANULARITY_SENTENCE:
332 return get_sentence_at_offset(self, offset, start_offset, end_offset);
333 case ATK_TEXT_GRANULARITY_LINE:
334 return get_line_at_offset(self, offset, start_offset, end_offset);
335 case ATK_TEXT_GRANULARITY_PARAGRAPH:
336 return get_paragraph_at_offset(self, offset, start_offset, end_offset);
337 default:
338 return nullptr;
339 }
340 }
get_sentence_at_offset
static gchar * get_sentence_at_offset(FlAccessibleTextField *self, gint offset, gint *start_offset, gint *end_offset)
Definition: fl_accessible_text_field.cc:118
get_char_at_offset
static gchar * get_char_at_offset(FlAccessibleTextField *self, gint offset, gint *start_offset, gint *end_offset)
Definition: fl_accessible_text_field.cc:96
get_word_at_offset
static gchar * get_word_at_offset(FlAccessibleTextField *self, gint offset, gint *start_offset, gint *end_offset)
Definition: fl_accessible_text_field.cc:107
get_paragraph_at_offset
static gchar * get_paragraph_at_offset(FlAccessibleTextField *self, gint offset, gint *start_offset, gint *end_offset)
Definition: fl_accessible_text_field.cc:155
get_line_at_offset
static gchar * get_line_at_offset(FlAccessibleTextField *self, gint offset, gint *start_offset, gint *end_offset)
Definition: fl_accessible_text_field.cc:129

References get_char_at_offset(), get_line_at_offset(), get_paragraph_at_offset(), get_sentence_at_offset(), and get_word_at_offset().

Referenced by fl_accessible_text_field_get_text_at_offset(), and fl_accessible_text_iface_init().

## ◆ fl_accessible_text_field_get_text()

static gchar* fl_accessible_text_field_get_text | ( | AtkText * | text,
|  | gint | start_offset,
|  | gint | end_offset
| ) |  |
| static

Definition at line 307 of file fl_accessible_text_field.cc.

309 {
310 g_return_val_if_fail(FL_IS_ACCESSIBLE_TEXT_FIELD(text), nullptr);
311 FlAccessibleTextField* self = FL_ACCESSIBLE_TEXT_FIELD(text);
312
313 return get_substring(self, start_offset, end_offset);
314 }

Referenced by fl_accessible_text_iface_init().

## ◆ fl_accessible_text_field_get_text_at_offset()

static gchar* fl_accessible_text_field_get_text_at_offset | ( | AtkText * | text,
|  | gint | offset,
|  | AtkTextBoundary | boundary_type,
|  | gint * | start_offset,
|  | gint * | end_offset
| ) |  |
| static

Definition at line 343 of file fl_accessible_text_field.cc.

348 {
349 switch (boundary_type) {
350 case ATK_TEXT_BOUNDARY_CHAR:
351 return fl_accessible_text_field_get_string_at_offset(
352 text, offset, ATK_TEXT_GRANULARITY_CHAR, start_offset, end_offset);
353 break;
354 case ATK_TEXT_BOUNDARY_WORD_START:
355 case ATK_TEXT_BOUNDARY_WORD_END:
356 return fl_accessible_text_field_get_string_at_offset(
357 text, offset, ATK_TEXT_GRANULARITY_WORD, start_offset, end_offset);
358 break;
359 case ATK_TEXT_BOUNDARY_SENTENCE_START:
360 case ATK_TEXT_BOUNDARY_SENTENCE_END:
361 return fl_accessible_text_field_get_string_at_offset(
362 text, offset, ATK_TEXT_GRANULARITY_SENTENCE, start_offset,
363 end_offset);
364 break;
365 case ATK_TEXT_BOUNDARY_LINE_START:
366 case ATK_TEXT_BOUNDARY_LINE_END:
367 return fl_accessible_text_field_get_string_at_offset(
368 text, offset, ATK_TEXT_GRANULARITY_LINE, start_offset, end_offset);
369 break;
370 default:
371 return nullptr;
372 }
373 }
fl_accessible_text_field_get_string_at_offset
static gchar * fl_accessible_text_field_get_string_at_offset(AtkText *text, gint offset, AtkTextGranularity granularity, gint *start_offset, gint *end_offset)
Definition: fl_accessible_text_field.cc:317

References fl_accessible_text_field_get_string_at_offset().

Referenced by fl_accessible_text_iface_init().

## ◆ fl_accessible_text_field_init()

static void fl_accessible_text_field_init | ( | FlAccessibleTextField * | self | ) |
| static

Definition at line 592 of file fl_accessible_text_field.cc.

592 {
593 self->selection_base = -1;
594 self->selection_extent = -1;
595
596 self->buffer = gtk_entry_buffer_new("", 0);
597
598 g_signal_connect_object(
599 self->buffer, "inserted-text",
600 G_CALLBACK(+[](FlAccessibleTextField* self, guint position, gchar* chars,
601 guint n_chars) {
602 g_signal_emit_by_name(self, "text-insert", position, n_chars, chars,
603 nullptr);
604 }),
605 self, G_CONNECT_SWAPPED);
606
607 g_signal_connect_object(self->buffer, "deleted-text",
608 G_CALLBACK(+[](FlAccessibleTextField* self,
609 guint position, guint n_chars) {
610 g_autofree gchar* chars = atk_text_get_text(
611 ATK_TEXT(self), position, position + n_chars);
612 g_signal_emit_by_name(self, "text-remove", position,
613 n_chars, chars, nullptr);
614 }),
615 self, G_CONNECT_SWAPPED);
616 }

## ◆ fl_accessible_text_field_insert_text()

static void fl_accessible_text_field_insert_text | ( | AtkEditableText * | editable_text,
|  | const gchar * | string,
|  | gint | length,
|  | gint * | position
| ) |  |
| static

Definition at line 487 of file fl_accessible_text_field.cc.

490 {
491 g_return_if_fail(FL_IS_ACCESSIBLE_TEXT_FIELD(editable_text));
492 FlAccessibleTextField* self = FL_ACCESSIBLE_TEXT_FIELD(editable_text);
493
494 *position +=
495 gtk_entry_buffer_insert_text(self->buffer, *position, string, length);
496
497 perform_set_text_action(self, gtk_entry_buffer_get_text(self->buffer));
498 perform_set_selection_action(self, *position, *position);
499 }
length
size_t length
Definition: fl_standard_message_codec_test.cc:1115

References length, perform_set_selection_action(), and perform_set_text_action().

Referenced by fl_accessible_editable_text_iface_init().

## ◆ fl_accessible_text_field_new()

FlAccessibleNode* fl_accessible_text_field_new | ( | FlEngine * | engine,
|  | FlutterViewId | view_id,
|  | int32_t | id
| ) |  |

fl_accessible_text_field_new: @engine: the #FlEngine this node came from. @view_id: the ID of the view that contains this semantics node. @id: the semantics node ID this object represents.

Creates a new accessibility object that exposes an editable Flutter text field to ATK.

Returns: a new #FlAccessibleNode.

Definition at line 618 of file fl_accessible_text_field.cc.

620 {
621 return FL_ACCESSIBLE_NODE(g_object_new(fl_accessible_text_field_get_type(),
622 "engine", engine, "view-id", view_id,
623 "node-id", id, nullptr));
624 }
view_id
G_BEGIN_DECLS FlutterViewId view_id
Definition: fl_view_accessible.h:49

References view_id.

Referenced by create_node(), and TEST().

## ◆ fl_accessible_text_field_paste_text()

static void fl_accessible_text_field_paste_text | ( | AtkEditableText * | editable_text,
|  | gint | position
| ) |  |
| static

Definition at line 541 of file fl_accessible_text_field.cc.

542 {
543 g_return_if_fail(FL_IS_ACCESSIBLE_TEXT_FIELD(editable_text));
544 FlAccessibleTextField* self = FL_ACCESSIBLE_TEXT_FIELD(editable_text);
545
546 perform_set_selection_action(self, position, position);
547
548 fl_accessible_node_perform_action(FL_ACCESSIBLE_NODE(editable_text),
549 kFlutterSemanticsActionPaste, nullptr);
550 }

References fl_accessible_node_perform_action(), and perform_set_selection_action().

Referenced by fl_accessible_editable_text_iface_init().

## ◆ fl_accessible_text_field_perform_action()

void fl_accessible_text_field_perform_action | ( | FlAccessibleNode * | self,
|  | FlutterSemanticsAction | action,
|  | GBytes * | data
| ) |  |

Definition at line 272 of file fl_accessible_text_field.cc.

274 {
275 FlAccessibleNodeClass* parent_class =
276 FL_ACCESSIBLE_NODE_CLASS(fl_accessible_text_field_parent_class);
277
278 switch (action) {
279 case kFlutterSemanticsActionMoveCursorForwardByCharacter:
280 case kFlutterSemanticsActionMoveCursorBackwardByCharacter:
281 case kFlutterSemanticsActionMoveCursorForwardByWord:
282 case kFlutterSemanticsActionMoveCursorBackwardByWord: {
283 // These actions require a boolean argument that indicates whether the
284 // selection should be extended or collapsed when moving the cursor.
285 g_autoptr(FlValue) extend_selection = fl_value_new_bool(false);
286 g_autoptr(FlStandardMessageCodec) codec = fl_standard_message_codec_new();
287 g_autoptr(GBytes) message = fl_message_codec_encode_message(
288 FL_MESSAGE_CODEC(codec), extend_selection, nullptr);
289 parent_class->perform_action(self, action, message);
290 break;
291 }
292 default:
293 parent_class->perform_action(self, action, data);
294 break;
295 }
296 }
fl_message_codec_encode_message
G_MODULE_EXPORT GBytes * fl_message_codec_encode_message(FlMessageCodec *self, FlValue *message, GError **error)
Definition: fl_message_codec.cc:17
fl_standard_message_codec_new
G_MODULE_EXPORT FlStandardMessageCodec * fl_standard_message_codec_new()
Definition: fl_standard_message_codec.cc:637
fl_value_new_bool
G_MODULE_EXPORT FlValue * fl_value_new_bool(bool value)
Definition: fl_value.cc:255
FlValue
typedefG_BEGIN_DECLS struct _FlValue FlValue
Definition: fl_value.h:42

References fl_message_codec_encode_message(), fl_standard_message_codec_new(), fl_value_new_bool(), and g_autoptr().

Referenced by fl_accessible_text_field_class_init().

## ◆ fl_accessible_text_field_remove_selection()

static gboolean fl_accessible_text_field_remove_selection | ( | AtkText * | text,
|  | gint | selection_num
| ) |  |
| static

Definition at line 446 of file fl_accessible_text_field.cc.

447 {
448 g_return_val_if_fail(FL_IS_ACCESSIBLE_TEXT_FIELD(text), false);
449 FlAccessibleTextField* self = FL_ACCESSIBLE_TEXT_FIELD(text);
450
451 if (selection_num != 0 || self->selection_base == self->selection_extent) {
452 return FALSE;
453 }
454
455 perform_set_selection_action(self, self->selection_extent,
456 self->selection_extent);
457 return TRUE;
458 }

References perform_set_selection_action(), and TRUE.

Referenced by fl_accessible_text_iface_init().

## ◆ fl_accessible_text_field_set_caret_offset()

static gboolean fl_accessible_text_field_set_caret_offset | ( | AtkText * | text,
|  | gint | offset
| ) |  |
| static

Definition at line 384 of file fl_accessible_text_field.cc.

385 {
386 g_return_val_if_fail(FL_IS_ACCESSIBLE_TEXT_FIELD(text), false);
387 FlAccessibleTextField* self = FL_ACCESSIBLE_TEXT_FIELD(text);
388
389 perform_set_selection_action(self, offset, offset);
390 return TRUE;
391 }

References perform_set_selection_action(), and TRUE.

Referenced by fl_accessible_text_iface_init().

## ◆ fl_accessible_text_field_set_selection()

static gboolean fl_accessible_text_field_set_selection | ( | AtkText * | text,
|  | gint | selection_num,
|  | gint | start_offset,
|  | gint | end_offset
| ) |  |
| static

Definition at line 461 of file fl_accessible_text_field.cc.

464 {
465 g_return_val_if_fail(FL_IS_ACCESSIBLE_TEXT_FIELD(text), false);
466 FlAccessibleTextField* self = FL_ACCESSIBLE_TEXT_FIELD(text);
467
468 if (selection_num != 0) {
469 return FALSE;
470 }
471
472 perform_set_selection_action(self, start_offset, end_offset);
473 return TRUE;
474 }

References perform_set_selection_action(), and TRUE.

Referenced by fl_accessible_text_iface_init().

## ◆ fl_accessible_text_field_set_text_contents()

static void fl_accessible_text_field_set_text_contents | ( | AtkEditableText * | editable_text,
|  | const gchar * | string
| ) |  |
| static

Definition at line 477 of file fl_accessible_text_field.cc.

479 {
480 g_return_if_fail(FL_IS_ACCESSIBLE_TEXT_FIELD(editable_text));
481 FlAccessibleTextField* self = FL_ACCESSIBLE_TEXT_FIELD(editable_text);
482
483 perform_set_text_action(self, string);
484 }

References perform_set_text_action().

Referenced by fl_accessible_editable_text_iface_init().

## ◆ fl_accessible_text_field_set_text_direction()

static void fl_accessible_text_field_set_text_direction | ( | FlAccessibleNode * | node,
|  | FlutterTextDirection | direction
| ) |  |
| static

Definition at line 262 of file fl_accessible_text_field.cc.

264 {
265 g_return_if_fail(FL_IS_ACCESSIBLE_TEXT_FIELD(node));
266 FlAccessibleTextField* self = FL_ACCESSIBLE_TEXT_FIELD(node);
267
268 self->text_direction = direction;
269 }

Referenced by fl_accessible_text_field_class_init().

## ◆ fl_accessible_text_field_set_text_selection()

static void fl_accessible_text_field_set_text_selection | ( | FlAccessibleNode * | node,
|  | gint | base,
|  | gint | extent
| ) |  |
| static

Definition at line 237 of file fl_accessible_text_field.cc.

239 {
240 g_return_if_fail(FL_IS_ACCESSIBLE_TEXT_FIELD(node));
241 FlAccessibleTextField* self = FL_ACCESSIBLE_TEXT_FIELD(node);
242
243 gboolean caret_moved = extent != self->selection_extent;
244 gboolean has_selection = base != extent;
245 gboolean had_selection = self->selection_base != self->selection_extent;
246 gboolean selection_changed = (has_selection || had_selection) &&
247 (caret_moved || base != self->selection_base);
248
249 self->selection_base = base;
250 self->selection_extent = extent;
251
252 if (selection_changed) {
253 g_signal_emit_by_name(self, "text-selection-changed", nullptr);
254 }
255
256 if (caret_moved) {
257 g_signal_emit_by_name(self, "text-caret-moved", extent, nullptr);
258 }
259 }

Referenced by fl_accessible_text_field_class_init().

## ◆ fl_accessible_text_field_set_value()

static void fl_accessible_text_field_set_value | ( | FlAccessibleNode * | node,
|  | const gchar * | value
| ) |  |
| static

Definition at line 224 of file fl_accessible_text_field.cc.

225 {
226 g_return_if_fail(FL_IS_ACCESSIBLE_TEXT_FIELD(node));
227 FlAccessibleTextField* self = FL_ACCESSIBLE_TEXT_FIELD(node);
228
229 if (g_strcmp0(gtk_entry_buffer_get_text(self->buffer), value) == 0) {
230 return;
231 }
232
233 gtk_entry_buffer_set_text(self->buffer, value, -1);
234 }
value
uint8_t value
Definition: fl_standard_message_codec.cc:36

References value.

Referenced by fl_accessible_text_field_class_init().

## ◆ fl_accessible_text_iface_init()

static void fl_accessible_text_iface_init | ( | AtkTextIface * | iface | ) |
| static

Definition at line 565 of file fl_accessible_text_field.cc.

565 {
566 iface->get_character_count = fl_accessible_text_field_get_character_count;
567 iface->get_text = fl_accessible_text_field_get_text;
568 iface->get_text_at_offset = fl_accessible_text_field_get_text_at_offset;
569 iface->get_string_at_offset = fl_accessible_text_field_get_string_at_offset;
570
571 iface->get_caret_offset = fl_accessible_text_field_get_caret_offset;
572 iface->set_caret_offset = fl_accessible_text_field_set_caret_offset;
573
574 iface->get_n_selections = fl_accessible_text_field_get_n_selections;
575 iface->get_selection = fl_accessible_text_field_get_selection;
576 iface->add_selection = fl_accessible_text_field_add_selection;
577 iface->remove_selection = fl_accessible_text_field_remove_selection;
578 iface->set_selection = fl_accessible_text_field_set_selection;
579 }
fl_accessible_text_field_get_n_selections
static gint fl_accessible_text_field_get_n_selections(AtkText *text)
Definition: fl_accessible_text_field.cc:394
fl_accessible_text_field_set_selection
static gboolean fl_accessible_text_field_set_selection(AtkText *text, gint selection_num, gint start_offset, gint end_offset)
Definition: fl_accessible_text_field.cc:461
fl_accessible_text_field_get_text_at_offset
static gchar * fl_accessible_text_field_get_text_at_offset(AtkText *text, gint offset, AtkTextBoundary boundary_type, gint *start_offset, gint *end_offset)
Definition: fl_accessible_text_field.cc:343
fl_accessible_text_field_remove_selection
static gboolean fl_accessible_text_field_remove_selection(AtkText *text, gint selection_num)
Definition: fl_accessible_text_field.cc:446
fl_accessible_text_field_get_selection
static gchar * fl_accessible_text_field_get_selection(AtkText *text, gint selection_num, gint *start_offset, gint *end_offset)
Definition: fl_accessible_text_field.cc:406
fl_accessible_text_field_set_caret_offset
static gboolean fl_accessible_text_field_set_caret_offset(AtkText *text, gint offset)
Definition: fl_accessible_text_field.cc:384
fl_accessible_text_field_add_selection
static gboolean fl_accessible_text_field_add_selection(AtkText *text, gint start_offset, gint end_offset)
Definition: fl_accessible_text_field.cc:431
fl_accessible_text_field_get_character_count
static gint fl_accessible_text_field_get_character_count(AtkText *text)
Definition: fl_accessible_text_field.cc:299
fl_accessible_text_field_get_text
static gchar * fl_accessible_text_field_get_text(AtkText *text, gint start_offset, gint end_offset)
Definition: fl_accessible_text_field.cc:307
fl_accessible_text_field_get_caret_offset
static gint fl_accessible_text_field_get_caret_offset(AtkText *text)
Definition: fl_accessible_text_field.cc:376

References fl_accessible_text_field_add_selection(), fl_accessible_text_field_get_caret_offset(), fl_accessible_text_field_get_character_count(), fl_accessible_text_field_get_n_selections(), fl_accessible_text_field_get_selection(), fl_accessible_text_field_get_string_at_offset(), fl_accessible_text_field_get_text(), fl_accessible_text_field_get_text_at_offset(), fl_accessible_text_field_remove_selection(), fl_accessible_text_field_set_caret_offset(), and fl_accessible_text_field_set_selection().

## ◆ G_DEFINE_TYPE_WITH_CODE()

G_DEFINE_TYPE_WITH_CODE | ( | FlAccessibleTextField | ,
|  | fl_accessible_text_field | ,
|  | fl_accessible_node_get_type() | ,
|  | G_IMPLEMENT_INTERFACE(ATK_TYPE_EDITABLE_TEXT, fl_accessible_editable_text_iface_init) |
| ) |  |

## ◆ g_utf8_substring()

return g_utf8_substring | ( | value | ,
|  | start | ,
|  | end |
| ) |  |

## ◆ get_char_at_offset()

static gchar* get_char_at_offset | ( | FlAccessibleTextField * | self,
|  | gint | offset,
|  | gint * | start_offset,
|  | gint * | end_offset
| ) |  |
| static

Definition at line 96 of file fl_accessible_text_field.cc.

99 {
100 return get_string_at_offset(
101 self, offset, offset + 1,
102 [](const PangoLogAttr* attr) -> bool { return attr->is_char_break; },
103 [](const PangoLogAttr* attr) -> bool { return attr->is_char_break; },
104 start_offset, end_offset);
105 }
get_string_at_offset
static gchar * get_string_at_offset(FlAccessibleTextField *self, gint start, gint end, FlTextBoundaryCallback is_start, FlTextBoundaryCallback is_end, gint *start_offset, gint *end_offset)
Definition: fl_accessible_text_field.cc:66

References get_string_at_offset().

Referenced by fl_accessible_text_field_get_string_at_offset().

## ◆ get_line_at_offset()

static gchar* get_line_at_offset | ( | FlAccessibleTextField * | self,
|  | gint | offset,
|  | gint * | start_offset,
|  | gint * | end_offset
| ) |  |
| static

Definition at line 129 of file fl_accessible_text_field.cc.

132 {
133 g_autoptr(PangoLayout) layout = create_pango_layout(self);
134
135 GSList* lines = pango_layout_get_lines_readonly(layout);
136 while (lines != nullptr) {
137 PangoLayoutLine* line = static_cast<PangoLayoutLine*>(lines->data);
138 if (offset >= line->start_index &&
139 offset <= line->start_index + line->length) {
140 if (start_offset != nullptr) {
141 *start_offset = line->start_index;
142 }
143 if (end_offset != nullptr) {
144 *end_offset = line->start_index + line->length;
145 }
146 return get_substring(self, line->start_index,
147 line->start_index + line->length);
148 }
149 lines = lines->next;
150 }
151
152 return nullptr;
153 }
create_pango_layout
static PangoLayout * create_pango_layout(FlAccessibleTextField *self)
Definition: fl_accessible_text_field.cc:59

References create_pango_layout(), and g_autoptr().

Referenced by fl_accessible_text_field_get_string_at_offset().

## ◆ get_pango_context()

static PangoContext* get_pango_context | ( | FlAccessibleTextField * | self | ) |
| static

Definition at line 49 of file fl_accessible_text_field.cc.

49 {
50 PangoFontMap* font_map = pango_cairo_font_map_get_default();
51 PangoContext* context = pango_font_map_create_context(font_map);
52 pango_context_set_base_dir(context,
53 self->text_direction == kFlutterTextDirectionRTL
54 ? PANGO_DIRECTION_RTL
55 : PANGO_DIRECTION_LTR);
56 return context;
57 }

Referenced by create_pango_layout().

## ◆ get_paragraph_at_offset()

static gchar* get_paragraph_at_offset | ( | FlAccessibleTextField * | self,
|  | gint | offset,
|  | gint * | start_offset,
|  | gint * | end_offset
| ) |  |
| static

Definition at line 155 of file fl_accessible_text_field.cc.

158 {
159 g_autoptr(PangoLayout) layout = create_pango_layout(self);
160
161 PangoLayoutLine* start = nullptr;
162 PangoLayoutLine* end = nullptr;
163 gint n_lines = pango_layout_get_line_count(layout);
164 for (gint i = 0; i < n_lines; ++i) {
165 PangoLayoutLine* line = pango_layout_get_line(layout, i);
166 if (line->is_paragraph_start) {
167 end = line;
168 }
169 if (start != nullptr && end != nullptr && offset >= start->start_index &&
170 offset <= end->start_index + end->length) {
171 if (start_offset != nullptr) {
172 *start_offset = start->start_index;
173 }
174 if (end_offset != nullptr) {
175 *end_offset = end->start_index + end->length;
176 }
177 return get_substring(self, start->start_index,
178 end->start_index + end->length);
179 }
180 if (line->is_paragraph_start) {
181 start = line;
182 }
183 }
184
185 return nullptr;
186 }
i
int i
Definition: fl_socket_accessible.cc:18

References create_pango_layout(), end, g_autoptr(), i, and start.

Referenced by fl_accessible_text_field_get_string_at_offset().

## ◆ get_sentence_at_offset()

static gchar* get_sentence_at_offset | ( | FlAccessibleTextField * | self,
|  | gint | offset,
|  | gint * | start_offset,
|  | gint * | end_offset
| ) |  |
| static

Definition at line 118 of file fl_accessible_text_field.cc.

121 {
122 return get_string_at_offset(
123 self, offset, offset,
124 [](const PangoLogAttr* attr) -> bool { return attr->is_sentence_start; },
125 [](const PangoLogAttr* attr) -> bool { return attr->is_sentence_end; },
126 start_offset, end_offset);
127 }

References get_string_at_offset().

Referenced by fl_accessible_text_field_get_string_at_offset().

## ◆ get_string_at_offset()

static gchar* get_string_at_offset | ( | FlAccessibleTextField * | self,
|  | gint | start,
|  | gint | end,
|  | FlTextBoundaryCallback | is_start,
|  | FlTextBoundaryCallback | is_end,
|  | gint * | start_offset,
|  | gint * | end_offset
| ) |  |
| static

Definition at line 66 of file fl_accessible_text_field.cc.

72 {
73 g_autoptr(PangoLayout) layout = create_pango_layout(self);
74
75 gint n_attrs = 0;
76 const PangoLogAttr* attrs =
77 pango_layout_get_log_attrs_readonly(layout, &n_attrs);
78
79 while (start > 0 && !is_start(&attrs[start])) {
80 --start;
81 }
82 if (start_offset != nullptr) {
83 *start_offset = start;
84 }
85
86 while (end < n_attrs && !is_end(&attrs[end])) {
87 ++end;
88 }
89 if (end_offset != nullptr) {
90 *end_offset = end;
91 }
92
93 return get_substring(self, start, end);
94 }

References create_pango_layout(), end, g_autoptr(), and start.

Referenced by get_char_at_offset(), get_sentence_at_offset(), and get_word_at_offset().

## ◆ get_word_at_offset()

static gchar* get_word_at_offset | ( | FlAccessibleTextField * | self,
|  | gint | offset,
|  | gint * | start_offset,
|  | gint * | end_offset
| ) |  |
| static

Definition at line 107 of file fl_accessible_text_field.cc.

110 {
111 return get_string_at_offset(
112 self, offset, offset,
113 [](const PangoLogAttr* attr) -> bool { return attr->is_word_start; },
114 [](const PangoLogAttr* attr) -> bool { return attr->is_word_end; },
115 start_offset, end_offset);
116 }

References get_string_at_offset().

Referenced by fl_accessible_text_field_get_string_at_offset().

## ◆ if()

if | ( | end | = `= -1` | ) |

Definition at line 42 of file fl_accessible_text_field.cc.

42 {
43 // g_utf8_substring() accepts -1 since 2.72
44 end = g_utf8_strlen(value, -1);
45 }

References end, and value.

Referenced by fl_keyboard_manager_init(), and handle_key_event().

## ◆ perform_set_selection_action()

static void perform_set_selection_action | ( | FlAccessibleTextField * | self,
|  | gint | base,
|  | gint | extent
| ) |  |
| static

Definition at line 199 of file fl_accessible_text_field.cc.

201 {
202 g_autoptr(FlValue) value = fl_value_new_map();
203 fl_value_set_string_take(value, "base", fl_value_new_int(base));
204 fl_value_set_string_take(value, "extent", fl_value_new_int(extent));
205
206 g_autoptr(FlStandardMessageCodec) codec = fl_standard_message_codec_new();
207 g_autoptr(GBytes) message =
208 fl_message_codec_encode_message(FL_MESSAGE_CODEC(codec), value, nullptr);
209
210 fl_accessible_node_perform_action(
211 FL_ACCESSIBLE_NODE(self), kFlutterSemanticsActionSetSelection, message);
212 }
fl_value_set_string_take
G_MODULE_EXPORT void fl_value_set_string_take(FlValue *self, const gchar *key, FlValue *value)
Definition: fl_value.cc:650
fl_value_new_int
G_MODULE_EXPORT FlValue * fl_value_new_int(int64_t value)
Definition: fl_value.cc:262
fl_value_new_map
G_MODULE_EXPORT FlValue * fl_value_new_map()
Definition: fl_value.cc:366

References fl_accessible_node_perform_action(), fl_message_codec_encode_message(), fl_standard_message_codec_new(), fl_value_new_int(), fl_value_new_map(), fl_value_set_string_take(), g_autoptr(), and value.

Referenced by fl_accessible_node_delete_text(), fl_accessible_text_field_add_selection(), fl_accessible_text_field_copy_text(), fl_accessible_text_field_cut_text(), fl_accessible_text_field_insert_text(), fl_accessible_text_field_paste_text(), fl_accessible_text_field_remove_selection(), fl_accessible_text_field_set_caret_offset(), and fl_accessible_text_field_set_selection().

## ◆ perform_set_text_action()

static void perform_set_text_action | ( | FlAccessibleTextField * | self,
|  | const char * | text
| ) |  |
| static

Definition at line 188 of file fl_accessible_text_field.cc.

189 {
190 g_autoptr(FlValue) value = fl_value_new_string(text);
191 g_autoptr(FlStandardMessageCodec) codec = fl_standard_message_codec_new();
192 g_autoptr(GBytes) message =
193 fl_message_codec_encode_message(FL_MESSAGE_CODEC(codec), value, nullptr);
194
195 fl_accessible_node_perform_action(FL_ACCESSIBLE_NODE(self),
196 kFlutterSemanticsActionSetText, message);
197 }
fl_value_new_string
G_MODULE_EXPORT FlValue * fl_value_new_string(const gchar *value)
Definition: fl_value.cc:276

References fl_accessible_node_perform_action(), fl_message_codec_encode_message(), fl_standard_message_codec_new(), fl_value_new_string(), g_autoptr(), and value.

Referenced by fl_accessible_node_delete_text(), fl_accessible_text_field_insert_text(), and fl_accessible_text_field_set_text_contents().

## Variable Documentation

## ◆ end

glong glong end

Initial value:
{
const gchar* value = gtk_entry_buffer_get_text(self->buffer)

Definition at line 40 of file fl_accessible_text_field.cc.

Referenced by flutter::TextInputModel::Delete(), flutter::TextInputModel::DeleteSurrounding(), fl_accessible_text_field_get_selection(), get_paragraph_at_offset(), get_string_at_offset(), if(), flutter::TextInputModel::MoveCursorForward(), and TEST().

## ◆ start

glong start

Definition at line 39 of file fl_accessible_text_field.cc.

Referenced by flutter::TextInputModel::Backspace(), flutter::TextInputModel::DeleteSurrounding(), fl_accessible_text_field_get_selection(), get_paragraph_at_offset(), get_string_at_offset(), flutter::TextInputModel::MoveCursorBack(), and TEST().