summaryrefslogtreecommitdiffstats
path: root/src/commands/cursor_move.rs
diff options
context:
space:
mode:
authorJiayi Zhao <jeff.no.zhao@gmail.com>2020-03-02 18:50:29 -0500
committerJiayi Zhao <jeff.no.zhao@gmail.com>2020-03-02 18:50:29 -0500
commite321dfc3c96f50f09c3953340a5a6fea72a5a245 (patch)
treedc13fee011e7c49536eb28b5b3d5de8bef93af89 /src/commands/cursor_move.rs
parent8bc73974e78883eb1f619d1829a8be77933e5c00 (diff)
add tab widget for showing which tab we are on
- code cleanup - pageup and pagedown now work properly
Diffstat (limited to 'src/commands/cursor_move.rs')
-rw-r--r--src/commands/cursor_move.rs20
1 files changed, 16 insertions, 4 deletions
diff --git a/src/commands/cursor_move.rs b/src/commands/cursor_move.rs
index 36ba233..d249181 100644
--- a/src/commands/cursor_move.rs
+++ b/src/commands/cursor_move.rs
@@ -134,10 +134,16 @@ impl std::fmt::Display for CursorMovePageUp {
}
impl JoshutoRunnable for CursorMovePageUp {
- fn execute(&self, context: &mut JoshutoContext, _: &mut TuiBackend) -> JoshutoResult<()> {
+ fn execute(&self, context: &mut JoshutoContext, backend: &mut TuiBackend) -> JoshutoResult<()> {
+ let half_page = {
+ match backend.terminal.as_ref().unwrap().size() {
+ Ok(rect) => rect.height as usize - 2,
+ _ => 10,
+ }
+ };
+
let movement = match context.curr_tab_ref().curr_list_ref() {
Some(curr_list) => {
- let half_page = 10;
curr_list
.index
.map(|idx| if idx > half_page { idx - half_page } else { 0 })
@@ -173,11 +179,17 @@ impl std::fmt::Display for CursorMovePageDown {
}
impl JoshutoRunnable for CursorMovePageDown {
- fn execute(&self, context: &mut JoshutoContext, _: &mut TuiBackend) -> JoshutoResult<()> {
+ fn execute(&self, context: &mut JoshutoContext, backend: &mut TuiBackend) -> JoshutoResult<()> {
+ let half_page = {
+ match backend.terminal.as_ref().unwrap().size() {
+ Ok(rect) => rect.height as usize - 2,
+ _ => 10,
+ }
+ };
+
let movement = match context.curr_tab_ref().curr_list_ref() {
Some(curr_list) => {
let dir_len = curr_list.contents.len();
- let half_page = 10;
curr_list.index.map(|idx| {
if idx + half_page > dir_len - 1 {
dir_len - 1