summaryrefslogtreecommitdiff
path: root/apps
diff options
context:
space:
mode:
Diffstat (limited to 'apps')
-rw-r--r--apps/showtext.c132
1 files changed, 0 insertions, 132 deletions
diff --git a/apps/showtext.c b/apps/showtext.c
deleted file mode 100644
index 0266a678f5..0000000000
--- a/apps/showtext.c
+++ /dev/null
@@ -1,132 +0,0 @@
1/***************************************************************************
2 * __________ __ ___.
3 * Open \______ \ ____ ____ | | _\_ |__ _______ ___
4 * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ /
5 * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < <
6 * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \
7 * \/ \/ \/ \/ \/
8 * $Id$
9 *
10 * Copyright (C) 2002 Daniel Stenberg
11 *
12 * All files in this archive are subject to the GNU General Public License.
13 * See the file COPYING in the source tree root for full license agreement.
14 *
15 * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
16 * KIND, either express or implied.
17 *
18 ****************************************************************************/
19
20#include <string.h>
21
22#include "file.h"
23#include "lcd.h"
24#include "kernel.h"
25#include "button.h"
26#include "sprintf.h"
27
28static int here=0;
29
30char *singleshow(char *word)
31{
32 static unsigned char words[22];
33 int len = strlen(word);
34
35 if(len>=10) {
36 if(len < 12 ) {
37 lcd_clear_display();
38 lcd_puts(0,0, word);
39 strcpy(words, "");
40 here=0;
41 return words;
42 }
43 /* huuuge word, use two lines! */
44 return NULL;
45 }
46
47 else if(here +1 + len <= 11) { /* 1 is for space */
48 if(words[0])
49 strcat(words, " ");
50 strcat(words, word);
51 here+=1+len;
52 return NULL; /* no show right now */
53 }
54 else {
55 lcd_clear_display();
56 lcd_puts(0,0, words);
57 strcpy(words, word);
58 here=len;
59 return words;
60 }
61}
62
63#define SEP(x) (((x) == '\n') || ((x) == '\t') || ((x) == ' '))
64
65void showtext(char *filename)
66{
67 static char textbuffer[1024];
68
69 int fd;
70 int size;
71 char *ptr;
72 char *end;
73 unsigned char backup;
74 char num[8];
75 int count=0;
76 int b;
77 char *show;
78 int delay = HZ;
79
80 fd = open(filename, O_RDONLY);
81
82 if(-1 == fd)
83 return;
84
85 do {
86 size = read(fd, textbuffer, sizeof(textbuffer));
87
88 ptr = textbuffer;
89 while (size > 0) {
90 while(ptr && *ptr && SEP(*ptr)) {
91 ptr++;
92 size--;
93 count++;
94 }
95 end = ptr;
96
97 while(end && *end && !SEP(*end)) {
98 end++;
99 count++;
100 }
101
102 backup = *end;
103 *end = 0;
104
105
106 show = singleshow(ptr);
107
108 if(show) {
109 snprintf(num, sizeof(num), "%d", count);
110 lcd_puts(0,1, num);
111 }
112
113 *end = backup;
114
115 ptr += (end - ptr);
116 size -= (end - ptr);
117
118 b = button_get(false);
119 if(b) {
120 size = -1;
121 break;
122 }
123 if(show)
124 sleep(delay);
125 }
126
127
128 } while(size>0);
129
130 close(fd);
131
132}