From 3cb7a4e221fa951fa0922747461bbaf7fcf247e8 Mon Sep 17 00:00:00 2001 From: Mufeed VH Date: Wed, 15 Nov 2023 10:41:29 +0400 Subject: [PATCH] Bug fixes and update resource files --- cpp/SampleIME/SampleIME.rc | 6 ++--- cpp/SampleIME/image/ToggleOff.ico | Bin 0 -> 2462 bytes cpp/SampleIME/image/ToggleOn.ico | Bin 0 -> 2462 bytes cpp/SampleIME/image/VarnamIME.ico | Bin 0 -> 4286 bytes cpp/prebuild.ps1 | 4 +++ govarnam-rust/assets/ml/ml.vstt | 0 govarnam-rust/example/src/main.rs | 22 +++++++++++----- govarnam/windows-build.bat | 6 +++-- rust/composition_processor/src/engine.rs | 32 ++++++++++++++++------- rust/ime/src/resources.rs | 2 +- varnam-windows.iss | 8 +++--- 11 files changed, 53 insertions(+), 27 deletions(-) create mode 100644 cpp/SampleIME/image/ToggleOff.ico create mode 100644 cpp/SampleIME/image/ToggleOn.ico create mode 100644 cpp/SampleIME/image/VarnamIME.ico create mode 100644 govarnam-rust/assets/ml/ml.vstt diff --git a/cpp/SampleIME/SampleIME.rc b/cpp/SampleIME/SampleIME.rc index 3d4875f..b138ef9 100644 --- a/cpp/SampleIME/SampleIME.rc +++ b/cpp/SampleIME/SampleIME.rc @@ -15,9 +15,9 @@ LANGUAGE LANG_ENGLISH, SUBLANG_ENGLISH_US // Icon with lowest ID value placed first to ensure application icon // remains consistent on all systems. -IDIS_SAMPLEIME ICON "image\\SampleIME.ico" -IDI_IME_MODE_ON ICON "image\\ImeModeOn.ico" -IDI_IME_MODE_OFF ICON "image\\ImeModeOff.ico" +IDIS_SAMPLEIME ICON "image\\VarnamIME.ico" +IDI_IME_MODE_ON ICON "image\\ToggleOn.ico" +IDI_IME_MODE_OFF ICON "image\\ToggleOff.ico" IDI_DOUBLE_SINGLE_BYTE_ON ICON "image\\DoubleSingleByteOn.ico" IDI_DOUBLE_SINGLE_BYTE_OFF ICON "image\\DoubleSingleByteOff.ico" IDI_PUNCTUATION_ON ICON "image\\PunctuationOn.ico" diff --git a/cpp/SampleIME/image/ToggleOff.ico b/cpp/SampleIME/image/ToggleOff.ico new file mode 100644 index 0000000000000000000000000000000000000000..df277a3ff27a48533862cacf6c8ae4c35e34c39e GIT binary patch literal 2462 zcmeHHp>6^}6r3tjRR`1|8x#%+UqDh(iLI+`>L9_K;46@P0T$7u0#%2i2|rN2V3{E| z$%ZUsNjP_N8Q$J|^X6{f0>A^Wb{qWcpm+qD0A5I@&?A*Ufwda-1S+1uJN*~rjtrTU zRz2#yh7F6ko|km;NMXsOdq!M8r$iTW(yGV(@`^F$jcdw(kUu3q8HZ#p>?2RZ@BYTb zD`}16+`^0~5B0@+*q6B$<9E5Xx8jz}g*?$2=_dTYGJGvb z&FB1l`xN_prN0H6_E5S&w_s;L3$DoGWNPr%VsRMytv2^LdFzX8b?U=d9!P}J45Nq?Xp(D0bK zFv$yf*S=hG?v@ODZ+3Q$+XaAvuYMnVzrphb&;>9cNMT5bFN3u<+6go~fhYQ}h)*J9 zLR$5x_pjKonCn@klSeAnB;7ON^>s>A!AW~ZxL;mzJo4aL%>Q>irQnTtC+5VMu#Y?) z{_GDXGV(n&_Huq9Cl8(DXZSvGJ?7karO>|4ALQhrvpgMj{5Nd2uk)T<%D>KhZWI19 za;f>$-S3Eg+OOc<`B~!qvRv-NwL0HV^|(LYt-Kvg{=R&VCjTFNk2bdx$eKV10V(|8 a5?|MObS9w7?|ADj&8Xw{fsPNg@}0Wp;zq>s}qCn}> zA^bQnhV}s^3MmgSs}-w!OQG$Ths}xN+bOke3+%7g&scuCx5W2e=K{}L?Ja)yx^Ve^ zAF5kkp}KVlhi^7xP51+_Jj%gv&jUNCP`T}VMO1LE3UpVLVqg*_j*UVHw) zF{2Hk`Q3;pX~(B&GU%MDf=);c^n>c4>rsX!9(nlqlyKNQQ|kUiJ~GQQuTf(L@9Yi| zU;1MHz6&j-I}@J4;oBB$JXZ}yR0&w8#n1__hHi)q%L41b{-ziVelAu=7I!(_{_YEP z^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|*bkpA;=@)i2|R+%gEtZKBp3n!22 z5@*xV$%+}LFkyr#K40XWWW12iUNUz%ab#(}-@gPq$#C{vI&!U;v0MMXIN)7VM))s< z{m;MCzKS+#tpU{LytP?$)S^Z^O)Cj_YewiNI@IRlHJJk?H5H+bggORN$3W^RB1Y6% Z?W9AUraID@=`#X#0FeVrl>Y literal 0 HcmV?d00001 diff --git a/cpp/prebuild.ps1 b/cpp/prebuild.ps1 index 57dfb39..e59e13a 100644 --- a/cpp/prebuild.ps1 +++ b/cpp/prebuild.ps1 @@ -1,10 +1,14 @@ $scriptDir = Split-Path -Path $MyInvocation.MyCommand.Definition -Parent +Get-ChildItem -Path $scriptDir -Include *.dll, *.pdb, *.exp -Recurse | ForEach-Object {Remove-Item $_.FullName -Force -Confirm:$false} + pushd $scriptDir/../govarnam .\windows-build.bat gendef libgovarnam.dll lib /def:libgovarnam.def /OUT:libgovarnam.lib /MACHINE:X64 Copy-Item "libgovarnam.lib" -Destination "C:\lib\libgovarnam.lib" +Copy-Item "libgovarnam.dll" -Destination "$scriptDir\x64\Debug\libgovarnam.dll" +Copy-Item "libgovarnam.lib" -Destination "$scriptDir\x64\Debug\libgovarnam.lib" popd pushd $scriptDir/../rust diff --git a/govarnam-rust/assets/ml/ml.vstt b/govarnam-rust/assets/ml/ml.vstt new file mode 100644 index 0000000..e69de29 diff --git a/govarnam-rust/example/src/main.rs b/govarnam-rust/example/src/main.rs index 7b94b36..ec805c5 100644 --- a/govarnam-rust/example/src/main.rs +++ b/govarnam-rust/example/src/main.rs @@ -19,14 +19,22 @@ static VARNAM: Lazy = Lazy::new(|| { }); fn main() { + let mut matches: Vec<(String, String)> = Vec::with_capacity(20); + let results = VARNAM.transliterate("namaskkaaram"); - for item in results { - println!( - "Word: {}, Weight: {}, Learned on: {}", - item.to_string(), - item.weight, - item.learned_on, - ); + // for item in results { + // println!( + // "Word: {}, Weight: {}, Learned on: {}", + // item.to_string(), + // item.weight, + // item.learned_on, + // ); + // } + + for result in results { + matches.push(("input".into(), result.to_string())) } + + eprintln!("{:?}", matches); } \ No newline at end of file diff --git a/govarnam/windows-build.bat b/govarnam/windows-build.bat index eb5ac2f..6351872 100644 --- a/govarnam/windows-build.bat +++ b/govarnam/windows-build.bat @@ -6,10 +6,12 @@ setlocal enabledelayedexpansion set "api_url=https://api.github.com/repos/varnamproject/schemes/releases/latest" :: Set .libvarnam schemes directory path -set "govarnam_path=C:\Users\%USERNAME%\.libvarnam" +@REM set "govarnam_path=C:\Users\%USERNAME%\.libvarnam" :: Set .libvarnam\schemes directory path -set "schemes_path=%govarnam_path%\schemes" +@REM set "schemes_path=%govarnam_path%\schemes" + +set "schemes_path=%cd%\schemes" :: Check for the 'update-schemes' command-line argument set "should_update=0" diff --git a/rust/composition_processor/src/engine.rs b/rust/composition_processor/src/engine.rs index c175e27..6fc3a3b 100644 --- a/rust/composition_processor/src/engine.rs +++ b/rust/composition_processor/src/engine.rs @@ -39,11 +39,21 @@ use once_cell::sync::Lazy; use govarnam::Varnam; static VARNAM: Lazy = Lazy::new(|| { - /// DEBUG - /// This should be adaptive to language switches - /// Currently using Malayalam VST for debugging - let scheme_path = "C:\\Users\\doxop\\.libvarnam\\schemes\\ml\\ml.vst"; - let learning_path = "C:\\Users\\doxop\\.libvarnam\\schemes\\learnings\\ml.vst.learnings"; + // DEBUG + // This should be adaptive to language switches + // Currently using Malayalam VST for debugging + let dll_instance_handle = unsafe { ime::dll::DLL_INSTANCE }; + + let file_name = unsafe { + let mut file_name = [0u16; MAX_PATH as usize]; + GetModuleFileNameW(dll_instance_handle, &mut file_name); + String::from_utf16(&file_name).unwrap() + }; + + let dir = std::path::Path::new(&file_name[..]).parent().unwrap(); + + let scheme_path = dir.join("schemes/ml/ml.vst"); + let learning_path = dir.join("schemes/learnings/ml.vst.learnings"); match Varnam::init( scheme_path, @@ -99,10 +109,10 @@ impl CompositionProcessorEngine { .init(thread_mgr, client_id, &self.compartment_wrapper) .ok(); unsafe { ime::font::set_default_candidate_text_font() }; - self.setup_dictionary_file( - unsafe { ime::dll::DLL_INSTANCE }, - ime::resources::TEXTSERVICE_DIC, - ); + // self.setup_dictionary_file( + // unsafe { ime::dll::DLL_INSTANCE }, + // ime::resources::TEXTSERVICE_DIC, + // ); true } @@ -127,6 +137,8 @@ impl CompositionProcessorEngine { let results = VARNAM.transliterate(keystroke_buffer.to_owned()); + // let results: Vec<&str> = Vec::from(["stuff", "stuff", "stuff", "stuff"]); + for result in results { matches.push((keystroke_buffer.clone(), result.to_string())) } @@ -174,7 +186,7 @@ impl CompositionProcessorEngine { Ok(true) } - fn setup_dictionary_file(&mut self, dll_instance_handle: HMODULE, dictionary_file_name: &str) { + fn _setup_dictionary_file(&mut self, dll_instance_handle: HMODULE, dictionary_file_name: &str) { let file_name = unsafe { let mut file_name = [0u16; MAX_PATH as usize]; GetModuleFileNameW(dll_instance_handle, &mut file_name); diff --git a/rust/ime/src/resources.rs b/rust/ime/src/resources.rs index 1ce57f2..34db045 100644 --- a/rust/ime/src/resources.rs +++ b/rust/ime/src/resources.rs @@ -6,7 +6,7 @@ pub const TEXTSERVICE_DIC: &str = "SampleIMESimplifiedQuanPinUtf8.txt"; // defined item in setting file table [PreservedKey] section //--------------------------------------------------------------------- -pub const IME_MODE_DESCRIPTION: &str = "Chinese/English input (Shift)"; +pub const IME_MODE_DESCRIPTION: &str = "Varnam/English (Shift)"; pub const IME_MODE_ON_ICO_INDEX: u32 = 21; pub const IME_MODE_OFF_ICO_INDEX: u32 = 22; diff --git a/varnam-windows.iss b/varnam-windows.iss index dbde9a7..2b55990 100644 --- a/varnam-windows.iss +++ b/varnam-windows.iss @@ -30,17 +30,17 @@ Name: "english"; MessagesFile: "compiler:Default.isl" [Files] Source: "govarnam\windows-build.bat"; DestDir: "{app}"; Flags: ignoreversion -Source: "C:\lib\libgovarnam.dll"; DestDir: "C:\lib"; Flags: ignoreversion -Source: "C:\lib\libgovarnam.lib"; DestDir: "C:\lib"; Flags: ignoreversion +Source: "cpp\x64\Debug\libgovarnam.dll"; DestDir: "{app}"; Flags: ignoreversion +Source: "cpp\x64\Debug\libgovarnam.lib"; DestDir: "{app}"; Flags: ignoreversion Source: "cpp\x64\Debug\Varnam Windows.dll"; DestDir: "{app}"; Flags: ignoreversion Source: "cpp\x64\Debug\Varnam Windows.exp"; DestDir: "{app}"; Flags: ignoreversion Source: "cpp\x64\Debug\Varnam Windows.lib"; DestDir: "{app}"; Flags: ignoreversion Source: "cpp\x64\Debug\Varnam Windows.pdb"; DestDir: "{app}"; Flags: ignoreversion [Run] -Filename: "{app}\windows-build.bat"; Parameters: ""; Flags: runhidden; StatusMsg: "Updating Govarnam schemes..." +Filename: "{app}\windows-build.bat"; Parameters: ""; Flags: runhidden; StatusMsg: "Updating Varnam schemes..." ; Register the DLL -Filename: "{sys}\regsvr32.exe"; Parameters: """{app}\Govarnam Windows.dll"""; Flags: runhidden; StatusMsg: "Registering Govarnam Windows DLL..." +Filename: "{sys}\regsvr32.exe"; Parameters: """{app}\Varnam Windows.dll"""; Flags: runhidden; StatusMsg: "Registering Varnam IME Windows DLL..." [Code] procedure AddToPath(NewPath: String);