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