diff options
author | Adam <Adam@anope.org> | 2011-12-19 15:37:15 -0500 |
---|---|---|
committer | Adam <Adam@anope.org> | 2011-12-19 15:37:15 -0500 |
commit | 45fc3ce1c41b06af6e03712988870ead95b72435 (patch) | |
tree | 7b574d077f77707edb3916fb43dfa30dec8b0f54 /include | |
parent | d320c73f23ff7a9b848b86b59c6bf91c1254e410 (diff) |
Fixed formatting of many lists and INFO outputs
Diffstat (limited to 'include')
-rw-r--r-- | include/language.h | 13 | ||||
-rw-r--r-- | include/modules.h | 6 | ||||
-rw-r--r-- | include/services.h | 25 |
3 files changed, 29 insertions, 15 deletions
diff --git a/include/language.h b/include/language.h index 91bc462cb..9af139ed9 100644 --- a/include/language.h +++ b/include/language.h @@ -30,7 +30,6 @@ #define NO_REASON _("No reason") #define UNKNOWN _("<unknown>") #define NO_EXPIRE _("does not expire") -#define END_OF_ANY_LIST _("End of \002%s\002 list.") #define LIST_INCORRECT_RANGE _("Incorrect range specified. The correct syntax is \002#\037from\037-\037to\037\002.") #define UNKNOWN_OPTION _("Unknown option \002%s\002.\n" \ "Type %s%s HELP %s for more information.") @@ -47,7 +46,6 @@ #define NICK_SET_UNKNOWN_OPTION _("Unknown SET option \002%s%s\002.") #define NICK_SET_DISPLAY_CHANGED _("The new display is now \002%s\002.") #define NICK_LIST_SYNTAX _("LIST \037pattern\037") -#define LIST_HEADER _("List of entries matching \002%s\002:") #define NICK_RECOVERED _("User claiming your nick has been killed.\n" \ "\002%s%s RELEASE %s\002 to get it back before %s timeout.") #define NICK_REQUESTED _("This nick has already been requested, please check your e-mail address for the pass code") @@ -62,16 +60,8 @@ #define CHAN_SETTING_UNSET _("%s for %s unset.") #define CHAN_SET_MLOCK_DEPRECATED _("MLOCK is deprecated. Use \002%s%s HELP MODE\002 instead.") #define CHAN_ACCESS_LEVEL_RANGE _("Access level must be between %d and %d inclusive.") -#define CHAN_ACCESS_LIST_HEADER _("Access list for %s:\n" \ - " Num Lev Mask") -#define CHAN_ACCESS_VIEW_AXS_FORMAT _(" %3d %4d %s\n" \ - " by %s on %s, last seen %s") -#define CHAN_AKICK_VIEW_FORMAT _("%3d %s (by %s on %s)\n" \ - " %s") #define CHAN_INFO_HEADER _("Information for channel \002%s\002:") #define CHAN_EXCEPTED _("\002%s\002 matches an except on %s and cannot be banned until the except have been removed.") -#define CHAN_LIST_ENTRY _("%3d %s\n" \ - " Added by %s on %s") #define MEMO_NEW_X_MEMO_ARRIVED _("There is a new memo on channel %s.\n" \ "Type \002%s%s READ %s %d\002 to read it.") #define MEMO_NEW_MEMO_ARRIVED _("You have a new memo from %s.\n" \ @@ -88,9 +78,6 @@ #define BOT_ASSIGN_READONLY _("Sorry, bot assignment is temporarily disabled.") #define ENABLED _("Enabled") #define DISABLED _("Disabled") -#define OPER_LIST_FORMAT _(" %3d %-32s %s") -#define OPER_VIEW_FORMAT _("%3d %s (by %s on %s; %s)\n" \ - " %s") #define HOST_SET_ERROR _("A vhost must be in the format of a valid hostmask.") #define HOST_SET_IDENT_ERROR _("A vhost ident must be in the format of a valid ident") #define HOST_SET_TOOLONG _("Error! The vhost is too long, please use a host shorter than %d characters.") diff --git a/include/modules.h b/include/modules.h index d3a43cd8a..ca0656e06 100644 --- a/include/modules.h +++ b/include/modules.h @@ -640,9 +640,10 @@ class CoreExport Module : public Extensible /** Called when a user requests info for a channel * @param source The user requesting info * @param ci The channel the user is requesting info for + * @param info Data to show the user requesting information * @param ShowHidden true if we should show the user everything */ - virtual void OnChanInfo(CommandSource &source, ChannelInfo *ci, bool ShowHidden) { } + virtual void OnChanInfo(CommandSource &source, ChannelInfo *ci, InfoFormatter &info, bool ShowHidden) { } /** Called on cs_findchan() * @param chname The name being looked up @@ -758,9 +759,10 @@ class CoreExport Module : public Extensible /** Called when a user requests info for a nick * @param source The user requesting info * @param na The nick the user is requesting info from + * @param info Data to show the user requesting information * @param ShowHidden true if we should show the user everything */ - virtual void OnNickInfo(CommandSource &source, NickAlias *na, bool ShowHidden) { } + virtual void OnNickInfo(CommandSource &source, NickAlias *na, InfoFormatter &info, bool ShowHidden) { } /** Called in findnick() * Useful to modify the na returned by findnick() diff --git a/include/services.h b/include/services.h index 1da51e296..3bf8d4494 100644 --- a/include/services.h +++ b/include/services.h @@ -915,4 +915,29 @@ class CoreExport NumberList virtual bool InvalidRange(const Anope::string &list); }; +class CoreExport ListFormatter +{ + public: + typedef std::map<Anope::string, Anope::string> ListEntry; + private: + std::vector<Anope::string> columns; + std::vector<ListEntry> entries; + public: + ListFormatter &addColumn(const Anope::string &name); + void addEntry(const ListEntry &entry); + bool isEmpty() const; + void Process(std::vector<Anope::string> &); +}; + +class CoreExport InfoFormatter +{ + User *user; + std::vector<std::pair<Anope::string, Anope::string> > replies; + unsigned longest; + public: + InfoFormatter(User *u); + void Process(std::vector<Anope::string> &); + Anope::string &operator[](const Anope::string &key); +}; + #endif /* SERVICES_H */ |