GCC Code Coverage Report
Directory: ./ Exec Total Coverage
File: gx_single_line_text_input_text_select.c Lines: 22 22 100.0 %
Date: 2026-03-06 19:21:09 Branches: 8 8 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
/**   Text Input Management (Single 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_single_line_text_input.h"
30
#include "gx_text_input_cursor.h"
31
32
/**************************************************************************/
33
/*                                                                        */
34
/*  FUNCTION                                               RELEASE        */
35
/*                                                                        */
36
/*    _gx_single_line_text_input_text_select              PORTABLE C      */
37
/*                                                           6.1          */
38
/*  AUTHOR                                                                */
39
/*                                                                        */
40
/*    Kenneth Maxwell, Microsoft Corporation                              */
41
/*                                                                        */
42
/*  DESCRIPTION                                                           */
43
/*                                                                        */
44
/*    This function highlighs text with specified start mark and end mark */
45
/*    index.                                                              */
46
/*                                                                        */
47
/*  INPUT                                                                 */
48
/*                                                                        */
49
/*    text_input                            Single-line text input widget */
50
/*                                            control block               */
51
/*    start_mark                            The index of the first        */
52
/*                                            highlight character.        */
53
/*    end_mark                              The index of the last         */
54
/*                                            highlight character         */
55
/*                                                                        */
56
/*  OUTPUT                                                                */
57
/*                                                                        */
58
/*    None                                                                */
59
/*                                                                        */
60
/*  CALLS                                                                 */
61
/*                                                                        */
62
/*    _gx_system_dirty_mark                Mark widget as drity           */
63
/*                                                                        */
64
/*  CALLED BY                                                             */
65
/*                                                                        */
66
/*    Application Code                                                    */
67
/*    GUIX Internal Code                                                  */
68
/*                                                                        */
69
/**************************************************************************/
70
397
UINT _gx_single_line_text_input_text_select(GX_SINGLE_LINE_TEXT_INPUT *input, UINT start_index, UINT end_index)
71
{
72
GX_RECTANGLE dirty_rect;
73
397
UINT         start_mark = input -> gx_single_line_text_input_start_mark;
74
397
UINT         end_mark = input -> gx_single_line_text_input_end_mark;
75
76
397
    if (start_index <= end_index)
77
    {
78
252
        input -> gx_single_line_text_input_start_mark = start_index;
79
252
        input -> gx_single_line_text_input_end_mark = end_index + 1;
80
    }
81
    else
82
    {
83
145
        input -> gx_single_line_text_input_start_mark = start_index + 1;
84
145
        input -> gx_single_line_text_input_end_mark = end_index;
85
    }
86
87
397
    if (input -> gx_widget_status & GX_STATUS_VISIBLE)
88
    {
89
396
        if (start_mark != end_mark)
90
        {
91
1
            _gx_single_line_text_input_text_rectangle_get(input, (INT)(start_mark - end_mark), &dirty_rect);
92
93
            /* Mark old highlight area as dirty. */
94
1
            _gx_system_dirty_partial_add((GX_WIDGET *)input, &dirty_rect);
95
        }
96
        else
97
        {
98
395
            _gx_text_input_cursor_dirty_rectangle_get(&input->gx_single_line_text_input_cursor_instance, &dirty_rect);
99
100
            /* Mark cursor area as dirty. */
101
395
            _gx_system_dirty_partial_add((GX_WIDGET *)input, &dirty_rect);
102
        }
103
104
396
        start_mark = input -> gx_single_line_text_input_start_mark;
105
396
        end_mark = input -> gx_single_line_text_input_end_mark;
106
107
396
        if (input -> gx_single_line_text_input_insert_pos != end_mark)
108
        {
109
293
            input -> gx_single_line_text_input_insert_pos = end_mark;
110
293
            _gx_single_line_text_input_position_update(input);
111
        }
112
113
396
        _gx_single_line_text_input_text_rectangle_get(input, (INT)(start_mark - end_mark), &dirty_rect);
114
115
        /* Mark highlight text area as dirty. */
116
396
        _gx_system_dirty_partial_add((GX_WIDGET *)input, &dirty_rect);
117
    }
118
119
397
    return GX_SUCCESS;
120
}
121