GCC Code Coverage Report
Directory: ./ Exec Total Coverage
File: gx_multi_line_text_view_text_id_set.c Lines: 12 12 100.0 %
Date: 2026-03-06 19:21:09 Branches: 6 6 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_utility.h"
32
#include "gx_window.h"
33
#include "gx_widget.h"
34
35
/**************************************************************************/
36
/*                                                                        */
37
/*  FUNCTION                                               RELEASE        */
38
/*                                                                        */
39
/*    _gx_multi_line_text_view_text_id_set                PORTABLE C      */
40
/*                                                           6.1          */
41
/*  AUTHOR                                                                */
42
/*                                                                        */
43
/*    Kenneth Maxwell, Microsoft Corporation                              */
44
/*                                                                        */
45
/*  DESCRIPTION                                                           */
46
/*                                                                        */
47
/*    This function creates a text input widget.                          */
48
/*                                                                        */
49
/*  INPUT                                                                 */
50
/*                                                                        */
51
/*    text_view                             Multi-line view control block */
52
/*    text_id                               Resource ID for the text      */
53
/*                                            string                      */
54
/*                                                                        */
55
/*  OUTPUT                                                                */
56
/*                                                                        */
57
/*    status                                Completion status             */
58
/*                                                                        */
59
/*  CALLS                                                                 */
60
/*                                                                        */
61
/*    _gx_utility_string_length_check       Test string length            */
62
/*    _gx_system_string_get                 Get the string from the ID    */
63
/*    _gx_system_memory_free                Application-defined memory    */
64
/*                                            free function               */
65
/*    _gx_multi_line_text_view_string_total_rows_compute                  */
66
/*                                          Compute the total rows of     */
67
/*                                            of the display text         */
68
/*    _gx_multi_line_text_view_line_cache_update                          */
69
/*                                          Update line cache             */
70
/*    _gx_window_scrollbar_find             Find scrollbar for a window   */
71
/*    _gx_scrollbar_reset                   Reset scrollbar information   */
72
/*    _gx_utility_utf8_string_character_count_get                         */
73
/*                                          Get character count of utf8   */
74
/*                                            string                      */
75
/*    _gx_system_dirty_mark                 Mark a widget as dirty        */
76
/*                                                                        */
77
/*  CALLED BY                                                             */
78
/*                                                                        */
79
/*    Application Code                                                    */
80
/*                                                                        */
81
/**************************************************************************/
82
220
UINT _gx_multi_line_text_view_text_id_set(GX_MULTI_LINE_TEXT_VIEW *text_view,
83
                                          GX_RESOURCE_ID text_id)
84
{
85
220
    if (text_view -> gx_widget_style & GX_STYLE_TEXT_COPY)
86
    {
87
13
        if (text_view -> gx_multi_line_text_view_text.gx_string_ptr)
88
        {
89
1
            _gx_system_memory_free((void *)text_view -> gx_multi_line_text_view_text.gx_string_ptr);
90
        }
91
    }
92
93
220
    text_view -> gx_multi_line_text_view_text_id = text_id;
94
220
    text_view -> gx_multi_line_text_view_text_total_rows = 0;
95
220
    text_view -> gx_multi_line_text_view_line_index_old = GX_TRUE;
96
97
220
    _gx_widget_string_get_ext((GX_WIDGET *)text_view, text_id, &text_view -> gx_multi_line_text_view_text);
98
220
    text_view -> gx_multi_line_text_view_text.gx_string_ptr = GX_NULL;
99
100
#if defined(GX_DYNAMIC_BIDI_TEXT_SUPPORT)
101
    if (text_view -> gx_multi_line_text_view_bidi_resolved_text_info)
102
    {
103
        _gx_utility_bidi_resolved_text_info_delete(&text_view -> gx_multi_line_text_view_bidi_resolved_text_info);
104
    }
105
#endif
106
107
220
    if (text_view -> gx_widget_status & GX_STATUS_VISIBLE)
108
    {
109
219
        _gx_system_dirty_mark((GX_WIDGET *)text_view);
110
    }
111
112
220
    return(GX_SUCCESS);
113
}
114