Files
qingjian/apps/linux/fcitx5/tests/support/context.h
T
jacklaoz 916bd29e15 feat(linux): 能在 FreeBSD 上源码安装 (#681)
Server、Fcitx5 插件与设置程序与 Linux 共用,差异按 target_os 分开:对端身份用 getpeereid、快捷键缺省走 Linux 那套、字体补 /usr/local 路径、安装脚本不用 GNU 独有的 realpath -m;mio 升到 1.2.4。
2026-10-19 16:08:00 +08:00

30 lines
1.1 KiB
C++
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
//! 默认面板回归使用的无应用输入上下文。
#pragma once
#include <fcitx/inputcontext.h>
#include <functional>
#include <utility>
class Context final : public fcitx::InputContext {
public:
explicit Context(fcitx::InputContextManager &manager) : InputContext(manager, "panel-test") { created(); }
~Context() override { destroy(); }
const char *frontend() const override { return "test"; }
std::string committed;
std::function<void()> onPreedit;
std::function<void()> onCommit;
protected:
void commitStringImpl(const std::string &text) override {
committed += text;
auto callback = std::move(onCommit);
if (callback) callback();
}
void deleteSurroundingTextImpl(int, unsigned int) override {}
void forwardKeyImpl(const fcitx::ForwardKeyEvent &) override {}
void updatePreeditImpl() override {
// 回调只触发一次。不用 std::move:libc++ 不保证移走后的 std::function 变空
auto callback = std::exchange(onPreedit, nullptr);
if (callback) callback();
}
};