Mail Archives: geda-user/2012/07/25/06:27:12
--------
Gabriel:
...
> The most annoying issue is that, being an attribute, it is displayed
> in a different color than the text associated with symbols which played
> a similar role in the standard library. I don't think it is right now
> possible to modify the colour depending on regexp matching on the attribute
> name; otherwise it would be nice if attribute name matching ".*label.*"
> would use text color (automatically atattribute promotion time).
...
An attribute is simply a pair of lines:
T 100 1300 5 10 0 0 0 0 1
author=Karl Hammar
where the "5" above is the colour, see [1] for details.
If your program remembers the "previous" line, it can change the
colour.
Like in:
$ ./ch_colour.pl refdes 3 < ../share/gschem/ellyt.sym > a.sym
$ diff -u ../share/gschem/ellyt.sym a.sym
--- ../share/gschem/ellyt.sym 2011-07-26 15:06:05.000000000 +0200
+++ a.sym 2012-07-25 12:23:12.633211147 +0200
@@ -26,7 +26,7 @@
author=Karl Hammar
T 100 1100 5 10 0 0 0 0 1
device=POLARIZED_CAPACITOR
-T 100 500 8 10 1 1 0 0 1
+T 100 500 3 10 1 1 0 0 1
refdes=C?
T 100 1300 5 10 0 0 0 0 1
description=polarized capacitor
$ cat ./ch_colour.pl
#!/usr/bin/perl -w
use strict;
my $attr = shift;
my $colour = shift;
my $save = "";
while (<>) {
if (m/^(T\s+\S+\s+\S+\s+)(\d+)(\s.*)$/) {
$save = [ $_, $1, $2, $3 ];
} elsif ($save) {
if (m/^$attr=/) {
print $$save[1], $colour, $$save[3], "\n";
print;
undef $save;
} else {
print $$save[0];
print;
undef $save;
}
} else {
print;
}
}
$
Regards,
/Karl Hammar
[1] http://wiki.geda-project.org/geda:file_format_spec#text_and_attributes
-----------------------------------------------------------------------
Aspö Data
Lilla Aspö 148
S-742 94 Östhammar
Sweden
+46 173 140 57
- Raw text -