[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 | |
---|
[a38becd] | 69 | if (owl_function_is_away()) { |
---|
[ad788b5] | 70 | getyx(sepwin, y, x); |
---|
| 71 | wmove(sepwin, y, x+2); |
---|
| 72 | wattron(sepwin, A_BOLD); |
---|
| 73 | wattroff(sepwin, A_REVERSE); |
---|
[a38becd] | 74 | waddstr(sepwin, " AWAY "); |
---|
[ad788b5] | 75 | wattron(sepwin, A_REVERSE); |
---|
| 76 | wattroff(sepwin, A_BOLD); |
---|
| 77 | } |
---|
| 78 | |
---|
[6eb3ed9] | 79 | if (owl_mainwin_is_curmsg_truncated(owl_global_get_mainwin(&g))) { |
---|
| 80 | getyx(sepwin, y, x); |
---|
| 81 | wmove(sepwin, y, x+2); |
---|
| 82 | wattron(sepwin, A_BOLD); |
---|
| 83 | cur_numlines = owl_global_get_curmsg_vert_offset(&g) + 1; |
---|
| 84 | cur_totallines = owl_message_get_numlines(owl_view_get_element(v, owl_global_get_curmsg(&g))); |
---|
| 85 | wprintw(sepwin, " <truncated: %d/%d> ", cur_numlines, cur_totallines); |
---|
| 86 | wattroff(sepwin, A_BOLD); |
---|
| 87 | } |
---|
| 88 | |
---|
[ad788b5] | 89 | if (owl_global_get_curmsg_vert_offset(&g)) { |
---|
| 90 | getyx(sepwin, y, x); |
---|
| 91 | wmove(sepwin, y, x+2); |
---|
| 92 | wattron(sepwin, A_BOLD); |
---|
| 93 | wattroff(sepwin, A_REVERSE); |
---|
| 94 | waddstr(sepwin, " SCROLL "); |
---|
| 95 | wattron(sepwin, A_REVERSE); |
---|
| 96 | wattroff(sepwin, A_BOLD); |
---|
| 97 | } |
---|
| 98 | |
---|
| 99 | appendtosepbar = owl_global_get_appendtosepbar(&g); |
---|
| 100 | if (appendtosepbar && *appendtosepbar) { |
---|
| 101 | getyx(sepwin, y, x); |
---|
| 102 | wmove(sepwin, y, x+2); |
---|
| 103 | waddstr(sepwin, " "); |
---|
| 104 | waddstr(sepwin, owl_global_get_appendtosepbar(&g)); |
---|
| 105 | waddstr(sepwin, " "); |
---|
| 106 | } |
---|
| 107 | |
---|
| 108 | getyx(sepwin, y, x); |
---|
| 109 | wmove(sepwin, y, owl_global_get_cols(&g)-1); |
---|
| 110 | |
---|
| 111 | wattroff(sepwin, A_BOLD); |
---|
| 112 | wattroff(sepwin, A_REVERSE); |
---|
| 113 | } |
---|