forked from microsoft/terminal
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathTfEditSession.h
219 lines (177 loc) · 7.98 KB
/
TfEditSession.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
/*++
Copyright (c) Microsoft Corporation.
Licensed under the MIT license.
Module Name:
TfEditSession.h
Abstract:
This file defines the CEditSessionObject Class.
Author:
Revision History:
Notes:
--*/
#pragma once
class CicCategoryMgr;
class CicDisplayAttributeMgr;
/* 183C627A-B46C-44ad-B797-82F6BEC82131 */
const GUID GUID_PROP_CONIME_TRACKCOMPOSITION = {
0x183c627a,
0xb46c,
0x44ad,
{ 0xb7, 0x97, 0x82, 0xf6, 0xbe, 0xc8, 0x21, 0x31 }
};
//+---------------------------------------------------------------------------
//
// CEditSessionObject
//
//----------------------------------------------------------------------------
class CEditSessionObject : public ITfEditSession
{
public:
CEditSessionObject() :
m_cRef(1) {}
virtual ~CEditSessionObject(){};
public:
//
// IUnknown methods
//
STDMETHODIMP QueryInterface(REFIID riid, void** ppvObj);
STDMETHODIMP_(ULONG)
AddRef(void);
STDMETHODIMP_(ULONG)
Release(void);
//
// ITfEditSession method
//
STDMETHODIMP DoEditSession(TfEditCookie ec)
{
HRESULT hr = _DoEditSession(ec);
Release(); // Release reference count for asynchronous edit session.
return hr;
}
//
// ImmIfSessionObject methods
//
protected:
[[nodiscard]] virtual HRESULT _DoEditSession(TfEditCookie ec) = 0;
//
// EditSession methods.
//
public:
[[nodiscard]] static HRESULT GetAllTextRange(TfEditCookie ec,
ITfContext* ic,
ITfRange** range,
LONG* lpTextLength,
TF_HALTCOND* lpHaltCond = nullptr);
protected:
[[nodiscard]] HRESULT SetTextInRange(TfEditCookie ec,
ITfRange* range,
__in_ecount_opt(len) LPWSTR psz,
DWORD len);
[[nodiscard]] HRESULT ClearTextInRange(TfEditCookie ec,
ITfRange* range);
[[nodiscard]] HRESULT _GetTextAndAttribute(TfEditCookie ec,
ITfRange* range,
std::wstring& CompStr,
std::vector<TfGuidAtom> CompGuid,
BOOL bInWriteSession,
CicCategoryMgr* pCicCatMgr,
CicDisplayAttributeMgr* pCicDispAttr)
{
std::wstring ResultStr;
return _GetTextAndAttribute(ec, range, CompStr, CompGuid, ResultStr, bInWriteSession, pCicCatMgr, pCicDispAttr);
}
[[nodiscard]] HRESULT _GetTextAndAttribute(TfEditCookie ec,
ITfRange* range,
std::wstring& CompStr,
std::vector<TfGuidAtom>& CompGuid,
std::wstring& ResultStr,
BOOL bInWriteSession,
CicCategoryMgr* pCicCatMgr,
CicDisplayAttributeMgr* pCicDispAttr);
[[nodiscard]] HRESULT _GetTextAndAttributeGapRange(TfEditCookie ec,
ITfRange* gap_range,
LONG result_comp,
std::wstring& CompStr,
std::vector<TfGuidAtom>& CompGuid,
std::wstring& ResultStr);
[[nodiscard]] HRESULT _GetTextAndAttributePropertyRange(TfEditCookie ec,
ITfRange* pPropRange,
BOOL fDispAttribute,
LONG result_comp,
BOOL bInWriteSession,
TF_DISPLAYATTRIBUTE da,
TfGuidAtom guidatom,
std::wstring& CompStr,
std::vector<TfGuidAtom>& CompGuid,
std::wstring& ResultStr);
[[nodiscard]] HRESULT _GetNoDisplayAttributeRange(TfEditCookie ec,
ITfRange* range,
const GUID** guids,
const int guid_size,
ITfRange* no_display_attribute_range);
[[nodiscard]] HRESULT _GetCursorPosition(TfEditCookie ec,
CCompCursorPos& CompCursorPos);
private:
int m_cRef;
};
//+---------------------------------------------------------------------------
//
// CEditSessionCompositionComplete
//
//----------------------------------------------------------------------------
class CEditSessionCompositionComplete : public CEditSessionObject
{
public:
CEditSessionCompositionComplete() {}
[[nodiscard]] HRESULT _DoEditSession(TfEditCookie ec)
{
return CompComplete(ec);
}
[[nodiscard]] HRESULT CompComplete(TfEditCookie ec);
};
//+---------------------------------------------------------------------------
//
// CEditSessionCompositionCleanup
//
//----------------------------------------------------------------------------
class CEditSessionCompositionCleanup : public CEditSessionObject
{
public:
CEditSessionCompositionCleanup() {}
[[nodiscard]] HRESULT _DoEditSession(TfEditCookie ec)
{
return EmptyCompositionRange(ec);
}
[[nodiscard]] HRESULT EmptyCompositionRange(TfEditCookie ec);
};
//+---------------------------------------------------------------------------
//
// CEditSessionUpdateCompositionString
//
//----------------------------------------------------------------------------
class CEditSessionUpdateCompositionString : public CEditSessionObject
{
public:
CEditSessionUpdateCompositionString() {}
[[nodiscard]] HRESULT _DoEditSession(TfEditCookie ec)
{
return UpdateCompositionString(ec);
}
[[nodiscard]] HRESULT UpdateCompositionString(TfEditCookie ec);
private:
[[nodiscard]] HRESULT _IsInterimSelection(TfEditCookie ec, ITfRange** pInterimRange, BOOL* pfInterim);
[[nodiscard]] HRESULT _MakeCompositionString(TfEditCookie ec,
ITfRange* FullTextRange,
BOOL bInWriteSession,
CicCategoryMgr* pCicCatMgr,
CicDisplayAttributeMgr* pCicDispAttr);
[[nodiscard]] HRESULT _MakeInterimString(TfEditCookie ec,
ITfRange* FullTextRange,
ITfRange* InterimRange,
LONG lTextLength,
BOOL bInWriteSession,
CicCategoryMgr* pCicCatMgr,
CicDisplayAttributeMgr* pCicDispAttr);
[[nodiscard]] HRESULT _CreateCategoryAndDisplayAttributeManager(CicCategoryMgr** pCicCatMgr,
CicDisplayAttributeMgr** pCicDispAttr);
};