… | |
… | |
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 , 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, 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)) |
… | |
… | |
682 | else |
692 | else |
683 | scr_blank_screen_mem (l, rstyle); |
693 | scr_blank_screen_mem (l, rstyle); |
684 | } |
694 | } |
685 | |
695 | |
686 | // move and/or clear selection, if any |
696 | // move and/or clear selection, if any |
687 | if (selection.op && current_screen == selection.screen) |
697 | if (selection.op && current_screen == selection.screen |
|
|
698 | && selection.beg.row <= row2) |
688 | { |
699 | { |
689 | selection.beg.row -= count; |
700 | selection.beg.row -= count; |
690 | selection.end.row -= count; |
701 | selection.end.row -= count; |
691 | selection.mark.row -= count; |
702 | selection.mark.row -= count; |
692 | |
703 | |
693 | if (selection.beg.row < top_row |
704 | selection_check (0); |
694 | || selection.end.row < top_row |
|
|
695 | || selection.mark.row < top_row) |
|
|
696 | { |
|
|
697 | CLEAR_ALL_SELECTION (); |
|
|
698 | selection.op = SELECTION_CLEAR; |
|
|
699 | } |
|
|
700 | } |
705 | } |
701 | |
706 | |
702 | // finally move the view window, if desired |
707 | // finally move the view window, if desired |
703 | if (option (Opt_scrollWithBuffer) |
708 | if (option (Opt_scrollWithBuffer) |
704 | && view_start != 0 |
709 | && view_start != 0 |
… | |
… | |
761 | for (int row = 0; row < rows; row++) |
766 | for (int row = 0; row < rows; row++) |
762 | ROW(row1 + row) = temp_buf [row]; |
767 | ROW(row1 + row) = temp_buf [row]; |
763 | |
768 | |
764 | // sever bottommost line |
769 | // sever bottommost line |
765 | { |
770 | { |
766 | line_t &l = ROW(row2 - 1); |
771 | line_t &l = ROW(row2); |
767 | l.is_longer (0); |
772 | l.is_longer (0); |
768 | l.touch (); |
773 | l.touch (); |
769 | } |
774 | } |
770 | |
|
|
771 | } |
775 | } |
772 | |
776 | |
773 | return count; |
777 | return count; |
774 | } |
778 | } |
775 | |
779 | |
… | |
… | |
781 | 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 |
782 | { |
786 | { |
783 | if (len <= 0) /* sanity */ |
787 | if (len <= 0) /* sanity */ |
784 | return; |
788 | return; |
785 | |
789 | |
786 | unsigned char checksel; |
790 | bool checksel; |
787 | unicode_t c; |
791 | unicode_t c; |
788 | int ncol = this->ncol; |
792 | int ncol = this->ncol; |
789 | const wchar_t *strend = str + len; |
793 | const wchar_t *strend = str + len; |
790 | |
794 | |
791 | want_refresh = 1; |
795 | want_refresh = 1; |
… | |
… | |
1313 | scr_blank_line (line, col, num, rstyle); |
1317 | scr_blank_line (line, col, num, rstyle); |
1314 | } |
1318 | } |
1315 | |
1319 | |
1316 | /* ------------------------------------------------------------------------- */ |
1320 | /* ------------------------------------------------------------------------- */ |
1317 | /* |
1321 | /* |
1318 | * Erase part of whole of the screen |
1322 | * Erase part or whole of the screen |
1319 | * XTERM_SEQ: Clear screen after cursor : ESC [ 0 J |
1323 | * XTERM_SEQ: Clear screen after cursor : ESC [ 0 J |
1320 | * XTERM_SEQ: Clear screen before cursor: ESC [ 1 J |
1324 | * XTERM_SEQ: Clear screen before cursor: ESC [ 1 J |
1321 | * XTERM_SEQ: Clear whole screen : ESC [ 2 J |
1325 | * XTERM_SEQ: Clear whole screen : ESC [ 2 J |
1322 | */ |
1326 | */ |
1323 | void |
1327 | void |
… | |
… | |
1332 | ZERO_SCROLLBACK (); |
1336 | ZERO_SCROLLBACK (); |
1333 | |
1337 | |
1334 | switch (mode) |
1338 | switch (mode) |
1335 | { |
1339 | { |
1336 | case 0: /* erase to end of screen */ |
1340 | case 0: /* erase to end of screen */ |
1337 | selection_check (1); |
|
|
1338 | scr_erase_line (0); |
1341 | scr_erase_line (0); |
1339 | row = screen.cur.row + 1; /* possible OOB */ |
1342 | row = screen.cur.row + 1; /* possible OOB */ |
1340 | num = nrow - row; |
1343 | num = nrow - row; |
1341 | break; |
1344 | break; |
1342 | case 1: /* erase to beginning of screen */ |
1345 | case 1: /* erase to beginning of screen */ |
1343 | selection_check (3); |
|
|
1344 | scr_erase_line (1); |
1346 | scr_erase_line (1); |
1345 | row = 0; |
1347 | row = 0; |
1346 | num = screen.cur.row; |
1348 | num = screen.cur.row; |
1347 | break; |
1349 | break; |
1348 | case 2: /* erase whole screen */ |
1350 | case 2: /* erase whole screen */ |
1349 | selection_check (3); |
|
|
1350 | row = 0; |
1351 | row = 0; |
1351 | num = nrow; |
1352 | num = nrow; |
1352 | break; |
1353 | break; |
1353 | default: |
1354 | default: |
1354 | return; |
1355 | return; |
… | |
… | |
1371 | { |
1372 | { |
1372 | ren = DEFAULT_RSTYLE; |
1373 | ren = DEFAULT_RSTYLE; |
1373 | |
1374 | |
1374 | if (mapped) |
1375 | if (mapped) |
1375 | XClearArea (dpy, vt, 0, |
1376 | XClearArea (dpy, vt, 0, |
1376 | Row2Pixel (row - view_start), (unsigned int)width, |
1377 | Row2Pixel (row - view_start), (unsigned int)vt_width, |
1377 | (unsigned int)Height2Pixel (num), False); |
1378 | (unsigned int)Height2Pixel (num), False); |
1378 | } |
1379 | } |
1379 | else |
1380 | else |
1380 | { |
1381 | { |
1381 | ren = rstyle & (RS_fgMask | RS_bgMask); |
1382 | ren = rstyle & (RS_fgMask | RS_bgMask); |
… | |
… | |
1384 | { |
1385 | { |
1385 | gcvalue.foreground = pix_colors[bgcolor_of (rstyle)]; |
1386 | gcvalue.foreground = pix_colors[bgcolor_of (rstyle)]; |
1386 | XChangeGC (dpy, gc, GCForeground, &gcvalue); |
1387 | XChangeGC (dpy, gc, GCForeground, &gcvalue); |
1387 | XFillRectangle (dpy, vt, gc, |
1388 | XFillRectangle (dpy, vt, gc, |
1388 | 0, Row2Pixel (row - view_start), |
1389 | 0, Row2Pixel (row - view_start), |
1389 | (unsigned int)width, |
1390 | (unsigned int)vt_width, |
1390 | (unsigned int)Height2Pixel (num)); |
1391 | (unsigned int)Height2Pixel (num)); |
1391 | gcvalue.foreground = pix_colors[Color_fg]; |
1392 | gcvalue.foreground = pix_colors[Color_fg]; |
1392 | XChangeGC (dpy, gc, GCForeground, &gcvalue); |
1393 | XChangeGC (dpy, gc, GCForeground, &gcvalue); |
1393 | } |
1394 | } |
1394 | } |
1395 | } |
… | |
… | |
1425 | |
1426 | |
1426 | want_refresh = 1; |
1427 | want_refresh = 1; |
1427 | ZERO_SCROLLBACK (); |
1428 | ZERO_SCROLLBACK (); |
1428 | |
1429 | |
1429 | num_scr_allow = 0; |
1430 | num_scr_allow = 0; |
1430 | 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 (); |
1431 | |
1436 | |
1432 | fs = SET_FONT (rstyle, FONTSET (rstyle)->find_font ('E')); |
1437 | fs = SET_FONT (rstyle, FONTSET (rstyle)->find_font ('E')); |
1433 | for (int row = nrow; row--; ) |
1438 | for (int row = nrow; row--; ) |
1434 | { |
1439 | { |
1435 | line_t &line = ROW(row); |
1440 | line_t &line = ROW(row); |
… | |
… | |
1876 | * Refresh the entire screen |
1881 | * Refresh the entire screen |
1877 | */ |
1882 | */ |
1878 | void |
1883 | void |
1879 | rxvt_term::scr_touch (bool refresh) NOTHROW |
1884 | rxvt_term::scr_touch (bool refresh) NOTHROW |
1880 | { |
1885 | { |
1881 | scr_expose (0, 0, width, height, refresh); |
1886 | scr_expose (0, 0, vt_width, vt_height, refresh); |
1882 | } |
1887 | } |
1883 | |
1888 | |
1884 | /* ------------------------------------------------------------------------- */ |
1889 | /* ------------------------------------------------------------------------- */ |
1885 | /* |
1890 | /* |
1886 | * 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 |
… | |
… | |
2048 | * A: set up vars |
2053 | * A: set up vars |
2049 | */ |
2054 | */ |
2050 | refresh_count = 0; |
2055 | refresh_count = 0; |
2051 | |
2056 | |
2052 | unsigned int old_screen_flags = screen.flags; |
2057 | unsigned int old_screen_flags = screen.flags; |
2053 | char have_bg = 0; |
2058 | bool have_bg = 0; |
2054 | #ifdef HAVE_BG_PIXMAP |
2059 | #ifdef HAVE_BG_PIXMAP |
2055 | have_bg = bg_pixmap != None; |
2060 | have_bg = bg_pixmap != None; |
2056 | #endif |
2061 | #endif |
2057 | ocrow = oldcursor.row; /* is there an old outline cursor on screen? */ |
2062 | ocrow = oldcursor.row; /* is there an old outline cursor on screen? */ |
2058 | |
2063 | |
… | |
… | |
2064 | HOOK_INVOKE ((this, HOOK_REFRESH_BEGIN, DT_END)); |
2069 | HOOK_INVOKE ((this, HOOK_REFRESH_BEGIN, DT_END)); |
2065 | #if ENABLE_OVERLAY |
2070 | #if ENABLE_OVERLAY |
2066 | scr_swap_overlay (); |
2071 | scr_swap_overlay (); |
2067 | #endif |
2072 | #endif |
2068 | |
2073 | |
2069 | char showcursor = screen.flags & Screen_VisibleCursor; |
2074 | bool showcursor = screen.flags & Screen_VisibleCursor; |
2070 | |
2075 | |
2071 | /* |
2076 | /* |
2072 | * C: set the cursor character (s) |
2077 | * C: set the cursor character (s) |
2073 | */ |
2078 | */ |
2074 | { |
2079 | { |
2075 | unsigned char setoldcursor; |
2080 | bool setoldcursor; |
2076 | |
2081 | |
2077 | #ifdef CURSOR_BLINK |
2082 | #ifdef CURSOR_BLINK |
2078 | if (hidden_cursor) |
2083 | if (hidden_cursor) |
2079 | showcursor = 0; |
2084 | showcursor = 0; |
2080 | #endif |
2085 | #endif |
… | |
… | |
2167 | { |
2172 | { |
2168 | int16_t nits; |
2173 | int16_t nits; |
2169 | int i = num_scr; |
2174 | int i = num_scr; |
2170 | int j; |
2175 | int j; |
2171 | int len, wlen; |
2176 | int len, wlen; |
2172 | dLocal (int, num_scr); |
|
|
2173 | |
2177 | |
2174 | j = nrow; |
2178 | j = nrow; |
2175 | wlen = len = -1; |
2179 | wlen = len = -1; |
2176 | row = i > 0 ? 0 : j - 1; |
2180 | row = i > 0 ? 0 : j - 1; |
2177 | |
2181 | |
… | |
… | |
2482 | |
2486 | |
2483 | XDrawRectangle (dpy, vt, gc, |
2487 | XDrawRectangle (dpy, vt, gc, |
2484 | Col2Pixel (col), |
2488 | Col2Pixel (col), |
2485 | Row2Pixel (oldcursor.row), |
2489 | Row2Pixel (oldcursor.row), |
2486 | (unsigned int) (Width2Pixel (cursorwidth) - 1), |
2490 | (unsigned int) (Width2Pixel (cursorwidth) - 1), |
2487 | (unsigned int) (Height2Pixel (1) - lineSpace - 1)); |
2491 | (unsigned int) (Height2Pixel (1) - 1)); |
2488 | } |
2492 | } |
2489 | } |
2493 | } |
2490 | |
2494 | |
2491 | /* |
2495 | /* |
2492 | * H: cleanup selection |
2496 | * H: cleanup selection |
… | |
… | |
2504 | } |
2508 | } |
2505 | |
2509 | |
2506 | void |
2510 | void |
2507 | rxvt_term::scr_remap_chars (line_t &l) NOTHROW |
2511 | rxvt_term::scr_remap_chars (line_t &l) NOTHROW |
2508 | { |
2512 | { |
2509 | if (!l.t) |
2513 | if (!l.valid ()) |
2510 | return; |
2514 | return; |
2511 | |
2515 | |
2512 | 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 |
2513 | |
2517 | |
2514 | for (int i = ncol; i--; ) |
2518 | for (int i = ncol; i--; ) |
… | |
… | |
2564 | { |
2568 | { |
2565 | if (transparent) |
2569 | if (transparent) |
2566 | XSetWindowBackgroundPixmap (dpy, scrollBar.win, ParentRelative); |
2570 | XSetWindowBackgroundPixmap (dpy, scrollBar.win, ParentRelative); |
2567 | else |
2571 | else |
2568 | XSetWindowBackground (dpy, scrollBar.win, pix_colors[Color_border]); |
2572 | XSetWindowBackground (dpy, scrollBar.win, pix_colors[Color_border]); |
2569 | scrollBar.state = STATE_IDLE; |
2573 | scrollBar.state = SB_STATE_IDLE; |
2570 | scrollBar.show (0); |
2574 | scrollBar.show (0); |
2571 | } |
2575 | } |
2572 | |
2576 | |
2573 | if (refresh) |
2577 | if (refresh) |
2574 | { |
2578 | { |
… | |
… | |
2668 | */ |
2672 | */ |
2669 | #if 0 |
2673 | #if 0 |
2670 | void |
2674 | void |
2671 | rxvt_term::scr_dump (int fd) NOTHROW |
2675 | rxvt_term::scr_dump (int fd) NOTHROW |
2672 | { |
2676 | { |
2673 | int row, wrote; |
2677 | // if this method is needed, it can be implemented by factoring the |
2674 | unsigned int width, towrite; |
2678 | // relevant code in scr_printscreen |
2675 | const char r1[] = "\n"; |
|
|
2676 | |
|
|
2677 | for (row = saveLines + top_row; |
|
|
2678 | row < saveLines + nrow - 1; row++) |
|
|
2679 | { |
|
|
2680 | width = row_buf[row].l >= 0 ? row_buf[row].l |
|
|
2681 | : ncol; |
|
|
2682 | for (towrite = width; towrite; towrite -= wrote) |
|
|
2683 | { |
|
|
2684 | wrote = write (fd, & (row_buf[row].t[width - towrite]), |
|
|
2685 | towrite); |
|
|
2686 | if (wrote < 0) |
|
|
2687 | return; /* XXX: death, no report */ |
|
|
2688 | } |
|
|
2689 | if (row_buf[row].l >= 0) |
|
|
2690 | if (write (fd, r1, 1) <= 0) |
|
|
2691 | return; /* XXX: death, no report */ |
|
|
2692 | } |
|
|
2693 | } |
2679 | } |
2694 | #endif |
2680 | #endif |
2695 | |
2681 | |
2696 | /* ------------------------------------------------------------------------- * |
2682 | /* ------------------------------------------------------------------------- * |
2697 | * CHARACTER SELECTION * |
2683 | * CHARACTER SELECTION * |
2698 | * ------------------------------------------------------------------------- */ |
2684 | * ------------------------------------------------------------------------- */ |
2699 | void |
2685 | void |
2700 | rxvt_term::selection_check (int check_more) NOTHROW |
2686 | rxvt_term::selection_check (int check_more) NOTHROW |
2701 | { |
2687 | { |
2702 | row_col_t pos; |
|
|
2703 | |
|
|
2704 | if (!selection.op) |
2688 | if (!selection.op) |
2705 | return; |
2689 | return; |
2706 | |
2690 | |
2707 | pos.row = pos.col = 0; |
|
|
2708 | if (!IN_RANGE_EXC (selection.beg.row, top_row, nrow) |
2691 | if (!IN_RANGE_EXC (selection.beg.row, top_row, nrow) |
2709 | || !IN_RANGE_EXC (selection.mark.row, top_row, nrow) |
2692 | || !IN_RANGE_EXC (selection.mark.row, top_row, nrow) |
2710 | || !IN_RANGE_EXC (selection.end.row, top_row, nrow) |
2693 | || !IN_RANGE_EXC (selection.end.row, top_row, nrow) |
2711 | || (check_more == 1 |
2694 | || (check_more == 1 |
2712 | && current_screen == selection.screen |
2695 | && current_screen == selection.screen |
2713 | && !ROWCOL_IS_BEFORE (screen.cur, selection.beg) |
2696 | && !ROWCOL_IS_BEFORE (screen.cur, selection.beg) |
2714 | && ROWCOL_IS_BEFORE (screen.cur, selection.end)) |
2697 | && ROWCOL_IS_BEFORE (screen.cur, selection.end))) |
2715 | || (check_more == 2 |
|
|
2716 | && ROWCOL_IS_BEFORE (selection.beg, pos) |
|
|
2717 | && ROWCOL_IS_AFTER (selection.end, pos)) |
|
|
2718 | || (check_more == 3 |
|
|
2719 | && ROWCOL_IS_AFTER (selection.end, pos)) |
|
|
2720 | || (check_more == 4 /* screen width change */ |
|
|
2721 | && (selection.beg.row != selection.end.row |
|
|
2722 | || selection.end.col > ncol))) |
|
|
2723 | CLEAR_SELECTION (); |
2698 | CLEAR_ALL_SELECTION (); |
2724 | } |
2699 | } |
2725 | |
2700 | |
2726 | /* ------------------------------------------------------------------------- */ |
2701 | /* ------------------------------------------------------------------------- */ |
2727 | /* |
2702 | /* |
2728 | * Paste a selection direct to the command fd |
2703 | * Paste a selection direct to the command fd |
… | |
… | |
2734 | for (unsigned int i = 0; i < len; i++) |
2709 | for (unsigned int i = 0; i < len; i++) |
2735 | if (data[i] == C0_LF) |
2710 | if (data[i] == C0_LF) |
2736 | data[i] = C0_CR; |
2711 | data[i] = C0_CR; |
2737 | |
2712 | |
2738 | if (priv_modes & PrivMode_BracketPaste) |
2713 | if (priv_modes & PrivMode_BracketPaste) |
2739 | tt_printf ("\e[200~"); |
2714 | tt_printf ("\x1b[200~"); |
2740 | |
2715 | |
2741 | tt_write (data, len); |
2716 | tt_write (data, len); |
2742 | |
2717 | |
2743 | if (priv_modes & PrivMode_BracketPaste) |
2718 | if (priv_modes & PrivMode_BracketPaste) |
2744 | tt_printf ("\e[201~"); |
2719 | tt_printf ("\x1b[201~"); |
2745 | } |
2720 | } |
2746 | |
2721 | |
2747 | void |
2722 | void |
2748 | rxvt_term::paste (char *data, unsigned int len) NOTHROW |
2723 | rxvt_term::paste (char *data, unsigned int len) NOTHROW |
2749 | { |
2724 | { |