summaryrefslogtreecommitdiff
path: root/src/bin/tyls.c
diff options
context:
space:
mode:
authorCarsten Haitzler <raster@rasterman.com>2013-02-14 15:53:29 +0000
committerCarsten Haitzler <raster@rasterman.com>2013-02-14 15:53:29 +0000
commit104e1b51cb96ac659e3ddc25025724b40b00d26f (patch)
tree006caacbbed9740ff0c9add556006c11405a1f38 /src/bin/tyls.c
parent6f6b57d141a1c35053f98a22d33c245a4937bba8 (diff)
make tyls more.. colorful. :)
SVN revision: 83896
Diffstat (limited to 'src/bin/tyls.c')
-rw-r--r--src/bin/tyls.c596
1 files changed, 462 insertions, 134 deletions
diff --git a/src/bin/tyls.c b/src/bin/tyls.c
index babc6b4..960475e 100644
--- a/src/bin/tyls.c
+++ b/src/bin/tyls.c
@@ -10,6 +10,7 @@
10#include <stdlib.h> 10#include <stdlib.h>
11#include <unistd.h> 11#include <unistd.h>
12#include <string.h> 12#include <string.h>
13#include <fnmatch.h>
13 14
14// this code sucks. just letting you know... in advance... in case you 15// this code sucks. just letting you know... in advance... in case you
15// might be tempted to think otherwise... :) 16// might be tempted to think otherwise... :)
@@ -75,22 +76,462 @@ is_fmt(const char *f, const char **extn)
75} 76}
76 77
77static void 78static void
78size_print(char *buf, int bufsz, unsigned long long size) 79size_print(char *buf, int bufsz, char *sz, unsigned long long size)
79{ 80{
80 if (size < 1024LL) 81 if (size < 1024LL)
81 snprintf(buf, bufsz, " %4lld", size); 82 {
83 snprintf(buf, bufsz, "%4lld", size);
84 *sz = ' ';
85 }
82 else if (size < (1024LL * 1024LL)) 86 else if (size < (1024LL * 1024LL))
83 snprintf(buf, bufsz, "%4lldK", size / (1024LL)); 87 {
88 snprintf(buf, bufsz, "%4lld", size / (1024LL));
89 *sz = 'K';
90 }
84 else if (size < (1024LL * 1024LL * 1024LL)) 91 else if (size < (1024LL * 1024LL * 1024LL))
85 snprintf(buf, bufsz, "%4lldM", size / (1024LL * 1024LL)); 92 {
93 snprintf(buf, bufsz, "%4lld", size / (1024LL * 1024LL));
94 *sz = 'M';
95 }
86 else if (size < (1024LL * 1024LL * 1024LL * 1024LL)) 96 else if (size < (1024LL * 1024LL * 1024LL * 1024LL))
87 snprintf(buf, bufsz, "%4lldG", size / (1024LL * 1024 * 1024LL)); 97 {
98 snprintf(buf, bufsz, "%4lld", size / (1024LL * 1024 * 1024LL));
99 *sz = 'G';
100 }
88 else if (size < (1024LL * 1024LL * 1024LL * 1024LL * 1024LL)) 101 else if (size < (1024LL * 1024LL * 1024LL * 1024LL * 1024LL))
89 snprintf(buf, bufsz, "%4lldT", size / (1024LL * 1024LL * 1024LL * 1024LL)); 102 {
103 snprintf(buf, bufsz, "%4lld", size / (1024LL * 1024LL * 1024LL * 1024LL));
104 *sz = 'T';
105 }
90 else if (size < (1024LL * 1024LL * 1024LL * 1024LL * 1024LL * 1024LL)) 106 else if (size < (1024LL * 1024LL * 1024LL * 1024LL * 1024LL * 1024LL))
91 snprintf(buf, bufsz, "%4lldP", size / (1024LL * 1024LL * 1024LL * 1024LL * 1024LL)); 107 {
108 snprintf(buf, bufsz, "%4lld", size / (1024LL * 1024LL * 1024LL * 1024LL * 1024LL));
109 *sz = 'P';
110 }
92 else 111 else
93 snprintf(buf, bufsz, "%4lldE", size / (1024LL * 1024LL * 1024LL * 1024LL * 1024LL * 1024LL)); 112 {
113 snprintf(buf, bufsz, "%4lld", size / (1024LL * 1024LL * 1024LL * 1024LL * 1024LL * 1024LL));
114 *sz = 'E';
115 }
116}
117
118#define RESET 0
119#define CORE 1
120#define CUBE 2
121#define GRAY 3
122
123#define BG 0
124#define FG 1
125
126#define BLACK 0
127#define RED 1
128#define GREEN 2
129#define YELLOW 3
130#define BLUE 4
131#define PURPLE 5
132#define CYAN 6
133#define WHITE 7
134#define BRIGHT 8
135
136// #3399ff
137// 51 153 355
138// as 6x6x6
139// 1.0 3.0 5.0
140
141static void
142colorprint(int mode, int fgbg, int r, int g, int b)
143{
144 if (mode == RESET)
145 {
146 printf("%c[0m", 0x1b);
147 }
148 else if (mode == CORE) // 8 bg and 8 fg colors
149 {
150 int v = 0;
151
152 if (r & BRIGHT) printf("%c[01m", 0x1b);
153 else printf("%c[0m", 0x1b);
154 if (fgbg == FG) v = 30 + (r & 0x7);
155 else v = 40 + (r & 0x7);
156 printf("%c[%im", 0x1b, v);
157 }
158 else if (mode == CUBE) // 6x6x6 cube
159 {
160 int v = 0, c = 0;
161
162 if (fgbg == FG) v = 38;
163 else v = 48;
164 c = 16 + ((r * 6 * 6) + (g * 6) + b);
165 printf("%c[%i;5;%im", 0x1b, v, c);
166 }
167 else if (mode == GRAY) // 26 levels of grey
168 {
169 }
170}
171
172static void
173sizeprint(char *sz, char szch)
174{
175 colorprint(CUBE, FG, 1, 3, 5);
176 printf("%s", sz);
177 if (szch == 'K')
178 colorprint(CUBE, FG, 3, 4, 5);
179 else if (szch == 'M')
180 colorprint(CUBE, FG, 5, 5, 5);
181 else if (szch == 'G')
182 colorprint(CUBE, FG, 5, 3, 0);
183 else if (szch == 'T')
184 colorprint(CUBE, FG, 5, 1, 1);
185 else if (szch == 'P')
186 colorprint(CUBE, FG, 5, 0, 0);
187 else if (szch == 'E')
188 colorprint(CUBE, FG, 5, 5, 0);
189 printf("%c", szch);
190 colorprint(RESET, 0, 0, 0, 0);
191}
192
193typedef struct _Cmatch
194{
195 short fr, fg, fb;
196 short br, bg, bb;
197 const char *match;
198} Cmatch;
199
200// for regular files
201const Cmatch fmatch[] =
202{
203 { 5, 5, 5, 9, 9, 9, "*.jpg"},
204 { 5, 5, 5, 9, 9, 9, "*.JPG"},
205 { 5, 5, 5, 9, 9, 9, "*.jpeg"},
206 { 5, 5, 5, 9, 9, 9, "*.JPEG"},
207 { 5, 5, 5, 9, 9, 9, "*.jfif"},
208 { 5, 5, 5, 9, 9, 9, "*.JFIF"},
209 { 5, 5, 5, 9, 9, 9, "*.jfi"},
210 { 5, 5, 5, 9, 9, 9, "*.JFI"},
211 { 5, 5, 5, 9, 9, 9, "*.png"},
212 { 5, 5, 5, 9, 9, 9, "*.PNG"},
213 { 5, 5, 5, 9, 9, 9, "*.bmp"},
214 { 5, 5, 5, 9, 9, 9, "*.BMP"},
215 { 5, 5, 5, 9, 9, 9, "*.gif"},
216 { 5, 5, 5, 9, 9, 9, "*.GIF"},
217 { 5, 5, 5, 9, 9, 9, "*.xcf"},
218 { 5, 5, 5, 9, 9, 9, "*.XCF"},
219 { 5, 5, 5, 9, 9, 9, "*.xcf.gz"},
220 { 5, 5, 5, 9, 9, 9, "*.XCF.gz"},
221 { 5, 5, 5, 9, 9, 9, "*.svg"},
222 { 5, 5, 5, 9, 9, 9, "*.SVG"},
223 { 5, 5, 5, 9, 9, 9, "*.svgz"},
224 { 5, 5, 5, 9, 9, 9, "*.SVGZ"},
225 { 5, 5, 5, 9, 9, 9, "*.svg.gz"},
226 { 5, 5, 5, 9, 9, 9, "*.SVG.GZ"},
227 { 5, 5, 5, 9, 9, 9, "*.ppm"},
228 { 5, 5, 5, 9, 9, 9, "*.PPM"},
229 { 5, 5, 5, 9, 9, 9, "*.tif"},
230 { 5, 5, 5, 9, 9, 9, "*.TIF"},
231 { 5, 5, 5, 9, 9, 9, "*.tiff"},
232 { 5, 5, 5, 9, 9, 9, "*.TIFF"},
233 { 5, 5, 5, 9, 9, 9, "*.ico"},
234 { 5, 5, 5, 9, 9, 9, "*.ICO"},
235 { 5, 5, 5, 9, 9, 9, "*.pgm"},
236 { 5, 5, 5, 9, 9, 9, "*.PGM"},
237 { 5, 5, 5, 9, 9, 9, "*.pbm"},
238 { 5, 5, 5, 9, 9, 9, "*.PBM"},
239 { 5, 5, 5, 9, 9, 9, "*.psd"},
240 { 5, 5, 5, 9, 9, 9, "*.PSD"},
241 { 5, 5, 5, 9, 9, 9, "*.wbmp"},
242 { 5, 5, 5, 9, 9, 9, "*.WBMP"},
243 { 5, 5, 5, 9, 9, 9, "*.cur"},
244 { 5, 5, 5, 9, 9, 9, "*.CUR"},
245 { 5, 5, 5, 9, 9, 9, "*.arw"},
246 { 5, 5, 5, 9, 9, 9, "*.ARW"},
247 { 5, 5, 5, 9, 9, 9, "*.webp"},
248 { 5, 5, 5, 9, 9, 9, "*.WEBP"},
249 { 5, 5, 5, 9, 9, 9, "*.cr2"},
250 { 5, 5, 5, 9, 9, 9, "*.CR2"},
251 { 5, 5, 5, 9, 9, 9, "*.crw"},
252 { 5, 5, 5, 9, 9, 9, "*.CRW"},
253 { 5, 5, 5, 9, 9, 9, "*.dcr"},
254 { 5, 5, 5, 9, 9, 9, "*.DCR"},
255 { 5, 5, 5, 9, 9, 9, "*.dng"},
256 { 5, 5, 5, 9, 9, 9, "*.DNG"},
257 { 5, 5, 5, 9, 9, 9, "*.k25"},
258 { 5, 5, 5, 9, 9, 9, "*.K25"},
259 { 5, 5, 5, 9, 9, 9, "*.kdc"},
260 { 5, 5, 5, 9, 9, 9, "*.KDC"},
261 { 5, 5, 5, 9, 9, 9, "*.thm"},
262 { 5, 5, 5, 9, 9, 9, "*.THM"},
263 { 5, 5, 5, 9, 9, 9, "*.erf"},
264 { 5, 5, 5, 9, 9, 9, "*.ERF"},
265 { 5, 5, 5, 9, 9, 9, "*.mrw"},
266 { 5, 5, 5, 9, 9, 9, "*.MRW"},
267 { 5, 5, 5, 9, 9, 9, "*.nef"},
268 { 5, 5, 5, 9, 9, 9, "*.NEF"},
269 { 5, 5, 5, 9, 9, 9, "*.nrf"},
270 { 5, 5, 5, 9, 9, 9, "*.NRF"},
271 { 5, 5, 5, 9, 9, 9, "*.nrw"},
272 { 5, 5, 5, 9, 9, 9, "*.NRW"},
273 { 5, 5, 5, 9, 9, 9, "*.orf"},
274 { 5, 5, 5, 9, 9, 9, "*.ORF"},
275 { 5, 5, 5, 9, 9, 9, "*.raw"},
276 { 5, 5, 5, 9, 9, 9, "*.RAW"},
277 { 5, 5, 5, 9, 9, 9, "*.rw2"},
278 { 5, 5, 5, 9, 9, 9, "*.RW2"},
279 { 5, 5, 5, 9, 9, 9, "*.pef"},
280 { 5, 5, 5, 9, 9, 9, "*.PEF"},
281 { 5, 5, 5, 9, 9, 9, "*.raf"},
282 { 5, 5, 5, 9, 9, 9, "*.RAF"},
283 { 5, 5, 5, 9, 9, 9, "*.sr2"},
284 { 5, 5, 5, 9, 9, 9, "*.SR2"},
285 { 5, 5, 5, 9, 9, 9, "*.srf"},
286 { 5, 5, 5, 9, 9, 9, "*.SRF"},
287 { 5, 5, 5, 9, 9, 9, "*.x3f"},
288 { 5, 5, 5, 9, 9, 9, "*.X3F"},
289
290 { 5, 5, 2, 9, 9, 9, "*.pdf"},
291 { 5, 5, 2, 9, 9, 9, "*.PDF"},
292 { 5, 5, 2, 9, 9, 9, "*.pdf"},
293 { 5, 5, 2, 9, 9, 9, "*.ps"},
294 { 5, 5, 2, 9, 9, 9, "*.PS"},
295 { 5, 5, 2, 9, 9, 9, "*.ps.gz"},
296 { 5, 5, 2, 9, 9, 9, "*.PS.GZ"},
297
298 { 3, 4, 5, 9, 9, 9, "*.asf"},
299 { 3, 4, 5, 9, 9, 9, "*.avi"},
300 { 3, 4, 5, 9, 9, 9, "*.bdm"},
301 { 3, 4, 5, 9, 9, 9, "*.bdmv"},
302 { 3, 4, 5, 9, 9, 9, "*.clpi"},
303 { 3, 4, 5, 9, 9, 9, "*.cpi"},
304 { 3, 4, 5, 9, 9, 9, "*.dv"},
305 { 3, 4, 5, 9, 9, 9, "*.fla"},
306 { 3, 4, 5, 9, 9, 9, "*.flv"},
307 { 3, 4, 5, 9, 9, 9, "*.m1v"},
308 { 3, 4, 5, 9, 9, 9, "*.m2t"},
309 { 3, 4, 5, 9, 9, 9, "*.m4v"},
310 { 3, 4, 5, 9, 9, 9, "*.mkv"},
311 { 3, 4, 5, 9, 9, 9, "*.mov"},
312 { 3, 4, 5, 9, 9, 9, "*.mp2"},
313 { 3, 4, 5, 9, 9, 9, "*.mp2ts"},
314 { 3, 4, 5, 9, 9, 9, "*.mp4"},
315 { 3, 4, 5, 9, 9, 9, "*.mpe"},
316 { 3, 4, 5, 9, 9, 9, "*.mpeg"},
317 { 3, 4, 5, 9, 9, 9, "*.mpg"},
318 { 3, 4, 5, 9, 9, 9, "*.mpl"},
319 { 3, 4, 5, 9, 9, 9, "*.mpls"},
320 { 3, 4, 5, 9, 9, 9, "*.mts"},
321 { 3, 4, 5, 9, 9, 9, "*.mxf"},
322 { 3, 4, 5, 9, 9, 9, "*.nut"},
323 { 3, 4, 5, 9, 9, 9, "*.nuv"},
324 { 3, 4, 5, 9, 9, 9, "*.ogg"},
325 { 3, 4, 5, 9, 9, 9, "*.ogv"},
326 { 3, 4, 5, 9, 9, 9, "*.ogm"},
327 { 3, 4, 5, 9, 9, 9, "*.qt"},
328 { 3, 4, 5, 9, 9, 9, "*.rm"},
329 { 3, 4, 5, 9, 9, 9, "*.rmj"},
330 { 3, 4, 5, 9, 9, 9, "*.rmm"},
331 { 3, 4, 5, 9, 9, 9, "*.rms"},
332 { 3, 4, 5, 9, 9, 9, "*.rmvb"},
333 { 3, 4, 5, 9, 9, 9, "*.rmx"},
334 { 3, 4, 5, 9, 9, 9, "*.rv"},
335 { 3, 4, 5, 9, 9, 9, "*.swf"},
336 { 3, 4, 5, 9, 9, 9, "*.ts"},
337 { 3, 4, 5, 9, 9, 9, "*.weba"},
338 { 3, 4, 5, 9, 9, 9, "*.webm"},
339 { 3, 4, 5, 9, 9, 9, "*.wmv"},
340 { 3, 4, 5, 9, 9, 9, "*.3g2"},
341 { 3, 4, 5, 9, 9, 9, "*.3gp2"},
342 { 3, 4, 5, 9, 9, 9, "*.3gpp"},
343 { 3, 4, 5, 9, 9, 9, "*.3gpp2"},
344 { 3, 4, 5, 9, 9, 9, "*.3p2"},
345 { 3, 4, 5, 9, 9, 9, "*.264"},
346 { 3, 4, 5, 9, 9, 9, "*.3gp"},
347
348 { 2, 3, 5, 9, 9, 9, "*.mp3"},
349 { 2, 3, 5, 9, 9, 9, "*.MP3"},
350 { 2, 3, 5, 9, 9, 9, "*.aac"},
351 { 2, 3, 5, 9, 9, 9, "*.AAC"},
352 { 2, 3, 5, 9, 9, 9, "*.wav"},
353 { 2, 3, 5, 9, 9, 9, "*.WAV"},
354
355 { 3, 5, 2, 9, 9, 9, "*.patch"},
356 { 3, 5, 2, 9, 9, 9, "*.PATCH"},
357 { 3, 5, 2, 9, 9, 9, "*.diff"},
358 { 3, 5, 2, 9, 9, 9, "*.DIFF"},
359
360 { 5, 1, 1, 9, 9, 9, "*.tar.*"},
361 { 5, 1, 1, 9, 9, 9, "*.TAR.*"},
362 { 5, 1, 1, 9, 9, 9, "*.tar"},
363 { 5, 1, 1, 9, 9, 9, "*.TAR"},
364 { 5, 1, 1, 9, 9, 9, "*.tgz"},
365 { 5, 1, 1, 9, 9, 9, "*.TGZ"},
366 { 5, 1, 1, 9, 9, 9, "*.tbz"},
367 { 5, 1, 1, 9, 9, 9, "*.TBZ"},
368 { 5, 1, 1, 9, 9, 9, "*.zip"},
369 { 5, 1, 1, 9, 9, 9, "*.ZIP"},
370 { 5, 1, 1, 9, 9, 9, "*.rar"},
371 { 5, 1, 1, 9, 9, 9, "*.RAR"},
372 { 5, 1, 1, 9, 9, 9, "*.cpio"},
373 { 5, 1, 1, 9, 9, 9, "*.CPIO"},
374
375 { 5, 1, 2, 9, 9, 9, "*.bin"},
376 { 5, 1, 2, 9, 9, 9, "*.BIN"},
377
378 { 0, 5, 2, 9, 9, 9, "*.iso"},
379 { 0, 5, 2, 9, 9, 9, "*.ISO"},
380 { 0, 5, 2, 9, 9, 9, "*.img"},
381 { 0, 5, 2, 9, 9, 9, "*.IMG"},
382
383 { 1, 1, 1, 9, 9, 9, "*~"},
384
385 { 5, 3, 1, 9, 9, 9, "Makefile"},
386 { 4, 2, 0, 9, 9, 9, "Makefile.in"},
387 { 3, 1, 0, 9, 9, 9, "*.am"},
388
389 { 4, 1, 5, 9, 9, 9, "*.m4"},
390
391 { 5, 2, 0, 9, 9, 9, "*.sh"},
392
393 { 2, 2, 3, 9, 9, 9, "*.in"},
394
395 { 5, 4, 0, 9, 9, 9, "configure"},
396 { 5, 3, 0, 9, 9, 9, "configure.in"},
397 { 5, 2, 0, 9, 9, 9, "configure.ac"},
398
399 { 0, 5, 5, 9, 9, 9, "*.c"},
400 { 0, 5, 5, 9, 9, 9, "*.C"},
401 { 1, 4, 5, 9, 9, 9, "*.x"},
402 { 1, 4, 5, 9, 9, 9, "*.X"},
403 { 1, 3, 5, 9, 9, 9, "*.h"},
404 { 1, 3, 5, 9, 9, 9, "*.H"},
405
406 { 5, 5, 2, 9, 9, 9, "*.edc"},
407 { 5, 5, 2, 9, 9, 9, "*.EDC"},
408
409 { 5, 3, 0, 9, 9, 9, "*.edj"},
410 { 5, 3, 0, 9, 9, 9, "*.EDJ"},
411
412 { 5, 0, 5, 9, 9, 9, "*.cc"},
413 { 5, 0, 5, 9, 9, 9, "*.CC"},
414 { 3, 1, 5, 9, 9, 9, "*.hh"},
415 { 3, 1, 5, 9, 9, 9, "*.HH"},
416
417 { 2, 0, 5, 9, 9, 9, "*.desktop"},
418 { 2, 0, 5, 9, 9, 9, "*.directory"},
419
420 { 0, 1, 3, 9, 9, 9, "*.o"},
421 { 0, 1, 3, 9, 9, 9, "*.O"},
422 { 0, 1, 3, 9, 9, 9, "*.lo"},
423
424 { 5, 1, 3, 9, 9, 9, "*.log"},
425 { 5, 1, 3, 9, 9, 9, "*.LOG"},
426
427 { 3, 1, 5, 9, 9, 9, "*.txt"},
428 { 3, 1, 5, 9, 9, 9, "*.TXT"},
429 { 3, 1, 5, 9, 9, 9, "README"},
430 { 3, 1, 5, 9, 9, 9, "Readme"},
431 { 3, 1, 5, 9, 9, 9, "readme"},
432 { 3, 1, 5, 9, 9, 9, "INSTALL"},
433 { 3, 1, 5, 9, 9, 9, "COPYING"},
434 { 3, 1, 5, 9, 9, 9, "NEWS"},
435 { 3, 1, 5, 9, 9, 9, "ChangeLog"},
436 { 3, 1, 5, 9, 9, 9, "AUTHORS"},
437 { 3, 1, 5, 9, 9, 9, "TODO"},
438 { 3, 1, 5, 9, 9, 9, "*.doc"},
439 { 3, 1, 5, 9, 9, 9, "*.DOC"},
440 { 3, 1, 5, 9, 9, 9, "*.docx"},
441 { 3, 1, 5, 9, 9, 9, "*.DOCX"},
442 { 3, 1, 5, 9, 9, 9, "*.html"},
443 { 3, 1, 5, 9, 9, 9, "*.HTML"},
444 { 3, 1, 5, 9, 9, 9, "*.htm"},
445 { 3, 1, 5, 9, 9, 9, "*.HTM"},
446
447 { 0, 0, 0, 0, 0, 0, NULL}
448};
449
450// for directories
451const Cmatch dmatch[] =
452{
453 { 5, 3, 0, 9, 9, 9, "Desktop"},
454 { 5, 3, 0, 9, 9, 9, "Desktop-*"},
455 { 4, 1, 5, 9, 9, 9, "public_html"},
456 { 0, 0, 0, 0, 0, 0, NULL}
457};
458
459// for exectuable files
460const Cmatch xmatch[] =
461{
462 { 0, 0, 0, 0, 0, 0, NULL}
463};
464
465static Eina_Bool
466printmatch(const char *name, const Cmatch *m)
467{
468 int i;
469
470 for (i = 0; m[i].match; i++)
471 {
472 if (!fnmatch(m[i].match, name, 0))
473 {
474 if (m[i].fr <= 5) colorprint(CUBE, FG, m[i].fr, m[i].fg, m[i].fb);
475 if (m[i].br <= 5) colorprint(CUBE, BG, m[i].br, m[i].bg, m[i].bb);
476 printf("%s", name);
477 return EINA_TRUE;
478 }
479 }
480 return EINA_FALSE;
481}
482
483static void
484fileprint(char *path, char *name, Eina_Bool type)
485{
486 Eina_Bool isdir = EINA_FALSE;
487 Eina_Bool islink = EINA_FALSE;
488
489 if (name || type)
490 {
491 char *ts;
492
493 if (ecore_file_is_dir(path)) isdir = EINA_TRUE;
494 ts = ecore_file_readlink(path);
495 if (ts)
496 {
497 islink = EINA_TRUE;
498 free(ts);
499 }
500 }
501 if (name)
502 {
503 if (isdir)
504 {
505 if (!printmatch(name, dmatch))
506 {
507 colorprint(CUBE, FG, 1, 3, 5);
508 printf("%s", name);
509 }
510 }
511 else
512 {
513 if (!printmatch(name, fmatch))
514 {
515 printf("%s", name);
516 }
517 }
518 }
519 if (type)
520 {
521 if (islink)
522 {
523 colorprint(CUBE, FG, 3, 1, 5);
524 printf("@");
525 }
526 else if (isdir)
527 {
528 colorprint(CUBE, FG, 3, 4, 5);
529 printf("/");
530 }
531 else
532 printf(" ");
533 }
534 colorprint(RESET, 0, 0, 0, 0);
94} 535}
95 536
96static void 537static void
@@ -133,6 +574,7 @@ list_dir(const char *dir, int mode)
133 maxlen--; 574 maxlen--;
134 stuff--; 575 stuff--;
135 } 576 }
577 if (cols > num) cols = num;
136 rows = ((num + (cols - 1)) / cols); 578 rows = ((num + (cols - 1)) / cols);
137 for (i = 0; i < rows; i++) 579 for (i = 0; i < rows; i++)
138 { 580 {
@@ -140,7 +582,7 @@ list_dir(const char *dir, int mode)
140 { 582 {
141 for (c = 0; c < cols; c++) 583 for (c = 0; c < cols; c++)
142 { 584 {
143 char buf[4096], sz[6]; 585 char buf[4096], sz[6], szch = ' ';
144 long long size; 586 long long size;
145 587
146 s = names[(c * rows) + i]; 588 s = names[(c * rows) + i];
@@ -149,29 +591,15 @@ list_dir(const char *dir, int mode)
149 int len = eina_unicode_utf8_get_len(s); 591 int len = eina_unicode_utf8_get_len(s);
150 cw = tw / cols; 592 cw = tw / cols;
151 size = ecore_file_size(buf); 593 size = ecore_file_size(buf);
152 size_print(sz, sizeof(sz), size); 594 size_print(sz, sizeof(sz), &szch, size);
153 len += stuff; 595 len += stuff;
154 printf("%c}it#%i;%i;%s%c", 0x1b, 2, 1, buf, 0); 596 printf("%c}it#%i;%i;%s%c", 0x1b, 2, 1, buf, 0);
155 printf("%c}ib%c", 0x1b, 0); 597 printf("%c}ib%c", 0x1b, 0);
156 printf("##"); 598 printf("##");
157 printf("%c}ie%c", 0x1b, 0); 599 printf("%c}ie%c", 0x1b, 0);
158 printf("%s %s", sz, s); 600 sizeprint(sz, szch);
159 if (ecore_file_is_dir(buf)) printf("/"); 601 printf(" ");
160 else 602 fileprint(buf, s, EINA_TRUE);
161 {
162 char *ts;
163
164 ts = ecore_file_readlink(buf);
165 if (ts)
166 {
167 printf("@");
168 free(ts);
169 }
170 else
171 {
172 printf(" ");
173 }
174 }
175 for (j = 0; j < (cw - len); j++) printf(" "); 603 for (j = 0; j < (cw - len); j++) printf(" ");
176 } 604 }
177 printf("\n"); 605 printf("\n");
@@ -193,7 +621,7 @@ list_dir(const char *dir, int mode)
193 printf("%c}ib%c", 0x1b, 0); 621 printf("%c}ib%c", 0x1b, 0);
194 printf("%c%c%c%c", 33 + c, 33 + c, 33 + c, 33 + c); 622 printf("%c%c%c%c", 33 + c, 33 + c, 33 + c, 33 + c);
195 printf("%c}ie%c", 0x1b, 0); 623 printf("%c}ie%c", 0x1b, 0);
196 printf("%s", s); 624 fileprint(buf, s, EINA_FALSE);
197 if (c < (cols - 1)) 625 if (c < (cols - 1))
198 { 626 {
199 for (j = 0; j < (cw - len); j++) printf(" "); 627 for (j = 0; j < (cw - len); j++) printf(" ");
@@ -202,7 +630,7 @@ list_dir(const char *dir, int mode)
202 printf("\n"); 630 printf("\n");
203 for (c = 0; c < cols; c++) 631 for (c = 0; c < cols; c++)
204 { 632 {
205 char buf[4096], sz[6]; 633 char buf[4096], sz[6], szch = ' ';
206 long long size; 634 long long size;
207 int len; 635 int len;
208 636
@@ -211,29 +639,15 @@ list_dir(const char *dir, int mode)
211 snprintf(buf, sizeof(buf), "%s/%s", dir, s); 639 snprintf(buf, sizeof(buf), "%s/%s", dir, s);
212 cw = tw / cols; 640 cw = tw / cols;
213 size = ecore_file_size(buf); 641 size = ecore_file_size(buf);
214 size_print(sz, sizeof(sz), size); 642 size_print(sz, sizeof(sz), &szch, size);
215 len = eina_unicode_utf8_get_len(sz) + 2 + 4; 643 len = eina_unicode_utf8_get_len(sz) + 2 + 4;
216 if (cols > 1) len += 1; 644 if (cols > 1) len += 1;
217 printf("%c}ib%c", 0x1b, 0); 645 printf("%c}ib%c", 0x1b, 0);
218 printf("%c%c%c%c", 33 + c, 33 + c, 33 + c, 33 + c); 646 printf("%c%c%c%c", 33 + c, 33 + c, 33 + c, 33 + c);
219 printf("%c}ie%c", 0x1b, 0); 647 printf("%c}ie%c", 0x1b, 0);
220 printf("%s ", sz); 648 sizeprint(sz, szch);
221 if (ecore_file_is_dir(buf)) printf("/"); 649 printf(" ");
222 else 650 fileprint(buf, NULL, EINA_TRUE);
223 {
224 char *ts;
225
226 ts = ecore_file_readlink(buf);
227 if (ts)
228 {
229 printf("@");
230 free(ts);
231 }
232 else
233 {
234 printf(" ");
235 }
236 }
237 if (c < (cols - 1)) 651 if (c < (cols - 1))
238 { 652 {
239 for (j = 0; j < (cw - len); j++) printf(" "); 653 for (j = 0; j < (cw - len); j++) printf(" ");
@@ -246,93 +660,6 @@ list_dir(const char *dir, int mode)
246 free(names); 660 free(names);
247 EINA_LIST_FREE(files, s) free(s); 661 EINA_LIST_FREE(files, s) free(s);
248} 662}
249/*
250 if ((is_fmt(rp, extn_img)) ||
251 (is_fmt(rp, extn_scale)) ||
252 (is_fmt(rp, extn_mov)))
253 {
254 o = evas_object_image_add(evas);
255 evas_object_image_file_set(o, rp, NULL);
256 evas_object_image_size_get(o, &w, &h);
257 if ((w >= 0) && (h > 0))
258 {
259 scaleterm(w, h, &iw, &ih);
260 prnt(rp, iw, ih, mode);
261 goto done;
262 }
263 evas_object_del(o);
264 o = NULL;
265 }
266
267 if (is_fmt(rp, extn_edj))
268 {
269 Eina_Bool ok = EINA_TRUE;
270
271 evas_object_del(o);
272 o = edje_object_add(evas);
273 if (!edje_object_file_set
274 (o, rp, "terminology/backgroud"))
275 {
276 if (!edje_object_file_set
277 (o, rp, "e/desktop/background"))
278 ok = EINA_FALSE;
279 }
280 if (ok)
281 {
282 Evas_Coord mw = 0, mh = 0;
283
284 edje_object_size_min_get(o, &mw, &mh);
285 if ((mw <= 0) || (mh <= 0))
286 edje_object_size_min_calc(o, &mw, &mh);
287 if ((mw <= 0) || (mh <= 0))
288 {
289 mw = (tw) * cw;
290 mh = (th - 1) * ch;
291 }
292 scaleterm(mw, mh, &iw, &ih);
293 prnt(rp, iw, ih, mode);
294 goto done;
295 }
296 evas_object_del(o);
297 o = NULL;
298 }
299
300 if ((is_fmt(rp, extn_aud)) ||
301 (is_fmt(rp, extn_mov)))
302 {
303 Eina_Bool ok = EINA_TRUE;
304
305 o = emotion_object_add(evas);
306 ok = emotion_object_init(o, NULL);
307 if (ok)
308 {
309 if (emotion_object_file_set(o, rp))
310 {
311 emotion_object_audio_mute_set(o, EINA_TRUE);
312 if (emotion_object_video_handled_get(o))
313 {
314 emotion_object_size_get(o, &w, &h);
315 if ((w >= 0) && (h > 0))
316 {
317 scaleterm(w, h, &iw, &ih);
318 prnt(rp, iw, ih, mode);
319 }
320 }
321 else
322 prnt(rp, tw, 3, NOIMG);
323 goto done;
324 }
325 }
326 evas_object_del(o);
327 o = NULL;
328 }
329done:
330 if (o) evas_object_del(o);
331 o = NULL;
332 free(rp);
333 }
334 evas_norender(evas);
335*/
336 663
337int 664int
338main(int argc, char **argv) 665main(int argc, char **argv)
@@ -424,6 +751,7 @@ main(int argc, char **argv)
424 free(rp); 751 free(rp);
425 } 752 }
426 } 753 }
754 fflush(stdout);
427 exit(0); 755 exit(0);
428// ecore_main_loop_begin(); 756// ecore_main_loop_begin();
429 ecore_evas_free(ee); 757 ecore_evas_free(ee);