The R Project SVN R

Rev

Rev 37860 | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 37860 Rev 38332
Line 55... Line 55...
55
#define min(a, b) (((a)<(b))?(a):(b))
55
#define min(a, b) (((a)<(b))?(a):(b))
56
#endif
56
#endif
57
#define BOXW(x) (min(((x<100 && nboxchars==0)?boxw[x]:box_w),WIDTH-boxw[0]-2*bwidth-2))
57
#define BOXW(x) (min(((x<100 && nboxchars==0)?boxw[x]:box_w),WIDTH-boxw[0]-2*bwidth-2))
58
 
58
 
59
#define FIELDWIDTH 10
59
#define FIELDWIDTH 10
-
 
60
#define BUFSIZE 200
60
 
61
 
61
/* Local Function Definitions */
62
/* Local Function Definitions */
62
 
63
 
63
static void advancerect(int);
64
static void advancerect(int);
64
static void bell();
65
static void bell();
Line 116... Line 117...
116
static int colmax, colmin, rowmax, rowmin;
117
static int colmax, colmin, rowmax, rowmin;
117
static int ndecimal;                    /* count decimal points */
118
static int ndecimal;                    /* count decimal points */
118
static int ne;                          /* count exponents */
119
static int ne;                          /* count exponents */
119
static int nneg;			/* indicate whether its a negative */
120
static int nneg;			/* indicate whether its a negative */
120
static int clength;                     /* number of characters currently entered */
121
static int clength;                     /* number of characters currently entered */
121
static char buf[200];
122
static char buf[BUFSIZE];
122
static char *bufp;
123
static char *bufp;
123
static int bwidth;			/* width of the border */
124
static int bwidth;			/* width of the border */
124
static int hwidth;			/* width of header  */
125
static int hwidth;			/* width of header  */
125
static int text_xoffset, text_yoffset;
126
static int text_xoffset, text_yoffset;
126
static field celledit;
127
static field celledit;
Line 766... Line 767...
766
 
767
 
767
    *bufp = '\0';
768
    *bufp = '\0';
768
 
769
 
769
    if (CellModified || CellEditable) {
770
    if (CellModified || CellEditable) {
770
	if (CellEditable) {
771
	if (CellEditable) {
771
	    strcpy(buf, gettext(celledit));
772
	    strncpy(buf, gettext(celledit), BUFSIZE-1);
772
	    clength = strlen(buf);
773
	    clength = strlen(buf);
773
	    hide(celledit);
774
	    hide(celledit);
774
	    del(celledit);
775
	    del(celledit);
775
	}
776
	}
776
	getccol();
777
	getccol();
Line 817... Line 818...
817
 
818
 
818
/* print a null terminated string, check to see if it is longer than
819
/* print a null terminated string, check to see if it is longer than
819
   the print area and print it, left adjusted if necessary; clear the
820
   the print area and print it, left adjusted if necessary; clear the
820
   area of previous text; */
821
   area of previous text; */
821
 
822
 
822
/* This version will only display 200 chars, but the maximum col width
823
/* This version will only display BUFSIZE chars, but the maximum col width
823
   will not allow that many */
824
   will not allow that many */
824
static void printstring(char *ibuf, int buflen, int row, int col, int left)
825
static void printstring(char *ibuf, int buflen, int row, int col, int left)
825
{
826
{
826
    int x_pos, y_pos, bw, fw, bufw;
827
    int x_pos, y_pos, bw, fw, bufw;
827
    char buf[201];
828
    char buf[BUFSIZE+1];
828
 
829
 
829
    find_coords(row, col, &x_pos, &y_pos);
830
    find_coords(row, col, &x_pos, &y_pos);
830
    if (col == 0) bw = boxw[0]; else bw = BOXW(col+colmin-1);
831
    if (col == 0) bw = boxw[0]; else bw = BOXW(col+colmin-1);
831
    cleararea(x_pos + 1, y_pos + 1, bw - 1, box_h - 1,
832
    cleararea(x_pos + 1, y_pos + 1, bw - 1, box_h - 1,
832
	      (row==0 || col==0) ? bbg:p->bg);
833
	      (row==0 || col==0) ? bbg:p->bg);
833
    fw = min(200, (bw - 8)/FW);
834
    fw = min(BUFSIZE, (bw - 8)/FW);
834
    bufw = min(fw, buflen);
835
    bufw = min(fw, buflen);
835
    strncpy(buf, ibuf, bufw);
836
    strncpy(buf, ibuf, bufw);
836
    buf[bufw] = '\0';
837
    buf[bufw] = '\0';
837
    if (buflen > fw) {
838
    if (buflen > fw) {
838
	if(left) {
839
	if(left) {
Line 1325... Line 1326...
1325
		     max(nwide/xScrollbarScale, 1), 0);
1326
		     max(nwide/xScrollbarScale, 1), 0);
1326
    show(de);
1327
    show(de);
1327
    show(de); /* a precaution, as PD reports transparent windows */
1328
    show(de); /* a precaution, as PD reports transparent windows */
1328
    BringToTop(de, 0);
1329
    BringToTop(de, 0);
1329
    R_de_up = TRUE;
1330
    R_de_up = TRUE;
-
 
1331
    buf[BUFSIZE-1] = '\0';
1330
    return FALSE;
1332
    return FALSE;
1331
}
1333
}
1332
 
1334
 
1333
/* Menus */
1335
/* Menus */
1334
 
1336
 
Line 1339... Line 1341...
1339
static int isnumeric, popupcol;
1341
static int isnumeric, popupcol;
1340
 
1342
 
1341
static void popupclose(control c)
1343
static void popupclose(control c)
1342
{
1344
{
1343
    SEXP tvec;
1345
    SEXP tvec;
1344
    char buf[30], clab[25];
1346
    char buf[BUFSIZE], clab[25];
1345
    int i;
1347
    int i;
1346
 
-
 
-
 
1348
    buf[BUFSIZE-1] = '\0';
1347
    strcpy(buf, gettext(varname));
1349
    strncpy(buf, gettext(varname), BUFSIZE-1);
1348
    if(!strlen(buf)) {
1350
    if(!strlen(buf)) {
1349
	askok(G_("column names cannot be blank"));
1351
	askok(G_("column names cannot be blank"));
1350
	return;
1352
	return;
1351
    }
1353
    }
1352
    if (popupcol > xmaxused) {
1354
    if (popupcol > xmaxused) {
Line 1415... Line 1417...
1415
{
1417
{
1416
    char *p;
1418
    char *p;
1417
 
1419
 
1418
    closerect();
1420
    closerect();
1419
    if ( clipboardhastext() &&
1421
    if ( clipboardhastext() &&
1420
	 !getstringfromclipboard(buf, 1999) ) {
1422
	 !getstringfromclipboard(buf, BUFSIZE-1) ) {
1421
	/* set current cell to first line of clipboard */
1423
	/* set current cell to first line of clipboard */
1422
	CellModified = TRUE;
1424
	CellModified = TRUE;
1423
	if ((p = strchr(buf, '\n'))) *p = '\0';
1425
	if ((p = strchr(buf, '\n'))) *p = '\0';
1424
	clength = strlen(buf);
1426
	clength = strlen(buf);
1425
	bufp = buf + clength;
1427
	bufp = buf + clength;