GCC Code Coverage Report
Directory: ./ Exec Total Coverage
File: gx_multi_line_text_view_text_set.c Lines: 23 23 100.0 %
Date: 2026-03-06 19:21:09 Branches: 10 10 100.0 %

Line Branch Exec Source
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 View Management (Multi Line Text View)              */
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_view.h"
30
#include "gx_scrollbar.h"
31
#include "gx_window.h"
32
#include "gx_widget.h"
33
#include "gx_utility.h"
34
35
/**************************************************************************/
36
/*                                                                        */
37
/*  FUNCTION                                               RELEASE        */
38
/*                                                                        */
39
/*    _gx_multi_line_text_view_text_set                   PORTABLE C      */
40
/*                                                           6.1          */
41
/*  AUTHOR                                                                */
42
/*                                                                        */
43
/*    Kenneth Maxwell, Microsoft Corporation                              */
44
/*                                                                        */
45
/*  DESCRIPTION (Deprecated)                                              */
46
/*                                                                        */
47
/*    This function assigns a text string to the multi line text view     */
48
/*    widget.                                                             */
49
/*                                                                        */
50
/*  INPUT                                                                 */
51
/*                                                                        */
52
/*    text_view                             Multi-line text view widget   */
53
/*                                            control block               */
54
/*    text                                  Null-terminated text string   */
55
/*                                                                        */
56
/*  OUTPUT                                                                */
57
/*                                                                        */
58
/*    status                                Completion status             */
59
/*                                                                        */
60
/*  CALLS                                                                 */
61
/*                                                                        */
62
/*    _gx_multi_line_text_view_text_set_ext                               */
63
/*                                                                        */
64
/*  CALLED BY                                                             */
65
/*                                                                        */
66
/*    Application Code                                                    */
67
/*                                                                        */
68
/**************************************************************************/
69
#if defined(GX_ENABLE_DEPRECATED_STRING_API)
70
34
UINT _gx_multi_line_text_view_text_set(GX_MULTI_LINE_TEXT_VIEW *text_view,
71
                                       GX_CONST GX_CHAR *text)
72
{
73
34
UINT      status = GX_SUCCESS;
74
34
UINT      length = 0;
75
GX_STRING string;
76
77
34
    if (text)
78
    {
79
31
        status = _gx_utility_string_length_check(text, &length, GX_MAX_STRING_LENGTH);
80
    }
81
82
34
    if (status == GX_SUCCESS)
83
    {
84
33
        string.gx_string_ptr = text;
85
33
        string.gx_string_length = length;
86
33
        status = _gx_multi_line_text_view_text_set_ext(text_view, &string);
87
    }
88
34
    return status;
89
}
90
#endif
91
92
93
94
/**************************************************************************/
95
/*                                                                        */
96
/*  FUNCTION                                               RELEASE        */
97
/*                                                                        */
98
/*    _gx_multi_line_text_view_text_set_ext               PORTABLE C      */
99
/*                                                           6.1          */
100
/*  AUTHOR                                                                */
101
/*                                                                        */
102
/*    Kenneth Maxwell, Microsoft Corporation                              */
103
/*                                                                        */
104
/*  DESCRIPTION                                                           */
105
/*                                                                        */
106
/*    This function assigns a text string to the multi line text view     */
107
/*    widget.                                                             */
108
/*                                                                        */
109
/*  INPUT                                                                 */
110
/*                                                                        */
111
/*    text_view                             Multi-line text view widget   */
112
/*                                            control block               */
113
/*    text                                  GX_STRING type text string    */
114
/*                                                                        */
115
/*  OUTPUT                                                                */
116
/*                                                                        */
117
/*    status                                Completion status             */
118
/*                                                                        */
119
/*  CALLS                                                                 */
120
/*                                                                        */
121
/*    _gx_utility_string_length_check       Test string length            */
122
/*    _gx_system_private_string_copy        Make a private copy for       */
123
/*                                            assigned text               */
124
/*    _gx_system_dirty_mark                 Mark a widget as dirty        */
125
/*                                                                        */
126
/*  CALLED BY                                                             */
127
/*                                                                        */
128
/*    Application Code                                                    */
129
/*                                                                        */
130
/**************************************************************************/
131
871
UINT _gx_multi_line_text_view_text_set_ext(GX_MULTI_LINE_TEXT_VIEW *text_view, GX_CONST GX_STRING *text)
132
{
133
871
UINT status = GX_SUCCESS;
134
135
871
    if (text_view -> gx_widget_style & GX_STYLE_TEXT_COPY)
136
    {
137
9
        status = _gx_system_private_string_copy(&text_view -> gx_multi_line_text_view_text, text);
138
    }
139
    else
140
    {
141
862
        if (text)
142
        {
143
861
            text_view -> gx_multi_line_text_view_text = *text;
144
        }
145
        else
146
        {
147
1
            text_view -> gx_multi_line_text_view_text.gx_string_ptr = GX_NULL;
148
1
            text_view -> gx_multi_line_text_view_text.gx_string_length = 0;
149
        }
150
    }
151
152
871
    text_view -> gx_multi_line_text_view_text_id = 0;
153
871
    text_view -> gx_multi_line_text_view_line_index_old = GX_TRUE;
154
155
#if defined(GX_DYNAMIC_BIDI_TEXT_SUPPORT)
156
    if (text_view -> gx_multi_line_text_view_bidi_resolved_text_info)
157
    {
158
        _gx_utility_bidi_resolved_text_info_delete(&text_view -> gx_multi_line_text_view_bidi_resolved_text_info);
159
    }
160
#endif
161
162
871
    if (text_view -> gx_widget_status & GX_STATUS_VISIBLE)
163
    {
164
294
        _gx_system_dirty_mark((GX_WIDGET *)text_view);
165
    }
166
167
871
    return(status);
168
}
169