diff options
author | George Hazan <george.hazan@gmail.com> | 2016-07-26 09:20:25 +0000 |
---|---|---|
committer | George Hazan <george.hazan@gmail.com> | 2016-07-26 09:20:25 +0000 |
commit | 6e53dfca72b932c4bdcd7aa02ca62bf8b2630eac (patch) | |
tree | 2e8bb660c908b54914abd562af8aafa4a486c846 /plugins/SpellChecker/src | |
parent | a61c8728b379057fe7f0a0d86fe0b037598229dd (diff) |
less TCHARs:
- TCHAR is replaced with wchar_t everywhere;
- LPGENT replaced with either LPGENW or LPGEN;
- fixes for ANSI plugins that improperly used _t functions;
- TCHAR *t removed from MAllStrings;
- ptszGroup, ptszTitle & ptszTab in OPTIONSDIALOGPAGE replaced with pwsz*
git-svn-id: http://svn.miranda-ng.org/main/trunk@17133 1316c22d-e87f-b044-9b9b-93d7a3e3ba9c
Diffstat (limited to 'plugins/SpellChecker/src')
-rw-r--r-- | plugins/SpellChecker/src/RichEdit.cpp | 20 | ||||
-rw-r--r-- | plugins/SpellChecker/src/RichEdit.h | 10 | ||||
-rw-r--r-- | plugins/SpellChecker/src/ardialog.cpp | 20 | ||||
-rw-r--r-- | plugins/SpellChecker/src/ardialog.h | 6 | ||||
-rw-r--r-- | plugins/SpellChecker/src/autoreplace.cpp | 48 | ||||
-rw-r--r-- | plugins/SpellChecker/src/autoreplace.h | 22 | ||||
-rw-r--r-- | plugins/SpellChecker/src/dictionary.cpp | 132 | ||||
-rw-r--r-- | plugins/SpellChecker/src/dictionary.h | 28 | ||||
-rw-r--r-- | plugins/SpellChecker/src/options.cpp | 28 | ||||
-rw-r--r-- | plugins/SpellChecker/src/options.h | 2 | ||||
-rw-r--r-- | plugins/SpellChecker/src/spellchecker.cpp | 30 | ||||
-rw-r--r-- | plugins/SpellChecker/src/stdafx.h | 18 | ||||
-rw-r--r-- | plugins/SpellChecker/src/utils.cpp | 152 |
13 files changed, 258 insertions, 258 deletions
diff --git a/plugins/SpellChecker/src/RichEdit.cpp b/plugins/SpellChecker/src/RichEdit.cpp index ea5846a42a..1317f767cd 100644 --- a/plugins/SpellChecker/src/RichEdit.cpp +++ b/plugins/SpellChecker/src/RichEdit.cpp @@ -143,7 +143,7 @@ int RichEdit::GetLineCount() const return SendMessage(EM_GETLINECOUNT, 0, 0);
}
-void RichEdit::GetLine(int line, TCHAR *text, size_t text_len) const
+void RichEdit::GetLine(int line, wchar_t *text, size_t text_len) const
{
*((WORD*)text) = WORD(text_len - 1);
unsigned size = (unsigned)SendMessage(EM_GETLINE, (WPARAM)line, (LPARAM)text);
@@ -152,7 +152,7 @@ void RichEdit::GetLine(int line, TCHAR *text, size_t text_len) const // to make both implementations return same size
int lineLen = GetLineLength(line);
size = (unsigned)max(0, min((int)text_len - 1, min((int)size, lineLen)));
- text[size] = _T('\0');
+ text[size] = '\0';
}
int RichEdit::GetLineLength(int line) const
@@ -193,7 +193,7 @@ int RichEdit::GetTextLength() const return GetWindowTextLength(m_hwnd);
}
-TCHAR* RichEdit::GetText(int start, int end) const
+wchar_t* RichEdit::GetText(int start, int end) const
{
if (end <= start)
end = GetTextLength();
@@ -211,26 +211,26 @@ TCHAR* RichEdit::GetText(int start, int end) const return mir_tstrdup(L"");
}
- TCHAR *res = mir_u2t(text);
+ wchar_t *res = mir_u2t(text);
range->Release();
::SysFreeString(text);
return res;
}
int len = (GetTextLength() + 1);
- TCHAR *tmp = (TCHAR *)mir_alloc(len * sizeof(TCHAR));
+ wchar_t *tmp = (wchar_t *)mir_alloc(len * sizeof(wchar_t));
GetWindowText(m_hwnd, tmp, len);
tmp[len] = 0;
- TCHAR *ret = (TCHAR *)mir_alloc((end - start + 1) * sizeof(TCHAR));
- memmove(ret, &tmp[start], (end - start) * sizeof(TCHAR));
+ wchar_t *ret = (wchar_t *)mir_alloc((end - start + 1) * sizeof(wchar_t));
+ memmove(ret, &tmp[start], (end - start) * sizeof(wchar_t));
ret[end - start] = 0;
mir_free(tmp);
return ret;
}
-void RichEdit::ReplaceSel(const TCHAR *new_text)
+void RichEdit::ReplaceSel(const wchar_t *new_text)
{
if (m_stopped) {
CHARRANGE sel = GetSel();
@@ -249,7 +249,7 @@ void RichEdit::ReplaceSel(const TCHAR *new_text) else SendMessage(EM_REPLACESEL, m_undoEnabled, (LPARAM)new_text);
}
-int RichEdit::Replace(int start, int end, const TCHAR *new_text)
+int RichEdit::Replace(int start, int end, const wchar_t *new_text)
{
CHARRANGE sel = GetSel();
CHARRANGE replace_sel = { start, end };
@@ -262,7 +262,7 @@ int RichEdit::Replace(int start, int end, const TCHAR *new_text) return dif;
}
-int RichEdit::Insert(int pos, const TCHAR *text)
+int RichEdit::Insert(int pos, const wchar_t *text)
{
CHARRANGE sel = GetSel();
CHARRANGE replace_sel = { pos, pos };
diff --git a/plugins/SpellChecker/src/RichEdit.h b/plugins/SpellChecker/src/RichEdit.h index 4556369c31..17ebe1e438 100644 --- a/plugins/SpellChecker/src/RichEdit.h +++ b/plugins/SpellChecker/src/RichEdit.h @@ -35,7 +35,7 @@ public: int GetCharFromPos(const POINT &pt);
int GetLineCount() const;
- void GetLine(int line, TCHAR *text, size_t text_len) const;
+ void GetLine(int line, wchar_t *text, size_t text_len) const;
int GetLineLength(int line) const;
int GetFirstCharOfLine(int line) const;
int GetLineFromChar(int charPos) const;
@@ -44,12 +44,12 @@ public: void SetSel(int start, int end);
void SetSel(const CHARRANGE &sel);
- TCHAR* GetText(int start, int end) const;
+ wchar_t* GetText(int start, int end) const;
int GetTextLength() const;
- void ReplaceSel(const TCHAR *new_text);
- int Replace(int start, int end, const TCHAR *new_text);
- int Insert(int pos, const TCHAR *text);
+ void ReplaceSel(const wchar_t *new_text);
+ int Replace(int start, int end, const wchar_t *new_text);
+ int Insert(int pos, const wchar_t *text);
int Delete(int start, int end);
private:
diff --git a/plugins/SpellChecker/src/ardialog.cpp b/plugins/SpellChecker/src/ardialog.cpp index 3b1258508f..0b1a14fa56 100644 --- a/plugins/SpellChecker/src/ardialog.cpp +++ b/plugins/SpellChecker/src/ardialog.cpp @@ -25,8 +25,8 @@ static INT_PTR CALLBACK AddReplacementDlgProc(HWND hwndDlg, UINT msg, WPARAM wPa struct Data
{
Dictionary *dict;
- tstring find;
- tstring replace;
+ std::wstring find;
+ std::wstring replace;
BOOL useVariables;
BOOL modal;
@@ -37,7 +37,7 @@ struct Data };
BOOL ShowAutoReplaceDialog(HWND parent, BOOL modal,
- Dictionary *dict, const TCHAR *find, const TCHAR *replace, BOOL useVariables,
+ Dictionary *dict, const wchar_t *find, const wchar_t *replace, BOOL useVariables,
BOOL findReadOnly, AutoReplaceDialogCallback callback, void *param)
{
Data *data = new Data();
@@ -79,11 +79,11 @@ static LRESULT CALLBACK OnlyCharsEditProc(HWND hwnd, UINT msg, WPARAM wParam, LP if (GetKeyState(VK_CONTROL) & 0x8000) // CTRL key
break;
{
- TCHAR c = (TCHAR)wParam;
+ wchar_t c = (wchar_t)wParam;
if (!data->dict->autoReplace->isWordChar(c))
return 1;
- TCHAR tmp[2] = { c, 0 };
+ wchar_t tmp[2] = { c, 0 };
CharLower(tmp);
wParam = tmp[0];
@@ -96,10 +96,10 @@ static LRESULT CALLBACK OnlyCharsEditProc(HWND hwnd, UINT msg, WPARAM wParam, LP switch (msg) {
case EM_PASTESPECIAL:
case WM_PASTE:
- TCHAR text[256];
+ wchar_t text[256];
GetWindowText(hwnd, text, _countof(text));
- scoped_free<TCHAR> dest = data->dict->autoReplace->filterText(text);
+ scoped_free<wchar_t> dest = data->dict->autoReplace->filterText(text);
SetWindowText(hwnd, dest);
break;
}
@@ -171,7 +171,7 @@ static INT_PTR CALLBACK AddReplacementDlgProc(HWND hwndDlg, UINT msg, WPARAM wPa SendDlgItemMessage(hwndDlg, IDC_NEW, EM_LIMITTEXT, 256, 0);
if (!data->find.empty()) {
- scoped_free<TCHAR> tmp = data->dict->autoReplace->filterText(data->find.c_str());
+ scoped_free<wchar_t> tmp = data->dict->autoReplace->filterText(data->find.c_str());
SetDlgItemText(hwndDlg, IDC_OLD, tmp);
}
if (!data->replace.empty())
@@ -213,7 +213,7 @@ static INT_PTR CALLBACK AddReplacementDlgProc(HWND hwndDlg, UINT msg, WPARAM wPa {
Data *data = (Data *)GetWindowLongPtr(hwndDlg, GWLP_USERDATA);
- TCHAR find[256];
+ wchar_t find[256];
if (data->findReadOnly)
mir_tstrncpy(find, data->find.c_str(), _countof(find));
else {
@@ -221,7 +221,7 @@ static INT_PTR CALLBACK AddReplacementDlgProc(HWND hwndDlg, UINT msg, WPARAM wPa lstrtrim(find);
}
- TCHAR replace[256];
+ wchar_t replace[256];
GetDlgItemText(hwndDlg, IDC_NEW, replace, _countof(replace));
lstrtrim(replace);
diff --git a/plugins/SpellChecker/src/ardialog.h b/plugins/SpellChecker/src/ardialog.h index 83f97c6026..6ece91cc4f 100644 --- a/plugins/SpellChecker/src/ardialog.h +++ b/plugins/SpellChecker/src/ardialog.h @@ -22,11 +22,11 @@ Boston, MA 02111-1307, USA. typedef void (*AutoReplaceDialogCallback)(BOOL canceled, Dictionary *dict,
- const TCHAR *find, const TCHAR *replace, BOOL useVariables,
- const TCHAR *original_find, void *param);
+ const wchar_t *find, const wchar_t *replace, BOOL useVariables,
+ const wchar_t *original_find, void *param);
BOOL ShowAutoReplaceDialog(HWND parent, BOOL modal,
- Dictionary *dict, const TCHAR *find, const TCHAR *replace, BOOL useVariables,
+ Dictionary *dict, const wchar_t *find, const wchar_t *replace, BOOL useVariables,
BOOL findReadOnly, AutoReplaceDialogCallback callback, void *param);
diff --git a/plugins/SpellChecker/src/autoreplace.cpp b/plugins/SpellChecker/src/autoreplace.cpp index 899146ffdf..a3ad88e928 100644 --- a/plugins/SpellChecker/src/autoreplace.cpp +++ b/plugins/SpellChecker/src/autoreplace.cpp @@ -24,13 +24,13 @@ AutoReplacement::AutoReplacement() {
}
-AutoReplacement::AutoReplacement(const TCHAR *replace, BOOL useVariables)
+AutoReplacement::AutoReplacement(const wchar_t *replace, BOOL useVariables)
: replace(replace), useVariables(useVariables)
{
}
-AutoReplaceMap::AutoReplaceMap(TCHAR *aFilename, Dictionary *dict)
+AutoReplaceMap::AutoReplaceMap(wchar_t *aFilename, Dictionary *dict)
{
m_dict = dict;
mir_tstrncpy(m_filename, aFilename, _countof(m_filename));
@@ -39,7 +39,7 @@ AutoReplaceMap::AutoReplaceMap(TCHAR *aFilename, Dictionary *dict) void AutoReplaceMap::loadAutoReplaceMap()
{
- FILE *file = _tfopen(m_filename, L"rb");
+ FILE *file = _wfopen(m_filename, L"rb");
if (file == NULL)
return;
@@ -88,17 +88,17 @@ void AutoReplaceMap::loadAutoReplaceMap() void AutoReplaceMap::writeAutoReplaceMap()
{
// Create path
- TCHAR *p = _tcsrchr(m_filename, _T('\\'));
+ wchar_t *p = wcsrchr(m_filename, '\\');
if (p != NULL) {
*p = 0;
CreateDirectoryTreeT(m_filename);
- *p = _T('\\');
+ *p = '\\';
}
// Write it
- FILE *file = _tfopen(m_filename, L"wb");
+ FILE *file = _wfopen(m_filename, L"wb");
if (file != NULL) {
- map<tstring, AutoReplacement>::iterator it = m_replacements.begin();
+ map<std::wstring, AutoReplacement>::iterator it = m_replacements.begin();
for (; it != m_replacements.end(); it++) {
AutoReplacement &ar = it->second;
@@ -115,32 +115,32 @@ void AutoReplaceMap::writeAutoReplaceMap() }
-BOOL AutoReplaceMap::isWordChar(TCHAR c)
+BOOL AutoReplaceMap::isWordChar(wchar_t c)
{
if (IsNumber(c))
return TRUE;
- if (_tcschr(L"-_.!@#$%&*()[]{}<>:?/\\=+", c) != NULL)
+ if (wcschr(L"-_.!@#$%&*()[]{}<>:?/\\=+", c) != NULL)
return TRUE;
return m_dict->isWordChar(c);
}
-TCHAR* AutoReplaceMap::autoReplace(const TCHAR * word)
+wchar_t* AutoReplaceMap::autoReplace(const wchar_t * word)
{
- scoped_free<TCHAR> from = _tcslwr(_tcsdup(word));
+ scoped_free<wchar_t> from = wcslwr(wcsdup(word));
if (m_replacements.find(from.get()) == m_replacements.end())
return NULL;
AutoReplacement &ar = m_replacements[from.get()];
- TCHAR *to;
+ wchar_t *to;
if (ar.useVariables)
- to = variables_parsedup((TCHAR *)ar.replace.c_str(), (TCHAR *)word, NULL);
+ to = variables_parsedup((wchar_t *)ar.replace.c_str(), (wchar_t *)word, NULL);
else
- to = _tcsdup(ar.replace.c_str());
+ to = wcsdup(ar.replace.c_str());
// Wich case to use?
size_t len = mir_tstrlen(word);
@@ -156,17 +156,17 @@ TCHAR* AutoReplaceMap::autoReplace(const TCHAR * word) return CharUpper(to);
// First upper
- TCHAR tmp[2];
+ wchar_t tmp[2];
tmp[0] = to[0];
- tmp[1] = _T('\0');
+ tmp[1] = '\0';
CharUpper(tmp);
to[0] = tmp[0];
return to;
}
-TCHAR* AutoReplaceMap::filterText(const TCHAR *find)
+wchar_t* AutoReplaceMap::filterText(const wchar_t *find)
{
- TCHAR *ret = _tcsdup(find);
+ wchar_t *ret = wcsdup(find);
int len = mir_tstrlen(ret);
int pos = 0;
for (int i = 0; i < len; i++)
@@ -176,27 +176,27 @@ TCHAR* AutoReplaceMap::filterText(const TCHAR *find) return CharLower(ret);
}
-void AutoReplaceMap::add(const TCHAR * aFrom, const TCHAR * to, BOOL useVariables)
+void AutoReplaceMap::add(const wchar_t * aFrom, const wchar_t * to, BOOL useVariables)
{
- scoped_free<TCHAR> from = filterText(aFrom);
+ scoped_free<wchar_t> from = filterText(aFrom);
m_replacements[from.get()] = AutoReplacement(to, useVariables);
writeAutoReplaceMap();
}
-void AutoReplaceMap::copyMap(map<tstring, AutoReplacement> *replacements)
+void AutoReplaceMap::copyMap(map<std::wstring, AutoReplacement> *replacements)
{
*replacements = m_replacements;
}
-void AutoReplaceMap::setMap(const map<tstring, AutoReplacement> &replacements)
+void AutoReplaceMap::setMap(const map<std::wstring, AutoReplacement> &replacements)
{
m_replacements.clear();
- map<tstring, AutoReplacement>::const_iterator it = replacements.begin();
+ map<std::wstring, AutoReplacement>::const_iterator it = replacements.begin();
for (; it != replacements.end(); it++) {
- scoped_free<TCHAR> from = filterText(it->first.c_str());
+ scoped_free<wchar_t> from = filterText(it->first.c_str());
m_replacements[from.get()] = it->second;
}
diff --git a/plugins/SpellChecker/src/autoreplace.h b/plugins/SpellChecker/src/autoreplace.h index 8a81fdfcbf..316f015e0d 100644 --- a/plugins/SpellChecker/src/autoreplace.h +++ b/plugins/SpellChecker/src/autoreplace.h @@ -24,11 +24,11 @@ Boston, MA 02111-1307, USA. struct AutoReplacement
{
- tstring replace;
+ std::wstring replace;
BOOL useVariables;
AutoReplacement();
- AutoReplacement(const TCHAR *replace, BOOL useVariables);
+ AutoReplacement(const wchar_t *replace, BOOL useVariables);
};
@@ -38,31 +38,31 @@ class Dictionary; class AutoReplaceMap
{
private:
- TCHAR m_filename[1024];
+ wchar_t m_filename[1024];
Dictionary *m_dict;
- map<tstring, AutoReplacement> m_replacements;
+ map<std::wstring, AutoReplacement> m_replacements;
void loadAutoReplaceMap();
void writeAutoReplaceMap();
public:
- AutoReplaceMap(TCHAR *filename, Dictionary *dict);
+ AutoReplaceMap(wchar_t *filename, Dictionary *dict);
- TCHAR* filterText(const TCHAR *find);
- BOOL isWordChar(TCHAR c);
+ wchar_t* filterText(const wchar_t *find);
+ BOOL isWordChar(wchar_t c);
/// Return an auto replacement to a word or NULL if none exists.
/// You have to free the item.
- TCHAR* autoReplace(const TCHAR *word);
+ wchar_t* autoReplace(const wchar_t *word);
/// Add a word to the list of auto-replaced words
- void add(const TCHAR *from, const TCHAR *to, BOOL useVariables = FALSE);
+ void add(const wchar_t *from, const wchar_t *to, BOOL useVariables = FALSE);
/// Make a copy of the auto replace map
- void copyMap(map<tstring, AutoReplacement> *replacements);
+ void copyMap(map<std::wstring, AutoReplacement> *replacements);
/// Make a copy of the auto replace map
- void setMap(const map<tstring, AutoReplacement> &replacements);
+ void setMap(const map<std::wstring, AutoReplacement> &replacements);
};
diff --git a/plugins/SpellChecker/src/dictionary.cpp b/plugins/SpellChecker/src/dictionary.cpp index 58218fc2b1..efad448000 100644 --- a/plugins/SpellChecker/src/dictionary.cpp +++ b/plugins/SpellChecker/src/dictionary.cpp @@ -25,16 +25,16 @@ Boston, MA 02111-1307, USA. // Additional languages that i could not find in Windows struct { - TCHAR *language; - TCHAR *localized_name; + wchar_t *language; + wchar_t *localized_name; } aditionalLanguages[] = { - { L"tl_PH", LPGENT("Tagalog (Philippines)") }, - { L"de_frami_neu", LPGENT("German (Germany)") } + { L"tl_PH", LPGENW("Tagalog (Philippines)") }, + { L"de_frami_neu", LPGENW("German (Germany)") } }; struct { - TCHAR *name; - TCHAR *key; + wchar_t *name; + wchar_t *key; } otherHunspellApps[] = { { L"Thunderbird", L"thunderbird.exe" }, { L"Firefox", L"firefox.exe" } @@ -355,19 +355,19 @@ void LoadThread(LPVOID hd); class HunspellDictionary : public Dictionary { protected: - TCHAR fileWithoutExtension[1024]; - TCHAR userPath[1024]; + wchar_t fileWithoutExtension[1024]; + wchar_t userPath[1024]; volatile int loaded; Hunspell *hunspell; - TCHAR *wordChars; + wchar_t *wordChars; UINT codePage; void loadCustomDict() { - TCHAR filename[1024]; + wchar_t filename[1024]; mir_sntprintf(filename, L"%s\\%s.cdic", userPath, language); - FILE *file = _tfopen(filename, L"rb"); + FILE *file = _wfopen(filename, L"rb"); if (file != NULL) { char tmp[1024]; int c, pos = 0; @@ -388,14 +388,14 @@ protected: } } - void appendToCustomDict(const TCHAR *word) + void appendToCustomDict(const wchar_t *word) { CreateDirectoryTreeT(userPath); - TCHAR filename[1024]; + wchar_t filename[1024]; mir_sntprintf(filename, L"%s\\%s.cdic", userPath, language); - FILE *file = _tfopen(filename, L"ab"); + FILE *file = _wfopen(filename, L"ab"); if (file != NULL) { char tmp[1024]; toHunspell(tmp, word, _countof(tmp)); @@ -404,7 +404,7 @@ protected: } } - virtual void addWordInternal(const TCHAR * word) + virtual void addWordInternal(const wchar_t * word) { if (loaded != LANGUAGE_LOADED) return; @@ -415,12 +415,12 @@ protected: hunspell->add(hunspell_word); } - void toHunspell(char *hunspellWord, const TCHAR *word, size_t hunspellWordLen) + void toHunspell(char *hunspellWord, const wchar_t *word, size_t hunspellWordLen) { WideCharToMultiByte(codePage, 0, word, -1, hunspellWord, (int)hunspellWordLen, NULL, NULL); } - TCHAR* fromHunspell(const char *hunspellWord) + wchar_t* fromHunspell(const char *hunspellWord) { int len = MultiByteToWideChar(codePage, 0, hunspellWord, -1, NULL, 0); WCHAR *ret = (WCHAR *)malloc((len + 1) * sizeof(WCHAR)); @@ -428,31 +428,31 @@ protected: return ret; } - TCHAR* fromHunspellAndFree(char *hunspellWord) + wchar_t* fromHunspellAndFree(char *hunspellWord) { if (hunspellWord == NULL) return NULL; - TCHAR *ret = fromHunspell(hunspellWord); + wchar_t *ret = fromHunspell(hunspellWord); free(hunspellWord); return ret; } public: - HunspellDictionary(TCHAR *aLanguage, TCHAR *aFileWithoutExtension, TCHAR *anUserPath, TCHAR *aSource) + HunspellDictionary(wchar_t *aLanguage, wchar_t *aFileWithoutExtension, wchar_t *anUserPath, wchar_t *aSource) { mir_tstrncpy(language, aLanguage, _countof(language)); mir_tstrncpy(fileWithoutExtension, aFileWithoutExtension, _countof(fileWithoutExtension)); mir_tstrncpy(userPath, anUserPath, _countof(userPath)); if (aSource == NULL) - source[0] = _T('\0'); + source[0] = '\0'; else mir_tstrncpy(source, aSource, _countof(source)); loaded = LANGUAGE_NOT_LOADED; - localized_name[0] = _T('\0'); - english_name[0] = _T('\0'); - full_name[0] = _T('\0'); + localized_name[0] = '\0'; + english_name[0] = '\0'; + full_name[0] = '\0'; hunspell = NULL; wordChars = NULL; codePage = CP_ACP; @@ -467,14 +467,14 @@ public: free(wordChars); } - TCHAR * merge(TCHAR * s1, TCHAR *s2) + wchar_t * merge(wchar_t * s1, wchar_t *s2) { int len1 = (s1 == NULL ? 0 : mir_tstrlen(s1)); int len2 = (s2 == NULL ? 0 : mir_tstrlen(s2)); - TCHAR *ret; + wchar_t *ret; if (len1 > 0 && len2 > 0) { - ret = (TCHAR *)malloc(sizeof(TCHAR) * (len1 + len2 + 1)); + ret = (wchar_t *)malloc(sizeof(wchar_t) * (len1 + len2 + 1)); mir_tstrncpy(ret, s1, len1 + 1); mir_tstrncpy(&ret[len1], s2, len2 + 1); @@ -490,7 +490,7 @@ public: FREE(s1); } else { - ret = (TCHAR *)malloc(sizeof(TCHAR)); + ret = (wchar_t *)malloc(sizeof(wchar_t)); ret[0] = 0; FREE(s1); @@ -500,13 +500,13 @@ public: // Remove duplicated chars int last = mir_tstrlen(ret) - 1; for (int i = 0; i <= last; i++) { - TCHAR c = ret[i]; + wchar_t c = ret[i]; for (int j = last; j > i; j--) { if (c != ret[j]) continue; if (j != last) ret[j] = ret[last]; - ret[last] = _T('\0'); + ret[last] = '\0'; last--; } } @@ -530,7 +530,7 @@ public: // Get codepage const char *dic_enc = hunspell->get_dic_encoding(); - TCHAR *hwordchars; + wchar_t *hwordchars; if (mir_strcmp(dic_enc, "UTF-8") == 0) { codePage = CP_UTF8; @@ -550,8 +550,8 @@ public: hwordchars = fromHunspell(hunspell->get_wordchars()); } - TCHAR *casechars = fromHunspellAndFree(get_casechars(dic_enc)); - TCHAR *try_string = fromHunspellAndFree(hunspell->get_try_string()); + wchar_t *casechars = fromHunspellAndFree(get_casechars(dic_enc)); + wchar_t *try_string = fromHunspellAndFree(hunspell->get_try_string()); wordChars = merge(merge(casechars, hwordchars), try_string); @@ -569,7 +569,7 @@ public: } // Return TRUE if the word is correct - virtual BOOL spell(const TCHAR *word) + virtual BOOL spell(const wchar_t *word) { load(); if (loaded != LANGUAGE_LOADED) @@ -584,7 +584,7 @@ public: } // Return a list of suggestions to a word - virtual Suggestions suggest(const TCHAR * word) + virtual Suggestions suggest(const wchar_t * word) { Suggestions ret = { 0 }; @@ -600,7 +600,7 @@ public: if (ret.count > 0 && words != NULL) { // Oki, lets make our array - ret.words = (TCHAR **)malloc(ret.count * sizeof(TCHAR *)); + ret.words = (wchar_t **)malloc(ret.count * sizeof(wchar_t *)); for (unsigned i = 0; i < ret.count; i++) { ret.words[i] = fromHunspell(words[i]); free(words[i]); @@ -613,7 +613,7 @@ public: } // Return a list of auto suggestions to a word - virtual Suggestions autoSuggest(const TCHAR * word) + virtual Suggestions autoSuggest(const wchar_t * word) { Suggestions ret = { 0 }; @@ -632,7 +632,7 @@ public: // Oki, lets make our array ret.count = count; - ret.words = (TCHAR **)malloc(ret.count * sizeof(TCHAR *)); + ret.words = (wchar_t **)malloc(ret.count * sizeof(wchar_t *)); for (int i = 0; i < count; i++) { ret.words[i] = fromHunspell(words[i]); free(words[i]); @@ -644,7 +644,7 @@ public: // Return a list of auto suggestions to a word // You have to free the list AND each item - virtual TCHAR * autoSuggestOne(const TCHAR * word) + virtual wchar_t * autoSuggestOne(const wchar_t * word) { load(); if (loaded != LANGUAGE_LOADED) @@ -659,7 +659,7 @@ public: if (count <= 0) return NULL; - TCHAR *ret = fromHunspell(words[0]); + wchar_t *ret = fromHunspell(words[0]); // Oki, lets make our array for (int i = 0; i < count; i++) @@ -670,7 +670,7 @@ public: } // Return TRUE if the char is a word char - virtual BOOL isWordChar(TCHAR c) + virtual BOOL isWordChar(wchar_t c) { if (c == 0) return FALSE; @@ -679,7 +679,7 @@ public: if (loaded != LANGUAGE_LOADED) return TRUE; - return _tcschr(wordChars, (_TINT)c) != NULL; + return wcschr(wordChars, (_TINT)c) != NULL; } // Assert that all needed data is loaded @@ -698,14 +698,14 @@ public: // Add a word to the user custom dict - virtual void addWord(const TCHAR * word) + virtual void addWord(const wchar_t * word) { addWordInternal(word); appendToCustomDict(word); } // Add a word to the list of ignored words - virtual void ignoreWord(const TCHAR * word) + virtual void ignoreWord(const wchar_t * word) { addWordInternal(word); } @@ -725,15 +725,15 @@ LIST<Dictionary> *tmp_dicts; // To get the names of the languages BOOL CALLBACK EnumLocalesProc(LPTSTR lpLocaleString) { - TCHAR *stopped = NULL; - USHORT langID = (USHORT)_tcstol(lpLocaleString, &stopped, 16); + wchar_t *stopped = NULL; + USHORT langID = (USHORT)wcstol(lpLocaleString, &stopped, 16); - TCHAR ini[32]; - TCHAR end[32]; + wchar_t ini[32]; + wchar_t end[32]; GetLocaleInfo(MAKELCID(langID, 0), LOCALE_SISO639LANGNAME, ini, _countof(ini)); GetLocaleInfo(MAKELCID(langID, 0), LOCALE_SISO3166CTRYNAME, end, _countof(end)); - TCHAR name[64]; + wchar_t name[64]; mir_sntprintf(name, L"%s_%s", ini, end); for (int i = 0; i < tmp_dicts->getCount(); i++) { @@ -747,10 +747,10 @@ BOOL CALLBACK EnumLocalesProc(LPTSTR lpLocaleString) if (dict->localized_name[0] == 0) GetLocaleInfo(MAKELCID(langID, 0), LOCALE_SNATIVEDISPLAYNAME, dict->localized_name, _countof(dict->localized_name)); if (dict->localized_name[0] == 0 && dict->english_name[0] != 0) { - TCHAR country[1024]; + wchar_t country[1024]; GetLocaleInfo(MAKELCID(langID, 0), LOCALE_SENGCOUNTRY, country, _countof(country)); - TCHAR localName[1024]; + wchar_t localName[1024]; if (country[0] != 0) mir_sntprintf(localName, L"%s (%s)", dict->english_name, country); else @@ -778,7 +778,7 @@ void GetDictsInfo(LIST<Dictionary> &dicts) for (int i = 0; i < dicts.getCount(); i++) { Dictionary *dict = dicts[i]; - if (dict->full_name[0] == _T('\0')) { + if (dict->full_name[0] == '\0') { DBVARIANT dbv; char lang[128]; @@ -788,7 +788,7 @@ void GetDictsInfo(LIST<Dictionary> &dicts) db_free(&dbv); } - if (dict->localized_name[0] == _T('\0')) { + if (dict->localized_name[0] == '\0') { for (size_t j = 0; j < _countof(aditionalLanguages); j++) { if (!mir_tstrcmp(aditionalLanguages[j].language, dict->language)) { mir_tstrncpy(dict->localized_name, TranslateTS(aditionalLanguages[j].localized_name), _countof(dict->localized_name)); @@ -797,7 +797,7 @@ void GetDictsInfo(LIST<Dictionary> &dicts) } } - if (dict->localized_name[0] != _T('\0')) { + if (dict->localized_name[0] != '\0') { mir_sntprintf(dict->full_name, L"%s [%s]", dict->localized_name, dict->language); } else { @@ -808,10 +808,10 @@ void GetDictsInfo(LIST<Dictionary> &dicts) } -void GetHunspellDictionariesFromFolder(LIST<Dictionary> &dicts, TCHAR *path, TCHAR *user_path, TCHAR *source) +void GetHunspellDictionariesFromFolder(LIST<Dictionary> &dicts, wchar_t *path, wchar_t *user_path, wchar_t *source) { // Load the language files and create an array with then - TCHAR file[1024] = { 0 }; + wchar_t file[1024] = { 0 }; mir_sntprintf(file, L"%s\\*.dic", path); BOOL found = FALSE; @@ -833,14 +833,14 @@ void GetHunspellDictionariesFromFolder(LIST<Dictionary> &dicts, TCHAR *path, TCH if (attrib == 0xFFFFFFFF || (attrib & FILE_ATTRIBUTE_DIRECTORY)) continue; - ffd.cFileName[mir_tstrlen(ffd.cFileName) - 4] = _T('\0'); + ffd.cFileName[mir_tstrlen(ffd.cFileName) - 4] = '\0'; - TCHAR *lang = ffd.cFileName; + wchar_t *lang = ffd.cFileName; // Replace - for _ for (size_t i = 0; i < mir_tstrlen(lang); i++) - if (lang[i] == _T('-')) - lang[i] = _T('_'); + if (lang[i] == '-') + lang[i] = '_'; // Check if dict is new bool exists = false; @@ -850,7 +850,7 @@ void GetHunspellDictionariesFromFolder(LIST<Dictionary> &dicts, TCHAR *path, TCH if (!exists) { found = TRUE; - file[mir_tstrlen(file) - 4] = _T('\0'); + file[mir_tstrlen(file) - 4] = '\0'; dicts.insert(new HunspellDictionary(lang, file, user_path, source)); } } while (FindNextFile(hFFD, &ffd)); @@ -861,7 +861,7 @@ void GetHunspellDictionariesFromFolder(LIST<Dictionary> &dicts, TCHAR *path, TCH // Return a list of avaible languages -void GetAvaibleDictionaries(LIST<Dictionary> &dicts, TCHAR *path, TCHAR *user_path) +void GetAvaibleDictionaries(LIST<Dictionary> &dicts, wchar_t *path, wchar_t *user_path) { // Get miranda folder dicts GetHunspellDictionariesFromFolder(dicts, path, user_path, NULL); @@ -869,7 +869,7 @@ void GetAvaibleDictionaries(LIST<Dictionary> &dicts, TCHAR *path, TCHAR *user_pa if (opts.use_other_apps_dicts) { // Get other apps dicts for (int i = 0; i < _countof(otherHunspellApps); i++) { - TCHAR key[1024]; + wchar_t key[1024]; mir_sntprintf(key, APPPATH, otherHunspellApps[i].key); HKEY hKey = 0; @@ -893,8 +893,8 @@ void GetAvaibleDictionaries(LIST<Dictionary> &dicts, TCHAR *path, TCHAR *user_pa if (ERROR_SUCCESS != RegEnumValue(hKey, local, key, &cchValue, NULL, NULL, NULL, NULL)) break; key[cchValue] = 0; - TCHAR *pos; - if (pos = _tcsrchr(key, _T('\\'))) { + wchar_t *pos; + if (pos = wcsrchr(key, '\\')) { if (!mir_tstrcmpi(&pos[1], otherHunspellApps[i].key)) { pos[0] = 0; lResult = ERROR_SUCCESS; @@ -907,7 +907,7 @@ void GetAvaibleDictionaries(LIST<Dictionary> &dicts, TCHAR *path, TCHAR *user_pa } if (ERROR_SUCCESS == lResult) { - TCHAR folder[1024]; + wchar_t folder[1024]; mir_sntprintf(folder, L"%s\\Dictionaries", key); GetHunspellDictionariesFromFolder(languages, folder, user_path, otherHunspellApps[i].name); diff --git a/plugins/SpellChecker/src/dictionary.h b/plugins/SpellChecker/src/dictionary.h index 09902435f6..da70a6a4c2 100644 --- a/plugins/SpellChecker/src/dictionary.h +++ b/plugins/SpellChecker/src/dictionary.h @@ -23,7 +23,7 @@ Boston, MA 02111-1307, USA. struct Suggestions {
- TCHAR ** words;
+ wchar_t ** words;
size_t count;
};
@@ -32,37 +32,37 @@ struct Suggestions { // All dictionaries use a lazy interface
class Dictionary {
public:
- TCHAR language[128];
- TCHAR localized_name[128];
- TCHAR english_name[128];
- TCHAR full_name[256];
- TCHAR source[128];
+ wchar_t language[128];
+ wchar_t localized_name[128];
+ wchar_t english_name[128];
+ wchar_t full_name[256];
+ wchar_t source[128];
AutoReplaceMap *autoReplace;
HANDLE hIcolib;
virtual ~Dictionary();
// Return TRUE if the word is correct
- virtual BOOL spell(const TCHAR *) = 0;
+ virtual BOOL spell(const wchar_t *) = 0;
// Return a list of suggestions to a word
- virtual Suggestions suggest(const TCHAR * word) = 0;
+ virtual Suggestions suggest(const wchar_t * word) = 0;
// Return a list of auto suggestions to a word
- virtual Suggestions autoSuggest(const TCHAR * word) = 0;
+ virtual Suggestions autoSuggest(const wchar_t * word) = 0;
// Return a auto suggestions to a word
// You have to free the item
- virtual TCHAR * autoSuggestOne(const TCHAR * word) = 0;
+ virtual wchar_t * autoSuggestOne(const wchar_t * word) = 0;
// Return TRUE if the char is a word char
- virtual BOOL isWordChar(TCHAR c) = 0;
+ virtual BOOL isWordChar(wchar_t c) = 0;
// Add a word to the user custom dict
- virtual void addWord(const TCHAR * word) = 0;
+ virtual void addWord(const wchar_t * word) = 0;
// Add a word to the list of ignored words
- virtual void ignoreWord(const TCHAR * word) = 0;
+ virtual void ignoreWord(const wchar_t * word) = 0;
// Assert that all needed data is loaded
virtual void load() = 0;
@@ -74,7 +74,7 @@ public: // Return a list of avaible languages
-void GetAvaibleDictionaries(LIST<Dictionary> &dicts, TCHAR *path, TCHAR *user_path);
+void GetAvaibleDictionaries(LIST<Dictionary> &dicts, wchar_t *path, wchar_t *user_path);
// Free the list returned by GetAvaibleDictionaries
void FreeDictionaries(LIST<Dictionary> &dicts);
diff --git a/plugins/SpellChecker/src/options.cpp b/plugins/SpellChecker/src/options.cpp index ed625ab6f2..c0bc78ab5a 100644 --- a/plugins/SpellChecker/src/options.cpp +++ b/plugins/SpellChecker/src/options.cpp @@ -88,7 +88,7 @@ void LoadOptions() LoadOpts(autoReplaceControls, _countof(autoReplaceControls), MODULE_NAME);
if (languages.getCount() <= 0) {
- opts.default_language[0] = _T('\0');
+ opts.default_language[0] = '\0';
return;
}
@@ -213,7 +213,7 @@ static INT_PTR CALLBACK OptionsDlgProc(HWND hwndDlg, UINT msg, WPARAM wParam, LP if (sel >= languages.getCount())
sel = 0;
db_set_ts(NULL, MODULE_NAME, "DefaultLanguage",
- (TCHAR *)languages[sel]->language);
+ (wchar_t *)languages[sel]->language);
mir_tstrcpy(opts.default_language, languages[sel]->language);
}
}
@@ -247,21 +247,21 @@ static INT_PTR CALLBACK OptionsDlgProc(HWND hwndDlg, UINT msg, WPARAM wParam, LP struct AutoreplaceData
{
Dictionary *dict;
- map<tstring, AutoReplacement> autoReplaceMap;
+ map<std::wstring, AutoReplacement> autoReplaceMap;
BOOL initialized;
BOOL changed;
AutoreplaceData(Dictionary *dict) : dict(dict), initialized(FALSE), changed(FALSE) {}
- void RemoveWord(const TCHAR *aWord)
+ void RemoveWord(const wchar_t *aWord)
{
- map<tstring, AutoReplacement>::iterator it = autoReplaceMap.find(aWord);
+ map<std::wstring, AutoReplacement>::iterator it = autoReplaceMap.find(aWord);
if (it != autoReplaceMap.end())
autoReplaceMap.erase(it);
changed = TRUE;
}
- void AddWord(const TCHAR *find, const TCHAR *replace, BOOL useVars)
+ void AddWord(const wchar_t *find, const wchar_t *replace, BOOL useVars)
{
autoReplaceMap[find] = AutoReplacement(replace, useVars);
changed = TRUE;
@@ -302,26 +302,26 @@ static void LoadReplacements(HWND hwndDlg) data->initialized = TRUE;
}
- map<tstring, AutoReplacement>::iterator it = data->autoReplaceMap.begin();
+ map<std::wstring, AutoReplacement>::iterator it = data->autoReplaceMap.begin();
for (int i = 0; it != data->autoReplaceMap.end(); it++, i++) {
LVITEM item = { 0 };
item.mask = LVIF_TEXT | LVIF_PARAM;
item.iItem = i;
item.iSubItem = 0;
- item.pszText = (TCHAR *)it->first.c_str();
+ item.pszText = (wchar_t *)it->first.c_str();
item.lParam = i;
ListView_InsertItem(hList, &item);
- ListView_SetItemText(hList, i, 1, (TCHAR *)it->second.replace.c_str());
+ ListView_SetItemText(hList, i, 1, (wchar_t *)it->second.replace.c_str());
}
EnableDisableCtrls(hwndDlg);
}
static void SaveNewReplacements(BOOL canceled, Dictionary*,
- const TCHAR *find, const TCHAR *replace, BOOL useVariables,
- const TCHAR *original_find, void *param)
+ const wchar_t *find, const wchar_t *replace, BOOL useVariables,
+ const wchar_t *original_find, void *param)
{
if (canceled)
return;
@@ -342,8 +342,8 @@ static void ShowAddReplacement(HWND hwndDlg, int item = -1) AutoreplaceData *data = (AutoreplaceData *)SendDlgItemMessage(hwndDlg, IDC_LANGUAGE, CB_GETITEMDATA, sel, 0);
- TCHAR find[256];
- const TCHAR *replace = NULL;
+ wchar_t find[256];
+ const wchar_t *replace = NULL;
BOOL useVariables = FALSE;
if (item < 0)
@@ -430,7 +430,7 @@ static INT_PTR CALLBACK AutoreplaceDlgProc(HWND hwndDlg, UINT msg, WPARAM wParam sel = SendMessage(hList, LVM_GETNEXTITEM, -1, LVNI_SELECTED);
while (sel >= 0) {
- TCHAR tmp[256];
+ wchar_t tmp[256];
ListView_GetItemText(hList, sel, 0, tmp, _countof(tmp));
data->RemoveWord(tmp);
diff --git a/plugins/SpellChecker/src/options.h b/plugins/SpellChecker/src/options.h index 65e33c0f4e..8d699d4adf 100644 --- a/plugins/SpellChecker/src/options.h +++ b/plugins/SpellChecker/src/options.h @@ -31,7 +31,7 @@ Boston, MA 02111-1307, USA. struct Options
{
- TCHAR default_language[32];
+ wchar_t default_language[32];
BOOL auto_replace_dict;
BOOL auto_replace_user;
BOOL ignore_uppercase;
diff --git a/plugins/SpellChecker/src/spellchecker.cpp b/plugins/SpellChecker/src/spellchecker.cpp index 7d12a021f5..e6217118c4 100644 --- a/plugins/SpellChecker/src/spellchecker.cpp +++ b/plugins/SpellChecker/src/spellchecker.cpp @@ -40,13 +40,13 @@ HINSTANCE hInst; int hLangpack = 0; HANDLE hDictionariesFolder = NULL; -TCHAR *dictionariesFolder; +wchar_t *dictionariesFolder; HANDLE hCustomDictionariesFolder = NULL; -TCHAR *customDictionariesFolder; +wchar_t *customDictionariesFolder; HANDLE hFlagsDllFolder = NULL; -TCHAR *flagsDllFolder; +wchar_t *flagsDllFolder; HBITMAP hCheckedBmp; BITMAP bmpChecked; @@ -79,7 +79,7 @@ static int IconsChanged(WPARAM, LPARAM) for (int i = 0; i < languages.getCount(); i++) { sid.dwId = i; - TCHAR tmp[128]; + wchar_t tmp[128]; mir_sntprintf(tmp, L"%s - %s", TranslateT("Spell Checker"), languages[i]->full_name); sid.tszTooltip = tmp; @@ -108,19 +108,19 @@ static int ModulesLoaded(WPARAM, LPARAM) // Folders plugin support if (hDictionariesFolder = FoldersRegisterCustomPathT(LPGEN("Spell Checker"), LPGEN("Dictionaries"), DICTIONARIES_FOLDER)) { - dictionariesFolder = (TCHAR *)mir_alloc(sizeof(TCHAR) * MAX_PATH); + dictionariesFolder = (wchar_t *)mir_alloc(sizeof(wchar_t) * MAX_PATH); FoldersGetCustomPathT(hDictionariesFolder, dictionariesFolder, MAX_PATH, L"."); } else dictionariesFolder = Utils_ReplaceVarsT(DICTIONARIES_FOLDER); if (hCustomDictionariesFolder = FoldersRegisterCustomPathT(LPGEN("Spell Checker"), LPGEN("Custom Dictionaries"), CUSTOM_DICTIONARIES_FOLDER)) { - customDictionariesFolder = (TCHAR *)mir_alloc(sizeof(TCHAR) * MAX_PATH); + customDictionariesFolder = (wchar_t *)mir_alloc(sizeof(wchar_t) * MAX_PATH); FoldersGetCustomPathT(hCustomDictionariesFolder, customDictionariesFolder, MAX_PATH, L"."); } else customDictionariesFolder = Utils_ReplaceVarsT(CUSTOM_DICTIONARIES_FOLDER); if (hFlagsDllFolder = FoldersRegisterCustomPathT(LPGEN("Spell Checker"), LPGEN("Flags DLL"), FLAGS_DLL_FOLDER)) { - flagsDllFolder = (TCHAR *)mir_alloc(sizeof(TCHAR) * MAX_PATH); + flagsDllFolder = (wchar_t *)mir_alloc(sizeof(wchar_t) * MAX_PATH); FoldersGetCustomPathT(hFlagsDllFolder, flagsDllFolder, MAX_PATH, L"."); } else flagsDllFolder = Utils_ReplaceVarsT(FLAGS_DLL_FOLDER); @@ -133,21 +133,21 @@ static int ModulesLoaded(WPARAM, LPARAM) if (opts.use_flags) { // Load flags dll - TCHAR flag_file[MAX_PATH]; + wchar_t flag_file[MAX_PATH]; mir_sntprintf(flag_file, L"%s\\flags_icons.dll", flagsDllFolder); HMODULE hFlagsDll = LoadLibraryEx(flag_file, NULL, LOAD_LIBRARY_AS_DATAFILE); - TCHAR path[MAX_PATH]; + wchar_t path[MAX_PATH]; GetModuleFileName(hInst, path, MAX_PATH); SKINICONDESC sid = { 0 }; sid.flags = SIDF_ALL_TCHAR | SIDF_SORTED; - sid.section.t = LPGENT("Spell Checker") L"/" LPGENT("Flags"); + sid.section.w = LPGENW("Spell Checker") L"/" LPGENW("Flags"); // Get language flags for (int i = 0; i < languages.getCount(); i++) { Dictionary *p = languages[i]; - sid.description.t = p->full_name; + sid.description.w = p->full_name; char lang[32]; mir_snprintf(lang, "spell_lang_%d", i); @@ -159,13 +159,13 @@ static int ModulesLoaded(WPARAM, LPARAM) if (hFlag != NULL) { sid.hDefaultIcon = hFlag; - sid.defaultFile.t = NULL; + sid.defaultFile.w = NULL; sid.iDefaultIndex = 0; } else { hFlagIcoLib = IcoLib_GetIcon("spellchecker_unknown"); sid.hDefaultIcon = hFlagIcoLib; - sid.defaultFile.t = NULL; + sid.defaultFile.w = NULL; sid.iDefaultIndex = 0; } @@ -183,7 +183,7 @@ static int ModulesLoaded(WPARAM, LPARAM) for (int j = 0; j < languages.getCount(); j++) { Dictionary *dict = languages[j]; - TCHAR filename[MAX_PATH]; + wchar_t filename[MAX_PATH]; mir_sntprintf(filename, L"%s\\%s.ar", customDictionariesFolder, dict->language); dict->autoReplace = new AutoReplaceMap(filename, dict); @@ -204,7 +204,7 @@ static int ModulesLoaded(WPARAM, LPARAM) for (int i = 0; i < languages.getCount(); i++) { sid.dwId = i; - TCHAR tmp[128]; + wchar_t tmp[128]; mir_sntprintf(tmp, L"%s - %s", TranslateT("Spell Checker"), languages[i]->full_name); sid.tszTooltip = tmp; sid.hIcon = (opts.use_flags) ? IcoLib_GetIconByHandle(languages[i]->hIcolib) : IcoLib_GetIcon("spellchecker_enabled"); diff --git a/plugins/SpellChecker/src/stdafx.h b/plugins/SpellChecker/src/stdafx.h index 66e5e39f3f..ea4ea9b6bc 100644 --- a/plugins/SpellChecker/src/stdafx.h +++ b/plugins/SpellChecker/src/stdafx.h @@ -96,7 +96,7 @@ extern HBITMAP hCheckedBmp; struct WrongWordPopupMenuData
{
Suggestions suggestions;
- TCHAR *word;
+ wchar_t *word;
CHARRANGE pos;
HMENU hMeSubMenu;
HMENU hCorrectSubMenu;
@@ -110,7 +110,7 @@ struct Dialog MCONTACT hContact;
char name[64];
Dictionary *lang;
- TCHAR lang_name[32];
+ wchar_t lang_name[32];
BOOL enabled;
BOOL srmm;
@@ -129,11 +129,11 @@ struct Dialog };
static BOOL CenterParent(HWND hwnd);
-TCHAR *lstrtrim(TCHAR *str);
-BOOL lstreq(TCHAR *a, TCHAR *b, size_t len = -1);
-inline BOOL IsNumber(TCHAR c)
+wchar_t *lstrtrim(wchar_t *str);
+BOOL lstreq(wchar_t *a, wchar_t *b, size_t len = -1);
+inline BOOL IsNumber(wchar_t c)
{
- return c >= _T('0') && c <= _T('9');
+ return c >= '0' && c <= '9';
}
int MsgWindowEvent(WPARAM wParam, LPARAM lParam);
@@ -151,9 +151,9 @@ INT_PTR ShowPopupMenuService(WPARAM wParam, LPARAM lParam); LRESULT CALLBACK MenuWndProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam);
void ModifyIcon(Dialog *dlg);
-BOOL GetWordCharRange(Dialog *dlg, CHARRANGE &sel, TCHAR *text, size_t text_len, int &first_char);
-TCHAR *GetWordUnderPoint(Dialog *dlg, POINT pt, CHARRANGE &sel);
+BOOL GetWordCharRange(Dialog *dlg, CHARRANGE &sel, wchar_t *text, size_t text_len, int &first_char);
+wchar_t *GetWordUnderPoint(Dialog *dlg, POINT pt, CHARRANGE &sel);
-int GetClosestLanguage(TCHAR *lang_name);
+int GetClosestLanguage(wchar_t *lang_name);
#endif // __COMMONS_H__
diff --git a/plugins/SpellChecker/src/utils.cpp b/plugins/SpellChecker/src/utils.cpp index 7242f0c98c..7df9b00d14 100644 --- a/plugins/SpellChecker/src/utils.cpp +++ b/plugins/SpellChecker/src/utils.cpp @@ -19,7 +19,7 @@ Boston, MA 02111-1307, USA. #include "stdafx.h"
-typedef void(*FoundWrongWordCallback)(TCHAR *word, CHARRANGE pos, void *param);
+typedef void(*FoundWrongWordCallback)(wchar_t *word, CHARRANGE pos, void *param);
typedef map<HWND, Dialog *> DialogMapType;
DialogMapType dialogs;
@@ -95,20 +95,20 @@ void SetNoUnderline(Dialog *dlg) dlg->re->Start();
}
-inline BOOL IsURL(TCHAR c)
+inline BOOL IsURL(wchar_t c)
{
- return (c >= _T('a') && c <= _T('z'))
- || (c >= _T('A') && c <= _T('Z'))
+ return (c >= 'a' && c <= 'z')
+ || (c >= 'A' && c <= 'Z')
|| IsNumber(c)
- || c == _T('.') || c == _T('/')
- || c == _T('\\') || c == _T('?')
- || c == _T('=') || c == _T('&')
- || c == _T('%') || c == _T('-')
- || c == _T('_') || c == _T(':')
- || c == _T('@') || c == _T('#');
+ || c == '.' || c == '/'
+ || c == '\\' || c == '?'
+ || c == '=' || c == '&'
+ || c == '%' || c == '-'
+ || c == '_' || c == ':'
+ || c == '@' || c == '#';
}
-int FindURLEnd(Dialog *dlg, TCHAR *text, int start_pos, int *checked_until = NULL)
+int FindURLEnd(Dialog *dlg, wchar_t *text, int start_pos, int *checked_until = NULL)
{
int num_slashes = 0;
int num_ats = 0;
@@ -117,12 +117,12 @@ int FindURLEnd(Dialog *dlg, TCHAR *text, int start_pos, int *checked_until = NUL int i = start_pos;
for (; IsURL(text[i]) || dlg->lang->isWordChar(text[i]); i++) {
- TCHAR c = text[i];
- if (c == _T('\\') || c == _T('/'))
+ wchar_t c = text[i];
+ if (c == '\\' || c == '/')
num_slashes++;
- else if (c == _T('.'))
+ else if (c == '.')
num_dots++;
- else if (c == _T('@'))
+ else if (c == '@')
num_ats++;
}
@@ -142,7 +142,7 @@ int FindURLEnd(Dialog *dlg, TCHAR *text, int start_pos, int *checked_until = NUL }
-int ReplaceWord(Dialog *dlg, CHARRANGE &sel, TCHAR *new_word)
+int ReplaceWord(Dialog *dlg, CHARRANGE &sel, wchar_t *new_word)
{
dlg->re->Stop();
dlg->re->ResumeUndo();
@@ -161,10 +161,10 @@ public: virtual ~TextParser() {}
/// @return true when finished an word
- virtual bool feed(int pos, TCHAR c) = 0;
+ virtual bool feed(int pos, wchar_t c) = 0;
virtual int getFirstCharPos() = 0;
virtual void reset() = 0;
- virtual void deal(const TCHAR *text, bool *mark, bool *replace, TCHAR **replacement) = 0;
+ virtual void deal(const wchar_t *text, bool *mark, bool *replace, wchar_t **replacement) = 0;
};
class SpellParser : public TextParser
@@ -185,14 +185,14 @@ public: found_real_char = FALSE;
}
- virtual bool feed(int pos, TCHAR c)
+ virtual bool feed(int pos, wchar_t c)
{
// Is inside a word?
if (dict->isWordChar(c) || IsNumber(c)) {
if (last_pos == -1)
last_pos = pos;
- if (c != _T('-') && !IsNumber(c))
+ if (c != '-' && !IsNumber(c))
found_real_char = TRUE;
return false;
@@ -209,7 +209,7 @@ public: return (!found_real_char) ? -1 : last_pos;
}
- virtual void deal(const TCHAR *text, bool *mark, bool *replace, TCHAR **replacement)
+ virtual void deal(const wchar_t *text, bool *mark, bool *replace, wchar_t **replacement)
{
// Is it correct?
if (dict->spell(text))
@@ -244,7 +244,7 @@ public: last_pos = -1;
}
- virtual bool feed(int pos, TCHAR c)
+ virtual bool feed(int pos, wchar_t c)
{
// Is inside a word?
if (ar->isWordChar(c)) {
@@ -261,7 +261,7 @@ public: return last_pos;
}
- virtual void deal(const TCHAR *text, bool*, bool *replace, TCHAR **replacement)
+ virtual void deal(const wchar_t *text, bool*, bool *replace, wchar_t **replacement)
{
*replacement = ar->autoReplace(text);
if (*replacement != NULL)
@@ -274,7 +274,7 @@ int CheckTextLine(Dialog *dlg, int line, TextParser *parser, const CHARRANGE &ignored, FoundWrongWordCallback callback, void *param)
{
int errors = 0;
- TCHAR text[1024];
+ wchar_t text[1024];
dlg->re->GetLine(line, text, _countof(text));
int len = mir_tstrlen(text);
int first_char = dlg->re->GetFirstCharOfLine(line);
@@ -312,7 +312,7 @@ int CheckTextLine(Dialog *dlg, int line, TextParser *parser, }
}
else {
- TCHAR c = text[pos];
+ wchar_t c = text[pos];
BOOL feed = parser->feed(pos, c);
if (!feed) {
@@ -356,7 +356,7 @@ int CheckTextLine(Dialog *dlg, int line, TextParser *parser, bool mark = false;
bool replace = false;
- TCHAR *replacement = NULL;
+ wchar_t *replacement = NULL;
parser->deal(&text[last_pos], &mark, &replace, &replacement);
if (replace) {
@@ -431,12 +431,12 @@ int CheckText(Dialog *dlg, BOOL check_all, FoundWrongWordCallback callback = NUL return errors;
}
-void ToLocaleID(TCHAR *szKLName, size_t size)
+void ToLocaleID(wchar_t *szKLName, size_t size)
{
- TCHAR *stopped = NULL;
- USHORT langID = (USHORT)_tcstol(szKLName, &stopped, 16);
+ wchar_t *stopped = NULL;
+ USHORT langID = (USHORT)wcstol(szKLName, &stopped, 16);
- TCHAR ini[32], end[32];
+ wchar_t ini[32], end[32];
GetLocaleInfo(MAKELCID(langID, 0), LOCALE_SISO639LANGNAME, ini, _countof(ini));
GetLocaleInfo(MAKELCID(langID, 0), LOCALE_SISO3166CTRYNAME, end, _countof(end));
@@ -445,7 +445,7 @@ void ToLocaleID(TCHAR *szKLName, size_t size) void LoadDictFromKbdl(Dialog *dlg)
{
- TCHAR szKLName[KL_NAMELENGTH + 1];
+ wchar_t szKLName[KL_NAMELENGTH + 1];
// Use default input language
HKL hkl = GetKeyboardLayout(0);
@@ -500,7 +500,7 @@ LRESULT CALLBACK OwnerProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam) if (opts.ask_when_sending_with_error) {
int errors = TimerCheck(dlg, TRUE);
if (errors > 0) {
- TCHAR text[500];
+ wchar_t text[500];
mir_sntprintf(text, TranslateT("There are %d spelling errors. Are you sure you want to send this message?"), errors);
if (MessageBox(hwnd, text, TranslateT("Spell Checker"), MB_ICONQUESTION | MB_YESNO) == IDNO)
return TRUE;
@@ -584,7 +584,7 @@ LRESULT CALLBACK EditProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam) break;
{
- TCHAR c = (TCHAR)wParam;
+ wchar_t c = (wchar_t)wParam;
BOOL deleting = (c == VK_BACK || c == VK_DELETE);
// Need to do that to avoid changing the word while typing
@@ -616,7 +616,7 @@ LRESULT CALLBACK EditProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam) CHARRANGE sel = dlg->re->GetSel();
- TCHAR text[1024];
+ wchar_t text[1024];
int first_char;
GetWordCharRange(dlg, sel, text, _countof(text), first_char);
@@ -674,7 +674,7 @@ LRESULT CALLBACK EditProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam) return ret;
}
-int GetClosestLanguage(TCHAR *lang_name)
+int GetClosestLanguage(wchar_t *lang_name)
{
int i;
@@ -684,11 +684,11 @@ int GetClosestLanguage(TCHAR *lang_name) return i;
// Try searching by the prefix only
- TCHAR lang[128];
+ wchar_t lang[128];
mir_tstrncpy(lang, lang_name, _countof(lang));
{
- TCHAR *p = _tcschr(lang, _T('_'));
- if (p != NULL) *p = _T('\0');
+ wchar_t *p = wcschr(lang, '_');
+ if (p != NULL) *p = '\0';
}
// First check if there is a language that is only the prefix
@@ -699,7 +699,7 @@ int GetClosestLanguage(TCHAR *lang_name) // Now try any suffix
size_t len = mir_tstrlen(lang);
for (i = 0; i < languages.getCount(); i++) {
- TCHAR *p = _tcschr(languages[i]->language, _T('_'));
+ wchar_t *p = wcschr(languages[i]->language, '_');
if (p == NULL)
continue;
@@ -707,7 +707,7 @@ int GetClosestLanguage(TCHAR *lang_name) if (prefix_len != len)
continue;
- if (_tcsnicmp(languages[i]->language, lang_name, len) == 0)
+ if (wcsnicmp(languages[i]->language, lang_name, len) == 0)
return i;
}
@@ -734,7 +734,7 @@ void GetUserProtoLanguageSetting(Dialog *dlg, MCONTACT hContact, char *group, ch }
if (dbv.type == DBVT_TCHAR && dbv.ptszVal != NULL) {
- TCHAR *lang = dbv.ptszVal;
+ wchar_t *lang = dbv.ptszVal;
for (int i = 0; i < languages.getCount(); i++) {
Dictionary *dict = languages[i];
@@ -756,18 +756,18 @@ void GetUserLanguageSetting(Dialog *dlg, char *setting) return;
GetUserProtoLanguageSetting(dlg, dlg->hContact, proto, setting);
- if (dlg->lang_name[0] != _T('\0'))
+ if (dlg->lang_name[0] != '\0')
return;
GetUserProtoLanguageSetting(dlg, dlg->hContact, "UserInfo", setting, FALSE);
- if (dlg->lang_name[0] != _T('\0'))
+ if (dlg->lang_name[0] != '\0')
return;
// If not found and is inside meta, try to get from the meta
MCONTACT hMetaContact = db_mc_getMeta(dlg->hContact);
if (hMetaContact != NULL) {
GetUserProtoLanguageSetting(dlg, hMetaContact, META_PROTO, setting);
- if (dlg->lang_name[0] != _T('\0'))
+ if (dlg->lang_name[0] != '\0')
return;
GetUserProtoLanguageSetting(dlg, hMetaContact, "UserInfo", setting, FALSE);
@@ -778,7 +778,7 @@ void GetContactLanguage(Dialog *dlg) {
DBVARIANT dbv = { 0 };
- dlg->lang_name[0] = _T('\0');
+ dlg->lang_name[0] = '\0';
if (dlg->hContact == NULL) {
if (!db_get_ts(NULL, MODULE_NAME, dlg->name, &dbv)) {
@@ -792,13 +792,13 @@ void GetContactLanguage(Dialog *dlg) db_free(&dbv);
}
- if (dlg->lang_name[0] == _T('\0') && !db_get_ts(dlg->hContact, "eSpeak", "TalkLanguage", &dbv)) {
+ if (dlg->lang_name[0] == '\0' && !db_get_ts(dlg->hContact, "eSpeak", "TalkLanguage", &dbv)) {
mir_tstrncpy(dlg->lang_name, dbv.ptszVal, _countof(dlg->lang_name));
db_free(&dbv);
}
// Try from metacontact
- if (dlg->lang_name[0] == _T('\0')) {
+ if (dlg->lang_name[0] == '\0') {
MCONTACT hMetaContact = db_mc_getMeta(dlg->hContact);
if (hMetaContact != NULL) {
if (!db_get_ts(hMetaContact, MODULE_NAME, "TalkLanguage", &dbv)) {
@@ -806,7 +806,7 @@ void GetContactLanguage(Dialog *dlg) db_free(&dbv);
}
- if (dlg->lang_name[0] == _T('\0') && !db_get_ts(hMetaContact, "eSpeak", "TalkLanguage", &dbv)) {
+ if (dlg->lang_name[0] == '\0' && !db_get_ts(hMetaContact, "eSpeak", "TalkLanguage", &dbv)) {
mir_tstrncpy(dlg->lang_name, dbv.ptszVal, _countof(dlg->lang_name));
db_free(&dbv);
}
@@ -814,17 +814,17 @@ void GetContactLanguage(Dialog *dlg) }
// Try to get from Language info
- if (dlg->lang_name[0] == _T('\0'))
+ if (dlg->lang_name[0] == '\0')
GetUserLanguageSetting(dlg, "Language");
- if (dlg->lang_name[0] == _T('\0'))
+ if (dlg->lang_name[0] == '\0')
GetUserLanguageSetting(dlg, "Language1");
- if (dlg->lang_name[0] == _T('\0'))
+ if (dlg->lang_name[0] == '\0')
GetUserLanguageSetting(dlg, "Language2");
- if (dlg->lang_name[0] == _T('\0'))
+ if (dlg->lang_name[0] == '\0')
GetUserLanguageSetting(dlg, "Language3");
// Use default lang
- if (dlg->lang_name[0] == _T('\0'))
+ if (dlg->lang_name[0] == '\0')
mir_tstrncpy(dlg->lang_name, opts.default_language, _countof(dlg->lang_name));
}
@@ -973,7 +973,7 @@ int RemoveContactTextBox(HWND hwnd) }
// TODO Make this better
-BOOL GetWordCharRange(Dialog *dlg, CHARRANGE &sel, TCHAR *text, size_t text_len, int &first_char)
+BOOL GetWordCharRange(Dialog *dlg, CHARRANGE &sel, wchar_t *text, size_t text_len, int &first_char)
{
// Get line
int line = dlg->re->GetLineFromChar(sel.cpMin);
@@ -989,7 +989,7 @@ BOOL GetWordCharRange(Dialog *dlg, CHARRANGE &sel, TCHAR *text, size_t text_len, sel.cpMin--;
sel.cpMin++;
- while (text[sel.cpMax - first_char] != _T('\0') && (dlg->lang->isWordChar(text[sel.cpMax - first_char])
+ while (text[sel.cpMax - first_char] != '\0' && (dlg->lang->isWordChar(text[sel.cpMax - first_char])
|| IsNumber(text[sel.cpMax - first_char])))
sel.cpMax++;
@@ -1000,12 +1000,12 @@ BOOL GetWordCharRange(Dialog *dlg, CHARRANGE &sel, TCHAR *text, size_t text_len, // See if it has only '-'s
BOOL has_valid_char = FALSE;
for (int i = sel.cpMin; i < sel.cpMax && !has_valid_char; i++)
- has_valid_char = (text[i - first_char] != _T('-'));
+ has_valid_char = (text[i - first_char] != '-');
return has_valid_char;
}
-TCHAR *GetWordUnderPoint(Dialog *dlg, POINT pt, CHARRANGE &sel)
+wchar_t *GetWordUnderPoint(Dialog *dlg, POINT pt, CHARRANGE &sel)
{
// Get text
if (dlg->re->GetTextLength() <= 0)
@@ -1015,19 +1015,19 @@ TCHAR *GetWordUnderPoint(Dialog *dlg, POINT pt, CHARRANGE &sel) sel.cpMin = sel.cpMax = dlg->re->GetCharFromPos(pt);
// Get text
- TCHAR text[1024];
+ wchar_t text[1024];
int first_char;
if (!GetWordCharRange(dlg, sel, text, _countof(text), first_char))
return NULL;
// copy the word
- text[sel.cpMax - first_char] = _T('\0');
- return _tcsdup(&text[sel.cpMin - first_char]);
+ text[sel.cpMax - first_char] = '\0';
+ return wcsdup(&text[sel.cpMin - first_char]);
}
-void AppendSubmenu(HMENU hMenu, HMENU hSubMenu, TCHAR *name)
+void AppendSubmenu(HMENU hMenu, HMENU hSubMenu, wchar_t *name)
{
MENUITEMINFO mii = { 0 };
mii.cbSize = sizeof(mii);
@@ -1039,7 +1039,7 @@ void AppendSubmenu(HMENU hMenu, HMENU hSubMenu, TCHAR *name) InsertMenuItem(hMenu, 0, TRUE, &mii);
}
-void AppendMenuItem(HMENU hMenu, int id, TCHAR *name, HICON hIcon, BOOL checked)
+void AppendMenuItem(HMENU hMenu, int id, wchar_t *name, HICON hIcon, BOOL checked)
{
ICONINFO iconInfo;
GetIconInfo(hIcon, &iconInfo);
@@ -1061,7 +1061,7 @@ void AppendMenuItem(HMENU hMenu, int id, TCHAR *name, HICON hIcon, BOOL checked) #define WORD_MENU_ID_BASE 100
#define AUTOREPLACE_MENU_ID_BASE 50
-void AddMenuForWord(Dialog *dlg, TCHAR *word, CHARRANGE &pos, HMENU hMenu, BOOL in_submenu, UINT base)
+void AddMenuForWord(Dialog *dlg, wchar_t *word, CHARRANGE &pos, HMENU hMenu, BOOL in_submenu, UINT base)
{
if (dlg->wrong_words == NULL)
dlg->wrong_words = new vector<WrongWordPopupMenuData>(1);
@@ -1116,7 +1116,7 @@ void AddMenuForWord(Dialog *dlg, TCHAR *word, CHARRANGE &pos, HMENU hMenu, BOOL if (!in_submenu && opts.show_wrong_word) {
InsertMenu(hMenu, 0, MF_BYPOSITION | MF_SEPARATOR, 0, 0);
- TCHAR text[128];
+ wchar_t text[128];
mir_sntprintf(text, TranslateT("Wrong word: %s"), word);
InsertMenu(hMenu, 0, MF_BYPOSITION, 0, text);
}
@@ -1128,13 +1128,13 @@ struct FoundWrongWordParam int count;
};
-void FoundWrongWord(TCHAR *word, CHARRANGE pos, void *param)
+void FoundWrongWord(wchar_t *word, CHARRANGE pos, void *param)
{
FoundWrongWordParam *p = (FoundWrongWordParam*)param;
p->count++;
- AddMenuForWord(p->dlg, _tcsdup(word), pos, p->dlg->hWrongWordsSubMenu, TRUE, WORD_MENU_ID_BASE * p->count);
+ AddMenuForWord(p->dlg, wcsdup(word), pos, p->dlg->hWrongWordsSubMenu, TRUE, WORD_MENU_ID_BASE * p->count);
}
void AddItemsToMenu(Dialog *dlg, HMENU hMenu, POINT pt, HWND hwndOwner)
@@ -1179,7 +1179,7 @@ void AddItemsToMenu(Dialog *dlg, HMENU hMenu, POINT pt, HWND hwndOwner) }
else {
CHARRANGE sel;
- TCHAR *word = GetWordUnderPoint(dlg, pt, sel);
+ wchar_t *word = GetWordUnderPoint(dlg, pt, sel);
if (word != NULL && !dlg->lang->spell(word)) {
InsertMenu(hMenu, 0, MF_BYPOSITION | MF_SEPARATOR, 0, 0);
AddMenuForWord(dlg, word, sel, hMenu, FALSE, WORD_MENU_ID_BASE);
@@ -1190,8 +1190,8 @@ void AddItemsToMenu(Dialog *dlg, HMENU hMenu, POINT pt, HWND hwndOwner) static void AddWordToDictCallback(BOOL canceled, Dictionary *dict,
- const TCHAR *find, const TCHAR *replace, BOOL useVariables,
- const TCHAR *, void *param)
+ const wchar_t *find, const wchar_t *replace, BOOL useVariables,
+ const wchar_t *, void *param)
{
if (canceled)
return;
@@ -1549,7 +1549,7 @@ LRESULT CALLBACK MenuWndProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam) return mir_callNextSubclass(hwnd, MenuWndProc, msg, wParam, lParam);
}
-TCHAR* lstrtrim(TCHAR *str)
+wchar_t* lstrtrim(wchar_t *str)
{
int len = mir_tstrlen(str);
@@ -1557,22 +1557,22 @@ TCHAR* lstrtrim(TCHAR *str) for (i = len - 1; i >= 0 && (str[i] == ' ' || str[i] == '\t'); --i);
if (i < len - 1) {
++i;
- str[i] = _T('\0');
+ str[i] = '\0';
len = i;
}
for (i = 0; i < len && (str[i] == ' ' || str[i] == '\t'); ++i);
if (i > 0)
- memmove(str, &str[i], (len - i + 1) * sizeof(TCHAR));
+ memmove(str, &str[i], (len - i + 1) * sizeof(wchar_t));
return str;
}
-BOOL lstreq(TCHAR *a, TCHAR *b, size_t len)
+BOOL lstreq(wchar_t *a, wchar_t *b, size_t len)
{
- a = CharLower(_tcsdup(a));
- b = CharLower(_tcsdup(b));
- BOOL ret = len ? !_tcsncmp(a, b, len) : !mir_tstrcmp(a, b);
+ a = CharLower(wcsdup(a));
+ b = CharLower(wcsdup(b));
+ BOOL ret = len ? !wcsncmp(a, b, len) : !mir_tstrcmp(a, b);
free(a);
free(b);
return ret;
|