Skip to content

Commit

Permalink
Merge branch 'epic/linux-mcompile' into chore/merge-master-into-linux…
Browse files Browse the repository at this point in the history
…-mcompile
  • Loading branch information
mcdurdin authored Oct 10, 2024
2 parents 4a67c5c + d8716d8 commit d541351
Show file tree
Hide file tree
Showing 17 changed files with 4,101 additions and 1 deletion.
1 change: 0 additions & 1 deletion .clang-format
Original file line number Diff line number Diff line change
Expand Up @@ -134,4 +134,3 @@ TabWidth: 8
UseCRLF: false
UseTab: Never
...

1 change: 1 addition & 0 deletions linux/build.sh
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ builder_describe \
":config=keyman-config keyman-config" \
":engine=ibus-keyman ibus-keyman" \
":service=keyman-system-service keyman-system-service" \
":mcompile=mcompile/keymap mnemonic layout recompiler for Linux" \
"clean" \
"configure" \
"build" \
Expand Down
3 changes: 3 additions & 0 deletions linux/mcompile/Readme.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
This is a proposal to rewrite mcompile for Linux. For this we need to query the base keyboard data from the Linux platform, then rewriting the keyboard .kmx using the same approach as is done in mcompile for Windows, but working from the data from the x11 keyboard on Linux.

Ideally, we'd rewrite mcompile to be cross-platform (Windows, Linux, macOS), so that the keyboard interrogation would be separated from the .kmx rewriting, at least to some degree. Nevertheless it would probably be easiest to start from a standalone implementation.
2 changes: 2 additions & 0 deletions linux/mcompile/keymap/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
resources/
build/
7 changes: 7 additions & 0 deletions linux/mcompile/keymap/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
This is a proposal to rewrite mcompile for Linux. For this we need to query the base keyboard data from the Linux platform, then rewriting the keyboard .kmx using the same approach as is done in mcompile for Windows, but working from the data from the x11 keyboard on Linux.

Ideally, we'd rewrite mcompile to be cross-platform (Windows, Linux, macOS), so that the keyboard interrogation would be separated from the .kmx rewriting, at least to some degree. Nevertheless it would probably be easiest to start from a standalone implementation.
Sample program that reads US basic keyboard and compares to key value group


# Keymap
63 changes: 63 additions & 0 deletions linux/mcompile/keymap/build.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
#!/usr/bin/env bash

## START STANDARD BUILD SCRIPT INCLUDE
# adjust relative paths as necessary
THIS_SCRIPT="$(readlink -f "${BASH_SOURCE[0]}")"
. "${THIS_SCRIPT%/*}/../../../resources/build/builder.inc.sh"
## END STANDARD BUILD SCRIPT INCLUDE

#. "$KEYMAN_ROOT/resources/shellHelperFunctions.sh"

################################ Main script ################################

builder_describe \
"Mnemonic layout recompiler for Linux" \
"@/common/include" \
"clean" \
"configure" \
"build" \
"test"

builder_parse "$@"

builder_describe_outputs \
configure build/build.ninja \
build build/mcompile

TARGET_PATH="$THIS_SCRIPT_PATH/build"

do_clean() {
rm -rf "$THIS_SCRIPT_PATH/resources"
rm -rf "$TARGET_PATH"
}

do_configure() {
# Import our standard compiler defines; this is copied from
# /resources/build/meson/standard.meson.build by build.sh, because meson doesn't
# allow us to reference a file outside its root
mkdir -p "$THIS_SCRIPT_PATH/resources"
cp "$KEYMAN_ROOT/resources/build/meson/standard.meson.build" "$THIS_SCRIPT_PATH/resources/meson.build"

pushd "$THIS_SCRIPT_PATH" > /dev/null
# Additional arguments are used by Linux build, e.g. -Dprefix=${INSTALLDIR}
meson setup build --buildtype $BUILDER_CONFIGURATION "${builder_extra_params[@]}"
popd > /dev/null

}

do_build() {
pushd "$TARGET_PATH" > /dev/null
ninja
popd > /dev/null
}

do_test() {
pushd "$TARGET_PATH" > /dev/null
meson test "${builder_extra_params[@]}"
popd > /dev/null
}

builder_run_action clean do_clean
builder_run_action configure do_configure
builder_run_action build do_build
builder_run_action test do_test
331 changes: 331 additions & 0 deletions linux/mcompile/keymap/deadkey.cpp

Large diffs are not rendered by default.

30 changes: 30 additions & 0 deletions linux/mcompile/keymap/deadkey.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@

#pragma once
#ifndef DEADKEY_H
#define DEADKEY_H

#include "mc_import_rules.h"
#include <map>

/** @brief create a Vector of DeadKey containing all combinations of deadkey + character for ALL possible Linux keyboards */
std::vector<DeadKey*> create_deadkeys_by_basechar();

/** @brief filter entries for the currently used Linux Keyboard out of a vector of all existing deadKey combinations */
void refine_alDead(KMX_WCHAR dk, std::vector<DeadKey*>& dkVec, std::vector<DeadKey*>& r_All_Vec);

/** @brief check whether a deadkey already exists in the deadkey vector */
bool found_dk_inVector(KMX_WCHAR dk, std::vector<DeadKey*>& dkVec);

/** @brief find all deadkey combinations for a certain deadkey in a vector of all deadkey combinations */
bool query_dk_combinations_for_specific_dk(vec_dword_2D& r_dk_ComposeTable, KMX_DWORD dk, vec_dword_2D& dk_SingleTable);

/** @brief convert a character to the upper-case equivalent and find the corresponding shiftstate of the entered keyval */
KMX_DWORD KMX_change_keyname_to_capital(KMX_DWORD kVal, KMX_DWORD& shift, GdkKeymap* keymap);

/** @brief append a 1D-vector containing name, base character and unicode_value to a 2D-Vector */
void add_deadkey_combination(vec_dword_2D& dk_ComposeTable, std::string diacritic_name, std::string base_char, KMX_DWORD unicode_value);

/** @brief create a 2D-Vector containing all possible combinations of deadkey + character for all Linux keyboards */
void create_DKTable(vec_dword_2D& dk_ComposeTable);

#endif /*DEADKEY_H*/
Loading

0 comments on commit d541351

Please sign in to comment.