diff options
author | Jiayi Zhao <jeff.no.zhao@gmail.com> | 2019-02-19 11:12:35 -0500 |
---|---|---|
committer | Jiayi Zhao <jeff.no.zhao@gmail.com> | 2019-02-19 11:12:35 -0500 |
commit | 1e3777d02d552e52c241c691c4f2fdf3b5de1c65 (patch) | |
tree | 4a6a6b058d96adaf5f4d2c8d0a6c9a8b21637394 | |
parent | 4ec505e7c83260a7525b0169e9bdbcf2e51248a4 (diff) |
make tab ui a little more pretty
-rw-r--r-- | src/ui.rs | 24 | ||||
-rw-r--r-- | src/window/view.rs | 4 |
2 files changed, 20 insertions, 8 deletions
@@ -213,15 +213,27 @@ pub fn wprint_file_info(win: ncurses::WINDOW, file: &structs::JoshutoDirEntry) { pub fn redraw_tab_view(win: &window::JoshutoPanel, context: &JoshutoContext) { let tab_len = context.tabs.len(); + ncurses::werase(win.win); if tab_len == 1 { - ncurses::werase(win.win); - } else { + } else if tab_len >= 6 { ncurses::wmove(win.win, 0, 0); ncurses::wattron(win.win, ncurses::A_BOLD()); - ncurses::waddstr( - win.win, - format!("{} {}", context.curr_tab_index + 1, tab_len).as_str(), - ); + ncurses::wattron(win.win, ncurses::A_STANDOUT()); + ncurses::waddstr(win.win, &format!("{}", context.curr_tab_index + 1)); + ncurses::wattroff(win.win, ncurses::A_STANDOUT()); + ncurses::waddstr(win.win, &format!(" {}", tab_len)); + ncurses::wattroff(win.win, ncurses::A_BOLD()); + } else { + ncurses::wattron(win.win, ncurses::A_BOLD()); + for i in 0..tab_len { + if i == context.curr_tab_index { + ncurses::wattron(win.win, ncurses::A_STANDOUT()); + ncurses::waddstr(win.win, &format!("{} ", i+1)); + ncurses::wattroff(win.win, ncurses::A_STANDOUT()); + } else { + ncurses::waddstr(win.win, &format!("{} ", i+1)); + } + } ncurses::wattroff(win.win, ncurses::A_BOLD()); } ncurses::wnoutrefresh(win.win); diff --git a/src/window/view.rs b/src/window/view.rs index ead7f0d..bb8a18f 100644 --- a/src/window/view.rs +++ b/src/window/view.rs @@ -26,8 +26,8 @@ impl JoshutoView { let win_coord: (usize, usize) = (0, 0); let top_win = JoshutoPanel::new(win_xy.0, win_xy.1, win_coord); - let win_xy: (i32, i32) = (1, 5); - let win_coord: (usize, usize) = (0, term_cols as usize - 5); + let win_xy: (i32, i32) = (1, 10); + let win_coord: (usize, usize) = (0, term_cols as usize - win_xy.1 as usize); let tab_win = JoshutoPanel::new(win_xy.0, win_xy.1, win_coord); let win_xy: (i32, i32) = (term_rows - 2, (term_divide * win_ratio.0 as i32) - 1); |