~kklimonda/ubuntu/lucid/rxvt-unicode/lp-514821

« back to all changes in this revision

Viewing changes to src/rxvtlib.h

  • Committer: Bazaar Package Importer
  • Author(s): Decklin Foster
  • Date: 2006-09-01 14:44:58 UTC
  • mfrom: (1.1.8 upstream) (3.1.1 etch)
  • Revision ID: james.westby@ubuntu.com-20060901144458-98hrz8zg01w8a3vy
Tags: 7.9-2
* Edit the comments in the app-defaults file, and disable all settings by
  default. If font autoselection fails, I would prefer to open a new bug
  specifically for that. (Closes: #385481)
* Reorganize and edit README.Debian, pushing as much as possible into FAQ
  format (with resource setting issues first).

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
#ifndef _RXVTLIB_H_             /* include once only */
2
 
#define _RXVTLIB_H_
3
 
 
4
 
#include <cstdio>
5
 
#include <cctype>
6
 
#include <cerrno>
7
 
#include <cstdarg>
8
 
#include <cstdlib>
9
 
#include <stdint.h>
10
 
#include <sys/types.h>
11
 
#include <unistd.h>
12
 
#include <cstring>
13
 
#include <fcntl.h>
14
 
/* #include <util.h> */
15
 
#include <assert.h>
16
 
#include <sys/ioctl.h>
17
 
#include <sys/time.h>
18
 
#include <time.h>
19
 
#include <sys/select.h>
20
 
/* #include <sys/strredir.h> */
21
 
 
22
 
#include <sys/wait.h>
23
 
#include <sys/stat.h>
24
 
 
25
 
#if HAVE_CWCHAR
26
 
# include <cwchar>
27
 
#elif HAVE_WCHAR_H
28
 
# include <wchar.h>
29
 
#else
30
 
// stdlib.h might provide it
31
 
#endif
32
 
 
33
 
extern "C" {
34
 
#include <X11/Xlib.h>
35
 
#include <X11/Xutil.h>
36
 
#include <X11/Xresource.h>
37
 
}
38
 
 
39
 
/*
40
 
 * If we haven't pulled in typedef's like  int16_t  then do them ourself
41
 
 * type of (normal and unsigned) basic sizes
42
 
 */
43
 
/* typedef short int16_t; */
44
 
/* typedef unsigned short uint16_t; */
45
 
/* typedef int int32_t; */
46
 
/* typedef unsigned int uint32_t; */
47
 
 
48
 
/* whatever normal size corresponds to a integer pointer */
49
 
#define intp_t int64_t
50
 
/* whatever normal size corresponds to a unsigned integer pointer */
51
 
#define u_intp_t u_int64_t
52
 
 
53
 
struct rxvt_fontset;
54
 
struct rxvt_color;
55
 
struct rxvt_vars;               /* defined later on */
56
 
struct rxvt_term;
57
 
struct rxvt_im;
58
 
struct rxvt_drawable;
59
 
 
60
 
typedef struct rxvt_term *rxvt_t;
61
 
 
62
 
extern rxvt_t rxvt_current_term;
63
 
 
64
 
#define SET_R(r) rxvt_current_term = const_cast<rxvt_term *>(r)
65
 
#define GET_R rxvt_current_term
66
 
 
67
 
typedef struct {
68
 
  int row;
69
 
  int col;
70
 
} row_col_t;
71
 
 
72
 
#if UNICODE_3
73
 
typedef uint32_t text_t;
74
 
#else
75
 
typedef uint16_t text_t; // saves lots of memory
76
 
#endif
77
 
typedef uint32_t rend_t;
78
 
typedef  int32_t tlen_t;  // was int16_t, but this results in smaller code and memory use
79
 
typedef  int32_t tlen_t_; // specifically for use in the line_t structure
80
 
 
81
 
struct line_t;
82
 
 
83
 
/*
84
 
 * terminal limits:
85
 
 *
86
 
 *  width      : 1 <= width
87
 
 *  height     : 1 <= height
88
 
 *  ncol       : 1 <= ncol       <= MAX(tlen_t)
89
 
 *  nrow       : 1 <= nrow       <= MAX(int)
90
 
 *  saveLines  : 0 <= saveLines  <= MAX(int)
91
 
 *  term_start : 0 <= term_start < saveLines
92
 
 *  total_rows : nrow + saveLines
93
 
 *
94
 
 *  top_row    : -saveLines <= top_row    <= 0
95
 
 *  view_start : top_row    <= view_start <= 0
96
 
 *
97
 
 *          | most coordinates are stored relative to term_start,
98
 
 *  ROW_BUF | which is the first line of the terminal screen
99
 
 *  |························= row_buf[0]
100
 
 *  |························= row_buf[1]
101
 
 *  |························= row_buf[2] etc.
102
 
 *  |
103
 
 *  +------------+···········= term_start + top_row
104
 
 *  | scrollback |                                      
105
 
 *  | scrollback +---------+·= term_start + view_start
106
 
 *  | scrollback | display |
107
 
 *  | scrollback | display |
108
 
 *  +------------+·display·+·= term_start
109
 
 *  |  terminal  | display |
110
 
 *  |  terminal  +---------+
111
 
 *  |  terminal  |
112
 
 *  |  terminal  |
113
 
 *  +------------+···········= term_stat + nrow - 1
114
 
 *  |
115
 
 *  |
116
 
 *  END······················= total_rows
117
 
 */
118
 
 
119
 
struct TermWin_t {
120
 
  int            width;         /* window width                    [pixels] */
121
 
  int            height;        /* window height                   [pixels] */
122
 
  int            fwidth;        /* font width                      [pixels] */
123
 
  int            fheight;       /* font height                     [pixels] */
124
 
  int            fbase;         /* font ascent (baseline)          [pixels] */
125
 
  int            ncol;          /* window columns              [characters] */
126
 
  int            nrow;          /* window rows                 [characters] */
127
 
  int            focus;         /* window has focus                         */
128
 
  int            mapped;        /* window state mapped?                     */
129
 
  int            int_bwidth;    /* internal border width                    */
130
 
  int            ext_bwidth;    /* external border width                    */
131
 
  int            lineSpace;     /* number of extra pixels between rows      */
132
 
  int            saveLines;     /* number of lines that fit in scrollback   */
133
 
  int            total_rows;    /* total number of rows in this terminal    */
134
 
  int            term_start;    /* term lines start here                    */
135
 
  int            view_start;    /* scrollback view starts here              */
136
 
  int            top_row;       /* topmost row index of scrollback          */
137
 
  Window         parent[6];     /* parent identifiers - we're parent[0]     */
138
 
  Window         vt;            /* vt100 window                             */
139
 
  GC             gc;            /* GC for drawing                           */
140
 
  Pixmap         pixmap;
141
 
  rxvt_drawable *drawable;
142
 
  rxvt_fontset  *fontset[4];
143
 
};
144
 
 
145
 
/*
146
 
 * screen accounting:
147
 
 * screen_t elements
148
 
 *   row:       Cursor row position                   : 0 <= row < nrow
149
 
 *   col:       Cursor column position                : 0 <= col < ncol
150
 
 *   tscroll:   Scrolling region top row inclusive    : 0 <= row < nrow
151
 
 *   bscroll:   Scrolling region bottom row inclusive : 0 <= row < nrow
152
 
 *
153
 
 * selection_t elements
154
 
 *   clicks:    1, 2 or 3 clicks - 4 indicates a special condition of 1 where
155
 
 *              nothing is selected
156
 
 *   beg:       row/column of beginning of selection  : never past mark
157
 
 *   mark:      row/column of initial click           : never past end
158
 
 *   end:       row/column of one character past end of selection
159
 
 * * Note: -nsaved <= beg.row <= mark.row <= end.row < nrow
160
 
 * * Note: col == -1 ==> we're left of screen
161
 
 *
162
 
 */
163
 
typedef struct {
164
 
  row_col_t       cur;          /* cursor position on the screen             */
165
 
  int             tscroll;      /* top of settable scroll region             */
166
 
  int             bscroll;      /* bottom of settable scroll region          */
167
 
  unsigned int    charset;      /* character set number [0..3]               */
168
 
  unsigned int    flags;        /* see below                                 */
169
 
  row_col_t       s_cur;        /* saved cursor position                     */
170
 
  unsigned int    s_charset;    /* saved character set number [0..3]         */
171
 
  char            s_charset_char;
172
 
  rend_t          s_rstyle;     /* saved rendition style                     */
173
 
} screen_t;
174
 
 
175
 
enum selection_op_t {
176
 
  SELECTION_CLEAR = 0,  /* nothing selected                          */
177
 
  SELECTION_INIT,       /* marked a point                            */
178
 
  SELECTION_BEGIN,      /* started a selection                       */
179
 
  SELECTION_CONT,       /* continued selection                       */
180
 
  SELECTION_DONE        /* selection put in CUT_BUFFER0              */
181
 
};
182
 
 
183
 
typedef struct {
184
 
  wchar_t          *text;       /* selected text                             */
185
 
  unsigned int      len;        /* length of selected text                   */
186
 
  unsigned int      screen;     /* screen being used                         */
187
 
  unsigned int      clicks;     /* number of clicks                          */
188
 
  selection_op_t    op;         /* current operation                         */
189
 
  bool              rect;       /* rectangluar selection?                    */
190
 
  row_col_t         beg;        /* beginning of selection   <= mark          */
191
 
  row_col_t         mark;       /* point of initial click   <= end           */
192
 
  row_col_t         end;        /* one character past end point              */
193
 
} selection_t;
194
 
 
195
 
/* ------------------------------------------------------------------------- */
196
 
 
197
 
/* screen_t flags */
198
 
#define Screen_Relative          (1<<0)  /* relative origin mode flag         */
199
 
#define Screen_VisibleCursor     (1<<1)  /* cursor visible?                   */
200
 
#define Screen_Autowrap          (1<<2)  /* auto-wrap flag                    */
201
 
#define Screen_Insert            (1<<3)  /* insert mode (vs. overstrike)      */
202
 
#define Screen_WrapNext          (1<<4)  /* need to wrap for next char?       */
203
 
#define Screen_DefaultFlags      (Screen_VisibleCursor | Screen_Autowrap)
204
 
 
205
 
/* rxvt_vars.options */
206
 
enum {
207
 
# define def(name,idx) Opt_ ## name = 1UL << (idx),
208
 
# define nodef(name)   Opt_ ## name = 0,
209
 
# include "optinc.h"
210
 
# undef nodef
211
 
# undef def
212
 
};
213
 
 
214
 
/* ------------------------------------------------------------------------- */
215
 
 
216
 
typedef struct {
217
 
  char            state;        /* scrollbar state                          */
218
 
  char            init;         /* scrollbar has been initialised           */
219
 
  unsigned int    beg;          /* slider sub-window begin height           */
220
 
  unsigned int    end;          /* slider sub-window end height             */
221
 
  unsigned int    top;          /* slider top position                      */
222
 
  unsigned int    bot;          /* slider bottom position                   */
223
 
  unsigned int    style;        /* style: rxvt, xterm, next                 */
224
 
  unsigned int    width;        /* scrollbar width                          */
225
 
  Window          win;
226
 
  int             (rxvt_term::*update)(int, int, int, int);
227
 
 
228
 
  void setIdle()   { state =  1 ; }
229
 
  void setMotion() { state = 'm'; }
230
 
  void setUp()     { state = 'U'; }
231
 
  void setDn()     { state = 'D'; }
232
 
} scrollBar_t;
233
 
 
234
 
struct rxvt_vars : TermWin_t {
235
 
  scrollBar_t     scrollBar;
236
 
  uint32_t        options;
237
 
  XSizeHints      szHint;
238
 
  rxvt_color     *pix_colors;
239
 
  rxvt_color     *pix_colors_focused;
240
 
#ifdef OFF_FOCUS_FADING
241
 
  rxvt_color     *pix_colors_unfocused;
242
 
#endif
243
 
  short           numpix_colors;
244
 
  Cursor          TermWin_cursor;       /* cursor for vt window */
245
 
  int             sb_shadow;    /* scrollbar shadow width                    */
246
 
  int             numlock_state;
247
 
  line_t         *row_buf;      // all lines, scrollback + terminal, circular, followed by temp_buf
248
 
  line_t         *drawn_buf;    // text on screen
249
 
  line_t         *swap_buf;     // lines for swap buffer
250
 
  char           *tabs;         /* per location: 1 == tab-stop               */
251
 
  screen_t        screen;
252
 
  screen_t        swap;
253
 
  selection_t     selection;
254
 
};
255
 
 
256
 
void rxvt_init ();
257
 
 
258
 
#endif                          /* _RXVTLIB_H_ */
259