Skip to content

Commit

Permalink
create_mock_context and create_dead_context
Browse files Browse the repository at this point in the history
  • Loading branch information
raphamorim committed Dec 22, 2024
1 parent 22f4d48 commit c7e0308
Showing 1 changed file with 39 additions and 3 deletions.
42 changes: 39 additions & 3 deletions frontends/rioterm/src/context/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -181,7 +181,42 @@ pub struct ContextManager<T: EventListener> {
pub titles: ContextManagerTitles,
}

pub fn create_mock_context<T: rio_backend::event::EventListener + Clone + std::marker::Send + 'static>(
pub fn create_dead_context<T: rio_backend::event::EventListener>(
event_proxy: T,
window_id: WindowId,
route_id: usize,
rich_text_id: usize,
dimension: ContextDimension,
) -> Context<T> {
let terminal = Crosswords::new(
dimension,
CursorShape::Block,
event_proxy,
window_id,
route_id,
);
let terminal: Arc<FairMutex<Crosswords<T>>> = Arc::new(FairMutex::new(terminal));
let (sender, _receiver) = corcovado::channel::channel();

Context {
route_id,
#[cfg(not(target_os = "windows"))]
main_fd: Arc::new(-1),
#[cfg(not(target_os = "windows"))]
shell_pid: 1,
messenger: Messenger::new(sender),
renderable_content: RenderableContent::new(Cursor::default()),
terminal,
rich_text_id,
dimension,
ime: Ime::new(),
}
}

#[cfg(test)]
pub fn create_mock_context<
T: rio_backend::event::EventListener + Clone + std::marker::Send + 'static,
>(
event_proxy: T,
window_id: WindowId,
route_id: usize,
Expand Down Expand Up @@ -210,7 +245,8 @@ pub fn create_mock_context<T: rio_backend::event::EventListener + Clone + std::m
rich_text_id,
dimension,
&config,
).unwrap()
)
.unwrap()

// let terminal = Crosswords::new(
// dimension,
Expand Down Expand Up @@ -384,7 +420,7 @@ impl<T: EventListener + Clone + std::marker::Send + 'static> ContextManager<T> {
window_id,
);

create_mock_context(
create_dead_context(
event_proxy.clone(),
window_id,
route_id,
Expand Down

0 comments on commit c7e0308

Please sign in to comment.