|
1 |
| -use base64::{engine::general_purpose, Engine as _}; |
2 |
| -use copypasta_ext::prelude::*; |
3 |
| -use copypasta_ext::wayland_bin::WaylandBinClipboardContext; |
4 |
| -use copypasta_ext::x11_bin::ClipboardContext as BinClipboardContext; |
5 |
| -use copypasta_ext::x11_fork::ClipboardContext as ForkClipboardContext; |
6 |
| -use crossterm::style::Print; |
7 | 1 | use dirs::home_dir;
|
8 | 2 | use std::path::PathBuf;
|
9 | 3 | use std::time::{SystemTime, UNIX_EPOCH};
|
10 | 4 | use std::{env, io};
|
11 | 5 |
|
12 |
| -pub enum CopyType { |
13 |
| - Native, |
14 |
| - OSC52, |
15 |
| -} |
16 |
| - |
17 | 6 | pub fn get_db_path() -> PathBuf {
|
18 | 7 | match env::var("COTP_DB_PATH") {
|
19 | 8 | Ok(value) => PathBuf::from(value),
|
@@ -90,42 +79,3 @@ pub fn verified_password(message: &str, minimum_length: usize) -> String {
|
90 | 79 | return password;
|
91 | 80 | }
|
92 | 81 | }
|
93 |
| - |
94 |
| -pub fn copy_string_to_clipboard(content: String) -> Result<CopyType, ()> { |
95 |
| - if env_var_set("SSH_CONNECTION") |
96 |
| - && crossterm::execute!( |
97 |
| - io::stdout(), |
98 |
| - Print(format!( |
99 |
| - "\x1B]52;c;{}\x07", |
100 |
| - general_purpose::STANDARD.encode(&content) |
101 |
| - )) |
102 |
| - ) |
103 |
| - .is_ok() |
104 |
| - { |
105 |
| - // We do not use copypasta_ext::osc52 module because we have enabled terminal raw mode, so we print with crossterm utilities |
106 |
| - // Check https://github.com/timvisee/rust-clipboard-ext/blob/371df19d2f961882a21c957f396d1e24548d1f28/src/osc52.rs#L92 |
107 |
| - Ok(CopyType::OSC52) |
108 |
| - } else if env_var_set("WAYLAND_DISPLAY") |
109 |
| - && WaylandBinClipboardContext::new() |
110 |
| - .and_then(|mut ctx| ctx.set_contents(content.clone())) |
111 |
| - .is_ok() |
112 |
| - { |
113 |
| - Ok(CopyType::Native) |
114 |
| - } else if BinClipboardContext::new() |
115 |
| - .and_then(|mut ctx| ctx.set_contents(content.clone())) |
116 |
| - .is_ok() |
117 |
| - || ForkClipboardContext::new() |
118 |
| - .and_then(|mut ctx| ctx.set_contents(content)) |
119 |
| - .is_ok() |
120 |
| - { |
121 |
| - Ok(CopyType::Native) |
122 |
| - } else { |
123 |
| - Err(()) |
124 |
| - } |
125 |
| -} |
126 |
| - |
127 |
| -fn env_var_set(env_var: &str) -> bool { |
128 |
| - env::var(env_var) |
129 |
| - .map(|v| !v.trim().is_empty()) |
130 |
| - .unwrap_or(false) |
131 |
| -} |
0 commit comments