# Class MainWindow | EchoHub Documentation
Main Terminal.Gui window for the EchoHub chat client.

# Class MainWindow

Namespace
  EchoHub.Client.UI

Assembly
  EchoHub.Client.dll

Main Terminal.Gui window for the EchoHub chat client.

    public sealed class MainWindow : Runnable, IDisposable, IRunnable

Inheritance
  object
  View
  Runnable
  MainWindow

Implements
  IDisposable
  IRunnable

Inherited Members
  Runnable.SetApp(IApplication)
  Runnable.SetIsRunning(bool)
  Runnable.RequestStop()
  Runnable.RaiseIsRunningChanging(bool, bool)
  Runnable.RaiseIsRunningChangedEvent(bool)
  Runnable.SetIsModal(bool)
  Runnable.RaiseIsModalChangedEvent(bool)
  Runnable.Result
  Runnable.IsRunning
  Runnable.IsModal
  Runnable.StopRequested
  Runnable.IsRunningChanging
  Runnable.IsRunningChanged
  Runnable.IsModalChanged
  View.NewMouseEvent(Mouse)
  View.RaiseMouseEvent(Mouse)
  View.GetAdornmentsThickness()
  View.GetSupportedCommands()
  View.InvokeCommands(Command[], ICommandBinding)
  View.InvokeCommand(Command, ICommandBinding)
  View.InvokeCommand(Command, ICommandContext)
  View.InvokeCommand(Command)
  View.SetContentSize(Size?)
  View.GetContentSize()
  View.GetWidthRequiredForSubViews()
  View.GetHeightRequiredForSubViews()
  View.ContentToScreen(in Point)
  View.ScreenToContent(in Point)
  View.ViewportToScreen(in Rectangle)
  View.ViewportToScreen(in Point)
  View.ViewportToScreen()
  View.ScreenToViewport(in Point)
  View.GetViewportOffsetFromFrame()
  View.ScrollVertical(int)
  View.ScrollHorizontal(int)
  View.Dispose()
  View.ToString()
  View.ToDebugString()
  View.BeginInit()
  View.EndInit()
  View.OnEnabledChanged()
  View.SetCursorNeedsUpdate()
  View.GetCurrentAttribute()
  View.GetAttributeForRole(VisualRole)
  View.SetAttribute(Attribute)
  View.SetAttributeForRole(VisualRole)
  View.GetClip()
  View.SetClip(Region)
  View.SetClipToScreen()
  View.ExcludeFromClip(Rectangle)
  View.ExcludeFromClip(Region)
  View.AddViewportToClip()
  View.Draw(DrawContext)
  View.DrawAdornments()
  View.ClearViewport(DrawContext)
  View.DrawText(DrawContext)
  View.DrawSubViews(DrawContext)
  View.RenderLineCanvas(DrawContext)
  View.Move(int, int)
  View.AddRune(Rune)
  View.AddRune(char)
  View.AddRune(int, int, Rune)
  View.AddStr(string)
  View.AddStr(int, int, string)
  View.DrawHotString(string, Attribute, Attribute)
  View.DrawHotString(string, bool)
  View.FillRect(Rectangle, Color?)
  View.FillRect(Rectangle, Rune)
  View.GetScheme()
  View.SetScheme(Scheme)
  View.GetSubViews(bool, bool, bool)
  View.Add(View)
  View.Add(params View[])
  View.Remove(View)
  View.RemoveAll()
  View.RemoveAll<TView>()
  View.GetTopSuperView(View, View)
  View.IsInHierarchy(View, View, bool)
  View.MoveSubViewTowardsEnd(View)
  View.MoveSubViewToEnd(View)
  View.MoveSubViewTowardsStart(View)
  View.MoveSubViewToStart(View)
  View.AddKeyBindingsForHotKey(Key, Key, object)
  View.AssignHotKeysToSubViews()
  View.NewKeyDownEvent(Key)
  View.Contains(in Point)
  View.FrameToScreen()
  View.ScreenToFrame(in Point)
  View.Layout(Size)
  View.Layout()
  View.SetRelativeLayout(Size)
  View.SetNeedsLayout()
  View.GetContainerSize()
  View.GetViewsUnderLocation(in Point, ViewportSettingsFlags)
  View.AdvanceFocus(NavigationDirection, TabBehavior?)
  View.FocusDeepest(NavigationDirection, TabBehavior?)
  View.OnCanFocusChanged()
  View.ClearFocus()
  View.SetFocus()
  View.SetNeedsDraw()
  View.SetNeedsDraw(Rectangle)
  View.OnTextChanged()
  View.MouseBindings
  View.MouseHoldRepeat
  View.MousePositionTracking
  View.MouseState
  View.MouseHighlightStates
  View.Margin
  View.ShadowStyle
  View.Border
  View.BorderStyle
  View.Padding
  View.Arrangement
  View.DefaultAcceptView
  View.CommandsToBubbleUp
  View.ContentSizeTracksViewport
  View.ViewportSettings
  View.Viewport
  View.Data
  View.Id
  View.App
  View.IsInitialized
  View.Enabled
  View.Visible
  View.Title
  View.Cursor
  View.Diagnostics
  View.LineCanvas
  View.SuperViewRendersLineCanvas
  View.SchemeName
  View.HasScheme
  View.SubViews
  View.SuperView
  View.HotKey
  View.HotKeySpecifier
  View.AssignHotKeys
  View.UsedHotKeys
  View.KeyBindings
  View.HotKeyBindings
  View.Frame
  View.X
  View.Y
  View.Height
  View.Width
  View.NeedsLayout
  View.ValidatePosDim
  View.CanFocus
  View.Focused
  View.IsCurrentTop
  View.MostFocused
  View.HasFocus
  View.TabStop
  View.NeedsDraw
  View.HorizontalScrollBar
  View.VerticalScrollBar
  View.PreserveTrailingSpaces
  View.Text
  View.TextAlignment
  View.TextDirection
  View.TextFormatter
  View.VerticalTextAlignment
  View.MouseEnter
  View.MouseLeave
  View.MouseHoldRepeatChanging
  View.MouseHoldRepeatChanged
  View.MouseEvent
  View.MouseStateChanged
  View.BorderStyleChanged
  View.CommandNotBound
  View.Accepting
  View.Accepted
  View.Activating
  View.Activated
  View.HandlingHotKey
  View.HotKeyCommand
  View.ContentSizeChanging
  View.ContentSizeChanged
  View.ViewportChanged
  View.Disposing
  View.Initialized
  View.EnabledChanged
  View.VisibleChanging
  View.VisibleChanged
  View.TitleChanging
  View.TitleChanged
  View.GettingAttributeForRole
  View.ClearingViewport
  View.ClearedViewport
  View.DrawingText
  View.DrewText
  View.DrawingContent
  View.DrawingSubViews
  View.DrawComplete
  View.SchemeNameChanging
  View.SchemeNameChanged
  View.GettingScheme
  View.SchemeChanging
  View.SchemeChanged
  View.SuperViewChanging
  View.SuperViewChanged
  View.SubViewAdded
  View.SubViewRemoved
  View.Removed
  View.HotKeyChanged
  View.KeyDown
  View.KeyDownNotHandled
  View.FrameChanged
  View.HeightChanging
  View.HeightChanged
  View.WidthChanging
  View.WidthChanged
  View.SubViewLayout
  View.SubViewsLaidOut
  View.AdvancingFocus
  View.CanFocusChanged
  View.FocusedChanged
  View.HasFocusChanging
  View.HasFocusChanged
  View.TextChanged
  object.GetType()
  object.Equals(object)
  object.Equals(object, object)
  object.ReferenceEquals(object, object)
  object.GetHashCode()

## Constructors

### MainWindow(IApplication, ChatMessageManager)

    public MainWindow(IApplication app, ChatMessageManager messageManager)

#### Parameters

`app` IApplication
`messageManager` ChatMessageManager

## Properties

### CurrentChannel

Get the current channel name.

    public string CurrentChannel { get; }

#### Property Value

string

### HasPendingReplyIndicator

    public bool HasPendingReplyIndicator { get; }

#### Property Value

bool

## Methods

### ApplyColorSchemes()

Applies the currently registered color schemes to all views. Call after theme changes to refresh colors.

    public void ApplyColorSchemes()

### ClearAll()

Clear all messages and channels (used on disconnect).

    public void ClearAll()

### EnsureChannelInList(string, bool?, bool?, bool?)

Ensure a channel exists in the left panel list (used for private channels joined via /join).

    public void EnsureChannelInList(string channelName, bool? isPublic = null, bool? isProtected = null, bool? isSystem = null)

#### Parameters

`channelName` string
`isPublic` bool?
`isProtected` bool?
`isSystem` bool?

### FocusInput()

Focus the input field for typing.

    public void FocusInput()

### GetChannelNames()

Get all channel names that have message buffers (for broadcasting status changes).

    public IReadOnlyList<string> GetChannelNames()

#### Returns

IReadOnlyList<string>

### RefreshMenuBar()

Rebuilds and replaces the menu bar (e.g., after theme list changes).

    public void RefreshMenuBar()

### RemoveChannel(string)

Remove a channel from the left panel list.

    public void RemoveChannel(string channelName)

#### Parameters

`channelName` string

### SetChannelTopic(string, string?)

Update the topic for a specific channel.

    public void SetChannelTopic(string channelName, string? topic)

#### Parameters

`channelName` string
`topic` string

### SetChannels(List<ChannelDto>)

Set the list of available channels, storing topics, and refresh the channel list view.

    public void SetChannels(List<ChannelDto> channels)

#### Parameters

`channels` List<ChannelDto>

### SetCurrentUser(string)

Set the current user name (delegates to message manager for @mention detection).

    public void SetCurrentUser(string username)

#### Parameters

`username` string

### SetReplyingTo(string?)

Shows/clears the "replying to" strip on the input frame's title. Pass null to clear.

    public void SetReplyingTo(string? label)

#### Parameters

`label` string

### SetStagedAttachments(IReadOnlyList<string>, string)

Updates the attachment staging indicator shown on the input frame's title, including the current ASCII-art size for images. Passing an empty list restores the default hint.

    public void SetStagedAttachments(IReadOnlyList<string> fileNames, string asciiSizeLabel)

#### Parameters

`fileNames` IReadOnlyList<string>
`asciiSizeLabel` string

### ShowError(string)

Show an error message to the user.

    public void ShowError(string message)

#### Parameters

`message` string

### SwitchToChannel(string)

Switch the chat view to the given channel, resetting its unread count and updating the topic bar.

    public void SwitchToChannel(string channelName)

#### Parameters

`channelName` string

### ToggleUsersPanel()

Toggle the online users panel visibility (F2).

    public void ToggleUsersPanel()

### UpdateOnlineUsers(List<UserPresenceDto>)

Update the online users list display.

    public void UpdateOnlineUsers(List<UserPresenceDto> users)

#### Parameters

`users` List<UserPresenceDto>

### UpdateStatusBar(string)

Update the connection status displayed in the status bar.

    public void UpdateStatusBar(string status)

#### Parameters

`status` string

## Events

### OnAudioPlayRequested

Fired when the user activates (Enter/click) an audio message. Parameters: attachmentUrl, fileName.

    public event Action<string, string>? OnAudioPlayRequested

#### Event Type

Action<string, string>

### OnChannelJoinRequested

Fired when the user activates a #channel reference in a message. Parameter is the channel name.

    public event Action<string>? OnChannelJoinRequested

#### Event Type

Action<string>

### OnChannelSelected

Fired when the user selects a channel. Parameter is the channel name.

    public event Action<string>? OnChannelSelected

#### Event Type

Action<string>

### OnCheckForUpdatesRequested

Fired when the user requests to check for updates.

    public event Action? OnCheckForUpdatesRequested

#### Event Type

Action

### OnConnectRequested

Fired when the user requests to connect via the menu.

    public event Action? OnConnectRequested

#### Event Type

Action

### OnCreateChannelRequested

Fired when the user requests to create a new channel.

    public event Action? OnCreateChannelRequested

#### Event Type

Action

### OnDeleteChannelRequested

Fired when the user requests to delete the current channel.

    public event Action? OnDeleteChannelRequested

#### Event Type

Action

### OnDeleteMessageRequested

Fired when the user presses Delete on the selected message. Parameter is the message id.

    public event Action<Guid>? OnDeleteMessageRequested

#### Event Type

Action<Guid>

### OnDisconnectRequested

Fired when the user requests to disconnect via the menu.

    public event Action? OnDisconnectRequested

#### Event Type

Action

### OnFileDownloadRequested

Fired when the user activates (Enter/click) a file message. Parameters: attachmentUrl, fileName.

    public event Action<string, string>? OnFileDownloadRequested

#### Event Type

Action<string, string>

### OnFilesStaged

Fired when local files arrive via paste or drag-and-drop to be staged as attachments. Parameters: channel name, absolute paths of existing files.

    public event Action<string, IReadOnlyList<string>>? OnFilesStaged

#### Event Type

Action<string, IReadOnlyList<string>>

### OnImageOpenRequested

Fired when the user activates an image's "[open]" action to view it without saving. Parameters: attachmentUrl, fileName.

    public event Action<string, string>? OnImageOpenRequested

#### Event Type

Action<string, string>

### OnImagePasted

Fired when raw image data is pasted from the clipboard (e.g. copied from a browser or a screenshot tool). Parameters: channel name, PNG-encoded image bytes.

    public event Action<string, byte[]>? OnImagePasted

#### Event Type

Action<string, byte[]>

### OnImageSaveRequested

Fired when the user activates an image's "[save original]" line. Parameters: attachmentUrl, fileName.

    public event Action<string, string>? OnImageSaveRequested

#### Event Type

Action<string, string>

### OnLoadMoreRequested

Fired when the user scrolls to the top of the message list and older messages should be loaded.

    public event Action? OnLoadMoreRequested

#### Event Type

Action

### OnLogoutRequested

Fired when the user requests to logout (disconnect + revoke session).

    public event Action? OnLogoutRequested

#### Event Type

Action

### OnMessageSubmitted

Fired when the user presses Enter in the input field. Parameters: channel name, message content.

    public event Action<string, string>? OnMessageSubmitted

#### Event Type

Action<string, string>

### OnProfileRequested

Fired when the user requests to open their profile panel.

    public event Action? OnProfileRequested

#### Event Type

Action

### OnReplyCancelRequested

Fired when the user cancels a pending reply (Esc in the input field).

    public event Action? OnReplyCancelRequested

#### Event Type

Action

### OnReplyRequested

Fired when the user picks "Reply" on a message. Parameters: message id, sender username, a short plain-text snippet for the reply strip.

    public event Action<Guid, string, string>? OnReplyRequested

#### Event Type

Action<Guid, string, string>

### OnRollbackRequested

Fired when the user requests to rollback to the previous version.

    public event Action? OnRollbackRequested

#### Event Type

Action

### OnSavedServersRequested

Fired when the user requests to view saved servers.

    public event Action? OnSavedServersRequested

#### Event Type

Action

### OnSearchRequested

Fired when the user requests to open the search dialog (via menu or Ctrl+K).

    public event Action? OnSearchRequested

#### Event Type

Action

### OnStatusRequested

Fired when the user requests to set their status.

    public event Action? OnStatusRequested

#### Event Type

Action

### OnThemeSelected

Fired when the user selects a theme from the menu. Parameter is the theme name.

    public event Action<string>? OnThemeSelected

#### Event Type

Action<string>

### OnUserProfileRequested

Fired when the user activates a username (in userlist or message). Parameter is the username.

    public event Action<string>? OnUserProfileRequested

#### Event Type

Action<string>