GCC Code Coverage Report
Directory: ./ Exec Total Coverage
File: gx_multi_line_text_input_mark_next.c Lines: 27 27 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 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_window.h"
30
#include "gx_scrollbar.h"
31
#include "gx_multi_line_text_input.h"
32
#include "gx_multi_line_text_view.h"
33
#include "gx_text_input_cursor.h"
34
#include "gx_utility.h"
35
36
/**************************************************************************/
37
/*                                                                        */
38
/*  FUNCTION                                               RELEASE        */
39
/*                                                                        */
40
/*    _gx_multi_line_text_input_mark_next                 PORTABLE C      */
41
/*                                                           6.1          */
42
/*  AUTHOR                                                                */
43
/*                                                                        */
44
/*    Kenneth Maxwell, Microsoft Corporation                              */
45
/*                                                                        */
46
/*  DESCRIPTION                                                           */
47
/*                                                                        */
48
/*    This function moves highlight text end mark one character right.    */
49
/*                                                                        */
50
/*  INPUT                                                                 */
51
/*                                                                        */
52
/*    text_input                        Multi line text input             */
53
/*                                        control block                   */
54
/*                                                                        */
55
/*  OUTPUT                                                                */
56
/*                                                                        */
57
/*    None                                                                */
58
/*                                                                        */
59
/*  CALLS                                                                 */
60
/*                                                                        */
61
/*    _gx_text_input_cursor_dirty_rectangle_get                           */
62
/*                                          Get cursor rectangle          */
63
/*    _gx_multi_line_text_input_cursor_pos_update                         */
64
/*                                          Calculate cursor position     */
65
/*                                            according to insert index   */
66
/*    _gx_system_dirty_partial_add          Add one dirty area to         */
67
/*                                            dirty list                  */
68
/*    _gx_system_dirty_mark                 Mark widget area dirty        */
69
/*    _gx_utility_utf8_string_character_get Parses utf8 string to         */
70
/*                                            multi-byte glyph            */
71
/*    _gx_utility_string_length_check       Test string length            */
72
/*                                                                        */
73
/*  CALLED BY                                                             */
74
/*                                                                        */
75
/*    _gx_multi_line_text_input_keydown_process                           */
76
/*                                                                        */
77
/**************************************************************************/
78
683
UINT _gx_multi_line_text_input_mark_next(GX_MULTI_LINE_TEXT_INPUT *text_input)
79
{
80
GX_RECTANGLE cur_rect;
81
INT          old_shift;
82
683
UINT         glyph_len = 1;
83
GX_STRING    string;
84
GX_POINT     start_pos;
85
GX_POINT     end_pos;
86
683
UINT         start_mark = text_input -> gx_multi_line_text_input_start_mark;
87
683
UINT         end_mark = text_input -> gx_multi_line_text_input_end_mark;
88
89
683
    if (start_mark == end_mark)
90
    {
91
85
        start_mark = text_input -> gx_multi_line_text_input_text_insert_position;
92
85
        end_mark = text_input -> gx_multi_line_text_input_text_insert_position;
93
94
85
        text_input -> gx_multi_line_text_input_start_mark = start_mark;
95
85
        text_input -> gx_multi_line_text_input_end_mark = end_mark;
96
    }
97
98
683
    if (end_mark < text_input -> gx_multi_line_text_view_text.gx_string_length)
99
    {
100
#ifdef GX_UTF8_SUPPORT
101
682
        string.gx_string_ptr = text_input -> gx_multi_line_text_view_text.gx_string_ptr + end_mark;
102
682
        string.gx_string_length = text_input -> gx_multi_line_text_view_text.gx_string_length - end_mark;
103
682
        _gx_utility_utf8_string_character_get(&string, GX_NULL, &glyph_len);
104
#endif
105
682
        string.gx_string_ptr = text_input -> gx_multi_line_text_view_text.gx_string_ptr + end_mark;
106
107

682
        if (string.gx_string_ptr[0] == GX_KEY_CARRIAGE_RETURN || string.gx_string_ptr[0] == GX_KEY_LINE_FEED)
108
        {
109
100
            glyph_len = text_input -> gx_multi_line_text_input_new_line_character_size;
110
        }
111
112
682
        text_input -> gx_multi_line_text_input_end_mark += glyph_len;
113
114
682
        old_shift = text_input -> gx_multi_line_text_view_text_scroll_shift;
115
116
682
        start_pos = text_input -> gx_multi_line_text_input_cursor_instance.gx_text_input_cursor_pos;
117
118
682
        text_input -> gx_multi_line_text_input_text_insert_position = text_input -> gx_multi_line_text_input_end_mark;
119
120
        /* Recalculate cursor position according to cursor insert position. */
121
682
        _gx_multi_line_text_input_cursor_pos_update(text_input, GX_TRUE);
122
123
682
        end_pos = text_input -> gx_multi_line_text_input_cursor_instance.gx_text_input_cursor_pos;
124
125
        /* Dirty mark. */
126
682
        if (old_shift == text_input -> gx_multi_line_text_view_text_scroll_shift)
127
        {
128
631
            _gx_multi_line_text_input_text_rectangle_get(text_input, start_pos, end_pos, &cur_rect);
129
130
            /* Mark highlight area as dirty. */
131
631
            _gx_system_dirty_partial_add((GX_WIDGET *)text_input, &cur_rect);
132
        }
133
        else
134
        {
135
51
            _gx_system_dirty_mark((GX_WIDGET *)text_input);
136
        }
137
    }
138
683
    return GX_SUCCESS;
139
}
140