rename BufferString to String

This commit is contained in:
Maxime Coste 2012-03-08 21:23:29 +00:00
parent f2fd2b125a
commit df0f7b4689
9 changed files with 24 additions and 26 deletions

View File

@ -23,7 +23,7 @@ T clamp(T min, T max, T val)
} }
Buffer::Buffer(const std::string& name, Type type, Buffer::Buffer(const std::string& name, Type type,
const BufferString& initial_content) const String& initial_content)
: m_name(name), m_type(type), : m_name(name), m_type(type),
m_history(1), m_history_cursor(m_history.begin()), m_history(1), m_history_cursor(m_history.begin()),
m_content(initial_content), m_last_save_undo_index(0) m_content(initial_content), m_last_save_undo_index(0)
@ -122,7 +122,7 @@ BufferSize Buffer::line_count() const
return m_lines.size(); return m_lines.size();
} }
BufferString Buffer::string(const BufferIterator& begin, const BufferIterator& end) const String Buffer::string(const BufferIterator& begin, const BufferIterator& end) const
{ {
return m_content.substr(begin.m_position, end - begin); return m_content.substr(begin.m_position, end - begin);
} }

View File

@ -17,7 +17,7 @@ class Window;
typedef int BufferPos; typedef int BufferPos;
typedef int BufferSize; typedef int BufferSize;
typedef char BufferChar; typedef char BufferChar;
typedef std::basic_string<BufferChar> BufferString; typedef std::basic_string<BufferChar> String;
struct BufferCoord : LineAndColumn<BufferCoord> struct BufferCoord : LineAndColumn<BufferCoord>
{ {
@ -81,17 +81,16 @@ struct Modification
Type type; Type type;
BufferIterator position; BufferIterator position;
BufferString content; String content;
Modification(Type type, BufferIterator position, Modification(Type type, BufferIterator position, const String& content)
const BufferString& content)
: type(type), position(position), content(content) {} : type(type), position(position), content(content) {}
Modification inverse() const; Modification inverse() const;
static Modification make_erase(BufferIterator begin, BufferIterator end); static Modification make_erase(BufferIterator begin, BufferIterator end);
static Modification make_insert(BufferIterator position, static Modification make_insert(BufferIterator position,
const BufferString& content); const String& content);
}; };
class ModificationListener class ModificationListener
@ -116,7 +115,7 @@ public:
}; };
Buffer(const std::string& name, Type type, Buffer(const std::string& name, Type type,
const BufferString& initial_content = "\n"); const String& initial_content = "\n");
Buffer(const Buffer&) = delete; Buffer(const Buffer&) = delete;
Buffer(Buffer&&) = delete; Buffer(Buffer&&) = delete;
Buffer& operator= (const Buffer&) = delete; Buffer& operator= (const Buffer&) = delete;
@ -130,7 +129,7 @@ public:
bool undo(); bool undo();
bool redo(); bool redo();
BufferString string(const BufferIterator& begin, String string(const BufferIterator& begin,
const BufferIterator& end) const; const BufferIterator& end) const;
BufferIterator begin() const; BufferIterator begin() const;
@ -146,7 +145,7 @@ public:
const std::string& name() const { return m_name; } const std::string& name() const { return m_name; }
const BufferString& content() const { return m_content; } const String& content() const { return m_content; }
Window* get_or_create_window(); Window* get_or_create_window();
void delete_window(Window* window); void delete_window(Window* window);
@ -179,7 +178,7 @@ private:
BufferSize line_length(BufferPos line) const; BufferSize line_length(BufferPos line) const;
void update_lines(const Modification& modification); void update_lines(const Modification& modification);
BufferString m_content; String m_content;
std::string m_name; std::string m_name;
const Type m_type; const Type m_type;
@ -207,7 +206,7 @@ inline Modification Modification::make_erase(BufferIterator begin,
} }
inline Modification Modification::make_insert(BufferIterator position, inline Modification Modification::make_insert(BufferIterator position,
const BufferString& content) const String& content)
{ {
return Modification(Insert, position, content); return Modification(Insert, position, content);
} }

View File

@ -5,7 +5,7 @@
namespace Kakoune namespace Kakoune
{ {
BufferString DisplayAtom::content() const String DisplayAtom::content() const
{ {
if (m_replacement_text.empty()) if (m_replacement_text.empty())
return m_begin.buffer().string(m_begin, m_end); return m_begin.buffer().string(m_begin, m_end);
@ -131,7 +131,7 @@ void DisplayBuffer::check_invariant() const
} }
void DisplayBuffer::replace_atom_content(iterator atom, void DisplayBuffer::replace_atom_content(iterator atom,
const BufferString& replacement) const String& replacement)
{ {
atom->m_replacement_text = replacement; atom->m_replacement_text = replacement;

View File

@ -77,7 +77,7 @@ struct DisplayAtom
Color& bg_color() { return m_bg_color; } Color& bg_color() { return m_bg_color; }
Attribute& attribute() { return m_attribute; } Attribute& attribute() { return m_attribute; }
BufferString content() const; String content() const;
DisplayCoord end_coord() const; DisplayCoord end_coord() const;
BufferIterator iterator_at(const DisplayCoord& coord) const; BufferIterator iterator_at(const DisplayCoord& coord) const;
DisplayCoord line_and_column_at(const BufferIterator& iterator) const; DisplayCoord line_and_column_at(const BufferIterator& iterator) const;
@ -93,7 +93,7 @@ private:
Color m_fg_color; Color m_fg_color;
Color m_bg_color; Color m_bg_color;
Attribute m_attribute; Attribute m_attribute;
BufferString m_replacement_text; String m_replacement_text;
}; };
// A DisplayBuffer is the visual content of a Window as a DisplayAtom list // A DisplayBuffer is the visual content of a Window as a DisplayAtom list
@ -114,7 +114,7 @@ public:
iterator insert(iterator where, const DisplayAtom& atom); iterator insert(iterator where, const DisplayAtom& atom);
iterator split(iterator atom, const BufferIterator& pos); iterator split(iterator atom, const BufferIterator& pos);
void replace_atom_content(iterator atom, const BufferString& replacement); void replace_atom_content(iterator atom, const String& replacement);
iterator begin() { return m_atoms.begin(); } iterator begin() { return m_atoms.begin(); }
iterator end() { return m_atoms.end(); } iterator end() { return m_atoms.end(); }

View File

@ -26,7 +26,7 @@ void Editor::erase()
} }
template<bool append> template<bool append>
static void do_insert(Editor& editor, const Editor::String& string) static void do_insert(Editor& editor, const String& string)
{ {
scoped_edition edition(editor); scoped_edition edition(editor);
for (auto& sel : editor.selections()) for (auto& sel : editor.selections())
@ -37,7 +37,7 @@ static void do_insert(Editor& editor, const Editor::String& string)
} }
template<bool append> template<bool append>
static void do_insert(Editor& editor, const memoryview<Editor::String>& strings) static void do_insert(Editor& editor, const memoryview<String>& strings)
{ {
if (strings.empty()) if (strings.empty())
return; return;
@ -79,7 +79,7 @@ void Editor::replace(const std::string& string)
insert(string); insert(string);
} }
std::vector<Editor::String> Editor::selections_content() const std::vector<String> Editor::selections_content() const
{ {
std::vector<String> contents; std::vector<String> contents;
for (auto& sel : selections()) for (auto& sel : selections())
@ -324,7 +324,7 @@ void IncrementalInserter::apply(Modification&& modification) const
m_editor.buffer().modify(std::move(modification)); m_editor.buffer().modify(std::move(modification));
} }
void IncrementalInserter::insert(const Editor::String& string) void IncrementalInserter::insert(const String& string)
{ {
for (auto& sel : m_editor.selections()) for (auto& sel : m_editor.selections())
apply(Modification::make_insert(sel.begin(), string)); apply(Modification::make_insert(sel.begin(), string));

View File

@ -19,7 +19,6 @@ class Register;
class Editor class Editor
{ {
public: public:
typedef BufferString String;
typedef std::function<SelectionAndCaptures (const Selection&)> Selector; typedef std::function<SelectionAndCaptures (const Selection&)> Selector;
typedef std::function<SelectionAndCapturesList (const Selection&)> MultiSelector; typedef std::function<SelectionAndCapturesList (const Selection&)> MultiSelector;
@ -110,7 +109,7 @@ public:
IncrementalInserter(Editor& editor, Mode mode = Mode::Insert); IncrementalInserter(Editor& editor, Mode mode = Mode::Insert);
~IncrementalInserter(); ~IncrementalInserter();
void insert(const Editor::String& string); void insert(const String& string);
void insert(const Register& reg); void insert(const Register& reg);
void erase(); void erase();
void move_cursors(const BufferCoord& offset); void move_cursors(const BufferCoord& offset);

View File

@ -88,7 +88,7 @@ void write_buffer_to_file(const Buffer& buffer, const std::string& filename)
if (fd == -1) if (fd == -1)
throw file_access_error(filename, strerror(errno)); throw file_access_error(filename, strerror(errno));
const BufferString& content = buffer.content(); const String& content = buffer.content();
ssize_t count = content.length() * sizeof(BufferChar); ssize_t count = content.length() * sizeof(BufferChar);
const char* ptr = content.c_str(); const char* ptr = content.c_str();

View File

@ -41,7 +41,7 @@ private:
}; };
typedef std::vector<Selection> SelectionList; typedef std::vector<Selection> SelectionList;
typedef std::vector<BufferString> CaptureList; typedef std::vector<String> CaptureList;
// Selections are often associated with a capture list // Selections are often associated with a capture list
// like when they are created from a regex match with // like when they are created from a regex match with

View File

@ -53,7 +53,7 @@ static DisplayCoord measure_string(Iterator begin, Iterator end)
return result; return result;
} }
static DisplayCoord measure_string(const Editor::String& string) static DisplayCoord measure_string(const String& string)
{ {
return measure_string(string.begin(), string.end()); return measure_string(string.begin(), string.end());
} }