Merge pull request #73 from ryanpcmcquen/master

remove needless whitespace from pluma/plumatextregion.c
This commit is contained in:
Stefano Karapetsas 2014-03-03 09:57:41 +01:00
commit ee354c1bae
1 changed files with 42 additions and 43 deletions

View File

@ -58,7 +58,7 @@ typedef struct _PlumaTextRegionIteratorReal PlumaTextRegionIteratorReal;
struct _PlumaTextRegionIteratorReal { struct _PlumaTextRegionIteratorReal {
PlumaTextRegion *region; PlumaTextRegion *region;
guint32 region_time_stamp; guint32 region_time_stamp;
GList *subregions; GList *subregions;
}; };
@ -79,17 +79,17 @@ find_nearest_subregion (PlumaTextRegion *region,
gboolean include_edges) gboolean include_edges)
{ {
GList *l, *retval; GList *l, *retval;
g_return_val_if_fail (region != NULL && iter != NULL, NULL); g_return_val_if_fail (region != NULL && iter != NULL, NULL);
if (!begin) if (!begin)
begin = region->subregions; begin = region->subregions;
if (begin) if (begin)
retval = begin->prev; retval = begin->prev;
else else
retval = NULL; retval = NULL;
for (l = begin; l; l = l->next) { for (l = begin; l; l = l->next) {
GtkTextIter sr_iter; GtkTextIter sr_iter;
Subregion *sr = l->data; Subregion *sr = l->data;
@ -125,12 +125,12 @@ pluma_text_region_new (GtkTextBuffer *buffer)
PlumaTextRegion *region; PlumaTextRegion *region;
g_return_val_if_fail (buffer != NULL, NULL); g_return_val_if_fail (buffer != NULL, NULL);
region = g_new (PlumaTextRegion, 1); region = g_new (PlumaTextRegion, 1);
region->buffer = buffer; region->buffer = buffer;
region->subregions = NULL; region->subregions = NULL;
region->time_stamp = 0; region->time_stamp = 0;
return region; return region;
} }
@ -151,7 +151,7 @@ pluma_text_region_destroy (PlumaTextRegion *region, gboolean delete_marks)
} }
region->buffer = NULL; region->buffer = NULL;
region->time_stamp = 0; region->time_stamp = 0;
g_free (region); g_free (region);
} }
@ -159,7 +159,7 @@ GtkTextBuffer *
pluma_text_region_get_buffer (PlumaTextRegion *region) pluma_text_region_get_buffer (PlumaTextRegion *region)
{ {
g_return_val_if_fail (region != NULL, NULL); g_return_val_if_fail (region != NULL, NULL);
return region->buffer; return region->buffer;
} }
@ -168,7 +168,7 @@ pluma_text_region_clear_zero_length_subregions (PlumaTextRegion *region)
{ {
GtkTextIter start, end; GtkTextIter start, end;
GList *node; GList *node;
g_return_if_fail (region != NULL); g_return_if_fail (region != NULL);
for (node = region->subregions; node; ) { for (node = region->subregions; node; ) {
@ -185,7 +185,7 @@ pluma_text_region_clear_zero_length_subregions (PlumaTextRegion *region)
node = g_list_delete_link (node, node); node = g_list_delete_link (node, node);
++region->time_stamp; ++region->time_stamp;
} else { } else {
node = node->next; node = node->next;
} }
@ -199,12 +199,12 @@ pluma_text_region_add (PlumaTextRegion *region,
{ {
GList *start_node, *end_node; GList *start_node, *end_node;
GtkTextIter start, end; GtkTextIter start, end;
g_return_if_fail (region != NULL && _start != NULL && _end != NULL); g_return_if_fail (region != NULL && _start != NULL && _end != NULL);
start = *_start; start = *_start;
end = *_end; end = *_end;
DEBUG (g_print ("---\n")); DEBUG (g_print ("---\n"));
DEBUG (pluma_text_region_debug_print (region)); DEBUG (pluma_text_region_debug_print (region));
DEBUG (g_message ("region_add (%d, %d)", DEBUG (g_message ("region_add (%d, %d)",
@ -212,7 +212,7 @@ pluma_text_region_add (PlumaTextRegion *region,
gtk_text_iter_get_offset (&end))); gtk_text_iter_get_offset (&end)));
gtk_text_iter_order (&start, &end); gtk_text_iter_order (&start, &end);
/* don't add zero-length regions */ /* don't add zero-length regions */
if (gtk_text_iter_equal (&start, &end)) if (gtk_text_iter_equal (&start, &end))
return; return;
@ -226,11 +226,11 @@ pluma_text_region_add (PlumaTextRegion *region,
Subregion *sr = g_new0 (Subregion, 1); Subregion *sr = g_new0 (Subregion, 1);
sr->start = gtk_text_buffer_create_mark (region->buffer, NULL, &start, TRUE); sr->start = gtk_text_buffer_create_mark (region->buffer, NULL, &start, TRUE);
sr->end = gtk_text_buffer_create_mark (region->buffer, NULL, &end, FALSE); sr->end = gtk_text_buffer_create_mark (region->buffer, NULL, &end, FALSE);
if (start_node == NULL) { if (start_node == NULL) {
/* append the new region */ /* append the new region */
region->subregions = g_list_append (region->subregions, sr); region->subregions = g_list_append (region->subregions, sr);
} else if (end_node == NULL) { } else if (end_node == NULL) {
/* prepend the new region */ /* prepend the new region */
region->subregions = g_list_prepend (region->subregions, sr); region->subregions = g_list_prepend (region->subregions, sr);
@ -248,7 +248,7 @@ pluma_text_region_add (PlumaTextRegion *region,
/* we need to merge some subregions */ /* we need to merge some subregions */
GList *l = start_node->next; GList *l = start_node->next;
Subregion *q; Subregion *q;
gtk_text_buffer_delete_mark (region->buffer, sr->end); gtk_text_buffer_delete_mark (region->buffer, sr->end);
while (l != end_node) { while (l != end_node) {
q = l->data; q = l->data;
@ -290,18 +290,18 @@ pluma_text_region_subtract (PlumaTextRegion *region,
GtkTextIter start, end; GtkTextIter start, end;
g_return_if_fail (region != NULL && _start != NULL && _end != NULL); g_return_if_fail (region != NULL && _start != NULL && _end != NULL);
start = *_start; start = *_start;
end = *_end; end = *_end;
DEBUG (g_print ("---\n")); DEBUG (g_print ("---\n"));
DEBUG (pluma_text_region_debug_print (region)); DEBUG (pluma_text_region_debug_print (region));
DEBUG (g_message ("region_substract (%d, %d)", DEBUG (g_message ("region_substract (%d, %d)",
gtk_text_iter_get_offset (&start), gtk_text_iter_get_offset (&start),
gtk_text_iter_get_offset (&end))); gtk_text_iter_get_offset (&end)));
gtk_text_iter_order (&start, &end); gtk_text_iter_order (&start, &end);
/* find bounding subregions */ /* find bounding subregions */
start_node = find_nearest_subregion (region, &start, NULL, FALSE, FALSE); start_node = find_nearest_subregion (region, &start, NULL, FALSE, FALSE);
end_node = find_nearest_subregion (region, &end, start_node, TRUE, FALSE); end_node = find_nearest_subregion (region, &end, start_node, TRUE, FALSE);
@ -309,10 +309,10 @@ pluma_text_region_subtract (PlumaTextRegion *region,
/* easy case first */ /* easy case first */
if (start_node == NULL || end_node == NULL || end_node == start_node->prev) if (start_node == NULL || end_node == NULL || end_node == start_node->prev)
return; return;
/* deal with the start point */ /* deal with the start point */
start_is_outside = end_is_outside = FALSE; start_is_outside = end_is_outside = FALSE;
sr = start_node->data; sr = start_node->data;
gtk_text_buffer_get_iter_at_mark (region->buffer, &sr_start_iter, sr->start); gtk_text_buffer_get_iter_at_mark (region->buffer, &sr_start_iter, sr->start);
gtk_text_buffer_get_iter_at_mark (region->buffer, &sr_end_iter, sr->end); gtk_text_buffer_get_iter_at_mark (region->buffer, &sr_end_iter, sr->end);
@ -335,7 +335,7 @@ pluma_text_region_subtract (PlumaTextRegion *region,
/* no further processing needed */ /* no further processing needed */
DEBUG (g_message ("subregion splitted")); DEBUG (g_message ("subregion splitted"));
return; return;
} else { } else {
/* the ending point is outside, so just move /* the ending point is outside, so just move
@ -346,17 +346,17 @@ pluma_text_region_subtract (PlumaTextRegion *region,
/* the starting point is outside (and so to the left) /* the starting point is outside (and so to the left)
of the first subregion */ of the first subregion */
DEBUG (g_message ("start is outside")); DEBUG (g_message ("start is outside"));
start_is_outside = TRUE; start_is_outside = TRUE;
} }
/* deal with the end point */ /* deal with the end point */
if (start_node != end_node) { if (start_node != end_node) {
sr = end_node->data; sr = end_node->data;
gtk_text_buffer_get_iter_at_mark (region->buffer, &sr_start_iter, sr->start); gtk_text_buffer_get_iter_at_mark (region->buffer, &sr_start_iter, sr->start);
gtk_text_buffer_get_iter_at_mark (region->buffer, &sr_end_iter, sr->end); gtk_text_buffer_get_iter_at_mark (region->buffer, &sr_end_iter, sr->end);
} }
if (gtk_text_iter_in_range (&end, &sr_start_iter, &sr_end_iter) && if (gtk_text_iter_in_range (&end, &sr_start_iter, &sr_end_iter) &&
!gtk_text_iter_equal (&end, &sr_end_iter)) { !gtk_text_iter_equal (&end, &sr_end_iter)) {
/* ending point is inside, move the start mark */ /* ending point is inside, move the start mark */
@ -364,18 +364,18 @@ pluma_text_region_subtract (PlumaTextRegion *region,
} else { } else {
end_is_outside = TRUE; end_is_outside = TRUE;
DEBUG (g_message ("end is outside")); DEBUG (g_message ("end is outside"));
} }
/* finally remove any intermediate subregions */ /* finally remove any intermediate subregions */
done = FALSE; done = FALSE;
node = start_node; node = start_node;
while (!done) { while (!done) {
if (node == end_node) if (node == end_node)
/* we are done, exit in the next iteration */ /* we are done, exit in the next iteration */
done = TRUE; done = TRUE;
if ((node == start_node && !start_is_outside) || if ((node == start_node && !start_is_outside) ||
(node == end_node && !end_is_outside)) { (node == end_node && !end_is_outside)) {
/* skip starting or ending node */ /* skip starting or ending node */
@ -417,7 +417,7 @@ pluma_text_region_nth_subregion (PlumaTextRegion *region,
GtkTextIter *end) GtkTextIter *end)
{ {
Subregion *sr; Subregion *sr;
g_return_val_if_fail (region != NULL, FALSE); g_return_val_if_fail (region != NULL, FALSE);
sr = g_list_nth_data (region->subregions, subregion); sr = g_list_nth_data (region->subregions, subregion);
@ -443,14 +443,14 @@ pluma_text_region_intersect (PlumaTextRegion *region,
gboolean done; gboolean done;
PlumaTextRegion *new_region; PlumaTextRegion *new_region;
GtkTextIter start, end; GtkTextIter start, end;
g_return_val_if_fail (region != NULL && _start != NULL && _end != NULL, NULL); g_return_val_if_fail (region != NULL && _start != NULL && _end != NULL, NULL);
start = *_start; start = *_start;
end = *_end; end = *_end;
gtk_text_iter_order (&start, &end); gtk_text_iter_order (&start, &end);
/* find bounding subregions */ /* find bounding subregions */
start_node = find_nearest_subregion (region, &start, NULL, FALSE, FALSE); start_node = find_nearest_subregion (region, &start, NULL, FALSE, FALSE);
end_node = find_nearest_subregion (region, &end, start_node, TRUE, FALSE); end_node = find_nearest_subregion (region, &end, start_node, TRUE, FALSE);
@ -458,10 +458,10 @@ pluma_text_region_intersect (PlumaTextRegion *region,
/* easy case first */ /* easy case first */
if (start_node == NULL || end_node == NULL || end_node == start_node->prev) if (start_node == NULL || end_node == NULL || end_node == start_node->prev)
return NULL; return NULL;
new_region = pluma_text_region_new (region->buffer); new_region = pluma_text_region_new (region->buffer);
done = FALSE; done = FALSE;
sr = start_node->data; sr = start_node->data;
gtk_text_buffer_get_iter_at_mark (region->buffer, &sr_start_iter, sr->start); gtk_text_buffer_get_iter_at_mark (region->buffer, &sr_start_iter, sr->start);
gtk_text_buffer_get_iter_at_mark (region->buffer, &sr_end_iter, sr->end); gtk_text_buffer_get_iter_at_mark (region->buffer, &sr_end_iter, sr->end);
@ -500,7 +500,7 @@ pluma_text_region_intersect (PlumaTextRegion *region,
gtk_text_buffer_get_iter_at_mark (region->buffer, &sr_start_iter, gtk_text_buffer_get_iter_at_mark (region->buffer, &sr_start_iter,
sr->start); sr->start);
gtk_text_buffer_get_iter_at_mark (region->buffer, &sr_end_iter, sr->end); gtk_text_buffer_get_iter_at_mark (region->buffer, &sr_end_iter, sr->end);
new_sr = g_new0 (Subregion, 1); new_sr = g_new0 (Subregion, 1);
new_region->subregions = g_list_prepend (new_region->subregions, new_sr); new_region->subregions = g_list_prepend (new_region->subregions, new_sr);
new_sr->start = gtk_text_buffer_create_mark (new_region->buffer, NULL, new_sr->start = gtk_text_buffer_create_mark (new_region->buffer, NULL,
@ -515,10 +515,10 @@ pluma_text_region_intersect (PlumaTextRegion *region,
sr = node->data; sr = node->data;
gtk_text_buffer_get_iter_at_mark (region->buffer, &sr_start_iter, sr->start); gtk_text_buffer_get_iter_at_mark (region->buffer, &sr_start_iter, sr->start);
gtk_text_buffer_get_iter_at_mark (region->buffer, &sr_end_iter, sr->end); gtk_text_buffer_get_iter_at_mark (region->buffer, &sr_end_iter, sr->end);
new_sr = g_new0 (Subregion, 1); new_sr = g_new0 (Subregion, 1);
new_region->subregions = g_list_prepend (new_region->subregions, new_sr); new_region->subregions = g_list_prepend (new_region->subregions, new_sr);
new_sr->start = gtk_text_buffer_create_mark (new_region->buffer, NULL, new_sr->start = gtk_text_buffer_create_mark (new_region->buffer, NULL,
&sr_start_iter, TRUE); &sr_start_iter, TRUE);
@ -628,7 +628,7 @@ void
pluma_text_region_debug_print (PlumaTextRegion *region) pluma_text_region_debug_print (PlumaTextRegion *region)
{ {
GList *l; GList *l;
g_return_if_fail (region != NULL); g_return_if_fail (region != NULL);
g_print ("Subregions: "); g_print ("Subregions: ");
@ -644,4 +644,3 @@ pluma_text_region_debug_print (PlumaTextRegion *region)
} }
g_print ("\n"); g_print ("\n");
} }