#ifndef display_buffer_hh_INCLUDED #define display_buffer_hh_INCLUDED #include #include #include "buffer.hh" namespace Kakoune { typedef int Attribute; enum Attributes { Normal = 0, Underline = 1, Reverse = 2, Blink = 4, Bold = 8, }; enum class Color { Default, Black, Red, Green, Yellow, Blue, Magenta, Cyan, White }; struct DisplayAtom { std::string content; BufferIterator begin; BufferIterator end; Color fg_color; Color bg_color; Attribute attribute; DisplayAtom(BufferIterator begin, BufferIterator end, const std::string& content, Color fg_color = Color::Default, Color bg_color = Color::Default, Attribute attribute = Attributes::Normal) : content(content), begin(begin), end(end), fg_color(fg_color), bg_color(bg_color), attribute(attribute) {} }; class DisplayBuffer { public: typedef std::vector AtomList; 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, size_t pos_in_atom); 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; private: AtomList m_atoms; }; } #endif // display_buffer_hh_INCLUDED