@@ -3,6 +3,8 @@
|
||||
#include <bitset>
|
||||
#include <memory>
|
||||
#include <optional>
|
||||
#include <string>
|
||||
#include <unordered_map>
|
||||
|
||||
#include <raylib.h>
|
||||
|
||||
@@ -31,6 +33,30 @@ struct ImGui {
|
||||
auto text_input(std::size_t id, std::pmr::string &str, Rectangle rec,
|
||||
TextInputOptions options = {}) -> std::bitset<2>;
|
||||
|
||||
struct TextInputSurrounding {
|
||||
std::string text;
|
||||
int cursor { 0 };
|
||||
int anchor { 0 };
|
||||
std::size_t caret_byte { 0 };
|
||||
};
|
||||
|
||||
struct TextInputCursor {
|
||||
Rectangle rect {};
|
||||
bool visible { true };
|
||||
};
|
||||
|
||||
auto focused_text_input() const -> std::optional<std::size_t>;
|
||||
auto text_input_surrounding(
|
||||
std::size_t id, std::pmr::string const &str) const
|
||||
-> std::optional<TextInputSurrounding>;
|
||||
auto text_input_cursor(std::size_t id) const
|
||||
-> std::optional<TextInputCursor>;
|
||||
void ime_commit_text(std::pmr::string &str, std::string_view text);
|
||||
void ime_delete_surrounding(
|
||||
std::pmr::string &str, std::size_t before, std::size_t after);
|
||||
void ime_set_preedit(std::string text, int cursor_begin, int cursor_end);
|
||||
void ime_clear_preedit();
|
||||
|
||||
void set_font(FontHandle font);
|
||||
|
||||
[[nodiscard]] inline auto id(std::string_view const str) -> std::size_t
|
||||
@@ -46,6 +72,14 @@ private:
|
||||
Vector2 cursor_position; // y not used if multiline == false
|
||||
bool caret_visible { true };
|
||||
double caret_timer { 0.0 };
|
||||
std::string preedit_text;
|
||||
int preedit_cursor_begin { 0 };
|
||||
int preedit_cursor_end { 0 };
|
||||
bool preedit_active { false };
|
||||
bool preedit_cursor_hidden { false };
|
||||
std::size_t caret_byte { 0 };
|
||||
Rectangle caret_rect {};
|
||||
bool external_change { false };
|
||||
};
|
||||
|
||||
std::unordered_map<std::size_t, TextInputState> m_ti_states;
|
||||
|
||||
Reference in New Issue
Block a user