diff --git a/src/ui/chat/tree/blocks.rs b/src/ui/chat/tree/blocks.rs index 5ba557f..2ded080 100644 --- a/src/ui/chat/tree/blocks.rs +++ b/src/ui/chat/tree/blocks.rs @@ -17,9 +17,8 @@ pub enum MsgContent { } pub struct MsgBlock { - id: I, - cursor: bool, - content: MsgContent, + pub id: I, + pub content: MsgContent, } impl MsgBlock { @@ -42,12 +41,50 @@ pub enum BlockBody { } pub struct Block { - line: i32, - indent: usize, - body: BlockBody, + pub line: i32, + pub indent: usize, + pub body: BlockBody, } impl Block { + pub fn bottom() -> Self { + Self { + line: 0, + indent: 0, + body: BlockBody::Marker(MarkerBlock::Bottom), + } + } + + pub fn after(indent: usize, id: I) -> Self { + Self { + line: 0, + indent, + body: BlockBody::Marker(MarkerBlock::After(id)), + } + } + + pub fn msg(indent: usize, id: I, nick: Styled, lines: Vec) -> Self { + Self { + line: 0, + indent, + body: BlockBody::Msg(MsgBlock { + id, + content: MsgContent::Msg { nick, lines }, + }), + } + } + + pub fn placeholder(indent: usize, id: I) -> Self { + Self { + line: 0, + indent, + body: BlockBody::Msg(MsgBlock { + id, + content: MsgContent::Placeholder, + }), + } + } + pub fn height(&self) -> i32 { match &self.body { BlockBody::Marker(m) => 0,