Skip to content

Commit 446fb19

Browse files
authored
Merge pull request #472 from yazgoo/tranparency-on-start
2 parents 66a2be6 + 04d4544 commit 446fb19

File tree

11 files changed

+32
-6
lines changed

11 files changed

+32
-6
lines changed

Cargo.lock

Lines changed: 2 additions & 3 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ log = "0.4.17"
3030
env_logger = "0.9.0"
3131
time = "0.3.13"
3232
clap = "3.2.22"
33-
tuikit = "0.4.6"
33+
tuikit = "0.5.0"
3434
vte = "0.11.0"
3535
fuzzy-matcher = "0.3.7"
3636
rayon = "1.5.3"

src/bin/main.rs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,7 @@ Usage: sk [options]
5454
--keep-right Keep the right end of the line visible on overflow
5555
--skip-to-pattern Line starts with the start of matched pattern
5656
--no-clear-if-empty Do not clear previous items if command returns empty result
57+
--no-clear-start Do not clear on start
5758
--show-cmd-error Send command error message if command fails
5859
5960
Layout
@@ -92,6 +93,7 @@ Usage: sk [options]
9293
--expect KEYS comma seperated keys that can be used to complete skim
9394
--read0 Read input delimited by ASCII NUL(\\0) characters
9495
--print0 Print output delimited by ASCII NUL(\\0) characters
96+
--no-clear-start Do not clear screen on start
9597
--no-clear Do not clear screen on exit
9698
--print-query Print query as the first line
9799
--print-cmd Print command query as the first line (after --print-query)
@@ -196,6 +198,7 @@ fn real_main() -> Result<i32, std::io::Error> {
196198
.arg(Arg::with_name("height").long("height").multiple(true).takes_value(true).default_value("100%"))
197199
.arg(Arg::with_name("no-height").long("no-height").multiple(true))
198200
.arg(Arg::with_name("no-clear").long("no-clear").multiple(true))
201+
.arg(Arg::with_name("no-clear-start").long("no-clear-start").multiple(true))
199202
.arg(Arg::with_name("no-mouse").long("no-mouse").multiple(true))
200203
.arg(Arg::with_name("preview").long("preview").multiple(true).takes_value(true))
201204
.arg(Arg::with_name("preview-window").long("preview-window").multiple(true).takes_value(true).default_value("right:50%"))
@@ -420,6 +423,7 @@ fn parse_options(options: &ArgMatches) -> SkimOptions<'_> {
420423
.no_hscroll(options.is_present("no-hscroll"))
421424
.no_mouse(options.is_present("no-mouse"))
422425
.no_clear(options.is_present("no-clear"))
426+
.no_clear_start(options.is_present("no-clear-start"))
423427
.tabstop(options.values_of("tabstop").and_then(|vals| vals.last()))
424428
.tiebreak(options.values_of("tiebreak").map(|x| x.collect::<Vec<_>>().join(",")))
425429
.tac(options.is_present("tac"))

src/header.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ use crate::event::{Event, EventHandler};
55
use crate::item::ItemPool;
66
use crate::theme::ColorTheme;
77
use crate::theme::DEFAULT_THEME;
8-
use crate::util::{print_item, str_lines, LinePrinter};
8+
use crate::util::{clear_canvas, print_item, str_lines, LinePrinter};
99
use crate::{DisplayContext, Matches, SkimOptions};
1010
use defer_drop::DeferDrop;
1111
use std::cmp::max;
@@ -89,6 +89,7 @@ impl Draw for Header {
8989
}
9090

9191
canvas.clear()?;
92+
clear_canvas(canvas)?;
9293

9394
for (idx, header) in self.header.iter().enumerate() {
9495
// print fixed header(specified by --header)

src/lib.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -312,6 +312,8 @@ impl Skim {
312312
.min_height(min_height)
313313
.height(height)
314314
.clear_on_exit(!options.no_clear)
315+
.disable_alternate_screen(options.no_clear_start)
316+
.clear_on_start(!options.no_clear_start)
315317
.hold(options.select1 || options.exit0 || options.sync),
316318
)
317319
.unwrap(),

src/model.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@ use crate::reader::{Reader, ReaderControl};
2727
use crate::selection::Selection;
2828
use crate::spinlock::SpinLock;
2929
use crate::theme::ColorTheme;
30+
use crate::util::clear_canvas;
3031
use crate::util::{depends_on_items, inject_command, margin_string_to_size, parse_margin, InjectContext};
3132
use crate::{FuzzyAlgorithm, MatchEngineFactory, MatchRange, SkimItem};
3233
use std::cmp::max;
@@ -884,6 +885,7 @@ impl Draw for Status {
884885

885886
canvas.clear()?;
886887
let (screen_width, _) = canvas.size()?;
888+
clear_canvas(canvas)?;
887889

888890
let info_attr = self.theme.info();
889891
let info_attr_bold = Attr {

src/options.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@ pub struct SkimOptions<'a> {
3131
pub margin: Option<&'a str>,
3232
pub no_height: bool,
3333
pub no_clear: bool,
34+
pub no_clear_start: bool,
3435
pub min_height: Option<&'a str>,
3536
pub height: Option<&'a str>,
3637
pub preview: Option<&'a str>,
@@ -81,6 +82,7 @@ impl<'a> Default for SkimOptions<'a> {
8182
margin: Some("0,0,0,0"),
8283
no_height: false,
8384
no_clear: false,
85+
no_clear_start: false,
8486
min_height: Some("10"),
8587
height: Some("100%"),
8688
preview: None,

src/previewer.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ use tuikit::prelude::{Event as TermEvent, *};
1616
use crate::ansi::{ANSIParser, AnsiString};
1717
use crate::event::{Event, EventHandler, UpdateScreen};
1818
use crate::spinlock::SpinLock;
19-
use crate::util::{atoi, depends_on_items, inject_command, InjectContext};
19+
use crate::util::{atoi, clear_canvas, depends_on_items, inject_command, InjectContext};
2020
use crate::{ItemPreview, PreviewContext, PreviewPosition, SkimItem};
2121

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

347348
if screen_width == 0 || screen_height == 0 {
348349
return Ok(());

src/query.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ use unicode_width::UnicodeWidthStr;
77
use crate::event::{Event, EventHandler, UpdateScreen};
88
use crate::options::SkimOptions;
99
use crate::theme::{ColorTheme, DEFAULT_THEME};
10+
use crate::util::clear_canvas;
1011

1112
#[derive(Clone, Copy, PartialEq)]
1213
enum QueryMode {
@@ -546,6 +547,7 @@ impl Draw for Query {
546547
let before = self.get_before();
547548
let after = self.get_after();
548549
let prompt = self.get_prompt();
550+
clear_canvas(canvas)?;
549551

550552
let prompt_width = canvas.print_with_attr(0, 0, prompt, self.theme.prompt())?;
551553
let before_width = canvas.print_with_attr(0, prompt_width, &before, self.theme.query())?;

src/selection.rs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ use crate::global::current_run_num;
1212
use crate::item::MatchedItem;
1313
use crate::orderedvec::OrderedVec;
1414
use crate::theme::{ColorTheme, DEFAULT_THEME};
15+
use crate::util::clear_canvas;
1516
use crate::util::{print_item, reshape_string, LinePrinter};
1617
use crate::{DisplayContext, MatchRange, Matches, Selector, SkimItem, SkimOptions};
1718
use regex::Regex;
@@ -532,6 +533,8 @@ impl Draw for Selection {
532533
let max_upper = self.item_cursor + screen_height;
533534
let item_idx_upper = min(max_upper, self.items.len());
534535

536+
clear_canvas(canvas)?;
537+
535538
for item_idx in item_idx_lower..item_idx_upper {
536539
let line_cursor = item_idx - item_idx_lower;
537540
let line_no = if self.reverse {

0 commit comments

Comments
 (0)