*
* Main frame
*
- * Nicolas Boichat, April 2004
+ * Nicolas Boichat, July 2004
*
*/
/*
#include <wx/filename.h>
+#undef Yield /* MinGW defines Yield */
+
// ----------------------------------------------------------------------------
// event tables and other macros for wxWindows
// ----------------------------------------------------------------------------
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);
lockedbyconsole = false;
consoleBuffer = "";
+
+ configfile = "";
}
/*
if (ct != NULL) {
ct->Delete();
ct = NULL;
+ wxTheApp->Yield();
}
if (promptparser == NULL) {
promptparser = new wxbPromptParser();
}
- wxString configfile;
-
if (config == "") {
if ((wxTheApp->argc == 3) && (wxString(wxTheApp->argv[1]) == "-c")) {
configfile = wxTheApp->argv[2];
if (ct != NULL) {
ct->Delete();
ct = NULL;
+ wxTheApp->Yield();
}
console_thread::FreeLib();
frame = NULL;
+ wxTheApp->Yield();
Close(TRUE);
}
wxYES_NO | wxICON_QUESTION, this);
if (answer == wxYES) {
wxConfigBase::Get()->Write("/ConfigFile", configfile);
+ wxConfigBase::Get()->Flush();
StartConsoleThread("");
return;
}
}
void wxbMainFrame::OnConnect(wxCommandEvent& event) {
- menuFile->Enable(MenuConnect, false);
- menuFile->Enable(MenuDisconnect, false);
- menuFile->Enable(ChangeConfigFile, false);
- menuFile->Enable(EditConfigFile, false);
-
- if (ct != NULL) {
- ct->Delete();
- ct = NULL;
- }
- if (promptparser == NULL) {
- promptparser = new wxbPromptParser();
- }
-
- ct = new console_thread();
- ct->Create();
- ct->Run();
- SetStatusText("Connecting to the director...");
+ StartConsoleThread(configfile);
}
void wxbMainFrame::OnDisconnect(wxCommandEvent& event) {
{
lockedbyconsole = true;
DisablePanels();
+ typeCtrl->HistoryAdd(typeCtrl->GetValue());
wxString str = typeCtrl->GetValue() + "\n";
Send(str);
}
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",
menuFile->Enable(MenuConnect, true);
menuFile->SetLabel(MenuConnect, "Reconnect");
menuFile->SetHelpString(MenuConnect, "Reconnect to the director");
- menuFile->Enable(MenuDisconnect, false);
+ menuFile->Enable(MenuDisconnect, true);
menuFile->Enable(ChangeConfigFile, true);
menuFile->Enable(EditConfigFile, true);
return;
if (status == CS_DISCONNECTED) {
consoleCtrl->AppendText(consoleBuffer);
consoleBuffer = "";
+ consoleCtrl->ScrollLines(3);
SetStatusText("Disconnected of the director.");
DisablePanels();
return;
Send("\n");
}
else {
- Send(wxString() << numbers[res] << "\n");
+ if (promptparser->isNumericalChoice()) {
+ Send(wxString() << numbers[res] << "\n");
+ }
+ else {
+ Send(wxString() << choices[res] << "\n");
+ }
}
}
else {
if (status == CS_DEBUG) {
consoleCtrl->AppendText(consoleBuffer);
consoleBuffer = "";
+ consoleCtrl->ScrollLines(3);
consoleCtrl->SetDefaultStyle(wxTextAttr(wxColour(0, 128, 0)));
}
else {
if (lockedbyconsole) {
EnableConsole(true);
}
- consoleBuffer << "<P>";
+ //consoleBuffer << "<P>";
}
if ((status == CS_END) || (status == CS_PROMPT) || (str.Find("\n") > -1)) {