source: sepbar.c @ 4f5e38f

release-1.8release-1.9
Last change on this file since 4f5e38f was 6eb3ed9, checked in by Anders Kaseorg <andersk@mit.edu>, 10 years ago
Show how far you are in a long message Addresses most of ticket #119 - it shows how far you are in a long message, but not in a message that you're typing. The display style I've somewhat arbitrarily chosen is to replace <truncated> with <truncated: $num_lines_through/$total_lines>. Additionally, the <truncated> part of sepbar has been moved to be next to 'SCROLL', which it is most similar to.
  • Property mode set to 100644
File size: 3.3 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  /* TODO: handle dirtiness in the sepbar */
9  owl_window_dirty(w);
10}
11
12static 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  int cur_numlines, cur_totallines;
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
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
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}
Note: See TracBrowser for help on using the repository browser.