delorie.com/archives/browse.cgi   search  
Mail Archives: geda-user/2012/07/25/06:27:12

X-Authentication-Warning: delorie.com: mail set sender to geda-user-bounces using -f
X-Recipient: geda-user AT delorie DOT com
X-Mailer: exmh version 2.7.2 01/07/2005 (debian 1:2.7.2-18) with nmh-1.3
X-Exmh-Isig-CompType: repl
X-Exmh-Isig-Folder: inbox
To: geda-user AT delorie DOT com
cc: karl AT aspodata DOT se
Fcc: +outbox
Subject: Re: [geda-user] Symbol attributes
In-reply-to: <20120725063536.GA24867@visitor2.iram.es>
References: <50084839 DOT 9080804 AT sbcglobal DOT net> <201207191830 DOT q6JIUH0o028413 AT envy DOT delorie DOT com> <juj1ab$sg2$1 AT dough DOT gmane DOT org> <500DB5AB DOT 4000903 AT sbcglobal DOT net> <jun5p4$o11$1 AT dough DOT gmane DOT org> <500F4824 DOT 1080905 AT sbcglobal DOT net> <20120725063536 DOT GA24867 AT visitor2 DOT iram DOT es>
Comments: In-reply-to Gabriel Paubert <paubert AT iram DOT es>
message dated "Wed, 25 Jul 2012 08:35:36 +0200."
Mime-Version: 1.0
Message-Id: <20120725102654.55EAD8279F78@turkos.aspodata.se>
Date: Wed, 25 Jul 2012 12:26:52 +0200 (CEST)
From: karl AT aspodata DOT se (Karl Hammar)
X-Virus-Scanned: ClamAV using ClamSMTP
Reply-To: geda-user AT delorie DOT com
Errors-To: nobody AT delorie DOT com
X-Mailing-List: geda-user AT delorie DOT com
X-Unsubscribes-To: listserv AT delorie DOT com

--------
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 -


  webmaster     delorie software   privacy  
  Copyright © 2019   by DJ Delorie     Updated Jul 2019