/[projects]/misc/tvtime-cli/tvtime-cli.c
ViewVC logotype

Contents of /misc/tvtime-cli/tvtime-cli.c

Parent Directory Parent Directory | Revision Log Revision Log


Revision 330 - (show annotations) (download)
Thu Sep 17 09:39:30 2009 UTC (14 years, 8 months ago) by torben
File MIME type: text/plain
File size: 1377 byte(s)
Added some more old code

1 #include <ncurses.h>
2 #include <stdlib.h>
3
4 #define ESC 27
5
6 void command(char* ch)
7 {
8 char buf[1024];
9 snprintf(buf, 1023, "tvtime-command %s 2>/dev/null >/dev/null", ch);
10 system(buf);
11 }
12
13 void handle_key(int ch)
14 {
15 switch(ch)
16 {
17 case KEY_DOWN:
18 command("down");
19 break;
20 case KEY_UP:
21 command("up");
22 break;
23 case KEY_LEFT:
24 command("left");
25 break;
26 case KEY_RIGHT:
27 command("right");
28 break;
29 case 'm':
30 case 'M':
31 command("toggle_mute");
32 break;
33 case KEY_ENTER:
34 case '\n':
35 command("enter");
36 break;
37 case '0':
38 command("channel_0");
39 break;
40 case '1':
41 command("channel_1");
42 break;
43 case '2':
44 command("channel_2");
45 break;
46 case '3':
47 command("channel_3");
48 break;
49 case '4':
50 command("channel_4");
51 break;
52 case '5':
53 command("channel_5");
54 break;
55 case '6':
56 command("channel_6");
57 break;
58 case '7':
59 command("channel_7");
60 break;
61 case '8':
62 command("channel_8");
63 break;
64 case '9':
65 command("channel_9");
66 break;
67 case ' ':
68 command("channel_jump");
69 break;
70 case 'f':
71 case 'F':
72 command("toggle_fullscreen");
73 }
74 }
75
76 int main(int argc, char**argv)
77 {
78 int ch = 0;
79
80 initscr();
81 keypad(stdscr, TRUE);
82 noecho();
83 printw("TvTime - cli\n");
84 do {
85 move(3,3);
86 printw("%4d", ch);
87 // clear();
88 ch = getch();
89 handle_key(ch);
90 } while (ch != ESC);
91
92 endwin();
93 return 0;
94 }

  ViewVC Help
Powered by ViewVC 1.1.20