1 /***************************************************************************
2 * Copyright (c) 2024 Microsoft Corporation
3 *
4 * This program and the accompanying materials are made available under the
5 * terms of the MIT License which is available at
6 * https://opensource.org/licenses/MIT.
7 *
8 * SPDX-License-Identifier: MIT
9 **************************************************************************/
10
11
12 /**************************************************************************/
13 /**************************************************************************/
14 /** */
15 /** GUIX Component */
16 /** */
17 /** Multi Line Text Input Management (Multi Line Text Input) */
18 /** */
19 /**************************************************************************/
20
21 #define GX_SOURCE_CODE
22
23
24 /* Include necessary system files. */
25
26 #include "gx_api.h"
27 #include "gx_system.h"
28 #include "gx_scrollbar.h"
29 #include "gx_multi_line_text_view.h"
30 #include "gx_multi_line_text_input.h"
31 #include "gx_window.h"
32
33 /**************************************************************************/
34 /* */
35 /* FUNCTION RELEASE */
36 /* */
37 /* _gx_multi_line_text_input_buffer_clear PORTABLE C */
38 /* 6.1 */
39 /* AUTHOR */
40 /* */
41 /* Kenneth Maxwell, Microsoft Corporation */
42 /* */
43 /* DESCRIPTION */
44 /* */
45 /* This function deletes all characters from the text input buffer. */
46 /* */
47 /* INPUT */
48 /* */
49 /* text_input Multi-line text input widget */
50 /* control blcok */
51 /* */
52 /* OUTPUT */
53 /* */
54 /* status Completion status */
55 /* */
56 /* CALLS */
57 /* */
58 /* _gx_multi_line_text_input_char_remove Remove characters from input */
59 /* buffer */
60 /* _gx_multi_line_text_view_string_total_rows_compute */
61 /* Calculate total rows */
62 /* _gx_multi_line_text_input_cursor_pos_update */
63 /* Update cursor position */
64 /* _gx_window_scrollbar_find Find scrollbar for a window */
65 /* _gx_scrollbar_reset Reset scroll bar information */
66 /* _gx_system_dirty_mark Mark the widget area as dirty */
67 /* */
68 /* CALLED BY */
69 /* */
70 /* GUIX Internal Code */
71 /* */
72 /* RELEASE HISTORY */
73 /* */
74 /* DATE NAME DESCRIPTION */
75 /* */
76 /* 05-19-2020 Kenneth Maxwell Initial Version 6.0 */
77 /* 09-30-2020 Kenneth Maxwell Modified comment(s), */
78 /* resulting in version 6.1 */
79 /* */
80 /**************************************************************************/
_gx_multi_line_text_input_buffer_clear(GX_MULTI_LINE_TEXT_INPUT * text_input)81 UINT _gx_multi_line_text_input_buffer_clear(GX_MULTI_LINE_TEXT_INPUT *text_input)
82 {
83 GX_SCROLLBAR *scroll;
84
85 if (text_input -> gx_multi_line_text_view_text.gx_string_length != 0)
86 {
87 _gx_multi_line_text_input_char_remove(text_input, 0, text_input -> gx_multi_line_text_view_text.gx_string_length);
88
89 /* Initiate line cache information. */
90 text_input -> gx_multi_line_text_view_first_cache_line = 0;
91 memset(text_input -> gx_multi_line_text_view_line_index, 0, sizeof(UINT) * GX_MULTI_LINE_INDEX_CACHE_SIZE);
92
93 /* Calculate new text rows. */
94 _gx_multi_line_text_view_string_total_rows_compute((GX_MULTI_LINE_TEXT_VIEW *)text_input);
95
96 text_input -> gx_multi_line_text_input_text_insert_position = 0;
97
98 _gx_window_scrollbar_find((GX_WINDOW *)text_input, GX_TYPE_VERTICAL_SCROLL, &scroll);
99 if (scroll)
100 {
101 /* Reset scrollbar. */
102 _gx_scrollbar_reset(scroll, GX_NULL);
103 }
104
105 _gx_multi_line_text_input_cursor_pos_update(text_input, GX_TRUE);
106
107 /* Mark the widget area dirty. */
108 _gx_system_dirty_mark((GX_WIDGET *)text_input);
109 }
110
111 return GX_SUCCESS;
112 }
113
114