mirror of https://github.com/lapce/lapce.git
terminal paint find
This commit is contained in:
parent
3bd4a16647
commit
3ca0bda446
|
@ -238,7 +238,6 @@ fn toggle_visual(&mut self, visual_mode: VisualMode) {
|
||||||
if !term.mode().contains(TermMode::VI) {
|
if !term.mode().contains(TermMode::VI) {
|
||||||
term.toggle_vi_mode();
|
term.toggle_vi_mode();
|
||||||
}
|
}
|
||||||
term.selection = None;
|
|
||||||
let ty = match visual_mode {
|
let ty = match visual_mode {
|
||||||
VisualMode::Normal => SelectionType::Simple,
|
VisualMode::Normal => SelectionType::Simple,
|
||||||
VisualMode::Linewise => SelectionType::Lines,
|
VisualMode::Linewise => SelectionType::Lines,
|
||||||
|
@ -956,6 +955,8 @@ fn paint(&mut self, ctx: &mut PaintCtx, data: &LapceTabData, env: &Env) {
|
||||||
for item in content.display_iter {
|
for item in content.display_iter {
|
||||||
let point = item.point;
|
let point = item.point;
|
||||||
let cell = item.cell;
|
let cell = item.cell;
|
||||||
|
let inverse = cell.flags.contains(Flags::INVERSE);
|
||||||
|
|
||||||
let x = point.column.0 as f64 * char_width;
|
let x = point.column.0 as f64 * char_width;
|
||||||
let y =
|
let y =
|
||||||
(point.line.0 as f64 + content.display_offset as f64) * line_height;
|
(point.line.0 as f64 + content.display_offset as f64) * line_height;
|
||||||
|
@ -972,7 +973,6 @@ fn paint(&mut self, ctx: &mut PaintCtx, data: &LapceTabData, env: &Env) {
|
||||||
fg = fg.with_alpha(0.66);
|
fg = fg.with_alpha(0.66);
|
||||||
}
|
}
|
||||||
|
|
||||||
let inverse = cell.flags.contains(Flags::INVERSE);
|
|
||||||
if inverse {
|
if inverse {
|
||||||
let fg_clone = fg.clone();
|
let fg_clone = fg.clone();
|
||||||
fg = bg;
|
fg = bg;
|
||||||
|
@ -1016,20 +1016,80 @@ fn paint(&mut self, ctx: &mut PaintCtx, data: &LapceTabData, env: &Env) {
|
||||||
fg = term_bg.clone();
|
fg = term_bg.clone();
|
||||||
}
|
}
|
||||||
|
|
||||||
let mut builder = ctx
|
if cell.c != ' ' && cell.c != '\t' {
|
||||||
.text()
|
let mut builder = ctx
|
||||||
.new_text_layout(cell.c.to_string())
|
.text()
|
||||||
.font(
|
.new_text_layout(cell.c.to_string())
|
||||||
data.config.editor.font_family(),
|
.font(
|
||||||
data.config.editor.font_size as f64,
|
data.config.editor.font_family(),
|
||||||
)
|
data.config.editor.font_size as f64,
|
||||||
.text_color(fg);
|
)
|
||||||
if bold {
|
.text_color(fg);
|
||||||
builder = builder
|
if bold {
|
||||||
.default_attribute(TextAttribute::Weight(FontWeight::BOLD));
|
builder = builder
|
||||||
|
.default_attribute(TextAttribute::Weight(FontWeight::BOLD));
|
||||||
|
}
|
||||||
|
let text_layout = builder.build().unwrap();
|
||||||
|
ctx.draw_text(&text_layout, Point::new(x, y + y_shift));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if let Some(search_string) = data.find.search_string.as_ref() {
|
||||||
|
if let Ok(dfas) = RegexSearch::new(search_string) {
|
||||||
|
let mut start = alacritty_terminal::index::Point::new(
|
||||||
|
alacritty_terminal::index::Line(
|
||||||
|
-(content.display_offset as i32),
|
||||||
|
),
|
||||||
|
alacritty_terminal::index::Column(0),
|
||||||
|
);
|
||||||
|
let end_line =
|
||||||
|
(start.line + term.screen_lines()).min(term.bottommost_line());
|
||||||
|
let mut max_lines = (end_line.0 - start.line.0) as usize;
|
||||||
|
|
||||||
|
while let Some(m) = term.search_next(
|
||||||
|
&dfas,
|
||||||
|
start,
|
||||||
|
Direction::Right,
|
||||||
|
Side::Left,
|
||||||
|
Some(max_lines),
|
||||||
|
) {
|
||||||
|
let match_start = m.start();
|
||||||
|
if match_start.line.0 < start.line.0
|
||||||
|
|| (match_start.line.0 == start.line.0
|
||||||
|
&& match_start.column.0 < start.column.0)
|
||||||
|
{
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
let x = match_start.column.0 as f64 * char_width;
|
||||||
|
let y = (match_start.line.0 as f64
|
||||||
|
+ content.display_offset as f64)
|
||||||
|
* line_height;
|
||||||
|
let rect = Rect::ZERO.with_origin(Point::new(x, y)).with_size(
|
||||||
|
Size::new(
|
||||||
|
(m.end().column.0 - m.start().column.0
|
||||||
|
+ term.grid()[*m.end()].c.width().unwrap_or(1))
|
||||||
|
as f64
|
||||||
|
* char_width,
|
||||||
|
line_height,
|
||||||
|
),
|
||||||
|
);
|
||||||
|
ctx.stroke(
|
||||||
|
rect,
|
||||||
|
data.config
|
||||||
|
.get_color_unchecked(LapceTheme::TERMINAL_FOREGROUND),
|
||||||
|
1.0,
|
||||||
|
);
|
||||||
|
start = *m.end();
|
||||||
|
if start.column.0 < term.last_column() {
|
||||||
|
start.column.0 += 1;
|
||||||
|
} else {
|
||||||
|
if start.line.0 < term.bottommost_line() {
|
||||||
|
start.column.0 = 0;
|
||||||
|
start.line.0 += 1;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
max_lines = (end_line.0 - start.line.0) as usize;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
let text_layout = builder.build().unwrap();
|
|
||||||
ctx.draw_text(&text_layout, Point::new(x, y + y_shift));
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1044,7 +1104,6 @@ impl EventProxy {}
|
||||||
|
|
||||||
impl EventListener for EventProxy {
|
impl EventListener for EventProxy {
|
||||||
fn send_event(&self, event: alacritty_terminal::event::Event) {
|
fn send_event(&self, event: alacritty_terminal::event::Event) {
|
||||||
println!("terminal event proxy got event {:?}", event);
|
|
||||||
match event {
|
match event {
|
||||||
alacritty_terminal::event::Event::PtyWrite(s) => {
|
alacritty_terminal::event::Event::PtyWrite(s) => {
|
||||||
println!("pyt write {}", s);
|
println!("pyt write {}", s);
|
||||||
|
|
Loading…
Reference in New Issue