feat(linux): mcompile-dk edit comments

This commit is contained in:
Sabine 2024-02-20 17:16:31 +01:00
parent 001dc52021
commit aa36aadcc0
10 changed files with 69 additions and 74 deletions

View file

@ -10,12 +10,9 @@ _S2 TODO QUESTION check if US basic is the right Keyboard to compare with
_S2 TODO check if I can use files from some other keyman path instead of a copy here ( e.g. filesystem.h exists elsewhere); where can I use incxstr from
_S2 TODO Do I need HKL for Linux / can I just use a void* or remove HKL ??, typeddef of KMX_HKL - can I delete all m_hkl from classes?
_S2 TODO Check/find use of wchar_t/wstring and replace with char16_t/u16string
_S2 TODO TODO keymap* or keymap** everywhere?
_S2 TODO check call by reference/value
_S2 TODO replace GDK
_S2 TODO what is wrong with kp->dpBitmapOffset/BitmapSize ?
_S2 TODO do I use all var in a function or are there unsused var?
_S2 TODO explain fields of aldead and All_Vector somewher
_s2 INFO idee spanish keyboard has dk on altgr !!
_S2 ...

View file

@ -10,25 +10,6 @@ v_dw_1D createLine(std::wstring first, std::wstring second, KMX_DWORD number, s
return line;
}
bool find_dk_combinations_for_specific_dk(v_dw_2D * p_dk_ComposeTable, v_dw_2D &dk_SingleTable, KMX_DWORD dk) {
v_dw_1D line;
for ( int i =0; i< (int) (*p_dk_ComposeTable).size(); i++) {
if (((*p_dk_ComposeTable)[i][0] == dk) && (IsKeymanUsedChar((*p_dk_ComposeTable)[i][1]))) {
line.push_back((*p_dk_ComposeTable)[i][0]);
line.push_back((*p_dk_ComposeTable)[i][1]);
line.push_back((*p_dk_ComposeTable)[i][2]);
dk_SingleTable.push_back(line);
line.clear();
}
}
if( dk_SingleTable.size()>0)
return true;
else
return false;
}
std::vector<DeadKey*> create_alDead() {
std::vector<DeadKey*> alDead;
v_dw_2D dk_ComposeTable;
@ -46,18 +27,6 @@ std::vector<DeadKey*> create_alDead() {
return alDead;
}
bool found_dk_inVector(KMX_WCHAR dk, std::vector<DeadKey*> &dkVec) {
int i=0;
if( dkVec.size() > 0) {
do {
if( dk == dkVec[i]->KMX_GetDeadCharacter())
return true;
i++;
} while (i < (int) dkVec.size());
}
return false;
}
void refine_alDead(KMX_WCHAR dk, std::vector<DeadKey*> &dkVec, std::vector<DeadKey*> *p_All_Vec) {
if( dk == 0)
return;
@ -73,6 +42,18 @@ void refine_alDead(KMX_WCHAR dk, std::vector<DeadKey*> &dkVec, std::vector<DeadK
}
}
bool found_dk_inVector(KMX_WCHAR dk, std::vector<DeadKey*> &dkVec) {
int i=0;
if( dkVec.size() > 0) {
do {
if( dk == dkVec[i]->KMX_GetDeadCharacter())
return true;
i++;
} while (i < (int) dkVec.size());
}
return false;
}
void sort_alDead(std::vector<DeadKey*> &small_Vec, std::vector<DeadKey*> *p_All_Vec) {
std::vector<DeadKey*> small_sorted;
int Vsmall_size;
@ -95,6 +76,25 @@ void sort_alDead(std::vector<DeadKey*> &small_Vec, std::vector<DeadKey*> *p_All_
small_Vec = small_sorted;
}
bool find_dk_combinations_for_specific_dk(v_dw_2D * p_dk_ComposeTable, v_dw_2D &dk_SingleTable, KMX_DWORD dk) {
v_dw_1D line;
for ( int i =0; i< (int) (*p_dk_ComposeTable).size(); i++) {
if (((*p_dk_ComposeTable)[i][0] == dk) && (IsKeymanUsedChar((*p_dk_ComposeTable)[i][1]))) {
line.push_back((*p_dk_ComposeTable)[i][0]);
line.push_back((*p_dk_ComposeTable)[i][1]);
line.push_back((*p_dk_ComposeTable)[i][2]);
dk_SingleTable.push_back(line);
line.clear();
}
}
if( dk_SingleTable.size()>0)
return true;
else
return false;
}
KMX_DWORD KMX_changeKeynameToCapital(KMX_DWORD KVal, KMX_DWORD &shift, GdkKeymap* keymap) {
guint Keyval = (guint) KVal;
GdkKeymapKey* keys;
@ -115,12 +115,12 @@ KMX_DWORD KMX_changeKeynameToCapital(KMX_DWORD KVal, KMX_DWORD &shift, GdkKeymap
// _S2 DESIGN NEEDED is this the right place to get dk from? if not where are they stored?
void create_DKTable(v_dw_2D & dk_ComposeTable) {
//values taken from: https://help.ubuntu.com/community/GtkDeadKeyTable#Latin
//create a 2D-Vector which contains data for ALL existing deadkey combinations on a Linux Keyboard:
//dk_ComposeTable[i][0] : First (e.g. dead_circumflex)
//dk_ComposeTable[i][1] : Second (e.g. a)
//dk_ComposeTable[i][3] : Unicode-Value (e.g. 0x00E2)
//dk_ComposeTable[i][4] : Character (e.g. small A with circumflex)
//values taken from: https://help.ubuntu.com/community/GtkDeadKeyTable#Latin
v_dw_1D line;

View file

@ -7,10 +7,10 @@
#include "mc_import_rules.h"
// creates a vector for a dk combination ( ` + a -> à )
// create a vector for a dk combination ( ` + a -> à )
v_dw_1D createLine(std::wstring first, std::wstring second, KMX_DWORD number, std::wstring nameresult);
// creates a 2D-vector of all dk combinations ( ` + a -> à ; ^ + a -> â ; `+ e -> è; ...)
// create a 2D-vector of all dk combinations ( ` + a -> à ; ^ + a -> â ; `+ e -> è; ...)
void create_DKTable(v_dw_2D & dk_ComposeTable);
// find all possible dk combinations that exist
@ -20,13 +20,13 @@ std::vector<DeadKey*> create_alDead();
void refine_alDead(KMX_WCHAR dk, std::vector<DeadKey*> &myVec, std::vector<DeadKey*> *p_All_Vec);
bool found_dk_inVector(KMX_WCHAR dk, std::vector<DeadKey*> &myVec);
// _S2 TODO probably not used
void sort_alDead(std::vector<DeadKey*> &myVec, std::vector<DeadKey*> *p_All_Vec);
// find all combination for a specific deadkey(dk) ^-> â,ê,î,ô,û,...
bool find_dk_combinations_for_specific_dk(v_dw_2D * dk_ComposeTable, v_dw_2D & dk_SingleTable, KMX_DWORD dk);
// get the shifted character of a key and write shiftstate of KVal to shift
KMX_DWORD KMX_changeKeynameToCapital(KMX_DWORD KVal, KMX_DWORD &shift, GdkKeymap* keymap);
// _S2 TODO probably not used
void sort_alDead(std::vector<DeadKey*> &myVec, std::vector<DeadKey*> *p_All_Vec);
# endif /*DEADKEY_H*/

View file

@ -3,8 +3,8 @@
#include <stdio.h>
#include "u16.h"
// Opens files on windows and non-windows platforms. Datatypes for Filename and mode must be the same.
// returns FILE* if file could be opened; FILE needs to be closed in calling function
// Open files on windows and non-windows platforms. Datatypes for Filename and mode must be the same.
// return FILE* if file could be opened; FILE must to be closed in calling function
FILE* Open_File(const KMX_CHAR* Filename, const KMX_CHAR* mode);
FILE* Open_File(const KMX_WCHART* Filename, const KMX_WCHART* mode);
FILE* Open_File(const KMX_WCHAR* Filename, const KMX_WCHAR* mode);

View file

@ -82,6 +82,16 @@ KMX_DWORD convertNamesTo_DWORD_Value(std::wstring tok_wstr) {
}
int createOneVectorFromBothKeyboards(v_dw_3D &All_Vector,GdkKeymap *keymap) {
// create a 3D-Vector which contains data of the US keyboard and the underlying Keyboard:
// All_Vector[ US_Keyboard ]
// [KeyCode_US ]
// [Keyval unshifted ]
// [Keyval shifted ]
// [Underlying Kbd]
// [KeyCode_underlying]
// [Keyval unshifted ]
// [Keyval shifted ]
std::string US_language = "us";
const char* text_us = "xkb_symbols \"basic\"";
//const char* text_us = "xkb_symbols \"intl\"";

View file

@ -67,12 +67,12 @@ typedef std::vector<std::vector<std::vector<KMX_DWORD> > > v_dw_3D;
static KMX_DWORD returnIfCharInvalid = 0;
static KMX_DWORD keycode_max = 94;
static KMX_DWORD deadkey_min = 0xfe50;
//static KMX_DWORD deadkey_max = 0xfe93;
static KMX_DWORD deadkey_max = 0xfe52; // _S2 TODO This has to go! my test: to only return 3 dk
static KMX_DWORD deadkey_max = 0xfe93;
//static KMX_DWORD deadkey_max = 0xfe52; // _S2 TODO This has to go! my test: to only return 3 dk
int map_VKShiftState_to_LinModifier(int VKShiftState);
// takes a std::wstring (=contents of line symbols-file ) and returns the (int) value of the character
// take a std::wstring (=contents of line symbols-file ) and returns the (int) value of the character
KMX_DWORD convertNamesTo_DWORD_Value(std::wstring tok_wstr);
// create a Vector with all entries of both keymaps+ keymap

View file

@ -139,15 +139,6 @@ public:
return this->m_sc;
}
// _S2 TODO can go later
std::wstring get_m_rgss(int i,int j) {
return m_rgss[i][j];
}
// _S2 TODO can go later
bool get_m_rgfDeadkey(int i,int j) {
return m_rgfDeadKey[i][j];
}
std::wstring KMX_GetShiftState(ShiftState shiftState, bool capsLock) {
return this->m_rgss[(UINT)shiftState][(capsLock ? 1 : 0)];
}
@ -340,6 +331,7 @@ int i4 = this->KMX_IsXxxxGrCapsEqualToXxxxShift() ? 8 : 0;*/
if(st[ich] < 0x20 || st[ich] == 0x7F) { isvalid=false; break; }
}
if(isvalid) {
// _S2 DIFFERENCE TO MCOMPILE WINDOWS
// this is different to mcompile windows !!!!
// this->m_sc stores SC-US = SCUnderlying
// this->m_vk stores VK-US ( not underlying !!)
@ -392,6 +384,7 @@ public:
return (Get_XxxxVk() == 0 ? ShftMenuCtrl : ShftXxxx);
}
// _S2 ToDo Do we need one/none?
bool KMX_IsControlChar(wchar_t ch) {
return (ch < 0x0020) || (ch >= 0x007F && ch <= 0x009F);
}
@ -431,11 +424,13 @@ bool KMX_ImportRules(LPKMX_KEYBOARD kp,v_dw_3D &All_Vector, GdkKeymap **keymap,
// flag that the VK is valid, and it can store the SC value.
for(UINT sc = 0x01; sc <= 0x7f; sc++) {
// _S2 DIFFERENCE TO MCOMPILE WINDOWS
// fills m_vk with the VK of the US keyboard
// ( mcompile win uses MapVirtualKeyEx() to fill m_vk with the VK of the Underlying keyboard)
// Linux cant get a VK for the US Keyboard using USVirtualKeyToScanCode/ScanCodeToUSVirtualKey
// Linux can get a VK for the US Keyboard using USVirtualKeyToScanCode/ScanCodeToUSVirtualKey
// Linux cannot get a VK for the underling Keyboard
// this "connection" is possible only while using All_Vector
// this "connection" is possible only when using All_Vector
KMX_VirtualKey *key = new KMX_VirtualKey(sc, hkl);
if((key->VK() != 0) ) {
@ -488,14 +483,14 @@ bool KMX_ImportRules(LPKMX_KEYBOARD kp,v_dw_3D &All_Vector, GdkKeymap **keymap,
for(ShiftState ss = Base; ss <= loader.KMX_MaxShiftState(); ss = (ShiftState)((int)ss + 1)) {
if(ss == Menu || ss == ShftMenu) {
// Alt and Shift+Alt don't work, so skip them 4+5
// Alt and Shift+Alt don't work, so skip them (ss 4+5)
continue;
}
//_S2 TODO to compare win-lin kmn-files skip ss6+7; MUST BE removed later!!!!
/*if(ss == MenuCtrl|| ss == ShftMenuCtrl) {
if(ss == MenuCtrl|| ss == ShftMenuCtrl) {
continue;
}*/
}
KMX_DWORD KC_US = (KMX_DWORD) KMX_get_KeyCodeUnderlying_From_VKUS(iKey);

View file

@ -11,6 +11,7 @@ private:
public:
DeadKey(KMX_WCHAR deadCharacter) ;
KMX_WCHAR KMX_DeadCharacter() ;
void KMX_AddDeadKeyRow(KMX_WCHAR baseCharacter, KMX_WCHAR combinedCharacter) ;

View file

@ -71,7 +71,6 @@ int run(int argc, std::vector<std::u16string> str_argv, char* argv_ch[] = NULL){
L" positional one based on the Linux keyboard\n"
L" layout on top position\n"
L" (-d convert deadkeys to plain keys) not available yet \n\n"
); // I4552
return 1;
@ -133,9 +132,6 @@ int run(int argc, std::vector<std::u16string> str_argv, char* argv_ch[] = NULL){
//DeleteReallocatedPointers(kmxfile); :TODO // _S2 not my ToDo :-)
delete kmxfile;
wprintf(L"\nmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm end\n");
wprintf(L"\n");
return 0;
}
@ -147,7 +143,6 @@ const UINT VKShiftState[] = {0, K_SHIFTFLAG, LCTRLFLAG|RALTFLAG, K_SHIFTFLAG|LCT
//
// For each key rule on the keyboard, remap its key to the
// correct shift state and key. Adjust the LCTRL+RALT -> RALT if necessary
// _S2 INFO exchange key->Key with the new value ( use vk instead of ch)
//
void KMX_TranslateKey(LPKMX_KEY key, KMX_WORD vk, UINT shift, KMX_WCHAR ch) {
// The weird LCTRL+RALT is Windows' way of mapping the AltGr key.
@ -214,7 +209,6 @@ void KMX_TranslateDeadkeyKey(LPKMX_KEY key, KMX_WCHAR deadkey, KMX_WORD vk, UINT
// _S2 INFO this produces a different output due to different layouts for Lin<-> win ( for the same language!!)
if((key->ShiftFlags == 0 || key->ShiftFlags & VIRTUALCHARKEY) && key->Key == ch) {
// The weird LCTRL+RALT is Windows' way of mapping the AltGr key.
// We store that as just RALT, and use the option "Simulate RAlt with Ctrl+Alt"
// to provide an alternate..
@ -433,6 +427,7 @@ KMX_BOOL KMX_DoConvert(LPKMX_KEYBOARD kbd, KMX_BOOL bDeadkeyConversion, gint arg
// Loop through each possible key on the keyboard
for (int i = 0;KMX_VKMap[i]; i++) { // I4651
// _S2 DIFFERENT TO MCOMPILE WINDOWS
// win goes via VK, Lin goes via SC/Keycode
UINT scUnderlying = KMX_get_KeyCodeUnderlying_From_VKUS(KMX_VKMap[i]);
@ -448,17 +443,14 @@ KMX_BOOL KMX_DoConvert(LPKMX_KEYBOARD kbd, KMX_BOOL bDeadkeyConversion, gint arg
switch(ch) {
case 0x0000: break;
case 0xFFFF: // _S2 INFO in kbd (=loaded from kmx-file): replace LCTRL+RALT -> Ctrl+Alt + write deadkey-> FFFF + CODE_DEADKEY + deadkey into context
KMX_ConvertDeadkey(kbd, KMX_VKMap[i], VKShiftState[j], DeadKey, All_Vector, keymap , dk_Table); break;
default: // _S2 INFO in kbd (=loaded from kmx-file): replace LCTRL+RALT -> Ctrl+Alt + switch keyvalues e.g. y<->z
KMX_TranslateKeyboard(kbd, KMX_VKMap[i], VKShiftState[j], ch);
case 0xFFFF: KMX_ConvertDeadkey(kbd, KMX_VKMap[i], VKShiftState[j], DeadKey, All_Vector, keymap , dk_Table); break;
default: KMX_TranslateKeyboard(kbd, KMX_VKMap[i], VKShiftState[j], ch);
}
}
}
KMX_ReportUnconvertedKeyboardRules(kbd);
// _S2 INFO use translated kbd and write data to rgkey[] then add things to rgkey[] to enable to write to kmx-format
if(!KMX_ImportRules(kbd, All_Vector, &keymap, &KMX_FDeadkeys, bDeadkeyConversion)) { // I4353 // I4552
return FALSE;
}

View file

@ -24,8 +24,6 @@
#include "deadkey.h"
#include "mc_kmxfile.h"
void KMX_LogError(PWCHAR fmt, ...) ;
struct KMX_DeadkeyMapping { // I4353
KMX_WCHAR deadkey, dkid;
UINT shift;
@ -40,4 +38,6 @@ PKMX_WCHAR KMX_incxstr(PKMX_WCHAR p);
int KMX_GetDeadkeys(v_dw_2D & dk_Table, KMX_WORD DeadKey, KMX_WORD *OutputPairs, GdkKeymap* keymap);
void KMX_LogError(PWCHAR fmt, ...) ;
#endif /*MCOMPILE_H*/