|
|
@ -5,6 +5,9 @@ use helix_core::Position;
|
|
|
|
use helix_view::graphics::{CursorKind, Rect};
|
|
|
|
use helix_view::graphics::{CursorKind, Rect};
|
|
|
|
|
|
|
|
|
|
|
|
use crossterm::event::Event;
|
|
|
|
use crossterm::event::Event;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
#[cfg(feature = "integration")]
|
|
|
|
|
|
|
|
use tui::backend::TestBackend;
|
|
|
|
use tui::buffer::Buffer as Surface;
|
|
|
|
use tui::buffer::Buffer as Surface;
|
|
|
|
|
|
|
|
|
|
|
|
pub type Callback = Box<dyn FnOnce(&mut Compositor, &mut Context)>;
|
|
|
|
pub type Callback = Box<dyn FnOnce(&mut Compositor, &mut Context)>;
|
|
|
@ -64,10 +67,20 @@ pub trait Component: Any + AnyComponent {
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
use anyhow::Context as AnyhowContext;
|
|
|
|
use anyhow::Context as AnyhowContext;
|
|
|
|
|
|
|
|
use tui::backend::Backend;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
#[cfg(not(feature = "integration"))]
|
|
|
|
|
|
|
|
use tui::backend::CrosstermBackend;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
#[cfg(not(feature = "integration"))]
|
|
|
|
use std::io::stdout;
|
|
|
|
use std::io::stdout;
|
|
|
|
use tui::backend::{Backend, CrosstermBackend};
|
|
|
|
|
|
|
|
|
|
|
|
#[cfg(not(feature = "integration"))]
|
|
|
|
type Terminal = tui::terminal::Terminal<CrosstermBackend<std::io::Stdout>>;
|
|
|
|
type Terminal = tui::terminal::Terminal<CrosstermBackend<std::io::Stdout>>;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
#[cfg(feature = "integration")]
|
|
|
|
|
|
|
|
type Terminal = tui::terminal::Terminal<TestBackend>;
|
|
|
|
|
|
|
|
|
|
|
|
pub struct Compositor {
|
|
|
|
pub struct Compositor {
|
|
|
|
layers: Vec<Box<dyn Component>>,
|
|
|
|
layers: Vec<Box<dyn Component>>,
|
|
|
|
terminal: Terminal,
|
|
|
|
terminal: Terminal,
|
|
|
@ -77,7 +90,12 @@ pub struct Compositor {
|
|
|
|
|
|
|
|
|
|
|
|
impl Compositor {
|
|
|
|
impl Compositor {
|
|
|
|
pub fn new() -> anyhow::Result<Self> {
|
|
|
|
pub fn new() -> anyhow::Result<Self> {
|
|
|
|
|
|
|
|
#[cfg(not(feature = "integration"))]
|
|
|
|
let backend = CrosstermBackend::new(stdout());
|
|
|
|
let backend = CrosstermBackend::new(stdout());
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
#[cfg(feature = "integration")]
|
|
|
|
|
|
|
|
let backend = TestBackend::new(120, 150);
|
|
|
|
|
|
|
|
|
|
|
|
let terminal = Terminal::new(backend).context("build terminal")?;
|
|
|
|
let terminal = Terminal::new(backend).context("build terminal")?;
|
|
|
|
Ok(Self {
|
|
|
|
Ok(Self {
|
|
|
|
layers: Vec::new(),
|
|
|
|
layers: Vec::new(),
|
|
|
|