diff options
author | George Hazan <george.hazan@gmail.com> | 2012-06-10 10:00:18 +0000 |
---|---|---|
committer | George Hazan <george.hazan@gmail.com> | 2012-06-10 10:00:18 +0000 |
commit | 3730671c0735c834098e24d9b03a501e521e0c90 (patch) | |
tree | 9531cc8cc45801420272e78c6f4333b90dec47d6 /plugins/ChangeKeyboardLayout/text_operations.c | |
parent | 9a452de527d55caed4dfdb01f8fc3d549d9be5b3 (diff) |
- valid type conversions
git-svn-id: http://svn.miranda-ng.org/main/trunk@375 1316c22d-e87f-b044-9b9b-93d7a3e3ba9c
Diffstat (limited to 'plugins/ChangeKeyboardLayout/text_operations.c')
-rw-r--r-- | plugins/ChangeKeyboardLayout/text_operations.c | 495 |
1 files changed, 247 insertions, 248 deletions
diff --git a/plugins/ChangeKeyboardLayout/text_operations.c b/plugins/ChangeKeyboardLayout/text_operations.c index 70851b38a1..8118d76afa 100644 --- a/plugins/ChangeKeyboardLayout/text_operations.c +++ b/plugins/ChangeKeyboardLayout/text_operations.c @@ -6,41 +6,41 @@ struct EditStreamData { int iCurrent;
};
-static DWORD CALLBACK EditStreamOutRtf(DWORD dwCookie,LPBYTE pbBuff,LONG cb,LONG *pcb)
+static DWORD CALLBACK EditStreamOutRtf(DWORD_PTR dwCookie, LPBYTE pbBuff, LONG cb, LONG *pcb)
{
- struct EditStreamData *esd=(struct EditStreamData*)dwCookie;
- esd->cbBuff+=cb;
- esd->pbBuff=(PBYTE)realloc(esd->pbBuff,esd->cbBuff+sizeof(TCHAR));
- CopyMemory(esd->pbBuff+esd->iCurrent,pbBuff,cb);
- esd->iCurrent+=cb;
- esd->pbBuff[esd->iCurrent]=0;
+ struct EditStreamData *esd = (struct EditStreamData*)dwCookie;
+ esd->cbBuff += cb;
+ esd->pbBuff = (PBYTE)realloc(esd->pbBuff, esd->cbBuff+sizeof(TCHAR));
+ CopyMemory(esd->pbBuff+esd->iCurrent, pbBuff, cb);
+ esd->iCurrent += cb;
+ esd->pbBuff[esd->iCurrent] = 0;
#if defined (_UNICODE)
- esd->pbBuff[esd->iCurrent+1]=0;
+ esd->pbBuff[esd->iCurrent+1] = 0;
#endif
- *pcb=cb;
+ *pcb = cb;
return 0;
}
LPTSTR GeTStringFromStreamData(struct EditStreamData *esd)
{
LPTSTR ptszTemp, ptszOutText;
- DWORD i,k;
+ DWORD i, k;
- ptszOutText=(LPTSTR)mir_alloc(MaxTextSize*sizeof(TCHAR));
- ptszTemp=(TCHAR*)esd->pbBuff;
+ ptszOutText = (LPTSTR)mir_alloc(MaxTextSize*sizeof(TCHAR));
+ ptszTemp = (TCHAR*)esd->pbBuff;
- for (i=k=0;i<_tcslen(ptszTemp);i++)
- if ((ptszTemp[i]==0x0A)||(ptszTemp[i]==0x2028))
- ptszOutText[k++]=0x0D;
- else if (ptszTemp[i]==0x0D)
+ for (i = k = 0;i<_tcslen(ptszTemp);i++)
+ if ((ptszTemp[i] == 0x0A)||(ptszTemp[i] == 0x2028))
+ ptszOutText[k++] = 0x0D;
+ else if (ptszTemp[i] == 0x0D)
{
- ptszOutText[k++]=0x0D;
- if (ptszTemp[i+1]==0x0A) i++;
+ ptszOutText[k++] = 0x0D;
+ if (ptszTemp[i+1] == 0x0A) i++;
}
else
- ptszOutText[k++]=ptszTemp[i];
+ ptszOutText[k++] = ptszTemp[i];
- ptszOutText[k]=0;
+ ptszOutText[k] = 0;
return ptszOutText;
}
@@ -52,14 +52,14 @@ BOOL CopyTextToClipboard(LPTSTR ptszText) if (OpenClipboard(NULL))
{
EmptyClipboard();
- hCopy=GlobalAlloc(GMEM_MOVEABLE,(_tcslen(ptszText)+1)*sizeof(TCHAR));
- _tcscpy(GlobalLock(hCopy),ptszText);
+ hCopy = GlobalAlloc(GMEM_MOVEABLE, (_tcslen(ptszText)+1)*sizeof(TCHAR));
+ _tcscpy((TCHAR*)GlobalLock(hCopy), ptszText);
GlobalUnlock(hCopy);
#if defined (_UNICODE)
- SetClipboardData(CF_UNICODETEXT,hCopy);
+ SetClipboardData(CF_UNICODETEXT, hCopy);
#else
- SetClipboardData(CF_TEXT,hCopy);
+ SetClipboardData(CF_TEXT, hCopy);
#endif
CloseClipboard();
@@ -69,11 +69,10 @@ BOOL CopyTextToClipboard(LPTSTR ptszText) return FALSE;
}
-LPTSTR GetNameOfLayout(HKL hklLayout)
+LPSTR GetNameOfLayout(HKL hklLayout)
{
- LPTSTR ptszLayName;
- ptszLayName=mir_alloc((KL_NAMELENGTH+1)*sizeof(TCHAR));
- sprintf(ptszLayName,"%08x",hklLayout);
+ LPSTR ptszLayName = (LPSTR)mir_alloc(KL_NAMELENGTH+1);
+ sprintf(ptszLayName, "%08x", hklLayout);
return ptszLayName;
}
@@ -83,7 +82,7 @@ LPTSTR GetShortNameOfLayout(HKL hklLayout) TCHAR szLI[20];
LPTSTR ptszLiShort;
- ptszLiShort=(LPTSTR)mir_alloc(3*sizeof(TCHAR));
+ ptszLiShort = (LPTSTR)mir_alloc(3*sizeof(TCHAR));
dwLcid = MAKELCID(hklLayout, 0);
GetLocaleInfo(dwLcid, LOCALE_SISO639LANGNAME , szLI, 10);
ptszLiShort[0] = toupper(szLI[0]);
@@ -97,7 +96,7 @@ HKL GetNextLayout(HKL hklCurLay) {
DWORD i;
for(i = 0; i < bLayNum; i++)
- if (hklLayouts[i]==hklCurLay)
+ if (hklLayouts[i] == hklCurLay)
return hklLayouts[(i+1)%(bLayNum)];
return NULL;
@@ -105,45 +104,45 @@ HKL GetNextLayout(HKL hklCurLay) LPTSTR GenerateLayoutString(HKL hklLayout)
{
- LPTSTR ptszLayStr,ptszTemp;
+ LPTSTR ptszLayStr, ptszTemp;
SHORT shVirtualKey;
UINT iScanCode;
- BYTE bState[256]={0};
- DWORD i,j;
+ BYTE bState[256] = {0};
+ DWORD i, j;
int iRes;
- ptszLayStr=(LPTSTR)mir_alloc(100*sizeof(TCHAR));
- ptszTemp=(LPTSTR)mir_alloc(3*sizeof(TCHAR));
- ptszTemp[0]=0;
- for(i=0;i<_tcslen(ptszKeybEng);i++)
+ ptszLayStr = (LPTSTR)mir_alloc(100*sizeof(TCHAR));
+ ptszTemp = (LPTSTR)mir_alloc(3*sizeof(TCHAR));
+ ptszTemp[0] = 0;
+ for(i = 0;i<_tcslen(ptszKeybEng);i++)
{
- shVirtualKey=VkKeyScanEx(ptszKeybEng[i],hklEng);
- iScanCode=MapVirtualKeyEx(shVirtualKey&0x00FF,0,hklEng);
+ shVirtualKey = VkKeyScanEx(ptszKeybEng[i], hklEng);
+ iScanCode = MapVirtualKeyEx(shVirtualKey&0x00FF, 0, hklEng);
- for (j=0;j<256;j++)
- bState[j]=0;
+ for (j = 0;j<256;j++)
+ bState[j] = 0;
- if (shVirtualKey&0x0100) bState[VK_SHIFT]=0x80;
- if (shVirtualKey&0x0200) bState[VK_CONTROL]=0x80;
- if (shVirtualKey&0x0400) bState[VK_MENU]=0x80;
+ if (shVirtualKey&0x0100) bState[VK_SHIFT] = 0x80;
+ if (shVirtualKey&0x0200) bState[VK_CONTROL] = 0x80;
+ if (shVirtualKey&0x0400) bState[VK_MENU] = 0x80;
- shVirtualKey=MapVirtualKeyEx(iScanCode,1,hklLayout);
- bState[shVirtualKey&0x00FF]=0x80;
+ shVirtualKey = MapVirtualKeyEx(iScanCode, 1, hklLayout);
+ bState[shVirtualKey&0x00FF] = 0x80;
#if defined (_UNICODE)
- iRes=ToUnicodeEx(shVirtualKey,iScanCode,bState,ptszTemp,3,0,hklLayout);
+ iRes = ToUnicodeEx(shVirtualKey, iScanCode, bState, ptszTemp, 3, 0, hklLayout);
// Защита от дэд-кеев
- if (iRes<0) ToUnicodeEx(shVirtualKey,iScanCode,bState,ptszTemp,3,0,hklLayout);
+ if (iRes<0) ToUnicodeEx(shVirtualKey, iScanCode, bState, ptszTemp, 3, 0, hklLayout);
#else
- iRes=ToAsciiEx(shVirtualKey,iScanCode,bState,ptszTemp,0,hklLayout);
+ iRes = ToAsciiEx(shVirtualKey, iScanCode, bState, ptszTemp, 0, hklLayout);
// Защита от дэд-кеев
- if (iRes<0) ToAsciiEx(shVirtualKey,iScanCode,bState,ptszTemp,0,hklLayout);
+ if (iRes<0) ToAsciiEx(shVirtualKey, iScanCode, bState, ptszTemp, 0, hklLayout);
#endif
//Если нам вернули нулевой символ, или не вернули ничего, то присвоим "звоночек"
- if (ptszTemp[0]==0) ptszLayStr[i]=3; else ptszLayStr[i]=ptszTemp[0];
+ if (ptszTemp[0] == 0) ptszLayStr[i] = 3; else ptszLayStr[i] = ptszTemp[0];
}
- ptszLayStr[i]=0;
+ ptszLayStr[i] = 0;
mir_free(ptszTemp);
return ptszLayStr;
@@ -152,8 +151,8 @@ LPTSTR GenerateLayoutString(HKL hklLayout) LPTSTR GetLayoutString(HKL hklLayout)
{
DWORD i;
- for (i=0;i<bLayNum;i++)
- if (hklLayouts[i]==hklLayout)
+ for (i = 0;i<bLayNum;i++)
+ if (hklLayouts[i] == hklLayout)
return ptszLayStrings[i];
return NULL;
}
@@ -163,72 +162,72 @@ LPTSTR ChangeTextCase(LPCTSTR ptszInText) LPTSTR ptszOutText;
DWORD i;
- ptszOutText=(LPTSTR)mir_alloc(MaxTextSize*sizeof(TCHAR));
+ ptszOutText = (LPTSTR)mir_alloc(MaxTextSize*sizeof(TCHAR));
if (!CoreCheck())
{
- _tcscpy(ptszOutText,TranslateT("Change Keyboard Layout plugin was designed to be used with Miranda IM only. For use with any other application, please contact author."));
+ _tcscpy(ptszOutText, TranslateT("Change Keyboard Layout plugin was designed to be used with Miranda IM only. For use with any other application, please contact author."));
return ptszOutText;
}
- _tcscpy(ptszOutText,ptszInText);
+ _tcscpy(ptszOutText, ptszInText);
- for (i=0;i<_tcslen(ptszInText);i++)
+ for (i = 0;i<_tcslen(ptszInText);i++)
{
- CharUpperBuff(&ptszOutText[i],1);
+ CharUpperBuff(&ptszOutText[i], 1);
- if (ptszOutText[i]==ptszInText[i])
- CharLowerBuff(&ptszOutText[i],1);
+ if (ptszOutText[i] == ptszInText[i])
+ CharLowerBuff(&ptszOutText[i], 1);
}
return ptszOutText;
}
-LPTSTR ChangeTextLayout(LPCTSTR ptszInText,HKL hklCurLay, HKL hklToLay, BOOL TwoWay)
+LPTSTR ChangeTextLayout(LPCTSTR ptszInText, HKL hklCurLay, HKL hklToLay, BOOL TwoWay)
{
LPTSTR ptszOutText;
- DWORD i,j;
+ DWORD i, j;
BOOL Found;
- LPTSTR ptszKeybCur,ptszKeybNext;
+ LPTSTR ptszKeybCur, ptszKeybNext;
- ptszOutText=(LPTSTR)mir_alloc(MaxTextSize*sizeof(TCHAR));
+ ptszOutText = (LPTSTR)mir_alloc(MaxTextSize*sizeof(TCHAR));
if (!CoreCheck())
{
- _tcscpy(ptszOutText,TranslateT("Change Keyboard Layout plugin was designed to be used with Miranda IM only. For use with any other application, please contact author."));
+ _tcscpy(ptszOutText, TranslateT("Change Keyboard Layout plugin was designed to be used with Miranda IM only. For use with any other application, please contact author."));
return ptszOutText;
}
- _tcscpy(ptszOutText,ptszInText);
+ _tcscpy(ptszOutText, ptszInText);
- if ((hklCurLay==NULL)||(hklToLay==NULL))
+ if ((hklCurLay == NULL)||(hklToLay == NULL))
return ptszOutText;
- ptszKeybCur=GetLayoutString(hklCurLay);
- ptszKeybNext=GetLayoutString(hklToLay);
+ ptszKeybCur = GetLayoutString(hklCurLay);
+ ptszKeybNext = GetLayoutString(hklToLay);
- if ((ptszKeybCur==0)||(ptszKeybNext==0))
+ if ((ptszKeybCur == 0)||(ptszKeybNext == 0))
return ptszOutText;
- for (i=0;i<_tcslen(ptszInText);i++)
+ for (i = 0;i<_tcslen(ptszInText);i++)
{
- Found=FALSE;
- for (j=0;(j<_tcslen(ptszKeybCur)&&(!Found));j++)
- if (ptszKeybCur[j]==ptszInText[i])
+ Found = FALSE;
+ for (j = 0;(j<_tcslen(ptszKeybCur) && (!Found));j++)
+ if (ptszKeybCur[j] == ptszInText[i])
{
- Found=TRUE;
+ Found = TRUE;
if (_tcslen(ptszKeybNext)>=j)
- ptszOutText[i]=ptszKeybNext[j];
+ ptszOutText[i] = ptszKeybNext[j];
}
- if (TwoWay&&(!Found))
- for (j=0;(j<_tcslen(ptszKeybNext)&&(!Found));j++)
- if (ptszKeybNext[j]==ptszInText[i])
+ if (TwoWay && (!Found))
+ for (j = 0;(j<_tcslen(ptszKeybNext) && (!Found));j++)
+ if (ptszKeybNext[j] == ptszInText[i])
{
- Found=TRUE;
+ Found = TRUE;
if (_tcslen(ptszKeybCur)>=j)
- ptszOutText[i]=ptszKeybCur[j];
+ ptszOutText[i] = ptszKeybCur[j];
}
};
return ptszOutText;
@@ -236,65 +235,65 @@ LPTSTR ChangeTextLayout(LPCTSTR ptszInText,HKL hklCurLay, HKL hklToLay, BOOL Two HKL GetLayoutOfText(LPCTSTR ptszInText)
{
- DWORD i,j;
+ DWORD i, j;
LPTSTR ptszKeybBuff;
- DWORD dwCountSymbols,dwMaxSymbols,dwTemp;
+ DWORD dwCountSymbols, dwMaxSymbols, dwTemp;
HKL hklCurLay;
- hklCurLay=hklLayouts[0];
- ptszKeybBuff=ptszLayStrings[0];
- dwMaxSymbols=dwTemp=0;
+ hklCurLay = hklLayouts[0];
+ ptszKeybBuff = ptszLayStrings[0];
+ dwMaxSymbols = dwTemp = 0;
- for (j=0;j<_tcslen(ptszInText);j++)
- if (_tcschr(ptszKeybBuff,ptszInText[j])!=NULL) ++dwMaxSymbols;
+ for (j = 0;j<_tcslen(ptszInText);j++)
+ if (_tcschr(ptszKeybBuff, ptszInText[j]) != NULL) ++dwMaxSymbols;
for(i = 1; i < bLayNum; i++)
{
- ptszKeybBuff=ptszLayStrings[i];
- dwCountSymbols=0;
+ ptszKeybBuff = ptszLayStrings[i];
+ dwCountSymbols = 0;
- for (j=0;j<_tcslen(ptszInText);j++)
- if (_tcschr(ptszKeybBuff,ptszInText[j])!=NULL) ++dwCountSymbols;
+ for (j = 0;j<_tcslen(ptszInText);j++)
+ if (_tcschr(ptszKeybBuff, ptszInText[j]) != NULL) ++dwCountSymbols;
- if (dwCountSymbols==dwMaxSymbols)
+ if (dwCountSymbols == dwMaxSymbols)
dwTemp = dwCountSymbols;
else if (dwCountSymbols>dwMaxSymbols)
{
- dwMaxSymbols=dwCountSymbols;
- hklCurLay=hklLayouts[i];
+ dwMaxSymbols = dwCountSymbols;
+ hklCurLay = hklLayouts[i];
}
}
if (dwMaxSymbols == dwTemp)
- hklCurLay=GetKeyboardLayout(0);
+ hklCurLay = GetKeyboardLayout(0);
return hklCurLay;
}
-int ChangeLayout(HWND hTextWnd,BYTE TextOperation,BOOL CurrentWord)
+int ChangeLayout(HWND hTextWnd, BYTE TextOperation, BOOL CurrentWord)
{
HKL hklCurLay, hklToLay;
- LPTSTR ptszInText,ptszOutText,ptszMBox,ptszPopupText,ptszTemp;
+ LPTSTR ptszInText, ptszOutText, ptszMBox, ptszPopupText, ptszTemp;
IEVIEWEVENT ieEvent;
- CHARRANGE crSelection,crTemp;
- DWORD dwStartWord,dwEndWord;
- int i,iRes;
+ CHARRANGE crSelection, crTemp;
+ DWORD dwStartWord, dwEndWord;
+ int i, iRes;
- BYTE WindowType=WTYPE_Unknown;
+ BYTE WindowType = WTYPE_Unknown;
BOOL WindowIsReadOnly, TwoWay;
- EDITSTREAM esStream={0};
+ EDITSTREAM esStream = {0};
struct EditStreamData esdData;
POPUPDATAT pdtData;
- esStream.dwCookie=(DWORD)&esdData;
- esStream.pfnCallback=EditStreamOutRtf;
+ esStream.dwCookie = (DWORD)&esdData;
+ esStream.pfnCallback = EditStreamOutRtf;
- if (hTextWnd==NULL)
- hTextWnd=GetFocus();
- if (hTextWnd!=NULL)
+ if (hTextWnd == NULL)
+ hTextWnd = GetFocus();
+ if (hTextWnd != NULL)
{
// --------------Определяем тип окна-----------------
@@ -302,95 +301,95 @@ int ChangeLayout(HWND hTextWnd,BYTE TextOperation,BOOL CurrentWord) ieEvent.cbSize = sizeof(IEVIEWEVENT);
ieEvent.dwFlags = 0;
ieEvent.iType = IEE_GET_SELECTION;
- //event.codepage=1200;
+ //event.codepage = 1200;
#if !defined(_UNICODE)
- ieEvent.dwFlags |= IEEF_NO_UNICODE;
+ ieEvent.dwFlags |= IEEF_NO_UNICODE;
#endif
if (ServiceExists(MS_HPP_EG_EVENT))
{
//То же самое для History++
ieEvent.hwnd = hTextWnd;
- ptszInText=(TCHAR*)CallService(MS_HPP_EG_EVENT, 0, (LPARAM)&ieEvent);
+ ptszInText = (TCHAR*)CallService(MS_HPP_EG_EVENT, 0, (LPARAM)&ieEvent);
- if (!IsBadStringPtr(ptszInText,MaxTextSize)) WindowType=WTYPE_HistoryPP;
+ if (!IsBadStringPtr(ptszInText, MaxTextSize)) WindowType = WTYPE_HistoryPP;
}
- if ((WindowType==WTYPE_Unknown)&&(ServiceExists(MS_IEVIEW_EVENT)))
+ if ((WindowType == WTYPE_Unknown) && (ServiceExists(MS_IEVIEW_EVENT)))
{
// Извращенное определение хэндла IEView
ieEvent.hwnd = GetParent(GetParent(hTextWnd));
- ptszInText=(TCHAR*)CallService(MS_IEVIEW_EVENT, 0, (LPARAM)&ieEvent);
- if (!IsBadStringPtr(ptszInText,MaxTextSize)) WindowType=WTYPE_IEView;
+ ptszInText = (TCHAR*)CallService(MS_IEVIEW_EVENT, 0, (LPARAM)&ieEvent);
+ if (!IsBadStringPtr(ptszInText, MaxTextSize)) WindowType = WTYPE_IEView;
}
- if (WindowType==WTYPE_Unknown)
+ if (WindowType == WTYPE_Unknown)
{
- ptszTemp=(LPTSTR)mir_alloc(255*sizeof(TCHAR));
- i = GetClassName(hTextWnd,ptszTemp,255);
+ ptszTemp = (LPTSTR)mir_alloc(255*sizeof(TCHAR));
+ i = GetClassName(hTextWnd, ptszTemp, 255);
ptszTemp[i] = 0;
- if (_tcsstr(CharUpper(ptszTemp),_T("RICHEDIT")) != NULL )
+ if (_tcsstr(CharUpper(ptszTemp), _T("RICHEDIT")) != NULL )
{
- WindowType=WTYPE_RichEdit;
- SendMessage(hTextWnd,EM_EXGETSEL,0,(LPARAM)&crSelection);
+ WindowType = WTYPE_RichEdit;
+ SendMessage(hTextWnd, EM_EXGETSEL, 0, (LPARAM)&crSelection);
}
mir_free(ptszTemp);
}
- if (WindowType==WTYPE_Unknown)
+ if (WindowType == WTYPE_Unknown)
{
- SendMessage(hTextWnd,EM_GETSEL,(WPARAM)&crSelection.cpMin,(LPARAM)&crSelection.cpMax);
- if ((SendMessage(hTextWnd,WM_GETDLGCODE,(WPARAM)NULL,(LPARAM)NULL)&(DLGC_HASSETSEL))&&(crSelection.cpMin>=0))
- WindowType=WTYPE_Edit;
+ SendMessage(hTextWnd, EM_GETSEL, (WPARAM)&crSelection.cpMin, (LPARAM)&crSelection.cpMax);
+ if ((SendMessage(hTextWnd, WM_GETDLGCODE, (WPARAM)NULL, (LPARAM)NULL)&(DLGC_HASSETSEL)) && (crSelection.cpMin>=0))
+ WindowType = WTYPE_Edit;
}
//Получим текст из Рича или обычного Едита
- if ((WindowType==WTYPE_RichEdit)||(WindowType==WTYPE_Edit))
+ if ((WindowType == WTYPE_RichEdit)||(WindowType == WTYPE_Edit))
{
- dwStartWord=dwEndWord=-1;
- SendMessage(hTextWnd,WM_SETREDRAW,FALSE,0);
+ dwStartWord = dwEndWord = -1;
+ SendMessage(hTextWnd, WM_SETREDRAW, FALSE, 0);
//Бэкап выделения
- crTemp=crSelection;
+ crTemp = crSelection;
// Если имеется выделенный текст, то получим его
- if(crSelection.cpMin!=crSelection.cpMax)
+ if(crSelection.cpMin != crSelection.cpMax)
{
- if (WindowType==WTYPE_RichEdit)
+ if (WindowType == WTYPE_RichEdit)
{
ZeroMemory(&esdData, sizeof(esdData));
#if defined (_UNICODE)
- if (SendMessage(hTextWnd,EM_STREAMOUT,SF_TEXT|SF_UNICODE|SFF_SELECTION,(LPARAM)&esStream)>0)
+ if (SendMessage(hTextWnd, EM_STREAMOUT, SF_TEXT|SF_UNICODE|SFF_SELECTION, (LPARAM)&esStream)>0)
#else
- if (SendMessage(hTextWnd,EM_STREAMOUT,SF_TEXT|SFF_SELECTION,(LPARAM)&esStream)>0)
+ if (SendMessage(hTextWnd, EM_STREAMOUT, SF_TEXT|SFF_SELECTION, (LPARAM)&esStream)>0)
#endif
- ptszInText=GeTStringFromStreamData(&esdData);
+ ptszInText = GeTStringFromStreamData(&esdData);
else
{
- SendMessage(hTextWnd,EM_EXSETSEL,0,(LPARAM)&crSelection);
- SendMessage(hTextWnd,WM_SETREDRAW,TRUE,0);
+ SendMessage(hTextWnd, EM_EXSETSEL, 0, (LPARAM)&crSelection);
+ SendMessage(hTextWnd, WM_SETREDRAW, TRUE, 0);
InvalidateRect(hTextWnd, NULL, FALSE);
return 1;
}
}
- if (WindowType==WTYPE_Edit)
+ if (WindowType == WTYPE_Edit)
{
- ptszTemp=(LPTSTR)mir_alloc(MaxTextSize*sizeof(TCHAR));
- ptszInText=(LPTSTR)mir_alloc(MaxTextSize*sizeof(TCHAR));
- iRes=SendMessage(hTextWnd,WM_GETTEXT,(WPARAM)MaxTextSize,(LPARAM)ptszTemp);
- if (!IsBadStringPtr(ptszInText,MaxTextSize)&&(iRes>0))
+ ptszTemp = (LPTSTR)mir_alloc(MaxTextSize*sizeof(TCHAR));
+ ptszInText = (LPTSTR)mir_alloc(MaxTextSize*sizeof(TCHAR));
+ iRes = SendMessage(hTextWnd, WM_GETTEXT, (WPARAM)MaxTextSize, (LPARAM)ptszTemp);
+ if (!IsBadStringPtr(ptszInText, MaxTextSize) && (iRes>0))
{
- _tcsncpy(ptszInText,&ptszTemp[crSelection.cpMin],crSelection.cpMax-crSelection.cpMin);
- ptszInText[crSelection.cpMax-crSelection.cpMin]=0;
+ _tcsncpy(ptszInText, &ptszTemp[crSelection.cpMin], crSelection.cpMax-crSelection.cpMin);
+ ptszInText[crSelection.cpMax-crSelection.cpMin] = 0;
mir_free(ptszTemp);
}
else
{
- SendMessage(hTextWnd,EM_EXSETSEL,0,(LPARAM)&crSelection);
- SendMessage(hTextWnd,WM_SETREDRAW,TRUE,0);
+ SendMessage(hTextWnd, EM_EXSETSEL, 0, (LPARAM)&crSelection);
+ SendMessage(hTextWnd, WM_SETREDRAW, TRUE, 0);
InvalidateRect(hTextWnd, NULL, FALSE);
return 1;
}
@@ -400,40 +399,40 @@ int ChangeLayout(HWND hTextWnd,BYTE TextOperation,BOOL CurrentWord) else
{
// Получаем весь текст в поле
- if (WindowType==WTYPE_RichEdit)
+ if (WindowType == WTYPE_RichEdit)
{
ZeroMemory(&esdData, sizeof(esdData));
- crTemp.cpMin=0;
- crTemp.cpMax=-1;
- SendMessage(hTextWnd,EM_EXSETSEL,0,(LPARAM)&crTemp);
+ crTemp.cpMin = 0;
+ crTemp.cpMax = -1;
+ SendMessage(hTextWnd, EM_EXSETSEL, 0, (LPARAM)&crTemp);
#if defined (_UNICODE)
- if (SendMessage(hTextWnd,EM_STREAMOUT,SF_TEXT|SF_UNICODE|SFF_SELECTION,(LPARAM)&esStream)!=0)
+ if (SendMessage(hTextWnd, EM_STREAMOUT, SF_TEXT|SF_UNICODE|SFF_SELECTION, (LPARAM)&esStream) != 0)
#else
- if (SendMessage(hTextWnd,EM_STREAMOUT,SF_TEXT|SFF_SELECTION,(LPARAM)&esStream)!=0)
+ if (SendMessage(hTextWnd, EM_STREAMOUT, SF_TEXT|SFF_SELECTION, (LPARAM)&esStream) != 0)
#endif
- ptszInText=GeTStringFromStreamData(&esdData);
+ ptszInText = GeTStringFromStreamData(&esdData);
else
{
- SendMessage(hTextWnd,EM_EXSETSEL,0,(LPARAM)&crSelection);
- SendMessage(hTextWnd,WM_SETREDRAW,TRUE,0);
+ SendMessage(hTextWnd, EM_EXSETSEL, 0, (LPARAM)&crSelection);
+ SendMessage(hTextWnd, WM_SETREDRAW, TRUE, 0);
InvalidateRect(hTextWnd, NULL, FALSE);
return 1;
}
}
- if (WindowType==WTYPE_Edit)
+ if (WindowType == WTYPE_Edit)
{
- ptszInText=(LPTSTR)mir_alloc(MaxTextSize*sizeof(TCHAR));
- iRes=SendMessage(hTextWnd,WM_GETTEXT,(WPARAM)MaxTextSize,(LPARAM)ptszInText);
+ ptszInText = (LPTSTR)mir_alloc(MaxTextSize*sizeof(TCHAR));
+ iRes = SendMessage(hTextWnd, WM_GETTEXT, (WPARAM)MaxTextSize, (LPARAM)ptszInText);
- if (!IsBadStringPtr(ptszInText,MaxTextSize)&&(iRes>0))
+ if (!IsBadStringPtr(ptszInText, MaxTextSize) && (iRes>0))
{
- crTemp.cpMin=0;
- crTemp.cpMax=_tcslen(ptszInText);
+ crTemp.cpMin = 0;
+ crTemp.cpMax = (int)_tcslen(ptszInText);
}
else
{
- SendMessage(hTextWnd,EM_EXSETSEL,0,(LPARAM)&crSelection);
- SendMessage(hTextWnd,WM_SETREDRAW,TRUE,0);
+ SendMessage(hTextWnd, EM_EXSETSEL, 0, (LPARAM)&crSelection);
+ SendMessage(hTextWnd, WM_SETREDRAW, TRUE, 0);
InvalidateRect(hTextWnd, NULL, FALSE);
return 1;
}
@@ -441,44 +440,44 @@ int ChangeLayout(HWND hTextWnd,BYTE TextOperation,BOOL CurrentWord) // Получаем текущее слово
if (CurrentWord)
{
- for (dwStartWord=crSelection.cpMin;(dwStartWord>0)&&(_tcschr(ptszSeparators,ptszInText[dwStartWord-1])==NULL);dwStartWord--);
- for (dwEndWord=crSelection.cpMin;(dwEndWord<(_tcslen(ptszInText)))&&(_tcschr(ptszSeparators,ptszInText[dwEndWord])==NULL);dwEndWord++);
+ for (dwStartWord = crSelection.cpMin;(dwStartWord>0) && (_tcschr(ptszSeparators, ptszInText[dwStartWord-1]) == NULL);dwStartWord--);
+ for (dwEndWord = crSelection.cpMin;(dwEndWord<(_tcslen(ptszInText))) && (_tcschr(ptszSeparators, ptszInText[dwEndWord]) == NULL);dwEndWord++);
- crTemp.cpMin=dwStartWord;
- crTemp.cpMax=dwEndWord;
+ crTemp.cpMin = dwStartWord;
+ crTemp.cpMax = dwEndWord;
- if (WindowType==WTYPE_RichEdit)
+ if (WindowType == WTYPE_RichEdit)
{
- SendMessage(hTextWnd,EM_EXSETSEL,0,(LPARAM)&crTemp);
+ SendMessage(hTextWnd, EM_EXSETSEL, 0, (LPARAM)&crTemp);
ZeroMemory(&esdData, sizeof(esdData));
#if defined (_UNICODE)
- if (SendMessage(hTextWnd,EM_STREAMOUT,SF_TEXT|SF_UNICODE|SFF_SELECTION,(LPARAM)&esStream)!=0)
+ if (SendMessage(hTextWnd, EM_STREAMOUT, SF_TEXT|SF_UNICODE|SFF_SELECTION, (LPARAM)&esStream) != 0)
#else
- if (SendMessage(hTextWnd,EM_STREAMOUT,SF_TEXT|SFF_SELECTION,(LPARAM)&esStream)!=0)
+ if (SendMessage(hTextWnd, EM_STREAMOUT, SF_TEXT|SFF_SELECTION, (LPARAM)&esStream) != 0)
#endif
- ptszInText=GeTStringFromStreamData(&esdData);
+ ptszInText = GeTStringFromStreamData(&esdData);
else
{
- SendMessage(hTextWnd,EM_EXSETSEL,0,(LPARAM)&crSelection);
- SendMessage(hTextWnd,WM_SETREDRAW,TRUE,0);
+ SendMessage(hTextWnd, EM_EXSETSEL, 0, (LPARAM)&crSelection);
+ SendMessage(hTextWnd, WM_SETREDRAW, TRUE, 0);
InvalidateRect(hTextWnd, NULL, FALSE);
return 1;
}
}
- if (WindowType==WTYPE_Edit)
+ if (WindowType == WTYPE_Edit)
{
- ptszTemp=(LPTSTR)mir_alloc(MaxTextSize*sizeof(TCHAR));
- _tcsncpy(ptszTemp,&ptszInText[crTemp.cpMin],crTemp.cpMax-crTemp.cpMin);
- ptszTemp[crTemp.cpMax-crTemp.cpMin]=0;
- _tcscpy(ptszInText,ptszTemp);
+ ptszTemp = (LPTSTR)mir_alloc(MaxTextSize*sizeof(TCHAR));
+ _tcsncpy(ptszTemp, &ptszInText[crTemp.cpMin], crTemp.cpMax-crTemp.cpMin);
+ ptszTemp[crTemp.cpMax-crTemp.cpMin] = 0;
+ _tcscpy(ptszInText, ptszTemp);
mir_free(ptszTemp);
- if (_tcslen(ptszInText)==0)
+ if (_tcslen(ptszInText) == 0)
{
mir_free(ptszInText);
- SendMessage(hTextWnd,EM_EXSETSEL,0,(LPARAM)&crSelection);
- SendMessage(hTextWnd,WM_SETREDRAW,TRUE,0);
+ SendMessage(hTextWnd, EM_EXSETSEL, 0, (LPARAM)&crSelection);
+ SendMessage(hTextWnd, WM_SETREDRAW, TRUE, 0);
InvalidateRect(hTextWnd, NULL, FALSE);
return 1;
}
@@ -487,65 +486,65 @@ int ChangeLayout(HWND hTextWnd,BYTE TextOperation,BOOL CurrentWord) }
}
// ---------------Выдаем результаты--------------------
- WindowIsReadOnly=FALSE;
- if ((WindowType==WTYPE_IEView)||(WindowType==WTYPE_HistoryPP)) WindowIsReadOnly=TRUE;
+ WindowIsReadOnly = FALSE;
+ if ((WindowType == WTYPE_IEView)||(WindowType == WTYPE_HistoryPP)) WindowIsReadOnly = TRUE;
- //if ((SendMessage(hTextWnd,EM_GETOPTIONS,0,0)&ECO_READONLY))
- if ((WindowType==WTYPE_RichEdit)||(WindowType==WTYPE_Edit))
- if (GetWindowLongPtr(hTextWnd,GWL_STYLE)&ES_READONLY)
- WindowIsReadOnly=TRUE;
+ //if ((SendMessage(hTextWnd, EM_GETOPTIONS, 0, 0)&ECO_READONLY))
+ if ((WindowType == WTYPE_RichEdit)||(WindowType == WTYPE_Edit))
+ if (GetWindowLongPtr(hTextWnd, GWL_STYLE)&ES_READONLY)
+ WindowIsReadOnly = TRUE;
// Лог Иевью и ХисториПП в режиме эмуляции Иевью и поля только для чтения.
- if ((WindowType!=WTYPE_Unknown)&&(!IsBadStringPtr(ptszInText,MaxTextSize)))
+ if ((WindowType != WTYPE_Unknown) && (!IsBadStringPtr(ptszInText, MaxTextSize)))
if (WindowIsReadOnly)
{
- ptszMBox=(LPTSTR)mir_alloc(MaxTextSize*sizeof(TCHAR));
- ptszMBox[0]=0;
+ ptszMBox = (LPTSTR)mir_alloc(MaxTextSize*sizeof(TCHAR));
+ ptszMBox[0] = 0;
- if (TextOperation==TOT_Layout)
+ if (TextOperation == TOT_Layout)
{
- hklCurLay=GetLayoutOfText(ptszInText);
- hklToLay=GetNextLayout(hklCurLay);
- TwoWay=(moOptions.TwoWay)&&(bLayNum==2);
+ hklCurLay = GetLayoutOfText(ptszInText);
+ hklToLay = GetNextLayout(hklCurLay);
+ TwoWay = (moOptions.TwoWay) && (bLayNum == 2);
- if (bLayNum==2)
+ if (bLayNum == 2)
{
- ptszMBox=ChangeTextLayout(ptszInText,hklCurLay,hklToLay,TwoWay);
+ ptszMBox = ChangeTextLayout(ptszInText, hklCurLay, hklToLay, TwoWay);
}
else
{
- for (i=0;i<bLayNum;i++)
- if (hklLayouts[i]!=hklCurLay)
+ for (i = 0;i<bLayNum;i++)
+ if (hklLayouts[i] != hklCurLay)
{
- if (_tcslen(ptszMBox)!=0)
- _tcscat(ptszMBox,_T("\n\n"));
- ptszTemp=GetShortNameOfLayout(hklLayouts[i]);
- _tcscat(ptszMBox,ptszTemp);
- _tcscat(ptszMBox,_T(":\n"));
- ptszOutText=ChangeTextLayout(ptszInText,hklCurLay,hklLayouts[i],FALSE);
- _tcscat(ptszMBox,ptszOutText);
+ if (_tcslen(ptszMBox) != 0)
+ _tcscat(ptszMBox, _T("\n\n"));
+ ptszTemp = GetShortNameOfLayout(hklLayouts[i]);
+ _tcscat(ptszMBox, ptszTemp);
+ _tcscat(ptszMBox, _T(":\n"));
+ ptszOutText = ChangeTextLayout(ptszInText, hklCurLay, hklLayouts[i], FALSE);
+ _tcscat(ptszMBox, ptszOutText);
mir_free(ptszTemp);
mir_free(ptszOutText);
}
}
}
- else if (TextOperation==TOT_Case)
+ else if (TextOperation == TOT_Case)
{
- ptszMBox=ChangeTextCase(ptszInText);
+ ptszMBox = ChangeTextCase(ptszInText);
}
mir_free(ptszInText);
- if ((WindowType==WTYPE_Edit)||(WindowType==WTYPE_RichEdit))
+ if ((WindowType == WTYPE_Edit)||(WindowType == WTYPE_RichEdit))
{
- SendMessage(hTextWnd,EM_EXSETSEL,0,(LPARAM)&crSelection);
- SendMessage(hTextWnd,WM_SETREDRAW,TRUE,0);
+ SendMessage(hTextWnd, EM_EXSETSEL, 0, (LPARAM)&crSelection);
+ SendMessage(hTextWnd, WM_SETREDRAW, TRUE, 0);
InvalidateRect(hTextWnd, NULL, FALSE);
}
- if (TextOperation==TOT_Layout)
+ if (TextOperation == TOT_Layout)
SkinPlaySound(SND_ChangeLayout);
- else if (TextOperation==TOT_Case)
+ else if (TextOperation == TOT_Case)
SkinPlaySound(SND_ChangeCase);
if (moOptions.CopyToClipboard)
@@ -553,25 +552,25 @@ int ChangeLayout(HWND hTextWnd,BYTE TextOperation,BOOL CurrentWord) //-------------------------------Покажем попапы------------------------------------------
if (moOptions.ShowPopup)
{
- ptszPopupText=(LPTSTR)mir_alloc(MaxTextSize*sizeof(TCHAR));
- _tcscpy(ptszPopupText,ptszMBox);
+ ptszPopupText = (LPTSTR)mir_alloc(MaxTextSize*sizeof(TCHAR));
+ _tcscpy(ptszPopupText, ptszMBox);
pdtData.cbSize = sizeof(POPUPDATAT);
ZeroMemory(&pdtData, sizeof(pdtData));
- _tcsncpy(pdtData.lptzContactName,TranslateT(ModuleName), MAX_CONTACTNAME);
+ _tcsncpy(pdtData.lptzContactName, TranslateT(ModuleName), MAX_CONTACTNAME);
_tcsncpy(pdtData.lptzText, ptszPopupText, MAX_SECONDLINE);
switch(poOptions.bColourType)
{
case PPC_POPUP:
- pdtData.colorBack=pdtData.colorText=0;
+ pdtData.colorBack = pdtData.colorText = 0;
break;
case PPC_WINDOWS:
- pdtData.colorBack=GetSysColor(COLOR_BTNFACE);
- pdtData.colorText=GetSysColor(COLOR_WINDOWTEXT);
+ pdtData.colorBack = GetSysColor(COLOR_BTNFACE);
+ pdtData.colorText = GetSysColor(COLOR_WINDOWTEXT);
break;
case PPC_CUSTOM:
- pdtData.colorBack=poOptions.crBackColour;
- pdtData.colorText=poOptions.crTextColour;
+ pdtData.colorBack = poOptions.crBackColour;
+ pdtData.colorText = poOptions.crTextColour;
break;
default:
break;
@@ -579,16 +578,16 @@ int ChangeLayout(HWND hTextWnd,BYTE TextOperation,BOOL CurrentWord) switch(poOptions.bTimeoutType)
{
case PPT_POPUP:
- pdtData.iSeconds=0;
+ pdtData.iSeconds = 0;
break;
case PPT_PERMANENT:
- pdtData.iSeconds=-1;
+ pdtData.iSeconds = -1;
break;
case PPC_CUSTOM:
- pdtData.iSeconds=poOptions.bTimeout;
+ pdtData.iSeconds = poOptions.bTimeout;
break;
}
- pdtData.PluginData =ptszPopupText;
+ pdtData.PluginData = ptszPopupText;
pdtData.lchIcon = hPopupIcon;
poOptions.paActions[0].lchIcon = hCopyIcon;
@@ -600,7 +599,7 @@ int ChangeLayout(HWND hTextWnd,BYTE TextOperation,BOOL CurrentWord) if (CallService(MS_POPUP_ADDPOPUPT, (WPARAM) &pdtData, APF_NEWDATA)<0)
{
mir_free(ptszPopupText);
- MessageBox(NULL,ptszMBox,_T(ModuleName),MB_ICONINFORMATION);
+ MessageBox(NULL, ptszMBox, _T(ModuleName), MB_ICONINFORMATION);
}
}
mir_free(ptszMBox);
@@ -609,38 +608,38 @@ int ChangeLayout(HWND hTextWnd,BYTE TextOperation,BOOL CurrentWord) //------------------Редактируемые поля ----------------------------
else
{
- if (TextOperation==TOT_Layout)
+ if (TextOperation == TOT_Layout)
{
- hklCurLay=GetLayoutOfText(ptszInText);
- hklToLay=GetNextLayout(hklCurLay);
- TwoWay=(moOptions.TwoWay)&&(bLayNum==2);
- ptszOutText=ChangeTextLayout(ptszInText,hklCurLay,hklToLay,TwoWay);
+ hklCurLay = GetLayoutOfText(ptszInText);
+ hklToLay = GetNextLayout(hklCurLay);
+ TwoWay = (moOptions.TwoWay) && (bLayNum == 2);
+ ptszOutText = ChangeTextLayout(ptszInText, hklCurLay, hklToLay, TwoWay);
}
- else if (TextOperation==TOT_Case)
+ else if (TextOperation == TOT_Case)
{
- ptszOutText=ChangeTextCase(ptszInText);
+ ptszOutText = ChangeTextCase(ptszInText);
}
- if (WindowType==WTYPE_RichEdit)
+ if (WindowType == WTYPE_RichEdit)
{
- SendMessage(hTextWnd,EM_EXSETSEL,0,(LPARAM)&crTemp);
- SendMessage(hTextWnd,EM_REPLACESEL,FALSE,(LPARAM)ptszOutText);
- SendMessage(hTextWnd,EM_EXSETSEL,0,(LPARAM)&crSelection);
+ SendMessage(hTextWnd, EM_EXSETSEL, 0, (LPARAM)&crTemp);
+ SendMessage(hTextWnd, EM_REPLACESEL, FALSE, (LPARAM)ptszOutText);
+ SendMessage(hTextWnd, EM_EXSETSEL, 0, (LPARAM)&crSelection);
}
else
{
- ptszTemp=(LPTSTR)mir_alloc(MaxTextSize*sizeof(TCHAR));
- SendMessage(hTextWnd,WM_GETTEXT,(WPARAM)MaxTextSize,(LPARAM)ptszTemp);
- for (i=crTemp.cpMin;i<crTemp.cpMax;i++)
- ptszTemp[i]=ptszOutText[i-crTemp.cpMin];
- SendMessage(hTextWnd,WM_SETTEXT,(WPARAM)NULL,(LPARAM)ptszTemp);
- SendMessage(hTextWnd,EM_SETSEL,crSelection.cpMin,crSelection.cpMax);
+ ptszTemp = (LPTSTR)mir_alloc(MaxTextSize*sizeof(TCHAR));
+ SendMessage(hTextWnd, WM_GETTEXT, (WPARAM)MaxTextSize, (LPARAM)ptszTemp);
+ for (i = crTemp.cpMin;i<crTemp.cpMax;i++)
+ ptszTemp[i] = ptszOutText[i-crTemp.cpMin];
+ SendMessage(hTextWnd, WM_SETTEXT, (WPARAM)NULL, (LPARAM)ptszTemp);
+ SendMessage(hTextWnd, EM_SETSEL, crSelection.cpMin, crSelection.cpMax);
mir_free(ptszTemp);
}
// Переключим раскладку или изменим состояние Caps Lock
- if ((TextOperation==TOT_Layout)&&(hklToLay!=NULL)&&(moOptions.ChangeSystemLayout))
- ActivateKeyboardLayout(hklToLay,KLF_SETFORPROCESS);
+ if ((TextOperation == TOT_Layout) && (hklToLay != NULL) && (moOptions.ChangeSystemLayout))
+ ActivateKeyboardLayout(hklToLay, KLF_SETFORPROCESS);
else if (TextOperation == TOT_Case)
{
// Если нужно инвертнуть
@@ -660,12 +659,12 @@ int ChangeLayout(HWND hTextWnd,BYTE TextOperation,BOOL CurrentWord) }
}
- SendMessage(hTextWnd,WM_SETREDRAW,TRUE,0);
+ SendMessage(hTextWnd, WM_SETREDRAW, TRUE, 0);
InvalidateRect(hTextWnd, NULL, FALSE);
- if (TextOperation==TOT_Layout)
+ if (TextOperation == TOT_Layout)
SkinPlaySound(SND_ChangeLayout);
- else if (TextOperation==TOT_Case)
+ else if (TextOperation == TOT_Case)
SkinPlaySound(SND_ChangeCase);
mir_free(ptszInText);
|