summaryrefslogtreecommitdiff
path: root/apps/recorder
diff options
context:
space:
mode:
authorLinus Nielsen Feltzing <linus@haxx.se>2003-11-17 02:10:09 +0000
committerLinus Nielsen Feltzing <linus@haxx.se>2003-11-17 02:10:09 +0000
commit210de716dbbb51c10814920e644b348ccd5c7e68 (patch)
tree01d4a8219cc4d5f68f7e2cd6fa84318fed6f5816 /apps/recorder
parent83b5b55d95d3fe7a8970360244e37dfd4c070c16 (diff)
downloadrockbox-210de716dbbb51c10814920e644b348ccd5c7e68.tar.gz
rockbox-210de716dbbb51c10814920e644b348ccd5c7e68.zip
Minor rework of the keyboard code. Also fixes bug #842448.
git-svn-id: svn://svn.rockbox.org/rockbox/trunk@4033 a1c6a512-1295-4272-9138-f99709370657
Diffstat (limited to 'apps/recorder')
-rw-r--r--apps/recorder/keyboard.c143
1 files changed, 72 insertions, 71 deletions
diff --git a/apps/recorder/keyboard.c b/apps/recorder/keyboard.c
index b4630d3e7d..b39a3aeec8 100644
--- a/apps/recorder/keyboard.c
+++ b/apps/recorder/keyboard.c
@@ -55,19 +55,7 @@ static void kbd_setupkeys(char* line[KEYBOARD_LINES], int page)
55 break; 55 break;
56 } 56 }
57} 57}
58#if 0 58
59static void kbd_draw_statusbar_button(int num, char* caption, int y, int fw)
60{
61 int x, x2, tw, cx;
62 x = num*(LCD_WIDTH/3);
63 x2 = (num+1)*(LCD_WIDTH/3);
64 tw = fw * strlen(caption);
65 cx = x2 - x;
66 /* center the text */
67 lcd_putsxy((x + (cx/2)) - (tw/2), y, caption);
68 lcd_invertrect(x, y - 1, (x2-x)-1, LCD_HEIGHT-y+1);
69}
70#endif
71int kbd_input(char* text, int buflen) 59int kbd_input(char* text, int buflen)
72{ 60{
73 bool done = false; 61 bool done = false;
@@ -79,6 +67,7 @@ int kbd_input(char* text, int buflen)
79 int status_y1, status_y2, curpos; 67 int status_y1, status_y2, curpos;
80 int len; 68 int len;
81 int editpos; 69 int editpos;
70 bool redraw = true;
82 char* line[KEYBOARD_LINES]; 71 char* line[KEYBOARD_LINES];
83 72
84 char outline[256]; 73 char outline[256];
@@ -90,7 +79,7 @@ int kbd_input(char* text, int buflen)
90 font_h = font->height; 79 font_h = font->height;
91 80
92 margin = 3; 81 margin = 3;
93 main_y = (KEYBOARD_LINES + 1) * font_h + margin; 82 main_y = (KEYBOARD_LINES + 1) * font_h + margin*2;
94 main_x = 0; 83 main_x = 0;
95 status_y1 = LCD_HEIGHT - font_h; 84 status_y1 = LCD_HEIGHT - font_h;
96 status_y2 = LCD_HEIGHT; 85 status_y2 = LCD_HEIGHT;
@@ -102,79 +91,90 @@ int kbd_input(char* text, int buflen)
102 91
103 while(!done) 92 while(!done)
104 { 93 {
105 lcd_clear_display();
106
107 /* draw page */
108 for (i=0; i < KEYBOARD_LINES; i++)
109 lcd_putsxy(0, i * font_h, line[i]);
110
111 len = strlen(text); 94 len = strlen(text);
112 95
113 /* separator */ 96 if(redraw)
114 lcd_drawline(0, main_y - margin, LCD_WIDTH, main_y - margin);
115
116 /* write out the text */
117 if (editpos < max_chars - 3 )
118 { 97 {
119 strncpy(outline, text, max_chars - 2); 98 lcd_clear_display();
120 if (len > max_chars - 2) 99
121 lcd_putsxy(LCD_WIDTH - font_w, main_y, ">"); 100 lcd_setfont(FONT_SYSFIXED);
122 curpos = (1 + editpos) * font_w; 101
123 } 102 /* draw page */
124 else 103 for (i=0; i < KEYBOARD_LINES; i++)
125 { 104 lcd_putsxy(0, 8+i * font_h, line[i]);
126 /* not room for all text, cut left, right or both */ 105
127 if (editpos == len ) 106 /* separator */
107 lcd_drawline(0, main_y - margin, LCD_WIDTH, main_y - margin);
108
109 /* write out the text */
110 if (editpos < max_chars - 3 )
128 { 111 {
129 if ( max_chars - 3 == len) 112 strncpy(outline, text, max_chars - 2);
130 { 113 if (len > max_chars - 2)
131 strncpy(outline, text, max_chars - 2); 114 lcd_putsxy(LCD_WIDTH - font_w, main_y, ">");
132 curpos = (1 + editpos) * font_w; 115 curpos = (1 + editpos) * font_w;
133 }
134 else
135 {
136 strncpy(outline, text + editpos - max_chars + 2,
137 max_chars - 2);
138 if (len > max_chars - 2)
139 lcd_putsxy(0, main_y, "<");
140 curpos = ( max_chars - 1) * font_w;
141 }
142 } 116 }
143 else 117 else
144 { 118 {
145 if (len - 1 == editpos) 119 /* not room for all text, cut left, right or both */
120 if (editpos == len )
146 { 121 {
147 strncpy(outline, text + editpos - max_chars + 3, 122 if ( max_chars - 3 == len)
148 max_chars - 2); 123 {
149 curpos = ( max_chars - 2) * font_w; 124 strncpy(outline, text, max_chars - 2);
125 curpos = (1 + editpos) * font_w;
126 }
127 else
128 {
129 strncpy(outline, text + editpos - max_chars + 2,
130 max_chars - 2);
131 if (len > max_chars - 2)
132 lcd_putsxy(0, main_y, "<");
133 curpos = ( max_chars - 1) * font_w;
134 }
150 } 135 }
151 else 136 else
152 { 137 {
153 strncpy(outline, text + editpos - max_chars + 4, 138 if (len - 1 == editpos)
154 max_chars - 2); 139 {
155 curpos = ( max_chars - 3) * font_w; 140 strncpy(outline, text + editpos - max_chars + 3,
141 max_chars - 2);
142 curpos = ( max_chars - 2) * font_w;
143 }
144 else
145 {
146 strncpy(outline, text + editpos - max_chars + 4,
147 max_chars - 2);
148 curpos = ( max_chars - 3) * font_w;
149 }
150 lcd_putsxy(LCD_WIDTH - font_w, main_y, ">");
151 lcd_putsxy(0, main_y, "<");
156 } 152 }
157 lcd_putsxy(LCD_WIDTH - font_w, main_y, ">");
158 lcd_putsxy(0, main_y, "<");
159 } 153 }
160 }
161 154
162 /* Zero terminate the string */ 155 /* Zero terminate the string */
163 outline[max_chars - 2] = '\0'; 156 outline[max_chars - 2] = '\0';
157
158 lcd_putsxy(font_w,main_y,outline);
159
160 /* cursor */
161 lcd_drawline(curpos, main_y, curpos, main_y + font_h);
162
163 /* draw the status bar */
164 buttonbar_set("Shift", "OK", "Del");
165 buttonbar_draw();
166
167 /* highlight the key that has focus */
168 lcd_invertrect(font_w * x, 8 + font_h * y, font_w, font_h);
169
170 status_draw(true);
164 171
165 lcd_putsxy(font_w,main_y,outline); 172 lcd_update();
166 173 }
167 /* cursor */
168 lcd_drawline(curpos, main_y, curpos, main_y + font_h);
169 174
170 /* draw the status bar */ 175 /* The default action is to redraw */
171 buttonbar_set("Shift", "OK", "Del"); 176 redraw = true;
172 buttonbar_draw();
173 177
174 /* highlight the key that has focus */
175 lcd_invertrect(font_w * x, font_h * y, font_w, font_h);
176 lcd_update();
177
178 switch ( button_get_w_tmo(HZ/2) ) { 178 switch ( button_get_w_tmo(HZ/2) ) {
179 179
180 case BUTTON_OFF: 180 case BUTTON_OFF:
@@ -286,6 +286,7 @@ int kbd_input(char* text, int buflen)
286 286
287 case BUTTON_NONE: 287 case BUTTON_NONE:
288 status_draw(false); 288 status_draw(false);
289 redraw = false;
289 break; 290 break;
290 } 291 }
291 } 292 }