diff options
author | crupest <crupest@outlook.com> | 2021-10-21 14:12:26 +0800 |
---|---|---|
committer | crupest <crupest@outlook.com> | 2021-10-21 14:12:26 +0800 |
commit | 695031ac33acd398bd1492bcce813b8346574ae2 (patch) | |
tree | c2ad61bd3db4aa8f07ee0929c26ba70a42275d64 /src/osx/gui/InputMethodPrivate.h | |
parent | e0e786729df8114555fa3af9fffe256b067ea823 (diff) | |
download | cru-695031ac33acd398bd1492bcce813b8346574ae2.tar.gz cru-695031ac33acd398bd1492bcce813b8346574ae2.tar.bz2 cru-695031ac33acd398bd1492bcce813b8346574ae2.zip |
...
Diffstat (limited to 'src/osx/gui/InputMethodPrivate.h')
-rw-r--r-- | src/osx/gui/InputMethodPrivate.h | 59 |
1 files changed, 59 insertions, 0 deletions
diff --git a/src/osx/gui/InputMethodPrivate.h b/src/osx/gui/InputMethodPrivate.h new file mode 100644 index 00000000..a4b61432 --- /dev/null +++ b/src/osx/gui/InputMethodPrivate.h @@ -0,0 +1,59 @@ +#pragma once +#include "cru/osx/gui/InputMethod.hpp" + +#import <AppKit/AppKit.h> + +@interface CruInputClient : NSObject <NSTextInputClient> +- (id)init:(cru::platform::gui::osx::details::OsxInputMethodContextPrivate*)p; +@end + +namespace cru::platform::gui::osx { +namespace details { +class OsxInputMethodContextPrivate { + friend OsxInputMethodContext; + + public: + OsxInputMethodContextPrivate(OsxInputMethodContext* input_method_context, OsxWindow* window); + + CRU_DELETE_COPY(OsxInputMethodContextPrivate) + CRU_DELETE_MOVE(OsxInputMethodContextPrivate) + + ~OsxInputMethodContextPrivate(); + + void SetCompositionText(CompositionText composition_text) { + composition_text_ = std::move(composition_text); + } + + void RaiseCompositionStartEvent(); + void RaiseCompositionEndEvent(); + void RaiseCompositionEvent(); + void RaiseTextEvent(StringView text); + + Point GetCandidateWindowPosition() const { return candidate_window_point_; } + void SetCandidateWindowPosition(const Point& p) { candidate_window_point_ = p; } + + Range GetSelectionRange() const { return selection_range_; } + void SetSelectionRange(Range selection_range) { selection_range_ = selection_range; } + + void PerformSel(SEL sel); + + private: + OsxWindow* window_; + + CompositionText composition_text_; + + Range selection_range_; + + OsxInputMethodContext* input_method_context_; + + // On Osx, this is the text lefttop point on screen. + Point candidate_window_point_; + + Event<std::nullptr_t> composition_start_event_; + Event<std::nullptr_t> composition_event_; + Event<std::nullptr_t> composition_end_event_; + Event<StringView> text_event_; +}; + +} +} |