1
1
mirror of https://github.com/wez/wezterm.git synced 2024-12-24 13:52:55 +03:00

wezterm: simplify search API

This commit is contained in:
Wez Furlong 2020-05-29 07:49:09 -07:00
parent 92fdf043b8
commit 9f02e88de1
3 changed files with 9 additions and 39 deletions

View File

@ -1,7 +1,7 @@
use crate::frontend::gui::termwindow::TermWindow;
use crate::mux::domain::DomainId;
use crate::mux::renderable::*;
use crate::mux::tab::{Pattern, SearchDirection, SearchResult};
use crate::mux::tab::{Pattern, SearchResult};
use crate::mux::tab::{Tab, TabId};
use portable_pty::PtySize;
use rangeset::RangeSet;
@ -190,12 +190,7 @@ impl Tab for SearchOverlay {
self.delegate.erase_scrollback()
}
fn search(
&self,
_row: StableRowIndex,
_direction: SearchDirection,
_pattern: &Pattern,
) -> Vec<SearchResult> {
fn search(&self, _pattern: &Pattern) -> Vec<SearchResult> {
// You can't search the search bar
vec![]
}
@ -297,11 +292,7 @@ impl SearchRenderable {
self.dirty_results.add(bar_pos);
if !self.pattern.is_empty() {
self.results = self.delegate.search(
bar_pos + 1,
SearchDirection::Backwards,
&Pattern::String(self.pattern.clone()),
);
self.results = self.delegate.search(&Pattern::String(self.pattern.clone()));
self.results.sort();
self.recompute_results();

View File

@ -1,7 +1,7 @@
use crate::mux::domain::DomainId;
use crate::mux::renderable::Renderable;
use crate::mux::tab::{alloc_tab_id, Tab, TabId};
use crate::mux::tab::{Pattern, SearchDirection, SearchResult};
use crate::mux::tab::{Pattern, SearchResult};
use anyhow::Error;
use portable_pty::{Child, MasterPty, PtySize};
use std::cell::{RefCell, RefMut};
@ -104,12 +104,7 @@ impl Tab for LocalTab {
self.terminal.borrow().get_current_dir().cloned()
}
fn search(
&self,
_row: StableRowIndex,
_direction: SearchDirection,
pattern: &Pattern,
) -> Vec<SearchResult> {
fn search(&self, pattern: &Pattern) -> Vec<SearchResult> {
let term = self.terminal.borrow();
let screen = term.screen();

View File

@ -49,12 +49,6 @@ pub enum Pattern {
// Regex(regex::Regex),
}
#[derive(Debug, Clone, Copy, Eq, PartialEq)]
pub enum SearchDirection {
Backwards,
// Forwards,
}
#[derive(Debug, Clone, Copy, Eq, PartialEq, PartialOrd, Ord)]
pub struct SearchResult {
pub start_y: StableRowIndex,
@ -80,20 +74,10 @@ pub trait Tab: Downcast {
fn erase_scrollback(&self) {}
/// Performs a search relative to the specified stable row index.
/// if direction is Backwards then the search proceeds to smaller
/// values of StableRowIndex. Forwards towards larger values.
/// If the result is empty then there are no matches in the specified
/// direction.
/// Otherwise, the result shall contain at least as many matches will
/// be visible in the current viewport, starting from the first match.
/// It may return matches outside that range.
fn search(
&self,
_row: StableRowIndex,
_direction: SearchDirection,
_pattern: &Pattern,
) -> Vec<SearchResult> {
/// Performs a search.
/// If the result is empty then there are no matches.
/// Otherwise, the result shall contain all possible matches.
fn search(&self, _pattern: &Pattern) -> Vec<SearchResult> {
vec![]
}