[STFL] Getting a widget's width without drawing it?

Andreas Leitgeb avl at logic.at
Thu Sep 20 09:08:24 CEST 2007


On Thu, Sep 20, 2007 at 01:57:28AM +0200, Clifford Wolf wrote:
> > 	$<colors and attributes>$<text to format>$
> > e.g. $fg=blue,bg=white$this is blue and white$.
> > Such a special string can be contained 0 or more times in a line. When the
> > character $ shall be displayed, it must be escaped with \

>   vbox
>     @style_foo:fg=white,bg=blue
>     @style_bar:fg=red,bg=black
>     @richtext:1
>     label
>       text:"This is a $foo$colorfull $bar$richtext $normal$test."
>     label
>       text:"This is a dollar sign: $$"
>     label
>       text:"Another dollar sign: $fg=blue$$$ $normal$(and it is blue)"
> 
> What do you think of that api?

Hello, I'm happy about the functionality (especially the style-tags),
but not so much about usage of the $-char.
I'd prefer some kind of subset/variant of (*shrug*) "html":
  text: This is a <foo>colorful</> <bar>richtext</> test.
I think this makes it easier, to visually recognise tags from
words, and also makes it easier for some external tool (wasn't
a spellchecker mentioned?).

I'll point out the differences:
   the big difference compared to the proposed approach is of course
     nestability of tags. there might be a tag for bold-face, and
     another for some color, and they could be just combined.  Of course
     text-terminals don't offer all that much choice, but they, too, 
     do "grow" sometimes, with new terminal-emulators coming up. We
     shouldn't lock ourselves in to what e.g. xterm currently supports.

   some difference to html: </> just ends the range for the innermost
      tag. no clumsy </foo> necessary, if the <foo> is just a few chars
      away. Of course, </foo> could still be used at will, especially
      with longer texts.

   There should, of course be a way to protect a single  "<". 
      we could do it also in html-style "&gt;", or ... I must admit
      I'm lacking some genious idea right now, I'll leave that open
      for now, and might get back to it...

That said, I'll leave the judgement to those who actually implement it,
since I haven't really involved myself, yet (not even in using stfl).



More information about the STFL mailing list