Path: utzoo!attcan!utgpu!news-server.csri.toronto.edu!rutgers!ucsd!ucbvax!bloom-beacon!eru!hagbard!sunic!mcsun!ukc!harrier.ukc.ac.uk!rlh2 From: rlh2@ukc.ac.uk (Richard Hesketh) Newsgroups: comp.windows.x Subject: Re: Application resource file etiquette Message-ID: <5637@harrier.ukc.ac.uk> Date: 6 Oct 90 16:07:13 GMT References: <69294@lll-winken.LLNL.GOV> <1990Oct5.155651.7094@smsc.sony.com> Reply-To: rlh2@ukc.ac.uk (Richard Hesketh) Organization: Computing Lab, University of Kent at Canterbury, UK. Lines: 91 Summary: Expires: Sender: Followup-To: In article <1990Oct5.155651.7094@smsc.sony.com> dce@smsc.sony.com (David Elliott) writes: >2. Modify the color namespace to handle "fallback" colors, which would > XTerm*background: black > XTerm*foreground: green(white) > > So that instead of the foreground going back to the default (black) > if green can't be handled, white is used. > >The second idea here is OK (please allow me at least some vanity ;-), but >could be too confusing. Whilst a complete (or at least better) solution is being developed this actually looks quite useful right now. For toolkit programs all it requires is a change in the StringToPixel converter which checks to see what type of screen this conversion is being made on and chooses the appropriate colour. Here's a patch to mit/Xt/Converters.c [patchlevel 18] (you can apply the patch then rip the converter out and put it in your own programs) that changes the StringToPixel converter to recognize the following format: XTerm*foreground: green/white I use a slash "/" because its easier to parse 8-). I really don't think it is any more confusing than specifying any other resource! The first colour is chosen if the screen has a depth greater than one. *** Converters.c.dist Sat Sep 29 16:46:26 1990 --- Converters.c Sat Oct 6 16:46:10 1990 *************** *** 351,357 **** XrmValuePtr toVal; XtPointer *closure_ret; { ! String str = (String)fromVal->addr; XColor screenColor; XColor exactColor; Screen *screen; --- 351,357 ---- XrmValuePtr toVal; XtPointer *closure_ret; { ! static String str = NULL; XColor screenColor; XColor exactColor; Screen *screen; *************** *** 360,365 **** --- 360,366 ---- Status status; String params[1]; Cardinal num_params=1; + String slash; if (*num_args != 2) XtAppErrorMsg(pd->appContext, XtNwrongParameters, "cvtStringToPixel", *************** *** 369,374 **** --- 370,393 ---- screen = *((Screen **) args[0].addr); colormap = *((Colormap *) args[1].addr); + + if (str != NULL) + XtFree(str); + + str = XtNewString((String)fromVal->addr); + slash = str; + while (*slash && *slash != '/') + slash++; + + if (*slash) { + if (DefaultDepthOfScreen(screen) == 1) { + /* use fallback colour for monochrome screens */ + slash = XtNewString(slash+1); + XtFree(str); + str = slash; + } else + *slash = '\0'; + } if (CompareISOLatin1(str, XtDefaultBackground) == 0) { *closure_ret = False; --- Richard Hesketh : @nsfnet-relay.ac.uk:rlh2@ukc.ac.uk : rlh2@ukc.ac.uk ..!{mcsun|mcvax}!ukc!rlh2 Computing Officer, Computing Lab., University of Kent at Canterbury, Canterbury, Kent, CT2 7NF, United Kingdom. Tel: +44 227 764000 ext 7620/7590 Fax: +44 227 762811