From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: =?ISO-8859-1?Q?Eduardo_Acu=F1a?= Newsgroups: gmane.lisp.guile.user Subject: Request for help Qt, C++ and guile REPL. Date: Thu, 20 Jun 2013 09:04:59 -0700 Message-ID: NNTP-Posting-Host: plane.gmane.org Mime-Version: 1.0 Content-Type: multipart/alternative; boundary=e89a8ff1cf12b3eef704df981b71 X-Trace: ger.gmane.org 1371744322 28708 80.91.229.3 (20 Jun 2013 16:05:22 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Thu, 20 Jun 2013 16:05:22 +0000 (UTC) To: guile-user@gnu.org Original-X-From: guile-user-bounces+guile-user=m.gmane.org@gnu.org Thu Jun 20 18:05:24 2013 Return-path: Envelope-to: guile-user@m.gmane.org Original-Received: from lists.gnu.org ([208.118.235.17]) by plane.gmane.org with esmtp (Exim 4.69) (envelope-from ) id 1UphMP-0005bM-Dm for guile-user@m.gmane.org; Thu, 20 Jun 2013 18:05:21 +0200 Original-Received: from localhost ([::1]:46972 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1UphMO-0003Tw-OP for guile-user@m.gmane.org; Thu, 20 Jun 2013 12:05:20 -0400 Original-Received: from eggs.gnu.org ([2001:4830:134:3::10]:58924) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1UphMB-0003Ka-H1 for guile-user@gnu.org; Thu, 20 Jun 2013 12:05:13 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1UphM4-0001Em-MJ for guile-user@gnu.org; Thu, 20 Jun 2013 12:05:07 -0400 Original-Received: from mail-oa0-x22c.google.com ([2607:f8b0:4003:c02::22c]:45784) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1UphM4-0001Ei-F4 for guile-user@gnu.org; Thu, 20 Jun 2013 12:05:00 -0400 Original-Received: by mail-oa0-f44.google.com with SMTP id l10so8218940oag.3 for ; Thu, 20 Jun 2013 09:04:59 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:date:message-id:subject:from:to:content-type; bh=am3WDADS1xgqgmlqbyfwDvCU49Qdh67zV31HLoPx8jY=; b=FehWxDR3lh09UVTQZH+AY69LpX1k5Uvl2qYllGBaWf1+yvG0+LRBTCQgKPN2cLLpN8 A/8i9WNPhs2HuTyW5tAPiYjtJ3Vs6IlE8rs3UZ+u1yio1FkzjXGUKAoN6e/jtHYX63+z D1z6csq2tORBMMZR/zwKe+xs1hpArEZr8M4Xg4h+YB5mGRahw68JIqBk6JVrQvrBvcRQ GFPxzgxP+++4pMKb+lPRdCryOLu8acg8zWMHoP0oivMUY9UlLY8kd/LHJ5lSjjtcRnbc A1vDNyRkQUmEB2lBWqqTWiwY6AHQGXzM8GHu2nZ8dGB4WJKDQjJGpSPhGyvBglN8RBxQ Slkw== X-Received: by 10.182.128.71 with SMTP id nm7mr1800132obb.12.1371744299641; Thu, 20 Jun 2013 09:04:59 -0700 (PDT) Original-Received: by 10.76.19.210 with HTTP; Thu, 20 Jun 2013 09:04:59 -0700 (PDT) X-detected-operating-system: by eggs.gnu.org: Error: Malformed IPv6 address (bad octet value). X-Received-From: 2607:f8b0:4003:c02::22c X-BeenThere: guile-user@gnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: General Guile related discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: guile-user-bounces+guile-user=m.gmane.org@gnu.org Original-Sender: guile-user-bounces+guile-user=m.gmane.org@gnu.org Xref: news.gmane.org gmane.lisp.guile.user:10483 Archived-At: --e89a8ff1cf12b3eef704df981b71 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: quoted-printable Hello! I have found the archives of this mailing list very helpful in the development of a piece of software i'm writing. And i have a few questions about the integration between guile, c++ and the library Qt. The program in question is a little gui repl, where the user can type guile code in a 'QLineEdit' widget and the evaluation gets printed in a 'QTextBrowser' widget. I have done this in a very basic way. But the problem is that if the user types: (begin (display "hello")(sleep 2)) the result gets printed after the 2 seconds. What can i do to get the gui repl more like que standard guile repl? Thank you in advance. Eduardo Acu=F1a 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 =3D 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 =3D this->input_line_edit->text(); result_obj =3D scm_c_eval_string(input.toStdString().data()); result_str =3D scm_object_to_string(result_obj, SCM_UNDEFINED); to_print =3D scm_to_locale_string(result_str); SCM out =3D scm_get_output_string(this->my_output_port); QString out_str =3D scm_to_locale_string(out); input =3D "> "+input; this->output_text_browser->append(input); if(out_str !=3D "") this->pantalla->append(out_str); if(to_print !=3D "#") 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 =3D scm_open_output_string(); scm_set_current_output_port(my_output_port); The entire proyect is in here:https://github.com/eduardoacye/Automaton 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++. --e89a8ff1cf12b3eef704df981b71 Content-Type: text/html; charset=ISO-8859-1 Content-Transfer-Encoding: quoted-printable
Hello!

I have= found the archives of this mailing list very helpful in the development of= a piece of software i'm writing. And i have a few questions about the = integration between guile, c++ and the library Qt.

The program in question is a little gui repl, where the user can type g= uile code in a 'QLineEdit' widget and the evaluation gets printed i= n a 'QTextBrowser' widget.

I have done this in a very basic = way. But the problem is that if the user types:

(begin (display "hello")(sleep 2))

the result gets pri= nted after the 2 seconds. What can i do to get the gui repl more like que s= tandard guile repl?

Thank you in advanc= e.

=
Eduardo Acu=F1a Yeomans.

= ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
the class declaration is this:

class GUIrepl : public QDialog
{=A0 =A0 Q_OBJECT

=A0 =A0 QTextBrowser *output_text_browser;
=A0= =A0 QLineEdit =A0 =A0*input_line_edit;
=A0 =A0 QPushButton =A0*evaluate= _btn;

=A0 =A0 SCM my_output_port;
public:
=A0 =A0 explicit GUIrepl(QWidget *parent =3D 0);
=A0 =A0 ~GUI= repl();
private slots:
=A0 =A0 void evaluate_expression();
};

;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;= ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;=
the function that handles the evaluation is this:

void GUIrepl::eval= uate_expression()
{
=A0 =A0 QString input;
=A0 =A0 SCM result_obj;=
=A0 =A0 SCM result_str;
=A0 =A0 QString to_print;
=A0 =A0
=A0 = =A0 input =3D this->input_line_edit->text();
=A0 =A0
=A0 =A0 result_obj =3D scm_c_eval_string(input.toStdString().dat= a());
=A0 =A0 result_str =3D scm_object_to_string(result_obj, SCM_UNDEFI= NED);
=A0 =A0 to_print =3D scm_to_locale_string(result_str);

=A0 = =A0 SCM out =3D scm_get_output_string(this->my_output_port);
=A0 =A0 QString out_str =3D scm_to_locale_string(out);
=A0 =A0
=A0 = =A0 input =3D "> "+input;
=A0 =A0 this->output_text_brow= ser->append(input);
=A0 =A0 if(out_str !=3D "")
this->= ;pantalla->append(out_str);
=A0 =A0 if(to_print !=3D "#<unspecified>")
this->outp= ut_text_browser->append(to_print);

=A0 =A0 this->input_line_ed= it->setText("");
=A0 =A0 scm_truncate_file(this->my_outp= ut_port, scm_from_uint16(0));
}

;;;;;;;;;;;;;;;;;;;;;;= ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
and in the GUIrepl class constructor i have this:

my_output_port =3D= scm_open_output_string();
scm_set_current_output_port(my_output_port);<= /font>


The entire proyect is i= n here:https://github.= com/eduardoacye/Automaton
Its very= basic and most of it is in spanish. Its going to be a program where you ca= n write algorithms in scheme for finite state machines, graph theory, gramm= ars and cellular automata and the graphic representation is in c++.<= /div>


--e89a8ff1cf12b3eef704df981b71--