← All compilation units

Flyology_TUI.Components.Chats

Description

Chats is a task-free retained controller. One caller owns Model and serializes all updates. Producers may send detached values to that caller, but this package owns no task, queue, network, or callback.

"="

function "=" (Left, Right : Message_Id) return Boolean
Parameters
Left
Right
Return value

Action_Region

function Action_Region
  (Item : Presentation; Id : Message_Id)
   return Flyology_TUI.Geometry.Rectangle
Parameters
Item
Id
Return value

Appearance

type Appearance is record
   Transcript : Flyology_TUI.Styles.Style := Flyology_TUI.Styles.Default;
   Header     : Flyology_TUI.Styles.Style := Flyology_TUI.Styles.Default;
   User_Bubble : Flyology_TUI.Styles.Style := Flyology_TUI.Styles.Default;
   Assistant_Bubble : Flyology_TUI.Styles.Style :=
     Flyology_TUI.Styles.Default;
   System_Bubble : Flyology_TUI.Styles.Style := Flyology_TUI.Styles.Default;
   Tool_Bubble : Flyology_TUI.Styles.Style := Flyology_TUI.Styles.Default;
   Notice_Bubble : Flyology_TUI.Styles.Style := Flyology_TUI.Styles.Default;
   User       : Flyology_TUI.Styles.Style := Flyology_TUI.Styles.Default;
   Assistant  : Flyology_TUI.Styles.Style := Flyology_TUI.Styles.Default;
   System     : Flyology_TUI.Styles.Style := Flyology_TUI.Styles.Default;
   Tool       : Flyology_TUI.Styles.Style := Flyology_TUI.Styles.Default;
   Notice     : Flyology_TUI.Styles.Style := Flyology_TUI.Styles.Default;
   Pending    : Flyology_TUI.Styles.Style := Flyology_TUI.Styles.Default;
   Streaming  : Flyology_TUI.Styles.Style := Flyology_TUI.Styles.Default;
   Failed     : Flyology_TUI.Styles.Style := Flyology_TUI.Styles.Default;
   Selected   : Flyology_TUI.Styles.Style := Flyology_TUI.Styles.Default;
   Focused    : Flyology_TUI.Styles.Style := Flyology_TUI.Styles.Default;
   Footer     : Flyology_TUI.Styles.Style := Flyology_TUI.Styles.Default;
   Composer   : Flyology_TUI.Styles.Style := Flyology_TUI.Styles.Default;
end record;
Record fields
Transcript
Header
User_Bubble
Assistant_Bubble
System_Bubble
Tool_Bubble
Notice_Bubble
User
Assistant
System
Tool
Notice
Pending
Streaming
Failed
Selected
Focused
Footer
Composer

Author_Id

type Author_Id is private;

Author_Label

function Author_Label (Author : Author_Id) return Wide_Wide_String
Parameters
Author
Return value

Body_Array

type Body_Array is array (Positive range <>) of Body_Entry;

Body_Entry

type Body_Entry is record
   Id      : Message_Id;
   Content : Flyology_TUI.Surfaces.Surface;
   Actions : Flyology_TUI.Surfaces.Surface;
end record;
Record fields
Id
Content
Actions

Body_Region

function Body_Region
  (Item : Presentation; Id : Message_Id)
   return Flyology_TUI.Geometry.Rectangle
Parameters
Item
Id
Return value

Body_Width_Limit

function Body_Width_Limit
  (Item : Model; Frame_Width : Natural) return Natural

Maximum width available to a caller-owned message body after applying the current frame percentage, absolute limit, and horizontal padding. A zero result means that the frame can publish no body cells.

Parameters
Item
Frame_Width
Return value

Bubble_Region

function Bubble_Region
  (Item : Presentation; Id : Message_Id)
   return Flyology_TUI.Geometry.Rectangle
Parameters
Item
Id
Return value

Capacity

Capacity : Positive;

Clear_Selection

procedure Clear_Selection (Item : in out Model)
Parameters
Item

Composer_Region

function Composer_Region
  (Item : Layout_Plan) return Flyology_TUI.Geometry.Rectangle
Parameters
Item
Return value

Contains

function Contains (Item : Model; Id : Message_Id) return Boolean
Parameters
Item
Id
Return value

Content_Height

function Content_Height (Item : Model) return Natural
Parameters
Item
Return value

Conversational_Layout

Conversational_Layout : constant Layout_Options :=
  (Mode                  => Message_Bubbles,
   Maximum_Message_Width => 72,
   Maximum_Percentage    => 72,
   Horizontal_Padding    => 1,
   Message_Gap           => 1);

Create

function Create
  (Messages      : Message_Array;
   Viewport_Rows : Natural := 12) return Model
Parameters
Messages
Viewport_Rows
Return value

Delivery_State

type Delivery_State is
  (Pending, Streaming, Delivered, Failed, Cancelled);
Enumeration literals
Pending
Streaming
Delivered
Failed
Cancelled

Dense_Layout

Dense_Layout : constant Layout_Options :=
  (Mode                  => Dense_Transcript,
   Maximum_Message_Width => Natural'Last,
   Maximum_Percentage    => 100,
   Horizontal_Padding    => 0,
   Message_Gap           => 0);

First_Visible_Cell

function First_Visible_Cell (Item : Model) return Natural
Parameters
Item
Return value

Focused_Id

function Focused_Id (Item : Model) return Message_Id
Parameters
Item
Return value

Follows_Tail

function Follows_Tail (Item : Model) return Boolean
Parameters
Item
Return value

Footer_Region

function Footer_Region
  (Item : Layout_Plan) return Flyology_TUI.Geometry.Rectangle
Parameters
Item
Return value

Frame

function Frame
  (Item : Presentation) return Flyology_TUI.Surfaces.Surface
Parameters
Item
Return value

From_Theme

function From_Theme
  (Theme : Flyology_TUI.Themes.Theme) return Appearance
Parameters
Theme
Return value

Handle

function Handle
  (Item  : in out Model;
   Event : Flyology_TUI.Events.Terminal_Event)
   return Flyology_TUI.Components.Interactions.Update_Result
Parameters
Item
Event
Return value

Handle

function Handle
  (Item   : in out Model;
   Event  : Flyology_TUI.Mouse.Local_Event;
   Layout : Presentation)
   return Flyology_TUI.Components.Interactions.Update_Result

Events over body, action, footer, or composer regions are deliberately unconsumed so the caller can route them to heterogeneous children.

Parameters
Item
Event
Layout
Return value

Has_Action_Region

function Has_Action_Region
  (Item : Presentation; Id : Message_Id) return Boolean
Parameters
Item
Id
Return value

Has_Composer

function Has_Composer (Item : Layout_Plan) return Boolean
Parameters
Item
Return value

Has_Focused_Message

function Has_Focused_Message (Item : Model) return Boolean
Parameters
Item
Return value

Has_Footer

function Has_Footer (Item : Layout_Plan) return Boolean
Parameters
Item
Return value

Has_Message

function Has_Message
  (Item : Presentation; Id : Message_Id) return Boolean
Parameters
Item
Id
Return value

Has_Selection

function Has_Selection (Item : Model) return Boolean
Parameters
Item
Return value

Header_Region

function Header_Region
  (Item : Presentation; Id : Message_Id)
   return Flyology_TUI.Geometry.Rectangle
Parameters
Item
Id
Return value

Height

function Height (Item : Layout_Plan) return Natural
Parameters
Item
Return value

Is_Empty

function Is_Empty (Item : Model) return Boolean
Parameters
Item
Return value

Layout

function Layout (Item : Model) return Layout_Options
Parameters
Item
Return value

Layout

function Layout (Item : Presentation) return Layout_Plan
Parameters
Item
Return value

Layout_Options

type Layout_Options is record
   Mode                  : Message_Layout_Mode := Dense_Transcript;
   Maximum_Message_Width : Natural := Natural'Last;
   Maximum_Percentage    : Message_Width_Percentage := 100;
   Horizontal_Padding    : Natural := 0;
   Message_Gap           : Natural := 0;
end record;
Record fields
Mode
Maximum_Message_Width
Maximum_Percentage
Horizontal_Padding
Message_Gap

Layout_Plan

type Layout_Plan is private;

Layout planning allocates no Surface. It identifies the stable ids whose body/action surfaces Present will require for the current viewport.

Length

function Length (Item : Model) return Natural
Parameters
Item
Return value

Mark_All_Seen

procedure Mark_All_Seen (Item : in out Model)
Parameters
Item

Measurement

type Measurement is record
   Id            : Message_Id;
   Body_Height   : Natural := 1;
   Action_Height : Natural := 0;
end record;
Record fields
Id
Body_Height
Action_Height

Measurement_Array

type Measurement_Array is array (Positive range <>) of Measurement;

Message

type Message is record
   Id       : Message_Id;
   Author   : Author_Id;
   Role     : Message_Role := User;
   Delivery : Delivery_State := Delivered;
   Sequence : Natural := 0;
end record;
Record fields
Id
Author
Role
Delivery
Sequence

Message_Array

type Message_Array is array (Positive range <>) of Message;

Message_At

function Message_At (Item : Model; Position : Positive) return Message
Parameters
Item
Position
Return value

Message_Id

type Message_Id is private;

Message_Layout_Mode

type Message_Layout_Mode is (Dense_Transcript, Message_Bubbles);
Enumeration literals
Dense_Transcript
Message_Bubbles

Message_Role

type Message_Role is (User, Assistant, System, Tool, Notice);
Enumeration literals
User
Assistant
System
Tool
Notice

Message_Width_Percentage

subtype Message_Width_Percentage is Positive range 1 .. 100;

Model

type Model is tagged private;

Plan

function Plan
  (Item            : Model;
   Width           : Natural;
   Footer_Height   : Natural := 0;
   Composer_Height : Natural := 0) return Layout_Plan
Parameters
Item
Width
Footer_Height
Composer_Height
Return value

Present

function Present
  (Item      : Model;
   Bodies    : Body_Array;
   Width     : Natural;
   Look      : Appearance;
   Has_Focus : Boolean := False) return Presentation
Parameters
Item
Bodies
Width
Look
Has_Focus
Return value

Present

function Present
  (Item      : Model;
   Bodies    : Body_Array;
   Width     : Natural;
   Footer    : Flyology_TUI.Surfaces.Surface;
   Composer  : Flyology_TUI.Surfaces.Surface;
   Look      : Appearance;
   Has_Focus : Boolean := False) return Presentation
Parameters
Item
Bodies
Width
Footer
Composer
Look
Has_Focus
Return value

Present

function Present
  (Item      : Model;
   Bodies    : Body_Array;
   Width     : Natural;
   Footer    : Flyology_TUI.Surfaces.Surface;
   Composer  : Flyology_TUI.Surfaces.Surface;
   Theme     : Flyology_TUI.Themes.Theme;
   Has_Focus : Boolean := False) return Presentation
Parameters
Item
Bodies
Width
Footer
Composer
Theme
Has_Focus
Return value

Present

function Present
  (Item      : Model;
   Bodies    : Body_Array;
   Width     : Natural;
   Theme     : Flyology_TUI.Themes.Theme;
   Has_Focus : Boolean := False) return Presentation
Parameters
Item
Bodies
Width
Theme
Has_Focus
Return value

Presentation

type Presentation is private;

Presentation borrows bodies, actions, footer, composer, and appearance. It retains only the composed frame, ids, and geometry. Bodies must have exactly the planned measured heights. Widths are clipped to the frame.

Reconcile_Measurements

procedure Reconcile_Measurements
  (Item         : in out Model;
   Measurements : Measurement_Array)

Measurements must contain exactly one entry for every current message. Validation and height-overflow checks complete before Model changes.

Parameters
Item
Measurements

Required_Body_Count

function Required_Body_Count (Item : Layout_Plan) return Natural
Parameters
Item
Return value

Required_Body_Id

function Required_Body_Id
  (Item : Layout_Plan; Position : Positive) return Message_Id
Parameters
Item
Position
Return value

Requires_Body

function Requires_Body
  (Item : Layout_Plan; Id : Message_Id) return Boolean
Parameters
Item
Id
Return value

Scroll_Cells

procedure Scroll_Cells
  (Item    : in out Model;
   Amount  : Integer;
   Changed : out Boolean)

Positive deltas move toward the tail; negative deltas move toward the start. Integer'First and other extreme values saturate safely.

Parameters
Item
Amount
Changed

Select_Id

procedure Select_Id (Item : in out Model; Id : Message_Id)
Parameters
Item
Id

Selected_Id

function Selected_Id (Item : Model) return Message_Id
Parameters
Item
Return value

Set_Follow_Tail

procedure Set_Follow_Tail
  (Item    : in out Model;
   Enabled : Boolean := True)
Parameters
Item
Enabled

Set_Layout

procedure Set_Layout
  (Item : in out Model; Options : Layout_Options)

Layout geometry is independent from Appearance and remains under the serial application owner's control. Dense_Layout preserves the original full-width transcript; Conversational_Layout adds readable bubbles.

Parameters
Item
Options

Set_Messages

procedure Set_Messages
  (Item     : in out Model;
   Messages : Message_Array)

Replacement validates capacity and duplicate ids before mutation. Measurements, focus, and selection follow surviving stable ids. New ids increment Unread_Count only while follow-tail is disabled.

Parameters
Item
Messages

Set_Viewport_Rows

procedure Set_Viewport_Rows (Item : in out Model; Rows : Natural)
Parameters
Item
Rows

Transcript_Region

function Transcript_Region
  (Item : Layout_Plan) return Flyology_TUI.Geometry.Rectangle
Parameters
Item
Return value

Unread_Count

function Unread_Count (Item : Model) return Natural
Parameters
Item
Return value

Update

procedure Update
  (Item  : in out Model;
   Event : Flyology_TUI.Events.Terminal_Event)
Parameters
Item
Event

Update

procedure Update
  (Item   : in out Model;
   Event  : Flyology_TUI.Mouse.Local_Event;
   Layout : Presentation)
Parameters
Item
Event
Layout

Viewport_Rows

function Viewport_Rows (Item : Model) return Natural
Parameters
Item
Return value

Width

function Width (Item : Layout_Plan) return Natural
Parameters
Item
Return value