File: icontable.pl.in

package info (click to toggle)
xastir 2.1.4-1
  • links: PTS, VCS
  • area: main
  • in suites: bullseye, sid
  • size: 13,676 kB
  • sloc: ansic: 121,100; perl: 7,529; sh: 5,535; makefile: 383; python: 312; sql: 102
file content (155 lines) | stat: -rwxr-xr-x 5,159 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
#!/usr/bin/perl
# XASTIR icon table overview generator                        20.02.01
#  Copyright (C) 2001 Rolf Bleher                  http://www.dk7in.de

#  This program is free software; you can redistribute it and/or modify
#  it under the terms of the GNU General Public License as published by
#  the Free Software Foundation; either version 2 of the License, or
#  (at your option) any later version.
#
#  This program is distributed in the hope that it will be useful,
#  but WITHOUT ANY WARRANTY; without even the implied warranty of
#  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
#  GNU General Public License for more details.
#
#  You should have received a copy of the GNU General Public License
#  along with this program; if not, write to the Free Software
#  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA

#  see file COPYING for details

#--------------------------------------------------------------------------

# This script produces an overview graphics with all symbols used by Xastir
# Output is as a XPM file to STDOUT
#     typical call:  icontable.pl > symbols.xpm

#--------------------------------------------------------------------------
use File::Basename;
$prefix="@prefix@";

# symbols file from XASTIR V2.1, change the path for your environment
$SYMBFILE = $prefix."/share/xastir/symbols/symbols.dat";

#--------------------------------------------------------------------------
%sympix = ();
$lasttable  = $table;
$lastsymbol = $symbol;
$tablist = "/\\";
@coltab = qw(#FFFF00 #CD6500 #A020F0 #CCCCCC #CD0000 #FF4040 #CD3333 #00008B #00BFFF #006400 #EE0000 #00CD00 #0000CD #FFFFFF #5A5A5A #878787 #454545 #000000 None);
setuppics();
#storepics();    # store all icons as separate XPM files
exit;
#--------------------------------------------------------------------------
sub setuppics {
  my $table  = '';
  my $symbol = '';
  my ($i,$j,$c);
  my $line;
  my $head;
  my $str;
  my $pix;
  my $pixstr;
  if (-f $SYMBFILE) {
    if (open(FH, "<$SYMBFILE")) {
      my %col = ();
SYM:  while(<FH>) {
        last if (/DONE/);
        if (/TABLE (.)/) {
          $table = $1;
          if(length($_)>20) { $descr = 1 }
          next;
        }
        if (/APRS (.)/) {
          $symbol = $1;
          next if ($table ne '/' && $table ne '\\');   # ignore other
          $pixstr = '';
          for ($i=0;$i<20;$i++) {
            $line = <FH>;
            $line =~ s/\n//;
            $line =~ s/\r//;
            next SYM if (length($line) != 20);
            $pixstr .= $line;
            for ($j=0;$j<20;$j++) {
              $c = substr($line,$j,1);
              $col{$c} = $c;
            }
          }
          $sympix{$table.$symbol} = $pixstr;
        }
      }
      $str = "";
      for ($i=0;$i<20;$i++) {
        $str .= "....................";
      }
      $sympix{"  "} = $str;
  
      $head = ''; $j = 0;
      foreach $c (keys %col) {
        $head .= colstr($c);
        $j++;
      }
     $head = "/* XPM */{\"337 258 $j 1 \",\n".$head;

#      12 lines with 16 symbols each     x 337  y 

      $pix = "";
      foreach $table ("/","\\") {
        for ($i=2;$i<8;$i++) {                  # symbol row
          $pix .=  "\"".("q" x 337)."\",\n";    # black hor line
          for ($j=0;$j<20;$j++) {               # scan line
            $pix .= "\"";                       # start of scan line
            for ($k=0;$k<16;$k++) {             # symbol column
              $pix .= "q";                      # vert line
              $symbol = chr($i*16+$k);
              $pix .= substr(getpic($table.$symbol),$j*20,20);
            }
            $pix .= "q\",\n";                   # vert line
          }
        }
        if ($table eq "\\") {           # {
          $pix .=  "\"".("q" x 337)."\"};\n";      # black hor line
        } else {
          $pix .=  "\"".("q" x 337)."\",\n";       # black hor line
          for ($i=0;$i<4;$i++) {
            $pix .=  "\"".("." x 337)."\",\n";     # hor space
          }
        }
      }
      printf($head.$pix);
      close(FH);
    }
  }
}
#--------------------------------------------------------------------------
sub colstr {                                 # setup string for color
  my ($c) = @_;
  if ($c eq '#') {                           # Yellow
    $cidx = 0;
  } elsif ($c ge 'a' && $c le 'q') {
    $cidx = ord($c)-ord('a')+1;
  } else {
    $cidx = @coltab-1;                       # Transparent
  }
  return("\"$c c $coltab[$cidx]\",\n");
}
#--------------------------------------------------------------------------
sub getpic {
  my ($id) = @_;
  $str = $sympix{$id};
  if (! $str) {
    $str = $sympix{"  "};      # default
  }
  $str;
}
#--------------------------------------------------------------------------
sub storepics {                              # extract all icons to files
  foreach $cc (keys %sympix) {
    $fname = sprintf("Aprs%2.2X%2.2X.xpm",ord(substr($cc,0,1)),ord(substr($cc,1,1)));
    if (open(FH,">$fname")) {
      printf(FH "%s",getpic($cc));
      close(FH);
    }
  }
}
#--------------------------------------------------------------------------