Flutter Engine
 
Loading...
Searching...
No Matches
fl_text_input_channel.h File Reference

Go to the source code of this file.

Classes

struct  FlTextInputChannelVTable
 

Enumerations

enum  FlTextInputType {
  FL_TEXT_INPUT_TYPE_TEXT ,
  FL_TEXT_INPUT_TYPE_MULTILINE ,
  FL_TEXT_INPUT_TYPE_NONE
}
 
enum  FlTextAffinity {
  FL_TEXT_AFFINITY_UPSTREAM ,
  FL_TEXT_AFFINITY_DOWNSTREAM
}
 

Functions

 G_DECLARE_FINAL_TYPE (FlTextInputChannel, fl_text_input_channel, FL, TEXT_INPUT_CHANNEL, GObject)
 
FlTextInputChannel * fl_text_input_channel_new (FlBinaryMessenger *messenger, FlTextInputChannelVTable *vtable, gpointer user_data)
 
void fl_text_input_channel_update_editing_state (FlTextInputChannel *channel, int64_t client_id, const gchar *text, int64_t selection_base, int64_t selection_extent, FlTextAffinity selection_affinity, gboolean selection_is_directional, int64_t composing_base, int64_t composing_extent, GCancellable *cancellable, GAsyncReadyCallback callback, gpointer user_data)
 
gboolean fl_text_input_channel_update_editing_state_finish (GObject *object, GAsyncResult *result, GError **error)
 
void fl_text_input_channel_update_editing_state_with_deltas (FlTextInputChannel *channel, int64_t client_id, const gchar *old_text, const gchar *delta_text, int64_t delta_start, int64_t delta_end, int64_t selection_base, int64_t selection_extent, FlTextAffinity selection_affinity, gboolean selection_is_directional, int64_t composing_base, int64_t composing_extent, GCancellable *cancellable, GAsyncReadyCallback callback, gpointer user_data)
 
gboolean fl_text_input_channel_update_editing_state_with_deltas_finish (GObject *object, GAsyncResult *result, GError **error)
 
void fl_text_input_channel_perform_action (FlTextInputChannel *channel, int64_t client_id, const gchar *input_action, GCancellable *cancellable, GAsyncReadyCallback callback, gpointer user_data)
 
gboolean fl_text_input_channel_perform_action_finish (GObject *object, GAsyncResult *result, GError **error)
 

Enumeration Type Documentation

◆ FlTextAffinity

Enumerator
FL_TEXT_AFFINITY_UPSTREAM 
FL_TEXT_AFFINITY_DOWNSTREAM 

Definition at line 22 of file fl_text_input_channel.h.

◆ FlTextInputType

Enumerator
FL_TEXT_INPUT_TYPE_TEXT 
FL_TEXT_INPUT_TYPE_MULTILINE 
FL_TEXT_INPUT_TYPE_NONE 

Definition at line 14 of file fl_text_input_channel.h.

14 {
16 // Send newline when multi-line and enter is pressed.
18 // The input method is not shown at all.
@ FL_TEXT_INPUT_TYPE_MULTILINE
@ FL_TEXT_INPUT_TYPE_TEXT
@ FL_TEXT_INPUT_TYPE_NONE

Function Documentation

◆ fl_text_input_channel_new()

FlTextInputChannel * fl_text_input_channel_new ( FlBinaryMessenger *  messenger,
FlTextInputChannelVTable vtable,
gpointer  user_data 
)

fl_text_input_channel_new: @messenger: an #FlBinaryMessenger. @vtable: callbacks for incoming method calls. @user_data: data to pass in callbacks.

Creates a new channel that implements SystemChannels.textInput from the Flutter services library.

Returns: a new #FlTextInputChannel.

Definition at line 245 of file fl_text_input_channel.cc.

247 {
248 g_return_val_if_fail(FL_IS_BINARY_MESSENGER(messenger), nullptr);
249 g_return_val_if_fail(vtable != nullptr, nullptr);
250
251 FlTextInputChannel* self = FL_TEXT_INPUT_CHANNEL(
252 g_object_new(fl_text_input_channel_get_type(), nullptr));
253
254 self->vtable = vtable;
255 self->user_data = user_data;
256
257 g_autoptr(FlJsonMethodCodec) codec = fl_json_method_codec_new();
258 self->channel =
259 fl_method_channel_new(messenger, kChannelName, FL_METHOD_CODEC(codec));
261 nullptr);
262
263 return self;
264}
g_autoptr(GMutexLocker) locker
G_MODULE_EXPORT FlJsonMethodCodec * fl_json_method_codec_new()
G_MODULE_EXPORT FlMethodChannel * fl_method_channel_new(FlBinaryMessenger *messenger, const gchar *name, FlMethodCodec *codec)
G_MODULE_EXPORT void fl_method_channel_set_method_call_handler(FlMethodChannel *self, FlMethodChannelMethodCallHandler handler, gpointer user_data, GDestroyNotify destroy_notify)
static void method_call_cb(FlMethodChannel *channel, FlMethodCall *method_call, gpointer user_data)
static constexpr char kChannelName[]

References fl_json_method_codec_new(), fl_method_channel_new(), fl_method_channel_set_method_call_handler(), g_autoptr(), kChannelName, method_call_cb(), self, and user_data.

Referenced by fl_text_input_handler_new().

◆ fl_text_input_channel_perform_action()

void fl_text_input_channel_perform_action ( FlTextInputChannel *  channel,
int64_t  client_id,
const gchar *  input_action,
GCancellable *  cancellable,
GAsyncReadyCallback  callback,
gpointer  user_data 
)

fl_text_input_channel_perform_action: @channel: an #FlTextInputChannel. @client_id: @input_action: action to perform. @cancellable: (allow-none): a #GCancellable or NULL. @callback: (scope async): a #GAsyncReadyCallback to call when the method returns. @user_data: (closure): user data to pass to @callback.

Definition at line 384 of file fl_text_input_channel.cc.

389 {
390 g_return_if_fail(FL_IS_TEXT_INPUT_CHANNEL(self));
391
395
397 cancellable, callback, user_data);
398}
G_BEGIN_DECLS G_MODULE_EXPORT FlValue * args
G_MODULE_EXPORT void fl_method_channel_invoke_method(FlMethodChannel *self, const gchar *method, FlValue *args, GCancellable *cancellable, GAsyncReadyCallback callback, gpointer user_data)
static constexpr char kPerformActionMethod[]
G_MODULE_EXPORT FlValue * fl_value_new_string(const gchar *value)
Definition fl_value.cc:276
G_MODULE_EXPORT FlValue * fl_value_new_int(int64_t value)
Definition fl_value.cc:262
G_MODULE_EXPORT void fl_value_append_take(FlValue *self, FlValue *value)
Definition fl_value.cc:600
G_MODULE_EXPORT FlValue * fl_value_new_list()
Definition fl_value.cc:349
typedefG_BEGIN_DECLS struct _FlValue FlValue
Definition fl_value.h:42
FlutterDesktopBinaryReply callback

References args, callback, fl_method_channel_invoke_method(), fl_value_append_take(), fl_value_new_int(), fl_value_new_list(), fl_value_new_string(), g_autoptr(), kPerformActionMethod, self, and user_data.

Referenced by perform_action().

◆ fl_text_input_channel_perform_action_finish()

gboolean fl_text_input_channel_perform_action_finish ( GObject *  object,
GAsyncResult *  result,
GError **  error 
)

fl_text_input_channel_perform_action_finish: @object:

Returns
: a #GAsyncResult. @error: (allow-none): #GError location to store the error occurring, or NULL to ignore.

Completes request started with fl_text_input_channel_perform_action().

Returns: TRUE on success.

Definition at line 400 of file fl_text_input_channel.cc.

402 {
403 g_autoptr(FlMethodResponse) response = fl_method_channel_invoke_method_finish(
404 FL_METHOD_CHANNEL(object), result, error);
405 if (response == nullptr) {
406 return FALSE;
407 }
408 return fl_method_response_get_result(response, error) != nullptr;
409}
G_MODULE_EXPORT FlMethodResponse * fl_method_channel_invoke_method_finish(FlMethodChannel *self, GAsyncResult *result, GError **error)
G_MODULE_EXPORT FlValue * fl_method_response_get_result(FlMethodResponse *self, GError **error)
const uint8_t uint32_t uint32_t GError ** error

References error, fl_method_channel_invoke_method_finish(), fl_method_response_get_result(), and g_autoptr().

Referenced by perform_action_response_cb().

◆ fl_text_input_channel_update_editing_state()

void fl_text_input_channel_update_editing_state ( FlTextInputChannel *  channel,
int64_t  client_id,
const gchar *  text,
int64_t  selection_base,
int64_t  selection_extent,
FlTextAffinity  selection_affinity,
gboolean  selection_is_directional,
int64_t  composing_base,
int64_t  composing_extent,
GCancellable *  cancellable,
GAsyncReadyCallback  callback,
gpointer  user_data 
)

fl_text_input_channel_update_editing_state: @channel: an #FlTextInputChannel. @client_id: @text: @selection_base: @selection_extent: @selection_affinity: @selection_is_directional: @composing_base: @composing_extent: @cancellable: (allow-none): a #GCancellable or NULL. @callback: (scope async): a #GAsyncReadyCallback to call when the method returns. @user_data: (closure): user data to pass to @callback.

Definition at line 266 of file fl_text_input_channel.cc.

278 {
279 g_return_if_fail(FL_IS_TEXT_INPUT_CHANNEL(self));
280
284
287 fl_value_new_int(selection_base));
289 fl_value_new_int(selection_extent));
292 fl_value_new_string(text_affinity_to_string(selection_affinity)));
294 fl_value_new_bool(selection_is_directional));
296 fl_value_new_int(composing_base));
298 fl_value_new_int(composing_extent));
299
300 fl_value_append(args, value);
301
303 args, cancellable, callback, user_data);
304}
int32_t value
static constexpr char kSelectionIsDirectionalKey[]
static constexpr char kSelectionExtentKey[]
static constexpr char kUpdateEditingStateMethod[]
static constexpr char kComposingExtentKey[]
static constexpr char kComposingBaseKey[]
static const gchar * text_affinity_to_string(FlTextAffinity affinity)
static constexpr char kSelectionAffinityKey[]
static constexpr char kTextKey[]
static constexpr char kSelectionBaseKey[]
G_MODULE_EXPORT FlValue * fl_value_new_map()
Definition fl_value.cc:366
G_MODULE_EXPORT void fl_value_set_string_take(FlValue *self, const gchar *key, FlValue *value)
Definition fl_value.cc:650
G_MODULE_EXPORT void fl_value_append(FlValue *self, FlValue *value)
Definition fl_value.cc:592
G_MODULE_EXPORT FlValue * fl_value_new_bool(bool value)
Definition fl_value.cc:255
std::u16string text

References args, callback, fl_method_channel_invoke_method(), fl_value_append(), fl_value_append_take(), fl_value_new_bool(), fl_value_new_int(), fl_value_new_list(), fl_value_new_map(), fl_value_new_string(), fl_value_set_string_take(), g_autoptr(), kComposingBaseKey, kComposingExtentKey, kSelectionAffinityKey, kSelectionBaseKey, kSelectionExtentKey, kSelectionIsDirectionalKey, kTextKey, kUpdateEditingStateMethod, self, text, text_affinity_to_string(), user_data, and value.

Referenced by update_editing_state().

◆ fl_text_input_channel_update_editing_state_finish()

gboolean fl_text_input_channel_update_editing_state_finish ( GObject *  object,
GAsyncResult *  result,
GError **  error 
)

fl_text_input_channel_update_editing_state_finish: @object:

Returns
: a #GAsyncResult. @error: (allow-none): #GError location to store the error occurring, or NULL to ignore.

Completes request started with fl_text_input_channel_update_editing_state().

Returns: TRUE on success.

Definition at line 306 of file fl_text_input_channel.cc.

308 {
309 g_autoptr(FlMethodResponse) response = fl_method_channel_invoke_method_finish(
310 FL_METHOD_CHANNEL(object), result, error);
311 if (response == nullptr) {
312 return FALSE;
313 }
314 return fl_method_response_get_result(response, error) != nullptr;
315}

References error, fl_method_channel_invoke_method_finish(), fl_method_response_get_result(), and g_autoptr().

Referenced by update_editing_state_response_cb().

◆ fl_text_input_channel_update_editing_state_with_deltas()

void fl_text_input_channel_update_editing_state_with_deltas ( FlTextInputChannel *  channel,
int64_t  client_id,
const gchar *  old_text,
const gchar *  delta_text,
int64_t  delta_start,
int64_t  delta_end,
int64_t  selection_base,
int64_t  selection_extent,
FlTextAffinity  selection_affinity,
gboolean  selection_is_directional,
int64_t  composing_base,
int64_t  composing_extent,
GCancellable *  cancellable,
GAsyncReadyCallback  callback,
gpointer  user_data 
)

fl_text_input_channel_update_editing_state_with_deltas: @channel: an #FlTextInputChannel. @client_id: @old_text: @delta_text: @delta_start: @delta_end: @selection_base: @selection_extent: @selection_affinity: @selection_is_directional: @composing_base: @composing_extent: @cancellable: (allow-none): a #GCancellable or NULL. @callback: (scope async): a #GAsyncReadyCallback to call when the method returns. @user_data: (closure): user data to pass to @callback.

Definition at line 317 of file fl_text_input_channel.cc.

332 {
333 g_return_if_fail(FL_IS_TEXT_INPUT_CHANNEL(self));
334
337
338 g_autoptr(FlValue) deltaValue = fl_value_new_map();
339 fl_value_set_string_take(deltaValue, "oldText",
340 fl_value_new_string(old_text));
341 fl_value_set_string_take(deltaValue, "deltaText",
342 fl_value_new_string(delta_text));
343 fl_value_set_string_take(deltaValue, "deltaStart",
344 fl_value_new_int(delta_start));
345 fl_value_set_string_take(deltaValue, "deltaEnd", fl_value_new_int(delta_end));
346 fl_value_set_string_take(deltaValue, "selectionBase",
347 fl_value_new_int(selection_base));
348 fl_value_set_string_take(deltaValue, "selectionExtent",
349 fl_value_new_int(selection_extent));
351 deltaValue, "selectionAffinity",
352 fl_value_new_string(text_affinity_to_string(selection_affinity)));
353 fl_value_set_string_take(deltaValue, "selectionIsDirectional",
354 fl_value_new_bool(selection_is_directional));
355 fl_value_set_string_take(deltaValue, "composingBase",
356 fl_value_new_int(composing_base));
357 fl_value_set_string_take(deltaValue, "composingExtent",
358 fl_value_new_int(composing_extent));
359
361 fl_value_append(deltas, deltaValue);
363 fl_value_set_string(value, "deltas", deltas);
364
365 fl_value_append(args, value);
366
369 cancellable, callback, user_data);
370}
static constexpr char kUpdateEditingStateWithDeltasMethod[]
G_MODULE_EXPORT void fl_value_set_string(FlValue *self, const gchar *key, FlValue *value)
Definition fl_value.cc:639

References args, callback, fl_method_channel_invoke_method(), fl_value_append(), fl_value_append_take(), fl_value_new_bool(), fl_value_new_int(), fl_value_new_list(), fl_value_new_map(), fl_value_new_string(), fl_value_set_string(), fl_value_set_string_take(), g_autoptr(), kUpdateEditingStateWithDeltasMethod, self, text_affinity_to_string(), user_data, and value.

Referenced by update_editing_state_with_delta().

◆ fl_text_input_channel_update_editing_state_with_deltas_finish()

gboolean fl_text_input_channel_update_editing_state_with_deltas_finish ( GObject *  object,
GAsyncResult *  result,
GError **  error 
)

fl_text_input_channel_update_editing_state_with_deltas_finish: @object:

Returns
: a #GAsyncResult. @error: (allow-none): #GError location to store the error occurring, or NULL to ignore.

Completes request started with fl_text_input_channel_update_editing_state_with_deltas().

Returns: TRUE on success.

Definition at line 372 of file fl_text_input_channel.cc.

375 {
376 g_autoptr(FlMethodResponse) response = fl_method_channel_invoke_method_finish(
377 FL_METHOD_CHANNEL(object), result, error);
378 if (response == nullptr) {
379 return FALSE;
380 }
381 return fl_method_response_get_result(response, error) != nullptr;
382}

References error, fl_method_channel_invoke_method_finish(), fl_method_response_get_result(), and g_autoptr().

Referenced by update_editing_state_with_deltas_response_cb().

◆ G_DECLARE_FINAL_TYPE()

G_DECLARE_FINAL_TYPE ( FlTextInputChannel  ,
fl_text_input_channel  ,
FL  ,
TEXT_INPUT_CHANNEL  ,
GObject   
)