Skip to content
This repository was archived by the owner on Feb 25, 2025. It is now read-only.
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 9 additions & 0 deletions shell/platform/common/text_range.h
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,15 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

#ifndef FLUTTER_SHELL_PLATFORM_COMMON_TEXT_RANGE_H_
#define FLUTTER_SHELL_PLATFORM_COMMON_TEXT_RANGE_H_

#include <algorithm>

#include "flutter/fml/logging.h"

namespace flutter {

// A directional range of text.
//
// A |TextRange| describes a range of text with |base| and |extent| positions.
Expand Down Expand Up @@ -92,3 +97,7 @@ class TextRange {
size_t base_;
size_t extent_;
};

} // namespace flutter

#endif // FLUTTER_SHELL_PLATFORM_COMMON_TEXT_RANGE_H_
10 changes: 6 additions & 4 deletions shell/platform/linux/fl_text_input_plugin.cc
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,7 @@ static void update_editing_state(FlTextInputPlugin* self) {
fl_value_append_take(args, fl_value_new_int(priv->client_id));
g_autoptr(FlValue) value = fl_value_new_map();

TextRange selection = priv->text_model->selection();
flutter::TextRange selection = priv->text_model->selection();
fl_value_set_string_take(
value, kTextKey,
fl_value_new_string(priv->text_model->GetText().c_str()));
Expand Down Expand Up @@ -195,7 +195,8 @@ static void im_preedit_changed_cb(FlTextInputPlugin* self) {
&cursor_offset);
cursor_offset += priv->text_model->composing_range().base();
priv->text_model->UpdateComposingText(buf);
priv->text_model->SetSelection(TextRange(cursor_offset, cursor_offset));
priv->text_model->SetSelection(
flutter::TextRange(cursor_offset, cursor_offset));

update_editing_state(self);
}
Expand Down Expand Up @@ -311,7 +312,8 @@ static FlMethodResponse* set_editing_state(FlTextInputPlugin* self,
}

priv->text_model->SetText(text);
priv->text_model->SetSelection(TextRange(selection_base, selection_extent));
priv->text_model->SetSelection(
flutter::TextRange(selection_base, selection_extent));

int64_t composing_base =
fl_value_get_int(fl_value_lookup_string(args, kComposingBaseKey));
Expand All @@ -323,7 +325,7 @@ static FlMethodResponse* set_editing_state(FlTextInputPlugin* self,
size_t composing_start = std::min(composing_base, composing_extent);
size_t cursor_offset = selection_base - composing_start;
priv->text_model->SetComposingRange(
TextRange(composing_base, composing_extent), cursor_offset);
flutter::TextRange(composing_base, composing_extent), cursor_offset);
}

return FL_METHOD_RESPONSE(fl_method_success_response_new(nullptr));
Expand Down