From 74e9a9d2feb3690dc06a310e0477cd6f17e25fab Mon Sep 17 00:00:00 2001 From: Sadie Powell Date: Wed, 16 Apr 2025 01:46:52 +0100 Subject: Automatically wrap the help output. --- include/commands.h | 3 ++- include/textproc.h | 18 +++++++++++++++--- 2 files changed, 17 insertions(+), 4 deletions(-) (limited to 'include') diff --git a/include/commands.h b/include/commands.h index e9df980e0..9692f438c 100644 --- a/include/commands.h +++ b/include/commands.h @@ -14,6 +14,7 @@ #include "service.h" #include "anope.h" #include "channels.h" +#include "textproc.h" struct CommandGroup final { @@ -153,7 +154,7 @@ public: /** Called when help is requested for the client this command is on. * @param source The source */ - virtual void OnServHelp(CommandSource &source); + virtual void OnServHelp(CommandSource &source, HelpWrapper &help); /** Requested when the user is requesting help on this command. Help on this command should be sent to the user. * @param source The source diff --git a/include/textproc.h b/include/textproc.h index 62c88bcb4..cfde60637 100644 --- a/include/textproc.h +++ b/include/textproc.h @@ -11,14 +11,26 @@ #pragma once -class TextSplitter final +class CoreExport HelpWrapper final +{ +private: + std::vector> entries; + size_t longest = 0; + +public: + void AddEntry(const Anope::string &name, const Anope::string &desc); + void SendTo(CommandSource &source); +}; + +class CoreExport TextSplitter final { private: - Anope::string text; std::vector formatting; + const size_t max_length; + Anope::string text; public: - TextSplitter(const Anope::string &t); + TextSplitter(const Anope::string &t, size_t ml = 0); bool GetLine(Anope::string &out); }; -- cgit