Eduardo Acuña Yeomans.
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
the class declaration is this:
class GUIrepl : public QDialog
{
Q_OBJECT
QTextBrowser *output_text_browser;
QLineEdit *input_line_edit;
QPushButton *evaluate_btn;
SCM my_output_port;
public:
explicit GUIrepl(QWidget *parent = 0);
~GUIrepl();
private slots:
void evaluate_expression();
};
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
the function that handles the evaluation is this:
void GUIrepl::evaluate_expression()
{
QString input;
SCM result_obj;
SCM result_str;
QString to_print;
input = this->input_line_edit->text();
result_obj = scm_c_eval_string(input.toStdString().data());
result_str = scm_object_to_string(result_obj, SCM_UNDEFINED);
to_print = scm_to_locale_string(result_str);
SCM out = scm_get_output_string(this->my_output_port);
QString out_str = scm_to_locale_string(out);
input = "> "+input;
this->output_text_browser->append(input);
if(out_str != "")
this->pantalla->append(out_str);
if(to_print != "#<unspecified>")
this->output_text_browser->append(to_print);
this->input_line_edit->setText("");
scm_truncate_file(this->my_output_port, scm_from_uint16(0));
}
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
and in the GUIrepl class constructor i have this:
my_output_port = scm_open_output_string();
scm_set_current_output_port(my_output_port);
Its very basic and most of it is in spanish. Its going to be a program where you can write algorithms in scheme for finite state machines, graph theory, grammars and cellular automata and the graphic representation is in c++.