Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add DSPELLCHECK_GETLANGUAGELIST_MSG to get language list #341

Merged
merged 1 commit into from
Apr 10, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading