1
1
mirror of https://github.com/wez/wezterm.git synced 2024-12-25 06:12:16 +03:00

remove some duplicated code in favor of spawn_window_impl

This commit is contained in:
Wez Furlong 2019-02-23 17:03:58 -08:00
parent 4f73904be4
commit e5e3fa91f8
2 changed files with 3 additions and 32 deletions

View File

@ -1,3 +1,4 @@
use super::GuiSystem;
use crate::futurecore;
use crate::gliumwindows;
pub use crate::gliumwindows::TerminalWindow;
@ -93,8 +94,6 @@ pub struct GlutinGuiSystem {
event_loop: Rc<GuiEventLoop>,
}
use super::GuiSystem;
impl GlutinGuiSystem {
pub fn new() -> Result<Rc<GuiSystem>, Error> {
let event_loop = Rc::new(GuiEventLoop::new()?);

View File

@ -4,7 +4,7 @@ use crate::font::FontConfiguration;
use crate::futurecore;
use crate::xwindows::xwin::TerminalWindow;
use crate::xwindows::Connection;
use crate::{openpty, Child, MasterPty};
use crate::{openpty, spawn_window_impl, Child, MasterPty};
use failure::Error;
use mio::unix::EventedFd;
use mio::{Event, Evented, Events, Poll, PollOpt, Ready, Token};
@ -244,35 +244,7 @@ impl GuiEventLoop {
config: &Rc<Config>,
fontconfig: &Rc<FontConfiguration>,
) -> Result<(), Error> {
let cmd = config.build_prog(None)?;
// First step is to figure out the font metrics so that we know how
// big things are going to be.
// we always load the cell_height for font 0,
// regardless of which font we are shaping here,
// so that we can scale glyphs appropriately
let metrics = fontconfig.default_font_metrics()?;
let initial_cols = 80u16;
let initial_rows = 24u16;
let initial_pixel_width = initial_cols * metrics.cell_width.ceil() as u16;
let initial_pixel_height = initial_rows * metrics.cell_height.ceil() as u16;
let (master, slave) = openpty(
initial_rows,
initial_cols,
initial_pixel_width,
initial_pixel_height,
)?;
let child = slave.spawn_command(cmd)?;
eprintln!("spawned: {:?}", child);
let terminal = term::Terminal::new(
initial_rows as usize,
initial_cols as usize,
config.scrollback_lines.unwrap_or(3500),
config.hyperlink_rules.clone(),
);
let (terminal, master, child) = spawn_window_impl(None, config, fontconfig)?;
let window = TerminalWindow::new(event_loop, terminal, master, child, fontconfig, config)?;