The R Project SVN R

Rev

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

Rev 46161 Rev 46169
Line 196... Line 196...
196
static char copycontents[sizeof(buf)+1] ;
196
static char copycontents[sizeof(buf)+1] ;
197
 
197
 
198
/* The next few and used only for the editor in MBCS locales */
198
/* The next few and used only for the editor in MBCS locales */
199
#ifdef USE_FONTSET
199
#ifdef USE_FONTSET
200
static Status           status;
200
static Status           status;
201
static XFontSet         font_set;
201
static XFontSet         font_set = NULL;
202
static XFontStruct	**fs_list;
202
static XFontStruct	**fs_list;
203
static int		font_set_cnt;
203
static int		font_set_cnt;
204
static char             fontset_name[]="-*-fixed-medium-r-*-*-*-120-*-*-*-*-*-*";
204
static char             fontset_name[]="-*-fixed-medium-r-*-*-*-120-*-*-*-*-*-*";
205
static XIM		ioim;
205
static XIM		ioim;
206
static XIMStyle         ioim_style;
206
static XIMStyle         ioim_style;
Line 223... Line 223...
223
    XIMStatusArea,
223
    XIMStatusArea,
224
    XIMStatusNothing,
224
    XIMStatusNothing,
225
    XIMStatusNone,
225
    XIMStatusNone,
226
    (XIMStyle)NULL,
226
    (XIMStyle)NULL,
227
};
227
};
228
static XIC ioic;
228
static XIC ioic = NULL;
229
#endif
229
#endif
230
 
230
 
231
#ifndef max
231
#ifndef max
232
#define max(a, b) (((a)>(b))?(a):(b))
232
#define max(a, b) (((a)>(b))?(a):(b))
233
#endif
233
#endif
Line 398... Line 398...
398
    eventloop(DE);
398
    eventloop(DE);
399
 
399
 
400
    endcontext(&cntxt);
400
    endcontext(&cntxt);
401
    closewin(DE);
401
    closewin(DE);
402
    if(nView == 0) {
402
    if(nView == 0) {
-
 
403
	if(fdView >= 0) { /* might be open after viewers, but unlikely */
-
 
404
	    removeInputHandler(&R_InputHandlers,
-
 
405
			       getInputHandler(R_InputHandlers,fdView));
-
 
406
	    fdView = -1;
-
 
407
	}
-
 
408
#ifdef USE_FONTSET
-
 
409
	if(font_set) {
-
 
410
	    XFreeFontSet(iodisplay, font_set);
-
 
411
	    font_set = NULL;
-
 
412
	}
-
 
413
#endif
403
	XCloseDisplay(iodisplay);
414
	XCloseDisplay(iodisplay);
404
	iodisplay = NULL;
415
	iodisplay = NULL;
405
    }
416
    }
406
 
417
 
407
    /* drop out unused columns */
418
    /* drop out unused columns */
Line 1546... Line 1557...
1546
 
1557
 
1547
static void eventloop(DEstruct DE)
1558
static void eventloop(DEstruct DE)
1548
{
1559
{
1549
    int done;
1560
    int done;
1550
    DEEvent ioevent;
1561
    DEEvent ioevent;
-
 
1562
    caddr_t temp;
1551
 
1563
 
1552
    done = 0;
1564
    done = 0;
1553
    while (done == 0) {
1565
    while (done == 0) {
1554
	XNextEvent(iodisplay, &ioevent);
1566
	XNextEvent(iodisplay, &ioevent);
-
 
1567
	XFindContext(iodisplay, ioevent.xany.window, deContext, &temp);
-
 
1568
	if ((DEstruct) temp != DE) { /* so a View window */
-
 
1569
	    if (WhichEvent(ioevent) == Expose)
-
 
1570
		drawwindow((DEstruct) temp);
1555
	{
1571
	} else {
1556
#ifdef USE_FONTSET
1572
#ifdef USE_FONTSET
1557
	    if (XFilterEvent(&ioevent, None)){
1573
	    if (XFilterEvent(&ioevent, None)){
1558
		if(ioic){
1574
		if(ioic){
1559
		    XSetICFocus(ioic);
1575
		    XSetICFocus(ioic);
1560
		    if (ioim_style & XIMPreeditPosition)
1576
		    if (ioim_style & XIMPreeditPosition)
Line 1622... Line 1638...
1622
    caddr_t temp;
1638
    caddr_t temp;
1623
    DEstruct DE = NULL;
1639
    DEstruct DE = NULL;
1624
    DEEvent ioevent;
1640
    DEEvent ioevent;
1625
    int done = 0;
1641
    int done = 0;
1626
 
1642
 
1627
    while (XPending(iodisplay)) {
1643
    while (nView && XPending(iodisplay)) {
1628
	XNextEvent(iodisplay, &ioevent);
1644
	XNextEvent(iodisplay, &ioevent);
1629
	XFindContext(iodisplay, ioevent.xany.window, deContext, &temp);
1645
	XFindContext(iodisplay, ioevent.xany.window, deContext, &temp);
1630
	DE = (DEstruct) temp;
1646
	DE = (DEstruct) temp;
1631
	switch (WhichEvent(ioevent)) {
1647
	switch (WhichEvent(ioevent)) {
1632
	case keyDown:/* KeyPress */
1648
	case keyDown:/* KeyPress */
Line 1662... Line 1678...
1662
	R_ReleaseObject(DE->work);
1678
	R_ReleaseObject(DE->work);
1663
	closewin(DE);
1679
	closewin(DE);
1664
	free(DE);
1680
	free(DE);
1665
	nView--;
1681
	nView--;
1666
	if(nView == 0) {
1682
	if(nView == 0) {
-
 
1683
	    /* NB: this is removing the handler that is currently
-
 
1684
	       being used: only OK to free here in R > 2.8.0 */
1667
	    removeInputHandler(&R_InputHandlers,
1685
	    removeInputHandler(&R_InputHandlers,
1668
			       getInputHandler(R_InputHandlers,fdView));
1686
			       getInputHandler(R_InputHandlers,fdView));
1669
	    fdView = -1;
1687
	    fdView = -1;
-
 
1688
#ifdef USE_FONTSET
-
 
1689
	    if(font_set) {
-
 
1690
		XFreeFontSet(iodisplay, font_set);
-
 
1691
		font_set = NULL;
-
 
1692
	    }
-
 
1693
#endif
1670
	    XCloseDisplay(iodisplay);
1694
	    XCloseDisplay(iodisplay);
1671
	    iodisplay = NULL;
1695
	    iodisplay = NULL;
1672
	}
1696
	}
1673
 
1697
 
1674
    }
1698
    }
Line 1985... Line 2009...
1985
	if(isString(opt)) {
2009
	if(isString(opt)) {
1986
	    const char *s = CHAR(STRING_ELT(opt, 0));
2010
	    const char *s = CHAR(STRING_ELT(opt, 0));
1987
	    sprintf(opt_fontset_name, s, "medium", "r", 12);
2011
	    sprintf(opt_fontset_name, s, "medium", "r", 12);
1988
	} else strcpy(opt_fontset_name, fontset_name);
2012
	} else strcpy(opt_fontset_name, fontset_name);
1989
 
2013
 
-
 
2014
	if(font_set == NULL) {
1990
	font_set = XCreateFontSet(iodisplay, opt_fontset_name,
2015
	    font_set = XCreateFontSet(iodisplay, opt_fontset_name,
1991
				  &missing_charset_list,
2016
				      &missing_charset_list,
1992
				  &missing_charset_count, &def_string);
2017
				      &missing_charset_count, &def_string);
1993
	if (missing_charset_count) XFreeStringList(missing_charset_list);
2018
	    if (missing_charset_count) XFreeStringList(missing_charset_list);
-
 
2019
	}
1994
	if (font_set == NULL) {
2020
	if (font_set == NULL) {
1995
	    warning("unable to create fontset %s", opt_fontset_name);
2021
	    warning("unable to create fontset %s", opt_fontset_name);
1996
	    return TRUE; /* ERROR */
2022
	    return TRUE; /* ERROR */
1997
	}
2023
	}
1998
    } else
2024
    } else
Line 2156... Line 2182...
2156
     */
2182
     */
2157
 
2183
 
2158
    DE->iogc = XCreateGC(iodisplay, DE->iowindow, 0, 0);
2184
    DE->iogc = XCreateGC(iodisplay, DE->iowindow, 0, 0);
2159
 
2185
 
2160
#ifdef USE_FONTSET
2186
#ifdef USE_FONTSET
2161
    if(mbcslocale) {
2187
    if(mbcslocale && DE->isEditor) {
2162
	ioim = XOpenIM(iodisplay, NULL, NULL, NULL);
2188
	ioim = XOpenIM(iodisplay, NULL, NULL, NULL);
2163
	if(!ioim) {
2189
	if(!ioim) {
2164
	    XDestroyWindow(iodisplay, DE->iowindow);
2190
	    XDestroyWindow(iodisplay, DE->iowindow);
2165
	    XCloseDisplay(iodisplay);
2191
	    XCloseDisplay(iodisplay);
2166
	    warning("unable to open X Input Method");
2192
	    warning("unable to open X Input Method");