source: sepbar.c @ d6f2d21

release-1.10release-1.7release-1.8release-1.9
Last change on this file since d6f2d21 was d6f2d21, checked in by David Benjamin <davidben@mit.edu>, 14 years ago
Hook up and use the message-received signal in the sepbar
  • Property mode set to 100644
File size: 3.2 KB
Line 
1#include "owl.h"
2
3static void sepbar_redraw(owl_window *w, WINDOW *sepwin, void *user_data);
4
5void 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_window_dirty(w);
10}
11
12void sepbar_dirty(void)
13{
14  owl_window_dirty(owl_global_get_curs_sepwin(&g));
15}
16
17static void sepbar_redraw(owl_window *w, WINDOW *sepwin, void *user_data)
18{
19  const owl_messagelist *ml;
20  const owl_view *v;
21  int x, y, i;
22  const char *foo, *appendtosepbar;
23
24  ml=owl_global_get_msglist(&g);
25  v=owl_global_get_current_view(&g);
26
27  werase(sepwin);
28  wattron(sepwin, A_REVERSE);
29  if (owl_global_is_fancylines(&g)) {
30    whline(sepwin, ACS_HLINE, owl_global_get_cols(&g));
31  } else {
32    whline(sepwin, '-', owl_global_get_cols(&g));
33  }
34
35  if (owl_global_is_sepbar_disable(&g)) {
36    getyx(sepwin, y, x);
37    wmove(sepwin, y, owl_global_get_cols(&g)-1);
38    return;
39  }
40
41  wmove(sepwin, 0, 2);
42
43  if (owl_messagelist_get_size(ml) == 0)
44    waddstr(sepwin, " (-/-) ");
45  else
46    wprintw(sepwin, " (%i/%i/%i) ", owl_global_get_curmsg(&g) + 1,
47            owl_view_get_size(v),
48            owl_messagelist_get_size(ml));
49
50  foo=owl_view_get_filtname(v);
51  if (strcmp(foo, owl_global_get_view_home(&g)))
52      wattroff(sepwin, A_REVERSE);
53  wprintw(sepwin, " %s ", owl_view_get_filtname(v));
54  if (strcmp(foo, owl_global_get_view_home(&g)))
55      wattron(sepwin, A_REVERSE);
56
57  if (owl_mainwin_is_curmsg_truncated(owl_global_get_mainwin(&g))) {
58    getyx(sepwin, y, x);
59    wmove(sepwin, y, x+2);
60    wattron(sepwin, A_BOLD);
61    waddstr(sepwin, " <truncated> ");
62    wattroff(sepwin, A_BOLD);
63  }
64
65  i=owl_mainwin_get_last_msg(owl_global_get_mainwin(&g));
66  if ((i != -1) &&
67      (i < owl_view_get_size(v)-1)) {
68    getyx(sepwin, y, x);
69    wmove(sepwin, y, x+2);
70    wattron(sepwin, A_BOLD);
71    waddstr(sepwin, " <more> ");
72    wattroff(sepwin, A_BOLD);
73  }
74
75  if (owl_global_get_rightshift(&g)>0) {
76    getyx(sepwin, y, x);
77    wmove(sepwin, y, x+2);
78    wprintw(sepwin, " right: %i ", owl_global_get_rightshift(&g));
79  }
80
81  if (owl_global_is_zaway(&g) || owl_global_is_aaway(&g)) {
82    getyx(sepwin, y, x);
83    wmove(sepwin, y, x+2);
84    wattron(sepwin, A_BOLD);
85    wattroff(sepwin, A_REVERSE);
86    if (owl_global_is_zaway(&g) && owl_global_is_aaway(&g)) {
87      waddstr(sepwin, " AWAY ");
88    } else if (owl_global_is_zaway(&g)) {
89      waddstr(sepwin, " Z-AWAY ");
90    } else if (owl_global_is_aaway(&g)) {
91      waddstr(sepwin, " A-AWAY ");
92    }
93    wattron(sepwin, A_REVERSE);
94    wattroff(sepwin, A_BOLD);
95  }
96
97  if (owl_global_get_curmsg_vert_offset(&g)) {
98    getyx(sepwin, y, x);
99    wmove(sepwin, y, x+2);
100    wattron(sepwin, A_BOLD);
101    wattroff(sepwin, A_REVERSE);
102    waddstr(sepwin, " SCROLL ");
103    wattron(sepwin, A_REVERSE);
104    wattroff(sepwin, A_BOLD);
105  }
106
107  appendtosepbar = owl_global_get_appendtosepbar(&g);
108  if (appendtosepbar && *appendtosepbar) {
109    getyx(sepwin, y, x);
110    wmove(sepwin, y, x+2);
111    waddstr(sepwin, " ");
112    waddstr(sepwin, owl_global_get_appendtosepbar(&g));
113    waddstr(sepwin, " ");
114  }
115
116  getyx(sepwin, y, x);
117  wmove(sepwin, y, owl_global_get_cols(&g)-1);
118   
119  wattroff(sepwin, A_BOLD);
120  wattroff(sepwin, A_REVERSE);
121}
Note: See TracBrowser for help on using the repository browser.