… | |
… | |
24 | * This file handles _all_ screen updates and selections |
24 | * This file handles _all_ screen updates and selections |
25 | */ |
25 | */ |
26 | |
26 | |
27 | #include "../config.h" /* NECESSARY */ |
27 | #include "../config.h" /* NECESSARY */ |
28 | #include "rxvt.h" /* NECESSARY */ |
28 | #include "rxvt.h" /* NECESSARY */ |
|
|
29 | #include "rxvtperl.h" /* NECESSARY */ |
29 | |
30 | |
30 | #include <X11/Xmd.h> /* get the typedef for CARD32 */ |
31 | #include <X11/Xmd.h> /* get the typedef for CARD32 */ |
31 | |
32 | |
32 | #include <inttypes.h> |
33 | #include <inttypes.h> |
33 | |
34 | |
… | |
… | |
46 | |
47 | |
47 | /* ------------------------------------------------------------------------- * |
48 | /* ------------------------------------------------------------------------- * |
48 | * GENERAL SCREEN AND SELECTION UPDATE ROUTINES * |
49 | * GENERAL SCREEN AND SELECTION UPDATE ROUTINES * |
49 | * ------------------------------------------------------------------------- */ |
50 | * ------------------------------------------------------------------------- */ |
50 | #define ZERO_SCROLLBACK() \ |
51 | #define ZERO_SCROLLBACK() \ |
51 | if (options & Opt_scrollTtyOutput) \ |
52 | if (OPTION (Opt_scrollTtyOutput)) \ |
52 | view_start = 0 |
53 | view_start = 0 |
53 | #define CLEAR_SELECTION() \ |
54 | #define CLEAR_SELECTION() \ |
54 | selection.beg.row = selection.beg.col \ |
55 | selection.beg.row = selection.beg.col \ |
55 | = selection.end.row = selection.end.col = 0 |
56 | = selection.end.row = selection.end.col = 0 |
56 | #define CLEAR_ALL_SELECTION() \ |
57 | #define CLEAR_ALL_SELECTION() \ |
… | |
… | |
83 | #define ROWCOL_IN_ROW_AT_OR_AFTER(X, Y) \ |
84 | #define ROWCOL_IN_ROW_AT_OR_AFTER(X, Y) \ |
84 | ROW_AND_COL_IN_ROW_AT_OR_AFTER ((X).row, (X).col, (Y).row, (Y).col) |
85 | ROW_AND_COL_IN_ROW_AT_OR_AFTER ((X).row, (X).col, (Y).row, (Y).col) |
85 | #define ROWCOL_IN_ROW_AT_OR_BEFORE(X, Y) \ |
86 | #define ROWCOL_IN_ROW_AT_OR_BEFORE(X, Y) \ |
86 | ROW_AND_COL_IN_ROW_AT_OR_BEFORE ((X).row, (X).col, (Y).row, (Y).col) |
87 | ROW_AND_COL_IN_ROW_AT_OR_BEFORE ((X).row, (X).col, (Y).row, (Y).col) |
87 | |
88 | |
88 | #define LINENO(n) (((n) + term_start + total_rows) % total_rows) |
|
|
89 | #define ROW(n) (save [LINENO (n)]) |
|
|
90 | |
|
|
91 | /* |
89 | /* |
92 | * CLEAR_ROWS : clear <num> rows starting from row <row> |
90 | * CLEAR_ROWS : clear <num> rows starting from row <row> |
93 | * CLEAR_CHARS: clear <num> chars starting from pixel position <x,y> |
91 | * CLEAR_CHARS: clear <num> chars starting from pixel position <x,y> |
94 | * ERASE_ROWS : set <num> rows starting from row <row> to the foreground colour |
92 | * ERASE_ROWS : set <num> rows starting from row <row> to the foreground colour |
95 | */ |
93 | */ |
… | |
… | |
150 | } |
148 | } |
151 | |
149 | |
152 | /* ------------------------------------------------------------------------- * |
150 | /* ------------------------------------------------------------------------- * |
153 | * SCREEN INITIALISATION * |
151 | * SCREEN INITIALISATION * |
154 | * ------------------------------------------------------------------------- */ |
152 | * ------------------------------------------------------------------------- */ |
|
|
153 | |
155 | void |
154 | void |
156 | rxvt_term::scr_reset () |
155 | rxvt_term::scr_reset () |
157 | { |
156 | { |
158 | unsigned int p, q; |
|
|
159 | int k; |
|
|
160 | |
|
|
161 | #if ENABLE_OVERLAY |
157 | #if ENABLE_OVERLAY |
162 | scr_overlay_off (); |
158 | scr_overlay_off (); |
163 | #endif |
159 | #endif |
164 | |
160 | |
165 | view_start = 0; |
161 | view_start = 0; |
… | |
… | |
175 | return; |
171 | return; |
176 | |
172 | |
177 | // we need at least two lines for wrapping to work correctly |
173 | // we need at least two lines for wrapping to work correctly |
178 | if (nrow + saveLines < 2) |
174 | if (nrow + saveLines < 2) |
179 | { |
175 | { |
|
|
176 | //TODO//FIXME |
180 | saveLines++; |
177 | saveLines++; |
181 | prev_nrow--; |
178 | prev_nrow--; |
182 | nsaved++; |
179 | nsaved++; |
183 | } |
180 | } |
184 | |
181 | |
… | |
… | |
188 | total_rows = nrow + saveLines; |
185 | total_rows = nrow + saveLines; |
189 | |
186 | |
190 | screen.tscroll = 0; |
187 | screen.tscroll = 0; |
191 | screen.bscroll = nrow - 1; |
188 | screen.bscroll = nrow - 1; |
192 | |
189 | |
193 | if (!save) |
190 | if (!row_buf) |
194 | { |
191 | { |
195 | /* |
192 | /* |
196 | * first time called so just malloc everything: don't rely on realloc |
193 | * first time called so just malloc everything: don't rely on realloc |
197 | * Note: this is still needed so that all the scrollback lines are NULL |
194 | * Note: this is still needed so that all the scrollback lines are NULL |
198 | */ |
195 | */ |
… | |
… | |
200 | term_start = 0; |
197 | term_start = 0; |
201 | |
198 | |
202 | talloc = new rxvt_salloc (ncol * sizeof (text_t)); |
199 | talloc = new rxvt_salloc (ncol * sizeof (text_t)); |
203 | ralloc = new rxvt_salloc (ncol * sizeof (rend_t)); |
200 | ralloc = new rxvt_salloc (ncol * sizeof (rend_t)); |
204 | |
201 | |
205 | save = (line_t *)rxvt_calloc (total_rows, sizeof (line_t)); |
|
|
206 | buf = (line_t *)rxvt_calloc (total_rows, sizeof (line_t)); |
202 | row_buf = (line_t *)rxvt_calloc (total_rows, sizeof (line_t)); |
|
|
203 | temp_buf = (line_t *)rxvt_calloc (total_rows, sizeof (line_t)); |
207 | drawn = (line_t *)rxvt_calloc (nrow, sizeof (line_t)); |
204 | drawn_buf = (line_t *)rxvt_calloc (nrow , sizeof (line_t)); |
208 | swap_save = (line_t *)rxvt_calloc (nrow, sizeof (line_t)); |
205 | swap_buf = (line_t *)rxvt_calloc (nrow , sizeof (line_t)); |
209 | |
206 | |
210 | for (p = nrow; p--; ) |
207 | for (int row = nrow; row--; ) |
211 | { |
208 | { |
212 | scr_blank_screen_mem (ROW(p), DEFAULT_RSTYLE); |
209 | scr_blank_screen_mem (ROW (row), DEFAULT_RSTYLE); |
213 | scr_blank_screen_mem (swap_save[p], DEFAULT_RSTYLE); |
210 | scr_blank_screen_mem (swap_buf [row], DEFAULT_RSTYLE); |
214 | scr_blank_screen_mem (drawn[p], DEFAULT_RSTYLE); |
211 | scr_blank_screen_mem (drawn_buf[row], DEFAULT_RSTYLE); |
215 | } |
212 | } |
216 | |
213 | |
217 | memset (charsets, 'B', sizeof (charsets)); |
214 | memset (charsets, 'B', sizeof (charsets)); |
218 | rstyle = DEFAULT_RSTYLE; |
215 | rstyle = DEFAULT_RSTYLE; |
219 | screen.flags = Screen_DefaultFlags; |
216 | screen.flags = Screen_DefaultFlags; |
… | |
… | |
243 | { |
240 | { |
244 | /* |
241 | /* |
245 | * add or delete rows as appropriate |
242 | * add or delete rows as appropriate |
246 | */ |
243 | */ |
247 | |
244 | |
248 | rxvt_salloc *old_ta; |
245 | rxvt_salloc *old_ta = talloc; talloc = new rxvt_salloc (ncol * sizeof (text_t)); |
249 | rxvt_salloc *old_ra; |
246 | rxvt_salloc *old_ra = ralloc; ralloc = new rxvt_salloc (ncol * sizeof (rend_t)); |
250 | |
247 | |
|
|
248 | #if 0 |
251 | if (nrow < prev_nrow) |
249 | if (nrow < prev_nrow) |
252 | { |
250 | { |
253 | /* delete rows */ |
|
|
254 | k = min (nsaved, prev_nrow - nrow); |
|
|
255 | // k = max (0, - ( (nrow - 1) - r->screen.cur.row)); // mmc's http://maruska.dyndns.org/wiki/scrolling-bug //make configurable? //D TODO |
|
|
256 | scr_scroll_text (0, (int)prev_nrow - 1, k, 1); |
|
|
257 | |
|
|
258 | for (p = nrow; p < prev_nrow; p++) |
251 | for (int row = nrow; row < prev_nrow; row++) |
259 | { |
252 | { |
260 | lfree (ROW(p)); |
|
|
261 | lfree (swap_save[p]); |
253 | lfree (swap_buf [row]); |
262 | lfree (drawn[p]); |
254 | lfree (drawn_buf[row]); |
263 | } |
255 | } |
|
|
256 | } |
|
|
257 | #endif |
264 | |
258 | |
265 | /* we have fewer rows so fix up cursor position */ |
259 | drawn_buf = (line_t *)rxvt_realloc (drawn_buf, nrow * sizeof (line_t)); |
266 | MIN_IT (screen.cur.row, (int32_t)nrow - 1); |
260 | temp_buf = (line_t *)rxvt_realloc (temp_buf , nrow * sizeof (line_t)); |
|
|
261 | swap_buf = (line_t *)rxvt_realloc (swap_buf , nrow * sizeof (line_t)); |
267 | |
262 | |
268 | scr_reset_realloc (); /* realloc _last_ */ |
263 | for (int row = min (nrow, prev_nrow); row--; ) |
|
|
264 | { |
|
|
265 | lresize (drawn_buf[row]); |
|
|
266 | lresize (swap_buf [row]); |
|
|
267 | } |
|
|
268 | |
|
|
269 | for (int row = prev_nrow; row < nrow; row++) |
|
|
270 | { |
|
|
271 | swap_buf [row].clear (); scr_blank_screen_mem (swap_buf [row], DEFAULT_RSTYLE); |
|
|
272 | drawn_buf[row].clear (); scr_blank_screen_mem (drawn_buf[row], DEFAULT_RSTYLE); |
|
|
273 | } |
|
|
274 | |
|
|
275 | line_t *old_buf = row_buf; row_buf = (line_t *)rxvt_calloc (total_rows, sizeof (line_t)); |
269 | } |
276 | |
270 | else if (nrow > prev_nrow) |
277 | int p = MOD (term_start + prev_nrow, prev_total_rows); // previous row |
|
|
278 | int pend = MOD (term_start - nsaved , prev_total_rows); |
|
|
279 | int q = total_rows; // rewrapped row |
|
|
280 | |
|
|
281 | if (nsaved) |
|
|
282 | { |
|
|
283 | // re-wrap lines, this is rather ugly, possibly because I am too dumb |
|
|
284 | // to come up with a lean and mean algorithm. |
|
|
285 | |
|
|
286 | row_col_t ocur = screen.cur; |
|
|
287 | ocur.row = MOD (term_start + ocur.row, prev_total_rows); |
|
|
288 | |
271 | { |
289 | do |
272 | /* add rows */ |
|
|
273 | scr_reset_realloc (); /* realloc _first_ */ |
|
|
274 | |
|
|
275 | int ocol = ncol; |
|
|
276 | ncol = prev_ncol; // save b/c scr_blank_screen_mem uses this |
|
|
277 | |
|
|
278 | k = min (nsaved, nrow - prev_nrow); |
|
|
279 | |
|
|
280 | for (p = prev_total_rows; p < total_rows; p++) |
|
|
281 | save[p].clear (); |
|
|
282 | |
|
|
283 | for (p = prev_total_rows; p < total_rows - k; p++) |
|
|
284 | scr_blank_screen_mem (save[p], DEFAULT_RSTYLE); |
|
|
285 | |
|
|
286 | for (p = prev_nrow; p < nrow; p++) |
|
|
287 | { |
290 | { |
288 | swap_save[p].clear (); scr_blank_screen_mem (swap_save[p], DEFAULT_RSTYLE); |
291 | p = MOD (p - 1, prev_total_rows); |
289 | drawn[p].clear (); scr_blank_screen_mem (drawn[p], DEFAULT_RSTYLE); |
|
|
290 | } |
|
|
291 | |
|
|
292 | if (k > 0) |
|
|
293 | { |
|
|
294 | scr_scroll_text (0, (int)nrow - 1, -k, 1); |
|
|
295 | screen.cur.row += k; |
|
|
296 | screen.s_cur.row += k; |
|
|
297 | nsaved -= k; |
|
|
298 | } |
|
|
299 | |
|
|
300 | #ifdef DEBUG_STRICT |
292 | #ifdef DEBUG_STRICT |
301 | assert (screen.cur.row < nrow); |
293 | assert (old_buf [MOD (p, prev_total_rows)].t); |
302 | #else /* drive with your eyes closed */ |
|
|
303 | MIN_IT (screen.cur.row, nrow - 1); |
|
|
304 | #endif |
294 | #endif |
305 | ncol = ocol; // save b/c scr_blank_screen_mem uses this |
|
|
306 | } |
|
|
307 | |
295 | |
308 | /* resize columns */ |
|
|
309 | if (ncol != prev_ncol) |
|
|
310 | { |
|
|
311 | old_ta = talloc; talloc = new rxvt_salloc (ncol * sizeof (text_t)); |
|
|
312 | old_ra = ralloc; ralloc = new rxvt_salloc (ncol * sizeof (rend_t)); |
|
|
313 | |
|
|
314 | for (p = total_rows; p--; ) |
|
|
315 | lresize (save[p]); |
|
|
316 | |
|
|
317 | for (p = nrow; p--; ) |
|
|
318 | { |
|
|
319 | lresize (drawn[p]); |
|
|
320 | lresize (swap_save[p]); |
|
|
321 | } |
|
|
322 | |
|
|
323 | MIN_IT (screen.cur.col, (int16_t)ncol - 1); |
|
|
324 | |
|
|
325 | delete old_ta; |
|
|
326 | delete old_ra; |
|
|
327 | } |
|
|
328 | |
|
|
329 | #if 0 |
|
|
330 | // re-wrap lines, this is rather ugly, possibly because I am too dumb |
|
|
331 | // to come up with a lean and mean algorithm. |
|
|
332 | rxvt_salloc *ta = new rxvt_salloc (ncol * sizeof (text_t)); |
|
|
333 | rxvt_salloc *ra = new rxvt_salloc (ncol * sizeof (rend_t)); |
|
|
334 | |
|
|
335 | text_t **tp = (text_t **)rxvt_calloc (total_rows, sizeof (text_t *)); |
|
|
336 | rend_t **rp = (rend_t **)rxvt_calloc (total_rows, sizeof (rend_t *)); |
|
|
337 | tlen_t *tl = (tlen_t *) rxvt_calloc (total_rows, sizeof (tlen_t)); |
|
|
338 | |
|
|
339 | for (p = 0; p < prev_total_rows; p++) printf ("P %p %d\n", save[p].t, save[p].l);//D |
|
|
340 | |
|
|
341 | p = prev_total_rows; |
|
|
342 | q = total_rows; |
|
|
343 | |
|
|
344 | while (p > 0 && q > 0) |
|
|
345 | { |
|
|
346 | --p; |
|
|
347 | |
|
|
348 | printf ("pq %d:%d\n", p, q); |
|
|
349 | if (save[p].t) |
|
|
350 | { |
|
|
351 | int llen = save[p].l; |
296 | int plines = 1; |
|
|
297 | int llen = old_buf [MOD (p, prev_total_rows)].l; |
352 | |
298 | |
353 | assert (llen >= 0); |
299 | while (p != pend && old_buf [MOD (p - 1, prev_total_rows)].is_longer ()) |
354 | |
|
|
355 | while (p && save[p - 1].l < 0) |
|
|
356 | { |
300 | { |
|
|
301 | p = MOD (p - 1, prev_total_rows); |
|
|
302 | |
357 | --p; |
303 | plines++; |
358 | llen += prev_ncol; |
304 | llen += prev_ncol; |
359 | } |
305 | } |
360 | |
306 | |
361 | int qlines = llen / ncol + 1; |
307 | int qlines = max (0, (llen - 1) / ncol) + 1; |
|
|
308 | |
|
|
309 | // drop partial lines completely |
|
|
310 | if (q < qlines) |
|
|
311 | break; |
|
|
312 | |
|
|
313 | q -= qlines; |
|
|
314 | |
362 | int lofs = 0; |
315 | int lofs = 0; |
|
|
316 | line_t *qline; |
363 | |
317 | |
364 | q -= qlines; |
318 | // re-assemble the full line by destination lines |
365 | |
|
|
366 | int qrow = q; |
|
|
367 | |
|
|
368 | printf ("QL %d llen %d\n", qlines, llen);//D |
|
|
369 | for (; qlines--; qrow++) |
319 | for (int qrow = q; qlines--; qrow++) |
370 | { |
320 | { |
|
|
321 | qline = row_buf + qrow; |
|
|
322 | lalloc (*qline); |
|
|
323 | qline->set_is_longer (); |
|
|
324 | |
371 | if (qrow >= 0) |
325 | int qcol = 0; |
|
|
326 | |
|
|
327 | // fill a single destination line |
|
|
328 | while (lofs < llen && qcol < ncol) |
372 | { |
329 | { |
373 | tp [qrow] = (text_t *)ta->alloc (); |
|
|
374 | rp [qrow] = (rend_t *)ra->alloc (); |
|
|
375 | tl [qrow] = LINE_CONT1; |
|
|
376 | |
|
|
377 | int qcol = 0; |
|
|
378 | |
|
|
379 | for (;;) |
|
|
380 | { |
|
|
381 | int prow = lofs / prev_ncol + p; |
330 | int prow = lofs / prev_ncol; |
382 | int pcol = lofs % prev_ncol; |
331 | int pcol = lofs % prev_ncol; |
383 | |
332 | |
|
|
333 | prow = MOD (p + prow, prev_total_rows); |
|
|
334 | |
|
|
335 | // we only adjust the cursor _row_ and put it into |
|
|
336 | // the topmost line of "long line" it was in, as |
|
|
337 | // this seems to upset applications/shells/readline |
|
|
338 | // least. |
|
|
339 | if (prow == ocur.row) |
|
|
340 | screen.cur.row = q - (total_rows - nrow); |
|
|
341 | |
|
|
342 | line_t &pline = old_buf [prow]; |
|
|
343 | |
384 | int len = min (min (prev_ncol - pcol, ncol - qcol), llen - lofs); |
344 | int len = min (min (prev_ncol - pcol, ncol - qcol), llen - lofs); |
385 | |
345 | |
386 | printf ("q %d lofs %d>%d len %d pq %d:%d p %d:%d q :%d\n", q, llen, lofs, len, prev_ncol, ncol, prow, pcol, qcol); |
|
|
387 | |
|
|
388 | if (len <= 0) |
|
|
389 | { |
|
|
390 | tl [qrow] = qcol; |
|
|
391 | |
|
|
392 | TODO |
|
|
393 | scr_blank_line (tp [qrow] + qcol, rp [qrow] + qcol, |
|
|
394 | ncol - qcol, DEFAULT_RSTYLE); |
|
|
395 | |
|
|
396 | break; |
|
|
397 | } |
|
|
398 | |
|
|
399 | assert (lofs < 1000); |
346 | assert (len); |
|
|
347 | assert (pline.t); |
400 | |
348 | |
401 | memcpy (tp [qrow] + qcol, save[prow].t + pcol, len * sizeof (text_t)); |
349 | memcpy (qline->t + qcol, pline.t + pcol, len * sizeof (text_t)); |
402 | memcpy (rp [qrow] + qcol, save[prow].r + pcol, len * sizeof (rend_t)); |
350 | memcpy (qline->r + qcol, pline.r + pcol, len * sizeof (rend_t)); |
403 | |
351 | |
404 | lofs += len; |
352 | lofs += len; |
405 | qcol += len; |
353 | qcol += len; |
406 | |
|
|
407 | if (qcol == ncol) |
|
|
408 | break; |
|
|
409 | } |
|
|
410 | } |
354 | } |
411 | else |
|
|
412 | lofs += ncol; |
|
|
413 | } |
355 | } |
|
|
356 | |
|
|
357 | qline->l = llen ? MOD (llen - 1, ncol) + 1 : 0; |
|
|
358 | #ifdef DEBUG_STRICT //TODO//FIXME//TEMPORARY |
|
|
359 | if (qline->l < 0) |
|
|
360 | { |
|
|
361 | fprintf (stderr, "ERROR, PLEASE REPORT to rxvt-unicode@plan9.de: qline->l %d = llen %d < ncol %d ? %d : MOD %d\n", qline->l,llen,ncol,llen,MOD (llen - 1, ncol) + 1);//D |
|
|
362 | qline->l = 0; |
|
|
363 | } |
|
|
364 | #endif |
|
|
365 | scr_blank_line (*qline, qline->l, ncol - qline->l, DEFAULT_RSTYLE); |
414 | } |
366 | } |
|
|
367 | while (p != pend && q > 0); |
|
|
368 | |
|
|
369 | term_start = total_rows - nrow; |
|
|
370 | nsaved = term_start - q; |
|
|
371 | |
|
|
372 | // make sure all terminal lines exist |
|
|
373 | while (nsaved < 0) |
|
|
374 | scr_blank_screen_mem (ROW (-++nsaved), DEFAULT_RSTYLE); |
|
|
375 | |
|
|
376 | } |
|
|
377 | else |
415 | } |
378 | { |
|
|
379 | // if no scrollback exists (yet), wing, instead of wrap |
|
|
380 | |
|
|
381 | for (int row = min (nrow, prev_nrow); row--; ) |
|
|
382 | { |
|
|
383 | line_t &pline = old_buf [MOD (term_start + row, prev_total_rows)]; |
|
|
384 | line_t &qline = row_buf [row]; |
416 | |
385 | |
417 | free (screen.text); screen.text = tp; |
386 | qline = pline; |
418 | free (screen.rend); screen.rend = rp; |
387 | lresize (qline); |
419 | free (screen.tlen); screen.tlen = tl; |
388 | } |
420 | |
389 | |
421 | for (p = 0; p < total_rows; p++) printf ("P %p %d\n", save[p].t, save[p].l);//D |
390 | for (int row = prev_nrow; row < nrow; row++) |
|
|
391 | { |
|
|
392 | row_buf [row].clear (); scr_blank_screen_mem (row_buf [row], DEFAULT_RSTYLE); |
|
|
393 | } |
|
|
394 | |
|
|
395 | term_start = 0; |
|
|
396 | } |
|
|
397 | |
|
|
398 | #ifdef DEBUG_STRICT //TODO: remove |
|
|
399 | for (int i = -nsaved; i < nrow; i++) |
|
|
400 | assert (ROW (i).t); |
422 | #endif |
401 | #endif |
|
|
402 | |
|
|
403 | free (old_buf); |
|
|
404 | delete old_ta; |
|
|
405 | delete old_ra; |
|
|
406 | |
|
|
407 | clamp_it (screen.cur.row, 0, nrow - 1); |
|
|
408 | clamp_it (screen.cur.col, 0, ncol - 1); |
423 | |
409 | |
424 | if (tabs) |
410 | if (tabs) |
425 | free (tabs); |
411 | free (tabs); |
426 | } |
412 | } |
427 | |
413 | |
428 | prev_nrow = nrow; |
414 | prev_nrow = nrow; |
429 | prev_ncol = ncol; |
415 | prev_ncol = ncol; |
430 | |
416 | |
431 | tabs = (char *)rxvt_malloc (ncol * sizeof (char)); |
417 | tabs = (char *)rxvt_malloc (ncol * sizeof (char)); |
432 | |
418 | |
433 | for (p = 0; p < ncol; p++) |
419 | for (int col = ncol; col--; ) |
434 | tabs[p] = (p % TABSIZE == 0) ? 1 : 0; |
420 | tabs [col] = col % TABSIZE == 0; |
435 | |
421 | |
436 | tt_winch (); |
422 | tt_winch (); |
437 | } |
|
|
438 | |
423 | |
439 | void |
424 | PERL_INVOKE ((this, HOOK_RESET, DT_END)); |
440 | rxvt_term::scr_reset_realloc () |
|
|
441 | { |
|
|
442 | swap_save = (line_t *) rxvt_realloc (swap_save , nrow * sizeof (line_t)); |
|
|
443 | drawn = (line_t *) rxvt_realloc (drawn , nrow * sizeof (line_t)); |
|
|
444 | buf = (line_t *) rxvt_realloc (buf , nrow * sizeof (line_t)); |
|
|
445 | save = (line_t *) rxvt_realloc (save , total_rows * sizeof (line_t)); |
|
|
446 | } |
425 | } |
447 | |
426 | |
448 | /* ------------------------------------------------------------------------- */ |
427 | /* ------------------------------------------------------------------------- */ |
449 | /* |
428 | /* |
450 | * Free everything. That way malloc debugging can find leakage. |
429 | * Free everything. That way malloc debugging can find leakage. |
… | |
… | |
453 | rxvt_term::scr_release () |
432 | rxvt_term::scr_release () |
454 | { |
433 | { |
455 | delete talloc; talloc = 0; |
434 | delete talloc; talloc = 0; |
456 | delete ralloc; ralloc = 0; |
435 | delete ralloc; ralloc = 0; |
457 | |
436 | |
458 | free (save); |
437 | free (row_buf); |
459 | free (swap_save); |
438 | free (swap_buf); |
460 | free (drawn); |
439 | free (drawn_buf); |
461 | free (buf); |
440 | free (temp_buf); |
462 | free (tabs); |
441 | free (tabs); |
|
|
442 | |
|
|
443 | row_buf = 0; // signal that we freed all the arrays |
463 | } |
444 | } |
464 | |
445 | |
465 | /* ------------------------------------------------------------------------- */ |
446 | /* ------------------------------------------------------------------------- */ |
466 | /* |
447 | /* |
467 | * Hard reset |
448 | * Hard reset |
… | |
… | |
518 | set_font_style (); |
499 | set_font_style (); |
519 | break; |
500 | break; |
520 | } |
501 | } |
521 | |
502 | |
522 | /* boundary check in case screen size changed between SAVE and RESTORE */ |
503 | /* boundary check in case screen size changed between SAVE and RESTORE */ |
523 | MIN_IT (s->cur.row, nrow - 1); |
504 | min_it (s->cur.row, nrow - 1); |
524 | MIN_IT (s->cur.col, ncol - 1); |
505 | min_it (s->cur.col, ncol - 1); |
525 | #ifdef DEBUG_STRICT |
506 | #ifdef DEBUG_STRICT |
526 | assert (s->cur.row >= 0); |
507 | assert (s->cur.row >= 0); |
527 | assert (s->cur.col >= 0); |
508 | assert (s->cur.col >= 0); |
528 | #else /* drive with your eyes closed */ |
|
|
529 | MAX_IT (s->cur.row, 0); |
|
|
530 | MAX_IT (s->cur.col, 0); |
|
|
531 | #endif |
509 | #endif |
532 | } |
510 | } |
533 | |
511 | |
534 | /* ------------------------------------------------------------------------- */ |
512 | /* ------------------------------------------------------------------------- */ |
535 | /* |
513 | /* |
… | |
… | |
538 | * XTERM_SEQ: Secondary screen: ESC [ ? 4 7 l |
516 | * XTERM_SEQ: Secondary screen: ESC [ ? 4 7 l |
539 | */ |
517 | */ |
540 | int |
518 | int |
541 | rxvt_term::scr_change_screen (int scrn) |
519 | rxvt_term::scr_change_screen (int scrn) |
542 | { |
520 | { |
543 | int i; |
|
|
544 | #if NSCREENS |
|
|
545 | int offset; |
|
|
546 | #endif |
|
|
547 | |
|
|
548 | want_refresh = 1; |
521 | want_refresh = 1; |
549 | |
|
|
550 | view_start = 0; |
522 | view_start = 0; |
551 | |
523 | |
552 | if (current_screen == scrn) |
524 | if (current_screen == scrn) |
553 | return scrn; |
525 | return scrn; |
554 | |
526 | |
555 | selection_check (2); /* check for boundary cross */ |
527 | selection_check (2); /* check for boundary cross */ |
556 | |
528 | |
557 | i = current_screen; current_screen = scrn; scrn = i; |
529 | int i = current_screen; current_screen = scrn; scrn = i; |
558 | |
530 | |
559 | SWAP_IT (screen.cur.row, swap.cur.row, int16_t); |
531 | ::swap (screen.cur.row, swap.cur.row); |
560 | SWAP_IT (screen.cur.col, swap.cur.col, int16_t); |
532 | ::swap (screen.cur.col, swap.cur.col); |
561 | MAX_IT (screen.cur.row, 0); |
533 | |
562 | MIN_IT (screen.cur.row, (int32_t)prev_nrow - 1); |
534 | screen.cur.row = clamp (screen.cur.row, 0, prev_nrow - 1); |
563 | MAX_IT (screen.cur.col, 0); |
535 | screen.cur.col = clamp (screen.cur.col, 0, prev_ncol - 1); |
564 | MIN_IT (screen.cur.col, (int32_t)prev_ncol - 1); |
|
|
565 | |
536 | |
566 | #if NSCREENS |
537 | #if NSCREENS |
567 | if (options & Opt_secondaryScreen) |
538 | if (OPTION (Opt_secondaryScreen)) |
568 | { |
539 | { |
569 | num_scr = 0; |
540 | num_scr = 0; |
570 | offset = saveLines; |
|
|
571 | |
541 | |
572 | for (i = prev_nrow; i--;) |
542 | for (int i = prev_nrow; i--; ) |
573 | SWAP_IT (ROW(i), swap_save[i], line_t); |
543 | ::swap (ROW(i), swap_buf [i]); |
574 | |
544 | |
575 | SWAP_IT (screen.charset, swap.charset, int16_t); |
545 | ::swap (screen.charset, swap.charset); |
576 | SWAP_IT (screen.flags, swap.flags, int); |
546 | ::swap (screen.flags, swap.flags); |
577 | screen.flags |= Screen_VisibleCursor; |
547 | screen.flags |= Screen_VisibleCursor; |
578 | swap.flags |= Screen_VisibleCursor; |
548 | swap.flags |= Screen_VisibleCursor; |
579 | } |
549 | } |
580 | else |
550 | else |
581 | #endif |
551 | #endif |
582 | if (options & Opt_secondaryScroll) |
552 | if (OPTION (Opt_secondaryScroll)) |
583 | scr_scroll_text (0, prev_nrow - 1, prev_nrow, 0); |
553 | scr_scroll_text (0, prev_nrow - 1, prev_nrow); |
584 | |
554 | |
585 | return scrn; |
555 | return scrn; |
586 | } |
556 | } |
587 | |
557 | |
588 | // clear WrapNext indicator, solidifying position on next line |
558 | // clear WrapNext indicator, solidifying position on next line |
… | |
… | |
595 | screen.flags &= ~Screen_WrapNext; |
565 | screen.flags &= ~Screen_WrapNext; |
596 | |
566 | |
597 | screen.cur.col = 0; |
567 | screen.cur.col = 0; |
598 | |
568 | |
599 | if (screen.cur.row == screen.bscroll) |
569 | if (screen.cur.row == screen.bscroll) |
600 | scr_scroll_text (screen.tscroll, screen.bscroll, 1, 0); |
570 | scr_scroll_text (screen.tscroll, screen.bscroll, 1); |
601 | else if (screen.cur.row < nrow - 1) |
571 | else if (screen.cur.row < nrow - 1) |
602 | screen.cur.row++; |
572 | screen.cur.row++; |
603 | } |
573 | } |
604 | |
574 | |
605 | /* ------------------------------------------------------------------------- */ |
575 | /* ------------------------------------------------------------------------- */ |
… | |
… | |
636 | /* ------------------------------------------------------------------------- */ |
606 | /* ------------------------------------------------------------------------- */ |
637 | /* |
607 | /* |
638 | * Scroll text between <row1> and <row2> inclusive, by <count> lines |
608 | * Scroll text between <row1> and <row2> inclusive, by <count> lines |
639 | * count positive ==> scroll up |
609 | * count positive ==> scroll up |
640 | * count negative ==> scroll down |
610 | * count negative ==> scroll down |
641 | * spec == 0 for normal routines |
|
|
642 | */ |
611 | */ |
643 | int |
612 | int |
644 | rxvt_term::scr_scroll_text (int row1, int row2, int count, int spec) |
613 | rxvt_term::scr_scroll_text (int row1, int row2, int count) |
645 | { |
614 | { |
646 | int i, j; |
|
|
647 | |
|
|
648 | if (count == 0 || (row1 > row2)) |
615 | if (count == 0 || (row1 > row2)) |
649 | return 0; |
616 | return 0; |
650 | |
617 | |
651 | want_refresh = 1; |
618 | want_refresh = 1; |
|
|
619 | num_scr += count; |
652 | |
620 | |
653 | if (row1 == 0 && count > 0 |
621 | if (count > 0 |
|
|
622 | && row1 == 0 |
|
|
623 | && row2 == nrow - 1 |
654 | && (current_screen == PRIMARY || options & Opt_secondaryScroll)) |
624 | && (current_screen == PRIMARY || OPTION (Opt_secondaryScroll))) |
655 | { |
625 | { |
656 | nsaved = min (nsaved + count, saveLines); |
626 | nsaved = min (nsaved + count, saveLines); |
|
|
627 | |
|
|
628 | PERL_INVOKE ((this, HOOK_SCROLL_BACK, DT_INT, count, DT_INT, nsaved, DT_END)); |
|
|
629 | |
657 | term_start = (term_start + count) % total_rows; |
630 | term_start = (term_start + count) % total_rows; |
658 | |
631 | |
659 | if (selection.op && current_screen == selection.screen) |
632 | if (selection.op && current_screen == selection.screen) |
660 | { |
633 | { |
661 | selection.beg.row -= count; |
634 | selection.beg.row -= count; |
662 | selection.end.row -= count; |
635 | selection.end.row -= count; |
663 | selection.mark.row -= count; |
636 | selection.mark.row -= count; |
|
|
637 | |
|
|
638 | if (selection.beg.row < -nsaved |
|
|
639 | || selection.end.row < -nsaved |
|
|
640 | || selection.mark.row < -nsaved) |
|
|
641 | { |
|
|
642 | CLEAR_ALL_SELECTION (); |
|
|
643 | selection.op = SELECTION_CLEAR; |
|
|
644 | } |
664 | } |
645 | } |
665 | |
646 | |
666 | for (int i = count; i--; ) |
647 | for (int i = count; i--; ) |
|
|
648 | { |
|
|
649 | ROW(row2 - i).l = 0; |
667 | scr_blank_screen_mem (ROW(row2 - i), rstyle); |
650 | scr_blank_screen_mem (ROW(row2 - i), rstyle); |
|
|
651 | } |
668 | |
652 | |
669 | if ((options & Opt_scrollWithBuffer) |
653 | if (OPTION (Opt_scrollWithBuffer) |
670 | && view_start != 0 |
654 | && view_start != 0 |
671 | && view_start != saveLines) |
655 | && view_start != saveLines) |
672 | scr_page (UP, count); |
656 | scr_page (UP, count); |
673 | } |
657 | } |
674 | else |
658 | else |
675 | { |
659 | { |
676 | if (!spec) |
|
|
677 | row1 += saveLines; |
|
|
678 | |
|
|
679 | row2 += saveLines; |
|
|
680 | |
|
|
681 | if (selection.op && current_screen == selection.screen) |
660 | if (selection.op && current_screen == selection.screen) |
682 | { |
661 | { |
683 | i = selection.beg.row + saveLines; |
662 | if ((selection.beg.row < row1 && selection.end.row > row1) |
684 | j = selection.end.row + saveLines; |
663 | || (selection.beg.row < row2 && selection.end.row > row2) |
685 | |
|
|
686 | if ((i < row1 && j > row1) |
|
|
687 | || (i < row2 && j > row2) |
|
|
688 | || (i - count < row1 && i >= row1) |
664 | || (selection.beg.row - count < row1 && selection.beg.row >= row1) |
689 | || (i - count > row2 && i <= row2) |
665 | || (selection.beg.row - count > row2 && selection.beg.row <= row2) |
690 | || (j - count < row1 && j >= row1) |
666 | || (selection.end.row - count < row1 && selection.end.row >= row1) |
691 | || (j - count > row2 && j <= row2)) |
667 | || (selection.end.row - count > row2 && selection.end.row <= row2)) |
692 | { |
668 | { |
693 | CLEAR_ALL_SELECTION (); |
669 | CLEAR_ALL_SELECTION (); |
694 | selection.op = SELECTION_CLEAR; /* XXX: too aggressive? */ |
670 | selection.op = SELECTION_CLEAR; |
695 | } |
671 | } |
696 | else if (j >= row1 && j <= row2) |
672 | else if (selection.end.row >= row1 && selection.end.row <= row2) |
697 | { |
673 | { |
698 | /* move selected region too */ |
674 | /* move selected region too */ |
699 | selection.beg.row -= count; |
675 | selection.beg.row -= count; |
700 | selection.end.row -= count; |
676 | selection.end.row -= count; |
701 | selection.mark.row -= count; |
677 | selection.mark.row -= count; |
|
|
678 | |
|
|
679 | selection_check (0); |
702 | } |
680 | } |
703 | } |
681 | } |
704 | |
682 | |
705 | selection_check (0); /* _after_ nsaved update */ |
683 | // use a simple and robust scrolling algorithm, this |
|
|
684 | // part of scr_scroll_text is not time-critical. |
706 | |
685 | |
707 | num_scr += count; |
|
|
708 | j = count; |
|
|
709 | |
|
|
710 | if (count < 0) |
|
|
711 | count = -count; |
|
|
712 | |
|
|
713 | i = row2 - row1 + 1; |
686 | int rows = row2 - row1 + 1; |
714 | MIN_IT (count, i); |
|
|
715 | |
687 | |
716 | if (j > 0) |
688 | min_it (count, rows); |
717 | { |
|
|
718 | /* scroll up */ |
|
|
719 | |
689 | |
720 | /* Copy lines that will get clobbered by the rotation */ |
690 | for (int row = 0; row < rows; row++) |
721 | memcpy (buf, save + row1, count * sizeof (line_t)); |
|
|
722 | |
|
|
723 | /* Rotate lines */ |
|
|
724 | i = row2 - row1 - count + 1; |
|
|
725 | memmove (save + row1, save + row1 + count, i * sizeof (line_t)); |
|
|
726 | |
|
|
727 | j = row2 - count + 1, i = count; |
|
|
728 | } |
691 | { |
729 | else /* if (j < 0) */ |
692 | temp_buf [row] = ROW(row1 + (row + count + rows) % rows); |
|
|
693 | |
|
|
694 | if (!IN_RANGE_EXC (row + count, 0, rows)) |
|
|
695 | scr_blank_screen_mem (temp_buf [row], rstyle); |
730 | { |
696 | } |
731 | /* scroll down */ |
|
|
732 | |
697 | |
733 | /* Copy lines that will get clobbered by the rotation */ |
698 | for (int row = 0; row < rows; row++) |
734 | for (i = 0, j = row2; i < count; i++, j--) |
699 | ROW(row1 + row) = temp_buf [row]; |
735 | buf[i] = save[j]; |
|
|
736 | |
|
|
737 | /* Rotate lines */ |
|
|
738 | for (j = row2, i = j - count; i >= row1; i--, j--) |
|
|
739 | save[j] = save[i]; |
|
|
740 | |
|
|
741 | j = row1, i = count; |
|
|
742 | count = -count; |
|
|
743 | } |
|
|
744 | |
|
|
745 | /* Resurrect lines */ |
|
|
746 | memcpy (save + j, buf, i * sizeof (line_t)); |
|
|
747 | |
|
|
748 | if (!spec) /* line length may not equal ncol */ |
|
|
749 | for (; i--; j++) |
|
|
750 | scr_blank_screen_mem (save[j], rstyle); |
|
|
751 | } |
700 | } |
752 | |
701 | |
753 | return count; |
702 | return count; |
754 | } |
703 | } |
755 | |
704 | |
… | |
… | |
763 | if (len <= 0) /* sanity */ |
712 | if (len <= 0) /* sanity */ |
764 | return; |
713 | return; |
765 | |
714 | |
766 | unsigned char checksel; |
715 | unsigned char checksel; |
767 | unicode_t c; |
716 | unicode_t c; |
768 | int row, last_col; |
717 | int last_col; |
769 | const unicode_t *strend = str + len; |
718 | const unicode_t *strend = str + len; |
770 | |
719 | |
771 | want_refresh = 1; |
720 | want_refresh = 1; |
772 | ZERO_SCROLLBACK (); |
721 | ZERO_SCROLLBACK (); |
773 | last_col = ncol; |
722 | last_col = ncol; |
774 | |
723 | |
775 | if (nlines > 0) |
724 | if (nlines > 0) |
776 | { |
725 | { |
777 | nlines += screen.cur.row - screen.bscroll; |
726 | nlines += screen.cur.row - screen.bscroll; |
|
|
727 | |
778 | if ((nlines > 0) |
728 | if (nlines > 0 |
779 | && (screen.tscroll == 0) |
729 | && screen.tscroll == 0 |
780 | && (screen.bscroll == (nrow - 1))) |
730 | && screen.bscroll == (nrow - 1)) |
781 | { |
731 | { |
782 | /* _at least_ this many lines need to be scrolled */ |
732 | /* _at least_ this many lines need to be scrolled */ |
783 | scr_scroll_text (screen.tscroll, screen.bscroll, nlines, 0); |
733 | scr_scroll_text (screen.tscroll, screen.bscroll, nlines); |
784 | screen.cur.row -= nlines; |
734 | screen.cur.row -= nlines; |
785 | } |
735 | } |
786 | } |
736 | } |
787 | |
737 | |
788 | #ifdef DEBUG_STRICT |
738 | #ifdef DEBUG_STRICT |
789 | assert (screen.cur.col < last_col); |
739 | assert (screen.cur.col < last_col); |
790 | assert ((screen.cur.row < nrow) |
740 | assert (screen.cur.row < nrow |
791 | && (screen.cur.row >= - (int32_t)nsaved)); |
741 | && screen.cur.row >= -nsaved); |
792 | #else /* drive with your eyes closed */ |
|
|
793 | MIN_IT (screen.cur.col, last_col - 1); |
|
|
794 | MIN_IT (screen.cur.row, (int32_t)nrow - 1); |
|
|
795 | MAX_IT (screen.cur.row, - (int32_t)nsaved); |
|
|
796 | #endif |
742 | #endif |
797 | row = screen.cur.row; |
743 | int row = screen.cur.row; |
798 | |
744 | |
799 | checksel = selection.op && current_screen == selection.screen ? 1 : 0; |
745 | checksel = selection.op && current_screen == selection.screen ? 1 : 0; |
800 | |
746 | |
801 | line_t *line = &ROW(row); |
747 | line_t *line = &ROW(row); |
802 | |
748 | |
… | |
… | |
804 | { |
750 | { |
805 | c = *str++; |
751 | c = *str++; |
806 | |
752 | |
807 | if (c < 0x20) |
753 | if (c < 0x20) |
808 | if (c == C0_LF) |
754 | if (c == C0_LF) |
809 | { |
755 | { |
810 | if (!line->is_longer ()) /* XXX: think about this */ |
756 | if (!line->is_longer ()) /* XXX: think about this */ |
811 | MAX_IT (line->l, screen.cur.col); |
757 | max_it (line->l, screen.cur.col); |
812 | |
758 | |
813 | screen.flags &= ~Screen_WrapNext; |
759 | screen.flags &= ~Screen_WrapNext; |
814 | |
760 | |
815 | if (screen.cur.row == screen.bscroll) |
761 | if (screen.cur.row == screen.bscroll) |
816 | scr_scroll_text (screen.tscroll, screen.bscroll, 1, 0); |
762 | scr_scroll_text (screen.tscroll, screen.bscroll, 1); |
817 | else if (screen.cur.row < (nrow - 1)) |
763 | else if (screen.cur.row < (nrow - 1)) |
818 | row = ++screen.cur.row; |
764 | row = ++screen.cur.row; |
819 | |
765 | |
820 | line = &ROW(row); /* _must_ refresh */ |
766 | line = &ROW(row); /* _must_ refresh */ |
821 | continue; |
767 | continue; |
822 | } |
768 | } |
823 | else if (c == C0_CR) |
769 | else if (c == C0_CR) |
824 | { |
770 | { |
825 | if (!line->is_longer ()) /* XXX: think about this */ |
771 | if (!line->is_longer ()) /* XXX: think about this */ |
826 | MAX_IT (line->l, screen.cur.col); |
772 | max_it (line->l, screen.cur.col); |
827 | |
773 | |
828 | screen.flags &= ~Screen_WrapNext; |
774 | screen.flags &= ~Screen_WrapNext; |
829 | screen.cur.col = 0; |
775 | screen.cur.col = 0; |
830 | continue; |
776 | continue; |
831 | } |
777 | } |
… | |
… | |
1007 | #endif |
953 | #endif |
1008 | } |
954 | } |
1009 | } |
955 | } |
1010 | |
956 | |
1011 | if (!line->is_longer ()) /* XXX: think about this */ |
957 | if (!line->is_longer ()) /* XXX: think about this */ |
1012 | MAX_IT (line->l, screen.cur.col); |
958 | max_it (line->l, screen.cur.col); |
1013 | |
959 | |
1014 | #ifdef DEBUG_STRICT |
960 | #ifdef DEBUG_STRICT |
1015 | assert (screen.cur.row >= 0); |
961 | assert (screen.cur.row >= 0); |
1016 | #else /* drive with your eyes closed */ |
|
|
1017 | MAX_IT (screen.cur.row, 0); |
|
|
1018 | #endif |
962 | #endif |
1019 | } |
963 | } |
1020 | |
964 | |
1021 | /* ------------------------------------------------------------------------- */ |
965 | /* ------------------------------------------------------------------------- */ |
1022 | /* |
966 | /* |
… | |
… | |
1061 | |
1005 | |
1062 | if (count == 0) |
1006 | if (count == 0) |
1063 | return; |
1007 | return; |
1064 | else if (count > 0) |
1008 | else if (count > 0) |
1065 | { |
1009 | { |
1066 | int row = screen.cur.row; |
|
|
1067 | |
|
|
1068 | line_t &l = ROW(row); |
1010 | line_t &l = ROW(screen.cur.row); |
1069 | rend_t base_rend = l.r[i]; |
1011 | rend_t base_rend = l.r[i]; |
1070 | ht &= l.t[i] == ' '; |
1012 | ht &= l.t[i] == ' '; |
1071 | |
1013 | |
1072 | for (; ++i < ncol; ) |
1014 | for (; ++i < ncol; ) |
1073 | if (tabs[i]) |
1015 | if (tabs[i]) |
… | |
… | |
1083 | if (count) |
1025 | if (count) |
1084 | x = ncol - 1; |
1026 | x = ncol - 1; |
1085 | |
1027 | |
1086 | // store horizontal tab commands as characters inside the text |
1028 | // store horizontal tab commands as characters inside the text |
1087 | // buffer so they can be selected and pasted. |
1029 | // buffer so they can be selected and pasted. |
1088 | if (ht && options & Opt_pastableTabs) |
1030 | if (ht && OPTION (Opt_pastableTabs)) |
1089 | { |
1031 | { |
1090 | base_rend = SET_FONT (base_rend, 0); |
1032 | base_rend = SET_FONT (base_rend, 0); |
1091 | |
1033 | |
1092 | if (!l.is_longer ()) /* XXX: think about this */ |
1034 | if (!l.is_longer ()) /* XXX: think about this */ |
1093 | MAX_IT (l.l, x); |
1035 | max_it (l.l, x); |
1094 | |
1036 | |
1095 | i = screen.cur.col; |
1037 | i = screen.cur.col; |
1096 | |
1038 | |
1097 | l.t[i] = '\t'; |
1039 | l.t[i] = '\t'; |
1098 | l.r[i] = base_rend; |
1040 | l.r[i] = base_rend; |
… | |
… | |
1148 | */ |
1090 | */ |
1149 | #if ENABLE_FRILLS |
1091 | #if ENABLE_FRILLS |
1150 | void |
1092 | void |
1151 | rxvt_term::scr_forwardindex () |
1093 | rxvt_term::scr_forwardindex () |
1152 | { |
1094 | { |
1153 | int row; |
|
|
1154 | |
|
|
1155 | if (screen.cur.col < ncol - 1) |
1095 | if (screen.cur.col < ncol - 1) |
1156 | scr_gotorc (0, 1, R_RELATIVE | C_RELATIVE); |
1096 | scr_gotorc (0, 1, R_RELATIVE | C_RELATIVE); |
1157 | else |
1097 | else |
1158 | { |
1098 | { |
1159 | row = screen.cur.row; |
|
|
1160 | |
|
|
1161 | if (ROW(row).is_longer ()) //TODO//FIXME//LEN |
1099 | if (ROW(screen.cur.row).is_longer ()) //TODO//FIXME//LEN |
1162 | ROW(row).l = ncol; |
1100 | ROW(screen.cur.row).l = ncol; |
1163 | |
1101 | |
1164 | scr_gotorc (0, 0, R_RELATIVE); |
1102 | scr_gotorc (0, 0, R_RELATIVE); |
1165 | scr_insdel_chars (1, DELETE); |
1103 | scr_insdel_chars (1, DELETE); |
1166 | scr_gotorc (0, ncol - 1, R_RELATIVE); |
1104 | scr_gotorc (0, ncol - 1, R_RELATIVE); |
1167 | } |
1105 | } |
… | |
… | |
1177 | { |
1115 | { |
1178 | want_refresh = 1; |
1116 | want_refresh = 1; |
1179 | ZERO_SCROLLBACK (); |
1117 | ZERO_SCROLLBACK (); |
1180 | |
1118 | |
1181 | screen.cur.col = relative & C_RELATIVE ? screen.cur.col + col : col; |
1119 | screen.cur.col = relative & C_RELATIVE ? screen.cur.col + col : col; |
1182 | MAX_IT (screen.cur.col, 0); |
1120 | clamp_it (screen.cur.col, 0, ncol - 1); |
1183 | MIN_IT (screen.cur.col, (int32_t)ncol - 1); |
|
|
1184 | |
1121 | |
1185 | screen.flags &= ~Screen_WrapNext; |
1122 | screen.flags &= ~Screen_WrapNext; |
1186 | |
1123 | |
1187 | if (relative & R_RELATIVE) |
1124 | if (relative & R_RELATIVE) |
1188 | { |
1125 | { |
… | |
… | |
1206 | else |
1143 | else |
1207 | { |
1144 | { |
1208 | if (screen.flags & Screen_Relative) |
1145 | if (screen.flags & Screen_Relative) |
1209 | { /* relative origin mode */ |
1146 | { /* relative origin mode */ |
1210 | screen.cur.row = row + screen.tscroll; |
1147 | screen.cur.row = row + screen.tscroll; |
1211 | MIN_IT (screen.cur.row, screen.bscroll); |
1148 | min_it (screen.cur.row, screen.bscroll); |
1212 | } |
1149 | } |
1213 | else |
1150 | else |
1214 | screen.cur.row = row; |
1151 | screen.cur.row = row; |
1215 | } |
1152 | } |
1216 | |
1153 | |
1217 | MAX_IT (screen.cur.row, 0); |
1154 | clamp_it (screen.cur.row, 0, nrow - 1); |
1218 | MIN_IT (screen.cur.row, (int32_t)nrow - 1); |
|
|
1219 | } |
1155 | } |
1220 | |
1156 | |
1221 | /* ------------------------------------------------------------------------- */ |
1157 | /* ------------------------------------------------------------------------- */ |
1222 | /* |
1158 | /* |
1223 | * direction should be UP or DN |
1159 | * direction should be UP or DN |
… | |
… | |
1234 | |
1170 | |
1235 | screen.flags &= ~Screen_WrapNext; |
1171 | screen.flags &= ~Screen_WrapNext; |
1236 | |
1172 | |
1237 | if ((screen.cur.row == screen.bscroll && direction == UP) |
1173 | if ((screen.cur.row == screen.bscroll && direction == UP) |
1238 | || (screen.cur.row == screen.tscroll && direction == DN)) |
1174 | || (screen.cur.row == screen.tscroll && direction == DN)) |
1239 | scr_scroll_text (screen.tscroll, screen.bscroll, dirn, 0); |
1175 | scr_scroll_text (screen.tscroll, screen.bscroll, dirn); |
1240 | else |
1176 | else |
1241 | screen.cur.row += dirn; |
1177 | screen.cur.row += dirn; |
1242 | |
1178 | |
1243 | MAX_IT (screen.cur.row, 0); |
1179 | clamp_it (screen.cur.row, 0, nrow - 1); |
1244 | MIN_IT (screen.cur.row, (int32_t)nrow - 1); |
|
|
1245 | selection_check (0); |
1180 | selection_check (0); |
1246 | } |
1181 | } |
1247 | |
1182 | |
1248 | /* ------------------------------------------------------------------------- */ |
1183 | /* ------------------------------------------------------------------------- */ |
1249 | /* |
1184 | /* |
… | |
… | |
1253 | * XTERM_SEQ: Clear whole line : ESC [ 2 K |
1188 | * XTERM_SEQ: Clear whole line : ESC [ 2 K |
1254 | */ |
1189 | */ |
1255 | void |
1190 | void |
1256 | rxvt_term::scr_erase_line (int mode) |
1191 | rxvt_term::scr_erase_line (int mode) |
1257 | { |
1192 | { |
1258 | unsigned int row, col, num; |
1193 | unsigned int col, num; |
1259 | |
1194 | |
1260 | want_refresh = 1; |
1195 | want_refresh = 1; |
1261 | ZERO_SCROLLBACK (); |
1196 | ZERO_SCROLLBACK (); |
1262 | |
1197 | |
1263 | selection_check (1); |
1198 | selection_check (1); |
1264 | |
1199 | |
1265 | row = screen.cur.row; |
1200 | line_t &line = ROW(screen.cur.row); |
1266 | |
1201 | |
1267 | switch (mode) |
1202 | switch (mode) |
1268 | { |
1203 | { |
1269 | case 0: /* erase to end of line */ |
1204 | case 0: /* erase to end of line */ |
1270 | col = screen.cur.col; |
1205 | col = screen.cur.col; |
1271 | num = ncol - col; |
1206 | num = ncol - col; |
1272 | MIN_IT (ROW(row).l, (int16_t)col); |
1207 | min_it (line.l, col); |
1273 | if (ROWCOL_IN_ROW_AT_OR_AFTER (selection.beg, screen.cur) |
1208 | if (ROWCOL_IN_ROW_AT_OR_AFTER (selection.beg, screen.cur) |
1274 | || ROWCOL_IN_ROW_AT_OR_AFTER (selection.end, screen.cur)) |
1209 | || ROWCOL_IN_ROW_AT_OR_AFTER (selection.end, screen.cur)) |
1275 | CLEAR_SELECTION (); |
1210 | CLEAR_SELECTION (); |
1276 | break; |
1211 | break; |
1277 | case 1: /* erase to beginning of line */ |
1212 | case 1: /* erase to beginning of line */ |
… | |
… | |
1282 | CLEAR_SELECTION (); |
1217 | CLEAR_SELECTION (); |
1283 | break; |
1218 | break; |
1284 | case 2: /* erase whole line */ |
1219 | case 2: /* erase whole line */ |
1285 | col = 0; |
1220 | col = 0; |
1286 | num = ncol; |
1221 | num = ncol; |
1287 | ROW(row).l = 0; |
1222 | line.l = 0; |
1288 | if (selection.beg.row <= screen.cur.row |
1223 | if (selection.beg.row <= screen.cur.row |
1289 | && selection.end.row >= screen.cur.row) |
1224 | && selection.end.row >= screen.cur.row) |
1290 | CLEAR_SELECTION (); |
1225 | CLEAR_SELECTION (); |
1291 | break; |
1226 | break; |
1292 | default: |
1227 | default: |
1293 | return; |
1228 | return; |
1294 | } |
1229 | } |
1295 | |
1230 | |
1296 | scr_blank_line (ROW(row), col, num, rstyle); |
1231 | scr_blank_line (line, col, num, rstyle); |
1297 | } |
1232 | } |
1298 | |
1233 | |
1299 | /* ------------------------------------------------------------------------- */ |
1234 | /* ------------------------------------------------------------------------- */ |
1300 | /* |
1235 | /* |
1301 | * Erase part of whole of the screen |
1236 | * Erase part of whole of the screen |
… | |
… | |
1305 | */ |
1240 | */ |
1306 | void |
1241 | void |
1307 | rxvt_term::scr_erase_screen (int mode) |
1242 | rxvt_term::scr_erase_screen (int mode) |
1308 | { |
1243 | { |
1309 | int num; |
1244 | int num; |
1310 | int32_t row, row_offset; |
1245 | int32_t row; |
1311 | rend_t ren; |
1246 | rend_t ren; |
1312 | XGCValues gcvalue; |
1247 | XGCValues gcvalue; |
1313 | |
1248 | |
1314 | want_refresh = 1; |
1249 | want_refresh = 1; |
1315 | ZERO_SCROLLBACK (); |
1250 | ZERO_SCROLLBACK (); |
1316 | |
|
|
1317 | row_offset = (int32_t)saveLines; |
|
|
1318 | |
1251 | |
1319 | switch (mode) |
1252 | switch (mode) |
1320 | { |
1253 | { |
1321 | case 0: /* erase to end of screen */ |
1254 | case 0: /* erase to end of screen */ |
1322 | selection_check (1); |
1255 | selection_check (1); |
… | |
… | |
1346 | CLEAR_SELECTION (); |
1279 | CLEAR_SELECTION (); |
1347 | |
1280 | |
1348 | if (row >= nrow) /* Out Of Bounds */ |
1281 | if (row >= nrow) /* Out Of Bounds */ |
1349 | return; |
1282 | return; |
1350 | |
1283 | |
1351 | MIN_IT (num, (nrow - row)); |
1284 | min_it (num, nrow - row); |
1352 | |
1285 | |
1353 | if (rstyle & (RS_RVid | RS_Uline)) |
1286 | if (rstyle & (RS_RVid | RS_Uline)) |
1354 | ren = (rend_t) ~RS_None; |
1287 | ren = (rend_t) ~RS_None; |
1355 | else if (GET_BASEBG (rstyle) == Color_bg) |
1288 | else if (GET_BASEBG (rstyle) == Color_bg) |
1356 | { |
1289 | { |
… | |
… | |
1358 | CLEAR_ROWS (row, num); |
1291 | CLEAR_ROWS (row, num); |
1359 | } |
1292 | } |
1360 | else |
1293 | else |
1361 | { |
1294 | { |
1362 | ren = rstyle & (RS_fgMask | RS_bgMask); |
1295 | ren = rstyle & (RS_fgMask | RS_bgMask); |
1363 | gcvalue.foreground = pix_colors[GET_BGCOLOR (rstyle)]; |
1296 | gcvalue.foreground = pix_colors[bgcolor_of (rstyle)]; |
1364 | XChangeGC (display->display, gc, GCForeground, &gcvalue); |
1297 | XChangeGC (display->display, gc, GCForeground, &gcvalue); |
1365 | ERASE_ROWS (row, num); |
1298 | ERASE_ROWS (row, num); |
1366 | gcvalue.foreground = pix_colors[Color_fg]; |
1299 | gcvalue.foreground = pix_colors[Color_fg]; |
1367 | XChangeGC (display->display, gc, GCForeground, &gcvalue); |
1300 | XChangeGC (display->display, gc, GCForeground, &gcvalue); |
1368 | } |
1301 | } |
1369 | |
1302 | |
1370 | for (; num--; row++) |
1303 | for (; num--; row++) |
1371 | { |
1304 | { |
|
|
1305 | ROW (row).l = 0; |
1372 | scr_blank_screen_mem (save[row + row_offset], rstyle); |
1306 | scr_blank_screen_mem (ROW (row), rstyle); |
1373 | save[row + row_offset].l = 0; |
|
|
1374 | scr_blank_line (drawn[row], 0, ncol, ren); |
1307 | scr_blank_line (drawn_buf [row], 0, ncol, ren); |
1375 | } |
1308 | } |
1376 | } |
1309 | } |
1377 | |
1310 | |
1378 | #if ENABLE_FRILLS |
1311 | #if ENABLE_FRILLS |
1379 | void |
1312 | void |
… | |
… | |
1392 | * XTERM_SEQ: Screen Alignment Test: ESC # 8 |
1325 | * XTERM_SEQ: Screen Alignment Test: ESC # 8 |
1393 | */ |
1326 | */ |
1394 | void |
1327 | void |
1395 | rxvt_term::scr_E () |
1328 | rxvt_term::scr_E () |
1396 | { |
1329 | { |
1397 | int i, j, k; |
|
|
1398 | rend_t *r1, fs; |
1330 | rend_t fs; |
1399 | |
1331 | |
1400 | want_refresh = 1; |
1332 | want_refresh = 1; |
1401 | ZERO_SCROLLBACK (); |
1333 | ZERO_SCROLLBACK (); |
1402 | |
1334 | |
1403 | num_scr_allow = 0; |
1335 | num_scr_allow = 0; |
1404 | selection_check (3); |
1336 | selection_check (3); |
1405 | |
1337 | |
1406 | fs = SET_FONT (rstyle, FONTSET (rstyle)->find_font ('E')); |
1338 | fs = SET_FONT (rstyle, FONTSET (rstyle)->find_font ('E')); |
1407 | for (k = saveLines, i = nrow; i--; k++) |
1339 | for (int row = nrow; row--; ) |
1408 | { |
1340 | { |
1409 | line_t &line = save[k]; |
1341 | line_t &line = ROW(row); |
1410 | |
1342 | |
1411 | fill_text (line.t, 'E', ncol); |
1343 | fill_text (line.t, 'E', ncol); |
|
|
1344 | rend_t *r1 = line.r; |
1412 | |
1345 | |
1413 | for (r1 = line.r, j = ncol; j--; ) |
1346 | for (int j = ncol; j--; ) |
1414 | *r1++ = fs; |
1347 | *r1++ = fs; |
1415 | |
1348 | |
1416 | line.l = ncol; /* make the `E's selectable */ |
1349 | line.l = ncol; /* make the `E's selectable */ |
1417 | } |
1350 | } |
1418 | } |
1351 | } |
… | |
… | |
1442 | count = end; |
1375 | count = end; |
1443 | } |
1376 | } |
1444 | |
1377 | |
1445 | scr_do_wrap (); |
1378 | scr_do_wrap (); |
1446 | |
1379 | |
1447 | scr_scroll_text (screen.cur.row, screen.bscroll, insdel * count, 0); |
1380 | scr_scroll_text (screen.cur.row, screen.bscroll, insdel * count); |
1448 | } |
1381 | } |
1449 | |
1382 | |
1450 | /* ------------------------------------------------------------------------- */ |
1383 | /* ------------------------------------------------------------------------- */ |
1451 | /* |
1384 | /* |
1452 | * Insert/Delete <count> characters from the current position |
1385 | * Insert/Delete <count> characters from the current position |
… | |
… | |
1464 | return; |
1397 | return; |
1465 | |
1398 | |
1466 | scr_do_wrap (); |
1399 | scr_do_wrap (); |
1467 | |
1400 | |
1468 | selection_check (1); |
1401 | selection_check (1); |
1469 | MIN_IT (count, (ncol - screen.cur.col)); |
1402 | min_it (count, ncol - screen.cur.col); |
1470 | |
1403 | |
1471 | row = screen.cur.row + saveLines; |
1404 | row = screen.cur.row; |
1472 | |
1405 | |
1473 | line_t *line = save + row; |
1406 | line_t *line = &ROW(row); |
1474 | |
1407 | |
1475 | switch (insdel) |
1408 | switch (insdel) |
1476 | { |
1409 | { |
1477 | case INSERT: |
1410 | case INSERT: |
1478 | for (col = ncol - 1; (col - count) >= screen.cur.col; col--) |
1411 | for (col = ncol - 1; (col - count) >= screen.cur.col; col--) |
… | |
… | |
1482 | } |
1415 | } |
1483 | |
1416 | |
1484 | if (!line->is_longer ()) |
1417 | if (!line->is_longer ()) |
1485 | { |
1418 | { |
1486 | line->l += count; |
1419 | line->l += count; |
1487 | MIN_IT (line->l, ncol); |
1420 | min_it (line->l, ncol); |
1488 | } |
1421 | } |
1489 | |
1422 | |
1490 | if (selection.op && current_screen == selection.screen |
1423 | if (selection.op && current_screen == selection.screen |
1491 | && ROWCOL_IN_ROW_AT_OR_AFTER (selection.beg, screen.cur)) |
1424 | && ROWCOL_IN_ROW_AT_OR_AFTER (selection.beg, screen.cur)) |
1492 | { |
1425 | { |
… | |
… | |
1499 | selection.mark.col += count; /* XXX: yes? */ |
1432 | selection.mark.col += count; /* XXX: yes? */ |
1500 | selection.end.col += count; |
1433 | selection.end.col += count; |
1501 | } |
1434 | } |
1502 | } |
1435 | } |
1503 | |
1436 | |
1504 | scr_blank_line (save[row], screen.cur.col, count, rstyle); |
1437 | scr_blank_line (*line, screen.cur.col, count, rstyle); |
1505 | break; |
1438 | break; |
1506 | |
1439 | |
1507 | case ERASE: |
1440 | case ERASE: |
1508 | screen.cur.col += count; /* don't worry if > ncol */ |
1441 | screen.cur.col += count; /* don't worry if > ncol */ |
1509 | selection_check (1); |
1442 | selection_check (1); |
1510 | screen.cur.col -= count; |
1443 | screen.cur.col -= count; |
1511 | scr_blank_line (save[row], screen.cur.col, count, rstyle); |
1444 | scr_blank_line (*line, screen.cur.col, count, rstyle); |
1512 | break; |
1445 | break; |
1513 | |
1446 | |
1514 | case DELETE: |
1447 | case DELETE: |
1515 | tr = line->r[ncol - 1] & (RS_fgMask | RS_bgMask | RS_baseattrMask); |
1448 | tr = line->r[ncol - 1] & (RS_fgMask | RS_bgMask | RS_baseattrMask); |
1516 | |
1449 | |
… | |
… | |
1523 | scr_blank_line (*line, ncol - count, count, tr); |
1456 | scr_blank_line (*line, ncol - count, count, tr); |
1524 | |
1457 | |
1525 | if (line->is_longer ()) /* break line continuation */ |
1458 | if (line->is_longer ()) /* break line continuation */ |
1526 | line->l = ncol; |
1459 | line->l = ncol; |
1527 | |
1460 | |
1528 | line->l -= count; |
1461 | line->l = max (line->l - count, 0); |
1529 | MAX_IT (line->l, 0); |
|
|
1530 | |
1462 | |
1531 | if (selection.op && current_screen == selection.screen |
1463 | if (selection.op && current_screen == selection.screen |
1532 | && ROWCOL_IN_ROW_AT_OR_AFTER (selection.beg, screen.cur)) |
1464 | && ROWCOL_IN_ROW_AT_OR_AFTER (selection.beg, screen.cur)) |
1533 | { |
1465 | { |
1534 | if (selection.end.row != screen.cur.row |
1466 | if (selection.end.row != screen.cur.row |
… | |
… | |
1554 | * XTERM_SEQ: Set region <top> - <bot> inclusive: ESC [ <top> ; <bot> r |
1486 | * XTERM_SEQ: Set region <top> - <bot> inclusive: ESC [ <top> ; <bot> r |
1555 | */ |
1487 | */ |
1556 | void |
1488 | void |
1557 | rxvt_term::scr_scroll_region (int top, int bot) |
1489 | rxvt_term::scr_scroll_region (int top, int bot) |
1558 | { |
1490 | { |
1559 | MAX_IT (top, 0); |
1491 | max_it (top, 0); |
1560 | MIN_IT (bot, (int)nrow - 1); |
1492 | min_it (bot, nrow - 1); |
1561 | |
1493 | |
1562 | if (top > bot) |
1494 | if (top > bot) |
1563 | return; |
1495 | return; |
1564 | |
1496 | |
1565 | screen.tscroll = top; |
1497 | screen.tscroll = top; |
… | |
… | |
1663 | XGCValues gcvalue; |
1595 | XGCValues gcvalue; |
1664 | |
1596 | |
1665 | if (rvideo != mode) |
1597 | if (rvideo != mode) |
1666 | { |
1598 | { |
1667 | rvideo = mode; |
1599 | rvideo = mode; |
1668 | SWAP_IT (pix_colors[Color_fg], pix_colors[Color_bg], rxvt_color); |
1600 | ::swap (pix_colors[Color_fg], pix_colors[Color_bg]); |
1669 | #if XPM_BACKGROUND |
1601 | #if XPM_BACKGROUND |
1670 | if (bgPixmap.pixmap == None) |
1602 | if (bgPixmap.pixmap == None) |
1671 | #endif |
1603 | #endif |
1672 | #if TRANSPARENT |
1604 | #if TRANSPARENT |
1673 | if (! (options & Opt_transparent) || am_transparent == 0) |
1605 | if (! OPTION (Opt_transparent) || am_transparent == 0) |
1674 | #endif |
1606 | #endif |
1675 | XSetWindowBackground (display->display, vt, |
1607 | XSetWindowBackground (display->display, vt, |
1676 | pix_colors[Color_bg]); |
1608 | pix_colors[Color_bg]); |
1677 | |
1609 | |
1678 | gcvalue.foreground = pix_colors[Color_fg]; |
1610 | gcvalue.foreground = pix_colors[Color_fg]; |
… | |
… | |
1769 | bool found = false; |
1701 | bool found = false; |
1770 | |
1702 | |
1771 | for (int i = 0; i < nrow; i++) |
1703 | for (int i = 0; i < nrow; i++) |
1772 | { |
1704 | { |
1773 | int col = 0; |
1705 | int col = 0; |
1774 | rend_t *drp = drawn[i].r; |
1706 | rend_t *drp = drawn_buf[i].r; |
1775 | |
1707 | |
1776 | for (; col < ncol; col++, drp++) |
1708 | for (; col < ncol; col++, drp++) |
1777 | if ((*drp & mask) == value) |
1709 | if ((*drp & mask) == value) |
1778 | { |
1710 | { |
1779 | found = true; |
1711 | found = true; |
… | |
… | |
1797 | rxvt_term::scr_expose (int x, int y, int ewidth, int eheight, bool refresh) |
1729 | rxvt_term::scr_expose (int x, int y, int ewidth, int eheight, bool refresh) |
1798 | { |
1730 | { |
1799 | int i; |
1731 | int i; |
1800 | row_col_t rc[RC_COUNT]; |
1732 | row_col_t rc[RC_COUNT]; |
1801 | |
1733 | |
1802 | if (!drawn) /* sanity check */ |
1734 | if (!drawn_buf) /* sanity check */ |
1803 | return; |
1735 | return; |
1804 | |
1736 | |
1805 | #ifndef NO_SLOW_LINK_SUPPORT |
1737 | #ifndef NO_SLOW_LINK_SUPPORT |
1806 | if (refresh_type == FAST_REFRESH && !display->is_local) |
1738 | if (refresh_type == FAST_REFRESH && !display->is_local) |
1807 | { |
1739 | { |
1808 | y = 0; |
1740 | y = 0; |
1809 | eheight = height; |
1741 | eheight = height; |
1810 | } |
1742 | } |
1811 | #endif |
|
|
1812 | |
|
|
1813 | #ifdef DEBUG_STRICT |
|
|
1814 | x = max (x, 0); |
|
|
1815 | x = min (x, (int)width); |
|
|
1816 | y = max (y, 0); |
|
|
1817 | y = min (y, (int)height); |
|
|
1818 | #endif |
1743 | #endif |
1819 | |
1744 | |
1820 | /* round down */ |
1745 | /* round down */ |
1821 | rc[PART_BEG].col = Pixel2Col (x); |
1746 | rc[PART_BEG].col = Pixel2Col (x); |
1822 | rc[PART_BEG].row = Pixel2Row (y); |
1747 | rc[PART_BEG].row = Pixel2Row (y); |
… | |
… | |
1825 | rc[PART_END].row = Pixel2Row (y + eheight + fheight - 1); |
1750 | rc[PART_END].row = Pixel2Row (y + eheight + fheight - 1); |
1826 | |
1751 | |
1827 | /* sanity checks */ |
1752 | /* sanity checks */ |
1828 | for (i = PART_BEG; i < RC_COUNT; i++) |
1753 | for (i = PART_BEG; i < RC_COUNT; i++) |
1829 | { |
1754 | { |
1830 | MIN_IT (rc[i].col, ncol - 1); |
1755 | min_it (rc[i].col, ncol - 1); |
1831 | MIN_IT (rc[i].row, nrow - 1); |
1756 | min_it (rc[i].row, nrow - 1); |
1832 | } |
1757 | } |
1833 | |
1758 | |
1834 | for (i = rc[PART_BEG].row; i <= rc[PART_END].row; i++) |
1759 | for (i = rc[PART_BEG].row; i <= rc[PART_END].row; i++) |
1835 | fill_text (&drawn[i].t[rc[PART_BEG].col], 0, rc[PART_END].col - rc[PART_BEG].col + 1); |
1760 | fill_text (&drawn_buf[i].t[rc[PART_BEG].col], 0, rc[PART_END].col - rc[PART_BEG].col + 1); |
1836 | |
1761 | |
1837 | if (refresh) |
1762 | if (refresh) |
1838 | scr_refresh (SLOW_REFRESH); |
1763 | scr_refresh (SLOW_REFRESH); |
1839 | } |
1764 | } |
1840 | |
1765 | |
… | |
… | |
1901 | } |
1826 | } |
1902 | |
1827 | |
1903 | int |
1828 | int |
1904 | rxvt_term::scr_changeview (unsigned int oldviewstart) |
1829 | rxvt_term::scr_changeview (unsigned int oldviewstart) |
1905 | { |
1830 | { |
|
|
1831 | PERL_INVOKE ((this, HOOK_VIEW_CHANGE, DT_INT, view_start, DT_END)); |
|
|
1832 | |
1906 | if (view_start != oldviewstart) |
1833 | if (view_start != oldviewstart) |
1907 | { |
1834 | { |
1908 | want_refresh = 1; |
1835 | want_refresh = 1; |
1909 | num_scr -= (view_start - oldviewstart); |
1836 | num_scr -= (view_start - oldviewstart); |
1910 | } |
1837 | } |
… | |
… | |
1918 | { |
1845 | { |
1919 | #ifndef NO_BELL |
1846 | #ifndef NO_BELL |
1920 | |
1847 | |
1921 | # ifndef NO_MAPALERT |
1848 | # ifndef NO_MAPALERT |
1922 | # ifdef MAPALERT_OPTION |
1849 | # ifdef MAPALERT_OPTION |
1923 | if (options & Opt_mapAlert) |
1850 | if (OPTION (Opt_mapAlert)) |
1924 | # endif |
1851 | # endif |
1925 | XMapWindow (display->display, parent[0]); |
1852 | XMapWindow (display->display, parent[0]); |
1926 | # endif |
1853 | # endif |
1927 | |
1854 | |
1928 | if (options & Opt_visualBell) |
1855 | if (OPTION (Opt_visualBell)) |
1929 | { |
1856 | { |
1930 | scr_rvideo_mode (!rvideo); /* refresh also done */ |
1857 | scr_rvideo_mode (!rvideo); /* refresh also done */ |
1931 | rxvt_usleep (VISUAL_BELL_DURATION); |
1858 | rxvt_usleep (VISUAL_BELL_DURATION); |
1932 | scr_rvideo_mode (!rvideo); /* refresh also done */ |
1859 | scr_rvideo_mode (!rvideo); /* refresh also done */ |
1933 | } |
1860 | } |
… | |
… | |
1941 | /* ARGSUSED */ |
1868 | /* ARGSUSED */ |
1942 | void |
1869 | void |
1943 | rxvt_term::scr_printscreen (int fullhist) |
1870 | rxvt_term::scr_printscreen (int fullhist) |
1944 | { |
1871 | { |
1945 | #ifdef PRINTPIPE |
1872 | #ifdef PRINTPIPE |
1946 | int i, r1, nrows, row_offset; |
1873 | int nrows, row_start; |
1947 | FILE *fd; |
1874 | FILE *fd; |
1948 | |
1875 | |
1949 | if ((fd = popen_printer ()) == NULL) |
1876 | if ((fd = popen_printer ()) == NULL) |
1950 | return; |
1877 | return; |
1951 | |
1878 | |
1952 | nrows = nrow; |
|
|
1953 | row_offset = saveLines; |
|
|
1954 | |
|
|
1955 | if (!fullhist) |
1879 | if (fullhist) |
1956 | row_offset -= view_start; |
1880 | { |
|
|
1881 | nrows = nrow + nsaved; |
|
|
1882 | row_start = -nsaved; |
|
|
1883 | } |
1957 | else |
1884 | else |
1958 | { |
1885 | { |
1959 | nrows += nsaved; |
1886 | nrows = nrow; |
1960 | row_offset -= nsaved; |
1887 | row_start = -view_start; |
1961 | } |
1888 | } |
1962 | |
1889 | |
1963 | wctomb (0, 0); |
1890 | wctomb (0, 0); |
1964 | |
1891 | |
1965 | for (r1 = 0; r1 < nrows; r1++) |
1892 | for (int r1 = 0; r1 < nrows; r1++) |
1966 | { |
1893 | { |
1967 | text_t *tp = save[r1 + row_offset].t; |
1894 | text_t *tp = ROW(r1).t; |
1968 | int len = save[r1 + row_offset].l; |
1895 | int len = ROW(r1).l; |
1969 | |
1896 | |
1970 | for (i = len >= 0 ? len : ncol - 1; i--; ) //TODO//FIXME//LEN |
1897 | for (int i = len >= 0 ? len : ncol - 1; i--; ) //TODO//FIXME//LEN |
1971 | { |
1898 | { |
1972 | char mb[MB_LEN_MAX]; |
1899 | char mb[MB_LEN_MAX]; |
1973 | text_t t = *tp++; |
1900 | text_t t = *tp++; |
1974 | if (t == NOCHAR) |
1901 | if (t == NOCHAR) |
1975 | continue; |
1902 | continue; |
… | |
… | |
2003 | { |
1930 | { |
2004 | unsigned char must_clear, /* use draw_string not draw_image_string */ |
1931 | unsigned char must_clear, /* use draw_string not draw_image_string */ |
2005 | showcursor; /* show the cursor */ |
1932 | showcursor; /* show the cursor */ |
2006 | int16_t col, row, /* column/row we're processing */ |
1933 | int16_t col, row, /* column/row we're processing */ |
2007 | ocrow; /* old cursor row */ |
1934 | ocrow; /* old cursor row */ |
2008 | int i, /* tmp */ |
1935 | int i; /* tmp */ |
2009 | row_offset; /* basic offset in screen structure */ |
|
|
2010 | #ifndef NO_CURSORCOLOR |
1936 | #ifndef NO_CURSORCOLOR |
2011 | rend_t cc1; /* store colours at cursor position (s) */ |
1937 | rend_t cc1; /* store colours at cursor position (s) */ |
2012 | #endif |
1938 | #endif |
2013 | rend_t *crp; // cursor rendition pointer |
1939 | rend_t *crp; // cursor rendition pointer |
2014 | |
1940 | |
… | |
… | |
2021 | * A: set up vars |
1947 | * A: set up vars |
2022 | */ |
1948 | */ |
2023 | must_clear = 0; |
1949 | must_clear = 0; |
2024 | refresh_count = 0; |
1950 | refresh_count = 0; |
2025 | |
1951 | |
2026 | row_offset = term_start - view_start; |
|
|
2027 | |
|
|
2028 | #if XPM_BACKGROUND |
1952 | #if XPM_BACKGROUND |
2029 | must_clear |= bgPixmap.pixmap != None; |
1953 | must_clear |= bgPixmap.pixmap != None; |
2030 | #endif |
1954 | #endif |
2031 | #if TRANSPARENT |
1955 | #if TRANSPARENT |
2032 | must_clear |= (options & Opt_transparent) && am_transparent; |
1956 | must_clear |= OPTION (Opt_transparent) && am_transparent; |
2033 | #endif |
1957 | #endif |
2034 | ocrow = oldcursor.row; /* is there an old outline cursor on screen? */ |
1958 | ocrow = oldcursor.row; /* is there an old outline cursor on screen? */ |
2035 | |
1959 | |
2036 | /* |
1960 | /* |
2037 | * B: reverse any characters which are selected |
1961 | * B: reverse any characters which are selected |
… | |
… | |
2061 | |
1985 | |
2062 | crp = &ROW(screen.cur.row).r[col]; |
1986 | crp = &ROW(screen.cur.row).r[col]; |
2063 | |
1987 | |
2064 | if (showcursor && focus) |
1988 | if (showcursor && focus) |
2065 | { |
1989 | { |
2066 | if (options & Opt_cursorUnderline) |
1990 | if (OPTION (Opt_cursorUnderline)) |
2067 | *crp ^= RS_Uline; |
1991 | *crp ^= RS_Uline; |
2068 | else |
1992 | else |
2069 | { |
1993 | { |
2070 | *crp ^= RS_RVid; |
1994 | *crp ^= RS_RVid; |
2071 | |
1995 | |
… | |
… | |
2073 | cc1 = *crp & (RS_fgMask | RS_bgMask); |
1997 | cc1 = *crp & (RS_fgMask | RS_bgMask); |
2074 | if (ISSET_PIXCOLOR (Color_cursor)) |
1998 | if (ISSET_PIXCOLOR (Color_cursor)) |
2075 | ccol1 = Color_cursor; |
1999 | ccol1 = Color_cursor; |
2076 | else |
2000 | else |
2077 | #ifdef CURSOR_COLOR_IS_RENDITION_COLOR |
2001 | #ifdef CURSOR_COLOR_IS_RENDITION_COLOR |
2078 | ccol1 = GET_FGCOLOR (rstyle); |
2002 | ccol1 = fgcolor_of (rstyle); |
2079 | #else |
2003 | #else |
2080 | ccol1 = Color_fg; |
2004 | ccol1 = Color_fg; |
2081 | #endif |
2005 | #endif |
2082 | if (ISSET_PIXCOLOR (Color_cursor2)) |
2006 | if (ISSET_PIXCOLOR (Color_cursor2)) |
2083 | ccol2 = Color_cursor2; |
2007 | ccol2 = Color_cursor2; |
2084 | else |
2008 | else |
2085 | #ifdef CURSOR_COLOR_IS_RENDITION_COLOR |
2009 | #ifdef CURSOR_COLOR_IS_RENDITION_COLOR |
2086 | ccol2 = GET_BGCOLOR (rstyle); |
2010 | ccol2 = bgcolor_of (rstyle); |
2087 | #else |
2011 | #else |
2088 | ccol2 = Color_bg; |
2012 | ccol2 = Color_bg; |
2089 | #endif |
2013 | #endif |
2090 | *crp = SET_FGCOLOR (*crp, ccol1); |
2014 | *crp = SET_FGCOLOR (*crp, ccol1); |
2091 | *crp = SET_BGCOLOR (*crp, ccol2); |
2015 | *crp = SET_BGCOLOR (*crp, ccol2); |
… | |
… | |
2101 | if (screen.cur.row + view_start != ocrow |
2025 | if (screen.cur.row + view_start != ocrow |
2102 | || screen.cur.col != oldcursor.col) |
2026 | || screen.cur.col != oldcursor.col) |
2103 | { |
2027 | { |
2104 | if (ocrow < nrow |
2028 | if (ocrow < nrow |
2105 | && oldcursor.col < ncol) |
2029 | && oldcursor.col < ncol) |
2106 | drawn[ocrow].r[oldcursor.col] ^= (RS_RVid | RS_Uline); |
2030 | drawn_buf[ocrow].r[oldcursor.col] ^= (RS_RVid | RS_Uline); |
2107 | |
2031 | |
2108 | if (focus || !showcursor) |
2032 | if (focus || !showcursor) |
2109 | oldcursor.row = -1; |
2033 | oldcursor.row = -1; |
2110 | else |
2034 | else |
2111 | setoldcursor = 1; |
2035 | setoldcursor = 1; |
… | |
… | |
2124 | oldcursor.col = screen.cur.col; |
2048 | oldcursor.col = screen.cur.col; |
2125 | } |
2049 | } |
2126 | } |
2050 | } |
2127 | } |
2051 | } |
2128 | |
2052 | |
|
|
2053 | PERL_INVOKE ((this, HOOK_REFRESH_BEGIN, DT_END)); |
2129 | #if ENABLE_OVERLAY |
2054 | #if ENABLE_OVERLAY |
2130 | scr_swap_overlay (); |
2055 | scr_swap_overlay (); |
2131 | #endif |
2056 | #endif |
2132 | |
2057 | |
2133 | #ifndef NO_SLOW_LINK_SUPPORT |
2058 | #ifndef NO_SLOW_LINK_SUPPORT |
… | |
… | |
2135 | * D: CopyArea pass - very useful for slower links |
2060 | * D: CopyArea pass - very useful for slower links |
2136 | * This has been deliberately kept simple. |
2061 | * This has been deliberately kept simple. |
2137 | */ |
2062 | */ |
2138 | i = num_scr; |
2063 | i = num_scr; |
2139 | if (!display->is_local |
2064 | if (!display->is_local |
2140 | && refresh_type == FAST_REFRESH && num_scr_allow && i |
2065 | && refresh_type == FAST_REFRESH && num_scr_allow && num_scr |
2141 | && abs (i) < nrow && !must_clear) |
2066 | && abs (num_scr) < nrow && !must_clear) |
2142 | { |
2067 | { |
2143 | int16_t nits; |
2068 | int16_t nits; |
2144 | int j; |
2069 | int j; |
2145 | int len, wlen; |
2070 | int len, wlen; |
2146 | |
2071 | |
… | |
… | |
2149 | row = i > 0 ? 0 : j - 1; |
2074 | row = i > 0 ? 0 : j - 1; |
2150 | for (; j-- >= 0; row += (i > 0 ? 1 : -1)) |
2075 | for (; j-- >= 0; row += (i > 0 ? 1 : -1)) |
2151 | { |
2076 | { |
2152 | if (row + i >= 0 && row + i < nrow && row + i != ocrow) |
2077 | if (row + i >= 0 && row + i < nrow && row + i != ocrow) |
2153 | { |
2078 | { |
2154 | line_t s = save[(row + row_offset) % nlines]; |
2079 | line_t s = ROW(row - view_start); |
2155 | line_t d = drawn[row]; |
2080 | line_t d = drawn_buf[row]; |
2156 | line_t d2 = drawn[row + i]; |
2081 | line_t d2 = drawn_buf[row + i]; |
2157 | |
2082 | |
2158 | for (nits = 0, col = ncol; col--; ) |
2083 | for (nits = 0, col = ncol; col--; ) |
2159 | if (s.t[col] != d2.t[col] || s.r[col] != d2.r[col]) |
2084 | if (s.t[col] != d2.t[col] || s.r[col] != d2.r[col]) |
2160 | nits--; |
2085 | nits--; |
2161 | else if (s.t[col] != d.t[col] || s.r[col] != d.r[col]) |
2086 | else if (s.t[col] != d.t[col] || s.r[col] != d.r[col]) |
… | |
… | |
2179 | |
2104 | |
2180 | if (len != -1) |
2105 | if (len != -1) |
2181 | { |
2106 | { |
2182 | /* also comes here at end if needed because of >= above */ |
2107 | /* also comes here at end if needed because of >= above */ |
2183 | if (wlen < len) |
2108 | if (wlen < len) |
2184 | SWAP_IT (wlen, len, int); |
2109 | ::swap (wlen, len); |
2185 | |
2110 | |
2186 | XCopyArea (display->display, vt, vt, |
2111 | XCopyArea (display->display, vt, vt, |
2187 | gc, 0, Row2Pixel (len + i), |
2112 | gc, 0, Row2Pixel (len + i), |
2188 | (unsigned int)TermWin_TotalWidth (), |
2113 | (unsigned int)this->width, |
2189 | (unsigned int)Height2Pixel (wlen - len + 1), |
2114 | (unsigned int)Height2Pixel (wlen - len + 1), |
2190 | 0, Row2Pixel (len)); |
2115 | 0, Row2Pixel (len)); |
2191 | len = -1; |
2116 | len = -1; |
2192 | } |
2117 | } |
2193 | } |
2118 | } |
… | |
… | |
2197 | /* |
2122 | /* |
2198 | * E: main pass across every character |
2123 | * E: main pass across every character |
2199 | */ |
2124 | */ |
2200 | for (row = 0; row < nrow; row++) |
2125 | for (row = 0; row < nrow; row++) |
2201 | { |
2126 | { |
2202 | text_t *stp = save[(row + row_offset) % total_rows].t; |
2127 | text_t *stp = ROW(row - view_start).t; |
2203 | rend_t *srp = save[(row + row_offset) % total_rows].r; |
2128 | rend_t *srp = ROW(row - view_start).r; |
2204 | text_t *dtp = drawn[row].t; |
2129 | text_t *dtp = drawn_buf[row].t; |
2205 | rend_t *drp = drawn[row].r; |
2130 | rend_t *drp = drawn_buf[row].r; |
2206 | |
2131 | |
2207 | /* |
2132 | /* |
2208 | * E2: OK, now the real pass |
2133 | * E2: OK, now the real pass |
2209 | */ |
2134 | */ |
2210 | int ypixel = (int)Row2Pixel (row); |
2135 | int ypixel = (int)Row2Pixel (row); |
… | |
… | |
2272 | count++, i--; |
2197 | count++, i--; |
2273 | |
2198 | |
2274 | /* |
2199 | /* |
2275 | * Determine the attributes for the string |
2200 | * Determine the attributes for the string |
2276 | */ |
2201 | */ |
2277 | int fore = GET_FGCOLOR (rend); // desired foreground |
2202 | int fore = fgcolor_of (rend); // desired foreground |
2278 | int back = GET_BGCOLOR (rend); // desired background |
2203 | int back = bgcolor_of (rend); // desired background |
2279 | |
2204 | |
2280 | // only do special processing if any attributes are set, which is rare |
2205 | // only do special processing if any attributes are set, which is unlikely |
2281 | if (rend & (RS_Bold | RS_Italic | RS_Uline | RS_RVid | RS_Blink | RS_Careful)) |
2206 | if (rend & (RS_Bold | RS_Italic | RS_Uline | RS_RVid | RS_Blink | RS_Careful)) |
2282 | { |
2207 | { |
2283 | #if ENABLE_STYLES |
2208 | #if ENABLE_STYLES |
2284 | // force redraw after "careful" characters to avoid pixel droppings |
2209 | // force redraw after "careful" characters to avoid pixel droppings |
2285 | if (srp[col] & RS_Careful && col < ncol - 1 && 0) |
2210 | if (srp[col] & RS_Careful && col < ncol - 1 && 0) |
… | |
… | |
2321 | fore = Color_UL; |
2246 | fore = Color_UL; |
2322 | #endif |
2247 | #endif |
2323 | |
2248 | |
2324 | if (invert) |
2249 | if (invert) |
2325 | { |
2250 | { |
2326 | SWAP_IT (fore, back, int); |
2251 | ::swap (fore, back); |
2327 | |
2252 | |
2328 | #ifndef NO_BOLD_UNDERLINE_REVERSE |
2253 | #ifndef NO_BOLD_UNDERLINE_REVERSE |
2329 | if (ISSET_PIXCOLOR (Color_RV)) |
2254 | if (ISSET_PIXCOLOR (Color_RV)) |
2330 | back = Color_RV; |
2255 | back = Color_RV; |
2331 | |
2256 | |
… | |
… | |
2396 | } /* for (row....) */ |
2321 | } /* for (row....) */ |
2397 | |
2322 | |
2398 | #if ENABLE_OVERLAY |
2323 | #if ENABLE_OVERLAY |
2399 | scr_swap_overlay (); |
2324 | scr_swap_overlay (); |
2400 | #endif |
2325 | #endif |
|
|
2326 | PERL_INVOKE ((this, HOOK_REFRESH_END, DT_END)); |
2401 | |
2327 | |
2402 | /* |
2328 | /* |
2403 | * G: cleanup cursor and display outline cursor if necessary |
2329 | * G: cleanup cursor and display outline cursor if necessary |
2404 | */ |
2330 | */ |
2405 | if (showcursor) |
2331 | if (showcursor) |
2406 | { |
2332 | { |
2407 | if (focus) |
2333 | if (focus) |
2408 | { |
2334 | { |
2409 | if (options & Opt_cursorUnderline) |
2335 | if (OPTION (Opt_cursorUnderline)) |
2410 | *crp ^= RS_Uline; |
2336 | *crp ^= RS_Uline; |
2411 | else |
2337 | else |
2412 | { |
2338 | { |
2413 | *crp ^= RS_RVid; |
2339 | *crp ^= RS_RVid; |
2414 | #ifndef NO_CURSORCOLOR |
2340 | #ifndef NO_CURSORCOLOR |
… | |
… | |
2423 | |
2349 | |
2424 | while (col && ROW(screen.cur.row).t[col] == NOCHAR) |
2350 | while (col && ROW(screen.cur.row).t[col] == NOCHAR) |
2425 | col--; |
2351 | col--; |
2426 | |
2352 | |
2427 | while (col + cursorwidth < ncol |
2353 | while (col + cursorwidth < ncol |
2428 | && drawn[oldcursor.row].t[col + cursorwidth] == NOCHAR) |
2354 | && drawn_buf[oldcursor.row].t[col + cursorwidth] == NOCHAR) |
2429 | cursorwidth++; |
2355 | cursorwidth++; |
2430 | |
2356 | |
2431 | #ifndef NO_CURSORCOLOR |
2357 | #ifndef NO_CURSORCOLOR |
2432 | if (ISSET_PIXCOLOR (Color_cursor)) |
2358 | if (ISSET_PIXCOLOR (Color_cursor)) |
2433 | XSetForeground (display->display, gc, pix_colors[Color_cursor]); |
2359 | XSetForeground (display->display, gc, pix_colors[Color_cursor]); |
… | |
… | |
2465 | |
2391 | |
2466 | void |
2392 | void |
2467 | rxvt_term::scr_remap_chars () |
2393 | rxvt_term::scr_remap_chars () |
2468 | { |
2394 | { |
2469 | for (int i = total_rows; i--; ) |
2395 | for (int i = total_rows; i--; ) |
2470 | scr_remap_chars (save[i]); |
2396 | scr_remap_chars (row_buf [i]); |
2471 | |
2397 | |
2472 | for (int i = nrow; i--; ) |
2398 | for (int i = nrow; i--; ) |
2473 | { |
2399 | { |
2474 | scr_remap_chars (drawn[i]); |
2400 | scr_remap_chars (drawn_buf [i]); |
2475 | scr_remap_chars (swap_save[i]); |
2401 | scr_remap_chars (swap_buf [i]); |
2476 | } |
2402 | } |
2477 | } |
2403 | } |
2478 | |
2404 | |
2479 | void |
2405 | void |
2480 | rxvt_term::scr_recolour () |
2406 | rxvt_term::scr_recolour () |
… | |
… | |
2533 | |
2459 | |
2534 | #if ENABLE_FRILLS |
2460 | #if ENABLE_FRILLS |
2535 | if (selection.rect) |
2461 | if (selection.rect) |
2536 | { |
2462 | { |
2537 | for (row = max (selection.beg.row, -view_start); row <= min (selection.end.row, view_end); row++) |
2463 | for (row = max (selection.beg.row, -view_start); row <= min (selection.end.row, view_end); row++) |
|
|
2464 | { |
|
|
2465 | text_t *stp = ROW(row).t; |
|
|
2466 | rend_t *srp = ROW(row).r; |
|
|
2467 | |
2538 | for (rend_t *srp = ROW(row).r, col = selection.beg.col; col < selection.end.col; col++) |
2468 | for (col = selection.beg.col; col < selection.end.col; col++) |
2539 | srp[col] ^= RS_RVid; |
2469 | srp[col] ^= RS_RVid; |
|
|
2470 | |
|
|
2471 | while (col-- > selection.beg.col && (stp[col] == NOCHAR || unicode::is_space (stp[col]))) |
|
|
2472 | srp[col] ^= RS_RVid | RS_Uline; |
|
|
2473 | |
|
|
2474 | if (++col < selection.end.col) |
|
|
2475 | srp[col] ^= RS_RVid | RS_Uline; |
|
|
2476 | } |
2540 | } |
2477 | } |
2541 | else |
2478 | else |
2542 | #endif |
2479 | #endif |
2543 | { |
2480 | { |
2544 | if (selection.beg.row >= -view_start) |
2481 | if (selection.beg.row >= -view_start) |
… | |
… | |
2547 | row = selection.beg.row; |
2484 | row = selection.beg.row; |
2548 | } |
2485 | } |
2549 | else |
2486 | else |
2550 | { |
2487 | { |
2551 | col = 0; |
2488 | col = 0; |
2552 | row = view_start; |
2489 | row = -view_start; |
2553 | } |
2490 | } |
2554 | |
2491 | |
2555 | for (; row < min (selection.end.row, view_end); row++, col = 0) |
2492 | for (; row < min (selection.end.row, view_end); row++, col = 0) |
2556 | for (rend_t *srp = ROW(row).r; col < ncol; col++) |
2493 | for (rend_t *srp = ROW(row).r; col < ncol; col++) |
2557 | srp[col] ^= RS_RVid; |
2494 | srp[col] ^= RS_RVid; |
… | |
… | |
2577 | char r1[] = "\n"; |
2514 | char r1[] = "\n"; |
2578 | |
2515 | |
2579 | for (row = saveLines - nsaved; |
2516 | for (row = saveLines - nsaved; |
2580 | row < saveLines + nrow - 1; row++) |
2517 | row < saveLines + nrow - 1; row++) |
2581 | { |
2518 | { |
2582 | width = save[row].l >= 0 ? save[row].l |
2519 | width = row_buf[row].l >= 0 ? row_buf[row].l |
2583 | : ncol; |
2520 | : ncol; |
2584 | for (towrite = width; towrite; towrite -= wrote) |
2521 | for (towrite = width; towrite; towrite -= wrote) |
2585 | { |
2522 | { |
2586 | wrote = write (fd, & (save[row].t[width - towrite]), |
2523 | wrote = write (fd, & (row_buf[row].t[width - towrite]), |
2587 | towrite); |
2524 | towrite); |
2588 | if (wrote < 0) |
2525 | if (wrote < 0) |
2589 | return; /* XXX: death, no report */ |
2526 | return; /* XXX: death, no report */ |
2590 | } |
2527 | } |
2591 | if (save[row].l >= 0) |
2528 | if (row_buf[row].l >= 0) |
2592 | if (write (fd, r1, 1) <= 0) |
2529 | if (write (fd, r1, 1) <= 0) |
2593 | return; /* XXX: death, no report */ |
2530 | return; /* XXX: death, no report */ |
2594 | } |
2531 | } |
2595 | } |
2532 | } |
2596 | #endif |
2533 | #endif |
… | |
… | |
2628 | /* ------------------------------------------------------------------------- */ |
2565 | /* ------------------------------------------------------------------------- */ |
2629 | /* |
2566 | /* |
2630 | * Paste a selection direct to the command fd |
2567 | * Paste a selection direct to the command fd |
2631 | */ |
2568 | */ |
2632 | void |
2569 | void |
2633 | rxvt_term::paste (unsigned char *data, unsigned int len) |
2570 | rxvt_term::paste (char *data, unsigned int len) |
2634 | { |
2571 | { |
2635 | /* convert normal newline chars into common keyboard Return key sequence */ |
2572 | /* convert normal newline chars into common keyboard Return key sequence */ |
2636 | for (unsigned int i = 0; i < len; i++) |
2573 | for (unsigned int i = 0; i < len; i++) |
2637 | if (data[i] == C0_LF) |
2574 | if (data[i] == C0_LF) |
2638 | data[i] = C0_CR; |
2575 | data[i] = C0_CR; |
… | |
… | |
2782 | { |
2719 | { |
2783 | wchar_t *w = rxvt_utf8towcs ((const char *)ct.value, ct.nitems); |
2720 | wchar_t *w = rxvt_utf8towcs ((const char *)ct.value, ct.nitems); |
2784 | char *s = rxvt_wcstombs (w); |
2721 | char *s = rxvt_wcstombs (w); |
2785 | free (w); |
2722 | free (w); |
2786 | // TODO: strlen == only the first element will be converted. well... |
2723 | // TODO: strlen == only the first element will be converted. well... |
2787 | paste ((unsigned char *)s, strlen (s)); |
2724 | paste (s, strlen (s)); |
2788 | free (s); |
2725 | free (s); |
2789 | } |
2726 | } |
2790 | else |
2727 | else |
2791 | #endif |
2728 | #endif |
2792 | if (XmbTextPropertyToTextList (display->display, &ct, &cl, &cr) >= 0 |
2729 | if (XmbTextPropertyToTextList (display->display, &ct, &cl, &cr) >= 0 |
2793 | && cl) |
2730 | && cl) |
2794 | { |
2731 | { |
2795 | for (int i = 0; i < cr; i++) |
2732 | for (int i = 0; i < cr; i++) |
2796 | paste ((unsigned char *)cl[i], strlen (cl[i])); |
2733 | paste (cl[i], strlen (cl[i])); |
2797 | |
2734 | |
2798 | XFreeStringList (cl); |
2735 | XFreeStringList (cl); |
2799 | } |
2736 | } |
2800 | else |
2737 | else |
2801 | paste (ct.value, ct.nitems); // paste raw |
2738 | paste ((char *)ct.value, ct.nitems); // paste raw |
2802 | |
2739 | |
2803 | bailout: |
2740 | bailout: |
2804 | XFree (ct.value); |
2741 | XFree (ct.value); |
2805 | |
2742 | |
2806 | if (selection_wait == Sel_normal) |
2743 | if (selection_wait == Sel_normal) |
… | |
… | |
2844 | return; /* outside window */ |
2781 | return; /* outside window */ |
2845 | |
2782 | |
2846 | if (selection.text) |
2783 | if (selection.text) |
2847 | { /* internal selection */ |
2784 | { /* internal selection */ |
2848 | char *str = rxvt_wcstombs (selection.text, selection.len); |
2785 | char *str = rxvt_wcstombs (selection.text, selection.len); |
2849 | paste ((unsigned char *)str, strlen (str)); |
2786 | paste (str, strlen (str)); |
2850 | free (str); |
2787 | free (str); |
2851 | return; |
2788 | return; |
2852 | } |
2789 | } |
2853 | else |
2790 | else |
2854 | { |
2791 | { |
… | |
… | |
2946 | selection.op = SELECTION_DONE; |
2883 | selection.op = SELECTION_DONE; |
2947 | |
2884 | |
2948 | if (selection.clicks == 4) |
2885 | if (selection.clicks == 4) |
2949 | return; /* nothing selected, go away */ |
2886 | return; /* nothing selected, go away */ |
2950 | |
2887 | |
|
|
2888 | if (PERL_INVOKE ((this, HOOK_SEL_MAKE, DT_LONG, (long)tm, DT_END))) |
|
|
2889 | return; |
|
|
2890 | |
2951 | i = (selection.end.row - selection.beg.row + 1) * (ncol + 1); |
2891 | i = (selection.end.row - selection.beg.row + 1) * (ncol + 1); |
2952 | new_selection_text = (wchar_t *)rxvt_malloc ((i + 4) * sizeof (wchar_t)); |
2892 | new_selection_text = (wchar_t *)rxvt_malloc ((i + 4) * sizeof (wchar_t)); |
2953 | |
2893 | |
2954 | int ofs = 0; |
2894 | int ofs = 0; |
2955 | int extra = 0; |
2895 | int extra = 0; |
… | |
… | |
2971 | #endif |
2911 | #endif |
2972 | end_col = ROW(row).is_longer () ? ncol : ROW(row).l; //TODO//FIXME//LEN |
2912 | end_col = ROW(row).is_longer () ? ncol : ROW(row).l; //TODO//FIXME//LEN |
2973 | |
2913 | |
2974 | col = max (col, 0); |
2914 | col = max (col, 0); |
2975 | |
2915 | |
2976 | if (row == selection.end.row || selection.rect) |
2916 | if (row == selection.end.row |
|
|
2917 | #if ENABLE_FRILLS |
|
|
2918 | || selection.rect |
|
|
2919 | #endif |
|
|
2920 | ) |
2977 | end_col = min (end_col, selection.end.col); |
2921 | min_it (end_col, selection.end.col); |
2978 | |
2922 | |
2979 | t = ROW(row).t + col; |
2923 | t = ROW(row).t + col; |
2980 | for (; col < end_col; col++) |
2924 | for (; col < end_col; col++) |
2981 | { |
2925 | { |
2982 | if (*t == NOCHAR) |
2926 | if (*t == NOCHAR) |
… | |
… | |
3000 | #endif |
2944 | #endif |
3001 | else |
2945 | else |
3002 | new_selection_text[ofs++] = *t++; |
2946 | new_selection_text[ofs++] = *t++; |
3003 | } |
2947 | } |
3004 | |
2948 | |
|
|
2949 | #if ENABLE_FRILLS |
|
|
2950 | if (selection.rect) |
|
|
2951 | { |
|
|
2952 | while (ofs |
|
|
2953 | && new_selection_text[ofs - 1] != C0_LF |
|
|
2954 | && unicode::is_space (new_selection_text[ofs - 1])) |
|
|
2955 | --ofs; |
|
|
2956 | |
|
|
2957 | new_selection_text[ofs++] = C0_LF; |
|
|
2958 | } |
|
|
2959 | else |
|
|
2960 | #endif |
3005 | if (!ROW(row).is_longer () && row != selection.end.row) |
2961 | if (!ROW(row).is_longer () && row != selection.end.row) |
3006 | new_selection_text[ofs++] = C0_LF; |
2962 | new_selection_text[ofs++] = C0_LF; |
3007 | } |
2963 | } |
3008 | |
2964 | |
3009 | if (end_col != selection.end.col) |
2965 | if (end_col != selection.end.col) |
3010 | new_selection_text[ofs++] = C0_LF; |
2966 | new_selection_text[ofs++] = C0_LF; |
3011 | |
2967 | |
… | |
… | |
3021 | |
2977 | |
3022 | // we usually allocate much more than necessary, so realloc it smaller again |
2978 | // we usually allocate much more than necessary, so realloc it smaller again |
3023 | selection.len = ofs; |
2979 | selection.len = ofs; |
3024 | selection.text = (wchar_t *)rxvt_realloc (new_selection_text, (ofs + 1) * sizeof (wchar_t)); |
2980 | selection.text = (wchar_t *)rxvt_realloc (new_selection_text, (ofs + 1) * sizeof (wchar_t)); |
3025 | |
2981 | |
|
|
2982 | if (PERL_INVOKE ((this, HOOK_SEL_GRAB, DT_LONG, (long)tm, DT_END))) |
|
|
2983 | return; |
|
|
2984 | |
|
|
2985 | selection_grab (tm); |
|
|
2986 | } |
|
|
2987 | |
|
|
2988 | bool |
|
|
2989 | rxvt_term::selection_grab (Time tm) |
|
|
2990 | { |
|
|
2991 | selection_time = tm; |
|
|
2992 | |
3026 | XSetSelectionOwner (display->display, XA_PRIMARY, vt, tm); |
2993 | XSetSelectionOwner (display->display, XA_PRIMARY, vt, tm); |
3027 | if (XGetSelectionOwner (display->display, XA_PRIMARY) == vt) |
2994 | if (XGetSelectionOwner (display->display, XA_PRIMARY) == vt) |
|
|
2995 | { |
3028 | display->set_selection_owner (this); |
2996 | display->set_selection_owner (this); |
|
|
2997 | return true; |
|
|
2998 | } |
3029 | else |
2999 | else |
3030 | rxvt_warn ("can't get primary selection, ignoring.\n"); |
3000 | return false; |
3031 | |
3001 | |
3032 | #if 0 |
3002 | #if 0 |
3033 | XTextProperty ct; |
3003 | XTextProperty ct; |
3034 | |
3004 | |
3035 | if (XwcTextListToTextProperty (display->display, &selection.text, 1, XStringStyle, &ct) >= 0) |
3005 | if (XwcTextListToTextProperty (display->display, &selection.text, 1, XStringStyle, &ct) >= 0) |
3036 | { |
3006 | { |
3037 | set_string_property (XA_CUT_BUFFER0, ct.value, ct.nitems); |
3007 | set_string_property (XA_CUT_BUFFER0, ct.value, ct.nitems); |
3038 | XFree (ct.value); |
3008 | XFree (ct.value); |
3039 | } |
3009 | } |
3040 | #endif |
3010 | #endif |
3041 | |
|
|
3042 | selection_time = tm; |
|
|
3043 | } |
3011 | } |
3044 | |
3012 | |
3045 | /* ------------------------------------------------------------------------- */ |
3013 | /* ------------------------------------------------------------------------- */ |
3046 | /* |
3014 | /* |
3047 | * Mark or select text based upon number of clicks: 1, 2, or 3 |
3015 | * Mark or select text based upon number of clicks: 1, 2, or 3 |
… | |
… | |
3073 | want_refresh = 1; |
3041 | want_refresh = 1; |
3074 | |
3042 | |
3075 | selection.mark.row = row - view_start; |
3043 | selection.mark.row = row - view_start; |
3076 | selection.mark.col = col; |
3044 | selection.mark.col = col; |
3077 | |
3045 | |
3078 | selection.mark.row = min (max (selection.mark.row, -nsaved), nrow - 1); |
3046 | selection.mark.row = clamp (selection.mark.row, -nsaved, nrow - 1); |
3079 | selection.mark.col = min (max (selection.mark.col, 0), ncol - 1); |
3047 | selection.mark.col = clamp (selection.mark.col, 0, ncol - 1); |
3080 | |
3048 | |
3081 | while (selection.mark.col > 0 |
3049 | while (selection.mark.col > 0 |
3082 | && ROW(selection.mark.row).t[selection.mark.col] == NOCHAR) |
3050 | && ROW(selection.mark.row).t[selection.mark.col] == NOCHAR) |
3083 | --selection.mark.col; |
3051 | --selection.mark.col; |
3084 | |
3052 | |
… | |
… | |
3169 | } |
3137 | } |
3170 | } |
3138 | } |
3171 | break; |
3139 | break; |
3172 | } |
3140 | } |
3173 | |
3141 | |
3174 | Old_Word_Selection_You_Die: |
|
|
3175 | if (dirn == DN) |
3142 | if (dirn == DN) |
3176 | col++; /* put us on one past the end */ |
3143 | col++; /* put us on one past the end */ |
3177 | |
3144 | |
3178 | /* Poke the values back in */ |
3145 | /* Poke the values back in */ |
3179 | ret->row = row; |
3146 | ret->row = row; |
… | |
… | |
3189 | * flag == 2 ==> button 3 motion |
3156 | * flag == 2 ==> button 3 motion |
3190 | */ |
3157 | */ |
3191 | void |
3158 | void |
3192 | rxvt_term::selection_extend (int x, int y, int flag) |
3159 | rxvt_term::selection_extend (int x, int y, int flag) |
3193 | { |
3160 | { |
3194 | int col = min (max (Pixel2Col (x), 0), nrow - 1); |
3161 | int col = clamp (Pixel2Col (x), 0, ncol); |
3195 | int row = min (max (Pixel2Row (y), 0), ncol); |
3162 | int row = clamp (Pixel2Row (y), 0, nrow - 1); |
3196 | |
3163 | |
3197 | /* |
3164 | /* |
3198 | * If we're selecting characters (single click) then we must check first |
3165 | * If we're selecting characters (single click) then we must check first |
3199 | * if we are at the same place as the original mark. If we are then |
3166 | * if we are at the same place as the original mark. If we are then |
3200 | * select nothing. Otherwise, if we're to the right of the mark, you have to |
3167 | * select nothing. Otherwise, if we're to the right of the mark, you have to |
… | |
… | |
3356 | else if (selection.clicks == 2) |
3323 | else if (selection.clicks == 2) |
3357 | { |
3324 | { |
3358 | if (ROWCOL_IS_AFTER (selection.end, selection.beg)) |
3325 | if (ROWCOL_IS_AFTER (selection.end, selection.beg)) |
3359 | selection.end.col--; |
3326 | selection.end.col--; |
3360 | |
3327 | |
|
|
3328 | if (!PERL_INVOKE ((this, HOOK_SEL_EXTEND, DT_END))) |
|
|
3329 | { |
3361 | selection_delimit_word (UP, &selection.beg, &selection.beg); |
3330 | selection_delimit_word (UP, &selection.beg, &selection.beg); |
3362 | selection_delimit_word (DN, &selection.end, &selection.end); |
3331 | selection_delimit_word (DN, &selection.end, &selection.end); |
|
|
3332 | } |
3363 | } |
3333 | } |
3364 | else if (selection.clicks == 3) |
3334 | else if (selection.clicks == 3) |
3365 | { |
3335 | { |
3366 | #if ENABLE_FRILLS |
3336 | #if ENABLE_FRILLS |
3367 | if (options & Opt_tripleclickwords) |
3337 | if (OPTION (Opt_tripleclickwords)) |
3368 | { |
3338 | { |
3369 | selection_delimit_word (UP, &selection.beg, &selection.beg); |
3339 | selection_delimit_word (UP, &selection.beg, &selection.beg); |
3370 | |
3340 | |
3371 | for (int end_row = selection.mark.row; end_row < nrow; end_row++) |
3341 | for (int end_row = selection.mark.row; end_row < nrow; end_row++) |
3372 | { |
3342 | { |
3373 | if (!ROW(end_row).is_longer ()) |
3343 | if (!ROW(end_row).is_longer ()) |
3374 | { |
3344 | { |
3375 | selection.end.row = end_row; |
3345 | selection.end.row = end_row; |
3376 | selection.end.col = save[end_row + saveLines].l; |
3346 | selection.end.col = ROW(end_row).l; |
3377 | selection_remove_trailing_spaces (); |
3347 | selection_remove_trailing_spaces (); |
3378 | break; |
3348 | break; |
3379 | } |
3349 | } |
3380 | } |
3350 | } |
3381 | } |
3351 | } |
… | |
… | |
3413 | } |
3383 | } |
3414 | } |
3384 | } |
3415 | |
3385 | |
3416 | #if ENABLE_FRILLS |
3386 | #if ENABLE_FRILLS |
3417 | if (selection.rect && selection.beg.col > selection.end.col) |
3387 | if (selection.rect && selection.beg.col > selection.end.col) |
3418 | SWAP_IT (selection.beg.col, selection.end.col, int); |
3388 | ::swap (selection.beg.col, selection.end.col); |
3419 | #endif |
3389 | #endif |
3420 | } |
3390 | } |
3421 | |
3391 | |
3422 | #if ENABLE_FRILLS |
3392 | #if ENABLE_FRILLS |
3423 | void |
3393 | void |
… | |
… | |
3433 | { |
3403 | { |
3434 | stp = ROW(end_row).t; |
3404 | stp = ROW(end_row).t; |
3435 | |
3405 | |
3436 | while (--end_col >= 0) |
3406 | while (--end_col >= 0) |
3437 | { |
3407 | { |
3438 | if (stp[end_col] != ' ' |
3408 | if (stp[end_col] != NOCHAR |
3439 | && stp[end_col] != '\t' |
3409 | && !unicode::is_space (stp[end_col])) |
3440 | && stp[end_col] != NOCHAR) |
|
|
3441 | break; |
3410 | break; |
3442 | } |
3411 | } |
3443 | |
3412 | |
3444 | if (end_col >= 0 |
3413 | if (end_col >= 0 |
3445 | || !ROW(end_row - 1).is_longer ()) |
3414 | || !ROW(end_row - 1).is_longer ()) |
… | |
… | |
3621 | */ |
3590 | */ |
3622 | void |
3591 | void |
3623 | rxvt_term::pixel_position (int *x, int *y) |
3592 | rxvt_term::pixel_position (int *x, int *y) |
3624 | { |
3593 | { |
3625 | *x = Pixel2Col (*x); |
3594 | *x = Pixel2Col (*x); |
3626 | /* MAX_IT (*x, 0); MIN_IT (*x, (int)ncol - 1); */ |
3595 | /* max_it (*x, 0); min_it (*x, (int)ncol - 1); */ |
3627 | *y = Pixel2Row (*y); |
3596 | *y = Pixel2Row (*y); |
3628 | /* MAX_IT (*y, 0); MIN_IT (*y, (int)nrow - 1); */ |
3597 | /* max_it (*y, 0); min_it (*y, (int)nrow - 1); */ |
3629 | } |
3598 | } |
3630 | |
3599 | |
3631 | /* ------------------------------------------------------------------------- */ |
3600 | /* ------------------------------------------------------------------------- */ |
3632 | #ifdef USE_XIM |
3601 | #ifdef USE_XIM |
3633 | void |
3602 | void |
… | |
… | |
3644 | |
3613 | |
3645 | #if ENABLE_OVERLAY |
3614 | #if ENABLE_OVERLAY |
3646 | void |
3615 | void |
3647 | rxvt_term::scr_overlay_new (int x, int y, int w, int h) |
3616 | rxvt_term::scr_overlay_new (int x, int y, int w, int h) |
3648 | { |
3617 | { |
3649 | if (nrow < 3 || ncol < 3) |
3618 | if (nrow < 1 || ncol < 1) |
3650 | return; |
3619 | return; |
3651 | |
3620 | |
3652 | want_refresh = 1; |
3621 | want_refresh = 1; |
3653 | |
3622 | |
3654 | scr_overlay_off (); |
3623 | scr_overlay_off (); |
3655 | |
3624 | |
3656 | if (x < 0) x = ncol - w; |
3625 | if (x < 0) x = ncol - w; |
3657 | if (y < 0) y = nrow - h; |
3626 | if (y < 0) y = nrow - h; |
3658 | |
3627 | |
3659 | // make space for border |
3628 | // make space for border |
3660 | w += 2; MIN_IT (w, ncol); |
3629 | w += 2; min_it (w, ncol); |
3661 | h += 2; MIN_IT (h, nrow); |
3630 | h += 2; min_it (h, nrow); |
3662 | |
3631 | |
3663 | x -= 1; MAX_IT (x, 0); |
3632 | x -= 1; clamp_it (x, 0, ncol - w); |
3664 | y -= 1; MAX_IT (y, 0); |
3633 | y -= 1; clamp_it (y, 0, nrow - h); |
3665 | |
|
|
3666 | MIN_IT (x, ncol - w); |
|
|
3667 | MIN_IT (y, nrow - h); |
|
|
3668 | |
3634 | |
3669 | ov_x = x; ov_y = y; |
3635 | ov_x = x; ov_y = y; |
3670 | ov_w = w; ov_h = h; |
3636 | ov_w = w; ov_h = h; |
3671 | |
3637 | |
3672 | ov_text = new text_t *[h]; |
3638 | ov_text = new text_t *[h]; |
… | |
… | |
3764 | for (int y = ov_h; y--; ) |
3730 | for (int y = ov_h; y--; ) |
3765 | { |
3731 | { |
3766 | text_t *t1 = ov_text[y]; |
3732 | text_t *t1 = ov_text[y]; |
3767 | rend_t *r1 = ov_rend[y]; |
3733 | rend_t *r1 = ov_rend[y]; |
3768 | |
3734 | |
3769 | text_t *t2 = ROW(y - view_start).t + ov_x; |
3735 | text_t *t2 = ROW(y + ov_y - view_start).t + ov_x; |
3770 | rend_t *r2 = ROW(y - view_start).r + ov_x; |
3736 | rend_t *r2 = ROW(y + ov_y - view_start).r + ov_x; |
3771 | |
3737 | |
3772 | for (int x = ov_w; x--; ) |
3738 | for (int x = ov_w; x--; ) |
3773 | { |
3739 | { |
3774 | text_t t = *t1; *t1++ = *t2; *t2++ = t; |
3740 | text_t t = *t1; *t1++ = *t2; *t2++ = t; |
3775 | rend_t r = *r1; *r1++ = *r2; *r2++ = SET_FONT (r, FONTSET (r)->find_font (t)); |
3741 | rend_t r = *r1; *r1++ = *r2; *r2++ = SET_FONT (r, FONTSET (r)->find_font (t)); |