mirror of
https://github.com/wez/wezterm.git
synced 2024-11-26 08:25:50 +03:00
termwiz::Modifiers is now wezterm_input_types::Modifiers
This commit is contained in:
parent
9f9e330dcd
commit
7d66bc761d
@ -46,12 +46,12 @@ vtparse = { version="0.6.2", path="../vtparse" }
|
||||
wezterm-bidi = { path = "../bidi", version="0.2.1" }
|
||||
wezterm-blob-leases = { path = "../wezterm-blob-leases", version="0.1" }
|
||||
wezterm-color-types = { path = "../color-types", version="0.2" }
|
||||
wezterm-input-types = { path = "../wezterm-input-types", version="0.1" }
|
||||
wezterm-input-types = { path = "../wezterm-input-types", version="0.1", default-features=false }
|
||||
wezterm-dynamic = { path = "../wezterm-dynamic", version="0.1" }
|
||||
|
||||
[features]
|
||||
widgets = ["cassowary", "fnv"]
|
||||
use_serde = ["serde", "wezterm-color-types/use_serde", "wezterm-blob-leases/serde", "bitflags/serde"]
|
||||
use_serde = ["serde", "wezterm-color-types/use_serde", "wezterm-blob-leases/serde", "bitflags/serde", "wezterm-input-types/serde"]
|
||||
use_image = ["image"]
|
||||
docs = ["widgets", "use_serde"]
|
||||
|
||||
|
@ -12,6 +12,8 @@ use bitflags::bitflags;
|
||||
use serde::{Deserialize, Serialize};
|
||||
use std::fmt::Write;
|
||||
|
||||
pub use wezterm_input_types::Modifiers;
|
||||
|
||||
pub const CSI: &str = "\x1b[";
|
||||
pub const SS3: &str = "\x1bO";
|
||||
|
||||
@ -42,30 +44,6 @@ use winapi::um::wincon::{
|
||||
WINDOW_BUFFER_SIZE_EVENT, WINDOW_BUFFER_SIZE_RECORD,
|
||||
};
|
||||
|
||||
bitflags! {
|
||||
#[cfg_attr(feature="use_serde", derive(Serialize, Deserialize))]
|
||||
#[derive(Default, Debug, Clone, Copy, PartialEq, Eq)]
|
||||
pub struct Modifiers: u16 {
|
||||
const NONE = 0;
|
||||
const SHIFT = 1<<1;
|
||||
const ALT = 1<<2;
|
||||
const CTRL = 1<<3;
|
||||
const SUPER = 1<<4;
|
||||
const LEFT_ALT = 1<<5;
|
||||
const RIGHT_ALT = 1<<6;
|
||||
/// This is a virtual modifier used by wezterm
|
||||
const LEADER = 1<<7;
|
||||
const LEFT_CTRL = 1<<8;
|
||||
const RIGHT_CTRL = 1<<9;
|
||||
const LEFT_SHIFT = 1<<10;
|
||||
const RIGHT_SHIFT = 1<<11;
|
||||
const ENHANCED_KEY = 1<<12;
|
||||
/// Not really a modifier, but a keyboard driver state
|
||||
const CAPS_LOCK = 1<<13;
|
||||
/// Not really a modifier, but a keyboard driver state
|
||||
const NUM_LOCK = 1<<14;
|
||||
}
|
||||
}
|
||||
bitflags! {
|
||||
#[cfg_attr(feature="use_serde", derive(Serialize, Deserialize))]
|
||||
#[derive(Debug, Default, Clone, PartialEq, Eq)]
|
||||
|
@ -172,67 +172,6 @@ impl KeyTableState {
|
||||
}
|
||||
}
|
||||
|
||||
pub fn window_mods_to_termwiz_mods(modifiers: ::window::Modifiers) -> termwiz::input::Modifiers {
|
||||
let mut result = termwiz::input::Modifiers::NONE;
|
||||
|
||||
if modifiers.contains(::window::Modifiers::SHIFT) {
|
||||
result.insert(termwiz::input::Modifiers::SHIFT);
|
||||
}
|
||||
if modifiers.contains(::window::Modifiers::LEFT_SHIFT) {
|
||||
result.insert(termwiz::input::Modifiers::LEFT_SHIFT);
|
||||
}
|
||||
if modifiers.contains(::window::Modifiers::RIGHT_SHIFT) {
|
||||
result.insert(termwiz::input::Modifiers::RIGHT_SHIFT);
|
||||
}
|
||||
|
||||
if modifiers.contains(::window::Modifiers::LEFT_ALT) {
|
||||
result.insert(termwiz::input::Modifiers::ALT);
|
||||
result.insert(termwiz::input::Modifiers::LEFT_ALT);
|
||||
}
|
||||
if modifiers.contains(::window::Modifiers::RIGHT_ALT) {
|
||||
/* We DONT want to do this: we carry through RIGHT_ALT
|
||||
* only for win32-input mode to track when AltGr was used,
|
||||
* but we don't want that to be treated as regular ALT
|
||||
* when encoding regular input for the terminal.
|
||||
* <https://github.com/wez/wezterm/issues/2127>
|
||||
result.insert(termwiz::input::Modifiers::ALT);
|
||||
*/
|
||||
|
||||
// But we do want the positional mod
|
||||
result.insert(termwiz::input::Modifiers::RIGHT_ALT);
|
||||
}
|
||||
if modifiers.contains(::window::Modifiers::ALT) {
|
||||
result.insert(termwiz::input::Modifiers::ALT);
|
||||
}
|
||||
|
||||
if modifiers.contains(::window::Modifiers::CTRL) {
|
||||
result.insert(termwiz::input::Modifiers::CTRL);
|
||||
}
|
||||
if modifiers.contains(::window::Modifiers::LEFT_CTRL) {
|
||||
result.insert(termwiz::input::Modifiers::LEFT_CTRL);
|
||||
}
|
||||
if modifiers.contains(::window::Modifiers::RIGHT_CTRL) {
|
||||
result.insert(termwiz::input::Modifiers::RIGHT_CTRL);
|
||||
}
|
||||
|
||||
if modifiers.contains(::window::Modifiers::SUPER) {
|
||||
result.insert(termwiz::input::Modifiers::SUPER);
|
||||
}
|
||||
if modifiers.contains(::window::Modifiers::LEADER) {
|
||||
result.insert(termwiz::input::Modifiers::LEADER);
|
||||
}
|
||||
if modifiers.contains(::window::Modifiers::ENHANCED_KEY) {
|
||||
result.insert(termwiz::input::Modifiers::ENHANCED_KEY);
|
||||
}
|
||||
if modifiers.contains(::window::Modifiers::CAPS_LOCK) {
|
||||
result.insert(termwiz::input::Modifiers::CAPS_LOCK);
|
||||
}
|
||||
if modifiers.contains(::window::Modifiers::NUM_LOCK) {
|
||||
result.insert(termwiz::input::Modifiers::NUM_LOCK);
|
||||
}
|
||||
result
|
||||
}
|
||||
|
||||
#[derive(Debug)]
|
||||
pub enum Key {
|
||||
Code(::termwiz::input::KeyCode),
|
||||
@ -334,7 +273,7 @@ impl super::TermWindow {
|
||||
if only_key_bindings == OnlyKeyBindings::No {
|
||||
if let Some(modal) = self.get_modal() {
|
||||
if let Key::Code(term_key) = self.win_key_code_to_termwiz_key_code(keycode) {
|
||||
let tw_raw_modifiers = window_mods_to_termwiz_mods(raw_modifiers);
|
||||
let tw_raw_modifiers = raw_modifiers;
|
||||
match modal.key_down(term_key, tw_raw_modifiers, self) {
|
||||
Ok(true) => return true,
|
||||
Ok(false) => {}
|
||||
@ -420,7 +359,7 @@ impl super::TermWindow {
|
||||
|
||||
if bypass_compose {
|
||||
if let Key::Code(term_key) = self.win_key_code_to_termwiz_key_code(keycode) {
|
||||
let tw_raw_modifiers = window_mods_to_termwiz_mods(raw_modifiers);
|
||||
let tw_raw_modifiers = raw_modifiers;
|
||||
|
||||
let mut did_encode = false;
|
||||
if let Some(key_event) = key_event {
|
||||
@ -676,7 +615,7 @@ impl super::TermWindow {
|
||||
);
|
||||
}
|
||||
|
||||
let modifiers = window_mods_to_termwiz_mods(window_key.modifiers);
|
||||
let modifiers = window_key.modifiers;
|
||||
|
||||
if self.process_key(
|
||||
&pane,
|
||||
|
@ -2521,8 +2521,8 @@ impl TermWindow {
|
||||
}
|
||||
SendString(s) => pane.writer().write_all(s.as_bytes())?,
|
||||
SendKey(key) => {
|
||||
use keyevent::{window_mods_to_termwiz_mods, Key};
|
||||
let mods = window_mods_to_termwiz_mods(key.mods);
|
||||
use keyevent::Key;
|
||||
let mods = key.mods;
|
||||
if let Key::Code(key) = self.win_key_code_to_termwiz_key_code(
|
||||
&key.key.resolve(self.config.key_map_preference),
|
||||
) {
|
||||
|
@ -1,5 +1,4 @@
|
||||
use crate::tabbar::TabBarItem;
|
||||
use crate::termwindow::keyevent::window_mods_to_termwiz_mods;
|
||||
use crate::termwindow::{
|
||||
GuiWin, MouseCapture, PositionedSplit, ScrollHit, TermWindowNotif, UIItem, UIItemType, TMB,
|
||||
};
|
||||
@ -984,7 +983,7 @@ impl super::TermWindow {
|
||||
y: row,
|
||||
x_pixel_offset,
|
||||
y_pixel_offset,
|
||||
modifiers: window_mods_to_termwiz_mods(event.modifiers),
|
||||
modifiers: event.modifiers,
|
||||
};
|
||||
|
||||
if allow_action
|
||||
|
@ -10,5 +10,8 @@ edition = "2018"
|
||||
bitflags = "1.3"
|
||||
euclid = "0.22"
|
||||
lazy_static = "1.4"
|
||||
serde = {version="1.0", features = ["rc", "derive"]}
|
||||
serde = {version="1.0", features = ["rc", "derive"], optional=true}
|
||||
wezterm-dynamic = {path="../wezterm-dynamic"}
|
||||
|
||||
[features]
|
||||
default = ["serde"]
|
||||
|
@ -462,7 +462,8 @@ impl ToString for KeyCode {
|
||||
}
|
||||
|
||||
bitflags! {
|
||||
#[derive(Default, Deserialize, Serialize, FromDynamic, ToDynamic)]
|
||||
#[cfg_attr(feature="serde", derive(Serialize, Deserialize))]
|
||||
#[derive(Default, FromDynamic, ToDynamic)]
|
||||
#[dynamic(into="String", try_from="String")]
|
||||
pub struct Modifiers: u16 {
|
||||
const NONE = 0;
|
||||
|
Loading…
Reference in New Issue
Block a user