FreeCalypso > hg > fc-magnetite
comparison src/ui3/atb/ATBEditor.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: | |
13 $Project code: | |
14 $Module: | |
15 $File: ATBEditor.c | |
16 $Revision: | |
17 | |
18 $Author: SH - Condat(UK) | |
19 $Date: | |
20 | |
21 ******************************************************************************** | |
22 | |
23 Description: ATB Editor component. | |
24 | |
25 | |
26 ******************************************************************************** | |
27 | |
28 $History: ATBEditor.c | |
29 | |
30 Mar 31, 2008 DR:OMAPS00164541 - x0082844 | |
31 Description: OTA ATT - GSM-BTR-1-5618 - MS wrongly displays long number stored in ADN | |
32 Solution:No need to check for the current chararcter, if its a space. | |
33 | |
34 Feb 02, 2006 DR: OMAPS00061468 - x0035544. | |
35 Description: SAT 27.22.4.22.2 SET UP IDLE MODE TEXT (Icon support) fails | |
36 Solution : Modifications for displaying idle mode text and icon are done in | |
37 ATB_edit_OutTextLines. | |
38 | |
39 Jan 16, 2006 DR: OMAPS00061460 - Shashi Shekar B.S. | |
40 Description: SAT Icon support | |
41 Solution : Modifications done in ATB_edit_OutTextLines | |
42 for display of the title icon. | |
43 | |
44 CRR:25542 - xpradipg - 26 Oct 2004 | |
45 Description: The last character is not deleted from the text entry screen in | |
46 any WAP page. | |
47 Solution: The formatIndex was set to zero on reaching the last character which | |
48 skips the removal of the last character. This assignment is moved out. | |
49 | |
50 Jul 22,2004 CRR:21605 xrashmic - SASKEN | |
51 Description: After deleting all the characters in the editor the case does not change to | |
52 sentence case. | |
53 Fix: After deleting a character, check if editor is empty and then set the case to | |
54 sentence case only if the user has not modified the case. | |
55 | |
56 | |
57 $End | |
58 | |
59 *******************************************************************************/ | |
60 | |
61 #ifndef ATB_EDITOR_C | |
62 #define ATB_EDITOR_C | |
63 #if defined (NEW_FRAME) | |
64 | |
65 #include "typedefs.h" | |
66 #include "vsi.h" | |
67 #include "pei.h" | |
68 #include "custom.h" | |
69 #include "gsm.h" | |
70 | |
71 #else | |
72 | |
73 #include "STDDEFS.H" | |
74 #include "custom.h" | |
75 #include "gsm.h" | |
76 #include "vsi.h" | |
77 | |
78 #endif | |
79 | |
80 #include <stdio.h> | |
81 #include <string.h> | |
82 #include <math.h> | |
83 | |
84 #include "dspl.h" | |
85 #include "ATBCommon.h" | |
86 #include "ATBDisplay.h" | |
87 #include "ATBEditor.h" | |
88 #include "font_bitmaps.h" | |
89 | |
90 #include "cus_aci.h" | |
91 #include "prim.h" | |
92 #include "pcm.h" | |
93 | |
94 #undef TRACE_ATBEDITOR | |
95 | |
96 extern UBYTE CaseChanged; // SPR 21605 | |
97 | |
98 // Shashi Shekar B.S., a0876501, Jan 16, 2006, DR: OMAPS00061460 | |
99 #ifdef FF_MMI_SAT_ICON | |
100 const unsigned char SATIconQuestionMark[] = | |
101 { | |
102 0x25,0x25,0x00,0x00,0x00,0x00,0x25,0x25, | |
103 0x25,0x00,0xE0,0xE0,0xE0,0xE0,0x00,0x25, | |
104 0x00,0xE0,0xE0,0xFF,0xFF,0xE0,0xE0,0x00, | |
105 0x00,0xE0,0xFF,0xE0,0xE0,0xFF,0xE0,0x00, | |
106 0x00,0xE0,0xE0,0xE0,0xE0,0xFF,0xE0,0x00, | |
107 0x00,0xE0,0xE0,0xFF,0xFF,0xE0,0xE0,0x00, | |
108 0x00,0xE0,0xE0,0xFF,0xE0,0xE0,0xE0,0x00, | |
109 0x00,0xE0,0xE0,0xFF,0xE0,0xE0,0xE0,0x00, | |
110 0x25,0x00,0xE0,0xE0,0xE0,0xE0,0x00,0x25, | |
111 0x25,0x25,0x00,0x00,0x00,0x00,0x25,0x25, | |
112 }; | |
113 #endif | |
114 | |
115 | |
116 /******************************************************************************* | |
117 | |
118 LOCAL FUNCTION PROTOTYPES | |
119 | |
120 *******************************************************************************/ | |
121 | |
122 /* SPR#1983 - SH - Add 'text' parameter */ | |
123 static int ATB_edit_Insert (T_ED_DATA *editor, T_ATB_TEXT *text, USHORT character); | |
124 static void ATB_edit_FindNext(T_ED_DATA *editor); | |
125 static USHORT ATB_edit_FindPrev(T_ED_DATA *editor); | |
126 static void ATB_edit_OutTextLines (T_ED_DATA *editor); | |
127 static void ATB_edit_WordWrap(T_ED_DATA *editor); | |
128 static void ATB_edit_UpdateCursorPos(T_ED_DATA *editor); | |
129 static ED_RES ATB_edit_Update (T_ED_DATA *editor, int dy); | |
130 static void ATB_edit_LineDestroyAll(T_ED_DATA *editor); | |
131 | |
132 | |
133 /******************************************************************************* | |
134 | |
135 $Function: ATB_edit_Create | |
136 | |
137 $Description: Create the editor. Allocate memory for the editor data and set up | |
138 some default parameters. | |
139 | |
140 $Returns: Pointer to the editor data, or NULL if memory allocation failed. | |
141 | |
142 $Arguments: editAttr - The editor attributes (caller allocated) | |
143 callback - Callback function | |
144 | |
145 *******************************************************************************/ | |
146 | |
147 T_ED_DATA* ATB_edit_Create (T_ED_ATTR *editAttr, T_ED_CB callback) | |
148 { | |
149 T_ED_DATA *editor; | |
150 | |
151 TRACE_FUNCTION("ATB_edit_Create()"); | |
152 | |
153 /* Allocate memory for editor data */ | |
154 | |
155 editor = (T_ED_DATA *) ATB_mem_Alloc(sizeof(T_ED_DATA)); | |
156 | |
157 if (!editor) | |
158 return NULL; | |
159 | |
160 /* Reset editor data */ | |
161 | |
162 memset(editor, 0, sizeof(T_ED_DATA)); | |
163 editor->display = FALSE; | |
164 editor->handler = callback; | |
165 editor->attr = editAttr; | |
166 editor->cursor.width = 8; | |
167 editor->initialised = FALSE; | |
168 editor->line = NULL; | |
169 | |
170 return editor; | |
171 } | |
172 | |
173 | |
174 /******************************************************************************* | |
175 | |
176 $Function: ATB_edit_Destroy | |
177 | |
178 $Description: Delete the editor. Free the allocated memory. | |
179 | |
180 $Returns: ED_OK - OK | |
181 ED_BAD_HANDLE - Editor data is null pointer | |
182 | |
183 $Arguments: editor - The editor data | |
184 | |
185 *******************************************************************************/ | |
186 | |
187 ED_RES ATB_edit_Destroy (T_ED_DATA *editor) | |
188 { | |
189 ED_RES result = ED_OK; | |
190 | |
191 TRACE_FUNCTION("ATB_edit_Destroy()"); | |
192 | |
193 if (editor) | |
194 { | |
195 ATB_edit_LineDestroyAll(editor); | |
196 | |
197 if (editor->hiddenText) | |
198 { | |
199 ATB_edit_HiddenExit(editor); | |
200 } | |
201 | |
202 ATB_mem_Free((void *)editor, sizeof(T_ED_DATA)); | |
203 } | |
204 else | |
205 result = ED_BAD_HANDLE; | |
206 | |
207 return result; | |
208 } | |
209 | |
210 | |
211 /******************************************************************************* | |
212 | |
213 $Function: ATB_edit_Init | |
214 | |
215 $Description: Initialise the editor. Ensures that valid combinations of editing modes | |
216 are set. Sets uppercase/lowercase appropriately. Moves the cursor | |
217 to the correct place in the text. Performs a word-wrap. | |
218 | |
219 $Returns: ED_OK - OK | |
220 | |
221 $Arguments: editor - The editor data | |
222 | |
223 *******************************************************************************/ | |
224 | |
225 ED_RES ATB_edit_Init (T_ED_DATA *editor) | |
226 { | |
227 TRACE_FUNCTION("ATB_edit_Init()"); | |
228 | |
229 | |
230 if (!editor) /* If editor handle doesn't exist, return error */ | |
231 return ED_BAD_HANDLE; | |
232 | |
233 /* Get the length of the supplied string */ | |
234 | |
235 ATB_string_Length(&editor->attr->text); | |
236 | |
237 /* SPR#1983 - SH - Set CAPS preference after moving cursor, | |
238 * as any cursor moves now reset CAPS to LOWER case. */ | |
239 | |
240 ATB_edit_SetCase(editor, ED_CASE_LOWER); | |
241 | |
242 /* Non read-only modes*/ | |
243 | |
244 if (!ATB_edit_Mode(editor, ED_MODE_READONLY)) | |
245 { | |
246 /* Initialise hidden mode */ | |
247 | |
248 if (ATB_edit_Mode(editor, ED_MODE_HIDDEN)) | |
249 { | |
250 ATB_edit_HiddenInit(editor); | |
251 ATB_edit_SetMode(editor, ED_MODE_OVERWRITE); | |
252 } | |
253 | |
254 /* Initialise formatted mode */ | |
255 | |
256 if (ATB_edit_Mode(editor, ED_MODE_FORMATTED)) | |
257 { | |
258 ATB_edit_SetMode(editor, ED_MODE_OVERWRITE | ED_MODE_ALPHA); | |
259 ATB_edit_MoveCursor(editor,ctrlTop,FALSE); /* Send cursor to start of string */ | |
260 | |
261 /* Check for "M" & "m" formats; these set the case to upper/lower by default. */ | |
262 /* SPR#1983 - SH - Also, overwrite mode can be switched off for these | |
263 * cases, free entry allowed.*/ | |
264 | |
265 ATB_edit_SetCase(editor, ED_CASE_CAPS); /* Caps is on by default */ | |
266 | |
267 if (strcmp(editor->attr->FormatString, "*M")==0) | |
268 { | |
269 ATB_edit_SetCase(editor, ED_CASE_UPPER); | |
270 ATB_edit_ResetMode(editor, ED_MODE_OVERWRITE); | |
271 } | |
272 | |
273 if (strcmp(editor->attr->FormatString, "*m")==0) | |
274 { | |
275 ATB_edit_SetCase(editor, ED_CASE_LOWER); | |
276 ATB_edit_ResetMode(editor, ED_MODE_OVERWRITE); | |
277 } | |
278 | |
279 } | |
280 /* Of the cursor modes, only formatted starts at the top, others start at the bottom */ | |
281 else | |
282 { | |
283 ATB_edit_MoveCursor(editor, ctrlBottom, FALSE); | |
284 | |
285 /* SPR#1983 - SH - If the buffer is empty, first character will be capitalised. | |
286 * Otherwise, lowercase is the default. */ | |
287 | |
288 if (editor->attr->text.len==0) | |
289 { | |
290 ATB_edit_SetCase(editor, ED_CASE_CAPS); /* Caps is on if first character */ | |
291 } | |
292 } | |
293 } | |
294 | |
295 /* No cursor modes */ | |
296 else | |
297 { | |
298 ATB_edit_MoveCursor(editor, ctrlTop, FALSE); | |
299 } | |
300 | |
301 /* Format text */ | |
302 | |
303 ATB_edit_Update(editor, 0); | |
304 | |
305 /* Make editor visible */ | |
306 | |
307 editor->display = TRUE; /* really show it */ | |
308 | |
309 return ED_OK; | |
310 } | |
311 | |
312 | |
313 /******************************************************************************* | |
314 | |
315 $Function: ATB_edit_Reset | |
316 | |
317 $Description: Reset the editor - move the cursor to the start. | |
318 | |
319 $Returns: ED_BAD_HANDLE - Editor data pointer is null | |
320 ED_OK - OK | |
321 | |
322 $Arguments: editor - The editor data | |
323 | |
324 *******************************************************************************/ | |
325 | |
326 ED_RES ATB_edit_Reset (T_ED_DATA *editor) | |
327 { | |
328 | |
329 TRACE_FUNCTION("ATB_edit_Reset()"); | |
330 | |
331 if (!editor) | |
332 return ED_BAD_HANDLE; /* Editor does not exist */ | |
333 | |
334 editor->cursor.pos = 0; /* Reset cursor position */ | |
335 editor->initialised = FALSE; /* Fully wrap all of text */ | |
336 ATB_edit_Refresh(editor); /* Refresh word wrap */ | |
337 return ED_OK; | |
338 } | |
339 | |
340 | |
341 /******************************************************************************* | |
342 | |
343 $Function: ATB_edit_Show | |
344 | |
345 $Description: Show the editor, if it is visible. | |
346 | |
347 $Returns: ED_OK - OK | |
348 | |
349 $Arguments: editor - The editor data | |
350 | |
351 *******************************************************************************/ | |
352 | |
353 ED_RES ATB_edit_Show (T_ED_DATA *editor) | |
354 { | |
355 /* x0045876, 14-Aug-2006 (WR - integer conversion resulted in a change of sign) */ | |
356 UBYTE previousFont = (UBYTE) -1; // store previous font | |
357 USHORT editX = editor->attr->win_size.px; // pos. of left of edit window | |
358 USHORT editY = editor->attr->win_size.py; // pos. of top of edit window | |
359 USHORT editWidth = editor->attr->win_size.sx; // width of edit window | |
360 USHORT editHeight = editor->attr->win_size.sy; // height of edit window | |
361 | |
362 TRACE_FUNCTION("ATB_edit_Show()"); | |
363 | |
364 if (!editor) | |
365 return ED_BAD_HANDLE; // Editor doesn't exist | |
366 | |
367 if (editor->display) | |
368 { | |
369 resources_setColour(editor->attr->colour); | |
370 | |
371 if (editor->attr->font != (UBYTE) -1) | |
372 previousFont = dspl_SelectFontbyID(editor->attr->font); // setup font | |
373 | |
374 dspl_Clear(editX,editY,editX+editWidth-1,editY+editHeight-1); // Clear the editor window | |
375 | |
376 ATB_edit_OutTextLines(editor); // Show text | |
377 | |
378 /* Display cursor, if it's switched on and we're not in multitap */ | |
379 | |
380 if (editor->attr->cursor!=ED_CURSOR_NONE && !editor->multitap) | |
381 { | |
382 ATB_display_Cursor(&editor->attr->text, editor->cursor.pos, editor->attr->cursor, editX+editor->cursor.x,editY+editor->cursor.y, | |
383 editor->cursor.width,editor->cursor.height); | |
384 } | |
385 } | |
386 | |
387 if (previousFont != (UBYTE) -1) | |
388 dspl_SelectFontbyID(previousFont); // Restore previous font | |
389 | |
390 return ED_OK; | |
391 } | |
392 | |
393 | |
394 /******************************************************************************* | |
395 | |
396 $Function: ATB_edit_Refresh | |
397 | |
398 $Description: Refresh the editor word wrap etc. | |
399 | |
400 $Returns: ED_OK - OK | |
401 | |
402 $Arguments: editor - The editor data | |
403 | |
404 *******************************************************************************/ | |
405 | |
406 ED_RES ATB_edit_Refresh (T_ED_DATA *editor) | |
407 { | |
408 TRACE_FUNCTION("ATB_edit_Refresh()"); | |
409 | |
410 if (!editor) | |
411 return ED_BAD_HANDLE; /* editor does not exist */ | |
412 | |
413 /* Get the length of the supplied string */ | |
414 | |
415 ATB_string_Length(&editor->attr->text); | |
416 | |
417 /* Update word wrap */ | |
418 | |
419 ATB_edit_Update(editor, 0); | |
420 | |
421 return ED_OK; | |
422 } | |
423 | |
424 | |
425 /******************************************************************************* | |
426 | |
427 $Function: ATB_edit_Hide | |
428 | |
429 $Description: Hide the editor | |
430 | |
431 $Returns: ED_BAD_HANDLE - Editor data pointer is null | |
432 ED_OK - OK | |
433 | |
434 $Arguments: editor - The editor data | |
435 | |
436 *******************************************************************************/ | |
437 | |
438 ED_RES ATB_edit_Hide (T_ED_DATA *editor) | |
439 { | |
440 TRACE_FUNCTION("ATB_edit_Hide()"); | |
441 | |
442 if (!editor) | |
443 return ED_BAD_HANDLE; /* element does not exist */ | |
444 | |
445 editor->display = FALSE; /* editor is not visible */ | |
446 | |
447 if (editor->handler) /* call event handler */ | |
448 { | |
449 (void)(editor->handler(ED_INVISIBLE,editor));/*a0393213 lint warnings removal - void cast is done to avoid lint warning though the function returns int*/ | |
450 } | |
451 return ED_OK; | |
452 } | |
453 | |
454 | |
455 /******************************************************************************* | |
456 | |
457 $Function: ATB_edit_Unhide | |
458 | |
459 $Description: Unhide the editor | |
460 | |
461 $Returns: ED_BAD_HANDLE - Editor data pointer is null | |
462 ED_OK - OK | |
463 | |
464 $Arguments: editor - The editor data | |
465 | |
466 *******************************************************************************/ | |
467 | |
468 ED_RES ATB_edit_Unhide (T_ED_DATA *editor) | |
469 { | |
470 TRACE_FUNCTION("ATB_edit_Unhide()"); | |
471 | |
472 if (!editor) | |
473 return ED_BAD_HANDLE; /* element does not exist */ | |
474 | |
475 editor->display = TRUE; | |
476 | |
477 if (editor->handler) /* call event handler */ | |
478 { | |
479 (void)(editor->handler(ED_VISIBLE,editor));/*a0393213 lint warnings removal - void cast is done to avoid lint warning though the function returns int*/ | |
480 } | |
481 return ED_OK; | |
482 } | |
483 | |
484 | |
485 /******************************************************************************* | |
486 | |
487 $Function: ATB_edit_MoveCursor | |
488 | |
489 $Description: Move the cursor | |
490 | |
491 $Returns: ED_ERROR - Unexpected cursor movement | |
492 ED_OK - OK | |
493 | |
494 $Arguments: editor - The editor data | |
495 character - The control character (ctrlLeft etc) | |
496 update - TRUE if word wrap is to be carried out after move | |
497 | |
498 *******************************************************************************/ | |
499 | |
500 ED_RES ATB_edit_MoveCursor (T_ED_DATA *editor, USHORT control, UBYTE update) | |
501 { | |
502 USHORT altCursorPos; | |
503 SHORT dy; | |
504 | |
505 TRACE_FUNCTION("ATB_edit_MoveCursor"); | |
506 | |
507 if (!editor) | |
508 return ED_BAD_HANDLE; /* element does not exist */ | |
509 | |
510 /* Can't move cursor in hidden mode, except to start and end */ | |
511 | |
512 dy = 0; | |
513 | |
514 switch(control) | |
515 { | |
516 case ctrlLeft: | |
517 if (!ATB_edit_Mode(editor, ED_MODE_READONLY)) /* Not in read only mode*/ | |
518 { | |
519 if (ATB_edit_Mode(editor, ED_MODE_FORMATTED)) /* formatted input */ | |
520 { | |
521 ATB_edit_FindPrev(editor); /* find previous non-fixed character */ | |
522 } | |
523 else | |
524 { | |
525 altCursorPos = editor->cursor.pos; /* Store original cursor position */ | |
526 | |
527 editor->cursor.pos = ATB_string_IndexMove(&editor->attr->text, editor->cursor.pos, -1); | |
528 | |
529 if (editor->cursor.pos==altCursorPos) /* If we're at the start of text */ | |
530 { | |
531 ATB_edit_MoveCursor(editor, ctrlBottom, FALSE); /* .. then go to the end of text! */ | |
532 } | |
533 } | |
534 } | |
535 break; | |
536 | |
537 case ctrlRight: | |
538 if (!ATB_edit_Mode(editor, ED_MODE_READONLY)) /* Not in read only mode*/ | |
539 { | |
540 if (ATB_edit_Mode(editor, ED_MODE_FORMATTED)) /* formatted input */ | |
541 { | |
542 ATB_edit_FindNext(editor); /* Move cursor forward once */ | |
543 } | |
544 else | |
545 { | |
546 altCursorPos = editor->cursor.pos; /* Store original cursor position */ | |
547 | |
548 editor->cursor.pos = ATB_string_IndexMove(&editor->attr->text, editor->cursor.pos, 1); | |
549 if (editor->cursor.pos==altCursorPos) /* If we're at the end of text */ | |
550 { | |
551 ATB_edit_MoveCursor(editor, ctrlTop, FALSE); /* .. then go to the start of text! */ | |
552 } | |
553 } | |
554 } | |
555 break; | |
556 | |
557 case ctrlUp: | |
558 if (editor->cursor.line > 0) | |
559 dy = -1; | |
560 break; | |
561 | |
562 case ctrlDown: | |
563 if (editor->cursor.line < (editor->numLines-1)) | |
564 dy = 1; | |
565 break; | |
566 | |
567 case ctrlTop: | |
568 editor->cursor.pos = 0; | |
569 editor->initialised = FALSE; /* We need to recalculate whole editor */ | |
570 | |
571 /* For formatted mode, skip over any fixed characters at the start */ | |
572 | |
573 if (ATB_edit_Mode(editor, ED_MODE_FORMATTED)) | |
574 { | |
575 editor->formatIndex = 0; | |
576 editor->fieldIndex = 0; | |
577 ATB_edit_FindNext(editor); | |
578 ATB_edit_FindPrev(editor); | |
579 } | |
580 break; | |
581 | |
582 case ctrlBottom: | |
583 /* Search until we find end of text */ | |
584 while (ATB_string_GetChar(&editor->attr->text, editor->cursor.pos)!=UNICODE_EOLN) | |
585 { | |
586 editor->cursor.pos++; | |
587 } | |
588 editor->initialised = FALSE; /* We need to recalculate whole editor */ | |
589 break; | |
590 | |
591 default: | |
592 TRACE_EVENT("** ERROR ** Unexpected cursor movement."); | |
593 return ED_ERROR; | |
594 /*break;*/ | |
595 } | |
596 | |
597 /* SPR#1983 - SH - In caps mode, any keypress switches to lower case */ | |
598 | |
599 if (editor->textcase==ED_CASE_CAPS) | |
600 editor->textcase = ED_CASE_LOWER; | |
601 | |
602 if (update || dy!=0) | |
603 { | |
604 ATB_edit_Update(editor, dy); | |
605 } | |
606 | |
607 return ED_OK; | |
608 } | |
609 | |
610 | |
611 /******************************************************************************* | |
612 | |
613 $Function: ATB_edit_DeleteLeft | |
614 | |
615 $Description: Delete the character to the left of the cursor | |
616 SPR#2342 - SH - Added flag 'update' | |
617 | |
618 $Returns: ED_OK - OK | |
619 | |
620 $Arguments: editor - The editor data | |
621 update - TRUE if word wrap is to be carried out after deletion | |
622 | |
623 *******************************************************************************/ | |
624 | |
625 ED_RES ATB_edit_DeleteLeft (T_ED_DATA *editor, UBYTE update) | |
626 { | |
627 ED_RES result = ED_OK; | |
628 USHORT altCursorPos; | |
629 char formatchar; | |
630 | |
631 TRACE_FUNCTION("ATB_edit_DeleteLeft"); | |
632 | |
633 if (!editor) | |
634 return ED_BAD_HANDLE; /* element does not exist */ | |
635 | |
636 /* SPR#1983 - SH - Hidden text changes now mirror normal text changes. */ | |
637 | |
638 /* Formatted mode */ | |
639 | |
640 if (ATB_edit_Mode(editor, ED_MODE_FORMATTED)) /* Formatted input */ | |
641 { | |
642 if (ATB_edit_FindPrev(editor)!=FINDPREV_FIRST_CHAR) /* Skip over fixed characters */ | |
643 { | |
644 if (editor->formatIndex>0) /* So we don't look back beyond start of string */ | |
645 { | |
646 /* If we're in a delimited field, do normal delete, otherwise just cursor back */ | |
647 formatchar = editor->attr->FormatString[editor->formatIndex-1]; | |
648 if ((formatchar>'0' && formatchar<='9') || formatchar=='*') /* If it's a number between 1 and 9, or a * */ | |
649 { | |
650 ATB_string_MoveLeft(&editor->attr->text, editor->cursor.pos, 1); | |
651 if (ATB_edit_Mode(editor, ED_MODE_HIDDEN)) | |
652 { | |
653 ATB_string_MoveLeft(editor->hiddenText, editor->cursor.pos, 1); | |
654 } | |
655 //CRR:25546 - xpradipg - 26 Oct 2004 | |
656 //the if block is moved out from the ATB_edit_FindPrev() | |
657 if (editor->fieldIndex==0) // If we've reached the beginning of the field | |
658 editor->formatIndex--; | |
659 } | |
660 } | |
661 result = ED_OK; | |
662 } | |
663 else | |
664 { | |
665 result = ED_DONE; /* Delete with empty buffer - escape from editor */ | |
666 } | |
667 } | |
668 | |
669 /* Overwrite mode */ | |
670 | |
671 else if (ATB_edit_Mode(editor, ED_MODE_OVERWRITE)) | |
672 { | |
673 /* If we're at the end of the string, shift the '0' back */ | |
674 if (editor->cursor.pos>0) | |
675 { | |
676 if (editor->cursor.pos == editor->attr->text.len) | |
677 { | |
678 result = ATB_edit_MoveCursor(editor, ctrlLeft, FALSE); | |
679 ATB_string_SetChar(&editor->attr->text, editor->cursor.pos, UNICODE_EOLN); | |
680 editor->attr->text.len--; | |
681 if (ATB_edit_Mode(editor, ED_MODE_HIDDEN)) | |
682 { | |
683 ATB_string_SetChar(editor->hiddenText, editor->cursor.pos, UNICODE_EOLN); | |
684 editor->hiddenText->len--; | |
685 } | |
686 } | |
687 /* Otherwise, overwrite with a space */ | |
688 else | |
689 { | |
690 result = ATB_edit_MoveCursor(editor, ctrlLeft, FALSE); | |
691 ATB_string_SetChar(&editor->attr->text, editor->cursor.pos, UNICODE_SPACE); | |
692 if (ATB_edit_Mode(editor, ED_MODE_HIDDEN)) | |
693 { | |
694 ATB_string_SetChar(editor->hiddenText, editor->cursor.pos, UNICODE_SPACE); | |
695 } | |
696 } | |
697 } | |
698 else | |
699 { | |
700 result = ED_DONE; /* Delete with empty buffer - escape from editor */ | |
701 } | |
702 } | |
703 else | |
704 { | |
705 /* Otherwise, just perform normal delete operation */ | |
706 altCursorPos = ATB_string_IndexMove(&editor->attr->text, editor->cursor.pos,-1); | |
707 if (altCursorPos!=editor->cursor.pos) | |
708 { | |
709 ATB_string_MoveLeft(&editor->attr->text, altCursorPos, editor->cursor.pos-altCursorPos); // Delete the difference! | |
710 | |
711 if (ATB_edit_Mode(editor, ED_MODE_HIDDEN)) | |
712 { | |
713 ATB_string_MoveLeft(editor->hiddenText, altCursorPos, editor->cursor.pos-altCursorPos); // Delete the difference! | |
714 } | |
715 | |
716 editor->cursor.pos = altCursorPos; | |
717 result = ED_OK; | |
718 } | |
719 else | |
720 result = ED_DONE; | |
721 } | |
722 | |
723 /* SPR#1983 - SH - In caps mode, any keypress switches to lower case */ | |
724 | |
725 if (editor->textcase==ED_CASE_CAPS) | |
726 editor->textcase = ED_CASE_LOWER; | |
727 | |
728 // Jul 22,2004 CRR:21605 xrashmic - SASKEN | |
729 // When deleting a character, if editor is empty, then set the case to | |
730 // sentence case only if the user has not modified the case explicitly. | |
731 if(editor->cursor.pos==0 && CaseChanged == FALSE) | |
732 { | |
733 editor->textcase = ED_CASE_CAPS; | |
734 } | |
735 | |
736 if (update) | |
737 { | |
738 ATB_edit_Update(editor,0); | |
739 } | |
740 | |
741 return result; | |
742 } | |
743 | |
744 | |
745 /******************************************************************************* | |
746 | |
747 $Function: ATB_edit_DeleteRight | |
748 | |
749 $Description: Delete the character to the right of the cursor | |
750 SPR#2342 - SH - Added flag 'update' | |
751 | |
752 $Returns: ED_OK - OK | |
753 | |
754 $Arguments: editor - The editor data | |
755 update - TRUE if word wrap is to be carried out after deletion | |
756 | |
757 *******************************************************************************/ | |
758 | |
759 ED_RES ATB_edit_DeleteRight (T_ED_DATA *editor, UBYTE update) | |
760 { | |
761 char formatchar; | |
762 | |
763 TRACE_FUNCTION("ATB_edit_DeleteRight"); | |
764 | |
765 if (!editor) | |
766 return ED_BAD_HANDLE; /* element does not exist */ | |
767 | |
768 /* SPR#1983 - SH - Hidden text changes now mirror normal text changes. */ | |
769 | |
770 /* Formatted mode */ | |
771 | |
772 if (ATB_edit_Mode(editor, ED_MODE_FORMATTED)) /* Formatted input */ | |
773 { | |
774 /* If we're in a delimited field, do normal delete right, otherwise ignore */ | |
775 if (editor->formatIndex>0) | |
776 { | |
777 formatchar = editor->attr->FormatString[editor->formatIndex-1]; | |
778 if ((formatchar>'0' && formatchar<='9') || formatchar=='*') /* If it's a number between 1 and 9, or a * */ | |
779 { | |
780 ATB_string_MoveLeft(&editor->attr->text, editor->cursor.pos, 1); | |
781 if (ATB_edit_Mode(editor, ED_MODE_HIDDEN)) | |
782 { | |
783 ATB_string_MoveLeft(editor->hiddenText, editor->cursor.pos, 1); | |
784 } | |
785 } | |
786 } | |
787 } | |
788 | |
789 /* Overwrite mode */ | |
790 | |
791 else if (ATB_edit_Mode(editor, ED_MODE_OVERWRITE)) | |
792 { | |
793 /* Make sure we're not at the end of the string */ | |
794 if (editor->cursor.pos<editor->attr->text.len) | |
795 { | |
796 if (!ATB_edit_Mode(editor, ED_MODE_HIDDEN)) | |
797 { | |
798 ATB_string_SetChar(&editor->attr->text, editor->cursor.pos, UNICODE_SPACE); | |
799 } | |
800 } | |
801 } | |
802 else | |
803 { | |
804 ATB_string_MoveLeft(&editor->attr->text, editor->cursor.pos, 1); /* Otherwise, just perform normal delete operation */ | |
805 if (ATB_edit_Mode(editor, ED_MODE_HIDDEN)) | |
806 { | |
807 ATB_string_MoveLeft(&editor->attr->text, editor->cursor.pos, 1); /* Otherwise, just perform normal delete operation */ | |
808 } | |
809 } | |
810 | |
811 /* SPR#1983 - SH - In caps mode, any keypress switches to lower case, if we're | |
812 * not in multi-tap */ | |
813 | |
814 if (!editor->multitap && editor->textcase==ED_CASE_CAPS) | |
815 editor->textcase = ED_CASE_LOWER; | |
816 | |
817 if (update) | |
818 { | |
819 ATB_edit_Update(editor,0); | |
820 } | |
821 | |
822 return ED_OK; | |
823 } | |
824 | |
825 | |
826 /******************************************************************************* | |
827 | |
828 $Function: ATB_edit_ClearAll | |
829 | |
830 $Description: Clear all text from the editor, move cursor to the top | |
831 | |
832 $Returns: ED_BAD_HANDLE - Editor data pointer is null | |
833 ED_DONE - Deleted from start of editor, exit editor | |
834 ED_OK - OK | |
835 | |
836 $Arguments: editor - The editor data | |
837 | |
838 *******************************************************************************/ | |
839 | |
840 ED_RES ATB_edit_ClearAll (T_ED_DATA *editor) | |
841 { | |
842 /* SPR#2275 - SH - No longer use variable 'textlength' */ | |
843 /* x0045876, 14-Aug-2006 (WR - variable "result" was set but never used) */ | |
844 /* ED_RES result; */ | |
845 | |
846 TRACE_FUNCTION("ATB_edit_ClearAll()"); | |
847 | |
848 if (!editor) | |
849 return ED_BAD_HANDLE; // element does not exist | |
850 | |
851 /* FORMATTED MODE */ | |
852 | |
853 if (ATB_edit_Mode(editor, ED_MODE_FORMATTED)) | |
854 { | |
855 /* Find first non-fixed character. SPR#2275 - Simplified */ | |
856 ATB_edit_MoveCursor(editor, ctrlTop, FALSE); // starting from the top. | |
857 } | |
858 | |
859 /* NORMAL MODE */ | |
860 | |
861 else | |
862 { | |
863 if (editor->attr->text.len==0) | |
864 { | |
865 /* x0045876, 14-Aug-2006 (WR - variable "result" was set but never used) */ | |
866 /* result = ED_DONE; */ | |
867 } | |
868 else | |
869 { | |
870 memset(editor->attr->text.data,'\0',editor->attr->size*ATB_string_Size(&editor->attr->text)); /* Clear buffer */ | |
871 editor->attr->text.len = 0; | |
872 if (ATB_edit_Mode(editor, ED_MODE_HIDDEN)) | |
873 { | |
874 memset(editor->hiddenText->data,'\0',editor->attr->size*ATB_string_Size(&editor->attr->text)); | |
875 editor->hiddenText->len = 0; | |
876 } | |
877 ATB_edit_Reset(editor); /* Send cursor to start */ | |
878 | |
879 /* x0045876, 14-Aug-2006 (WR - variable "result" was set but never used) */ | |
880 /* result = ED_OK; */ | |
881 } | |
882 } | |
883 | |
884 ATB_edit_Update(editor,0); /* Update word wrap & cursor */ | |
885 | |
886 return ED_OK; | |
887 } | |
888 | |
889 | |
890 /******************************************************************************* | |
891 | |
892 $Function: ATB_edit_Char | |
893 | |
894 $Description: Insert a character into the editor text, or execute a control code | |
895 | |
896 $Returns: ED_OK - OK | |
897 | |
898 $Arguments: editor - The editor data | |
899 character - The character - in unicode representation | |
900 update - TRUE if word wrap is to be carried out after insertion | |
901 | |
902 *******************************************************************************/ | |
903 | |
904 ED_RES ATB_edit_Char (T_ED_DATA *editor, USHORT character, UBYTE update) | |
905 { | |
906 TRACE_FUNCTION("ATB_edit_Char()"); | |
907 | |
908 if (!editor) | |
909 return ED_BAD_HANDLE; // element does not exist | |
910 | |
911 switch (character) | |
912 { | |
913 /* Quit editor */ | |
914 | |
915 case ctrlEscape: | |
916 return ED_DONE; | |
917 /*break;*/ | |
918 | |
919 /* Cursor movements*/ | |
920 | |
921 case ctrlLeft: | |
922 case ctrlRight: | |
923 case ctrlUp: | |
924 case ctrlDown: | |
925 case ctrlTop: | |
926 case ctrlBottom: | |
927 ATB_edit_MoveCursor(editor, character, update); | |
928 break; | |
929 | |
930 /* Backspace */ | |
931 | |
932 case ctrlBack: | |
933 ATB_edit_DeleteLeft(editor, update); /* SPR#2342 - SH */ | |
934 break; | |
935 | |
936 /* Delete character under cursor */ | |
937 | |
938 case ctrlDel: | |
939 ATB_edit_DeleteRight(editor, update); /* SPR#2342 - SH */ | |
940 break; | |
941 | |
942 /* CR/LF */ | |
943 | |
944 case ctrlEnter: | |
945 character = UNICODE_LINEFEED; | |
946 /* SPR#1983 - SH - Insert into normal buffer */ | |
947 if (ATB_edit_Insert(editor, &editor->attr->text, character)) | |
948 { | |
949 ATB_edit_MoveCursor(editor,ctrlRight,update); | |
950 } | |
951 break; | |
952 | |
953 /* Normal character */ | |
954 | |
955 default: | |
956 /* SPR#1983 - SH - Insert into normal buffer */ | |
957 if (ATB_edit_Insert(editor, &editor->attr->text, character)) | |
958 { | |
959 /* Character inserted OK. Move cursor to right if we're not in multitap */ | |
960 if (!editor->multitap) | |
961 { | |
962 ATB_edit_MoveCursor(editor,ctrlRight,FALSE); | |
963 } | |
964 | |
965 if (update) | |
966 { | |
967 ATB_edit_Update(editor, 0); | |
968 } | |
969 } | |
970 break; | |
971 } | |
972 | |
973 /* SPR#1983 - SH - In caps mode, any keypress switches to lower case */ | |
974 | |
975 if (!editor->multitap && editor->textcase==ED_CASE_CAPS) | |
976 editor->textcase = ED_CASE_LOWER; | |
977 | |
978 return ED_OK; | |
979 } | |
980 | |
981 | |
982 /******************************************************************************* | |
983 | |
984 $Function: ATB_edit_AsciiChar | |
985 | |
986 $Description: Insert an ascii character into the editor text, or execute a control code | |
987 | |
988 $Returns: ED_OK - OK | |
989 | |
990 $Arguments: editor - The editor data | |
991 character - The ascii character | |
992 update - TRUE if word wrap is to be carried out after insertion | |
993 | |
994 *******************************************************************************/ | |
995 | |
996 ED_RES ATB_edit_AsciiChar (T_ED_DATA *editor, char character, UBYTE update) | |
997 { | |
998 USHORT unicodeChar; | |
999 | |
1000 if (character<ctrlMax) | |
1001 unicodeChar = (USHORT)(unsigned char)character; | |
1002 else | |
1003 unicodeChar = ATB_char_Unicode(character); | |
1004 | |
1005 return ATB_edit_Char(editor, unicodeChar, update); | |
1006 } | |
1007 | |
1008 | |
1009 /******************************************************************************* | |
1010 | |
1011 $Function: ATB_edit_Insert | |
1012 | |
1013 $Description: Insert a character into the editor text | |
1014 SPR#1983 - SH - Added 'text' parameter. | |
1015 | |
1016 $Returns: TRUE if character was inserted | |
1017 | |
1018 $Arguments: editor - The editor data | |
1019 text - The text string (normal or hidden buffer) | |
1020 character - The character - in unicode representation | |
1021 | |
1022 *******************************************************************************/ | |
1023 | |
1024 static int ATB_edit_Insert (T_ED_DATA *editor, T_ATB_TEXT *text, USHORT character) | |
1025 { | |
1026 int result = FALSE; | |
1027 | |
1028 TRACE_FUNCTION("ATB_edit_Insert()"); | |
1029 | |
1030 if (!ATB_edit_Mode(editor, ED_MODE_READONLY)) // Can't insert into read only mode | |
1031 { | |
1032 if (ATB_edit_Mode(editor, ED_MODE_OVERWRITE)) | |
1033 { | |
1034 if (editor->cursor.pos < (editor->attr->size-1)) /* Make sure character will fit */ | |
1035 { | |
1036 result = TRUE; /* We can write the cahracter */ | |
1037 | |
1038 /* If overwriting end of line, we need to increment length of string */ | |
1039 if (ATB_string_GetChar(text, editor->cursor.pos)==UNICODE_EOLN) | |
1040 { | |
1041 | |
1042 /* Ensure string ends with end of line character */ | |
1043 ATB_string_SetChar(text, editor->cursor.pos+1, UNICODE_EOLN); | |
1044 text->len++; | |
1045 } | |
1046 } | |
1047 } | |
1048 else /* For insert mode, check if we have space */ | |
1049 { | |
1050 result = ATB_string_MoveRight(text, editor->cursor.pos, 1, editor->attr->size); // move rest of text right to leave space | |
1051 } | |
1052 | |
1053 if (result) | |
1054 { | |
1055 ATB_string_SetChar(text, editor->cursor.pos, character); // Insert the character | |
1056 } | |
1057 } | |
1058 else | |
1059 { | |
1060 result = FALSE; | |
1061 } | |
1062 | |
1063 return result; | |
1064 } | |
1065 | |
1066 | |
1067 /******************************************************************************* | |
1068 | |
1069 $Function: ATB_edit_MultiTap | |
1070 | |
1071 $Description: Displays the specified character over the cursor | |
1072 | |
1073 $Returns: None. | |
1074 | |
1075 $Arguments: editor - The editor data | |
1076 character - The character to display | |
1077 multitap - TRUE if multi-tap is currently in progress | |
1078 | |
1079 *******************************************************************************/ | |
1080 | |
1081 ED_RES ATB_edit_MultiTap(T_ED_DATA *editor, USHORT character, BOOL multitap) | |
1082 { | |
1083 UBYTE oldmultitap; | |
1084 ED_RES result = ED_OK; | |
1085 | |
1086 TRACE_FUNCTION("ATB_edit_MultiTap()"); | |
1087 | |
1088 if (!editor) | |
1089 return ED_BAD_HANDLE; // element does not exist | |
1090 | |
1091 oldmultitap = editor->multitap; | |
1092 editor->multitap = multitap; | |
1093 | |
1094 /* If we were previously in multitap, and in insert mode, delete character under cursor. | |
1095 * Since this deletes current character in both visible and | |
1096 * hidden buffer, do this before inserting character to either buffer. */ | |
1097 | |
1098 if (oldmultitap && !multitap && !ATB_edit_Mode(editor, ED_MODE_HIDDEN)) | |
1099 { | |
1100 result = ATB_edit_MoveCursor(editor, ctrlRight, TRUE); | |
1101 } | |
1102 else | |
1103 { | |
1104 if (oldmultitap && !ATB_edit_Mode(editor, ED_MODE_OVERWRITE)) | |
1105 { | |
1106 ATB_edit_DeleteRight(editor, FALSE); /* SPR#2342 - SH */ | |
1107 } | |
1108 | |
1109 /* Hidden mode */ | |
1110 | |
1111 if (ATB_edit_Mode(editor, ED_MODE_HIDDEN)) /* In hidden mode... */ | |
1112 { | |
1113 ATB_edit_Insert(editor, editor->hiddenText, character); | |
1114 | |
1115 if (!multitap) /* n multi-tap, show character...*/ | |
1116 character = UNICODE_STAR; /* ...otherwise show star */ | |
1117 } | |
1118 | |
1119 result = ATB_edit_Char(editor,character,TRUE); | |
1120 } | |
1121 | |
1122 return result; | |
1123 } | |
1124 | |
1125 | |
1126 /******************************************************************************* | |
1127 | |
1128 $Function: ATB_edit_AsciiMultiTap | |
1129 | |
1130 $Description: Displays the specified ascii character over the cursor | |
1131 | |
1132 $Returns: None. | |
1133 | |
1134 $Arguments: editor - The editor data | |
1135 character - The ascii character to display | |
1136 multitap - TRUE if multi-tap is currently in progress | |
1137 | |
1138 *******************************************************************************/ | |
1139 | |
1140 ED_RES ATB_edit_AsciiMultiTap(T_ED_DATA *editor, char character, BOOL multitap) | |
1141 { | |
1142 USHORT unicodeChar; | |
1143 | |
1144 if (character<ctrlMax) | |
1145 unicodeChar = (USHORT)(unsigned char)character; | |
1146 else | |
1147 unicodeChar = ATB_char_Unicode(character); | |
1148 | |
1149 return ATB_edit_MultiTap(editor, unicodeChar, multitap); | |
1150 } | |
1151 | |
1152 | |
1153 /******************************************************************************* | |
1154 | |
1155 $Function: ATB_edit_FindNext | |
1156 | |
1157 $Description: For formatted input, adds a character to the input buffer then finds | |
1158 the next non-fixed character space for the cursor to occupy | |
1159 | |
1160 $Returns: None | |
1161 | |
1162 $Arguments: editor - The editor data | |
1163 character - The character (or code) to insert | |
1164 | |
1165 *******************************************************************************/ | |
1166 | |
1167 static void ATB_edit_FindNext(T_ED_DATA *editor) | |
1168 { | |
1169 char *format = editor->attr->FormatString; | |
1170 char formatchar; | |
1171 UBYTE inField = ENTRY_NOT_IN_FIELD; | |
1172 | |
1173 TRACE_FUNCTION("ATB_edit_FindNext()"); | |
1174 | |
1175 // xreddymn - Included xrashmic's fix for 12470 | |
1176 if(editor->attr->text.len==0) | |
1177 { | |
1178 return; | |
1179 } | |
1180 | |
1181 /* Check for delimited field */ | |
1182 | |
1183 if (editor->formatIndex>0) | |
1184 { | |
1185 formatchar = format[editor->formatIndex-1]; | |
1186 if ((formatchar>'0' && formatchar<='9') || formatchar=='*') | |
1187 inField = ENTRY_IN_FIELD; | |
1188 } | |
1189 | |
1190 formatchar = format[editor->formatIndex]; | |
1191 if ((formatchar>'0' && formatchar<='9') || formatchar=='*') | |
1192 inField = ENTRY_ENTERING_FIELD; | |
1193 | |
1194 /* Check for cursor right at end of string - don't allow */ | |
1195 | |
1196 if (editor->cursor.pos>=editor->attr->text.len | |
1197 && editor->formatIndex>-1 && inField==ENTRY_NOT_IN_FIELD) | |
1198 { | |
1199 return; | |
1200 } | |
1201 | |
1202 /* Move cursor position right */ | |
1203 | |
1204 editor->cursor.pos = ATB_string_IndexMove(&editor->attr->text, editor->cursor.pos, 1); | |
1205 | |
1206 /* Check for start of fixed input field */ | |
1207 | |
1208 if (inField==ENTRY_ENTERING_FIELD) | |
1209 { | |
1210 editor->formatIndex++; // Get us into the field... | |
1211 editor->fieldIndex = 0; // ...and reset the field index | |
1212 formatchar = format[editor->formatIndex]; | |
1213 if (formatchar=='M') | |
1214 editor->textcase = ED_CASE_UPPER; | |
1215 if (formatchar=='m') | |
1216 editor->textcase = ED_CASE_LOWER; | |
1217 inField = ENTRY_IN_FIELD; | |
1218 } | |
1219 | |
1220 /* Check whether we're in a fixed input field, e.g. "4N" or "8X" */ | |
1221 | |
1222 if (inField==ENTRY_IN_FIELD) // So we don't look back beyond start of string | |
1223 { | |
1224 formatchar = format[editor->formatIndex-1]; | |
1225 editor->fieldIndex++; // Increment the position in the field | |
1226 if (editor->fieldIndex==(int)(formatchar-'0')) // If we've entered the number of characters specified (note- will never happen for the '*' !) | |
1227 { | |
1228 editor->formatIndex++; // point to NULL at end of string (no more input) | |
1229 } | |
1230 return; | |
1231 } | |
1232 | |
1233 /* If not, just look at next format character as usual */ | |
1234 | |
1235 editor->formatIndex++; // Point to next character | |
1236 | |
1237 while (editor->formatIndex<(SHORT)strlen(format) && format[editor->formatIndex]=='\\') // Fixed characters encountered | |
1238 { | |
1239 editor->cursor.pos = ATB_string_IndexMove(&editor->attr->text, editor->cursor.pos, 1); // Skip over them | |
1240 editor->formatIndex+=2; | |
1241 } | |
1242 | |
1243 if (editor->formatIndex>(SHORT)(strlen(format))) // Don't look beyond end of string | |
1244 editor->formatIndex = strlen(format); | |
1245 | |
1246 return; | |
1247 } | |
1248 | |
1249 | |
1250 /******************************************************************************* | |
1251 | |
1252 $Function: ATB_edit_FindPrev | |
1253 | |
1254 $Description: For formatted input, finds the previous non-fixed character and | |
1255 moves the cursor there if possible | |
1256 | |
1257 $Returns: FINDPREV_NO_CHANGE if the cursor position is not changed (nowhere to go) | |
1258 FINDPREV_PREV_FOUND if the previous character has been found | |
1259 FINDPREV_FIRST_CHAR if the cursor was over the first non-fixed character | |
1260 FINDPREV_LAST_CHAR if the cursor is at the last non-fixed character | |
1261 | |
1262 $Arguments: editor - The editor data | |
1263 | |
1264 *******************************************************************************/ | |
1265 | |
1266 static USHORT ATB_edit_FindPrev(T_ED_DATA *editor) | |
1267 { | |
1268 char *format = editor->attr->FormatString; | |
1269 char formatchar; | |
1270 SHORT editIndex; | |
1271 | |
1272 TRACE_FUNCTION("ATB_edit_FindPrev()"); | |
1273 | |
1274 /* Check if cursor is at start of string, return 2 */ | |
1275 | |
1276 if (editor->cursor.pos == 0) | |
1277 { | |
1278 return FINDPREV_FIRST_CHAR; | |
1279 } | |
1280 | |
1281 /* Check whether we're in a fixed input field, e.g. "4N" or "8X" */ | |
1282 | |
1283 if (editor->formatIndex>0) // So we don't look back beyond start of string | |
1284 { | |
1285 formatchar = format[editor->formatIndex-1]; | |
1286 if ((formatchar>'0' && formatchar<='9') || formatchar=='*') // If it's a number between 1 and 9, or a * | |
1287 { | |
1288 if (editor->cursor.pos > 0) | |
1289 editor->cursor.pos--; | |
1290 | |
1291 if (editor->cursor.pos < editor->attr->size-1) // (Don't decrement if at last char in string) | |
1292 editor->fieldIndex--; // Decrement the position in the field | |
1293 | |
1294 if (editor->cursor.pos==editor->attr->text.len-1) // Special case if last character - tell editor to shorten the string | |
1295 return FINDPREV_LAST_CHAR; | |
1296 | |
1297 return FINDPREV_PREV_FOUND; // then we're done | |
1298 } | |
1299 } | |
1300 | |
1301 /* If not (or if we've just come out of one) just look at next format character as usual */ | |
1302 | |
1303 editIndex = editor->formatIndex-1; // Make copy of format position, starting off to left | |
1304 | |
1305 while (editIndex>0) | |
1306 { | |
1307 if (format[editIndex-1]=='\\') // If there's a fixed char | |
1308 editIndex -=2; // Look back a further 2 characters | |
1309 else // If there's a non-fixed character | |
1310 break; // then exit loop | |
1311 } | |
1312 | |
1313 if (editIndex==-1) // Go back from 1st character in editor | |
1314 { | |
1315 return FINDPREV_FIRST_CHAR; | |
1316 } | |
1317 | |
1318 formatchar = format[editIndex-1]; | |
1319 if ((formatchar>'0' && formatchar<='9') || formatchar=='*') | |
1320 editor->fieldIndex--; | |
1321 | |
1322 if (editIndex>-1) // Provided there is somewhere to go.... | |
1323 { | |
1324 while(editor->formatIndex>editIndex) | |
1325 { | |
1326 if (editor->cursor.pos > 0) | |
1327 { | |
1328 editor->cursor.pos--; // move cursor there | |
1329 editor->formatIndex--; | |
1330 } | |
1331 if (format[editor->formatIndex]=='\\') | |
1332 editor->formatIndex--; | |
1333 } | |
1334 return FINDPREV_PREV_FOUND; // Found new position | |
1335 } | |
1336 | |
1337 return FINDPREV_NO_CHANGE; // Position unchanged | |
1338 } | |
1339 | |
1340 | |
1341 /******************************************************************************* | |
1342 | |
1343 $Function: ATB_edit_GetCasePref | |
1344 | |
1345 $Description: Returns the preferred case for the current position in the editor | |
1346 | |
1347 $Returns: ED_CASEPREF_NUM - Any numeric character | |
1348 ED_CASEPREF_ALPHA_UC - Any symbolic or alphabetic uppercase | |
1349 character | |
1350 ED_CASEPREF_ALPHA_LC - Any symbolic or alphabetic lowercase | |
1351 character | |
1352 ED_CASEPREF_ALPHANUM - Any symbolic, numeric, or alphabetic | |
1353 character | |
1354 ED_CASEPREF_ALPHANUM_UC - Any symbolic, numeric, or alphabetic | |
1355 uppercase character | |
1356 ED_CASEPREF_ALPHANUM_LC - Any symbolic, numeric, or alphabetic | |
1357 lowercase character | |
1358 | |
1359 $Arguments: editor - The editor data | |
1360 | |
1361 *******************************************************************************/ | |
1362 | |
1363 T_ED_CASE_PREF ATB_edit_GetCasePref(T_ED_DATA *editor) | |
1364 { | |
1365 T_ED_CASE_PREF casePref; | |
1366 char formatchar; | |
1367 char *format; | |
1368 | |
1369 /* FORMATTED MODE */ | |
1370 | |
1371 if (ATB_edit_Mode(editor, ED_MODE_FORMATTED)) | |
1372 { | |
1373 format = editor->attr->FormatString; | |
1374 formatchar = format[editor->formatIndex]; | |
1375 | |
1376 if ((formatchar>'0' && formatchar<='9') || formatchar=='*') // Delimiter for format field | |
1377 { | |
1378 editor->formatIndex++; | |
1379 editor->fieldIndex = 0; | |
1380 formatchar = format[editor->formatIndex]; // Next character is the format for the field | |
1381 } | |
1382 | |
1383 switch(formatchar) | |
1384 { | |
1385 case 'X': /* Uppercase alphanumeric */ | |
1386 casePref = ED_CASEPREF_ALPHANUM_UC; | |
1387 break; | |
1388 case 'x': | |
1389 casePref = ED_CASEPREF_ALPHANUM_LC; /* Lowercase alphanumeric */ | |
1390 break; | |
1391 case 'A': /* Uppercase alphabetic */ | |
1392 casePref = ED_CASEPREF_ALPHA_UC; | |
1393 break; | |
1394 case 'a': /* Lowercase alphabetic */ | |
1395 casePref = ED_CASEPREF_ALPHA_LC; | |
1396 break; | |
1397 case 'M': | |
1398 casePref = ED_CASEPREF_ALPHANUM; | |
1399 break; | |
1400 case 'm': | |
1401 casePref = ED_CASEPREF_ALPHANUM; | |
1402 break; | |
1403 case 'N': | |
1404 casePref = ED_CASEPREF_NUM; | |
1405 break; | |
1406 | |
1407 default: | |
1408 casePref = ED_CASEPREF_NONE; | |
1409 break; | |
1410 } | |
1411 } | |
1412 | |
1413 /* NORMAL MODE */ | |
1414 else | |
1415 { | |
1416 casePref = ED_CASEPREF_NUM; /* SPR#2342 - SH - Default to numeric mode */ | |
1417 | |
1418 if (ATB_edit_Mode(editor, ED_MODE_ALPHA) | |
1419 && ATB_edit_GetCase(editor)!=ED_CASE_NUM) | |
1420 { | |
1421 casePref = ED_CASEPREF_ALPHANUM; | |
1422 } | |
1423 } | |
1424 | |
1425 return casePref; | |
1426 } | |
1427 | |
1428 | |
1429 /******************************************************************************* | |
1430 | |
1431 $Function: ATB_edit_OutTextLines | |
1432 | |
1433 $Description: Draw the visible lines of text onto the screen | |
1434 | |
1435 $Returns: None | |
1436 | |
1437 $Arguments: editor - The editor data | |
1438 | |
1439 *******************************************************************************/ | |
1440 | |
1441 static void ATB_edit_OutTextLines (T_ED_DATA *editor) | |
1442 { | |
1443 USHORT editX = editor->attr->win_size.px; /* X position in editor */ | |
1444 USHORT editY = editor->attr->win_size.py; /* Y position in editor */ | |
1445 USHORT editWidth = editor->attr->win_size.sx; /* Height of the editor */ | |
1446 USHORT editHeight = editor->attr->win_size.sy; /* Height of the editor */ | |
1447 USHORT lineNo; | |
1448 USHORT heightOnScreen; /* Height of lines shown so far */ | |
1449 USHORT offsetX=0; /* X offset of line */ | |
1450 T_DS_TEXTFORMAT tempFormat; /* Temporary storage for format attributes */ | |
1451 T_ED_LINE *line; /* Current line attributes */ | |
1452 T_ATB_TEXT currentLine; /* Current line */ | |
1453 // Shashi Shekar B.S., a0876501, Jan 16, 2006, DR: OMAPS00061460 | |
1454 #ifdef FF_MMI_SAT_ICON | |
1455 USHORT titleIconWidth = 0; | |
1456 USHORT iconX, iconY; | |
1457 USHORT titleHeight = 0; | |
1458 #endif | |
1459 | |
1460 TRACE_FUNCTION("ATB_edit_OutTextLines()"); | |
1461 | |
1462 if (editor == NULL) | |
1463 return; | |
1464 | |
1465 // Shashi Shekar B.S., a0876501, Jan 16, 2006, DR: OMAPS00061460 | |
1466 #ifdef FF_MMI_SAT_ICON | |
1467 if (editor->attr->TitleIcon.data != NULL && !editor->attr->TitleIcon.isTitle) | |
1468 { | |
1469 if (editor->attr->TitleIcon.width > TITLE_ICON_WIDTH) | |
1470 { | |
1471 titleIconWidth = TITLE_ICON_WIDTH; | |
1472 } | |
1473 else | |
1474 { | |
1475 titleIconWidth = editor->attr->TitleIcon.width; | |
1476 } | |
1477 } | |
1478 else | |
1479 { | |
1480 titleIconWidth = 0; | |
1481 } | |
1482 | |
1483 if(titleIconWidth) | |
1484 editX = editX + titleIconWidth + 1; | |
1485 #endif | |
1486 | |
1487 heightOnScreen = 0; | |
1488 line = ATB_edit_LineGet(editor, editor->winStartLine); | |
1489 | |
1490 // Shashi Shekar B.S., a0876501, Jan 16, 2006, DR: OMAPS00061460 | |
1491 #ifdef FF_MMI_SAT_ICON | |
1492 if(line != NULL) | |
1493 titleHeight = line->height; | |
1494 #endif | |
1495 /*a0393213 lint warning removal - check 'line!=NULL' added*/ | |
1496 for (lineNo = editor->winStartLine; lineNo < editor->numLines && heightOnScreen<=editHeight && line!=NULL; lineNo++) | |
1497 { | |
1498 heightOnScreen += line->height; /* Add this height to the total height so far... */ | |
1499 | |
1500 if (editor->display && heightOnScreen <= editHeight) /* and make sure this fits onto the screen */ | |
1501 { | |
1502 if (line->next!=NULL) | |
1503 currentLine.len = line->next->pos - line->pos; /* End of line is the first character of the next line */ | |
1504 else /*a0393213 lint warnings removal*/ | |
1505 { | |
1506 currentLine.len=0; | |
1507 TRACE_ERROR("ATB_edit_OutTextLines():line missing"); | |
1508 } | |
1509 currentLine.dcs = editor->attr->text.dcs; | |
1510 currentLine.data = &editor->attr->text.data[line->pos*ATB_string_Size(¤tLine)]; | |
1511 | |
1512 offsetX = 0; | |
1513 if (line->format.attr & DS_ALIGN_RIGHT) | |
1514 { | |
1515 offsetX = editWidth-ATB_display_StringWidth(¤tLine, &line->format); | |
1516 } | |
1517 else if (line->format.attr & DS_ALIGN_CENTRE) | |
1518 { | |
1519 offsetX = (editWidth-ATB_display_StringWidth(¤tLine, &line->format))/2; | |
1520 } | |
1521 ATB_display_CopyFormat(&tempFormat, &line->format); /* So format of lines doesn't change */ | |
1522 ATB_display_Text(offsetX+editX, editY, &tempFormat, ¤tLine); | |
1523 } | |
1524 | |
1525 editY += line->height; /* Move down by line height, ready for the next one */ | |
1526 line = line->next; /* Get next line */ | |
1527 } | |
1528 //Sudha.V., x0035544, Feb 02, 2006, DR: OMAPS00061468 | |
1529 // Shashi Shekar B.S., a0876501, Jan 16, 2006, DR: OMAPS00061460 | |
1530 #ifdef FF_MMI_SAT_ICON | |
1531 if(editor->attr->TitleIcon.data != NULL && !editor->attr->TitleIcon.isTitle) | |
1532 { | |
1533 switch(editor->attr->TitleIcon.display_type) | |
1534 { | |
1535 case SAT_ICON_NONE: | |
1536 break; | |
1537 case SAT_ICON_IDLEMODE_TEXT: | |
1538 | |
1539 if ((editor->attr->TitleIcon.width > TITLE_ICON_WIDTH) || (editor-> | |
1540 attr->TitleIcon.height > TITLE_ICON_HEIGHT)) | |
1541 { | |
1542 iconX = editX+offsetX - editor->attr->TitleIcon.width-2; | |
1543 iconY = editor->attr->win_size.py+ ((titleHeight-2)/2); | |
1544 dspl_BitBlt2(iconX, iconY, 8, | |
1545 10, (void*)SATIconQuestionMark, 0, BMP_FORMAT_256_COLOUR); | |
1546 | |
1547 } | |
1548 else | |
1549 { | |
1550 iconX = editX+offsetX - editor->attr->TitleIcon.width-2; | |
1551 iconY = editor->attr->win_size.py + ((titleHeight-2)/2) - ( | |
1552 editor->attr->TitleIcon.height / 2); | |
1553 dspl_BitBlt2(iconX, iconY, editor->attr->TitleIcon.width, | |
1554 editor->attr->TitleIcon.height, (void*)editor->attr->TitleIcon. | |
1555 data, 0, BMP_FORMAT_256_COLOUR); | |
1556 } | |
1557 break; | |
1558 | |
1559 case SAT_ICON_DISPLAY_TEXT: | |
1560 | |
1561 if ((editor->attr->TitleIcon.width > TITLE_ICON_WIDTH) || (editor-> | |
1562 attr->TitleIcon.height > TITLE_ICON_HEIGHT)) | |
1563 { | |
1564 iconX = 1; | |
1565 iconY = 1+ ((titleHeight-2) / 2) - (10 / 2); | |
1566 dspl_BitBlt2(iconX, iconY, 8, | |
1567 10, (void*)SATIconQuestionMark, 0, BMP_FORMAT_256_COLOUR); | |
1568 | |
1569 } | |
1570 else | |
1571 { | |
1572 iconX = 1; | |
1573 iconY = 1+ ((titleHeight-2) / 2) - (editor->attr->TitleIcon. | |
1574 height / 2); | |
1575 dspl_BitBlt2(iconX, iconY, editor->attr->TitleIcon.width, | |
1576 editor->attr->TitleIcon.height, (void*)editor->attr->TitleIcon.data, 0 | |
1577 , BMP_FORMAT_256_COLOUR); | |
1578 } | |
1579 break; | |
1580 } | |
1581 } | |
1582 #endif | |
1583 | |
1584 return; | |
1585 } | |
1586 | |
1587 | |
1588 /******************************************************************************* | |
1589 | |
1590 $Function: ATB_edit_Update | |
1591 | |
1592 $Description: Update editor (without displaying), moving cursor up or down by 'dy' lines. | |
1593 | |
1594 This function goes through the text, word-wraps it with the help of ATB_edit_WordWrap, | |
1595 and works out the start position of text on-screen and the X and Y pixel positions | |
1596 of the cursor (with the help of ATB_edit_UpdateCursorPos). The character position of | |
1597 the start of each line within the string is stored, so that ATB_edit_OutTextLines can | |
1598 quickly display the editor contents without further calculation. | |
1599 | |
1600 $Returns: ED_BAD_HANDLE - Editor data pointer is null | |
1601 ED_OK - OK | |
1602 | |
1603 $Arguments: editor - The editor data | |
1604 dy - number of lines (+ or -) that the cursor must scroll | |
1605 up or down. | |
1606 | |
1607 *******************************************************************************/ | |
1608 | |
1609 static ED_RES ATB_edit_Update (T_ED_DATA *editor, int dy) | |
1610 { | |
1611 USHORT cursorCharPos=0; /* New cursor character position */ | |
1612 USHORT linePos; /* Char pos in string of current line. */ | |
1613 USHORT lineNo; /* Line being considered */ | |
1614 USHORT editComplete; /* Flag indicating cursor position found/updated or end of line reached. */ | |
1615 USHORT character; /* Current unicode char. */ | |
1616 T_ED_LINE *line; /* Pointer to current entry in line chain */ | |
1617 USHORT cursorColumn; /* Column cursor is in - always multiple of 8 pixels */ | |
1618 SHORT charMaxWidth; | |
1619 | |
1620 TRACE_FUNCTION("ATB_edit_Update()"); | |
1621 | |
1622 /* Make sure the editor exists and has text in it */ | |
1623 | |
1624 if (!editor) | |
1625 return ED_BAD_HANDLE; | |
1626 | |
1627 /* For non read-only modes, or on first process, perform word wrap */ | |
1628 | |
1629 if (!ATB_edit_Mode(editor, ED_MODE_READONLY) || editor->initialised==FALSE) | |
1630 { | |
1631 editor->viewStartPos = 0; | |
1632 editor->viewHeight = 0; | |
1633 editor->totalHeight = 0; | |
1634 editor->startOfLine = TRUE; /* We're at the start of a line */ | |
1635 editor->endOfText = FALSE; | |
1636 editor->precedingEOL = FALSE; /* Used to detect if preceding character was CR/LF */ | |
1637 editor->thischar.lineWidth = 0; /* Width of current line */ | |
1638 editor->cursor.line = 0; /* Line that the cursor is on */ | |
1639 editor->space.pos = 0; /* Possible position for soft linebreak - none as yet */ | |
1640 | |
1641 /* Set up data if this is the first time... */ | |
1642 | |
1643 if (!editor->initialised) | |
1644 { | |
1645 editor->thischar.pos = 0; | |
1646 editor->numLines = 0; /* total number of lines in editor, start at 0 */ | |
1647 | |
1648 line = ATB_edit_LineGet(editor, 0); | |
1649 line->pos = 0; /* first line starts at start of buffer */ | |
1650 line->height = 0; /* Height of first line */ | |
1651 ATB_display_CopyFormat(&line->format, &editor->attr->startFormat); /* Start with this text formatting */ | |
1652 ATB_display_CopyFormat(&editor->thischar.format, &editor->attr->startFormat); // Start with this text formatting | |
1653 | |
1654 editor->winStartLine = 0; /* First line to be displayed in window */ | |
1655 | |
1656 editor->initialised = TRUE; | |
1657 } | |
1658 | |
1659 /* Set up data if this is NOT the first time */ | |
1660 | |
1661 else | |
1662 { | |
1663 /* We only need to word wrap text that might have been changed by user text entry. | |
1664 * The user can affect the previous line (by inserting a space or deleting, so the word is | |
1665 * wrapped to a previous line) and all subsequent lines. Therefore if we start word wrapping | |
1666 * on the line previous to where the cursor is, we can encompass all changes. */ | |
1667 line = ATB_edit_LineGet(editor, 0); | |
1668 for (lineNo = 0; lineNo<editor->numLines && editor->cursor.pos>=line->pos; lineNo++) | |
1669 { | |
1670 line = line->next; | |
1671 } | |
1672 if (lineNo>0) | |
1673 lineNo--; | |
1674 if (lineNo>0) | |
1675 lineNo--; | |
1676 | |
1677 line = ATB_edit_LineGet(editor, lineNo); | |
1678 editor->thischar.pos = line->pos; /* Start looking at this line */ | |
1679 editor->numLines = lineNo; /* This no. of lines so far */ | |
1680 ATB_display_CopyFormat(&editor->thischar.format, &line->format); /* Start with this text formatting */ | |
1681 line->height = 0; /* Height of first line */ | |
1682 } | |
1683 | |
1684 | |
1685 /* Set up some values */ | |
1686 | |
1687 cursorCharPos = editor->cursor.pos; /* Cursor position in the string */ | |
1688 linePos = 0; // Position on the current line | |
1689 | |
1690 /* Word wrap the text into separate lines, storing the start position and height of each. | |
1691 * Also, find the cursor and work out its X position. */ | |
1692 | |
1693 while(!editor->endOfText) // Go through from first character to last character | |
1694 { | |
1695 ATB_edit_WordWrap(editor); // What is the character? What's its width? | |
1696 | |
1697 if (editor->endOfLine) // Newline, or current char will not fit on previous line. | |
1698 { | |
1699 editor->numLines++; // We've got another line | |
1700 editor->startOfLine = TRUE; // New line is starting | |
1701 } | |
1702 | |
1703 if (editor->startOfLine) | |
1704 { | |
1705 line = ATB_edit_LineGet(editor, editor->numLines); | |
1706 line->pos = editor->startPos; | |
1707 line->height = editor->thischar.height; // Height of line set to that of first character | |
1708 ATB_display_CopyFormat(&line->format,&editor->thischar.format); | |
1709 /* Formatting at start of line to that of 1st character */ | |
1710 editor->thischar.lineWidth = 0; | |
1711 | |
1712 line = ATB_edit_LineGet(editor, editor->winStartLine); | |
1713 if (editor->startPos <= line->pos) /* Is this the first line to be displayed in the editor? */ | |
1714 { | |
1715 editor->winStartLine = editor->numLines; /* If so, set this line to the start window line */ | |
1716 } | |
1717 editor->startOfLine = FALSE; | |
1718 } | |
1719 | |
1720 if (editor->endOfText) /* If it's a unicode terminator... */ | |
1721 { | |
1722 if (cursorCharPos > editor->thischar.pos) /* Cursor is past end of text - move to char before end of line. */ | |
1723 cursorCharPos = editor->thischar.pos; | |
1724 } | |
1725 | |
1726 if (editor->startPos == cursorCharPos) // We've found the cursor | |
1727 { | |
1728 editor->cursor.line = editor->numLines; // Store the line it's on | |
1729 editor->cursor.width = editor->thischar.width; // Set the width of the cursor | |
1730 editor->cursor.x = editor->thischar.lineWidth; // And its position | |
1731 editor->cursor.attr = editor->thischar.format.attr; // Save the format attribute | |
1732 } | |
1733 | |
1734 editor->thischar.lineWidth += editor->thischar.width; | |
1735 editor->thischar.pos++; | |
1736 } // End while | |
1737 | |
1738 editor->numLines++; // Number of lines is one more than the last line | |
1739 line = ATB_edit_LineGet(editor, editor->numLines); | |
1740 line->pos = editor->thischar.pos; // End of last line | |
1741 | |
1742 ATB_edit_UpdateCursorPos(editor); // Update, but if dy!=0 we may have to change this | |
1743 } | |
1744 | |
1745 /* We now have the start position of each line and its height stored in an array. | |
1746 * We also have the cursor's current X position on its line (but its line may be offscreen) */ | |
1747 | |
1748 if (dy) // If we're sending the cursor up/down some lines... | |
1749 { | |
1750 editor->cursor.line = editor->cursor.line+dy; // Change cursor line | |
1751 | |
1752 if (editor->cursor.line >= editor->numLines ) // Make sure line cursor is on doesn't go beyond... | |
1753 editor->cursor.line = editor->numLines-1; // ...last line of editor... | |
1754 | |
1755 if (editor->cursor.line < 0) // ...or above... | |
1756 editor->cursor.line = 0; // ...first line of editor | |
1757 | |
1758 /* In read-only mode, stop scrolling down when the bottom line of the text | |
1759 * is visible at the bottom of the window */ | |
1760 | |
1761 if (ATB_edit_Mode(editor,ED_MODE_READONLY)) | |
1762 { | |
1763 if (editor->numLines>=editor->linesPerScreen | |
1764 && editor->cursor.line >= (editor->numLines - editor->linesPerScreen)) | |
1765 { | |
1766 editor->cursor.line = (editor->numLines - editor->linesPerScreen); | |
1767 } | |
1768 | |
1769 editor->winStartLine = editor->cursor.line; | |
1770 } | |
1771 } | |
1772 | |
1773 /* Reset all our horizontal variables */ | |
1774 | |
1775 editor->thischar.pos = 0; | |
1776 editor->thischar.lineWidth = 0; | |
1777 editComplete = TRUE; | |
1778 editor->endOfText = FALSE; | |
1779 editor->space.pos = 0; | |
1780 | |
1781 /* Work out how many lines fit on the current screen */ | |
1782 | |
1783 ATB_edit_UpdateCursorPos(editor); | |
1784 lineNo = 0; | |
1785 | |
1786 /* Update the line where we start showing the text on the window */ | |
1787 | |
1788 if (editor->cursor.line < editor->winStartLine) //cursor is on a line before current window screen | |
1789 { | |
1790 editor->winStartLine = editor->cursor.line; | |
1791 editComplete = FALSE; | |
1792 } | |
1793 else if (editor->cursor.line >= (editor->winStartLine+editor->linesPerScreen)) //cursor is below the bottom of the screen | |
1794 { | |
1795 editor->winStartLine = editor->cursor.line-(editor->linesPerScreen-1); | |
1796 editComplete = FALSE; | |
1797 } | |
1798 | |
1799 if (dy!= 0) /* If we're moving up or down */ | |
1800 { | |
1801 editComplete = FALSE; | |
1802 } | |
1803 | |
1804 if (!editComplete) /* Calculate new cursor X and Y positions */ | |
1805 { | |
1806 if (dy!=0) /* If we've changed line, find new X position */ | |
1807 { | |
1808 line = ATB_edit_LineGet(editor, editor->cursor.line); | |
1809 editor->thischar.lineWidth = 0; | |
1810 linePos = line->pos; // Start of current line | |
1811 ATB_display_CopyFormat(&editor->thischar.format, &line->format); // Format attributes of 1st character | |
1812 /* Get column - is always a multiple of the maximum character width. Makes sure cursor doesn't wander | |
1813 * left or right too much when moving up or down by lines */ | |
1814 charMaxWidth = (SHORT)ATB_display_GetMaxCharWidth(&editor->thischar.format); | |
1815 cursorColumn = editor->cursor.x - (editor->cursor.x % charMaxWidth); | |
1816 | |
1817 linePos--; | |
1818 editor->thischar.width = 0; | |
1819 | |
1820 /* SPR#2342 - SH - Improved finding cursor position on adjacent lines. | |
1821 * First search until we're in the column or at the end of the line */ | |
1822 | |
1823 do | |
1824 { | |
1825 linePos++; | |
1826 editor->thischar.lineWidth += editor->thischar.width; | |
1827 character = ATB_string_GetChar(&editor->attr->text, linePos); | |
1828 editor->thischar.width = ATB_display_GetCharWidth(character, &editor->thischar.format); | |
1829 } | |
1830 while (editor->thischar.lineWidth<cursorColumn && linePos < (line->next->pos-1)); | |
1831 | |
1832 /* Is there a character also in the column, but closer to our original character? */ | |
1833 | |
1834 while ((editor->thischar.lineWidth+editor->thischar.width) < (cursorColumn+charMaxWidth) | |
1835 && linePos< (line->next->pos-1) | |
1836 && (editor->cursor.x - editor->thischar.lineWidth)> editor->thischar.width) | |
1837 { | |
1838 linePos++; | |
1839 editor->thischar.lineWidth += editor->thischar.width; | |
1840 character = ATB_string_GetChar(&editor->attr->text, linePos); | |
1841 editor->thischar.width = ATB_display_GetCharWidth(character, &editor->thischar.format); | |
1842 } | |
1843 | |
1844 /* Set the new cursor X position */ | |
1845 cursorCharPos = linePos; // New cursor position in buffer | |
1846 editor->cursor.width = editor->thischar.width; // Set the width of the cursor | |
1847 editor->cursor.x = editor->thischar.lineWidth; // And its position | |
1848 editor->cursor.attr = editor->thischar.format.attr; // Save the format attribute | |
1849 } | |
1850 ATB_edit_UpdateCursorPos(editor); | |
1851 } | |
1852 | |
1853 /* Change cursor position */ | |
1854 | |
1855 editor->cursor.pos = cursorCharPos; | |
1856 | |
1857 return ED_OK; | |
1858 } | |
1859 | |
1860 | |
1861 /******************************************************************************* | |
1862 | |
1863 $Function: ATB_edit_WordWrap | |
1864 | |
1865 $Description: Main word wrap function. Takes in the characters of the string | |
1866 one by one, calculating the total width displayed on screen and setting flags | |
1867 when a string should be wrapped, a carriage return is encountered, the end | |
1868 of string has been reached. | |
1869 | |
1870 Tracks the last space character and goes back there when a word runs over | |
1871 the edge of the screen. Also works out the height of the current line, based on | |
1872 the maximum character height found. | |
1873 | |
1874 $Returns: None | |
1875 | |
1876 $Arguments: editor - The editor data | |
1877 | |
1878 *******************************************************************************/ | |
1879 | |
1880 static void ATB_edit_WordWrap(T_ED_DATA *editor) | |
1881 { | |
1882 USHORT character; | |
1883 int punctuation; | |
1884 T_ED_LINE *line; | |
1885 | |
1886 #ifdef TRACE_ATBEDITOR | |
1887 TRACE_FUNCTION("ATB_edit_WordWrap()"); | |
1888 #endif | |
1889 | |
1890 editor->endOfLine = FALSE; | |
1891 line = ATB_edit_LineGet(editor, editor->numLines); | |
1892 | |
1893 /* Get the character from the buffer */ | |
1894 | |
1895 editor->startPos = editor->thischar.pos; | |
1896 character = ATB_string_GetChar(&editor->attr->text, editor->thischar.pos); | |
1897 | |
1898 /* Find the character's dimensions */ | |
1899 | |
1900 /* If we're multi-tapping a character, or in fixed-width mode, it has the maximum width */ | |
1901 | |
1902 if (editor->multitap && editor->thischar.pos==editor->cursor.pos) | |
1903 editor->thischar.width = ATB_display_GetCharWidth(UNICODE_WIDEST_CHAR, &editor->thischar.format); | |
1904 else | |
1905 editor->thischar.width = ATB_display_GetCharWidth(character, &editor->thischar.format); // Character width | |
1906 | |
1907 editor->thischar.height = ATB_display_GetCharHeight(character, &editor->thischar.format); | |
1908 | |
1909 /* Check to see if last character was a CR/LF */ | |
1910 | |
1911 if (editor->precedingEOL) | |
1912 { | |
1913 editor->endOfLine = TRUE; | |
1914 editor->precedingEOL = FALSE; | |
1915 } | |
1916 else // otherwise, character included on line | |
1917 { | |
1918 if (editor->thischar.height > line->height) // if height>height so far... | |
1919 line->height = editor->thischar.height; // ...adjust the height so far | |
1920 } | |
1921 | |
1922 /* Set flags appropriate for the character */ | |
1923 | |
1924 switch(character) | |
1925 { | |
1926 case UNICODE_EOLN: | |
1927 editor->endOfText = TRUE; // We're at the end of the editor text | |
1928 break; | |
1929 | |
1930 case UNICODE_LINEFEED: | |
1931 case UNICODE_CR: | |
1932 editor->precedingEOL = TRUE; // This is an end of line | |
1933 break; | |
1934 | |
1935 default: | |
1936 break; | |
1937 } | |
1938 | |
1939 /* Check if wrapping required */ | |
1940 | |
1941 if ( (editor->thischar.lineWidth+editor->thischar.width)>editor->attr->win_size.sx ) // Current character will go off edge of editor | |
1942 { | |
1943 editor->endOfLine = TRUE; | |
1944 //Mar 31, 2008 DR:OMAPS00164541 Shubhro (x0082844) -->Start //No need to check for current character, if its a space. | |
1945 #if 0 | |
1946 // If we've found a space, and it's a word wrapping mode */ | |
1947 | |
1948 if (editor->space.pos > 0 && editor->precedingSpace==FALSE | |
1949 && !ATB_edit_Mode(editor, ED_MODE_OVERWRITE)) | |
1950 { | |
1951 editor->thischar.pos = editor->space.pos; // reset character position back to here | |
1952 editor->startPos = editor->space.pos; // character is space, so start of block=character pos | |
1953 editor->thischar.width = editor->space.width; | |
1954 editor->thischar.height = editor->space.height; | |
1955 ATB_display_CopyFormat(&editor->thischar.format,&editor->space.format); | |
1956 line->height = editor->space.lineHeight; | |
1957 editor->endOfText = FALSE; // If we're wrapping on an EOLN, we've gone back | |
1958 } | |
1959 editor->space.pos = 0; // Reset space position to start of line | |
1960 editor->precedingSpace = FALSE; | |
1961 #endif | |
1962 } | |
1963 #if 0 | |
1964 else | |
1965 { | |
1966 if (editor->precedingSpace) // Remember enough info so that this point can be restored | |
1967 { | |
1968 editor->space.pos = editor->startPos; // Store position of start of current block, or just character pos. | |
1969 editor->space.width = editor->thischar.width; | |
1970 editor->space.height = editor->thischar.height; | |
1971 ATB_display_CopyFormat(&editor->space.format,&editor->thischar.format); | |
1972 editor->space.lineHeight = line->height; | |
1973 editor->precedingSpace = FALSE; | |
1974 } | |
1975 | |
1976 punctuation = FALSE; | |
1977 if (character==UNICODE_SPACE) // Wrap only on spaces | |
1978 { | |
1979 punctuation = TRUE; | |
1980 } | |
1981 | |
1982 if ((punctuation) && (editor->thischar.lineWidth > 0)) //A space is a good point for a soft break | |
1983 { | |
1984 editor->precedingSpace = TRUE; | |
1985 } | |
1986 } | |
1987 #endif | |
1988 //Mar 31, 2008 DR:OMAPS00164541 Shubhro (x0082844) -->End | |
1989 | |
1990 return; | |
1991 } | |
1992 | |
1993 | |
1994 /******************************************************************************* | |
1995 | |
1996 $Function: ATB_edit_UpdateCursorPos | |
1997 | |
1998 $Description: Update the cursor's vertical position, based on its position within | |
1999 the string. | |
2000 | |
2001 $Returns: None | |
2002 | |
2003 $Arguments: editor - The editor data | |
2004 | |
2005 *******************************************************************************/ | |
2006 | |
2007 static void ATB_edit_UpdateCursorPos(T_ED_DATA *editor) | |
2008 { | |
2009 USHORT lineNo; | |
2010 USHORT lineHeight; | |
2011 USHORT editHeight = editor->attr->win_size.sy; | |
2012 T_ED_LINE *line; | |
2013 | |
2014 #ifdef TRACE_ATBEDITOR | |
2015 TRACE_FUNCTION("ATB_edit_UpdateCursorPos()"); | |
2016 #endif | |
2017 | |
2018 editor->cursor.y = 0; // Recalculate cursor Y position... | |
2019 editor->viewHeight = 0; // ...and height of viewable screen... | |
2020 editor->totalHeight = 0; // ...and total height of screen... | |
2021 editor->viewStartPos = 0; // ...and the start pixel position of the view... | |
2022 editor->linesPerScreen = 0; // ...and number of lines to the screen | |
2023 lineNo = 0; | |
2024 | |
2025 while (lineNo<editor->numLines) | |
2026 { | |
2027 line = ATB_edit_LineGet(editor, lineNo); | |
2028 | |
2029 lineHeight = line->height; | |
2030 | |
2031 if (lineNo==editor->cursor.line) | |
2032 editor->cursor.y = editor->viewHeight; // Y position of cursor | |
2033 | |
2034 if (lineNo==editor->winStartLine) // starting posn rel to start of editor text | |
2035 editor->viewStartPos = editor->totalHeight; | |
2036 | |
2037 if (lineNo>=editor->winStartLine && (editor->viewHeight+lineHeight)<=editHeight) | |
2038 { | |
2039 editor->viewHeight += lineHeight; | |
2040 editor->linesPerScreen++; | |
2041 } | |
2042 | |
2043 editor->totalHeight += lineHeight; | |
2044 lineNo++; | |
2045 } | |
2046 | |
2047 line = ATB_edit_LineGet(editor, editor->cursor.line); | |
2048 editor->cursor.height = line->height; // Change its height | |
2049 | |
2050 return; | |
2051 } | |
2052 | |
2053 | |
2054 /************************************/ | |
2055 /* GLOBAL PROCEDURES */ | |
2056 /* Add/removing words in the editor */ | |
2057 /************************************/ | |
2058 | |
2059 /******************************************************************************* | |
2060 | |
2061 $Function: ATB_edit_InsertString | |
2062 | |
2063 $Description: Insert a string at the cursor. | |
2064 | |
2065 $Returns: ED_BAD_HANDLE - Editor data pointer is null | |
2066 ED_OK - OK | |
2067 | |
2068 $Arguments: editor - The editor data | |
2069 insText - The text to insert | |
2070 | |
2071 *******************************************************************************/ | |
2072 | |
2073 ED_RES ATB_edit_InsertString (T_ED_DATA *editor, T_ATB_TEXT *insText) | |
2074 { | |
2075 T_ATB_TEXT *text; | |
2076 int textIndex; | |
2077 USHORT character; | |
2078 | |
2079 TRACE_FUNCTION("ATB_edit_InsertString()"); | |
2080 | |
2081 if (!editor) // Make sure editor exists | |
2082 return ED_BAD_HANDLE; | |
2083 | |
2084 if (insText==NULL || insText->len==0) | |
2085 return ED_OK; /* No string to insert - trivial operation. */ | |
2086 | |
2087 if (ATB_edit_Mode(editor, ED_MODE_READONLY) ) /* Don't insert in read-only mode*/ | |
2088 return ED_ERROR; | |
2089 | |
2090 text = &editor->attr->text; | |
2091 | |
2092 if ((text->len+insText->len) >= editor->attr->size) | |
2093 return ED_ERROR; /* String too long */ | |
2094 | |
2095 /* Move text up by the length of insText */ | |
2096 | |
2097 ATB_string_MoveRight(text, editor->cursor.pos, insText->len, editor->attr->size); | |
2098 | |
2099 /* Copy string into buffer */ | |
2100 | |
2101 for (textIndex=0; textIndex<insText->len; textIndex++) | |
2102 { | |
2103 character = ATB_string_GetChar(insText, textIndex); | |
2104 ATB_string_SetChar(text, editor->cursor.pos+textIndex, character); | |
2105 } | |
2106 | |
2107 editor->cursor.pos = editor->cursor.pos+insText->len; | |
2108 | |
2109 /* Reformat updated text */ | |
2110 | |
2111 ATB_edit_Update(editor, 0); | |
2112 | |
2113 return ED_OK; | |
2114 } | |
2115 | |
2116 | |
2117 /******************************************************************************* | |
2118 | |
2119 $Function: ATB_edit_GetCursorChar | |
2120 | |
2121 $Description: Return the character at a position offset from the current cursor | |
2122 position by the value supplied. | |
2123 | |
2124 $Returns: The character, or UNICODE_EOLN if goes beyond bounds of string. | |
2125 | |
2126 $Arguments: editor - The editor data | |
2127 offset - The offset from the current cursor position from which | |
2128 to get the character | |
2129 | |
2130 *******************************************************************************/ | |
2131 | |
2132 USHORT ATB_edit_GetCursorChar(T_ED_DATA *editor, int offset) | |
2133 { | |
2134 USHORT textIndex; | |
2135 USHORT character; | |
2136 | |
2137 TRACE_FUNCTION("ATB_edit_GetCursorChar"); | |
2138 | |
2139 textIndex = editor->cursor.pos+offset; | |
2140 | |
2141 /*a0393213 warnings removal-pointless comparison of unsigned integer with zero*/ | |
2142 if (textIndex > editor->attr->text.len) | |
2143 character = UNICODE_EOLN; | |
2144 else | |
2145 character = ATB_string_GetChar(&editor->attr->text, textIndex); | |
2146 | |
2147 return character; | |
2148 } | |
2149 | |
2150 | |
2151 /******************************************************************************* | |
2152 | |
2153 $Function: ATB_edit_CapitaliseWord | |
2154 | |
2155 $Description: Returns TRUE if next word after cursor ought to be capitalised | |
2156 | |
2157 $Returns: None. | |
2158 | |
2159 $Arguments: editor - The editor data | |
2160 | |
2161 *******************************************************************************/ | |
2162 | |
2163 BOOL ATB_edit_CapitaliseWord(T_ED_DATA *editor) | |
2164 { | |
2165 USHORT LastChar; | |
2166 USHORT CharBefore; | |
2167 | |
2168 /* First check to see if first word is to be capitalised */ | |
2169 | |
2170 if (editor->textcase==ED_CASE_CAPS) | |
2171 return TRUE; | |
2172 | |
2173 /* If not, look at preceding characters */ | |
2174 | |
2175 LastChar = ATB_edit_GetCursorChar(editor, -1); | |
2176 CharBefore = ATB_edit_GetCursorChar(editor, -2); | |
2177 | |
2178 if (LastChar==UNICODE_FULLSTOP || LastChar==UNICODE_EXCLAMATION | |
2179 || LastChar==UNICODE_QUESTION || LastChar==UNICODE_EOLN) | |
2180 return TRUE; | |
2181 | |
2182 if (LastChar==UNICODE_SPACE) | |
2183 if(CharBefore==UNICODE_FULLSTOP || CharBefore==UNICODE_EXCLAMATION || CharBefore==UNICODE_QUESTION) | |
2184 return TRUE; | |
2185 | |
2186 return FALSE; | |
2187 } | |
2188 | |
2189 /******************************************************************************* | |
2190 | |
2191 $Function: ATB_edit_FindCapital | |
2192 | |
2193 $Description: returns the code of the input char converted to a capital. If char has no | |
2194 upper case equivalent returns original char. | |
2195 Added for issue 1508 | |
2196 | |
2197 $Returns: UBYTE | |
2198 | |
2199 $Arguments: char | |
2200 | |
2201 *******************************************************************************/ | |
2202 | |
2203 USHORT ATB_edit_FindCapital(USHORT small_char) | |
2204 { char ascii_code= ATB_char_Ascii(small_char); | |
2205 | |
2206 | |
2207 /*if "normal" character*/ | |
2208 if (ascii_code>96 && ascii_code< 123) | |
2209 return (ATB_char_Unicode(ascii_code - 0x20)); | |
2210 | |
2211 switch ((UCHAR)ascii_code) /*a0393213 lint warnings removal - typecast done*/ | |
2212 { | |
2213 /* x0045876, 14-Aug-2006 (WR - statment unreachable) */ | |
2214 case (130): return ATB_char_Unicode((char)154); /* break; */ /*U with umlaut*/ | |
2215 case (132): return ATB_char_Unicode((char)142); /* break; */ /*A with umlaut*/ | |
2216 case (148): return ATB_char_Unicode((char)153); /* break; */ /*O with umlaut*/ | |
2217 default: return ATB_char_Unicode(ascii_code); | |
2218 } | |
2219 | |
2220 } | |
2221 /******************************************************************************* | |
2222 | |
2223 $Function: ATB_edit_HiddenInit | |
2224 | |
2225 $Description: Initialize editor for hidden mode. | |
2226 | |
2227 $Returns: None. | |
2228 | |
2229 $Arguments: editor - The editor data | |
2230 | |
2231 *******************************************************************************/ | |
2232 | |
2233 ED_RES ATB_edit_HiddenInit(T_ED_DATA *editor) | |
2234 { | |
2235 USHORT len = editor->attr->text.len; | |
2236 | |
2237 TRACE_FUNCTION("ATB_edit_HiddenInit()"); | |
2238 | |
2239 if (!editor) | |
2240 return ED_BAD_HANDLE; // element does not exist | |
2241 if (editor->hiddenText) | |
2242 return ED_ERROR; | |
2243 | |
2244 /* get memory for the temporary buffer */ | |
2245 editor->hiddenText = (T_ATB_TEXT *) ATB_mem_Alloc(sizeof(T_ATB_TEXT)); | |
2246 editor->hiddenText->len = 0; | |
2247 editor->hiddenText->data = (UBYTE *)ATB_mem_Alloc(editor->attr->size*ATB_string_Size(&editor->attr->text)); | |
2248 | |
2249 /* copy text to the temporary buffer */ | |
2250 ATB_string_Copy(editor->hiddenText, &editor->attr->text); | |
2251 | |
2252 /* overwrite the string in the editor buffer with stars */ | |
2253 memset(editor->attr->text.data,'\0',editor->attr->size*ATB_string_Size(&editor->attr->text)); /* Clear buffer */ | |
2254 editor->attr->text.len = 0; | |
2255 ATB_edit_Reset(editor); /* Send cursor to start */ | |
2256 | |
2257 while (editor->attr->text.len < len) | |
2258 ATB_edit_AsciiChar(editor,'*',FALSE); | |
2259 | |
2260 return ED_OK; | |
2261 } | |
2262 | |
2263 | |
2264 /******************************************************************************* | |
2265 | |
2266 $Function: ATB_edit_HiddenExit | |
2267 | |
2268 $Description: Deinitialize editor for hidden mode. | |
2269 | |
2270 $Returns: None. | |
2271 | |
2272 $Arguments: editor - The editor data | |
2273 | |
2274 *******************************************************************************/ | |
2275 | |
2276 ED_RES ATB_edit_HiddenExit(T_ED_DATA *editor) | |
2277 { | |
2278 TRACE_FUNCTION("ATB_edit_HiddenExit()"); | |
2279 | |
2280 if (!editor) | |
2281 return ED_BAD_HANDLE; // element does not exist | |
2282 if (!editor->hiddenText) | |
2283 return ED_ERROR; | |
2284 | |
2285 /* For hidden mode, copy the hidden text into the buffer & free memory */ | |
2286 ATB_string_Copy(&editor->attr->text, editor->hiddenText); | |
2287 ATB_mem_Free ((void *)editor->hiddenText->data, editor->attr->size*ATB_string_Size(editor->hiddenText)); | |
2288 ATB_mem_Free ((void *)editor->hiddenText, sizeof(T_ATB_TEXT)); | |
2289 editor->hiddenText = NULL; | |
2290 | |
2291 /* x0045876, 14-Aug-2006 (WR - "ATB_edit_HiddenExit" should return a value) */ | |
2292 return ED_DONE; | |
2293 } | |
2294 | |
2295 | |
2296 /******************************************************************************* | |
2297 | |
2298 $Function: ATB_edit_Mode | |
2299 | |
2300 $Description: Returns TRUE if the appropriate bits are set in the editor mode | |
2301 | |
2302 $Returns: None. | |
2303 | |
2304 $Arguments: editor - The editor data | |
2305 mode - The mode bits to check | |
2306 | |
2307 *******************************************************************************/ | |
2308 | |
2309 void ATB_edit_SetAttr(T_ED_DATA *editor, T_ATB_WIN_SIZE *win_size, ULONG colour, UBYTE font, USHORT mode, USHORT cursor, T_ATB_TEXT *text, USHORT size) | |
2310 { | |
2311 memcpy(&editor->attr->win_size, win_size, sizeof(T_ATB_WIN_SIZE)); | |
2312 editor->attr->colour = colour; | |
2313 editor->attr->font = font; | |
2314 editor->attr->cursor = cursor; | |
2315 editor->attr->mode = mode; | |
2316 memcpy(&editor->attr->text, text, sizeof(T_ATB_TEXT)); | |
2317 editor->attr->size = size; | |
2318 | |
2319 return; | |
2320 } | |
2321 | |
2322 | |
2323 /******************************************************************************* | |
2324 | |
2325 $Function: ATB_edit_Mode | |
2326 | |
2327 $Description: Returns TRUE if the appropriate bits are set in the editor mode | |
2328 | |
2329 $Returns: None. | |
2330 | |
2331 $Arguments: editor - The editor data | |
2332 mode - The mode bits to check | |
2333 | |
2334 *******************************************************************************/ | |
2335 | |
2336 UBYTE ATB_edit_Mode(T_ED_DATA *editor, USHORT mode) | |
2337 { | |
2338 UBYTE result; | |
2339 | |
2340 if (editor->attr->mode & mode) | |
2341 result = TRUE; | |
2342 else | |
2343 result = FALSE; | |
2344 | |
2345 return result; | |
2346 } | |
2347 | |
2348 | |
2349 /******************************************************************************* | |
2350 | |
2351 $Function: ATB_edit_SetMode | |
2352 | |
2353 $Description: Sets the appropriate bits in the editor mode | |
2354 | |
2355 $Returns: None. | |
2356 | |
2357 $Arguments: editor - The editor data | |
2358 mode - The mode bits to set | |
2359 | |
2360 *******************************************************************************/ | |
2361 | |
2362 void ATB_edit_SetMode(T_ED_DATA *editor, USHORT mode) | |
2363 { | |
2364 editor->attr->mode |= mode; | |
2365 | |
2366 return; | |
2367 } | |
2368 | |
2369 | |
2370 /******************************************************************************* | |
2371 | |
2372 $Function: ATB_edit_ResetMode | |
2373 | |
2374 $Description: Resets the appropriate bits in the editor mode | |
2375 | |
2376 $Returns: None. | |
2377 | |
2378 $Arguments: editor - The editor data | |
2379 mode - The mode bits to reset | |
2380 | |
2381 *******************************************************************************/ | |
2382 | |
2383 void ATB_edit_ResetMode(T_ED_DATA *editor, USHORT mode) | |
2384 { | |
2385 editor->attr->mode &= (~mode); | |
2386 | |
2387 return; | |
2388 } | |
2389 | |
2390 | |
2391 /******************************************************************************* | |
2392 | |
2393 $Function: ATB_edit_SetStyle | |
2394 | |
2395 $Description: Sets the appropriate bits in the editor style | |
2396 | |
2397 $Returns: None. | |
2398 | |
2399 $Arguments: editor - The editor data | |
2400 format - The format bits to set | |
2401 | |
2402 *******************************************************************************/ | |
2403 | |
2404 void ATB_edit_SetStyle(T_ED_DATA *editor, USHORT style) | |
2405 { | |
2406 UBYTE mask; | |
2407 | |
2408 mask = 0; | |
2409 | |
2410 switch(style) | |
2411 { | |
2412 case DS_ALIGN_LEFT: | |
2413 case DS_ALIGN_RIGHT: | |
2414 case DS_ALIGN_CENTRE: | |
2415 mask = DS_ALIGN_RIGHT | DS_ALIGN_CENTRE; | |
2416 break; | |
2417 } | |
2418 | |
2419 /* Switch off previous format */ | |
2420 editor->attr->startFormat.attr &= (~mask); | |
2421 /* Switch on new format */ | |
2422 editor->attr->startFormat.attr |= style; | |
2423 | |
2424 return; | |
2425 } | |
2426 | |
2427 /******************************************************************************* | |
2428 | |
2429 $Function: ATB_edit_ResetFormat | |
2430 | |
2431 $Description: Resets the appropriate bits in the editor format | |
2432 | |
2433 $Returns: None. | |
2434 | |
2435 $Arguments: editor - The editor data | |
2436 format - The format bits to reset | |
2437 | |
2438 *******************************************************************************/ | |
2439 | |
2440 void ATB_edit_ResetFormat(T_ED_DATA *editor, USHORT format) | |
2441 { | |
2442 editor->attr->startFormat.attr &= (~format); | |
2443 | |
2444 return; | |
2445 } | |
2446 | |
2447 | |
2448 /******************************************************************************* | |
2449 | |
2450 $Function: ATB_edit_GetCase | |
2451 | |
2452 $Description: Returns the currently selected text case | |
2453 | |
2454 $Returns: ED_CASE_UPPER | |
2455 ED_CASE_LOWER | |
2456 ED_CASE_CAPS | |
2457 ED_CASE_NUM | |
2458 ED_CASE_NONE | |
2459 | |
2460 $Arguments: editor - The editor data | |
2461 | |
2462 *******************************************************************************/ | |
2463 | |
2464 UBYTE ATB_edit_GetCase(T_ED_DATA *editor) | |
2465 { | |
2466 return (UBYTE)editor->textcase; | |
2467 } | |
2468 | |
2469 | |
2470 /******************************************************************************* | |
2471 | |
2472 $Function: ATB_edit_SetCase | |
2473 | |
2474 $Description: Changes the currently selected text case | |
2475 | |
2476 $Returns: None | |
2477 | |
2478 $Arguments: editor - The editor data | |
2479 textcase - Case to select. One of: | |
2480 ED_CASE_UPPER | |
2481 ED_CASE_LOWER | |
2482 ED_CASE_CAPS | |
2483 ED_CASE_NUM | |
2484 ED_CASE_NONE | |
2485 | |
2486 *******************************************************************************/ | |
2487 | |
2488 void ATB_edit_SetCase(T_ED_DATA *editor, UBYTE textcase) | |
2489 { | |
2490 editor->textcase = textcase; | |
2491 return; | |
2492 } | |
2493 | |
2494 | |
2495 /******************************************************************************* | |
2496 | |
2497 $Function: ATB_edit_LineGet | |
2498 | |
2499 $Description: Get the pointer to the requested line in the linked list | |
2500 | |
2501 $Returns: The required line structure | |
2502 | |
2503 $Arguments: editor - The text editor | |
2504 lineNo - The line required | |
2505 | |
2506 *******************************************************************************/ | |
2507 | |
2508 T_ED_LINE *ATB_edit_LineGet(T_ED_DATA *editor, SHORT lineNo) | |
2509 { | |
2510 T_ED_LINE *line = editor->line; | |
2511 SHORT thisLineNo; | |
2512 | |
2513 thisLineNo = 0; | |
2514 if (lineNo<0) | |
2515 lineNo = 0; | |
2516 | |
2517 /* If the first line doesn't exist... */ | |
2518 | |
2519 if (line==NULL) | |
2520 { | |
2521 editor->line = (T_ED_LINE *)ATB_mem_Alloc(sizeof(T_ED_LINE)); | |
2522 memset(editor->line, 0, sizeof(T_ED_LINE)); | |
2523 editor->line->next = NULL; | |
2524 line = editor->line; | |
2525 } | |
2526 | |
2527 /* Search for the line required */ | |
2528 | |
2529 while (thisLineNo<lineNo) | |
2530 { | |
2531 if (line->next==NULL) | |
2532 { | |
2533 line->next = (T_ED_LINE *)ATB_mem_Alloc(sizeof(T_ED_LINE)); | |
2534 memset(line->next, 0, sizeof(T_ED_LINE)); | |
2535 line->next->next = NULL; | |
2536 } | |
2537 line = line->next; | |
2538 lineNo--; | |
2539 } | |
2540 | |
2541 return line; | |
2542 } | |
2543 | |
2544 | |
2545 /******************************************************************************* | |
2546 | |
2547 $Function: ATB_edit_LineDestroyAll | |
2548 | |
2549 $Description: Destroy all entries in the line linked list | |
2550 | |
2551 $Returns: None | |
2552 | |
2553 $Arguments: editor - The text editor | |
2554 | |
2555 *******************************************************************************/ | |
2556 | |
2557 static void ATB_edit_LineDestroyAll(T_ED_DATA *editor) | |
2558 { | |
2559 T_ED_LINE *line = editor->line; | |
2560 T_ED_LINE *newLine; | |
2561 | |
2562 while (line!=NULL) | |
2563 { | |
2564 newLine = line->next; | |
2565 ATB_mem_Free((void *)line, sizeof(T_ED_LINE)); | |
2566 line = newLine; | |
2567 } | |
2568 | |
2569 return; | |
2570 } | |
2571 #endif |