| // 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 int32 MAX_PROFILE_NAME_LENGTH = 128; | 
 | const int32 MAX_ALLOWED_PROFILES = 24; | 
 | const int32 MAX_ID_LENGTH = 36; | 
 |  | 
 | /// An alias to a profile's id. | 
 | using ProfileId = string:MAX_ID_LENGTH; | 
 |  | 
 | /// Common error code used across different settings. | 
 | enum ProfileError { | 
 |     /// 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() -> (vector<ProfileEntry>:MAX_ALLOWED_PROFILES profile_list); | 
 |  | 
 |     /// 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(ProfileId id) -> () 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(vector<ProfileEntry>:MAX_ALLOWED_PROFILES profile_entries); | 
 |  | 
 |     /// Returns the profile with the given [id]. | 
 |     /// | 
 |     /// If there is no profile with the given [name] an error will be returned. | 
 |     GetProfile(ProfileId id) -> (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(ProfileId id, Profile profile) -> () error ProfileError; | 
 |  | 
 |     /// Creates a new profile. | 
 |     /// | 
 |     /// After the profile is created it can be updated with a call to [Update]. | 
 |     CreateNew() -> (ProfileId id, 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(ProfileId id); | 
 |  | 
 |     /// Triggered when a given profile is updated. | 
 |     -> OnProfileUpdated(ProfileId id, Profile profile); | 
 | }; | 
 |  | 
 | /// The [ProfileEntry] is a readonly value which represents | 
 | /// a profile that has been saved. | 
 | struct ProfileEntry { | 
 |  | 
 |     /// A unique identifier for this profile represented as a UUID V4 string. | 
 |     ProfileId id; | 
 |  | 
 |     /// The user visible name of the profile. | 
 |     string:MAX_PROFILE_NAME_LENGTH name; | 
 |  | 
 |     /// Indicates if this is the users chosen default profile. | 
 |     bool is_default; | 
 | }; | 
 |  | 
 | /// A table representing the values stored in the profile. | 
 | table Profile { | 
 |  | 
 |     /// The visible name for this profile. | 
 |     1: string:MAX_PROFILE_NAME_LENGTH name; | 
 |  | 
 |     /// The font family used in text rendering. | 
 |     2: fuchsia.fonts.FamilyName font_family; | 
 |  | 
 |     /// The point size to render text. | 
 |     3: float32 point_size; | 
 |  | 
 |     /// The color to render the background; | 
 |     4: fuchsia.ui.types.ColorRgb background_color; | 
 |  | 
 |     /// The normal text color. | 
 |     5: fuchsia.ui.types.ColorRgb foreground_color; | 
 |  | 
 |     /// A color used to render bold text. | 
 |     6: fuchsia.ui.types.ColorRgb bold_color; | 
 |  | 
 |     /// The color of the selected text. | 
 |     7: fuchsia.ui.types.ColorRgb selected_background_color; | 
 |  | 
 |     /// The color of the selected text. | 
 |     8: fuchsia.ui.types.ColorRgb selected_foreground_color; | 
 |  | 
 |     /// If true, bold characters will use the bright color variant as well. | 
 |     9: bool use_bright_for_bold; | 
 |  | 
 |     10: array<fuchsia.ui.types.ColorRgb>:16 ansi_colors; | 
 |  | 
 |     /// A struct representing the cursor. | 
 |     11: Cursor cursor; | 
 | }; | 
 |  | 
 | /// A description of the terminal's cursor. | 
 | struct Cursor { | 
 |  | 
 |     /// The color to render the cursor. | 
 |     fuchsia.ui.types.ColorRgb color; | 
 |  | 
 |     /// The cursors style. | 
 |     CursorStyle style; | 
 |  | 
 |     /// whether the cursor should blink or not. | 
 |     bool blink; | 
 | }; | 
 |  | 
 | enum CursorStyle { | 
 |     /// 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; | 
 | }; |