aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorThomas White <taw@physics.org>2021-06-28 18:10:55 +0200
committerThomas White <taw@physics.org>2021-06-28 18:10:55 +0200
commit0ed5cee753d2644271e57e530d1bc2d9e065e00c (patch)
tree8bebdff8956ebbb8dca11365e1f0b98ba43a5128
parent2e09f09966a15aa838af9ae96daef702cac09569 (diff)
Fixture display: Add --verbose
-rw-r--r--src/repl-connection.c13
-rw-r--r--src/repl-connection.h3
-rw-r--r--src/starlet-fixture-display.c13
3 files changed, 22 insertions, 7 deletions
diff --git a/src/repl-connection.c b/src/repl-connection.c
index 3dc1896..663c649 100644
--- a/src/repl-connection.c
+++ b/src/repl-connection.c
@@ -42,6 +42,7 @@ struct _replconnection
char input[2048];
void (*process_func)(SCM sexp, void *data);
void *process_func_data;
+ int verbose;
};
@@ -80,7 +81,9 @@ static void process_line(const char *line_orig, ReplConnection *repl)
SCM port, str, sexp;
char *line = strip_crap(line_orig);
- printf("%p recv: '%s'\n", repl, line);
+ if ( repl->verbose ) {
+ printf("%p recv: '%s'\n", repl, line);
+ }
str = scm_from_utf8_string(line);
port = scm_open_input_string(str);
@@ -160,7 +163,8 @@ static void input_ready(GObject *source, GAsyncResult *res, gpointer vp)
ReplConnection *repl_connection_new(const char *socket,
void (*process_func)(SCM sexp, void *data),
- void *data)
+ void *data,
+ int verbose)
{
ReplConnection *repl;
GSocketClient *client;
@@ -186,6 +190,7 @@ ReplConnection *repl_connection_new(const char *socket,
repl->process_func = process_func;
repl->process_func_data = data;
+ repl->verbose = verbose;
repl_send(repl, "(let loop ()"
" (let ((line (read)))"
@@ -208,7 +213,9 @@ int repl_send(ReplConnection *repl, const char *line)
{
GError *error = NULL;
GOutputStream *out = g_io_stream_get_output_stream(G_IO_STREAM(repl->conn));
- printf("%p send: %s\n", repl, line);
+ if ( repl->verbose ) {
+ printf("%p send: %s\n", repl, line);
+ }
if ( g_output_stream_write(out, line, strlen(line), NULL, &error) == -1 ) {
fprintf(stderr, "Couldn't send: %s\n", error->message);
return 1;
diff --git a/src/repl-connection.h b/src/repl-connection.h
index 69f3f0b..433d3b2 100644
--- a/src/repl-connection.h
+++ b/src/repl-connection.h
@@ -28,7 +28,8 @@ typedef struct _replconnection ReplConnection;
extern ReplConnection *repl_connection_new(const char *socket,
void (*process_func)(SCM sexp, void *data),
- void *data);
+ void *data,
+ int verbose);
extern int repl_send(ReplConnection *repl, const char *line);
extern void repl_connection_close(ReplConnection *repl);
extern int repl_closed(ReplConnection *repl);
diff --git a/src/starlet-fixture-display.c b/src/starlet-fixture-display.c
index 8f1d34c..2914b23 100644
--- a/src/starlet-fixture-display.c
+++ b/src/starlet-fixture-display.c
@@ -287,8 +287,9 @@ static struct fixture *find_fixture(struct fixture_display *fixd,
static void show_help(const char *s)
{
printf(_("Syntax: %s [options]\n\n"), s);
- printf(_("Show fixtures in Starlet"
+ printf(_("Show fixtures in Starlet\n"
" -s, --socket REPL socket for Starlet process (default guile.socket).\n"
+ " -v, --verbose Show all REPL communications.\n"
" -h, --help Display this help message.\n"));
}
@@ -466,16 +467,18 @@ int main(int argc, char *argv[])
GtkWidget *mainwindow;
GtkWidget *da;
char *socket = NULL;
+ int verbose = 0;
gtk_init(&argc, &argv);
const struct option longopts[] = {
{"help", 0, NULL, 'h'},
{"socket", 1, NULL, 's'},
+ {"verbose", 0, NULL, 'v'},
{0, 0, NULL, 0}
};
- while ((c = getopt_long(argc, argv, "h", longopts, NULL)) != -1) {
+ while ((c = getopt_long(argc, argv, "hvs:", longopts, NULL)) != -1) {
switch (c)
{
@@ -487,6 +490,10 @@ int main(int argc, char *argv[])
socket = strdup(optarg);
break;
+ case 'v' :
+ verbose = 1;
+ break;
+
case 0 :
break;
@@ -535,7 +542,7 @@ int main(int argc, char *argv[])
g_timeout_add(50, redraw_cb, &fixd);
- fixd.repl = repl_connection_new(socket, process_line, &fixd);
+ fixd.repl = repl_connection_new(socket, process_line, &fixd, verbose);
repl_send(fixd.repl, "(list 'patched-fixtures (patched-fixture-names))");
gtk_main();