Clear this buffer. If it was previously not clear, it has been updated. Otherwise it is just reset to default state. A new buffer is always initially cleared.
| 683 | // Clear this buffer. If it was previously not clear, it has been updated. |
| 684 | // Otherwise it is just reset to default state. A new buffer is always initially cleared. |
| 685 | void ZepBuffer::Clear() |
| 686 | { |
| 687 | // A buffer that is empty is brand new; just make it 0 chars and return |
| 688 | if (m_workingBuffer.size() <= 1) |
| 689 | { |
| 690 | m_workingBuffer.clear(); |
| 691 | m_workingBuffer.push_back(0); |
| 692 | m_lineEnds.clear(); |
| 693 | m_fileFlags = ZSetFlags(m_fileFlags, FileFlags::TerminatedWithZero); |
| 694 | m_lineEnds.push_back(End().Index() + 1); |
| 695 | return; |
| 696 | } |
| 697 | |
| 698 | // Inform clients we are about to change the buffer |
| 699 | GetEditor().Broadcast(std::make_shared<BufferMessage>(this, BufferMessageType::PreBufferChange, GlyphIterator(this), End())); |
| 700 | |
| 701 | m_workingBuffer.clear(); |
| 702 | m_workingBuffer.push_back(0); |
| 703 | m_lineEnds.clear(); |
| 704 | m_fileFlags = ZSetFlags(m_fileFlags, FileFlags::TerminatedWithZero); |
| 705 | m_lineEnds.push_back(End().Index() + 1); |
| 706 | |
| 707 | { |
| 708 | MarkUpdate(); |
| 709 | GetEditor().Broadcast(std::make_shared<BufferMessage>(this, BufferMessageType::TextDeleted, GlyphIterator(this), End())); |
| 710 | } |
| 711 | } |
| 712 | |
| 713 | // Replace the buffer with the text |
| 714 | void ZepBuffer::SetText(const std::string& text, bool initFromFile) |