GCC Code Coverage Report
Directory: ./ Exec Total Coverage
File: gx_multi_line_text_input_mark_up.c Lines: 29 29 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
/**   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_widget.h"
31
#include "gx_scrollbar.h"
32
#include "gx_multi_line_text_input.h"
33
#include "gx_multi_line_text_view.h"
34
#include "gx_text_input_cursor.h"
35
36
/**************************************************************************/
37
/*                                                                        */
38
/*  FUNCTION                                               RELEASE        */
39
/*                                                                        */
40
/*    _gx_multi_line_text_input_up_arrow                  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 line up.            */
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_widget_font_get                   Retrieve font                 */
62
/*    _gx_text_input_cursor_dirty_rectangle_get                           */
63
/*                                          Get cursor rectangle          */
64
/*    _gx_multi_line_text_input_cursor_pos_calculate                      */
65
/*                                          Calculate cursor position     */
66
/*                                            according to click index    */
67
/*    _gx_system_dirty_partial_add          Add one dirty area to         */
68
/*                                            dirty list                  */
69
/*    _gx_system_dirty_mark                 Mark widget area dirty        */
70
/*                                                                        */
71
/*  CALLED BY                                                             */
72
/*                                                                        */
73
/*    _gx_multi_line_text_input_keydown_process                           */
74
/*                                                                        */
75
/**************************************************************************/
76
157
UINT _gx_multi_line_text_input_mark_up(GX_MULTI_LINE_TEXT_INPUT *text_input)
77
{
78
157
GX_TEXT_INPUT_CURSOR *cursor_ptr = &text_input -> gx_multi_line_text_input_cursor_instance;
79
GX_VALUE              line_height;
80
GX_VALUE              half_line_height;
81
GX_POINT              cursor_pos;
82
INT                   shift;
83
GX_RECTANGLE          cursor_rect;
84
GX_FONT              *font;
85
157
UINT                  start_mark = text_input -> gx_multi_line_text_input_start_mark;
86
157
UINT                  end_mark = text_input -> gx_multi_line_text_input_end_mark;
87
GX_VALUE              width;
88
89
157
    if (start_mark == end_mark)
90
    {
91
59
        start_mark = text_input -> gx_multi_line_text_input_text_insert_position;
92
59
        end_mark = text_input -> gx_multi_line_text_input_text_insert_position;
93
94
59
        text_input -> gx_multi_line_text_input_start_mark = start_mark;
95
59
        text_input -> gx_multi_line_text_input_end_mark = end_mark;
96
    }
97
98
157
    shift = text_input -> gx_multi_line_text_view_text_scroll_shift;
99
100
157
    _gx_widget_font_get((GX_WIDGET *)text_input, text_input -> gx_multi_line_text_view_font_id, &font);
101
102
157
    if (!font)
103
    {
104
1
        return GX_FAILURE;
105
    }
106
107
156
    line_height = (GX_VALUE)(font -> gx_font_line_height + text_input -> gx_multi_line_text_view_line_space);
108
109
156
    if (!line_height)
110
    {
111
1
        return GX_FAILURE;
112
    }
113
114
155
    cursor_pos = cursor_ptr -> gx_text_input_cursor_pos;
115
155
    cursor_pos.gx_point_y = (GX_VALUE)(cursor_pos.gx_point_y - line_height);
116
155
    _gx_multi_line_text_input_cursor_pos_calculate(text_input, cursor_pos);
117
155
    text_input -> gx_multi_line_text_input_end_mark = text_input -> gx_multi_line_text_input_text_insert_position;
118
119
155
    if (shift == text_input -> gx_multi_line_text_view_text_scroll_shift)
120
    {
121
69
        _gx_widget_border_width_get((GX_WIDGET *)text_input, &width);
122
69
        _gx_widget_client_get((GX_WIDGET *)text_input, width, &cursor_rect);
123
124
69
        half_line_height = (GX_VALUE)((line_height + 1) >> 1);
125
69
        cursor_rect.gx_rectangle_top = (GX_VALUE)(cursor_pos.gx_point_y - half_line_height);
126
69
        cursor_rect.gx_rectangle_bottom = (GX_VALUE)(cursor_pos.gx_point_y + line_height + half_line_height);
127
128
        /* Mark highlight area as dirty. */
129
69
        _gx_system_dirty_partial_add((GX_WIDGET *)text_input, &cursor_rect);
130
    }
131
    else
132
    {
133
        /* Mark widget area dirty. */
134
86
        _gx_system_dirty_mark((GX_WIDGET *)text_input);
135
    }
136
137
155
    return GX_SUCCESS;
138
}
139