1use std::sync::Arc;
2
3use gpui2::geometry::{relative, rems, Size};
4
5use crate::prelude::*;
6use crate::{theme, Icon, IconButton, Pane, Tab};
7
8#[derive(Element)]
9pub struct Terminal {}
10
11impl Terminal {
12 pub fn new() -> Self {
13 Self {}
14 }
15
16 fn render<V: 'static>(&mut self, _: &mut V, cx: &mut ViewContext<V>) -> impl IntoElement<V> {
17 let theme = theme(cx);
18
19 let can_navigate_back = true;
20 let can_navigate_forward = false;
21
22 div()
23 .flex()
24 .flex_col()
25 .w_full()
26 .child(
27 // Terminal Tabs.
28 div()
29 .w_full()
30 .flex()
31 .fill(theme.middle.base.default.background)
32 .child(
33 div().px_1().flex().flex_none().gap_2().child(
34 div()
35 .flex()
36 .items_center()
37 .gap_px()
38 .child(
39 IconButton::new(Icon::ArrowLeft).state(
40 InteractionState::Enabled.if_enabled(can_navigate_back),
41 ),
42 )
43 .child(IconButton::new(Icon::ArrowRight).state(
44 InteractionState::Enabled.if_enabled(can_navigate_forward),
45 )),
46 ),
47 )
48 .child(
49 div().w_0().flex_1().h_full().child(
50 div()
51 .flex()
52 .child(
53 Tab::new()
54 .title("zed — fish".to_string())
55 .icon(Icon::Terminal)
56 .close_side(IconSide::Right)
57 .current(true),
58 )
59 .child(
60 Tab::new()
61 .title("zed — fish".to_string())
62 .icon(Icon::Terminal)
63 .close_side(IconSide::Right)
64 .current(false),
65 ),
66 ),
67 ),
68 )
69 // Terminal Pane.
70 .child(Pane::new(
71 ScrollState::default(),
72 Size {
73 width: relative(1.).into(),
74 height: rems(36.).into(),
75 },
76 |_, payload| {
77 let theme = payload.downcast_ref::<Arc<Theme>>().unwrap();
78
79 vec![crate::static_data::terminal_buffer(&theme).into_any()]
80 },
81 Box::new(theme),
82 ))
83 }
84}