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); |
---|
8 | owl_dirty_window_on_signal(w, g.gn, "message-received"); |
---|
9 | owl_dirty_window_on_signal(w, g.gn, "command-executed"); |
---|
10 | owl_window_dirty(w); |
---|
11 | } |
---|
12 | |
---|
13 | static void sepbar_redraw(owl_window *w, WINDOW *sepwin, void *user_data) |
---|
14 | { |
---|
15 | const owl_messagelist *ml; |
---|
16 | const owl_view *v; |
---|
17 | int x, y, i; |
---|
18 | const char *foo, *appendtosepbar; |
---|
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 | if (owl_mainwin_is_curmsg_truncated(owl_global_get_mainwin(&g))) { |
---|
54 | getyx(sepwin, y, x); |
---|
55 | wmove(sepwin, y, x+2); |
---|
56 | wattron(sepwin, A_BOLD); |
---|
57 | waddstr(sepwin, " <truncated> "); |
---|
58 | wattroff(sepwin, A_BOLD); |
---|
59 | } |
---|
60 | |
---|
61 | i=owl_mainwin_get_last_msg(owl_global_get_mainwin(&g)); |
---|
62 | if ((i != -1) && |
---|
63 | (i < owl_view_get_size(v)-1)) { |
---|
64 | getyx(sepwin, y, x); |
---|
65 | wmove(sepwin, y, x+2); |
---|
66 | wattron(sepwin, A_BOLD); |
---|
67 | waddstr(sepwin, " <more> "); |
---|
68 | wattroff(sepwin, A_BOLD); |
---|
69 | } |
---|
70 | |
---|
71 | if (owl_global_get_rightshift(&g)>0) { |
---|
72 | getyx(sepwin, y, x); |
---|
73 | wmove(sepwin, y, x+2); |
---|
74 | wprintw(sepwin, " right: %i ", owl_global_get_rightshift(&g)); |
---|
75 | } |
---|
76 | |
---|
77 | if (owl_global_is_zaway(&g) || owl_global_is_aaway(&g)) { |
---|
78 | getyx(sepwin, y, x); |
---|
79 | wmove(sepwin, y, x+2); |
---|
80 | wattron(sepwin, A_BOLD); |
---|
81 | wattroff(sepwin, A_REVERSE); |
---|
82 | if (owl_global_is_zaway(&g) && owl_global_is_aaway(&g)) { |
---|
83 | waddstr(sepwin, " AWAY "); |
---|
84 | } else if (owl_global_is_zaway(&g)) { |
---|
85 | waddstr(sepwin, " Z-AWAY "); |
---|
86 | } else if (owl_global_is_aaway(&g)) { |
---|
87 | waddstr(sepwin, " A-AWAY "); |
---|
88 | } |
---|
89 | wattron(sepwin, A_REVERSE); |
---|
90 | wattroff(sepwin, A_BOLD); |
---|
91 | } |
---|
92 | |
---|
93 | if (owl_global_get_curmsg_vert_offset(&g)) { |
---|
94 | getyx(sepwin, y, x); |
---|
95 | wmove(sepwin, y, x+2); |
---|
96 | wattron(sepwin, A_BOLD); |
---|
97 | wattroff(sepwin, A_REVERSE); |
---|
98 | waddstr(sepwin, " SCROLL "); |
---|
99 | wattron(sepwin, A_REVERSE); |
---|
100 | wattroff(sepwin, A_BOLD); |
---|
101 | } |
---|
102 | |
---|
103 | appendtosepbar = owl_global_get_appendtosepbar(&g); |
---|
104 | if (appendtosepbar && *appendtosepbar) { |
---|
105 | getyx(sepwin, y, x); |
---|
106 | wmove(sepwin, y, x+2); |
---|
107 | waddstr(sepwin, " "); |
---|
108 | waddstr(sepwin, owl_global_get_appendtosepbar(&g)); |
---|
109 | waddstr(sepwin, " "); |
---|
110 | } |
---|
111 | |
---|
112 | getyx(sepwin, y, x); |
---|
113 | wmove(sepwin, y, owl_global_get_cols(&g)-1); |
---|
114 | |
---|
115 | wattroff(sepwin, A_BOLD); |
---|
116 | wattroff(sepwin, A_REVERSE); |
---|
117 | } |
---|