move term to its own crate
This makes it harder to accidentally violate separation of concerns.
This commit is contained in:
1 parent
4dcab21a97
commit
11e6d538fc
10 files changed
+52
-32
No files matched your search
+5
-2
@@ -1,3 +1,5 @@
|
||||
[workspace]
|
||||
|
||||
[package]
|
||||
authors = ["Wez Furlong <wez@wezfurlong.org>"]
|
||||
name = "wezterm"
|
||||
@@ -12,9 +14,10 @@ libc = "0.2.36"
|
||||
mio = "0.6.12"
|
||||
resize = "0.3.0"
|
||||
servo-fontconfig = "0.4.0"
|
||||
unicode-segmentation = "1.2.0"
|
||||
unicode-width = "0.1.4"
|
||||
vte = "0.3.2"
|
||||
|
||||
[dependencies.term]
|
||||
path = "term"
|
||||
|
||||
[dependencies.xcb]
|
||||
features = ["shm"]
|
||||
|
||||
+1
-7
@@ -1,20 +1,15 @@
|
||||
#![feature(slice_patterns)]
|
||||
|
||||
#[macro_use]
|
||||
extern crate failure;
|
||||
#[macro_use]
|
||||
extern crate bitflags;
|
||||
extern crate unicode_width;
|
||||
extern crate unicode_segmentation;
|
||||
extern crate harfbuzz_sys;
|
||||
#[cfg(not(target_os = "macos"))]
|
||||
extern crate fontconfig; // from servo-fontconfig
|
||||
#[cfg(not(target_os = "macos"))]
|
||||
extern crate freetype;
|
||||
extern crate resize;
|
||||
extern crate vte;
|
||||
extern crate libc;
|
||||
extern crate mio;
|
||||
extern crate term;
|
||||
#[macro_use]
|
||||
pub mod log;
|
||||
|
||||
@@ -34,7 +29,6 @@ mod xkeysyms;
|
||||
mod font;
|
||||
use font::{Font, FontPattern, ftwrap};
|
||||
|
||||
mod term;
|
||||
mod pty;
|
||||
mod sigchld;
|
||||
mod xwin;
|
||||
|
||||
+15
-17
@@ -195,24 +195,22 @@ pub const XK_asciitilde: xcb_keysym_t = 0x007e;
|
||||
use term::KeyCode;
|
||||
use term::KeyModifiers;
|
||||
|
||||
impl From<xcb_keysym_t> for KeyCode {
|
||||
fn from(k: xcb_keysym_t) -> Self {
|
||||
match k {
|
||||
XK_space...XK_asciitilde => {
|
||||
// This range overlaps with ascii
|
||||
KeyCode::Char(k as u8 as char)
|
||||
}
|
||||
XK_BackSpace | XK_Tab | XK_Linefeed | XK_Return | XK_Escape => {
|
||||
KeyCode::Char((k & 0xff) as u8 as char)
|
||||
}
|
||||
XK_Control_L | XK_Control_R => KeyCode::Control,
|
||||
XK_Alt_L | XK_Alt_R => KeyCode::Alt,
|
||||
XK_Meta_L | XK_Meta_R => KeyCode::Meta,
|
||||
XK_Super_L | XK_Super_R => KeyCode::Super,
|
||||
XK_Hyper_L | XK_Hyper_R => KeyCode::Hyper,
|
||||
XK_Shift_L | XK_Shift_R => KeyCode::Shift,
|
||||
_ => KeyCode::Unknown,
|
||||
pub fn xcb_keysym_to_keycode(k: xcb_keysym_t) -> KeyCode {
|
||||
match k {
|
||||
XK_space...XK_asciitilde => {
|
||||
// This range overlaps with ascii
|
||||
KeyCode::Char(k as u8 as char)
|
||||
}
|
||||
XK_BackSpace | XK_Tab | XK_Linefeed | XK_Return | XK_Escape => {
|
||||
KeyCode::Char((k & 0xff) as u8 as char)
|
||||
}
|
||||
XK_Control_L | XK_Control_R => KeyCode::Control,
|
||||
XK_Alt_L | XK_Alt_R => KeyCode::Alt,
|
||||
XK_Meta_L | XK_Meta_R => KeyCode::Meta,
|
||||
XK_Super_L | XK_Super_R => KeyCode::Super,
|
||||
XK_Hyper_L | XK_Hyper_R => KeyCode::Hyper,
|
||||
XK_Shift_L | XK_Shift_R => KeyCode::Shift,
|
||||
_ => KeyCode::Unknown,
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
+1
-1
@@ -527,7 +527,7 @@ impl<'a> TerminalWindow<'a> {
|
||||
event,
|
||||
mods.contains(KeyModifiers::SHIFT),
|
||||
);
|
||||
(sym.into(), mods)
|
||||
(xkeysyms::xcb_keysym_to_keycode(sym), mods)
|
||||
}
|
||||
|
||||
pub fn key_down(&mut self, event: &xcb::KeyPressEvent) -> Result<(), Error> {
|
||||
|
||||
@@ -0,0 +1,12 @@
|
||||
[package]
|
||||
authors = ["Wez Furlong <wez@wezfurlong.org>"]
|
||||
name = "term"
|
||||
version = "0.1.0"
|
||||
|
||||
[dependencies]
|
||||
bitflags = "1.0.1"
|
||||
failure = "0.1.1"
|
||||
unicode-segmentation = "1.2.0"
|
||||
unicode-width = "0.1.4"
|
||||
vte = "0.3.2"
|
||||
|
||||
File renamed without changes.
File renamed without changes.
@@ -0,0 +1,3 @@
|
||||
macro_rules! debug {
|
||||
($($arg:tt)*) => (if cfg!(debug_assertions) { println!($($arg)*) })
|
||||
}
|
||||
@@ -1,10 +1,20 @@
|
||||
//! Terminal model
|
||||
#![feature(slice_patterns)]
|
||||
|
||||
#[allow(unused_imports)]
|
||||
#[macro_use]
|
||||
extern crate failure;
|
||||
#[macro_use]
|
||||
extern crate bitflags;
|
||||
extern crate unicode_width;
|
||||
extern crate unicode_segmentation;
|
||||
extern crate vte;
|
||||
|
||||
use failure::Error;
|
||||
use std;
|
||||
use std::ops::{Deref, DerefMut};
|
||||
use unicode_segmentation;
|
||||
use vte;
|
||||
|
||||
#[macro_use]
|
||||
mod debug;
|
||||
|
||||
pub mod color;
|
||||
mod csi;
|
||||
@@ -955,9 +965,9 @@ impl vte::Perform for TerminalState {
|
||||
(b'M', &[], &[]) => self.reverse_index(),
|
||||
|
||||
// Enable alternate character set mode (smacs)
|
||||
(b'0', &[b'('], &[]) => {},
|
||||
(b'0', &[b'('], &[]) => {}
|
||||
// Exit alternate character set mode (rmacs)
|
||||
(b'B', &[b'('], &[]) => {},
|
||||
(b'B', &[b'('], &[]) => {}
|
||||
|
||||
(..) => {
|
||||
println!(
|
||||
File renamed without changes.
Reference in new issue
Block a user