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.41 by pcg, Sun Feb 29 15:31:56 2004 UTC vs.
Revision 1.43 by pcg, Wed Mar 3 02:59:53 2004 UTC

889 // rely on wcwidth to tell us the character width, at least for non-ascii 889 // rely on wcwidth to tell us the character width, at least for non-ascii
890 int width = c <= 128 ? 1 : wcwidth (c); 890 int width = c <= 128 ? 1 : wcwidth (c);
891 891
892 // width -1 characters (e.g. combining chars) are ignored currently. 892 // width -1 characters (e.g. combining chars) are ignored currently.
893 if (width > 0) 893 if (width > 0)
894 {
894 do 895 do
895 { 896 {
896 stp[screen.cur.col] = c; 897 stp[screen.cur.col] = c;
897 srp[screen.cur.col] = rend; 898 srp[screen.cur.col] = rend;
898 899
899 if (screen.cur.col < last_col - 1) 900 if (screen.cur.col < last_col - 1)
900 screen.cur.col++; 901 screen.cur.col++;
901 else 902 else
902 { 903 {
903 screen.tlen[row] = last_col; 904 screen.tlen[row] = last_col;
904 if (screen.flags & Screen_Autowrap) 905 if (screen.flags & Screen_Autowrap)
905 screen.flags |= Screen_WrapNext; 906 screen.flags |= Screen_WrapNext;
906 break; 907 break;
907 } 908 }
908 909
909 c = NOCHAR; 910 c = NOCHAR;
910 } 911 }
911 while (--width > 0); 912 while (--width > 0);
913
914 // pad with spaces when overwriting wide character with smaller one
915 for (int c = screen.cur.col; stp[c] == NOCHAR && c < last_col; c++)
916 {
917 stp[c] = ' ';
918 srp[c] = rend;
919 }
920 }
912 else 921 else
913 (void)0; /* handle combining character etc. here. */ 922 (void)0; /* handle combining character etc. here. */
914 } 923 }
915 924
916 if (screen.tlen[row] != -1) /* XXX: think about this */ 925 if (screen.tlen[row] != -1) /* XXX: think about this */
1098 else 1107 else
1099 screen.cur.row = row; 1108 screen.cur.row = row;
1100 } 1109 }
1101 MAX_IT (screen.cur.row, 0); 1110 MAX_IT (screen.cur.row, 0);
1102 MIN_IT (screen.cur.row, (int32_t)TermWin.nrow - 1); 1111 MIN_IT (screen.cur.row, (int32_t)TermWin.nrow - 1);
1112
1113 while (screen.cur.col > 0
1114 && screen.text[screen.cur.row + TermWin.saveLines][screen.cur.col] == NOCHAR)
1115 screen.cur.col--;
1103} 1116}
1104 1117
1105/* ------------------------------------------------------------------------- */ 1118/* ------------------------------------------------------------------------- */
1106/* 1119/*
1107 * direction should be UP or DN 1120 * direction should be UP or DN
2054 int ypixel = (int)Row2Pixel (row); 2067 int ypixel = (int)Row2Pixel (row);
2055 2068
2056 for (col = 0; col < TermWin.ncol; col++) 2069 for (col = 0; col < TermWin.ncol; col++)
2057 { 2070 {
2058 /* compare new text with old - if exactly the same then continue */ 2071 /* compare new text with old - if exactly the same then continue */
2072 if (stp[col] == dtp[col] /* Must match characters to skip. */
2073 && (srp[col] == drp[col] /* Either rendition the same or */
2074 || (stp[col] == ' ' /* space w/ no background change */
2075 && GET_BGATTR (srp[col]) == GET_BGATTR (drp[col]))))
2076 continue;
2077
2078 // redraw one or more characters
2079
2080 // seek to the beginning if wide characters
2081 while (stp[col] == NOCHAR && col > 0)
2082 --col;
2083
2059 rend_t rend = srp[col]; /* screen rendition (target rendtion) */ 2084 rend_t rend = srp[col]; /* screen rendition (target rendtion) */
2060
2061 if (stp[col] == dtp[col] /* Must match characters to skip. */
2062 && (rend == drp[col] /* Either rendition the same or */
2063 || (stp[col] == ' ' /* space w/ no background change */
2064 && GET_BGATTR (rend) == GET_BGATTR (drp[col]))))
2065 continue;
2066
2067 text_t *text = stp + col; 2085 text_t *text = stp + col;
2068 int count = 1; 2086 int count = 1;
2069 2087
2070 /* redraw one or more characters */
2071
2072 dtp[col] = stp[col]; 2088 dtp[col] = stp[col];
2073 drp[col] = rend; 2089 drp[col] = rend;
2074
2075 if (*text == NOCHAR) // never start redrawing at invisible characters. */
2076 continue;
2077 2090
2078 int xpixel = Col2Pixel (col); 2091 int xpixel = Col2Pixel (col);
2079 2092
2080 // this loop looks very messy, it can probably be optimized 2093 // this loop looks very messy, it can probably be optimized
2081 // and cleaned a bit by you? 2094 // and cleaned a bit by you?
2197 else 2210 else
2198 font->draw (*TermWin.drawable, xpixel, ypixel, text, count, fore, back); 2211 font->draw (*TermWin.drawable, xpixel, ypixel, text, count, fore, back);
2199 2212
2200 if ((rend & RS_Uline) && (font->descent > 1)) 2213 if ((rend & RS_Uline) && (font->descent > 1))
2201 XDrawLine (display->display, drawBuffer, TermWin.gc, 2214 XDrawLine (display->display, drawBuffer, TermWin.gc,
2202 xpixel, ypixel + font->ascent + 1, 2215 xpixel, ypixel + font->ascent + 1,
2203 xpixel + Width2Pixel (count) - 1, ypixel + font->ascent + 1); 2216 xpixel + Width2Pixel (count) - 1, ypixel + font->ascent + 1);
2204 } /* for (col....) */ 2217 } /* for (col....) */
2205 } /* for (row....) */ 2218 } /* for (row....) */
2206 2219
2207 /* 2220 /*
2208 * G: cleanup cursor and display outline cursor if necessary 2221 * G: cleanup cursor and display outline cursor if necessary
2228 while (oldcursor.col + cursorwidth < TermWin.ncol 2241 while (oldcursor.col + cursorwidth < TermWin.ncol
2229 && drawn_text[oldcursor.row][oldcursor.col + cursorwidth] == NOCHAR) 2242 && drawn_text[oldcursor.row][oldcursor.col + cursorwidth] == NOCHAR)
2230 cursorwidth++; 2243 cursorwidth++;
2231 2244
2232 XDrawRectangle (display->display, drawBuffer, TermWin.gc, 2245 XDrawRectangle (display->display, drawBuffer, TermWin.gc,
2233 Col2Pixel (oldcursor.col), 2246 Col2Pixel (oldcursor.col),
2234 Row2Pixel (oldcursor.row), 2247 Row2Pixel (oldcursor.row),
2235 (unsigned int) (Width2Pixel (cursorwidth) - 1), 2248 (unsigned int) (Width2Pixel (cursorwidth) - 1),
2236 (unsigned int) (Height2Pixel (1) - TermWin.lineSpace - 1)); 2249 (unsigned int) (Height2Pixel (1) - TermWin.lineSpace - 1));
2237 } 2250 }
2238 } 2251 }
2239 2252
2240 /* 2253 /*
2241 * H: cleanup selection 2254 * H: cleanup selection
2249 /* 2262 /*
2250 * clear the whole screen height, note that width == 0 is treated 2263 * clear the whole screen height, note that width == 0 is treated
2251 * specially by XClearArea 2264 * specially by XClearArea
2252 */ 2265 */
2253 XClearArea (display->display, TermWin.vt, 0, 0, 2266 XClearArea (display->display, TermWin.vt, 0, 0,
2254 (unsigned int)TermWin.int_bwidth, 2267 (unsigned int)TermWin.int_bwidth,
2255 (unsigned int)TermWin_TotalHeight (), False); 2268 (unsigned int)TermWin_TotalHeight (), False);
2269
2256 if (clearlast && TermWin.int_bwidth) 2270 if (clearlast && TermWin.int_bwidth)
2257 /* 2271 /*
2258 * clear the whole screen height, note that width == 0 is treated 2272 * clear the whole screen height, note that width == 0 is treated
2259 * specially by XClearArea 2273 * specially by XClearArea
2260 */ 2274 */
2261 XClearArea (display->display, TermWin.vt, 2275 XClearArea (display->display, TermWin.vt,
2262 TermWin.width + TermWin.int_bwidth, 0, 2276 TermWin.width + TermWin.int_bwidth, 0,
2263 (unsigned int)TermWin.int_bwidth, 2277 (unsigned int)TermWin.int_bwidth,
2264 (unsigned int)TermWin_TotalHeight (), False); 2278 (unsigned int)TermWin_TotalHeight (), False);
2279
2265 if (refresh_type & SMOOTH_REFRESH) 2280 if (refresh_type & SMOOTH_REFRESH)
2266 XSync (display->display, False); 2281 XSync (display->display, False);
2267 2282
2268 num_scr = 0; 2283 num_scr = 0;
2269 num_scr_allow = 1; 2284 num_scr_allow = 1;
2293 } 2308 }
2294} 2309}
2295 2310
2296/* ------------------------------------------------------------------------- */ 2311/* ------------------------------------------------------------------------- */
2297void 2312void
2298rxvt_term::scr_clear () 2313rxvt_term::scr_clear (bool really)
2299{ 2314{
2300 if (!TermWin.mapped) 2315 if (!TermWin.mapped)
2301 return; 2316 return;
2302 2317
2303 num_scr_allow = 0; 2318 num_scr_allow = 0;
2304 want_refresh = 1; 2319 want_refresh = 1;
2320
2305#ifdef TRANSPARENT 2321#ifdef TRANSPARENT
2306 if ((Options & Opt_transparent) && (am_pixmap_trans == 0)) 2322 if ((Options & Opt_transparent) && (am_pixmap_trans == 0))
2307 { 2323 {
2308 int i; 2324 int i;
2309 2325
2316 if (TermWin.parent[i] != None) 2332 if (TermWin.parent[i] != None)
2317 XClearWindow (display->display, TermWin.parent[i]); 2333 XClearWindow (display->display, TermWin.parent[i]);
2318 } 2334 }
2319#endif 2335#endif
2320 2336
2337 if (really)
2321 XClearWindow (display->display, TermWin.vt); 2338 XClearWindow (display->display, TermWin.vt);
2322} 2339}
2323 2340
2324/* ------------------------------------------------------------------------- */ 2341/* ------------------------------------------------------------------------- */
2325void 2342void
2326rxvt_term::scr_reverse_selection () 2343rxvt_term::scr_reverse_selection ()
2327{ 2344{
2328 int i, col, row, end_row;
2329 rend_t *srp;
2330
2331 if (selection.op && current_screen == selection.screen) 2345 if (selection.op && current_screen == selection.screen)
2332 { 2346 {
2333 end_row = TermWin.saveLines - TermWin.view_start; 2347 int end_row = TermWin.saveLines - TermWin.view_start;
2334 i = selection.beg.row + TermWin.saveLines; 2348 int i = selection.beg.row + TermWin.saveLines;
2335 row = selection.end.row + TermWin.saveLines; 2349 int col, row = selection.end.row + TermWin.saveLines;
2350 rend_t *srp;
2351
2336 if (i >= end_row) 2352 if (i >= end_row)
2337 col = selection.beg.col; 2353 col = selection.beg.col;
2338 else 2354 else
2339 { 2355 {
2340 col = 0; 2356 col = 0;
2341 i = end_row; 2357 i = end_row;
2342 } 2358 }
2359
2343 end_row += TermWin.nrow; 2360 end_row += TermWin.nrow;
2344 for (; i < row && i < end_row; i++, col = 0) 2361 for (; i < row && i < end_row; i++, col = 0)
2345 for (srp = screen.rend[i]; col < TermWin.ncol; col++) 2362 for (srp = screen.rend[i]; col < TermWin.ncol; col++)
2346 srp[col] ^= RS_RVid; 2363 srp[col] ^= RS_RVid;
2364
2347 if (i == row && i < end_row) 2365 if (i == row && i < end_row)
2348 for (srp = screen.rend[i]; col < selection.end.col; col++) 2366 for (srp = screen.rend[i]; col < selection.end.col; col++)
2349 srp[col] ^= RS_RVid; 2367 srp[col] ^= RS_RVid;
2350 } 2368 }
2351} 2369}
2713 * EXT: button 1 or 3 release 2731 * EXT: button 1 or 3 release
2714 */ 2732 */
2715void 2733void
2716rxvt_term::selection_make (Time tm) 2734rxvt_term::selection_make (Time tm)
2717{ 2735{
2718 int i, col, end_col, row, end_row; 2736 int i, col, end_col, row, end_row;
2719 unsigned char *new_selection_text; 2737 unsigned char *new_selection_text;
2720 char *str; 2738 char *str;
2721 text_t *t; 2739 text_t *t;
2722#ifdef ACS_ASCII
2723 rend_t *re;
2724#endif
2725 2740
2726 D_SELECT ((stderr, "rxvt_selection_make (): selection.op=%d, selection.clicks=%d", selection.op, selection.clicks)); 2741 D_SELECT ((stderr, "rxvt_selection_make (): selection.op=%d, selection.clicks=%d", selection.op, selection.clicks));
2727 switch (selection.op) 2742 switch (selection.op)
2728 { 2743 {
2729 case SELECTION_CONT: 2744 case SELECTION_CONT:
2742 2757
2743 if (selection.clicks == 4) 2758 if (selection.clicks == 4)
2744 return; /* nothing selected, go away */ 2759 return; /* nothing selected, go away */
2745 2760
2746 i = (selection.end.row - selection.beg.row + 1) * (TermWin.ncol + 1) + 1; 2761 i = (selection.end.row - selection.beg.row + 1) * (TermWin.ncol + 1) + 1;
2747 str = (char *)rxvt_malloc (i * MB_CUR_MAX + 1); 2762 str = (char *)rxvt_malloc ((i + 2) * MB_CUR_MAX + 1);
2748 2763
2749 new_selection_text = (unsigned char *)str; 2764 new_selection_text = (unsigned char *)str;
2750 2765
2751 col = selection.beg.col; 2766 col = selection.beg.col;
2752 MAX_IT (col, 0); 2767 MAX_IT (col, 0);
2753 row = selection.beg.row + TermWin.saveLines; 2768 row = selection.beg.row + TermWin.saveLines;
2754 end_row = selection.end.row + TermWin.saveLines; 2769 end_row = selection.end.row + TermWin.saveLines;
2770 struct mbstate mbs;
2755 2771
2756 for (; row <= end_row; row++, col = 0) 2772 for (; row <= end_row; row++, col = 0)
2757 { 2773 {
2758 t = & (screen.text[row][col]); 2774 t = & (screen.text[row][col]);
2759 2775
2768 for (; col < end_col; col++) 2784 for (; col < end_col; col++)
2769 if (*t == NOCHAR) 2785 if (*t == NOCHAR)
2770 t++; 2786 t++;
2771 else 2787 else
2772 { 2788 {
2773 int len = wctomb (str, *t++); 2789 int len = wcrtomb (str, *t++, mbs);
2774 if (len > 0) 2790 if (len > 0)
2775 str += len; 2791 str += len;
2776 } 2792 }
2777 2793
2778 if (screen.tlen[row] != -1 && row != end_row) 2794 if (screen.tlen[row] != -1 && row != end_row)

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines