51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
*/
-#ifndef CHAT_HEADER
-#define CHAT_HEADER
+#pragma once
#include <string>
#include <vector>
#include "irrlichttypes.h"
#include "util/enriched_string.h"
+#include "settings.h"
// Chat console related classes
// Append chat line
// Removes oldest chat line if scrollback size is reached
- void addLine(std::wstring name, std::wstring text);
+ void addLine(const std::wstring &name, const std::wstring &text);
// Remove all chat lines
void clear();
// Delete lines older than maxAge.
void deleteByAge(f32 maxAge);
- // Get number of columns, 0 if reformat has not been called yet.
- u32 getColumns() const;
// Get number of rows, 0 if reformat has not been called yet.
u32 getRows() const;
// Update console size and reformat all formatted lines.
u32 formatChatLine(const ChatLine& line, u32 cols,
std::vector<ChatFormattedLine>& destination) const;
+ void resize(u32 scrollback);
protected:
s32 getTopScrollPos() const;
s32 getBottomScrollPos() const;
void input(const std::wstring &str);
// Add a string to the history
- void addToHistory(std::wstring line);
+ void addToHistory(const std::wstring &line);
// Get current line
std::wstring getLine() const { return m_line; }
void clear();
// Replace the current line with the given text
- std::wstring replace(std::wstring line);
+ std::wstring replace(const std::wstring &line);
// Select previous command from history
void historyPrev();
~ChatBackend() = default;
// Add chat message
- void addMessage(std::wstring name, std::wstring text);
+ void addMessage(const std::wstring &name, std::wstring text);
// Parse and add unparsed chat message
void addUnparsedMessage(std::wstring line);
// Get the recent messages buffer
ChatBuffer& getRecentBuffer();
// Concatenate all recent messages
- EnrichedString getRecentChat();
+ EnrichedString getRecentChat() const;
// Get the console prompt
ChatPrompt& getPrompt();
void scrollPageDown();
void scrollPageUp();
+ // Resize recent buffer based on settings
+ void applySettings();
+
private:
ChatBuffer m_console_buffer;
ChatBuffer m_recent_buffer;
ChatPrompt m_prompt;
};
-
-#endif
-