diff options
author | Marius Vollmer <mvo@zagadka.de> | 2004-09-23 17:44:40 +0000 |
---|---|---|
committer | Marius Vollmer <mvo@zagadka.de> | 2004-09-23 17:44:40 +0000 |
commit | d232520a23677ac22435e6c3144e8634376cb295 (patch) | |
tree | 8343d39a056a738ded77cd52ea11185e8d75623c | |
parent | d5ac9b2a8c46dbe1bbe074cd93cb9e6693073bd6 (diff) | |
download | guile-d232520a23677ac22435e6c3144e8634376cb295.tar.gz |
* print.h (scm_print_state): Added highlight_objects.
* print.c (make_print_state, scm_free_print_state): Initialize it
to SCM_EOL.
(scm_iprin1): Wrap output in '{...}' when object is contained in
highlight_objects.
-rw-r--r-- | libguile/print.c | 18 | ||||
-rw-r--r-- | libguile/print.h | 5 |
2 files changed, 21 insertions, 2 deletions
diff --git a/libguile/print.c b/libguile/print.c index 5a0eaadd4..ee5e34c84 100644 --- a/libguile/print.c +++ b/libguile/print.c @@ -160,6 +160,7 @@ make_print_state (void) pstate->ref_vect = scm_c_make_vector (PSTATE_SIZE, SCM_UNDEFINED); pstate->ref_stack = SCM_WRITABLE_VELTS (pstate->ref_vect); pstate->ceiling = SCM_VECTOR_LENGTH (pstate->ref_vect); + pstate->highlight_objects = SCM_EOL; return print_state; } @@ -192,6 +193,7 @@ scm_free_print_state (SCM print_state) */ pstate->fancyp = 0; pstate->revealed = 0; + pstate->highlight_objects = SCM_EOL; scm_i_plugin_mutex_lock (&print_state_mutex); handle = scm_cons (print_state, print_state_pool); print_state_pool = handle; @@ -350,9 +352,25 @@ scm_print_symbol_name (const char *str, size_t len, SCM port) SCM_GPROC(s_write, "write", 1, 1, 0, scm_write, g_write); SCM_GPROC(s_display, "display", 1, 1, 0, scm_display, g_display); +static void iprin1 (SCM exp, SCM port, scm_print_state *pstate); + void scm_iprin1 (SCM exp, SCM port, scm_print_state *pstate) { + if (pstate->fancyp + && scm_is_true (scm_memq (exp, pstate->highlight_objects))) + { + scm_lfwrite ("{", 1, port); + iprin1 (exp, port, pstate); + scm_lfwrite ("}", 1, port); + } + else + iprin1 (exp, port, pstate); +} + +static void +iprin1 (SCM exp, SCM port, scm_print_state *pstate) +{ switch (SCM_ITAG3 (exp)) { case scm_tc3_closure: diff --git a/libguile/print.h b/libguile/print.h index 6d9c47c31..740572eb0 100644 --- a/libguile/print.h +++ b/libguile/print.h @@ -3,7 +3,7 @@ #ifndef SCM_PRINT_H #define SCM_PRINT_H -/* Copyright (C) 1995,1996,1998,2000,2001, 2003 Free Software Foundation, Inc. +/* Copyright (C) 1995,1996,1998,2000,2001, 2003, 2004 Free Software Foundation, Inc. * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public @@ -55,7 +55,7 @@ do { \ #define SCM_COERCE_OUTPORT(p) \ (SCM_PORT_WITH_PS_P (p) ? SCM_PORT_WITH_PS_PORT (p) : p) -#define SCM_PRINT_STATE_LAYOUT "sruwuwuwuwuwpwuwuwuruopr" +#define SCM_PRINT_STATE_LAYOUT "sruwuwuwuwuwpwuwuwuruoprpw" typedef struct scm_print_state { SCM handle; /* Struct handle */ int revealed; /* Has the state escaped to Scheme? */ @@ -70,6 +70,7 @@ typedef struct scm_print_state { SCM *ref_stack; /* Stack of references used during circular reference detection */ SCM ref_vect; + SCM highlight_objects; /* List of objects to be highlighted */ } scm_print_state; SCM_API SCM scm_print_state_vtable; |