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_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 |
|
|
/**************************************************************************/ |
75 |
|
63 |
UINT _gx_multi_line_text_input_mark_end(GX_MULTI_LINE_TEXT_INPUT *text_input) |
76 |
|
|
{ |
77 |
|
63 |
GX_TEXT_INPUT_CURSOR *cursor_ptr = &text_input -> gx_multi_line_text_input_cursor_instance; |
78 |
|
|
GX_POINT old_cursor_pos; |
79 |
|
|
GX_POINT cursor_pos; |
80 |
|
|
GX_RECTANGLE cursor_rect; |
81 |
|
|
INT shift; |
82 |
|
63 |
UINT start_mark = text_input -> gx_multi_line_text_input_start_mark; |
83 |
|
63 |
UINT end_mark = text_input -> gx_multi_line_text_input_end_mark; |
84 |
|
|
|
85 |
|
63 |
old_cursor_pos = cursor_ptr -> gx_text_input_cursor_pos; |
86 |
✓✓ |
63 |
if (start_mark == end_mark) |
87 |
|
|
{ |
88 |
|
27 |
start_mark = text_input -> gx_multi_line_text_input_text_insert_position; |
89 |
|
27 |
end_mark = text_input -> gx_multi_line_text_input_text_insert_position; |
90 |
|
|
|
91 |
|
27 |
text_input -> gx_multi_line_text_input_start_mark = start_mark; |
92 |
|
27 |
text_input -> gx_multi_line_text_input_end_mark = end_mark; |
93 |
|
|
} |
94 |
|
|
|
95 |
|
63 |
cursor_pos = old_cursor_pos; |
96 |
|
63 |
cursor_pos.gx_point_x = (GX_VALUE)(text_input -> gx_window_client.gx_rectangle_right - |
97 |
|
63 |
text_input -> gx_multi_line_text_view_whitespace); |
98 |
|
|
|
99 |
|
63 |
shift = text_input -> gx_multi_line_text_view_text_scroll_shift; |
100 |
|
|
|
101 |
|
|
/* Calculate new cursor position. */ |
102 |
|
63 |
_gx_multi_line_text_input_cursor_pos_calculate(text_input, cursor_pos); |
103 |
|
|
|
104 |
|
63 |
text_input -> gx_multi_line_text_input_end_mark = text_input -> gx_multi_line_text_input_text_insert_position; |
105 |
✓✓ |
63 |
if (shift == text_input -> gx_multi_line_text_view_text_scroll_shift) |
106 |
|
|
{ |
107 |
|
39 |
_gx_multi_line_text_input_text_rectangle_get(text_input, old_cursor_pos, cursor_ptr -> gx_text_input_cursor_pos, &cursor_rect); |
108 |
|
|
|
109 |
|
|
/* Mark highlight area as dirty. */ |
110 |
|
39 |
_gx_system_dirty_partial_add((GX_WIDGET *)text_input, &cursor_rect); |
111 |
|
|
} |
112 |
|
|
else |
113 |
|
|
{ |
114 |
|
24 |
_gx_system_dirty_mark((GX_WIDGET *)text_input); |
115 |
|
|
} |
116 |
|
|
|
117 |
|
63 |
return GX_SUCCESS; |
118 |
|
|
} |
119 |
|
|
|