"Fossies" - the Fresh Open Source Software Archive 
Member "namefix.pl/libs/nf_print.pm" (23 Dec 2009, 4876 Bytes) of package /linux/privat/old/namefix.pl_4.0.2.tar.gz:
As a special service "Fossies" has tried to format the requested source page into HTML format using (guessed) Perl source code syntax highlighting (style:
standard) with prefixed line numbers and
code folding option.
Alternatively you can here
view or
download the uninterpreted source code file.
For more information about "nf_print.pm" see the
Fossies "Dox" file reference documentation.
1 use strict;
2 use warnings;
3
4 #--------------------------------------------------------------------------------------------------------------
5 # namefix print
6 #--------------------------------------------------------------------------------------------------------------
7
8 sub nf_print
9 {
10 if($main::CLI) # redirect old print calls for CLI mode
11 {
12 &plog(1, "sub nf_print: use of this sub in CLI mode is depreciated");
13 &cli_print(@_);
14 return 1;
15 }
16
17 my $s1 = shift;
18 my $s2 = shift;
19 my $fi = "";
20 my $c = "";
21 my $arrow = " -> ";
22 chomp $s1;
23
24 # cli print does not guess at how to print anylonger
25 # it expects <MSG> for plain text
26 # the gui print will recieve the same treatment in the future.
27 if($s2 eq "<MSG>")
28 {
29 $s2 = $s1;
30 }
31
32 if(!$s2)
33 {
34 $s2 = "";
35 }
36
37 chomp $s2;
38 &plog(3, "sub nf_print: \"$s1\", \"$s2\"");
39
40 my $hlist_file = $s1;
41 if(!$main::LISTING && !$main::testmode)
42 {
43 $hlist_file = $s2;
44 }
45
46 $main::hlist2->add
47 (
48 $main::hl_counter,
49 -data=>[$hlist_file, $main::hlist_cwd]
50 );
51
52 if # if file is a directory, attach dir icon
53 (
54 $s1 !~ /^\s+$/ && # for some reason -d \s+ returns positive, so check for it here.
55 (
56 $s1 eq ".." || # .. doesnt get detected as a dir when renaming, identify by value instead
57 (($main::LISTING || $main::testmode) && -d $s1) || # listing check if s1 is file
58 (!$main::LISTING && -d $s2) # file renamed, check if s2 is file :)
59 )
60 )
61 {
62 &plog(4, "sub nf_print: \"$s1\" is a dir, attaching dir icon");
63 $main::hlist2->itemCreate
64 (
65 $main::hl_counter,
66 0,
67 -itemtype=>'imagetext',
68 -image=>$main::folderimage
69 );
70 }
71 elsif # if file is file, attach file icon
72 (
73 (($main::LISTING || $main::testmode) && -f $s1) ||
74 (!$main::LISTING && -f $s2)
75 )
76 {
77 &plog(4, "sub nf_print: \"$s1\" is a file, attaching file icon");
78 $main::hlist2->itemCreate
79 (
80 $main::hl_counter,
81 0,
82 -itemtype=>'imagetext',
83 -image=>$main::fileimage
84 );
85 }
86 else # just been given text to print, no icon and no arrow
87 {
88 $c = cwd();
89 &plog(4, "sub nf_print: \"$s1\" not detected as a file / dir, attaching black icon");
90 $arrow = "";
91 $main::hlist2->itemCreate
92 (
93 $main::hl_counter,
94 0,
95 -itemtype => "text",
96 -text => " "
97 );
98 }
99
100 if($main::id3_mode == 1)
101 {
102 &plog(4, "sub nf_print: id3_mode enabled");
103 my $art = shift;
104 my $tit = shift;
105 my $tra = shift;
106 my $alb = shift;
107 my $com = shift;
108 my $gen = shift;
109 my $year = shift;
110
111 if(!$s2)
112 {
113 $fi = $s1;
114 }
115 else
116 {
117 chomp $s2;
118 $fi = $s2;
119 }
120
121 $main::hlist2->itemCreate($main::hl_counter, 1, -text => "$s1");
122
123 if($art)
124 {
125 $main::hlist2->itemCreate($main::hl_counter, 2, -text => "$art");
126 }
127 if($tra)
128 {
129 $main::hlist2->itemCreate($main::hl_counter, 3, -text => "$tra");
130 }
131 if($tit)
132 {
133 $main::hlist2->itemCreate($main::hl_counter, 4, -text => "$tit");
134 }
135 if($alb)
136 {
137 $main::hlist2->itemCreate($main::hl_counter, 5, -text => "$alb");
138 }
139
140 if($gen)
141 {
142 $main::hlist2->itemCreate($main::hl_counter, 6, -text => "$gen");
143 }
144
145 if($year)
146 {
147 $main::hlist2->itemCreate($main::hl_counter, 7, -text => "$year");
148 }
149
150 if($com)
151 {
152 $main::hlist2->itemCreate($main::hl_counter, 8, -text => "$com");
153 }
154
155 if($main::LISTING == 0) # if renaming or previewing print 'after' fields
156 {
157 my $newart = shift;
158 my $newtit = shift;
159 my $newtra = shift;
160 my $newalb = shift;
161 my $newcom = shift;
162 my $newgen = shift;
163 my $newyear = shift;
164
165 if($s1 ne "..")
166 {
167 &plog(4, "sub nf_print: id3_mode, renaming mode, adding new fields");
168 $main::hlist2->itemCreate($main::hl_counter, 9, -text => "$arrow");
169 $main::hlist2->itemCreate($main::hl_counter, 10, -text => "$fi");
170
171 if($newart)
172 {
173 $main::hlist2->itemCreate($main::hl_counter, 11, -text => "$newart");
174 }
175 if($newtra)
176 {
177 $main::hlist2->itemCreate($main::hl_counter, 12, -text => "$newtra");
178 }
179 if($newtit)
180 {
181 $main::hlist2->itemCreate($main::hl_counter, 13, -text => "$newtit");
182 }
183 if($newalb)
184 {
185 $main::hlist2->itemCreate($main::hl_counter, 14, -text => "$newalb");
186 }
187 if($newgen)
188 {
189 $main::hlist2->itemCreate($main::hl_counter, 15, -text => "$newgen");
190 }
191 if($newyear)
192 {
193 $main::hlist2->itemCreate($main::hl_counter, 16, -text => "$newyear");
194 }
195 if($newcom)
196 {
197 $main::hlist2->itemCreate($main::hl_counter, 17, -text => "$newcom");
198 }
199 }
200 }
201 }
202 else
203 {
204 if(!$s2)
205 {
206 $s2 = $s1;
207 }
208 $main::hlist2->itemCreate($main::hl_counter, 1, -text => "$s1");
209
210 if($main::LISTING == 0)
211 {
212 if($s1 ne "..")
213 {
214 &plog(4, "sub nf_print: normal mode, renaming adding new fields");
215 $main::hlist2->itemCreate($main::hl_counter, 2, -text => "$arrow");
216 $main::hlist2->itemCreate($main::hl_counter, 3, -text => "$s2");
217 }
218 }
219 }
220 $main::hl_counter++;
221 &fn_update_delay;
222 }
223
224 1;