@@ -5,6 +5,9 @@ use helix_core::Position;
5use helix_view::graphics::{CursorKind, Rect};
5use helix_view::graphics::{CursorKind, Rect};
7use crossterm::event::Event;
7use crossterm::event::Event;
9+#[cfg(feature = "integration")]
10+use tui::backend::TestBackend;
8use tui::buffer::Buffer as Surface;
11use tui::buffer::Buffer as Surface;
10pub type Callback = Box<dyn FnOnce(&mut Compositor, &mut Context)>;
13pub type Callback = Box<dyn FnOnce(&mut Compositor, &mut Context)>;
@@ -64,10 +67,20 @@ pub trait Component: Any + AnyComponent {
66use anyhow::Context as AnyhowContext;
69use anyhow::Context as AnyhowContext;
70+use tui::backend::Backend;
72+#[cfg(not(feature = "integration"))]
73+use tui::backend::CrosstermBackend;
75+#[cfg(not(feature = "integration"))]
67use std::io::stdout;
76use std::io::stdout;
68−use tui::backend::{Backend, CrosstermBackend};
77+
78+#[cfg(not(feature = "integration"))]
69type Terminal = tui::terminal::Terminal<CrosstermBackend<std::io::Stdout>>;
79type Terminal = tui::terminal::Terminal<CrosstermBackend<std::io::Stdout>>;
81+#[cfg(feature = "integration")]
82+type Terminal = tui::terminal::Terminal<TestBackend>;
71pub struct Compositor {
84pub struct Compositor {
72 layers: Vec<Box<dyn Component>>,
85 layers: Vec<Box<dyn Component>>,
73 terminal: Terminal,
86 terminal: Terminal,
@@ -77,7 +90,12 @@ pub struct Compositor {
78impl Compositor {
91impl Compositor {
79 pub fn new() -> anyhow::Result<Self> {
92 pub fn new() -> anyhow::Result<Self> {
93+ #[cfg(not(feature = "integration"))]
80 let backend = CrosstermBackend::new(stdout());
94 let backend = CrosstermBackend::new(stdout());
96+ #[cfg(feature = "integration")]
97+ let backend = TestBackend::new(120, 150);
81 let terminal = Terminal::new(backend).context("build terminal")?;
99 let terminal = Terminal::new(backend).context("build terminal")?;
82 Ok(Self {
100 Ok(Self {
83 layers: Vec::new(),
101 layers: Vec::new(),