summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorNoah Levitt <nlevitt@columbia.edu>2003-08-14 16:33:36 +0000
committerNoah Levitt <nlevitt@src.gnome.org>2003-08-14 16:33:36 +0000
commitf10ac7aa461dbd08fbc8e1077836f871ed9934af (patch)
tree6fa52f90c5afc4a27ac6e2cf2457ffd9ad3655e5
parente8797c8fc739232838152a594442f0d486ca9cbd (diff)
downloadpango-f10ac7aa461dbd08fbc8e1077836f871ed9934af.tar.gz
Add backspace_deletes_character to PangoLogAttr. (#114483)
2003-08-14 Noah Levitt <nlevitt@columbia.edu> * docs/tmpl/main.sgml: * pango/break.c: * pango/pango-break.h: Add backspace_deletes_character to PangoLogAttr. (#114483)
-rw-r--r--ChangeLog7
-rw-r--r--ChangeLog.pre-1-107
-rw-r--r--ChangeLog.pre-1-47
-rw-r--r--ChangeLog.pre-1-67
-rw-r--r--ChangeLog.pre-1-87
-rw-r--r--docs/tmpl/main.sgml12
-rw-r--r--pango/break.c20
-rw-r--r--pango/pango-break.h5
8 files changed, 72 insertions, 0 deletions
diff --git a/ChangeLog b/ChangeLog
index 5e5baf48..7ebc97c9 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,10 @@
+2003-08-14 Noah Levitt <nlevitt@columbia.edu>
+
+ * 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 <otaylor@redhat.com>
* 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 <nlevitt@columbia.edu>
+
+ * 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 <otaylor@redhat.com>
* 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 <nlevitt@columbia.edu>
+
+ * 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 <otaylor@redhat.com>
* 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 <nlevitt@columbia.edu>
+
+ * 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 <otaylor@redhat.com>
* 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 <nlevitt@columbia.edu>
+
+ * 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 <otaylor@redhat.com>
* 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.
<!-- ##### FUNCTION pango_shape ##### -->
<para>
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