Skip to content

Commit

Permalink
Bug fixes and update resource files
Browse files Browse the repository at this point in the history
  • Loading branch information
mufeedvh committed Nov 15, 2023
1 parent bf4ef49 commit 3cb7a4e
Show file tree
Hide file tree
Showing 11 changed files with 53 additions and 27 deletions.
6 changes: 3 additions & 3 deletions cpp/SampleIME/SampleIME.rc
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down
Binary file added cpp/SampleIME/image/ToggleOff.ico
Binary file not shown.
Binary file added cpp/SampleIME/image/ToggleOn.ico
Binary file not shown.
Binary file added cpp/SampleIME/image/VarnamIME.ico
Binary file not shown.
4 changes: 4 additions & 0 deletions cpp/prebuild.ps1
Original file line number Diff line number Diff line change
@@ -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
Expand Down
Empty file added govarnam-rust/assets/ml/ml.vstt
Empty file.
22 changes: 15 additions & 7 deletions govarnam-rust/example/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -19,14 +19,22 @@ static VARNAM: Lazy<Varnam> = 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);
}
6 changes: 4 additions & 2 deletions govarnam/windows-build.bat
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down
32 changes: 22 additions & 10 deletions rust/composition_processor/src/engine.rs
Original file line number Diff line number Diff line change
Expand Up @@ -39,11 +39,21 @@ use once_cell::sync::Lazy;
use govarnam::Varnam;

static VARNAM: Lazy<Varnam> = 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,
Expand Down Expand Up @@ -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
}
Expand All @@ -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()))
}
Expand Down Expand Up @@ -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);
Expand Down
2 changes: 1 addition & 1 deletion rust/ime/src/resources.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand Down
8 changes: 4 additions & 4 deletions varnam-windows.iss
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down

0 comments on commit 3cb7a4e

Please sign in to comment.