The R Project SVN R

Rev

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

Rev 49591 Rev 51659
Line 1046... Line 1046...
1046
	SET_VECTOR_ELT(DE->work, wcol - 1, tmp2);
1046
	SET_VECTOR_ELT(DE->work, wcol - 1, tmp2);
1047
    }
1047
    }
1048
    return newcol;
1048
    return newcol;
1049
}
1049
}
1050
 
1050
 
1051
static SEXP lang5(SEXP s, SEXP t, SEXP u, SEXP v, SEXP w)
-
 
1052
{
-
 
1053
    PROTECT(s);
-
 
1054
    s = LCONS(s, list4(t, u, v, w));
-
 
1055
    UNPROTECT(1);
-
 
1056
    return s;
-
 
1057
}
-
 
1058
 
-
 
1059
static SEXP processEscapes(SEXP x)
1051
static SEXP processEscapes(SEXP x)
1060
{
1052
{
1061
    SEXP newval, pattern, replacement, expr;
1053
    SEXP newval, pattern, replacement, expr;
1062
    ParseStatus status;
1054
    ParseStatus status;
1063
    
1055
 
1064
    /* We process escape sequences in a scalar string by escaping
1056
    /* We process escape sequences in a scalar string by escaping
1065
       unescaped quotes, then quoting the whole thing and parsing it.  This
1057
       unescaped quotes, then quoting the whole thing and parsing it.  This
1066
       is supposed to be equivalent to the R code
1058
       is supposed to be equivalent to the R code
1067
 
1059
 
1068
       newval <- gsub(perl=TRUE, "(?<!\\\\)((\\\\\\\\)*)\"", "\\1\\\\\"", x)
1060
       newval <- gsub(perl=TRUE, "(?<!\\\\)((\\\\\\\\)*)\"", "\\1\\\\\"", x)
Line 1070... Line 1062...
1070
       newval <- eval(parse(text=newval))
1062
       newval <- eval(parse(text=newval))
1071
 
1063
 
1072
       We do it this way to avoid extracting the escape handling
1064
       We do it this way to avoid extracting the escape handling
1073
       code from the parser.  We need it in C code because this may be executed
1065
       code from the parser.  We need it in C code because this may be executed
1074
       numerous times from C in dataentry.c */
1066
       numerous times from C in dataentry.c */
1075
    	
1067
 
1076
    PROTECT( pattern = mkString("(?<!\\\\)((\\\\\\\\)*)\"") );
1068
    PROTECT( pattern = mkString("(?<!\\\\)((\\\\\\\\)*)\"") );
1077
    PROTECT( replacement = mkString("\\1\\\\\"") );
1069
    PROTECT( replacement = mkString("\\1\\\\\"") );
1078
    PROTECT( expr = lang5(install("gsub"), ScalarLogical(1), pattern, replacement, x) );
1070
    PROTECT( expr = lang5(install("gsub"), ScalarLogical(1), pattern, replacement, x) );
1079
    SET_TAG( CDR(expr), install("perl") );
1071
    SET_TAG( CDR(expr), install("perl") );
1080
 
1072
 
Line 1082... Line 1074...
1082
    PROTECT( pattern = mkString("(^.*$)") );
1074
    PROTECT( pattern = mkString("(^.*$)") );
1083
    PROTECT( replacement = mkString("\"\\1\"") );
1075
    PROTECT( replacement = mkString("\"\\1\"") );
1084
    PROTECT( expr = lang4(install("sub"), pattern, replacement, newval) );
1076
    PROTECT( expr = lang4(install("sub"), pattern, replacement, newval) );
1085
    PROTECT( newval = eval(expr, R_BaseEnv) );
1077
    PROTECT( newval = eval(expr, R_BaseEnv) );
1086
    PROTECT( expr = R_ParseVector( newval, 1, &status, R_NilValue) );
1078
    PROTECT( expr = R_ParseVector( newval, 1, &status, R_NilValue) );
1087
    
1079
 
1088
    /* We only handle the first entry. If this were available more generally,
1080
    /* We only handle the first entry. If this were available more generally,
1089
       we'd probably want to loop over all of expr */
1081
       we'd probably want to loop over all of expr */
1090
       
1082
 
1091
    if (status == PARSE_OK && length(expr))
1083
    if (status == PARSE_OK && length(expr))
1092
	PROTECT( newval = eval(VECTOR_ELT(expr, 0), R_BaseEnv) );
1084
	PROTECT( newval = eval(VECTOR_ELT(expr, 0), R_BaseEnv) );
1093
    else
1085
    else
1094
	PROTECT( newval = R_NilValue );  /* protect just so the count doesn't change */
1086
	PROTECT( newval = R_NilValue );  /* protect just so the count doesn't change */
1095
    UNPROTECT(10);
1087
    UNPROTECT(10);
Line 1664... Line 1656...
1664
    else if (iokey == XK_Page_Down) {
1656
    else if (iokey == XK_Page_Down) {
1665
	if(DE->isEditor)
1657
	if(DE->isEditor)
1666
	    jumpwin(DE, DE->colmin, DE->rowmax);
1658
	    jumpwin(DE, DE->colmin, DE->rowmax);
1667
	else {
1659
	else {
1668
	    int i = DE->ymaxused - DE->nhigh + 2;
1660
	    int i = DE->ymaxused - DE->nhigh + 2;
1669
            jumpwin(DE, DE->colmin, min(i, DE->rowmax));	    
1661
            jumpwin(DE, DE->colmin, min(i, DE->rowmax));
1670
	}
1662
	}
1671
	cell_cursor_init(DE);
1663
	cell_cursor_init(DE);
1672
    }
1664
    }
1673
#elif defined(XK_Next)
1665
#elif defined(XK_Next)
1674
    else if (iokey == XK_Next) {
1666
    else if (iokey == XK_Next) {
1675
	if(DE->isEditor)
1667
	if(DE->isEditor)
1676
	    jumpwin(DE, DE->colmin, DE->rowmax);
1668
	    jumpwin(DE, DE->colmin, DE->rowmax);
1677
	else {
1669
	else {
1678
	    int i = DE->ymaxused - DE->nhigh + 2;
1670
	    int i = DE->ymaxused - DE->nhigh + 2;
1679
            jumpwin(DE, DE->colmin, min(i, DE->rowmax));	    
1671
            jumpwin(DE, DE->colmin, min(i, DE->rowmax));
1680
	}
1672
	}
1681
	cell_cursor_init(DE);
1673
	cell_cursor_init(DE);
1682
    }
1674
    }
1683
#endif
1675
#endif
1684
    else if (DE->isEditor && (iokey == XK_BackSpace || iokey == XK_Delete)) {
1676
    else if (DE->isEditor && (iokey == XK_BackSpace || iokey == XK_Delete)) {