1 /**************************************************************************/
2 /*                                                                        */
3 /*       Copyright (c) Microsoft Corporation. All rights reserved.        */
4 /*                                                                        */
5 /*       This software is licensed under the Microsoft Software License   */
6 /*       Terms for Microsoft Azure RTOS. Full text of the license can be  */
7 /*       found in the LICENSE file at https://aka.ms/AzureRTOS_EULA       */
8 /*       and in the root directory of this software.                      */
9 /*                                                                        */
10 /**************************************************************************/
11 
12 
13 /**************************************************************************/
14 /**************************************************************************/
15 /**                                                                       */
16 /** GUIX Component                                                        */
17 /**                                                                       */
18 /**   Multi Line Text Input                                               */
19 /**                                                                       */
20 /**************************************************************************/
21 
22 #define GX_SOURCE_CODE
23 
24 
25 /* Include necessary system files.  */
26 
27 #include "gx_api.h"
28 #include "gx_system.h"
29 #include "gx_multi_line_text_input.h"
30 #include "gx_multi_line_text_view.h"
31 #include "gx_text_input_cursor.h"
32 
33 /**************************************************************************/
34 /*                                                                        */
35 /*  FUNCTION                                               RELEASE        */
36 /*                                                                        */
37 /*    _gx_multi_line_text_input_mark_end                  PORTABLE C      */
38 /*                                                           6.1          */
39 /*  AUTHOR                                                                */
40 /*                                                                        */
41 /*    Kenneth Maxwell, Microsoft Corporation                              */
42 /*                                                                        */
43 /*  DESCRIPTION                                                           */
44 /*                                                                        */
45 /*    This function moves the end mark of highligh text to the end        */
46 /*    of the line.                                                        */
47 /*                                                                        */
48 /*  INPUT                                                                 */
49 /*                                                                        */
50 /*    text_input                            Multi line text input         */
51 /*                                            control block               */
52 /*                                                                        */
53 /*  OUTPUT                                                                */
54 /*                                                                        */
55 /*    None                                                                */
56 /*                                                                        */
57 /*  CALLS                                                                 */
58 /*                                                                        */
59 /*    _gx_text_input_cursor_dirty_rectangle_get                           */
60 /*                                          Retrieve cursor rectangle     */
61 /*    _gx_multi_line_text_input_cursor_pos_calculate                      */
62 /*                                          Calculate cursor position     */
63 /*                                            according to click point    */
64 /*    _gx_multi_line_text_input_text_rectangle_get                        */
65 /*                                          Retrieve text rectangle       */
66 /*                                            between specified positions */
67 /*    _gx_system_dirty_partial_add          Mark specified area dirty     */
68 /*    _gx_system_dirty_mark                 Mark specified widget dirty   */
69 /*                                                                        */
70 /*  CALLED BY                                                             */
71 /*                                                                        */
72 /*    _gx_multi_line_text_input_keydown_process                           */
73 /*                                                                        */
74 /*  RELEASE HISTORY                                                       */
75 /*                                                                        */
76 /*    DATE              NAME                      DESCRIPTION             */
77 /*                                                                        */
78 /*  05-19-2020     Kenneth Maxwell          Initial Version 6.0           */
79 /*  09-30-2020     Kenneth Maxwell          Modified comment(s),          */
80 /*                                            resulting in version 6.1    */
81 /*                                                                        */
82 /**************************************************************************/
_gx_multi_line_text_input_mark_end(GX_MULTI_LINE_TEXT_INPUT * text_input)83 UINT _gx_multi_line_text_input_mark_end(GX_MULTI_LINE_TEXT_INPUT *text_input)
84 {
85 GX_TEXT_INPUT_CURSOR *cursor_ptr = &text_input -> gx_multi_line_text_input_cursor_instance;
86 GX_POINT              old_cursor_pos;
87 GX_POINT              cursor_pos;
88 GX_RECTANGLE          cursor_rect;
89 INT                   shift;
90 UINT                  start_mark = text_input -> gx_multi_line_text_input_start_mark;
91 UINT                  end_mark = text_input -> gx_multi_line_text_input_end_mark;
92 
93     old_cursor_pos = cursor_ptr -> gx_text_input_cursor_pos;
94     if (start_mark == end_mark)
95     {
96         start_mark = text_input -> gx_multi_line_text_input_text_insert_position;
97         end_mark = text_input -> gx_multi_line_text_input_text_insert_position;
98 
99         text_input -> gx_multi_line_text_input_start_mark = start_mark;
100         text_input -> gx_multi_line_text_input_end_mark = end_mark;
101     }
102 
103     cursor_pos = old_cursor_pos;
104     cursor_pos.gx_point_x = (GX_VALUE)(text_input -> gx_window_client.gx_rectangle_right -
105                                        text_input -> gx_multi_line_text_view_whitespace);
106 
107     shift = text_input -> gx_multi_line_text_view_text_scroll_shift;
108 
109     /* Calculate new cursor position. */
110     _gx_multi_line_text_input_cursor_pos_calculate(text_input, cursor_pos);
111 
112     text_input -> gx_multi_line_text_input_end_mark = text_input -> gx_multi_line_text_input_text_insert_position;
113     if (shift == text_input -> gx_multi_line_text_view_text_scroll_shift)
114     {
115         _gx_multi_line_text_input_text_rectangle_get(text_input, old_cursor_pos, cursor_ptr -> gx_text_input_cursor_pos, &cursor_rect);
116 
117         /* Mark highlight area as dirty. */
118         _gx_system_dirty_partial_add((GX_WIDGET *)text_input, &cursor_rect);
119     }
120     else
121     {
122         _gx_system_dirty_mark((GX_WIDGET *)text_input);
123     }
124 
125     return GX_SUCCESS;
126 }
127 
128