libcvd-members
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[libcvd-members] gvars3/src GUI.cc


From: Georg Klein
Subject: [libcvd-members] gvars3/src GUI.cc
Date: Wed, 31 May 2006 10:28:25 +0000

CVSROOT:        /cvsroot/libcvd
Module name:    gvars3
Branch:         
Changes by:     Georg Klein <address@hidden>    06/05/31 10:28:25

Modified files:
        src            : GUI.cc 

Log message:
        Added history print & save functions

CVSWeb URLs:
http://cvs.savannah.gnu.org/viewcvs/libcvd/gvars3/src/GUI.cc.diff?tr1=1.9&tr2=1.10&r1=text&r2=text

Patches:
Index: gvars3/src/GUI.cc
diff -u gvars3/src/GUI.cc:1.9 gvars3/src/GUI.cc:1.10
--- gvars3/src/GUI.cc:1.9       Tue May 16 11:09:55 2006
+++ gvars3/src/GUI.cc   Wed May 31 10:28:25 2006
@@ -583,6 +583,43 @@
 #include <readline/readline.h>
 #include <readline/history.h>
 
+void print_history(ostream &ost)
+{
+  HIST_ENTRY **apHistEntries = history_list();
+  if(apHistEntries)
+    while((*apHistEntries)!=NULL)
+      {
+       ost << (*apHistEntries)->line << endl;
+       apHistEntries++;
+      }
+};
+
+void builtin_history(void* ptr, string sCommand, string sParams)
+{
+  cout << "History: " << endl;
+  print_history(cout);
+};
+
+void builtin_save_history(void* ptr, string sCommand, string sParams)
+{
+  vector<string> v = ChopAndUnquoteString(sParams);
+  if(v.size()!=1) 
+    cout << "? GUI internal savehistory command: need one param (filename)." 
<< endl;
+  else
+    {
+      ofstream ofs;
+      ofs.open(v[0].c_str());
+      if(!ofs.good())
+       cout << "? GUI internal savehistory command: cannot open " << v[0] << " 
for write." << endl;
+      else
+       {
+         print_history(ofs);
+         ofs.close();
+         cout << "  Saved to " << v[0] << endl;
+       }
+    };
+};
+
 
 char * GUI::ReadlineCommandGeneratorCB(const char *szText, int nState)
 {
@@ -693,6 +730,8 @@
        RegisterBuiltin("ifeq", builtin_ifeq);
        RegisterBuiltin("toggle", builtin_toggle);
        RegisterBuiltin("set", builtin_set);
+       RegisterBuiltin("history", builtin_history);
+       RegisterBuiltin("savehistory", builtin_save_history);
        RegisterBuiltin("?", builtin_qmark);
        RegisterBuiltin("gvarlist", builtin_gvarlist);
        RegisterBuiltin("printvar", builtin_printvar);




reply via email to

[Prev in Thread] Current Thread [Next in Thread]