plug-ins/script-fu/script-fu-text-console.c plug-ins/script-fu/script-fu.c

2007-05-25  Kevin Cozens  <kcozens@cvs.gnome.org>

	* plug-ins/script-fu/script-fu-text-console.c
	* plug-ins/script-fu/script-fu.c
	* plug-ins/script-fu/scheme-wrapper.c
	* plug-ins/script-fu/scheme-wrapper.h: Applied slightly modified
	patch from Eric Lamarque that makes use of TinyScheme's interactive
	mode for the text console in Script-Fu. Fixes bug #440674.

svn path=/trunk/; revision=22622
This commit is contained in:
Kevin Cozens 2007-05-25 17:45:49 +00:00 committed by Kevin Cozens
parent 9cea61d6b0
commit 0ce5d22b3b
5 changed files with 20 additions and 61 deletions

View File

@ -1,3 +1,12 @@
2007-05-25 Kevin Cozens <kcozens@cvs.gnome.org>
* plug-ins/script-fu/script-fu-text-console.c
* plug-ins/script-fu/script-fu.c
* plug-ins/script-fu/scheme-wrapper.c
* plug-ins/script-fu/scheme-wrapper.h: Applied patch from Eric
Lamarque that makes use of TinyScheme's interactive mode for
the text console in Script-Fu. Fixes bug #440674.
2007-05-25 Sven Neumann <sven@gimp.org>
* plug-ins/common/lens.c: applied patch from Aurimas Juška that
@ -11,7 +20,7 @@
* plug-ins/script-fu/scheme-wrapper.c (ts_output_string): Updated
to expect a 'const char *' and an int but no file pointer.
* plug-ins/script-fu/tinyscheme/scheme.c:
* plug-ins/script-fu/tinyscheme/scheme.c
* plug-ins/script-fu/tinyscheme/scheme.h: Changes due to use of
'const char *' for ts_output_routine.

View File

@ -217,6 +217,12 @@ ts_print_welcome (void)
fprintf (ts_output, "Copyright (c) Dimitrios Souflis\n");
}
void
ts_interpret_stdin (void)
{
scheme_load_file(&sc, stdin);
}
gint
ts_interpret_string (const gchar *expr)
{

View File

@ -36,6 +36,8 @@ void tinyscheme_deinit (void);
void ts_output_string (const char *string, int len);
void ts_interpret_stdin (void);
/* if the return value is 0, success. error otherwise. */
gint ts_interpret_string (const gchar *);

View File

@ -32,10 +32,6 @@
#include "script-fu-intl.h"
static void script_fu_text_console_interface (void);
void
script_fu_text_console_run (const gchar *name,
gint nparams,
@ -50,7 +46,7 @@ script_fu_text_console_run (const gchar *name,
ts_print_welcome ();
/* Run the interface */
script_fu_text_console_interface ();
ts_interpret_stdin();
values[0].type = GIMP_PDB_STATUS;
values[0].data.d_status = GIMP_PDB_SUCCESS;
@ -58,58 +54,3 @@ script_fu_text_console_run (const gchar *name,
*nreturn_vals = 1;
*return_vals = values;
}
static gboolean
read_command (GString *command)
{
gint next;
gint level = 0;
g_string_truncate (command, 0);
while ((next = fgetc (stdin)) != EOF)
{
guchar c = (guchar) next;
switch (c)
{
case '\n':
if (level == 0)
return TRUE;
c = ' ';
break;
case '(':
level++;
break;
case ')':
level--;
break;
default:
break;
}
g_string_append_c (command, c);
}
if (errno)
g_printerr ("error reading from stdin: %s\n", g_strerror (errno));
return FALSE;
}
static void
script_fu_text_console_interface (void)
{
GString *command = g_string_new (NULL);
while (read_command (command))
{
if (command->len > 0)
ts_interpret_string (command->str);
}
g_string_free (command, TRUE);
}

View File

@ -230,6 +230,7 @@ script_fu_run (const gchar *name,
* The script-fu text console for interactive Scheme development
*/
ts_output_routine = NULL;
script_fu_text_console_run (name, nparams, param,
nreturn_vals, return_vals);
}