… | |
… | |
77 | typedef uint32_t text_t; |
77 | typedef uint32_t text_t; |
78 | #else |
78 | #else |
79 | typedef uint16_t text_t; // saves lots of memory |
79 | typedef uint16_t text_t; // saves lots of memory |
80 | #endif |
80 | #endif |
81 | typedef uint32_t rend_t; |
81 | typedef uint32_t rend_t; |
|
|
82 | typedef int16_t tlen_t; |
|
|
83 | |
|
|
84 | #define LINE_CONT -1 |
|
|
85 | |
|
|
86 | struct line_t { |
|
|
87 | text_t *t; // terminal the text |
|
|
88 | rend_t *r; // rendition, uses RS_ flags |
|
|
89 | tlen_t l; // length of each text line, LINE_CONT == continued on next line |
|
|
90 | |
|
|
91 | bool is_cont () |
|
|
92 | { |
|
|
93 | return l < 0; |
|
|
94 | } |
|
|
95 | |
|
|
96 | void clear () |
|
|
97 | { |
|
|
98 | t = 0; |
|
|
99 | r = 0; |
|
|
100 | l = 0; |
|
|
101 | } |
|
|
102 | }; |
82 | |
103 | |
83 | /* |
104 | /* |
84 | * TermWin elements limits |
105 | * TermWin elements limits |
85 | * width : 1 <= width |
106 | * width : 1 <= width |
86 | * height : 1 <= height |
107 | * height : 1 <= height |
87 | * ncol : 1 <= ncol <= MAX(int16_t) |
108 | * ncol : 1 <= ncol <= MAX(int16_t) |
88 | * nrow : 1 <= nrow <= MAX(int16_t) |
109 | * nrow : 1 <= nrow <= MAX(int16_t) |
89 | * saveLines : 0 <= saveLines <= MAX(int16_t) |
110 | * saveLines : 0 <= saveLines <= MAX(int16_t) |
90 | * nscrolled : 0 <= nscrolled <= saveLines |
111 | * nsaved : 0 <= nscrolled <= saveLines |
|
|
112 | * term_start: 0 <= term_start < saveLines |
91 | * view_start: 0 <= view_start <= nscrolled |
113 | * view_start: 0 <= view_start < saveLines |
92 | */ |
114 | */ |
93 | |
115 | |
94 | typedef struct { |
116 | struct TermWin_t { |
95 | int width; /* window width [pixels] */ |
117 | int width; /* window width [pixels] */ |
96 | int height; /* window height [pixels] */ |
118 | int height; /* window height [pixels] */ |
97 | int fwidth; /* font width [pixels] */ |
119 | int fwidth; /* font width [pixels] */ |
98 | int fheight; /* font height [pixels] */ |
120 | int fheight; /* font height [pixels] */ |
99 | int fweight, fslant; |
121 | int fweight, fslant; |
… | |
… | |
104 | int mapped; /* window state mapped? */ |
126 | int mapped; /* window state mapped? */ |
105 | int int_bwidth; /* internal border width */ |
127 | int int_bwidth; /* internal border width */ |
106 | int ext_bwidth; /* external border width */ |
128 | int ext_bwidth; /* external border width */ |
107 | int lineSpace; /* number of extra pixels between rows */ |
129 | int lineSpace; /* number of extra pixels between rows */ |
108 | int saveLines; /* number of lines that fit in scrollback */ |
130 | int saveLines; /* number of lines that fit in scrollback */ |
109 | int nscrolled; /* number of line actually scrolled */ |
131 | int nsaved; /* number of line actually scrolled */ |
|
|
132 | int nscrolled; /*D*///TODO remove |
|
|
133 | int term_start; /* term lines start here */ |
110 | int view_start; /* scrollback view starts here */ |
134 | int view_start; /* scrollback view starts here */ |
111 | Window parent[6]; /* parent identifiers - we're parent[0] */ |
135 | Window parent[6]; /* parent identifiers - we're parent[0] */ |
112 | Window vt; /* vt100 window */ |
136 | Window vt; /* vt100 window */ |
113 | GC gc; /* GC for drawing */ |
137 | GC gc; /* GC for drawing */ |
114 | Pixmap pixmap; |
138 | Pixmap pixmap; |
115 | rxvt_drawable *drawable; |
139 | rxvt_drawable *drawable; |
116 | rxvt_fontset *fontset[4]; |
140 | rxvt_fontset *fontset[4]; |
117 | } TermWin_t; |
141 | }; |
118 | |
142 | |
119 | /* |
143 | /* |
120 | * screen accounting: |
144 | * screen accounting: |
121 | * screen_t elements |
145 | * screen_t elements |
122 | * text: Contains all text information including the scrollback buffer. |
146 | * text: Contains all text information including the scrollback buffer. |
123 | * Each line is length TermWin.ncol |
147 | * Each line is length ncol |
124 | * tlen: The length of the line or -1 for wrapped lines. |
148 | * tlen: The length of the line or -1 for wrapped lines. |
125 | * rend: Contains rendition information: font, bold, colour, etc. |
149 | * rend: Contains rendition information: font, bold, colour, etc. |
126 | * * Note: Each line for both text and rend are only allocated on demand, and |
150 | * * Note: Each line for both text and rend are only allocated on demand, and |
127 | * text[x] is allocated <=> rend[x] is allocated for all x. |
151 | * text[x] is allocated <=> rend[x] is allocated for all x. |
128 | * row: Cursor row position : 0 <= row < TermWin.nrow |
152 | * row: Cursor row position : 0 <= row < nrow |
129 | * col: Cursor column position : 0 <= col < TermWin.ncol |
153 | * col: Cursor column position : 0 <= col < ncol |
130 | * tscroll: Scrolling region top row inclusive : 0 <= row < TermWin.nrow |
154 | * tscroll: Scrolling region top row inclusive : 0 <= row < nrow |
131 | * bscroll: Scrolling region bottom row inclusive : 0 <= row < TermWin.nrow |
155 | * bscroll: Scrolling region bottom row inclusive : 0 <= row < nrow |
132 | * |
156 | * |
133 | * selection_t elements |
157 | * selection_t elements |
134 | * clicks: 1, 2 or 3 clicks - 4 indicates a special condition of 1 where |
158 | * clicks: 1, 2 or 3 clicks - 4 indicates a special condition of 1 where |
135 | * nothing is selected |
159 | * nothing is selected |
136 | * beg: row/column of beginning of selection : never past mark |
160 | * beg: row/column of beginning of selection : never past mark |
137 | * mark: row/column of initial click : never past end |
161 | * mark: row/column of initial click : never past end |
138 | * end: row/column of one character past end of selection |
162 | * end: row/column of one character past end of selection |
139 | * * Note: -TermWin.nscrolled <= beg.row <= mark.row <= end.row < TermWin.nrow |
163 | * * Note: -nscrolled <= beg.row <= mark.row <= end.row < nrow |
140 | * * Note: col == -1 ==> we're left of screen |
164 | * * Note: col == -1 ==> we're left of screen |
141 | * |
165 | * |
142 | * Layout of text/rend information in the screen_t text/rend structures: |
166 | * Layout of text/rend information in the screen_t text/rend structures: |
143 | * Rows [0] ... [TermWin.saveLines - 1] |
167 | * Rows [0] ... [saveLines - 1] |
144 | * scrollback region : we're only here if TermWin.view_start != 0 |
168 | * scrollback region : we're only here if view_start != 0 |
145 | * Rows [TermWin.saveLines] ... [TermWin.saveLines + TermWin.nrow - 1] |
169 | * Rows [saveLines] ... [saveLines + nrow - 1] |
146 | * normal `unscrolled' screen region |
170 | * normal `unscrolled' screen region |
147 | */ |
171 | */ |
148 | typedef struct { |
172 | typedef struct { |
149 | int16_t *tlen; /* length of each text line */ |
173 | line_t **line; |
150 | text_t **text; /* _all_ the text */ |
174 | |
151 | rend_t **rend; /* rendition, uses RS_ flags */ |
|
|
152 | row_col_t cur; /* cursor position on the screen */ |
175 | row_col_t cur; /* cursor position on the screen */ |
153 | unsigned int tscroll; /* top of settable scroll region */ |
176 | unsigned int tscroll; /* top of settable scroll region */ |
154 | unsigned int bscroll; /* bottom of settable scroll region */ |
177 | unsigned int bscroll; /* bottom of settable scroll region */ |
155 | unsigned int charset; /* character set number [0..3] */ |
178 | unsigned int charset; /* character set number [0..3] */ |
156 | unsigned int flags; /* see below */ |
179 | unsigned int flags; /* see below */ |
… | |
… | |
254 | void setMotion() { state = 'm'; } |
277 | void setMotion() { state = 'm'; } |
255 | void setUp() { state = 'U'; } |
278 | void setUp() { state = 'U'; } |
256 | void setDn() { state = 'D'; } |
279 | void setDn() { state = 'D'; } |
257 | } scrollBar_t; |
280 | } scrollBar_t; |
258 | |
281 | |
259 | struct rxvt_vars { |
282 | struct rxvt_vars : TermWin_t { |
260 | TermWin_t TermWin; |
|
|
261 | scrollBar_t scrollBar; |
283 | scrollBar_t scrollBar; |
262 | menuBar_t menuBar; |
284 | menuBar_t menuBar; |
263 | unsigned long options; |
285 | unsigned long options; |
264 | XSizeHints szHint; |
286 | XSizeHints szHint; |
265 | rxvt_display *display; |
287 | rxvt_display *display; |
… | |
… | |
271 | short numpix_colors; |
293 | short numpix_colors; |
272 | Cursor TermWin_cursor; /* cursor for vt window */ |
294 | Cursor TermWin_cursor; /* cursor for vt window */ |
273 | int sb_shadow; /* scrollbar shadow width */ |
295 | int sb_shadow; /* scrollbar shadow width */ |
274 | rxvt_ptytty pty; |
296 | rxvt_ptytty pty; |
275 | int numlock_state; |
297 | int numlock_state; |
276 | text_t **drawn_text; /* text drawn on screen (characters) */ |
298 | line_t *save; // all lines, scorllback + terminal, circular |
277 | rend_t **drawn_rend; /* text drawn on screen (rendition) */ |
299 | line_t *drawn; // text on screen |
278 | text_t **buf_text; |
300 | line_t *buf; // temporary buffer |
279 | rend_t **buf_rend; |
301 | line_t *swap_save; // lines for swap buffer |
280 | char *tabs; /* per location: 1 == tab-stop */ |
302 | char *tabs; /* per location: 1 == tab-stop */ |
281 | screen_t screen; |
303 | screen_t screen; |
282 | screen_t swap; |
304 | screen_t swap; |
283 | selection_t selection; |
305 | selection_t selection; |
284 | }; |
306 | }; |