/*************************************************************************** * Copyright (c) 2024 Microsoft Corporation * * This program and the accompanying materials are made available under the * terms of the MIT License which is available at * https://opensource.org/licenses/MIT. * * SPDX-License-Identifier: MIT **************************************************************************/ /**************************************************************************/ /**************************************************************************/ /** */ /** GUIX Component */ /** */ /** Text Input Management (Single Line Text Input) */ /** */ /**************************************************************************/ #define GX_SOURCE_CODE /* Include necessary system files. */ #include "gx_api.h" #include "gx_multi_line_text_input.h" #include "gx_system.h" #include "gx_text_input_cursor.h" /**************************************************************************/ /* */ /* FUNCTION RELEASE */ /* */ /* _gx_multi_line_text_input_text_select PORTABLE C */ /* 6.1 */ /* AUTHOR */ /* */ /* Kenneth Maxwell, Microsoft Corporation */ /* */ /* DESCRIPTION */ /* */ /* This function highlighs text with specified start mark and end mark */ /* index. */ /* */ /* INPUT */ /* */ /* input Multi-line text input widget */ /* control block */ /* start_mark The index of the first */ /* highlight character. */ /* end_mark The index of the last */ /* highlight character */ /* */ /* OUTPUT */ /* */ /* None */ /* */ /* CALLS */ /* */ /* _gx_system_dirty_mark Mark widget as drity */ /* */ /* CALLED BY */ /* */ /* Application Code */ /* GUIX Internal Code */ /* */ /* RELEASE HISTORY */ /* */ /* DATE NAME DESCRIPTION */ /* */ /* 05-19-2020 Kenneth Maxwell Initial Version 6.0 */ /* 09-30-2020 Kenneth Maxwell Modified comment(s), */ /* resulting in version 6.1 */ /* */ /**************************************************************************/ UINT _gx_multi_line_text_input_text_select(GX_MULTI_LINE_TEXT_INPUT *input, UINT start_index, UINT end_index) { GX_RECTANGLE dirty_rect; UINT start_mark = input -> gx_multi_line_text_input_start_mark; UINT end_mark = input -> gx_multi_line_text_input_end_mark; if (start_index <= end_index) { input -> gx_multi_line_text_input_start_mark = start_index; input -> gx_multi_line_text_input_end_mark = end_index + 1; } else { input -> gx_multi_line_text_input_start_mark = start_index + 1; input -> gx_multi_line_text_input_end_mark = end_index; } if (input -> gx_widget_status & GX_STATUS_VISIBLE) { if (start_mark != end_mark) { _gx_multi_line_text_input_highlight_rectangle_get(input, &dirty_rect); /* Mark highlight area as dirty. */ _gx_system_dirty_partial_add((GX_WIDGET *)input, &dirty_rect); } else { _gx_text_input_cursor_dirty_rectangle_get(&input -> gx_multi_line_text_input_cursor_instance, &dirty_rect); /* Mark cursor area as dirty. */ _gx_system_dirty_partial_add((GX_WIDGET *)input, &dirty_rect); } start_mark = input -> gx_multi_line_text_input_start_mark; end_mark = input -> gx_multi_line_text_input_end_mark; if (input -> gx_multi_line_text_input_text_insert_position != end_mark) { input -> gx_multi_line_text_input_text_insert_position = end_mark; _gx_multi_line_text_input_cursor_pos_update(input, GX_FALSE); } _gx_multi_line_text_input_highlight_rectangle_get(input, &dirty_rect); /* Mark highlight area as dirty. */ _gx_system_dirty_partial_add((GX_WIDGET *)input, &dirty_rect); } return GX_SUCCESS; }