~ubuntu-branches/ubuntu/vivid/aptitude/vivid

« back to all changes in this revision

Viewing changes to src/cmdline/terminal.h

  • Committer: Bazaar Package Importer
  • Author(s): Michael Vogt
  • Date: 2011-06-22 12:32:56 UTC
  • mfrom: (1.8.6 sid)
  • Revision ID: james.westby@ubuntu.com-20110622123256-8aox9w9ch3x72dci
Tags: 0.6.4-1ubuntu1
* Merge from debian unstable.  Remaining changes:
  - debian/05aptitude: never autoremove kernels
  - drop aptitude-doc to Suggests
  - 03_branding.dpatch: ubuntu branding
  - 04_changelog.dpatch: take changelogs from changelogs.ubuntu.com
  - 09_ubuntu_fortify_source.dpatch: Suppress a number of warnings (turned
    into errors by -Werror) triggered by Ubuntu's default of
    -D_FORTIFY_SOURCE=2.
  - 11_ubuntu_uses_sudo.dpatch: fix status line of 'Become root' menu entry
    to not refer to su.
  - 12_point_manpage_to_doc_package.dpatch: point Finnish manpage to the
    correct place for further info
  - 14_html2text_preferred.dpatch: switch back to html2text in favor of
    elinks, since html2text is in main and elinks isn't.
* dropped 01_intltool_update.dpatch
* updated 15_ftbfs_new_apt

Show diffs side-by-side

added added

removed removed

Lines of Context:
45
45
    /** \brief Abstraction of the I/O device used for the command-line
46
46
     *  code.
47
47
     *
48
 
     *  A virtual interface is used so that we can dummy it out for
49
 
     *  testing (see mocks/terminal.h).
50
 
     */
51
 
    class terminal
 
48
     *  Virtual interfaces are used so that we can dummy them out for
 
49
     *  testing (see mocks/terminal.h).  Using several virtual
 
50
     *  interfaces allows code to specify more precisely which
 
51
     *  functionality is required, so we don't have to
 
52
     */
 
53
    // @{
 
54
 
 
55
    /** \brief Interface representing the ability to write to the
 
56
     *  terminal.
 
57
     */
 
58
    class terminal_output
52
59
    {
53
60
    public:
54
 
      virtual ~terminal();
 
61
      virtual ~terminal_output();
55
62
 
56
63
      /** \brief Check whether the output stream seems to be connected
57
64
       *  to a terminal.
79
86
       *  printed.
80
87
       */
81
88
      virtual void flush() = 0;
 
89
    };
 
90
 
 
91
    /** \brief Interface representing the ability to read from the
 
92
     *  terminal.
 
93
     */
 
94
    class terminal_input
 
95
    {
 
96
    public:
 
97
      ~terminal_input();
82
98
 
83
99
      /** \brief Prompt for a line of input from the terminal device.
84
100
       *
96
112
       *  and aborts the program.
97
113
       */
98
114
      virtual std::wstring prompt_for_input(const std::wstring &msg) = 0;
 
115
    };
 
116
 
 
117
    /** \brief Interface representing the ability to read the
 
118
     *  characteristics of the terminal.
 
119
     */
 
120
    class terminal_metrics
 
121
    {
 
122
    public:
 
123
      ~terminal_metrics();
99
124
 
100
125
      /** \brief Retrieve the current screen width.
101
126
       *
127
152
       */
128
153
      virtual int wcwidth(wchar_t ch) = 0;
129
154
    };
 
155
    // @}
 
156
 
 
157
    /** \brief Master interface representing all the terminal
 
158
     *  capabilities at once.
 
159
     *
 
160
     *  This should normally not be passed as a parameter to
 
161
     *  functions; it exists so that create_terminal() has a return
 
162
     *  type.
 
163
     */
 
164
    class terminal_io : public terminal_input,
 
165
                        public terminal_locale,
 
166
                        public terminal_metrics,
 
167
                        public terminal_output
 
168
    {
 
169
    };
130
170
 
131
171
    /** \brief Create a terminal object attached to the standard I/O
132
 
        streams.
133
 
     */
134
 
    boost::shared_ptr<terminal> create_terminal();
135
 
 
136
 
    /** \brief Create a terminal locale object using the system locale
137
 
     *  definitions.
138
 
     */
139
 
    boost::shared_ptr<terminal_locale> create_terminal_locale();
 
172
     *  streams and using the system locale definitions.
 
173
     */
 
174
    boost::shared_ptr<terminal_io> create_terminal();
140
175
  }
141
176
}
142
177