ladybird/Applications/IRCClient/IRCLogBuffer.h
Andreas Kling 73fdbba59c AK: Rename <AK/AKString.h> to <AK/String.h>
This was a workaround to be able to build on case-insensitive file
systems where it might get confused about <string.h> vs <String.h>.

Let's just not support building that way, so String.h can have an
objectively nicer name. :^)
2019-09-06 15:36:54 +02:00

38 lines
1.0 KiB
C++

#pragma once
#include <AK/String.h>
#include <AK/CircularQueue.h>
#include <AK/RefPtr.h>
#include <AK/RefCounted.h>
#include <LibDraw/Color.h>
class IRCLogBufferModel;
class IRCLogBuffer : public RefCounted<IRCLogBuffer> {
public:
static NonnullRefPtr<IRCLogBuffer> create();
~IRCLogBuffer();
struct Message {
time_t timestamp { 0 };
char prefix { 0 };
String sender;
String text;
Color color { Color::Black };
};
int count() const { return m_messages.size(); }
const Message& at(int index) const { return m_messages.at(index); }
void add_message(char prefix, const String& name, const String& text, Color = Color::Black);
void add_message(const String& text, Color = Color::Black);
void dump() const;
const IRCLogBufferModel* model() const { return m_model.ptr(); }
IRCLogBufferModel* model() { return m_model.ptr(); }
private:
IRCLogBuffer();
NonnullRefPtr<IRCLogBufferModel> m_model;
CircularQueue<Message, 1000> m_messages;
};