1 | /*--------------------------------*-C-*--------------------------------------* |
1 | /*--------------------------------*-C-*--------------------------------------* |
2 | * File: screen.c |
2 | * File: screen.c |
3 | *---------------------------------------------------------------------------* |
3 | *---------------------------------------------------------------------------* |
4 | * $Id: screen.C,v 1.7 2003/12/16 23:04:13 pcg Exp $ |
|
|
5 | * |
4 | * |
6 | * Copyright (c) 1997-2001 Geoff Wing <gcw@pobox.com> |
5 | * Copyright (c) 1997-2001 Geoff Wing <gcw@pobox.com> |
7 | * |
6 | * |
8 | * This program is free software; you can redistribute it and/or modify |
7 | * This program is free software; you can redistribute it and/or modify |
9 | * it under the terms of the GNU General Public License as published by |
8 | * it under the terms of the GNU General Public License as published by |
… | |
… | |
31 | #include <X11/Xmd.h> /* get the typedef for CARD32 */ |
30 | #include <X11/Xmd.h> /* get the typedef for CARD32 */ |
32 | |
31 | |
33 | #include <stdint.h> |
32 | #include <stdint.h> |
34 | #include <wchar.h> |
33 | #include <wchar.h> |
35 | |
34 | |
|
|
35 | #include "salloc.C" // HACK!! |
|
|
36 | |
36 | inline void fill_text (text_t *start, text_t value, int len) |
37 | inline void fill_text (text_t *start, text_t value, int len) |
37 | { |
38 | { |
38 | while (len--) |
39 | while (len--) |
39 | *start++ = value; |
40 | *start++ = value; |
40 | } |
41 | } |
… | |
… | |
87 | /* |
88 | /* |
88 | * CLEAR_ROWS : clear <num> rows starting from row <row> |
89 | * CLEAR_ROWS : clear <num> rows starting from row <row> |
89 | * CLEAR_CHARS: clear <num> chars starting from pixel position <x,y> |
90 | * CLEAR_CHARS: clear <num> chars starting from pixel position <x,y> |
90 | * ERASE_ROWS : set <num> rows starting from row <row> to the foreground colour |
91 | * ERASE_ROWS : set <num> rows starting from row <row> to the foreground colour |
91 | */ |
92 | */ |
92 | #define drawBuffer (R->TermWin.vt) |
93 | #define drawBuffer TermWin.vt |
93 | |
94 | |
94 | #define CLEAR_ROWS(row, num) \ |
95 | #define CLEAR_ROWS(row, num) \ |
95 | if (R->TermWin.mapped) \ |
96 | if (TermWin.mapped) \ |
96 | XClearArea(R->Xdisplay, drawBuffer, R->TermWin.int_bwidth, \ |
97 | XClearArea (Xdisplay, drawBuffer, TermWin.int_bwidth, \ |
97 | Row2Pixel(row), (unsigned int)R->TermWin.width, \ |
98 | Row2Pixel(row), (unsigned int)TermWin.width, \ |
98 | (unsigned int)Height2Pixel(num), False) |
99 | (unsigned int)Height2Pixel(num), False) |
99 | |
100 | |
100 | #define CLEAR_CHARS(x, y, num) \ |
101 | #define CLEAR_CHARS(x, y, num) \ |
101 | if (R->TermWin.mapped) \ |
102 | if (TermWin.mapped) \ |
102 | XClearArea(R->Xdisplay, drawBuffer, x, y, \ |
103 | XClearArea (Xdisplay, drawBuffer, x, y, \ |
103 | (unsigned int)Width2Pixel(num), \ |
104 | (unsigned int)Width2Pixel(num), \ |
104 | (unsigned int)Height2Pixel(1), False) |
105 | (unsigned int)Height2Pixel(1), False) |
105 | |
106 | |
106 | #define ERASE_ROWS(row, num) \ |
107 | #define ERASE_ROWS(row, num) \ |
107 | XFillRectangle(R->Xdisplay, drawBuffer, R->TermWin.gc, \ |
108 | XFillRectangle (Xdisplay, drawBuffer, TermWin.gc, \ |
108 | R->TermWin.int_bwidth, Row2Pixel(row), \ |
109 | TermWin.int_bwidth, Row2Pixel(row), \ |
109 | (unsigned int)R->TermWin.width, \ |
110 | (unsigned int)TermWin.width, \ |
110 | (unsigned int)Height2Pixel(num)) |
111 | (unsigned int)Height2Pixel(num)) |
111 | |
112 | |
112 | /* ------------------------------------------------------------------------- * |
113 | /* ------------------------------------------------------------------------- * |
113 | * SCREEN `COMMON' ROUTINES * |
114 | * SCREEN `COMMON' ROUTINES * |
114 | * ------------------------------------------------------------------------- */ |
115 | * ------------------------------------------------------------------------- */ |
115 | /* Fill part/all of a line with blanks. */ |
116 | /* Fill part/all of a line with blanks. */ |
116 | /* INTPROTO */ |
|
|
117 | void |
117 | void |
118 | rxvt_blank_line(pR_ text_t *et, rend_t *er, unsigned int width, rend_t efs) |
118 | rxvt_term::scr_blank_line (text_t *et, rend_t *er, unsigned int width, rend_t efs) |
119 | { |
119 | { |
120 | efs &= ~RS_baseattrMask; |
120 | efs &= ~RS_baseattrMask; |
121 | efs = SET_FONT (efs, R->TermWin.fontset->find_font (' ')); |
121 | efs = SET_FONT (efs, TermWin.fontset->find_font (' ')); |
122 | |
122 | |
123 | while (width--) |
123 | while (width--) |
124 | { |
124 | { |
125 | *et++ = ' '; |
125 | *et++ = ' '; |
126 | *er++ = efs; |
126 | *er++ = efs; |
127 | } |
127 | } |
128 | } |
128 | } |
129 | |
129 | |
130 | /* ------------------------------------------------------------------------- */ |
130 | /* ------------------------------------------------------------------------- */ |
131 | /* Fill a full line with blanks - make sure it is allocated first */ |
131 | /* Fill a full line with blanks - make sure it is allocated first */ |
132 | /* INTPROTO */ |
|
|
133 | void |
132 | void |
134 | rxvt_blank_screen_mem(pR_ text_t **tp, rend_t **rp, unsigned int row, rend_t efs) |
133 | rxvt_term::scr_blank_screen_mem (text_t **tp, rend_t **rp, unsigned int row, rend_t efs) |
135 | { |
134 | { |
136 | int width = R->TermWin.ncol; |
|
|
137 | rend_t *er; |
|
|
138 | |
|
|
139 | #ifdef DEBUG_STRICT |
135 | #ifdef DEBUG_STRICT |
140 | assert((tp[row] && rp[row]) || (tp[row] == NULL && rp[row] == NULL)); |
136 | assert((tp[row] && rp[row]) || (tp[row] == NULL && rp[row] == NULL)); |
141 | #endif |
137 | #endif |
142 | if (tp[row] == NULL) { |
138 | if (tp[row] == NULL) |
143 | tp[row] = (text_t *)rxvt_malloc(sizeof(text_t) * width); |
|
|
144 | rp[row] = (rend_t *)rxvt_malloc(sizeof(rend_t) * width); |
|
|
145 | } |
139 | { |
|
|
140 | tp[row] = (text_t *)talloc->alloc (); |
|
|
141 | rp[row] = (rend_t *)ralloc->alloc (); |
|
|
142 | } |
|
|
143 | |
146 | rxvt_blank_line (aR_ tp[row], rp[row], width, efs); |
144 | scr_blank_line (tp[row], rp[row], TermWin.ncol, efs); |
147 | } |
145 | } |
148 | |
146 | |
149 | /* ------------------------------------------------------------------------- * |
147 | /* ------------------------------------------------------------------------- * |
150 | * SCREEN INITIALISATION * |
148 | * SCREEN INITIALISATION * |
151 | * ------------------------------------------------------------------------- */ |
149 | * ------------------------------------------------------------------------- */ |
152 | /* EXTPROTO */ |
|
|
153 | void |
150 | void |
154 | rxvt_scr_reset(pR) |
151 | rxvt_term::scr_reset () |
155 | { |
152 | { |
156 | unsigned int ncol, nrow, prev_ncol, prev_nrow, |
153 | unsigned int ncol, nrow, total_rows, prev_total_rows; |
157 | total_rows, prev_total_rows; |
|
|
158 | unsigned int p, q; |
154 | unsigned int p, q; |
159 | int k; |
155 | int k; |
160 | rend_t setrstyle; |
156 | rend_t setrstyle; |
161 | |
157 | |
162 | D_SCREEN((stderr, "rxvt_scr_reset()")); |
158 | D_SCREEN((stderr, "rxvt_scr_reset()")); |
163 | |
159 | |
164 | R->TermWin.view_start = 0; |
160 | TermWin.view_start = 0; |
165 | R->num_scr = 0; |
161 | num_scr = 0; |
166 | |
162 | |
167 | prev_ncol = R->prev_ncol; |
|
|
168 | prev_nrow = R->prev_nrow; |
|
|
169 | if (R->TermWin.ncol == 0) |
163 | if (TermWin.ncol == 0) |
170 | R->TermWin.ncol = 80; |
164 | TermWin.ncol = 80; |
|
|
165 | |
171 | if (R->TermWin.nrow == 0) |
166 | if (TermWin.nrow == 0) |
172 | R->TermWin.nrow = 24; |
167 | TermWin.nrow = 24; |
|
|
168 | |
173 | ncol = R->TermWin.ncol; |
169 | ncol = TermWin.ncol; |
174 | nrow = R->TermWin.nrow; |
170 | nrow = TermWin.nrow; |
|
|
171 | |
175 | if (ncol == prev_ncol && nrow == prev_nrow) |
172 | if (ncol == prev_ncol && nrow == prev_nrow) |
176 | return; |
173 | return; |
177 | |
174 | |
178 | R->want_refresh = 1; |
175 | want_refresh = 1; |
179 | |
176 | |
180 | total_rows = nrow + R->TermWin.saveLines; |
177 | total_rows = nrow + TermWin.saveLines; |
181 | prev_total_rows = prev_nrow + R->TermWin.saveLines; |
178 | prev_total_rows = prev_nrow + TermWin.saveLines; |
182 | |
179 | |
183 | R->screen.tscroll = 0; |
180 | screen.tscroll = 0; |
184 | R->screen.bscroll = nrow - 1; |
181 | screen.bscroll = nrow - 1; |
185 | |
182 | |
|
|
183 | if (!talloc) |
|
|
184 | { |
|
|
185 | talloc = new rxvt_salloc (ncol * sizeof (text_t)); |
|
|
186 | ralloc = new rxvt_salloc (ncol * sizeof (rend_t)); |
|
|
187 | } |
|
|
188 | |
186 | if (prev_nrow == 0) { |
189 | if (prev_nrow == 0) |
187 | /* |
190 | { |
|
|
191 | /* |
188 | * A: first time called so just malloc everything : don't rely on realloc |
192 | * first time called so just malloc everything : don't rely on realloc |
189 | * Note: this is still needed so that all the scrollback lines are NULL |
193 | * Note: this is still needed so that all the scrollback lines are NULL |
190 | */ |
194 | */ |
191 | R->screen.text = (text_t **)rxvt_calloc(total_rows, sizeof(text_t *)); |
195 | screen.text = (text_t **)rxvt_calloc(total_rows, sizeof(text_t *)); |
192 | R->buf_text = (text_t **)rxvt_calloc(total_rows, sizeof(text_t *)); |
196 | buf_text = (text_t **)rxvt_calloc(total_rows, sizeof(text_t *)); |
193 | R->drawn_text = (text_t **)rxvt_calloc(nrow, sizeof(text_t *)); |
197 | drawn_text = (text_t **)rxvt_calloc(nrow, sizeof(text_t *)); |
194 | R->swap.text = (text_t **)rxvt_calloc(nrow, sizeof(text_t *)); |
198 | swap.text = (text_t **)rxvt_calloc(nrow, sizeof(text_t *)); |
195 | |
199 | |
196 | R->screen.tlen = (int16_t *)rxvt_calloc(total_rows, sizeof(int16_t)); |
200 | screen.tlen = (int16_t *)rxvt_calloc(total_rows, sizeof(int16_t)); |
197 | R->swap.tlen = (int16_t *)rxvt_calloc(nrow, sizeof(int16_t)); |
201 | swap.tlen = (int16_t *)rxvt_calloc(nrow, sizeof(int16_t)); |
198 | |
202 | |
199 | R->screen.rend = (rend_t **)rxvt_calloc(total_rows, sizeof(rend_t *)); |
203 | screen.rend = (rend_t **)rxvt_calloc(total_rows, sizeof(rend_t *)); |
200 | R->buf_rend = (rend_t **)rxvt_calloc(total_rows, sizeof(rend_t *)); |
204 | buf_rend = (rend_t **)rxvt_calloc(total_rows, sizeof(rend_t *)); |
201 | R->drawn_rend = (rend_t **)rxvt_calloc(nrow, sizeof(rend_t *)); |
205 | drawn_rend = (rend_t **)rxvt_calloc(nrow, sizeof(rend_t *)); |
202 | R->swap.rend = (rend_t **)rxvt_calloc(nrow, sizeof(rend_t *)); |
206 | swap.rend = (rend_t **)rxvt_calloc(nrow, sizeof(rend_t *)); |
203 | |
207 | |
204 | for (p = 0; p < nrow; p++) { |
208 | for (p = 0; p < nrow; p++) |
|
|
209 | { |
205 | q = p + R->TermWin.saveLines; |
210 | q = p + TermWin.saveLines; |
206 | rxvt_blank_screen_mem(aR_ R->screen.text, R->screen.rend, |
211 | scr_blank_screen_mem (screen.text, screen.rend, q, DEFAULT_RSTYLE); |
207 | q, DEFAULT_RSTYLE); |
212 | scr_blank_screen_mem (swap.text, swap.rend, p, DEFAULT_RSTYLE); |
208 | rxvt_blank_screen_mem(aR_ R->swap.text, R->swap.rend, |
|
|
209 | p, DEFAULT_RSTYLE); |
|
|
210 | R->screen.tlen[q] = R->swap.tlen[p] = 0; |
213 | screen.tlen[q] = swap.tlen[p] = 0; |
211 | rxvt_blank_screen_mem(aR_ R->drawn_text, R->drawn_rend, |
214 | scr_blank_screen_mem (drawn_text, drawn_rend, p, DEFAULT_RSTYLE); |
212 | p, DEFAULT_RSTYLE); |
|
|
213 | } |
215 | } |
|
|
216 | |
214 | MEMSET(R->charsets, 'B', sizeof(R->charsets)); |
217 | MEMSET(charsets, 'B', sizeof(charsets)); |
215 | R->TermWin.nscrolled = 0; /* no saved lines */ |
218 | TermWin.nscrolled = 0; /* no saved lines */ |
216 | R->rstyle = DEFAULT_RSTYLE; |
219 | rstyle = DEFAULT_RSTYLE; |
217 | R->screen.flags = Screen_DefaultFlags; |
220 | screen.flags = Screen_DefaultFlags; |
218 | R->screen.cur.row = R->screen.cur.col = 0; |
221 | screen.cur.row = screen.cur.col = 0; |
219 | R->screen.charset = 0; |
222 | screen.charset = 0; |
220 | R->current_screen = PRIMARY; |
223 | current_screen = PRIMARY; |
221 | rxvt_scr_cursor(aR_ SAVE); |
224 | rxvt_scr_cursor (this, SAVE); |
|
|
225 | |
222 | #if NSCREENS |
226 | #if NSCREENS |
223 | R->swap.flags = Screen_DefaultFlags; |
227 | swap.flags = Screen_DefaultFlags; |
224 | R->swap.cur.row = R->swap.cur.col = 0; |
228 | swap.cur.row = swap.cur.col = 0; |
225 | R->swap.charset = 0; |
229 | swap.charset = 0; |
226 | R->current_screen = SECONDARY; |
230 | current_screen = SECONDARY; |
227 | rxvt_scr_cursor(aR_ SAVE); |
231 | rxvt_scr_cursor (this, SAVE); |
228 | R->current_screen = PRIMARY; |
232 | current_screen = PRIMARY; |
229 | #endif |
233 | #endif |
|
|
234 | |
230 | R->selection.text = NULL; |
235 | selection.text = NULL; |
231 | R->selection.len = 0; |
236 | selection.len = 0; |
232 | R->selection.op = SELECTION_CLEAR; |
237 | selection.op = SELECTION_CLEAR; |
233 | R->selection.screen = PRIMARY; |
238 | selection.screen = PRIMARY; |
234 | R->selection.clicks = 0; |
239 | selection.clicks = 0; |
235 | CLEAR_ALL_SELECTION(R); |
240 | CLEAR_ALL_SELECTION (this); |
236 | R->rvideo = 0; |
241 | rvideo = 0; |
237 | |
242 | } |
238 | } else { |
243 | else |
239 | /* |
244 | { |
|
|
245 | /* |
240 | * B1: add or delete rows as appropriate |
246 | * add or delete rows as appropriate |
241 | */ |
247 | */ |
242 | setrstyle = DEFAULT_RSTYLE; |
248 | setrstyle = DEFAULT_RSTYLE; |
243 | |
249 | |
244 | if (nrow < prev_nrow) { |
250 | if (nrow < prev_nrow) |
|
|
251 | { |
245 | /* delete rows */ |
252 | /* delete rows */ |
246 | k = min(R->TermWin.nscrolled, prev_nrow - nrow); |
253 | k = min (TermWin.nscrolled, prev_nrow - nrow); |
247 | rxvt_scroll_text(aR_ 0, (int)prev_nrow - 1, k, 1); |
254 | scr_scroll_text (0, (int)prev_nrow - 1, k, 1); |
|
|
255 | |
248 | for (p = nrow; p < prev_nrow; p++) { |
256 | for (p = nrow; p < prev_nrow; p++) |
|
|
257 | { |
249 | q = p + R->TermWin.saveLines; |
258 | q = p + TermWin.saveLines; |
250 | if (R->screen.text[q]) { |
259 | if (screen.text[q]) |
|
|
260 | { |
251 | #ifdef DEBUG_STRICT |
261 | #ifdef DEBUG_STRICT |
252 | assert(R->screen.rend[q]); |
262 | assert (screen.rend[q]); |
253 | #endif |
263 | #endif |
254 | free(R->screen.text[q]); |
264 | talloc->free (screen.text[q]); |
255 | free(R->screen.rend[q]); |
265 | ralloc->free (screen.rend[q]); |
256 | } |
266 | } |
257 | if (R->swap.text[p]) { |
267 | if (swap.text[p]) |
|
|
268 | { |
258 | #ifdef DEBUG_STRICT |
269 | #ifdef DEBUG_STRICT |
259 | assert(R->swap.rend[p]); |
270 | assert (swap.rend[p]); |
260 | #endif |
271 | #endif |
261 | free(R->swap.text[p]); |
272 | talloc->free (swap.text[p]); |
262 | free(R->swap.rend[p]); |
273 | ralloc->free (swap.rend[p]); |
263 | } |
274 | } |
264 | #ifdef DEBUG_STRICT |
275 | #ifdef DEBUG_STRICT |
265 | assert(R->drawn_text[p] && R->drawn_rend[p]); |
276 | assert (drawn_text[p] && drawn_rend[p]); |
266 | #endif |
277 | #endif |
267 | free(R->drawn_text[p]); |
278 | talloc->free (drawn_text[p]); |
268 | free(R->drawn_rend[p]); |
279 | ralloc->free (drawn_rend[p]); |
269 | } |
280 | } |
|
|
281 | |
270 | /* we have fewer rows so fix up cursor position */ |
282 | /* we have fewer rows so fix up cursor position */ |
271 | MIN_IT(R->screen.cur.row, (int32_t)nrow - 1); |
283 | MIN_IT (screen.cur.row, (int32_t)nrow - 1); |
272 | MIN_IT(R->swap.cur.row, (int32_t)nrow - 1); |
284 | MIN_IT (swap.cur.row, (int32_t)nrow - 1); |
273 | |
285 | |
274 | rxvt_scr_reset_realloc(aR); /* realloc _last_ */ |
286 | scr_reset_realloc (); /* realloc _last_ */ |
275 | |
287 | } |
276 | } else if (nrow > prev_nrow) { |
288 | else if (nrow > prev_nrow) |
|
|
289 | { |
277 | /* add rows */ |
290 | /* add rows */ |
278 | rxvt_scr_reset_realloc(aR); /* realloc _first_ */ |
291 | scr_reset_realloc (); /* realloc _first_ */ |
279 | |
292 | |
|
|
293 | TermWin.ncol = prev_ncol; // save b/c scr_blank_screen_mem uses this |
|
|
294 | |
280 | k = min(R->TermWin.nscrolled, nrow - prev_nrow); |
295 | k = min (TermWin.nscrolled, nrow - prev_nrow); |
|
|
296 | |
281 | for (p = prev_total_rows; p < total_rows; p++) { |
297 | for (p = prev_total_rows; p < total_rows; p++) |
|
|
298 | { |
282 | R->screen.tlen[p] = 0; |
299 | screen.tlen[p] = 0; |
283 | R->screen.text[p] = NULL; |
300 | screen.text[p] = NULL; |
284 | R->screen.rend[p] = NULL; |
301 | screen.rend[p] = NULL; |
285 | } |
302 | } |
|
|
303 | |
286 | for (p = prev_total_rows; p < total_rows - k; p++) |
304 | for (p = prev_total_rows; p < total_rows - k; p++) |
287 | rxvt_blank_screen_mem(aR_ R->screen.text, R->screen.rend, |
305 | scr_blank_screen_mem (screen.text, screen.rend, p, setrstyle); |
288 | p, setrstyle); |
306 | |
289 | for (p = prev_nrow; p < nrow; p++) { |
307 | for (p = prev_nrow; p < nrow; p++) |
|
|
308 | { |
290 | R->swap.tlen[p] = 0; |
309 | swap.tlen[p] = 0; |
291 | R->swap.text[p] = NULL; |
310 | swap.text[p] = NULL; |
292 | R->swap.rend[p] = NULL; |
311 | swap.rend[p] = NULL; |
293 | R->drawn_text[p] = NULL; |
312 | drawn_text[p] = NULL; |
294 | R->drawn_rend[p] = NULL; |
313 | drawn_rend[p] = NULL; |
295 | rxvt_blank_screen_mem(aR_ R->swap.text, R->swap.rend, |
314 | scr_blank_screen_mem (swap.text, swap.rend, p, setrstyle); |
296 | p, setrstyle); |
|
|
297 | rxvt_blank_screen_mem(aR_ R->drawn_text, R->drawn_rend, |
315 | scr_blank_screen_mem (drawn_text, drawn_rend, p, setrstyle); |
298 | p, setrstyle); |
|
|
299 | } |
316 | } |
|
|
317 | |
300 | if (k > 0) { |
318 | if (k > 0) |
|
|
319 | { |
301 | rxvt_scroll_text(aR_ 0, (int)nrow - 1, -k, 1); |
320 | scr_scroll_text (0, (int)nrow - 1, -k, 1); |
302 | R->screen.cur.row += k; |
321 | screen.cur.row += k; |
303 | R->screen.s_cur.row += k; |
322 | screen.s_cur.row += k; |
304 | R->TermWin.nscrolled -= k; |
323 | TermWin.nscrolled -= k; |
305 | } |
324 | } |
306 | #ifdef DEBUG_STRICT |
325 | #ifdef DEBUG_STRICT |
307 | assert(R->screen.cur.row < R->TermWin.nrow); |
326 | assert(screen.cur.row < TermWin.nrow); |
308 | assert(R->swap.cur.row < R->TermWin.nrow); |
327 | assert(swap.cur.row < TermWin.nrow); |
309 | #else /* drive with your eyes closed */ |
328 | #else /* drive with your eyes closed */ |
|
|
329 | |
310 | MIN_IT(R->screen.cur.row, nrow - 1); |
330 | MIN_IT(screen.cur.row, nrow - 1); |
311 | MIN_IT(R->swap.cur.row, nrow - 1); |
331 | MIN_IT(swap.cur.row, nrow - 1); |
312 | #endif |
332 | #endif |
|
|
333 | TermWin.ncol = ncol; // save b/c scr_blank_screen_mem uses this |
313 | } |
334 | } |
|
|
335 | |
314 | /* B2: resize columns */ |
336 | /* resize columns */ |
315 | if (ncol != prev_ncol) { |
337 | if (ncol != prev_ncol) |
|
|
338 | { |
|
|
339 | int common = min (prev_ncol, ncol); |
|
|
340 | rxvt_salloc *ta = new rxvt_salloc (ncol * sizeof (text_t)); |
|
|
341 | rxvt_salloc *ra = new rxvt_salloc (ncol * sizeof (rend_t)); |
|
|
342 | |
316 | for (p = 0; p < total_rows; p++) { |
343 | for (p = 0; p < total_rows; p++) |
|
|
344 | { |
317 | if (R->screen.text[p]) { |
345 | if (screen.text[p]) |
318 | R->screen.text[p] = (text_t *)rxvt_realloc(R->screen.text[p], ncol * sizeof(text_t)); |
346 | { |
319 | R->screen.rend[p] = (rend_t *)rxvt_realloc(R->screen.rend[p], ncol * sizeof(rend_t)); |
347 | text_t *t = (text_t *)ta->alloc (); memcpy (t, screen.text[p], common * sizeof (text_t)); screen.text[p] = t; |
|
|
348 | rend_t *r = (rend_t *)ra->alloc (); memcpy (r, screen.rend[p], common * sizeof (rend_t)); screen.rend[p] = r; |
|
|
349 | |
320 | MIN_IT(R->screen.tlen[p], (int16_t)ncol); |
350 | MIN_IT(screen.tlen[p], (int16_t)ncol); |
|
|
351 | |
321 | if (ncol > prev_ncol) |
352 | if (ncol > prev_ncol) |
322 | rxvt_blank_line(aR_ |
353 | scr_blank_line (&(screen.text[p][prev_ncol]), |
323 | &(R->screen.text[p][prev_ncol]), |
|
|
324 | &(R->screen.rend[p][prev_ncol]), |
354 | &(screen.rend[p][prev_ncol]), |
325 | ncol - prev_ncol, |
355 | ncol - prev_ncol, |
326 | setrstyle); |
356 | setrstyle); |
327 | } |
357 | } |
328 | } |
358 | } |
|
|
359 | |
329 | for (p = 0; p < nrow; p++) { |
360 | for (p = 0; p < nrow; p++) |
330 | R->drawn_text[p] = (text_t *)rxvt_realloc(R->drawn_text[p], ncol * sizeof(text_t)); |
361 | { |
331 | R->drawn_rend[p] = (rend_t *)rxvt_realloc(R->drawn_rend[p], ncol * sizeof(rend_t)); |
362 | text_t *t = (text_t *)ta->alloc (); memcpy (t, drawn_text[p], common * sizeof (text_t)); drawn_text[p] = t; |
|
|
363 | rend_t *r = (rend_t *)ra->alloc (); memcpy (r, drawn_rend[p], common * sizeof (rend_t)); drawn_rend[p] = r; |
|
|
364 | |
|
|
365 | if (ncol > prev_ncol) |
|
|
366 | scr_blank_line (&(drawn_text[p][prev_ncol]), |
|
|
367 | &(drawn_rend[p][prev_ncol]), |
|
|
368 | ncol - prev_ncol, setrstyle); |
|
|
369 | |
332 | if (R->swap.text[p]) { |
370 | if (swap.text[p]) |
333 | R->swap.text[p] = (text_t *)rxvt_realloc(R->swap.text[p], ncol * sizeof(text_t)); |
371 | { |
334 | R->swap.rend[p] = (rend_t *)rxvt_realloc(R->swap.rend[p], ncol * sizeof(rend_t)); |
372 | text_t *t = (text_t *)ta->alloc (); memcpy (t, swap.text[p], common * sizeof (text_t)); swap.text[p] = t; |
|
|
373 | rend_t *r = (rend_t *)ra->alloc (); memcpy (r, swap.rend[p], common * sizeof (rend_t)); swap.rend[p] = r; |
|
|
374 | |
335 | MIN_IT(R->swap.tlen[p], (int16_t)ncol); |
375 | MIN_IT(swap.tlen[p], (int16_t)ncol); |
|
|
376 | |
336 | if (ncol > prev_ncol) |
377 | if (ncol > prev_ncol) |
337 | rxvt_blank_line(aR_ |
378 | scr_blank_line (&(swap.text[p][prev_ncol]), |
338 | &(R->swap.text[p][prev_ncol]), |
|
|
339 | &(R->swap.rend[p][prev_ncol]), |
379 | &(swap.rend[p][prev_ncol]), |
340 | ncol - prev_ncol, setrstyle); |
380 | ncol - prev_ncol, setrstyle); |
341 | } |
381 | } |
342 | if (ncol > prev_ncol) |
382 | |
343 | rxvt_blank_line(aR_ |
|
|
344 | &(R->drawn_text[p][prev_ncol]), |
|
|
345 | &(R->drawn_rend[p][prev_ncol]), |
|
|
346 | ncol - prev_ncol, setrstyle); |
|
|
347 | } |
383 | } |
|
|
384 | |
348 | MIN_IT(R->screen.cur.col, (int16_t)ncol - 1); |
385 | MIN_IT (screen.cur.col, (int16_t)ncol - 1); |
349 | MIN_IT(R->swap.cur.col, (int16_t)ncol - 1); |
386 | MIN_IT (swap.cur.col, (int16_t)ncol - 1); |
|
|
387 | |
|
|
388 | delete talloc; talloc = ta; |
|
|
389 | delete ralloc; ralloc = ra; |
350 | } |
390 | } |
|
|
391 | |
351 | if (R->tabs) |
392 | if (tabs) |
352 | free(R->tabs); |
393 | free(tabs); |
353 | } |
394 | } |
354 | |
395 | |
|
|
396 | prev_nrow = nrow; |
|
|
397 | prev_ncol = ncol; |
|
|
398 | |
355 | R->tabs = (char *)rxvt_malloc(ncol * sizeof(char)); |
399 | tabs = (char *)rxvt_malloc (ncol * sizeof(char)); |
356 | |
400 | |
357 | for (p = 0; p < ncol; p++) |
401 | for (p = 0; p < ncol; p++) |
358 | R->tabs[p] = (p % TABSIZE == 0) ? 1 : 0; |
402 | tabs[p] = (p % TABSIZE == 0) ? 1 : 0; |
359 | |
403 | |
360 | R->prev_nrow = nrow; |
|
|
361 | R->prev_ncol = ncol; |
|
|
362 | |
|
|
363 | R->tt_winch (); |
404 | tt_winch (); |
364 | } |
405 | } |
365 | |
406 | |
366 | /* INTPROTO */ |
|
|
367 | void |
407 | void |
368 | rxvt_scr_reset_realloc(pR) |
408 | rxvt_term::scr_reset_realloc() |
369 | { |
409 | { |
370 | uint16_t total_rows, nrow; |
410 | uint16_t total_rows, nrow; |
371 | |
411 | |
372 | nrow = R->TermWin.nrow; |
412 | nrow = TermWin.nrow; |
373 | total_rows = nrow + R->TermWin.saveLines; |
413 | total_rows = nrow + TermWin.saveLines; |
374 | /* *INDENT-OFF* */ |
414 | /* *INDENT-OFF* */ |
375 | R->screen.text = (text_t **)rxvt_realloc(R->screen.text, total_rows * sizeof(text_t *)); |
415 | screen.text = (text_t **)rxvt_realloc(screen.text, total_rows * sizeof(text_t *)); |
376 | R->buf_text = (text_t **)rxvt_realloc(R->buf_text , total_rows * sizeof(text_t *)); |
416 | buf_text = (text_t **)rxvt_realloc(buf_text , total_rows * sizeof(text_t *)); |
377 | R->drawn_text = (text_t **)rxvt_realloc(R->drawn_text , nrow * sizeof(text_t *)); |
417 | drawn_text = (text_t **)rxvt_realloc(drawn_text , nrow * sizeof(text_t *)); |
378 | R->swap.text = (text_t **)rxvt_realloc(R->swap.text , nrow * sizeof(text_t *)); |
418 | swap.text = (text_t **)rxvt_realloc(swap.text , nrow * sizeof(text_t *)); |
379 | |
419 | |
380 | R->screen.tlen = (int16_t *)rxvt_realloc(R->screen.tlen, total_rows * sizeof(int16_t)); |
420 | screen.tlen = (int16_t *)rxvt_realloc(screen.tlen, total_rows * sizeof(int16_t)); |
381 | R->swap.tlen = (int16_t *)rxvt_realloc(R->swap.tlen , total_rows * sizeof(int16_t)); |
421 | swap.tlen = (int16_t *)rxvt_realloc(swap.tlen , total_rows * sizeof(int16_t)); |
382 | |
422 | |
383 | R->screen.rend = (rend_t **)rxvt_realloc(R->screen.rend, total_rows * sizeof(rend_t *)); |
423 | screen.rend = (rend_t **)rxvt_realloc(screen.rend, total_rows * sizeof(rend_t *)); |
384 | R->buf_rend = (rend_t **)rxvt_realloc(R->buf_rend , total_rows * sizeof(rend_t *)); |
424 | buf_rend = (rend_t **)rxvt_realloc(buf_rend , total_rows * sizeof(rend_t *)); |
385 | R->drawn_rend = (rend_t **)rxvt_realloc(R->drawn_rend , nrow * sizeof(rend_t *)); |
425 | drawn_rend = (rend_t **)rxvt_realloc(drawn_rend , nrow * sizeof(rend_t *)); |
386 | R->swap.rend = (rend_t **)rxvt_realloc(R->swap.rend , nrow * sizeof(rend_t *)); |
426 | swap.rend = (rend_t **)rxvt_realloc(swap.rend , nrow * sizeof(rend_t *)); |
387 | /* *INDENT-ON* */ |
427 | /* *INDENT-ON* */ |
388 | } |
428 | } |
389 | |
429 | |
390 | /* ------------------------------------------------------------------------- */ |
430 | /* ------------------------------------------------------------------------- */ |
391 | /* |
431 | /* |
392 | * Free everything. That way malloc debugging can find leakage. |
432 | * Free everything. That way malloc debugging can find leakage. |
393 | */ |
433 | */ |
394 | /* EXTPROTO */ |
|
|
395 | void |
434 | void |
396 | rxvt_scr_release(pR) |
435 | rxvt_term::scr_release() |
397 | { |
436 | { |
398 | uint16_t total_rows; |
437 | uint16_t total_rows; |
399 | int i; |
438 | int i; |
400 | |
439 | |
401 | total_rows = R->TermWin.nrow + R->TermWin.saveLines; |
440 | total_rows = TermWin.nrow + TermWin.saveLines; |
402 | for (i = 0; i < total_rows; i++) { |
441 | |
403 | if (R->screen.text[i]) { /* then so is R->screen.rend[i] */ |
|
|
404 | free(R->screen.text[i]); |
|
|
405 | #ifdef DEBUG_STRICT |
442 | #ifdef DEBUG_STRICT |
|
|
443 | for (i = 0; i < total_rows; i++) |
|
|
444 | { |
|
|
445 | if (screen.text[i]) |
|
|
446 | /* then so is screen.rend[i] */ |
406 | assert(R->screen.rend[i]); |
447 | assert(screen.rend[i]); |
407 | #endif |
|
|
408 | free(R->screen.rend[i]); |
|
|
409 | } |
|
|
410 | } |
448 | } |
411 | for (i = 0; i < R->TermWin.nrow; i++) { |
449 | #endif |
412 | free(R->drawn_text[i]); |
450 | |
413 | free(R->drawn_rend[i]); |
451 | delete talloc; talloc = 0; |
414 | free(R->swap.text[i]); |
452 | delete ralloc; ralloc = 0; |
415 | free(R->swap.rend[i]); |
453 | |
416 | } |
|
|
417 | free(R->screen.text); |
454 | free (screen.text); |
418 | free(R->screen.tlen); |
455 | free (screen.tlen); |
419 | free(R->screen.rend); |
456 | free (screen.rend); |
420 | free(R->drawn_text); |
457 | free (drawn_text); |
421 | free(R->drawn_rend); |
458 | free (drawn_rend); |
422 | free(R->swap.text); |
459 | free (swap.text); |
423 | free(R->swap.tlen); |
460 | free (swap.tlen); |
424 | free(R->swap.rend); |
461 | free (swap.rend); |
425 | free(R->buf_text); |
462 | free (buf_text); |
426 | free(R->buf_rend); |
463 | free (buf_rend); |
427 | free(R->tabs); |
464 | free (tabs); |
428 | |
465 | |
429 | /* NULL these so if anything tries to use them, we'll know about it */ |
466 | /* NULL these so if anything tries to use them, we'll know about it */ |
430 | R->screen.text = R->drawn_text = R->swap.text = NULL; |
467 | screen.text = drawn_text = swap.text = NULL; |
431 | R->screen.rend = R->drawn_rend = R->swap.rend = NULL; |
468 | screen.rend = drawn_rend = swap.rend = NULL; |
432 | R->screen.tlen = R->swap.tlen = NULL; |
469 | screen.tlen = swap.tlen = NULL; |
433 | R->buf_text = NULL; |
470 | buf_text = NULL; |
434 | R->buf_rend = NULL; |
471 | buf_rend = NULL; |
435 | R->tabs = NULL; |
472 | tabs = NULL; |
436 | } |
473 | } |
437 | |
474 | |
438 | /* ------------------------------------------------------------------------- */ |
475 | /* ------------------------------------------------------------------------- */ |
439 | /* |
476 | /* |
440 | * Hard reset |
477 | * Hard reset |
441 | */ |
478 | */ |
442 | /* EXTPROTO */ |
479 | /* EXTPROTO */ |
443 | void |
480 | void |
444 | rxvt_scr_poweron(pR) |
481 | rxvt_scr_poweron(pR) |
445 | { |
482 | { |
446 | D_SCREEN((stderr, "rxvt_scr_poweron()")); |
483 | D_SCREEN((stderr, "rxvt_scr_poweron()")); |
447 | |
484 | |
448 | rxvt_scr_release(aR); |
485 | R->scr_release (); |
449 | R->prev_nrow = R->prev_ncol = 0; |
486 | R->prev_nrow = R->prev_ncol = 0; |
450 | rxvt_scr_reset(aR); |
487 | R->scr_reset (); |
451 | |
488 | |
452 | rxvt_scr_clear(aR); |
489 | R->scr_clear (); |
453 | rxvt_scr_refresh(aR_ SLOW_REFRESH); |
490 | R->scr_refresh (SLOW_REFRESH); |
454 | #ifdef RXVT_GRAPHICS |
491 | #ifdef RXVT_GRAPHICS |
455 | rxvt_Gr_reset(aR); |
492 | rxvt_Gr_reset (aR); |
456 | #endif |
493 | #endif |
457 | } |
494 | } |
458 | |
495 | |
459 | /* ------------------------------------------------------------------------- * |
496 | /* ------------------------------------------------------------------------- * |
460 | * PROCESS SCREEN COMMANDS * |
497 | * PROCESS SCREEN COMMANDS * |
… | |
… | |
576 | if (R->current_screen == PRIMARY |
613 | if (R->current_screen == PRIMARY |
577 | # ifdef RXVT_GRAPHICS |
614 | # ifdef RXVT_GRAPHICS |
578 | && !rxvt_Gr_Displayed(aR) |
615 | && !rxvt_Gr_Displayed(aR) |
579 | # endif |
616 | # endif |
580 | ) |
617 | ) |
581 | rxvt_scroll_text(aR_ 0, (R->prev_nrow - 1), R->prev_nrow, 0); |
618 | R->scr_scroll_text(0, (R->prev_nrow - 1), R->prev_nrow, 0); |
582 | # endif |
619 | # endif |
583 | #endif |
620 | #endif |
584 | return scrn; |
621 | return scrn; |
585 | } |
622 | } |
586 | |
623 | |
… | |
… | |
620 | * Scroll text between <row1> and <row2> inclusive, by <count> lines |
657 | * Scroll text between <row1> and <row2> inclusive, by <count> lines |
621 | * count positive ==> scroll up |
658 | * count positive ==> scroll up |
622 | * count negative ==> scroll down |
659 | * count negative ==> scroll down |
623 | * spec == 0 for normal routines |
660 | * spec == 0 for normal routines |
624 | */ |
661 | */ |
625 | /* EXTPROTO */ |
|
|
626 | int |
662 | int |
627 | rxvt_scroll_text(pR_ int row1, int row2, int count, int spec) |
663 | rxvt_term::scr_scroll_text (int row1, int row2, int count, int spec) |
628 | { |
664 | { |
629 | int i, j; |
665 | int i, j; |
630 | long nscrolled; |
666 | long nscrolled; |
631 | |
667 | |
632 | if (count == 0 || (row1 > row2)) |
668 | if (count == 0 || (row1 > row2)) |
633 | return 0; |
669 | return 0; |
634 | |
670 | |
635 | R->want_refresh = 1; |
671 | want_refresh = 1; |
636 | D_SCREEN((stderr, "rxvt_scroll_text(%d,%d,%d,%d): %s", row1, row2, count, spec, (R->current_screen == PRIMARY) ? "Primary" : "Secondary")); |
672 | D_SCREEN((stderr, "rxvt_scroll_text(%d,%d,%d,%d): %s", row1, row2, count, spec, (current_screen == PRIMARY) ? "Primary" : "Secondary")); |
637 | |
673 | |
638 | if ((count > 0) && (row1 == 0) && (R->current_screen == PRIMARY)) { |
674 | if ((count > 0) && (row1 == 0) && (current_screen == PRIMARY)) |
|
|
675 | { |
639 | nscrolled = (long)R->TermWin.nscrolled + (long)count;; |
676 | nscrolled = (long)TermWin.nscrolled + (long)count; |
|
|
677 | |
640 | if (nscrolled > (long)R->TermWin.saveLines) |
678 | if (nscrolled > (long)TermWin.saveLines) |
641 | R->TermWin.nscrolled = R->TermWin.saveLines; |
679 | TermWin.nscrolled = TermWin.saveLines; |
642 | else |
680 | else |
643 | R->TermWin.nscrolled = (uint16_t)nscrolled; |
681 | TermWin.nscrolled = (uint16_t)nscrolled; |
|
|
682 | |
644 | if ((R->Options & Opt_scrollWithBuffer) |
683 | if ((Options & Opt_scrollWithBuffer) |
645 | && R->TermWin.view_start != 0 |
684 | && TermWin.view_start != 0 |
646 | && R->TermWin.view_start != R->TermWin.saveLines) |
685 | && TermWin.view_start != TermWin.saveLines) |
647 | rxvt_scr_page(aR_ UP, count); |
686 | rxvt_scr_page (this, UP, count); |
|
|
687 | } |
648 | } else if (!spec) |
688 | else if (!spec) |
649 | row1 += R->TermWin.saveLines; |
|
|
650 | row2 += R->TermWin.saveLines; |
689 | row1 += TermWin.saveLines; |
651 | |
690 | |
|
|
691 | row2 += TermWin.saveLines; |
|
|
692 | |
652 | if (R->selection.op && R->current_screen == R->selection.screen) { |
693 | if (selection.op && current_screen == selection.screen) |
|
|
694 | { |
653 | i = R->selection.beg.row + R->TermWin.saveLines; |
695 | i = selection.beg.row + TermWin.saveLines; |
654 | j = R->selection.end.row + R->TermWin.saveLines; |
696 | j = selection.end.row + TermWin.saveLines; |
655 | if ((i < row1 && j > row1) |
697 | if ((i < row1 && j > row1) |
656 | || (i < row2 && j > row2) |
698 | || (i < row2 && j > row2) |
657 | || (i - count < row1 && i >= row1) |
699 | || (i - count < row1 && i >= row1) |
658 | || (i - count > row2 && i <= row2) |
700 | || (i - count > row2 && i <= row2) |
659 | || (j - count < row1 && j >= row1) |
701 | || (j - count < row1 && j >= row1) |
660 | || (j - count > row2 && j <= row2)) { |
702 | || (j - count > row2 && j <= row2)) |
|
|
703 | { |
661 | CLEAR_ALL_SELECTION(R); |
704 | CLEAR_ALL_SELECTION (this); |
662 | R->selection.op = SELECTION_CLEAR; /* XXX: too aggressive? */ |
705 | selection.op = SELECTION_CLEAR; /* XXX: too aggressive? */ |
|
|
706 | } |
663 | } else if (j >= row1 && j <= row2) { |
707 | else if (j >= row1 && j <= row2) |
|
|
708 | { |
664 | /* move selected region too */ |
709 | /* move selected region too */ |
665 | R->selection.beg.row -= count; |
710 | selection.beg.row -= count; |
666 | R->selection.end.row -= count; |
711 | selection.end.row -= count; |
667 | R->selection.mark.row -= count; |
712 | selection.mark.row -= count; |
668 | } |
713 | } |
669 | } |
714 | } |
|
|
715 | |
670 | rxvt_selection_check(aR_ 0); /* _after_ R->TermWin.nscrolled update */ |
716 | rxvt_selection_check (this, 0); /* _after_ TermWin.nscrolled update */ |
671 | |
717 | |
672 | R->num_scr += count; |
718 | num_scr += count; |
673 | j = count; |
719 | j = count; |
|
|
720 | |
674 | if (count < 0) |
721 | if (count < 0) |
675 | count = -count; |
722 | count = -count; |
|
|
723 | |
676 | i = row2 - row1 + 1; |
724 | i = row2 - row1 + 1; |
677 | MIN_IT(count, i); |
725 | MIN_IT(count, i); |
678 | |
726 | |
679 | if (j > 0) { |
727 | if (j > 0) |
|
|
728 | { |
680 | /* A: scroll up */ |
729 | /* A: scroll up */ |
681 | |
730 | |
682 | /* A1: Copy lines that will get clobbered by the rotation */ |
731 | /* A1: Copy lines that will get clobbered by the rotation */ |
683 | for (i = 0, j = row1; i < count; i++, j++) { |
732 | for (i = 0, j = row1; i < count; i++, j++) |
|
|
733 | { |
684 | R->buf_text[i] = R->screen.text[j]; |
734 | buf_text[i] = screen.text[j]; |
685 | R->buf_rend[i] = R->screen.rend[j]; |
735 | buf_rend[i] = screen.rend[j]; |
686 | } |
736 | } |
687 | /* A2: Rotate lines */ |
737 | /* A2: Rotate lines */ |
688 | for (j = row1, i = j + count; i <= row2; i++, j++) { |
738 | for (j = row1, i = j + count; i <= row2; i++, j++) |
|
|
739 | { |
689 | R->screen.tlen[j] = R->screen.tlen[i]; |
740 | screen.tlen[j] = screen.tlen[i]; |
690 | R->screen.text[j] = R->screen.text[i]; |
741 | screen.text[j] = screen.text[i]; |
691 | R->screen.rend[j] = R->screen.rend[i]; |
742 | screen.rend[j] = screen.rend[i]; |
692 | } |
743 | } |
693 | j = row2 - count + 1, i = count; |
744 | j = row2 - count + 1, i = count; |
|
|
745 | } |
694 | } else /* if (j < 0) */ { |
746 | else /* if (j < 0) */ |
|
|
747 | { |
695 | /* B: scroll down */ |
748 | /* B: scroll down */ |
696 | |
749 | |
697 | /* B1: Copy lines that will get clobbered by the rotation */ |
750 | /* B1: Copy lines that will get clobbered by the rotation */ |
698 | for (i = 0, j = row2; i < count; i++, j--) { |
751 | for (i = 0, j = row2; i < count; i++, j--) |
|
|
752 | { |
699 | R->buf_text[i] = R->screen.text[j]; |
753 | buf_text[i] = screen.text[j]; |
700 | R->buf_rend[i] = R->screen.rend[j]; |
754 | buf_rend[i] = screen.rend[j]; |
701 | } |
755 | } |
702 | /* B2: Rotate lines */ |
756 | /* B2: Rotate lines */ |
703 | for (j = row2, i = j - count; i >= row1; i--, j--) { |
757 | for (j = row2, i = j - count; i >= row1; i--, j--) |
|
|
758 | { |
704 | R->screen.tlen[j] = R->screen.tlen[i]; |
759 | screen.tlen[j] = screen.tlen[i]; |
705 | R->screen.text[j] = R->screen.text[i]; |
760 | screen.text[j] = screen.text[i]; |
706 | R->screen.rend[j] = R->screen.rend[i]; |
761 | screen.rend[j] = screen.rend[i]; |
707 | } |
762 | } |
708 | j = row1, i = count; |
763 | j = row1, i = count; |
709 | count = -count; |
764 | count = -count; |
710 | } |
765 | } |
711 | |
766 | |
712 | /* C: Resurrect lines */ |
767 | /* C: Resurrect lines */ |
713 | for (; i--; j++) { |
768 | for (; i--; j++) |
|
|
769 | { |
714 | R->screen.tlen[j] = 0; |
770 | screen.tlen[j] = 0; |
715 | R->screen.text[j] = R->buf_text[i]; |
771 | screen.text[j] = buf_text[i]; |
716 | R->screen.rend[j] = R->buf_rend[i]; |
772 | screen.rend[j] = buf_rend[i]; |
|
|
773 | |
717 | if (!spec) /* line length may not equal TermWin.ncol */ |
774 | if (!spec) /* line length may not equal TermWin.ncol */ |
718 | rxvt_blank_screen_mem(aR_ R->screen.text, R->screen.rend, |
775 | scr_blank_screen_mem (screen.text, screen.rend, |
719 | (unsigned int)j, R->rstyle); |
776 | (unsigned int)j, rstyle); |
720 | } |
777 | } |
721 | |
778 | |
722 | #ifdef RXVT_GRAPHICS |
779 | #ifdef RXVT_GRAPHICS |
723 | if (rxvt_Gr_Displayed(aR)) |
780 | if (rxvt_Gr_Displayed (this)) |
724 | rxvt_Gr_scroll(aR_ count); |
781 | rxvt_Gr_scroll(this, count); |
725 | #endif |
782 | #endif |
|
|
783 | |
726 | return count; |
784 | return count; |
727 | } |
785 | } |
728 | |
786 | |
729 | /* ------------------------------------------------------------------------- */ |
787 | /* ------------------------------------------------------------------------- */ |
730 | /* |
788 | /* |
731 | * Add text given in <str> of length <len> to screen struct |
789 | * Add text given in <str> of length <len> to screen struct |
… | |
… | |
752 | nlines += (R->screen.cur.row - R->screen.bscroll); |
810 | nlines += (R->screen.cur.row - R->screen.bscroll); |
753 | if ((nlines > 0) |
811 | if ((nlines > 0) |
754 | && (R->screen.tscroll == 0) |
812 | && (R->screen.tscroll == 0) |
755 | && (R->screen.bscroll == (R->TermWin.nrow - 1))) { |
813 | && (R->screen.bscroll == (R->TermWin.nrow - 1))) { |
756 | /* _at least_ this many lines need to be scrolled */ |
814 | /* _at least_ this many lines need to be scrolled */ |
757 | rxvt_scroll_text(aR_ R->screen.tscroll, R->screen.bscroll, nlines, |
815 | R->scr_scroll_text(R->screen.tscroll, R->screen.bscroll, nlines, 0); |
758 | 0); |
|
|
759 | R->screen.cur.row -= nlines; |
816 | R->screen.cur.row -= nlines; |
760 | } |
817 | } |
761 | } |
818 | } |
762 | #ifdef DEBUG_STRICT |
819 | #ifdef DEBUG_STRICT |
763 | assert(R->screen.cur.col < last_col); |
820 | assert(R->screen.cur.col < last_col); |
… | |
… | |
779 | |
836 | |
780 | for (i = 0; i < len;) { |
837 | for (i = 0; i < len;) { |
781 | c = str[i++]; |
838 | c = str[i++]; |
782 | switch (c) { |
839 | switch (c) { |
783 | case '\t': |
840 | case '\t': |
784 | rxvt_scr_tab(aR_ 1); |
841 | rxvt_scr_tab (aR_ 1); |
785 | continue; |
842 | continue; |
786 | case '\n': |
843 | case '\n': |
787 | if (R->screen.tlen[row] != -1) /* XXX: think about this */ |
844 | if (R->screen.tlen[row] != -1) /* XXX: think about this */ |
788 | MAX_IT(R->screen.tlen[row], R->screen.cur.col); |
845 | MAX_IT(R->screen.tlen[row], R->screen.cur.col); |
789 | R->screen.flags &= ~Screen_WrapNext; |
846 | R->screen.flags &= ~Screen_WrapNext; |
790 | if (R->screen.cur.row == R->screen.bscroll) |
847 | if (R->screen.cur.row == R->screen.bscroll) |
791 | rxvt_scroll_text(aR_ R->screen.tscroll, R->screen.bscroll, 1, 0); |
848 | R->scr_scroll_text (R->screen.tscroll, R->screen.bscroll, 1, 0); |
792 | else if (R->screen.cur.row < (R->TermWin.nrow - 1)) |
849 | else if (R->screen.cur.row < (R->TermWin.nrow - 1)) |
793 | row = (++R->screen.cur.row) + R->TermWin.saveLines; |
850 | row = (++R->screen.cur.row) + R->TermWin.saveLines; |
794 | stp = R->screen.text[row]; /* _must_ refresh */ |
851 | stp = R->screen.text[row]; /* _must_ refresh */ |
795 | srp = R->screen.rend[row]; /* _must_ refresh */ |
852 | srp = R->screen.rend[row]; /* _must_ refresh */ |
796 | continue; |
853 | continue; |
… | |
… | |
813 | clearsel = 1; |
870 | clearsel = 1; |
814 | } |
871 | } |
815 | if (R->screen.flags & Screen_WrapNext) { |
872 | if (R->screen.flags & Screen_WrapNext) { |
816 | R->screen.tlen[row] = -1; |
873 | R->screen.tlen[row] = -1; |
817 | if (R->screen.cur.row == R->screen.bscroll) |
874 | if (R->screen.cur.row == R->screen.bscroll) |
818 | rxvt_scroll_text(aR_ R->screen.tscroll, R->screen.bscroll, 1, 0); |
875 | R->scr_scroll_text(R->screen.tscroll, R->screen.bscroll, 1, 0); |
819 | else if (R->screen.cur.row < (R->TermWin.nrow - 1)) |
876 | else if (R->screen.cur.row < (R->TermWin.nrow - 1)) |
820 | row = (++R->screen.cur.row) + R->TermWin.saveLines; |
877 | row = (++R->screen.cur.row) + R->TermWin.saveLines; |
821 | stp = R->screen.text[row]; /* _must_ refresh */ |
878 | stp = R->screen.text[row]; /* _must_ refresh */ |
822 | srp = R->screen.rend[row]; /* _must_ refresh */ |
879 | srp = R->screen.rend[row]; /* _must_ refresh */ |
823 | R->screen.cur.col = 0; |
880 | R->screen.cur.col = 0; |
… | |
… | |
841 | case 'z': c = 0x2265; break; case '{': c = 0x03c0; break; case '|': c = 0x2260; break; |
898 | case 'z': c = 0x2265; break; case '{': c = 0x03c0; break; case '|': c = 0x2260; break; |
842 | case '}': c = 0x00a3; break; case '~': c = 0x00b7; break; |
899 | case '}': c = 0x00a3; break; case '~': c = 0x00b7; break; |
843 | } |
900 | } |
844 | |
901 | |
845 | rend_t rend = SET_FONT (R->rstyle, R->TermWin.fontset->find_font (c)); |
902 | rend_t rend = SET_FONT (R->rstyle, R->TermWin.fontset->find_font (c)); |
846 | |
|
|
847 | stp[R->screen.cur.col] = c; |
|
|
848 | srp[R->screen.cur.col] = rend; |
|
|
849 | |
|
|
850 | if (c > 255) |
|
|
851 | { |
|
|
852 | // rely on wcwidth to tell us the character width, at least for non iso-8859-1 |
903 | // rely on wcwidth to tell us the character width, at least for non-ascii |
853 | int width = wcwidth (c); |
904 | int width = c <= 128 ? 1 : wcwidth (c); |
|
|
905 | |
|
|
906 | // width -1 characters (e.g. combining chars) are ignored currently. |
|
|
907 | if (width > 0) |
|
|
908 | do |
854 | |
909 | { |
855 | if (width > 1) |
910 | stp[R->screen.cur.col] = c; |
856 | { |
|
|
857 | while (--width > 0 && R->screen.cur.col < last_col - 1) |
|
|
858 | { |
|
|
859 | |
|
|
860 | srp[R->screen.cur.col] |= RS_wide; |
911 | srp[R->screen.cur.col] = rend; |
861 | |
912 | |
|
|
913 | if (R->screen.cur.col < last_col - 1) |
862 | R->screen.cur.col++; |
914 | R->screen.cur.col++; |
863 | stp[R->screen.cur.col] = NOCHAR; |
915 | else |
864 | srp[R->screen.cur.col] = rend; |
|
|
865 | } |
916 | { |
866 | } |
|
|
867 | } |
|
|
868 | |
|
|
869 | if (R->screen.cur.col < last_col - 1) |
|
|
870 | R->screen.cur.col++; |
|
|
871 | else { |
|
|
872 | R->screen.tlen[row] = last_col; |
917 | R->screen.tlen[row] = last_col; |
873 | if (R->screen.flags & Screen_Autowrap) |
918 | if (R->screen.flags & Screen_Autowrap) |
874 | R->screen.flags |= Screen_WrapNext; |
919 | R->screen.flags |= Screen_WrapNext; |
|
|
920 | break; |
|
|
921 | } |
|
|
922 | |
|
|
923 | c = NOCHAR; |
875 | } |
924 | } |
|
|
925 | while (--width > 0); |
|
|
926 | else |
|
|
927 | 1; /* handle combining character etc. here. */ |
876 | } |
928 | } |
|
|
929 | |
877 | if (R->screen.tlen[row] != -1) /* XXX: think about this */ |
930 | if (R->screen.tlen[row] != -1) /* XXX: think about this */ |
878 | MAX_IT(R->screen.tlen[row], R->screen.cur.col); |
931 | MAX_IT(R->screen.tlen[row], R->screen.cur.col); |
879 | |
932 | |
880 | /* |
933 | /* |
881 | * If we wrote anywhere in the selected area, kill the selection |
934 | * If we wrote anywhere in the selected area, kill the selection |
882 | * XXX: should we kill the mark too? Possibly, but maybe that |
935 | * XXX: should we kill the mark too? Possibly, but maybe that |
883 | * should be a similar check. |
936 | * should be a similar check. |
… | |
… | |
1075 | #endif |
1128 | #endif |
1076 | |
1129 | |
1077 | R->screen.flags &= ~Screen_WrapNext; |
1130 | R->screen.flags &= ~Screen_WrapNext; |
1078 | if ((R->screen.cur.row == R->screen.bscroll && direction == UP) |
1131 | if ((R->screen.cur.row == R->screen.bscroll && direction == UP) |
1079 | || (R->screen.cur.row == R->screen.tscroll && direction == DN)) |
1132 | || (R->screen.cur.row == R->screen.tscroll && direction == DN)) |
1080 | rxvt_scroll_text(aR_ R->screen.tscroll, R->screen.bscroll, dirn, 0); |
1133 | R->scr_scroll_text(R->screen.tscroll, R->screen.bscroll, dirn, 0); |
1081 | else |
1134 | else |
1082 | R->screen.cur.row += dirn; |
1135 | R->screen.cur.row += dirn; |
1083 | MAX_IT(R->screen.cur.row, 0); |
1136 | MAX_IT(R->screen.cur.row, 0); |
1084 | MIN_IT(R->screen.cur.row, (int32_t)R->TermWin.nrow - 1); |
1137 | MIN_IT(R->screen.cur.row, (int32_t)R->TermWin.nrow - 1); |
1085 | rxvt_selection_check(aR_ 0); |
1138 | rxvt_selection_check(aR_ 0); |
… | |
… | |
1094 | */ |
1147 | */ |
1095 | /* EXTPROTO */ |
1148 | /* EXTPROTO */ |
1096 | void |
1149 | void |
1097 | rxvt_scr_erase_line(pR_ int mode) |
1150 | rxvt_scr_erase_line(pR_ int mode) |
1098 | { |
1151 | { |
1099 | unsigned int row, col, num; |
1152 | unsigned int row, col, num; |
1100 | |
1153 | |
1101 | R->want_refresh = 1; |
1154 | R->want_refresh = 1; |
1102 | D_SCREEN((stderr, "rxvt_scr_erase_line(%d) at screen row: %d", mode, R->screen.cur.row)); |
1155 | D_SCREEN((stderr, "rxvt_scr_erase_line(%d) at screen row: %d", mode, R->screen.cur.row)); |
1103 | ZERO_SCROLLBACK(R); |
1156 | ZERO_SCROLLBACK (R); |
1104 | |
1157 | |
1105 | #ifdef RXVT_GRAPHICS |
1158 | #ifdef RXVT_GRAPHICS |
1106 | if (rxvt_Gr_Displayed(aR)) |
1159 | if (rxvt_Gr_Displayed (aR)) |
1107 | rxvt_Gr_scroll(aR_ 0); |
1160 | rxvt_Gr_scroll (aR_ 0); |
1108 | #endif |
1161 | #endif |
1109 | |
1162 | |
1110 | rxvt_selection_check(aR_ 1); |
1163 | rxvt_selection_check (aR_ 1); |
1111 | |
1164 | |
1112 | R->screen.flags &= ~Screen_WrapNext; |
1165 | R->screen.flags &= ~Screen_WrapNext; |
1113 | |
1166 | |
1114 | row = R->TermWin.saveLines + R->screen.cur.row; |
1167 | row = R->TermWin.saveLines + R->screen.cur.row; |
1115 | switch (mode) { |
1168 | switch (mode) |
|
|
1169 | { |
1116 | case 0: /* erase to end of line */ |
1170 | case 0: /* erase to end of line */ |
1117 | col = R->screen.cur.col; |
1171 | col = R->screen.cur.col; |
1118 | num = R->TermWin.ncol - col; |
1172 | num = R->TermWin.ncol - col; |
1119 | MIN_IT(R->screen.tlen[row], (int16_t)col); |
1173 | MIN_IT(R->screen.tlen[row], (int16_t)col); |
1120 | if (ROWCOL_IN_ROW_AT_OR_AFTER(R->selection.beg, R->screen.cur) |
1174 | if (ROWCOL_IN_ROW_AT_OR_AFTER(R->selection.beg, R->screen.cur) |
1121 | || ROWCOL_IN_ROW_AT_OR_AFTER(R->selection.end, R->screen.cur)) |
1175 | || ROWCOL_IN_ROW_AT_OR_AFTER(R->selection.end, R->screen.cur)) |
1122 | CLEAR_SELECTION(R); |
1176 | CLEAR_SELECTION(R); |
1123 | break; |
1177 | break; |
1124 | case 1: /* erase to beginning of line */ |
1178 | case 1: /* erase to beginning of line */ |
1125 | col = 0; |
1179 | col = 0; |
1126 | num = R->screen.cur.col + 1; |
1180 | num = R->screen.cur.col + 1; |
1127 | if (ROWCOL_IN_ROW_AT_OR_BEFORE(R->selection.beg, R->screen.cur) |
1181 | if (ROWCOL_IN_ROW_AT_OR_BEFORE(R->selection.beg, R->screen.cur) |
1128 | || ROWCOL_IN_ROW_AT_OR_BEFORE(R->selection.end, R->screen.cur)) |
1182 | || ROWCOL_IN_ROW_AT_OR_BEFORE(R->selection.end, R->screen.cur)) |
1129 | CLEAR_SELECTION(R); |
1183 | CLEAR_SELECTION(R); |
1130 | break; |
1184 | break; |
1131 | case 2: /* erase whole line */ |
1185 | case 2: /* erase whole line */ |
1132 | col = 0; |
1186 | col = 0; |
1133 | num = R->TermWin.ncol; |
1187 | num = R->TermWin.ncol; |
1134 | R->screen.tlen[row] = 0; |
1188 | R->screen.tlen[row] = 0; |
1135 | if (R->selection.beg.row <= R->screen.cur.row |
1189 | if (R->selection.beg.row <= R->screen.cur.row |
1136 | && R->selection.end.row >= R->screen.cur.row) |
1190 | && R->selection.end.row >= R->screen.cur.row) |
1137 | CLEAR_SELECTION(R); |
1191 | CLEAR_SELECTION(R); |
1138 | break; |
1192 | break; |
1139 | default: |
1193 | default: |
1140 | return; |
1194 | return; |
1141 | } |
1195 | } |
|
|
1196 | |
1142 | if (R->screen.text[row]) |
1197 | if (R->screen.text[row]) |
1143 | rxvt_blank_line(aR_ |
1198 | R->scr_blank_line (&(R->screen.text[row][col]), |
1144 | &(R->screen.text[row][col]), |
|
|
1145 | &(R->screen.rend[row][col]), num, R->rstyle); |
1199 | &(R->screen.rend[row][col]), num, R->rstyle); |
1146 | else |
1200 | else |
1147 | rxvt_blank_screen_mem(aR_ R->screen.text, R->screen.rend, row, |
1201 | R->scr_blank_screen_mem (R->screen.text, R->screen.rend, row, R->rstyle); |
1148 | R->rstyle); |
|
|
1149 | } |
1202 | } |
1150 | |
1203 | |
1151 | /* ------------------------------------------------------------------------- */ |
1204 | /* ------------------------------------------------------------------------- */ |
1152 | /* |
1205 | /* |
1153 | * Erase part of whole of the screen |
1206 | * Erase part of whole of the screen |
1154 | * XTERM_SEQ: Clear screen after cursor : ESC [ 0 J |
1207 | * XTERM_SEQ: Clear screen after cursor : ESC [ 0 J |
1155 | * XTERM_SEQ: Clear screen before cursor: ESC [ 1 J |
1208 | * XTERM_SEQ: Clear screen before cursor: ESC [ 1 J |
1156 | * XTERM_SEQ: Clear whole screen : ESC [ 2 J |
1209 | * XTERM_SEQ: Clear whole screen : ESC [ 2 J |
1157 | */ |
1210 | */ |
1158 | /* EXTPROTO */ |
|
|
1159 | void |
1211 | void |
1160 | rxvt_scr_erase_screen(pR_ int mode) |
1212 | rxvt_term::scr_erase_screen (int mode) |
1161 | { |
1213 | { |
1162 | int num; |
1214 | int num; |
1163 | int32_t row, row_offset; |
1215 | int32_t row, row_offset; |
1164 | rend_t ren; |
1216 | rend_t ren; |
1165 | XGCValues gcvalue; |
1217 | XGCValues gcvalue; |
1166 | |
1218 | |
1167 | R->want_refresh = 1; |
1219 | want_refresh = 1; |
1168 | D_SCREEN((stderr, "rxvt_scr_erase_screen(%d) at screen row: %d", mode, R->screen.cur.row)); |
1220 | D_SCREEN((stderr, "rxvt_scr_erase_screen(%d) at screen row: %d", mode, screen.cur.row)); |
1169 | ZERO_SCROLLBACK(R); |
1221 | ZERO_SCROLLBACK(this); |
1170 | row_offset = (int32_t)R->TermWin.saveLines; |
1222 | row_offset = (int32_t)TermWin.saveLines; |
1171 | |
1223 | |
1172 | switch (mode) { |
1224 | switch (mode) { |
1173 | case 0: /* erase to end of screen */ |
1225 | case 0: /* erase to end of screen */ |
1174 | rxvt_selection_check(aR_ 1); |
1226 | rxvt_selection_check(this,1); |
1175 | rxvt_scr_erase_line(aR_ 0); |
1227 | rxvt_scr_erase_line(this,0); |
1176 | row = R->screen.cur.row + 1; /* possible OOB */ |
1228 | row = screen.cur.row + 1; /* possible OOB */ |
1177 | num = R->TermWin.nrow - row; |
1229 | num = TermWin.nrow - row; |
1178 | break; |
1230 | break; |
1179 | case 1: /* erase to beginning of screen */ |
1231 | case 1: /* erase to beginning of screen */ |
1180 | rxvt_selection_check(aR_ 3); |
1232 | rxvt_selection_check(this,3); |
1181 | rxvt_scr_erase_line(aR_ 1); |
1233 | rxvt_scr_erase_line(this,1); |
1182 | row = 0; |
1234 | row = 0; |
1183 | num = R->screen.cur.row; |
1235 | num = screen.cur.row; |
1184 | break; |
1236 | break; |
1185 | case 2: /* erase whole screen */ |
1237 | case 2: /* erase whole screen */ |
1186 | rxvt_selection_check(aR_ 3); |
1238 | rxvt_selection_check (this, 3); |
1187 | #ifdef RXVT_GRAPHICS |
1239 | #ifdef RXVT_GRAPHICS |
1188 | rxvt_Gr_ClearScreen(aR); |
1240 | rxvt_Gr_ClearScreen (this); |
1189 | #endif |
1241 | #endif |
1190 | row = 0; |
1242 | row = 0; |
1191 | num = R->TermWin.nrow; |
1243 | num = TermWin.nrow; |
1192 | break; |
1244 | break; |
1193 | default: |
1245 | default: |
1194 | return; |
1246 | return; |
1195 | } |
1247 | } |
1196 | R->refresh_type |= REFRESH_BOUNDS; |
1248 | refresh_type |= REFRESH_BOUNDS; |
1197 | if (R->selection.op && R->current_screen == R->selection.screen |
1249 | if (selection.op && current_screen == selection.screen |
1198 | && ((R->selection.beg.row >= row && R->selection.beg.row <= row + num) |
1250 | && ((selection.beg.row >= row && selection.beg.row <= row + num) |
1199 | || (R->selection.end.row >= row |
1251 | || (selection.end.row >= row |
1200 | && R->selection.end.row <= row + num))) |
1252 | && selection.end.row <= row + num))) |
1201 | CLEAR_SELECTION(R); |
1253 | CLEAR_SELECTION (this); |
1202 | if (row >= R->TermWin.nrow) /* Out Of Bounds */ |
1254 | if (row >= TermWin.nrow) /* Out Of Bounds */ |
1203 | return; |
1255 | return; |
1204 | MIN_IT(num, (R->TermWin.nrow - row)); |
1256 | MIN_IT(num, (TermWin.nrow - row)); |
1205 | if (R->rstyle & (RS_RVid | RS_Uline)) |
1257 | if (rstyle & (RS_RVid | RS_Uline)) |
1206 | ren = (rend_t) ~RS_None; |
1258 | ren = (rend_t) ~RS_None; |
1207 | else if (GET_BASEBG(R->rstyle) == Color_bg) { |
1259 | else if (GET_BASEBG(rstyle) == Color_bg) { |
1208 | ren = DEFAULT_RSTYLE; |
1260 | ren = DEFAULT_RSTYLE; |
1209 | CLEAR_ROWS(row, num); |
1261 | CLEAR_ROWS(row, num); |
1210 | } else { |
1262 | } else { |
1211 | ren = (R->rstyle & (RS_fgMask | RS_bgMask)); |
1263 | ren = (rstyle & (RS_fgMask | RS_bgMask)); |
1212 | gcvalue.foreground = R->PixColors[GET_BGCOLOR(R->rstyle)]; |
1264 | gcvalue.foreground = PixColors[GET_BGCOLOR(rstyle)]; |
1213 | XChangeGC(R->Xdisplay, R->TermWin.gc, GCForeground, &gcvalue); |
1265 | XChangeGC(Xdisplay, TermWin.gc, GCForeground, &gcvalue); |
1214 | ERASE_ROWS(row, num); |
1266 | ERASE_ROWS(row, num); |
1215 | gcvalue.foreground = R->PixColors[Color_fg]; |
1267 | gcvalue.foreground = PixColors[Color_fg]; |
1216 | XChangeGC(R->Xdisplay, R->TermWin.gc, GCForeground, &gcvalue); |
1268 | XChangeGC(Xdisplay, TermWin.gc, GCForeground, &gcvalue); |
1217 | } |
1269 | } |
1218 | for (; num--; row++) { |
1270 | for (; num--; row++) { |
1219 | rxvt_blank_screen_mem(aR_ R->screen.text, R->screen.rend, |
1271 | scr_blank_screen_mem (screen.text, screen.rend, |
1220 | (unsigned int)(row + row_offset), R->rstyle); |
1272 | (unsigned int)(row + row_offset), rstyle); |
1221 | R->screen.tlen[row + row_offset] = 0; |
1273 | screen.tlen[row + row_offset] = 0; |
1222 | rxvt_blank_line(aR_ |
1274 | scr_blank_line (drawn_text[row], drawn_rend[row], |
1223 | R->drawn_text[row], R->drawn_rend[row], |
|
|
1224 | (unsigned int)R->TermWin.ncol, ren); |
1275 | (unsigned int)TermWin.ncol, ren); |
1225 | } |
1276 | } |
1226 | } |
1277 | } |
1227 | |
1278 | |
1228 | /* ------------------------------------------------------------------------- */ |
1279 | /* ------------------------------------------------------------------------- */ |
1229 | /* |
1280 | /* |
… | |
… | |
1280 | else if (insdel == INSERT) |
1331 | else if (insdel == INSERT) |
1281 | count = end; |
1332 | count = end; |
1282 | } |
1333 | } |
1283 | R->screen.flags &= ~Screen_WrapNext; |
1334 | R->screen.flags &= ~Screen_WrapNext; |
1284 | |
1335 | |
1285 | rxvt_scroll_text(aR_ R->screen.cur.row, R->screen.bscroll, insdel * count, |
1336 | R->scr_scroll_text(R->screen.cur.row, R->screen.bscroll, insdel * count, 0); |
1286 | 0); |
|
|
1287 | } |
1337 | } |
1288 | |
1338 | |
1289 | /* ------------------------------------------------------------------------- */ |
1339 | /* ------------------------------------------------------------------------- */ |
1290 | /* |
1340 | /* |
1291 | * Insert/Delete <count> characters from the current position |
1341 | * Insert/Delete <count> characters from the current position |
… | |
… | |
1340 | R->selection.beg.col += count; |
1390 | R->selection.beg.col += count; |
1341 | R->selection.mark.col += count; /* XXX: yes? */ |
1391 | R->selection.mark.col += count; /* XXX: yes? */ |
1342 | R->selection.end.col += count; |
1392 | R->selection.end.col += count; |
1343 | } |
1393 | } |
1344 | } |
1394 | } |
1345 | rxvt_blank_line(aR_ &(stp[R->screen.cur.col]), &(srp[R->screen.cur.col]), |
1395 | R->scr_blank_line (&(stp[R->screen.cur.col]), &(srp[R->screen.cur.col]), |
1346 | (unsigned int)count, R->rstyle); |
1396 | (unsigned int)count, R->rstyle); |
1347 | break; |
1397 | break; |
1348 | case ERASE: |
1398 | case ERASE: |
1349 | R->screen.cur.col += count; /* don't worry if > R->TermWin.ncol */ |
1399 | R->screen.cur.col += count; /* don't worry if > R->TermWin.ncol */ |
1350 | rxvt_selection_check(aR_ 1); |
1400 | rxvt_selection_check(aR_ 1); |
1351 | R->screen.cur.col -= count; |
1401 | R->screen.cur.col -= count; |
1352 | rxvt_blank_line(aR_ &(stp[R->screen.cur.col]), &(srp[R->screen.cur.col]), |
1402 | R->scr_blank_line (&(stp[R->screen.cur.col]), &(srp[R->screen.cur.col]), |
1353 | (unsigned int)count, R->rstyle); |
1403 | (unsigned int)count, R->rstyle); |
1354 | break; |
1404 | break; |
1355 | case DELETE: |
1405 | case DELETE: |
1356 | tr = srp[R->TermWin.ncol - 1] |
1406 | tr = srp[R->TermWin.ncol - 1] |
1357 | & (RS_fgMask | RS_bgMask | RS_baseattrMask); |
1407 | & (RS_fgMask | RS_bgMask | RS_baseattrMask); |
1358 | for (col = R->screen.cur.col; (col + count) < R->TermWin.ncol; col++) { |
1408 | for (col = R->screen.cur.col; (col + count) < R->TermWin.ncol; col++) { |
1359 | stp[col] = stp[col + count]; |
1409 | stp[col] = stp[col + count]; |
1360 | srp[col] = srp[col + count]; |
1410 | srp[col] = srp[col + count]; |
1361 | } |
1411 | } |
1362 | rxvt_blank_line(aR_ |
1412 | R->scr_blank_line (&(stp[R->TermWin.ncol - count]), |
1363 | &(stp[R->TermWin.ncol - count]), |
|
|
1364 | &(srp[R->TermWin.ncol - count]), |
1413 | &(srp[R->TermWin.ncol - count]), |
1365 | (unsigned int)count, tr); |
1414 | (unsigned int)count, tr); |
1366 | if (*slp == -1) /* break line continuation */ |
1415 | if (*slp == -1) /* break line continuation */ |
1367 | *slp = R->TermWin.ncol; |
1416 | *slp = R->TermWin.ncol; |
1368 | *slp -= count; |
1417 | *slp -= count; |
1369 | MAX_IT(*slp, 0); |
1418 | MAX_IT(*slp, 0); |
1370 | if (R->selection.op && R->current_screen == R->selection.screen |
1419 | if (R->selection.op && R->current_screen == R->selection.screen |
… | |
… | |
1515 | |
1564 | |
1516 | gcvalue.foreground = R->PixColors[Color_fg]; |
1565 | gcvalue.foreground = R->PixColors[Color_fg]; |
1517 | gcvalue.background = R->PixColors[Color_bg]; |
1566 | gcvalue.background = R->PixColors[Color_bg]; |
1518 | XChangeGC(R->Xdisplay, R->TermWin.gc, GCBackground | GCForeground, |
1567 | XChangeGC(R->Xdisplay, R->TermWin.gc, GCBackground | GCForeground, |
1519 | &gcvalue); |
1568 | &gcvalue); |
1520 | rxvt_scr_clear(aR); |
1569 | R->scr_clear (); |
1521 | rxvt_scr_touch(aR_ True); |
1570 | R->scr_touch (true); |
1522 | } |
1571 | } |
1523 | } |
1572 | } |
1524 | |
1573 | |
1525 | /* ------------------------------------------------------------------------- */ |
1574 | /* ------------------------------------------------------------------------- */ |
1526 | /* |
1575 | /* |
… | |
… | |
1596 | rxvt_set_font_style(aR); |
1645 | rxvt_set_font_style(aR); |
1597 | } |
1646 | } |
1598 | |
1647 | |
1599 | |
1648 | |
1600 | /* ------------------------------------------------------------------------- * |
1649 | /* ------------------------------------------------------------------------- * |
1601 | * GRAPHICS COLOURS * |
|
|
1602 | * ------------------------------------------------------------------------- */ |
|
|
1603 | |
|
|
1604 | #ifdef RXVT_GRAPHICS |
|
|
1605 | /* EXTPROTO */ |
|
|
1606 | int |
|
|
1607 | rxvt_scr_get_fgcolor(pR) |
|
|
1608 | { |
|
|
1609 | return GET_FGCOLOR(R->rstyle); |
|
|
1610 | } |
|
|
1611 | |
|
|
1612 | /* ------------------------------------------------------------------------- */ |
|
|
1613 | /* EXTPROTO */ |
|
|
1614 | int |
|
|
1615 | rxvt_scr_get_bgcolor(pR) |
|
|
1616 | { |
|
|
1617 | return GET_BGCOLOR(R->rstyle); |
|
|
1618 | } |
|
|
1619 | #endif |
|
|
1620 | |
|
|
1621 | /* ------------------------------------------------------------------------- * |
|
|
1622 | * MAJOR SCREEN MANIPULATION * |
1650 | * MAJOR SCREEN MANIPULATION * |
1623 | * ------------------------------------------------------------------------- */ |
1651 | * ------------------------------------------------------------------------- */ |
1624 | |
1652 | |
1625 | /* |
1653 | /* |
1626 | * Refresh an area |
1654 | * Refresh an area |
… | |
… | |
1629 | PART_BEG = 0, |
1657 | PART_BEG = 0, |
1630 | PART_END, |
1658 | PART_END, |
1631 | RC_COUNT |
1659 | RC_COUNT |
1632 | }; |
1660 | }; |
1633 | |
1661 | |
1634 | /* EXTPROTO */ |
|
|
1635 | void |
1662 | void |
1636 | rxvt_scr_expose(pR_ int x, int y, int width, int height, Bool refresh) |
1663 | rxvt_term::scr_expose (int x, int y, int width, int height, bool refresh) |
1637 | { |
1664 | { |
1638 | int i; |
1665 | int i; |
1639 | row_col_t rc[RC_COUNT]; |
1666 | row_col_t rc[RC_COUNT]; |
1640 | |
1667 | |
1641 | if (R->drawn_text == NULL) /* sanity check */ |
1668 | if (drawn_text == NULL) /* sanity check */ |
1642 | return; |
1669 | return; |
1643 | |
1670 | |
1644 | #ifdef DEBUG_STRICT |
1671 | #ifdef DEBUG_STRICT |
1645 | x = max(x, (int)R->TermWin.int_bwidth); |
1672 | x = max(x, (int)TermWin.int_bwidth); |
1646 | x = min(x, (int)R->TermWin.width); |
1673 | x = min(x, (int)TermWin.width); |
1647 | y = max(y, (int)R->TermWin.int_bwidth); |
1674 | y = max(y, (int)TermWin.int_bwidth); |
1648 | y = min(y, (int)R->TermWin.height); |
1675 | y = min(y, (int)TermWin.height); |
1649 | #endif |
1676 | #endif |
1650 | |
1677 | |
1651 | /* round down */ |
1678 | /* round down */ |
1652 | rc[PART_BEG].col = Pixel2Col(x); |
1679 | rc[PART_BEG].col = Pixel2Col(x); |
1653 | rc[PART_BEG].row = Pixel2Row(y); |
1680 | rc[PART_BEG].row = Pixel2Row(y); |
1654 | /* round up */ |
1681 | /* round up */ |
1655 | rc[PART_END].col = Pixel2Width(x + width + R->TermWin.fwidth - 1); |
1682 | rc[PART_END].col = Pixel2Width(x + width + TermWin.fwidth - 1); |
1656 | rc[PART_END].row = Pixel2Row(y + height + R->TermWin.fheight - 1); |
1683 | rc[PART_END].row = Pixel2Row(y + height + TermWin.fheight - 1); |
1657 | |
1684 | |
1658 | /* sanity checks */ |
1685 | /* sanity checks */ |
1659 | for (i = PART_BEG; i < RC_COUNT; i++) { |
1686 | for (i = PART_BEG; i < RC_COUNT; i++) |
|
|
1687 | { |
1660 | MIN_IT(rc[i].col, R->TermWin.ncol - 1); |
1688 | MIN_IT(rc[i].col, TermWin.ncol - 1); |
1661 | MIN_IT(rc[i].row, R->TermWin.nrow - 1); |
1689 | MIN_IT(rc[i].row, TermWin.nrow - 1); |
1662 | } |
1690 | } |
1663 | |
1691 | |
1664 | D_SCREEN((stderr, "rxvt_scr_expose(x:%d, y:%d, w:%d, h:%d) area (c:%d,r:%d)-(c:%d,r:%d)", x, y, width, height, rc[PART_BEG].col, rc[PART_BEG].row, rc[PART_END].col, rc[PART_END].row)); |
1692 | D_SCREEN((stderr, "rxvt_scr_expose(x:%d, y:%d, w:%d, h:%d) area (c:%d,r:%d)-(c:%d,r:%d)", x, y, width, height, rc[PART_BEG].col, rc[PART_BEG].row, rc[PART_END].col, rc[PART_END].row)); |
1665 | |
1693 | |
1666 | for (i = rc[PART_BEG].row; i <= rc[PART_END].row; i++) |
1694 | for (i = rc[PART_BEG].row; i <= rc[PART_END].row; i++) |
1667 | fill_text (&(R->drawn_text[i][rc[PART_BEG].col]), 0, |
1695 | fill_text (&(drawn_text[i][rc[PART_BEG].col]), 0, |
1668 | (rc[PART_END].col - rc[PART_BEG].col + 1)); |
1696 | (rc[PART_END].col - rc[PART_BEG].col + 1)); |
1669 | |
1697 | |
1670 | if (refresh) |
1698 | if (refresh) |
1671 | rxvt_scr_refresh(aR_ SLOW_REFRESH | REFRESH_BOUNDS); |
1699 | scr_refresh (SLOW_REFRESH | REFRESH_BOUNDS); |
1672 | } |
1700 | } |
1673 | |
1701 | |
1674 | /* ------------------------------------------------------------------------- */ |
1702 | /* ------------------------------------------------------------------------- */ |
1675 | /* |
1703 | /* |
1676 | * Refresh the entire screen |
1704 | * Refresh the entire screen |
1677 | */ |
1705 | */ |
1678 | /* EXTPROTO */ |
|
|
1679 | void |
1706 | void |
1680 | rxvt_scr_touch(pR_ Bool refresh) |
1707 | rxvt_term::scr_touch (bool refresh) |
1681 | { |
1708 | { |
1682 | rxvt_scr_expose(aR_ 0, 0, R->TermWin.width, R->TermWin.height, refresh); |
1709 | scr_expose (0, 0, TermWin.width, TermWin.height, refresh); |
1683 | } |
1710 | } |
1684 | |
1711 | |
1685 | /* ------------------------------------------------------------------------- */ |
1712 | /* ------------------------------------------------------------------------- */ |
1686 | /* |
1713 | /* |
1687 | * Move the display so that the line represented by scrollbar value Y is at |
1714 | * Move the display so that the line represented by scrollbar value Y is at |
… | |
… | |
1806 | * Refresh the screen |
1833 | * Refresh the screen |
1807 | * R->drawn_text/R->drawn_rend contain the screen information before the update. |
1834 | * R->drawn_text/R->drawn_rend contain the screen information before the update. |
1808 | * R->screen.text/R->screen.rend contain what the screen will change to. |
1835 | * R->screen.text/R->screen.rend contain what the screen will change to. |
1809 | */ |
1836 | */ |
1810 | |
1837 | |
1811 | #if defined (NO_BRIGHTCOLOR) || defined (VERYBOLD) |
|
|
1812 | # define MONO_BOLD(x) ((x) & (RS_Bold|RS_Blink)) |
|
|
1813 | # define MONO_BOLD_FG(x, fg) MONO_BOLD(x) |
|
|
1814 | #else |
|
|
1815 | # define MONO_BOLD(x) \ |
|
|
1816 | (((x) & (RS_Bold | RS_fgMask)) == (RS_Bold | Color_fg)) |
|
|
1817 | # define MONO_BOLD_FG(x, fg) (((x) & RS_Bold) && (fg) == Color_fg) |
|
|
1818 | #endif |
|
|
1819 | |
|
|
1820 | #define FONT_WIDTH(X, Y) \ |
1838 | #define FONT_WIDTH(X, Y) \ |
1821 | (X)->per_char[(Y) - (X)->min_char_or_byte2].width |
1839 | (X)->per_char[(Y) - (X)->min_char_or_byte2].width |
1822 | #define FONT_RBEAR(X, Y) \ |
1840 | #define FONT_RBEAR(X, Y) \ |
1823 | (X)->per_char[(Y) - (X)->min_char_or_byte2].rbearing |
1841 | (X)->per_char[(Y) - (X)->min_char_or_byte2].rbearing |
1824 | #define FONT_LBEAR(X, Y) \ |
1842 | #define FONT_LBEAR(X, Y) \ |
1825 | (X)->per_char[(Y) - (X)->min_char_or_byte2].lbearing |
1843 | (X)->per_char[(Y) - (X)->min_char_or_byte2].lbearing |
1826 | #define IS_FONT_CHAR(X, Y) \ |
1844 | #define IS_FONT_CHAR(X, Y) \ |
1827 | ((Y) >= (X)->min_char_or_byte2 && (Y) <= (X)->max_char_or_byte2) |
1845 | ((Y) >= (X)->min_char_or_byte2 && (Y) <= (X)->max_char_or_byte2) |
1828 | |
1846 | |
1829 | /* EXTPROTO */ |
|
|
1830 | void |
1847 | void |
1831 | rxvt_scr_refresh(pR_ unsigned char refresh_type) |
1848 | rxvt_term::scr_refresh (unsigned char refresh_type) |
1832 | { |
1849 | { |
1833 | unsigned char clearfirst, /* first character writes before cell */ |
1850 | unsigned char clearfirst, /* first character writes before cell */ |
1834 | clearlast, /* last character writes beyond cell */ |
1851 | clearlast, /* last character writes beyond cell */ |
1835 | must_clear, /* use draw_string not draw_image_string */ |
1852 | must_clear, /* use draw_string not draw_image_string */ |
1836 | #ifndef NO_BOLDFONT |
|
|
1837 | bfont, /* we've changed font to bold font */ |
|
|
1838 | #endif |
|
|
1839 | rvid, /* reverse video this position */ |
1853 | rvid, /* reverse video this position */ |
1840 | wbyte, /* we're in multibyte */ |
|
|
1841 | showcursor; /* show the cursor */ |
1854 | showcursor; /* show the cursor */ |
1842 | int fore, back; /* desired foreground/background */ |
|
|
1843 | int16_t col, row, /* column/row we're processing */ |
1855 | int16_t col, row, /* column/row we're processing */ |
1844 | ocrow; /* old cursor row */ |
1856 | ocrow; /* old cursor row */ |
1845 | int cursorwidth; |
1857 | int cursorwidth; |
1846 | int i, /* tmp */ |
1858 | int i, /* tmp */ |
1847 | row_offset; /* basic offset in screen structure */ |
1859 | row_offset; /* basic offset in screen structure */ |
… | |
… | |
1849 | rend_t cc1; /* store colours at cursor position(s) */ |
1861 | rend_t cc1; /* store colours at cursor position(s) */ |
1850 | rend_t cc2; /* store colours at cursor position(s) */ |
1862 | rend_t cc2; /* store colours at cursor position(s) */ |
1851 | #endif |
1863 | #endif |
1852 | rend_t *drp, *srp; /* drawn-rend-pointer, screen-rend-pointer */ |
1864 | rend_t *drp, *srp; /* drawn-rend-pointer, screen-rend-pointer */ |
1853 | text_t *dtp, *stp; /* drawn-text-pointer, screen-text-pointer */ |
1865 | text_t *dtp, *stp; /* drawn-text-pointer, screen-text-pointer */ |
1854 | char *buffer; /* local copy of R->buffer */ |
|
|
1855 | |
1866 | |
1856 | if (refresh_type == NO_REFRESH || !R->TermWin.mapped) |
1867 | if (refresh_type == NO_REFRESH || !TermWin.mapped) |
1857 | return; |
1868 | return; |
1858 | |
1869 | |
1859 | /* |
1870 | /* |
1860 | * A: set up vars |
1871 | * A: set up vars |
1861 | */ |
1872 | */ |
1862 | clearfirst = clearlast = must_clear = wbyte = 0; |
1873 | clearfirst = clearlast = must_clear = 0; |
1863 | #ifndef NO_BOLDFONT |
|
|
1864 | bfont = 0; |
|
|
1865 | #endif |
|
|
1866 | |
1874 | |
1867 | if (R->currmaxcol < R->TermWin.ncol) |
1875 | if (currmaxcol < TermWin.ncol) |
1868 | { |
1876 | { |
1869 | R->currmaxcol = R->TermWin.ncol; |
1877 | currmaxcol = TermWin.ncol; |
1870 | R->buffer = (char *)rxvt_realloc (R->buffer, |
1878 | buffer = (char *)rxvt_realloc (buffer, |
1871 | sizeof(char) * (R->currmaxcol + 1) * MB_CUR_MAX); |
1879 | sizeof(char) * (currmaxcol + 1) * MB_CUR_MAX); |
1872 | } |
1880 | } |
1873 | |
1881 | |
1874 | buffer = R->buffer; |
|
|
1875 | R->refresh_count = 0; |
1882 | refresh_count = 0; |
1876 | |
1883 | |
1877 | row_offset = R->TermWin.saveLines - R->TermWin.view_start; |
1884 | row_offset = TermWin.saveLines - TermWin.view_start; |
1878 | |
1885 | |
1879 | if ((refresh_type & REFRESH_BOUNDS)) |
1886 | if ((refresh_type & REFRESH_BOUNDS)) |
1880 | { |
1887 | { |
1881 | clearfirst = clearlast = 1; |
1888 | clearfirst = clearlast = 1; |
1882 | R->refresh_type &= ~REFRESH_BOUNDS; |
1889 | refresh_type &= ~REFRESH_BOUNDS; |
1883 | } |
1890 | } |
1884 | |
1891 | |
1885 | #if defined(XPM_BACKGROUND) |
1892 | #if defined(XPM_BACKGROUND) |
1886 | must_clear |= (R->bgPixmap.pixmap != None); |
1893 | must_clear |= (bgPixmap.pixmap != None); |
1887 | #endif |
1894 | #endif |
1888 | #if defined(TRANSPARENT) |
1895 | #if defined(TRANSPARENT) |
1889 | must_clear |= ((R->Options & Opt_transparent) && R->am_transparent); |
1896 | must_clear |= ((Options & Opt_transparent) && am_transparent); |
1890 | #endif |
1897 | #endif |
1891 | ocrow = R->oldcursor.row; /* is there an old outline cursor on screen? */ |
1898 | ocrow = oldcursor.row; /* is there an old outline cursor on screen? */ |
1892 | |
1899 | |
1893 | /* |
1900 | /* |
1894 | * B: reverse any characters which are selected |
1901 | * B: reverse any characters which are selected |
1895 | */ |
1902 | */ |
1896 | rxvt_scr_reverse_selection(aR); |
1903 | rxvt_scr_reverse_selection (this); |
1897 | |
1904 | |
1898 | /* |
1905 | /* |
1899 | * C: set the cursor character(s) |
1906 | * C: set the cursor character(s) |
1900 | */ |
1907 | */ |
1901 | { |
1908 | { |
1902 | unsigned char setoldcursor; |
1909 | unsigned char setoldcursor; |
1903 | rend_t ccol1, /* Cursor colour */ |
1910 | rend_t ccol1, /* Cursor colour */ |
1904 | ccol2; /* Cursor colour2 */ |
1911 | ccol2; /* Cursor colour2 */ |
1905 | |
1912 | |
1906 | showcursor = (R->screen.flags & Screen_VisibleCursor); |
1913 | showcursor = (screen.flags & Screen_VisibleCursor); |
1907 | cursorwidth = 0; |
1914 | cursorwidth = 0; |
1908 | #ifdef CURSOR_BLINK |
1915 | #ifdef CURSOR_BLINK |
1909 | if (R->hidden_cursor) |
1916 | if (hidden_cursor) |
1910 | showcursor = 0; |
1917 | showcursor = 0; |
1911 | #endif |
1918 | #endif |
1912 | |
1919 | |
1913 | cursorwidth = 0; |
1920 | cursorwidth = 0; |
1914 | |
1921 | |
1915 | if (showcursor) |
1922 | if (showcursor) |
1916 | { |
1923 | { |
1917 | cursorwidth++; |
1924 | cursorwidth++; |
1918 | |
1925 | |
1919 | srp = &(R->screen.rend[R->screen.cur.row + R->TermWin.saveLines] |
1926 | srp = &(screen.rend[screen.cur.row + TermWin.saveLines] |
1920 | [R->screen.cur.col]); |
1927 | [screen.cur.col]); |
1921 | |
1928 | |
1922 | if (showcursor && R->TermWin.focus) |
1929 | if (showcursor && TermWin.focus) |
1923 | { |
1930 | { |
1924 | *srp ^= RS_RVid; |
1931 | *srp ^= RS_RVid; |
1925 | #ifndef NO_CURSORCOLOR |
1932 | #ifndef NO_CURSORCOLOR |
1926 | cc1 = *srp & (RS_fgMask | RS_bgMask); |
1933 | cc1 = *srp & (RS_fgMask | RS_bgMask); |
1927 | if (XDEPTH > 2 && ISSET_PIXCOLOR(R, Color_cursor)) |
1934 | if (Xdepth > 2 && ISSET_PIXCOLOR (this, Color_cursor)) |
1928 | ccol1 = Color_cursor; |
1935 | ccol1 = Color_cursor; |
1929 | else |
1936 | else |
1930 | #ifdef CURSOR_COLOR_IS_RENDITION_COLOR |
1937 | #ifdef CURSOR_COLOR_IS_RENDITION_COLOR |
1931 | ccol1 = GET_FGCOLOR(R->rstyle); |
1938 | ccol1 = GET_FGCOLOR(rstyle); |
1932 | #else |
1939 | #else |
1933 | ccol1 = Color_fg; |
1940 | ccol1 = Color_fg; |
1934 | #endif |
1941 | #endif |
1935 | if (XDEPTH > 2 && ISSET_PIXCOLOR(R, Color_cursor2)) |
1942 | if (Xdepth > 2 && ISSET_PIXCOLOR (this, Color_cursor2)) |
1936 | ccol2 = Color_cursor2; |
1943 | ccol2 = Color_cursor2; |
1937 | else |
1944 | else |
1938 | #ifdef CURSOR_COLOR_IS_RENDITION_COLOR |
1945 | #ifdef CURSOR_COLOR_IS_RENDITION_COLOR |
1939 | ccol2 = GET_BGCOLOR(R->rstyle); |
1946 | ccol2 = GET_BGCOLOR(rstyle); |
1940 | #else |
1947 | #else |
1941 | ccol2 = Color_bg; |
1948 | ccol2 = Color_bg; |
1942 | #endif |
1949 | #endif |
1943 | *srp = SET_FGCOLOR(*srp, ccol1); |
1950 | *srp = SET_FGCOLOR(*srp, ccol1); |
1944 | *srp = SET_BGCOLOR(*srp, ccol2); |
1951 | *srp = SET_BGCOLOR(*srp, ccol2); |
1945 | #endif |
1952 | #endif |
1946 | } |
1953 | } |
1947 | |
|
|
1948 | while (IS_WIDE (*srp)) |
|
|
1949 | cursorwidth++, srp++; |
|
|
1950 | } |
1954 | } |
1951 | |
1955 | |
1952 | /* make sure no outline cursor is left around */ |
1956 | /* make sure no outline cursor is left around */ |
1953 | setoldcursor = 0; |
1957 | setoldcursor = 0; |
1954 | if (ocrow != -1) { |
1958 | if (ocrow != -1) { |
1955 | if (R->screen.cur.row + R->TermWin.view_start != ocrow |
1959 | if (screen.cur.row + TermWin.view_start != ocrow |
1956 | || R->screen.cur.col != R->oldcursor.col) { |
1960 | || screen.cur.col != oldcursor.col) { |
1957 | if (ocrow < R->TermWin.nrow |
1961 | if (ocrow < TermWin.nrow |
1958 | && R->oldcursor.col < R->TermWin.ncol) { |
1962 | && oldcursor.col < TermWin.ncol) { |
1959 | R->drawn_rend[ocrow][R->oldcursor.col] ^= (RS_RVid | RS_Uline); |
1963 | drawn_rend[ocrow][oldcursor.col] ^= (RS_RVid | RS_Uline); |
1960 | } |
1964 | } |
1961 | if (R->TermWin.focus || !showcursor) |
1965 | if (TermWin.focus || !showcursor) |
1962 | R->oldcursor.row = -1; |
1966 | oldcursor.row = -1; |
1963 | else |
1967 | else |
1964 | setoldcursor = 1; |
1968 | setoldcursor = 1; |
1965 | } |
1969 | } |
1966 | } else if (!R->TermWin.focus) |
1970 | } else if (!TermWin.focus) |
1967 | setoldcursor = 1; |
1971 | setoldcursor = 1; |
1968 | if (setoldcursor) { |
1972 | if (setoldcursor) { |
1969 | if (R->screen.cur.row + R->TermWin.view_start >= R->TermWin.nrow) |
1973 | if (screen.cur.row + TermWin.view_start >= TermWin.nrow) |
1970 | R->oldcursor.row = -1; |
1974 | oldcursor.row = -1; |
1971 | else { |
1975 | else { |
1972 | R->oldcursor.row = R->screen.cur.row + R->TermWin.view_start; |
1976 | oldcursor.row = screen.cur.row + TermWin.view_start; |
1973 | R->oldcursor.col = R->screen.cur.col; |
1977 | oldcursor.col = screen.cur.col; |
1974 | } |
1978 | } |
1975 | } |
1979 | } |
1976 | } |
1980 | } |
1977 | |
1981 | |
1978 | #ifndef NO_SLOW_LINK_SUPPORT |
1982 | #ifndef NO_SLOW_LINK_SUPPORT |
1979 | /* |
1983 | /* |
1980 | * D: CopyArea pass - very useful for slower links |
1984 | * D: CopyArea pass - very useful for slower links |
1981 | * This has been deliberately kept simple. |
1985 | * This has been deliberately kept simple. |
1982 | */ |
1986 | */ |
1983 | i = R->num_scr; |
1987 | i = num_scr; |
1984 | if (refresh_type == FAST_REFRESH && R->num_scr_allow && i |
1988 | if (refresh_type == FAST_REFRESH && num_scr_allow && i |
1985 | && abs(i) < R->TermWin.nrow && !must_clear) |
1989 | && abs(i) < TermWin.nrow && !must_clear) |
1986 | { |
1990 | { |
1987 | int16_t nits; |
1991 | int16_t nits; |
1988 | int j; |
1992 | int j; |
1989 | rend_t *drp2; |
1993 | rend_t *drp2; |
1990 | text_t *dtp2; |
1994 | text_t *dtp2; |
1991 | int len, wlen; |
1995 | int len, wlen; |
1992 | |
1996 | |
1993 | j = R->TermWin.nrow; |
1997 | j = TermWin.nrow; |
1994 | wlen = len = -1; |
1998 | wlen = len = -1; |
1995 | row = i > 0 ? 0 : j - 1; |
1999 | row = i > 0 ? 0 : j - 1; |
1996 | for (; j-- >= 0; row += (i > 0 ? 1 : -1)) |
2000 | for (; j-- >= 0; row += (i > 0 ? 1 : -1)) |
1997 | { |
2001 | { |
1998 | if (row + i >= 0 && row + i < R->TermWin.nrow && row + i != ocrow) |
2002 | if (row + i >= 0 && row + i < TermWin.nrow && row + i != ocrow) |
1999 | { |
2003 | { |
2000 | stp = R->screen.text[row + row_offset]; |
2004 | stp = screen.text[row + row_offset]; |
2001 | srp = R->screen.rend[row + row_offset]; |
2005 | srp = screen.rend[row + row_offset]; |
2002 | dtp = R->drawn_text[row]; |
2006 | dtp = drawn_text[row]; |
2003 | dtp2 = R->drawn_text[row + i]; |
2007 | dtp2 = drawn_text[row + i]; |
2004 | drp = R->drawn_rend[row]; |
2008 | drp = drawn_rend[row]; |
2005 | drp2 = R->drawn_rend[row + i]; |
2009 | drp2 = drawn_rend[row + i]; |
2006 | |
2010 | |
2007 | for (nits = 0, col = R->TermWin.ncol; col--; ) |
2011 | for (nits = 0, col = TermWin.ncol; col--; ) |
2008 | if (stp[col] != dtp2[col] || srp[col] != drp2[col]) |
2012 | if (stp[col] != dtp2[col] || srp[col] != drp2[col]) |
2009 | nits--; |
2013 | nits--; |
2010 | else if (stp[col] != dtp[col] || srp[col] != drp[col]) |
2014 | else if (stp[col] != dtp[col] || srp[col] != drp[col]) |
2011 | nits++; |
2015 | nits++; |
2012 | |
2016 | |
2013 | if (nits > 8) /* XXX: arbitrary choice */ |
2017 | if (nits > 8) /* XXX: arbitrary choice */ |
2014 | { |
2018 | { |
2015 | for (col = R->TermWin.ncol; col--; ) |
2019 | for (col = TermWin.ncol; col--; ) |
2016 | { |
2020 | { |
2017 | *dtp++ = *dtp2++; |
2021 | *dtp++ = *dtp2++; |
2018 | *drp++ = *drp2++; |
2022 | *drp++ = *drp2++; |
2019 | } |
2023 | } |
2020 | |
2024 | |
… | |
… | |
2029 | if (len != -1) |
2033 | if (len != -1) |
2030 | { |
2034 | { |
2031 | /* also comes here at end if needed because of >= above */ |
2035 | /* also comes here at end if needed because of >= above */ |
2032 | if (wlen < len) |
2036 | if (wlen < len) |
2033 | SWAP_IT(wlen, len, int); |
2037 | SWAP_IT(wlen, len, int); |
|
|
2038 | |
2034 | D_SCREEN((stderr, "rxvt_scr_refresh(): XCopyArea: %d -> %d (height: %d)", len + i, len, wlen - len + 1)); |
2039 | D_SCREEN((stderr, "rxvt_scr_refresh(): XCopyArea: %d -> %d (height: %d)", len + i, len, wlen - len + 1)); |
2035 | XCopyArea(R->Xdisplay, R->TermWin.vt, R->TermWin.vt, |
2040 | XCopyArea (Xdisplay, TermWin.vt, TermWin.vt, |
2036 | R->TermWin.gc, 0, Row2Pixel(len + i), |
2041 | TermWin.gc, 0, Row2Pixel (len + i), |
2037 | (unsigned int)TermWin_TotalWidth(), |
2042 | (unsigned int)TermWin_TotalWidth (), |
2038 | (unsigned int)Height2Pixel(wlen - len + 1), |
2043 | (unsigned int)Height2Pixel (wlen - len + 1), |
2039 | 0, Row2Pixel(len)); |
2044 | 0, Row2Pixel (len)); |
2040 | len = -1; |
2045 | len = -1; |
2041 | } |
2046 | } |
2042 | } |
2047 | } |
2043 | } |
2048 | } |
2044 | #endif |
2049 | #endif |
2045 | |
2050 | |
2046 | /* |
2051 | /* |
2047 | * E: main pass across every character |
2052 | * E: main pass across every character |
2048 | */ |
2053 | */ |
2049 | for (row = 0; row < R->TermWin.nrow; row++) |
2054 | for (row = 0; row < TermWin.nrow; row++) |
2050 | { |
2055 | { |
2051 | stp = R->screen.text[row + row_offset]; |
2056 | stp = screen.text[row + row_offset]; |
2052 | srp = R->screen.rend[row + row_offset]; |
2057 | srp = screen.rend[row + row_offset]; |
2053 | dtp = R->drawn_text[row]; |
2058 | dtp = drawn_text[row]; |
2054 | drp = R->drawn_rend[row]; |
2059 | drp = drawn_rend[row]; |
2055 | |
2060 | |
2056 | /* |
2061 | /* |
2057 | * E2: OK, now the real pass |
2062 | * E2: OK, now the real pass |
2058 | */ |
2063 | */ |
2059 | int ypixel = (int)Row2Pixel(row); |
2064 | int ypixel = (int)Row2Pixel(row); |
2060 | |
2065 | |
2061 | for (col = 0; col < R->TermWin.ncol; col++) |
2066 | for (col = 0; col < TermWin.ncol; col++) |
2062 | { |
2067 | { |
2063 | /* compare new text with old - if exactly the same then continue */ |
2068 | /* compare new text with old - if exactly the same then continue */ |
2064 | rend_t rend = srp[col]; /* screen rendition (target rendtion) */ |
2069 | rend_t rend = srp[col]; /* screen rendition (target rendtion) */ |
2065 | |
2070 | |
2066 | if (stp[col] == dtp[col] /* Must match characters to skip. */ |
2071 | if (stp[col] == dtp[col] /* Must match characters to skip. */ |
… | |
… | |
2082 | |
2087 | |
2083 | int xpixel = Col2Pixel(col); |
2088 | int xpixel = Col2Pixel(col); |
2084 | |
2089 | |
2085 | // this loop looks very messy, it can probably be optimized |
2090 | // this loop looks very messy, it can probably be optimized |
2086 | // and cleaned a bit by you? |
2091 | // and cleaned a bit by you? |
2087 | for (i = 0; ++col < R->TermWin.ncol; ) |
2092 | for (i = 0; ++col < TermWin.ncol; ) |
2088 | { |
2093 | { |
2089 | if (stp[col] == NOCHAR) |
2094 | if (stp[col] == NOCHAR) |
2090 | { |
2095 | { |
2091 | dtp[col] = stp[col]; |
2096 | dtp[col] = stp[col]; |
2092 | drp[col] = rend; |
2097 | drp[col] = rend; |
… | |
… | |
2096 | i++; |
2101 | i++; |
2097 | |
2102 | |
2098 | continue; |
2103 | continue; |
2099 | } |
2104 | } |
2100 | |
2105 | |
2101 | if (((rend ^ srp[col]) & ~RS_wide) != 0) |
2106 | if (rend != srp[col]) |
2102 | break; |
2107 | break; |
2103 | |
2108 | |
2104 | count++; |
2109 | count++; |
2105 | |
2110 | |
2106 | if (stp[col] != dtp[col] |
2111 | if (stp[col] != dtp[col] |
… | |
… | |
2118 | } |
2123 | } |
2119 | |
2124 | |
2120 | col--; /* went one too far. move back */ |
2125 | col--; /* went one too far. move back */ |
2121 | count -= i; /* dump any matching trailing chars */ |
2126 | count -= i; /* dump any matching trailing chars */ |
2122 | |
2127 | |
2123 | /* |
2128 | /* |
2124 | * Determine the attributes for the string |
2129 | * Determine the attributes for the string |
2125 | */ |
2130 | */ |
2126 | int fid = GET_FONT(rend); |
2131 | int fid = GET_FONT (rend); |
2127 | fore = GET_FGCOLOR(rend); |
2132 | int fore = GET_FGCOLOR (rend); // desired foreground |
2128 | back = GET_BGCOLOR(rend); |
2133 | int back = GET_BGCOLOR (rend); // desired background |
|
|
2134 | |
2129 | rend = GET_ATTR(rend); |
2135 | rend = GET_ATTR (rend); |
2130 | |
2136 | |
2131 | rvid = (rend & RS_RVid) ? 1 : 0; |
2137 | rvid = !!(rend & RS_RVid); |
2132 | #ifdef OPTION_HC |
2138 | #ifdef OPTION_HC |
2133 | if (!rvid && (rend & RS_Blink)) |
2139 | if (!rvid && (rend & RS_Blink)) |
2134 | { |
2140 | { |
2135 | if (XDEPTH > 2 && ISSET_PIXCOLOR(R, Color_HC)) |
2141 | if (Xdepth > 2 && ISSET_PIXCOLOR (this, Color_HC)) |
2136 | back = Color_HC; |
2142 | back = Color_HC; |
2137 | else |
2143 | else |
2138 | rvid = !rvid; /* fall back */ |
2144 | rvid = !rvid; /* fall back */ |
2139 | } |
2145 | } |
2140 | #endif |
2146 | #endif |
2141 | if (rvid) |
2147 | if (rvid) |
2142 | { |
2148 | { |
2143 | SWAP_IT(fore, back, int); |
2149 | SWAP_IT(fore, back, int); |
2144 | |
2150 | |
2145 | #ifndef NO_BOLD_UNDERLINE_REVERSE |
2151 | #ifndef NO_BOLD_UNDERLINE_REVERSE |
2146 | if (XDEPTH > 2 && ISSET_PIXCOLOR(R, Color_RV) |
2152 | if (Xdepth > 2 && ISSET_PIXCOLOR (this, Color_RV) |
2147 | # ifndef NO_CURSORCOLOR |
2153 | # ifndef NO_CURSORCOLOR |
2148 | && !ISSET_PIXCOLOR(R, Color_cursor) |
2154 | && !ISSET_PIXCOLOR (this, Color_cursor) |
2149 | # endif |
2155 | # endif |
2150 | ) |
2156 | ) |
2151 | back = Color_RV; |
2157 | back = Color_RV; |
2152 | #endif |
2158 | #endif |
2153 | } |
2159 | } |
2154 | #ifndef NO_BOLD_UNDERLINE_REVERSE |
2160 | #ifndef NO_BOLD_UNDERLINE_REVERSE |
2155 | else if (rend & RS_Bold) |
2161 | else if (rend & RS_Bold) |
2156 | { |
2162 | { |
2157 | if (XDEPTH > 2 && ISSET_PIXCOLOR(R, Color_BD)) |
2163 | if (Xdepth > 2 && ISSET_PIXCOLOR (this, Color_BD)) |
2158 | { |
|
|
2159 | fore = Color_BD; |
2164 | fore = Color_BD; |
2160 | # ifndef VERYBOLD |
|
|
2161 | rend &= ~RS_Bold; /* we've taken care of it */ |
|
|
2162 | # endif |
|
|
2163 | } |
|
|
2164 | } |
2165 | } |
2165 | else if (rend & RS_Uline) |
2166 | else if (rend & RS_Uline) |
2166 | { |
2167 | { |
2167 | if (XDEPTH > 2 && ISSET_PIXCOLOR(R, Color_UL)) |
2168 | if (Xdepth > 2 && ISSET_PIXCOLOR (this, Color_UL)) |
2168 | { |
|
|
2169 | fore = Color_UL; |
2169 | fore = Color_UL; |
2170 | rend &= ~RS_Uline; /* we've taken care of it */ |
|
|
2171 | } |
|
|
2172 | } |
2170 | } |
2173 | #endif |
2171 | #endif |
2174 | |
2172 | |
2175 | /* |
2173 | /* |
2176 | * Actually do the drawing of the string here |
2174 | * Actually do the drawing of the string here |
2177 | */ |
2175 | */ |
2178 | rxvt_font *font = (*R->TermWin.fontset)[fid]; |
2176 | rxvt_font *font = (*TermWin.fontset)[fid]; |
2179 | |
2177 | |
2180 | if (back == Color_bg) |
2178 | if (back == Color_bg) |
2181 | { |
2179 | { |
2182 | if (must_clear) |
2180 | if (must_clear) |
2183 | { |
2181 | { |
… | |
… | |
2186 | { |
2184 | { |
2187 | font->draw (xpixel, ypixel, text, count, fore, -1); |
2185 | font->draw (xpixel, ypixel, text, count, fore, -1); |
2188 | goto nodraw; |
2186 | goto nodraw; |
2189 | } |
2187 | } |
2190 | |
2188 | |
2191 | CLEAR_CHARS(xpixel, ypixel, count); |
2189 | CLEAR_CHARS (xpixel, ypixel, count); |
2192 | nodraw: ; |
2190 | nodraw: ; |
2193 | } |
2191 | } |
2194 | else |
2192 | else |
2195 | font->draw (xpixel, ypixel, text, count, fore, Color_bg); |
2193 | font->draw (xpixel, ypixel, text, count, fore, Color_bg); |
2196 | } |
2194 | } |
2197 | else |
2195 | else |
2198 | font->draw (xpixel, ypixel, text, count, fore, back); |
2196 | font->draw (xpixel, ypixel, text, count, fore, back); |
2199 | |
2197 | |
2200 | if ((rend & RS_Uline) && (font->descent > 1)) |
2198 | if ((rend & RS_Uline) && (font->descent > 1)) |
2201 | XDrawLine(R->Xdisplay, drawBuffer, R->TermWin.gc, |
2199 | XDrawLine(Xdisplay, drawBuffer, TermWin.gc, |
2202 | xpixel, ypixel + font->ascent + 1, |
2200 | xpixel, ypixel + font->ascent + 1, |
2203 | xpixel + Width2Pixel(count) - 1, ypixel + font->ascent + 1); |
2201 | xpixel + Width2Pixel(count) - 1, ypixel + font->ascent + 1); |
2204 | } /* for (col....) */ |
2202 | } /* for (col....) */ |
2205 | } /* for (row....) */ |
2203 | } /* for (row....) */ |
2206 | |
2204 | |
2207 | /* |
2205 | /* |
2208 | * G: cleanup cursor and display outline cursor if necessary |
2206 | * G: cleanup cursor and display outline cursor if necessary |
2209 | */ |
2207 | */ |
2210 | if (showcursor) { |
2208 | if (showcursor) { |
2211 | if (R->TermWin.focus) { |
2209 | if (TermWin.focus) { |
2212 | srp = &(R->screen.rend[R->screen.cur.row + R->TermWin.saveLines] |
2210 | srp = &(screen.rend[screen.cur.row + TermWin.saveLines] |
2213 | [R->screen.cur.col]); |
2211 | [screen.cur.col]); |
2214 | *srp ^= RS_RVid; |
2212 | *srp ^= RS_RVid; |
2215 | #ifndef NO_CURSORCOLOR |
2213 | #ifndef NO_CURSORCOLOR |
2216 | *srp = (*srp & ~(RS_fgMask | RS_bgMask)) | cc1; |
2214 | *srp = (*srp & ~(RS_fgMask | RS_bgMask)) | cc1; |
2217 | #endif |
2215 | #endif |
2218 | } else if (R->oldcursor.row >= 0) { |
2216 | } else if (oldcursor.row >= 0) { |
2219 | #ifndef NO_CURSORCOLOR |
2217 | #ifndef NO_CURSORCOLOR |
2220 | unsigned long gcmask; /* Graphics Context mask */ |
2218 | unsigned long gcmask; /* Graphics Context mask */ |
2221 | |
2219 | |
2222 | if (XDEPTH > 2 && ISSET_PIXCOLOR(R, Color_cursor)) { |
2220 | if (Xdepth > 2 && ISSET_PIXCOLOR (this, Color_cursor)) |
2223 | XSetForeground (R->Xdisplay, R->TermWin.gc, R->PixColors[Color_cursor]); |
2221 | XSetForeground (Xdisplay, TermWin.gc, PixColors[Color_cursor]); |
2224 | } |
|
|
2225 | #endif |
2222 | #endif |
2226 | XDrawRectangle(R->Xdisplay, drawBuffer, R->TermWin.gc, |
2223 | XDrawRectangle(Xdisplay, drawBuffer, TermWin.gc, |
2227 | Col2Pixel(R->oldcursor.col), |
2224 | Col2Pixel(oldcursor.col), |
2228 | Row2Pixel(R->oldcursor.row), |
2225 | Row2Pixel(oldcursor.row), |
2229 | (unsigned int)(Width2Pixel(cursorwidth) - 1), |
2226 | (unsigned int)(Width2Pixel(cursorwidth) - 1), |
2230 | (unsigned int)(Height2Pixel(1) - R->TermWin.lineSpace - 1)); |
2227 | (unsigned int)(Height2Pixel(1) - TermWin.lineSpace - 1)); |
2231 | } |
2228 | } |
2232 | } |
2229 | } |
2233 | /* |
2230 | |
|
|
2231 | /* |
2234 | * H: cleanup selection |
2232 | * H: cleanup selection |
2235 | */ |
2233 | */ |
2236 | rxvt_scr_reverse_selection(aR); |
2234 | rxvt_scr_reverse_selection (this); |
2237 | |
2235 | |
2238 | /* |
2236 | /* |
2239 | * I: other general cleanup |
2237 | * I: other general cleanup |
2240 | */ |
2238 | */ |
2241 | if (clearfirst && R->TermWin.int_bwidth) |
2239 | if (clearfirst && TermWin.int_bwidth) |
2242 | /* |
2240 | /* |
2243 | * clear the whole screen height, note that width == 0 is treated |
2241 | * clear the whole screen height, note that width == 0 is treated |
2244 | * specially by XClearArea |
2242 | * specially by XClearArea |
2245 | */ |
2243 | */ |
2246 | XClearArea(R->Xdisplay, R->TermWin.vt, 0, 0, |
2244 | XClearArea(Xdisplay, TermWin.vt, 0, 0, |
2247 | (unsigned int)R->TermWin.int_bwidth, |
2245 | (unsigned int)TermWin.int_bwidth, |
2248 | (unsigned int)TermWin_TotalHeight(), False); |
2246 | (unsigned int)TermWin_TotalHeight(), False); |
2249 | if (clearlast && R->TermWin.int_bwidth) |
2247 | if (clearlast && TermWin.int_bwidth) |
2250 | /* |
2248 | /* |
2251 | * clear the whole screen height, note that width == 0 is treated |
2249 | * clear the whole screen height, note that width == 0 is treated |
2252 | * specially by XClearArea |
2250 | * specially by XClearArea |
2253 | */ |
2251 | */ |
2254 | XClearArea(R->Xdisplay, R->TermWin.vt, |
2252 | XClearArea(Xdisplay, TermWin.vt, |
2255 | R->TermWin.width + R->TermWin.int_bwidth, 0, |
2253 | TermWin.width + TermWin.int_bwidth, 0, |
2256 | (unsigned int)R->TermWin.int_bwidth, |
2254 | (unsigned int)TermWin.int_bwidth, |
2257 | (unsigned int)TermWin_TotalHeight(), False); |
2255 | (unsigned int)TermWin_TotalHeight(), False); |
2258 | if (refresh_type & SMOOTH_REFRESH) |
2256 | if (refresh_type & SMOOTH_REFRESH) |
2259 | XSync(R->Xdisplay, False); |
2257 | XSync(Xdisplay, False); |
2260 | |
2258 | |
2261 | R->num_scr = 0; |
2259 | num_scr = 0; |
2262 | R->num_scr_allow = 1; |
2260 | num_scr_allow = 1; |
2263 | R->want_refresh = 0; /* screen is current */ |
2261 | want_refresh = 0; /* screen is current */ |
2264 | } |
2262 | } |
2265 | /* ------------------------------------------------------------------------- */ |
|
|
2266 | |
2263 | |
2267 | /* EXTPROTO */ |
2264 | /* ------------------------------------------------------------------------- */ |
2268 | void |
2265 | void |
2269 | rxvt_scr_clear(pR) |
2266 | rxvt_term::scr_clear() |
2270 | { |
2267 | { |
2271 | if (!R->TermWin.mapped) |
2268 | if (!TermWin.mapped) |
2272 | return; |
2269 | return; |
|
|
2270 | |
2273 | R->num_scr_allow = 0; |
2271 | num_scr_allow = 0; |
2274 | R->want_refresh = 1; |
2272 | want_refresh = 1; |
2275 | #ifdef TRANSPARENT |
2273 | #ifdef TRANSPARENT |
2276 | if ((R->Options & Opt_transparent) && (R->am_pixmap_trans == 0)) { |
2274 | if ((Options & Opt_transparent) && (am_pixmap_trans == 0)) |
2277 | int i; |
2275 | { |
|
|
2276 | int i; |
2278 | |
2277 | |
2279 | if (!(R->Options & Opt_transparent_all)) |
2278 | if (!(Options & Opt_transparent_all)) |
2280 | i = 0; |
2279 | i = 0; |
2281 | else |
2280 | else |
2282 | i = (int)(sizeof(R->TermWin.parent) / sizeof(Window)); |
2281 | i = (int)(sizeof(TermWin.parent) / sizeof(Window)); |
2283 | for (; i--;) |
2282 | |
|
|
2283 | while (i--) |
2284 | if (R->TermWin.parent[i] != None) |
2284 | if (TermWin.parent[i] != None) |
2285 | XClearWindow(R->Xdisplay, R->TermWin.parent[i]); |
2285 | XClearWindow(Xdisplay, TermWin.parent[i]); |
2286 | } |
2286 | } |
2287 | #endif |
2287 | #endif |
|
|
2288 | |
2288 | XClearWindow(R->Xdisplay, R->TermWin.vt); |
2289 | XClearWindow (Xdisplay, TermWin.vt); |
2289 | } |
2290 | } |
2290 | |
2291 | |
2291 | /* ------------------------------------------------------------------------- */ |
2292 | /* ------------------------------------------------------------------------- */ |
2292 | /* INTPROTO */ |
2293 | /* INTPROTO */ |
2293 | void |
2294 | void |
… | |
… | |
2401 | rxvt_term::paste (const unsigned char *data, unsigned int len) |
2402 | rxvt_term::paste (const unsigned char *data, unsigned int len) |
2402 | { |
2403 | { |
2403 | unsigned int i, j, n; |
2404 | unsigned int i, j, n; |
2404 | unsigned char *ds = (unsigned char *)rxvt_malloc (PROP_SIZE); |
2405 | unsigned char *ds = (unsigned char *)rxvt_malloc (PROP_SIZE); |
2405 | |
2406 | |
|
|
2407 | #if 0 |
|
|
2408 | /* a paste should act like the user is typing, so check scrollTtyKeypress */ |
|
|
2409 | ZERO_SCROLLBACK (r); |
|
|
2410 | #endif |
|
|
2411 | |
2406 | /* convert normal newline chars into common keyboard Return key sequence */ |
2412 | /* convert normal newline chars into common keyboard Return key sequence */ |
2407 | for (i = 0; i < len; i += PROP_SIZE) |
2413 | for (i = 0; i < len; i += PROP_SIZE) |
2408 | { |
2414 | { |
2409 | n = min (len - i, PROP_SIZE); |
2415 | n = min (len - i, PROP_SIZE); |
2410 | MEMCPY (ds, data + i, n); |
2416 | MEMCPY (ds, data + i, n); |
… | |
… | |
2429 | rxvt_selection_paste(pR_ Window win, Atom prop, Bool delete_prop) |
2435 | rxvt_selection_paste(pR_ Window win, Atom prop, Bool delete_prop) |
2430 | { |
2436 | { |
2431 | long nread = 0; |
2437 | long nread = 0; |
2432 | unsigned long bytes_after; |
2438 | unsigned long bytes_after; |
2433 | XTextProperty ct; |
2439 | XTextProperty ct; |
2434 | int dummy_count; |
|
|
2435 | char **cl; |
|
|
2436 | |
2440 | |
2437 | D_SELECT((stderr, "rxvt_selection_paste(%08lx, %lu, %d), wait=%2x", win, (unsigned long)prop, (int)delete_prop, R->selection_wait)); |
2441 | D_SELECT((stderr, "rxvt_selection_paste(%08lx, %lu, %d), wait=%2x", win, (unsigned long)prop, (int)delete_prop, R->selection_wait)); |
2438 | |
2442 | |
2439 | if (prop == None) /* check for failed XConvertSelection */ |
2443 | if (prop == None) /* check for failed XConvertSelection */ |
2440 | { |
2444 | { |
… | |
… | |
2443 | int selnum = R->selection_type & Sel_whereMask; |
2447 | int selnum = R->selection_type & Sel_whereMask; |
2444 | |
2448 | |
2445 | R->selection_type = 0; |
2449 | R->selection_type = 0; |
2446 | if (selnum != Sel_direct) |
2450 | if (selnum != Sel_direct) |
2447 | rxvt_selection_request_other(aR_ XA_STRING, selnum); |
2451 | rxvt_selection_request_other(aR_ XA_STRING, selnum); |
|
|
2452 | } |
|
|
2453 | |
|
|
2454 | if ((R->selection_type & Sel_UTF8String)) |
|
|
2455 | { |
|
|
2456 | int selnum = R->selection_type & Sel_whereMask; |
|
|
2457 | |
|
|
2458 | R->selection_type = Sel_CompoundText; |
|
|
2459 | if (selnum != Sel_direct) |
|
|
2460 | rxvt_selection_request_other(aR_ R->xa[XA_COMPOUND_TEXT], selnum); |
|
|
2461 | else |
|
|
2462 | R->selection_type = 0; |
2448 | } |
2463 | } |
2449 | |
2464 | |
2450 | return 0; |
2465 | return 0; |
2451 | } |
2466 | } |
2452 | |
2467 | |
… | |
… | |
2487 | nread = -1; /* discount any previous stuff */ |
2502 | nread = -1; /* discount any previous stuff */ |
2488 | break; |
2503 | break; |
2489 | } |
2504 | } |
2490 | |
2505 | |
2491 | nread += ct.nitems; |
2506 | nread += ct.nitems; |
|
|
2507 | |
|
|
2508 | char **cl; |
|
|
2509 | int cr; |
2492 | if (XmbTextPropertyToTextList (R->Xdisplay, &ct, &cl, |
2510 | if (XmbTextPropertyToTextList (R->Xdisplay, &ct, &cl, |
2493 | &dummy_count) == Success && cl) |
2511 | &cr) >= 0 && cl) |
2494 | { |
2512 | { |
|
|
2513 | for (int i = 0; i < cr; i++) |
2495 | R->paste ((unsigned char *)cl[0], STRLEN (cl[0])); |
2514 | R->paste ((unsigned char *)cl[i], STRLEN (cl[i])); |
|
|
2515 | |
2496 | XFreeStringList (cl); |
2516 | XFreeStringList (cl); |
2497 | } |
2517 | } |
2498 | else |
2518 | else |
2499 | R->paste (ct.value, ct.nitems); |
2519 | R->paste (ct.value, ct.nitems); |
2500 | |
2520 | |
… | |
… | |
2515 | } |
2535 | } |
2516 | |
2536 | |
2517 | void |
2537 | void |
2518 | rxvt_term::incr_cb (time_watcher &w) |
2538 | rxvt_term::incr_cb (time_watcher &w) |
2519 | { |
2539 | { |
2520 | w.stop (); |
|
|
2521 | selection_wait = Sel_none; |
2540 | selection_wait = Sel_none; |
2522 | |
2541 | |
2523 | rxvt_print_error("data loss: timeout on INCR selection paste"); |
2542 | rxvt_print_error ("data loss: timeout on INCR selection paste"); |
2524 | } |
2543 | } |
2525 | |
2544 | |
2526 | /* |
2545 | /* |
2527 | * INCR support originally provided by Paul Sheer <psheer@obsidian.co.za> |
2546 | * INCR support originally provided by Paul Sheer <psheer@obsidian.co.za> |
2528 | */ |
2547 | */ |
… | |
… | |
2594 | int i; |
2613 | int i; |
2595 | |
2614 | |
2596 | R->selection_request_time = tm; |
2615 | R->selection_request_time = tm; |
2597 | R->selection_wait = Sel_normal; |
2616 | R->selection_wait = Sel_normal; |
2598 | for (i = Sel_Primary; i <= Sel_Clipboard; i++) { |
2617 | for (i = Sel_Primary; i <= Sel_Clipboard; i++) { |
|
|
2618 | #if X_HAVE_UTF8_STRING |
|
|
2619 | R->selection_type = Sel_UTF8String; |
|
|
2620 | if (rxvt_selection_request_other(aR_ R->xa[XA_UTF8_STRING], i)) |
|
|
2621 | return; |
|
|
2622 | #else |
2599 | R->selection_type = Sel_CompoundText; |
2623 | R->selection_type = Sel_CompoundText; |
2600 | if (rxvt_selection_request_other(aR_ R->xa[XA_COMPOUND_TEXT], i)) |
2624 | if (rxvt_selection_request_other(aR_ R->xa[XA_COMPOUND_TEXT], i)) |
2601 | return; |
2625 | return; |
|
|
2626 | #endif |
2602 | } |
2627 | } |
2603 | } |
2628 | } |
2604 | R->selection_wait = Sel_none; /* don't loop in rxvt_selection_paste() */ |
2629 | R->selection_wait = Sel_none; /* don't loop in rxvt_selection_paste() */ |
2605 | D_SELECT((stderr, "rxvt_selection_request: pasting CUT_BUFFER0")); |
2630 | D_SELECT((stderr, "rxvt_selection_request: pasting CUT_BUFFER0")); |
2606 | rxvt_selection_paste(aR_ Xroot, XA_CUT_BUFFER0, False); |
2631 | rxvt_selection_paste(aR_ Xroot, XA_CUT_BUFFER0, False); |
… | |
… | |
2738 | { |
2763 | { |
2739 | free (new_selection_text); |
2764 | free (new_selection_text); |
2740 | return; |
2765 | return; |
2741 | } |
2766 | } |
2742 | |
2767 | |
2743 | // due to MB_MAX_CUR, selection wastage is usually high |
2768 | // due to MB_MAX_CUR, selection wastage is usually high, so realloc |
2744 | if (str - (char *)new_selection_text > 1024) |
2769 | if (str - (char *)new_selection_text > 1024) |
2745 | new_selection_text = (unsigned char *)rxvt_realloc (new_selection_text, i + 1); |
2770 | new_selection_text = (unsigned char *)rxvt_realloc (new_selection_text, i + 1); |
2746 | |
2771 | |
2747 | R->selection.len = i; |
2772 | R->selection.len = i; |
|
|
2773 | |
2748 | if (R->selection.text) |
2774 | if (R->selection.text) |
2749 | free (R->selection.text); |
2775 | free (R->selection.text); |
2750 | |
2776 | |
2751 | R->selection.text = new_selection_text; |
2777 | R->selection.text = new_selection_text; |
2752 | |
2778 | |
2753 | XSetSelectionOwner(R->Xdisplay, XA_PRIMARY, R->TermWin.vt, tm); |
2779 | XSetSelectionOwner(R->Xdisplay, XA_PRIMARY, R->TermWin.vt, tm); |
2754 | if (XGetSelectionOwner(R->Xdisplay, XA_PRIMARY) != R->TermWin.vt) |
2780 | if (XGetSelectionOwner(R->Xdisplay, XA_PRIMARY) != R->TermWin.vt) |
2755 | rxvt_print_error("can't get primary selection"); |
2781 | rxvt_print_error("can't get primary selection"); |
|
|
2782 | |
|
|
2783 | |
|
|
2784 | { |
|
|
2785 | XTextProperty ct; |
|
|
2786 | char *cl = (char *)R->selection.text; |
|
|
2787 | |
|
|
2788 | if (XmbTextListToTextProperty(R->Xdisplay, &cl, 1, XStringStyle, &ct) >= 0) |
|
|
2789 | { |
|
|
2790 | XChangeProperty(R->Xdisplay, Xroot, XA_CUT_BUFFER0, XA_STRING, 8, |
|
|
2791 | PropModeReplace, ct.value, ct.nitems); |
|
|
2792 | XFree (ct.value); |
|
|
2793 | } |
|
|
2794 | else |
2756 | XChangeProperty(R->Xdisplay, Xroot, XA_CUT_BUFFER0, XA_STRING, 8, |
2795 | XChangeProperty(R->Xdisplay, Xroot, XA_CUT_BUFFER0, XA_STRING, 8, |
2757 | PropModeReplace, R->selection.text, (int)R->selection.len); |
2796 | PropModeReplace, R->selection.text, (int)R->selection.len); |
|
|
2797 | } |
|
|
2798 | |
2758 | R->selection_time = tm; |
2799 | R->selection_time = tm; |
2759 | D_SELECT((stderr, "rxvt_selection_make(): R->selection.len=%d", R->selection.len)); |
2800 | D_SELECT((stderr, "rxvt_selection_make(): R->selection.len=%d", R->selection.len)); |
2760 | } |
2801 | } |
2761 | |
2802 | |
2762 | /* ------------------------------------------------------------------------- */ |
2803 | /* ------------------------------------------------------------------------- */ |
2763 | /* |
2804 | /* |
2764 | * Mark or select text based upon number of clicks: 1, 2, or 3 |
2805 | * Mark or select text based upon number of clicks: 1, 2, or 3 |
2765 | * EXT: button 1 press |
2806 | * EXT: button 1 press |
2766 | */ |
2807 | */ |
2767 | /* EXTPROTO */ |
|
|
2768 | void |
2808 | void |
2769 | rxvt_selection_click(pR_ int clicks, int x, int y) |
2809 | rxvt_term::selection_click (int clicks, int x, int y) |
2770 | { |
2810 | { |
2771 | D_SELECT((stderr, "rxvt_selection_click(%d, %d, %d)", clicks, x, y)); |
2811 | D_SELECT((stderr, "rxvt_selection_click(%d, %d, %d)", clicks, x, y)); |
2772 | |
2812 | |
2773 | clicks = ((clicks - 1) % 3) + 1; |
2813 | clicks = ((clicks - 1) % 3) + 1; |
2774 | R->selection.clicks = clicks; /* save clicks so extend will work */ |
2814 | selection.clicks = clicks; /* save clicks so extend will work */ |
2775 | |
2815 | |
2776 | rxvt_selection_start_colrow(aR_ Pixel2Col(x), Pixel2Row(y)); |
2816 | rxvt_selection_start_colrow (this, Pixel2Col(x), Pixel2Row(y)); |
|
|
2817 | |
2777 | if (clicks == 2 || clicks == 3) |
2818 | if (clicks == 2 || clicks == 3) |
2778 | rxvt_selection_extend_colrow(aR_ R->selection.mark.col, |
2819 | rxvt_selection_extend_colrow (this, selection.mark.col, |
2779 | R->selection.mark.row |
|
|
2780 | + R->TermWin.view_start, |
2820 | selection.mark.row + TermWin.view_start, |
2781 | 0, /* button 3 */ |
2821 | 0, /* button 3 */ |
2782 | 1, /* button press */ |
2822 | 1, /* button press */ |
2783 | 0); /* click change */ |
2823 | 0); /* click change */ |
2784 | } |
2824 | } |
2785 | |
2825 | |
2786 | /* ------------------------------------------------------------------------- */ |
2826 | /* ------------------------------------------------------------------------- */ |
2787 | /* |
2827 | /* |
2788 | * Mark a selection at the specified col/row |
2828 | * Mark a selection at the specified col/row |
… | |
… | |
2898 | * EXT: button 3 press; button 1 or 3 drag |
2938 | * EXT: button 3 press; button 1 or 3 drag |
2899 | * flag == 0 ==> button 1 |
2939 | * flag == 0 ==> button 1 |
2900 | * flag == 1 ==> button 3 press |
2940 | * flag == 1 ==> button 3 press |
2901 | * flag == 2 ==> button 3 motion |
2941 | * flag == 2 ==> button 3 motion |
2902 | */ |
2942 | */ |
2903 | /* EXTPROTO */ |
|
|
2904 | void |
2943 | void |
2905 | rxvt_selection_extend(pR_ int x, int y, int flag) |
2944 | rxvt_term::selection_extend (int x, int y, int flag) |
2906 | { |
2945 | { |
2907 | int col, row; |
2946 | int col, row; |
2908 | |
2947 | |
2909 | col = Pixel2Col(x); |
2948 | col = Pixel2Col(x); |
2910 | row = Pixel2Row(y); |
2949 | row = Pixel2Row(y); |
2911 | MAX_IT(row, 0); |
2950 | MAX_IT(row, 0); |
2912 | MIN_IT(row, (int)R->TermWin.nrow - 1); |
2951 | MIN_IT(row, (int)TermWin.nrow - 1); |
2913 | MAX_IT(col, 0); |
2952 | MAX_IT(col, 0); |
2914 | MIN_IT(col, (int)R->TermWin.ncol); |
2953 | MIN_IT(col, (int)TermWin.ncol); |
|
|
2954 | |
2915 | #ifndef NO_NEW_SELECTION |
2955 | #ifndef NO_NEW_SELECTION |
2916 | /* |
2956 | /* |
2917 | * If we're selecting characters (single click) then we must check first |
2957 | * If we're selecting characters (single click) then we must check first |
2918 | * if we are at the same place as the original mark. If we are then |
2958 | * if we are at the same place as the original mark. If we are then |
2919 | * select nothing. Otherwise, if we're to the right of the mark, you have to |
2959 | * select nothing. Otherwise, if we're to the right of the mark, you have to |
2920 | * be _past_ a character for it to be selected. |
2960 | * be _past_ a character for it to be selected. |
2921 | */ |
2961 | */ |
2922 | if (R->selection_style != OLD_SELECT) { |
2962 | if (selection_style != OLD_SELECT) |
|
|
2963 | { |
2923 | if (((R->selection.clicks % 3) == 1) && !flag |
2964 | if (((selection.clicks % 3) == 1) && !flag |
2924 | && (col == R->selection.mark.col |
2965 | && (col == selection.mark.col |
2925 | && (row == R->selection.mark.row + R->TermWin.view_start))) { |
2966 | && (row == selection.mark.row + TermWin.view_start))) |
|
|
2967 | { |
2926 | /* select nothing */ |
2968 | /* select nothing */ |
2927 | R->selection.beg.row = R->selection.end.row = 0; |
2969 | selection.beg.row = selection.end.row = 0; |
2928 | R->selection.beg.col = R->selection.end.col = 0; |
2970 | selection.beg.col = selection.end.col = 0; |
2929 | R->selection.clicks = 4; |
2971 | selection.clicks = 4; |
2930 | R->want_refresh = 1; |
2972 | want_refresh = 1; |
2931 | D_SELECT((stderr, "rxvt_selection_extend() R->selection.clicks = 4")); |
2973 | D_SELECT((stderr, "rxvt_selection_extend() selection.clicks = 4")); |
2932 | return; |
2974 | return; |
2933 | } |
2975 | } |
2934 | } |
2976 | } |
2935 | #endif |
2977 | #endif |
2936 | if (R->selection.clicks == 4) |
2978 | if (selection.clicks == 4) |
2937 | R->selection.clicks = 1; |
2979 | selection.clicks = 1; |
|
|
2980 | |
2938 | rxvt_selection_extend_colrow(aR_ col, row, !!flag, /* ? button 3 */ |
2981 | rxvt_selection_extend_colrow (this, col, row, !!flag, /* ? button 3 */ |
2939 | flag == 1 ? 1 : 0, /* ? button press */ |
2982 | flag == 1 ? 1 : 0, /* ? button press */ |
2940 | 0); /* no click change */ |
2983 | 0); /* no click change */ |
2941 | } |
2984 | } |
2942 | |
2985 | |
2943 | /* ------------------------------------------------------------------------- */ |
2986 | /* ------------------------------------------------------------------------- */ |
2944 | /* |
2987 | /* |
2945 | * Extend the selection to the specified col/row |
2988 | * Extend the selection to the specified col/row |
… | |
… | |
3199 | /* ------------------------------------------------------------------------- */ |
3242 | /* ------------------------------------------------------------------------- */ |
3200 | /* |
3243 | /* |
3201 | * Double click on button 3 when already selected |
3244 | * Double click on button 3 when already selected |
3202 | * EXT: button 3 double click |
3245 | * EXT: button 3 double click |
3203 | */ |
3246 | */ |
3204 | /* EXTPROTO */ |
|
|
3205 | void |
3247 | void |
3206 | rxvt_selection_rotate(pR_ int x, int y) |
3248 | rxvt_term::selection_rotate (int x, int y) |
3207 | { |
3249 | { |
3208 | R->selection.clicks = R->selection.clicks % 3 + 1; |
3250 | selection.clicks = selection.clicks % 3 + 1; |
3209 | rxvt_selection_extend_colrow(aR_ Pixel2Col(x), Pixel2Row(y), 1, 0, 1); |
3251 | rxvt_selection_extend_colrow (this, Pixel2Col(x), Pixel2Row(y), 1, 0, 1); |
3210 | } |
3252 | } |
3211 | |
3253 | |
3212 | /* ------------------------------------------------------------------------- */ |
3254 | /* ------------------------------------------------------------------------- */ |
3213 | /* |
3255 | /* |
3214 | * On some systems, the Atom typedef is 64 bits wide. We need to have a type |
3256 | * On some systems, the Atom typedef is 64 bits wide. We need to have a type |
3215 | * that is exactly 32 bits wide, because a format of 64 is not allowed by |
3257 | * that is exactly 32 bits wide, because a format of 64 is not allowed by |
3216 | * the X11 protocol. |
3258 | * the X11 protocol. |
3217 | */ |
3259 | */ |
3218 | typedef CARD32 Atom32; |
3260 | typedef CARD32 Atom32; |
3219 | |
3261 | |
3220 | /* ------------------------------------------------------------------------- */ |
3262 | /* ------------------------------------------------------------------------- */ |
3221 | /* |
3263 | /* |
3222 | * Respond to a request for our current selection |
3264 | * Respond to a request for our current selection |
3223 | * EXT: SelectionRequest |
3265 | * EXT: SelectionRequest |
… | |
… | |
3225 | /* EXTPROTO */ |
3267 | /* EXTPROTO */ |
3226 | void |
3268 | void |
3227 | rxvt_selection_send(pR_ const XSelectionRequestEvent *rq) |
3269 | rxvt_selection_send(pR_ const XSelectionRequestEvent *rq) |
3228 | { |
3270 | { |
3229 | XSelectionEvent ev; |
3271 | XSelectionEvent ev; |
3230 | #ifdef USE_XIM |
|
|
3231 | Atom32 target_list[4]; |
|
|
3232 | #else |
|
|
3233 | Atom32 target_list[3]; |
|
|
3234 | #endif |
|
|
3235 | Atom target; |
|
|
3236 | XTextProperty ct; |
3272 | XTextProperty ct; |
3237 | XICCEncodingStyle style; |
3273 | XICCEncodingStyle style; |
3238 | char *cl[2], dummy[1]; |
3274 | Atom target; |
3239 | |
3275 | |
3240 | ev.type = SelectionNotify; |
3276 | ev.type = SelectionNotify; |
3241 | ev.property = None; |
3277 | ev.property = None; |
3242 | ev.display = rq->display; |
3278 | ev.display = rq->display; |
3243 | ev.requestor = rq->requestor; |
3279 | ev.requestor = rq->requestor; |
3244 | ev.selection = rq->selection; |
3280 | ev.selection = rq->selection; |
3245 | ev.target = rq->target; |
3281 | ev.target = rq->target; |
3246 | ev.time = rq->time; |
3282 | ev.time = rq->time; |
3247 | |
3283 | |
3248 | if (rq->target == R->xa[XA_TARGETS]) { |
3284 | if (rq->target == R->xa[XA_TARGETS]) { |
|
|
3285 | Atom32 target_list[5]; |
|
|
3286 | Atom32 *target = target_list; |
|
|
3287 | |
3249 | target_list[0] = (Atom32) R->xa[XA_TARGETS]; |
3288 | *target++ = (Atom32) R->xa[XA_TARGETS]; |
3250 | target_list[1] = (Atom32) XA_STRING; |
3289 | *target++ = (Atom32) XA_STRING; |
3251 | target_list[2] = (Atom32) R->xa[XA_TEXT]; |
3290 | *target++ = (Atom32) R->xa[XA_TEXT]; |
3252 | #ifdef USE_XIM |
|
|
3253 | target_list[3] = (Atom32) R->xa[XA_COMPOUND_TEXT]; |
3291 | *target++ = (Atom32) R->xa[XA_COMPOUND_TEXT]; |
|
|
3292 | #if X_HAVE_UTF8_STRING |
|
|
3293 | *target++ = (Atom32) R->xa[XA_UTF8_STRING]; |
3254 | #endif |
3294 | #endif |
3255 | XChangeProperty(R->Xdisplay, rq->requestor, rq->property, XA_ATOM, |
3295 | XChangeProperty(R->Xdisplay, rq->requestor, rq->property, XA_ATOM, |
3256 | (8 * sizeof(target_list[0])), PropModeReplace, |
3296 | (8 * sizeof(target_list[0])), PropModeReplace, |
3257 | (unsigned char *)target_list, |
3297 | (unsigned char *)target_list, |
3258 | (sizeof(target_list) / sizeof(target_list[0]))); |
3298 | target - target_list); |
3259 | ev.property = rq->property; |
3299 | ev.property = rq->property; |
3260 | } else if (rq->target == R->xa[XA_MULTIPLE]) { |
3300 | } else if (rq->target == R->xa[XA_MULTIPLE]) { |
3261 | /* TODO: Handle MULTIPLE */ |
3301 | /* TODO: Handle MULTIPLE */ |
3262 | } else if (rq->target == R->xa[XA_TIMESTAMP] && R->selection.text) { |
3302 | } else if (rq->target == R->xa[XA_TIMESTAMP] && R->selection.text) { |
3263 | XChangeProperty(R->Xdisplay, rq->requestor, rq->property, XA_INTEGER, |
3303 | XChangeProperty(R->Xdisplay, rq->requestor, rq->property, XA_INTEGER, |
3264 | (8 * sizeof(Time)), PropModeReplace, |
3304 | (8 * sizeof(Time)), PropModeReplace, |
3265 | (unsigned char *)&R->selection_time, 1); |
3305 | (unsigned char *)&R->selection_time, 1); |
3266 | ev.property = rq->property; |
3306 | ev.property = rq->property; |
3267 | } else if (rq->target == XA_STRING |
3307 | } else if (rq->target == XA_STRING |
|
|
3308 | || rq->target == R->xa[XA_TEXT] |
3268 | || rq->target == R->xa[XA_COMPOUND_TEXT] |
3309 | || rq->target == R->xa[XA_COMPOUND_TEXT] |
3269 | || rq->target == R->xa[XA_TEXT]) { |
3310 | || rq->target == R->xa[XA_UTF8_STRING] |
3270 | #ifdef USE_XIM |
3311 | ) { |
3271 | short freect = 0; |
3312 | short freect = 0; |
3272 | #endif |
|
|
3273 | int selectlen; |
3313 | int selectlen; |
|
|
3314 | char *cl; |
3274 | |
3315 | |
3275 | #ifdef USE_XIM |
3316 | target = rq->target; |
|
|
3317 | |
3276 | if (rq->target != XA_STRING) { |
3318 | if (target == XA_STRING) |
|
|
3319 | // we actually don't do XA_STRING, but who cares, as i18n clients |
|
|
3320 | // will ask for another format anyways. |
|
|
3321 | style = XStringStyle; |
|
|
3322 | else if (target == R->xa[XA_TEXT]) |
|
|
3323 | style = XTextStyle; |
|
|
3324 | else if (target == R->xa[XA_COMPOUND_TEXT]) |
|
|
3325 | style = XCompoundTextStyle; |
|
|
3326 | #if X_HAVE_UTF8_STRING |
|
|
3327 | else if (target == R->xa[XA_UTF8_STRING]) |
|
|
3328 | style = XUTF8StringStyle; |
|
|
3329 | #endif |
|
|
3330 | else |
|
|
3331 | { |
3277 | target = R->xa[XA_COMPOUND_TEXT]; |
3332 | target = R->xa[XA_COMPOUND_TEXT]; |
3278 | style = (rq->target == R->xa[XA_COMPOUND_TEXT]) |
|
|
3279 | ? XCompoundTextStyle : XStdICCTextStyle; |
|
|
3280 | } else |
|
|
3281 | #endif |
|
|
3282 | { |
|
|
3283 | target = XA_STRING; |
|
|
3284 | style = XStringStyle; |
3333 | style = XCompoundTextStyle; |
3285 | } |
3334 | } |
|
|
3335 | |
3286 | if (R->selection.text) { |
3336 | if (R->selection.text) { |
3287 | cl[0] = (char *)R->selection.text; |
3337 | cl = (char *)R->selection.text; |
3288 | selectlen = R->selection.len; |
3338 | selectlen = R->selection.len; |
3289 | } else { |
3339 | } else { |
3290 | cl[0] = dummy; |
3340 | cl = ""; |
3291 | *dummy = '\0'; |
|
|
3292 | selectlen = 0; |
3341 | selectlen = 0; |
3293 | } |
3342 | } |
3294 | #ifdef USE_XIM |
3343 | |
3295 | if (XmbTextListToTextProperty(R->Xdisplay, cl, 1, style, &ct) |
3344 | if (XmbTextListToTextProperty(R->Xdisplay, &cl, 1, style, &ct) >= 0) |
3296 | == Success) /* if we failed to convert then send it raw */ |
|
|
3297 | freect = 1; |
3345 | freect = 1; |
3298 | else |
3346 | else |
3299 | #endif |
|
|
3300 | { |
3347 | { |
|
|
3348 | /* if we failed to convert then send it raw */ |
3301 | ct.value = (unsigned char *)cl[0]; |
3349 | ct.value = (unsigned char *)cl; |
3302 | ct.nitems = selectlen; |
3350 | ct.nitems = selectlen; |
3303 | } |
3351 | } |
|
|
3352 | |
3304 | XChangeProperty(R->Xdisplay, rq->requestor, rq->property, |
3353 | XChangeProperty(R->Xdisplay, rq->requestor, rq->property, |
3305 | target, 8, PropModeReplace, |
3354 | target, 8, PropModeReplace, |
3306 | ct.value, (int)ct.nitems); |
3355 | ct.value, (int)ct.nitems); |
3307 | ev.property = rq->property; |
3356 | ev.property = rq->property; |
3308 | #ifdef USE_XIM |
3357 | |
3309 | if (freect) |
3358 | if (freect) |
3310 | XFree(ct.value); |
3359 | XFree (ct.value); |
3311 | #endif |
|
|
3312 | } |
3360 | } |
3313 | XSendEvent(R->Xdisplay, rq->requestor, False, 0L, (XEvent *)&ev); |
3361 | XSendEvent(R->Xdisplay, rq->requestor, False, 0L, (XEvent *)&ev); |
3314 | } |
3362 | } |
3315 | |
3363 | |
3316 | /* ------------------------------------------------------------------------- * |
3364 | /* ------------------------------------------------------------------------- * |
… | |
… | |
3318 | * ------------------------------------------------------------------------- */ |
3366 | * ------------------------------------------------------------------------- */ |
3319 | |
3367 | |
3320 | /* |
3368 | /* |
3321 | * return col/row values corresponding to x/y pixel values |
3369 | * return col/row values corresponding to x/y pixel values |
3322 | */ |
3370 | */ |
3323 | /* EXTPROTO */ |
|
|
3324 | void |
3371 | void |
3325 | rxvt_pixel_position(pR_ int *x, int *y) |
3372 | rxvt_term::pixel_position (int *x, int *y) |
3326 | { |
3373 | { |
3327 | *x = Pixel2Col(*x); |
3374 | *x = Pixel2Col(*x); |
3328 | /* MAX_IT(*x, 0); MIN_IT(*x, (int)R->TermWin.ncol - 1); */ |
3375 | /* MAX_IT(*x, 0); MIN_IT(*x, (int)R->TermWin.ncol - 1); */ |
3329 | *y = Pixel2Row(*y); |
3376 | *y = Pixel2Row(*y); |
3330 | /* MAX_IT(*y, 0); MIN_IT(*y, (int)R->TermWin.nrow - 1); */ |
3377 | /* MAX_IT(*y, 0); MIN_IT(*y, (int)R->TermWin.nrow - 1); */ |
3331 | } |
3378 | } |
|
|
3379 | |
3332 | /* ------------------------------------------------------------------------- */ |
3380 | /* ------------------------------------------------------------------------- */ |
3333 | #ifdef USE_XIM |
3381 | #ifdef USE_XIM |
3334 | /* EXTPROTO */ |
|
|
3335 | void |
3382 | void |
3336 | rxvt_setPosition(pR_ XPoint *pos) |
3383 | rxvt_term::set_position (XPoint *pos) |
3337 | { |
3384 | { |
3338 | XWindowAttributes xwa; |
3385 | XWindowAttributes xwa; |
3339 | |
3386 | |
3340 | XGetWindowAttributes(R->Xdisplay, R->TermWin.vt, &xwa); |
3387 | XGetWindowAttributes (Xdisplay, TermWin.vt, &xwa); |
3341 | pos->x = Col2Pixel(R->screen.cur.col) + xwa.x; |
3388 | pos->x = Col2Pixel (screen.cur.col) + xwa.x; |
3342 | pos->y = Height2Pixel((R->screen.cur.row + 1)) + xwa.y |
3389 | pos->y = Height2Pixel ((screen.cur.row + 1)) + xwa.y - TermWin.lineSpace; |
3343 | - R->TermWin.lineSpace; |
|
|
3344 | } |
3390 | } |
|
|
3391 | |
3345 | #endif |
3392 | #endif |
3346 | /* ------------------------------------------------------------------------- */ |
3393 | /* ------------------------------------------------------------------------- */ |
3347 | |
3394 | |
3348 | /* ------------------------------------------------------------------------- * |
3395 | /* ------------------------------------------------------------------------- * |
3349 | * DEBUG ROUTINES * |
3396 | * DEBUG ROUTINES * |