diff -urN AfterStep-1.2-p1/configure.h AfterStep-1.2-p1-I18N/configure.h --- AfterStep-1.2-p1/configure.h Wed Sep 17 17:47:47 1997 +++ AfterStep-1.2-p1-I18N/configure.h Tue Oct 28 21:54:35 1997 @@ -18,6 +18,16 @@ #define XPMLIBRARY -L/usr/X11R6/lib -lXpm /*************************************************************************** + *#define I18N + * If you want to use i18n feature, specify #define I18N + * Then you can use non-english fonts in window title, Icon, + * and Menu. you have to set the locale appropriately before + * you start the window manager. + ***************************************************************************/ +#define I18N + + +/*************************************************************************** * If you don't want the Shaped window extensions, #define NO_SHAPE * Shaped window extensions seem to increase the window managers RSS * by about 60 Kbytes. They provide for leaving a title-bar on the window diff -urN AfterStep-1.2-p1/src/add_window.c AfterStep-1.2-p1-I18N/src/add_window.c --- AfterStep-1.2-p1/src/add_window.c Mon Sep 15 04:20:35 1997 +++ AfterStep-1.2-p1-I18N/src/add_window.c Tue Oct 28 22:32:53 1997 @@ -109,6 +109,10 @@ XrmValue rm_value; unsigned long buttons; XTextProperty text_prop; +#ifdef I18N + char **list; + int num; +#endif NeedToResizeToo = False; /* allocate space for the afterstep window */ @@ -127,10 +131,26 @@ return (NULL); } if (XGetWMName(dpy, tmp_win->w, &text_prop) != 0) - tmp_win->name = (char *) text_prop.value; +#ifdef I18N + { + if (text_prop.value) { + text_prop.nitems = strlen(text_prop.value); + if (text_prop.encoding == XA_STRING) + tmp_win->name = (char *)text_prop.value; + else { + if (XmbTextPropertyToTextList(dpy,&text_prop,&list,&num) >= Success && *list && num > 0) + tmp_win->name = *list; + else + tmp_win->name = (char *)text_prop.value; + } + } else + tmp_win->name = NoName; + } +#else + tmp_win->name = (char *)text_prop.value; +#endif else - tmp_win->name = NoName; - + tmp_win->name = NoName; tmp_win->focus_sequence = 1; SetCirculateSequence(tmp_win, -1); tmp_win->class = NoClass; @@ -261,9 +281,35 @@ return (NULL); } XSetWindowBorderWidth(dpy, tmp_win->w, 0); +#ifdef I18N + if (XGetWindowProperty(dpy, tmp_win->w, XA_WM_ICON_NAME, 0L, 200L, False, + AnyPropertyType, &actual_type, &actual_format, &nitems, + &bytesafter,(unsigned char **)&tmp_win->icon_name) + == Success && actual_type != None) { + text_prop.value = tmp_win->icon_name; + text_prop.encoding = actual_type; + text_prop.format = actual_format; + text_prop.nitems = nitems; + if (text_prop.value) { + text_prop.nitems = strlen(text_prop.value); + if (text_prop.encoding == XA_STRING) + tmp_win->icon_name = (char *)text_prop.value; + else { + if (XmbTextPropertyToTextList(dpy,&text_prop,&list,&num) >= Success + && *list && num > 0) + tmp_win->icon_name = *list; + else + tmp_win->icon_name = (char *)text_prop.value; + } + } else + tmp_win->icon_name = NULL; + } else + tmp_win->icon_name = NULL; +#else XGetWindowProperty(dpy, tmp_win->w, XA_WM_ICON_NAME, 0L, 200L, False, XA_STRING, &actual_type, &actual_format, &nitems, &bytesafter, (unsigned char **) &tmp_win->icon_name); +#endif if (tmp_win->icon_name == (char *) NULL) tmp_win->icon_name = tmp_win->name; @@ -455,9 +501,27 @@ } XChangeWindowAttributes(dpy, tmp_win->w, valuemask, &attributes); if (XGetWMName(dpy, tmp_win->w, &text_prop) != 0) - tmp_win->name = (char *) text_prop.value; +#ifdef I18N + { + if (text_prop.value) { + text_prop.nitems = strlen(text_prop.value); + if (text_prop.encoding == XA_STRING) + tmp_win->name = (char *)text_prop.value; + else { + if (XmbTextPropertyToTextList(dpy,&text_prop,&list,&num) >= Success + && *list && num > 0) + tmp_win->name = *list; + else + tmp_win->name = (char *)text_prop.value; + } + } else + tmp_win->name = NoName; + } +#else + tmp_win->name = (char *)text_prop.value; +#endif else - tmp_win->name = NoName; + tmp_win->name = NoName; #ifndef NO_PAGER if (tmp_win->w != Scr.Pager_w) diff -urN AfterStep-1.2-p1/src/afterstep.c AfterStep-1.2-p1-I18N/src/afterstep.c --- AfterStep-1.2-p1/src/afterstep.c Mon Sep 15 04:20:35 1997 +++ AfterStep-1.2-p1-I18N/src/afterstep.c Tue Oct 28 20:42:34 1997 @@ -66,6 +66,10 @@ #include #endif /* ! NO_SHAPE */ +#ifdef I18N +#include +#endif + #if defined (sparc) && defined (SVR4) /* Solaris has sysinfo instead of gethostname. */ #include @@ -157,6 +161,10 @@ Bool single = False; Bool option_error = FALSE; +#ifdef I18N + if (setlocale(LC_CTYPE, "") == NULL) + afterstep_err("can't set locale", NULL, NULL, NULL); +#endif for (i = 1; i < argc; i++) { if (mystrncasecmp(argv[i], "-debug", 6) == 0) debugging = True; diff -urN AfterStep-1.2-p1/src/afterstep.h AfterStep-1.2-p1-I18N/src/afterstep.h --- AfterStep-1.2-p1/src/afterstep.h Mon Sep 15 04:20:38 1997 +++ AfterStep-1.2-p1-I18N/src/afterstep.h Tue Oct 28 20:44:23 1997 @@ -118,6 +118,9 @@ typedef struct MyFont { char *name; /* name of the font */ XFontStruct *font; /* font structure */ +#ifdef I18N + XFontSet fontset; /* font set */ +#endif int height; /* height of the font */ int y; /* Y coordinate to draw characters */ } MyFont; diff -urN AfterStep-1.2-p1/src/borders.c AfterStep-1.2-p1-I18N/src/borders.c --- AfterStep-1.2-p1/src/borders.c Tue Sep 16 03:54:17 1997 +++ AfterStep-1.2-p1-I18N/src/borders.c Tue Oct 28 22:13:43 1997 @@ -286,6 +286,8 @@ } if ((t->icon_name != NULL) && (Scr.PagerFont.height > 0)) { NewFontAndColor(Scr.PagerFont.font->fid, TextColor, BackColor); +#undef FONTSET +#define FONTSET Scr.PagerFont.fontset XDrawImageString(dpy, t->pager_view, Scr.FontGC, 2, Scr.PagerFont.y + 2, t->icon_name, strlen(t->icon_name)); } @@ -593,6 +595,8 @@ NewFontAndColor(Scr.WindowFont.font->fid, Forecolor, BackColor); +#undef FONTSET +#define FONTSET Scr.WindowFont.fontset if (NewTitle) XClearWindow(dpy, t->title_w); @@ -628,8 +632,13 @@ } if (t->name != (char *) NULL) { if (onoroff && (Textures.flags & GradientText)) { +#ifdef I18N + DrawTexturedText(dpy, t->title_w, Scr.WindowFont.font, Scr.WindowFont.fontset, hor_off, + 4, Scr.TitleGradient, t->name, strlen(t->name)); +#else DrawTexturedText(dpy, t->title_w, Scr.WindowFont.font, hor_off, 4, Scr.TitleGradient, t->name, strlen(t->name)); +#endif } else { XDrawString(dpy, t->title_w, Scr.FontGC, hor_off, Scr.WindowFont.y + 4, diff -urN AfterStep-1.2-p1/src/configure.c AfterStep-1.2-p1-I18N/src/configure.c --- AfterStep-1.2-p1/src/configure.c Tue Sep 16 03:54:54 1997 +++ AfterStep-1.2-p1-I18N/src/configure.c Tue Oct 28 22:50:43 1997 @@ -28,6 +28,10 @@ #include #include +#ifdef I18N +#include +#endif + #include #include @@ -367,6 +371,11 @@ char line[256], *tline; char *Home; /* the HOME environment variable */ int HomeLen; /* length of Home */ + +#ifdef I18N + char *Lang; +#endif + #ifndef NO_TEXTURE int icol, mcol, ucol, tcol, scol; /* texture colors */ int defcol; @@ -410,10 +419,35 @@ strcat(home_file, "/"); strcat(home_file, &config_file[2]); } else { - home_file = safemalloc(HomeLen + strlen(config_file) + 3); - strcpy(home_file, Home); - strcat(home_file, "/"); - strcat(home_file, config_file); +#ifdef I18N + if ((Lang = setlocale(LC_CTYPE, NULL)) != NULL) { + home_file = safemalloc(HomeLen+strlen(Lang)+strlen(config_file)+4); + strcpy(home_file,Home); + strcat(home_file,"/"); + strcat(home_file,Lang); + strcat(home_file,"/"); + strcat(home_file,config_file); + config_fd = fopen(home_file,"r"); + if (config_fd == (FILE *)NULL) { + free(home_file); + home_file = safemalloc(HomeLen+strlen(config_file)+3); + strcpy(home_file,Home); + strcat(home_file,"/"); + strcat(home_file,config_file); + } else + fclose(config_fd); + } else { + home_file = safemalloc(HomeLen+strlen(config_file)+3); + strcpy(home_file,Home); + strcat(home_file,"/"); + strcat(home_file,config_file); + } +#else + home_file = safemalloc(HomeLen+strlen(config_file)+3); + strcpy(home_file,Home); + strcat(home_file,"/"); + strcat(home_file,config_file); +#endif } afterstep_file = home_file; config_fd = fopen(home_file, "r"); @@ -431,7 +465,7 @@ tline = fgets(line, (sizeof line) - 1, config_fd); orig_tline = tline; while (tline != (char *) 0) { - while (isspace(*tline)) + while (isspace((unsigned char)*tline)) tline++; if ((strlen(&tline[0]) > 1) && (tline[0] != '#') && (tline[0] != '*')) match_string(main_config, tline, "error in config:", config_fd); @@ -1243,6 +1277,15 @@ #endif void GetColors(void) { +#ifdef I18N + XFontSetExtents *fset_extents; + XFontStruct **fs_list; + char **ml; + int mc; + char *ds; + char *fn_tmp; + int fn_tmp_length; +#endif extern MyFont *IconFont; if (have_the_colors) @@ -1308,6 +1351,33 @@ } /* load the font */ +#ifdef I18N + if ((Scr.StdFont.fontset = XCreateFontSet(dpy, Scr.StdFont.name, &ml, + &mc, &ds)) == NULL) { + nofont(Scr.StdFont.name); + fn_tmp_length = strlen(Scr.StdFont.name) + strlen(",-*--14-*"); + fn_tmp = malloc(fn_tmp_length + 1); + strcpy(fn_tmp,Scr.StdFont.name); + strcat(fn_tmp,",-*--14-*"); + fprintf(stderr,"Trying... %s\n",fn_tmp); + if ((Scr.StdFont.fontset = XCreateFontSet(dpy, fn_tmp, + &ml, &mc, &ds)) == NULL) { + nofont(fn_tmp); + fprintf(stderr,"Trying... fixed,-*--14-*\n"); + if ((Scr.StdFont.fontset = XCreateFontSet(dpy, "fixed,-*--14-*", + &ml, &mc, &ds)) == NULL) { + fprintf(stderr,"ERROR: no fontset available\n"); + exit(1); + } + } + } + XFontsOfFontSet(Scr.StdFont.fontset, &fs_list, &ml); + Scr.StdFont.font = fs_list[0]; + fset_extents = XExtentsOfFontSet(Scr.StdFont.fontset); + Scr.StdFont.height = fset_extents->max_logical_extent.height; + Scr.StdFont.y = Scr.StdFont.font->ascent; + Scr.EntryHeight = Scr.StdFont.height + HEIGHT_EXTRA +2; +#else if ((Scr.StdFont.font = XLoadQueryFont(dpy, Scr.StdFont.name)) == NULL) { nofont(Scr.StdFont.name); if ((Scr.StdFont.font = XLoadQueryFont(dpy, "fixed")) == NULL) @@ -1316,7 +1386,34 @@ Scr.StdFont.height = Scr.StdFont.font->ascent + Scr.StdFont.font->descent; Scr.StdFont.y = Scr.StdFont.font->ascent; Scr.EntryHeight = Scr.StdFont.height + HEIGHT_EXTRA + 2; +#endif /* load the window-title font */ +#ifdef I18N + if ((Scr.WindowFont.fontset = XCreateFontSet(dpy, Scr.WindowFont.name, &ml, + &mc, &ds)) == NULL) { + nofont(Scr.WindowFont.name); + fn_tmp_length = strlen(Scr.WindowFont.name) + strlen(",-*--14-*"); + fn_tmp = malloc(fn_tmp_length + 1); + strcpy(fn_tmp,Scr.WindowFont.name); + strcat(fn_tmp,",-*--14-*"); + fprintf(stderr,"Trying... %s\n",fn_tmp); + if ((Scr.WindowFont.fontset = XCreateFontSet(dpy, fn_tmp, + &ml, &mc, &ds)) == NULL) { + nofont(fn_tmp); + fprintf(stderr,"Trying... fixed,-*--14-*\n"); + if ((Scr.WindowFont.fontset = XCreateFontSet(dpy, "fixed,-*--14-*", + &ml, &mc, &ds)) == NULL) { + fprintf(stderr,"ERROR: no fontset available\n"); + exit(1); + } + } + } + XFontsOfFontSet(Scr.WindowFont.fontset, &fs_list, &ml); + Scr.WindowFont.font = fs_list[0]; + fset_extents = XExtentsOfFontSet(Scr.WindowFont.fontset); + Scr.WindowFont.height = fset_extents->max_logical_extent.height; + Scr.WindowFont.y = Scr.WindowFont.font->ascent; +#else if ((Scr.WindowFont.font = XLoadQueryFont(dpy, Scr.WindowFont.name)) == NULL) { nofont(Scr.WindowFont.name); if ((Scr.WindowFont.font = XLoadQueryFont(dpy, "fixed")) == NULL) @@ -1325,28 +1422,71 @@ Scr.WindowFont.height = Scr.WindowFont.font->ascent + Scr.WindowFont.font->descent; Scr.WindowFont.y = Scr.WindowFont.font->ascent; +#endif /* load the pager-label font */ #ifndef NO_PAGER - if (Scr.PagerFont.name != NULL) { - if ((Scr.PagerFont.font = XLoadQueryFont(dpy, Scr.PagerFont.name)) != NULL) { - Scr.PagerFont.height = - Scr.PagerFont.font->ascent + Scr.PagerFont.font->descent; - Scr.PagerFont.y = Scr.PagerFont.font->ascent; - } else - nofont(Scr.PagerFont.name); + if (Scr.PagerFont.name != NULL) + { +#ifdef I18N + if ((Scr.PagerFont.fontset = XCreateFontSet(dpy, Scr.PagerFont.name, &ml, + &mc, &ds)) != NULL) { + XFontsOfFontSet(Scr.PagerFont.fontset, &fs_list, &ml); + Scr.PagerFont.font = fs_list[0]; + fset_extents = XExtentsOfFontSet(Scr.PagerFont.fontset); + Scr.PagerFont.height = fset_extents->max_logical_extent.height; + Scr.PagerFont.y = Scr.PagerFont.font->ascent; + } +#else + if ((Scr.PagerFont.font = XLoadQueryFont(dpy, Scr.PagerFont.name)) != NULL) { + Scr.PagerFont.height = + Scr.PagerFont.font->ascent + Scr.PagerFont.font->descent; + Scr.PagerFont.y = Scr.PagerFont.font->ascent; + } +#endif + else + nofont(Scr.PagerFont.name); } #endif IconFont = &Scr.StdFont; if (Scr.IconFont.name != NULL) { - if ((Scr.IconFont.font = XLoadQueryFont(dpy, Scr.IconFont.name)) != NULL) { - Scr.IconFont.height = - Scr.IconFont.font->ascent + Scr.IconFont.font->descent; - Scr.IconFont.y = Scr.IconFont.font->ascent; - IconFont = &Scr.IconFont; - } else - nofont(Scr.IconFont.name); +#ifdef I18N + if ((Scr.IconFont.fontset = XCreateFontSet(dpy, Scr.IconFont.name, &ml, + &mc, &ds)) == NULL) { + nofont(Scr.IconFont.name); + fn_tmp_length = strlen(Scr.IconFont.name) + strlen(",-*--14-*"); + fn_tmp = malloc(fn_tmp_length + 1); + strcpy(fn_tmp,Scr.IconFont.name); + strcat(fn_tmp,",-*--14-*"); + fprintf(stderr,"Trying... %s\n",fn_tmp); + if ((Scr.IconFont.fontset = XCreateFontSet(dpy, fn_tmp, + &ml, &mc, &ds)) == NULL) { + nofont(fn_tmp); + fprintf(stderr,"Trying... fixed,-*--14-*\n"); + if ((Scr.IconFont.fontset = XCreateFontSet(dpy, "fixed,-*--14-*", + &ml, &mc, &ds)) == NULL) { + fprintf(stderr,"ERROR: no fontset available\n"); + exit(1); + } + } + } + + XFontsOfFontSet(Scr.IconFont.fontset, &fs_list, &ml); + Scr.IconFont.font = fs_list[0]; + fset_extents = XExtentsOfFontSet(Scr.IconFont.fontset); + Scr.IconFont.height = fset_extents->max_logical_extent.height; + Scr.IconFont.y = Scr.IconFont.font->ascent; + IconFont = &Scr.IconFont; +#else + if ((Scr.IconFont.font = XLoadQueryFont(dpy, Scr.IconFont.name))!=NULL) { + Scr.IconFont.height= + Scr.IconFont.font->ascent+Scr.IconFont.font->descent; + Scr.IconFont.y = Scr.IconFont.font->ascent; + IconFont = &Scr.IconFont; + } else + nofont(Scr.IconFont.name); +#endif } else { if ((Scr.IconFont.font = XLoadQueryFont(dpy, "fixed")) != NULL) { Scr.IconFont.height = @@ -1398,7 +1538,7 @@ mr = NewMenuRoot(name); GetColors(); - while (isspace(*pline)) + while (isspace((unsigned char)*pline)) pline++; while ((pline != (char *) 0) && (mystrncasecmp("End", pline, 3) != 0)) { @@ -1430,7 +1570,7 @@ orig_tline = pline; - while (isspace(*pline)) + while (isspace((unsigned char)*pline)) pline++; } MakeMenu(mr); @@ -1746,7 +1886,7 @@ cur->x = 5; if (cur->func == F_TITLE) /* Title */ - cur->y_height = NS_TITLE_HEIGHT + 1; + cur->y_height = Scr.EntryHeight; else if (cur->func == F_NOP && *cur->item == 0) /* Separator */ cur->y_height = HEIGHT_SEPARATOR; @@ -2053,11 +2193,11 @@ char *tmp, *ptr; int len; - while (isspace(*source)) + while (isspace((unsigned char)*source)) source++; len = strlen(source); tmp = source + len - 1; - while (((isspace(*tmp)) || (*tmp == '\n')) && (tmp >= source)) { + while (((isspace((unsigned char)*tmp)) || (*tmp == '\n')) && (tmp >= source)) { tmp--; len--; } diff -urN AfterStep-1.2-p1/src/events.c AfterStep-1.2-p1-I18N/src/events.c --- AfterStep-1.2-p1/src/events.c Mon Sep 15 04:20:36 1997 +++ AfterStep-1.2-p1-I18N/src/events.c Tue Oct 28 22:08:58 1997 @@ -343,12 +343,44 @@ int actual_format; unsigned long nitems, bytesafter; +#ifdef I18N + XTextProperty text_prop; + char **list; + int num; + Status status_ret; +#endif + if ((!Tmp_win) || (XGetGeometry(dpy, Tmp_win->w, &JunkRoot, &JunkX, &JunkY, &JunkWidth, &JunkHeight, &JunkBW, &JunkDepth) == 0)) return; switch (Event.xproperty.atom) { case XA_WM_NAME: +#ifdef I18N + if (XGetWindowProperty (dpy, Tmp_win->w, Event.xproperty.atom, 0L, + MAX_NAME_LEN, False, AnyPropertyType, &actual, + &actual_format, &nitems, &bytesafter, + (unsigned char **) &prop) != Success || + actual == None) + return; + text_prop.value = prop; + text_prop.encoding = actual; + text_prop.format = actual_format; + text_prop.nitems = nitems; + if (text_prop.value) { + text_prop.nitems = strlen(text_prop.value); + if (text_prop.encoding == XA_STRING) + prop = (char *)text_prop.value; + else { + if (XmbTextPropertyToTextList(dpy,&text_prop,&list,&num) >= Success + && *list && num > 0) + prop = *list; + else + prop = (char *)text_prop.value; + } + } else + prop = NoName; +#else if (XGetWindowProperty(dpy, Tmp_win->w, Event.xproperty.atom, 0L, MAX_NAME_LEN, False, XA_STRING, &actual, &actual_format, &nitems, &bytesafter, @@ -357,6 +389,7 @@ return; if (!prop) prop = NoName; +#endif free_window_names(Tmp_win, True, False); Tmp_win->name = prop; @@ -381,6 +414,32 @@ break; case XA_WM_ICON_NAME: +#ifdef I18N + if (XGetWindowProperty (dpy, Tmp_win->w, Event.xproperty.atom, 0L, + MAX_NAME_LEN, False, AnyPropertyType, &actual, + &actual_format, &nitems, &bytesafter, + (unsigned char **) &prop) != Success || + actual == None) + return; + text_prop.value = prop; + text_prop.encoding = actual; + text_prop.format = actual_format; + text_prop.nitems = nitems; + if (text_prop.value) { + text_prop.nitems = strlen(text_prop.value); + if (text_prop.encoding == XA_STRING) + prop = (char *)text_prop.value; + else { + if (XmbTextPropertyToTextList(dpy,&text_prop,&list,&num) >= Success + && *list && num > 0) + prop = *list; + else + prop = (char *)text_prop.value; + } + } else + prop = NoName; +#else + if (XGetWindowProperty(dpy, Tmp_win->w, Event.xproperty.atom, 0, MAX_ICON_NAME_LEN, False, XA_STRING, &actual, &actual_format, &nitems, &bytesafter, @@ -389,6 +448,7 @@ return; if (!prop) prop = NoName; +#endif free_window_names(Tmp_win, False, True); Tmp_win->icon_name = prop; BroadcastName(M_ICON_NAME, Tmp_win->w, Tmp_win->frame, diff -urN AfterStep-1.2-p1/src/functions.c AfterStep-1.2-p1-I18N/src/functions.c --- AfterStep-1.2-p1/src/functions.c Mon Sep 15 04:20:36 1997 +++ AfterStep-1.2-p1-I18N/src/functions.c Tue Oct 28 21:18:37 1997 @@ -447,6 +447,8 @@ XClearWindow(dpy, tmp_win->pager_view); if ((tmp_win->icon_name != NULL) && (Scr.PagerFont.height > 0)) { NewFontAndColor(Scr.PagerFont.font->fid, TextColor, BackColor); +#undef FONTSET +#define FONTSET Scr.PagerFont.fontset XDrawString(dpy, tmp_win->pager_view, Scr.FontGC, 2, Scr.PagerFont.y + 2, tmp_win->icon_name, strlen(tmp_win->icon_name)); } diff -urN AfterStep-1.2-p1/src/icons.c AfterStep-1.2-p1-I18N/src/icons.c --- AfterStep-1.2-p1/src/icons.c Mon Sep 15 04:20:36 1997 +++ AfterStep-1.2-p1-I18N/src/icons.c Tue Oct 28 22:51:01 1997 @@ -217,36 +217,26 @@ Tmp_win->icon_p_width - 2, titleH + 6); XSetForeground(dpy, Scr.IconGC, Scr.HiColors.fore); if (Tmp_win->icon_name == NULL) { - if (Tmp_win->name != NULL) { - cnt = strlen(Tmp_win->name); - textX = XTextWidth(Scr.IconFont.font, Tmp_win->name, cnt); - if (textX < Tmp_win->icon_p_width) { - textX = (Tmp_win->icon_p_width - textX) / 2; - text = Tmp_win->name; - } else { - int i; - /* try to find approx. characters that fit here */ - i = (Tmp_win->icon_p_width * cnt) / textX; - textX = 1; - text = &(Tmp_win->name[cnt - i]); - cnt = i; - } - } + if (Tmp_win->name!=NULL) { + cnt = strlen(Tmp_win->name); + textX = XTextWidth(Scr.IconFont.font,Tmp_win->name, cnt); + if (textX > Tmp_win->icon_p_width - 4) + textX = Tmp_win->icon_p_width - 4 - textX; + else + textX = (Tmp_win->icon_p_width - textX)/2; + text = Tmp_win->name; + } } else { - cnt = strlen(Tmp_win->icon_name); - textX = XTextWidth(Scr.IconFont.font, Tmp_win->icon_name, cnt); - if (textX < Tmp_win->icon_p_width) { - textX = (Tmp_win->icon_p_width - textX) / 2; - text = Tmp_win->icon_name; - } else { - int i; - /* try to find approx. characters that fit here */ - i = (Tmp_win->icon_p_width * cnt) / textX; - textX = 1; - text = &(Tmp_win->icon_name[cnt - i]); - cnt = i; - } + cnt = strlen(Tmp_win->icon_name); + textX = XTextWidth(Scr.IconFont.font,Tmp_win->icon_name, cnt); + if (textX > Tmp_win->icon_p_width - 4) + textX = Tmp_win->icon_p_width - 4 - textX; + else + textX = (Tmp_win->icon_p_width - textX)/2; + text = Tmp_win->icon_name; } +#undef FONTSET +#define FONTSET Scr.IconFont.fontset XDrawString(dpy, Tmp_win->icon_pixmap_w, Scr.IconGC, textX, Scr.IconFont.font->ascent + 1, text, cnt); } diff -urN AfterStep-1.2-p1/src/lib/CopyString.c AfterStep-1.2-p1-I18N/src/lib/CopyString.c --- AfterStep-1.2-p1/src/lib/CopyString.c Wed Aug 21 23:23:34 1996 +++ AfterStep-1.2-p1-I18N/src/lib/CopyString.c Tue Oct 28 21:40:20 1997 @@ -12,7 +12,7 @@ int len; char *start; - while(((isspace(*source))&&(*source != '\n'))&&(*source != 0)) + while(((isspace((unsigned char)*source))&&(*source != '\n'))&&(*source != 0)) { source++; } @@ -25,7 +25,7 @@ } source--; - while((isspace(*source))&&(*source != 0)&&(len >0)) + while((isspace((unsigned char)*source))&&(*source != 0)&&(len >0)) { len--; source--; diff -urN AfterStep-1.2-p1/src/menus.c AfterStep-1.2-p1-I18N/src/menus.c --- AfterStep-1.2-p1/src/menus.c Mon Sep 15 04:20:36 1997 +++ AfterStep-1.2-p1-I18N/src/menus.c Tue Oct 28 22:30:38 1997 @@ -127,7 +127,7 @@ } if (ActiveItem) { if (!(Scr.flags & MenusHigh)) - y = MenuY - 10 + ((ActiveItem->item_num) * (ActiveItem->y_height)); + y = MenuY + ((ActiveItem->item_num)*(ActiveItem->y_height))-(Scr.EntryHeight & 1) - (Scr.EntryHeight >> 1); else y = MenuY + (Scr.EntryHeight >> 1); @@ -388,17 +388,37 @@ XChangeGC(dpy, Scr.ScratchGC1, Globalgcm, &Globalgcv); currentGC = Scr.ScratchGC1; } - if (*mi->item) - XDrawString(dpy, mr->w, currentGC, mi->x, text_y, mi->item, mi->strlen); - if (mi->strlen2 > 0) - XDrawString(dpy, mr->w, currentGC, mi->x2, text_y, mi->item2, mi->strlen2); - - d = (Scr.EntryHeight - 7) / 2; - if (mi->func != F_POPUP && mi->hotkey != 0) { - hk[0] = mi->hotkey; - XDrawString(dpy, mr->w, currentGC, - mr->width - d - 4 - XTextWidth(Scr.StdFont.font, hk, 1) / 2, - text_y, hk, 1); + if (mi->item_num == 0) { /* when paintig first entry(menu title) */ + text_y = Scr.WindowFont.y + 4; +#undef FONTSET +#define FONTSET Scr.WindowFont.fontset + if(*mi->item) + XDrawString(dpy, mr->w, currentGC,mi->x,text_y, mi->item, mi->strlen); + if(mi->strlen2>0) + XDrawString(dpy, mr->w, currentGC,mi->x2,text_y, mi->item2,mi->strlen2); + + d=(Scr.EntryHeight-7)/2; + if(mi->func != F_POPUP && mi->hotkey != 0) { + hk[0]= mi->hotkey; + XDrawString(dpy, mr->w, currentGC, + mr->width-d-4- XTextWidth(Scr.StdFont.font, hk, 1)/2, + text_y, hk, 1); + } + } else { +#undef FONTSET +#define FONTSET Scr.StdFont.fontset + if(*mi->item) + XDrawString(dpy, mr->w, currentGC,mi->x,text_y, mi->item, mi->strlen); + if(mi->strlen2>0) + XDrawString(dpy, mr->w, currentGC,mi->x2,text_y, mi->item2,mi->strlen2); + + d=(Scr.EntryHeight-7)/2; + if(mi->func != F_POPUP && mi->hotkey != 0) { + hk[0]= mi->hotkey; + XDrawString(dpy, mr->w, currentGC, + mr->width-d-4- XTextWidth(Scr.StdFont.font, hk, 1)/2, + text_y, hk, 1); + } } d = (Scr.EntryHeight - 7) / 2; if (mi->func == F_POPUP) diff -urN AfterStep-1.2-p1/src/misc.h AfterStep-1.2-p1-I18N/src/misc.h --- AfterStep-1.2-p1/src/misc.h Mon Sep 15 04:20:39 1997 +++ AfterStep-1.2-p1-I18N/src/misc.h Tue Oct 28 21:29:26 1997 @@ -105,6 +105,16 @@ XChangeGC(dpy,Scr.FontGC,Globalgcm,&Globalgcv); \ } +#ifdef I18N +#ifdef __STDC__ +#define XTextWidth(x,y,z) XmbTextEscapement(x ## set,y,z) +#else +#define XTextWidth(x,y,z) XmbTextEscapement(x/**/set,y,z) +#endif +#define XDrawString(t,u,v,w,x,y,z) XmbDrawString(t,u,FONTSET,v,w,x,y,z) +#define XDrawImageString(t,u,v,w,x,y,z) XmbDrawImageString(t,u,FONTSET,v,w,x,y,z) +#endif + #ifdef NO_ICONS #define ICON_HEIGHT 1 #else diff -urN AfterStep-1.2-p1/src/module.c AfterStep-1.2-p1-I18N/src/module.c --- AfterStep-1.2-p1/src/module.c Mon Sep 15 04:20:37 1997 +++ AfterStep-1.2-p1-I18N/src/module.c Tue Oct 28 21:30:03 1997 @@ -103,11 +103,11 @@ strcpy(command, action); cptr = command; - while ((isspace(*cptr)) && (*cptr != '\n') && (*cptr != 0)) + while ((isspace((unsigned char)*cptr)) && (*cptr != '\n') && (*cptr != 0)) cptr++; end = cptr; - while ((!(isspace(*end)) && (*end != '\n')) && (*end != 0) && (end < (command + 256))) + while ((!(isspace((unsigned char)*end)) && (*end != '\n')) && (*end != 0) && (end < (command + 256))) end++; if ((*end == 0) || (end >= command + 256)) @@ -117,7 +117,7 @@ *end = 0; if (aptr) { - while ((isspace(*aptr) || (*aptr == '\n')) && (*aptr != 0) && (aptr < (command + 256))) + while ((isspace((unsigned char)*aptr) || (*aptr == '\n')) && (*aptr != 0) && (aptr < (command + 256))) aptr++; if ((*aptr == 0) || (*aptr == '\n')) aptr = NULL; diff -urN AfterStep-1.2-p1/src/move.c AfterStep-1.2-p1-I18N/src/move.c --- AfterStep-1.2-p1/src/move.c Mon Sep 15 04:20:37 1997 +++ AfterStep-1.2-p1-I18N/src/move.c Tue Oct 28 21:30:28 1997 @@ -293,6 +293,8 @@ offset = (Scr.SizeStringWidth + SIZE_HINDENT * 2 - XTextWidth(Scr.StdFont.font, str, strlen(str))) / 2; +#undef FONTSET +#define FONTSET Scr.StdFont.fontset XDrawString(dpy, Scr.SizeWindow, Scr.NormalGC, offset, Scr.StdFont.font->ascent + SIZE_VINDENT, diff -urN AfterStep-1.2-p1/src/pager.c AfterStep-1.2-p1-I18N/src/pager.c --- AfterStep-1.2-p1/src/pager.c Mon Sep 15 04:20:37 1997 +++ AfterStep-1.2-p1-I18N/src/pager.c Tue Oct 28 21:31:00 1997 @@ -67,6 +67,8 @@ TextColor = Scr.HiColors.fore; BackColor = Scr.HiColors.back; NewFontAndColor(Scr.PagerFont.font->fid, TextColor, BackColor); +#undef FONTSET +#define FONTSET Scr.PagerFont.fontset flush_expose(Scr.Hilite->pager_view); XDrawImageString(dpy, Scr.Hilite->pager_view, Scr.FontGC, 2, Scr.PagerFont.y + 2, diff -urN AfterStep-1.2-p1/src/resize.c AfterStep-1.2-p1-I18N/src/resize.c --- AfterStep-1.2-p1/src/resize.c Mon Sep 15 04:20:37 1997 +++ AfterStep-1.2-p1-I18N/src/resize.c Tue Oct 28 21:31:44 1997 @@ -415,6 +415,8 @@ Scr.StdFont.height, False); } +#undef FONTSET +#define FONTSET Scr.StdFont.fontset XDrawString(dpy, Scr.SizeWindow, Scr.NormalGC, offset, Scr.StdFont.font->ascent + SIZE_VINDENT, str, 13); diff -urN AfterStep-1.2-p1/src/stepgfx.c AfterStep-1.2-p1-I18N/src/stepgfx.c --- AfterStep-1.2-p1/src/stepgfx.c Mon Sep 15 04:20:37 1997 +++ AfterStep-1.2-p1-I18N/src/stepgfx.c Tue Oct 28 21:33:43 1997 @@ -603,8 +603,13 @@ * text - text to draw * chars - chars in text ************************************************************************/ +#ifdef I18N +void DrawTexturedText(Display *dpy, Drawable d, XFontStruct *font, XFontSet fontset, + int x, int y, Pixmap gradient, char *text, int chars) +#else void DrawTexturedText(Display * dpy, Drawable d, XFontStruct * font, int x, int y, Pixmap gradient, char *text, int chars) +#endif { Pixmap mask; int w, h; @@ -612,7 +617,11 @@ XGCValues gcv; /* make the mask pixmap */ +#ifdef I18N + w = XmbTextEscapement(fontset,text,chars); +#else w = XTextWidth(font, text, chars); +#endif h = font->ascent + font->descent; mask = XCreatePixmap(dpy, DefaultRootWindow(dpy), w + 1, h + 1, 1); gcv.foreground = 0; @@ -621,7 +630,11 @@ gc = XCreateGC(dpy, mask, GCFunction | GCForeground | GCFont, &gcv); XFillRectangle(dpy, mask, gc, 0, 0, w, h); XSetForeground(dpy, gc, 1); +#ifdef I18N + XmbDrawString(dpy,mask,fontset,gc,0,font->ascent,text,chars); +#else XDrawString(dpy, mask, gc, 0, font->ascent, text, chars); +#endif XFreeGC(dpy, gc); /* draw the texture */ gcv.function = GXcopy; diff -urN AfterStep-1.2-p1/src/stepgfx.h AfterStep-1.2-p1-I18N/src/stepgfx.h --- AfterStep-1.2-p1/src/stepgfx.h Mon Sep 15 04:20:39 1997 +++ AfterStep-1.2-p1-I18N/src/stepgfx.h Tue Oct 28 22:08:05 1997 @@ -21,8 +21,13 @@ extern int DrawDegradeRelief(Display * dpy, Drawable d, int x, int y, int w, int h, int from[3], int to[3], int relief, int maxcols); +#ifdef I18N +extern void DrawTexturedText(Display *dpy, Drawable d, XFontStruct *font, XFontSet fontset, + int x, int y, Pixmap gradient, char *text, int chars); +#else extern void DrawTexturedText(Display * dpy, Drawable d, XFontStruct * font, int x, int y, Pixmap gradient, char *text, int chars); +#endif extern int MakeShadowColors(Display * dpy, int from[3], int to[3], unsigned long *dark, unsigned long *light); diff -urN AfterStep-1.2-p1/src/style.c AfterStep-1.2-p1-I18N/src/style.c --- AfterStep-1.2-p1/src/style.c Thu Sep 18 00:37:20 1997 +++ AfterStep-1.2-p1-I18N/src/style.c Tue Oct 28 21:38:03 1997 @@ -56,11 +56,11 @@ if(restofline == NULL)return; while((*restofline != 0)&&(*restofline != '\n')) { - while(isspace(*restofline))restofline++; + while(isspace((unsigned char)*restofline))restofline++; if(mystrncasecmp(restofline,"ICON",4)==0) { restofline +=4; - while(isspace(*restofline))restofline++; + while(isspace((unsigned char)*restofline))restofline++; tmp = restofline; len = 0; while((tmp != NULL)&&(*tmp != 0)&&(*tmp != ',')&&(*tmp != '\n')) @@ -83,11 +83,11 @@ if(mystrncasecmp(restofline,"COLOR",5)==0) { restofline +=5; - while(isspace(*restofline))restofline++; + while(isspace((unsigned char)*restofline))restofline++; tmp = restofline; len = 0; while((tmp != NULL)&&(*tmp != 0)&&(*tmp != ',')&& - (*tmp != '\n')&&(*tmp != '/')&&(!isspace(*tmp))) + (*tmp != '\n')&&(*tmp != '/')&&(!isspace((unsigned char)*tmp))) { tmp++; len++; @@ -100,15 +100,15 @@ off_flags |= FORE_COLOR_FLAG; } - while(isspace(*tmp))tmp++; + while(isspace((unsigned char)*tmp))tmp++; if(*tmp == '/') { tmp++; - while(isspace(*tmp))tmp++; + while(isspace((unsigned char)*tmp))tmp++; restofline = tmp; len = 0; while((tmp != NULL)&&(*tmp != 0)&&(*tmp != ',')&& - (*tmp != '\n')&&(*tmp != '/')&&(!isspace(*tmp))) + (*tmp != '\n')&&(*tmp != '/')&&(!isspace((unsigned char)*tmp))) { tmp++; len++; @@ -126,11 +126,11 @@ if(mystrncasecmp(restofline,"FORECOLOR",9)==0) { restofline +=9; - while(isspace(*restofline))restofline++; + while(isspace((unsigned char)*restofline))restofline++; tmp = restofline; len = 0; while((tmp != NULL)&&(*tmp != 0)&&(*tmp != ',')&& - (*tmp != '\n')&&(*tmp != '/')&&(!isspace(*tmp))) + (*tmp != '\n')&&(*tmp != '/')&&(!isspace((unsigned char)*tmp))) { tmp++; len++; @@ -148,11 +148,11 @@ if(mystrncasecmp(restofline,"BACKCOLOR",9)==0) { restofline +=9; - while(isspace(*restofline))restofline++; + while(isspace((unsigned char)*restofline))restofline++; tmp = restofline; len = 0; while((tmp != NULL)&&(*tmp != 0)&&(*tmp != ',')&& - (*tmp != '\n')&&(*tmp != '/')&&(!isspace(*tmp))) + (*tmp != '\n')&&(*tmp != '/')&&(!isspace((unsigned char)*tmp))) { tmp++; len++; @@ -201,11 +201,11 @@ restofline +=8; sscanf(restofline,"%d",&butt); - while(isspace(*restofline))restofline++; - while((!isspace(*restofline))&&(*restofline!= 0)&& + while(isspace((unsigned char)*restofline))restofline++; + while((!isspace((unsigned char)*restofline))&&(*restofline!= 0)&& (*restofline != ',')&&(*restofline != '\n')) restofline++; - while(isspace(*restofline))restofline++; + while(isspace((unsigned char)*restofline))restofline++; off_buttons |= (1<<(butt-1)); } @@ -214,11 +214,11 @@ restofline +=6; sscanf(restofline,"%d",&butt); - while(isspace(*restofline))restofline++; - while((!isspace(*restofline))&&(*restofline!= 0)&& + while(isspace((unsigned char)*restofline))restofline++; + while((!isspace((unsigned char)*restofline))&&(*restofline!= 0)&& (*restofline != ',')&&(*restofline != '\n')) restofline++; - while(isspace(*restofline))restofline++; + while(isspace((unsigned char)*restofline))restofline++; on_buttons |= (1<<(butt-1)); } @@ -277,40 +277,40 @@ restofline +=11; off_flags |= BW_FLAG; sscanf(restofline,"%d",&bw); - while(isspace(*restofline))restofline++; - while((!isspace(*restofline))&&(*restofline!= 0)&& + while(isspace((unsigned char)*restofline))restofline++; + while((!isspace((unsigned char)*restofline))&&(*restofline!= 0)&& (*restofline != ',')&&(*restofline != '\n')) restofline++; - while(isspace(*restofline))restofline++; + while(isspace((unsigned char)*restofline))restofline++; } else if(mystrncasecmp(restofline,"HandleWidth",11)==0) { restofline +=11; off_flags |= NOBW_FLAG; sscanf(restofline,"%d",&nobw); - while(isspace(*restofline))restofline++; - while((!isspace(*restofline))&&(*restofline!= 0)&& + while(isspace((unsigned char)*restofline))restofline++; + while((!isspace((unsigned char)*restofline))&&(*restofline!= 0)&& (*restofline != ',')&&(*restofline != '\n')) restofline++; - while(isspace(*restofline))restofline++; + while(isspace((unsigned char)*restofline))restofline++; } else if(mystrncasecmp(restofline,"STARTSONDESK",12)==0) { restofline +=12; off_flags |= STAYSONDESK_FLAG; sscanf(restofline,"%d",&desknumber); - while(isspace(*restofline))restofline++; - while((!isspace(*restofline))&&(*restofline!= 0)&& + while(isspace((unsigned char)*restofline))restofline++; + while((!isspace((unsigned char)*restofline))&&(*restofline!= 0)&& (*restofline != ',')&&(*restofline != '\n')) restofline++; - while(isspace(*restofline))restofline++; + while(isspace((unsigned char)*restofline))restofline++; } else if(mystrncasecmp(restofline,"STARTSANYWHERE",14)==0) { restofline +=14; on_flags |= STAYSONDESK_FLAG; } - while(isspace(*restofline))restofline++; + while(isspace((unsigned char)*restofline))restofline++; if(*restofline == ',') restofline++; else if((*restofline != 0)&&(*restofline != '\n'))