summaryrefslogtreecommitdiff
path: root/src/cmdline
diff options
context:
space:
mode:
authorDaniel Burrows <dburrows@debian.org>2010-07-10 21:08:02 -0700
committerDaniel Burrows <dburrows@debian.org>2010-07-10 21:08:02 -0700
commit381582bfb62fc7c8ed87ae2f9c19260c26b7bd02 (patch)
tree8160ec404ad00f9a9c35bf247e08221929be0dda /src/cmdline
parentb38248a433bf6849c7aed56b2841e150f16f837c (diff)
downloadaptitude-381582bfb62fc7c8ed87ae2f9c19260c26b7bd02.tar.gz
Make display_and_advance work even when the output isn't a terminal.
Also documented this new behavior and wrote a unit test for it.
Diffstat (limited to 'src/cmdline')
-rw-r--r--src/cmdline/transient_message.cc21
-rw-r--r--src/cmdline/transient_message.h3
2 files changed, 15 insertions, 9 deletions
diff --git a/src/cmdline/transient_message.cc b/src/cmdline/transient_message.cc
index a90f6fda..f486b527 100644
--- a/src/cmdline/transient_message.cc
+++ b/src/cmdline/transient_message.cc
@@ -46,23 +46,28 @@ namespace aptitude
namespace
{
- /** \brief Transient message implementation that makes all
- * methods into NOPs.
+ /** \brief Transient message implementation for non-terminal
+ * output.
*/
class dummy_transient_message : public transient_message
{
+ shared_ptr<terminal_output> term_output;
+
public:
+ explicit dummy_transient_message(const shared_ptr<terminal_output> &_term_output)
+ : term_output(_term_output)
+ {
+ }
+
void set_text(const std::wstring &msg)
{
}
void display_and_advance(const std::wstring &msg)
{
- // I could generate output here, but the messages passed to
- // display_and_advance might be inappropriate for
- // non-terminal output; this layer of the code doesn't have
- // the necessary information to decide whether they should
- // be displayed.
+ term_output->write_text(msg);
+ term_output->write_text(L"\n");
+ term_output->flush();
}
};
@@ -178,7 +183,7 @@ namespace aptitude
const shared_ptr<terminal_output> &term_output)
{
if(!term_output->output_is_a_terminal())
- return make_shared<dummy_transient_message>();
+ return make_shared<dummy_transient_message>(term_output);
else
return make_shared<transient_message_impl>(term_locale, term_metrics, term_output);
}
diff --git a/src/cmdline/transient_message.h b/src/cmdline/transient_message.h
index 787c1d56..8ee66298 100644
--- a/src/cmdline/transient_message.h
+++ b/src/cmdline/transient_message.h
@@ -56,7 +56,8 @@ namespace aptitude
/** \brief Create a new transient message object.
*
* If the given terminal is not a tty when this function is
- * invoked, no output will be generated.
+ * invoked, display_and_advance will generate output as usual,
+ * but set_text will be ignored.
*
* \param term_locale Locale information for the given terminal.
* \param term_metrics The terminal metrics object to use.