summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorJiayi Zhao <jeff.no.zhao@gmail.com>2019-06-01 12:32:35 -0400
committerJiayi Zhao <jeff.no.zhao@gmail.com>2019-06-01 12:32:35 -0400
commit8629383c8a65695d01ea5a7d6dbdee5e1833d442 (patch)
treef849f1847d453b34a8ea2585e1e3f83f675efb47 /src
parentda20212f32c8b43400d0aec2af39376651f32b9d (diff)
optimize some printing code
Diffstat (limited to 'src')
-rw-r--r--src/commands/command_line.rs8
-rw-r--r--src/ui.rs17
2 files changed, 9 insertions, 16 deletions
diff --git a/src/commands/command_line.rs b/src/commands/command_line.rs
index 6589fb4..036ad55 100644
--- a/src/commands/command_line.rs
+++ b/src/commands/command_line.rs
@@ -63,14 +63,6 @@ impl CommandLine {
Ok(())
}
}
- pub fn readline_with(
- context: &mut JoshutoContext,
- view: &JoshutoView,
- textfield: JoshutoTextField,
- ) -> Result<(), JoshutoError> {
- drop(textfield);
- Ok(())
- }
}
impl JoshutoCommand for CommandLine {}
diff --git a/src/ui.rs b/src/ui.rs
index d6ddd97..5547a7f 100644
--- a/src/ui.rs
+++ b/src/ui.rs
@@ -198,8 +198,8 @@ pub fn display_contents(
ncurses::werase(win.win);
ncurses::wmove(win.win, 0, 0);
- let dir_contents = &dirlist.contents;
let (start, end) = (dirlist.pagestate.start, dirlist.pagestate.end);
+ let dir_contents = &dirlist.contents[start..end];
let curr_index = dirlist.index.unwrap();
@@ -209,16 +209,17 @@ pub fn display_contents(
wprint_entry
};
- for (i, entry) in dir_contents.iter().enumerate().take(end).skip(start) {
- let coord: (i32, i32) = (i as i32 - start as i32, 0);
+ for (i, entry) in dir_contents.iter().enumerate() {
+ let coord: (i32, i32) = (i as i32, 0);
ncurses::wmove(win.win, coord.0, coord.1);
- let mut attr: ncurses::attr_t = 0;
- if i == curr_index {
- attr |= ncurses::A_STANDOUT();
- }
- let attrs = get_theme_attr(attr, entry);
+ let attrs: ncurses::attr_t = if i + start == curr_index {
+ ncurses::A_STANDOUT()
+ } else {
+ 0
+ };
+ let attrs = get_theme_attr(attrs, entry);
draw_func(win, entry, attrs.0, coord);