Hideable Buttons

From TrillWiki

Jump to: navigation, search

by Sjoerd on 09/04/04

Many people with setting files in their skin have the option to show, or not to show the hide Button.

Like this (image the symbols in brackets are buttons):

[ * User you are typing to_(v)(_)(=)(x)]

becomes:

[ * User you are typing to____(_)(=)(x)]

But, when you have longer names (eg "User with very long name you are typing to"), most of the time:

[ * User with very long nam(v)(_)(=)(x)]

becomes:

[ * User with very long nam___(_)(=)(x)]

This happens because most people use for the icontrol:


visible="&showbutton;"/>


and in their settings file:


<!ENTITY showbutton "1">

with the description to change 1 to 0 if you don't want to see it.

Here's how I would change it using selectable DTD files.

First, I'd make a file named: hideis1.dtd and add this to it:


<!ENTITY showthehidebutton "1">
<!ENTITY topicright "[valueright]">


Then another file called hideis0.dtd


<!ENTITY showthehidebutton "0">
<!ENTITY topicright "[valueright]">


In your trillian.dtd, add the line:


<!ENTITY % showhide SYSTEM "settings/hideis&showbutton;.dtd">
%showhide;
(See below -Tometheus)

Finally, in the topic control which should change width:


<right num="&topicright;" width="1"/>


The result would become:

[ * User with very long nam(v)(_)(=)(x)]
[ * User with very long name t(_)(=)(x)]

This technique can become very useful for a config file, by defining parts the user can change (the <!ENTITY showthehidebutton "0"> bit), and then using these bits in the code as you would a reference to any file, you can store all the bits a user might want to change in one file.



comment by Tometheus

Good concept, but it doesn't quite work as described here.

<!ENTITY % showhide SYSTEM "settings/hideis&showbutton;.dtd">
%showhide;
  1. The use of &showbutton; in a % SYSTEM entity won't work. ("&" entities only expand on the XML level, not the DTD level)
  2. Even if it was changed to a '%', % entities are bypassed in % SYSTEM entities, so you have to trick the parser into evaluating it.

So here's the TRILLIAN.DTD correction that will work.

<!ENTITY % ENTshowhide
'<!ENTITY &#37; showhide SYSTEM "settings/hideis%showbutton;.dtd">' >
%ENTshowhide; %showhide;

The call to %ENTshowhide; with the &#37; forces the showhide entity to parse the entire string, including the %showbutton;, since the parser is required to expand &#37; immediately.

Then, once you have that expanded, you can call %showhide; to actually load your chosen file.

See the XML Spec Section 4 and Appendix D


comment by eh?one

Now that we have skin math in Trillian 3.0+ we can just use this: dtd: <!ENTITY showthehidebutton "(0|1)"> xml: <right num="(&showthehidebutton;*16)+48" width="1"/>

Personal tools