From c09cd7512491cee1e82c1ad8128ce9fd4bc3f79b Mon Sep 17 00:00:00 2001 From: Boris Kolpackov Date: Fri, 22 Sep 2017 23:32:28 +0200 Subject: Initial modularization with both Clang and VC hacks Note: gave up on VC about half way though. --- libbutl/pager.hxx | 88 ------------------------------------------------------- 1 file changed, 88 deletions(-) delete mode 100644 libbutl/pager.hxx (limited to 'libbutl/pager.hxx') diff --git a/libbutl/pager.hxx b/libbutl/pager.hxx deleted file mode 100644 index f167f10..0000000 --- a/libbutl/pager.hxx +++ /dev/null @@ -1,88 +0,0 @@ -// file : libbutl/pager.hxx -*- C++ -*- -// copyright : Copyright (c) 2014-2017 Code Synthesis Ltd -// license : MIT; see accompanying LICENSE file - -#ifndef LIBBUTL_PAGER_HXX -#define LIBBUTL_PAGER_HXX - -#include -#include -#include - -#include - -#include -#include - -namespace butl -{ - // Try to run the output through a pager program, such as more or less (no - // pun intended, less is used by default). If the default pager program is - // used, then the output is indented so that 80-character long lines will - // appear centered in the terminal. If the default pager program fails to - // start, then the output is sent directly to STDOUT. - // - // If the pager program is specified and is empty, then no pager is used - // and the output is sent directly to STDOUT. - // - // Throw std::system_error if there are problems with the pager program. - // - // Typical usage: - // - // try - // { - // pager p ("help for foo"); - // ostream& os (p.stream ()); - // - // os << "Foo is such and so ..."; - // - // if (!p.wait ()) - // ... // Pager program returned non-zero status. - // } - // catch (const std::system_error& e) - // { - // cerr << "pager error: " << e << endl; - // } - // - class LIBBUTL_SYMEXPORT pager: protected std::streambuf - { - public: - ~pager () {wait (true);} - - // If verbose is true, then print (to STDERR) the pager command line. - // - pager (const std::string& name, - bool verbose = false, - const std::string* pager = nullptr, - const std::vector* pager_options = nullptr); - - std::ostream& - stream () {return os_.is_open () ? os_ : std::cout;} - - bool - wait (bool ignore_errors = false); - - // The streambuf output interface that implements indentation. You can - // override it to implement custom output pre-processing. - // - protected: - using int_type = std::streambuf::int_type; - using traits_type = std::streambuf::traits_type; - - virtual int_type - overflow (int_type); - - virtual int - sync (); - - private: - process p_; - ofdstream os_; - - std::string indent_; - int_type prev_ = '\n'; // Previous character. - std::streambuf* buf_ = nullptr; - }; -} - -#endif // LIBBUTL_PAGER_HXX -- cgit v1.1