11 #include "fcitx-utils/macros.h" 12 #include "candidatelist.h" 24 std::shared_ptr<CandidateList> candidate_;
26 CustomInputPanelCallback customCallback_ =
nullptr;
27 CustomInputPanelCallback customVirtualKeyboardCallback_ =
nullptr;
36 InputPanel::~InputPanel() {}
38 void InputPanel::setAuxDown(
const Text &text) {
43 void InputPanel::setAuxUp(
const Text &text) {
48 void InputPanel::setCandidateList(std::unique_ptr<CandidateList> candidate) {
50 d->candidate_ = std::move(candidate);
55 d->clientPreedit_ = clientPreedit.
normalize();
58 if (d->clientPreedit_.empty()) {
63 void InputPanel::setPreedit(
const Text &text) {
68 const Text &InputPanel::auxDown()
const {
73 const Text &InputPanel::auxUp()
const {
80 return d->clientPreedit_;
83 const Text &InputPanel::preedit()
const {
90 return d->overlayMessage_;
95 d->overlayMessage_ = std::move(text);
100 return d->customCallback_;
104 CustomInputPanelCallback callback) {
106 d->customCallback_ = std::move(callback);
109 const CustomInputPanelCallback &
110 InputPanel::customVirtualKeyboardCallback()
const {
112 return d->customVirtualKeyboardCallback_;
115 void InputPanel::setCustomVirtualKeyboardCallback(
116 CustomInputPanelCallback callback) {
118 d->customVirtualKeyboardCallback_ = std::move(callback);
121 void InputPanel::reset() {
124 d->clientPreedit_.clear();
125 d->clientPreedit_.setCursor(0);
126 d->candidate_.reset();
129 d->overlayMessage_.clear();
130 d->customCallback_ =
nullptr;
131 d->customVirtualKeyboardCallback_ =
nullptr;
136 return d->preedit_.empty() && d->clientPreedit_.empty() &&
137 (!d->candidate_ || d->candidate_->size() == 0) &&
138 d->auxUp_.empty() && d->auxDown_.empty();
141 std::shared_ptr<CandidateList> InputPanel::candidateList()
const {
143 return d->candidate_;
const Text & clientPreedit() const
The preedit text embedded in client window.
const CustomInputPanelCallback & customInputPanelCallback() const
Return the current input panel display callback.
Formatted string commonly used in user interface.
const Text & overlayMessage() const
An text message that allows the input method to display a message on top of the input panel...
A class represents a formatted string.
Text normalize() const
Remove empty string piece and merge the string with same format.
InputPanel(InputContext *ic)
Construct a Input Panel associated with given input context.
void setCursor(int pos=-1)
Set cursor by byte.
bool empty() const
Whether input panel is totally empty.
An input context represents a client of Fcitx.
void setCustomInputPanelCallback(CustomInputPanelCallback callback)
Set a custom callback to display the input panel.
void setOverlayMessage(Text text)
Set an overlay message on the input panel.