4
This program is free software; you can redistribute it and/or modify
5
it under the terms of the GNU General Public License as published by
6
the Free Software Foundation; either version 2 of the License, or
7
(at your option) any later version.
9
This program is distributed in the hope that it will be useful,
10
but WITHOUT ANY WARRANTY; without even the implied warranty of
11
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12
GNU General Public License for more details.
14
You should have received a copy of the GNU General Public License
15
along with this program; if not, write to the Free Software
16
Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
22
#ifdef HAVE_LIBNCURSES
24
N_SCROLLWIN *newscrollwin(int lines, int cols, int y, int x, char *title, int maxlines)
28
win = calloc(1, sizeof(N_SCROLLWIN));
30
win->win = newpad(maxlines, cols - 2);
31
win->out = newwin(lines, cols, y, x);
32
win->y_max = maxlines;
37
win->title = strdup(title);
39
scrollok(win->win, TRUE);
41
/* move the cursor to the right starting point */
43
win->y_scroll = maxlines - (lines-2);
44
wmove(win->win, win->y_scroll - 1, 0);
46
/* draw the outer window */
48
wattrset(win->out, COLOR_PAIR(3));
50
wborder(win->out, ACS_VLINE, ACS_VLINE, ACS_HLINE, ACS_HLINE,
51
ACS_ULCORNER, ACS_URCORNER,
52
ACS_LLCORNER, ACS_LRCORNER);
54
wmove(win->out, 0, 2);
55
wattrset(win->out, COLOR_PAIR(2));
56
waddstr(win->out, " ");
57
waddstr(win->out, title);
58
waddstr(win->out, " ");
59
wattrset(win->out, COLOR_PAIR(3));
66
/* redraw the window with or without focus */
68
void redrawscrollwin(N_SCROLLWIN *win, int focus)
72
wattron(win->out, A_BOLD);
75
wmove(win->out, 0, 0);
77
wattron(win->out, COLOR_PAIR(3));
79
wborder(win->out, ACS_VLINE, ACS_VLINE, ACS_HLINE, ACS_HLINE,
80
ACS_ULCORNER, ACS_URCORNER,
81
ACS_LLCORNER, ACS_LRCORNER);
85
wmove(win->out, 0, 0);
86
wattron(win->out, COLOR_PAIR(4));
87
waddch(win->out, ACS_LARROW);
88
waddch(win->out, ACS_RARROW);
89
wattroff(win->out, COLOR_PAIR(4));
92
wattron(win->out, COLOR_PAIR(2));
93
wmove(win->out, 0, 2);
94
waddstr(win->out, " ");
95
waddstr(win->out, win->title);
96
waddstr(win->out, " ");
97
wattroff(win->out, COLOR_PAIR(2));
102
wattroff(win->out, A_BOLD);
106
SAFE_SCROLL_REFRESH(win);
109
/* display the scroll indicator on the right */
111
void drawscroller(N_SCROLLWIN *win)
113
short height = (win->lines-2) * (win->lines-2) / win->y_max;
114
short vpos = win->lines * win->y_scroll / win->y_max;
116
wattron(win->out, COLOR_PAIR(2));
117
wattroff(win->out, A_BOLD);
119
height = (height < 1) ? 1 : height;
121
vpos = (vpos == 0) ? 1 : vpos;
122
vpos = (vpos > (win->lines-1) - height) ? (win->lines-1) - height : vpos;
124
wmove(win->out, 1, win->x + win->cols - 1);
125
wvline(win->out, ACS_CKBOARD, win->lines - 2);
126
wattron(win->out, A_REVERSE);
127
wmove(win->out, vpos, win->x + win->cols - 1);
128
wvline(win->out, ' ', height);
129
wattroff(win->out, A_REVERSE);
131
wnoutrefresh(win->out);
134
/* scroll a window for delta lines */
136
void winscroll(N_SCROLLWIN *win, int delta)
138
win->y_scroll += delta;
139
win->y_scroll = (win->y_scroll < 0) ? 0 : win->y_scroll;
140
win->y_scroll = (win->y_scroll > win->y_max - (win->lines-2) )
141
? win->y_max - (win->lines-2)
146
SAFE_SCROLL_REFRESH(win);
149
void delscrollwin(N_SCROLLWIN **win)
153
SAFE_WREFRESH((*win)->win);
155
SAFE_WREFRESH((*win)->out);
158
SAFE_FREE((*win)->title);