- Write code for the graphical terminal widget
git-svn-id: svn://svn.gna.org/svn/sgpemv2/trunk@315 3ecf2c5c-341e-0410-92b4-d18e462d057c
This commit is contained in:
parent
be3de1dade
commit
d6a19ca35d
|
@ -27,10 +27,36 @@
|
||||||
#include <gtkmm/textview.h>
|
#include <gtkmm/textview.h>
|
||||||
#include <glibmm/ustring.h>
|
#include <glibmm/ustring.h>
|
||||||
|
|
||||||
|
#include <algorithm>
|
||||||
|
|
||||||
using namespace sgpem;
|
using namespace sgpem;
|
||||||
|
|
||||||
GraphicalTerminalIO::GraphicalTerminalIO()
|
GraphicalTerminalIO::GraphicalTerminalIO()
|
||||||
{}
|
{
|
||||||
|
using namespace Gtk;
|
||||||
|
|
||||||
|
set_title(_("Textual Simulation Log"));
|
||||||
|
set_default_size(500,300);
|
||||||
|
|
||||||
|
Gtk::Box* mainbox = manage(new VBox());
|
||||||
|
add(*mainbox);
|
||||||
|
|
||||||
|
_text_output.set_editable(false);
|
||||||
|
_text_output.modify_font(Pango::FontDescription("monospace"));
|
||||||
|
mainbox->pack_start(_text_output);
|
||||||
|
|
||||||
|
Gtk::Box* cmdbox = manage(new HBox());
|
||||||
|
mainbox->pack_end(*cmdbox, false, false);
|
||||||
|
|
||||||
|
cmdbox->pack_start(_text_input);
|
||||||
|
|
||||||
|
//Gtk::Button* bt_tell = manage(new Button(_("Tell")));
|
||||||
|
// signals lack return value:
|
||||||
|
//bt_tell->signal_clicked().connect(sigc::mem_fun(*this, read_buffer));
|
||||||
|
//cmdbox->pack_start(*bt_tell, false, true);
|
||||||
|
|
||||||
|
show_all_children();
|
||||||
|
}
|
||||||
|
|
||||||
GraphicalTerminalIO::~GraphicalTerminalIO()
|
GraphicalTerminalIO::~GraphicalTerminalIO()
|
||||||
{}
|
{}
|
||||||
|
@ -38,13 +64,25 @@ GraphicalTerminalIO::~GraphicalTerminalIO()
|
||||||
GraphicalTerminalIO::size_type
|
GraphicalTerminalIO::size_type
|
||||||
GraphicalTerminalIO::write_buffer(const Glib::ustring& buffer)
|
GraphicalTerminalIO::write_buffer(const Glib::ustring& buffer)
|
||||||
{
|
{
|
||||||
// FIXME
|
_text_output.get_buffer()->insert_at_cursor(buffer);
|
||||||
return 0;
|
return buffer.size();
|
||||||
}
|
}
|
||||||
|
|
||||||
GraphicalTerminalIO::size_type
|
Glib::ustring
|
||||||
GraphicalTerminalIO::read_command(Glib::ustring& buffer) const
|
GraphicalTerminalIO::read_command() const
|
||||||
{
|
{
|
||||||
// FIXME
|
using Glib::ustring;
|
||||||
|
static const ustring whitespaces = " \r\b\n\t\a";
|
||||||
|
// are there any other wspaces?
|
||||||
|
|
||||||
|
ustring command = _text_input.get_text();
|
||||||
|
|
||||||
|
// trimming:
|
||||||
|
size_type f = command.find_first_not_of(whitespaces);
|
||||||
|
size_type l = command.find_last_not_of(whitespaces);
|
||||||
|
if(f == ustring::npos)
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
|
_text_input.set_text(ustring(""));
|
||||||
|
return command.substr(f,l);
|
||||||
}
|
}
|
||||||
|
|
|
@ -27,6 +27,7 @@
|
||||||
#include <gtkmm/box.h>
|
#include <gtkmm/box.h>
|
||||||
#include <gtkmm/entry.h>
|
#include <gtkmm/entry.h>
|
||||||
#include <gtkmm/textview.h>
|
#include <gtkmm/textview.h>
|
||||||
|
#include <gtkmm/window.h>
|
||||||
#include <glibmm/ustring.h>
|
#include <glibmm/ustring.h>
|
||||||
|
|
||||||
#include "io_manager.hh"
|
#include "io_manager.hh"
|
||||||
|
@ -42,7 +43,7 @@ namespace sgpem {
|
||||||
/** \brief
|
/** \brief
|
||||||
*
|
*
|
||||||
* ... long desc ... */
|
* ... long desc ... */
|
||||||
class GraphicalTerminalIO : public IOManager, public Gtk::VBox
|
class GraphicalTerminalIO : public IOManager, public Gtk::Window
|
||||||
{
|
{
|
||||||
typedef unsigned int size_type;
|
typedef unsigned int size_type;
|
||||||
public:
|
public:
|
||||||
|
@ -50,10 +51,10 @@ namespace sgpem {
|
||||||
virtual ~GraphicalTerminalIO();
|
virtual ~GraphicalTerminalIO();
|
||||||
|
|
||||||
virtual size_type write_buffer(const Glib::ustring& buffer);
|
virtual size_type write_buffer(const Glib::ustring& buffer);
|
||||||
virtual size_type read_command(Glib::ustring& buffer) const;
|
virtual Glib::ustring read_command() const;
|
||||||
private:
|
private:
|
||||||
Gtk::TextView text_output;
|
Gtk::TextView _text_output;
|
||||||
Gtk::Entry text_input;
|
mutable Gtk::Entry _text_input;
|
||||||
};
|
};
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -44,7 +44,7 @@ namespace sgpem {
|
||||||
virtual ~IOManager() {}
|
virtual ~IOManager() {}
|
||||||
|
|
||||||
virtual size_type write_buffer(const Glib::ustring& buffer) = 0;
|
virtual size_type write_buffer(const Glib::ustring& buffer) = 0;
|
||||||
virtual size_type read_command(Glib::ustring& buffer) const = 0;
|
virtual Glib::ustring read_command() const = 0;
|
||||||
};
|
};
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -61,7 +61,7 @@ main(int argc, char* argv[])
|
||||||
filenames.insert(filenames.begin(), a_ptr, a_ptr+a_count);
|
filenames.insert(filenames.begin(), a_ptr, a_ptr+a_count);
|
||||||
}
|
}
|
||||||
*/
|
*/
|
||||||
//start_gui(argc, argv);
|
start_gui(argc, argv);
|
||||||
|
|
||||||
//SMOKE-TEST for backend classes
|
//SMOKE-TEST for backend classes
|
||||||
cout << "\n\n********************************";
|
cout << "\n\n********************************";
|
||||||
|
|
|
@ -34,7 +34,7 @@ using namespace sgpem;
|
||||||
MainWindow::MainWindow()
|
MainWindow::MainWindow()
|
||||||
{
|
{
|
||||||
set_title(PACKAGE_STRING);
|
set_title(PACKAGE_STRING);
|
||||||
set_default_size(800, 600);
|
//set_default_size(800, 600);
|
||||||
|
|
||||||
Gtk::Box* mainbox = manage(new Gtk::VBox());
|
Gtk::Box* mainbox = manage(new Gtk::VBox());
|
||||||
add(*mainbox);
|
add(*mainbox);
|
||||||
|
|
|
@ -21,7 +21,7 @@
|
||||||
#include "config.h"
|
#include "config.h"
|
||||||
#include "gettext.h"
|
#include "gettext.h"
|
||||||
|
|
||||||
#include "main_window.hh"
|
#include "graphical_terminal_io.hh"
|
||||||
#include "start_gui.hh"
|
#include "start_gui.hh"
|
||||||
|
|
||||||
#include <gtkmm/main.h>
|
#include <gtkmm/main.h>
|
||||||
|
@ -30,6 +30,6 @@ void
|
||||||
start_gui(int argc, char** argv)
|
start_gui(int argc, char** argv)
|
||||||
{
|
{
|
||||||
Gtk::Main gtk_main(argc,argv);
|
Gtk::Main gtk_main(argc,argv);
|
||||||
sgpem::MainWindow main_window;
|
sgpem::GraphicalTerminalIO main_window;
|
||||||
Gtk::Main::run(main_window);
|
Gtk::Main::run(main_window);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue