From f10ac7aa461dbd08fbc8e1077836f871ed9934af Mon Sep 17 00:00:00 2001 From: Noah Levitt Date: Thu, 14 Aug 2003 16:33:36 +0000 Subject: Add backspace_deletes_character to PangoLogAttr. (#114483) 2003-08-14 Noah Levitt * docs/tmpl/main.sgml: * pango/break.c: * pango/pango-break.h: Add backspace_deletes_character to PangoLogAttr. (#114483) --- ChangeLog | 7 +++++++ ChangeLog.pre-1-10 | 7 +++++++ ChangeLog.pre-1-4 | 7 +++++++ ChangeLog.pre-1-6 | 7 +++++++ ChangeLog.pre-1-8 | 7 +++++++ docs/tmpl/main.sgml | 12 ++++++++++++ pango/break.c | 20 ++++++++++++++++++++ pango/pango-break.h | 5 +++++ 8 files changed, 72 insertions(+) diff --git a/ChangeLog b/ChangeLog index 5e5baf48..7ebc97c9 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,10 @@ +2003-08-14 Noah Levitt + + * docs/tmpl/main.sgml: + * pango/break.c: + * pango/pango-break.h: Add backspace_deletes_character to + PangoLogAttr. (#114483) + Thu Aug 14 10:41:21 2003 Owen Taylor * pango/modules.c (init_modules): Call g_type_init() diff --git a/ChangeLog.pre-1-10 b/ChangeLog.pre-1-10 index 5e5baf48..7ebc97c9 100644 --- a/ChangeLog.pre-1-10 +++ b/ChangeLog.pre-1-10 @@ -1,3 +1,10 @@ +2003-08-14 Noah Levitt + + * docs/tmpl/main.sgml: + * pango/break.c: + * pango/pango-break.h: Add backspace_deletes_character to + PangoLogAttr. (#114483) + Thu Aug 14 10:41:21 2003 Owen Taylor * pango/modules.c (init_modules): Call g_type_init() diff --git a/ChangeLog.pre-1-4 b/ChangeLog.pre-1-4 index 5e5baf48..7ebc97c9 100644 --- a/ChangeLog.pre-1-4 +++ b/ChangeLog.pre-1-4 @@ -1,3 +1,10 @@ +2003-08-14 Noah Levitt + + * docs/tmpl/main.sgml: + * pango/break.c: + * pango/pango-break.h: Add backspace_deletes_character to + PangoLogAttr. (#114483) + Thu Aug 14 10:41:21 2003 Owen Taylor * pango/modules.c (init_modules): Call g_type_init() diff --git a/ChangeLog.pre-1-6 b/ChangeLog.pre-1-6 index 5e5baf48..7ebc97c9 100644 --- a/ChangeLog.pre-1-6 +++ b/ChangeLog.pre-1-6 @@ -1,3 +1,10 @@ +2003-08-14 Noah Levitt + + * docs/tmpl/main.sgml: + * pango/break.c: + * pango/pango-break.h: Add backspace_deletes_character to + PangoLogAttr. (#114483) + Thu Aug 14 10:41:21 2003 Owen Taylor * pango/modules.c (init_modules): Call g_type_init() diff --git a/ChangeLog.pre-1-8 b/ChangeLog.pre-1-8 index 5e5baf48..7ebc97c9 100644 --- a/ChangeLog.pre-1-8 +++ b/ChangeLog.pre-1-8 @@ -1,3 +1,10 @@ +2003-08-14 Noah Levitt + + * docs/tmpl/main.sgml: + * pango/break.c: + * pango/pango-break.h: Add backspace_deletes_character to + PangoLogAttr. (#114483) + Thu Aug 14 10:41:21 2003 Owen Taylor * pango/modules.c (init_modules): Call g_type_init() diff --git a/docs/tmpl/main.sgml b/docs/tmpl/main.sgml index 9a7ef804..bb894008 100644 --- a/docs/tmpl/main.sgml +++ b/docs/tmpl/main.sgml @@ -308,6 +308,18 @@ about the attributes of a single character. @is_sentence_boundary: @is_sentence_start: @is_sentence_end: +@backspace_deletes_character: If set, backspace deletes one character + rather than the entire grapheme cluster. This + field is only meaningful on grapheme + boundaries (where @is_cursor_position is + set). In some languages, the full grapheme + (e.g. letter + diacritics) is considered a + unit, while in others, each decomposed + character in the grapheme is a unit. In the + default implementation of #pango_break, this + bit is set on all grapheme boundaries except + those following Latin, Cyrillic or Greek base + characters. diff --git a/pango/break.c b/pango/break.c index 491e936f..bbe6b730 100644 --- a/pango/break.c +++ b/pango/break.c @@ -328,6 +328,11 @@ static int line_break_indexes[] = { #define HIRAGANA(wc) ((wc) >= 0x3040 && (wc) <= 0x309F) #define KATAKANA(wc) ((wc) >= 0x30A0 && (wc) <= 0x30FF) +#define LATIN(wc) (((wc) >= 0x0020 && (wc) <= 0x02AF) || ((wc) >= 0x1E00 && (wc) <= 0x1EFF)) +#define CYRILLIC(wc) (((wc) >= 0x0400 && (wc) <= 0x052F)) +#define GREEK(wc) (((wc) >= 0x0370 && (wc) <= 0x3FF) || ((wc) >= 0x1F00 && (wc) <= 0x1FFF)) +#define BACKSPACE_DELETES_CHARACTER(wc) (!LATIN (wc) && !CYRILLIC (wc) && !GREEK (wc)) + /* p. 132-133 of Unicode spec table 5-6 will help understand this */ typedef enum @@ -406,6 +411,7 @@ pango_default_break (const gchar *text, gboolean prev_was_break_space; WordType current_word_type = WordNone; gunichar last_word_letter = 0; + gunichar base_character = 0; SentenceState sentence_state = STATE_SENTENCE_OUTSIDE; /* Tracks what will be the end of the sentence if a period is * determined to actually be a sentence-ending period. @@ -598,6 +604,13 @@ pango_default_break (const gchar *text, } } + /* If this is a grapheme boundary, we have to decide if backspace + * deletes a character or the whole grapheme cluster */ + if (attrs[i].is_cursor_position) + attrs[i].backspace_deletes_character = BACKSPACE_DELETES_CHARACTER (base_character); + else + attrs[i].backspace_deletes_character = FALSE; + /* ---- Line breaking ---- */ break_type = g_unichar_break_type (wc); @@ -1277,6 +1290,13 @@ pango_default_break (const gchar *text, prev_type = type; prev_wc = wc; + + /* wc might not be a valid unicode base character, but really all we + * need to know is the last non-combining character */ + if (type != G_UNICODE_COMBINING_MARK && + type != G_UNICODE_ENCLOSING_MARK && + type != G_UNICODE_NON_SPACING_MARK) + base_character = wc; } } diff --git a/pango/pango-break.h b/pango/pango-break.h index 3662009b..0ef4b5f3 100644 --- a/pango/pango-break.h +++ b/pango/pango-break.h @@ -64,6 +64,11 @@ struct _PangoLogAttr guint is_sentence_boundary : 1; guint is_sentence_start : 1; /* first character in a sentence */ guint is_sentence_end : 1; /* first non-sentence char after a sentence */ + + /* if set, backspace deletes one character rather than + * the entire grapheme cluster + */ + guint backspace_deletes_character : 1; }; /* Determine information about cluster/word/line breaks in a string -- cgit v1.2.1