The R Project SVN R

Rev

Rev 51627 | Rev 51958 | Go to most recent revision | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 51627 Rev 51948
Line 308... Line 308...
308
 
308
 
309
extern int R_HistorySize;  /* from Defn.h */
309
extern int R_HistorySize;  /* from Defn.h */
310
 
310
 
311
ConsoleData
311
ConsoleData
312
newconsoledata(font f, int rows, int cols, int bufbytes, int buflines,
312
newconsoledata(font f, int rows, int cols, int bufbytes, int buflines,
313
	       rgb *guiColors, int kind, int buffered)
313
	       rgb *guiColors, int kind, int buffered, int cursor_blink)
314
{
314
{
315
    ConsoleData p;
315
    ConsoleData p;
316
 
316
 
317
    initapp(0, 0);
317
    initapp(0, 0);
318
    p = (ConsoleData) malloc(sizeof(struct structConsoleData));
318
    p = (ConsoleData) malloc(sizeof(struct structConsoleData));
Line 358... Line 358...
358
    p->mx0 = 5;
358
    p->mx0 = 5;
359
    p->mx1 = 14;
359
    p->mx1 = 14;
360
    p->sel = 0;
360
    p->sel = 0;
361
    p->input = 0;
361
    p->input = 0;
362
    p->lazyupdate = buffered;
362
    p->lazyupdate = buffered;
-
 
363
    p->cursor_blink = cursor_blink;
363
    return (p);
364
    return (p);
364
}
365
}
365
 
366
 
366
static int col_to_pos(ConsoleData p, int x)
367
static int col_to_pos(ConsoleData p, int x)
367
{
368
{
Line 474... Line 475...
474
}
475
}
475
 
476
 
476
#define WLHELPER(a, b, c, d) writelineHelper(p, a, b, c, d, j, len, s)
477
#define WLHELPER(a, b, c, d) writelineHelper(p, a, b, c, d, j, len, s)
477
 
478
 
478
/* write line i of the buffer at row j on bitmap */
479
/* write line i of the buffer at row j on bitmap */
479
static int writeline(ConsoleData p, int i, int j)
480
static int writeline(control c, ConsoleData p, int i, int j)
480
{
481
{
481
    wchar_t *s, *stmp, *p0;
482
    wchar_t *s, *stmp, *p0;
482
    int   insel, len, col1, d;
483
    int   insel, len, col1, d;
483
    int   c1, c2, c3, x0, y0, x1, y1;
484
    int   c1, c2, c3, x0, y0, x1, y1;
484
    rect r;
485
    rect r;
Line 535... Line 536...
535
	WLHELPER(0, col1, fg, bg);
536
	WLHELPER(0, col1, fg, bg);
536
    /* This is the cursor, and it may need to be variable-width */
537
    /* This is the cursor, and it may need to be variable-width */
537
    if ((p->r >= 0) && (CURCOL >= FC) && (CURCOL < FC + COLS) &&
538
    if ((p->r >= 0) && (CURCOL >= FC) && (CURCOL < FC + COLS) &&
538
	(i == NUMLINES - 1) && (p->sel == 0 || !intersect_input(p, 0))) {
539
	(i == NUMLINES - 1) && (p->sel == 0 || !intersect_input(p, 0))) {
539
	if (!p->overwrite) {
540
	if (!p->overwrite) {
-
 
541
	    if (p->cursor_blink) {
-
 
542
	    	setcaret(c, BORDERX + (CURCOL - FC) * FW, BORDERY + j * FH, 
-
 
543
	    	            p->cursor_blink == 1 ? 1 : FW/4, FH);
-
 
544
	    	showcaret(c, 1);
-
 
545
	    } else showcaret(c, 0);
-
 
546
	    
-
 
547
	    if (p->cursor_blink < 2) {
540
	    r = rect(BORDERX + (CURCOL - FC) * FW, BORDERY + j * FH, FW/4, FH);
548
	    	r = rect(BORDERX + (CURCOL - FC) * FW, BORDERY + j * FH, FW/4, FH);
541
	    gfillrect(p->bm, highlight, r);
549
	    	gfillrect(p->bm, highlight, r);
-
 
550
	    }
542
	} else if(mbcslocale) { /* determine the width of the current char */
551
	} else if(mbcslocale) { /* determine the width of the current char */
543
	    int w0;
552
	    int w0;
544
	    wchar_t *P = s, wc = 0, nn[2] = L" ";
553
	    wchar_t *P = s, wc = 0, nn[2] = L" ";
545
	    for (w0 = 0; w0 <= CURCOL; P++) {
554
	    for (w0 = 0; w0 <= CURCOL; P++) {
546
		wc = *P;
555
		wc = *P;
Line 548... Line 557...
548
		w0 += Ri18n_wcwidth(wc);
557
		w0 += Ri18n_wcwidth(wc);
549
	    }
558
	    }
550
	    /* term string '\0' box width = 1 fix */
559
	    /* term string '\0' box width = 1 fix */
551
	    w0 = wc ? Ri18n_wcwidth(wc) : 1;
560
	    w0 = wc ? Ri18n_wcwidth(wc) : 1;
552
	    nn[0] = wc;
561
	    nn[0] = wc;
-
 
562
	    if (p->cursor_blink) {
-
 
563
	    	setcaret(c, BORDERX + (CURCOL - FC) * FW, BORDERY + j * FH, 
-
 
564
	    		    p->cursor_blink == 1 ? 1 : FW/4, FH);
-
 
565
	    	showcaret(c, 1);
-
 
566
	    }
-
 
567
	    if (p->cursor_blink < 2) {
553
	    r = rect(BORDERX + (CURCOL - FC) * FW, BORDERY + j * FH,
568
	    	r = rect(BORDERX + (CURCOL - FC) * FW, BORDERY + j * FH,
554
		     w0 * FW, FH);
569
		         w0 * FW, FH);
555
	    gfillrect(p->bm, highlight, r);
570
	    	gfillrect(p->bm, highlight, r);
556
	    gdrawwcs(p->bm, p->f, bg, pt(r.x, r.y), nn);
571
	    	gdrawwcs(p->bm, p->f, bg, pt(r.x, r.y), nn);
-
 
572
	    }
557
	} else
573
	} else {
-
 
574
	    if (p->cursor_blink) {
-
 
575
		setcaret(c, BORDERX + (CURCOL - FC) * FW, BORDERY + j * FH, 
-
 
576
		            p->cursor_blink == 1 ? 1 : FW, FH);
-
 
577
	    	showcaret(c, 1);
-
 
578
	    }
-
 
579
	    if (p->cursor_blink < 2) 
558
	    WLHELPER(CURCOL - FC, CURCOL - FC, bg, highlight);
580
	    	WLHELPER(CURCOL - FC, CURCOL - FC, bg, highlight); 
-
 
581
	}
559
    }
582
    }
560
    if (insel != 0) return len;
583
    if (insel != 0) return len;
561
    c1 = (p->my0 < p->my1);
584
    c1 = (p->my0 < p->my1);
562
    c2 = (p->my0 == p->my1);
585
    c2 = (p->my0 == p->my1);
563
    c3 = (p->mx0 < p->mx1);
586
    c3 = (p->mx0 < p->mx1);
Line 648... Line 671...
648
	return;;
671
	return;;
649
    }
672
    }
650
    if (p->needredraw) {
673
    if (p->needredraw) {
651
	ww = min(NUMLINES, ROWS) - 1;
674
	ww = min(NUMLINES, ROWS) - 1;
652
	rw = FV + ww;
675
	rw = FV + ww;
653
	writeline(p, rw, ww);
676
	writeline(c, p, rw, ww);
654
	if (ds == 0) {
677
	if (ds == 0) {
655
	    RSHOW(RLINE(ww));
678
	    RSHOW(RLINE(ww));
656
	    return;;
679
	    return;;
657
	}
680
	}
658
    }
681
    }
Line 1904... Line 1927...
1904
int fontsty, pointsize;
1927
int fontsty, pointsize;
1905
int consoler = 25, consolec = 80, consolex = 0, consoley = 0;
1928
int consoler = 25, consolec = 80, consolex = 0, consoley = 0;
1906
int pagerrow = 25, pagercol = 80;
1929
int pagerrow = 25, pagercol = 80;
1907
int pagerMultiple = 1, haveusedapager = 0;
1930
int pagerMultiple = 1, haveusedapager = 0;
1908
int consolebufb = DIMLBUF, consolebufl = MLBUF, consolebuffered = 1;
1931
int consolebufb = DIMLBUF, consolebufl = MLBUF, consolebuffered = 1;
-
 
1932
int consoleblink = 1;
1909
 
1933
 
1910
void
1934
void
1911
setconsoleoptions(const char *fnname,int fnsty, int fnpoints,
1935
setconsoleoptions(const char *fnname,int fnsty, int fnpoints,
1912
		  int rows, int cols, int consx, int consy,
1936
		  int rows, int cols, int consx, int consy,
1913
		  rgb *nguiColors,
1937
		  rgb *nguiColors,
1914
		  int pgr, int pgc, int multiplewindows, int widthonresize,
1938
		  int pgr, int pgc, int multiplewindows, int widthonresize,
1915
		  int bufbytes, int buflines, int buffered)
1939
		  int bufbytes, int buflines, int buffered, int cursor_blink)
1916
{
1940
{
1917
    char msg[LF_FACESIZE + 128];
1941
    char msg[LF_FACESIZE + 128];
1918
    strncpy(fontname, fnname, LF_FACESIZE);
1942
    strncpy(fontname, fnname, LF_FACESIZE);
1919
    fontname[LF_FACESIZE] = L'\0';
1943
    fontname[LF_FACESIZE] = L'\0';
1920
    fontsty =   fnsty;
1944
    fontsty =   fnsty;
Line 1950... Line 1974...
1950
    pagerMultiple = multiplewindows;
1974
    pagerMultiple = multiplewindows;
1951
    setWidthOnResize = widthonresize;
1975
    setWidthOnResize = widthonresize;
1952
    consolebufb = bufbytes;
1976
    consolebufb = bufbytes;
1953
    consolebufl = buflines;
1977
    consolebufl = buflines;
1954
    consolebuffered = buffered;
1978
    consolebuffered = buffered;
-
 
1979
    consoleblink = cursor_blink;
1955
}
1980
}
1956
 
1981
 
1957
void consoleprint(console c)
1982
void consoleprint(console c)
1958
{
1983
{
1959
    ConsoleData p = getdata(c);
1984
    ConsoleData p = getdata(c);
Line 2144... Line 2169...
2144
    ConsoleData p;
2169
    ConsoleData p;
2145
 
2170
 
2146
    p = newconsoledata((consolefn) ? consolefn : FixedFont,
2171
    p = newconsoledata((consolefn) ? consolefn : FixedFont,
2147
		       consoler, consolec, consolebufb, consolebufl,
2172
		       consoler, consolec, consolebufb, consolebufl,
2148
		       guiColors,
2173
		       guiColors,
2149
		       CONSOLE, consolebuffered);
2174
		       CONSOLE, consolebuffered, consoleblink);
2150
    if (!p) return NULL;
2175
    if (!p) return NULL;
2151
    c = (console) newwindow(name, rect(consolex, consoley, WIDTH, HEIGHT),
2176
    c = (console) newwindow(name, rect(consolex, consoley, WIDTH, HEIGHT),
2152
			    flags | TrackMouse | VScrollbar | HScrollbar);
2177
			    flags | TrackMouse | VScrollbar | HScrollbar);
2153
    HEIGHT = getheight(c);
2178
    HEIGHT = getheight(c);
2154
    WIDTH  = getwidth(c);
2179
    WIDTH  = getwidth(c);