This PR mainlines the current state of new GPUI2-based UI from the `gpui2-ui` branch. Release Notes: - N/A --------- Co-authored-by: Nate Butler <iamnbutler@gmail.com> Co-authored-by: Piotr Osiewicz <24362066+osiewicz@users.noreply.github.com> Co-authored-by: Nate <nate@zed.dev>
85 lines
3.0 KiB
Rust
85 lines
3.0 KiB
Rust
use std::sync::Arc;
|
|
|
|
use gpui2::geometry::{relative, rems, Size};
|
|
|
|
use crate::prelude::*;
|
|
use crate::{theme, Icon, IconButton, Pane, Tab};
|
|
|
|
#[derive(Element)]
|
|
pub struct Terminal {}
|
|
|
|
impl Terminal {
|
|
pub fn new() -> Self {
|
|
Self {}
|
|
}
|
|
|
|
fn render<V: 'static>(&mut self, _: &mut V, cx: &mut ViewContext<V>) -> impl IntoElement<V> {
|
|
let theme = theme(cx);
|
|
|
|
let can_navigate_back = true;
|
|
let can_navigate_forward = false;
|
|
|
|
div()
|
|
.flex()
|
|
.flex_col()
|
|
.w_full()
|
|
.child(
|
|
// Terminal Tabs.
|
|
div()
|
|
.w_full()
|
|
.flex()
|
|
.fill(theme.middle.base.default.background)
|
|
.child(
|
|
div().px_1().flex().flex_none().gap_2().child(
|
|
div()
|
|
.flex()
|
|
.items_center()
|
|
.gap_px()
|
|
.child(
|
|
IconButton::new(Icon::ArrowLeft).state(
|
|
InteractionState::Enabled.if_enabled(can_navigate_back),
|
|
),
|
|
)
|
|
.child(IconButton::new(Icon::ArrowRight).state(
|
|
InteractionState::Enabled.if_enabled(can_navigate_forward),
|
|
)),
|
|
),
|
|
)
|
|
.child(
|
|
div().w_0().flex_1().h_full().child(
|
|
div()
|
|
.flex()
|
|
.child(
|
|
Tab::new()
|
|
.title("zed — fish".to_string())
|
|
.icon(Icon::Terminal)
|
|
.close_side(IconSide::Right)
|
|
.current(true),
|
|
)
|
|
.child(
|
|
Tab::new()
|
|
.title("zed — fish".to_string())
|
|
.icon(Icon::Terminal)
|
|
.close_side(IconSide::Right)
|
|
.current(false),
|
|
),
|
|
),
|
|
),
|
|
)
|
|
// Terminal Pane.
|
|
.child(Pane::new(
|
|
ScrollState::default(),
|
|
Size {
|
|
width: relative(1.).into(),
|
|
height: rems(36.).into(),
|
|
},
|
|
|_, payload| {
|
|
let theme = payload.downcast_ref::<Arc<Theme>>().unwrap();
|
|
|
|
vec![crate::static_data::terminal_buffer(&theme).into_any()]
|
|
},
|
|
Box::new(theme),
|
|
))
|
|
}
|
|
}
|