]> git.sur5r.net Git - bacula/bacula/commitdiff
- wxbHistoryTextCtrl : Created a new text control that keep an history
authorNicolas Boichat <nicolas@boichat.ch>
Thu, 15 Jul 2004 17:09:06 +0000 (17:09 +0000)
committerNicolas Boichat <nicolas@boichat.ch>
Thu, 15 Jul 2004 17:09:06 +0000 (17:09 +0000)
     of typed commands.
 - wxbMainFrame : Fixed config file problem when changing the default
     configuration file (Linux)

git-svn-id: https://bacula.svn.sourceforge.net/svnroot/bacula/trunk@1466 91ce42f0-d328-0410-95d8-f526ca767f89

bacula/src/wx-console/CHANGELOG
bacula/src/wx-console/Makefile.in
bacula/src/wx-console/TODO
bacula/src/wx-console/wxbhistorytextctrl.cpp [new file with mode: 0644]
bacula/src/wx-console/wxbhistorytextctrl.h [new file with mode: 0644]
bacula/src/wx-console/wxbmainframe.cpp
bacula/src/wx-console/wxbmainframe.h

index 2d31e0e75c47fc75e7450fa6de904032b1afe2d4..9a56cfcf4a2b7dcfd0058178bd1128c37adc1daa 100644 (file)
@@ -1,3 +1,11 @@
+15-07-2004 :
+ - wxbHistoryTextCtrl : Created a new text control that keep an history
+     of typed commands.
+
+14-07-2004 :
+ - wxbMainFrame : Fixed config file problem when changing the default
+     configuration file (Linux)
+
 03-07-2004 :
  - wxbConfigPanel : Fixed ?: operator cast problem with gcc 2.95.
 
index 9c3f0163c3b861ccd61643bddba143f3f5758104..0457717cbac1845818f841ce19b1ccbeb301e607 100644 (file)
@@ -22,10 +22,10 @@ dummy:
 #
 CONSSRCS = main.cpp console_thread.cpp authenticate.c console_conf.c wxbrestorepanel.cpp \
             wxbmainframe.cpp wxbtableparser.cpp wxbtreectrl.cpp wxblistctrl.cpp wxbutils.cpp \
-            wxbconfigpanel.cpp wxbconfigfileeditor.cpp
+            wxbconfigpanel.cpp wxbconfigfileeditor.cpp wxbhistorytextctrl.cpp
 CONSOBJS = main.o console_thread.o authenticate.o console_conf.o wxbrestorepanel.o \
             wxbmainframe.o wxbtableparser.o wxbtreectrl.o wxblistctrl.o wxbutils.o \
-            wxbconfigpanel.o wxbconfigfileeditor.o
+            wxbconfigpanel.o wxbconfigfileeditor.o wxbhistorytextctrl.o
 
 win32 = wx-console_private.res
 
index 858787c2f6162faae0ceea3052f0ee73ef30a9b7..3d907a8c7e2a814f0816abee5ef3a7aa6970caa6 100644 (file)
@@ -1,5 +1,9 @@
 general : Show nice messages boxes when errors occurs.
 
+wxbRestorePanel : Crashing when there is no backup to show (fresh install)
+
+GTK2 : The console control is not scrolled correctly
+
 Win32 : Crash when quitting while trying to connect
 
 Mac OS X : "You must first get a unique identifier for your application, 
@@ -22,7 +26,7 @@ wxbUtils : add clients, jobs, filesets, pools... list, merge patch file (wxbnewu
 
 general : add a tab containing messages
 
-wxbMainFrame : Implement command history (accessible with up and down keys)
+wxbMainFrame : Implement command completion (tab)
 
 wxbMainFrame : When an unexpected question is in this format (***? (yes/mod/no):),
    show a list to choose one of these possibilities.
diff --git a/bacula/src/wx-console/wxbhistorytextctrl.cpp b/bacula/src/wx-console/wxbhistorytextctrl.cpp
new file mode 100644 (file)
index 0000000..eb5120e
--- /dev/null
@@ -0,0 +1,73 @@
+/*
+ *
+ *   Text control with an history of commands typed
+ *
+ *    Nicolas Boichat, July 2004
+ *
+ */
+/*
+   Copyright (C) 2004 Kern Sibbald and John Walker
+
+   This program is free software; you can redistribute it and/or
+   modify it under the terms of the GNU General Public License
+   as published by the Free Software Foundation; either version 2
+   of the License, or (at your option) any later version.
+
+   This program is distributed in the hope that it will be useful,
+   but WITHOUT ANY WARRANTY; without even the implied warranty of
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+   GNU General Public License for more details.
+
+   You should have received a copy of the GNU General Public License
+   along with this program; if not, write to the Free Software
+   Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
+ */
+#include "wxbhistorytextctrl.h"
+
+BEGIN_EVENT_TABLE(wxbHistoryTextCtrl, wxTextCtrl)
+   EVT_KEY_UP(wxbHistoryTextCtrl::OnKeyUp)
+END_EVENT_TABLE()
+
+wxbHistoryTextCtrl::wxbHistoryTextCtrl(wxWindow* parent, wxWindowID id, 
+      const wxString& value, const wxPoint& pos, 
+      const wxSize& size , 
+      const wxValidator& validator, 
+      const wxString& name): 
+         wxTextCtrl(parent, id, value, pos, size, 
+            wxTE_PROCESS_ENTER, validator, name) {
+   index = 0;
+   history.Add("");
+}
+
+void wxbHistoryTextCtrl::HistoryAdd(wxString cmd) {
+   if (cmd == "") return;
+   index = history.Count();
+   history[index-1] = cmd;
+   history.Add("");
+}
+
+void wxbHistoryTextCtrl::OnKeyUp(wxKeyEvent& event) {
+   if (event.m_keyCode == WXK_UP) {
+      if (index > 0) {
+         if (index == (history.Count()-1)) {
+            history[index] = GetValue();
+         }
+         index--;
+         SetValue(history[index]);
+         SetInsertionPointEnd();
+      }
+   }
+   else if (event.m_keyCode == WXK_DOWN) {
+      if (index < (history.Count()-1)) {
+         index++;
+         SetValue(history[index]);
+         SetInsertionPointEnd();
+      }      
+   }
+   else {
+      event.Skip();
+   }
+}
+
+
diff --git a/bacula/src/wx-console/wxbhistorytextctrl.h b/bacula/src/wx-console/wxbhistorytextctrl.h
new file mode 100644 (file)
index 0000000..a3c0ccf
--- /dev/null
@@ -0,0 +1,56 @@
+/*
+ *
+ *   Text control with an history of commands typed
+ *
+ *    Nicolas Boichat, July 2004
+ *
+ */
+/*
+   Copyright (C) 2004 Kern Sibbald and John Walker
+
+   This program is free software; you can redistribute it and/or
+   modify it under the terms of the GNU General Public License
+   as published by the Free Software Foundation; either version 2
+   of the License, or (at your option) any later version.
+
+   This program is distributed in the hope that it will be useful,
+   but WITHOUT ANY WARRANTY; without even the implied warranty of
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+   GNU General Public License for more details.
+
+   You should have received a copy of the GNU General Public License
+   along with this program; if not, write to the Free Software
+   Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
+ */
+
+#ifndef WXBHISTORYTEXTCTRL
+#define WXBHISTORYTEXTCTRL
+
+#include "wx/wxprec.h"
+
+#ifndef WX_PRECOMP
+   #include "wx/wx.h"
+#endif
+
+#include <wx/treectrl.h>
+
+class wxbHistoryTextCtrl: public wxTextCtrl {
+   public:
+      wxbHistoryTextCtrl(wxWindow* parent, wxWindowID id, 
+         const wxString& value = "", const wxPoint& pos = wxDefaultPosition,
+         const wxSize& size = wxDefaultSize, 
+         const wxValidator& validator = wxDefaultValidator, 
+         const wxString& name = wxTextCtrlNameStr);
+         
+      void HistoryAdd(wxString cmd);
+   private:
+      wxArrayString history;
+      int index;
+      
+      void OnKeyUp(wxKeyEvent& event);
+      
+      DECLARE_EVENT_TABLE();
+};
+
+#endif //WXBHISTORYTEXTCTRL
+
index c61c574216dc86b82af3a6214d868bc7e8c900a5..13a29fb4c3bd29061fa95124bb0b47efb1fd6f1b 100644 (file)
@@ -2,7 +2,7 @@
  *
  *   Main frame
  *
- *    Nicolas Boichat, April 2004
+ *    Nicolas Boichat, July 2004
  *
  */
 /*
@@ -264,7 +264,7 @@ wxbMainFrame::wxbMainFrame(const wxString& title, const wxPoint& pos, const wxSi
    consoleSizer->AddGrowableCol(0);
    consoleSizer->AddGrowableRow(0);
 
-   typeCtrl = new wxTextCtrl(consolePanel,TypeText,"",wxDefaultPosition,wxSize(200,20), wxTE_PROCESS_ENTER);
+   typeCtrl = new wxbHistoryTextCtrl(consolePanel,TypeText,"",wxDefaultPosition,wxSize(200,20));
    sendButton = new wxButton(consolePanel, SendButton, "Send");
    
    wxFlexGridSizer *typeSizer = new wxFlexGridSizer(1, 3, 0, 0);
@@ -479,6 +479,7 @@ void wxbMainFrame::OnChangeConfig(wxCommandEvent& event) {
                            wxYES_NO | wxICON_QUESTION, this);
          if (answer == wxYES) {
               wxConfigBase::Get()->Write("/ConfigFile", configfile);
+              wxConfigBase::Get()->Flush();
               StartConsoleThread("");
               return;
          }
@@ -512,6 +513,7 @@ void wxbMainFrame::OnEnter(wxCommandEvent& WXUNUSED(event))
 {
    lockedbyconsole = true;
    DisablePanels();
+   typeCtrl->HistoryAdd(typeCtrl->GetValue());
    wxString str = typeCtrl->GetValue() + "\n";
    Send(str);
 }
@@ -538,6 +540,7 @@ void wxbMainFrame::Print(wxString str, int status)
       consoleCtrl->AppendText(consoleBuffer);
       consoleBuffer = "";
       SetStatusText("Console thread terminated.");
+      consoleCtrl->ScrollLines(3);
       ct = NULL;
       DisablePanels();
       int answer = wxMessageBox("Connection to the director lost. Quit program?", "Connection lost",
@@ -569,6 +572,7 @@ void wxbMainFrame::Print(wxString str, int status)
    if (status == CS_DISCONNECTED) {
       consoleCtrl->AppendText(consoleBuffer);
       consoleBuffer = "";
+      consoleCtrl->ScrollLines(3);
       SetStatusText("Disconnected of the director.");
       DisablePanels();
       return;
@@ -637,6 +641,7 @@ void wxbMainFrame::Print(wxString str, int status)
    if (status == CS_DEBUG) {
       consoleCtrl->AppendText(consoleBuffer);
       consoleBuffer = "";
+      consoleCtrl->ScrollLines(3);
       consoleCtrl->SetDefaultStyle(wxTextAttr(wxColour(0, 128, 0)));
    }
    else {
index 3dab968191a2f40318ef8e12d3e10dc866457f5c..9cdcc000057e84fa2b6cbccf6106ec4ff494cdd3 100644 (file)
@@ -2,7 +2,7 @@
  *
  *   Main frame header file
  *
- *    Nicolas Boichat, April 2004
+ *    Nicolas Boichat, July 2004
  *
  */
 /*
@@ -48,6 +48,8 @@
 
 #include "wxbutils.h"
 
+#include "wxbhistorytextctrl.h"
+
 WX_DEFINE_ARRAY(wxbDataParser*, wxbDataParsers);
 
 // ----------------------------------------------------------------------------
@@ -135,11 +137,13 @@ private:
    wxbMainFrame(const wxString& title, const wxPoint& pos, const wxSize& size, long style);
    ~wxbMainFrame();
    
+   static wxbMainFrame *frame; /* this */
+
    wxMenu *menuFile;
 
    wxNotebook *notebook; /* main notebook */
    wxTextCtrl *consoleCtrl; /* wxTextCtrl containing graphical console */
-   wxTextCtrl *typeCtrl; /* wxTextCtrl for console user input */
+   wxbHistoryTextCtrl *typeCtrl; /* wxbHistoryTextCtrl for console user input */
    wxButton *sendButton; /* wxButton used to send data */
 
    wxbPanel **panels; /* panels array, contained in the notebook */
@@ -147,14 +151,12 @@ private:
 
    wxbPromptParser* promptparser; /* prompt parser catching uncatched questions */
 
-   static wxbMainFrame *frame; /* this */
-   
    bool lockedbyconsole; /* true if the panels have been locked by something typed in the console */
    
    wxString configfile; /* configfile used */
    
    wxString consoleBuffer; /* Buffer used to print in the console line by line */
-   
+     
    // any class wishing to process wxWindows events must use this macro
    DECLARE_EVENT_TABLE()
 };