diff options
author | Jiayi Zhao <jeff.no.zhao@gmail.com> | 2019-02-20 19:54:37 -0500 |
---|---|---|
committer | Jiayi Zhao <jeff.no.zhao@gmail.com> | 2019-02-20 19:54:37 -0500 |
commit | c7497dd187e9729aef2630f22b481d02864ad3bb (patch) | |
tree | d48a7034209d27c4e3d686764d431466044d5bc7 /src/preview.rs | |
parent | f75182734a5bec0987b424aff28e2ed0acf2fe38 (diff) |
cargo fmt
Diffstat (limited to 'src/preview.rs')
-rw-r--r-- | src/preview.rs | 69 |
1 files changed, 37 insertions, 32 deletions
diff --git a/src/preview.rs b/src/preview.rs index 6e88d32..bd093bd 100644 --- a/src/preview.rs +++ b/src/preview.rs @@ -10,9 +10,14 @@ pub fn preview_file(curr_tab: &mut JoshutoTab, views: &JoshutoView, config_t: &J if let Some(ref curr_list) = curr_tab.curr_list { if let Some(entry) = curr_list.get_curr_ref() { if entry.path.is_dir() { - match curr_tab.history.get_mut_or_create(&entry.path, &config_t.sort_type) { + match curr_tab + .history + .get_mut_or_create(&entry.path, &config_t.sort_type) + { Ok(dirlist) => { - views.right_win.display_contents(dirlist, config_t.scroll_offset); + views + .right_win + .display_contents(dirlist, config_t.scroll_offset); views.right_win.queue_for_refresh(); } Err(e) => { @@ -23,44 +28,44 @@ pub fn preview_file(curr_tab: &mut JoshutoTab, views: &JoshutoView, config_t: &J ncurses::werase(views.right_win.win); ncurses::wnoutrefresh(views.right_win.win); } -/* - else { - ncurses::werase(views.right_win.win); + /* + else { + ncurses::werase(views.right_win.win); - if let Some(file_ext) = entry.path.extension() { - if let Some(file_ext) = file_ext.to_str() { - match file_ext { - "o" | "a" | "avi" | "mp3" | "mp4" | "wmv" | "wma" | - "mkv" | "flv" | "vob" | "wav" | "mpc" | "flac" | - "divx" | "xcf" | "pdf" | "torrent" | "class" | "so" | - "img" | "pyc" | "dmg" | "png" | "jpg" | "jpeg" | "out" | "svg" => { - ui::wprint_err(&context.views.right_win, "Binary File"); - }, - _ => { - let detective = mime_detective::MimeDetective::new().unwrap(); - match detective.detect_filepath(&entry.path) { - Ok(mime_type) => { - match mime_type.type_() { - mime::TEXT => { - text_preview(&context.views.right_win, &entry.path); + if let Some(file_ext) = entry.path.extension() { + if let Some(file_ext) = file_ext.to_str() { + match file_ext { + "o" | "a" | "avi" | "mp3" | "mp4" | "wmv" | "wma" | + "mkv" | "flv" | "vob" | "wav" | "mpc" | "flac" | + "divx" | "xcf" | "pdf" | "torrent" | "class" | "so" | + "img" | "pyc" | "dmg" | "png" | "jpg" | "jpeg" | "out" | "svg" => { + ui::wprint_err(&context.views.right_win, "Binary File"); + }, + _ => { + let detective = mime_detective::MimeDetective::new().unwrap(); + match detective.detect_filepath(&entry.path) { + Ok(mime_type) => { + match mime_type.type_() { + mime::TEXT => { + text_preview(&context.views.right_win, &entry.path); + }, + _ => { + ui::wprint_err(&context.views.right_win, mime_type.type_().as_str()); + }, + } }, - _ => { - ui::wprint_err(&context.views.right_win, mime_type.type_().as_str()); + Err(e) => { + ui::wprint_err(&context.views.right_win, e.to_string().as_str()); }, } - }, - Err(e) => { - ui::wprint_err(&context.views.right_win, e.to_string().as_str()); - }, + } } } } - } - } - ncurses::wnoutrefresh(context.views.right_win.win); - } -*/ + ncurses::wnoutrefresh(context.views.right_win.win); + } + */ } else { ncurses::werase(views.right_win.win); ncurses::wnoutrefresh(views.right_win.win); |