ViewVC Help
View File | Revision Log | Show Annotations | Download File
/cvs/rxvt-unicode/src/screen.C
(Generate patch)

Comparing rxvt-unicode/src/screen.C (file contents):
Revision 1.82 by root, Wed Aug 4 03:33:53 2004 UTC vs.
Revision 1.89 by root, Fri Aug 13 22:38:57 2004 UTC

172 nrow = TermWin.nrow; 172 nrow = TermWin.nrow;
173 173
174 if (ncol == prev_ncol && nrow == prev_nrow) 174 if (ncol == prev_ncol && nrow == prev_nrow)
175 return; 175 return;
176 176
177 // we need at least two lines for wrapping to work correctly
178 if (nrow + TermWin.saveLines < 2)
179 {
180 TermWin.saveLines++;
181 prev_nrow--;
182 TermWin.nscrolled++;
183 }
184
177 want_refresh = 1; 185 want_refresh = 1;
178 186
187 prev_total_rows = prev_nrow + TermWin.saveLines;
179 total_rows = nrow + TermWin.saveLines; 188 total_rows = nrow + TermWin.saveLines;
180 prev_total_rows = prev_nrow + TermWin.saveLines;
181 189
182 screen.tscroll = 0; 190 screen.tscroll = 0;
183 screen.bscroll = nrow - 1; 191 screen.bscroll = nrow - 1;
184 192
185 if (!talloc) 193 if (!talloc)
186 { 194 {
187 talloc = new rxvt_salloc (ncol * sizeof (text_t)); 195 talloc = new rxvt_salloc (ncol * sizeof (text_t));
188 ralloc = new rxvt_salloc (ncol * sizeof (rend_t)); 196 ralloc = new rxvt_salloc (ncol * sizeof (rend_t));
189 } 197 }
190 198
191 if (prev_nrow == 0) 199 if (!screen.text)
192 { 200 {
193 /* 201 /*
194 * first time called so just malloc everything: don't rely on realloc 202 * first time called so just malloc everything: don't rely on realloc
195 * Note: this is still needed so that all the scrollback lines are NULL 203 * Note: this is still needed so that all the scrollback lines are NULL
196 */ 204 */
705 if (j > 0) 713 if (j > 0)
706 { 714 {
707 /* A: scroll up */ 715 /* A: scroll up */
708 716
709 /* A1: Copy lines that will get clobbered by the rotation */ 717 /* A1: Copy lines that will get clobbered by the rotation */
718 memcpy (buf_text, screen.text + row1, count * sizeof (text_t *));
719 memcpy (buf_rend, screen.rend + row1, count * sizeof (rend_t *));
720
721 /* A2: Rotate lines */
722 i = row2 - row1 - count + 1;
723 memmove (screen.tlen + row1, screen.tlen + row1 + count, i * sizeof (int16_t));
724 memmove (screen.text + row1, screen.text + row1 + count, i * sizeof (text_t *));
725 memmove (screen.rend + row1, screen.rend + row1 + count, i * sizeof (rend_t *));
726
727 j = row2 - count + 1, i = count;
728 }
729 else /* if (j < 0) */
730 {
731 /* B: scroll down */
732
733 /* B1: Copy lines that will get clobbered by the rotation */
710 for (i = 0, j = row1; i < count; i++, j++) 734 for (i = 0, j = row2; i < count; i++, j--)
711 { 735 {
712 buf_text[i] = screen.text[j]; 736 buf_text[i] = screen.text[j];
713 buf_rend[i] = screen.rend[j]; 737 buf_rend[i] = screen.rend[j];
714 } 738 }
715 739
716 /* A2: Rotate lines */ 740 /* B2: Rotate lines */
717 for (j = row1, i = j + count; i <= row2; i++, j++) 741 for (j = row2, i = j - count; i >= row1; i--, j--)
718 { 742 {
719 screen.tlen[j] = screen.tlen[i]; 743 screen.tlen[j] = screen.tlen[i];
720 screen.text[j] = screen.text[i]; 744 screen.text[j] = screen.text[i];
721 screen.rend[j] = screen.rend[i]; 745 screen.rend[j] = screen.rend[i];
722 } 746 }
723 747
724 j = row2 - count + 1, i = count;
725 }
726 else /* if (j < 0) */
727 {
728 /* B: scroll down */
729
730 /* B1: Copy lines that will get clobbered by the rotation */
731 for (i = 0, j = row2; i < count; i++, j--)
732 {
733 buf_text[i] = screen.text[j];
734 buf_rend[i] = screen.rend[j];
735 }
736
737 /* B2: Rotate lines */
738 for (j = row2, i = j - count; i >= row1; i--, j--)
739 {
740 screen.tlen[j] = screen.tlen[i];
741 screen.text[j] = screen.text[i];
742 screen.rend[j] = screen.rend[i];
743 }
744
745 j = row1, i = count; 748 j = row1, i = count;
746 count = -count; 749 count = -count;
747 } 750 }
748 751
749 /* C: Resurrect lines */ 752 /* C: Resurrect lines */
753 memset (screen.tlen + j, 0, i * sizeof (int16_t));
754 memcpy (screen.text + j, buf_text, i * sizeof (text_t *));
755 memcpy (screen.rend + j, buf_rend, i * sizeof (text_t *));
756 if (!spec) /* line length may not equal TermWin.ncol */
750 for (; i--; j++) 757 for (; i--; j++)
751 {
752 screen.tlen[j] = 0;
753 screen.text[j] = buf_text[i];
754 screen.rend[j] = buf_rend[i];
755
756 if (!spec) /* line length may not equal TermWin.ncol */
757 scr_blank_screen_mem (screen.text, screen.rend, (unsigned int)j, rstyle); 758 scr_blank_screen_mem (screen.text, screen.rend, (unsigned int)j, rstyle);
758 }
759 759
760 return count; 760 return count;
761} 761}
762 762
763/* ------------------------------------------------------------------------- */ 763/* ------------------------------------------------------------------------- */
781 781
782 D_SCREEN ((stderr, "rxvt_scr_add_lines (%d,%d)", nlines, len)); 782 D_SCREEN ((stderr, "rxvt_scr_add_lines (%d,%d)", nlines, len));
783 ZERO_SCROLLBACK (); 783 ZERO_SCROLLBACK ();
784 if (nlines > 0) 784 if (nlines > 0)
785 { 785 {
786 nlines += (screen.cur.row - screen.bscroll); 786 nlines += screen.cur.row - screen.bscroll;
787 if ((nlines > 0) 787 if ((nlines > 0)
788 && (screen.tscroll == 0) 788 && (screen.tscroll == 0)
789 && (screen.bscroll == (TermWin.nrow - 1))) 789 && (screen.bscroll == (TermWin.nrow - 1)))
790 { 790 {
791 /* _at least_ this many lines need to be scrolled */ 791 /* _at least_ this many lines need to be scrolled */
792 scr_scroll_text (screen.tscroll, screen.bscroll, nlines, 0); 792 scr_scroll_text (screen.tscroll, screen.bscroll, nlines, 0);
793 screen.cur.row -= nlines; 793 screen.cur.row -= nlines;
794 } 794 }
795 } 795 }
796
796#ifdef DEBUG_STRICT 797#ifdef DEBUG_STRICT
797 assert (screen.cur.col < last_col); 798 assert (screen.cur.col < last_col);
798 assert ((screen.cur.row < TermWin.nrow) 799 assert ((screen.cur.row < TermWin.nrow)
799 && (screen.cur.row >= - (int32_t)TermWin.nscrolled)); 800 && (screen.cur.row >= - (int32_t)TermWin.nscrolled));
800#else /* drive with your eyes closed */ 801#else /* drive with your eyes closed */
871 scr_insdel_chars (1, INSERT); 872 scr_insdel_chars (1, INSERT);
872 873
873 // rely on wcwidth to tell us the character width, at least for non-latin1 874 // rely on wcwidth to tell us the character width, at least for non-latin1
874 // do wcwidth before further replacements, as wcwidth says that line-drawing 875 // do wcwidth before further replacements, as wcwidth says that line-drawing
875 // characters have width -1 (DOH!) on GNU/Linux sometimes. 876 // characters have width -1 (DOH!) on GNU/Linux sometimes.
876 int width = c < 256 ? 1 : wcwidth (c); 877 int width = c < 0x100 ? 1 : wcwidth (c);
877 878
878 if (charsets[screen.charset] == '0') // DEC SPECIAL 879 if (charsets[screen.charset] == '0') // DEC SPECIAL
879 { 880 {
880 // vt100 special graphics and line drawing 881 // vt100 special graphics and line drawing
881 static uint16_t vt100_0[32] = { // 5f .. 7e 882 static uint16_t vt100_0[32] = { // 5f .. 7e
1292 break; 1293 break;
1293 default: 1294 default:
1294 return; 1295 return;
1295 } 1296 }
1296 1297
1297 refresh_type |= REFRESH_BOUNDS;
1298
1299 if (selection.op && current_screen == selection.screen 1298 if (selection.op && current_screen == selection.screen
1300 && ((selection.beg.row >= row && selection.beg.row <= row + num) 1299 && ((selection.beg.row >= row && selection.beg.row <= row + num)
1301 || (selection.end.row >= row 1300 || (selection.end.row >= row
1302 && selection.end.row <= row + num))) 1301 && selection.end.row <= row + num)))
1303 CLEAR_SELECTION (); 1302 CLEAR_SELECTION ();
1785 1784
1786 for (i = rc[PART_BEG].row; i <= rc[PART_END].row; i++) 1785 for (i = rc[PART_BEG].row; i <= rc[PART_END].row; i++)
1787 fill_text (&drawn_text[i][rc[PART_BEG].col], 0, rc[PART_END].col - rc[PART_BEG].col + 1); 1786 fill_text (&drawn_text[i][rc[PART_BEG].col], 0, rc[PART_END].col - rc[PART_BEG].col + 1);
1788 1787
1789 if (refresh) 1788 if (refresh)
1790 scr_refresh (SLOW_REFRESH | REFRESH_BOUNDS); 1789 scr_refresh (SLOW_REFRESH);
1791} 1790}
1792 1791
1793/* ------------------------------------------------------------------------- */ 1792/* ------------------------------------------------------------------------- */
1794/* 1793/*
1795 * Refresh the entire screen 1794 * Refresh the entire screen
1830 * direction should be UP or DN 1829 * direction should be UP or DN
1831 */ 1830 */
1832int 1831int
1833rxvt_term::scr_page (enum page_dirn direction, int nlines) 1832rxvt_term::scr_page (enum page_dirn direction, int nlines)
1834{ 1833{
1835 int n; 1834 int n;
1836 uint16_t oldviewstart; 1835 uint16_t oldviewstart;
1837 1836
1838 D_SCREEN ((stderr, "rxvt_scr_page (%s, %d) view_start:%d", ((direction == UP) ? "UP" : "DN"), nlines, TermWin.view_start)); 1837 D_SCREEN ((stderr, "rxvt_scr_page (%s, %d) view_start:%d", ((direction == UP) ? "UP" : "DN"), nlines, TermWin.view_start));
1839#ifdef DEBUG_STRICT 1838#ifdef DEBUG_STRICT
1840 assert ((nlines >= 0) && (nlines <= TermWin.nrow)); 1839 assert ((nlines >= 0) && (nlines <= TermWin.nrow));
1841#endif 1840#endif
1937 ((Y) >= (X)->min_char_or_byte2 && (Y) <= (X)->max_char_or_byte2) 1936 ((Y) >= (X)->min_char_or_byte2 && (Y) <= (X)->max_char_or_byte2)
1938 1937
1939void 1938void
1940rxvt_term::scr_refresh (unsigned char refresh_type) 1939rxvt_term::scr_refresh (unsigned char refresh_type)
1941{ 1940{
1942 unsigned char clearfirst, /* first character writes before cell */
1943 clearlast, /* last character writes beyond cell */
1944 must_clear, /* use draw_string not draw_image_string */ 1941 unsigned char must_clear, /* use draw_string not draw_image_string */
1945 rvid, /* reverse video this position */ 1942 rvid, /* reverse video this position */
1946 showcursor; /* show the cursor */ 1943 showcursor; /* show the cursor */
1947 int16_t col, row, /* column/row we're processing */ 1944 int16_t col, row, /* column/row we're processing */
1948 ocrow; /* old cursor row */ 1945 ocrow; /* old cursor row */
1949 int i, /* tmp */ 1946 int i, /* tmp */
1958 return; 1955 return;
1959 1956
1960 /* 1957 /*
1961 * A: set up vars 1958 * A: set up vars
1962 */ 1959 */
1963 clearfirst = clearlast = must_clear = 0; 1960 must_clear = 0;
1964 1961
1965 refresh_count = 0; 1962 refresh_count = 0;
1966 1963
1967 row_offset = TermWin.saveLines - TermWin.view_start; 1964 row_offset = TermWin.saveLines - TermWin.view_start;
1968
1969 if ((refresh_type & REFRESH_BOUNDS))
1970 {
1971 clearfirst = clearlast = 1;
1972 refresh_type &= ~REFRESH_BOUNDS;
1973 }
1974 1965
1975#ifdef XPM_BACKGROUND 1966#ifdef XPM_BACKGROUND
1976 must_clear |= (bgPixmap.pixmap != None); 1967 must_clear |= (bgPixmap.pixmap != None);
1977#endif 1968#endif
1978#ifdef TRANSPARENT 1969#ifdef TRANSPARENT
2331 2322
2332 /* 2323 /*
2333 * H: cleanup selection 2324 * H: cleanup selection
2334 */ 2325 */
2335 scr_reverse_selection (); 2326 scr_reverse_selection ();
2336
2337 /*
2338 * I: other general cleanup
2339 */
2340#if 0
2341 if (clearfirst && TermWin.int_bwidth)
2342 /*
2343 * clear the whole screen height, note that width == 0 is treated
2344 * specially by XClearArea
2345 */
2346 XClearArea (display->display, TermWin.vt, 0, 0,
2347 (unsigned int)TermWin.int_bwidth,
2348 (unsigned int)TermWin_TotalHeight (), False);
2349
2350 if (clearlast && TermWin.int_bwidth)
2351 /*
2352 * clear the whole screen height, note that width == 0 is treated
2353 * specially by XClearArea
2354 */
2355 XClearArea (display->display, TermWin.vt,
2356 TermWin.width + TermWin.int_bwidth, 0,
2357 (unsigned int)TermWin.int_bwidth,
2358 (unsigned int)TermWin_TotalHeight (), False);
2359#endif
2360 2327
2361 if (refresh_type & SMOOTH_REFRESH) 2328 if (refresh_type & SMOOTH_REFRESH)
2362 XFlush (display->display); 2329 XFlush (display->display);
2363 2330
2364 num_scr = 0; 2331 num_scr = 0;
2600 if (ct.encoding == 0) 2567 if (ct.encoding == 0)
2601 { 2568 {
2602 D_SELECT ((stderr, "rxvt_selection_paste: property didn't exist!")); 2569 D_SELECT ((stderr, "rxvt_selection_paste: property didn't exist!"));
2603 break; 2570 break;
2604 } 2571 }
2572 else if (ct.encoding == xa[XA_INCR])
2573 {
2574 // INCR selection, start handshake
2575 XDeleteProperty (display->display, win, prop);
2576 selection_wait = Sel_incr;
2577 incr_ev.start (NOW + 10);
2578 break;
2579 }
2605 2580
2606 if (ct.value == NULL) 2581 if (ct.value == NULL)
2607 { 2582 {
2608 D_SELECT ((stderr, "rxvt_selection_paste: property shooting blanks!")); 2583 D_SELECT ((stderr, "rxvt_selection_paste: property shooting blanks!"));
2609 continue; 2584 continue;
2670 * INCR support originally provided by Paul Sheer <psheer@obsidian.co.za> 2645 * INCR support originally provided by Paul Sheer <psheer@obsidian.co.za>
2671 */ 2646 */
2672void 2647void
2673rxvt_term::selection_property (Window win, Atom prop) 2648rxvt_term::selection_property (Window win, Atom prop)
2674{ 2649{
2675 int reget_time = 0; 2650 if (prop == None || selection_wait != Sel_incr)
2676
2677 if (prop == None)
2678 return; 2651 return;
2679 2652
2680 D_SELECT ((stderr, "rxvt_selection_property (%08lx, %lu)", win, (unsigned long)prop));
2681 if (selection_wait == Sel_normal)
2682 {
2683 int a, afmt;
2684 Atom atype;
2685 unsigned long bytes_after, nitems;
2686 unsigned char *s = NULL;
2687
2688 a = XGetWindowProperty (display->display, win, prop, 0L, 1L, False,
2689 xa[XA_INCR], &atype, &afmt, &nitems,
2690 &bytes_after, &s);
2691 if (s)
2692 XFree (s);
2693 if (a != Success)
2694 return;
2695
2696#ifndef __CYGWIN32__
2697 if (atype == xa[XA_INCR])
2698 { /* start an INCR transfer */
2699 D_SELECT ((stderr, "rxvt_selection_property: INCR: starting transfer"));
2700 XDeleteProperty (display->display, win, prop);
2701 XFlush (display->display);
2702 reget_time = 1;
2703 selection_wait = Sel_incr;
2704 }
2705#endif
2706
2707 }
2708 else if (selection_wait == Sel_incr)
2709 {
2710 reget_time = 1;
2711
2712 if (selection_paste (win, prop, True) == -1) 2653 if (selection_paste (win, prop, 1) > 0)
2713 {
2714 D_SELECT ((stderr, "rxvt_selection_property: INCR: clean end"));
2715 selection_wait = Sel_none;
2716 incr_ev.stop ();
2717 }
2718 }
2719 if (reget_time) /* received more data so reget time */
2720 incr_ev.start (NOW + 10); 2654 incr_ev.start (NOW + 10);
2655 else
2656 {
2657 selection_wait = Sel_none;
2658 incr_ev.stop ();
2659 }
2721} 2660}
2722 2661
2723/* ------------------------------------------------------------------------- */ 2662/* ------------------------------------------------------------------------- */
2724/* 2663/*
2725 * Request the current selection: 2664 * Request the current selection:
3430 (8 * sizeof (target_list[0])), PropModeReplace, 3369 (8 * sizeof (target_list[0])), PropModeReplace,
3431 (unsigned char *)target_list, 3370 (unsigned char *)target_list,
3432 target - target_list); 3371 target - target_list);
3433 ev.property = rq.property; 3372 ev.property = rq.property;
3434 } 3373 }
3374#if TODO // TODO
3435 else if (rq.target == xa[XA_MULTIPLE]) 3375 else if (rq.target == xa[XA_MULTIPLE])
3436 { 3376 {
3437 /* TODO: Handle MULTIPLE */ 3377 /* TODO: Handle MULTIPLE */
3438 } 3378 }
3379#endif
3439 else if (rq.target == xa[XA_TIMESTAMP] && selection.text) 3380 else if (rq.target == xa[XA_TIMESTAMP] && selection.text)
3440 { 3381 {
3441 XChangeProperty (display->display, rq.requestor, rq.property, XA_INTEGER, 3382 XChangeProperty (display->display, rq.requestor, rq.property, XA_INTEGER,
3442 (8 * sizeof (Time)), PropModeReplace, 3383 (8 * sizeof (Time)), PropModeReplace,
3443 (unsigned char *)&selection_time, 1); 3384 (unsigned char *)&selection_time, 1);

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines