📄 out.cc
字号:
//=======================================================================// Out.cc//-----------------------------------------------------------------------// This file is part of the package paco// Copyright (C) 2004-2007 David Rosal <david.3r@gmail.com>// For more information visit http://paco.sourceforge.net//=======================================================================#include "config.h"#include "global.h"#include "paco/paco.h" // str2num()#include <string>#include <iostream>// Used to determine the screen width#if HAVE_STRUCT_WINSIZE# if HAVE_TERMIOS_H# include <termios.h># endif# if HAVE_SYS_IOCTL_H# include <sys/ioctl.h># endif# ifndef TIOCGWINSZ# define TIOCGWINSZ 0x5413# endif#endifusing std::string;using std::cerr;using namespace Paco;Out::Out(): mVerbosity(QUIET){ }// [static]int Out::screenWidth(){ char* columns = getenv("COLUMNS"); int width = columns ? str2num<int>(columns) : 0; if (!width) { width = 80;#if HAVE_STRUCT_WINSIZE struct winsize w; if (isatty(1) && (ioctl(1, TIOCGWINSZ, &w) != -1) && w.ws_col) width = w.ws_col;#endif } return width;}void Out::vrb(string const& msg, int __errno /* = 0 */){ if (mVerbosity > QUIET) { if (__errno) cerr << "paco: "; cerr << msg; if (__errno) cerr << ": " << strerror(__errno) << "\n"; }}void Out::dbg(string const& msg, bool printProgName /* = true */){ if (mVerbosity > VERBOSE) cerr << (printProgName ? "paco :: " : "") << msg;}void Out::dbgTitle(string const& title /* = "" */){ if (mVerbosity < DEBUG) return; string head("paco :: ----"); cerr << head; int cnt = head.size(); if (title.size()) { cerr << "[ " + title + " ]"; cnt += title.size() + 4; } cerr << string(screenWidth() - cnt, '-') << "\n";}Out::Silencer::Silencer(): mOldVerbosity(gOut.verbosity()){ gOut.verbosity() = QUIET;}Out::Silencer::~Silencer(){ gOut.verbosity() = mOldVerbosity;}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -