1 | /* |
---|
2 | * neercs console-based window manager |
---|
3 | * Copyright (c) 2006 Sam Hocevar <sam@zoy.org> |
---|
4 | * 2008 Jean-Yves Lamoureux <jylam@lnxscene.org> |
---|
5 | * All Rights Reserved |
---|
6 | * |
---|
7 | * $Id: main.c 2360 2008-06-11 16:23:46Z jylam $ |
---|
8 | * |
---|
9 | * This program is free software. It comes without any warranty, to |
---|
10 | * the extent permitted by applicable law. You can redistribute it |
---|
11 | * and/or modify it under the terms of the Do What The Fuck You Want |
---|
12 | * To Public License, Version 2, as published by Sam Hocevar. See |
---|
13 | * http://sam.zoy.org/wtfpl/COPYING for more details. |
---|
14 | */ |
---|
15 | |
---|
16 | #include <cucul.h> |
---|
17 | #include <caca.h> |
---|
18 | #include <stdlib.h> |
---|
19 | |
---|
20 | #include "neercs.h" |
---|
21 | |
---|
22 | |
---|
23 | void draw_thumbnails(cucul_canvas_t *cv, struct screen_list *screen_list, int pty) |
---|
24 | { |
---|
25 | char const * const *fonts; |
---|
26 | cucul_dither_t *d; |
---|
27 | cucul_font_t *f; |
---|
28 | uint8_t *buf; |
---|
29 | int i; |
---|
30 | int miniw, minih; |
---|
31 | |
---|
32 | if(screen_list->count) |
---|
33 | { |
---|
34 | fonts = cucul_get_font_list(); |
---|
35 | f = cucul_load_font(fonts[0], 0); |
---|
36 | |
---|
37 | miniw = cucul_get_canvas_width(screen_list->screen[0]->cv) |
---|
38 | * cucul_get_font_width(f); |
---|
39 | minih = cucul_get_canvas_height(screen_list->screen[0]->cv) |
---|
40 | * cucul_get_font_height(f); |
---|
41 | buf = malloc(4 * miniw * minih); |
---|
42 | |
---|
43 | #if defined(HAVE_ENDIAN_H) |
---|
44 | if(__BYTE_ORDER == __BIG_ENDIAN) |
---|
45 | #else |
---|
46 | /* This is compile-time optimised with at least -O1 or -Os */ |
---|
47 | uint32_t const tmp = 0x12345678; |
---|
48 | if(*(uint8_t const *)&tmp == 0x12) |
---|
49 | #endif |
---|
50 | d = cucul_create_dither(32, miniw, minih, 4 * miniw, |
---|
51 | 0xff0000, 0xff00, 0xff, 0x0); |
---|
52 | else |
---|
53 | d = cucul_create_dither(32, miniw, minih, 4 * miniw, |
---|
54 | 0xff00, 0xff0000, 0xff000000, 0x0); |
---|
55 | |
---|
56 | for(i = 0; i < screen_list->count; i++) |
---|
57 | { |
---|
58 | cucul_render_canvas(screen_list->screen[i]->cv, f, buf, |
---|
59 | miniw, minih, miniw * 4); |
---|
60 | cucul_dither_bitmap(cv, 20 * i, |
---|
61 | cucul_get_canvas_height(cv) - 6, 19, 6, d, buf); |
---|
62 | cucul_set_color_ansi(cv, CUCUL_WHITE, CUCUL_BLUE); |
---|
63 | |
---|
64 | if(pty == i) |
---|
65 | cucul_draw_cp437_box(cv,20 * i, |
---|
66 | cucul_get_canvas_height(cv) - 6, 19, 6); |
---|
67 | cucul_printf(cv, 20 * i, |
---|
68 | cucul_get_canvas_height(cv) - 6, "(%i)", i); |
---|
69 | } |
---|
70 | |
---|
71 | cucul_free_dither(d); |
---|
72 | cucul_free_font(f); |
---|
73 | |
---|
74 | free(buf); |
---|
75 | } |
---|
76 | |
---|
77 | } |
---|