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

Function MapImeIndicators

src/qscint/src/InputMethod.cpp:82–128  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

80}
81
82static std::vector<int> MapImeIndicators(QInputMethodEvent *event)
83{
84 std::vector<int> imeIndicator(event->preeditString().size(), SC_INDICATOR_UNKNOWN);
85 foreach (QInputMethodEvent::Attribute attr, event->attributes()) {
86 if (attr.type == QInputMethodEvent::TextFormat) {
87 QTextFormat format = attr.value.value<QTextFormat>();
88 QTextCharFormat charFormat = format.toCharFormat();
89
90 int indicator = SC_INDICATOR_UNKNOWN;
91 switch (charFormat.underlineStyle()) {
92 case QTextCharFormat::NoUnderline: // win32, linux
93 indicator = SC_INDICATOR_TARGET;
94 break;
95 case QTextCharFormat::SingleUnderline: // osx
96 case QTextCharFormat::DashUnderline: // win32, linux
97 indicator = SC_INDICATOR_INPUT;
98 break;
99 case QTextCharFormat::DotLine:
100 case QTextCharFormat::DashDotLine:
101 case QTextCharFormat::WaveUnderline:
102 case QTextCharFormat::SpellCheckUnderline:
103 indicator = SC_INDICATOR_CONVERTED;
104 break;
105
106 default:
107 indicator = SC_INDICATOR_UNKNOWN;
108 }
109
110 if (format.hasProperty(QTextFormat::BackgroundBrush)) // win32, linux
111 indicator = SC_INDICATOR_TARGET;
112
113#ifdef Q_OS_OSX
114 if (charFormat.underlineStyle() == QTextCharFormat::SingleUnderline) {
115 QColor uc = charFormat.underlineColor();
116 if (uc.lightness() < 2) { // osx
117 indicator = SC_INDICATOR_TARGET;
118 }
119 }
120#endif
121
122 for (int i = attr.start; i < attr.start+attr.length; i++) {
123 imeIndicator[i] = indicator;
124 }
125 }
126 }
127 return imeIndicator;
128}
129
130void QsciScintillaBase::inputMethodEvent(QInputMethodEvent *event)
131{

Callers 1

inputMethodEventMethod · 0.85

Calls 1

sizeMethod · 0.45

Tested by

no test coverage detected