[ad788b5] | 1 | #include "owl.h" |
---|
| 2 | |
---|
| 3 | static void sepbar_redraw(owl_window *w, WINDOW *sepwin, void *user_data); |
---|
| 4 | |
---|
| 5 | void owl_sepbar_init(owl_window *w) |
---|
| 6 | { |
---|
| 7 | g_signal_connect(w, "redraw", G_CALLBACK(sepbar_redraw), NULL); |
---|
[044f19f] | 8 | /* TODO: handle dirtiness in the sepbar */ |
---|
[521e600] | 9 | owl_window_dirty(w); |
---|
[ad788b5] | 10 | } |
---|
| 11 | |
---|
| 12 | static void sepbar_redraw(owl_window *w, WINDOW *sepwin, void *user_data) |
---|
| 13 | { |
---|
| 14 | const owl_messagelist *ml; |
---|
| 15 | const owl_view *v; |
---|
| 16 | int x, y, i; |
---|
| 17 | const char *foo, *appendtosepbar; |
---|
| 18 | |
---|
| 19 | ml=owl_global_get_msglist(&g); |
---|
| 20 | v=owl_global_get_current_view(&g); |
---|
| 21 | |
---|
| 22 | werase(sepwin); |
---|
| 23 | wattron(sepwin, A_REVERSE); |
---|
| 24 | if (owl_global_is_fancylines(&g)) { |
---|
| 25 | whline(sepwin, ACS_HLINE, owl_global_get_cols(&g)); |
---|
| 26 | } else { |
---|
| 27 | whline(sepwin, '-', owl_global_get_cols(&g)); |
---|
| 28 | } |
---|
| 29 | |
---|
| 30 | if (owl_global_is_sepbar_disable(&g)) { |
---|
| 31 | getyx(sepwin, y, x); |
---|
| 32 | wmove(sepwin, y, owl_global_get_cols(&g)-1); |
---|
| 33 | return; |
---|
| 34 | } |
---|
| 35 | |
---|
| 36 | wmove(sepwin, 0, 2); |
---|
| 37 | |
---|
| 38 | if (owl_messagelist_get_size(ml) == 0) |
---|
| 39 | waddstr(sepwin, " (-/-) "); |
---|
| 40 | else |
---|
| 41 | wprintw(sepwin, " (%i/%i/%i) ", owl_global_get_curmsg(&g) + 1, |
---|
| 42 | owl_view_get_size(v), |
---|
| 43 | owl_messagelist_get_size(ml)); |
---|
| 44 | |
---|
| 45 | foo=owl_view_get_filtname(v); |
---|
| 46 | if (strcmp(foo, owl_global_get_view_home(&g))) |
---|
| 47 | wattroff(sepwin, A_REVERSE); |
---|
| 48 | wprintw(sepwin, " %s ", owl_view_get_filtname(v)); |
---|
| 49 | if (strcmp(foo, owl_global_get_view_home(&g))) |
---|
| 50 | wattron(sepwin, A_REVERSE); |
---|
| 51 | |
---|
| 52 | if (owl_mainwin_is_curmsg_truncated(owl_global_get_mainwin(&g))) { |
---|
| 53 | getyx(sepwin, y, x); |
---|
| 54 | wmove(sepwin, y, x+2); |
---|
| 55 | wattron(sepwin, A_BOLD); |
---|
| 56 | waddstr(sepwin, " <truncated> "); |
---|
| 57 | wattroff(sepwin, A_BOLD); |
---|
| 58 | } |
---|
| 59 | |
---|
| 60 | i=owl_mainwin_get_last_msg(owl_global_get_mainwin(&g)); |
---|
| 61 | if ((i != -1) && |
---|
| 62 | (i < owl_view_get_size(v)-1)) { |
---|
| 63 | getyx(sepwin, y, x); |
---|
| 64 | wmove(sepwin, y, x+2); |
---|
| 65 | wattron(sepwin, A_BOLD); |
---|
| 66 | waddstr(sepwin, " <more> "); |
---|
| 67 | wattroff(sepwin, A_BOLD); |
---|
| 68 | } |
---|
| 69 | |
---|
| 70 | if (owl_global_get_rightshift(&g)>0) { |
---|
| 71 | getyx(sepwin, y, x); |
---|
| 72 | wmove(sepwin, y, x+2); |
---|
| 73 | wprintw(sepwin, " right: %i ", owl_global_get_rightshift(&g)); |
---|
| 74 | } |
---|
| 75 | |
---|
| 76 | if (owl_global_is_zaway(&g) || owl_global_is_aaway(&g)) { |
---|
| 77 | getyx(sepwin, y, x); |
---|
| 78 | wmove(sepwin, y, x+2); |
---|
| 79 | wattron(sepwin, A_BOLD); |
---|
| 80 | wattroff(sepwin, A_REVERSE); |
---|
| 81 | if (owl_global_is_zaway(&g) && owl_global_is_aaway(&g)) { |
---|
| 82 | waddstr(sepwin, " AWAY "); |
---|
| 83 | } else if (owl_global_is_zaway(&g)) { |
---|
| 84 | waddstr(sepwin, " Z-AWAY "); |
---|
| 85 | } else if (owl_global_is_aaway(&g)) { |
---|
| 86 | waddstr(sepwin, " A-AWAY "); |
---|
| 87 | } |
---|
| 88 | wattron(sepwin, A_REVERSE); |
---|
| 89 | wattroff(sepwin, A_BOLD); |
---|
| 90 | } |
---|
| 91 | |
---|
| 92 | if (owl_global_get_curmsg_vert_offset(&g)) { |
---|
| 93 | getyx(sepwin, y, x); |
---|
| 94 | wmove(sepwin, y, x+2); |
---|
| 95 | wattron(sepwin, A_BOLD); |
---|
| 96 | wattroff(sepwin, A_REVERSE); |
---|
| 97 | waddstr(sepwin, " SCROLL "); |
---|
| 98 | wattron(sepwin, A_REVERSE); |
---|
| 99 | wattroff(sepwin, A_BOLD); |
---|
| 100 | } |
---|
| 101 | |
---|
| 102 | appendtosepbar = owl_global_get_appendtosepbar(&g); |
---|
| 103 | if (appendtosepbar && *appendtosepbar) { |
---|
| 104 | getyx(sepwin, y, x); |
---|
| 105 | wmove(sepwin, y, x+2); |
---|
| 106 | waddstr(sepwin, " "); |
---|
| 107 | waddstr(sepwin, owl_global_get_appendtosepbar(&g)); |
---|
| 108 | waddstr(sepwin, " "); |
---|
| 109 | } |
---|
| 110 | |
---|
| 111 | getyx(sepwin, y, x); |
---|
| 112 | wmove(sepwin, y, owl_global_get_cols(&g)-1); |
---|
| 113 | |
---|
| 114 | wattroff(sepwin, A_BOLD); |
---|
| 115 | wattroff(sepwin, A_REVERSE); |
---|
| 116 | } |
---|