mirror of https://github.com/AxioDL/boo.git
Xlib in sync with new text system
This commit is contained in:
parent
9f9ff269fe
commit
52692b0459
|
@ -115,7 +115,7 @@ struct ITextInputCallback
|
|||
|
||||
virtual std::string substringForRange(const std::pair<int,int>& range,
|
||||
std::pair<int,int>& actualRange) const=0;
|
||||
virtual void insertText(const std::string& str, const std::pair<int,int>& range)=0;
|
||||
virtual void insertText(const std::string& str, const std::pair<int,int>& range={-1,0})=0;
|
||||
virtual int characterIndexAtPoint(const SWindowCoord& point) const=0;
|
||||
virtual SWindowRect rectForCharacterRange(const std::pair<int,int>& range,
|
||||
std::pair<int,int>& actualRange) const=0;
|
||||
|
@ -158,7 +158,6 @@ public:
|
|||
{(void)mod;(void)isRepeat;}
|
||||
virtual void modKeyUp(EModifierKey mod) {(void)mod;}
|
||||
|
||||
virtual void utf8FragmentDown(const std::string& str) {(void)str;}
|
||||
virtual ITextInputCallback* getTextInputCallback() {return nullptr;}
|
||||
|
||||
virtual void focusLost() {}
|
||||
|
|
|
@ -267,6 +267,7 @@ public:
|
|||
case WM_NCMOUSELEAVE:
|
||||
case WM_MOUSEHOVER:
|
||||
case WM_NCMOUSEHOVER:
|
||||
case WM_UNICHAR:
|
||||
case WM_IME_COMPOSITION:
|
||||
window->_incomingEvent(&HWNDEvent(uMsg, wParam, lParam));
|
||||
|
||||
|
|
|
@ -1170,10 +1170,23 @@ public:
|
|||
}
|
||||
return;
|
||||
}
|
||||
case WM_UNICHAR:
|
||||
{
|
||||
if (m_callback)
|
||||
{
|
||||
ITextInputCallback* inputCb = m_callback->getTextInputCallback();
|
||||
uint8_t utf8ch[4];
|
||||
size_t len = utf8proc_encode_char(e.wParam, utf8ch);
|
||||
if (inputCb && len)
|
||||
inputCb->insertText(std::string((char*)utf8ch, len));
|
||||
}
|
||||
return;
|
||||
}
|
||||
case WM_IME_COMPOSITION:
|
||||
{
|
||||
if (m_callback)
|
||||
{
|
||||
ITextInputCallback* inputCb = m_callback->getTextInputCallback();
|
||||
if ((e.lParam & GCS_RESULTSTR) != 0)
|
||||
{
|
||||
wchar_t str[512];
|
||||
|
@ -1182,11 +1195,8 @@ public:
|
|||
{
|
||||
size_t szOut;
|
||||
std::unique_ptr<uint8_t[]> out = MakeUnicodeLF(str, len/2, szOut);
|
||||
if (szOut)
|
||||
{
|
||||
std::string strOut((char*)out.get(), szOut);
|
||||
m_callback->utf8FragmentDown(strOut);
|
||||
}
|
||||
if (szOut && inputCb)
|
||||
inputCb->insertText(std::string((char*)out.get(), szOut));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1237,15 +1237,22 @@ public:
|
|||
unsigned int state = event->xkey.state;
|
||||
event->xkey.state &= ~ControlMask;
|
||||
std::string utf8Frag = translateUTF8(&event->xkey, m_xIC);
|
||||
ITextInputCallback* inputCb = m_callback->getTextInputCallback();
|
||||
if (utf8Frag.size())
|
||||
{
|
||||
m_callback->utf8FragmentDown(utf8Frag);
|
||||
if (inputCb)
|
||||
inputCb->insertText(utf8Frag);
|
||||
return;
|
||||
}
|
||||
char charCode = translateKeysym(&event->xkey, specialKey, modifierKey);
|
||||
EModifierKey modifierMask = translateModifiers(state);
|
||||
if (charCode)
|
||||
{
|
||||
if (inputCb &&
|
||||
(modifierMask & (EModifierKey::Ctrl|EModifierKey::Command)) == EModifierKey::None)
|
||||
inputCb->insertText(std::string(1, charCode));
|
||||
m_callback->charKeyDown(charCode, modifierMask, false);
|
||||
}
|
||||
else if (specialKey != ESpecialKey::None)
|
||||
m_callback->specialKeyDown(specialKey, modifierMask, false);
|
||||
else if (modifierKey != EModifierKey::None)
|
||||
|
|
Loading…
Reference in New Issue