// SPDX-License-Identifier: GPL-3.0-only // SPDX-FileCopyrightText: Copyright (C) 2026 Catcrafts® export module Nostro.Ui:Input; import std; import :Geometry; // What the window tells the toolkit of the keyboard, and what the toolkit tells the window of the text field that // has the focus, in terms of neither: the window's own key codes and the compositor's protocol stay on its side. export namespace Nostro::Ui { // The keys the toolkit acts on. A letter is the key that types it on the user's layout, not a place on the keyboard. enum class Key : std::uint8_t { None, Enter, Escape, Tab, Space, Backspace, Delete, Left, Right, Up, Down, Home, End, PageUp, PageDown, F5, A, C, F, R, V, X }; struct Modifiers { bool shift = false; bool control = false; friend bool operator==(const Modifiers&, const Modifiers&) = default; }; // What a text field holds, by which an on-screen keyboard picks its layout. enum class TextPurpose : std::uint8_t { Normal, Digits, // a whole number Number, // a number with a decimal separator Phone, Url, Email, Name, Password }; // How an input method treats what is typed, or-ed together. The values are text-input-v3's content hints, so the // window passes them on as they are. namespace TextHint { inline constexpr std::uint32_t none = 0x0; inline constexpr std::uint32_t completion = 0x1; inline constexpr std::uint32_t spellcheck = 0x2; inline constexpr std::uint32_t autoCapitalization = 0x4; inline constexpr std::uint32_t lowercase = 0x8; inline constexpr std::uint32_t hiddenText = 0x40; // show nothing of what is typed inline constexpr std::uint32_t sensitiveData = 0x80; // store and learn nothing of it inline constexpr std::uint32_t prose = completion | spellcheck | autoCapitalization; inline constexpr std::uint32_t secret = hiddenText | sensitiveData; } // The text field that has the focus, for the compositor's input method: whether there is one, where its caret is // (an on-screen keyboard keeps clear of it), and what it holds. `field` tells one field from the next: when it // changes, the input method starts afresh. struct TextInputRequest { bool active = false; Box caret; TextPurpose purpose = TextPurpose::Normal; std::uint32_t hints = TextHint::none; std::size_t field = 0; friend bool operator==(const TextInputRequest&, const TextInputRequest&) = default; }; }