7 #ifndef _FCITX_UTILS_INPUTBUFFER_H_ 8 #define _FCITX_UTILS_INPUTBUFFER_H_ 14 #include <string_view> 16 #include <fcitx-utils/fcitxutils_export.h> 18 #include <fcitx-utils/macros.h> 26 class InputBufferPrivate;
52 bool type(
const char *s,
size_t length) {
return typeImpl(s, length); }
54 bool type(
const std::string &s) {
return type(s.c_str(), s.size()); }
56 bool type(
const char *s) {
return type(s, std::strlen(s)); }
58 bool type(uint32_t unicode);
61 virtual void erase(
size_t from,
size_t to);
63 virtual void setCursor(
size_t cursor);
66 size_t maxSize()
const;
69 void setMaxSize(
size_t s);
72 const std::string &userInput()
const;
75 size_t cursor()
const;
78 size_t cursorByChar()
const;
84 uint32_t charAt(
size_t i)
const;
87 std::pair<size_t, size_t> rangeAt(
size_t i)
const;
90 std::string_view viewAt(
size_t i)
const;
93 size_t sizeAt(
size_t i)
const;
96 bool empty()
const {
return size() == 0; }
127 virtual bool typeImpl(
const char *s,
size_t length);
130 std::unique_ptr<InputBufferPrivate> d_ptr;
135 #endif // _FCITX_UTILS_INPUTBUFFER_H_
bool del()
Helper function to implement "delete" key.
bool type(const char *s, size_t length)
Type a C-String with length into buffer.
Whether the input buffer only supports cursor at the end of buffer.
size_t length(Iter start, Iter end)
Return the number UTF-8 characters in the string iterator range.
void clear()
Clear all buffer.
bool empty() const
Whether buffer is empty.
bool type(const std::string &s)
Type an std::stirng to buffer.
Class provides bit flag support for Enum.
bool backspace()
Helper function to implement "backspace" key.
Helper template class to make easier to use type safe enum flags.
bool type(const char *s)
Type a C-String to buffer.
The input buffer is ascii character only, non ascii char will raise exception.