Utils/Termlib: Implement aux display hide/show support
g0dil [Thu, 8 Jan 2009 22:02:37 +0000 (22:02 +0000)]
git-svn-id: https://svn.berlios.de/svnroot/repos/senf/trunk@1049 270642c3-0616-0410-b53a-bc976706d245

Utils/Termlib/Editor.cc
Utils/Termlib/Editor.hh

index f268efb..e8291a2 100644 (file)
@@ -324,6 +324,11 @@ prefix_ void senf::term::LineEditor::show()
     if (enabled_)
         return;
     enabled_ = true;
+    for (unsigned n (0); n < auxDisplay_.size(); ++n) {
+        toLine(n+1);
+        put(auxDisplay_[n]);
+    }
+    toLine(0);
     forceRedisplay();
 }
 
@@ -331,6 +336,7 @@ prefix_ void senf::term::LineEditor::hide()
 {
     if (! enabled_)
         return;
+    reset();
     clearLine();
     enabled_ = false;
 }
@@ -464,6 +470,9 @@ prefix_ void senf::term::LineEditor::auxDisplay(int line, std::string const & te
     toLine(line+1);
     clearLine();
     put(text);
+    while (auxDisplay_.size() < line+1)
+        auxDisplay_.push_back("");
+    auxDisplay_[line] = text;
 }
 
 prefix_ unsigned senf::term::LineEditor::maxAuxDisplayHeight()
@@ -474,6 +483,7 @@ prefix_ unsigned senf::term::LineEditor::maxAuxDisplayHeight()
 prefix_ void senf::term::LineEditor::clearAuxDisplay()
 {
     reset();
+    auxDisplay_.clear();
 }
 
 prefix_ std::string const & senf::term::LineEditor::text()
index d2d091c..e173a29 100644 (file)
@@ -159,6 +159,7 @@ namespace term {
 
         typedef std::map<keycode_t, KeyBinding> KeyMap;
         typedef std::vector<std::string> History;
+        typedef std::vector<std::string> AuxDisplay;
 
         bool enabled_;
         bool redisplayNeeded_;
@@ -173,6 +174,7 @@ namespace term {
         KeyMap bindings_;
         History history_;
         unsigned historyPoint_;
+        AuxDisplay auxDisplay_;
     };
 
 namespace bindings {