… | |
… | |
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() \ |
… | |
… | |
239 | { |
240 | { |
240 | /* |
241 | /* |
241 | * add or delete rows as appropriate |
242 | * add or delete rows as appropriate |
242 | */ |
243 | */ |
243 | |
244 | |
244 | printf ("resize %d:%d => %d:%d\n", prev_nrow, prev_ncol, nrow, ncol);//D |
|
|
245 | |
|
|
246 | rxvt_salloc *old_ta = talloc; talloc = new rxvt_salloc (ncol * sizeof (text_t)); |
245 | rxvt_salloc *old_ta = talloc; talloc = new rxvt_salloc (ncol * sizeof (text_t)); |
247 | rxvt_salloc *old_ra = ralloc; ralloc = new rxvt_salloc (ncol * sizeof (rend_t)); |
246 | rxvt_salloc *old_ra = ralloc; ralloc = new rxvt_salloc (ncol * sizeof (rend_t)); |
248 | |
247 | |
249 | #if 0 |
248 | #if 0 |
250 | if (nrow < prev_nrow) |
249 | if (nrow < prev_nrow) |
… | |
… | |
255 | lfree (drawn_buf[row]); |
254 | lfree (drawn_buf[row]); |
256 | } |
255 | } |
257 | } |
256 | } |
258 | #endif |
257 | #endif |
259 | |
258 | |
260 | drawn_buf = (line_t *) rxvt_realloc (drawn_buf, nrow * sizeof (line_t)); |
259 | drawn_buf = (line_t *)rxvt_realloc (drawn_buf, nrow * sizeof (line_t)); |
261 | temp_buf = (line_t *) rxvt_realloc (temp_buf , nrow * sizeof (line_t)); |
260 | temp_buf = (line_t *)rxvt_realloc (temp_buf , nrow * sizeof (line_t)); |
262 | swap_buf = (line_t *) rxvt_realloc (swap_buf , nrow * sizeof (line_t)); |
261 | swap_buf = (line_t *)rxvt_realloc (swap_buf , nrow * sizeof (line_t)); |
263 | |
262 | |
264 | for (int row = min (nrow, prev_nrow); row--; ) |
263 | for (int row = min (nrow, prev_nrow); row--; ) |
265 | { |
264 | { |
266 | lresize (drawn_buf[row]); |
265 | lresize (drawn_buf[row]); |
267 | lresize (swap_buf [row]); |
266 | lresize (swap_buf [row]); |
… | |
… | |
273 | drawn_buf[row].clear (); scr_blank_screen_mem (drawn_buf[row], DEFAULT_RSTYLE); |
272 | drawn_buf[row].clear (); scr_blank_screen_mem (drawn_buf[row], DEFAULT_RSTYLE); |
274 | } |
273 | } |
275 | |
274 | |
276 | line_t *old_buf = row_buf; row_buf = (line_t *)rxvt_calloc (total_rows, sizeof (line_t)); |
275 | line_t *old_buf = row_buf; row_buf = (line_t *)rxvt_calloc (total_rows, sizeof (line_t)); |
277 | |
276 | |
278 | // re-wrap lines, this is rather ugly, possibly because I am too dumb |
|
|
279 | // to come up with a lean and mean algorithm. |
|
|
280 | |
|
|
281 | int p = MOD (term_start + nrow , prev_total_rows); // previous row |
277 | int p = MOD (term_start + prev_nrow, prev_total_rows); // previous row |
282 | int pend = MOD (term_start - nsaved, prev_total_rows); |
278 | int pend = MOD (term_start - nsaved , prev_total_rows); |
283 | int q = total_rows; // rewrapped row |
279 | int q = total_rows; // rewrapped row |
284 | |
280 | |
285 | while (p != pend && q > 0) |
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 | |
286 | { |
289 | do |
287 | p = MOD (p - 1, prev_total_rows); |
|
|
288 | |
|
|
289 | assert (old_buf [MOD (p, prev_total_rows)].t); |
|
|
290 | assert (!old_buf [MOD (p, prev_total_rows)].is_longer ()); |
|
|
291 | |
|
|
292 | int llen = old_buf [MOD (p, prev_total_rows)].l; |
|
|
293 | |
|
|
294 | while (p != pend && old_buf [MOD (p - 1, prev_total_rows)].is_longer ()) |
|
|
295 | { |
290 | { |
296 | p = MOD (p - 1, prev_total_rows); |
291 | p = MOD (p - 1, prev_total_rows); |
|
|
292 | #ifdef DEBUG_STRICT |
|
|
293 | assert (old_buf [MOD (p, prev_total_rows)].t); |
|
|
294 | #endif |
297 | |
295 | |
298 | llen += prev_ncol; |
|
|
299 | } |
|
|
300 | |
|
|
301 | int qlines = llen / ncol + 1; |
|
|
302 | int lofs = 0; |
296 | int plines = 1; |
|
|
297 | int llen = old_buf [MOD (p, prev_total_rows)].l; |
303 | |
298 | |
304 | q -= qlines; |
299 | while (p != pend && old_buf [MOD (p - 1, prev_total_rows)].is_longer ()) |
305 | |
|
|
306 | int qrow = q; |
|
|
307 | |
|
|
308 | for (; qlines--; qrow++) |
|
|
309 | { |
|
|
310 | if (qrow >= 0) |
|
|
311 | { |
300 | { |
|
|
301 | p = MOD (p - 1, prev_total_rows); |
|
|
302 | |
|
|
303 | plines++; |
|
|
304 | llen += prev_ncol; |
|
|
305 | } |
|
|
306 | |
|
|
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 | |
|
|
315 | int lofs = 0; |
|
|
316 | line_t *qline; |
|
|
317 | |
|
|
318 | // re-assemble the full line by destination lines |
|
|
319 | for (int qrow = q; qlines--; qrow++) |
|
|
320 | { |
312 | line_t &qline = row_buf [qrow]; |
321 | qline = row_buf + qrow; |
313 | |
|
|
314 | lalloc (qline); |
322 | lalloc (*qline); |
315 | qline.set_is_longer (); |
323 | qline->set_is_longer (); |
316 | |
324 | |
317 | int qcol = 0; |
325 | int qcol = 0; |
318 | |
326 | |
319 | for (;;) |
327 | // fill a single destination line |
|
|
328 | while (lofs < llen && qcol < ncol) |
320 | { |
329 | { |
321 | int prow = lofs / prev_ncol + p; |
330 | int prow = lofs / prev_ncol; |
322 | int pcol = lofs % prev_ncol; |
331 | int pcol = lofs % prev_ncol; |
323 | |
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 | |
324 | line_t &pline = old_buf [p]; |
342 | line_t &pline = old_buf [prow]; |
325 | |
343 | |
326 | int len = min (min (prev_ncol - pcol, ncol - qcol), llen - lofs); |
344 | int len = min (min (prev_ncol - pcol, ncol - qcol), llen - lofs); |
327 | |
345 | |
328 | 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); |
|
|
329 | |
|
|
330 | if (len <= 0) |
|
|
331 | { |
|
|
332 | qline.l = qcol; |
|
|
333 | scr_blank_line (qline, qcol, ncol - qcol, DEFAULT_RSTYLE); |
|
|
334 | break; |
|
|
335 | } |
|
|
336 | |
|
|
337 | assert (lofs < 1000); |
346 | assert (len); |
|
|
347 | assert (pline.t); |
338 | |
348 | |
339 | memcpy (qline.t + qcol, pline.t + pcol, len * sizeof (text_t)); |
349 | memcpy (qline->t + qcol, pline.t + pcol, len * sizeof (text_t)); |
340 | memcpy (qline.r + qcol, pline.r + pcol, len * sizeof (rend_t)); |
350 | memcpy (qline->r + qcol, pline.r + pcol, len * sizeof (rend_t)); |
341 | |
351 | |
342 | lofs += len; |
352 | lofs += len; |
343 | qcol += len; |
353 | qcol += len; |
344 | |
|
|
345 | if (qcol == ncol) |
|
|
346 | break; |
|
|
347 | } |
354 | } |
348 | } |
355 | } |
|
|
356 | |
|
|
357 | qline->l = llen ? MOD (llen - 1, ncol) + 1 : 0; |
|
|
358 | #ifdef DEBUG_STRICT //TODO//FIXME//TEMPORARY |
|
|
359 | if (qline->l < 0) |
349 | else |
360 | { |
350 | lofs += ncol; |
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); |
351 | } |
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 |
352 | } |
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]; |
|
|
385 | |
|
|
386 | qline = pline; |
|
|
387 | lresize (qline); |
|
|
388 | } |
|
|
389 | |
|
|
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); |
|
|
401 | #endif |
353 | |
402 | |
354 | free (old_buf); |
403 | free (old_buf); |
355 | delete old_ta; |
404 | delete old_ta; |
356 | delete old_ra; |
405 | delete old_ra; |
357 | |
406 | |
358 | min_it (screen.cur.row, nrow - 1); |
407 | clamp_it (screen.cur.row, 0, nrow - 1); |
359 | min_it (screen.cur.col, ncol - 1); |
408 | clamp_it (screen.cur.col, 0, ncol - 1); |
360 | |
409 | |
361 | if (tabs) |
410 | if (tabs) |
362 | free (tabs); |
411 | free (tabs); |
363 | } |
412 | } |
364 | |
413 | |
… | |
… | |
369 | |
418 | |
370 | for (int col = ncol; col--; ) |
419 | for (int col = ncol; col--; ) |
371 | tabs [col] = col % TABSIZE == 0; |
420 | tabs [col] = col % TABSIZE == 0; |
372 | |
421 | |
373 | tt_winch (); |
422 | tt_winch (); |
|
|
423 | |
|
|
424 | PERL_INVOKE ((this, HOOK_RESET, DT_END)); |
374 | } |
425 | } |
375 | |
426 | |
376 | /* ------------------------------------------------------------------------- */ |
427 | /* ------------------------------------------------------------------------- */ |
377 | /* |
428 | /* |
378 | * Free everything. That way malloc debugging can find leakage. |
429 | * Free everything. That way malloc debugging can find leakage. |
… | |
… | |
386 | free (row_buf); |
437 | free (row_buf); |
387 | free (swap_buf); |
438 | free (swap_buf); |
388 | free (drawn_buf); |
439 | free (drawn_buf); |
389 | free (temp_buf); |
440 | free (temp_buf); |
390 | free (tabs); |
441 | free (tabs); |
|
|
442 | |
|
|
443 | row_buf = 0; // signal that we freed all the arrays |
391 | } |
444 | } |
392 | |
445 | |
393 | /* ------------------------------------------------------------------------- */ |
446 | /* ------------------------------------------------------------------------- */ |
394 | /* |
447 | /* |
395 | * Hard reset |
448 | * Hard reset |
… | |
… | |
451 | min_it (s->cur.row, nrow - 1); |
504 | min_it (s->cur.row, nrow - 1); |
452 | min_it (s->cur.col, ncol - 1); |
505 | min_it (s->cur.col, ncol - 1); |
453 | #ifdef DEBUG_STRICT |
506 | #ifdef DEBUG_STRICT |
454 | assert (s->cur.row >= 0); |
507 | assert (s->cur.row >= 0); |
455 | assert (s->cur.col >= 0); |
508 | assert (s->cur.col >= 0); |
456 | #else /* drive with your eyes closed */ |
|
|
457 | max_it (s->cur.row, 0); |
|
|
458 | max_it (s->cur.col, 0); |
|
|
459 | #endif |
509 | #endif |
460 | } |
510 | } |
461 | |
511 | |
462 | /* ------------------------------------------------------------------------- */ |
512 | /* ------------------------------------------------------------------------- */ |
463 | /* |
513 | /* |
… | |
… | |
483 | |
533 | |
484 | screen.cur.row = clamp (screen.cur.row, 0, prev_nrow - 1); |
534 | screen.cur.row = clamp (screen.cur.row, 0, prev_nrow - 1); |
485 | screen.cur.col = clamp (screen.cur.col, 0, prev_ncol - 1); |
535 | screen.cur.col = clamp (screen.cur.col, 0, prev_ncol - 1); |
486 | |
536 | |
487 | #if NSCREENS |
537 | #if NSCREENS |
488 | if (options & Opt_secondaryScreen) |
538 | if (OPTION (Opt_secondaryScreen)) |
489 | { |
539 | { |
490 | num_scr = 0; |
540 | num_scr = 0; |
491 | |
541 | |
492 | for (int i = nrow; i--; ) |
542 | for (int i = prev_nrow; i--; ) |
493 | ::swap (ROW(i), swap_buf [i]); |
543 | ::swap (ROW(i), swap_buf [i]); |
494 | |
544 | |
495 | ::swap (screen.charset, swap.charset); |
545 | ::swap (screen.charset, swap.charset); |
496 | ::swap (screen.flags, swap.flags); |
546 | ::swap (screen.flags, swap.flags); |
497 | screen.flags |= Screen_VisibleCursor; |
547 | screen.flags |= Screen_VisibleCursor; |
498 | swap.flags |= Screen_VisibleCursor; |
548 | swap.flags |= Screen_VisibleCursor; |
499 | } |
549 | } |
500 | else |
550 | else |
501 | #endif |
551 | #endif |
502 | if (options & Opt_secondaryScroll) |
552 | if (OPTION (Opt_secondaryScroll)) |
503 | scr_scroll_text (0, prev_nrow - 1, prev_nrow); |
553 | scr_scroll_text (0, prev_nrow - 1, prev_nrow); |
504 | |
554 | |
505 | return scrn; |
555 | return scrn; |
506 | } |
556 | } |
507 | |
557 | |
… | |
… | |
569 | num_scr += count; |
619 | num_scr += count; |
570 | |
620 | |
571 | if (count > 0 |
621 | if (count > 0 |
572 | && row1 == 0 |
622 | && row1 == 0 |
573 | && row2 == nrow - 1 |
623 | && row2 == nrow - 1 |
574 | && (current_screen == PRIMARY || options & Opt_secondaryScroll)) |
624 | && (current_screen == PRIMARY || OPTION (Opt_secondaryScroll))) |
575 | { |
625 | { |
576 | 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 | |
577 | term_start = (term_start + count) % total_rows; |
630 | term_start = (term_start + count) % total_rows; |
578 | |
631 | |
579 | if (selection.op && current_screen == selection.screen) |
632 | if (selection.op && current_screen == selection.screen) |
580 | { |
633 | { |
581 | selection.beg.row -= count; |
634 | selection.beg.row -= count; |
582 | selection.end.row -= count; |
635 | selection.end.row -= count; |
583 | selection.mark.row -= count; |
636 | selection.mark.row -= count; |
584 | |
637 | |
585 | selection_check (0); |
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 | } |
586 | } |
645 | } |
587 | |
646 | |
588 | for (int i = count; i--; ) |
647 | for (int i = count; i--; ) |
|
|
648 | { |
|
|
649 | ROW(row2 - i).l = 0; |
589 | scr_blank_screen_mem (ROW(row2 - i), rstyle); |
650 | scr_blank_screen_mem (ROW(row2 - i), rstyle); |
|
|
651 | } |
590 | |
652 | |
591 | if ((options & Opt_scrollWithBuffer) |
653 | if (OPTION (Opt_scrollWithBuffer) |
592 | && view_start != 0 |
654 | && view_start != 0 |
593 | && view_start != saveLines) |
655 | && view_start != saveLines) |
594 | scr_page (UP, count); |
656 | scr_page (UP, count); |
595 | } |
657 | } |
596 | else |
658 | else |
597 | { |
659 | { |
598 | if (selection.op && current_screen == selection.screen) |
660 | if (selection.op && current_screen == selection.screen) |
599 | { |
661 | { |
600 | int i = selection.beg.row; |
662 | if ((selection.beg.row < row1 && selection.end.row > row1) |
601 | int j = selection.end.row; |
663 | || (selection.beg.row < row2 && selection.end.row > row2) |
602 | |
|
|
603 | if ((i < row1 && j > row1) |
|
|
604 | || (i < row2 && j > row2) |
|
|
605 | || (i - count < row1 && i >= row1) |
664 | || (selection.beg.row - count < row1 && selection.beg.row >= row1) |
606 | || (i - count > row2 && i <= row2) |
665 | || (selection.beg.row - count > row2 && selection.beg.row <= row2) |
607 | || (j - count < row1 && j >= row1) |
666 | || (selection.end.row - count < row1 && selection.end.row >= row1) |
608 | || (j - count > row2 && j <= row2)) |
667 | || (selection.end.row - count > row2 && selection.end.row <= row2)) |
609 | { |
668 | { |
610 | CLEAR_ALL_SELECTION (); |
669 | CLEAR_ALL_SELECTION (); |
611 | selection.op = SELECTION_CLEAR; /* XXX: too aggressive? */ |
670 | selection.op = SELECTION_CLEAR; |
612 | } |
671 | } |
613 | else if (j >= row1 && j <= row2) |
672 | else if (selection.end.row >= row1 && selection.end.row <= row2) |
614 | { |
673 | { |
615 | /* move selected region too */ |
674 | /* move selected region too */ |
616 | selection.beg.row -= count; |
675 | selection.beg.row -= count; |
617 | selection.end.row -= count; |
676 | selection.end.row -= count; |
618 | selection.mark.row -= count; |
677 | selection.mark.row -= count; |
… | |
… | |
653 | if (len <= 0) /* sanity */ |
712 | if (len <= 0) /* sanity */ |
654 | return; |
713 | return; |
655 | |
714 | |
656 | unsigned char checksel; |
715 | unsigned char checksel; |
657 | unicode_t c; |
716 | unicode_t c; |
658 | int row, last_col; |
717 | int last_col; |
659 | const unicode_t *strend = str + len; |
718 | const unicode_t *strend = str + len; |
660 | |
719 | |
661 | want_refresh = 1; |
720 | want_refresh = 1; |
662 | ZERO_SCROLLBACK (); |
721 | ZERO_SCROLLBACK (); |
663 | last_col = ncol; |
722 | last_col = ncol; |
… | |
… | |
677 | |
736 | |
678 | #ifdef DEBUG_STRICT |
737 | #ifdef DEBUG_STRICT |
679 | assert (screen.cur.col < last_col); |
738 | assert (screen.cur.col < last_col); |
680 | assert (screen.cur.row < nrow |
739 | assert (screen.cur.row < nrow |
681 | && screen.cur.row >= -nsaved); |
740 | && screen.cur.row >= -nsaved); |
682 | #else /* drive with your eyes closed */ |
|
|
683 | min_it (screen.cur.col, last_col - 1); |
|
|
684 | clamp_it (screen.cur.row, -nsaved, nrow - 1); |
|
|
685 | #endif |
741 | #endif |
686 | row = screen.cur.row; |
742 | int row = screen.cur.row; |
687 | |
743 | |
688 | checksel = selection.op && current_screen == selection.screen ? 1 : 0; |
744 | checksel = selection.op && current_screen == selection.screen ? 1 : 0; |
689 | |
745 | |
690 | line_t *line = &ROW(row); |
746 | line_t *line = &ROW(row); |
691 | |
747 | |
… | |
… | |
693 | { |
749 | { |
694 | c = *str++; |
750 | c = *str++; |
695 | |
751 | |
696 | if (c < 0x20) |
752 | if (c < 0x20) |
697 | if (c == C0_LF) |
753 | if (c == C0_LF) |
698 | { |
754 | { |
699 | if (!line->is_longer ()) /* XXX: think about this */ |
755 | if (!line->is_longer ()) /* XXX: think about this */ |
700 | max_it (line->l, screen.cur.col); |
756 | max_it (line->l, screen.cur.col); |
701 | |
757 | |
702 | screen.flags &= ~Screen_WrapNext; |
758 | screen.flags &= ~Screen_WrapNext; |
703 | |
759 | |
… | |
… | |
900 | if (!line->is_longer ()) /* XXX: think about this */ |
956 | if (!line->is_longer ()) /* XXX: think about this */ |
901 | max_it (line->l, screen.cur.col); |
957 | max_it (line->l, screen.cur.col); |
902 | |
958 | |
903 | #ifdef DEBUG_STRICT |
959 | #ifdef DEBUG_STRICT |
904 | assert (screen.cur.row >= 0); |
960 | assert (screen.cur.row >= 0); |
905 | #else /* drive with your eyes closed */ |
|
|
906 | max_it (screen.cur.row, 0); |
|
|
907 | #endif |
961 | #endif |
908 | } |
962 | } |
909 | |
963 | |
910 | /* ------------------------------------------------------------------------- */ |
964 | /* ------------------------------------------------------------------------- */ |
911 | /* |
965 | /* |
… | |
… | |
950 | |
1004 | |
951 | if (count == 0) |
1005 | if (count == 0) |
952 | return; |
1006 | return; |
953 | else if (count > 0) |
1007 | else if (count > 0) |
954 | { |
1008 | { |
955 | int row = screen.cur.row; |
|
|
956 | |
|
|
957 | line_t &l = ROW(row); |
1009 | line_t &l = ROW(screen.cur.row); |
958 | rend_t base_rend = l.r[i]; |
1010 | rend_t base_rend = l.r[i]; |
959 | ht &= l.t[i] == ' '; |
1011 | ht &= l.t[i] == ' '; |
960 | |
1012 | |
961 | for (; ++i < ncol; ) |
1013 | for (; ++i < ncol; ) |
962 | if (tabs[i]) |
1014 | if (tabs[i]) |
… | |
… | |
972 | if (count) |
1024 | if (count) |
973 | x = ncol - 1; |
1025 | x = ncol - 1; |
974 | |
1026 | |
975 | // store horizontal tab commands as characters inside the text |
1027 | // store horizontal tab commands as characters inside the text |
976 | // buffer so they can be selected and pasted. |
1028 | // buffer so they can be selected and pasted. |
977 | if (ht && options & Opt_pastableTabs) |
1029 | if (ht && OPTION (Opt_pastableTabs)) |
978 | { |
1030 | { |
979 | base_rend = SET_FONT (base_rend, 0); |
1031 | base_rend = SET_FONT (base_rend, 0); |
980 | |
1032 | |
981 | if (!l.is_longer ()) /* XXX: think about this */ |
1033 | if (!l.is_longer ()) /* XXX: think about this */ |
982 | max_it (l.l, x); |
1034 | max_it (l.l, x); |
… | |
… | |
1037 | */ |
1089 | */ |
1038 | #if ENABLE_FRILLS |
1090 | #if ENABLE_FRILLS |
1039 | void |
1091 | void |
1040 | rxvt_term::scr_forwardindex () |
1092 | rxvt_term::scr_forwardindex () |
1041 | { |
1093 | { |
1042 | int row; |
|
|
1043 | |
|
|
1044 | if (screen.cur.col < ncol - 1) |
1094 | if (screen.cur.col < ncol - 1) |
1045 | scr_gotorc (0, 1, R_RELATIVE | C_RELATIVE); |
1095 | scr_gotorc (0, 1, R_RELATIVE | C_RELATIVE); |
1046 | else |
1096 | else |
1047 | { |
1097 | { |
1048 | row = screen.cur.row; |
|
|
1049 | |
|
|
1050 | if (ROW(row).is_longer ()) //TODO//FIXME//LEN |
1098 | if (ROW(screen.cur.row).is_longer ()) //TODO//FIXME//LEN |
1051 | ROW(row).l = ncol; |
1099 | ROW(screen.cur.row).l = ncol; |
1052 | |
1100 | |
1053 | scr_gotorc (0, 0, R_RELATIVE); |
1101 | scr_gotorc (0, 0, R_RELATIVE); |
1054 | scr_insdel_chars (1, DELETE); |
1102 | scr_insdel_chars (1, DELETE); |
1055 | scr_gotorc (0, ncol - 1, R_RELATIVE); |
1103 | scr_gotorc (0, ncol - 1, R_RELATIVE); |
1056 | } |
1104 | } |
… | |
… | |
1139 | * XTERM_SEQ: Clear whole line : ESC [ 2 K |
1187 | * XTERM_SEQ: Clear whole line : ESC [ 2 K |
1140 | */ |
1188 | */ |
1141 | void |
1189 | void |
1142 | rxvt_term::scr_erase_line (int mode) |
1190 | rxvt_term::scr_erase_line (int mode) |
1143 | { |
1191 | { |
1144 | unsigned int row, col, num; |
1192 | unsigned int col, num; |
1145 | |
1193 | |
1146 | want_refresh = 1; |
1194 | want_refresh = 1; |
1147 | ZERO_SCROLLBACK (); |
1195 | ZERO_SCROLLBACK (); |
1148 | |
1196 | |
1149 | selection_check (1); |
1197 | selection_check (1); |
1150 | |
1198 | |
1151 | row = screen.cur.row; |
1199 | line_t &line = ROW(screen.cur.row); |
1152 | |
1200 | |
1153 | switch (mode) |
1201 | switch (mode) |
1154 | { |
1202 | { |
1155 | case 0: /* erase to end of line */ |
1203 | case 0: /* erase to end of line */ |
1156 | col = screen.cur.col; |
1204 | col = screen.cur.col; |
1157 | num = ncol - col; |
1205 | num = ncol - col; |
1158 | min_it (ROW(row).l, col); |
1206 | min_it (line.l, col); |
1159 | if (ROWCOL_IN_ROW_AT_OR_AFTER (selection.beg, screen.cur) |
1207 | if (ROWCOL_IN_ROW_AT_OR_AFTER (selection.beg, screen.cur) |
1160 | || ROWCOL_IN_ROW_AT_OR_AFTER (selection.end, screen.cur)) |
1208 | || ROWCOL_IN_ROW_AT_OR_AFTER (selection.end, screen.cur)) |
1161 | CLEAR_SELECTION (); |
1209 | CLEAR_SELECTION (); |
1162 | break; |
1210 | break; |
1163 | case 1: /* erase to beginning of line */ |
1211 | case 1: /* erase to beginning of line */ |
… | |
… | |
1168 | CLEAR_SELECTION (); |
1216 | CLEAR_SELECTION (); |
1169 | break; |
1217 | break; |
1170 | case 2: /* erase whole line */ |
1218 | case 2: /* erase whole line */ |
1171 | col = 0; |
1219 | col = 0; |
1172 | num = ncol; |
1220 | num = ncol; |
1173 | ROW(row).l = 0; |
1221 | line.l = 0; |
1174 | if (selection.beg.row <= screen.cur.row |
1222 | if (selection.beg.row <= screen.cur.row |
1175 | && selection.end.row >= screen.cur.row) |
1223 | && selection.end.row >= screen.cur.row) |
1176 | CLEAR_SELECTION (); |
1224 | CLEAR_SELECTION (); |
1177 | break; |
1225 | break; |
1178 | default: |
1226 | default: |
1179 | return; |
1227 | return; |
1180 | } |
1228 | } |
1181 | |
1229 | |
1182 | scr_blank_line (ROW(row), col, num, rstyle); |
1230 | scr_blank_line (line, col, num, rstyle); |
1183 | } |
1231 | } |
1184 | |
1232 | |
1185 | /* ------------------------------------------------------------------------- */ |
1233 | /* ------------------------------------------------------------------------- */ |
1186 | /* |
1234 | /* |
1187 | * Erase part of whole of the screen |
1235 | * Erase part of whole of the screen |
… | |
… | |
1242 | CLEAR_ROWS (row, num); |
1290 | CLEAR_ROWS (row, num); |
1243 | } |
1291 | } |
1244 | else |
1292 | else |
1245 | { |
1293 | { |
1246 | ren = rstyle & (RS_fgMask | RS_bgMask); |
1294 | ren = rstyle & (RS_fgMask | RS_bgMask); |
1247 | gcvalue.foreground = pix_colors[GET_BGCOLOR (rstyle)]; |
1295 | gcvalue.foreground = pix_colors[bgcolor_of (rstyle)]; |
1248 | XChangeGC (display->display, gc, GCForeground, &gcvalue); |
1296 | XChangeGC (display->display, gc, GCForeground, &gcvalue); |
1249 | ERASE_ROWS (row, num); |
1297 | ERASE_ROWS (row, num); |
1250 | gcvalue.foreground = pix_colors[Color_fg]; |
1298 | gcvalue.foreground = pix_colors[Color_fg]; |
1251 | XChangeGC (display->display, gc, GCForeground, &gcvalue); |
1299 | XChangeGC (display->display, gc, GCForeground, &gcvalue); |
1252 | } |
1300 | } |
1253 | |
1301 | |
1254 | for (; num--; row++) |
1302 | for (; num--; row++) |
1255 | { |
1303 | { |
|
|
1304 | ROW (row).l = 0; |
1256 | scr_blank_screen_mem (ROW (row), rstyle); |
1305 | scr_blank_screen_mem (ROW (row), rstyle); |
1257 | ROW (row).l = 0; |
|
|
1258 | scr_blank_line (drawn_buf [row], 0, ncol, ren); |
1306 | scr_blank_line (drawn_buf [row], 0, ncol, ren); |
1259 | } |
1307 | } |
1260 | } |
1308 | } |
1261 | |
1309 | |
1262 | #if ENABLE_FRILLS |
1310 | #if ENABLE_FRILLS |
… | |
… | |
1551 | ::swap (pix_colors[Color_fg], pix_colors[Color_bg]); |
1599 | ::swap (pix_colors[Color_fg], pix_colors[Color_bg]); |
1552 | #if XPM_BACKGROUND |
1600 | #if XPM_BACKGROUND |
1553 | if (bgPixmap.pixmap == None) |
1601 | if (bgPixmap.pixmap == None) |
1554 | #endif |
1602 | #endif |
1555 | #if TRANSPARENT |
1603 | #if TRANSPARENT |
1556 | if (! (options & Opt_transparent) || am_transparent == 0) |
1604 | if (! OPTION (Opt_transparent) || am_transparent == 0) |
1557 | #endif |
1605 | #endif |
1558 | XSetWindowBackground (display->display, vt, |
1606 | XSetWindowBackground (display->display, vt, |
1559 | pix_colors[Color_bg]); |
1607 | pix_colors[Color_bg]); |
1560 | |
1608 | |
1561 | gcvalue.foreground = pix_colors[Color_fg]; |
1609 | gcvalue.foreground = pix_colors[Color_fg]; |
… | |
… | |
1691 | y = 0; |
1739 | y = 0; |
1692 | eheight = height; |
1740 | eheight = height; |
1693 | } |
1741 | } |
1694 | #endif |
1742 | #endif |
1695 | |
1743 | |
1696 | #ifdef DEBUG_STRICT |
|
|
1697 | #if 0 |
|
|
1698 | // that's not debugging //TODO //FIXME |
|
|
1699 | clamp_it (x, 0, width); |
|
|
1700 | clamp_it (y, 0, height); |
|
|
1701 | #endif |
|
|
1702 | #endif |
|
|
1703 | |
|
|
1704 | /* round down */ |
1744 | /* round down */ |
1705 | rc[PART_BEG].col = Pixel2Col (x); |
1745 | rc[PART_BEG].col = Pixel2Col (x); |
1706 | rc[PART_BEG].row = Pixel2Row (y); |
1746 | rc[PART_BEG].row = Pixel2Row (y); |
1707 | /* round up */ |
1747 | /* round up */ |
1708 | rc[PART_END].col = Pixel2Width (x + ewidth + fwidth - 1); |
1748 | rc[PART_END].col = Pixel2Width (x + ewidth + fwidth - 1); |
… | |
… | |
1785 | } |
1825 | } |
1786 | |
1826 | |
1787 | int |
1827 | int |
1788 | rxvt_term::scr_changeview (unsigned int oldviewstart) |
1828 | rxvt_term::scr_changeview (unsigned int oldviewstart) |
1789 | { |
1829 | { |
|
|
1830 | PERL_INVOKE ((this, HOOK_VIEW_CHANGE, DT_INT, view_start, DT_END)); |
|
|
1831 | |
1790 | if (view_start != oldviewstart) |
1832 | if (view_start != oldviewstart) |
1791 | { |
1833 | { |
1792 | want_refresh = 1; |
1834 | want_refresh = 1; |
1793 | num_scr -= (view_start - oldviewstart); |
1835 | num_scr -= (view_start - oldviewstart); |
1794 | } |
1836 | } |
… | |
… | |
1802 | { |
1844 | { |
1803 | #ifndef NO_BELL |
1845 | #ifndef NO_BELL |
1804 | |
1846 | |
1805 | # ifndef NO_MAPALERT |
1847 | # ifndef NO_MAPALERT |
1806 | # ifdef MAPALERT_OPTION |
1848 | # ifdef MAPALERT_OPTION |
1807 | if (options & Opt_mapAlert) |
1849 | if (OPTION (Opt_mapAlert)) |
1808 | # endif |
1850 | # endif |
1809 | XMapWindow (display->display, parent[0]); |
1851 | XMapWindow (display->display, parent[0]); |
1810 | # endif |
1852 | # endif |
1811 | |
1853 | |
1812 | if (options & Opt_visualBell) |
1854 | if (OPTION (Opt_visualBell)) |
1813 | { |
1855 | { |
1814 | scr_rvideo_mode (!rvideo); /* refresh also done */ |
1856 | scr_rvideo_mode (!rvideo); /* refresh also done */ |
1815 | rxvt_usleep (VISUAL_BELL_DURATION); |
1857 | rxvt_usleep (VISUAL_BELL_DURATION); |
1816 | scr_rvideo_mode (!rvideo); /* refresh also done */ |
1858 | scr_rvideo_mode (!rvideo); /* refresh also done */ |
1817 | } |
1859 | } |
… | |
… | |
1908 | |
1950 | |
1909 | #if XPM_BACKGROUND |
1951 | #if XPM_BACKGROUND |
1910 | must_clear |= bgPixmap.pixmap != None; |
1952 | must_clear |= bgPixmap.pixmap != None; |
1911 | #endif |
1953 | #endif |
1912 | #if TRANSPARENT |
1954 | #if TRANSPARENT |
1913 | must_clear |= (options & Opt_transparent) && am_transparent; |
1955 | must_clear |= OPTION (Opt_transparent) && am_transparent; |
1914 | #endif |
1956 | #endif |
1915 | ocrow = oldcursor.row; /* is there an old outline cursor on screen? */ |
1957 | ocrow = oldcursor.row; /* is there an old outline cursor on screen? */ |
1916 | |
1958 | |
1917 | /* |
1959 | /* |
1918 | * B: reverse any characters which are selected |
1960 | * B: reverse any characters which are selected |
… | |
… | |
1942 | |
1984 | |
1943 | crp = &ROW(screen.cur.row).r[col]; |
1985 | crp = &ROW(screen.cur.row).r[col]; |
1944 | |
1986 | |
1945 | if (showcursor && focus) |
1987 | if (showcursor && focus) |
1946 | { |
1988 | { |
1947 | if (options & Opt_cursorUnderline) |
1989 | if (OPTION (Opt_cursorUnderline)) |
1948 | *crp ^= RS_Uline; |
1990 | *crp ^= RS_Uline; |
1949 | else |
1991 | else |
1950 | { |
1992 | { |
1951 | *crp ^= RS_RVid; |
1993 | *crp ^= RS_RVid; |
1952 | |
1994 | |
… | |
… | |
1954 | cc1 = *crp & (RS_fgMask | RS_bgMask); |
1996 | cc1 = *crp & (RS_fgMask | RS_bgMask); |
1955 | if (ISSET_PIXCOLOR (Color_cursor)) |
1997 | if (ISSET_PIXCOLOR (Color_cursor)) |
1956 | ccol1 = Color_cursor; |
1998 | ccol1 = Color_cursor; |
1957 | else |
1999 | else |
1958 | #ifdef CURSOR_COLOR_IS_RENDITION_COLOR |
2000 | #ifdef CURSOR_COLOR_IS_RENDITION_COLOR |
1959 | ccol1 = GET_FGCOLOR (rstyle); |
2001 | ccol1 = fgcolor_of (rstyle); |
1960 | #else |
2002 | #else |
1961 | ccol1 = Color_fg; |
2003 | ccol1 = Color_fg; |
1962 | #endif |
2004 | #endif |
1963 | if (ISSET_PIXCOLOR (Color_cursor2)) |
2005 | if (ISSET_PIXCOLOR (Color_cursor2)) |
1964 | ccol2 = Color_cursor2; |
2006 | ccol2 = Color_cursor2; |
1965 | else |
2007 | else |
1966 | #ifdef CURSOR_COLOR_IS_RENDITION_COLOR |
2008 | #ifdef CURSOR_COLOR_IS_RENDITION_COLOR |
1967 | ccol2 = GET_BGCOLOR (rstyle); |
2009 | ccol2 = bgcolor_of (rstyle); |
1968 | #else |
2010 | #else |
1969 | ccol2 = Color_bg; |
2011 | ccol2 = Color_bg; |
1970 | #endif |
2012 | #endif |
1971 | *crp = SET_FGCOLOR (*crp, ccol1); |
2013 | *crp = SET_FGCOLOR (*crp, ccol1); |
1972 | *crp = SET_BGCOLOR (*crp, ccol2); |
2014 | *crp = SET_BGCOLOR (*crp, ccol2); |
… | |
… | |
2005 | oldcursor.col = screen.cur.col; |
2047 | oldcursor.col = screen.cur.col; |
2006 | } |
2048 | } |
2007 | } |
2049 | } |
2008 | } |
2050 | } |
2009 | |
2051 | |
|
|
2052 | PERL_INVOKE ((this, HOOK_REFRESH_BEGIN, DT_END)); |
2010 | #if ENABLE_OVERLAY |
2053 | #if ENABLE_OVERLAY |
2011 | scr_swap_overlay (); |
2054 | scr_swap_overlay (); |
2012 | #endif |
2055 | #endif |
2013 | |
2056 | |
2014 | #ifndef NO_SLOW_LINK_SUPPORT |
2057 | #ifndef NO_SLOW_LINK_SUPPORT |
… | |
… | |
2064 | if (wlen < len) |
2107 | if (wlen < len) |
2065 | ::swap (wlen, len); |
2108 | ::swap (wlen, len); |
2066 | |
2109 | |
2067 | XCopyArea (display->display, vt, vt, |
2110 | XCopyArea (display->display, vt, vt, |
2068 | gc, 0, Row2Pixel (len + i), |
2111 | gc, 0, Row2Pixel (len + i), |
2069 | (unsigned int)TermWin_TotalWidth (), |
2112 | (unsigned int)this->width, |
2070 | (unsigned int)Height2Pixel (wlen - len + 1), |
2113 | (unsigned int)Height2Pixel (wlen - len + 1), |
2071 | 0, Row2Pixel (len)); |
2114 | 0, Row2Pixel (len)); |
2072 | len = -1; |
2115 | len = -1; |
2073 | } |
2116 | } |
2074 | } |
2117 | } |
… | |
… | |
2153 | count++, i--; |
2196 | count++, i--; |
2154 | |
2197 | |
2155 | /* |
2198 | /* |
2156 | * Determine the attributes for the string |
2199 | * Determine the attributes for the string |
2157 | */ |
2200 | */ |
2158 | int fore = GET_FGCOLOR (rend); // desired foreground |
2201 | int fore = fgcolor_of (rend); // desired foreground |
2159 | int back = GET_BGCOLOR (rend); // desired background |
2202 | int back = bgcolor_of (rend); // desired background |
2160 | |
2203 | |
2161 | // only do special processing if any attributes are set, which is rare |
2204 | // only do special processing if any attributes are set, which is unlikely |
2162 | if (rend & (RS_Bold | RS_Italic | RS_Uline | RS_RVid | RS_Blink | RS_Careful)) |
2205 | if (rend & (RS_Bold | RS_Italic | RS_Uline | RS_RVid | RS_Blink | RS_Careful)) |
2163 | { |
2206 | { |
2164 | #if ENABLE_STYLES |
2207 | #if ENABLE_STYLES |
2165 | // force redraw after "careful" characters to avoid pixel droppings |
2208 | // force redraw after "careful" characters to avoid pixel droppings |
2166 | if (srp[col] & RS_Careful && col < ncol - 1 && 0) |
2209 | if (srp[col] & RS_Careful && col < ncol - 1 && 0) |
… | |
… | |
2277 | } /* for (row....) */ |
2320 | } /* for (row....) */ |
2278 | |
2321 | |
2279 | #if ENABLE_OVERLAY |
2322 | #if ENABLE_OVERLAY |
2280 | scr_swap_overlay (); |
2323 | scr_swap_overlay (); |
2281 | #endif |
2324 | #endif |
|
|
2325 | PERL_INVOKE ((this, HOOK_REFRESH_END, DT_END)); |
2282 | |
2326 | |
2283 | /* |
2327 | /* |
2284 | * G: cleanup cursor and display outline cursor if necessary |
2328 | * G: cleanup cursor and display outline cursor if necessary |
2285 | */ |
2329 | */ |
2286 | if (showcursor) |
2330 | if (showcursor) |
2287 | { |
2331 | { |
2288 | if (focus) |
2332 | if (focus) |
2289 | { |
2333 | { |
2290 | if (options & Opt_cursorUnderline) |
2334 | if (OPTION (Opt_cursorUnderline)) |
2291 | *crp ^= RS_Uline; |
2335 | *crp ^= RS_Uline; |
2292 | else |
2336 | else |
2293 | { |
2337 | { |
2294 | *crp ^= RS_RVid; |
2338 | *crp ^= RS_RVid; |
2295 | #ifndef NO_CURSORCOLOR |
2339 | #ifndef NO_CURSORCOLOR |
… | |
… | |
2414 | |
2458 | |
2415 | #if ENABLE_FRILLS |
2459 | #if ENABLE_FRILLS |
2416 | if (selection.rect) |
2460 | if (selection.rect) |
2417 | { |
2461 | { |
2418 | for (row = max (selection.beg.row, -view_start); row <= min (selection.end.row, view_end); row++) |
2462 | for (row = max (selection.beg.row, -view_start); row <= min (selection.end.row, view_end); row++) |
|
|
2463 | { |
|
|
2464 | text_t *stp = ROW(row).t; |
|
|
2465 | rend_t *srp = ROW(row).r; |
|
|
2466 | |
2419 | for (rend_t *srp = ROW(row).r, col = selection.beg.col; col < selection.end.col; col++) |
2467 | for (col = selection.beg.col; col < selection.end.col; col++) |
2420 | srp[col] ^= RS_RVid; |
2468 | srp[col] ^= RS_RVid; |
|
|
2469 | |
|
|
2470 | while (col-- > selection.beg.col && (stp[col] == NOCHAR || unicode::is_space (stp[col]))) |
|
|
2471 | srp[col] ^= RS_RVid | RS_Uline; |
|
|
2472 | |
|
|
2473 | if (++col < selection.end.col) |
|
|
2474 | srp[col] ^= RS_RVid | RS_Uline; |
|
|
2475 | } |
2421 | } |
2476 | } |
2422 | else |
2477 | else |
2423 | #endif |
2478 | #endif |
2424 | { |
2479 | { |
2425 | if (selection.beg.row >= -view_start) |
2480 | if (selection.beg.row >= -view_start) |
… | |
… | |
2428 | row = selection.beg.row; |
2483 | row = selection.beg.row; |
2429 | } |
2484 | } |
2430 | else |
2485 | else |
2431 | { |
2486 | { |
2432 | col = 0; |
2487 | col = 0; |
2433 | row = view_start; |
2488 | row = -view_start; |
2434 | } |
2489 | } |
2435 | |
2490 | |
2436 | for (; row < min (selection.end.row, view_end); row++, col = 0) |
2491 | for (; row < min (selection.end.row, view_end); row++, col = 0) |
2437 | for (rend_t *srp = ROW(row).r; col < ncol; col++) |
2492 | for (rend_t *srp = ROW(row).r; col < ncol; col++) |
2438 | srp[col] ^= RS_RVid; |
2493 | srp[col] ^= RS_RVid; |
… | |
… | |
2509 | /* ------------------------------------------------------------------------- */ |
2564 | /* ------------------------------------------------------------------------- */ |
2510 | /* |
2565 | /* |
2511 | * Paste a selection direct to the command fd |
2566 | * Paste a selection direct to the command fd |
2512 | */ |
2567 | */ |
2513 | void |
2568 | void |
2514 | rxvt_term::paste (unsigned char *data, unsigned int len) |
2569 | rxvt_term::paste (char *data, unsigned int len) |
2515 | { |
2570 | { |
2516 | /* convert normal newline chars into common keyboard Return key sequence */ |
2571 | /* convert normal newline chars into common keyboard Return key sequence */ |
2517 | for (unsigned int i = 0; i < len; i++) |
2572 | for (unsigned int i = 0; i < len; i++) |
2518 | if (data[i] == C0_LF) |
2573 | if (data[i] == C0_LF) |
2519 | data[i] = C0_CR; |
2574 | data[i] = C0_CR; |
… | |
… | |
2663 | { |
2718 | { |
2664 | wchar_t *w = rxvt_utf8towcs ((const char *)ct.value, ct.nitems); |
2719 | wchar_t *w = rxvt_utf8towcs ((const char *)ct.value, ct.nitems); |
2665 | char *s = rxvt_wcstombs (w); |
2720 | char *s = rxvt_wcstombs (w); |
2666 | free (w); |
2721 | free (w); |
2667 | // TODO: strlen == only the first element will be converted. well... |
2722 | // TODO: strlen == only the first element will be converted. well... |
2668 | paste ((unsigned char *)s, strlen (s)); |
2723 | paste (s, strlen (s)); |
2669 | free (s); |
2724 | free (s); |
2670 | } |
2725 | } |
2671 | else |
2726 | else |
2672 | #endif |
2727 | #endif |
2673 | if (XmbTextPropertyToTextList (display->display, &ct, &cl, &cr) >= 0 |
2728 | if (XmbTextPropertyToTextList (display->display, &ct, &cl, &cr) >= 0 |
2674 | && cl) |
2729 | && cl) |
2675 | { |
2730 | { |
2676 | for (int i = 0; i < cr; i++) |
2731 | for (int i = 0; i < cr; i++) |
2677 | paste ((unsigned char *)cl[i], strlen (cl[i])); |
2732 | paste (cl[i], strlen (cl[i])); |
2678 | |
2733 | |
2679 | XFreeStringList (cl); |
2734 | XFreeStringList (cl); |
2680 | } |
2735 | } |
2681 | else |
2736 | else |
2682 | paste (ct.value, ct.nitems); // paste raw |
2737 | paste ((char *)ct.value, ct.nitems); // paste raw |
2683 | |
2738 | |
2684 | bailout: |
2739 | bailout: |
2685 | XFree (ct.value); |
2740 | XFree (ct.value); |
2686 | |
2741 | |
2687 | if (selection_wait == Sel_normal) |
2742 | if (selection_wait == Sel_normal) |
… | |
… | |
2725 | return; /* outside window */ |
2780 | return; /* outside window */ |
2726 | |
2781 | |
2727 | if (selection.text) |
2782 | if (selection.text) |
2728 | { /* internal selection */ |
2783 | { /* internal selection */ |
2729 | char *str = rxvt_wcstombs (selection.text, selection.len); |
2784 | char *str = rxvt_wcstombs (selection.text, selection.len); |
2730 | paste ((unsigned char *)str, strlen (str)); |
2785 | paste (str, strlen (str)); |
2731 | free (str); |
2786 | free (str); |
2732 | return; |
2787 | return; |
2733 | } |
2788 | } |
2734 | else |
2789 | else |
2735 | { |
2790 | { |
… | |
… | |
2827 | selection.op = SELECTION_DONE; |
2882 | selection.op = SELECTION_DONE; |
2828 | |
2883 | |
2829 | if (selection.clicks == 4) |
2884 | if (selection.clicks == 4) |
2830 | return; /* nothing selected, go away */ |
2885 | return; /* nothing selected, go away */ |
2831 | |
2886 | |
|
|
2887 | if (PERL_INVOKE ((this, HOOK_SEL_MAKE, DT_LONG, (long)tm, DT_END))) |
|
|
2888 | return; |
|
|
2889 | |
2832 | i = (selection.end.row - selection.beg.row + 1) * (ncol + 1); |
2890 | i = (selection.end.row - selection.beg.row + 1) * (ncol + 1); |
2833 | new_selection_text = (wchar_t *)rxvt_malloc ((i + 4) * sizeof (wchar_t)); |
2891 | new_selection_text = (wchar_t *)rxvt_malloc ((i + 4) * sizeof (wchar_t)); |
2834 | |
2892 | |
2835 | int ofs = 0; |
2893 | int ofs = 0; |
2836 | int extra = 0; |
2894 | int extra = 0; |
… | |
… | |
2852 | #endif |
2910 | #endif |
2853 | end_col = ROW(row).is_longer () ? ncol : ROW(row).l; //TODO//FIXME//LEN |
2911 | end_col = ROW(row).is_longer () ? ncol : ROW(row).l; //TODO//FIXME//LEN |
2854 | |
2912 | |
2855 | col = max (col, 0); |
2913 | col = max (col, 0); |
2856 | |
2914 | |
2857 | if (row == selection.end.row || selection.rect) |
2915 | if (row == selection.end.row |
|
|
2916 | #if ENABLE_FRILLS |
|
|
2917 | || selection.rect |
|
|
2918 | #endif |
|
|
2919 | ) |
2858 | end_col = min (end_col, selection.end.col); |
2920 | min_it (end_col, selection.end.col); |
2859 | |
2921 | |
2860 | t = ROW(row).t + col; |
2922 | t = ROW(row).t + col; |
2861 | for (; col < end_col; col++) |
2923 | for (; col < end_col; col++) |
2862 | { |
2924 | { |
2863 | if (*t == NOCHAR) |
2925 | if (*t == NOCHAR) |
… | |
… | |
2881 | #endif |
2943 | #endif |
2882 | else |
2944 | else |
2883 | new_selection_text[ofs++] = *t++; |
2945 | new_selection_text[ofs++] = *t++; |
2884 | } |
2946 | } |
2885 | |
2947 | |
|
|
2948 | #if ENABLE_FRILLS |
|
|
2949 | if (selection.rect) |
|
|
2950 | { |
|
|
2951 | while (ofs |
|
|
2952 | && new_selection_text[ofs - 1] != C0_LF |
|
|
2953 | && unicode::is_space (new_selection_text[ofs - 1])) |
|
|
2954 | --ofs; |
|
|
2955 | |
|
|
2956 | new_selection_text[ofs++] = C0_LF; |
|
|
2957 | } |
|
|
2958 | else |
|
|
2959 | #endif |
2886 | if (!ROW(row).is_longer () && row != selection.end.row) |
2960 | if (!ROW(row).is_longer () && row != selection.end.row) |
2887 | new_selection_text[ofs++] = C0_LF; |
2961 | new_selection_text[ofs++] = C0_LF; |
2888 | } |
2962 | } |
2889 | |
2963 | |
2890 | if (end_col != selection.end.col) |
2964 | if (end_col != selection.end.col) |
2891 | new_selection_text[ofs++] = C0_LF; |
2965 | new_selection_text[ofs++] = C0_LF; |
2892 | |
2966 | |
… | |
… | |
2902 | |
2976 | |
2903 | // we usually allocate much more than necessary, so realloc it smaller again |
2977 | // we usually allocate much more than necessary, so realloc it smaller again |
2904 | selection.len = ofs; |
2978 | selection.len = ofs; |
2905 | selection.text = (wchar_t *)rxvt_realloc (new_selection_text, (ofs + 1) * sizeof (wchar_t)); |
2979 | selection.text = (wchar_t *)rxvt_realloc (new_selection_text, (ofs + 1) * sizeof (wchar_t)); |
2906 | |
2980 | |
|
|
2981 | if (PERL_INVOKE ((this, HOOK_SEL_GRAB, DT_LONG, (long)tm, DT_END))) |
|
|
2982 | return; |
|
|
2983 | |
|
|
2984 | selection_grab (tm); |
|
|
2985 | } |
|
|
2986 | |
|
|
2987 | bool |
|
|
2988 | rxvt_term::selection_grab (Time tm) |
|
|
2989 | { |
|
|
2990 | selection_time = tm; |
|
|
2991 | |
2907 | XSetSelectionOwner (display->display, XA_PRIMARY, vt, tm); |
2992 | XSetSelectionOwner (display->display, XA_PRIMARY, vt, tm); |
2908 | if (XGetSelectionOwner (display->display, XA_PRIMARY) == vt) |
2993 | if (XGetSelectionOwner (display->display, XA_PRIMARY) == vt) |
|
|
2994 | { |
2909 | display->set_selection_owner (this); |
2995 | display->set_selection_owner (this); |
|
|
2996 | return true; |
|
|
2997 | } |
2910 | else |
2998 | else |
2911 | rxvt_warn ("can't get primary selection, ignoring.\n"); |
2999 | return false; |
2912 | |
3000 | |
2913 | #if 0 |
3001 | #if 0 |
2914 | XTextProperty ct; |
3002 | XTextProperty ct; |
2915 | |
3003 | |
2916 | if (XwcTextListToTextProperty (display->display, &selection.text, 1, XStringStyle, &ct) >= 0) |
3004 | if (XwcTextListToTextProperty (display->display, &selection.text, 1, XStringStyle, &ct) >= 0) |
2917 | { |
3005 | { |
2918 | set_string_property (XA_CUT_BUFFER0, ct.value, ct.nitems); |
3006 | set_string_property (XA_CUT_BUFFER0, ct.value, ct.nitems); |
2919 | XFree (ct.value); |
3007 | XFree (ct.value); |
2920 | } |
3008 | } |
2921 | #endif |
3009 | #endif |
2922 | |
|
|
2923 | selection_time = tm; |
|
|
2924 | } |
3010 | } |
2925 | |
3011 | |
2926 | /* ------------------------------------------------------------------------- */ |
3012 | /* ------------------------------------------------------------------------- */ |
2927 | /* |
3013 | /* |
2928 | * Mark or select text based upon number of clicks: 1, 2, or 3 |
3014 | * Mark or select text based upon number of clicks: 1, 2, or 3 |
… | |
… | |
3237 | else if (selection.clicks == 2) |
3323 | else if (selection.clicks == 2) |
3238 | { |
3324 | { |
3239 | if (ROWCOL_IS_AFTER (selection.end, selection.beg)) |
3325 | if (ROWCOL_IS_AFTER (selection.end, selection.beg)) |
3240 | selection.end.col--; |
3326 | selection.end.col--; |
3241 | |
3327 | |
|
|
3328 | if (!PERL_INVOKE ((this, HOOK_SEL_EXTEND, DT_END))) |
|
|
3329 | { |
3242 | selection_delimit_word (UP, &selection.beg, &selection.beg); |
3330 | selection_delimit_word (UP, &selection.beg, &selection.beg); |
3243 | selection_delimit_word (DN, &selection.end, &selection.end); |
3331 | selection_delimit_word (DN, &selection.end, &selection.end); |
|
|
3332 | } |
3244 | } |
3333 | } |
3245 | else if (selection.clicks == 3) |
3334 | else if (selection.clicks == 3) |
3246 | { |
3335 | { |
3247 | #if ENABLE_FRILLS |
3336 | #if ENABLE_FRILLS |
3248 | if (options & Opt_tripleclickwords) |
3337 | if (OPTION (Opt_tripleclickwords)) |
3249 | { |
3338 | { |
3250 | selection_delimit_word (UP, &selection.beg, &selection.beg); |
3339 | selection_delimit_word (UP, &selection.beg, &selection.beg); |
3251 | |
3340 | |
3252 | 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++) |
3253 | { |
3342 | { |
… | |
… | |
3314 | { |
3403 | { |
3315 | stp = ROW(end_row).t; |
3404 | stp = ROW(end_row).t; |
3316 | |
3405 | |
3317 | while (--end_col >= 0) |
3406 | while (--end_col >= 0) |
3318 | { |
3407 | { |
3319 | if (stp[end_col] != ' ' |
3408 | if (stp[end_col] != NOCHAR |
3320 | && stp[end_col] != '\t' |
3409 | && !unicode::is_space (stp[end_col])) |
3321 | && stp[end_col] != NOCHAR) |
|
|
3322 | break; |
3410 | break; |
3323 | } |
3411 | } |
3324 | |
3412 | |
3325 | if (end_col >= 0 |
3413 | if (end_col >= 0 |
3326 | || !ROW(end_row - 1).is_longer ()) |
3414 | || !ROW(end_row - 1).is_longer ()) |
… | |
… | |
3525 | |
3613 | |
3526 | #if ENABLE_OVERLAY |
3614 | #if ENABLE_OVERLAY |
3527 | void |
3615 | void |
3528 | 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) |
3529 | { |
3617 | { |
3530 | if (nrow < 3 || ncol < 3) |
3618 | if (nrow < 1 || ncol < 1) |
3531 | return; |
3619 | return; |
3532 | |
3620 | |
3533 | want_refresh = 1; |
3621 | want_refresh = 1; |
3534 | |
3622 | |
3535 | scr_overlay_off (); |
3623 | scr_overlay_off (); |
… | |
… | |
3642 | for (int y = ov_h; y--; ) |
3730 | for (int y = ov_h; y--; ) |
3643 | { |
3731 | { |
3644 | text_t *t1 = ov_text[y]; |
3732 | text_t *t1 = ov_text[y]; |
3645 | rend_t *r1 = ov_rend[y]; |
3733 | rend_t *r1 = ov_rend[y]; |
3646 | |
3734 | |
3647 | text_t *t2 = ROW(y - view_start).t + ov_x; |
3735 | text_t *t2 = ROW(y + ov_y - view_start).t + ov_x; |
3648 | rend_t *r2 = ROW(y - view_start).r + ov_x; |
3736 | rend_t *r2 = ROW(y + ov_y - view_start).r + ov_x; |
3649 | |
3737 | |
3650 | for (int x = ov_w; x--; ) |
3738 | for (int x = ov_w; x--; ) |
3651 | { |
3739 | { |
3652 | text_t t = *t1; *t1++ = *t2; *t2++ = t; |
3740 | text_t t = *t1; *t1++ = *t2; *t2++ = t; |
3653 | 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)); |