MCPcopy Create free account
hub / github.com/cxasm/notepad-- / inputMethodEvent

Method inputMethodEvent

src/qscint/src/InputMethod.cpp:130–214  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

128}
129
130void QsciScintillaBase::inputMethodEvent(QInputMethodEvent *event)
131{
132 // Copy & paste by johnsonj with a lot of helps of Neil
133 // Great thanks for my forerunners, jiniya and BLUEnLIVE
134
135 if (sci->pdoc->IsReadOnly() || sci->SelectionContainsProtected()) {
136 // Here, a canceling and/or completing composition function is needed.
137 return;
138 }
139
140 bool initialCompose = false;
141 if (sci->pdoc->TentativeActive()) {
142 sci->pdoc->TentativeUndo();
143 } else {
144 // No tentative undo means start of this composition so
145 // Fill in any virtual spaces.
146 initialCompose = true;
147 }
148
149 sci->view.imeCaretBlockOverride = false;
150
151 if (!event->commitString().isEmpty()) {
152 const QString commitStr = event->commitString();
153 const int commitStrLen = commitStr.length();
154
155 for (int i = 0; i < commitStrLen;) {
156 const int ucWidth = commitStr.at(i).isHighSurrogate() ? 2 : 1;
157 const QString oneCharUTF16 = commitStr.mid(i, ucWidth);
158 const QByteArray oneChar = textAsBytes(oneCharUTF16);
159 const int oneCharLen = oneChar.length();
160
161 sci->AddCharUTF(oneChar.data(), oneChar.length());
162 i += ucWidth;
163 }
164
165 } else if (!event->preeditString().isEmpty()) {
166 const QString preeditStr = event->preeditString();
167 const int preeditStrLen = preeditStr.length();
168 if (preeditStrLen == 0) {
169 sci->ShowCaretAtCurrentPosition();
170 return;
171 }
172
173 if (initialCompose)
174 sci->ClearBeforeTentativeStart();
175 sci->pdoc->TentativeStart(); // TentativeActive() from now on.
176
177 std::vector<int> imeIndicator = MapImeIndicators(event);
178
179 for (unsigned int i = 0; i < preeditStrLen;) {
180 const unsigned int ucWidth = preeditStr.at(i).isHighSurrogate() ? 2 : 1;
181 const QString oneCharUTF16 = preeditStr.mid(i, ucWidth);
182 const QByteArray oneChar = textAsBytes(oneCharUTF16);
183 const int oneCharLen = oneChar.length();
184
185 sci->AddCharUTF(oneChar.data(), oneCharLen);
186
187 DrawImeIndicator(sci, imeIndicator[i], oneCharLen);

Callers

nothing calls this directly

Calls 15

MapImeIndicatorsFunction · 0.85
DrawImeIndicatorFunction · 0.85
GetImeCaretPosFunction · 0.85
MoveImeCaretsFunction · 0.85
IsHangulFunction · 0.85
TentativeUndoMethod · 0.80
isEmptyMethod · 0.80
dataMethod · 0.80

Tested by

no test coverage detected