Skip to content

Commit

Permalink
Add DSPELLCHECK_GETLANGUAGELIST_MSG to get language list (#341)
Browse files Browse the repository at this point in the history
  • Loading branch information
Predelnik authored Apr 10, 2024
1 parent 91795f7 commit 4f174f3
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 3 deletions.
13 changes: 10 additions & 3 deletions include/PluginMsg.h
Original file line number Diff line number Diff line change
@@ -1,9 +1,16 @@
#pragma once

#define DSPELLCHECK_SETLANG_MSG 1
#define DSPELLCHECK_SETLANG_MSG 1 // See DSpellCheckSetLangMsgInfo
#define DSPELLCHECK_GETLANGUAGELIST_MSG 2 // See DSpellCheckGetLanguageListMsgInfo

struct DSpellCheckSetLangMsgInfo
{
// 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
struct DSpellCheckSetLangMsgInfo {
const wchar_t *lang_name;
bool *was_success; // optional out param, pointed bool set to true if language was switched
};

// language_callback will be called once for each language with payload provided as a second struct element
struct DSpellCheckGetLanguageListMsgInfo {
void (*language_callback)(void *payload, const wchar_t *lang_name);
void *payload;
};
9 changes: 9 additions & 0 deletions src/plugin/Plugin.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -898,6 +898,15 @@ bool process_internal_msg(const CommunicationInfo& communication_info) {
}
}
break;
case DSPELLCHECK_GETLANGUAGELIST_MSG: {
if (const auto info = reinterpret_cast<DSpellCheckGetLanguageListMsgInfo *>(communication_info.info)) {
const auto lang_list = speller_container->active_speller().get_language_list();
for (auto &lang : lang_list) {
info->language_callback(info->payload, lang.orig_name.c_str());
}
}
}
return true;
}
return false;
}
Expand Down

0 comments on commit 4f174f3

Please sign in to comment.