1 |
|
|
/*************************************************************************** |
2 |
|
|
* Copyright (c) 2024 Microsoft Corporation |
3 |
|
|
* Copyright (c) 2026-present Eclipse ThreadX contributors |
4 |
|
|
* |
5 |
|
|
* This program and the accompanying materials are made available under the |
6 |
|
|
* terms of the MIT License which is available at |
7 |
|
|
* https://opensource.org/licenses/MIT. |
8 |
|
|
* |
9 |
|
|
* SPDX-License-Identifier: MIT |
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_window.h" |
30 |
|
|
#include "gx_multi_line_text_input.h" |
31 |
|
|
#include "gx_multi_line_text_view.h" |
32 |
|
|
#include "gx_text_input_cursor.h" |
33 |
|
|
|
34 |
|
|
/**************************************************************************/ |
35 |
|
|
/* */ |
36 |
|
|
/* FUNCTION RELEASE */ |
37 |
|
|
/* */ |
38 |
|
|
/* _gx_multi_line_text_input_end PORTABLE C */ |
39 |
|
|
/* 6.1 */ |
40 |
|
|
/* AUTHOR */ |
41 |
|
|
/* */ |
42 |
|
|
/* Kenneth Maxwell, Microsoft Corporation */ |
43 |
|
|
/* */ |
44 |
|
|
/* DESCRIPTION */ |
45 |
|
|
/* */ |
46 |
|
|
/* This function deletes a character after the cursor. */ |
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_multi_line_text_input_cursor_pos_calculate */ |
60 |
|
|
/* Calculate cursor position */ |
61 |
|
|
/* according to click point */ |
62 |
|
|
/* _gx_multi_line_text_input_cursor_rectangle_define */ |
63 |
|
|
/* Define a rectangle for the */ |
64 |
|
|
/* cursor */ |
65 |
|
|
/* _gx_system_dirty_partial_add Add one dirty area to */ |
66 |
|
|
/* dirty list */ |
67 |
|
|
/* */ |
68 |
|
|
/* CALLED BY */ |
69 |
|
|
/* */ |
70 |
|
|
/* _gx_multi_line_text_input_keydown_process */ |
71 |
|
|
/* */ |
72 |
|
|
/**************************************************************************/ |
73 |
|
269 |
UINT _gx_multi_line_text_input_end(GX_MULTI_LINE_TEXT_INPUT *text_input) |
74 |
|
|
{ |
75 |
|
269 |
GX_TEXT_INPUT_CURSOR *cursor_ptr = &text_input -> gx_multi_line_text_input_cursor_instance; |
76 |
|
|
GX_POINT cur_pos; |
77 |
|
|
GX_RECTANGLE cur_rect; |
78 |
|
|
UINT line_end_index; |
79 |
|
|
UINT line_cache_start; |
80 |
|
|
UINT index; |
81 |
|
|
|
82 |
✓✓ |
269 |
if (text_input -> gx_multi_line_text_input_start_mark != text_input -> gx_multi_line_text_input_end_mark) |
83 |
|
|
{ |
84 |
|
70 |
_gx_multi_line_text_input_right_arrow(text_input); |
85 |
|
|
} |
86 |
|
|
|
87 |
|
269 |
cur_pos = cursor_ptr -> gx_text_input_cursor_pos; |
88 |
|
|
|
89 |
|
269 |
_gx_text_input_cursor_dirty_rectangle_get(&text_input -> gx_multi_line_text_input_cursor_instance, &cur_rect); |
90 |
|
|
|
91 |
|
269 |
cur_pos.gx_point_x = (GX_VALUE)(text_input -> gx_window_client.gx_rectangle_right - |
92 |
|
269 |
text_input -> gx_multi_line_text_view_whitespace); |
93 |
|
|
|
94 |
|
|
/* Calculate new cursor position. */ |
95 |
|
269 |
_gx_multi_line_text_input_cursor_pos_calculate(text_input, cur_pos); |
96 |
|
|
|
97 |
|
|
/* Calcualte insert position, consider the situation that there are some whitespaces in the end of |
98 |
|
|
cursor line. */ |
99 |
|
269 |
line_cache_start = text_input -> gx_multi_line_text_view_first_cache_line; |
100 |
|
|
|
101 |
|
269 |
index = text_input -> gx_multi_line_text_input_text_cursor_line - 1; |
102 |
|
|
|
103 |
✓✓ |
269 |
if ((INT)(index - line_cache_start) >= (INT)(text_input -> gx_multi_line_text_view_cache_size - 1)) |
104 |
|
|
{ |
105 |
|
66 |
line_end_index = text_input -> gx_multi_line_text_view_text.gx_string_length; |
106 |
|
|
} |
107 |
|
|
else |
108 |
|
|
{ |
109 |
|
203 |
line_end_index = text_input -> gx_multi_line_text_view_line_index[index - line_cache_start + 1]; |
110 |
|
|
} |
111 |
|
269 |
text_input -> gx_multi_line_text_input_text_insert_position = line_end_index; |
112 |
|
|
|
113 |
✓✓ |
269 |
if (cur_rect.gx_rectangle_left != cursor_ptr -> gx_text_input_cursor_pos.gx_point_x) |
114 |
|
|
{ |
115 |
|
|
/* Mark old cursor rectangle dirty. */ |
116 |
|
140 |
_gx_system_dirty_partial_add((GX_WIDGET *)text_input, &cur_rect); |
117 |
|
|
|
118 |
|
|
/* Mark new cursor rectangle dirty. */ |
119 |
|
140 |
_gx_text_input_cursor_dirty_rectangle_get(&text_input -> gx_multi_line_text_input_cursor_instance, &cur_rect); |
120 |
|
140 |
_gx_system_dirty_partial_add((GX_WIDGET *)text_input, &cur_rect); |
121 |
|
|
} |
122 |
|
|
|
123 |
|
269 |
return GX_SUCCESS; |
124 |
|
|
} |
125 |
|
|
|