summaryrefslogtreecommitdiff
path: root/gtk/gtktextiter.c
diff options
context:
space:
mode:
authorHavoc Pennington <hp@redhat.com>2000-12-04 23:04:17 +0000
committerHavoc Pennington <hp@src.gnome.org>2000-12-04 23:04:17 +0000
commit9365d0d7dc44e67a371590edf7b5f8744963e04c (patch)
tree72f57f594f861aafca4ddc4815b16d1969699ead /gtk/gtktextiter.c
parentd77144614bb39e62dc40cd9b8c510b4cfee04c62 (diff)
downloadgdk-pixbuf-9365d0d7dc44e67a371590edf7b5f8744963e04c.tar.gz
fix this to be sane
2000-12-04 Havoc Pennington <hp@redhat.com> * gtk/gtkpaned.c (gtk_paned_expose): fix this to be sane * gtk/gtkvpaned.c (gtk_vpaned_expose): Add an expose handler * gtk/gtkhpaned.c (gtk_hpaned_expose): Add an expose handler * gtk/gtknotebook.c (gtk_notebook_draw_tab): put in a temporary hack to avoid infinite loops (queue draw instead of draw) - Owen has more appropriate fixes in a branch he'll check in later. * gtk/gtktextiter.c (gtk_text_iter_ends_line): handle paragraph separator, CR, and CRLF as line ends * gtk/gtktextbtree.c (gtk_text_btree_insert): on insertion, break into lines using pango_find_paragraph_boundary(); other bits of the widget are still going to be broken if the boundary isn't '\n' though
Diffstat (limited to 'gtk/gtktextiter.c')
-rw-r--r--gtk/gtktextiter.c35
1 files changed, 33 insertions, 2 deletions
diff --git a/gtk/gtktextiter.c b/gtk/gtktextiter.c
index d73e0a858..fae5b5dc6 100644
--- a/gtk/gtktextiter.c
+++ b/gtk/gtktextiter.c
@@ -1326,18 +1326,49 @@ gtk_text_iter_starts_line (const GtkTextIter *iter)
* gtk_text_iter_ends_line:
* @iter: an iterator
*
- * Returns TRUE if @iter points to a newline character.
+ * Returns TRUE if @iter points to the start of the paragraph delimiter
+ * characters for a line (delimiters will be either a newline, a
+ * carriage return, a carriage return followed by a newline, or a
+ * Unicode paragraph separator character). Note that an iterator pointing
+ * to the \n of a \r\n pair will not be counted as the end of a line,
+ * the line ends before the \r.
*
* Return value: whether @iter is at the end of a line
**/
gboolean
gtk_text_iter_ends_line (const GtkTextIter *iter)
{
+ GtkTextRealIter *real;
+ gunichar wc;
+
g_return_val_if_fail (iter != NULL, FALSE);
+ real = gtk_text_iter_make_real (iter);
+
check_invariants (iter);
- return gtk_text_iter_get_char (iter) == '\n';
+ /* Only one character has type G_UNICODE_PARAGRAPH_SEPARATOR in
+ * Unicode 3.0; update this if that changes.
+ */
+#define PARAGRAPH_SEPARATOR 0x2029
+
+ wc = gtk_text_iter_get_char (iter);
+
+ if (wc == '\r' || wc == PARAGRAPH_SEPARATOR)
+ return TRUE;
+ else if (wc == '\n')
+ {
+ /* need to determine if a \r precedes the \n, in which case
+ * we aren't the end of the line
+ */
+ GtkTextIter tmp = *iter;
+ if (!gtk_text_iter_prev_char (&tmp))
+ return FALSE;
+
+ return gtk_text_iter_get_char (&tmp) != '\r';
+ }
+ else
+ return FALSE;
}
/**