diff options
Diffstat (limited to 'include/cru/platform')
-rw-r--r-- | include/cru/platform/graph_base.hpp | 28 | ||||
-rw-r--r-- | include/cru/platform/native/input_method.hpp | 9 |
2 files changed, 14 insertions, 23 deletions
diff --git a/include/cru/platform/graph_base.hpp b/include/cru/platform/graph_base.hpp index 5840ce18..98ac3993 100644 --- a/include/cru/platform/graph_base.hpp +++ b/include/cru/platform/graph_base.hpp @@ -1,5 +1,5 @@ #pragma once -#include "cru/common/pre_config.hpp" +#include "cru/common/base.hpp" #include <cstdint> #include <optional> @@ -214,30 +214,18 @@ constexpr bool operator!=(const Ellipse& left, const Ellipse& right) { } struct TextRange final { - constexpr static std::optional<TextRange> FromTwoSides(unsigned first, - unsigned second) { - if (first > second) - return std::make_optional<TextRange>(second, first - second); - if (first < second) - return std::make_optional<TextRange>(first, second - first); - return std::nullopt; - } - - constexpr static std::pair<unsigned, unsigned> ToTwoSides( - std::optional<TextRange> text_range, unsigned default_position = 0) { - if (text_range.has_value()) - return std::make_pair( - text_range.value().position, - text_range.value().position + text_range.value().count); - return std::make_pair(default_position, default_position); + constexpr static TextRange FromTwoSides(gsl::index start, gsl::index end) { + return TextRange(start, end - start); } constexpr TextRange() = default; - constexpr TextRange(const unsigned position, const unsigned count) + constexpr TextRange(const gsl::index position, const gsl::index count) : position(position), count(count) {} - unsigned position = 0; - unsigned count = 0; + gsl::index GetEnd() const { return position + count; } + + gsl::index position = 0; + gsl::index count = 0; }; struct Color { diff --git a/include/cru/platform/native/input_method.hpp b/include/cru/platform/native/input_method.hpp index 00017502..56e2fb27 100644 --- a/include/cru/platform/native/input_method.hpp +++ b/include/cru/platform/native/input_method.hpp @@ -7,15 +7,18 @@ #include <vector> namespace cru::platform::native { -struct CompositionUnderline { +struct CompositionClause { int start; int end; + bool target; }; +using CompositionClauses = std::vector<CompositionClause>; + struct CompositionText { std::string text; - std::vector<CompositionUnderline> underlines; - int caret_position; + CompositionClauses clauses; + TextRange selection; }; struct IInputMethodContext : virtual INativeResource { |