[latexila] Draw non-breaking spaces
- From: Sébastien Wilmet <swilmet src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [latexila] Draw non-breaking spaces
- Date: Sat, 2 Dec 2017 12:55:20 +0000 (UTC)
commit 741d436ec6fb218eb1b3dce3f907c4254943cba8
Author: Sébastien Wilmet <swilmet gnome org>
Date: Sat Dec 2 13:42:49 2017 +0100
Draw non-breaking spaces
That was a low-hanging fruit.
The rationale is explained in a comment in the code.
docs/reference/latexila-sections.txt | 1 +
src/document_view.vala | 2 ++
src/liblatexila/latexila-view.c | 32 ++++++++++++++++++++++++++++++++
src/liblatexila/latexila-view.h | 2 ++
4 files changed, 37 insertions(+), 0 deletions(-)
---
diff --git a/docs/reference/latexila-sections.txt b/docs/reference/latexila-sections.txt
index 90e135a..9cbfe67 100644
--- a/docs/reference/latexila-sections.txt
+++ b/docs/reference/latexila-sections.txt
@@ -283,5 +283,6 @@ latexila_utils_register_icons
<SECTION>
<FILE>view</FILE>
+latexila_view_configure_space_drawer
latexila_view_get_indentation_style
</SECTION>
diff --git a/src/document_view.vala b/src/document_view.vala
index 9b3eccb..61a9703 100644
--- a/src/document_view.vala
+++ b/src/document_view.vala
@@ -46,6 +46,8 @@ public class DocumentView : Tepl.View
auto_indent = true;
indent_width = -1;
+ Latexila.view_configure_space_drawer (this);
+
/* settings */
_editor_settings = new GLib.Settings ("org.gnome.latexila.preferences.editor");
diff --git a/src/liblatexila/latexila-view.c b/src/liblatexila/latexila-view.c
index f204f6c..2896a15 100644
--- a/src/liblatexila/latexila-view.c
+++ b/src/liblatexila/latexila-view.c
@@ -28,6 +28,38 @@
#include "latexila-view.h"
/**
+ * latexila_view_configure_space_drawer:
+ * @view: a #GtkSourceView.
+ *
+ * Configures the #GtkSourceSpaceDrawer of @view, to draw non-breaking spaces at
+ * all locations.
+ */
+void
+latexila_view_configure_space_drawer (GtkSourceView *view)
+{
+ GtkSourceSpaceDrawer *space_drawer;
+
+ g_return_if_fail (GTK_SOURCE_IS_VIEW (view));
+
+ space_drawer = gtk_source_view_get_space_drawer (view);
+
+ /* Rationale for always drawing non-breaking spaces:
+ *
+ * With my Dvorak bépo keyboard layout, it is possible to type a non-breaking
+ * space. I remember that one time I inserted one by mistake in LaTeXila, and
+ * when compiling the document there was an incomprehensible error, it took me
+ * some time to figure out that there was a non-breaking space... So, I think
+ * it's better to always draw non-breaking spaces, to distinguish them from
+ * normal spaces. -- swilmet
+ */
+ gtk_source_space_drawer_set_types_for_locations (space_drawer,
+ GTK_SOURCE_SPACE_LOCATION_ALL,
+ GTK_SOURCE_SPACE_TYPE_NBSP);
+
+ gtk_source_space_drawer_set_enable_matrix (space_drawer, TRUE);
+}
+
+/**
* latexila_view_get_indentation_style:
* @view: a #GtkSourceView.
*
diff --git a/src/liblatexila/latexila-view.h b/src/liblatexila/latexila-view.h
index 7738211..ca070c4 100644
--- a/src/liblatexila/latexila-view.h
+++ b/src/liblatexila/latexila-view.h
@@ -24,6 +24,8 @@
G_BEGIN_DECLS
+void latexila_view_configure_space_drawer (GtkSourceView *view);
+
gchar * latexila_view_get_indentation_style (GtkSourceView *view);
G_END_DECLS
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]