[gtksourceview] Make (un)indent_lines methods public
- From: Paolo Borelli <pborelli src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gtksourceview] Make (un)indent_lines methods public
- Date: Sat, 17 Jan 2015 13:54:24 +0000 (UTC)
commit ad8849df161ab2f46cb0bc1d00630e3110a4f454
Author: Paolo Borelli <pborelli gnome org>
Date: Sat Jan 17 14:52:22 2015 +0100
Make (un)indent_lines methods public
This is useful for editors that want to implement custom UI to
indent and unindent (in particular builder's vim mode)
docs/reference/gtksourceview-3.0-sections.txt | 2 +
gtksourceview/gtksourceview.c | 38 +++++++++++++++++++++----
gtksourceview/gtksourceview.h | 7 ++++
3 files changed, 41 insertions(+), 6 deletions(-)
---
diff --git a/docs/reference/gtksourceview-3.0-sections.txt b/docs/reference/gtksourceview-3.0-sections.txt
index 13c9aaf..de20088 100644
--- a/docs/reference/gtksourceview-3.0-sections.txt
+++ b/docs/reference/gtksourceview-3.0-sections.txt
@@ -820,6 +820,8 @@ gtk_source_view_set_indent_width
gtk_source_view_get_indent_width
gtk_source_view_set_insert_spaces_instead_of_tabs
gtk_source_view_get_insert_spaces_instead_of_tabs
+gtk_source_view_indent_lines
+gtk_source_view_unindent_lines
gtk_source_view_get_visual_column
gtk_source_view_set_smart_home_end
gtk_source_view_get_smart_home_end
diff --git a/gtksourceview/gtksourceview.c b/gtksourceview/gtksourceview.c
index 4f01c4e..2c8730c 100644
--- a/gtksourceview/gtksourceview.c
+++ b/gtksourceview/gtksourceview.c
@@ -3080,8 +3080,21 @@ get_indent_string (guint tabs, guint spaces)
return str;
}
-static void
-indent_lines (GtkSourceView *view, GtkTextIter *start, GtkTextIter *end)
+/**
+ * gtk_source_view_indent_lines:
+ * @view: a #GtkSourceView.
+ * @start: #GtkTextIter of the first line to indent
+ * @end: #GtkTextIter of the last line to indent
+ *
+ * Insert one indentation level at the beginning of the
+ * specified lines.
+ *
+ * Since: 3.16
+ */
+void
+gtk_source_view_indent_lines (GtkSourceView *view,
+ GtkTextIter *start,
+ GtkTextIter *end)
{
GtkTextBuffer *buf;
gint start_line, end_line;
@@ -3184,8 +3197,21 @@ indent_lines (GtkSourceView *view, GtkTextIter *start, GtkTextIter *end)
gtk_text_buffer_get_insert (buf));
}
-static void
-unindent_lines (GtkSourceView *view, GtkTextIter *start, GtkTextIter *end)
+/**
+ * gtk_source_view_unindent_lines:
+ * @view: a #GtkSourceView.
+ * @start: #GtkTextIter of the first line to indent
+ * @end: #GtkTextIter of the last line to indent
+ *
+ * Removes one indentation level at the beginning of the
+ * specified lines.
+ *
+ * Since: 3.16
+ */
+void
+gtk_source_view_unindent_lines (GtkSourceView *view,
+ GtkTextIter *start,
+ GtkTextIter *end)
{
GtkTextBuffer *buf;
gint start_line, end_line;
@@ -3713,7 +3739,7 @@ gtk_source_view_key_press_event (GtkWidget *widget,
/* shift+tab: always unindent */
if (event->state & GDK_SHIFT_MASK)
{
- unindent_lines (view, &s, &e);
+ gtk_source_view_unindent_lines (view, &s, &e);
return TRUE;
}
@@ -3725,7 +3751,7 @@ gtk_source_view_key_press_event (GtkWidget *widget,
((gtk_text_iter_starts_line (&s) && gtk_text_iter_ends_line (&e)) ||
(gtk_text_iter_get_line (&s) != gtk_text_iter_get_line (&e))))
{
- indent_lines (view, &s, &e);
+ gtk_source_view_indent_lines (view, &s, &e);
return TRUE;
}
}
diff --git a/gtksourceview/gtksourceview.h b/gtksourceview/gtksourceview.h
index dc0a3d2..459d743 100644
--- a/gtksourceview/gtksourceview.h
+++ b/gtksourceview/gtksourceview.h
@@ -162,6 +162,13 @@ void gtk_source_view_set_indent_on_tab (GtkSourceView *view,
gboolean enable);
gboolean gtk_source_view_get_indent_on_tab (GtkSourceView *view);
+void gtk_source_view_indent_lines (GtkSourceView *view,
+ GtkTextIter *start,
+ GtkTextIter *end);
+void gtk_source_view_unindent_lines (GtkSourceView *view,
+ GtkTextIter *start,
+ GtkTextIter *end);
+
void gtk_source_view_set_highlight_current_line
(GtkSourceView *view,
gboolean highlight);
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]