11 #include "fcitx-utils/macros.h" 12 #include "candidatelist.h" 23 std::shared_ptr<CandidateList> candidate_;
25 CustomInputPanelCallback customCallback_ =
nullptr;
26 CustomInputPanelCallback customVirtualKeyboardCallback_ =
nullptr;
35 InputPanel::~InputPanel() {}
37 void InputPanel::setAuxDown(
const Text &text) {
42 void InputPanel::setAuxUp(
const Text &text) {
47 void InputPanel::setCandidateList(std::unique_ptr<CandidateList> candidate) {
49 d->candidate_ = std::move(candidate);
54 d->clientPreedit_ = clientPreedit.
normalize();
57 if (d->clientPreedit_.empty()) {
62 void InputPanel::setPreedit(
const Text &text) {
67 const Text &InputPanel::auxDown()
const {
72 const Text &InputPanel::auxUp()
const {
79 return d->clientPreedit_;
82 const Text &InputPanel::preedit()
const {
89 return d->customCallback_;
93 CustomInputPanelCallback callback) {
95 d->customCallback_ = std::move(callback);
98 const CustomInputPanelCallback &
99 InputPanel::customVirtualKeyboardCallback()
const {
101 return d->customVirtualKeyboardCallback_;
104 void InputPanel::setCustomVirtualKeyboardCallback(
105 CustomInputPanelCallback callback) {
107 d->customVirtualKeyboardCallback_ = std::move(callback);
110 void InputPanel::reset() {
113 d->clientPreedit_.clear();
114 d->clientPreedit_.setCursor(0);
115 d->candidate_.reset();
118 d->customCallback_ =
nullptr;
119 d->customVirtualKeyboardCallback_ =
nullptr;
124 return d->preedit_.empty() && d->clientPreedit_.empty() &&
125 (!d->candidate_ || d->candidate_->size() == 0) &&
126 d->auxUp_.empty() && d->auxDown_.empty();
129 std::shared_ptr<CandidateList> InputPanel::candidateList()
const {
131 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.
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.