mirror of
https://github.com/RedWizardsLab/EchoHub.git
synced 2026-09-06 07:36:01 +02:00
Add hex color parsing helper and implement custom list sources for channels and users
- 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.
This commit is contained in:
@@ -0,0 +1,27 @@
|
||||
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;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user