[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; |
---|
[6eb3ed9] | 18 | int cur_numlines, cur_totallines; |
---|
[ad788b5] | 19 | |
---|
| 20 | ml=owl_global_get_msglist(&g); |
---|
| 21 | v=owl_global_get_current_view(&g); |
---|
| 22 | |
---|
| 23 | werase(sepwin); |
---|
| 24 | wattron(sepwin, A_REVERSE); |
---|
| 25 | if (owl_global_is_fancylines(&g)) { |
---|
| 26 | whline(sepwin, ACS_HLINE, owl_global_get_cols(&g)); |
---|
| 27 | } else { |
---|
| 28 | whline(sepwin, '-', owl_global_get_cols(&g)); |
---|
| 29 | } |
---|
| 30 | |
---|
| 31 | if (owl_global_is_sepbar_disable(&g)) { |
---|
| 32 | getyx(sepwin, y, x); |
---|
| 33 | wmove(sepwin, y, owl_global_get_cols(&g)-1); |
---|
| 34 | return; |
---|
| 35 | } |
---|
| 36 | |
---|
| 37 | wmove(sepwin, 0, 2); |
---|
| 38 | |
---|
| 39 | if (owl_messagelist_get_size(ml) == 0) |
---|
| 40 | waddstr(sepwin, " (-/-) "); |
---|
| 41 | else |
---|
| 42 | wprintw(sepwin, " (%i/%i/%i) ", owl_global_get_curmsg(&g) + 1, |
---|
| 43 | owl_view_get_size(v), |
---|
| 44 | owl_messagelist_get_size(ml)); |
---|
| 45 | |
---|
| 46 | foo=owl_view_get_filtname(v); |
---|
| 47 | if (strcmp(foo, owl_global_get_view_home(&g))) |
---|
| 48 | wattroff(sepwin, A_REVERSE); |
---|
| 49 | wprintw(sepwin, " %s ", owl_view_get_filtname(v)); |
---|
| 50 | if (strcmp(foo, owl_global_get_view_home(&g))) |
---|
| 51 | wattron(sepwin, A_REVERSE); |
---|
| 52 | |
---|
| 53 | i=owl_mainwin_get_last_msg(owl_global_get_mainwin(&g)); |
---|
| 54 | if ((i != -1) && |
---|
| 55 | (i < owl_view_get_size(v)-1)) { |
---|
| 56 | getyx(sepwin, y, x); |
---|
| 57 | wmove(sepwin, y, x+2); |
---|
| 58 | wattron(sepwin, A_BOLD); |
---|
| 59 | waddstr(sepwin, " <more> "); |
---|
| 60 | wattroff(sepwin, A_BOLD); |
---|
| 61 | } |
---|
| 62 | |
---|
| 63 | if (owl_global_get_rightshift(&g)>0) { |
---|
| 64 | getyx(sepwin, y, x); |
---|
| 65 | wmove(sepwin, y, x+2); |
---|
| 66 | wprintw(sepwin, " right: %i ", owl_global_get_rightshift(&g)); |
---|
| 67 | } |
---|
| 68 | |
---|
| 69 | if (owl_global_is_zaway(&g) || owl_global_is_aaway(&g)) { |
---|
| 70 | getyx(sepwin, y, x); |
---|
| 71 | wmove(sepwin, y, x+2); |
---|
| 72 | wattron(sepwin, A_BOLD); |
---|
| 73 | wattroff(sepwin, A_REVERSE); |
---|
| 74 | if (owl_global_is_zaway(&g) && owl_global_is_aaway(&g)) { |
---|
| 75 | waddstr(sepwin, " AWAY "); |
---|
| 76 | } else if (owl_global_is_zaway(&g)) { |
---|
| 77 | waddstr(sepwin, " Z-AWAY "); |
---|
| 78 | } else if (owl_global_is_aaway(&g)) { |
---|
| 79 | waddstr(sepwin, " A-AWAY "); |
---|
| 80 | } |
---|
| 81 | wattron(sepwin, A_REVERSE); |
---|
| 82 | wattroff(sepwin, A_BOLD); |
---|
| 83 | } |
---|
| 84 | |
---|
[6eb3ed9] | 85 | if (owl_mainwin_is_curmsg_truncated(owl_global_get_mainwin(&g))) { |
---|
| 86 | getyx(sepwin, y, x); |
---|
| 87 | wmove(sepwin, y, x+2); |
---|
| 88 | wattron(sepwin, A_BOLD); |
---|
| 89 | cur_numlines = owl_global_get_curmsg_vert_offset(&g) + 1; |
---|
| 90 | cur_totallines = owl_message_get_numlines(owl_view_get_element(v, owl_global_get_curmsg(&g))); |
---|
| 91 | wprintw(sepwin, " <truncated: %d/%d> ", cur_numlines, cur_totallines); |
---|
| 92 | wattroff(sepwin, A_BOLD); |
---|
| 93 | } |
---|
| 94 | |
---|
[ad788b5] | 95 | if (owl_global_get_curmsg_vert_offset(&g)) { |
---|
| 96 | getyx(sepwin, y, x); |
---|
| 97 | wmove(sepwin, y, x+2); |
---|
| 98 | wattron(sepwin, A_BOLD); |
---|
| 99 | wattroff(sepwin, A_REVERSE); |
---|
| 100 | waddstr(sepwin, " SCROLL "); |
---|
| 101 | wattron(sepwin, A_REVERSE); |
---|
| 102 | wattroff(sepwin, A_BOLD); |
---|
| 103 | } |
---|
| 104 | |
---|
| 105 | appendtosepbar = owl_global_get_appendtosepbar(&g); |
---|
| 106 | if (appendtosepbar && *appendtosepbar) { |
---|
| 107 | getyx(sepwin, y, x); |
---|
| 108 | wmove(sepwin, y, x+2); |
---|
| 109 | waddstr(sepwin, " "); |
---|
| 110 | waddstr(sepwin, owl_global_get_appendtosepbar(&g)); |
---|
| 111 | waddstr(sepwin, " "); |
---|
| 112 | } |
---|
| 113 | |
---|
| 114 | getyx(sepwin, y, x); |
---|
| 115 | wmove(sepwin, y, owl_global_get_cols(&g)-1); |
---|
| 116 | |
---|
| 117 | wattroff(sepwin, A_BOLD); |
---|
| 118 | wattroff(sepwin, A_REVERSE); |
---|
| 119 | } |
---|