Skip to content

Commit

Permalink
Merge branch 'master' into chore/cli-deps-cleanup
Browse files Browse the repository at this point in the history
  • Loading branch information
yazgoo authored Oct 29, 2022
2 parents 35d6296 + afe1667 commit a182914
Show file tree
Hide file tree
Showing 12 changed files with 47 additions and 8 deletions.
13 changes: 13 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,18 @@
# Change Log

## 0.10.0: 2022-12-28

Features:

- transparency on start
- add light colors parsing support
- Update --tiebreak options with length

Fixes:

- fix ci.yml
- update deps and fix lots of clippy lints

## 0.9.4: 2021-02-15

Feature:
Expand Down
7 changes: 3 additions & 4 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "skim"
version = "0.9.4"
version = "0.10.1"
authors = ["Zhang Jinzhou <[email protected]>"]
description = "Fuzzy Finder in rust!"
documentation = "https://docs.rs/skim"
Expand Down Expand Up @@ -30,7 +30,7 @@ log = "0.4.17"
env_logger = { version = "0.9.0", optional = true }
time = "0.3.13"
clap = { version = "3.2.22", optional = true }
tuikit = "0.4.6"
tuikit = "0.5.0"
vte = "0.11.0"
fuzzy-matcher = "0.3.7"
rayon = "1.5.3"
Expand Down
4 changes: 4 additions & 0 deletions src/bin/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,7 @@ Usage: sk [options]
--keep-right Keep the right end of the line visible on overflow
--skip-to-pattern Line starts with the start of matched pattern
--no-clear-if-empty Do not clear previous items if command returns empty result
--no-clear-start Do not clear on start
--show-cmd-error Send command error message if command fails
Layout
Expand Down Expand Up @@ -92,6 +93,7 @@ Usage: sk [options]
--expect KEYS comma seperated keys that can be used to complete skim
--read0 Read input delimited by ASCII NUL(\\0) characters
--print0 Print output delimited by ASCII NUL(\\0) characters
--no-clear-start Do not clear screen on start
--no-clear Do not clear screen on exit
--print-query Print query as the first line
--print-cmd Print command query as the first line (after --print-query)
Expand Down Expand Up @@ -196,6 +198,7 @@ fn real_main() -> Result<i32, std::io::Error> {
.arg(Arg::with_name("height").long("height").multiple(true).takes_value(true).default_value("100%"))
.arg(Arg::with_name("no-height").long("no-height").multiple(true))
.arg(Arg::with_name("no-clear").long("no-clear").multiple(true))
.arg(Arg::with_name("no-clear-start").long("no-clear-start").multiple(true))
.arg(Arg::with_name("no-mouse").long("no-mouse").multiple(true))
.arg(Arg::with_name("preview").long("preview").multiple(true).takes_value(true))
.arg(Arg::with_name("preview-window").long("preview-window").multiple(true).takes_value(true).default_value("right:50%"))
Expand Down Expand Up @@ -420,6 +423,7 @@ fn parse_options(options: &ArgMatches) -> SkimOptions<'_> {
.no_hscroll(options.is_present("no-hscroll"))
.no_mouse(options.is_present("no-mouse"))
.no_clear(options.is_present("no-clear"))
.no_clear_start(options.is_present("no-clear-start"))
.tabstop(options.values_of("tabstop").and_then(|vals| vals.last()))
.tiebreak(options.values_of("tiebreak").map(|x| x.collect::<Vec<_>>().join(",")))
.tac(options.is_present("tac"))
Expand Down
3 changes: 2 additions & 1 deletion src/header.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ use crate::event::{Event, EventHandler};
use crate::item::ItemPool;
use crate::theme::ColorTheme;
use crate::theme::DEFAULT_THEME;
use crate::util::{print_item, str_lines, LinePrinter};
use crate::util::{clear_canvas, print_item, str_lines, LinePrinter};
use crate::{DisplayContext, Matches, SkimOptions};
use defer_drop::DeferDrop;
use std::cmp::max;
Expand Down Expand Up @@ -89,6 +89,7 @@ impl Draw for Header {
}

canvas.clear()?;
clear_canvas(canvas)?;

for (idx, header) in self.header.iter().enumerate() {
// print fixed header(specified by --header)
Expand Down
2 changes: 2 additions & 0 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -312,6 +312,8 @@ impl Skim {
.min_height(min_height)
.height(height)
.clear_on_exit(!options.no_clear)
.disable_alternate_screen(options.no_clear_start)
.clear_on_start(!options.no_clear_start)
.hold(options.select1 || options.exit0 || options.sync),
)
.unwrap(),
Expand Down
2 changes: 2 additions & 0 deletions src/model.rs
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ use crate::reader::{Reader, ReaderControl};
use crate::selection::Selection;
use crate::spinlock::SpinLock;
use crate::theme::ColorTheme;
use crate::util::clear_canvas;
use crate::util::{depends_on_items, inject_command, margin_string_to_size, parse_margin, InjectContext};
use crate::{FuzzyAlgorithm, MatchEngineFactory, MatchRange, SkimItem};
use std::cmp::max;
Expand Down Expand Up @@ -884,6 +885,7 @@ impl Draw for Status {

canvas.clear()?;
let (screen_width, _) = canvas.size()?;
clear_canvas(canvas)?;

let info_attr = self.theme.info();
let info_attr_bold = Attr {
Expand Down
2 changes: 2 additions & 0 deletions src/options.rs
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ pub struct SkimOptions<'a> {
pub margin: Option<&'a str>,
pub no_height: bool,
pub no_clear: bool,
pub no_clear_start: bool,
pub min_height: Option<&'a str>,
pub height: Option<&'a str>,
pub preview: Option<&'a str>,
Expand Down Expand Up @@ -81,6 +82,7 @@ impl<'a> Default for SkimOptions<'a> {
margin: Some("0,0,0,0"),
no_height: false,
no_clear: false,
no_clear_start: false,
min_height: Some("10"),
height: Some("100%"),
preview: None,
Expand Down
3 changes: 2 additions & 1 deletion src/previewer.rs
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ use tuikit::prelude::{Event as TermEvent, *};
use crate::ansi::{ANSIParser, AnsiString};
use crate::event::{Event, EventHandler, UpdateScreen};
use crate::spinlock::SpinLock;
use crate::util::{atoi, depends_on_items, inject_command, InjectContext};
use crate::util::{atoi, clear_canvas, depends_on_items, inject_command, InjectContext};
use crate::{ItemPreview, PreviewContext, PreviewPosition, SkimItem};

const TAB_STOP: usize = 8;
Expand Down Expand Up @@ -343,6 +343,7 @@ impl Draw for Previewer {
fn draw(&self, canvas: &mut dyn Canvas) -> DrawResult<()> {
canvas.clear()?;
let (screen_width, screen_height) = canvas.size()?;
clear_canvas(canvas)?;

if screen_width == 0 || screen_height == 0 {
return Ok(());
Expand Down
2 changes: 2 additions & 0 deletions src/query.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ use unicode_width::UnicodeWidthStr;
use crate::event::{Event, EventHandler, UpdateScreen};
use crate::options::SkimOptions;
use crate::theme::{ColorTheme, DEFAULT_THEME};
use crate::util::clear_canvas;

#[derive(Clone, Copy, PartialEq)]
enum QueryMode {
Expand Down Expand Up @@ -546,6 +547,7 @@ impl Draw for Query {
let before = self.get_before();
let after = self.get_after();
let prompt = self.get_prompt();
clear_canvas(canvas)?;

let prompt_width = canvas.print_with_attr(0, 0, prompt, self.theme.prompt())?;
let before_width = canvas.print_with_attr(0, prompt_width, &before, self.theme.query())?;
Expand Down
3 changes: 3 additions & 0 deletions src/selection.rs
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ use crate::global::current_run_num;
use crate::item::MatchedItem;
use crate::orderedvec::OrderedVec;
use crate::theme::{ColorTheme, DEFAULT_THEME};
use crate::util::clear_canvas;
use crate::util::{print_item, reshape_string, LinePrinter};
use crate::{DisplayContext, MatchRange, Matches, Selector, SkimItem, SkimOptions};
use regex::Regex;
Expand Down Expand Up @@ -532,6 +533,8 @@ impl Draw for Selection {
let max_upper = self.item_cursor + screen_height;
let item_idx_upper = min(max_upper, self.items.len());

clear_canvas(canvas)?;

for item_idx in item_idx_lower..item_idx_upper {
let line_cursor = item_idx - item_idx_lower;
let line_no = if self.reverse {
Expand Down
10 changes: 10 additions & 0 deletions src/util.rs
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,16 @@ lazy_static! {
static ref RE_NUMBER: Regex = Regex::new(r"[+|-]?\d+").unwrap();
}

pub fn clear_canvas(canvas: &mut dyn Canvas) -> DrawResult<()> {
let (screen_width, screen_height) = canvas.size()?;
for y in 0..screen_height {
for x in 0..screen_width {
canvas.print(y, x, " ")?;
}
}
Ok(())
}

pub fn escape_single_quote(text: &str) -> String {
RE_ESCAPE
.replace_all(text, |x: &Captures| match x.get(0).unwrap().as_str() {
Expand Down

0 comments on commit a182914

Please sign in to comment.