From 26a42452130b836a67d2f5f16964b0b293903629 Mon Sep 17 00:00:00 2001 From: Stephan Dilly Date: Tue, 2 Jun 2020 14:40:24 +0200 Subject: [PATCH] better cmd ordering --- src/app.rs | 28 +++++++++++++++++----------- src/components/filetree.rs | 15 +++++++++------ src/strings.rs | 4 ++++ src/tabs/status.rs | 6 +++--- 4 files changed, 33 insertions(+), 20 deletions(-) diff --git a/src/app.rs b/src/app.rs index da7a46db..72edbb25 100644 --- a/src/app.rs +++ b/src/app.rs @@ -16,7 +16,7 @@ use anyhow::{anyhow, Result}; use asyncgit::{sync, AsyncNotification, CWD}; use crossbeam_channel::Sender; use crossterm::event::{Event, KeyEvent}; -use strings::commands; +use strings::{commands, order}; use tui::{ backend::Backend, layout::{Constraint, Direction, Layout, Rect}, @@ -373,16 +373,22 @@ impl App { } } - res.push(CommandInfo::new( - commands::TOGGLE_TABS, - true, - !self.any_popup_visible(), - )); - res.push(CommandInfo::new( - commands::TOGGLE_TABS_DIRECT, - true, - !self.any_popup_visible(), - )); + res.push( + CommandInfo::new( + commands::TOGGLE_TABS, + true, + !self.any_popup_visible(), + ) + .order(order::NAV), + ); + res.push( + CommandInfo::new( + commands::TOGGLE_TABS_DIRECT, + true, + !self.any_popup_visible(), + ) + .order(order::NAV), + ); res.push( CommandInfo::new( diff --git a/src/components/filetree.rs b/src/components/filetree.rs index aef1bfa5..2f7cac26 100644 --- a/src/components/filetree.rs +++ b/src/components/filetree.rs @@ -17,7 +17,7 @@ use anyhow::Result; use asyncgit::{hash, StatusItem, StatusItemType}; use crossterm::event::Event; use std::{borrow::Cow, convert::From, path::Path}; -use strings::commands; +use strings::{commands, order}; use tui::{backend::Backend, layout::Rect, widgets::Text, Frame}; /// @@ -248,11 +248,14 @@ impl Component for FileTreeComponent { out: &mut Vec, force_all: bool, ) -> CommandBlocking { - out.push(CommandInfo::new( - commands::NAVIGATE_TREE, - !self.is_empty(), - self.focused || force_all, - )); + out.push( + CommandInfo::new( + commands::NAVIGATE_TREE, + !self.is_empty(), + self.focused || force_all, + ) + .order(order::NAV), + ); CommandBlocking::PassingOn } diff --git a/src/strings.rs b/src/strings.rs index 2942c9eb..bd7b4658 100644 --- a/src/strings.rs +++ b/src/strings.rs @@ -28,6 +28,10 @@ pub static HELP_TITLE: &str = "Help: all commands"; pub static STASHING_FILES_TITLE: &str = "Files to Stash"; pub static STASHING_OPTIONS_TITLE: &str = "Options"; +pub mod order { + pub static NAV: i8 = 1; +} + pub mod commands { use crate::components::CommandText; diff --git a/src/tabs/status.rs b/src/tabs/status.rs index fe4967db..d9eb6e3b 100644 --- a/src/tabs/status.rs +++ b/src/tabs/status.rs @@ -19,7 +19,7 @@ use asyncgit::{ use components::{command_pump, visibility_blocking}; use crossbeam_channel::Sender; use crossterm::event::Event; -use strings::commands; +use strings::{commands, order}; use tui::layout::{Constraint, Direction, Layout}; /// @@ -326,7 +326,7 @@ impl Component for Status { (self.visible && self.focus == Focus::WorkDir) || force_all, ) - .order(-2), + .order(order::NAV), ); out.push( @@ -336,7 +336,7 @@ impl Component for Status { (self.visible && self.focus == Focus::Stage) || force_all, ) - .order(-2), + .order(order::NAV), ); visibility_blocking(self)