summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorGeorge Hazan <ghazan@miranda.im>2017-05-01 11:58:04 +0300
committerGeorge Hazan <ghazan@miranda.im>2017-05-01 11:58:04 +0300
commit28d98a38c756991d461301efb483e4980a2def69 (patch)
treed317b4a941832d3cc4137a6f597c029757913987 /src
parentd75d5e8706b06457b799831448f282818233abe9 (diff)
Utils_IsRtl - core function to detect RTL direcction
Diffstat (limited to 'src')
-rw-r--r--src/core/stdmsg/src/msgdialog.cpp15
-rw-r--r--src/mir_core/src/mir_core.def1
-rw-r--r--src/mir_core/src/mir_core64.def1
-rw-r--r--src/mir_core/src/utils.cpp13
4 files changed, 16 insertions, 14 deletions
diff --git a/src/core/stdmsg/src/msgdialog.cpp b/src/core/stdmsg/src/msgdialog.cpp
index d66a15cc00..e8e58a5fdc 100644
--- a/src/core/stdmsg/src/msgdialog.cpp
+++ b/src/core/stdmsg/src/msgdialog.cpp
@@ -35,26 +35,13 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
static const UINT sendControls[] = { IDC_SRMM_MESSAGE };
-static int RTL_Detect(const wchar_t *ptszText)
-{
- int iLen = (int)mir_wstrlen(ptszText);
- WORD *infoTypeC2 = (WORD*)alloca(sizeof(WORD)* (iLen + 2));
- GetStringTypeEx(LOCALE_USER_DEFAULT, CT_CTYPE2, ptszText, iLen, infoTypeC2);
-
- for (int i = 0; i < iLen; i++)
- if (infoTypeC2[i] == C2_RIGHTTOLEFT)
- return 1;
-
- return 0;
-}
-
int SendMessageDirect(const wchar_t *szMsg, MCONTACT hContact)
{
if (hContact == 0)
return 0;
int flags = 0;
- if (RTL_Detect(szMsg))
+ if (Utils_IsRtl(szMsg))
flags |= PREF_RTL;
T2Utf sendBuffer(szMsg);
diff --git a/src/mir_core/src/mir_core.def b/src/mir_core/src/mir_core.def
index ebc69f8d19..5fd89d1bca 100644
--- a/src/mir_core/src/mir_core.def
+++ b/src/mir_core/src/mir_core.def
@@ -1050,3 +1050,4 @@ CallFunctionSync @1170
?SetReadOnly@CCtrlRichEdit@@QAEX_N@Z @1237 NONAME
?Hide@CDlgBase@@QAEXXZ @1238 NONAME
?Resize@CDlgBase@@QAEXXZ @1239 NONAME
+Utils_IsRtl @1240
diff --git a/src/mir_core/src/mir_core64.def b/src/mir_core/src/mir_core64.def
index 2e5c83b8af..02fa033f13 100644
--- a/src/mir_core/src/mir_core64.def
+++ b/src/mir_core/src/mir_core64.def
@@ -1050,3 +1050,4 @@ CallFunctionSync @1170
?SetReadOnly@CCtrlRichEdit@@QEAAX_N@Z @1237 NONAME
?Hide@CDlgBase@@QEAAXXZ @1238 NONAME
?Resize@CDlgBase@@QEAAXXZ @1239 NONAME
+Utils_IsRtl @1240
diff --git a/src/mir_core/src/utils.cpp b/src/mir_core/src/utils.cpp
index 7b26bb6aab..f2f007d2f4 100644
--- a/src/mir_core/src/utils.cpp
+++ b/src/mir_core/src/utils.cpp
@@ -536,3 +536,16 @@ MIR_CORE_DLL(void) Utils_GetRandom(void *pszDest, size_t cbLen)
p[i] = rand() & 0xFF;
}
}
+
+MIR_CORE_DLL(bool) Utils_IsRtl(const wchar_t *pszwText)
+{
+ size_t iLen = mir_wstrlen(pszwText);
+ mir_ptr<WORD> infoTypeC2((WORD*)mir_calloc(sizeof(WORD) * (iLen + 2)));
+ GetStringTypeW(CT_CTYPE2, pszwText, (int)iLen, infoTypeC2);
+
+ for (size_t i = 0; i < iLen; i++)
+ if (infoTypeC2[i] == C2_RIGHTTOLEFT)
+ return true;
+
+ return false;
+}