1
1
mirror of https://github.com/mawww/kakoune.git synced 2024-12-30 15:13:30 +03:00
kakoune/src/display_buffer.hh

85 lines
1.7 KiB
C++
Raw Normal View History

2011-09-02 20:51:20 +04:00
#ifndef display_buffer_hh_INCLUDED
#define display_buffer_hh_INCLUDED
#include <string>
#include <vector>
#include "buffer.hh"
2011-09-02 20:51:20 +04:00
namespace Kakoune
{
typedef int Attribute;
enum Attributes
{
2011-09-26 03:51:12 +04:00
Normal = 0,
Underline = 1,
Reverse = 2,
Blink = 4,
Bold = 8,
};
enum class Color
{
Default,
Black,
Red,
Green,
Yellow,
Blue,
Magenta,
Cyan,
White
2011-09-02 20:51:20 +04:00
};
struct DisplayAtom
{
BufferIterator begin;
BufferIterator end;
Color fg_color;
Color bg_color;
Attribute attribute;
BufferString replacement_text;
2011-09-02 20:51:20 +04:00
DisplayAtom(BufferIterator begin, BufferIterator end,
Color fg_color = Color::Default,
Color bg_color = Color::Default,
Attribute attribute = Attributes::Normal)
: begin(begin),
end(end),
fg_color(fg_color),
bg_color(bg_color),
attribute(attribute)
2011-09-26 03:51:12 +04:00
{}
2011-09-02 20:51:20 +04:00
};
class DisplayBuffer
{
public:
typedef std::vector<DisplayAtom> AtomList;
2011-09-02 20:51:20 +04:00
typedef AtomList::iterator iterator;
typedef AtomList::const_iterator const_iterator;
DisplayBuffer();
void clear() { m_atoms.clear(); }
void append(const DisplayAtom& atom) { m_atoms.push_back(atom); }
iterator insert(iterator where, const DisplayAtom& atom) { return m_atoms.insert(where, atom); }
iterator split(iterator atom, const BufferIterator& pos);
2011-09-02 20:51:20 +04:00
iterator begin() { return m_atoms.begin(); }
iterator end() { return m_atoms.end(); }
const_iterator begin() const { return m_atoms.begin(); }
const_iterator end() const { return m_atoms.end(); }
void check_invariant() const;
2011-09-02 20:51:20 +04:00
private:
AtomList m_atoms;
};
}
#endif // display_buffer_hh_INCLUDED