The R Project SVN R

Rev

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

Rev 44407 Rev 45475
Line 778... Line 778...
778
	SEXP tmp = STRING_ELT(DE->names, col - 1);
778
	SEXP tmp = STRING_ELT(DE->names, col - 1);
779
	if(tmp != NA_STRING) return(CHAR(tmp));
779
	if(tmp != NA_STRING) return(CHAR(tmp));
780
    }
780
    }
781
    nwrote = snprintf(clab, 25, "var%d", col);
781
    nwrote = snprintf(clab, 25, "var%d", col);
782
    if (nwrote >= 25)
782
    if (nwrote >= 25)
783
        error("get_col_name: column number too big to stringify");
783
	error("get_col_name: column number too big to stringify");
784
    return (const char *)clab;
784
    return (const char *)clab;
785
}
785
}
786
 
786
 
787
static int get_col_width(DEstruct DE, int col)
787
static int get_col_width(DEstruct DE, int col)
788
{
788
{
Line 956... Line 956...
956
	doHscroll(DE, DE->colmin+1);
956
	doHscroll(DE, DE->colmin+1);
957
	break;
957
	break;
958
    case RIGHT:
958
    case RIGHT:
959
	oldcol = DE->colmin;
959
	oldcol = DE->colmin;
960
	wcol = DE->colmin + DE->ccol + 1; /* column to be selected */
960
	wcol = DE->colmin + DE->ccol + 1; /* column to be selected */
961
        /* There may not be room to fit the next column in */
961
	/* There may not be room to fit the next column in */
962
	w = DE->fullwindowWidth - DE->boxw[0] - BOXW(DE->colmax + 1);
962
	w = DE->fullwindowWidth - DE->boxw[0] - BOXW(DE->colmax + 1);
963
	for (i = DE->colmax; i >= oldcol; i--) {
963
	for (i = DE->colmax; i >= oldcol; i--) {
964
	    w -= BOXW(i);
964
	    w -= BOXW(i);
965
	    if(w < 0) {
965
	    if(w < 0) {
966
		DE->colmin = i + 1;
966
		DE->colmin = i + 1;
Line 1128... Line 1128...
1128
   area of previous text; */
1128
   area of previous text; */
1129
 
1129
 
1130
/* This version will only display 200 chars, but the maximum col width
1130
/* This version will only display 200 chars, but the maximum col width
1131
   will not allow that many */
1131
   will not allow that many */
1132
static void printstring(DEstruct DE, const char *ibuf, int buflen, int row,
1132
static void printstring(DEstruct DE, const char *ibuf, int buflen, int row,
1133
                        int col, int left)
1133
			int col, int left)
1134
{
1134
{
1135
    int i, x_pos, y_pos, bw, bufw;
1135
    int i, x_pos, y_pos, bw, bufw;
1136
    char pbuf[BOOSTED_BUF_SIZE];
1136
    char pbuf[BOOSTED_BUF_SIZE];
1137
#ifdef USE_FONTSET
1137
#ifdef USE_FONTSET
1138
    int wcsbufw,j;
1138
    int wcsbufw,j;
Line 1152... Line 1152...
1152
 
1152
 
1153
    p = pbuf;
1153
    p = pbuf;
1154
    wcsbufw = mbsrtowcs(wcspbuf, (const char **)&p, bufw, NULL);
1154
    wcsbufw = mbsrtowcs(wcspbuf, (const char **)&p, bufw, NULL);
1155
    wcspbuf[wcsbufw]=L'\0';
1155
    wcspbuf[wcsbufw]=L'\0';
1156
    if(left) {
1156
    if(left) {
1157
        for (i = wcsbufw; i > 1; i--) {
1157
	for (i = wcsbufw; i > 1; i--) {
1158
	    for(j=0;*(wcspc+j)!=L'\0';j++)wcs[j]=*(wcspc+j);
1158
	    for(j=0;*(wcspc+j)!=L'\0';j++)wcs[j]=*(wcspc+j);
1159
	    wcs[j]=L'\0';
1159
	    wcs[j]=L'\0';
1160
	    w_p=wcs;
1160
	    w_p=wcs;
1161
	    cnt=wcsrtombs(s,(const wchar_t **)&w_p,sizeof(s)-1,NULL);
1161
	    cnt=wcsrtombs(s,(const wchar_t **)&w_p,sizeof(s)-1,NULL);
1162
	    s[cnt]='\0';
1162
	    s[cnt]='\0';
1163
            if (textwidth(DE, s, strlen(s)) < (bw - DE->text_offset)) break;
1163
	    if (textwidth(DE, s, strlen(s)) < (bw - DE->text_offset)) break;
1164
            *(++wcspc) = L'<';
1164
	    *(++wcspc) = L'<';
1165
        }
1165
	}
1166
    } else {
1166
    } else {
1167
        for (i = wcsbufw; i > 1; i--) {
1167
	for (i = wcsbufw; i > 1; i--) {
1168
	    for(j=0;*(wcspc+j)!=L'\0';j++)wcs[j]=*(wcspc+j);
1168
	    for(j=0;*(wcspc+j)!=L'\0';j++)wcs[j]=*(wcspc+j);
1169
	    wcs[j]=L'\0';
1169
	    wcs[j]=L'\0';
1170
	    w_p=wcs;
1170
	    w_p=wcs;
1171
	    cnt=wcsrtombs(s,(const wchar_t **)&w_p,sizeof(s)-1,NULL);
1171
	    cnt=wcsrtombs(s,(const wchar_t **)&w_p,sizeof(s)-1,NULL);
1172
	    s[cnt]='\0';
1172
	    s[cnt]='\0';
1173
            if (textwidth(DE, s, strlen(s)) < (bw - DE->text_offset)) break;
1173
	    if (textwidth(DE, s, strlen(s)) < (bw - DE->text_offset)) break;
1174
            *(wcspbuf + i - 2) = L'>';
1174
	    *(wcspbuf + i - 2) = L'>';
1175
            *(wcspbuf + i - 1) = L'\0';
1175
	    *(wcspbuf + i - 1) = L'\0';
1176
        }
1176
	}
1177
    }
1177
    }
1178
    for(j=0;*(wcspc+j)!=L'\0';j++) wcs[j]=*(wcspc+j);
1178
    for(j=0;*(wcspc+j)!=L'\0';j++) wcs[j]=*(wcspc+j);
1179
    wcs[j]=L'\0';
1179
    wcs[j]=L'\0';
1180
    w_p=wcs;
1180
    w_p=wcs;
1181
    cnt=wcsrtombs(s,(const wchar_t **)&w_p,sizeof(s)-1,NULL);
1181
    cnt=wcsrtombs(s,(const wchar_t **)&w_p,sizeof(s)-1,NULL);
Line 1189... Line 1189...
1189
    if (col == 0) bw = DE->boxw[0]; else bw = BOXW(col+DE->colmin-1);
1189
    if (col == 0) bw = DE->boxw[0]; else bw = BOXW(col+DE->colmin-1);
1190
    cleararea(DE, x_pos + 2, y_pos + 2, bw - 3, DE->box_h - 3);
1190
    cleararea(DE, x_pos + 2, y_pos + 2, bw - 3, DE->box_h - 3);
1191
    bufw = (buflen > 200) ? 200 : buflen;
1191
    bufw = (buflen > 200) ? 200 : buflen;
1192
    strncpy(pbuf, ibuf, bufw);
1192
    strncpy(pbuf, ibuf, bufw);
1193
    if(left) {
1193
    if(left) {
1194
        for (i = bufw; i > 1; i--) {
1194
	for (i = bufw; i > 1; i--) {
1195
            if (textwidth(DE, pc, i) < (bw - DE->text_offset)) break;
1195
	    if (textwidth(DE, pc, i) < (bw - DE->text_offset)) break;
1196
            *(++pc) = '<';
1196
	    *(++pc) = '<';
1197
        }
1197
	}
1198
    } else {
1198
    } else {
1199
        for (i = bufw; i > 1; i--) {
1199
	for (i = bufw; i > 1; i--) {
1200
            if (textwidth(DE, pbuf, i) < (bw - DE->text_offset)) break;
1200
	    if (textwidth(DE, pbuf, i) < (bw - DE->text_offset)) break;
1201
            *(pbuf + i - 2) = '>';
1201
	    *(pbuf + i - 2) = '>';
1202
        }
1202
	}
1203
    }
1203
    }
1204
    drawtext(DE, x_pos + DE->text_offset, y_pos + DE->box_h - DE->text_offset,
1204
    drawtext(DE, x_pos + DE->text_offset, y_pos + DE->box_h - DE->text_offset,
1205
	     pc, i);
1205
	     pc, i);
1206
#endif /* USE_FONTSET */
1206
#endif /* USE_FONTSET */
1207
 
1207
 
Line 1240... Line 1240...
1240
#endif
1240
#endif
1241
 
1241
 
1242
    if ( c == '\033' ) { /* ESC */
1242
    if ( c == '\033' ) { /* ESC */
1243
	CellModified = FALSE;
1243
	CellModified = FALSE;
1244
	clength = 0;
1244
	clength = 0;
1245
        bufp = buf;
1245
	bufp = buf;
1246
	drawelt(DE, DE->crow, DE->ccol);
1246
	drawelt(DE, DE->crow, DE->ccol);
1247
	cell_cursor_init(DE);
1247
	cell_cursor_init(DE);
1248
	return;
1248
	return;
1249
    } else
1249
    } else
1250
	CellModified = TRUE;
1250
	CellModified = TRUE;
Line 1306... Line 1306...
1306
	      if (!inSpecial && !iswdigit(wcs[i])) goto donehc;
1306
	      if (!inSpecial && !iswdigit(wcs[i])) goto donehc;
1307
	      break;
1307
	      break;
1308
	  }
1308
	  }
1309
      }
1309
      }
1310
#else
1310
#else
1311
        switch (c) {
1311
	switch (c) {
1312
	case '-':
1312
	case '-':
1313
	    if (nneg == 0) nneg++; else goto donehc;
1313
	    if (nneg == 0) nneg++; else goto donehc;
1314
	    break;
1314
	    break;
1315
	case '.':
1315
	case '.':
1316
	    if (ndecimal == 0) ndecimal++; else goto donehc;
1316
	    if (ndecimal == 0) ndecimal++; else goto donehc;
Line 1383... Line 1383...
1383
	sprintf(clab, DE->labform, i);
1383
	sprintf(clab, DE->labform, i);
1384
	printstring(DE, clab, strlen(clab), i - DE->rowmin + 1, 0, 0);
1384
	printstring(DE, clab, strlen(clab), i - DE->rowmin + 1, 0, 0);
1385
    }
1385
    }
1386
}
1386
}
1387
 
1387
 
1388
               /* ================ X11-specific ================ */
1388
	       /* ================ X11-specific ================ */
1389
 
1389
 
1390
/* find out whether the button click was in the quit box */
1390
/* find out whether the button click was in the quit box */
1391
static int checkquit(int xw)
1391
static int checkquit(int xw)
1392
{
1392
{
1393
    if (xw > box_coords[1] && xw < box_coords[0]) return 1;
1393
    if (xw > box_coords[1] && xw < box_coords[0]) return 1;
Line 1479... Line 1479...
1479
    return 0;
1479
    return 0;
1480
}
1480
}
1481
 
1481
 
1482
 
1482
 
1483
/* Event Loop Functions */
1483
/* Event Loop Functions */
1484
#define mouseDown 	ButtonPress
1484
#define mouseDown	ButtonPress
1485
#define keyDown		KeyPress
1485
#define keyDown		KeyPress
1486
#define activateEvt	MapNotify
1486
#define activateEvt	MapNotify
1487
#define updateEvt	Expose
1487
#define updateEvt	Expose
1488
 
1488
 
1489
static void eventloop(DEstruct DE)
1489
static void eventloop(DEstruct DE)
Line 1491... Line 1491...
1491
    int done;
1491
    int done;
1492
    DEEvent ioevent;
1492
    DEEvent ioevent;
1493
 
1493
 
1494
    done = 0;
1494
    done = 0;
1495
    while (done == 0) {
1495
    while (done == 0) {
1496
        XNextEvent(iodisplay, &ioevent);
1496
	XNextEvent(iodisplay, &ioevent);
1497
        {
1497
	{
1498
#ifdef USE_FONTSET
1498
#ifdef USE_FONTSET
1499
            if (XFilterEvent(&ioevent, None)){
1499
	    if (XFilterEvent(&ioevent, None)){
1500
		if(ioic){
1500
		if(ioic){
1501
		    XSetICFocus(ioic);
1501
		    XSetICFocus(ioic);
1502
		    if (ioim_style & XIMPreeditPosition)
1502
		    if (ioim_style & XIMPreeditPosition)
1503
			calc_pre_edit_pos(DE);
1503
			calc_pre_edit_pos(DE);
1504
		}
1504
		}
Line 1508... Line 1508...
1508
 
1508
 
1509
	    switch (WhichEvent(ioevent)) {
1509
	    switch (WhichEvent(ioevent)) {
1510
	    case keyDown:/* KeyPress */
1510
	    case keyDown:/* KeyPress */
1511
		doSpreadKey(DE, 0, &ioevent);
1511
		doSpreadKey(DE, 0, &ioevent);
1512
		break;
1512
		break;
1513
            case Expose:
1513
	    case Expose:
1514
		while(XCheckTypedEvent(iodisplay, Expose, &ioevent))
1514
		while(XCheckTypedEvent(iodisplay, Expose, &ioevent))
1515
		    ;
1515
		    ;
1516
		/*
1516
		/*
1517
		 * XIM on  - KeyPress - Expose
1517
		 * XIM on  - KeyPress - Expose
1518
		 * XIM off - KeyPress - KeyRelease
1518
		 * XIM off - KeyPress - KeyRelease
1519
		 * colname change XIM on mode. type Backspace.
1519
		 * colname change XIM on mode. type Backspace.
1520
		 */
1520
		 */
1521
	        if(DE->crow == 0){
1521
		if(DE->crow == 0){
1522
		    drawwindow(DE);
1522
		    drawwindow(DE);
1523
		    printstring(DE, buf, clength, DE->crow, DE->ccol, 1);
1523
		    printstring(DE, buf, clength, DE->crow, DE->ccol, 1);
1524
		} else {
1524
		} else {
1525
		    closerect(DE);
1525
		    closerect(DE);
1526
		    drawwindow(DE);
1526
		    drawwindow(DE);
1527
		    cell_cursor_init(DE);
1527
		    cell_cursor_init(DE);
1528
		}
1528
		}
1529
		break;
1529
		break;
1530
	    case activateEvt:/* MapNotify */
1530
	    case activateEvt:/* MapNotify */
1531
	      	closerect(DE);
1531
		closerect(DE);
1532
		drawwindow(DE);
1532
		drawwindow(DE);
1533
		cell_cursor_init(DE);
1533
		cell_cursor_init(DE);
1534
 		break;
1534
		break;
1535
	    case mouseDown:/* ButtonPress */
1535
	    case mouseDown:/* ButtonPress */
1536
		if(DE->isEditor) {
1536
		if(DE->isEditor) {
1537
		    done  = doMouseDown(DE, &ioevent);
1537
		    done  = doMouseDown(DE, &ioevent);
1538
		    cell_cursor_init(DE);
1538
		    cell_cursor_init(DE);
1539
		}
1539
		}
Line 1565... Line 1565...
1565
    DEstruct DE = NULL;
1565
    DEstruct DE = NULL;
1566
    DEEvent ioevent;
1566
    DEEvent ioevent;
1567
    int done = 0;
1567
    int done = 0;
1568
 
1568
 
1569
    while (XPending(iodisplay)) {
1569
    while (XPending(iodisplay)) {
1570
        XNextEvent(iodisplay, &ioevent);
1570
	XNextEvent(iodisplay, &ioevent);
1571
	XFindContext(iodisplay, ioevent.xany.window, deContext, &temp);
1571
	XFindContext(iodisplay, ioevent.xany.window, deContext, &temp);
1572
	DE = (DEstruct) temp;
1572
	DE = (DEstruct) temp;
1573
	switch (WhichEvent(ioevent)) {
1573
	switch (WhichEvent(ioevent)) {
1574
	case keyDown:/* KeyPress */
1574
	case keyDown:/* KeyPress */
1575
	    doSpreadKey(DE, 0, &ioevent);
1575
	    doSpreadKey(DE, 0, &ioevent);
Line 1610... Line 1610...
1610
			       getInputHandler(R_InputHandlers,fdView));
1610
			       getInputHandler(R_InputHandlers,fdView));
1611
	    fdView = -1;
1611
	    fdView = -1;
1612
	    XCloseDisplay(iodisplay);
1612
	    XCloseDisplay(iodisplay);
1613
	    iodisplay = NULL;
1613
	    iodisplay = NULL;
1614
	}
1614
	}
1615
	
1615
 
1616
    }
1616
    }
1617
}
1617
}
1618
 
1618
 
1619
static int doMouseDown(DEstruct DE, DEEvent * event)
1619
static int doMouseDown(DEstruct DE, DEEvent * event)
1620
{
1620
{
Line 1735... Line 1735...
1735
    memset(text,0,sizeof(text));
1735
    memset(text,0,sizeof(text));
1736
 
1736
 
1737
#ifdef USE_FONTSET
1737
#ifdef USE_FONTSET
1738
    if(mbcslocale) {
1738
    if(mbcslocale) {
1739
#ifdef HAVE_XUTF8LOOKUPSTRING
1739
#ifdef HAVE_XUTF8LOOKUPSTRING
1740
        if(utf8locale)
1740
	if(utf8locale)
1741
	    Xutf8LookupString(ioic, (XKeyEvent *)event,
1741
	    Xutf8LookupString(ioic, (XKeyEvent *)event,
1742
			      text, sizeof(text) - clength,
1742
			      text, sizeof(text) - clength,
1743
			      &iokey, &status);
1743
			      &iokey, &status);
1744
	else
1744
	else
1745
#endif
1745
#endif
Line 1908... Line 1908...
1908
	}
1908
	}
1909
	deContext = XUniqueContext();
1909
	deContext = XUniqueContext();
1910
	XSetErrorHandler(R_X11Err);
1910
	XSetErrorHandler(R_X11Err);
1911
	XSetIOErrorHandler(R_X11IOErr);
1911
	XSetIOErrorHandler(R_X11IOErr);
1912
    }
1912
    }
1913
    
1913
 
1914
 
1914
 
1915
    /* Get Font Loaded if we can */
1915
    /* Get Font Loaded if we can */
1916
 
1916
 
1917
#ifdef USE_FONTSET
1917
#ifdef USE_FONTSET
1918
    if(mbcslocale) {
1918
    if(mbcslocale) {
Line 2017... Line 2017...
2017
#ifdef USE_Xt
2017
#ifdef USE_Xt
2018
    {
2018
    {
2019
	XtAppContext app_con;
2019
	XtAppContext app_con;
2020
	Widget toplevel;
2020
	Widget toplevel;
2021
	Display *xtdpy;
2021
	Display *xtdpy;
2022
        int zero = 0;
2022
	int zero = 0;
2023
 
2023
 
2024
	XtToolkitInitialize();
2024
	XtToolkitInitialize();
2025
	app_con = XtCreateApplicationContext();
2025
	app_con = XtCreateApplicationContext();
2026
	/* XtAppSetFallbackResources(app_con, x_fallback_resources);*/
2026
	/* XtAppSetFallbackResources(app_con, x_fallback_resources);*/
2027
	xtdpy = XtOpenDisplay(app_con, NULL, "r_dataentry", "R_dataentry",
2027
	xtdpy = XtOpenDisplay(app_con, NULL, "r_dataentry", "R_dataentry",
Line 2126... Line 2126...
2126
	xpoint.x = 0; xpoint.y=0;
2126
	xpoint.x = 0; xpoint.y=0;
2127
	xva_nlist = XVaCreateNestedList(0, XNFontSet, font_set,
2127
	xva_nlist = XVaCreateNestedList(0, XNFontSet, font_set,
2128
					XNSpotLocation, &xpoint, NULL);
2128
					XNSpotLocation, &xpoint, NULL);
2129
 
2129
 
2130
	ioic = XCreateIC(ioim,
2130
	ioic = XCreateIC(ioim,
2131
 			 XNInputStyle, ioim_style,
2131
			 XNInputStyle, ioim_style,
2132
			 XNClientWindow,DE->iowindow,
2132
			 XNClientWindow,DE->iowindow,
2133
			 XNFocusWindow,DE->iowindow,
2133
			 XNFocusWindow,DE->iowindow,
2134
			 XNPreeditAttributes, xva_nlist,
2134
			 XNPreeditAttributes, xva_nlist,
2135
			 XNStatusAttributes, xva_nlist,
2135
			 XNStatusAttributes, xva_nlist,
2136
			 NULL);
2136
			 NULL);
Line 2283... Line 2283...
2283
static void drawtext(DEstruct DE, int xpos, int ypos, char *text, int len)
2283
static void drawtext(DEstruct DE, int xpos, int ypos, char *text, int len)
2284
{
2284
{
2285
#ifdef USE_FONTSET
2285
#ifdef USE_FONTSET
2286
    if(mbcslocale)
2286
    if(mbcslocale)
2287
#ifdef HAVE_XUTF8DRAWIMAGESTRING
2287
#ifdef HAVE_XUTF8DRAWIMAGESTRING
2288
        if(utf8locale)
2288
	if(utf8locale)
2289
	    Xutf8DrawImageString(iodisplay, DE->iowindow, font_set,
2289
	    Xutf8DrawImageString(iodisplay, DE->iowindow, font_set,
2290
				 DE->iogc, xpos, ypos,text, len);
2290
				 DE->iogc, xpos, ypos,text, len);
2291
        else
2291
	else
2292
#endif
2292
#endif
2293
	    XmbDrawImageString(iodisplay, DE->iowindow, font_set,
2293
	    XmbDrawImageString(iodisplay, DE->iowindow, font_set,
2294
			       DE->iogc, xpos, ypos,text, len);
2294
			       DE->iogc, xpos, ypos,text, len);
2295
    else
2295
    else
2296
#endif
2296
#endif
Line 2310... Line 2310...
2310
    char *buf = CallocCharBuf(nchar);
2310
    char *buf = CallocCharBuf(nchar);
2311
    strncpy(buf, text, nchar);
2311
    strncpy(buf, text, nchar);
2312
#ifdef USE_FONTSET
2312
#ifdef USE_FONTSET
2313
    if(mbcslocale) {
2313
    if(mbcslocale) {
2314
#ifdef HAVE_XUTF8TEXTESCAPEMENT
2314
#ifdef HAVE_XUTF8TEXTESCAPEMENT
2315
        if (utf8locale)
2315
	if (utf8locale)
2316
	    ans = Xutf8TextEscapement(font_set, buf, nchar);
2316
	    ans = Xutf8TextEscapement(font_set, buf, nchar);
2317
        else
2317
	else
2318
#endif
2318
#endif
2319
	    ans = XmbTextEscapement(font_set, buf, nchar);
2319
	    ans = XmbTextEscapement(font_set, buf, nchar);
2320
        Free(buf);
2320
	Free(buf);
2321
        return ans;
2321
	return ans;
2322
    }
2322
    }
2323
#endif
2323
#endif
2324
    ans = XTextWidth(DE->font_info, buf, nchar);
2324
    ans = XTextWidth(DE->font_info, buf, nchar);
2325
    Free(buf);
2325
    Free(buf);
2326
    return ans;
2326
    return ans;
Line 2357... Line 2357...
2357
    tvec = VECTOR_ELT(DE->work, popupcol - 1);
2357
    tvec = VECTOR_ELT(DE->work, popupcol - 1);
2358
    name = CHAR(STRING_ELT(DE->names, popupcol - 1));
2358
    name = CHAR(STRING_ELT(DE->names, popupcol - 1));
2359
#ifdef USE_FONTSET
2359
#ifdef USE_FONTSET
2360
    if(mbcslocale)
2360
    if(mbcslocale)
2361
#ifdef HAVE_XUTF8DRAWSTRING
2361
#ifdef HAVE_XUTF8DRAWSTRING
2362
        if(utf8locale)
2362
	if(utf8locale)
2363
	    Xutf8DrawString(iodisplay,
2363
	    Xutf8DrawString(iodisplay,
2364
			    menupanes[0],
2364
			    menupanes[0],
2365
			    font_set, DE->iogc, 3, DE->box_h - 3, name,
2365
			    font_set, DE->iogc, 3, DE->box_h - 3, name,
2366
			    strlen(name));
2366
			    strlen(name));
2367
	else
2367
	else
Line 2370... Line 2370...
2370
			  menupanes[0],
2370
			  menupanes[0],
2371
			  font_set, DE->iogc, 3, DE->box_h - 3, name,
2371
			  font_set, DE->iogc, 3, DE->box_h - 3, name,
2372
			  strlen(name));
2372
			  strlen(name));
2373
    else
2373
    else
2374
#endif
2374
#endif
2375
        XDrawString(iodisplay,
2375
	XDrawString(iodisplay,
2376
		    menupanes[0], DE->iogc, 3, DE->box_h - 3, name,
2376
		    menupanes[0], DE->iogc, 3, DE->box_h - 3, name,
2377
		    strlen(name));
2377
		    strlen(name));
2378
    for (i = 1; i < 4; i++)
2378
    for (i = 1; i < 4; i++)
2379
#ifdef USE_FONTSET
2379
#ifdef USE_FONTSET
2380
      if(mbcslocale)
2380
      if(mbcslocale)
2381
#ifdef HAVE_XUTF8DRAWSTRING
2381
#ifdef HAVE_XUTF8DRAWSTRING
2382
        if(utf8locale)
2382
	if(utf8locale)
2383
	  Xutf8DrawString(iodisplay,
2383
	  Xutf8DrawString(iodisplay,
2384
			  menupanes[i],
2384
			  menupanes[i],
2385
			  font_set, DE->iogc, 3, DE->box_h - 3,
2385
			  font_set, DE->iogc, 3, DE->box_h - 3,
2386
			  menu_label[i - 1], strlen(menu_label[i - 1]));
2386
			  menu_label[i - 1], strlen(menu_label[i - 1]));
2387
	else
2387
	else
Line 2398... Line 2398...
2398
 
2398
 
2399
    if (isNull(tvec) || TYPEOF(tvec) == REALSXP)
2399
    if (isNull(tvec) || TYPEOF(tvec) == REALSXP)
2400
#ifdef USE_FONTSET
2400
#ifdef USE_FONTSET
2401
      if(mbcslocale)
2401
      if(mbcslocale)
2402
#ifdef HAVE_XUTF8DRAWSTRING
2402
#ifdef HAVE_XUTF8DRAWSTRING
2403
        if(utf8locale)
2403
	if(utf8locale)
2404
	  Xutf8DrawString(iodisplay,
2404
	  Xutf8DrawString(iodisplay,
2405
			  menupanes[1],
2405
			  menupanes[1],
2406
			  font_set, DE->iogc, 0, DE->box_h - 3,
2406
			  font_set, DE->iogc, 0, DE->box_h - 3,
2407
			  "*", 1);
2407
			  "*", 1);
2408
	else
2408
	else
Line 2417... Line 2417...
2417
		    "*", 1);
2417
		    "*", 1);
2418
    else
2418
    else
2419
#ifdef USE_FONTSET
2419
#ifdef USE_FONTSET
2420
      if(mbcslocale)
2420
      if(mbcslocale)
2421
#ifdef HAVE_XUTF8DRAWSTRING
2421
#ifdef HAVE_XUTF8DRAWSTRING
2422
        if(utf8locale)
2422
	if(utf8locale)
2423
	  Xutf8DrawString(iodisplay,
2423
	  Xutf8DrawString(iodisplay,
2424
			  menupanes[2],
2424
			  menupanes[2],
2425
			  font_set, DE->iogc, 0, DE->box_h - 3,
2425
			  font_set, DE->iogc, 0, DE->box_h - 3,
2426
			  "*", 1);
2426
			  "*", 1);
2427
	else
2427
	else
Line 2487... Line 2487...
2487
		    clearrect(DE);
2487
		    clearrect(DE);
2488
		    goto done;
2488
		    goto done;
2489
		}
2489
		}
2490
	    }
2490
	    }
2491
	}
2491
	}
2492
        /* this doesn't work and perhaps I should move it up to the
2492
	/* this doesn't work and perhaps I should move it up to the
2493
           main control loop */
2493
	   main control loop */
2494
	else if (event.type == Expose) {
2494
	else if (event.type == Expose) {
2495
	    if (event.xexpose.window == menuwindow) {
2495
	    if (event.xexpose.window == menuwindow) {
2496
		XDrawString(iodisplay, menupanes[0], DE->iogc, 3,
2496
		XDrawString(iodisplay, menupanes[0], DE->iogc, 3,
2497
			    DE->box_h - 3, name, strlen(name));
2497
			    DE->box_h - 3, name, strlen(name));
2498
		for (i = 1; i < 4; i++)
2498
		for (i = 1; i < 4; i++)
Line 2530... Line 2530...
2530
	if (length(DE->work) >= whichcol) {
2530
	if (length(DE->work) >= whichcol) {
2531
	    tmp = VECTOR_ELT(DE->work, whichcol - 1);
2531
	    tmp = VECTOR_ELT(DE->work, whichcol - 1);
2532
	    if (tmp != R_NilValue &&
2532
	    if (tmp != R_NilValue &&
2533
		(i = whichrow - 1) < LENGTH(tmp) ) {
2533
		(i = whichrow - 1) < LENGTH(tmp) ) {
2534
		PrintDefaults(R_NilValue);
2534
		PrintDefaults(R_NilValue);
2535
                if (TYPEOF(tmp) == REALSXP) {
2535
		if (TYPEOF(tmp) == REALSXP) {
2536
			strncpy(copycontents, EncodeElement(tmp, i, 0, '.'),
2536
			strncpy(copycontents, EncodeElement(tmp, i, 0, '.'),
2537
				BOOSTED_BUF_SIZE-1);
2537
				BOOSTED_BUF_SIZE-1);
2538
			copycontents[BOOSTED_BUF_SIZE-1]='\0';
2538
			copycontents[BOOSTED_BUF_SIZE-1]='\0';
2539
                } else if (TYPEOF(tmp) == STRSXP) {
2539
		} else if (TYPEOF(tmp) == STRSXP) {
2540
                    if (STRING_ELT(tmp, i) != ssNA_STRING) {
2540
		    if (STRING_ELT(tmp, i) != ssNA_STRING) {
2541
			strncpy(copycontents, EncodeElement(tmp, i, 0, '.'),
2541
			strncpy(copycontents, EncodeElement(tmp, i, 0, '.'),
2542
				BOOSTED_BUF_SIZE-1);
2542
				BOOSTED_BUF_SIZE-1);
2543
			copycontents[BOOSTED_BUF_SIZE-1]='\0';
2543
			copycontents[BOOSTED_BUF_SIZE-1]='\0';
2544
		    }
2544
		    }
2545
		}
2545
		}
Line 2619... Line 2619...
2619
    memset(wcs, 0 ,sizeof(wcs));
2619
    memset(wcs, 0 ,sizeof(wcs));
2620
    memset(&mb_st,0, sizeof(mbstate_t));
2620
    memset(&mb_st,0, sizeof(mbstate_t));
2621
 
2621
 
2622
    if((size_t)-1 == (cnt = mbsrtowcs(wcs, (const char **)&mbs,
2622
    if((size_t)-1 == (cnt = mbsrtowcs(wcs, (const char **)&mbs,
2623
				      strlen(mbs), &mb_st))) {
2623
				      strlen(mbs), &mb_st))) {
2624
        return 0;
2624
	return 0;
2625
    }
2625
    }
2626
    if(wcs[0] == L'\0') return 0;
2626
    if(wcs[0] == L'\0') return 0;
2627
 
2627
 
2628
    memset(last_mbs, 0, sizeof(last_mbs));
2628
    memset(last_mbs, 0, sizeof(last_mbs));
2629
    bytes = wcrtomb(last_mbs, wcs[cnt-1], &mb_st); /* -Wall */
2629
    bytes = wcrtomb(last_mbs, wcs[cnt-1], &mb_st); /* -Wall */