MCPcopy Create free account
hub / github.com/Rezonality/zep / Clear

Method Clear

src/buffer.cpp:685–711  ·  view source on GitHub ↗

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.

Source from the content-addressed store, hash-verified

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.
685void 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
714void ZepBuffer::SetText(const std::string& text, bool initFromFile)

Callers 2

BuildTreeMethod · 0.45
RedoMethod · 0.45

Calls 7

ZSetFlagsFunction · 0.85
GlyphIteratorClass · 0.85
IndexMethod · 0.80
BroadcastMethod · 0.80
sizeMethod · 0.45
clearMethod · 0.45
push_backMethod · 0.45

Tested by

no test coverage detected