Skip to content

Commit

Permalink
Merge pull request #9384 from keymanapp/feat/linux/mcompile-DoConvert…
Browse files Browse the repository at this point in the history
…-read

feat(linux): mnemonic layout support 🐘
  • Loading branch information
mcdurdin authored Aug 14, 2024
2 parents fe21f86 + d0d5aa3 commit 2f0deef
Show file tree
Hide file tree
Showing 21 changed files with 3,620 additions and 2,476 deletions.
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
...

8 changes: 0 additions & 8 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -183,11 +183,3 @@ lcov.info
/keyman*.buildinfo
/keyman*.changes
/keyman*.tar.?z

#Sabine:
# /common/test/keyboards/invalid/source/*.kmx
# /developer/src/test/auto/kmcomp/*.kmn
# /developer/src/test/auto/kmcomp/*.kvk
# /developer/src/test/auto/kmcomp/*.kvk*
# /developer/src/test/auto/kmcomp/*.txt
/linux/mcompile/keymap/X_bak
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/
21 changes: 3 additions & 18 deletions linux/mcompile/keymap/README.md
Original file line number Diff line number Diff line change
@@ -1,22 +1,7 @@
# Keymap
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



TODO check if US basic is the right Keyboard to compare with
TODO non-letter characters don't work OK yet
TODO Umlauts don't work OK yet
TODO Check for use of correct dimensions in Vector/prevent error if dims are not correct
TODO prevent crashes: handle possible Errors in CreateCompleteRow_US, Split_US_To_3D_Vector
TODO check Keycode of TLDE, BKSL, LSGT
TODO remove unnecessary printf/cout
TODO path for xkb/symbols as compile time option in meson
TODO append_other_ToVector: ensure shift states of GetKeyvalsFromKeymap are not out of range
TODO check how many/which shift states we use ( at the moment we read all shiftstate-columns of US but then use only 2 colums
(non-shift + shift) then use as many colums for Other )

TODO define folder to store File_US.txt" in and find better name
TODO get rid of GTK functions that are deprecated and use X11 instead
TODO retrieve name of Other keyboard and use appropriate name instead of "Other"
TODO ...
# 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 2f0deef

Please sign in to comment.