[comp.windows.x] WHITE PAPER: Enhancing the X resource file syntax

marbru@auto-trol.UUCP (Martin Brunecky) (09/25/90)

   WHITE PAPER:  Enhancing the X resource file syntax

   The  resource  file  syntax,  as  required   by   XrmGetFileDatabase   and
   XrmPutLineResource  is  well  known.   However,  any  frequent Xrm user is
   probably tired of typing lines like:

      MyApp*file_menu.btn1.foreground:  white
      MyApp*file_menu.btn1.background:  black
      MyApp*file_menu.btn1.borderColor: red
      ....
      MyApp*file_menu.btn1.xxxx:        yyyy

   Sure, using loose bindings and/or using unique names (such as  f_menu_b_1)
   and/or using cpp, the amount of typing (and the resource file size) can be
   reduced.  But often at the cost of clarity and/or flexibility.

   So why not allow something like:

      MyApp*file_menu.btn1.foreground: white
      -.background:                    black
      -.borderColor:                   red

   The "-" operator would save lots of typing. It would reduce the file size.
   It would increase readability.
   Plus, it would allow internal optimizations within XrmGetFileDatabase:  it
   could  save the overhead of string parsing and database search list lookup
   for the repeated database path.  May be not that significant.   But  small
   improvements  keep  adding, and we all are desperately looking for ways to
   improve Xt applications startup performance.

   Thus, consider this yet another wish list item for R5.



-- 
=*= Opinions presented here are solely of my own and not those of Auto-trol =*=
Martin Brunecky                   marbru@auto-trol.COM
(303) 252-2499                    {...}ncar!ico!auto-trol!marbru
Auto-trol Technology Corp. 12500 North Washington St., Denver, CO 80241-2404 

Pabbisetty.henr@XEROX.COM (Nagesh Pabbisetty) (09/25/90)

The current resource-naming syntax is:
	MyApp*file_menu.btn1.foreground:  white
	MyApp*file_menu.btn1.background:  black
	MyApp*file_menu.btn1.borderColor: red
	....
	MyApp*file_menu.btn1.xxxx:        yyyy

Martin Brunecky proposed the following:
	MyApp*file_menu.btn1.foreground: white
      	-.background:                    black
     	-.borderColor:                   red


Using the convention I propose, the above example will be translated into:

	[MyApp*file_menu.btn1]
	foreground:  white
	background:  black
	borderColor: red
	....
	xxxx:        yyyy

PROPOSED CONVENTION
--------------------
Here, the top portion in square brackets represents the entire widget
hierarchy upto the last level. The last level items are specified in this
section. We can require successive sections to be separated by one or more
blank lines.

This way, it could force all the application defaults related to a
widget/tool to be grouped at one location in the defaults file. So, in
parsing, all that needs to be done is to search for the path (which is
enclosed in brackets) and then read all defaults until a blank line is
read.

Any comments?

- nagesh

-------------------------------------------------------------------------------
Intelnet: 8*227-5458				MaBell: (716)427-5458
Pup	: Pabbisetty.henr			Snail Mail: 
NS	: Pabbisetty:Henr801C:xerox		  801-27C, 1350 Jefferson Road,
Arpa	: pabbiset@arisia.xerox.com		  Rochester, NY 14623.

-------------------------------------------------------------------------------

Pabbisetty.henr@XEROX.COM (Nagesh Pabbisetty) (09/26/90)

The current resource-naming syntax is:
	MyApp*file_menu.btn1.foreground:  white
	MyApp*file_menu.btn1.background:  black
	MyApp*file_menu.btn1.borderColor: red
	....
	MyApp*file_menu.btn1.xxxx:        yyyy

You proposed the following syntax:
	MyApp*file_menu.btn1.foreground: white
      	-.background:                    black
     	-.borderColor:                   red


Using the convention I propose, the above example will be translated into:

	[MyApp*file_menu.btn1]
	foreground:  white
	background:  black
	borderColor: red
	....
	xxxx:        yyyy

PROPOSED CONVENTION
--------------------
	[sectionName]
	itemName: itemValue
	itemName: itemValue
	...
	itemName: itemValue
	<one or more blank lines>
	
Here, the sectionName states the entire widget hierarchy upto the last
level. The last level items are specified as "itemName: itemValue" in this
section on separate lines. Each section should be terminated by 1 or more
blank lines.

This way, it could force all the application defaults related to a
widget/tool to be grouped at one location in each defaults file. So, in
parsing, all that needs to be done is to search for the path (sectionName)
and then read all defaults until a blank line is read.

Any comments?

- nagesh

-------------------------------------------------------------------------------
Intelnet: 8*227-5458				MaBell: (716)427-5458
Pup	: Pabbisetty.henr			Snail Mail: 
NS	: Pabbisetty:Henr801C:xerox		  801-27C, 1350 Jefferson Road,
Arpa	: pabbiset@arisia.xerox.com		  Rochester, NY 14623.

-------------------------------------------------------------------------------

rws@EXPO.LCS.MIT.EDU (Bob Scheifler) (09/26/90)

    The "-" operator would save lots of typing.

Resources should seldom be typed by hand. :-)

    It would increase readability.

Resources should seldom be edited by textual reading. :-)

    But  small
    improvements  keep  adding, and we all are desperately looking for ways to
    improve Xt applications startup performance.

So far, we haven't found that loading resource contributes very significantly
to the startup time (except when sucking a resource property from an X terminal
over a serial line :-).  Our current work on XrmGetFileDatabase (which I think
has already sped it up by a factor of 2?) didn't have much affect, that I recall.
Other trivial changes to Xt have had considerably more effect, and other
non-trivial changes will have even more effect.

Your wish is noted, but right now I (at least) am much more interested in simple
changes to Xrm that increase functionality.

thoth@lightning.cis.ufl.edu (Gilligan) (09/27/90)

  you realize that all your

 	MyApp*file_menu.btn1.foreground: white
      	-.background:                    black
     	-.borderColor:                   red

stuff could probably be simulated with a perl filter.  If you want I
could try to write one.
--
--
"Until it's on my desk, it's vaporware"  (`it' is the NeXT)

marbru@auto-trol.UUCP (Martin Brunecky) (09/27/90)

In article <THOTH.90Sep26133300@lightning.cis.ufl.edu> thoth@lightning.cis.ufl.edu (Gilligan) writes:
>
>  you realize that all your
> 	MyApp*file_menu.btn1.foreground: white
>      	-.background:                    black
>
>stuff could probably be simulated with a perl filter.  If you want I
>could try to write one.

   No, thanx, no filter. The same reason I don't want to run cpp on
   my app-defaults and other resource files. As I am using Xrm to
   define the entire application (WsXc, Wcl/Mri...), I want the file
   to be edited, and loaded without any further steps.
   Note, I am talking files with several hundreds of lines (equivalent
   of UIL or C code of several thousands of lines).
   I just want to make my files more readable, smaller in size and
   faster processed (though the last one is the least important).

-- 
=*= Opinions presented here are solely of my own and not those of Auto-trol =*=
Martin Brunecky                   marbru@auto-trol.COM
(303) 252-2499                    {...}ncar!ico!auto-trol!marbru
Auto-trol Technology Corp. 12500 North Washington St., Denver, CO 80241-2404 

jeenglis@alcor.usc.edu (Joe English Muffin) (10/01/90)

marbru@auto-trol.UUCP (Martin Brunecky) writes:

>   The  resource  file  syntax,  as  required   by   XrmGetFileDatabase   and
>   XrmPutLineResource  is  well  known.   However,  any  frequent Xrm user is
>   probably tired of typing lines like:

>      MyApp*file_menu.btn1.foreground:  white
>      MyApp*file_menu.btn1.background:  black
>      MyApp*file_menu.btn1.borderColor: red
>      ....
>      MyApp*file_menu.btn1.xxxx:        yyyy

[ ... ]

>   So why not allow something like:

>      MyApp*file_menu.btn1.foreground: white
>      -.background:                    black
>      -.borderColor:                   red

How about a syntax like this instead:

    MyApp*file_menu.btn1{
        .foreground:    puce
        .background:    purple
        .borderColor:   greenish
    }

This would also allow nesting, as in:

    MyApp{
        *Command{
            .foreground:    lightmagenta
            .background:    mauve
            .shapeStyle:    hexagonal
        }
        file_menu.btn1{
            ... etc.
        }
    }


--Joe English

  jeenglis@alcor.usc.edu

randy@erik.UUCP (Randy Brown) (10/02/90)

>How about a syntax like this instead:
>
>    MyApp*file_menu.btn1{
>        .foreground:    puce
>        .background:    purple
>        .borderColor:   greenish
>    }
>
>This would also allow nesting, as in:

Since we seem to be running a poll, this gets my vote.  It's easy to parse (at
least for the parser I use most often :-) and expresses the nested parent-child
nature of the hierarchy.  Indentation should be OPTIONAL, of course.

Randy Brown (uunet!erik!rbrown)