libzypp 17.37.17
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
21namespace ztui {
22
23class OutNormal : public Out
24{
25public:
27 ~OutNormal() override;
28
29public:
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
53protected:
54 bool mine( Type type ) override;
55
56 /* Return current terminal width or 'unsigned(-1)' when failed */
57 unsigned termwidth() const override;
58
59private:
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. */
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 setUseColors(bool value) override
Hint for a handler whether config would allow to use colors.
Definition OutNormal.h:50
void fixupProgressNL()
Definition OutNormal.cc:56
void displayTick(const std::string &s)
Definition OutNormal.cc:158
void dwnldProgressStart(const zypp::Url &uri) override
Reoprt start of a download.
Definition OutNormal.cc:245
void error(const std::string &problem_desc, const std::string &hint) override
Show an error message and an optional hint.
Definition OutNormal.cc:94
OutNormal(Verbosity verbosity=NORMAL)
Definition OutNormal.cc:33
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
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
void displayProgress(const std::string &s, int percent)
Definition OutNormal.cc:127
void infoLine(const TermLine &msg, Verbosity verbosity, Type mask) override
info taking a TermLine
Definition OutNormal.cc:80
unsigned termwidth() const override
Width for formatted output [0==unlimited].
Definition OutNormal.cc:451
void dwnldProgress(const zypp::Url &uri, int value, long rate) override
Reports download progress.
Definition OutNormal.cc:272
bool infoWarningFilter(Verbosity verbosity, Type mask)
Definition OutNormal.cc:47
void promptHelp(const PromptOptions &poptions) override
Print help for prompt, if available.
Definition OutNormal.cc:416
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
void progress(const std::string &id, const std::string &label, int value) override
Progress report for an on-going operation.
Definition OutNormal.cc:198
void warning(const std::string &msg, Verbosity verbosity, Type mask) override
Show a warning.
Definition OutNormal.cc:83
~OutNormal() override
Definition OutNormal.cc:41
void dwnldProgressEnd(const zypp::Url &uri, long rate, zypp::TriBool error) override
Reports end of a download.
Definition OutNormal.cc:312
bool mine(Type type) override
Determine whether the output is intended for the particular type.
Definition OutNormal.cc:44
Verbosity verbosity() const
Get current verbosity.
Definition Out.h:864
Out(TypeBit type, Verbosity verbosity=NORMAL)
Definition Out.h:450
Info info()
Definition Out.h:678
Verbosity
Verbosity levels.
Definition Out.h:428
@ NORMAL
Default output verbosity level.
Definition Out.h:430
TypeBit type() const
Return the type of the instance.
Definition Out.h:895
unsigned PromptId
Definition Out.h:447
Example: PromptOptions popts; popts.setOptions(_("y/n/p"), 0 / * default reply * /); popts....
Base class for Exception.
Definition Exception.h:153
Url manipulation class.
Definition Url.h:93
boost::logic::tribool TriBool
3-state boolean logic (true, false and indeterminate).
Definition String.h:31