On Wednesday, November 6, 2013 3:07:48 PM UTC-6, Edward K. Ream wrote:
> I've hacked away on Brian's script. This has been a lot of fun.
The old way of generating selectors was:
table = (
# bits: dirty=8,clone=4,mark=2,body=1.
(0,'leaf'),
(1,'body'),
(2,'mark'),
(3,'mark-body'),
(4,'clone'),
(5,'clone-body'),
(6,'clone-mark'),
(7,'clone-mark-body'),
(8,'dirty'),
(9,'dirty-body'),
(10,'dirty-mark'),
(11,'dirty-mark-body'),
(12,'dirty-clone'),
(13,'dirty-clone-body'),
(14,'dirty-clone-mark'),
(15,'dirty-clone-mark-body'),
)
boxes_css = '\n'.join([
'li.%s {\n background-image: url(%s)\n}' %
(kind,icon('box%02d.GIF' % (n)))
for n,kind in table])
But this is bad style. It is error prone and hides the essential
relationships in the box naming.
In contrast, the following shows that icons are named in a specific manner.
def selector(n):
table = ((8,'dirty'),(4,'clone'),(2,'mark'),(1,'body'))
return '-'.join([s for n2,s in table if n & n2]) or 'leaf'
def css(n):
return 'li.%s {\n background-image: url(%s)\n}' % (
selector(n),icon('box%02d.GIF' % n))
boxes_css = '\n'.join([css(n) for n in range(15)])
The table in the selector function makes the bits explicit: the dirty bit
is the 8 bit, and so on.
Leo's code uses these relationships, so it's best to do so here as well.
Edward
--
You received this message because you are subscribed to the Google Groups
"leo-editor" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To post to this group, send email to [email protected].
Visit this group at http://groups.google.com/group/leo-editor.
For more options, visit https://groups.google.com/groups/opt_out.