Buffer::filename() returns shared_ptr to string
This commit is contained in:
parent
37d27d6063
commit
2ae1d72d6a
@ -86,7 +86,7 @@ bool Buffer::load_from_file(const char * filename)
|
|||||||
}
|
}
|
||||||
|
|
||||||
load_text_in_buffer(buffer, buffer_size, file_size);
|
load_text_in_buffer(buffer, buffer_size, file_size);
|
||||||
m_filename = filename;
|
m_filename = std::make_shared<std::string>(filename);
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
@ -131,7 +131,7 @@ public:
|
|||||||
bool insert_mode() const { return m_insert_mode; }
|
bool insert_mode() const { return m_insert_mode; }
|
||||||
void insert_code_point(const Buffer::Iterator & position, uint32_t code_point);
|
void insert_code_point(const Buffer::Iterator & position, uint32_t code_point);
|
||||||
void erase_code_point(const Buffer::Iterator & position);
|
void erase_code_point(const Buffer::Iterator & position);
|
||||||
std::string filename() const { return m_filename; }
|
std::shared_ptr<std::string> filename() const { return m_filename; }
|
||||||
Iterator begin() const { return Iterator(this); }
|
Iterator begin() const { return Iterator(this); }
|
||||||
Iterator end() const { return *m_eof_iterator; }
|
Iterator end() const { return *m_eof_iterator; }
|
||||||
void push_operation() { m_operation_level++; }
|
void push_operation() { m_operation_level++; }
|
||||||
@ -152,7 +152,7 @@ protected:
|
|||||||
std::list<std::shared_ptr<Iterator>> m_iterators;
|
std::list<std::shared_ptr<Iterator>> m_iterators;
|
||||||
std::list<std::shared_ptr<Iterator>> m_cursors;
|
std::list<std::shared_ptr<Iterator>> m_cursors;
|
||||||
std::shared_ptr<Iterator> m_eof_iterator;
|
std::shared_ptr<Iterator> m_eof_iterator;
|
||||||
std::string m_filename;
|
std::shared_ptr<std::string> m_filename;
|
||||||
std::shared_ptr<ChangeOperation> m_current_change_operation;
|
std::shared_ptr<ChangeOperation> m_current_change_operation;
|
||||||
int m_operation_level;
|
int m_operation_level;
|
||||||
size_t m_current_change_operation_index;
|
size_t m_current_change_operation_index;
|
||||||
|
@ -521,9 +521,9 @@ void BufferPane::kill_character_at_cursor()
|
|||||||
|
|
||||||
void BufferPane::write_file()
|
void BufferPane::write_file()
|
||||||
{
|
{
|
||||||
if (m_buffer->filename() != "")
|
if (m_buffer->filename())
|
||||||
{
|
{
|
||||||
m_buffer->write_to_file(m_buffer->filename().c_str());
|
m_buffer->write_to_file(m_buffer->filename()->c_str());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -748,11 +748,7 @@ void BufferPane::draw_status_bar()
|
|||||||
int cursor_position_length = strlen(cursor_position);
|
int cursor_position_length = strlen(cursor_position);
|
||||||
int x = m_width - m_window->font()->get_advance() * cursor_position_length;
|
int x = m_width - m_window->font()->get_advance() * cursor_position_length;
|
||||||
m_window->gl()->draw_rect(win_x(x - 2), win_y(0), 1, m_window->font()->get_line_height(), 0.5, 0.5, 0.5, 1.0);
|
m_window->gl()->draw_rect(win_x(x - 2), win_y(0), 1, m_window->font()->get_line_height(), 0.5, 0.5, 0.5, 1.0);
|
||||||
std::string filename = m_buffer->filename();
|
std::string filename = m_buffer->filename() ? *m_buffer->filename() : "[No Name]";
|
||||||
if (filename == "")
|
|
||||||
{
|
|
||||||
filename = "[No Name]";
|
|
||||||
}
|
|
||||||
int filename_x = std::min(0, x - 3 - (int)filename.size() * m_window->font()->get_advance());
|
int filename_x = std::min(0, x - 3 - (int)filename.size() * m_window->font()->get_advance());
|
||||||
for (int i = 0; i < cursor_position_length; i++)
|
for (int i = 0; i < cursor_position_length; i++)
|
||||||
{
|
{
|
||||||
|
Loading…
x
Reference in New Issue
Block a user