[vte/wip/egmont/bidi: 2/7] bidi: Add API to enable or disable bidirectional text support
- From: Egmont Koblinger <egmontkob src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [vte/wip/egmont/bidi: 2/7] bidi: Add API to enable or disable bidirectional text support
- Date: Tue, 4 Jun 2019 12:12:39 +0000 (UTC)
commit 0a113c9c3b86d1de00922e2af238cabfd588fe27
Author: Egmont Koblinger <egmont gmail com>
Date: Tue Jun 4 11:05:09 2019 +0200
bidi: Add API to enable or disable bidirectional text support
doc/reference/vte-sections.txt | 2 ++
src/app/app.cc | 4 +++
src/vte.cc | 13 +++++++++
src/vte/vteterminal.h | 7 +++++
src/vtegtk.cc | 65 ++++++++++++++++++++++++++++++++++++++++++
src/vtegtk.hh | 1 +
src/vteinternal.hh | 2 ++
7 files changed, 94 insertions(+)
---
diff --git a/doc/reference/vte-sections.txt b/doc/reference/vte-sections.txt
index 9ab873c1..d973d0c1 100644
--- a/doc/reference/vte-sections.txt
+++ b/doc/reference/vte-sections.txt
@@ -24,6 +24,8 @@ vte_terminal_set_font_scale
vte_terminal_get_font_scale
vte_terminal_set_audible_bell
vte_terminal_get_audible_bell
+vte_terminal_set_allow_bidi
+vte_terminal_get_allow_bidi
vte_terminal_set_allow_bold
vte_terminal_get_allow_bold
vte_terminal_set_bold_is_bright
diff --git a/src/app/app.cc b/src/app/app.cc
index 529b584d..6b5cb77f 100644
--- a/src/app/app.cc
+++ b/src/app/app.cc
@@ -48,6 +48,7 @@ public:
gboolean icon_title{false};
gboolean keep{false};
gboolean no_argb_visual{false};
+ gboolean no_bidi{false};
gboolean no_bold{false};
gboolean no_builtin_dingus{false};
gboolean no_context_menu{false};
@@ -383,6 +384,8 @@ public:
"Live on after the command exits", nullptr },
{ "no-argb-visual", 0, 0, G_OPTION_ARG_NONE, &no_argb_visual,
"Don't use an ARGB visual", nullptr },
+ { "no-bidi", 0, 0, G_OPTION_ARG_NONE, &no_bidi,
+ "Disable BiDi", nullptr },
{ "no-bold", 0, 0, G_OPTION_ARG_NONE, &no_bold,
"Disable bold", nullptr },
{ "no-builtin-dingus", 0, 0, G_OPTION_ARG_NONE, &no_builtin_dingus,
@@ -1918,6 +1921,7 @@ vteapp_window_constructed(GObject *object)
vte_terminal_set_allow_hyperlink(window->terminal, !options.no_hyperlink);
vte_terminal_set_audible_bell(window->terminal, options.audible_bell);
+ vte_terminal_set_allow_bidi(window->terminal, !options.no_bidi);
vte_terminal_set_allow_bold(window->terminal, !options.no_bold);
vte_terminal_set_bold_is_bright(window->terminal, options.bold_is_bright);
vte_terminal_set_cell_height_scale(window->terminal, options.cell_height_scale);
diff --git a/src/vte.cc b/src/vte.cc
index 919aef22..11f2bedb 100644
--- a/src/vte.cc
+++ b/src/vte.cc
@@ -8028,6 +8028,7 @@ Terminal::Terminal(vte::platform::Widget* w,
m_allow_bold = TRUE;
m_bold_is_bright = FALSE;
m_rewrap_on_resize = TRUE;
+ m_allow_bidi = true;
m_input_enabled = TRUE;
@@ -9756,6 +9757,18 @@ Terminal::set_text_blink_mode(VteTextBlinkMode setting)
return true;
}
+bool
+Terminal::set_allow_bidi(bool setting)
+{
+ if (setting == m_allow_bidi)
+ return false;
+
+ m_allow_bidi = setting;
+ invalidate_all();
+
+ return true;
+}
+
bool
Terminal::set_allow_bold(bool setting)
{
diff --git a/src/vte/vteterminal.h b/src/vte/vteterminal.h
index 26ac236e..d1cc24f9 100644
--- a/src/vte/vteterminal.h
+++ b/src/vte/vteterminal.h
@@ -337,6 +337,13 @@ _VTE_PUBLIC
void vte_terminal_set_delete_binding(VteTerminal *terminal,
VteEraseBinding binding) _VTE_GNUC_NONNULL(1);
+/* BiDi */
+_VTE_PUBLIC
+void vte_terminal_set_allow_bidi(VteTerminal *terminal,
+ gboolean allow_bidi) _VTE_GNUC_NONNULL(1);
+_VTE_PUBLIC
+gboolean vte_terminal_get_allow_bidi(VteTerminal *terminal) _VTE_GNUC_NONNULL(1);
+
/* Manipulate the autohide setting. */
_VTE_PUBLIC
void vte_terminal_set_mouse_autohide(VteTerminal *terminal,
diff --git a/src/vtegtk.cc b/src/vtegtk.cc
index f8f296b9..6b1dc41c 100644
--- a/src/vtegtk.cc
+++ b/src/vtegtk.cc
@@ -451,6 +451,9 @@ vte_terminal_get_property (GObject *object,
case PROP_VSCROLL_POLICY:
g_value_set_enum (value, widget->vscroll_policy());
break;
+ case PROP_ALLOW_BIDI:
+ g_value_set_boolean (value, vte_terminal_get_allow_bidi (terminal));
+ break;
case PROP_ALLOW_BOLD:
g_value_set_boolean (value, vte_terminal_get_allow_bold (terminal));
break;
@@ -564,6 +567,9 @@ vte_terminal_set_property (GObject *object,
case PROP_VSCROLL_POLICY:
vte_terminal_set_vscroll_policy(terminal,
(GtkScrollablePolicy)g_value_get_enum(value));
break;
+ case PROP_ALLOW_BIDI:
+ vte_terminal_set_allow_bidi (terminal, g_value_get_boolean (value));
+ break;
case PROP_ALLOW_BOLD:
vte_terminal_set_allow_bold (terminal, g_value_get_boolean (value));
break;
@@ -1397,6 +1403,22 @@ vte_terminal_class_init(VteTerminalClass *klass)
G_OBJECT_CLASS_TYPE(klass),
g_cclosure_marshal_VOID__VOIDv);
+ /**
+ * VteTerminal:allow-bidi:
+ *
+ * Controls whether or not the terminal will allow bidirectional
+ * text rendering.
+ *
+ * Currently Arabic shaping is also subject to this setting, but
+ * this might change in the future without notice.
+ *
+ * Since: 0.58
+ */
+ pspecs[PROP_ALLOW_BIDI] =
+ g_param_spec_boolean ("allow-bidi", NULL, NULL,
+ TRUE,
+ (GParamFlags) (G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS |
G_PARAM_EXPLICIT_NOTIFY));
+
/**
* VteTerminal:allow-bold:
*
@@ -3094,6 +3116,49 @@ vte_terminal_set_text_blink_mode(VteTerminal *terminal,
g_object_notify_by_pspec(G_OBJECT(terminal), pspecs[PROP_TEXT_BLINK_MODE]);
}
+/**
+ * vte_terminal_get_allow_bidi:
+ * @terminal: a #VteTerminal
+ *
+ * Checks whether the terminal allows bidirectional text rendering.
+ *
+ * Currently Arabic shaping is also subject to this setting, but
+ * this might change in the future without notice.
+ *
+ * Returns: %TRUE if BiDi is enabled, %FALSE if not
+ *
+ * Since: 0.58
+ */
+gboolean
+vte_terminal_get_allow_bidi(VteTerminal *terminal)
+{
+ g_return_val_if_fail(VTE_IS_TERMINAL(terminal), FALSE);
+ return IMPL(terminal)->m_allow_bidi;
+}
+
+/**
+ * vte_terminal_set_allow_bidi:
+ * @terminal: a #VteTerminal
+ * @allow_bidi: %TRUE to enable BiDi support
+ *
+ * Controls whether or not the terminal will allow bidirectional
+ * text rendering.
+ *
+ * Currently Arabic shaping is also subject to this setting, but
+ * this might change in the future without notice.
+ *
+ * Since: 0.58
+ */
+void
+vte_terminal_set_allow_bidi(VteTerminal *terminal,
+ gboolean allow_bidi)
+{
+ g_return_if_fail(VTE_IS_TERMINAL(terminal));
+
+ if (IMPL(terminal)->set_allow_bidi(allow_bidi != FALSE))
+ g_object_notify_by_pspec(G_OBJECT(terminal), pspecs[PROP_ALLOW_BIDI]);
+}
+
/**
* vte_terminal_get_allow_bold:
* @terminal: a #VteTerminal
diff --git a/src/vtegtk.hh b/src/vtegtk.hh
index c49754ef..0d4fcfeb 100644
--- a/src/vtegtk.hh
+++ b/src/vtegtk.hh
@@ -63,6 +63,7 @@ extern guint signals[LAST_SIGNAL];
enum {
PROP_0,
+ PROP_ALLOW_BIDI,
PROP_ALLOW_BOLD,
PROP_ALLOW_HYPERLINK,
PROP_AUDIBLE_BELL,
diff --git a/src/vteinternal.hh b/src/vteinternal.hh
index 0c36f832..a12a99fa 100644
--- a/src/vteinternal.hh
+++ b/src/vteinternal.hh
@@ -619,6 +619,7 @@ public:
/* RingView and friends */
vte::base::RingView m_ringview;
+ bool m_allow_bidi;
/* BiDi parameters outside of ECMA and DEC private modes */
guint m_bidi_rtl : 1;
@@ -1147,6 +1148,7 @@ public:
bool set_audible_bell(bool setting);
bool set_text_blink_mode(VteTextBlinkMode setting);
+ bool set_allow_bidi(bool setting);
bool set_allow_bold(bool setting);
bool set_allow_hyperlink(bool setting);
bool set_backspace_binding(VteEraseBinding binding);
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]