Skip to content

Commit

Permalink
fixup! update markers
Browse files Browse the repository at this point in the history
  • Loading branch information
raphamorim committed Dec 22, 2024
1 parent 1baf8b2 commit 123e43b
Show file tree
Hide file tree
Showing 2 changed files with 155 additions and 155 deletions.
306 changes: 153 additions & 153 deletions frontends/rioterm/src/context/grid.rs
Original file line number Diff line number Diff line change
Expand Up @@ -969,182 +969,182 @@ pub mod test {
use pretty_assertions::assert_eq;
use rio_window::window::WindowId;

#[test]
fn test_single_context_respecting_margin_and_no_quad_creation() {
let margin = Delta {
x: 10.,
top_y: 20.,
bottom_y: 20.,
};

let context_dimension = ContextDimension::build(
1200.0,
800.0,
SugarDimensions {
scale: 2.,
width: 18.,
height: 9.,
},
1.0,
Delta::<f32>::default(),
);

assert_eq!(context_dimension.columns, 66);
assert_eq!(context_dimension.lines, 88);
let rich_text_id = 0;
let route_id = 0;
let context = create_mock_context(
VoidListener {},
WindowId::from(0),
route_id,
rich_text_id,
context_dimension,
);
let context_width = context.dimension.width;
let context_height = context.dimension.height;
let context_margin = context.dimension.margin;
let grid = ContextGrid::<VoidListener>::new(context, margin, [0., 0., 0., 0.]);
// The first context should fill completely w/h grid
assert_eq!(grid.width, context_width);
assert_eq!(grid.height, context_height);

// Context margin should empty
assert_eq!(Delta::<f32>::default(), context_margin);
assert_eq!(grid.margin, margin);

assert_eq!(
grid.objects(),
vec![Object::RichText(RichText {
id: rich_text_id,
position: [10., 20.],
})]
);
}

// #[test]
// fn test_split_right() {
// fn test_single_context_respecting_margin_and_no_quad_creation() {
// let margin = Delta {
// x: 0.,
// top_y: 0.,
// bottom_y: 0.,
// x: 10.,
// top_y: 20.,
// bottom_y: 20.,
// };

// let context_dimension = ContextDimension::build(
// 1200.0,
// 800.0,
// SugarDimensions {
// scale: 1.,
// width: 14.,
// height: 8.,
// scale: 2.,
// width: 18.,
// height: 9.,
// },
// 1.0,
// Delta::<f32>::default(),
// );

// assert_eq!(context_dimension.columns, 85);
// assert_eq!(context_dimension.lines, 100);

// let (first_context, first_context_id) = {
// let rich_text_id = 0;
// let route_id = 0;
// (
// create_mock_context(
// VoidListener {},
// WindowId::from(0),
// route_id,
// rich_text_id,
// context_dimension,
// ),
// rich_text_id,
// )
// };

// let (second_context, second_context_id) = {
// let rich_text_id = 1;
// let route_id = 0;
// (
// create_mock_context(
// VoidListener {},
// WindowId::from(0),
// route_id,
// rich_text_id,
// context_dimension,
// ),
// rich_text_id,
// )
// };

// let mut grid =
// ContextGrid::<VoidListener>::new(first_context, margin, [1., 0., 0., 0.]);
// assert_eq!(context_dimension.columns, 66);
// assert_eq!(context_dimension.lines, 88);
// let rich_text_id = 0;
// let route_id = 0;
// let context = create_mock_context(
// VoidListener {},
// WindowId::from(0),
// route_id,
// rich_text_id,
// context_dimension,
// );
// let context_width = context.dimension.width;
// let context_height = context.dimension.height;
// let context_margin = context.dimension.margin;
// let grid = ContextGrid::<VoidListener>::new(context, margin, [0., 0., 0., 0.]);
// // The first context should fill completely w/h grid
// assert_eq!(grid.width, context_width);
// assert_eq!(grid.height, context_height);

// // Context margin should empty
// assert_eq!(Delta::<f32>::default(), context_margin);
// assert_eq!(grid.margin, margin);

// assert_eq!(
// grid.objects(),
// vec![Object::RichText(RichText {
// id: first_context_id,
// position: [0., 0.],
// id: rich_text_id,
// position: [10., 20.],
// })]
// );
// grid.split_right(second_context);
// }

// assert_eq!(
// grid.objects(),
// vec![
// Object::RichText(RichText {
// id: first_context_id,
// position: [0.0, 0.0],
// }),
// create_border([1.0, 0.0, 0.0, 0.0], [0.0, 800.0], [598., 1.0]),
// create_border([1.0, 0.0, 0.0, 0.0], [598.0, 0.0], [1.0, 800.0]),
// Object::RichText(RichText {
// id: second_context_id,
// position: [600., 0.0]
// }),
// create_border([1.0, 0.0, 0.0, 0.0], [600.0, 800.0], [600.0, 1.0]),
// create_border([1.0, 0.0, 0.0, 0.0], [1200.0, 0.0], [1.0, 800.0]),
// ]
// );
#[test]
fn test_split_right() {
let margin = Delta {
x: 0.,
top_y: 0.,
bottom_y: 0.,
};

// let (third_context, third_context_id) = {
// let rich_text_id = 2;
// let route_id = 0;
// (
// create_mock_context(
// VoidListener {},
// WindowId::from(0),
// route_id,
// rich_text_id,
// context_dimension,
// ),
// rich_text_id,
// )
// };
let context_dimension = ContextDimension::build(
1200.0,
800.0,
SugarDimensions {
scale: 1.,
width: 14.,
height: 8.,
},
1.0,
Delta::<f32>::default(),
);

// grid.split_right(third_context);
assert_eq!(context_dimension.columns, 85);
assert_eq!(context_dimension.lines, 100);

let (first_context, first_context_id) = {
let rich_text_id = 0;
let route_id = 0;
(
create_mock_context(
VoidListener {},
WindowId::from(0),
route_id,
rich_text_id,
context_dimension,
),
rich_text_id,
)
};

// assert_eq!(
// grid.objects(),
// vec![
// Object::RichText(RichText {
// id: first_context_id,
// position: [0.0, 0.0],
// }),
// create_border([1.0, 0.0, 0.0, 0.0], [0.0, 800.0], [598., 1.0]),
// create_border([1.0, 0.0, 0.0, 0.0], [598.0, 0.0], [1.0, 800.0]),
// Object::RichText(RichText {
// id: second_context_id,
// position: [600.0, 0.0]
// }),
// create_border([1.0, 0.0, 0.0, 0.0], [600.0, 800.0], [298.0, 1.0]),
// create_border([1.0, 0.0, 0.0, 0.0], [898.0, 0.0], [1.0, 800.0]),
// Object::RichText(RichText {
// id: third_context_id,
// position: [900.0, 0.0]
// }),
// create_border([1.0, 0.0, 0.0, 0.0], [900.0, 800.0], [300.0, 1.0]),
// create_border([1.0, 0.0, 0.0, 0.0], [1200.0, 0.0], [1.0, 800.0]),
// ]
// );
// }
let (second_context, second_context_id) = {
let rich_text_id = 1;
let route_id = 0;
(
create_mock_context(
VoidListener {},
WindowId::from(0),
route_id,
rich_text_id,
context_dimension,
),
rich_text_id,
)
};

let mut grid =
ContextGrid::<VoidListener>::new(first_context, margin, [1., 0., 0., 0.]);

assert_eq!(
grid.objects(),
vec![Object::RichText(RichText {
id: first_context_id,
position: [0., 0.],
})]
);
grid.split_right(second_context);

assert_eq!(
grid.objects(),
vec![
Object::RichText(RichText {
id: first_context_id,
position: [0.0, 0.0],
}),
create_border([1.0, 0.0, 0.0, 0.0], [0.0, 800.0], [598., 1.0]),
create_border([1.0, 0.0, 0.0, 0.0], [598.0, 0.0], [1.0, 800.0]),
Object::RichText(RichText {
id: second_context_id,
position: [600., 0.0]
}),
create_border([1.0, 0.0, 0.0, 0.0], [600.0, 800.0], [600.0, 1.0]),
create_border([1.0, 0.0, 0.0, 0.0], [1200.0, 0.0], [1.0, 800.0]),
]
);

let (third_context, third_context_id) = {
let rich_text_id = 2;
let route_id = 0;
(
create_mock_context(
VoidListener {},
WindowId::from(0),
route_id,
rich_text_id,
context_dimension,
),
rich_text_id,
)
};

grid.split_right(third_context);

assert_eq!(
grid.objects(),
vec![
Object::RichText(RichText {
id: first_context_id,
position: [0.0, 0.0],
}),
create_border([1.0, 0.0, 0.0, 0.0], [0.0, 800.0], [598., 1.0]),
create_border([1.0, 0.0, 0.0, 0.0], [598.0, 0.0], [1.0, 800.0]),
Object::RichText(RichText {
id: second_context_id,
position: [600.0, 0.0]
}),
create_border([1.0, 0.0, 0.0, 0.0], [600.0, 800.0], [298.0, 1.0]),
create_border([1.0, 0.0, 0.0, 0.0], [898.0, 0.0], [1.0, 800.0]),
Object::RichText(RichText {
id: third_context_id,
position: [900.0, 0.0]
}),
create_border([1.0, 0.0, 0.0, 0.0], [900.0, 800.0], [300.0, 1.0]),
create_border([1.0, 0.0, 0.0, 0.0], [1200.0, 0.0], [1.0, 800.0]),
]
);
}

// #[test]
// fn test_split_right_with_margin() {
Expand Down
4 changes: 2 additions & 2 deletions frontends/rioterm/src/context/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -181,7 +181,7 @@ 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_mock_context<T: rio_backend::event::EventListener>(
event_proxy: T,
window_id: WindowId,
route_id: usize,
Expand All @@ -191,7 +191,7 @@ pub fn create_mock_context<T: rio_backend::event::EventListener + Clone + std::m
let terminal = Crosswords::new(
dimension,
CursorShape::Block,
event_proxy.clone(),
event_proxy,
window_id,
route_id,
);
Expand Down

0 comments on commit 123e43b

Please sign in to comment.