… | |
… | |
98 | |
98 | |
99 | /* Fill part/all of a line with blanks. */ |
99 | /* Fill part/all of a line with blanks. */ |
100 | void |
100 | void |
101 | rxvt_term::scr_blank_line (line_t &l, unsigned int col, unsigned int width, rend_t efs) const NOTHROW |
101 | rxvt_term::scr_blank_line (line_t &l, unsigned int col, unsigned int width, rend_t efs) const NOTHROW |
102 | { |
102 | { |
103 | if (!l.t) |
103 | if (!l.valid ()) |
104 | { |
104 | { |
105 | lalloc (l); |
105 | l.alloc (); |
106 | col = 0; |
106 | col = 0; |
107 | width = ncol; |
107 | width = ncol; |
108 | } |
108 | } |
109 | |
109 | |
110 | l.touch (); |
110 | l.touch (); |
… | |
… | |
157 | /* ------------------------------------------------------------------------- * |
157 | /* ------------------------------------------------------------------------- * |
158 | * SCREEN INITIALISATION * |
158 | * SCREEN INITIALISATION * |
159 | * ------------------------------------------------------------------------- */ |
159 | * ------------------------------------------------------------------------- */ |
160 | |
160 | |
161 | void |
161 | void |
|
|
162 | rxvt_term::scr_alloc () |
|
|
163 | { |
|
|
164 | int tsize = sizeof (text_t) * ncol; |
|
|
165 | int rsize = sizeof (rend_t) * ncol; |
|
|
166 | |
|
|
167 | // we assume that rend_t size is a sufficient alignment |
|
|
168 | // factor for tetx_t and line_t values, and we only |
|
|
169 | // need to adjust tsize. |
|
|
170 | tsize = (tsize + sizeof (rend_t) - 1); |
|
|
171 | tsize -= tsize % sizeof (rend_t); |
|
|
172 | |
|
|
173 | int all_rows = total_rows + nrow + nrow; |
|
|
174 | |
|
|
175 | chunk_size = (sizeof (line_t) + rsize + tsize) * all_rows; |
|
|
176 | chunk = rxvt_malloc (chunk_size); |
|
|
177 | |
|
|
178 | char *base = (char *)chunk + sizeof (line_t) * all_rows; |
|
|
179 | |
|
|
180 | for (int row = 0; row < all_rows; ++row) |
|
|
181 | { |
|
|
182 | line_t &l = ((line_t *)chunk) [row]; |
|
|
183 | |
|
|
184 | l.t = (text_t *)base; base += tsize; |
|
|
185 | l.r = (rend_t *)base; base += rsize; |
|
|
186 | l.l = -1; |
|
|
187 | l.f = 0; |
|
|
188 | } |
|
|
189 | |
|
|
190 | drawn_buf = (line_t *)chunk; |
|
|
191 | swap_buf = drawn_buf + nrow; |
|
|
192 | row_buf = swap_buf + nrow; |
|
|
193 | } |
|
|
194 | |
|
|
195 | void |
162 | rxvt_term::scr_reset () |
196 | rxvt_term::scr_reset () |
163 | { |
197 | { |
164 | #if ENABLE_OVERLAY |
198 | #if ENABLE_OVERLAY |
165 | scr_overlay_off (); |
199 | scr_overlay_off (); |
166 | #endif |
200 | #endif |
… | |
… | |
192 | total_rows = nrow + saveLines; |
226 | total_rows = nrow + saveLines; |
193 | |
227 | |
194 | screen.tscroll = 0; |
228 | screen.tscroll = 0; |
195 | screen.bscroll = nrow - 1; |
229 | screen.bscroll = nrow - 1; |
196 | |
230 | |
|
|
231 | void *prev_chunk = chunk; |
|
|
232 | line_t *prev_drawn_buf = drawn_buf; |
|
|
233 | line_t *prev_swap_buf = swap_buf; |
|
|
234 | line_t *prev_row_buf = row_buf; |
|
|
235 | |
|
|
236 | int common_col = min (prev_ncol, ncol); |
|
|
237 | |
|
|
238 | scr_alloc (); |
|
|
239 | |
197 | if (!row_buf) |
240 | if (!prev_row_buf) |
198 | { |
241 | { |
199 | /* |
242 | /* |
200 | * first time called so just malloc everything: don't rely on realloc |
243 | * first time called so just malloc everything: don't rely on realloc |
201 | */ |
244 | */ |
202 | top_row = 0; |
245 | top_row = 0; |
203 | term_start = 0; |
246 | term_start = 0; |
204 | |
|
|
205 | talloc = new rxvt_salloc (ncol * sizeof (text_t)); |
|
|
206 | ralloc = new rxvt_salloc (ncol * sizeof (rend_t)); |
|
|
207 | |
|
|
208 | row_buf = (line_t *)rxvt_calloc (total_rows + nrow, sizeof (line_t)); |
|
|
209 | drawn_buf = (line_t *)rxvt_calloc (nrow , sizeof (line_t)); |
|
|
210 | swap_buf = (line_t *)rxvt_calloc (nrow , sizeof (line_t)); |
|
|
211 | |
|
|
212 | for (int row = nrow; row--; ) |
|
|
213 | { |
|
|
214 | scr_blank_screen_mem (ROW (row), DEFAULT_RSTYLE); |
|
|
215 | scr_blank_screen_mem (swap_buf [row], DEFAULT_RSTYLE); |
|
|
216 | scr_blank_screen_mem (drawn_buf[row], DEFAULT_RSTYLE); |
|
|
217 | } |
|
|
218 | |
247 | |
219 | memset (charsets, 'B', sizeof (charsets)); |
248 | memset (charsets, 'B', sizeof (charsets)); |
220 | rstyle = DEFAULT_RSTYLE; |
249 | rstyle = DEFAULT_RSTYLE; |
221 | screen.flags = Screen_DefaultFlags; |
250 | screen.flags = Screen_DefaultFlags; |
222 | screen.cur.row = screen.cur.col = 0; |
251 | screen.cur.row = screen.cur.col = 0; |
… | |
… | |
245 | { |
274 | { |
246 | /* |
275 | /* |
247 | * add or delete rows as appropriate |
276 | * add or delete rows as appropriate |
248 | */ |
277 | */ |
249 | |
278 | |
250 | rxvt_salloc *old_ta = talloc; talloc = new rxvt_salloc (ncol * sizeof (text_t)); |
|
|
251 | rxvt_salloc *old_ra = ralloc; ralloc = new rxvt_salloc (ncol * sizeof (rend_t)); |
|
|
252 | |
|
|
253 | #if 0 |
|
|
254 | if (nrow < prev_nrow) |
|
|
255 | { |
|
|
256 | for (int row = nrow; row < prev_nrow; row++) |
|
|
257 | { |
|
|
258 | lfree (swap_buf [row]); |
|
|
259 | lfree (drawn_buf[row]); |
|
|
260 | } |
|
|
261 | } |
|
|
262 | #endif |
|
|
263 | |
|
|
264 | drawn_buf = (line_t *)rxvt_realloc (drawn_buf, nrow * sizeof (line_t)); |
|
|
265 | swap_buf = (line_t *)rxvt_realloc (swap_buf , nrow * sizeof (line_t)); |
|
|
266 | |
|
|
267 | for (int row = min (nrow, prev_nrow); row--; ) |
279 | for (int row = min (nrow, prev_nrow); row--; ) |
268 | { |
280 | { |
269 | lresize (drawn_buf[row]); |
281 | scr_blank_screen_mem (drawn_buf [row], DEFAULT_RSTYLE); |
270 | lresize (swap_buf [row]); |
282 | scr_blank_screen_mem (swap_buf [row], DEFAULT_RSTYLE); |
271 | } |
|
|
272 | |
283 | |
273 | for (int row = prev_nrow; row < nrow; row++) |
284 | memcpy (drawn_buf [row].t, prev_drawn_buf [row].t, sizeof (text_t) * common_col); |
|
|
285 | memcpy (drawn_buf [row].r, prev_drawn_buf [row].r, sizeof (rend_t) * common_col); |
|
|
286 | memcpy (swap_buf [row].t, prev_swap_buf [row].t, sizeof (text_t) * common_col); |
|
|
287 | memcpy (swap_buf [row].r, prev_swap_buf [row].r, sizeof (rend_t) * common_col); |
274 | { |
288 | } |
275 | swap_buf [row].clear (); scr_blank_screen_mem (swap_buf [row], DEFAULT_RSTYLE); |
|
|
276 | drawn_buf[row].clear (); scr_blank_screen_mem (drawn_buf[row], DEFAULT_RSTYLE); |
|
|
277 | } |
|
|
278 | |
|
|
279 | line_t *old_buf = row_buf; |
|
|
280 | row_buf = (line_t *)rxvt_calloc (total_rows + nrow, sizeof (line_t)); |
|
|
281 | |
289 | |
282 | int p = MOD (term_start + prev_nrow, prev_total_rows); // previous row |
290 | int p = MOD (term_start + prev_nrow, prev_total_rows); // previous row |
283 | int pend = MOD (term_start + top_row , prev_total_rows); |
291 | int pend = MOD (term_start + top_row , prev_total_rows); |
284 | int q = total_rows; // rewrapped row |
292 | int q = total_rows; // rewrapped row |
285 | |
293 | |
… | |
… | |
293 | ocur.row = MOD (term_start + ocur.row, prev_total_rows); |
301 | ocur.row = MOD (term_start + ocur.row, prev_total_rows); |
294 | |
302 | |
295 | do |
303 | do |
296 | { |
304 | { |
297 | p = MOD (p - 1, prev_total_rows); |
305 | p = MOD (p - 1, prev_total_rows); |
298 | assert (old_buf [MOD (p, prev_total_rows)].t); |
306 | assert (prev_row_buf [MOD (p, prev_total_rows)].t); |
299 | int plines = 1; |
307 | int plines = 1; |
300 | int llen = old_buf [MOD (p, prev_total_rows)].l; |
308 | int llen = prev_row_buf [MOD (p, prev_total_rows)].l; |
301 | |
309 | |
302 | while (p != pend && old_buf [MOD (p - 1, prev_total_rows)].is_longer ()) |
310 | while (p != pend && prev_row_buf [MOD (p - 1, prev_total_rows)].is_longer ()) |
303 | { |
311 | { |
304 | p = MOD (p - 1, prev_total_rows); |
312 | p = MOD (p - 1, prev_total_rows); |
305 | |
313 | |
306 | plines++; |
314 | plines++; |
307 | llen += prev_ncol; |
315 | llen += prev_ncol; |
… | |
… | |
320 | |
328 | |
321 | // re-assemble the full line by destination lines |
329 | // re-assemble the full line by destination lines |
322 | for (int qrow = q; qlines--; qrow++) |
330 | for (int qrow = q; qlines--; qrow++) |
323 | { |
331 | { |
324 | qline = row_buf + qrow; |
332 | qline = row_buf + qrow; |
325 | lalloc (*qline); |
333 | qline->alloc (); // redundant with next line |
326 | qline->l = ncol; |
334 | qline->l = ncol; |
327 | qline->is_longer (1); |
335 | qline->is_longer (1); |
328 | |
336 | |
329 | int qcol = 0; |
337 | int qcol = 0; |
330 | |
338 | |
… | |
… | |
345 | // this seems to upset applications/shells/readline |
353 | // this seems to upset applications/shells/readline |
346 | // least. |
354 | // least. |
347 | if (prow == ocur.row) |
355 | if (prow == ocur.row) |
348 | screen.cur.row = q - (total_rows - nrow); |
356 | screen.cur.row = q - (total_rows - nrow); |
349 | |
357 | |
350 | line_t &pline = old_buf [prow]; |
358 | line_t &pline = prev_row_buf [prow]; |
351 | |
359 | |
352 | int len = min (min (prev_ncol - pcol, ncol - qcol), llen - lofs); |
360 | int len = min (min (prev_ncol - pcol, ncol - qcol), llen - lofs); |
353 | |
361 | |
354 | memcpy (qline->t + qcol, pline.t + pcol, len * sizeof (text_t)); |
362 | memcpy (qline->t + qcol, pline.t + pcol, len * sizeof (text_t)); |
355 | memcpy (qline->r + qcol, pline.r + pcol, len * sizeof (rend_t)); |
363 | memcpy (qline->r + qcol, pline.r + pcol, len * sizeof (rend_t)); |
… | |
… | |
376 | { |
384 | { |
377 | // if no scrollback exists (yet), wing, instead of wrap |
385 | // if no scrollback exists (yet), wing, instead of wrap |
378 | |
386 | |
379 | for (int row = min (nrow, prev_nrow); row--; ) |
387 | for (int row = min (nrow, prev_nrow); row--; ) |
380 | { |
388 | { |
381 | line_t &pline = old_buf [MOD (term_start + row, prev_total_rows)]; |
389 | line_t &src = prev_row_buf [MOD (term_start + row, prev_total_rows)]; |
382 | line_t &qline = row_buf [row]; |
390 | line_t &dst = row_buf [row]; |
383 | |
391 | |
384 | qline = pline; |
392 | scr_blank_screen_mem (dst, DEFAULT_RSTYLE); |
385 | lresize (qline); |
393 | |
|
|
394 | memcpy (dst.t, src.t, sizeof (text_t) * common_col); |
|
|
395 | memcpy (dst.r, src.r, sizeof (rend_t) * common_col); |
386 | } |
396 | } |
387 | |
397 | |
388 | for (int row = prev_nrow; row < nrow; row++) |
398 | for (int row = prev_nrow; row < nrow; row++) |
389 | { |
|
|
390 | row_buf [row].clear (); scr_blank_screen_mem (row_buf [row], DEFAULT_RSTYLE); |
399 | scr_blank_screen_mem (row_buf [row], DEFAULT_RSTYLE); |
391 | } |
|
|
392 | |
400 | |
393 | term_start = 0; |
401 | term_start = 0; |
394 | } |
402 | } |
395 | |
|
|
396 | free (old_buf); |
|
|
397 | delete old_ta; |
|
|
398 | delete old_ra; |
|
|
399 | |
403 | |
400 | clamp_it (screen.cur.row, 0, nrow - 1); |
404 | clamp_it (screen.cur.row, 0, nrow - 1); |
401 | clamp_it (screen.cur.col, 0, ncol - 1); |
405 | clamp_it (screen.cur.col, 0, ncol - 1); |
402 | } |
406 | } |
403 | |
407 | |
|
|
408 | for (int row = nrow; row--; ) |
|
|
409 | { |
|
|
410 | if (!ROW (row).valid ()) scr_blank_screen_mem (ROW (row), DEFAULT_RSTYLE); |
|
|
411 | if (!swap_buf [row].valid ()) scr_blank_screen_mem (swap_buf [row], DEFAULT_RSTYLE); |
|
|
412 | if (!drawn_buf [row].valid ()) scr_blank_screen_mem (drawn_buf [row], DEFAULT_RSTYLE); |
|
|
413 | } |
|
|
414 | |
|
|
415 | free (prev_chunk); |
|
|
416 | |
404 | free (tabs); |
417 | free (tabs); |
405 | tabs = (char *)rxvt_malloc (ncol); |
418 | tabs = (char *)rxvt_malloc (ncol); |
406 | |
419 | |
407 | for (int col = ncol; col--; ) |
420 | for (int col = ncol; col--; ) |
408 | tabs [col] = col % TABSIZE == 0; |
421 | tabs [col] = col % TABSIZE == 0; |
… | |
… | |
422 | * Free everything. That way malloc debugging can find leakage. |
435 | * Free everything. That way malloc debugging can find leakage. |
423 | */ |
436 | */ |
424 | void |
437 | void |
425 | rxvt_term::scr_release () NOTHROW |
438 | rxvt_term::scr_release () NOTHROW |
426 | { |
439 | { |
427 | if (row_buf) |
440 | free (chunk); |
428 | { |
|
|
429 | delete talloc; talloc = 0; |
|
|
430 | delete ralloc; ralloc = 0; |
|
|
431 | |
|
|
432 | free (row_buf); |
|
|
433 | free (swap_buf); |
|
|
434 | free (drawn_buf); |
|
|
435 | row_buf = 0; // signal that we freed all the arrays above |
|
|
436 | |
|
|
437 | free (tabs); |
441 | free (tabs); |
438 | tabs = 0; |
|
|
439 | } |
|
|
440 | } |
442 | } |
441 | |
443 | |
442 | /* ------------------------------------------------------------------------- */ |
444 | /* ------------------------------------------------------------------------- */ |
443 | /* |
445 | /* |
444 | * Hard/Soft reset |
446 | * Hard/Soft reset |
445 | */ |
447 | */ |
446 | void |
448 | void |
447 | rxvt_term::scr_poweron () |
449 | rxvt_term::scr_poweron () |
448 | { |
450 | { |
449 | scr_release (); |
451 | scr_release (); |
|
|
452 | |
|
|
453 | row_buf = 0; |
|
|
454 | tabs = 0; |
450 | prev_nrow = prev_ncol = 0; |
455 | prev_nrow = prev_ncol = 0; |
451 | rvideo_mode = false; |
456 | rvideo_mode = false; |
452 | scr_soft_reset (); |
457 | scr_soft_reset (); |
453 | scr_reset (); |
458 | scr_reset (); |
454 | |
459 | |
455 | scr_clear (true); |
460 | scr_clear (true); |
456 | scr_refresh (); |
461 | scr_refresh (); |
457 | } |
462 | } |
458 | |
463 | |
459 | void |
464 | void |
460 | rxvt_term::scr_soft_reset () |
465 | rxvt_term::scr_soft_reset () NOTHROW |
461 | { |
466 | { |
462 | /* only affects modes, nothing drastic such as clearing the screen */ |
467 | /* only affects modes, nothing drastic such as clearing the screen */ |
463 | #if ENABLE_OVERLAY |
468 | #if ENABLE_OVERLAY |
464 | scr_overlay_off (); |
469 | scr_overlay_off (); |
465 | #endif |
470 | #endif |
… | |
… | |
520 | assert (s->cur.row >= 0); |
525 | assert (s->cur.row >= 0); |
521 | assert (s->cur.col >= 0); |
526 | assert (s->cur.col >= 0); |
522 | } |
527 | } |
523 | |
528 | |
524 | void |
529 | void |
525 | rxvt_term::scr_swap_screen () |
530 | rxvt_term::scr_swap_screen () NOTHROW |
526 | { |
531 | { |
527 | if (!option (Opt_secondaryScreen)) |
532 | if (!option (Opt_secondaryScreen)) |
528 | return; |
533 | return; |
529 | |
534 | |
530 | for (int i = prev_nrow; i--; ) |
535 | for (int i = prev_nrow; i--; ) |
… | |
… | |
549 | return; |
554 | return; |
550 | |
555 | |
551 | want_refresh = 1; |
556 | want_refresh = 1; |
552 | view_start = 0; |
557 | view_start = 0; |
553 | |
558 | |
554 | selection_check (2); /* check for boundary cross */ |
559 | /* check for boundary cross */ |
|
|
560 | row_col_t pos; |
|
|
561 | pos.row = pos.col = 0; |
|
|
562 | if (ROWCOL_IS_BEFORE (selection.beg, pos) |
|
|
563 | && ROWCOL_IS_AFTER (selection.end, pos)) |
|
|
564 | CLEAR_SELECTION (); |
555 | |
565 | |
556 | current_screen = scrn; |
566 | current_screen = scrn; |
557 | |
567 | |
558 | #if NSCREENS |
568 | #if NSCREENS |
559 | if (option (Opt_secondaryScreen)) |
569 | if (option (Opt_secondaryScreen)) |
… | |
… | |
638 | |
648 | |
639 | if (count > 0 |
649 | if (count > 0 |
640 | && row1 == 0 |
650 | && row1 == 0 |
641 | && (current_screen == PRIMARY || option (Opt_secondaryScroll))) |
651 | && (current_screen == PRIMARY || option (Opt_secondaryScroll))) |
642 | { |
652 | { |
|
|
653 | min_it (count, total_rows - (nrow - (row2 + 1))); |
|
|
654 | |
643 | top_row = max (top_row - count, -saveLines); |
655 | top_row = max (top_row - count, -saveLines); |
644 | |
|
|
645 | // scroll everything up 'count' lines |
|
|
646 | term_start = (term_start + count) % total_rows; |
|
|
647 | |
656 | |
648 | // sever bottommost line |
657 | // sever bottommost line |
649 | { |
658 | { |
650 | line_t &l = ROW(row2 - count); |
659 | line_t &l = ROW(row2); |
651 | l.is_longer (0); |
660 | l.is_longer (0); |
652 | l.touch (); |
661 | l.touch (); |
653 | } |
662 | } |
654 | |
663 | |
|
|
664 | // scroll everything up 'count' lines |
|
|
665 | term_start = (term_start + count) % total_rows; |
|
|
666 | |
|
|
667 | // now copy lines below the scroll region bottom to the |
|
|
668 | // bottom of the screen again, so they look as if they |
|
|
669 | // hadn't moved. |
|
|
670 | for (int i = nrow; --i > row2; ) |
|
|
671 | { |
|
|
672 | line_t &l1 = ROW(i - count); |
|
|
673 | line_t &l2 = ROW(i); |
|
|
674 | |
|
|
675 | ::swap (l1, l2); |
|
|
676 | l2.touch (); |
|
|
677 | } |
|
|
678 | |
655 | // erase newly scrolled-in lines |
679 | // erase newly scrolled-in lines |
656 | for (int i = count; i--; ) |
680 | for (int i = count; i--; ) |
657 | { |
681 | { |
658 | line_t &l = ROW(nrow - 1 - i); |
682 | line_t &l = ROW(row2 - i); |
659 | |
683 | |
660 | // optimize if already cleared, can be significant on slow machines |
684 | // optimise if already cleared, can be significant on slow machines |
661 | // could be rolled into scr_blank_screen_mem |
685 | // could be rolled into scr_blank_screen_mem |
662 | if (l.r && l.l < ncol - 1 && !((l.r[l.l + 1] ^ rstyle) & (RS_fgMask | RS_bgMask))) |
686 | if (l.r && l.l < ncol - 1 && !((l.r[l.l + 1] ^ rstyle) & (RS_fgMask | RS_bgMask))) |
663 | { |
687 | { |
664 | scr_blank_line (l, 0, l.l, rstyle); |
688 | scr_blank_line (l, 0, l.l, rstyle); |
665 | l.l = 0; |
689 | l.l = 0; |
… | |
… | |
667 | } |
691 | } |
668 | else |
692 | else |
669 | scr_blank_screen_mem (l, rstyle); |
693 | scr_blank_screen_mem (l, rstyle); |
670 | } |
694 | } |
671 | |
695 | |
672 | // now copy lines below the scroll region bottom to the |
|
|
673 | // bottom of the screen again, so they look as if they |
|
|
674 | // hadn't moved. |
|
|
675 | for (int i = nrow; --i > row2; ) |
|
|
676 | { |
|
|
677 | line_t &l1 = ROW(i - count); |
|
|
678 | line_t &l2 = ROW(i); |
|
|
679 | |
|
|
680 | ::swap (l1, l2); |
|
|
681 | l2.touch (); |
|
|
682 | } |
|
|
683 | |
|
|
684 | // move and/or clear selection, if any |
696 | // move and/or clear selection, if any |
685 | if (selection.op && current_screen == selection.screen) |
697 | if (selection.op && current_screen == selection.screen |
|
|
698 | && selection.beg.row <= row2) |
686 | { |
699 | { |
687 | selection.beg.row -= count; |
700 | selection.beg.row -= count; |
688 | selection.end.row -= count; |
701 | selection.end.row -= count; |
689 | selection.mark.row -= count; |
702 | selection.mark.row -= count; |
690 | |
703 | |
691 | if (selection.beg.row < top_row |
704 | selection_check (0); |
692 | || selection.end.row < top_row |
|
|
693 | || selection.mark.row < top_row) |
|
|
694 | { |
|
|
695 | CLEAR_ALL_SELECTION (); |
|
|
696 | selection.op = SELECTION_CLEAR; |
|
|
697 | } |
|
|
698 | } |
705 | } |
699 | |
706 | |
700 | // finally move the view window, if desired |
707 | // finally move the view window, if desired |
701 | if (option (Opt_scrollWithBuffer) |
708 | if (option (Opt_scrollWithBuffer) |
702 | && view_start != 0 |
709 | && view_start != 0 |
… | |
… | |
732 | } |
739 | } |
733 | |
740 | |
734 | // use a simple and robust scrolling algorithm, this |
741 | // use a simple and robust scrolling algorithm, this |
735 | // part of scr_scroll_text is not time-critical. |
742 | // part of scr_scroll_text is not time-critical. |
736 | |
743 | |
|
|
744 | // sever line above scroll region |
|
|
745 | if (row1) |
|
|
746 | { |
|
|
747 | line_t &l = ROW(row1 - 1); |
|
|
748 | l.is_longer (0); |
|
|
749 | l.touch (); |
|
|
750 | } |
|
|
751 | |
737 | int rows = row2 - row1 + 1; |
752 | int rows = row2 - row1 + 1; |
738 | |
753 | |
739 | min_it (count, rows); |
754 | min_it (count, rows); |
740 | |
755 | |
741 | line_t *temp_buf = row_buf + total_rows; |
756 | line_t *temp_buf = rxvt_temp_buf<line_t> (rows); |
742 | |
757 | |
743 | for (int row = 0; row < rows; row++) |
758 | for (int row = 0; row < rows; row++) |
744 | { |
759 | { |
745 | temp_buf [row] = ROW(row1 + (row + count + rows) % rows); |
760 | temp_buf [row] = ROW(row1 + (row + count + rows) % rows); |
746 | |
761 | |
… | |
… | |
748 | scr_blank_screen_mem (temp_buf [row], rstyle); |
763 | scr_blank_screen_mem (temp_buf [row], rstyle); |
749 | } |
764 | } |
750 | |
765 | |
751 | for (int row = 0; row < rows; row++) |
766 | for (int row = 0; row < rows; row++) |
752 | ROW(row1 + row) = temp_buf [row]; |
767 | ROW(row1 + row) = temp_buf [row]; |
|
|
768 | |
|
|
769 | // sever bottommost line |
|
|
770 | { |
|
|
771 | line_t &l = ROW(row2); |
|
|
772 | l.is_longer (0); |
|
|
773 | l.touch (); |
|
|
774 | } |
753 | } |
775 | } |
754 | |
776 | |
755 | return count; |
777 | return count; |
756 | } |
778 | } |
757 | |
779 | |
… | |
… | |
763 | rxvt_term::scr_add_lines (const wchar_t *str, int len, int minlines) NOTHROW |
785 | rxvt_term::scr_add_lines (const wchar_t *str, int len, int minlines) NOTHROW |
764 | { |
786 | { |
765 | if (len <= 0) /* sanity */ |
787 | if (len <= 0) /* sanity */ |
766 | return; |
788 | return; |
767 | |
789 | |
768 | unsigned char checksel; |
790 | bool checksel; |
769 | unicode_t c; |
791 | unicode_t c; |
770 | int ncol = this->ncol; |
792 | int ncol = this->ncol; |
771 | const wchar_t *strend = str + len; |
793 | const wchar_t *strend = str + len; |
772 | |
794 | |
773 | want_refresh = 1; |
795 | want_refresh = 1; |
… | |
… | |
799 | |
821 | |
800 | while (str < strend) |
822 | while (str < strend) |
801 | { |
823 | { |
802 | c = (unicode_t)*str++; // convert to rxvt-unicodes representation |
824 | c = (unicode_t)*str++; // convert to rxvt-unicodes representation |
803 | |
825 | |
804 | if (expect_false (c < 0x20)) |
826 | if (ecb_unlikely (c < 0x20)) |
805 | if (c == C0_LF) |
827 | if (c == C0_LF) |
806 | { |
828 | { |
807 | max_it (line->l, screen.cur.col); |
829 | max_it (line->l, screen.cur.col); |
808 | |
830 | |
809 | screen.flags &= ~Screen_WrapNext; |
831 | screen.flags &= ~Screen_WrapNext; |
… | |
… | |
828 | { |
850 | { |
829 | scr_tab (1, true); |
851 | scr_tab (1, true); |
830 | continue; |
852 | continue; |
831 | } |
853 | } |
832 | |
854 | |
833 | if (expect_false ( |
855 | if (ecb_unlikely ( |
834 | checksel /* see if we're writing within selection */ |
856 | checksel /* see if we're writing within selection */ |
835 | && !ROWCOL_IS_BEFORE (screen.cur, selection.beg) |
857 | && !ROWCOL_IS_BEFORE (screen.cur, selection.beg) |
836 | && ROWCOL_IS_BEFORE (screen.cur, selection.end) |
858 | && ROWCOL_IS_BEFORE (screen.cur, selection.end) |
837 | )) |
859 | )) |
838 | { |
860 | { |
… | |
… | |
843 | * should be a similar check. |
865 | * should be a similar check. |
844 | */ |
866 | */ |
845 | CLEAR_SELECTION (); |
867 | CLEAR_SELECTION (); |
846 | } |
868 | } |
847 | |
869 | |
848 | if (expect_false (screen.flags & Screen_WrapNext)) |
870 | if (ecb_unlikely (screen.flags & Screen_WrapNext)) |
849 | { |
871 | { |
850 | scr_do_wrap (); |
872 | scr_do_wrap (); |
851 | |
873 | |
852 | line->l = ncol; |
874 | line->l = ncol; |
853 | line->is_longer (1); |
875 | line->is_longer (1); |
… | |
… | |
855 | row = screen.cur.row; |
877 | row = screen.cur.row; |
856 | line = &ROW(row); /* _must_ refresh */ |
878 | line = &ROW(row); /* _must_ refresh */ |
857 | } |
879 | } |
858 | |
880 | |
859 | // some utf-8 decoders "decode" surrogate characters: let's fix this. |
881 | // some utf-8 decoders "decode" surrogate characters: let's fix this. |
860 | if (expect_false (IN_RANGE_INC (c, 0xd800, 0xdfff))) |
882 | if (ecb_unlikely (IN_RANGE_INC (c, 0xd800, 0xdfff))) |
861 | c = 0xfffd; |
883 | c = 0xfffd; |
862 | |
884 | |
863 | // rely on wcwidth to tell us the character width, do wcwidth before |
885 | // rely on wcwidth to tell us the character width, do wcwidth before |
864 | // further replacements, as wcwidth might return -1 for the line |
886 | // further replacements, as wcwidth might return -1 for the line |
865 | // drawing characters below as they might be invalid in the current |
887 | // drawing characters below as they might be invalid in the current |
866 | // locale. |
888 | // locale. |
867 | int width = WCWIDTH (c); |
889 | int width = WCWIDTH (c); |
868 | |
890 | |
869 | if (expect_false (charsets [screen.charset] == '0')) // DEC SPECIAL |
891 | if (ecb_unlikely (charsets [screen.charset] == '0')) // DEC SPECIAL |
870 | { |
892 | { |
871 | // vt100 special graphics and line drawing |
893 | // vt100 special graphics and line drawing |
872 | // 5f-7e standard vt100 |
894 | // 5f-7e standard vt100 |
873 | // 40-5e rxvt extension for extra curses acs chars |
895 | // 40-5e rxvt extension for extra curses acs chars |
874 | static uint16_t vt100_0[62] = { // 41 .. 7e |
896 | static uint16_t vt100_0[62] = { // 41 .. 7e |
… | |
… | |
887 | c = vt100_0[c - 0x41]; |
909 | c = vt100_0[c - 0x41]; |
888 | width = 1; // vt100 line drawing characters are always single-width |
910 | width = 1; // vt100 line drawing characters are always single-width |
889 | } |
911 | } |
890 | } |
912 | } |
891 | |
913 | |
892 | if (expect_false (screen.flags & Screen_Insert)) |
914 | if (ecb_unlikely (screen.flags & Screen_Insert)) |
893 | scr_insdel_chars (width, INSERT); |
915 | scr_insdel_chars (width, INSERT); |
894 | |
916 | |
895 | if (width != 0) |
917 | if (width != 0) |
896 | { |
918 | { |
897 | #if !UNICODE_3 |
919 | #if !UNICODE_3 |
… | |
… | |
905 | #endif |
927 | #endif |
906 | |
928 | |
907 | rend_t rend = SET_FONT (rstyle, FONTSET (rstyle)->find_font (c)); |
929 | rend_t rend = SET_FONT (rstyle, FONTSET (rstyle)->find_font (c)); |
908 | |
930 | |
909 | // if the character doesn't fit into the remaining columns... |
931 | // if the character doesn't fit into the remaining columns... |
910 | if (expect_false (screen.cur.col > ncol - width && ncol >= width)) |
932 | if (ecb_unlikely (screen.cur.col > ncol - width && ncol >= width)) |
911 | { |
933 | { |
912 | if (screen.flags & Screen_Autowrap) |
934 | if (screen.flags & Screen_Autowrap) |
913 | { |
935 | { |
914 | // ... artificially enlargen the previous one |
936 | // ... artificially enlargen the previous one |
915 | c = NOCHAR; |
937 | c = NOCHAR; |
… | |
… | |
922 | |
944 | |
923 | // nuke the character at this position, if required |
945 | // nuke the character at this position, if required |
924 | // due to wonderful coincidences everywhere else in this loop |
946 | // due to wonderful coincidences everywhere else in this loop |
925 | // we never have to check for overwriting a wide char itself, |
947 | // we never have to check for overwriting a wide char itself, |
926 | // only its tail. |
948 | // only its tail. |
927 | if (expect_false (line->t[screen.cur.col] == NOCHAR)) |
949 | if (ecb_unlikely (line->t[screen.cur.col] == NOCHAR)) |
928 | scr_kill_char (*line, screen.cur.col); |
950 | scr_kill_char (*line, screen.cur.col); |
929 | |
951 | |
930 | line->touch (); |
952 | line->touch (); |
931 | |
953 | |
932 | do |
954 | do |
933 | { |
955 | { |
934 | line->t[screen.cur.col] = c; |
956 | line->t[screen.cur.col] = c; |
935 | line->r[screen.cur.col] = rend; |
957 | line->r[screen.cur.col] = rend; |
936 | |
958 | |
937 | if (expect_true (screen.cur.col < ncol - 1)) |
959 | if (ecb_likely (screen.cur.col < ncol - 1)) |
938 | screen.cur.col++; |
960 | screen.cur.col++; |
939 | else |
961 | else |
940 | { |
962 | { |
941 | line->l = ncol; |
963 | line->l = ncol; |
942 | if (screen.flags & Screen_Autowrap) |
964 | if (screen.flags & Screen_Autowrap) |
… | |
… | |
945 | goto end_of_line; |
967 | goto end_of_line; |
946 | } |
968 | } |
947 | |
969 | |
948 | c = NOCHAR; |
970 | c = NOCHAR; |
949 | } |
971 | } |
950 | while (expect_false (--width > 0)); |
972 | while (ecb_unlikely (--width > 0)); |
951 | |
973 | |
952 | // pad with spaces when overwriting wide character with smaller one |
974 | // pad with spaces when overwriting wide character with smaller one |
953 | for (int c = screen.cur.col; expect_false (c < ncol && line->t[c] == NOCHAR); c++) |
975 | for (int c = screen.cur.col; ecb_unlikely (c < ncol && line->t[c] == NOCHAR); c++) |
954 | { |
976 | { |
955 | line->t[c] = ' '; |
977 | line->t[c] = ' '; |
956 | line->r[c] = rend; |
978 | line->r[c] = rend; |
957 | } |
979 | } |
958 | |
980 | |
… | |
… | |
1295 | scr_blank_line (line, col, num, rstyle); |
1317 | scr_blank_line (line, col, num, rstyle); |
1296 | } |
1318 | } |
1297 | |
1319 | |
1298 | /* ------------------------------------------------------------------------- */ |
1320 | /* ------------------------------------------------------------------------- */ |
1299 | /* |
1321 | /* |
1300 | * Erase part of whole of the screen |
1322 | * Erase part or whole of the screen |
1301 | * XTERM_SEQ: Clear screen after cursor : ESC [ 0 J |
1323 | * XTERM_SEQ: Clear screen after cursor : ESC [ 0 J |
1302 | * XTERM_SEQ: Clear screen before cursor: ESC [ 1 J |
1324 | * XTERM_SEQ: Clear screen before cursor: ESC [ 1 J |
1303 | * XTERM_SEQ: Clear whole screen : ESC [ 2 J |
1325 | * XTERM_SEQ: Clear whole screen : ESC [ 2 J |
1304 | */ |
1326 | */ |
1305 | void |
1327 | void |
… | |
… | |
1314 | ZERO_SCROLLBACK (); |
1336 | ZERO_SCROLLBACK (); |
1315 | |
1337 | |
1316 | switch (mode) |
1338 | switch (mode) |
1317 | { |
1339 | { |
1318 | case 0: /* erase to end of screen */ |
1340 | case 0: /* erase to end of screen */ |
1319 | selection_check (1); |
|
|
1320 | scr_erase_line (0); |
1341 | scr_erase_line (0); |
1321 | row = screen.cur.row + 1; /* possible OOB */ |
1342 | row = screen.cur.row + 1; /* possible OOB */ |
1322 | num = nrow - row; |
1343 | num = nrow - row; |
1323 | break; |
1344 | break; |
1324 | case 1: /* erase to beginning of screen */ |
1345 | case 1: /* erase to beginning of screen */ |
1325 | selection_check (3); |
|
|
1326 | scr_erase_line (1); |
1346 | scr_erase_line (1); |
1327 | row = 0; |
1347 | row = 0; |
1328 | num = screen.cur.row; |
1348 | num = screen.cur.row; |
1329 | break; |
1349 | break; |
1330 | case 2: /* erase whole screen */ |
1350 | case 2: /* erase whole screen */ |
1331 | selection_check (3); |
|
|
1332 | row = 0; |
1351 | row = 0; |
1333 | num = nrow; |
1352 | num = nrow; |
1334 | break; |
1353 | break; |
1335 | default: |
1354 | default: |
1336 | return; |
1355 | return; |
… | |
… | |
1353 | { |
1372 | { |
1354 | ren = DEFAULT_RSTYLE; |
1373 | ren = DEFAULT_RSTYLE; |
1355 | |
1374 | |
1356 | if (mapped) |
1375 | if (mapped) |
1357 | XClearArea (dpy, vt, 0, |
1376 | XClearArea (dpy, vt, 0, |
1358 | Row2Pixel (row - view_start), (unsigned int)width, |
1377 | Row2Pixel (row - view_start), (unsigned int)vt_width, |
1359 | (unsigned int)Height2Pixel (num), False); |
1378 | (unsigned int)Height2Pixel (num), False); |
1360 | } |
1379 | } |
1361 | else |
1380 | else |
1362 | { |
1381 | { |
1363 | ren = rstyle & (RS_fgMask | RS_bgMask); |
1382 | ren = rstyle & (RS_fgMask | RS_bgMask); |
… | |
… | |
1366 | { |
1385 | { |
1367 | gcvalue.foreground = pix_colors[bgcolor_of (rstyle)]; |
1386 | gcvalue.foreground = pix_colors[bgcolor_of (rstyle)]; |
1368 | XChangeGC (dpy, gc, GCForeground, &gcvalue); |
1387 | XChangeGC (dpy, gc, GCForeground, &gcvalue); |
1369 | XFillRectangle (dpy, vt, gc, |
1388 | XFillRectangle (dpy, vt, gc, |
1370 | 0, Row2Pixel (row - view_start), |
1389 | 0, Row2Pixel (row - view_start), |
1371 | (unsigned int)width, |
1390 | (unsigned int)vt_width, |
1372 | (unsigned int)Height2Pixel (num)); |
1391 | (unsigned int)Height2Pixel (num)); |
1373 | gcvalue.foreground = pix_colors[Color_fg]; |
1392 | gcvalue.foreground = pix_colors[Color_fg]; |
1374 | XChangeGC (dpy, gc, GCForeground, &gcvalue); |
1393 | XChangeGC (dpy, gc, GCForeground, &gcvalue); |
1375 | } |
1394 | } |
1376 | } |
1395 | } |
… | |
… | |
1407 | |
1426 | |
1408 | want_refresh = 1; |
1427 | want_refresh = 1; |
1409 | ZERO_SCROLLBACK (); |
1428 | ZERO_SCROLLBACK (); |
1410 | |
1429 | |
1411 | num_scr_allow = 0; |
1430 | num_scr_allow = 0; |
1412 | selection_check (3); |
1431 | |
|
|
1432 | row_col_t pos; |
|
|
1433 | pos.row = pos.col = 0; |
|
|
1434 | if (ROWCOL_IS_AFTER (selection.end, pos)) |
|
|
1435 | CLEAR_SELECTION (); |
1413 | |
1436 | |
1414 | fs = SET_FONT (rstyle, FONTSET (rstyle)->find_font ('E')); |
1437 | fs = SET_FONT (rstyle, FONTSET (rstyle)->find_font ('E')); |
1415 | for (int row = nrow; row--; ) |
1438 | for (int row = nrow; row--; ) |
1416 | { |
1439 | { |
1417 | line_t &line = ROW(row); |
1440 | line_t &line = ROW(row); |
… | |
… | |
1858 | * Refresh the entire screen |
1881 | * Refresh the entire screen |
1859 | */ |
1882 | */ |
1860 | void |
1883 | void |
1861 | rxvt_term::scr_touch (bool refresh) NOTHROW |
1884 | rxvt_term::scr_touch (bool refresh) NOTHROW |
1862 | { |
1885 | { |
1863 | scr_expose (0, 0, width, height, refresh); |
1886 | scr_expose (0, 0, vt_width, vt_height, refresh); |
1864 | } |
1887 | } |
1865 | |
1888 | |
1866 | /* ------------------------------------------------------------------------- */ |
1889 | /* ------------------------------------------------------------------------- */ |
1867 | /* |
1890 | /* |
1868 | * Move the display so that the line represented by scrollbar value Y is at |
1891 | * Move the display so that the line represented by scrollbar value Y is at |
… | |
… | |
2030 | * A: set up vars |
2053 | * A: set up vars |
2031 | */ |
2054 | */ |
2032 | refresh_count = 0; |
2055 | refresh_count = 0; |
2033 | |
2056 | |
2034 | unsigned int old_screen_flags = screen.flags; |
2057 | unsigned int old_screen_flags = screen.flags; |
2035 | char have_bg = 0; |
2058 | bool have_bg = 0; |
2036 | #ifdef HAVE_BG_PIXMAP |
2059 | #ifdef HAVE_BG_PIXMAP |
2037 | have_bg = bg_pixmap != None; |
2060 | have_bg = bg_pixmap != None; |
2038 | #endif |
2061 | #endif |
2039 | ocrow = oldcursor.row; /* is there an old outline cursor on screen? */ |
2062 | ocrow = oldcursor.row; /* is there an old outline cursor on screen? */ |
2040 | |
2063 | |
… | |
… | |
2046 | HOOK_INVOKE ((this, HOOK_REFRESH_BEGIN, DT_END)); |
2069 | HOOK_INVOKE ((this, HOOK_REFRESH_BEGIN, DT_END)); |
2047 | #if ENABLE_OVERLAY |
2070 | #if ENABLE_OVERLAY |
2048 | scr_swap_overlay (); |
2071 | scr_swap_overlay (); |
2049 | #endif |
2072 | #endif |
2050 | |
2073 | |
2051 | char showcursor = screen.flags & Screen_VisibleCursor; |
2074 | bool showcursor = screen.flags & Screen_VisibleCursor; |
2052 | |
2075 | |
2053 | /* |
2076 | /* |
2054 | * C: set the cursor character (s) |
2077 | * C: set the cursor character (s) |
2055 | */ |
2078 | */ |
2056 | { |
2079 | { |
2057 | unsigned char setoldcursor; |
2080 | bool setoldcursor; |
2058 | |
2081 | |
2059 | #ifdef CURSOR_BLINK |
2082 | #ifdef CURSOR_BLINK |
2060 | if (hidden_cursor) |
2083 | if (hidden_cursor) |
2061 | showcursor = 0; |
2084 | showcursor = 0; |
2062 | #endif |
2085 | #endif |
… | |
… | |
2149 | { |
2172 | { |
2150 | int16_t nits; |
2173 | int16_t nits; |
2151 | int i = num_scr; |
2174 | int i = num_scr; |
2152 | int j; |
2175 | int j; |
2153 | int len, wlen; |
2176 | int len, wlen; |
2154 | dLocal (int, num_scr); |
|
|
2155 | |
2177 | |
2156 | j = nrow; |
2178 | j = nrow; |
2157 | wlen = len = -1; |
2179 | wlen = len = -1; |
2158 | row = i > 0 ? 0 : j - 1; |
2180 | row = i > 0 ? 0 : j - 1; |
2159 | |
2181 | |
… | |
… | |
2234 | continue; |
2256 | continue; |
2235 | |
2257 | |
2236 | // redraw one or more characters |
2258 | // redraw one or more characters |
2237 | |
2259 | |
2238 | // seek to the beginning of wide characters |
2260 | // seek to the beginning of wide characters |
2239 | while (expect_false (stp[col] == NOCHAR && col > 0)) |
2261 | while (ecb_unlikely (stp[col] == NOCHAR && col > 0)) |
2240 | --col; |
2262 | --col; |
2241 | |
2263 | |
2242 | rend_t rend = srp[col]; /* screen rendition (target rendition) */ |
2264 | rend_t rend = srp[col]; /* screen rendition (target rendition) */ |
2243 | text_t *text = stp + col; |
2265 | text_t *text = stp + col; |
2244 | int count = 1; |
2266 | int count = 1; |
… | |
… | |
2282 | |
2304 | |
2283 | col--; /* went one too far. move back */ |
2305 | col--; /* went one too far. move back */ |
2284 | count -= i; /* dump any matching trailing chars */ |
2306 | count -= i; /* dump any matching trailing chars */ |
2285 | |
2307 | |
2286 | // sometimes we optimize away the trailing NOCHAR's, add them back |
2308 | // sometimes we optimize away the trailing NOCHAR's, add them back |
2287 | while (expect_false (i && text[count] == NOCHAR)) |
2309 | while (ecb_unlikely (i && text[count] == NOCHAR)) |
2288 | count++, i--; |
2310 | count++, i--; |
2289 | |
2311 | |
2290 | /* |
2312 | /* |
2291 | * Determine the attributes for the string |
2313 | * Determine the attributes for the string |
2292 | */ |
2314 | */ |
2293 | int fore = fgcolor_of (rend); // desired foreground |
2315 | int fore = fgcolor_of (rend); // desired foreground |
2294 | int back = bgcolor_of (rend); // desired background |
2316 | int back = bgcolor_of (rend); // desired background |
2295 | |
2317 | |
2296 | // only do special processing if any attributes are set, which is unlikely |
2318 | // only do special processing if any attributes are set, which is unlikely |
2297 | if (expect_false (rend & (RS_baseattrMask | RS_Careful | RS_Sel))) |
2319 | if (ecb_unlikely (rend & (RS_baseattrMask | RS_Careful | RS_Sel))) |
2298 | { |
2320 | { |
2299 | bool invert = rend & RS_RVid; |
2321 | bool invert = rend & RS_RVid; |
2300 | |
2322 | |
2301 | #ifndef NO_BOLD_UNDERLINE_REVERSE |
2323 | #ifndef NO_BOLD_UNDERLINE_REVERSE |
2302 | if (rend & RS_Bold && fore == Color_fg) |
2324 | if (rend & RS_Bold && fore == Color_fg) |
… | |
… | |
2391 | /* |
2413 | /* |
2392 | * Actually do the drawing of the string here |
2414 | * Actually do the drawing of the string here |
2393 | */ |
2415 | */ |
2394 | rxvt_font *font = (*fontset[GET_STYLE (rend)])[GET_FONT (rend)]; |
2416 | rxvt_font *font = (*fontset[GET_STYLE (rend)])[GET_FONT (rend)]; |
2395 | |
2417 | |
2396 | if (expect_true (have_bg && back == Color_bg)) |
2418 | if (ecb_likely (have_bg && back == Color_bg)) |
2397 | { |
2419 | { |
2398 | // this is very ugly, maybe push it into ->draw? |
2420 | // this is very ugly, maybe push it into ->draw? |
2399 | |
2421 | |
2400 | for (i = 0; i < count; i++) /* don't draw empty strings */ |
2422 | for (i = 0; i < count; i++) /* don't draw empty strings */ |
2401 | if (text[i] != ' ') |
2423 | if (text[i] != ' ') |
… | |
… | |
2408 | did_clear: ; |
2430 | did_clear: ; |
2409 | } |
2431 | } |
2410 | else |
2432 | else |
2411 | font->draw (*drawable, xpixel, ypixel, text, count, fore, back); |
2433 | font->draw (*drawable, xpixel, ypixel, text, count, fore, back); |
2412 | |
2434 | |
2413 | if (expect_false (rend & RS_Uline && font->descent > 1 && fore != back)) |
2435 | if (ecb_unlikely (rend & RS_Uline && font->descent > 1 && fore != back)) |
2414 | { |
2436 | { |
2415 | #if ENABLE_FRILLS |
2437 | #if ENABLE_FRILLS |
2416 | if (ISSET_PIXCOLOR (Color_underline)) |
2438 | if (ISSET_PIXCOLOR (Color_underline)) |
2417 | XSetForeground (dpy, gc, pix_colors[Color_underline]); |
2439 | XSetForeground (dpy, gc, pix_colors[Color_underline]); |
2418 | else |
2440 | else |
… | |
… | |
2464 | |
2486 | |
2465 | XDrawRectangle (dpy, vt, gc, |
2487 | XDrawRectangle (dpy, vt, gc, |
2466 | Col2Pixel (col), |
2488 | Col2Pixel (col), |
2467 | Row2Pixel (oldcursor.row), |
2489 | Row2Pixel (oldcursor.row), |
2468 | (unsigned int) (Width2Pixel (cursorwidth) - 1), |
2490 | (unsigned int) (Width2Pixel (cursorwidth) - 1), |
2469 | (unsigned int) (Height2Pixel (1) - lineSpace - 1)); |
2491 | (unsigned int) (Height2Pixel (1) - 1)); |
2470 | } |
2492 | } |
2471 | } |
2493 | } |
2472 | |
2494 | |
2473 | /* |
2495 | /* |
2474 | * H: cleanup selection |
2496 | * H: cleanup selection |
… | |
… | |
2486 | } |
2508 | } |
2487 | |
2509 | |
2488 | void |
2510 | void |
2489 | rxvt_term::scr_remap_chars (line_t &l) NOTHROW |
2511 | rxvt_term::scr_remap_chars (line_t &l) NOTHROW |
2490 | { |
2512 | { |
2491 | if (!l.t) |
2513 | if (!l.valid ()) |
2492 | return; |
2514 | return; |
2493 | |
2515 | |
2494 | l.touch (); // maybe a bit of an overkill, but it's not performance-relevant |
2516 | l.touch (); // maybe a bit of an overkill, but it's not performance-relevant |
2495 | |
2517 | |
2496 | for (int i = ncol; i--; ) |
2518 | for (int i = ncol; i--; ) |
… | |
… | |
2546 | { |
2568 | { |
2547 | if (transparent) |
2569 | if (transparent) |
2548 | XSetWindowBackgroundPixmap (dpy, scrollBar.win, ParentRelative); |
2570 | XSetWindowBackgroundPixmap (dpy, scrollBar.win, ParentRelative); |
2549 | else |
2571 | else |
2550 | XSetWindowBackground (dpy, scrollBar.win, pix_colors[Color_border]); |
2572 | XSetWindowBackground (dpy, scrollBar.win, pix_colors[Color_border]); |
2551 | scrollBar.state = STATE_IDLE; |
2573 | scrollBar.state = SB_STATE_IDLE; |
2552 | scrollBar.show (0); |
2574 | scrollBar.show (0); |
2553 | } |
2575 | } |
2554 | |
2576 | |
2555 | if (refresh) |
2577 | if (refresh) |
2556 | { |
2578 | { |
… | |
… | |
2650 | */ |
2672 | */ |
2651 | #if 0 |
2673 | #if 0 |
2652 | void |
2674 | void |
2653 | rxvt_term::scr_dump (int fd) NOTHROW |
2675 | rxvt_term::scr_dump (int fd) NOTHROW |
2654 | { |
2676 | { |
2655 | int row, wrote; |
2677 | // if this method is needed, it can be implemented by factoring the |
2656 | unsigned int width, towrite; |
2678 | // relevant code in scr_printscreen |
2657 | const char r1[] = "\n"; |
|
|
2658 | |
|
|
2659 | for (row = saveLines + top_row; |
|
|
2660 | row < saveLines + nrow - 1; row++) |
|
|
2661 | { |
|
|
2662 | width = row_buf[row].l >= 0 ? row_buf[row].l |
|
|
2663 | : ncol; |
|
|
2664 | for (towrite = width; towrite; towrite -= wrote) |
|
|
2665 | { |
|
|
2666 | wrote = write (fd, & (row_buf[row].t[width - towrite]), |
|
|
2667 | towrite); |
|
|
2668 | if (wrote < 0) |
|
|
2669 | return; /* XXX: death, no report */ |
|
|
2670 | } |
|
|
2671 | if (row_buf[row].l >= 0) |
|
|
2672 | if (write (fd, r1, 1) <= 0) |
|
|
2673 | return; /* XXX: death, no report */ |
|
|
2674 | } |
|
|
2675 | } |
2679 | } |
2676 | #endif |
2680 | #endif |
2677 | |
2681 | |
2678 | /* ------------------------------------------------------------------------- * |
2682 | /* ------------------------------------------------------------------------- * |
2679 | * CHARACTER SELECTION * |
2683 | * CHARACTER SELECTION * |
2680 | * ------------------------------------------------------------------------- */ |
2684 | * ------------------------------------------------------------------------- */ |
2681 | void |
2685 | void |
2682 | rxvt_term::selection_check (int check_more) NOTHROW |
2686 | rxvt_term::selection_check (int check_more) NOTHROW |
2683 | { |
2687 | { |
2684 | row_col_t pos; |
|
|
2685 | |
|
|
2686 | if (!selection.op) |
2688 | if (!selection.op) |
2687 | return; |
2689 | return; |
2688 | |
2690 | |
2689 | pos.row = pos.col = 0; |
|
|
2690 | if (!IN_RANGE_EXC (selection.beg.row, top_row, nrow) |
2691 | if (!IN_RANGE_EXC (selection.beg.row, top_row, nrow) |
2691 | || !IN_RANGE_EXC (selection.mark.row, top_row, nrow) |
2692 | || !IN_RANGE_EXC (selection.mark.row, top_row, nrow) |
2692 | || !IN_RANGE_EXC (selection.end.row, top_row, nrow) |
2693 | || !IN_RANGE_EXC (selection.end.row, top_row, nrow) |
2693 | || (check_more == 1 |
2694 | || (check_more == 1 |
2694 | && current_screen == selection.screen |
2695 | && current_screen == selection.screen |
2695 | && !ROWCOL_IS_BEFORE (screen.cur, selection.beg) |
2696 | && !ROWCOL_IS_BEFORE (screen.cur, selection.beg) |
2696 | && ROWCOL_IS_BEFORE (screen.cur, selection.end)) |
2697 | && ROWCOL_IS_BEFORE (screen.cur, selection.end))) |
2697 | || (check_more == 2 |
|
|
2698 | && ROWCOL_IS_BEFORE (selection.beg, pos) |
|
|
2699 | && ROWCOL_IS_AFTER (selection.end, pos)) |
|
|
2700 | || (check_more == 3 |
|
|
2701 | && ROWCOL_IS_AFTER (selection.end, pos)) |
|
|
2702 | || (check_more == 4 /* screen width change */ |
|
|
2703 | && (selection.beg.row != selection.end.row |
|
|
2704 | || selection.end.col > ncol))) |
|
|
2705 | CLEAR_SELECTION (); |
2698 | CLEAR_ALL_SELECTION (); |
2706 | } |
2699 | } |
2707 | |
2700 | |
2708 | /* ------------------------------------------------------------------------- */ |
2701 | /* ------------------------------------------------------------------------- */ |
2709 | /* |
2702 | /* |
2710 | * Paste a selection direct to the command fd |
2703 | * Paste a selection direct to the command fd |
… | |
… | |
2716 | for (unsigned int i = 0; i < len; i++) |
2709 | for (unsigned int i = 0; i < len; i++) |
2717 | if (data[i] == C0_LF) |
2710 | if (data[i] == C0_LF) |
2718 | data[i] = C0_CR; |
2711 | data[i] = C0_CR; |
2719 | |
2712 | |
2720 | if (priv_modes & PrivMode_BracketPaste) |
2713 | if (priv_modes & PrivMode_BracketPaste) |
2721 | tt_printf ("\e[200~"); |
2714 | tt_printf ("\x1b[200~"); |
2722 | |
2715 | |
2723 | tt_write (data, len); |
2716 | tt_write (data, len); |
2724 | |
2717 | |
2725 | if (priv_modes & PrivMode_BracketPaste) |
2718 | if (priv_modes & PrivMode_BracketPaste) |
2726 | tt_printf ("\e[201~"); |
2719 | tt_printf ("\x1b[201~"); |
2727 | } |
2720 | } |
2728 | |
2721 | |
2729 | void |
2722 | void |
2730 | rxvt_term::paste (char *data, unsigned int len) NOTHROW |
2723 | rxvt_term::paste (char *data, unsigned int len) NOTHROW |
2731 | { |
2724 | { |