fix: Telex spacing timing, add --update self-updater, add Telex engine tests

- Add 15ms delay between clipboard paste and trailing uinput ASCII
- Add 3 new Telex tests (Tuaans→Tuấn, nguyeenx→nguyễn, gios→gió)
- AppRun: --update flag downloads latest AppImage from GitHub releases
This commit is contained in:
Khoa Vo 2026-06-26 15:38:00 +07:00
parent 42a0dad026
commit 4374d3a804
3 changed files with 64 additions and 4 deletions

View file

@ -528,4 +528,36 @@ mod tests {
assert_eq!(process(InputMethod::Telex, "chafo"), "chào"); assert_eq!(process(InputMethod::Telex, "chafo"), "chào");
assert_eq!(process(InputMethod::Vni, "chao2"), "chào"); assert_eq!(process(InputMethod::Vni, "chao2"), "chào");
} }
#[test]
fn test_telex_tuaan() {
let mut e = crate::bamboo::BambooEngine::new(crate::input_method::InputMethod::Telex);
let mut out = String::new();
for ch in "Tuaans".chars() {
if let Some(o) = e.process_key(ch) { out = o; }
}
assert_eq!(out, "Tuấn", "Expected Tuấn, got {}", out);
}
#[test]
fn test_telex_nguyeenx() {
let mut e = crate::bamboo::BambooEngine::new(crate::input_method::InputMethod::Telex);
let mut out = String::new();
for ch in "nguyeenx".chars() {
if let Some(o) = e.process_key(ch) { out = o; }
}
assert_eq!(out, "nguyễn", "Expected nguyễn, got {}", out);
}
#[test]
fn test_telex_gios() {
let mut e = crate::bamboo::BambooEngine::new(crate::input_method::InputMethod::Telex);
let mut out = String::new();
for ch in "gios".chars() {
if let Some(o) = e.process_key(ch) { out = o; }
}
assert_eq!(out, "gió", "Expected gió, got {}", out);
}
} }

View file

@ -197,6 +197,30 @@ cat > "$APPDIR/AppRun" << 'EOF'
#!/bin/sh #!/bin/sh
HERE="$(dirname "$(readlink -f "${0}")")" HERE="$(dirname "$(readlink -f "${0}")")"
# Handle --update flag: download latest AppImage from GitHub
if [ "$1" = "--update" ]; then
echo "Viet+ Self-Updater"
RELEASE_URL="https://github.com/vndangkhoa/vietc/releases/latest/download/Viet+-x86_64.AppImage"
TEMP="/tmp/Viet+-update.AppImage"
echo "Downloading latest release..."
if command -v curl >/dev/null 2>&1; then
curl -L -o "$TEMP" "$RELEASE_URL" 2>/dev/null
elif command -v wget >/dev/null 2>&1; then
wget -q -O "$TEMP" "$RELEASE_URL" 2>/dev/null
else
echo "ERROR: curl or wget required for updates" >&2
exit 1
fi
if [ -s "$TEMP" ]; then
chmod +x "$TEMP"
mv "$TEMP" "$(readlink -f "${0}")"
echo "Updated! Restart the AppImage."
else
echo "ERROR: Download failed" >&2
fi
exit 0
fi
# Export our bin dir on PATH so child processes can find sibling binaries # Export our bin dir on PATH so child processes can find sibling binaries
export PATH="$HERE/usr/bin:$PATH" export PATH="$HERE/usr/bin:$PATH"

View file

@ -380,10 +380,14 @@ impl UinputInjector {
} }
} }
// Trailing ASCII via uinput (spaces, punctuation) // Trailing ASCII via uinput (spaces, punctuation).
for ch in ascii_tail.chars() { // Small delay lets the clipboard paste finish before trailing chars arrive.
if let Some(kc) = char_to_linux_keycode(ch) { if !ascii_tail.is_empty() {
self.send_key_stroke(kc, false); std::thread::sleep(std::time::Duration::from_millis(15));
for ch in ascii_tail.chars() {
if let Some(kc) = char_to_linux_keycode(ch) {
self.send_key_stroke(kc, false);
}
} }
} }