Skip to content

Commit 4f174f3

Browse files
authored
Add DSPELLCHECK_GETLANGUAGELIST_MSG to get language list (#341)
1 parent 91795f7 commit 4f174f3

File tree

2 files changed

+19
-3
lines changed

2 files changed

+19
-3
lines changed

include/PluginMsg.h

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,16 @@
11
#pragma once
22

3-
#define DSPELLCHECK_SETLANG_MSG 1
3+
#define DSPELLCHECK_SETLANG_MSG 1 // See DSpellCheckSetLangMsgInfo
4+
#define DSPELLCHECK_GETLANGUAGELIST_MSG 2 // See DSpellCheckGetLanguageListMsgInfo
45

5-
struct DSpellCheckSetLangMsgInfo
6-
{
6+
// Set language to lang_name, if was_success non-zero, it will be set to true in case of success and fales in case of failure
7+
struct DSpellCheckSetLangMsgInfo {
78
const wchar_t *lang_name;
89
bool *was_success; // optional out param, pointed bool set to true if language was switched
910
};
11+
12+
// language_callback will be called once for each language with payload provided as a second struct element
13+
struct DSpellCheckGetLanguageListMsgInfo {
14+
void (*language_callback)(void *payload, const wchar_t *lang_name);
15+
void *payload;
16+
};

src/plugin/Plugin.cpp

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -898,6 +898,15 @@ bool process_internal_msg(const CommunicationInfo& communication_info) {
898898
}
899899
}
900900
break;
901+
case DSPELLCHECK_GETLANGUAGELIST_MSG: {
902+
if (const auto info = reinterpret_cast<DSpellCheckGetLanguageListMsgInfo *>(communication_info.info)) {
903+
const auto lang_list = speller_container->active_speller().get_language_list();
904+
for (auto &lang : lang_list) {
905+
info->language_callback(info->payload, lang.orig_name.c_str());
906+
}
907+
}
908+
}
909+
return true;
901910
}
902911
return false;
903912
}

0 commit comments

Comments
 (0)