Skip to content
Snippets Groups Projects
Select Git revision
  • master
  • github/fork/hrani/master
  • github/fork/dilawar/master
  • chamcham
  • chhennapoda
  • wheel
  • 3.2.0-pre0
  • v3.1.3
  • 3.1.2
  • 3.1.1
  • chamcham-3.1.1
  • 3.1.0
  • ghevar_3.0.2_pre2
  • ghevar_3.0.2
14 results

README.md

Blame
  • textbuffer.cpp 1.14 KiB
    #include "textbuffer.hpp"
    
    /******************************************************************************
                                  TextBuffer
    ******************************************************************************/
    TextBuffer& TextBuffer::add_gutter() {
        text_ << gutter_;
        return *this;
    }
    void TextBuffer::add_line(std::string const& line) {
        text_ << gutter_ << line << std::endl;
    }
    void TextBuffer::add_line() {
        text_ << std::endl;
    }
    void TextBuffer::end_line(std::string const& line) {
        text_ << line << std::endl;
    }
    void TextBuffer::end_line() {
        text_ << std::endl;
    }
    
    std::string TextBuffer::str() const {
        return text_.str();
    }
    
    void TextBuffer::set_gutter(int width) {
        indent_ = width;
        gutter_ = std::string(indent_, ' ');
    }
    
    void TextBuffer::increase_indentation() {
        indent_ += indentation_width_;
        if(indent_<0) {
            indent_=0;
        }
        gutter_ = std::string(indent_, ' ');
    }
    void TextBuffer::decrease_indentation() {
        indent_ -= indentation_width_;
        if(indent_<0) {
            indent_=0;
        }
        gutter_ = std::string(indent_, ' ');
    }
    
    std::stringstream& TextBuffer::text() {
        return text_;
    }