The R Project SVN R

Rev

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

Rev 45067 Rev 45070
Line 84... Line 84...
84
    Rboolean CellModified, CellEditable;
84
    Rboolean CellModified, CellEditable;
85
    int xmaxused, ymaxused;
85
    int xmaxused, ymaxused;
86
    int oldWIDTH, oldHEIGHT;
86
    int oldWIDTH, oldHEIGHT;
87
    int nboxchars;
87
    int nboxchars;
88
    char labform[6];
88
    char labform[6];
89
    int xScrollbarScale, yScrollbarScale;    
89
    int xScrollbarScale, yScrollbarScale;
90
    SEXP work, names, lens;
90
    SEXP work, names, lens;
91
    PROTECT_INDEX wpi, npi, lpi;
91
    PROTECT_INDEX wpi, npi, lpi;
92
    menuitem de_mvw;
92
    menuitem de_mvw;
93
    SEXP ssNA_STRING;
93
    SEXP ssNA_STRING;
94
    Rboolean isEditor;
94
    Rboolean isEditor;
Line 231... Line 231...
231
    DE->inSpecial = 0;
231
    DE->inSpecial = 0;
232
    DE->ccol = 1;
232
    DE->ccol = 1;
233
    DE->crow = 1;
233
    DE->crow = 1;
234
    DE->colmin = 1;
234
    DE->colmin = 1;
235
    DE->rowmin = 1;
235
    DE->rowmin = 1;
236
    PROTECT(DE->ssNA_STRING = duplicate(NA_STRING)); 
236
    PROTECT(DE->ssNA_STRING = duplicate(NA_STRING));
237
    nprotect++;
237
    nprotect++;
238
    DE->bwidth = 0;
238
    DE->bwidth = 0;
239
    DE->hwidth = 5;
239
    DE->hwidth = 5;
240
 
240
 
241
    /* setup work, names, lens  */
241
    /* setup work, names, lens  */
242
    DE->xmaxused = length(DE->work); DE->ymaxused = 0;
242
    DE->xmaxused = length(DE->work); DE->ymaxused = 0;
243
    PROTECT_WITH_INDEX(DE->lens = allocVector(INTSXP, DE->xmaxused), &DE->lpi);
243
    PROTECT_WITH_INDEX(DE->lens = allocVector(INTSXP, DE->xmaxused), &DE->lpi);
244
    nprotect++;
244
    nprotect++;
245
 
245
 
246
    if (isNull(tnames)) {
246
    if (isNull(tnames)) {
247
	PROTECT_WITH_INDEX(DE->names = allocVector(STRSXP, DE->xmaxused), 
247
	PROTECT_WITH_INDEX(DE->names = allocVector(STRSXP, DE->xmaxused),
248
			   &DE->npi);
248
			   &DE->npi);
249
	for(i = 0; i < DE->xmaxused; i++) {
249
	for(i = 0; i < DE->xmaxused; i++) {
250
	    sprintf(clab, "var%d", i);
250
	    sprintf(clab, "var%d", i);
251
	    SET_STRING_ELT(DE->names, i, mkChar(clab));
251
	    SET_STRING_ELT(DE->names, i, mkChar(clab));
252
	}
252
	}
Line 350... Line 350...
350
    DE->windowWidth = w = 2*DE->bwidth + DE->boxw[0] + BOXW(DE->colmin);
350
    DE->windowWidth = w = 2*DE->bwidth + DE->boxw[0] + BOXW(DE->colmin);
351
    DE->nwide = 2;
351
    DE->nwide = 2;
352
    for (i = 2; i < 100; i++) { /* 100 on-screen columns cannot occur */
352
    for (i = 2; i < 100; i++) { /* 100 on-screen columns cannot occur */
353
	dw = BOXW(i + DE->colmin - 1);
353
	dw = BOXW(i + DE->colmin - 1);
354
	if((w += dw) > DE->p->w ||
354
	if((w += dw) > DE->p->w ||
355
	    (!DE->isEditor && i > DE->xmaxused - DE->colmin + 1)
355
	   (!DE->isEditor && i > DE->xmaxused - DE->colmin + 1)
356
	    ) {
356
	    ) {
357
	    DE->nwide = i;
357
	    DE->nwide = i;
358
	    DE->windowWidth = w - dw;
358
	    DE->windowWidth = w - dw;
359
	    break;
359
	    break;
360
	}
360
	}
Line 414... Line 414...
414
}
414
}
415
 
415
 
416
/* find_coords finds the coordinates of the upper left corner of the
416
/* find_coords finds the coordinates of the upper left corner of the
417
   given cell on the screen: row and col are on-screen coords */
417
   given cell on the screen: row and col are on-screen coords */
418
 
418
 
419
static void find_coords(DEstruct DE, 
419
static void find_coords(DEstruct DE,
420
			int row, int col, int *xcoord, int *ycoord)
420
			int row, int col, int *xcoord, int *ycoord)
421
{
421
{
422
    int i, w;
422
    int i, w;
423
    w = DE->bwidth;
423
    w = DE->bwidth;
424
    if (col > 0) w += DE->boxw[0];
424
    if (col > 0) w += DE->boxw[0];
Line 553... Line 553...
553
 
553
 
554
 
554
 
555
/* whichcol is absolute col no, col is position on screen */
555
/* whichcol is absolute col no, col is position on screen */
556
static void drawcol(DEstruct DE, int whichcol)
556
static void drawcol(DEstruct DE, int whichcol)
557
{
557
{
558
    int i, src_x, src_y, len, col = whichcol - DE->colmin + 1, 
558
    int i, src_x, src_y, len, col = whichcol - DE->colmin + 1,
559
	bw = BOXW(whichcol);
559
	bw = BOXW(whichcol);
560
    const char *clab;
560
    const char *clab;
561
    SEXP tmp;
561
    SEXP tmp;
562
 
562
 
563
    find_coords(DE, 0, col, &src_x, &src_y);
563
    find_coords(DE, 0, col, &src_x, &src_y);
Line 568... Line 568...
568
 
568
 
569
    /* now fill it in if it is active */
569
    /* now fill it in if it is active */
570
    clab = get_col_name(DE, whichcol);
570
    clab = get_col_name(DE, whichcol);
571
    printstring(DE, clab, strlen(clab), 0, col, 0);
571
    printstring(DE, clab, strlen(clab), 0, col, 0);
572
 
572
 
573
   if (DE->xmaxused >= whichcol) {
573
    if (DE->xmaxused >= whichcol) {
574
	tmp = VECTOR_ELT(DE->work, whichcol - 1);
574
	tmp = VECTOR_ELT(DE->work, whichcol - 1);
575
	if (!isNull(tmp)) {
575
	if (!isNull(tmp)) {
576
	    len = min(DE->rowmax, INTEGER(DE->lens)[whichcol - 1]);
576
	    len = min(DE->rowmax, INTEGER(DE->lens)[whichcol - 1]);
577
	    for (i = (DE->rowmin - 1); i < len; i++)
577
	    for (i = (DE->rowmin - 1); i < len; i++)
578
		printelt(DE, tmp, i, i - DE->rowmin + 2, col);
578
		printelt(DE, tmp, i, i - DE->rowmin + 2, col);
Line 587... Line 587...
587
    int i, src_x, src_y, row = whichrow - DE->rowmin + 1, w;
587
    int i, src_x, src_y, row = whichrow - DE->rowmin + 1, w;
588
    char rlab[15];
588
    char rlab[15];
589
    SEXP tvec;
589
    SEXP tvec;
590
 
590
 
591
    find_coords(DE, row, 0, &src_x, &src_y);
591
    find_coords(DE, row, 0, &src_x, &src_y);
592
    cleararea(DE, src_x, src_y, DE->windowWidth, DE->box_h, 
592
    cleararea(DE, src_x, src_y, DE->windowWidth, DE->box_h,
593
	      (whichrow > 0) ? DE->p->bg : bbg);
593
	      (whichrow > 0) ? DE->p->bg : bbg);
594
    drawrectangle(DE, src_x, src_y, DE->boxw[0], DE->box_h, 1, 1);
594
    drawrectangle(DE, src_x, src_y, DE->boxw[0], DE->box_h, 1, 1);
595
 
595
 
596
    sprintf(rlab, DE->labform, whichrow);
596
    sprintf(rlab, DE->labform, whichrow);
597
    printstring(DE, rlab, strlen(rlab), row, 0, 0);
597
    printstring(DE, rlab, strlen(rlab), row, 0, 0);
Line 684... Line 684...
684
	doHscroll(DE, DE->colmin + 1);
684
	doHscroll(DE, DE->colmin + 1);
685
	break;
685
	break;
686
    case RIGHT:
686
    case RIGHT:
687
	oldcol = DE->colmin;
687
	oldcol = DE->colmin;
688
	wcol = DE->colmin + DE->ccol + 1; /* column to be selected */
688
	wcol = DE->colmin + DE->ccol + 1; /* column to be selected */
689
        /* There may not be room to fit the next column in */
689
	/* There may not be room to fit the next column in */
690
	w = DE->p->w - DE->boxw[0] - BOXW(DE->colmax + 1);
690
	w = DE->p->w - DE->boxw[0] - BOXW(DE->colmax + 1);
691
	for (i = DE->colmax; i >= oldcol; i--) {
691
	for (i = DE->colmax; i >= oldcol; i--) {
692
	    w -= BOXW(i);
692
	    w -= BOXW(i);
693
	    if(w < 0) {
693
	    if(w < 0) {
694
		DE->colmin = i + 1;
694
		DE->colmin = i + 1;
Line 747... Line 747...
747
	REPROTECT(DE->lens = lengthgets(DE->lens, wcol), DE->lpi);
747
	REPROTECT(DE->lens = lengthgets(DE->lens, wcol), DE->lpi);
748
	DE->xmaxused = wcol;
748
	DE->xmaxused = wcol;
749
    }
749
    }
750
    if (isNull(VECTOR_ELT(DE->work, wcol - 1))) {
750
    if (isNull(VECTOR_ELT(DE->work, wcol - 1))) {
751
	newcol = TRUE;
751
	newcol = TRUE;
752
	SET_VECTOR_ELT(DE->work, wcol - 1, 
752
	SET_VECTOR_ELT(DE->work, wcol - 1,
753
		       ssNewVector(DE, REALSXP, max(100, wrow)));
753
		       ssNewVector(DE, REALSXP, max(100, wrow)));
754
	INTEGER(DE->lens)[wcol - 1] = 0;
754
	INTEGER(DE->lens)[wcol - 1] = 0;
755
    }
755
    }
756
    if (!isVector(tmp = VECTOR_ELT(DE->work, wcol - 1)))
756
    if (!isVector(tmp = VECTOR_ELT(DE->work, wcol - 1)))
757
	error(G_("internal type error in dataentry"));
757
	error(G_("internal type error in dataentry"));
Line 777... Line 777...
777
   into the correct place and as the correct type */
777
   into the correct place and as the correct type */
778
 
778
 
779
static void closerect(DEstruct DE)
779
static void closerect(DEstruct DE)
780
{
780
{
781
    SEXP cvec;
781
    SEXP cvec;
782
    int wcol = DE->ccol + DE->colmin - 1, wrow = DE->rowmin + DE->crow - 1, 
782
    int wcol = DE->ccol + DE->colmin - 1, wrow = DE->rowmin + DE->crow - 1,
783
	wrow0;
783
	wrow0;
784
    Rboolean newcol;
784
    Rboolean newcol;
785
 
785
 
786
    *(DE->bufp) = '\0';
786
    *(DE->bufp) = '\0';
787
 
787
 
Line 839... Line 839...
839
   the print area and print it, left adjusted if necessary; clear the
839
   the print area and print it, left adjusted if necessary; clear the
840
   area of previous text; */
840
   area of previous text; */
841
 
841
 
842
/* This version will only display BUFSIZE chars, but the maximum col width
842
/* This version will only display BUFSIZE chars, but the maximum col width
843
   will not allow that many */
843
   will not allow that many */
844
static void printstring(DEstruct DE, const char *ibuf, int buflen, 
844
static void printstring(DEstruct DE, const char *ibuf, int buflen,
845
			int row, int col, int left)
845
			int row, int col, int left)
846
{
846
{
847
    int x_pos, y_pos, bw, fw, bufw;
847
    int x_pos, y_pos, bw, fw, bufw;
848
    char buf[BUFSIZE+1];
848
    char buf[BUFSIZE+1];
849
 
849
 
Line 871... Line 871...
871
static void clearrect(DEstruct DE)
871
static void clearrect(DEstruct DE)
872
{
872
{
873
    int x_pos, y_pos;
873
    int x_pos, y_pos;
874
 
874
 
875
    find_coords(DE, DE->crow, DE->ccol, &x_pos, &y_pos);
875
    find_coords(DE, DE->crow, DE->ccol, &x_pos, &y_pos);
876
    cleararea(DE, x_pos, y_pos, BOXW(DE->ccol+DE->colmin-1), 
876
    cleararea(DE, x_pos, y_pos, BOXW(DE->ccol+DE->colmin-1),
877
	      DE->box_h, DE->p->bg);
877
	      DE->box_h, DE->p->bg);
878
}
878
}
879
 
879
 
880
/* handlechar has to be able to parse decimal numbers and strings,
880
/* handlechar has to be able to parse decimal numbers and strings,
881
   depending on the current column type, only printing characters
881
   depending on the current column type, only printing characters
Line 952... Line 952...
952
 
952
 
953
    *(DE->bufp)++ = text[0];
953
    *(DE->bufp)++ = text[0];
954
    printstring(DE, DE->buf, DE->clength, DE->crow, DE->ccol, 1);
954
    printstring(DE, DE->buf, DE->clength, DE->crow, DE->ccol, 1);
955
    return;
955
    return;
956
 
956
 
957
 donehc:
957
donehc:
958
    bell();
958
    bell();
959
}
959
}
960
 
960
 
961
static void printlabs(DEstruct DE)
961
static void printlabs(DEstruct DE)
962
{
962
{
Line 972... Line 972...
972
	sprintf(clab, DE->labform, i);
972
	sprintf(clab, DE->labform, i);
973
	printstring(DE, clab, strlen(clab), i - DE->rowmin + 1, 0, 0);
973
	printstring(DE, clab, strlen(clab), i - DE->rowmin + 1, 0, 0);
974
    }
974
    }
975
}
975
}
976
 
976
 
977
              /* ================ GraphApp-specific ================ */
977
	      /* ================ GraphApp-specific ================ */
978
 
978
 
979
static void bell(void)
979
static void bell(void)
980
{
980
{
981
    gabeep();
981
    gabeep();
982
}
982
}
Line 991... Line 991...
991
{
991
{
992
    gfillrect(DE->de, DE->p->bg, rect(0, 0, DE->p->w, DE->p->h));
992
    gfillrect(DE->de, DE->p->bg, rect(0, 0, DE->p->w, DE->p->h));
993
}
993
}
994
 
994
 
995
 
995
 
996
static void drawrectangle(DEstruct DE, 
996
static void drawrectangle(DEstruct DE,
997
			  int xpos, int ypos, int width, int height,
997
			  int xpos, int ypos, int width, int height,
998
			  int lwd, int fore)
998
			  int lwd, int fore)
999
{
999
{
1000
    /* only used on screen, so always fast */
1000
    /* only used on screen, so always fast */
1001
    gdrawrect(DE->de, lwd, 0, (fore==1)? DE->p->ufg: DE->p->bg,
1001
    gdrawrect(DE->de, lwd, 0, (fore==1)? DE->p->ufg: DE->p->bg,
1002
	      rect(xpos, ypos, width, height), 1, PS_ENDCAP_SQUARE, 
1002
	      rect(xpos, ypos, width, height), 1, PS_ENDCAP_SQUARE,
1003
	      PS_JOIN_BEVEL, 10);
1003
	      PS_JOIN_BEVEL, 10);
1004
}
1004
}
1005
 
1005
 
1006
static void de_drawtext(DEstruct DE, int xpos, int ypos, const char *text)
1006
static void de_drawtext(DEstruct DE, int xpos, int ypos, const char *text)
1007
{
1007
{
Line 1058... Line 1058...
1058
	    bell();
1058
	    bell();
1059
	}
1059
	}
1060
    } else if(k == '\b') {
1060
    } else if(k == '\b') {
1061
	moveback(DE);
1061
	moveback(DE);
1062
    } else if(k == '\n' || k == '\r') {
1062
    } else if(k == '\n' || k == '\r') {
1063
	    advancerect(DE, DOWN);
1063
	advancerect(DE, DOWN);
1064
    } else if(k == '\t') {
1064
    } else if(k == '\t') {
1065
	if (st & ShiftKey) advancerect(DE, LEFT);
1065
	if (st & ShiftKey) advancerect(DE, LEFT);
1066
	else advancerect(DE, RIGHT);
1066
	else advancerect(DE, RIGHT);
1067
    } else {
1067
    } else {
1068
	text[0] = k;
1068
	text[0] = k;
Line 1210... Line 1210...
1210
	w = DE->bwidth + DE->boxw[0];
1210
	w = DE->bwidth + DE->boxw[0];
1211
	for (i = 1; i <= DE->nwide; i++)
1211
	for (i = 1; i <= DE->nwide; i++)
1212
	    if((w += BOXW(i+DE->colmin-1)) > xw) {
1212
	    if((w += BOXW(i+DE->colmin-1)) > xw) {
1213
		wcol = i;
1213
		wcol = i;
1214
		break;
1214
		break;
1215
	}
1215
	    }
1216
 
1216
 
1217
	/* see if we selected a line */
1217
	/* see if we selected a line */
1218
	w = DE->bwidth;
1218
	w = DE->bwidth;
1219
	online = 0;
1219
	online = 0;
1220
	for (i = 0; i <= DE->nwide; i++) {
1220
	for (i = 0; i <= DE->nwide; i++) {
Line 1239... Line 1239...
1239
		/* in 0th column */
1239
		/* in 0th column */
1240
		highlightrect(DE);
1240
		highlightrect(DE);
1241
		bell();
1241
		bell();
1242
	    }
1242
	    }
1243
	} else if (wrow > DE->nhigh - 1 || wcol > DE->nwide - 1) {
1243
	} else if (wrow > DE->nhigh - 1 || wcol > DE->nwide - 1) {
1244
		/* off the grid */
1244
	    /* off the grid */
1245
		highlightrect(DE);
1245
	    highlightrect(DE);
1246
		bell();
1246
	    bell();
1247
		return;
1247
	    return;
1248
	} else if (buttons & DblClick) {
1248
	} else if (buttons & DblClick) {
1249
	    int x, y, bw;
1249
	    int x, y, bw;
1250
	    const char *prev;
1250
	    const char *prev;
1251
	    rect rr;
1251
	    rect rr;
1252
 
1252
 
Line 1312... Line 1312...
1312
    if(DE->hwidth > 0)
1312
    if(DE->hwidth > 0)
1313
	gfillrect(DE->de, bbg, rect(0, 0, DE->p->w, DE->hwidth));
1313
	gfillrect(DE->de, bbg, rect(0, 0, DE->p->w, DE->hwidth));
1314
    gfillrect(DE->de, bbg, rect(0, 0, DE->boxw[0], DE->windowHeight));
1314
    gfillrect(DE->de, bbg, rect(0, 0, DE->boxw[0], DE->windowHeight));
1315
 
1315
 
1316
    for (i = 1; i < DE->nhigh; i++)
1316
    for (i = 1; i < DE->nhigh; i++)
1317
	drawrectangle(DE, 0, DE->hwidth + i * DE->box_h, DE->boxw[0], 
1317
	drawrectangle(DE, 0, DE->hwidth + i * DE->box_h, DE->boxw[0],
1318
		      DE->box_h, 1, 1);
1318
		      DE->box_h, 1, 1);
1319
    if(DE->isEditor) {
1319
    if(DE->isEditor) {
1320
	DE->colmax = DE->colmin + (DE->nwide - 2);
1320
	DE->colmax = DE->colmin + (DE->nwide - 2);
1321
	DE->rowmax = DE->rowmin + (DE->nhigh - 2);
1321
	DE->rowmax = DE->rowmin + (DE->nhigh - 2);
1322
    } else {
1322
    } else {
1323
	DE->colmax = min(DE->xmaxused, DE->colmin + (DE->nwide - 2));
1323
	DE->colmax = min(DE->xmaxused, DE->colmin + (DE->nwide - 2));
1324
	DE->rowmax = min(DE->ymaxused, DE->rowmin + (DE->nhigh - 2));
1324
	DE->rowmax = min(DE->ymaxused, DE->rowmin + (DE->nhigh - 2));
1325
    }
1325
    }
1326
    printlabs(DE);
1326
    printlabs(DE);
1327
    for (i = DE->colmin; i <= DE->colmax; i++) drawcol(DE,i);
1327
    for (i = DE->colmin; i <= DE->colmax; i++) drawcol(DE,i);
1328
    gfillrect(DE->de, DE->p->bg, rect(DE->windowWidth+1, DE->hwidth, 
1328
    gfillrect(DE->de, DE->p->bg, rect(DE->windowWidth+1, DE->hwidth,
1329
				      DE->p->w - DE->windowWidth-1,
1329
				      DE->p->w - DE->windowWidth-1,
1330
				      DE->p->h - DE->hwidth));
1330
				      DE->p->h - DE->hwidth));
1331
    highlightrect(DE);
1331
    highlightrect(DE);
1332
}
1332
}
1333
 
1333
 
Line 1438... Line 1438...
1438
	DE->xmaxused = popupcol;
1438
	DE->xmaxused = popupcol;
1439
    }
1439
    }
1440
    tvec = VECTOR_ELT(DE->work, popupcol - 1);
1440
    tvec = VECTOR_ELT(DE->work, popupcol - 1);
1441
    if(ischecked(rb_num) && !isnumeric) {
1441
    if(ischecked(rb_num) && !isnumeric) {
1442
	if (isNull(tvec))
1442
	if (isNull(tvec))
1443
	    SET_VECTOR_ELT(DE->work, popupcol - 1, 
1443
	    SET_VECTOR_ELT(DE->work, popupcol - 1,
1444
			   ssNewVector(DE, REALSXP, 100));
1444
			   ssNewVector(DE, REALSXP, 100));
1445
	else
1445
	else
1446
	    SET_VECTOR_ELT(DE->work, popupcol - 1, coerceVector(tvec, REALSXP));
1446
	    SET_VECTOR_ELT(DE->work, popupcol - 1, coerceVector(tvec, REALSXP));
1447
    } else if(ischecked(rb_char) && isnumeric) {
1447
    } else if(ischecked(rb_char) && isnumeric) {
1448
	if (isNull(tvec))
1448
	if (isNull(tvec))
1449
	    SET_VECTOR_ELT(DE->work, popupcol - 1, 
1449
	    SET_VECTOR_ELT(DE->work, popupcol - 1,
1450
			   ssNewVector(DE, STRSXP, 100));
1450
			   ssNewVector(DE, STRSXP, 100));
1451
	else
1451
	else
1452
	    SET_VECTOR_ELT(DE->work, popupcol - 1, coerceVector(tvec, STRSXP));
1452
	    SET_VECTOR_ELT(DE->work, popupcol - 1, coerceVector(tvec, STRSXP));
1453
    }
1453
    }
1454
    SET_STRING_ELT(DE->names, popupcol - 1, mkChar(buf));
1454
    SET_STRING_ELT(DE->names, popupcol - 1, mkChar(buf));
Line 1543... Line 1543...
1543
    DEstruct DE = getdata(c);
1543
    DEstruct DE = getdata(c);
1544
    if (pos < 0) { /* horizontal */
1544
    if (pos < 0) { /* horizontal */
1545
	DE->colmin = min(DE->xmaxused, -pos*DE->xScrollbarScale);
1545
	DE->colmin = min(DE->xmaxused, -pos*DE->xScrollbarScale);
1546
    } else {
1546
    } else {
1547
	DE->rowmin = 1 + pos*DE->yScrollbarScale;
1547
	DE->rowmin = 1 + pos*DE->yScrollbarScale;
1548
	if(DE->rowmin > DE->ymaxused - DE->nhigh + 2) 
1548
	if(DE->rowmin > DE->ymaxused - DE->nhigh + 2)
1549
	    DE->rowmin = max(1,DE->ymaxused - DE->nhigh + 2);
1549
	    DE->rowmin = max(1,DE->ymaxused - DE->nhigh + 2);
1550
    }
1550
    }
1551
    drawwindow(DE);
1551
    drawwindow(DE);
1552
}
1552
}
1553
 
1553
 
Line 1587... Line 1587...
1587
static void de_popup_vw(DEstruct DE)
1587
static void de_popup_vw(DEstruct DE)
1588
{
1588
{
1589
    char blah[25];
1589
    char blah[25];
1590
 
1590
 
1591
    devw = newwindow(G_("Cell width(s)"),
1591
    devw = newwindow(G_("Cell width(s)"),
1592
		      rect(0, 0, 250, 60),
1592
		     rect(0, 0, 250, 60),
1593
		      Titlebar | Centered | Closebox | Modal);
1593
		     Titlebar | Centered | Closebox | Modal);
1594
    setdata(devw, DE);
1594
    setdata(devw, DE);
1595
    setclose(devw, vw_close);
1595
    setclose(devw, vw_close);
1596
    setbackground(devw, bbg);
1596
    setbackground(devw, bbg);
1597
    lwhat = newlabel(G_("Cell width"), rect(10, 20, 70, 20), AlignLeft);
1597
    lwhat = newlabel(G_("Cell width"), rect(10, 20, 70, 20), AlignLeft);
1598
    sprintf(blah, "%d", DE->nboxchars);
1598
    sprintf(blah, "%d", DE->nboxchars);
Line 1630... Line 1630...
1630
{
1630
{
1631
    DEstruct DE = getdata(c);
1631
    DEstruct DE = getdata(c);
1632
    if (((DE->p->w  == r.width) &&
1632
    if (((DE->p->w  == r.width) &&
1633
	 (DE->p->h == r.height)) ||
1633
	 (DE->p->h == r.height)) ||
1634
	(r.width == 0) || (r.height == 0) ) /* minimize */
1634
	(r.width == 0) || (r.height == 0) ) /* minimize */
1635
        return;;
1635
	return;;
1636
    DE->p->w = r.width;
1636
    DE->p->w = r.width;
1637
    DE->p->h = r.height;
1637
    DE->p->h = r.height;
1638
}
1638
}
1639
 
1639
 
1640
 
1640
 
Line 1665... Line 1665...
1665
 
1665
 
1666
static void depopupact(control m)
1666
static void depopupact(control m)
1667
{
1667
{
1668
    DEstruct DE = getdata(m);
1668
    DEstruct DE = getdata(m);
1669
    /* use this to customize the menu */
1669
    /* use this to customize the menu */
1670
    
1670
 
1671
    if (ismdi())
1671
    if (ismdi())
1672
    	disable(DePopup[6].m);
1672
	disable(DePopup[6].m);
1673
    else {
1673
    else {
1674
    	if (isTopmost(DE->de))
1674
	if (isTopmost(DE->de))
1675
    	    check(DePopup[6].m);
1675
	    check(DePopup[6].m);
1676
    	else
1676
	else
1677
    	    uncheck(DePopup[6].m);
1677
	    uncheck(DePopup[6].m);
1678
    }
1678
    }
1679
}
1679
}
1680
 
1680
 
1681
 
1681
 
1682
#define MCHECK(a) if (!(a)) {del(c);return NULL;}
1682
#define MCHECK(a) if (!(a)) {del(c);return NULL;}
Line 1688... Line 1688...
1688
    int w, h, x, y;
1688
    int w, h, x, y;
1689
    dataeditor c;
1689
    dataeditor c;
1690
    menuitem m;
1690
    menuitem m;
1691
 
1691
 
1692
    DE->p = newconsoledata((consolefn) ? consolefn : FixedFont,
1692
    DE->p = newconsoledata((consolefn) ? consolefn : FixedFont,
1693
		       pagerrow, pagercol, 0, 0,
1693
			   pagerrow, pagercol, 0, 0,
1694
		       consolefg, consoleuser, consolebg,
1694
			   consolefg, consoleuser, consolebg,
1695
		       DATAEDITOR, 0);
1695
			   DATAEDITOR, 0);
1696
    if (!DE->p) return NULL;
1696
    if (!DE->p) return NULL;
1697
 
1697
 
1698
    w = DE->p->w ;
1698
    w = DE->p->w ;
1699
    h = DE->p->h;
1699
    h = DE->p->h;
1700
    if (ismdi()) {
1700
    if (ismdi()) {
Line 1707... Line 1707...
1707
    }
1707
    }
1708
    c = (dataeditor) newwindow(title, rect(x, y, w, h),
1708
    c = (dataeditor) newwindow(title, rect(x, y, w, h),
1709
			       Document | StandardWindow | Menubar |
1709
			       Document | StandardWindow | Menubar |
1710
			       VScrollbar | HScrollbar | TrackMouse);
1710
			       VScrollbar | HScrollbar | TrackMouse);
1711
    if (!c) {
1711
    if (!c) {
1712
         freeConsoleData(DE->p);
1712
	freeConsoleData(DE->p);
1713
         return NULL;
1713
	return NULL;
1714
    }
1714
    }
1715
    setdata(c, DE);
1715
    setdata(c, DE);
1716
    if(h == 0) DE->p->h = getheight(c);
1716
    if(h == 0) DE->p->h = getheight(c);
1717
    if(w == 0) DE->p->w  = getwidth(c);
1717
    if(w == 0) DE->p->w  = getwidth(c);
1718
    (DE->p->cols) = DE->p->w / (DE->p->fw) - 1;
1718
    (DE->p->cols) = DE->p->w / (DE->p->fw) - 1;
Line 1721... Line 1721...
1721
    DE->p->top = (DE->p->h - (DE->p->rows)*(DE->p->fh)) / 2;
1721
    DE->p->top = (DE->p->h - (DE->p->rows)*(DE->p->fh)) / 2;
1722
    gsetcursor(c, ArrowCursor);
1722
    gsetcursor(c, ArrowCursor);
1723
    setbackground(c, consolebg);
1723
    setbackground(c, consolebg);
1724
    if (ismdi() && (RguiMDI & RW_TOOLBAR)) {
1724
    if (ismdi() && (RguiMDI & RW_TOOLBAR)) {
1725
	/* blank toolbar to stop windows jumping around */
1725
	/* blank toolbar to stop windows jumping around */
1726
        int btsize = 24;
1726
	int btsize = 24;
1727
        control tb;
1727
	control tb;
1728
        addto(c);
1728
	addto(c);
1729
        MCHECK(tb = newtoolbar(btsize + 4));
1729
	MCHECK(tb = newtoolbar(btsize + 4));
1730
	gsetcursor(tb, ArrowCursor);
1730
	gsetcursor(tb, ArrowCursor);
1731
    }
1731
    }
1732
    if(DE->isEditor) {
1732
    if(DE->isEditor) {
1733
	MCHECK(m = gpopup(depopupact, DePopup));
1733
	MCHECK(m = gpopup(depopupact, DePopup));
1734
	setdata(m, DE);
1734
	setdata(m, DE);
Line 1751... Line 1751...
1751
	MCHECK(m = newmenuitem(G_("Paste \tCTRL+V"), 0, de_paste));
1751
	MCHECK(m = newmenuitem(G_("Paste \tCTRL+V"), 0, de_paste));
1752
	setdata(m, DE);
1752
	setdata(m, DE);
1753
	MCHECK(m = newmenuitem(G_("Delete\tDEL"), 0, de_delete));
1753
	MCHECK(m = newmenuitem(G_("Delete\tDEL"), 0, de_delete));
1754
	setdata(m, DE);
1754
	setdata(m, DE);
1755
	MCHECK(m = newmenuitem("-", 0, NULL));
1755
	MCHECK(m = newmenuitem("-", 0, NULL));
1756
	MCHECK(m = DE->de_mvw = newmenuitem(G_("Cell widths ..."), 0, 
1756
	MCHECK(m = DE->de_mvw = newmenuitem(G_("Cell widths ..."), 0,
1757
					    menudecellwidth));
1757
					    menudecellwidth));
1758
	setdata(m, DE);
1758
	setdata(m, DE);
1759
	MCHECK(m = newmenu(G_("Help")));
1759
	MCHECK(m = newmenu(G_("Help")));
1760
	MCHECK(newmenuitem(G_("Data editor"), 0, menudehelp));
1760
	MCHECK(newmenuitem(G_("Data editor"), 0, menudehelp));
1761
    }
1761
    }
1762
    
1762
 
1763
    setdata(c, DE); /* Why the repeat? */
1763
    setdata(c, DE); /* Why the repeat? */
1764
    setresize(c, deresize);
1764
    setresize(c, deresize);
1765
    setredraw(c, de_redraw);
1765
    setredraw(c, de_redraw);
1766
    setdel(c, deldataeditor);
1766
    setdel(c, deldataeditor);
1767
    setclose(c, declose);
1767
    setclose(c, declose);
Line 1816... Line 1816...
1816
    DE->inSpecial = 0;
1816
    DE->inSpecial = 0;
1817
    DE->ccol = 1;
1817
    DE->ccol = 1;
1818
    DE->crow = 1;
1818
    DE->crow = 1;
1819
    DE->colmin = 1;
1819
    DE->colmin = 1;
1820
    DE->rowmin = 1;
1820
    DE->rowmin = 1;
1821
    PROTECT(DE->ssNA_STRING = duplicate(NA_STRING)); 
1821
    PROTECT(DE->ssNA_STRING = duplicate(NA_STRING));
1822
    nprotect++;
1822
    nprotect++;
1823
    DE->bwidth = 0;
1823
    DE->bwidth = 0;
1824
    DE->hwidth = 5;
1824
    DE->hwidth = 5;
1825
 
1825
 
1826
    /* setup lens  */
1826
    /* setup lens  */