GCC Code Coverage Report
Directory: ./ Exec Total Coverage
File: gx_multi_line_text_input_buffer_clear.c Lines: 13 13 100.0 %
Date: 2026-03-06 19:21:09 Branches: 4 4 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 Input Management (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_scrollbar.h"
30
#include "gx_multi_line_text_view.h"
31
#include "gx_multi_line_text_input.h"
32
#include "gx_window.h"
33
34
/**************************************************************************/
35
/*                                                                        */
36
/*  FUNCTION                                               RELEASE        */
37
/*                                                                        */
38
/*    _gx_multi_line_text_input_buffer_clear              PORTABLE C      */
39
/*                                                           6.1          */
40
/*  AUTHOR                                                                */
41
/*                                                                        */
42
/*    Kenneth Maxwell, Microsoft Corporation                              */
43
/*                                                                        */
44
/*  DESCRIPTION                                                           */
45
/*                                                                        */
46
/*    This function deletes all characters from the text input buffer.    */
47
/*                                                                        */
48
/*  INPUT                                                                 */
49
/*                                                                        */
50
/*    text_input                            Multi-line text input widget  */
51
/*                                            control blcok               */
52
/*                                                                        */
53
/*  OUTPUT                                                                */
54
/*                                                                        */
55
/*    status                                Completion status             */
56
/*                                                                        */
57
/*  CALLS                                                                 */
58
/*                                                                        */
59
/*   _gx_multi_line_text_input_char_remove  Remove characters from input  */
60
/*                                            buffer                      */
61
/*   _gx_multi_line_text_view_string_total_rows_compute                   */
62
/*                                          Calculate total rows          */
63
/*   _gx_multi_line_text_input_cursor_pos_update                          */
64
/*                                          Update cursor position        */
65
/*   _gx_window_scrollbar_find              Find scrollbar for a window   */
66
/*   _gx_scrollbar_reset                    Reset scroll bar information  */
67
/*   _gx_system_dirty_mark                  Mark the widget area as dirty */
68
/*                                                                        */
69
/*  CALLED BY                                                             */
70
/*                                                                        */
71
/*    GUIX Internal Code                                                  */
72
/*                                                                        */
73
/**************************************************************************/
74
14
UINT _gx_multi_line_text_input_buffer_clear(GX_MULTI_LINE_TEXT_INPUT *text_input)
75
{
76
GX_SCROLLBAR *scroll;
77
78
14
    if (text_input -> gx_multi_line_text_view_text.gx_string_length != 0)
79
    {
80
12
        _gx_multi_line_text_input_char_remove(text_input, 0, text_input -> gx_multi_line_text_view_text.gx_string_length);
81
82
        /* Initiate line cache information. */
83
12
        text_input -> gx_multi_line_text_view_first_cache_line = 0;
84
12
        memset(text_input -> gx_multi_line_text_view_line_index, 0, sizeof(UINT) * GX_MULTI_LINE_INDEX_CACHE_SIZE);
85
86
        /* Calculate new text rows. */
87
12
        _gx_multi_line_text_view_string_total_rows_compute((GX_MULTI_LINE_TEXT_VIEW *)text_input);
88
89
12
        text_input -> gx_multi_line_text_input_text_insert_position = 0;
90
91
12
        _gx_window_scrollbar_find((GX_WINDOW *)text_input, GX_TYPE_VERTICAL_SCROLL, &scroll);
92
12
        if (scroll)
93
        {
94
            /* Reset scrollbar.  */
95
10
            _gx_scrollbar_reset(scroll, GX_NULL);
96
        }
97
98
12
        _gx_multi_line_text_input_cursor_pos_update(text_input, GX_TRUE);
99
100
        /* Mark the widget area dirty. */
101
12
        _gx_system_dirty_mark((GX_WIDGET *)text_input);
102
    }
103
104
14
    return GX_SUCCESS;
105
}
106