GCC Code Coverage Report
Directory: ./ Exec Total Coverage
File: gx_multi_line_text_input_up_arrow.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
/**   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 move the cursor up by one line.                       */
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
209
UINT _gx_multi_line_text_input_up_arrow(GX_MULTI_LINE_TEXT_INPUT *text_input)
77
{
78
209
GX_TEXT_INPUT_CURSOR *cursor_ptr = &text_input -> gx_multi_line_text_input_cursor_instance;
79
GX_VALUE              line_height;
80
GX_POINT              cursor_pos;
81
INT                   shift;
82
GX_RECTANGLE          cursor_rect;
83
GX_FONT              *font;
84
85
209
    _gx_widget_font_get((GX_WIDGET *)text_input, text_input -> gx_multi_line_text_view_font_id, &font);
86
87
209
    if (!font)
88
    {
89
1
        return GX_FAILURE;
90
    }
91
92
208
    if (text_input -> gx_multi_line_text_input_start_mark != text_input -> gx_multi_line_text_input_end_mark)
93
    {
94
1
        _gx_multi_line_text_input_left_arrow(text_input);
95
    }
96
97
    /* Record cursor rectangle and scroll shift value before recalculate cursor position. */
98
208
    _gx_text_input_cursor_dirty_rectangle_get(&text_input -> gx_multi_line_text_input_cursor_instance, &cursor_rect);
99
208
    shift = text_input -> gx_multi_line_text_view_text_scroll_shift;
100
101
208
    line_height = (GX_VALUE)(font -> gx_font_line_height +
102
208
                             text_input -> gx_multi_line_text_view_line_space);
103
104
208
    if (!line_height)
105
    {
106
1
        return GX_FAILURE;
107
    }
108
109
207
    cursor_pos = cursor_ptr -> gx_text_input_cursor_pos;
110
207
    cursor_pos.gx_point_y = (GX_VALUE)(cursor_pos.gx_point_y - line_height);
111
207
    _gx_multi_line_text_input_cursor_pos_calculate(text_input, cursor_pos);
112
113
114
207
    if (shift == text_input -> gx_multi_line_text_view_text_scroll_shift)
115
    {
116
        /* Mark old cursor area dirty. */
117
202
        _gx_system_dirty_partial_add((GX_WIDGET *)text_input, &cursor_rect);
118
119
202
        _gx_text_input_cursor_dirty_rectangle_get(&text_input -> gx_multi_line_text_input_cursor_instance, &cursor_rect);
120
121
        /* Mark new cursor area dirty. */
122
202
        _gx_system_dirty_partial_add((GX_WIDGET *)text_input, &cursor_rect);
123
    }
124
    else
125
    {
126
        /* Mark widget area dirty. */
127
5
        _gx_system_dirty_mark((GX_WIDGET *)text_input);
128
    }
129
130
207
    return GX_SUCCESS;
131
}
132