FreeCalypso > hg > fc-magnetite
comparison src/ui3/bmi/AUICalcEditor.c @ 420:e8ddbb0837ed
src/ui3: initial import of TCS3/LoCosto BMI & MFW code
author | Mychaela Falconia <falcon@freecalypso.org> |
---|---|
date | Sun, 21 Jan 2018 03:09:00 +0000 |
parents | |
children |
comparison
equal
deleted
inserted
replaced
419:59143cd42ec7 | 420:e8ddbb0837ed |
---|---|
1 /******************************************************************************* | |
2 | |
3 CONDAT (UK) | |
4 | |
5 ******************************************************************************** | |
6 | |
7 This software product is the property of Condat (UK) Ltd and may not be | |
8 disclosed to any third party without the express permission of the owner. | |
9 | |
10 ******************************************************************************** | |
11 | |
12 $Project name: Basic MMI | |
13 $Project code: BMI (6349) | |
14 $Module: MMI | |
15 $File: AUICalcEditor.c | |
16 $Revision: 1.0 | |
17 | |
18 $Author: Condat(UK) | |
19 $Date: 22/02/01 | |
20 | |
21 ******************************************************************************** | |
22 | |
23 Description: Editor for calculator, or generic floating-point number input | |
24 | |
25 | |
26 | |
27 ******************************************************************************** | |
28 | |
29 $History: AUICalcEditor.c | |
30 | |
31 xrashmic 20 Oct, 2005 MMI-SPR-33845 | |
32 To display BACK softkey when no more character are left in the calculator editor | |
33 | |
34 14/11/02 Original Condat(UK) BMI version. | |
35 $End | |
36 | |
37 *******************************************************************************/ | |
38 | |
39 #define ENTITY_MFW | |
40 | |
41 /* includes */ | |
42 #include <string.h> | |
43 #include <stdio.h> | |
44 #include <stdlib.h> | |
45 | |
46 #if defined (NEW_FRAME) | |
47 | |
48 #include "typedefs.h" | |
49 #include "vsi.h" | |
50 #include "pei.h" | |
51 #include "custom.h" | |
52 #include "gsm.h" | |
53 | |
54 #else | |
55 | |
56 #include "STDDEFS.H" | |
57 #include "custom.h" | |
58 #include "gsm.h" | |
59 #include "vsi.h" | |
60 | |
61 #endif | |
62 | |
63 #include "mfw_mfw.h" | |
64 #include "mfw_win.h" | |
65 #include "mfw_kbd.h" | |
66 #include "mfw_tim.h" | |
67 #include "mfw_phb.h" | |
68 #include "mfw_sms.h" | |
69 #include "mfw_ss.h" | |
70 #include "mfw_icn.h" | |
71 #include "mfw_mnu.h" | |
72 #include "mfw_lng.h" | |
73 #include "mfw_sat.h" | |
74 #include "mfw_kbd.h" | |
75 #include "mfw_nm.h" | |
76 #include "mfw_cm.h" | |
77 | |
78 #include "dspl.h" | |
79 | |
80 #include "ksd.h" | |
81 #include "psa.h" | |
82 | |
83 #include "MmiDummy.h" | |
84 #include "MmiMmi.h" | |
85 | |
86 #include "MmiDialogs.h" | |
87 #include "MmiLists.h" | |
88 #include "MmiMenu.h" | |
89 #include "MmiSoftKeys.h" | |
90 #include "MmiIdle.h" | |
91 #include "MmiResources.h" | |
92 | |
93 #include "cus_aci.h" | |
94 #include "prim.h" | |
95 #ifndef PCM_2_FFS | |
96 #include "pcm.h" | |
97 #endif | |
98 | |
99 #include "mmiColours.h" | |
100 | |
101 #include "ATBCommon.h" | |
102 #include "ATBDisplay.h" | |
103 #include "ATBEditor.h" | |
104 #include "AUIEditor.h" | |
105 #include "AUITextEntry.h" | |
106 | |
107 #include "AUICalcEditor.h" | |
108 | |
109 typedef struct | |
110 { | |
111 T_MMI_CONTROL mmi_control; | |
112 T_MFW_HND parent; // The parent window | |
113 T_MFW_HND win; // The edit window | |
114 T_MFW_HND kbd; // The keyboard handler | |
115 T_MFW_HND kbd_long; // The longpress keyboard handler | |
116 T_MFW_HND timer; // The timer for timeouts | |
117 | |
118 T_ED_DATA *editor; /* The ATB editor */ | |
119 T_AUI_EDITOR_DATA editor_data; /* The MMI editor data, provided by caller */ | |
120 T_AUI_ENTRY_DATA *entry_data; /* The MMI text entry data */ | |
121 | |
122 BOOL haveTitle; /* TRUE if a title is supplied */ | |
123 T_ATB_TEXT title; /* Title of editor */ | |
124 BOOL haveResult; /* TRUE if a result is supplied */ | |
125 T_ATB_TEXT result; /* Text of result */ | |
126 | |
127 BOOL doNextLongPress; /* Flag used to notice/not notice long keypress */ | |
128 BOOL hasDecimalPoint; /* Ensures only one decimal point per number */ | |
129 } | |
130 T_AUI_CALC_DATA; | |
131 | |
132 /* LOCAL FUNCTION PROTOTYPES */ | |
133 static T_MFW_HND AUI_calc_Create(T_MFW_HND parent, T_AUI_EDITOR_DATA *editor_data); | |
134 static void AUI_calc_ExecCb(T_MFW_HND win, USHORT event, SHORT value, void *parameter); | |
135 static int AUI_calc_WinCb(T_MFW_EVENT event, T_MFW_WIN *win_data); | |
136 static int AUI_calc_KbdCb(T_MFW_EVENT event, T_MFW_KBD *keyboard); | |
137 static int AUI_calc_KbdLongCb(T_MFW_EVENT event, T_MFW_KBD *keyboard); | |
138 | |
139 | |
140 | |
141 | |
142 /******************************************************************************* | |
143 | |
144 $Function: AUI_calc_Start | |
145 | |
146 $Description: Start the Calc editor. | |
147 | |
148 $Returns: None. | |
149 | |
150 $Arguments: None. | |
151 | |
152 *******************************************************************************/ | |
153 | |
154 T_MFW_HND AUI_calc_Start(T_MFW_HND parent, T_AUI_EDITOR_DATA *editor_data) | |
155 { | |
156 T_MFW_HND win; | |
157 | |
158 TRACE_FUNCTION ("AUI_calc_Start()"); | |
159 win = AUI_calc_Create(parent, editor_data); | |
160 | |
161 return win; | |
162 } | |
163 | |
164 | |
165 /******************************************************************************* | |
166 | |
167 $Function: AUI_calc_Create | |
168 | |
169 $Description: Create the Calc editor. | |
170 | |
171 $Returns: Pointer to the editor's window. | |
172 | |
173 $Arguments: parent - The parent window. | |
174 | |
175 *******************************************************************************/ | |
176 | |
177 static T_MFW_HND AUI_calc_Create(T_MFW_HND parent, T_AUI_EDITOR_DATA *editor_data) | |
178 { | |
179 T_AUI_CALC_DATA *data = (T_AUI_CALC_DATA *)ALLOC_MEMORY(sizeof (T_AUI_CALC_DATA)); | |
180 T_MFW_WIN *win_data; | |
181 | |
182 TRACE_FUNCTION ("AUI_calc_Create()"); | |
183 | |
184 /* Create window handler */ | |
185 | |
186 data->win = win_create(parent, 0, E_WIN_VISIBLE, (T_MFW_CB)AUI_calc_WinCb); // Create window | |
187 | |
188 if (data->win==NULL) // Make sure window exists | |
189 { | |
190 return NULL; | |
191 } | |
192 | |
193 /* Connect the dialog data to the MFW-window */ | |
194 | |
195 data->mmi_control.dialog = (T_DIALOG_FUNC)AUI_calc_ExecCb; /* Setup the destination for events */ | |
196 data->mmi_control.data = data; | |
197 data->parent = parent; | |
198 win_data = ((T_MFW_HDR *)data->win)->data; | |
199 win_data->user = (void *)data; | |
200 | |
201 data->kbd = kbd_create(data->win, KEY_ALL,(T_MFW_CB)AUI_calc_KbdCb); | |
202 data->kbd_long = kbd_create(data->win, KEY_ALL|KEY_LONG,(T_MFW_CB)AUI_calc_KbdLongCb); | |
203 data->editor = ATB_edit_Create(&data->editor_data.editor_attr,0); | |
204 | |
205 data->editor_data = *editor_data; | |
206 data->entry_data = AUI_entry_Create(data->win, data->editor, E_CALC_UPDATE); | |
207 | |
208 SEND_EVENT(data->win, E_CALC_INIT, 0, 0); | |
209 | |
210 /* Return window handle */ | |
211 | |
212 return data->win; | |
213 } | |
214 | |
215 | |
216 /******************************************************************************* | |
217 | |
218 $Function: AUI_calc_Destroy | |
219 | |
220 $Description: Destroy the Calc editor. | |
221 | |
222 $Returns: None. | |
223 | |
224 $Arguments: window - The editor window. | |
225 | |
226 *******************************************************************************/ | |
227 | |
228 void AUI_calc_Destroy(T_MFW_HND win) | |
229 { | |
230 T_MFW_WIN *win_data = ((T_MFW_HDR *)win)->data; | |
231 T_AUI_CALC_DATA *data = (T_AUI_CALC_DATA *)win_data->user; | |
232 | |
233 if (data) | |
234 { | |
235 AUI_entry_Destroy(data->entry_data); | |
236 | |
237 win_delete (data->win); | |
238 | |
239 /* Free memory allocated to store result */ | |
240 | |
241 if (data->haveResult) | |
242 { | |
243 FREE_MEMORY(data->result.data, data->result.len*sizeof(char)); | |
244 } | |
245 | |
246 /* Free editor memory */ | |
247 | |
248 ATB_edit_Destroy(data->editor); | |
249 FREE_MEMORY ((void *)data, sizeof (T_AUI_CALC_DATA)); | |
250 } | |
251 | |
252 return; | |
253 } | |
254 | |
255 | |
256 /******************************************************************************* | |
257 | |
258 $Function: AUI_calc_ExecCb | |
259 | |
260 $Description: Dialog function for Calc editor. | |
261 | |
262 $Returns: None. | |
263 | |
264 $Arguments: None. | |
265 | |
266 *******************************************************************************/ | |
267 | |
268 static void AUI_calc_ExecCb(T_MFW_HND win, USHORT event, SHORT value, void *parameter) | |
269 { | |
270 T_MFW_WIN *win_data = ((T_MFW_HDR *)win)->data; | |
271 T_AUI_CALC_DATA *data = (T_AUI_CALC_DATA *)win_data->user; | |
272 T_MFW_HND parent_win = data->parent; | |
273 USHORT textIndex; | |
274 T_ATB_TEXT text; | |
275 /* Store these in case editor is destroyed on callback */ | |
276 USHORT Identifier = data->editor_data.Identifier; | |
277 T_AUI_EDIT_CB Callback = data->editor_data.Callback; | |
278 UBYTE destroyEditor = data->editor_data.destroyEditor; | |
279 | |
280 TRACE_FUNCTION ("AUI_calc_ExecCb()"); | |
281 | |
282 switch (event) | |
283 { | |
284 /* Initialise */ | |
285 | |
286 case E_CALC_INIT: | |
287 TRACE_EVENT("E_CALC_INIT"); | |
288 ATB_edit_Init(data->editor); | |
289 | |
290 data->haveTitle = FALSE; | |
291 data->haveResult = FALSE; | |
292 | |
293 /* If we require an output line, shrink editor to fit it at bottom | |
294 * NB TitleString is assumed here to be a numeric string of ascii digits */ | |
295 | |
296 if (data->editor_data.TitleString) | |
297 { | |
298 data->haveResult = TRUE; | |
299 text.dcs = ATB_DCS_ASCII; | |
300 text.data = data->editor_data.TitleString; | |
301 text.len = ATB_string_Length(&text); | |
302 | |
303 data->result.data = ALLOC_MEMORY(text.len*sizeof(char)); | |
304 ATB_string_Copy(&data->result, &text); | |
305 | |
306 /* Change size of editor to fit result line in */ | |
307 data->editor_data.editor_attr.win_size.sy -= ATB_display_StringHeight(&data->result, NULL); | |
308 } | |
309 | |
310 /* Set up title */ | |
311 | |
312 if (data->editor_data.TitleId!=NULL) | |
313 { | |
314 data->haveTitle = TRUE; | |
315 data->title.data = (UBYTE *)MmiRsrcGetText(data->editor_data.TitleId); | |
316 } | |
317 | |
318 /* If title exists, get its dcs and length */ | |
319 | |
320 if (data->haveTitle) | |
321 { | |
322 if (data->title.data[0]==0x80) | |
323 { | |
324 data->title.data += 2; /* Skip over two unicode indicator bytes */ | |
325 data->title.dcs = ATB_DCS_UNICODE; | |
326 } | |
327 #ifdef EASY_TEXT_ENABLED | |
328 else if (Mmi_getCurrentLanguage() == CHINESE_LANGUAGE) | |
329 { | |
330 data->title.dcs = ATB_DCS_UNICODE; | |
331 } | |
332 #endif | |
333 else | |
334 { | |
335 data->title.dcs = ATB_DCS_ASCII; | |
336 } | |
337 | |
338 data->title.len = ATB_string_Length(&data->title); | |
339 } | |
340 | |
341 /* Check to see if number already has decimal point */ | |
342 | |
343 data->hasDecimalPoint = FALSE; | |
344 | |
345 for (textIndex = 0; textIndex<data->editor->attr->text.len; textIndex++) | |
346 { | |
347 if (ATB_string_GetChar(&data->editor->attr->text, textIndex)==UNICODE_FULLSTOP) | |
348 { | |
349 data->hasDecimalPoint = TRUE; | |
350 } | |
351 } | |
352 | |
353 /* Show the window */ | |
354 win_show(data->win); | |
355 break; | |
356 | |
357 case E_CALC_UPDATE: | |
358 TRACE_EVENT("E_CALC_UPDATE"); | |
359 win_show(data->win); | |
360 break; | |
361 | |
362 case E_CALC_DEINIT: | |
363 TRACE_EVENT("E_CALC_DEINIT"); | |
364 | |
365 if (Callback) | |
366 (Callback) (parent_win, Identifier, value); | |
367 | |
368 if (destroyEditor) | |
369 AUI_calc_Destroy(data->win); | |
370 | |
371 break; | |
372 | |
373 } | |
374 | |
375 return; | |
376 } | |
377 | |
378 /******************************************************************************* | |
379 | |
380 $Function: AUI_calc_WinCb | |
381 | |
382 $Description: Calc editor window event handler. | |
383 | |
384 $Returns: None. | |
385 | |
386 $Arguments: event - the event | |
387 win - the editor window | |
388 | |
389 *******************************************************************************/ | |
390 | |
391 static int AUI_calc_WinCb(T_MFW_EVENT event, T_MFW_WIN *win_data) | |
392 { | |
393 T_AUI_CALC_DATA *data = (T_AUI_CALC_DATA *)win_data->user; | |
394 T_ED_DATA *editor = data->editor; | |
395 T_ATB_WIN_SIZE *win_size = &data->editor->attr->win_size; | |
396 T_DS_TEXTFORMAT format; | |
397 // USHORT titleLen; // RAVI | |
398 | |
399 TRACE_EVENT("AUI_calc_WinCb"); | |
400 | |
401 if (!data) | |
402 return MFW_EVENT_CONSUMED; | |
403 | |
404 switch(event) | |
405 { | |
406 case E_WIN_VISIBLE: /* window is visible */ | |
407 if (win_data->flags & E_WIN_VISIBLE) | |
408 { | |
409 if (editor->update==ED_UPDATE_TRIVIAL) | |
410 { | |
411 TRACE_EVENT("Only updating editor."); | |
412 ATB_edit_Show(data->editor); | |
413 } | |
414 else | |
415 { | |
416 TRACE_EVENT("Updating whole screen."); | |
417 | |
418 ATB_edit_Show(data->editor); | |
419 | |
420 /* Set the colour for drawing title */ | |
421 | |
422 resources_setTitleColour(COLOUR_EDITOR); | |
423 | |
424 /* TITLE */ | |
425 | |
426 dspl_Clear(0,0, SCREEN_SIZE_X-1, win_size->py-1); | |
427 | |
428 if (data->haveTitle) | |
429 { | |
430 ATB_display_SetFormatAttr(&format, 0, FALSE); | |
431 ATB_display_Text(0,0,&format, &data->title); | |
432 } | |
433 | |
434 /* RESULT */ | |
435 | |
436 if (data->haveResult) | |
437 { | |
438 resources_setHLColour(COLOUR_EDITOR); | |
439 ATB_display_SetFormatAttr(&format, 0, FALSE); | |
440 dspl_Clear( win_size->px, win_size->py+win_size->sy, win_size->px+win_size->sx, | |
441 win_size->py+win_size->sy+ATB_display_StringHeight(&data->result, &format)); | |
442 | |
443 ATB_display_Text(win_size->px+win_size->sx-ATB_display_StringWidth(&data->result, &format), | |
444 win_size->py+win_size->sy,&format, &data->result); | |
445 } | |
446 | |
447 /* Display Soft Keys */ | |
448 //xrashmic 20 Oct, 2005 MMI-SPR-33845 | |
449 //Need to display the alternate right softkey when the editor is does not contain any character other than 0. | |
450 if (data->editor_data.editor_attr.text.len == data->editor_data.min_enter && (data->editor_data.editor_attr.text.data[0] == '0')) | |
451 { | |
452 /* entered less than the required number of chars: Alternate Softkey appears */ | |
453 displaySoftKeys(data->editor_data.LeftSoftKey,data->editor_data.AltRightSoftKey); | |
454 } | |
455 else | |
456 { | |
457 /* entered sufficient number of chars: Normal Softkey appears */ | |
458 displaySoftKeys(data->editor_data.LeftSoftKey, data->editor_data.RightSoftKey); | |
459 } | |
460 } | |
461 } | |
462 break; | |
463 } | |
464 | |
465 data->editor->update = ED_UPDATE_DEFAULT; | |
466 | |
467 return MFW_EVENT_CONSUMED; | |
468 } | |
469 | |
470 | |
471 /******************************************************************************* | |
472 | |
473 $Function: AUI_calc_KbdCb | |
474 | |
475 $Description: Calc editor keyboard event handler | |
476 | |
477 $Returns: None. | |
478 | |
479 $Arguments: event - The keyboard event | |
480 keyboard - The keypress info | |
481 | |
482 *******************************************************************************/ | |
483 | |
484 static int AUI_calc_KbdCb(T_MFW_EVENT event, T_MFW_KBD *keyboard) | |
485 { | |
486 T_MFW_HND win = mfw_parent (mfw_header()); | |
487 T_MFW_WIN *win_data = ((T_MFW_HDR *)win)->data; | |
488 T_AUI_CALC_DATA *data = (T_AUI_CALC_DATA *)win_data->user; | |
489 ED_RES result; | |
490 | |
491 TRACE_FUNCTION("AUI_calc_KbdCb()"); | |
492 | |
493 /* Suppress unwanted long keypresses */ | |
494 | |
495 data->doNextLongPress = TRUE; /* next Key_long event is correct */ | |
496 data->editor->update = ED_UPDATE_DEFAULT; /* Default behaviour is just to update text */ | |
497 | |
498 switch (keyboard->code) | |
499 { | |
500 #ifdef COLOURDISPLAY | |
501 case KCD_MNUSELECT: | |
502 if (data->editor_data.Callback) | |
503 (data->editor_data.Callback) (data->parent, data->editor_data.Identifier, INFO_KCD_SELECT); | |
504 break; | |
505 | |
506 #endif /* COLOURDISPLAY */ | |
507 | |
508 case KCD_STAR: | |
509 if (data->editor_data.Callback) | |
510 (data->editor_data.Callback) (data->parent, data->editor_data.Identifier, INFO_KCD_STAR); | |
511 break; | |
512 | |
513 case KCD_HASH: | |
514 /* Insert decimal point, if the number doesn't have one already */ | |
515 if (!data->hasDecimalPoint) | |
516 { | |
517 data->hasDecimalPoint = TRUE; | |
518 AUI_entry_EditChar(data->entry_data, UNICODE_FULLSTOP, FALSE); | |
519 win_show(data->win); | |
520 } | |
521 break; | |
522 | |
523 case KCD_LEFT: | |
524 if (data->editor_data.editor_attr.text.len < data->editor_data.min_enter) | |
525 { | |
526 /* Entered less than the required number of chars */ | |
527 if (data->editor_data.AltLeftSoftKey!=TxtNull) | |
528 { | |
529 /* an alternate softkey is defined: execute it */ | |
530 SEND_EVENT (win, E_CALC_DEINIT, INFO_KCD_ALTERNATELEFT, NULL); | |
531 } | |
532 } | |
533 else if (data->editor_data.LeftSoftKey!=TxtNull) | |
534 { | |
535 /* Left Softkey is enabled (and entered sufficient number of chars): execute it */ | |
536 SEND_EVENT (win, E_CALC_DEINIT, INFO_KCD_LEFT, NULL); | |
537 } | |
538 break; | |
539 | |
540 case KCD_HUP: | |
541 SEND_EVENT(data->win, E_CALC_DEINIT, INFO_KCD_HUP, 0); | |
542 break; | |
543 | |
544 case KCD_RIGHT: | |
545 /* If we're deleting the decimal point... */ | |
546 if (ATB_edit_GetCursorChar(data->editor, -1)==UNICODE_FULLSTOP) | |
547 { | |
548 data->hasDecimalPoint = FALSE; | |
549 } | |
550 | |
551 /* If we've just got a zero, delete it so we can exit with next call to ATB_edit_DeleteLeft() */ | |
552 | |
553 if (ATB_edit_GetCursorChar(data->editor, -1)==ATB_char_Unicode('0')) | |
554 { | |
555 ATB_edit_DeleteLeft(data->editor, FALSE); /* SPR#2342 - SH */ | |
556 } | |
557 | |
558 /* Perform normal delete */ | |
559 result = ATB_edit_DeleteLeft(data->editor, TRUE); /* SPR#2342 - SH */ | |
560 | |
561 /* If buffer is now empty, insert '0' */ | |
562 if (data->editor->attr->text.len==0 && result!=ED_DONE) | |
563 { | |
564 AUI_entry_EditChar(data->entry_data, ATB_char_Unicode('0'), FALSE); | |
565 } | |
566 | |
567 /* If we've deleted on an empty buffer, exit editor */ | |
568 if (result==ED_DONE) | |
569 { | |
570 SEND_EVENT(data->win, E_CALC_DEINIT, INFO_KCD_RIGHT, 0); | |
571 } | |
572 else | |
573 { | |
574 win_show(data->win); | |
575 } | |
576 break; | |
577 | |
578 /* 0 - 9 */ | |
579 | |
580 case KCD_0: | |
581 case KCD_1: | |
582 case KCD_2: | |
583 case KCD_3: | |
584 case KCD_4: | |
585 case KCD_5: | |
586 case KCD_6: | |
587 case KCD_7: | |
588 case KCD_8: | |
589 case KCD_9: | |
590 /* Remove leading zero */ | |
591 if (data->editor->attr->text.len==1 && ATB_edit_GetCursorChar(data->editor, -1)==ATB_char_Unicode('0')) | |
592 { | |
593 ATB_edit_DeleteLeft(data->editor, FALSE); /* SPR#2342 - SH */ | |
594 } | |
595 | |
596 /* Insert the digit */ | |
597 AUI_entry_EventKey(data->entry_data, event, keyboard); | |
598 win_show(data->win); | |
599 break; | |
600 } | |
601 | |
602 return MFW_EVENT_CONSUMED; | |
603 } | |
604 | |
605 | |
606 /******************************************************************************* | |
607 | |
608 $Function: AUI_calc_KbdLongCb | |
609 | |
610 $Description: Calc editor long keypress event handler | |
611 | |
612 $Returns: None. | |
613 | |
614 $Arguments: event - The keyboard event | |
615 keyboard - The keypress info | |
616 | |
617 *******************************************************************************/ | |
618 | |
619 static int AUI_calc_KbdLongCb(T_MFW_EVENT event, T_MFW_KBD *keyboard) | |
620 { | |
621 T_MFW_HND win = mfw_parent (mfw_header()); | |
622 T_MFW_WIN *win_data = ((T_MFW_HDR *)win)->data; | |
623 T_AUI_CALC_DATA *data = (T_AUI_CALC_DATA *)win_data->user; | |
624 ED_RES result; | |
625 | |
626 /* Suppress unwanted long keypresses */ | |
627 | |
628 if ( data->doNextLongPress ) | |
629 data->doNextLongPress = FALSE; /* mark Key_long event as consumed but do current long press */ | |
630 else | |
631 return MFW_EVENT_CONSUMED; /* don't do current long press */ | |
632 | |
633 switch (keyboard->code) | |
634 { | |
635 case KCD_RIGHT: | |
636 /* Long press of RSK deletes buffer */ | |
637 result = ATB_edit_ClearAll(data->editor); | |
638 | |
639 /* If buffer is now empty, insert '0' */ | |
640 if (data->editor->attr->text.len==0 && result!=ED_DONE) | |
641 { | |
642 AUI_entry_EditChar(data->entry_data, ATB_char_Unicode('0'), FALSE); | |
643 } | |
644 | |
645 /* If we've deleted on an empty buffer, exit editor */ | |
646 if (result==ED_DONE) | |
647 { | |
648 SEND_EVENT(data->win, E_CALC_DEINIT, INFO_KCD_RIGHT, 0); | |
649 } | |
650 else | |
651 { | |
652 win_show(data->win); | |
653 } | |
654 break; | |
655 } | |
656 | |
657 return MFW_EVENT_CONSUMED; | |
658 } |