mirror of
https://github.com/mii443/vrclipboard-ime-gui.git
synced 2025-12-03 03:08:27 +00:00
add auto skip when outside of VRChat
This commit is contained in:
2
src-tauri/Cargo.lock
generated
2
src-tauri/Cargo.lock
generated
@@ -3903,7 +3903,7 @@ checksum = "49874b5167b65d7193b8aba1567f5c7d93d001cafc34600cee003eda787e483f"
|
||||
|
||||
[[package]]
|
||||
name = "vrclipboard-ime-gui"
|
||||
version = "1.8.0"
|
||||
version = "1.9.0"
|
||||
dependencies = [
|
||||
"anyhow",
|
||||
"calc",
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
[package]
|
||||
name = "vrclipboard-ime-gui"
|
||||
version = "1.8.0"
|
||||
version = "1.9.0"
|
||||
description = "VRClipboard IME"
|
||||
authors = ["mii"]
|
||||
edition = "2021"
|
||||
@@ -41,6 +41,7 @@ features = [
|
||||
"Win32_UI_Input_Ime",
|
||||
"Win32_UI_TextServices",
|
||||
"Win32_UI_Input_KeyboardAndMouse",
|
||||
"Win32_System_DataExchange",
|
||||
"Win32_UI_WindowsAndMessaging"
|
||||
]
|
||||
|
||||
|
||||
@@ -24,7 +24,9 @@ pub struct Config {
|
||||
#[serde(default = "bool_true")]
|
||||
pub skip_url: bool,
|
||||
#[serde(default = "bool_false")]
|
||||
pub use_tsf_reconvert: bool
|
||||
pub use_tsf_reconvert: bool,
|
||||
#[serde(default = "bool_true")]
|
||||
pub skip_on_out_of_vrc: bool,
|
||||
}
|
||||
|
||||
impl Default for Config {
|
||||
@@ -36,7 +38,8 @@ impl Default for Config {
|
||||
ignore_prefix: true,
|
||||
on_copy_mode: OnCopyMode::ReturnToChatbox,
|
||||
skip_url: true,
|
||||
use_tsf_reconvert: false
|
||||
use_tsf_reconvert: false,
|
||||
skip_on_out_of_vrc: true,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -6,6 +6,7 @@ use clipboard_master::{ClipboardHandler, CallbackResult};
|
||||
use regex::Regex;
|
||||
use rosc::{encoder, OscMessage, OscPacket, OscType};
|
||||
use tauri::{AppHandle, Manager};
|
||||
use windows::Win32::System::DataExchange::GetClipboardOwner;
|
||||
use crate::{config::{Config, OnCopyMode}, conversion::Conversion, tsf_conversion::TsfConversion, Log, STATE};
|
||||
use anyhow::Result;
|
||||
use tracing::{info, warn, error};
|
||||
@@ -34,6 +35,10 @@ impl ConversionHandler {
|
||||
}
|
||||
|
||||
impl ConversionHandler {
|
||||
fn clipboard_has_owner(&mut self) -> bool {
|
||||
unsafe { GetClipboardOwner() }.is_ok()
|
||||
}
|
||||
|
||||
fn tsf_conversion(&mut self, contents: &str, config: &Config) -> Result<()> {
|
||||
if contents.chars().count() > 140 {
|
||||
info!("Content exceeds 140 characters, skipping TSF conversion");
|
||||
@@ -126,6 +131,11 @@ impl ConversionHandler {
|
||||
impl ClipboardHandler for ConversionHandler {
|
||||
fn on_clipboard_change(&mut self) -> CallbackResult {
|
||||
let config = self.get_config();
|
||||
if config.skip_on_out_of_vrc && self.clipboard_has_owner() {
|
||||
info!("Clipboard has owner (maybe from outside of VRChat), skipping conversion");
|
||||
return CallbackResult::Next;
|
||||
}
|
||||
|
||||
if let Ok(mut contents) = self.clipboard_ctx.get_contents() {
|
||||
if config.use_tsf_reconvert {
|
||||
if let Err(e) = self.tsf_conversion(&contents, &config) {
|
||||
|
||||
@@ -7,7 +7,7 @@
|
||||
},
|
||||
"package": {
|
||||
"productName": "vrclipboard-ime-gui",
|
||||
"version": "1.8.0"
|
||||
"version": "1.9.0"
|
||||
},
|
||||
"tauri": {
|
||||
"updater": {
|
||||
|
||||
Reference in New Issue
Block a user