libzypp  17.32.5
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:
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 
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_*/
void progressStart(const std::string &id, const std::string &label, bool is_tick) override
Start of an operation with reported progress.
Definition: OutNormal.cc:181
void fixupProgressNL()
Definition: OutNormal.cc:55
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:357
void dwnldProgress(const zypp::Url &uri, int value, long rate) override
Reports download progress.
Definition: OutNormal.cc:271
boost::logic::tribool TriBool
3-state boolean logic (true, false and indeterminate).
Definition: String.h:30
void progress(const std::string &id, const std::string &label, int value) override
Progress report for an on-going operation.
Definition: OutNormal.cc:197
Base class for producing common (for now) zypper output.
Definition: Out.h:429
~OutNormal() override
Definition: OutNormal.cc:40
bool infoWarningFilter(Verbosity verbosity, Type mask)
Definition: OutNormal.cc:46
void warning(const std::string &msg, Verbosity verbosity, Type mask) override
Show a warning.
Definition: OutNormal.cc:82
bool _use_colors
Definition: OutNormal.h:65
void error(const std::string &problem_desc, const std::string &hint) override
Show an error message and an optional hint.
Definition: OutNormal.cc:93
Example: PromptOptions popts; popts.setOptions(_("y/n/p"), 0 / * default reply * /); popts...
Definition: promptoptions.h:38
Verbosity verbosity() const
Get current verbosity.
Definition: Out.h:870
void displayProgress(const std::string &s, int percent)
Definition: OutNormal.cc:126
unsigned PromptId
Definition: Out.h:453
bool mine(Type type) override
Determine whether the output is intended for the particular type.
Definition: OutNormal.cc:43
Default output verbosity level.
Definition: Out.h:436
void dwnldProgressStart(const zypp::Url &uri) override
Reoprt start of a download.
Definition: OutNormal.cc:244
unsigned termwidth() const override
Width for formatted output [0==unlimited].
Definition: OutNormal.cc:450
Verbosity
Verbosity levels.
Definition: Out.h:433
void dwnldProgressEnd(const zypp::Url &uri, long rate, zypp::TriBool error) override
Reports end of a download.
Definition: OutNormal.cc:311
Base class for Exception.
Definition: Exception.h:146
void displayTick(const std::string &s)
Definition: OutNormal.cc:157
void infoLine(const TermLine &msg, Verbosity verbosity, Type mask) override
info taking a TermLine
Definition: OutNormal.cc:79
TypeBit type() const
Return the type of the instance.
Definition: Out.h:901
OutNormal(Verbosity verbosity=NORMAL)
Definition: OutNormal.cc:32
void setUseColors(bool value) override
Hint for a handler whether config would allow to use colors.
Definition: OutNormal.h:50
Info info()
Definition: Out.h:684
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:210
void promptHelp(const PromptOptions &poptions) override
Print help for prompt, if available.
Definition: OutNormal.cc:415
Url manipulation class.
Definition: Url.h:91