(&mut self, events: &mut Vec<(Event, EventStatus)>, output: &mut T)
| 238 | pub struct CopyPaste {} |
| 239 | impl<T: USBKeyOut> ProcessKeys<T> for CopyPaste { |
| 240 | fn process_keys(&mut self, events: &mut Vec<(Event, EventStatus)>, output: &mut T) ->HandlerResult { |
| 241 | //step 0: on key release, remove all prior key presses. |
| 242 | for (e, status) in iter_unhandled_mut(events) { |
| 243 | match e { |
| 244 | Event::KeyPress(kc) => { |
| 245 | if kc.keycode == KeyCode::Copy.into() { |
| 246 | output.send_keys(&[KeyCode::LCtrl, KeyCode::Insert]); |
| 247 | output.send_empty(); |
| 248 | *status = EventStatus::Handled; |
| 249 | } |
| 250 | if kc.keycode == KeyCode::Paste.into() { |
| 251 | output.send_keys(&[KeyCode::LShift, KeyCode::Insert]); |
| 252 | output.send_empty(); |
| 253 | *status = EventStatus::Handled; |
| 254 | } |
| 255 | if kc.keycode == KeyCode::Cut.into() { |
| 256 | output.send_keys(&[KeyCode::LShift, KeyCode::Delete]); |
| 257 | output.send_empty(); |
| 258 | *status = EventStatus::Handled; |
| 259 | } |
| 260 | } |
| 261 | Event::KeyRelease(kc) => { |
| 262 | if kc.keycode == KeyCode::Copy.into() { |
| 263 | *status = EventStatus::Handled; |
| 264 | } |
| 265 | if kc.keycode == KeyCode::Paste.into() { |
| 266 | *status = EventStatus::Handled; |
| 267 | } |
| 268 | if kc.keycode == KeyCode::Cut.into() { |
| 269 | *status = EventStatus::Handled; |
| 270 | } |
| 271 | } |
| 272 | _ => {} |
| 273 | } |
| 274 | } |
| 275 | HandlerResult::NoOp |
| 276 | } |
| 277 | } |
| 278 | |
| 279 |
no test coverage detected