Skip to content

Commit

Permalink
Continue 6359
Browse files Browse the repository at this point in the history
  • Loading branch information
alabuzhev committed Aug 17, 2024
1 parent e13c21a commit 56286af
Show file tree
Hide file tree
Showing 3 changed files with 25 additions and 4 deletions.
5 changes: 5 additions & 0 deletions far/changelog
Original file line number Diff line number Diff line change
@@ -1,3 +1,8 @@
--------------------------------------------------------------------------------
drkns 2024-08-17 11:35:12+01:00 - build 6360

1. Continue 6359.

--------------------------------------------------------------------------------
drkns 2024-08-15 01:55:21+01:00 - build 6359

Expand Down
22 changes: 19 additions & 3 deletions far/platform.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -676,6 +676,9 @@ static auto get_keyboard_layout_list_registry_ctf()

// GUID_TFCAT_TIP_KEYBOARD
const auto LayoutsKey = os::reg::key::current_user.open(far::format(L"{}\\AssemblyItem\\0x{:08X}\\{{34745C63-B2F0-4784-8B67-5E12C8701A31}}"sv, CtfSortOrderPath, Language.Id), KEY_ENUMERATE_SUB_KEYS);
if (!LayoutsKey)
continue;

for (const auto& IndexStr: LayoutsKey->enum_keys())
{
try
Expand Down Expand Up @@ -773,15 +776,28 @@ static auto default_keyboard_layout()
return GetKeyboardLayout(0);
}

static std::vector<HKL> try_get_keyboard_list(function_ref<std::vector<HKL>()> Callable)
{
try
{
return Callable();
}
catch (far_exception const& e)
{
LOGWARNING(L"{}", e);
return {};
}
}

std::vector<HKL> get_keyboard_layout_list()
{
auto Result = get_keyboard_layout_list_registry_ctf();
auto Result = try_get_keyboard_list(get_keyboard_layout_list_registry_ctf);

if (Result.empty())
Result = get_keyboard_layout_list_api();
Result = try_get_keyboard_list(get_keyboard_layout_list_api);

if (Result.empty())
Result = get_keyboard_layout_list_registry_base();
Result = try_get_keyboard_list(get_keyboard_layout_list_registry_base);

// Only the CTF method returns layouts in the correct order.
// We want to prioritise the default layout, because InitKeysArray uses the first match strategy,
Expand Down
2 changes: 1 addition & 1 deletion far/vbuild.m4
Original file line number Diff line number Diff line change
@@ -1 +1 @@
6359
6360

0 comments on commit 56286af

Please sign in to comment.