| // Copyright 2019 The Fuchsia Authors. All rights reserved. |
| // Use of this source code is governed by a BSD-style license that can be |
| // found in the LICENSE file. |
| library fuchsia.terminal; |
| |
| using fuchsia.fonts; |
| using fuchsia.ui.types; |
| |
| const MAX_PROFILE_NAME_LENGTH int32 = 128; |
| const MAX_ALLOWED_PROFILES int32 = 24; |
| const MAX_ID_LENGTH int32 = 36; |
| |
| /// An alias to a profile's id. |
| alias ProfileId = string:MAX_ID_LENGTH; |
| |
| /// Common error code used across different settings. |
| type ProfileError = strict enum { |
| /// Indicates that the requested profile does not exist. |
| NOT_FOUND = 1; |
| |
| /// Indicates that the profile with a given name already exists. |
| NAME_ALREADY_EXISTS = 2; |
| }; |
| |
| /// A service which provides profile information for the terminal. |
| @discoverable |
| protocol Profiles { |
| |
| /// Returns the list of [ProfileEntry] objects. |
| GetProfileList() -> (struct { |
| profile_list vector<ProfileEntry>:MAX_ALLOWED_PROFILES; |
| }); |
| |
| /// Sets the profile with the given id as the default. |
| /// |
| /// This method can fail if a profile with the given id does not exist. |
| SetDefault(struct { |
| id ProfileId; |
| }) -> (struct {}) error ProfileError; |
| |
| /// Event which is triggered when the list of profiles have been updated. |
| /// |
| /// Note: this method will not be called if properties of an individual |
| /// profile are updated. |
| -> OnProfileListUpdated(struct { |
| profile_entries vector<ProfileEntry>:MAX_ALLOWED_PROFILES; |
| }); |
| |
| /// Returns the profile with the given [id]. |
| /// |
| /// If there is no profile with the given [name] an error will be returned. |
| GetProfile(struct { |
| id ProfileId; |
| }) -> (struct { |
| profile Profile; |
| }) error ProfileError; |
| |
| /// Updates the profile with the given id. |
| /// |
| /// This method will fail if a profile with the given id does not already |
| /// exist. A Profile must be created with a call to [CreateProfile]. |
| UpdateProfile(struct { |
| id ProfileId; |
| profile Profile; |
| }) -> (struct {}) error ProfileError; |
| |
| /// Creates a new profile. |
| /// |
| /// After the profile is created it can be updated with a call to [Update]. |
| CreateNew() -> (struct { |
| id ProfileId; |
| profile Profile; |
| }); |
| |
| /// Deletes the profile with the given id. |
| /// |
| /// If no profile with [id] exists this method does nothing. If the |
| /// default profile is deleted then a new profile will be set as the |
| /// default. However, which profile is chosen as the new profile is not |
| /// defined and it is up to the implementor to choose. The new default |
| /// profile can be retrieved by listening for the OnProfileListUpdated |
| /// event. |
| Delete(struct { |
| id ProfileId; |
| }); |
| |
| /// Triggered when a given profile is updated. |
| -> OnProfileUpdated(struct { |
| id ProfileId; |
| profile Profile; |
| }); |
| }; |
| |
| /// The [ProfileEntry] is a readonly value which represents |
| /// a profile that has been saved. |
| type ProfileEntry = struct { |
| |
| /// A unique identifier for this profile represented as a UUID V4 string. |
| id ProfileId; |
| |
| /// The user visible name of the profile. |
| name string:MAX_PROFILE_NAME_LENGTH; |
| |
| /// Indicates if this is the users chosen default profile. |
| is_default bool; |
| }; |
| |
| /// A table representing the values stored in the profile. |
| type Profile = table { |
| |
| /// The visible name for this profile. |
| 1: name string:MAX_PROFILE_NAME_LENGTH; |
| |
| /// The font family used in text rendering. |
| 2: font_family fuchsia.fonts.FamilyName; |
| |
| /// The point size to render text. |
| 3: point_size float32; |
| |
| /// The color to render the background; |
| 4: background_color fuchsia.ui.types.ColorRgb; |
| |
| /// The normal text color. |
| 5: foreground_color fuchsia.ui.types.ColorRgb; |
| |
| /// A color used to render bold text. |
| 6: bold_color fuchsia.ui.types.ColorRgb; |
| |
| /// The color of the selected text. |
| 7: selected_background_color fuchsia.ui.types.ColorRgb; |
| |
| /// The color of the selected text. |
| 8: selected_foreground_color fuchsia.ui.types.ColorRgb; |
| |
| /// If true, bold characters will use the bright color variant as well. |
| 9: use_bright_for_bold bool; |
| |
| 10: ansi_colors array<fuchsia.ui.types.ColorRgb, 16>; |
| |
| /// A struct representing the cursor. |
| 11: cursor Cursor; |
| }; |
| |
| /// A description of the terminal's cursor. |
| type Cursor = struct { |
| |
| /// The color to render the cursor. |
| color fuchsia.ui.types.ColorRgb; |
| |
| /// The cursors style. |
| style CursorStyle; |
| |
| /// whether the cursor should blink or not. |
| blink bool; |
| }; |
| |
| type CursorStyle = strict enum { |
| /// Renders the terminal's cursor as a block. |
| BLOCK = 1; |
| |
| /// Renders the terminal's cursor as a single underline. |
| UNDERLINE = 2; |
| |
| /// Renders the terminal's cursor as a single vertical bar. |
| VERTICAL_BAR = 3; |
| }; |