libzypp 17.37.10

OutNormal.h
Go to the documentation of this file.
1/*---------------------------------------------------------------------\
2| ____ _ __ __ ___ |
3| |__ / \ / / . \ . \ |
4| / / \ V /| _/ _/ |
5| / /__ | | | | | | |
6| /_____||_| |_| |_| |
7| |
8----------------------------------------------------------------------/
9*
10* This file contains private API, this might break at any time between releases.
11* Strictly for internal use!
12*/
13
14#ifndef OUTNORMAL_H_
15#define OUTNORMAL_H_
16
17#include <zypp-tui/output/Out.h>
18#include <termios.h>
19#include <sys/ioctl.h>
20
21 namespace ztui {
22
23 class OutNormal : public Out
24{
25 public:
26 OutNormal(Verbosity verbosity = NORMAL);
27 ~OutNormal() override;
28
29 public:
30 void info( const std::string & msg, Verbosity verbosity, Type mask ) override;
31 void infoLine( const TermLine & msg, Verbosity verbosity, Type mask ) override;
32 void warning( const std::string & msg, Verbosity verbosity, Type mask ) override;
33 void error( const std::string & problem_desc, const std::string & hint ) override;
34 void error( const zypp::Exception & e, const std::string & problem_desc, const std::string & hint ) override;
35
36 // progress
37 void progressStart( const std::string & id, const std::string & label, bool is_tick ) override;
38 void progress( const std::string & id, const std::string & label, int value ) override;
39 void progressEnd( const std::string & id, const std::string & label, const std::string & donetag, bool error) override;
40
41 // progress with download rate
42 void dwnldProgressStart( const zypp::Url & uri ) override;
43 void dwnldProgress( const zypp::Url & uri, int value, long rate ) override;
44 void dwnldProgressEnd( const zypp::Url & uri, long rate, zypp::TriBool error ) override;
45
46 void prompt( PromptId id, const std::string & prompt, const PromptOptions & poptions, const std::string & startdesc ) override;
47
48 void promptHelp( const PromptOptions & poptions ) override;
49
50 void setUseColors( bool value ) override
51 { _use_colors = value; }
52
53 protected:
54 bool mine( Type type ) override;
55
56 /* Return current terminal width or 'unsigned(-1)' when failed */
57 unsigned termwidth() const override;
58
59 private:
60 bool infoWarningFilter(Verbosity verbosity, Type mask);
61 void fixupProgressNL(); //< Make sure we're at BOL even if a ProgressBar is active
62 void displayProgress(const std::string & s, int percent);
63 void displayTick(const std::string & s);
64
65 bool _use_colors;
66 bool _isatty;
67 /* Newline flag. false if the last output did not end with new line character
68 * (like in a self-overwriting progress line), false otherwise. */
69 bool _newline;
70 /* True if the last output line was longer than the terminal width */
71 bool _oneup;
72};
73
74}
75
76#endif /*OUTNORMAL_H_*/
Out.h
ztui::OutNormal::setUseColors
void setUseColors(bool value) override
Hint for a handler whether config would allow to use colors.
Definition OutNormal.h:50
ztui::OutNormal::fixupProgressNL
void fixupProgressNL()
Definition OutNormal.cc:56
ztui::OutNormal::displayTick
void displayTick(const std::string &s)
Definition OutNormal.cc:158
ztui::OutNormal::dwnldProgressStart
void dwnldProgressStart(const zypp::Url &uri) override
Reoprt start of a download.
Definition OutNormal.cc:245
ztui::OutNormal::_isatty
bool _isatty
Definition OutNormal.h:66
ztui::OutNormal::error
void error(const std::string &problem_desc, const std::string &hint) override
Show an error message and an optional hint.
Definition OutNormal.cc:94
ztui::OutNormal::OutNormal
OutNormal(Verbosity verbosity=NORMAL)
Definition OutNormal.cc:33
ztui::OutNormal::_use_colors
bool _use_colors
Definition OutNormal.h:65
ztui::OutNormal::progressEnd
void progressEnd(const std::string &id, const std::string &label, const std::string &donetag, bool error) override
End of an operation with reported progress.
Definition OutNormal.cc:211
ztui::OutNormal::prompt
void prompt(PromptId id, const std::string &prompt, const PromptOptions &poptions, const std::string &startdesc) override
Prompt the user for a decision.
Definition OutNormal.cc:358
ztui::OutNormal::displayProgress
void displayProgress(const std::string &s, int percent)
Definition OutNormal.cc:127
ztui::OutNormal::infoLine
void infoLine(const TermLine &msg, Verbosity verbosity, Type mask) override
info taking a TermLine
Definition OutNormal.cc:80
ztui::OutNormal::termwidth
unsigned termwidth() const override
Width for formatted output [0==unlimited].
Definition OutNormal.cc:451
ztui::OutNormal::dwnldProgress
void dwnldProgress(const zypp::Url &uri, int value, long rate) override
Reports download progress.
Definition OutNormal.cc:272
ztui::OutNormal::infoWarningFilter
bool infoWarningFilter(Verbosity verbosity, Type mask)
Definition OutNormal.cc:47
ztui::OutNormal::promptHelp
void promptHelp(const PromptOptions &poptions) override
Print help for prompt, if available.
Definition OutNormal.cc:416
ztui::OutNormal::progressStart
void progressStart(const std::string &id, const std::string &label, bool is_tick) override
Start of an operation with reported progress.
Definition OutNormal.cc:182
ztui::OutNormal::progress
void progress(const std::string &id, const std::string &label, int value) override
Progress report for an on-going operation.
Definition OutNormal.cc:198
ztui::OutNormal::_oneup
bool _oneup
Definition OutNormal.h:71
ztui::OutNormal::warning
void warning(const std::string &msg, Verbosity verbosity, Type mask) override
Show a warning.
Definition OutNormal.cc:83
ztui::OutNormal::~OutNormal
~OutNormal() override
Definition OutNormal.cc:41
ztui::OutNormal::dwnldProgressEnd
void dwnldProgressEnd(const zypp::Url &uri, long rate, zypp::TriBool error) override
Reports end of a download.
Definition OutNormal.cc:312
ztui::OutNormal::_newline
bool _newline
Definition OutNormal.h:69
ztui::OutNormal::mine
bool mine(Type type) override
Determine whether the output is intended for the particular type.
Definition OutNormal.cc:44
ztui::Out::verbosity
Verbosity verbosity() const
Get current verbosity.
Definition Out.h:864
ztui::Out::Out
Out(TypeBit type, Verbosity verbosity=NORMAL)
Definition Out.h:450
ztui::Out::info
Info info()
Definition Out.h:678
ztui::Out::Verbosity
Verbosity
Verbosity levels.
Definition Out.h:428
ztui::Out::NORMAL
@ NORMAL
Default output verbosity level.
Definition Out.h:430
ztui::Out::type
TypeBit type() const
Return the type of the instance.
Definition Out.h:895
ztui::Out::PromptId
unsigned PromptId
Definition Out.h:447
ztui::PromptOptions
Example: PromptOptions popts; popts.setOptions(_("y/n/p"), 0 / * default reply * /); popts....
Definition promptoptions.h:39
zypp::Exception
Base class for Exception.
Definition Exception.h:153
zypp::Url
Url manipulation class.
Definition Url.h:93
ztui
Definition application.cc:13
ztui::ProgressEnd::error
@ error
Definition Out.h:45
zypp::TriBool
boost::logic::tribool TriBool
3-state boolean logic (true, false and indeterminate).
Definition String.h:31
ztui::TermLine
Definition Out.h:343