From 537433f57aa844a893f1d6ea4f4b95c62ff3ca9a Mon Sep 17 00:00:00 2001 From: Michael Jennings Date: Wed, 18 Aug 1999 22:00:59 +0000 Subject: [PATCH] Wed Aug 18 14:58:08 PDT 1999 Michael Jennings Cleanups on the automake/libtool stuff in src/. Thanks to John Ellson for getting me interested enough to set about fixing it. :-) Also cleaned up the XIM code to fit with the rest of Eterm. SVN revision: 54 --- ChangeLog | 9 ++ configure.in | 2 +- src/Makefile.am | 11 +-- src/command.c | 229 +++++++++++++++++++----------------------------- 4 files changed, 105 insertions(+), 146 deletions(-) diff --git a/ChangeLog b/ChangeLog index 96f83fd..f28a4a3 100644 --- a/ChangeLog +++ b/ChangeLog @@ -2280,3 +2280,12 @@ Tue Aug 17 18:06:01 PDT 1999 Michael Jennings code, but it's now 0.9. It also includes a timer subsystem. ------------------------------------------------------------------------------- +Wed Aug 18 14:58:08 PDT 1999 Michael Jennings + + Cleanups on the automake/libtool stuff in src/. Thanks to John + Ellson for getting me interested enough to set + about fixing it. :-) + + Also cleaned up the XIM code to fit with the rest of Eterm. + +------------------------------------------------------------------------------- diff --git a/configure.in b/configure.in index c019ff0..f5a9c94 100644 --- a/configure.in +++ b/configure.in @@ -6,7 +6,7 @@ AM_INIT_AUTOMAKE(Eterm, 0.9) dnl# Set some basic variables DATE="`date '+%d %B %Y'`" AC_SUBST(DATE) -AUTHORS="Tuomo Venalainen (vendu@cc.hut.fi) and Michael Jennings (mej@eterm.org)" +AUTHORS="Michael Jennings (mej@eterm.org) and Tuomo Venäläinen (vendu@cc.hut.fi) " AC_SUBST(AUTHORS) dnl# Supply default CFLAGS, if not specified by `CFLAGS=flags ./configure' diff --git a/src/Makefile.am b/src/Makefile.am index 1d2f4f2..61a952b 100644 --- a/src/Makefile.am +++ b/src/Makefile.am @@ -4,19 +4,16 @@ lib_LTLIBRARIES = libEterm.la libEterm_la_SOURCES = actions.c command.c e.c events.c graphics.c grkelot.c menus.c misc.c netdisp.c \ options.c pixmap.c screen.c scrollbar.c system.c term.c threads.c timer.c utmp.c windows.c - +libEterm_la_DEPENDENCIES = $(DIST_ROOT)/libmej/libmej.la feature.h libEterm_la_LDFLAGS = -version-info 9:0:9 bin_PROGRAMS = Eterm - Eterm_SOURCES = main.c - -Eterm_DEPENDENCIES = libEterm.la ../libmej/libmej.la feature.h +Eterm_DEPENDENCIES = libEterm.la +Eterm_LDFLAGS = -rpath $(libdir):$(pkglibdir) libEterm.la INCLUDES = -I. -I$(top_srcdir)/libmej -I.. -I$(includedir) -I$(prefix)/include $(X_CFLAGS) - -Eterm_LDFLAGS = -rpath $(libdir):$(pkglibdir) -LDADD = -L$(DIST_ROOT)/src/.libs -lEterm -L$(DIST_ROOT)/libmej/.libs -L$(libdir) -L$(prefix)/lib $(LIBS) -lmej $(GRLIBS) $(X_LIBS) +LDADD = $(DIST_ROOT)/libmej/libmej.la -L$(libdir) -L$(prefix)/lib $(LIBS) $(GRLIBS) $(X_LIBS) EXTRA_DIST = actions.h command.h debug.h e.h eterm_utmp.h events.h feature.h graphics.h grkelot.h grx.h main.h menus.h misc.h \ options.h pixmap.h profile.h screen.h scrollbar.h system.h term.h threads.h timer.h windows.h graphics/Makefile.am \ diff --git a/src/command.c b/src/command.c index 261c0b5..4bde27b 100644 --- a/src/command.c +++ b/src/command.c @@ -1690,48 +1690,44 @@ create_fontset(const char *font1, const char *font2) #ifdef USE_XIM static int xim_real_init(void); # ifdef USE_X11R6_XIM -static void xim_destroy_cb(XIM xim, XPointer client_data, - XPointer call_data); -static void xim_instantiate_cb(Display *display, XPointer client_data, - XPointer call_data); +static void xim_destroy_cb(XIM xim, XPointer client_data, XPointer call_data); +static void xim_instantiate_cb(Display *display, XPointer client_data, XPointer call_data); # endif #endif - void init_locale(void) { - char *locale = NULL; + char *locale = NULL; - locale = setlocale(LC_CTYPE, ""); - TermWin.fontset = (XFontSet) -1; - if (locale == NULL) - print_error("Setting locale failed."); - else { + locale = setlocale(LC_CTYPE, ""); + TermWin.fontset = (XFontSet) -1; + if (locale == NULL) { + print_error("Setting locale failed."); + } else { #ifdef MULTI_CHARSET - TermWin.fontset = create_fontset(rs_font[0], rs_mfont[0]); + TermWin.fontset = create_fontset(rs_font[0], rs_mfont[0]); #else - TermWin.fontset = create_fontset(rs_font[0], (const char *) NULL); + TermWin.fontset = create_fontset(rs_font[0], (const char *) NULL); #endif #ifdef USE_XIM # ifdef MULTI_CHARSET - if (strcmp(locale, "C")) + if (strcmp(locale, "C")) # endif { - if (xim_real_init() != -1) - return; + if (xim_real_init() != -1) { + return; + } # ifdef USE_X11R6_XIM - XRegisterIMInstantiateCallback(Xdisplay, NULL, NULL, NULL, - xim_instantiate_cb, NULL); + XRegisterIMInstantiateCallback(Xdisplay, NULL, NULL, NULL, xim_instantiate_cb, NULL); # endif } #endif - } + } } #endif /* USE_XIM || MULTI_CHARSET */ #ifdef USE_XIM - static void xim_set_size(XRectangle * size) { @@ -1751,19 +1747,19 @@ xim_set_color(unsigned long *fg, unsigned long *bg) static void xim_send_spot(void) { - XPoint spot; - XVaNestedList preedit_attr; - XIMStyle input_style; + XPoint spot; + XVaNestedList preedit_attr; + XIMStyle input_style; - if (Input_Context == NULL) + if (Input_Context == NULL) { return; - else { + } else { XGetICValues(Input_Context, XNInputStyle, &input_style, NULL); - if (!(input_style & XIMPreeditPosition)) + if (!(input_style & XIMPreeditPosition)) { return; + } } xim_get_position(&spot); - preedit_attr = XVaCreateNestedList(0, XNSpotLocation, &spot, NULL); XSetICValues(Input_Context, XNPreeditAttributes, preedit_attr, NULL); XFree(preedit_attr); @@ -1773,22 +1769,16 @@ static void xim_get_area(XRectangle *preedit_rect, XRectangle *status_rect, XRectangle *needed_rect) { - preedit_rect->x = needed_rect->width - + (scrollbar_visible() && !(Options & Opt_scrollBar_right) - ? (SB_WIDTH) : 0); + preedit_rect->x = needed_rect->width + (scrollbar_visible() && !(Options & Opt_scrollBar_right) ? (scrollBar.width) : 0); preedit_rect->y = Height2Pixel(TermWin.nrow - 1); - preedit_rect->width = Width2Pixel(TermWin.ncol + 1) - needed_rect->width - + (!(Options & Opt_scrollBar_right) - ? (SB_WIDTH) : 0); + preedit_rect->width = Width2Pixel(TermWin.ncol + 1) - needed_rect->width + (!(Options & Opt_scrollBar_right) ? (scrollBar.width) : 0); preedit_rect->height = Height2Pixel(1); - status_rect->x = (scrollbar_visible() && !(Options & Opt_scrollBar_right)) - ? (SB_WIDTH) : 0; + status_rect->x = (scrollbar_visible() && !(Options & Opt_scrollBar_right)) ? (scrollBar.width) : 0; status_rect->y = Height2Pixel(TermWin.nrow - 1); - status_rect->width = needed_rect->width ? needed_rect->width - : Width2Pixel(TermWin.ncol + 1); + status_rect->width = needed_rect->width ? needed_rect->width : Width2Pixel(TermWin.ncol + 1); status_rect->height = Height2Pixel(1); } @@ -1797,75 +1787,77 @@ static void xim_destroy_cb(XIM xim, XPointer client_data, XPointer call_data) { Input_Context = NULL; - XRegisterIMInstantiateCallback(Xdisplay, NULL, NULL, NULL, - xim_instantiate_cb, NULL); + XRegisterIMInstantiateCallback(Xdisplay, NULL, NULL, NULL, xim_instantiate_cb, NULL); } static void -xim_instantiate_cb(Display *display, XPointer client_data, - XPointer call_data) +xim_instantiate_cb(Display *display, XPointer client_data, XPointer call_data) { xim_real_init(); - if (Input_Context) - XUnregisterIMInstantiateCallback(Xdisplay, NULL, NULL, NULL, - xim_instantiate_cb, NULL); + if (Input_Context) { + XUnregisterIMInstantiateCallback(Xdisplay, NULL, NULL, NULL, xim_instantiate_cb, NULL); + } } #endif static int xim_real_init(void) { - char *p, *s, buf[64], tmp[1024]; - char *end, *next_s; - XIM xim = NULL; - XIMStyle input_style = 0; - XIMStyles *xim_styles = NULL; - int found; - XPoint spot; - XRectangle rect, status_rect, needed_rect; - unsigned long fg, bg; - XVaNestedList preedit_attr = NULL; - XVaNestedList status_attr = NULL; + char *p, *s, buf[64], tmp[1024]; + char *end, *next_s; + XIM xim = NULL; + XIMStyle input_style = 0; + XIMStyles *xim_styles = NULL; + int found; + XPoint spot; + XRectangle rect, status_rect, needed_rect; + unsigned long fg, bg; + XVaNestedList preedit_attr = NULL; + XVaNestedList status_attr = NULL; - if (Input_Context) - return 0; + REQUIRE(Input_Context != NULL); if (rs_inputMethod && *rs_inputMethod) { strncpy(tmp, rs_inputMethod, sizeof(tmp) - 1); for (s = tmp; *s; s = next_s + 1) { - for (; *s && isspace(*s); s++) ; - if (!*s) + for (; *s && isspace(*s); s++); + if (!*s) { break; - for (end = s; (*end && (*end != ',')); end++) ; - for (next_s = end--; ((end >= s) && isspace(*end)); end--) ; + } + for (end = s; (*end && (*end != ',')); end++); + for (next_s = end--; ((end >= s) && isspace(*end)); end--); *(end + 1) = '\0'; - if (*s) { snprintf(buf, sizeof(buf), "@im=%s", s); - if ((p = XSetLocaleModifiers(buf)) != NULL && *p - && (xim = XOpenIM(Xdisplay, NULL, NULL, NULL)) != NULL) + if (((p = XSetLocaleModifiers(buf)) != NULL) && (*p) && ((xim = XOpenIM(Xdisplay, NULL, NULL, NULL)) != NULL)) { break; + } } - if (!*next_s) + if (!*next_s) { break; + } } } /* try with XMODIFIERS env. var. */ - if (xim == NULL && (p = XSetLocaleModifiers("")) != NULL && *p) + if (xim == NULL && (p = XSetLocaleModifiers("")) != NULL && *p) { xim = XOpenIM(Xdisplay, NULL, NULL, NULL); + } #ifndef USE_X11R6_XIM /* try with no modifiers base */ - if (xim == NULL && (p = XSetLocaleModifiers("@im=none")) != NULL && *p) + if (xim == NULL && (p = XSetLocaleModifiers("@im=none")) != NULL && *p) { xim = XOpenIM(Xdisplay, NULL, NULL, NULL); + } #endif - if (xim == NULL) + if (xim == NULL) { xim = XOpenIM(Xdisplay, NULL, NULL, NULL); + } - if (xim == NULL) + if (xim == NULL) { return -1; + } #ifdef USE_X11R6_XIM { @@ -1873,36 +1865,36 @@ xim_real_init(void) destroy_cb.callback = xim_destroy_cb; destroy_cb.client_data = NULL; - if (XSetIMValues(xim, XNDestroyCallback, &destroy_cb, NULL)) + if (XSetIMValues(xim, XNDestroyCallback, &destroy_cb, NULL)) { print_error("Could not set destroy callback to IM"); + } } #endif - if (XGetIMValues(xim, XNQueryInputStyle, &xim_styles, NULL) - || !xim_styles) { + if ((XGetIMValues(xim, XNQueryInputStyle, &xim_styles, NULL)) || (!xim_styles)) { print_error("input method doesn't support any style"); XCloseIM(xim); return -1; } - strncpy(tmp, (rs_preeditType ? rs_preeditType - : "OverTheSpot,OffTheSpot,Root"), - sizeof(tmp) - 1); + strncpy(tmp, (rs_preeditType ? rs_preeditType : "OverTheSpot,OffTheSpot,Root"), sizeof(tmp) - 1); for (found = 0, s = tmp; *s && !found; s = next_s + 1) { unsigned short i; - for (; *s && isspace(*s); s++) ; - if (!*s) + for (; *s && isspace(*s); s++); + if (!*s) { break; - for (end = s; (*end && (*end != ',')); end++) ; - for (next_s = end--; ((end >= s) && isspace(*end)); end--) ; + } + for (end = s; (*end && (*end != ',')); end++); + for (next_s = end--; ((end >= s) && isspace(*end)); end--); *(end + 1) = '\0'; - if (!strcmp(s, "OverTheSpot")) + if (!strcmp(s, "OverTheSpot")) { input_style = (XIMPreeditPosition | XIMStatusNothing); - else if (!strcmp(s, "OffTheSpot")) + } else if (!strcmp(s, "OffTheSpot")) { input_style = (XIMPreeditArea | XIMStatusArea); - else if (!strcmp(s, "Root")) + } else if (!strcmp(s, "Root")) { input_style = (XIMPreeditNothing | XIMStatusNothing); + } for (i = 0; i < xim_styles->count_styles; i++) { if (input_style == xim_styles->supported_styles[i]) { @@ -1918,8 +1910,7 @@ xim_real_init(void) XCloseIM(xim); return -1; } - if ((input_style != (XIMPreeditNothing | XIMStatusNothing)) - && (input_style != (XIMPreeditArea | XIMStatusArea)) + if ((input_style != (XIMPreeditNothing | XIMStatusNothing)) && (input_style != (XIMPreeditArea | XIMStatusArea)) && (input_style != (XIMPreeditPosition | XIMStatusNothing))) { print_error("This program does not support the preedit type"); XCloseIM(xim); @@ -1929,44 +1920,17 @@ xim_real_init(void) xim_set_size(&rect); xim_get_position(&spot); xim_set_color(&fg, &bg); - - preedit_attr = XVaCreateNestedList(0, XNArea, &rect, - XNSpotLocation, &spot, - XNForeground, fg, - XNBackground, bg, - XNFontSet, TermWin.fontset, - NULL); + preedit_attr = XVaCreateNestedList(0, XNArea, &rect, XNSpotLocation, &spot, XNForeground, fg, XNBackground, bg, XNFontSet, TermWin.fontset, NULL); } else if (input_style & XIMPreeditArea) { xim_set_color(&fg, &bg); - - /* - * The necessary width of preedit area is unknown - * until create input context. - */ + /* The necessary width of preedit area is unknown until create input context. */ needed_rect.width = 0; - xim_get_area(&rect, &status_rect, &needed_rect); - - preedit_attr = XVaCreateNestedList(0, XNArea, &rect, - XNForeground, fg, - XNBackground, bg, - XNFontSet, TermWin.fontset, - NULL); - status_attr = XVaCreateNestedList(0, XNArea, &status_rect, - XNForeground, fg, - XNBackground, bg, - XNFontSet, TermWin.fontset, - NULL); + preedit_attr = XVaCreateNestedList(0, XNArea, &rect, XNForeground, fg, XNBackground, bg, XNFontSet, TermWin.fontset, NULL); + status_attr = XVaCreateNestedList(0, XNArea, &status_rect, XNForeground, fg, XNBackground, bg, XNFontSet, TermWin.fontset, NULL); } - - Input_Context = XCreateIC(xim, XNInputStyle, input_style, - XNClientWindow, TermWin.parent, - XNFocusWindow, TermWin.parent, - preedit_attr ? XNPreeditAttributes : NULL, - preedit_attr, - status_attr ? XNStatusAttributes : NULL, - status_attr, - NULL); + Input_Context = XCreateIC(xim, XNInputStyle, input_style, XNClientWindow, TermWin.parent, XNFocusWindow, TermWin.parent, + preedit_attr ? XNPreeditAttributes : NULL, preedit_attr, status_attr ? XNStatusAttributes : NULL, status_attr, NULL); XFree(preedit_attr); XFree(status_attr); if (Input_Context == NULL) { @@ -1974,7 +1938,6 @@ xim_real_init(void) XCloseIM(xim); return -1; } - if (input_style & XIMPreeditArea) xim_set_status_position(); return 0; @@ -1983,12 +1946,11 @@ xim_real_init(void) void xim_set_status_position(void) { - XIMStyle input_style; - XRectangle preedit_rect, status_rect, *needed_rect; - XVaNestedList preedit_attr, status_attr; + XIMStyle input_style; + XRectangle preedit_rect, status_rect, *needed_rect; + XVaNestedList preedit_attr, status_attr; - if (Input_Context == NULL) - return; + REQUIRE(Input_Context != NULL); XGetICValues(Input_Context, XNInputStyle, &input_style, NULL); @@ -2002,11 +1964,7 @@ xim_set_status_position(void) preedit_attr = XVaCreateNestedList(0, XNArea, &preedit_rect, NULL); status_attr = XVaCreateNestedList(0, XNArea, &status_rect, NULL); - - XSetICValues(Input_Context, - XNPreeditAttributes, preedit_attr, - XNStatusAttributes, status_attr, NULL); - + XSetICValues(Input_Context, XNPreeditAttributes, preedit_attr, XNStatusAttributes, status_attr, NULL); XFree(preedit_attr); XFree(status_attr); } @@ -2014,23 +1972,18 @@ xim_set_status_position(void) void xim_set_fontset(void) { - XIMStyle input_style; - XVaNestedList preedit_attr; - XVaNestedList status_attr; + XIMStyle input_style; + XVaNestedList preedit_attr; + XVaNestedList status_attr; - if (Input_Context == NULL) - return; + REQUIRE(Input_Context != NULL); XGetICValues(Input_Context, XNInputStyle, &input_style, NULL); if (input_style & (XIMPreeditArea | XIMPreeditPosition)) { preedit_attr = XVaCreateNestedList(0, XNFontSet, TermWin.fontset, NULL); status_attr = XVaCreateNestedList(0, XNFontSet, TermWin.fontset, NULL); - - XSetICValues(Input_Context, - XNPreeditAttributes, preedit_attr, - XNStatusAttributes, status_attr, NULL); - + XSetICValues(Input_Context, XNPreeditAttributes, preedit_attr, XNStatusAttributes, status_attr, NULL); XFree(preedit_attr); XFree(status_attr); }