summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMichael Gran <spk121@yahoo.com>2009-09-03 07:47:26 -0700
committerMichael Gran <spk121@yahoo.com>2009-09-03 07:47:26 -0700
commit0dcd7e61534c9d1e33de904196cb505daf320a42 (patch)
tree69422df6efe24318f3dc72f8a3d49366eff6a67c
parentaa2cba9c882ba8bd69750b120d2b7ccd7250b562 (diff)
downloadguile-0dcd7e61534c9d1e33de904196cb505daf320a42.tar.gz
Modify read and print of combining characters
Since combining characters, such as accents, modify the appearance of the previous letter, it looks awkward in its character literal form (#\name) since it modified the backslash. This instead prints the combining character on a small circle. * libguile/chars.h (SCM_CODEPOINT_DOTTED_CIRCLE): new #define * libguile/print.c (iprint1): print combining characters on dotted circles * libguile/read.c (scm_read_character): parse the combination of combining characters and dotted circles
-rw-r--r--libguile/chars.h3
-rw-r--r--libguile/print.c17
-rw-r--r--libguile/read.c3
3 files changed, 20 insertions, 3 deletions
diff --git a/libguile/chars.h b/libguile/chars.h
index 69ef8d005..04eb9f09f 100644
--- a/libguile/chars.h
+++ b/libguile/chars.h
@@ -47,9 +47,10 @@ typedef scm_t_int32 scm_t_wchar;
? SCM_MAKE_ITAG8 ((scm_t_bits) (unsigned char) (x), scm_tc8_char) \
: SCM_MAKE_ITAG8 ((scm_t_bits) (x), scm_tc8_char))
-#define SCM_CODEPOINT_MAX (0x10ffff)
+#define SCM_CODEPOINT_DOTTED_CIRCLE (0x25cc)
#define SCM_CODEPOINT_SURROGATE_START (0xd800)
#define SCM_CODEPOINT_SURROGATE_END (0xdfff)
+#define SCM_CODEPOINT_MAX (0x10ffff)
#define SCM_IS_UNICODE_CHAR(c) \
(((scm_t_wchar) (c) >= 0 \
&& (scm_t_wchar) (c) < SCM_CODEPOINT_SURROGATE_START) \
diff --git a/libguile/print.c b/libguile/print.c
index 86d067b8b..f4826d4ee 100644
--- a/libguile/print.c
+++ b/libguile/print.c
@@ -463,13 +463,26 @@ iprin1 (SCM exp, SCM port, scm_print_state *pstate)
/* Print the character if is graphic character. */
{
scm_t_wchar *wbuf;
- SCM wstr = scm_i_make_wide_string (1, &wbuf);
+ SCM wstr;
char *buf;
size_t len;
const char *enc;
enc = scm_i_get_port_encoding (port);
- wbuf[0] = i;
+ if (uc_combining_class (i) == UC_CCC_NR)
+ {
+ wstr = scm_i_make_wide_string (1, &wbuf);
+ wbuf[0] = i;
+ }
+ else
+ {
+ /* Character is a combining character: print it connected
+ to a dotted circle instead of connecting it to the
+ backslash in '#\' */
+ wstr = scm_i_make_wide_string (2, &wbuf);
+ wbuf[0] = SCM_CODEPOINT_DOTTED_CIRCLE;
+ wbuf[1] = i;
+ }
if (enc == NULL)
{
if (i <= 0xFF)
diff --git a/libguile/read.c b/libguile/read.c
index b2773cd3c..269e96b21 100644
--- a/libguile/read.c
+++ b/libguile/read.c
@@ -844,6 +844,9 @@ scm_read_character (scm_t_wchar chr, SCM port)
return SCM_MAKE_CHAR (scm_i_string_ref (charname, 0));
cp = scm_i_string_ref (charname, 0);
+ if (cp == SCM_CODEPOINT_DOTTED_CIRCLE && charname_len == 2)
+ return SCM_MAKE_CHAR (scm_i_string_ref (charname, 1));
+
if (cp >= '0' && cp < '8')
{
/* Dirk:FIXME:: This type of character syntax is not R5RS