ladybird/Applications/IRCClient/IRCLogBuffer.h
Andreas Kling 1c0669f010 LibDraw: Introduce (formerly known as SharedGraphics.)
Instead of LibGUI and WindowServer building their own copies of the drawing
and graphics code, let's it in a separate LibDraw library.

This avoids building the code twice, and will encourage better separation
of concerns. :^)
2019-07-18 10:18:16 +02:00

37 lines
1 KiB
C++

#pragma once
#include <AK/AKString.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;
};