tycat... faster shutdown... and understand edje and mp3/music files...
and stuff SVN revision: 83429
This commit is contained in:
parent
552b55319a
commit
47fe497356
165
src/bin/tycat.c
165
src/bin/tycat.c
|
@ -4,6 +4,7 @@
|
||||||
#include <Ecore_Evas.h>
|
#include <Ecore_Evas.h>
|
||||||
#include <Ecore_File.h>
|
#include <Ecore_File.h>
|
||||||
#include <Edje.h>
|
#include <Edje.h>
|
||||||
|
#include <Emotion.h>
|
||||||
#include <termios.h>
|
#include <termios.h>
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
|
@ -13,7 +14,8 @@
|
||||||
enum {
|
enum {
|
||||||
CENTER,
|
CENTER,
|
||||||
FILL,
|
FILL,
|
||||||
STRETCH
|
STRETCH,
|
||||||
|
NOIMG
|
||||||
};
|
};
|
||||||
|
|
||||||
Ecore_Evas *ee = NULL;
|
Ecore_Evas *ee = NULL;
|
||||||
|
@ -21,8 +23,6 @@ Evas *evas = NULL;
|
||||||
Evas_Object *o = NULL;
|
Evas_Object *o = NULL;
|
||||||
struct termios told, tnew;
|
struct termios told, tnew;
|
||||||
int tw = 0, th = 0, cw = 0, ch = 0;
|
int tw = 0, th = 0, cw = 0, ch = 0;
|
||||||
int w = 0, h = 0;
|
|
||||||
int iw = 0, ih = 0;
|
|
||||||
|
|
||||||
static int
|
static int
|
||||||
echo_off(void)
|
echo_off(void)
|
||||||
|
@ -40,10 +40,64 @@ echo_on(void)
|
||||||
return tcsetattr(0, TCSAFLUSH, &told);
|
return tcsetattr(0, TCSAFLUSH, &told);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static void
|
||||||
|
scaleterm(int w, int h, int *iw, int *ih)
|
||||||
|
{
|
||||||
|
if (w > (tw * cw))
|
||||||
|
{
|
||||||
|
*iw = tw;
|
||||||
|
*ih = ((h * (tw * cw) / w) + (ch - 1)) / ch;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
*iw = (w + (cw - 1)) / cw;
|
||||||
|
*ih = (h + (ch - 1)) / ch;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
static void
|
||||||
|
prnt(const char *path, int w, int h, int mode)
|
||||||
|
{
|
||||||
|
int x, y, i;
|
||||||
|
char *line, buf[4096];
|
||||||
|
|
||||||
|
if ((w >= 512) || (h >= 512)) return;
|
||||||
|
line = malloc(w + 100);
|
||||||
|
if (!line) return;
|
||||||
|
if (mode == CENTER)
|
||||||
|
snprintf(buf, sizeof(buf), "%c}ic#%i;%i;%s", 0x1b, w, h, path);
|
||||||
|
else if (mode == FILL)
|
||||||
|
snprintf(buf, sizeof(buf), "%c}if#%i;%i;%s", 0x1b, w, h, path);
|
||||||
|
else
|
||||||
|
snprintf(buf, sizeof(buf), "%c}is#%i;%i;%s", 0x1b, w, h, path);
|
||||||
|
if (write(0, buf, strlen(buf) + 1) < 0) perror("write");
|
||||||
|
i = 0;
|
||||||
|
line[i++] = 0x1b;
|
||||||
|
line[i++] = '}';
|
||||||
|
line[i++] = 'i';
|
||||||
|
line[i++] = 'b';
|
||||||
|
line[i++] = 0;
|
||||||
|
for (x = 0; x < w; x++) line[i++] = '#';
|
||||||
|
line[i++] = 0x1b;
|
||||||
|
line[i++] = '}';
|
||||||
|
line[i++] = 'i';
|
||||||
|
line[i++] = 'e';
|
||||||
|
line[i++] = 0;
|
||||||
|
line[i++] = '\n';
|
||||||
|
line[i++] = 0;
|
||||||
|
for (y = 0; y < h; y++)
|
||||||
|
{
|
||||||
|
if (write(0, line, i) < 0) perror("write");
|
||||||
|
}
|
||||||
|
free(line);
|
||||||
|
}
|
||||||
|
|
||||||
int
|
int
|
||||||
main(int argc, char **argv)
|
main(int argc, char **argv)
|
||||||
{
|
{
|
||||||
char buf[8192];
|
char buf[64];
|
||||||
|
int w = 0, h = 0;
|
||||||
|
int iw = 0, ih = 0;
|
||||||
|
|
||||||
if (!getenv("TERMINOLOGY")) return 0;
|
if (!getenv("TERMINOLOGY")) return 0;
|
||||||
if (argc <= 1)
|
if (argc <= 1)
|
||||||
|
@ -62,13 +116,13 @@ main(int argc, char **argv)
|
||||||
evas_init();
|
evas_init();
|
||||||
ecore_evas_init();
|
ecore_evas_init();
|
||||||
edje_init();
|
edje_init();
|
||||||
|
emotion_init();
|
||||||
ee = ecore_evas_buffer_new(1, 1);
|
ee = ecore_evas_buffer_new(1, 1);
|
||||||
if (ee)
|
if (ee)
|
||||||
{
|
{
|
||||||
int i, mode = CENTER;
|
int i, mode = CENTER;
|
||||||
|
|
||||||
evas = ecore_evas_get(ee);
|
evas = ecore_evas_get(ee);
|
||||||
o = evas_object_image_add(evas);
|
|
||||||
echo_off();
|
echo_off();
|
||||||
snprintf(buf, sizeof(buf), "%c}qs", 0x1b);
|
snprintf(buf, sizeof(buf), "%c}qs", 0x1b);
|
||||||
if (write(0, buf, strlen(buf) + 1) < 0) perror("write");
|
if (write(0, buf, strlen(buf) + 1) < 0) perror("write");
|
||||||
|
@ -77,6 +131,11 @@ main(int argc, char **argv)
|
||||||
echo_on();
|
echo_on();
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
if ((tw <= 0) || (th <= 0) || (cw <= 1) || (ch <= 1))
|
||||||
|
{
|
||||||
|
echo_on();
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
echo_on();
|
echo_on();
|
||||||
for (i = 1; i < argc; i++)
|
for (i = 1; i < argc; i++)
|
||||||
{
|
{
|
||||||
|
@ -105,70 +164,80 @@ main(int argc, char **argv)
|
||||||
rp = ecore_file_realpath(path);
|
rp = ecore_file_realpath(path);
|
||||||
if (rp)
|
if (rp)
|
||||||
{
|
{
|
||||||
|
o = evas_object_image_add(evas);
|
||||||
evas_object_image_file_set(o, rp, NULL);
|
evas_object_image_file_set(o, rp, NULL);
|
||||||
evas_object_image_size_get(o, &w, &h);
|
evas_object_image_size_get(o, &w, &h);
|
||||||
if ((w >= 0) && (h > 0))
|
if ((w >= 0) && (h > 0))
|
||||||
{
|
{
|
||||||
int x, y, i;
|
scaleterm(w, h, &iw, &ih);
|
||||||
char *line;
|
prnt(rp, iw, ih, mode);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
Eina_Bool ok = EINA_TRUE;
|
||||||
|
|
||||||
if ((tw <= 0) || (th <= 0) || (cw <= 1) || (ch <= 1))
|
evas_object_del(o);
|
||||||
|
o = edje_object_add(evas);
|
||||||
|
if (!edje_object_file_set
|
||||||
|
(o, rp, "terminology/backgroud"))
|
||||||
{
|
{
|
||||||
free(rp);
|
if (!edje_object_file_set
|
||||||
continue;
|
(o, rp, "e/desktop/background"))
|
||||||
|
ok = EINA_FALSE;
|
||||||
}
|
}
|
||||||
if (w > (tw * cw))
|
if (ok)
|
||||||
{
|
{
|
||||||
iw = tw;
|
Evas_Coord mw = 0, mh = 0;
|
||||||
ih = ((h * (tw * cw) / w) + (ch - 1)) / ch;
|
|
||||||
|
edje_object_size_min_get(o, &mw, &mh);
|
||||||
|
if ((mw <= 0) || (mh <= 0))
|
||||||
|
edje_object_size_min_calc(o, &mw, &mh);
|
||||||
|
if ((mw <= 0) || (mh <= 0))
|
||||||
|
{
|
||||||
|
mw = (tw) * cw;
|
||||||
|
mh = (th - 1) * ch;
|
||||||
|
}
|
||||||
|
scaleterm(mw, mh, &iw, &ih);
|
||||||
|
prnt(rp, iw, ih, mode);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
iw = (w + (cw - 1)) / cw;
|
ok = EINA_TRUE;
|
||||||
ih = (h + (ch - 1)) / ch;
|
|
||||||
}
|
evas_object_del(o);
|
||||||
line = malloc(iw + 100);
|
|
||||||
if (!line)
|
o = emotion_object_add(evas);
|
||||||
|
ok = emotion_object_init(o, NULL);
|
||||||
|
if (ok)
|
||||||
{
|
{
|
||||||
free(rp);
|
if (emotion_object_file_set(o, rp))
|
||||||
continue;
|
{
|
||||||
|
emotion_object_audio_mute_set(o, EINA_TRUE);
|
||||||
|
if (emotion_object_video_handled_get(o))
|
||||||
|
{
|
||||||
|
emotion_object_size_get(o, &w, &h);
|
||||||
|
if ((w >= 0) && (h > 0))
|
||||||
|
{
|
||||||
|
scaleterm(w, h, &iw, &ih);
|
||||||
|
prnt(rp, iw, ih, mode);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
if (mode == CENTER)
|
|
||||||
snprintf(buf, sizeof(buf), "%c}ic#%i;%i;%s",
|
|
||||||
0x1b, iw, ih, rp);
|
|
||||||
else if (mode == FILL)
|
|
||||||
snprintf(buf, sizeof(buf), "%c}if#%i;%i;%s",
|
|
||||||
0x1b, iw, ih, rp);
|
|
||||||
else
|
else
|
||||||
snprintf(buf, sizeof(buf), "%c}is#%i;%i;%s",
|
prnt(rp, tw, 3, NOIMG);
|
||||||
0x1b, iw, ih, rp);
|
|
||||||
if (write(0, buf, strlen(buf) + 1) < 0) perror("write");
|
|
||||||
i = 0;
|
|
||||||
line[i++] = 0x1b;
|
|
||||||
line[i++] = '}';
|
|
||||||
line[i++] = 'i';
|
|
||||||
line[i++] = 'b';
|
|
||||||
line[i++] = 0;
|
|
||||||
for (x = 0; x < iw; x++) line[i++] = '#';
|
|
||||||
line[i++] = 0x1b;
|
|
||||||
line[i++] = '}';
|
|
||||||
line[i++] = 'i';
|
|
||||||
line[i++] = 'e';
|
|
||||||
line[i++] = 0;
|
|
||||||
line[i++] = '\n';
|
|
||||||
line[i++] = 0;
|
|
||||||
for (y = 0; y < ih; y++)
|
|
||||||
{
|
|
||||||
if (write(0, line, i) < 0) perror("write");
|
|
||||||
}
|
}
|
||||||
free(line);
|
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
evas_object_del(o);
|
||||||
free(rp);
|
free(rp);
|
||||||
}
|
}
|
||||||
|
evas_norender(evas);
|
||||||
}
|
}
|
||||||
|
exit(0);
|
||||||
// ecore_main_loop_begin();
|
// ecore_main_loop_begin();
|
||||||
ecore_evas_free(ee);
|
// ecore_evas_free(ee);
|
||||||
}
|
}
|
||||||
|
emotion_shutdown();
|
||||||
edje_shutdown();
|
edje_shutdown();
|
||||||
ecore_evas_shutdown();
|
ecore_evas_shutdown();
|
||||||
evas_shutdown();
|
evas_shutdown();
|
||||||
|
|
Loading…
Reference in New Issue