1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
extern crate tinyfiledialogs;
use std::ffi::OsStr;
use std::path::{PathBuf, Path};
use self::tinyfiledialogs::{open_file_dialog, save_file_dialog};
pub fn move_cursor_up(n: usize) -> String {
format!("\x1B[{}A", n)
}
pub fn move_cursor_down(n: usize) -> String {
format!("\x1B[{}B", n)
}
pub fn move_cursor_back(n: usize) -> String {
format!("\x1B[{}D", n)
}
pub fn show_cursor(show: bool) -> &'static str {
if show { "\x1B[?25h" } else { "\x1B[?25l" }
}
pub fn save_file_picker(filename: &OsStr, extension: Option<&OsStr>) -> Option<PathBuf> {
let _ = extension;
save_file_dialog("Pick save location.", &Path::new(filename).display().to_string()).map(|s| s.into())
}
pub fn open_file_picker() -> Option<PathBuf> {
open_file_dialog("Pick file to upload.", "", None).map(|s| s.into())
}