summaryrefslogtreecommitdiff
path: root/src/cmdline/terminal.h
diff options
context:
space:
mode:
authorDaniel Burrows <Daniel Burrows Daniel_Burrows@alumni.brown.edu>2010-06-07 09:23:57 -0700
committerDaniel Burrows <Daniel Burrows Daniel_Burrows@alumni.brown.edu>2010-06-07 09:23:57 -0700
commitc27c15052851d397faba13cbb608dc875895b2b6 (patch)
tree133e8807fcee5a2a98bac162c027115e458c5606 /src/cmdline/terminal.h
parent63ac4c507f54189f69f3951ab2ff96c6dc3caad5 (diff)
downloadaptitude-c27c15052851d397faba13cbb608dc875895b2b6.tar.gz
Wrap a layer of indirection around wcwidth().
This is necessary so that I can test the behavior of terminal output routines that care about string widths, without depending on system locale settings or data.
Diffstat (limited to 'src/cmdline/terminal.h')
-rw-r--r--src/cmdline/terminal.h24
1 files changed, 24 insertions, 0 deletions
diff --git a/src/cmdline/terminal.h b/src/cmdline/terminal.h
index 9071264e..b77765dc 100644
--- a/src/cmdline/terminal.h
+++ b/src/cmdline/terminal.h
@@ -109,10 +109,34 @@ namespace aptitude
virtual unsigned int get_screen_width() = 0;
};
+ /** \brief Locale functionality related to the terminal (thus,
+ * primarily LC_CTYPE).
+ *
+ * This is wrapped up so that the unit tests can verify the
+ * code's output behavior without depending on the value of the
+ * system locale or the set of locale definitions that are
+ * installed on the system.
+ */
+ class terminal_locale
+ {
+ public:
+ virtual ~terminal_locale();
+
+ /** \brief Return the number of terminal columns occupied by a
+ * wide character.
+ */
+ virtual int wcwidth(wchar_t ch) = 0;
+ };
+
/** \brief Create a terminal object attached to the standard I/O
streams.
*/
boost::shared_ptr<terminal> create_terminal();
+
+ /** \brief Create a terminal locale object using the system locale
+ * definitions.
+ */
+ boost::shared_ptr<terminal_locale> create_terminal_locale();
}
}