summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorCanop <cano.petrole@gmail.com>2020-06-29 16:03:41 +0200
committerCanop <cano.petrole@gmail.com>2020-06-29 16:03:41 +0200
commit83dcfd8166e6f07e7c6bb811bfe5dc2f58aede04 (patch)
treee55bc8bd2831431d322cfb81f99dc9396888f64b
parent93a5dcf11c9d1a35b429ac2bf3e164848c0f2ad5 (diff)
version 0.18.2 - remove all flickering causesv0.18.2
-rw-r--r--CHANGELOG.md4
-rw-r--r--Cargo.lock2
-rw-r--r--Cargo.toml4
-rw-r--r--src/app/app.rs18
-rw-r--r--src/app/panel.rs25
-rw-r--r--src/display/crop_writer.rs15
-rw-r--r--src/display/displayable_tree.rs14
-rw-r--r--src/display/flags_display.rs33
-rw-r--r--src/display/mod.rs3
-rw-r--r--src/display/screen.rs12
-rw-r--r--website/docs/css/extra.css3
11 files changed, 66 insertions, 67 deletions
diff --git a/CHANGELOG.md b/CHANGELOG.md
index 134b186..2938990 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -1,3 +1,7 @@
+<a name="v0.18.2"></a>
+### v0.18.2 - 2020-06-29
+Remove flickering
+
<a name="v0.18.1"></a>
### v0.18.1 - 2020-06-28
Column order is now configurable - Fix #127
diff --git a/Cargo.lock b/Cargo.lock
index 33f9e1f..8e00613 100644
--- a/Cargo.lock
+++ b/Cargo.lock
@@ -84,7 +84,7 @@ dependencies = [
[[package]]
name = "broot"
-version = "0.18.1"
+version = "0.18.2"
dependencies = [
"bet",
"chrono",
diff --git a/Cargo.toml b/Cargo.toml
index 1aadd14..bd91c54 100644
--- a/Cargo.toml
+++ b/Cargo.toml
@@ -1,10 +1,10 @@
[package]
name = "broot"
-version = "0.18.1"
+version = "0.18.2"
authors = ["dystroy <denys.seguret@gmail.com>"]
repository = "https://github.com/Canop/broot"
documentation = "https://dystroy.org/broot"
-description = "Fuzzy Search + tree + cd"
+description = "A new file manager"
edition = "2018"
keywords = ["cli", "fuzzy", "tree", "search", "regex"]
license = "MIT"
diff --git a/src/app/app.rs b/src/app/app.rs
index b2b9d0c..ce89f77 100644
--- a/src/app/app.rs
+++ b/src/app/app.rs
@@ -276,16 +276,16 @@ impl App {
screen: &mut Screen,
con: &AppContext,
dam: &mut Dam,
- ) -> Result<(), ProgramError> {
+ ) -> Result<bool, ProgramError> {
// we start with the focused panel
- self.mut_panel().do_pending_tasks(screen, con, dam)?;
+ let mut did_something = self.mut_panel().do_pending_tasks(screen, con, dam)?;
// then the other ones
for idx in 0..self.panels.len().get() {
if idx != self.active_panel_idx {
- self.panels[idx].do_pending_tasks(screen, con, dam)?;
+ did_something |= self.panels[idx].do_pending_tasks(screen, con, dam)?;
}
}
- Ok(())
+ Ok(did_something)
}
/// This is the main loop of the application
@@ -321,14 +321,14 @@ impl App {
}
}
- self.display_panels(w, screen, &skin, con)?;
- w.flush()?;
-
loop {
if !self.quitting {
- self.do_pending_tasks(screen, con, &mut dam)?;
self.display_panels(w, screen, &skin, con)?;
w.flush()?;
+ if self.do_pending_tasks(screen, con, &mut dam)? {
+ self.display_panels(w, screen, &skin, con)?;
+ w.flush()?;
+ }
}
let event = match dam.next_event() {
Some(event) => event,
@@ -362,8 +362,6 @@ impl App {
self.apply_command(w, cmd, screen, &skin.focused, con)?;
}
}
- self.display_panels(w, screen, &skin, con)?;
- w.flush()?;
event_source.unblock(self.quitting);
}
diff --git a/src/app/panel.rs b/src/app/panel.rs
index 397908e..55000fe 100644
--- a/src/app/panel.rs
+++ b/src/app/panel.rs
@@ -2,7 +2,14 @@ use {
super::*,
crate::{
command::*,
- display::{status_line, Areas, Screen, W, WIDE_STATUS, write_flags},
+ display::{
+ status_line,
+ Areas,
+ Screen,
+ W,
+ WIDE_STATUS,
+ flags_display,
+ },
errors::ProgramError,
keys,
skin::PanelSkin,
@@ -89,11 +96,13 @@ impl Panel {
screen: &mut Screen,
con: &AppContext,
dam: &mut Dam,
- ) -> Result<(), ProgramError> {
+ ) -> Result<bool, ProgramError> {
+ let mut did_something = false;
while self.mut_state().get_pending_task().is_some() & !dam.has_event() {
self.mut_state().do_pending_task(screen, con, dam);
+ did_something = true;
}
- Ok(())
+ Ok(did_something)
}
/// return a new command
@@ -163,13 +172,19 @@ impl Panel {
if active || !WIDE_STATUS {
self.write_status(w, panel_skin, screen)?;
}
- self.input.display(w, active, self.areas.input.clone(), panel_skin)?;
+ let mut input_area = self.areas.input.clone();
if active {
self.write_purpose(w, panel_skin, screen, con)?;
let flags = self.state().get_flags();
let input_content_len = self.input.get_content().len() as u16;
- write_flags(w, &flags, &self.areas.input, input_content_len, screen, panel_skin)?;
+ let flags_len = flags_display::visible_width(&flags);
+ if input_area.width > input_content_len + 1 + flags_len {
+ input_area.width -= flags_len + 1;
+ screen.goto(w, input_area.left + input_area.width - 1, input_area.top)?;
+ flags_display::write(w, &flags, panel_skin)?;
+ }
}
+ self.input.display(w, active, input_area, panel_skin)?;
Ok(())
}
diff --git a/src/display/crop_writer.rs b/src/display/crop_writer.rs
index 45758ba..1b6e508 100644
--- a/src/display/crop_writer.rs
+++ b/src/display/crop_writer.rs
@@ -1,8 +1,4 @@
use {
- crossterm::{
- terminal::{Clear, ClearType},
- QueueableCommand,
- },
termimad::{CompoundStyle, Result},
};
@@ -39,6 +35,13 @@ where
}
Ok(())
}
+ pub fn fill(&mut self, cs: &CompoundStyle, c: char) -> Result<()> {
+ while !self.is_full() {
+ self.allowed -= 1;
+ cs.queue(self.w, c)?;
+ }
+ Ok(())
+ }
pub fn queue_string(&mut self, cs: &CompoundStyle, s: String) -> Result<()> {
if !self.is_full() {
let len = s.chars().count();
@@ -57,8 +60,4 @@ where
pub fn queue_bg(&mut self, cs: &CompoundStyle) -> Result<()> {
cs.queue_bg(self.w)
}
- pub fn clear(&mut self, clear_type: ClearType) -> Result<()> {
- self.w.queue(Clear(clear_type))?;
- Ok(())
- }
}
diff --git a/src/display/displayable_tree.rs b/src/display/displayable_tree.rs
index 8b71183..795ab21 100644
--- a/src/display/displayable_tree.rs
+++ b/src/display/displayable_tree.rs
@@ -19,7 +19,6 @@ use {
crossterm::{
cursor,
style::{Color, SetBackgroundColor},
- terminal::ClearType,
QueueableCommand,
},
git2::Status,
@@ -402,12 +401,12 @@ impl<'s, 't> DisplayableTree<'s, 't> {
selected: bool,
) -> Result<(), ProgramError> {
if self.in_app {
- if selected {
- cw.queue_bg(&self.skin.selected_line)?;
+ let style = if selected {
+ &self.skin.selected_line
} else {
- cw.queue_bg(&self.skin.default)?;
- }
- cw.clear(ClearType::UntilNewLine)?;
+ &self.skin.default
+ };
+ cw.fill(style, ' ')?;
}
Ok(())
}
@@ -419,8 +418,7 @@ impl<'s, 't> DisplayableTree<'s, 't> {
let user_group_max_lengths = user_group_max_lengths(&tree);
let total_size = tree.total_sum();
let scrollbar = if self.in_app {
- self.area
- .scrollbar(tree.scroll, tree.lines.len() as i32 - 1)
+ self.area.scrollbar(tree.scroll, tree.lines.len() as i32 - 1)
} else {
None
};
diff --git a/src/display/flags_display.rs b/src/display/flags_display.rs
index 97a2849..c7ff58e 100644
--- a/src/display/flags_display.rs
+++ b/src/display/flags_display.rs
@@ -1,38 +1,29 @@
use {
+ super::W,
crate::{
- display::{Screen, W},
errors::ProgramError,
flag::Flag,
skin::PanelSkin,
},
- termimad::Area,
};
-/// draw the flags at the bottom right of the given area
-/// (this area is usually the input: flags are displayed over it)
-pub fn write_flags(
- w: &mut W,
- flags: &[Flag],
- area: &Area,
- input_content_len: u16,
- screen: &mut Screen,
- panel_skin: &PanelSkin,
-) -> Result<(), ProgramError> {
- if flags.is_empty() {
- return Ok(());
- }
+/// compute the needed length for displaying the flags
+pub fn visible_width(flags: &[Flag]) -> u16 {
let mut width = flags.len() * 2 + 1;
for flag in flags {
width += flag.name.len(); // we assume only ascii chars
width += flag.value.len();
}
- let width = width as u16;
- if width + input_content_len + 2 >= area.width {
- debug!("not enough space to display flags");
- return Ok(());
- }
- screen.goto(w, area.left + area.width - 1 - width, area.top)?;
+ width as u16
+}
+
+/// draw the flags
+pub fn write(
+ w: &mut W,
+ flags: &[Flag],
+ panel_skin: &PanelSkin,
+) -> Result<(), ProgramError> {
for flag in flags {
panel_skin.styles.flag_label.queue_str(w, &format!( " {}:", flag.name))?;
panel_skin.styles.flag_value.queue(w, flag.value)?;
diff --git a/src/display/mod.rs b/src/display/mod.rs
index 97424ca..01b47eb 100644
--- a/src/display/mod.rs
+++ b/src/display/mod.rs
@@ -24,7 +24,7 @@ mod areas;
mod col;
mod crop_writer;
mod displayable_tree;
-mod flags_display;
+pub mod flags_display;
mod git_status_display;
pub mod status_line;
mod matched_string;
@@ -37,7 +37,6 @@ pub use {
col::{Col, Cols, DEFAULT_COLS},
crop_writer::CropWriter,
displayable_tree::DisplayableTree,
- flags_display::write_flags,
git_status_display::GitStatusDisplay,
matched_string::MatchedString,
screen::Screen,
diff --git a/src/display/screen.rs b/src/display/screen.rs
index e08f60e..3ea1fe0 100644
--- a/src/display/screen.rs
+++ b/src/display/screen.rs
@@ -39,26 +39,18 @@ impl Screen {
self.set_terminal_size(w, h, con);
Ok(())
}
- /// move the cursor to x,y and clears the line.
- pub fn goto_clear(&self, w: &mut W, x: u16, y: u16) -> Result<(), ProgramError> {
- self.goto(w, x, y)?;
- self.clear_line(w)
- }
/// move the cursor to x,y
pub fn goto(&self, w: &mut W, x: u16, y: u16) -> Result<(), ProgramError> {
w.queue(cursor::MoveTo(x, y))?;
Ok(())
}
- /// clear the whole screen
- pub fn clear(&self, w: &mut W) -> Result<(), ProgramError> {
- w.queue(Clear(ClearType::All))?;
- Ok(())
- }
/// clear from the cursor to the end of line
pub fn clear_line(&self, w: &mut W) -> Result<(), ProgramError> {
w.queue(Clear(ClearType::UntilNewLine))?;
Ok(())
}
+ /// clear the area and everything to the right.
+ /// Should be used with parcimony as it could lead to flickering.
pub fn clear_area_to_right(&self, w: &mut W, area: &Area) -> Result<(), ProgramError> {
for y in area.top..area.top+area.height {
self.goto(w, area.left, y)?;
diff --git a/website/docs/css/extra.css b/website/docs/css/extra.css
index 20c94d6..5c5912b 100644
--- a/website/docs/css/extra.css
+++ b/website/docs/css/extra.css
@@ -17,6 +17,9 @@ h3 {
.navbar {
background-image: linear-gradient(#184965,#02121b);
+ /*
+ background: #333;
+ */
}
pre {