mirror of
https://github.com/RedWizardsLab/EchoHub.git
synced 2026-09-04 23:34:10 +02:00
- Introduced HexColorHelper for parsing hex color strings to Terminal.Gui Attributes and Colors. - Created ChannelListSource for managing and rendering a list of channels with unread counts and active indicators. - Developed UserListSource for displaying online users with per-user nickname colors. - Refactored MainWindow to utilize ChatMessageManager for handling messages and channel state. - Updated project references and removed unused content from the server project. - Adjusted tests to reflect changes in namespaces and structure.
28 lines
780 B
C#
28 lines
780 B
C#
using Terminal.Gui.Drawing;
|
|
using Terminal.Gui.Text;
|
|
using Terminal.Gui.Views;
|
|
|
|
namespace EchoHub.Client.UI.Chat;
|
|
|
|
/// <summary>
|
|
/// Shared rendering helpers for IListDataSource implementations.
|
|
/// </summary>
|
|
static class RenderHelpers
|
|
{
|
|
/// <summary>
|
|
/// Write text grapheme-by-grapheme to a ListView, respecting a width limit.
|
|
/// Returns the updated drawn-columns count.
|
|
/// </summary>
|
|
public static int WriteText(ListView lv, string text, int drawn, int maxWidth)
|
|
{
|
|
foreach (var grapheme in GraphemeHelper.GetGraphemes(text))
|
|
{
|
|
var cols = Math.Max(grapheme.GetColumns(), 1);
|
|
if (drawn + cols > maxWidth) break;
|
|
lv.AddStr(grapheme);
|
|
drawn += cols;
|
|
}
|
|
return drawn;
|
|
}
|
|
}
|