The R Project SVN R

Rev

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

Rev 45491 Rev 46677
Line 964... Line 964...
964
	    p->needredraw = 1;
964
	    p->needredraw = 1;
965
	}
965
	}
966
    }
966
    }
967
}
967
}
968
 
968
 
-
 
969
/* cmd is in native encoding */
969
void consolecmd(control c, const char *cmd)
970
void consolecmd(control c, const char *cmd)
970
{
971
{
971
    ConsoleData p = getdata(c);
972
    ConsoleData p = getdata(c);
972
 
973
 
973
    const char *ch;
-
 
974
    int i;
974
    int i;
975
    if (p->sel) {
975
    if (p->sel) {
976
	deleteselected(p);
976
	deleteselected(p);
977
	p->sel = 0;
977
	p->sel = 0;
978
	p->needredraw = 1;
978
	p->needredraw = 1;
979
	REDRAW;
979
	REDRAW;
980
    }
980
    }
981
    storekey(c, BEGINLINE);
981
    storekey(c, BEGINLINE);
982
    storekey(c, KILLRESTOFLINE);
982
    storekey(c, KILLRESTOFLINE);
-
 
983
    {
-
 
984
	size_t sz = (strlen(cmd) + 1) * sizeof(wchar_t);
-
 
985
	wchar_t *wcs = (wchar_t *) alloca(sz);
-
 
986
	memset(wcs, 0, sz);
-
 
987
	mbstowcs(wcs, cmd, sz-1);
983
    for (ch = cmd; *ch; ch++) storekey(c, *ch);
988
	for(i = 0; wcs[i]; i++) storekey(c, wcs[i]);
-
 
989
    }
984
    storekey(c, '\n');
990
    storekey(c, '\n');
985
/* if we are editing we save the actual line */
991
/* if we are editing we save the actual line */
986
    if (p->r > -1) {
992
    if (p->r > -1) {
987
	char buf[2000], *cp; /* maximum 2 bytes/char */
993
	char buf[2000], *cp; /* maximum 2 bytes/char */
988
	wchar_t *wc = &(p->lbuf->s[p->lbuf->ns - 1][prompt_len]);
994
	wchar_t *wc = &(p->lbuf->s[p->lbuf->ns - 1][prompt_len]);
Line 1603... Line 1609...
1603
static void wcstobuf(char *buf, int len, const wchar_t *in)
1609
static void wcstobuf(char *buf, int len, const wchar_t *in)
1604
{
1610
{
1605
    int used, tot = 0;
1611
    int used, tot = 0;
1606
    char *p = buf, tmp[7];
1612
    char *p = buf, tmp[7];
1607
    const wchar_t *wc = in;
1613
    const wchar_t *wc = in;
1608
    
1614
 
1609
    for(; wc; wc++, p+=used, tot+=used) {
1615
    for(; wc; wc++, p+=used, tot+=used) {
1610
	if(tot >= len - 2) break;
1616
	if(tot >= len - 2) break;
1611
	used = wctomb(p, *wc);
1617
	used = wctomb(p, *wc);
1612
	if (used < 0) {
1618
	if (used < 0) {
1613
	    snprintf(tmp, 7, "\\u%x", *wc);
1619
	    snprintf(tmp, 7, "\\u%x", *wc);