mirror of
https://github.com/roc-lang/roc.git
synced 2025-10-02 16:21:11 +00:00
feat: only render unline if attribute is there
This commit is contained in:
parent
0853c0bdb7
commit
6e752645a6
2 changed files with 58 additions and 28 deletions
|
@ -47,16 +47,28 @@ pub struct UnderlineEnd {
|
|||
#[derive(Debug)]
|
||||
pub enum Attribute {
|
||||
// Rust does not yet support types for enum variants so we have to do it like this
|
||||
Caret { caret: Caret },
|
||||
Caret {
|
||||
caret: Caret,
|
||||
},
|
||||
|
||||
SelectionStart { selection_start: SelectionStart },
|
||||
SelectionEnd { selection_end: SelectionEnd },
|
||||
SelectionStart {
|
||||
selection_start: SelectionStart,
|
||||
},
|
||||
SelectionEnd {
|
||||
selection_end: SelectionEnd,
|
||||
},
|
||||
|
||||
HighlightStart { highlight_start: HighlightStart },
|
||||
HighlightEnd { highlight_end: HighlightEnd },
|
||||
HighlightStart {
|
||||
highlight_start: HighlightStart,
|
||||
},
|
||||
HighlightEnd {
|
||||
highlight_end: HighlightEnd,
|
||||
},
|
||||
|
||||
UnderlineStart { underline_start: UnderlineStart },
|
||||
UnderlineEnd { underline_end: UnderlineEnd },
|
||||
Underline {
|
||||
underline_start: UnderlineStart,
|
||||
underline_end: UnderlineEnd,
|
||||
},
|
||||
}
|
||||
|
||||
#[derive(Debug, Default)]
|
||||
|
|
|
@ -3,9 +3,15 @@ use crate::editor::{ed_error::EdResult, theme::EdTheme, util::map_get};
|
|||
use crate::graphics::primitives::rect::Rect;
|
||||
use crate::graphics::primitives::text as gr_text;
|
||||
use cgmath::Vector2;
|
||||
use roc_code_markup::markup::nodes::{MarkupNode, BLANK_PLACEHOLDER};
|
||||
use roc_code_markup::slow_pool::{MarkNodeId, SlowPool};
|
||||
use roc_code_markup::{syntax_highlight::HighlightStyle, underline_style::UnderlineStyle};
|
||||
use roc_code_markup::{
|
||||
markup::{
|
||||
attribute::Attribute,
|
||||
nodes::{MarkupNode, BLANK_PLACEHOLDER},
|
||||
},
|
||||
slow_pool::{MarkNodeId, SlowPool},
|
||||
syntax_highlight::HighlightStyle,
|
||||
underline_style::UnderlineStyle,
|
||||
};
|
||||
use winit::dpi::PhysicalSize;
|
||||
|
||||
use crate::{editor::config::Config, graphics::colors};
|
||||
|
@ -127,7 +133,7 @@ fn markup_to_wgpu_helper<'a>(
|
|||
content,
|
||||
ast_node_id: _,
|
||||
syn_high_style,
|
||||
attributes: _,
|
||||
attributes,
|
||||
parent_id_opt: _,
|
||||
newlines_at_end,
|
||||
} => {
|
||||
|
@ -139,20 +145,19 @@ fn markup_to_wgpu_helper<'a>(
|
|||
.with_color(colors::to_slice(*highlight_color))
|
||||
.with_scale(code_style.font_size);
|
||||
|
||||
for attribute in &attributes.all {
|
||||
match attribute {
|
||||
Attribute::Underline {
|
||||
underline_start: _,
|
||||
underline_end: _,
|
||||
} => {
|
||||
let top_left_coords = (
|
||||
code_style.txt_coords.x + (txt_row_col.1 as f32) * char_width,
|
||||
code_style.txt_coords.y + (txt_row_col.0 as f32) * char_height + 1.0 * char_height,
|
||||
code_style.txt_coords.y
|
||||
+ (txt_row_col.0 as f32) * char_height
|
||||
+ 1.0 * char_height,
|
||||
);
|
||||
|
||||
txt_row_col.1 += content.len();
|
||||
|
||||
for _ in 0..*newlines_at_end {
|
||||
txt_row_col.0 += 1;
|
||||
txt_row_col.1 = 0;
|
||||
}
|
||||
|
||||
wgpu_texts.push(glyph_text);
|
||||
|
||||
let underline_rect = Rect {
|
||||
top_left_coords: top_left_coords.into(),
|
||||
width: char_width * (full_content.len() as f32),
|
||||
|
@ -166,6 +171,19 @@ fn markup_to_wgpu_helper<'a>(
|
|||
|
||||
rects.push(underline_rect);
|
||||
}
|
||||
rest => todo!("handle Attribute: {:?}", rest),
|
||||
}
|
||||
}
|
||||
|
||||
txt_row_col.1 += content.len();
|
||||
|
||||
for _ in 0..*newlines_at_end {
|
||||
txt_row_col.0 += 1;
|
||||
txt_row_col.1 = 0;
|
||||
}
|
||||
|
||||
wgpu_texts.push(glyph_text);
|
||||
}
|
||||
MarkupNode::Blank {
|
||||
ast_node_id: _,
|
||||
attributes: _,
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue