aboutsummaryrefslogtreecommitdiffstats
path: root/zellij-server/src/output
diff options
context:
space:
mode:
authorEatgrass <eatgrass@live.cn>2023-11-05 08:30:35 -0600
committerGitHub <noreply@github.com>2023-11-05 15:30:35 +0100
commit7f87d93a430a47c82ce3f177a6a2609d3f6abade (patch)
tree677e43c0c0613ef2e20377295c5e2212833c028f /zellij-server/src/output
parentdocs(changelog): session resurrection UI (diff)
downloadsl0ppij-7f87d93a430a47c82ce3f177a6a2609d3f6abade.tar.gz
sl0ppij-7f87d93a430a47c82ce3f177a6a2609d3f6abade.tar.xz
sl0ppij-7f87d93a430a47c82ce3f177a6a2609d3f6abade.zip
feat(terminal): support styled underlines (#2730)
* feat: support styled underlines * remove deadcode * Add ansi_underlines config option * Add missing variables * Add ansi_underlines on Output and OutputBuffer * Fix tests * Add separate styled underline enum * Remove ansi_underlines from fg and bg * Remove unneeded variables * Rename ansi_underlines -> styled_underlines * Simplify CharacterStyles::new() * Move styled_underlines config description * Fix single underline and remove extra field on CharacterStyles * Read styled-underlines flag from cli opts * remove extra attribute left from merge conflict --------- Co-authored-by: Mike Lloyd <mike.lloyd03@pm.me> Co-authored-by: Mike Lloyd <49411532+mike-lloyd03@users.noreply.github.com> Co-authored-by: Aram Drevekenin <aram@poor.dev>
Diffstat (limited to 'zellij-server/src/output')
-rw-r--r--zellij-server/src/output/mod.rs16
1 files changed, 13 insertions, 3 deletions
diff --git a/zellij-server/src/output/mod.rs b/zellij-server/src/output/mod.rs
index d7515337..3f99b401 100644
--- a/zellij-server/src/output/mod.rs
+++ b/zellij-server/src/output/mod.rs
@@ -83,6 +83,7 @@ fn serialize_chunks_with_newlines(
character_chunks: Vec<CharacterChunk>,
_sixel_chunks: Option<&Vec<SixelImageChunk>>, // TODO: fix this sometime
link_handler: Option<&mut Rc<RefCell<LinkHandler>>>,
+ styled_underlines: bool,
) -> Result<String> {
let err_context = || "failed to serialize input chunks".to_string();
@@ -90,7 +91,8 @@ fn serialize_chunks_with_newlines(
let link_handler = link_handler.map(|l_h| l_h.borrow());
for character_chunk in character_chunks {
let chunk_changed_colors = character_chunk.changed_colors();
- let mut character_styles = CharacterStyles::new();
+ let mut character_styles =
+ CharacterStyles::new().enable_styled_underlines(styled_underlines);
vte_output.push_str("\n\r");
let mut chunk_width = character_chunk.x;
for t_character in character_chunk.terminal_characters.iter() {
@@ -120,6 +122,7 @@ fn serialize_chunks(
sixel_chunks: Option<&Vec<SixelImageChunk>>,
link_handler: Option<&mut Rc<RefCell<LinkHandler>>>,
sixel_image_store: Option<&mut SixelImageStore>,
+ styled_underlines: bool,
) -> Result<String> {
let err_context = || "failed to serialize input chunks".to_string();
@@ -128,7 +131,8 @@ fn serialize_chunks(
let link_handler = link_handler.map(|l_h| l_h.borrow());
for character_chunk in character_chunks {
let chunk_changed_colors = character_chunk.changed_colors();
- let mut character_styles = CharacterStyles::new();
+ let mut character_styles =
+ CharacterStyles::new().enable_styled_underlines(styled_underlines);
vte_goto_instruction(character_chunk.x, character_chunk.y, &mut vte_output)
.with_context(err_context)?;
let mut chunk_width = character_chunk.x;
@@ -245,16 +249,19 @@ pub struct Output {
sixel_image_store: Rc<RefCell<SixelImageStore>>,
character_cell_size: Rc<RefCell<Option<SizeInPixels>>>,
floating_panes_stack: Option<FloatingPanesStack>,
+ styled_underlines: bool,
}
impl Output {
pub fn new(
sixel_image_store: Rc<RefCell<SixelImageStore>>,
character_cell_size: Rc<RefCell<Option<SizeInPixels>>>,
+ styled_underlines: bool,
) -> Self {
Output {
sixel_image_store,
character_cell_size,
+ styled_underlines,
..Default::default()
}
}
@@ -417,6 +424,7 @@ impl Output {
self.sixel_chunks.get(&client_id),
self.link_handler.as_mut(),
Some(&mut self.sixel_image_store.borrow_mut()),
+ self.styled_underlines,
)
.with_context(err_context)?,
); // TODO: less allocations?
@@ -869,6 +877,7 @@ impl CharacterChunk {
pub struct OutputBuffer {
pub changed_lines: HashSet<usize>, // line index
pub should_update_all_lines: bool,
+ styled_underlines: bool,
}
impl Default for OutputBuffer {
@@ -876,6 +885,7 @@ impl Default for OutputBuffer {
OutputBuffer {
changed_lines: HashSet::new(),
should_update_all_lines: true, // first time we should do a full render
+ styled_underlines: true,
}
}
}
@@ -913,7 +923,7 @@ impl OutputBuffer {
let y = line_index;
chunks.push(CharacterChunk::new(terminal_characters, x, y));
}
- serialize_chunks_with_newlines(chunks, None, None)
+ serialize_chunks_with_newlines(chunks, None, None, self.styled_underlines)
}
pub fn changed_chunks_in_viewport(
&self,