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

Method inputMethodQuery

src/qscint/src/InputMethod.cpp:216–281  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

214}
215
216QVariant QsciScintillaBase::inputMethodQuery(Qt::InputMethodQuery query) const
217{
218 int pos = SendScintilla(SCI_GETCURRENTPOS);
219 int line = SendScintilla(SCI_LINEFROMPOSITION, pos);
220
221 switch (query) {
222 case Qt::ImHints:
223 return QWidget::inputMethodQuery(query);
224
225 case Qt::ImCursorRectangle:
226 {
227 int startPos = (preeditPos >= 0) ? preeditPos : pos;
228 Scintilla::Point pt = sci->LocationFromPosition(startPos);
229 int width = SendScintilla(SCI_GETCARETWIDTH);
230 int height = SendScintilla(SCI_TEXTHEIGHT, line);
231 return QRect(pt.x, pt.y, width, height);
232 }
233
234 case Qt::ImFont:
235 {
236 char fontName[64];
237 int style = SendScintilla(SCI_GETSTYLEAT, pos);
238 int len = SendScintilla(SCI_STYLEGETFONT, style, (sptr_t)fontName);
239 int size = SendScintilla(SCI_STYLEGETSIZE, style);
240 bool italic = SendScintilla(SCI_STYLEGETITALIC, style);
241 int weight = SendScintilla(SCI_STYLEGETBOLD, style) ? QFont::Bold : -1;
242 return QFont(QString::fromUtf8(fontName, len), size, weight, italic);
243 }
244
245 case Qt::ImCursorPosition:
246 {
247 int paraStart = sci->pdoc->ParaUp(pos);
248 return pos - paraStart;
249 }
250
251 case Qt::ImSurroundingText:
252 {
253 int paraStart = sci->pdoc->ParaUp(pos);
254 int paraEnd = sci->pdoc->ParaDown(pos);
255 QVarLengthArray<char,1024> buffer(paraEnd - paraStart + 1);
256
257 Sci_CharacterRange charRange;
258 charRange.cpMin = paraStart;
259 charRange.cpMax = paraEnd;
260
261 Sci_TextRange textRange;
262 textRange.chrg = charRange;
263 textRange.lpstrText = buffer.data();
264
265 SendScintilla(SCI_GETTEXTRANGE, 0, (sptr_t)&textRange);
266
267 return bytesAsText(buffer.constData());
268 }
269
270 case Qt::ImCurrentSelection:
271 {
272 QVarLengthArray<char,1024> buffer(SendScintilla(SCI_GETSELTEXT));
273 SendScintilla(SCI_GETSELTEXT, 0, (sptr_t)buffer.data());

Callers

nothing calls this directly

Calls 4

ParaUpMethod · 0.80
ParaDownMethod · 0.80
dataMethod · 0.80
LocationFromPositionMethod · 0.45

Tested by

no test coverage detected