From df0f7b46893b9c87d33df246b7012d4058a79eab Mon Sep 17 00:00:00 2001 From: Maxime Coste Date: Thu, 8 Mar 2012 21:23:29 +0000 Subject: [PATCH] rename BufferString to String --- src/buffer.cc | 4 ++-- src/buffer.hh | 19 +++++++++---------- src/display_buffer.cc | 4 ++-- src/display_buffer.hh | 6 +++--- src/editor.cc | 8 ++++---- src/editor.hh | 3 +-- src/file.cc | 2 +- src/selection.hh | 2 +- src/window.cc | 2 +- 9 files changed, 24 insertions(+), 26 deletions(-) diff --git a/src/buffer.cc b/src/buffer.cc index d62d2e82..d4a5b882 100644 --- a/src/buffer.cc +++ b/src/buffer.cc @@ -23,7 +23,7 @@ T clamp(T min, T max, T val) } Buffer::Buffer(const std::string& name, Type type, - const BufferString& initial_content) + const String& initial_content) : m_name(name), m_type(type), m_history(1), m_history_cursor(m_history.begin()), m_content(initial_content), m_last_save_undo_index(0) @@ -122,7 +122,7 @@ BufferSize Buffer::line_count() const 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); } diff --git a/src/buffer.hh b/src/buffer.hh index 483485fd..6e881e92 100644 --- a/src/buffer.hh +++ b/src/buffer.hh @@ -17,7 +17,7 @@ class Window; typedef int BufferPos; typedef int BufferSize; typedef char BufferChar; -typedef std::basic_string BufferString; +typedef std::basic_string String; struct BufferCoord : LineAndColumn { @@ -81,17 +81,16 @@ struct Modification Type type; BufferIterator position; - BufferString content; + String content; - Modification(Type type, BufferIterator position, - const BufferString& content) + Modification(Type type, BufferIterator position, const String& content) : type(type), position(position), content(content) {} Modification inverse() const; static Modification make_erase(BufferIterator begin, BufferIterator end); static Modification make_insert(BufferIterator position, - const BufferString& content); + const String& content); }; class ModificationListener @@ -116,7 +115,7 @@ public: }; Buffer(const std::string& name, Type type, - const BufferString& initial_content = "\n"); + const String& initial_content = "\n"); Buffer(const Buffer&) = delete; Buffer(Buffer&&) = delete; Buffer& operator= (const Buffer&) = delete; @@ -130,7 +129,7 @@ public: bool undo(); bool redo(); - BufferString string(const BufferIterator& begin, + String string(const BufferIterator& begin, const BufferIterator& end) const; BufferIterator begin() const; @@ -146,7 +145,7 @@ public: 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(); void delete_window(Window* window); @@ -179,7 +178,7 @@ private: BufferSize line_length(BufferPos line) const; void update_lines(const Modification& modification); - BufferString m_content; + String m_content; std::string m_name; const Type m_type; @@ -207,7 +206,7 @@ inline Modification Modification::make_erase(BufferIterator begin, } inline Modification Modification::make_insert(BufferIterator position, - const BufferString& content) + const String& content) { return Modification(Insert, position, content); } diff --git a/src/display_buffer.cc b/src/display_buffer.cc index 44c09443..8f90901d 100644 --- a/src/display_buffer.cc +++ b/src/display_buffer.cc @@ -5,7 +5,7 @@ namespace Kakoune { -BufferString DisplayAtom::content() const +String DisplayAtom::content() const { if (m_replacement_text.empty()) 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, - const BufferString& replacement) + const String& replacement) { atom->m_replacement_text = replacement; diff --git a/src/display_buffer.hh b/src/display_buffer.hh index 3f253940..aeafae14 100644 --- a/src/display_buffer.hh +++ b/src/display_buffer.hh @@ -77,7 +77,7 @@ struct DisplayAtom Color& bg_color() { return m_bg_color; } Attribute& attribute() { return m_attribute; } - BufferString content() const; + String content() const; DisplayCoord end_coord() const; BufferIterator iterator_at(const DisplayCoord& coord) const; DisplayCoord line_and_column_at(const BufferIterator& iterator) const; @@ -93,7 +93,7 @@ private: Color m_fg_color; Color m_bg_color; Attribute m_attribute; - BufferString m_replacement_text; + String m_replacement_text; }; // 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 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 end() { return m_atoms.end(); } diff --git a/src/editor.cc b/src/editor.cc index de242891..c0bb6f76 100644 --- a/src/editor.cc +++ b/src/editor.cc @@ -26,7 +26,7 @@ void Editor::erase() } template -static void do_insert(Editor& editor, const Editor::String& string) +static void do_insert(Editor& editor, const String& string) { scoped_edition edition(editor); for (auto& sel : editor.selections()) @@ -37,7 +37,7 @@ static void do_insert(Editor& editor, const Editor::String& string) } template -static void do_insert(Editor& editor, const memoryview& strings) +static void do_insert(Editor& editor, const memoryview& strings) { if (strings.empty()) return; @@ -79,7 +79,7 @@ void Editor::replace(const std::string& string) insert(string); } -std::vector Editor::selections_content() const +std::vector Editor::selections_content() const { std::vector contents; for (auto& sel : selections()) @@ -324,7 +324,7 @@ void IncrementalInserter::apply(Modification&& modification) const 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()) apply(Modification::make_insert(sel.begin(), string)); diff --git a/src/editor.hh b/src/editor.hh index f019d053..70ea9d64 100644 --- a/src/editor.hh +++ b/src/editor.hh @@ -19,7 +19,6 @@ class Register; class Editor { public: - typedef BufferString String; typedef std::function Selector; typedef std::function MultiSelector; @@ -110,7 +109,7 @@ public: IncrementalInserter(Editor& editor, Mode mode = Mode::Insert); ~IncrementalInserter(); - void insert(const Editor::String& string); + void insert(const String& string); void insert(const Register& reg); void erase(); void move_cursors(const BufferCoord& offset); diff --git a/src/file.cc b/src/file.cc index eb01081d..ca074e2f 100644 --- a/src/file.cc +++ b/src/file.cc @@ -88,7 +88,7 @@ void write_buffer_to_file(const Buffer& buffer, const std::string& filename) if (fd == -1) throw file_access_error(filename, strerror(errno)); - const BufferString& content = buffer.content(); + const String& content = buffer.content(); ssize_t count = content.length() * sizeof(BufferChar); const char* ptr = content.c_str(); diff --git a/src/selection.hh b/src/selection.hh index dbc19fc0..20b13dda 100644 --- a/src/selection.hh +++ b/src/selection.hh @@ -41,7 +41,7 @@ private: }; typedef std::vector SelectionList; -typedef std::vector CaptureList; +typedef std::vector CaptureList; // Selections are often associated with a capture list // like when they are created from a regex match with diff --git a/src/window.cc b/src/window.cc index a6a1e0dc..a9eab6d7 100644 --- a/src/window.cc +++ b/src/window.cc @@ -53,7 +53,7 @@ static DisplayCoord measure_string(Iterator begin, Iterator end) return result; } -static DisplayCoord measure_string(const Editor::String& string) +static DisplayCoord measure_string(const String& string) { return measure_string(string.begin(), string.end()); }