1
0
mirror of https://github.com/anope/anope.git synced 2026-06-26 15:16:38 +02:00

Vendor utfcpp, use to fix alignment for non-ascii syntax messages.

This commit is contained in:
Sadie Powell
2025-08-24 23:18:06 +01:00
parent 04de41ad7f
commit 43f88524e2
6 changed files with 823 additions and 1 deletions
+4 -1
View File
@@ -17,6 +17,8 @@
#include "regchannel.h"
#include "channels.h"
#include "utfcpp/unchecked.h"
void CommandReply::SendMessage(CommandSource &source, const Anope::string &msg)
{
SendMessage(source.service, msg);
@@ -150,6 +152,7 @@ void Command::SendSyntax(CommandSource &source)
{
auto first = true;
Anope::string prefix = Language::Translate(source.GetAccount(), _("Syntax"));
Anope::string padding(utf8::unchecked::distance(prefix.str().begin(), prefix.str().end()), ' ');
for (const auto &[syntax, predicate] : this->syntax)
{
if (predicate && !predicate(source))
@@ -163,7 +166,7 @@ void Command::SendSyntax(CommandSource &source)
}
else
{
source.Reply("%-*s \002%s %s\002", (int)prefix.length(), "", source.command.nobreak().c_str(),
source.Reply("%s \002%s %s\002", padding.c_str(), source.command.nobreak().c_str(),
Language::Translate(source.GetAccount(), syntax.c_str()));
}
}