Add support for copying to clipboard (based on patch by Dana Jansens).
[dana/urxvt.git] / src / scrollbar-xterm.C
1 /*----------------------------------------------------------------------*
2  * File:        scrollbar-xterm.C
3  *----------------------------------------------------------------------*
4  *
5  * Copyright (c) 1997,1998 mj olesen <olesen@me.QueensU.CA>
6  * Copyright (c) 1999-2001 Geoff Wing <gcw@pobox.com>
7  * Copyright (c) 2004-2006 Marc Lehmann <pcg@goof.com>
8  *
9  * This program is free software; you can redistribute it and/or modify
10  * it under the terms of the GNU General Public License as published by
11  * the Free Software Foundation; either version 2 of the License, or
12  * (at your option) any later version.
13  *
14  * This program is distributed in the hope that it will be useful,
15  * but WITHOUT ANY WARRANTY; without even the implied warranty of
16  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
17  * GNU General Public License for more details.
18  *
19  * You should have received a copy of the GNU General Public License
20  * along with this program; if not, write to the Free Software
21  * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
22  *----------------------------------------------------------------------*/
23
24 #include "../config.h"          /* NECESSARY */
25 #include "rxvt.h"               /* NECESSARY */
26
27 /*----------------------------------------------------------------------*/
28 #if defined(XTERM_SCROLLBAR)
29
30 #define x_stp_width     8
31 #define x_stp_height    2
32 const unsigned char x_stp_bits[] = { 0xaa, 0x55 };
33
34 int
35 scrollBar_t::show_xterm (int update)
36 {
37   int xsb = 0;
38   int sbwidth = width - 1;
39
40   if ((init & R_SB_XTERM) == 0)
41     {
42       XGCValues       gcvalue;
43
44       init |= R_SB_XTERM;
45       gcvalue.stipple = XCreateBitmapFromData (term->dpy, win,
46                                                (char *)x_stp_bits, x_stp_width,
47                                                x_stp_height);
48       if (!gcvalue.stipple)
49         rxvt_fatal ("can't create bitmap\n");
50
51       gcvalue.fill_style = FillOpaqueStippled;
52       gcvalue.foreground = term->pix_colors_focused[Color_scroll];
53       gcvalue.background = term->pix_colors_focused[Color_bg];
54
55       xscrollbarGC = XCreateGC (term->dpy, win,
56                                 GCForeground | GCBackground
57                                 | GCFillStyle | GCStipple, &gcvalue);
58       gcvalue.foreground = term->pix_colors_focused[Color_border];
59       ShadowGC = XCreateGC (term->dpy, win, GCForeground, &gcvalue);
60     }
61
62   xsb = term->option (Opt_scrollBar_right) ? 1 : 0;
63
64   if (update)
65     {
66       if (last_top < top)
67         XClearArea (term->dpy, win,
68                     xsb, last_top,
69                     sbwidth, (top - last_top), False);
70
71       if (bot < last_bot)
72         XClearArea (term->dpy, win,
73                     xsb, bot,
74                     sbwidth, (last_bot - bot), False);
75     }
76   else
77     XClearWindow (term->dpy, win);
78
79   /* scrollbar slider */
80   XFillRectangle (term->dpy, win, xscrollbarGC,
81                   xsb + 1, top, sbwidth - 2, bot - top);
82
83   XDrawLine (term->dpy, win, ShadowGC,
84              xsb ? 0 : sbwidth, beg,
85              xsb ? 0 : sbwidth, end);
86   return 1;
87 }
88 #endif /* XTERM_SCROLLBAR */
89 /*----------------------- end-of-file (C source) -----------------------*/