Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feat command mode #58

Merged
merged 33 commits into from
May 22, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
33 commits
Select commit Hold shift + click to select a range
61a815b
Add vim like command mode
NickHackman May 17, 2019
4d6fad8
Add cmd mode for infobar, cmd mode help and quit
NickHackman May 17, 2019
5eab4dd
Add Command mode
NickHackman May 17, 2019
3a9f4a4
Add command mode m/max, takes new max image length
NickHackman May 17, 2019
5ae1ab1
Refractored code, fixed bug in :max
NickHackman May 17, 2019
553e0a5
Add force render, added docs to command_mode_run
NickHackman May 17, 2019
9fa525a
Refractor name change in ui.rs
NickHackman May 18, 2019
1cbce37
Add newglob Err msg if file doesn't exist, bug fix
NickHackman May 18, 2019
f84d117
Add Commands enum for command mode
NickHackman May 19, 2019
5bbf788
Fix bug in newglob, add dep shellexpand and regex
NickHackman May 19, 2019
0c266b6
Fixed Bugs, empty images didn't render bar command
NickHackman May 19, 2019
66af23a
Merge branch 'development' into feat-redefine-glob
NickHackman May 19, 2019
7be5457
Refractored code in response to clippy suggestions
NickHackman May 19, 2019
0a12516
Merge remote-tracking branch 'refs/remotes/origin/feat-redefine-glob'…
NickHackman May 19, 2019
cc6e324
Rewrite of Modal system, add Error
NickHackman May 20, 2019
d0908dc
Refractored code in command_mode.rs
NickHackman May 21, 2019
4799c82
Add lazy_static!. Make path_regex compile once
gurgalex May 21, 2019
ad6bbc3
Remove unneeded lifetimes due to cloning
gurgalex May 21, 2019
5fb3e7e
Refractored command_mode.rs
NickHackman May 21, 2019
e02ab69
Merge remote-tracking branch 'refs/remotes/origin/feat-redefine-glob'…
NickHackman May 21, 2019
b085855
Fixed issue with merge
NickHackman May 21, 2019
fb30e21
Fixed bug in sort on empty, and when merging
NickHackman May 21, 2019
0819674
Added virutal mapping for ':'
NickHackman May 21, 2019
396fef9
Changed Event Handling for Normal mode
NickHackman May 21, 2019
fa916a7
Fixed bug max_viewable, would be overwritten
NickHackman May 21, 2019
e25df1c
Updated README with Command mode options
NickHackman May 21, 2019
bcfa4c2
Fixed bug in command mode destfolder
NickHackman May 21, 2019
a5b0f1a
Removed unecessary L/R shift in ui.rs
NickHackman May 21, 2019
b12894d
Entering command mode toggles bar on by default
NickHackman May 21, 2019
a0db6e8
Fixed bugs delete, move, and command mode df
NickHackman May 22, 2019
5e548a4
Fixed bug, program returns an error
NickHackman May 22, 2019
2ea2226
Command mode newglob, reset keep folder
NickHackman May 22, 2019
42941ac
Paths::curent_dir -> base_dir, better track of df
NickHackman May 22, 2019
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ clap = "2.33"
glob = "0.3"
fs_extra = "1.1"
natord = "1.0.9"
shellexpand = "1.0"

[dependencies.sdl2]
version = "0.32"
Expand Down
15 changes: 14 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ Set the maximum number of images to be displayed `m` or `--max` flag. 0 means in

```$ riv -m 0 **/*.png```

### Controls
### Normal Mode Controls


| Key | Action |
Expand All @@ -70,6 +70,19 @@ Set the maximum number of images to be displayed `m` or `--max` flag. 0 means in
| z OR Left Click | Toggle actual size vs scaled image |
| . (period) | Repeat last action |

### Command Mode Controls


| Command | Action |
|-----------------------------|----------------------------------------------------------|
| ng OR newglob [glob] | **Required argument** the new glob/directory/file |
| ? OR help | Toggle fullscreen mode |
gurgalex marked this conversation as resolved.
Show resolved Hide resolved
| q OR quit | Quit |
| sort (method) | *Optional argument* the new method to sort by |
| df OR destfolder [path] | **Required argument** new folder to move/copy images to |
| m OR max [positive integer] | **Required argument** new maximum number of files to view|


## Getting Started

These instructions will get you a copy of the project up and running on your local machine for development and testing purposes.
Expand Down
2 changes: 1 addition & 1 deletion src/cli.rs
Original file line number Diff line number Diff line change
Expand Up @@ -124,7 +124,7 @@ pub fn cli() -> Result<Args, String> {
})
}

fn push_image_path(v: &mut Vec<PathBuf>, p: PathBuf) {
pub(crate) fn push_image_path(v: &mut Vec<PathBuf>, p: PathBuf) {
if let Some(ext) = p.extension() {
if let Some(ext_str) = ext.to_str() {
let low = ext_str.to_string().to_lowercase();
Expand Down
62 changes: 41 additions & 21 deletions src/infobar.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,32 +3,52 @@
//! Module InfoBar provides structures and functions for building and rendering an infobar

use crate::paths::Paths;
use crate::ui::Mode;

/// Text contains the strings required to print the infobar.
pub struct Text {
/// current image is the string of the current image path
pub current_image: String,
/// index is the string represention of the index.
pub index: String,
/// Either displays the name of the current image or the current command the user is typing in
/// command mode
pub information: String,
/// In normal mode this is the string represention of the index, in command mode this is
/// "Command"
pub mode: String,
}

impl From<&Paths> for Text {
fn from(p: &Paths) -> Self {
let current_image = match p.images.get(p.index) {
Some(path) => match path.to_str() {
Some(name) => name.to_string(),
None => "No file".to_string(),
},
None => "No file selected".to_string(),
impl Text {
/// Updates the infobar based on the current mode of the applicaiton
/// Normal Mode:
/// mode = index of current image
/// information = path to current image
/// Command Mode:
/// mode = "Command"
/// information = curerntly entered user string
/// Error Mode:
/// mode = "Error"
/// information = error message to display
pub fn update(current_mode: &Mode, paths: &Paths) -> Self {
let (mode, information) = match current_mode {
Mode::Command(msg) => ("Command".to_string(), format!(":{}", msg)),
Mode::Normal => {
let information: String;
let mode: String;
information = match paths.images.get(paths.index) {
Some(path) => match path.to_str() {
Some(name) => name.to_string(),
None => "No file".to_string(),
},
None => "No file selected".to_string(),
};
mode = if paths.images.is_empty() {
"No files in path".to_string()
} else {
format!("{} of {}", paths.index + 1, paths.max_viewable)
};
(mode, information)
}
Mode::Error(msg) => ("Error".to_string(), msg.to_string()),
_ => ("Exit".to_string(), "Exiting... Goodbye".to_string()),
};
let index = if p.images.is_empty() {
"No files in path".to_string()
} else {
format!("{} of {}", p.index + 1, p.max_viewable)
};
Text {
current_image,
index,
}
Text { information, mode }
}
}
6 changes: 5 additions & 1 deletion src/paths.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,14 @@ pub struct Paths {
pub images: Vec<PathBuf>,
/// dest_folder is the path of the destination folder for moving and copying images.
pub dest_folder: PathBuf,
/// dest_folder was modified from the default keep through Command mode df or destfolder
pub changed_dest_folder: bool,
/// current_dir is the path of the current directory where the program was launched from
pub current_dir: PathBuf,
pub base_dir: PathBuf,
/// index is the index of the images vector of the current image to be displayed.
pub index: usize,
/// Artificial user facing length of images limited by max cli argument
pub max_viewable: usize,
/// Actual length the user said was maximum for images
pub actual_max_viewable: usize,
}
Loading