diff options
author | Havoc Pennington <hp@pobox.com> | 2000-09-30 17:08:25 +0000 |
---|---|---|
committer | Havoc Pennington <hp@src.gnome.org> | 2000-09-30 17:08:25 +0000 |
commit | 632fda6f0bd578006226b29badcfb63729f5eba2 (patch) | |
tree | 3326ce59b9514267f898dbd4b1d7cd9f49517c7c /gtk/gtktextmark.c | |
parent | f717bda19732f874762f2c48521d8370f15bf3f0 (diff) | |
download | gtk+-632fda6f0bd578006226b29badcfb63729f5eba2.tar.gz |
Handle NULL start/end pointers
2000-09-30 Havoc Pennington <hp@pobox.com>
* gtk/gtktextbtree.c (gtk_text_btree_get_selection_bounds): Handle
NULL start/end pointers
* gtk/gtktextbuffer.c: Write some docs
(gtk_text_buffer_get_selection_bounds): Allow start/end to be
NULL, so you can just check whether there's a selection.
* gtk/gtktextbtree.c (gtk_text_btree_remove_mark): No need to
cleanup_line or segments_changed ourselves, it gets done
in unlink_segment
* gtk/gtktextmark.h:
s/gtk_text_mark_deleted/gtk_text_mark_get_deleted/
* gtk/gtktextsegment.h: Clean up some indentation and naming mess
* gtk/gtktextmark.c: delete some more old Tk cruft
* gtk/gtktextbuffer.c (gtk_text_buffer_delete_mark): add ref to
mark before removing it, so we can emit MARK_DELETED with a valid
pointer.
(gtk_text_buffer_mark_set): hold ref across signal emission
* gtk/gtktextbtree.c (gtk_text_btree_remove_mark): improve
whining about attempts to delete special marks
* gtk/gtktextbuffer.c (_gtk_text_buffer_spew): Prepend with
underscore, since it's internal.
* gtk/gtktextbuffer.h: Remove find_string prototype, this is
now implemented in terms of iterators in gtktextiter.h
* gtk/gtktextbuffer.c (gtk_text_buffer_set_text):
New function, destructively sets contents of buffer. Also
a convenient way to clear the buffer by setting text to ""
* gtk/gtktextiter.c (gtk_text_iter_make_surreal): reformat
multiline string literal
* gtk/testtext.c (text_changed_callback): Redraw line numbers if
text changes.
* gtk/gtktextiter.c (forward_char): Return FALSE if new location
is not dereferenceable
(gtk_text_iter_forward_lines): fix return value
Diffstat (limited to 'gtk/gtktextmark.c')
-rw-r--r-- | gtk/gtktextmark.c | 208 |
1 files changed, 43 insertions, 165 deletions
diff --git a/gtk/gtktextmark.c b/gtk/gtktextmark.c index 4a53161ed2..6cf14624ab 100644 --- a/gtk/gtktextmark.c +++ b/gtk/gtktextmark.c @@ -59,7 +59,7 @@ gtk_text_mark_unref (GtkTextMark *mark) } gboolean -gtk_text_mark_deleted (GtkTextMark *mark) +gtk_text_mark_get_deleted (GtkTextMark *mark) { GtkTextLineSegment *seg; @@ -79,14 +79,14 @@ gtk_text_mark_deleted (GtkTextMark *mark) GtkTextLineSegment* -mark_segment_new(GtkTextBTree *tree, - gboolean left_gravity, - const gchar *name) +mark_segment_new (GtkTextBTree *tree, + gboolean left_gravity, + const gchar *name) { GtkTextLineSegment *mark; - mark = (GtkTextLineSegment *) g_malloc0(MSEG_SIZE); - mark->body.mark.name = g_strdup(name); + mark = (GtkTextLineSegment *) g_malloc0 (MSEG_SIZE); + mark->body.mark.name = g_strdup (name); if (left_gravity) mark->type = >k_text_left_mark_type; @@ -111,10 +111,10 @@ mark_segment_new(GtkTextBTree *tree, void mark_segment_ref(GtkTextLineSegment *mark) { - g_return_if_fail(mark != NULL); - g_return_if_fail(mark->type == >k_text_right_mark_type || - mark->type == >k_text_left_mark_type); - g_return_if_fail(mark->body.mark.refcount > 0); + g_return_if_fail (mark != NULL); + g_return_if_fail (mark->type == >k_text_right_mark_type || + mark->type == >k_text_left_mark_type); + g_return_if_fail (mark->body.mark.refcount > 0); mark->body.mark.refcount += 1; } @@ -122,10 +122,10 @@ mark_segment_ref(GtkTextLineSegment *mark) void mark_segment_unref(GtkTextLineSegment *mark) { - g_return_if_fail(mark != NULL); - g_return_if_fail(mark->type == >k_text_right_mark_type || - mark->type == >k_text_left_mark_type); - g_return_if_fail(mark->body.mark.refcount > 0); + g_return_if_fail (mark != NULL); + g_return_if_fail (mark->type == >k_text_right_mark_type || + mark->type == >k_text_left_mark_type); + g_return_if_fail (mark->body.mark.refcount > 0); mark->body.mark.refcount -= 1; @@ -137,17 +137,15 @@ mark_segment_unref(GtkTextLineSegment *mark) } } -/* - * Forward references for procedures defined in this file: - */ -static int mark_segment_delete_func (GtkTextLineSegment *segPtr, - GtkTextLine *line, - int treeGone); -static GtkTextLineSegment *mark_segment_cleanup_func (GtkTextLineSegment *segPtr, - GtkTextLine *line); -static void mark_segment_check_func (GtkTextLineSegment *segPtr, - GtkTextLine *line); +static int mark_segment_delete_func (GtkTextLineSegment *segPtr, + GtkTextLine *line, + int treeGone); +static GtkTextLineSegment *mark_segment_cleanup_func (GtkTextLineSegment *segPtr, + GtkTextLine *line); +static void mark_segment_check_func (GtkTextLineSegment *segPtr, + GtkTextLine *line); + /* * The following structures declare the "mark" segment types. @@ -157,26 +155,25 @@ static void mark_segment_check_func (GtkTextLineSegment *segPtr, */ GtkTextLineSegmentClass gtk_text_right_mark_type = { - "mark", /* name */ + "mark", /* name */ FALSE, /* leftGravity */ - (GtkTextLineSegmentSplitFunc) NULL, /* splitFunc */ + NULL, /* splitFunc */ mark_segment_delete_func, /* deleteFunc */ mark_segment_cleanup_func, /* cleanupFunc */ - (GtkTextLineSegmentLineChangeFunc) NULL, /* lineChangeFunc */ + NULL, /* lineChangeFunc */ mark_segment_check_func /* checkFunc */ }; GtkTextLineSegmentClass gtk_text_left_mark_type = { - "mark", /* name */ + "mark", /* name */ TRUE, /* leftGravity */ - (GtkTextLineSegmentSplitFunc) NULL, /* splitFunc */ + NULL, /* splitFunc */ mark_segment_delete_func, /* deleteFunc */ mark_segment_cleanup_func, /* cleanupFunc */ - (GtkTextLineSegmentLineChangeFunc) NULL, /* lineChangeFunc */ + NULL, /* lineChangeFunc */ mark_segment_check_func /* checkFunc */ }; - /* *-------------------------------------------------------------- * @@ -195,18 +192,14 @@ GtkTextLineSegmentClass gtk_text_left_mark_type = { *-------------------------------------------------------------- */ - /* ARGSUSED */ -static int -mark_segment_delete_func(segPtr, line, treeGone) - GtkTextLineSegment *segPtr; /* Segment being deleted. */ - GtkTextLine *line; /* Line containing segment. */ - int treeGone; /* Non-zero means the entire tree is - * being deleted, so everything must - * get cleaned up. */ +static gboolean +mark_segment_delete_func (GtkTextLineSegment *segPtr, + GtkTextLine *line, + gboolean tree_gone) { - return 1; + return TRUE; } - + /* *-------------------------------------------------------------- * @@ -225,112 +218,14 @@ mark_segment_delete_func(segPtr, line, treeGone) */ static GtkTextLineSegment * -mark_segment_cleanup_func(markPtr, line) - GtkTextLineSegment *markPtr; /* Mark segment that's being moved. */ - GtkTextLine *line; /* Line that now contains segment. */ -{ - markPtr->body.mark.line = line; - return markPtr; -} - -#if 0 - - -/* - *-------------------------------------------------------------- - * - * GtkTextInsertDisplayFunc -- - * - * This procedure is called to display the insertion - * cursor. - * - * Results: - * None. - * - * Side effects: - * Graphics are drawn. - * - *-------------------------------------------------------------- - */ - - /* ARGSUSED */ -void -GtkTextInsertDisplayFunc(chunkPtr, x, y, height, baseline, display, dst, screenY) - GtkTextDisplayChunk *chunkPtr; /* Chunk that is to be drawn. */ - int x; /* X-position in dst at which to - * draw this chunk (may differ from - * the x-position in the chunk because - * of scrolling). */ - int y; /* Y-position at which to draw this - * chunk in dst (x-position is in - * the chunk itself). */ - int height; /* Total height of line. */ - int baseline; /* Offset of baseline from y. */ - Display *display; /* Display to use for drawing. */ - Drawable dst; /* Pixmap or window in which to draw - * chunk. */ - int screenY; /* Y-coordinate in text window that - * corresponds to y. */ +mark_segment_cleanup_func(GtkTextLineSegment *seg, + GtkTextLine *line) { - GtkTextView *tkxt = (GtkTextView *) chunkPtr->clientData; - int halfWidth = tkxt->insertWidth/2; - - if ((x + halfWidth) < 0) { - /* - * The insertion cursor is off-screen. Just return. - */ - - return; - } - - /* - * As a special hack to keep the cursor visible on mono displays - * (or anywhere else that the selection and insertion cursors - * have the same color) write the default background in the cursor - * area (instead of nothing) when the cursor isn't on. Otherwise - * the selection might hide the cursor. - */ - - if (tkxt->flags & INSERT_ON) { - Tk_Fill3DRectangle(tkxt->tkwin, dst, tkxt->insertBorder, - x - tkxt->insertWidth/2, y, tkxt->insertWidth, - height, tkxt->insertBorderWidth, TK_RELIEF_RAISED); - } else if (tkxt->selBorder == tkxt->insertBorder) { - Tk_Fill3DRectangle(tkxt->tkwin, dst, tkxt->border, - x - tkxt->insertWidth/2, y, tkxt->insertWidth, - height, 0, TK_RELIEF_FLAT); - } + /* not sure why Tk did this here and not in LineChangeFunc */ + seg->body.mark.line = line; + return seg; } - -/* - *-------------------------------------------------------------- - * - * InsertUndisplayFunc -- - * - * This procedure is called when the insertion cursor is no - * longer at a visible point on the display. It does nothing - * right now. - * - * Results: - * None. - * - * Side effects: - * None. - * - *-------------------------------------------------------------- - */ - /* ARGSUSED */ -static void -InsertUndisplayFunc(tkxt, chunkPtr) - GtkTextView *tkxt; /* Overall information about text - * widget. */ - GtkTextDisplayChunk *chunkPtr; /* Chunk that is about to be freed. */ -{ - return; -} - -#endif /* *-------------------------------------------------------------- * @@ -350,26 +245,9 @@ InsertUndisplayFunc(tkxt, chunkPtr) */ static void -mark_segment_check_func(markPtr, line) - GtkTextLineSegment *markPtr; /* Segment to check. */ - GtkTextLine *line; /* Line containing segment. */ +mark_segment_check_func(GtkTextLineSegment *seg, + GtkTextLine *line) { - if (markPtr->body.mark.line != line) - g_error("mark_segment_check_func: markPtr->body.mark.line bogus"); - - /* No longer do this because we don't have access to btree - struct members */ -#if 0 - /* - * Make sure that the mark is still present in the text's mark - * hash table. - */ - for (hPtr = Tcl_FirstHashEntry(&markPtr->body.mark.tkxt->markTable, - &search); hPtr != markPtr->body.mark.hPtr; - hPtr = Tcl_NextHashEntry(&search)) { - if (hPtr == NULL) { - panic("mark_segment_check_func couldn't find hash table entry for mark"); - } - } -#endif + if (seg->body.mark.line != line) + g_error("mark_segment_check_func: seg->body.mark.line bogus"); } |