change opener to rifle

This commit is contained in:
rabite 2019-02-09 19:34:21 +01:00
parent 528f725145
commit e07f9af433
3 changed files with 17 additions and 6 deletions

View File

@ -72,17 +72,17 @@ impl FileBrowser {
Err(ref err) if err.description() == "placeholder".to_string() => Err(ref err) if err.description() == "placeholder".to_string() =>
self.show_status("No! Can't open this!"), self.show_status("No! Can't open this!"),
_ => { _ => {
let status = std::process::Command::new("xdg-open") let status = std::process::Command::new("rifle")
.args(dbg!(file.path.file_name())) .args(file.path.file_name())
.status(); .status();
match status { match status {
Ok(status) => Ok(status) =>
self.show_status(&format!("\"{}\" exited with {}", self.show_status(&format!("\"{}\" exited with {}",
"xdg-open", status)), "rifle", status)),
Err(err) => Err(err) =>
self.show_status(&format!("Can't run this \"{}\": {}", self.show_status(&format!("Can't run this \"{}\": {}",
"xdg-open", err)) "rifle", err))
} }
} }

View File

@ -3,6 +3,7 @@ use termion::event::{Event, Key};
use unicode_width::UnicodeWidthStr; use unicode_width::UnicodeWidthStr;
use std::path::{Path, PathBuf}; use std::path::{Path, PathBuf};
use std::io::Write;
use crate::coordinates::{Coordinates, Position, Size}; use crate::coordinates::{Coordinates, Position, Size};
use crate::files::{File, Files}; use crate::files::{File, Files};
@ -320,6 +321,11 @@ where
.arg("-c") .arg("-c")
.arg(&cmd) .arg(&cmd)
.status(); .status();
write!(std::io::stdout(), "{}{}",
termion::style::Reset,
termion::clear::All).unwrap();
match status { match status {
Ok(status) => self.show_status(&format!("\"{}\" exited with {}", Ok(status) => self.show_status(&format!("\"{}\" exited with {}",
cmd, status)), cmd, status)),

View File

@ -74,6 +74,7 @@ where
//Self::clear_status(); //Self::clear_status();
let event = event.unwrap(); let event = event.unwrap();
self.widget.on_event(event); self.widget.on_event(event);
self.screen.cursor_hide();
self.draw(); self.draw();
} }
} }
@ -136,8 +137,8 @@ pub fn show_status(status: &str) {
pub fn minibuffer(query: &str) -> Option<String> { pub fn minibuffer(query: &str) -> Option<String> {
show_status(&(query.to_string() + ": ")); show_status(&(query.to_string() + ": "));
write!(stdout(), "{}{}", write!(stdout(), "{}{}",
termion::cursor::Show, termion::cursor::Show,
termion::cursor::Save).unwrap(); termion::cursor::Save).unwrap();
stdout().flush().unwrap(); stdout().flush().unwrap();
let mut buffer = "".to_string(); let mut buffer = "".to_string();
@ -150,8 +151,12 @@ pub fn minibuffer(query: &str) -> Option<String> {
Key::Esc | Key::Ctrl('c') => break, Key::Esc | Key::Ctrl('c') => break,
Key::Char('\n') => { Key::Char('\n') => {
if buffer == "" { if buffer == "" {
write!(stdout(), "{}", termion::cursor::Hide).unwrap();
stdout().flush().unwrap();
return None; return None;
} else { } else {
write!(stdout(), "{}", termion::cursor::Hide).unwrap();
stdout().flush().unwrap();
return Some(buffer); return Some(buffer);
} }
} }