Skip to content

Commit

Permalink
Added clipboard ignore format handling
Browse files Browse the repository at this point in the history
  • Loading branch information
davystrong committed Sep 19, 2021
1 parent a168c60 commit 4e58e4e
Show file tree
Hide file tree
Showing 6 changed files with 257 additions and 273 deletions.
2 changes: 1 addition & 1 deletion Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "filo-clipboard"
version = "0.5.0"
version = "0.6.0"
edition = "2018"

# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
Expand Down
244 changes: 0 additions & 244 deletions src/event_handler.rs

This file was deleted.

10 changes: 2 additions & 8 deletions src/lib.rs
Original file line number Diff line number Diff line change
@@ -1,20 +1,14 @@
#![feature(unboxed_closures)]
#![feature(fn_traits)]

pub mod cli;
pub mod clipboard_extras;
pub mod key_utils;
pub mod winapi_functions;
pub mod window;
pub mod event_handler;

use cli::Opts;
use crate::window::Window;
use crate::event_handler::EventHandler;
use cli::Opts;

pub fn run(opts: Opts) {
// Create a window and event handler
let event_loop_callback = EventHandler::new(opts.max_history);
let mut window = Window::new(event_loop_callback);
let mut window = Window::new(opts.max_history);
window.run_event_loop();
}
16 changes: 15 additions & 1 deletion src/winapi_functions.rs
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,20 @@ pub fn remove_clipboard_format_listener(
}
}

pub fn is_clipboard_format_available(format: u32) -> bool {
(unsafe { winuser::IsClipboardFormatAvailable(format) } != 0)
}

pub fn register_clipboard_format(
lpsz_format: &str,
) -> Result<u32, error_code::ErrorCode<error_code::SystemCategory>> {
let lpsz_format = CString::new(lpsz_format).unwrap();
match unsafe { winuser::RegisterClipboardFormatA(lpsz_format.as_ptr()) } {
0 => Err(SystemError::last()),
id => Ok(id),
}
}

pub fn register_hotkey(
h_wnd: &mut winapi::shared::windef::HWND__,
id: i32,
Expand Down Expand Up @@ -146,4 +160,4 @@ pub fn get_clipboard_data(
handle if handle.is_null() => Err(SystemError::last()),
handle => Ok(handle),
}
}
}
Loading

0 comments on commit 4e58e4e

Please sign in to comment.