Chat-O-Matic/application/views/RenderView.cpp
Jaidyn Ann e760818007 (librunview) Init new RenderView/RunView
Base-level replacement of the Vision-derived text RunView― a couple
important features supported by the replacee haven't been implemented yet,
including:
	* Right-click menu
	* URL-highlighting/selection
	* Emote support
2021-07-14 15:12:04 -05:00

55 lines
1.1 KiB
C++

/*
* Copyright 2021, Jaidyn Levesque <jadedctrl@teknik.io>
* All rights reserved. Distributed under the terms of the MIT license.
*/
#include "RenderView.h"
#include <InterfaceDefs.h>
RenderView::RenderView(const char* name)
:
RunView(name)
{
}
void
RenderView::AppendMessage(const char* nick, const char* message,
rgb_color nameColor, time_t time)
{
if (BString(message).IsEmpty() == true) return;
AppendTimestamp(time);
Append("<", nameColor);
Append(nick);
Append("> ", nameColor);
Append(message);
if (BString(message).EndsWith("\n") == false) Append("\n");
}
void
RenderView::AppendGenericMessage(const char* message)
{
if (BString(message).IsEmpty() == true) return;
AppendTimestamp(time(NULL));
Append(message, ui_color(B_PANEL_TEXT_COLOR), B_BOLD_FACE);
if (BString(message).EndsWith("\n") == false) Append("\n");
}
void
RenderView::AppendTimestamp(time_t time)
{
if (time == 0) {
Append("[xx:xx] ", ui_color(B_LINK_HOVER_COLOR));
return;
}
char timestamp[9] = { '\0' };
strftime(timestamp, 8, "[%H:%M] ", localtime(&time));
Append(timestamp, ui_color(B_LINK_HOVER_COLOR));
}