mirror of
https://github.com/RGBCube/serenity
synced 2025-07-26 05:27:46 +00:00
IRCClient: Use new format functions.
This commit is contained in:
parent
d2ca7ca017
commit
da9c995a8c
7 changed files with 35 additions and 29 deletions
|
@ -62,22 +62,22 @@ static String timestamp_string()
|
|||
{
|
||||
auto now = time(nullptr);
|
||||
auto* tm = localtime(&now);
|
||||
return String::format("%02u:%02u:%02u ", tm->tm_hour, tm->tm_min, tm->tm_sec);
|
||||
return String::formatted("{:02}:{:02}:{:02} ", tm->tm_hour, tm->tm_min, tm->tm_sec);
|
||||
}
|
||||
|
||||
void IRCLogBuffer::add_message(char prefix, const String& name, const String& text, Color color)
|
||||
{
|
||||
auto nick_string = String::format("<%c%s> ", prefix ? prefix : ' ', name.characters());
|
||||
auto html = String::format(
|
||||
"<span>%s</span>"
|
||||
"<b>%s</b>"
|
||||
"<span>%s</span>",
|
||||
timestamp_string().characters(),
|
||||
escape_html_entities(nick_string).characters(),
|
||||
escape_html_entities(text).characters());
|
||||
auto nick_string = String::formatted("<{}{}> ", prefix ? prefix : ' ', name.characters());
|
||||
auto html = String::formatted(
|
||||
"<span>{}</span>"
|
||||
"<b>{}</b>"
|
||||
"<span>{}</span>",
|
||||
timestamp_string(),
|
||||
escape_html_entities(nick_string),
|
||||
escape_html_entities(text));
|
||||
|
||||
auto wrapper = Web::DOM::create_element(*m_document, Web::HTML::TagNames::div);
|
||||
wrapper->set_attribute(Web::HTML::AttributeNames::style, String::format("color: %s", color.to_string().characters()));
|
||||
wrapper->set_attribute(Web::HTML::AttributeNames::style, String::formatted("color: {}", color.to_string()));
|
||||
wrapper->set_inner_html(html);
|
||||
m_container_element->append_child(wrapper);
|
||||
m_document->force_layout();
|
||||
|
@ -85,13 +85,13 @@ void IRCLogBuffer::add_message(char prefix, const String& name, const String& te
|
|||
|
||||
void IRCLogBuffer::add_message(const String& text, Color color)
|
||||
{
|
||||
auto html = String::format(
|
||||
"<span>%s</span>"
|
||||
"<span>%s</span>",
|
||||
timestamp_string().characters(),
|
||||
escape_html_entities(text).characters());
|
||||
auto html = String::formatted(
|
||||
"<span>{}</span>"
|
||||
"<span>{}</span>",
|
||||
timestamp_string(),
|
||||
escape_html_entities(text));
|
||||
auto wrapper = Web::DOM::create_element(*m_document, Web::HTML::TagNames::div);
|
||||
wrapper->set_attribute(Web::HTML::AttributeNames::style, String::format("color: %s", color.to_string().characters()));
|
||||
wrapper->set_attribute(Web::HTML::AttributeNames::style, String::formatted("color: {}", color.to_string()));
|
||||
wrapper->set_inner_html(html);
|
||||
m_container_element->append_child(wrapper);
|
||||
m_document->force_layout();
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue