2021-07-14 13:17:00 -05:00
|
|
|
/*
|
|
|
|
* Copyright 2021, Jaidyn Levesque <jadedctrl@teknik.io>
|
|
|
|
* All rights reserved. Distributed under the terms of the MIT license.
|
|
|
|
*/
|
2021-05-19 16:12:19 -05:00
|
|
|
|
2021-07-14 13:17:00 -05:00
|
|
|
#include "RenderView.h"
|
2021-05-19 16:12:19 -05:00
|
|
|
|
2021-07-14 13:17:00 -05:00
|
|
|
#include <InterfaceDefs.h>
|
2010-05-07 04:47:10 -05:00
|
|
|
|
2010-05-20 13:37:01 -05:00
|
|
|
|
2021-07-14 13:17:00 -05:00
|
|
|
RenderView::RenderView(const char* name)
|
2012-10-18 15:59:15 -05:00
|
|
|
:
|
2021-07-14 13:17:00 -05:00
|
|
|
RunView(name)
|
2010-05-07 04:47:10 -05:00
|
|
|
{
|
|
|
|
}
|
|
|
|
|
2021-05-24 01:47:21 -05:00
|
|
|
|
2010-05-20 13:37:01 -05:00
|
|
|
void
|
2021-06-20 12:44:20 -05:00
|
|
|
RenderView::AppendMessage(const char* nick, const char* message,
|
2021-07-14 13:17:00 -05:00
|
|
|
rgb_color nameColor, time_t time)
|
2010-05-07 04:47:10 -05:00
|
|
|
{
|
2021-07-14 13:17:00 -05:00
|
|
|
if (BString(message).IsEmpty() == true) return;
|
2010-05-20 13:37:01 -05:00
|
|
|
|
2021-07-14 13:17:00 -05:00
|
|
|
AppendTimestamp(time);
|
|
|
|
Append("<", nameColor);
|
|
|
|
Append(nick);
|
|
|
|
Append("> ", nameColor);
|
|
|
|
Append(message);
|
2010-05-07 04:47:10 -05:00
|
|
|
|
2021-07-14 13:17:00 -05:00
|
|
|
if (BString(message).EndsWith("\n") == false) Append("\n");
|
2021-05-24 19:12:42 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2010-05-07 04:47:10 -05:00
|
|
|
void
|
2021-07-14 13:17:00 -05:00
|
|
|
RenderView::AppendGenericMessage(const char* message)
|
2010-05-20 13:37:01 -05:00
|
|
|
{
|
2021-07-14 13:17:00 -05:00
|
|
|
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");
|
2010-05-07 04:47:10 -05:00
|
|
|
}
|
|
|
|
|
2021-05-24 01:47:21 -05:00
|
|
|
|
2010-05-07 04:47:10 -05:00
|
|
|
void
|
2021-07-14 13:17:00 -05:00
|
|
|
RenderView::AppendTimestamp(time_t time)
|
2010-05-07 04:47:10 -05:00
|
|
|
{
|
2021-07-14 13:17:00 -05:00
|
|
|
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));
|
2010-05-07 04:47:10 -05:00
|
|
|
}
|