[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: Wed, 5 Jun 2019 12:50:53 +0000 (UTC)
commit f8410b55f2937b5c815fb467ddb508af233e5949
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 | 4 ++
src/app/app.cc | 8 +++
src/vte.cc | 36 ++++++++++++++
src/vte/vteterminal.h | 13 +++++
src/vtegtk.cc | 108 +++++++++++++++++++++++++++++++++++++++++
src/vtegtk.hh | 2 +
src/vteinternal.hh | 4 ++
7 files changed, 175 insertions(+)
---
diff --git a/doc/reference/vte-sections.txt b/doc/reference/vte-sections.txt
index 9ab873c1..ad504297 100644
--- a/doc/reference/vte-sections.txt
+++ b/doc/reference/vte-sections.txt
@@ -64,6 +64,10 @@ vte_terminal_set_backspace_binding
vte_terminal_set_delete_binding
vte_terminal_set_mouse_autohide
vte_terminal_get_mouse_autohide
+vte_terminal_set_enable_bidi
+vte_terminal_get_enable_bidi
+vte_terminal_set_enable_shaping
+vte_terminal_get_enable_shaping
vte_terminal_reset
vte_terminal_get_text
vte_terminal_get_text_range
diff --git a/src/app/app.cc b/src/app/app.cc
index 529b584d..d845b5ce 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};
@@ -55,6 +56,7 @@ public:
gboolean no_geometry_hints{false};
gboolean no_hyperlink{false};
gboolean no_rewrap{false};
+ gboolean no_shaping{false};
gboolean no_shell{false};
gboolean object_notifications{false};
gboolean reverse{false};
@@ -383,6 +385,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,
@@ -397,6 +401,8 @@ public:
"Disable hyperlinks", nullptr },
{ "no-rewrap", 'R', 0, G_OPTION_ARG_NONE, &no_rewrap,
"Disable rewrapping on resize", nullptr },
+ { "no-shaping", 0, 0, G_OPTION_ARG_NONE, &no_shaping,
+ "Disable Arabic shaping", nullptr },
{ "no-shell", 'S', 0, G_OPTION_ARG_NONE, &no_shell,
"Disable spawning a shell inside the terminal", nullptr },
{ "object-notifications", 'N', 0, G_OPTION_ARG_NONE, &object_notifications,
@@ -1925,6 +1931,8 @@ vteapp_window_constructed(GObject *object)
vte_terminal_set_cjk_ambiguous_width(window->terminal, options.cjk_ambiguous_width);
vte_terminal_set_cursor_blink_mode(window->terminal, options.cursor_blink_mode);
vte_terminal_set_cursor_shape(window->terminal, options.cursor_shape);
+ vte_terminal_set_enable_bidi(window->terminal, !options.no_bidi);
+ vte_terminal_set_enable_shaping(window->terminal, !options.no_shaping);
vte_terminal_set_mouse_autohide(window->terminal, true);
vte_terminal_set_rewrap_on_resize(window->terminal, !options.no_rewrap);
vte_terminal_set_scroll_on_output(window->terminal, false);
diff --git a/src/vte.cc b/src/vte.cc
index 919aef22..fdcc1010 100644
--- a/src/vte.cc
+++ b/src/vte.cc
@@ -8028,6 +8028,8 @@ Terminal::Terminal(vte::platform::Widget* w,
m_allow_bold = TRUE;
m_bold_is_bright = FALSE;
m_rewrap_on_resize = TRUE;
+ m_enable_bidi = true;
+ m_enable_shaping = true;
m_input_enabled = TRUE;
@@ -9756,6 +9758,40 @@ Terminal::set_text_blink_mode(VteTextBlinkMode setting)
return true;
}
+bool
+Terminal::set_enable_bidi(bool setting)
+{
+ if (setting == m_enable_bidi)
+ return false;
+
+ m_enable_bidi = setting;
+ invalidate_all();
+
+ /* Chances are that we can free up some BiDi/shaping buffers that we
+ * won't need for a while. */
+ if (!setting)
+ m_ringview.pause();
+
+ return true;
+}
+
+bool
+Terminal::set_enable_shaping(bool setting)
+{
+ if (setting == m_enable_shaping)
+ return false;
+
+ m_enable_shaping = setting;
+ invalidate_all();
+
+ /* Chances are that we can free up some BiDi/shaping buffers that we
+ * won't need for a while. */
+ if (!setting)
+ m_ringview.pause();
+
+ return true;
+}
+
bool
Terminal::set_allow_bold(bool setting)
{
diff --git a/src/vte/vteterminal.h b/src/vte/vteterminal.h
index 26ac236e..708a9a82 100644
--- a/src/vte/vteterminal.h
+++ b/src/vte/vteterminal.h
@@ -337,6 +337,19 @@ _VTE_PUBLIC
void vte_terminal_set_delete_binding(VteTerminal *terminal,
VteEraseBinding binding) _VTE_GNUC_NONNULL(1);
+/* BiDi and shaping */
+_VTE_PUBLIC
+void vte_terminal_set_enable_bidi(VteTerminal *terminal,
+ gboolean enable_bidi) _VTE_GNUC_NONNULL(1);
+_VTE_PUBLIC
+gboolean vte_terminal_get_enable_bidi(VteTerminal *terminal) _VTE_GNUC_NONNULL(1);
+
+_VTE_PUBLIC
+void vte_terminal_set_enable_shaping(VteTerminal *terminal,
+ gboolean enable_shaping) _VTE_GNUC_NONNULL(1);
+_VTE_PUBLIC
+gboolean vte_terminal_get_enable_shaping(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..338d7f41 100644
--- a/src/vtegtk.cc
+++ b/src/vtegtk.cc
@@ -490,6 +490,12 @@ vte_terminal_get_property (GObject *object,
case PROP_DELETE_BINDING:
g_value_set_enum (value, impl->m_delete_binding);
break;
+ case PROP_ENABLE_BIDI:
+ g_value_set_boolean (value, vte_terminal_get_enable_bidi (terminal));
+ break;
+ case PROP_ENABLE_SHAPING:
+ g_value_set_boolean (value, vte_terminal_get_enable_shaping (terminal));
+ break;
case PROP_ENCODING:
g_value_set_string (value, vte_terminal_get_encoding (terminal));
break;
@@ -597,6 +603,12 @@ vte_terminal_set_property (GObject *object,
case PROP_DELETE_BINDING:
vte_terminal_set_delete_binding (terminal, (VteEraseBinding)g_value_get_enum
(value));
break;
+ case PROP_ENABLE_BIDI:
+ vte_terminal_set_enable_bidi (terminal, g_value_get_boolean (value));
+ break;
+ case PROP_ENABLE_SHAPING:
+ vte_terminal_set_enable_shaping (terminal, g_value_get_boolean (value));
+ break;
case PROP_ENCODING:
vte_terminal_set_encoding (terminal, g_value_get_string (value), NULL);
break;
@@ -1537,6 +1549,30 @@ vte_terminal_class_init(VteTerminalClass *klass)
VTE_ERASE_AUTO,
(GParamFlags) (G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS |
G_PARAM_EXPLICIT_NOTIFY));
+ /**
+ * VteTerminal:enable-bidi:
+ *
+ * Controls whether or not the terminal will perform bidirectional text rendering.
+ *
+ * Since: 0.58
+ */
+ pspecs[PROP_ENABLE_BIDI] =
+ g_param_spec_boolean ("enable-bidi", NULL, NULL,
+ TRUE,
+ (GParamFlags) (G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS |
G_PARAM_EXPLICIT_NOTIFY));
+
+ /**
+ * VteTerminal:enable-shaping:
+ *
+ * Controls whether or not the terminal will shape Arabic text.
+ *
+ * Since: 0.58
+ */
+ pspecs[PROP_ENABLE_SHAPING] =
+ g_param_spec_boolean ("enable-shaping", NULL, NULL,
+ TRUE,
+ (GParamFlags) (G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS |
G_PARAM_EXPLICIT_NOTIFY));
+
/**
* VteTerminal:font-scale:
*
@@ -3690,6 +3726,78 @@ vte_terminal_set_delete_binding(VteTerminal *terminal,
g_object_notify_by_pspec(G_OBJECT(terminal), pspecs[PROP_DELETE_BINDING]);
}
+/**
+ * vte_terminal_get_enable_bidi:
+ * @terminal: a #VteTerminal
+ *
+ * Checks whether the terminal performs bidirectional text rendering.
+ *
+ * Returns: %TRUE if BiDi is enabled, %FALSE if not
+ *
+ * Since: 0.58
+ */
+gboolean
+vte_terminal_get_enable_bidi(VteTerminal *terminal)
+{
+ g_return_val_if_fail(VTE_IS_TERMINAL(terminal), FALSE);
+ return IMPL(terminal)->m_enable_bidi;
+}
+
+/**
+ * vte_terminal_set_enable_bidi:
+ * @terminal: a #VteTerminal
+ * @enable_bidi: %TRUE to enable BiDi support
+ *
+ * Controls whether or not the terminal will perform bidirectional text rendering.
+ *
+ * Since: 0.58
+ */
+void
+vte_terminal_set_enable_bidi(VteTerminal *terminal,
+ gboolean enable_bidi)
+{
+ g_return_if_fail(VTE_IS_TERMINAL(terminal));
+
+ if (IMPL(terminal)->set_enable_bidi(enable_bidi != FALSE))
+ g_object_notify_by_pspec(G_OBJECT(terminal), pspecs[PROP_ENABLE_BIDI]);
+}
+
+/**
+ * vte_terminal_get_enable_shaping:
+ * @terminal: a #VteTerminal
+ *
+ * Checks whether the terminal shapes Arabic text.
+ *
+ * Returns: %TRUE if Arabic shaping is enabled, %FALSE if not
+ *
+ * Since: 0.58
+ */
+gboolean
+vte_terminal_get_enable_shaping(VteTerminal *terminal)
+{
+ g_return_val_if_fail(VTE_IS_TERMINAL(terminal), FALSE);
+ return IMPL(terminal)->m_enable_shaping;
+}
+
+/**
+ * vte_terminal_set_enable_shaping:
+ * @terminal: a #VteTerminal
+ * @enable_shaping: %TRUE to enable Arabic shaping
+ *
+ * Controls whether or not the terminal will shape Arabic text.
+ *
+ * Since: 0.58
+ */
+void
+vte_terminal_set_enable_shaping(VteTerminal *terminal,
+ gboolean enable_shaping)
+{
+ g_return_if_fail(VTE_IS_TERMINAL(terminal));
+
+ if (IMPL(terminal)->set_enable_shaping(enable_shaping != FALSE))
+ g_object_notify_by_pspec(G_OBJECT(terminal), pspecs[PROP_ENABLE_SHAPING]);
+}
+
/**
* vte_terminal_get_encoding:
* @terminal: a #VteTerminal
diff --git a/src/vtegtk.hh b/src/vtegtk.hh
index c49754ef..e2515b34 100644
--- a/src/vtegtk.hh
+++ b/src/vtegtk.hh
@@ -76,6 +76,8 @@ enum {
PROP_CURRENT_DIRECTORY_URI,
PROP_CURRENT_FILE_URI,
PROP_DELETE_BINDING,
+ PROP_ENABLE_BIDI,
+ PROP_ENABLE_SHAPING,
PROP_ENCODING,
PROP_FONT_DESC,
PROP_FONT_SCALE,
diff --git a/src/vteinternal.hh b/src/vteinternal.hh
index 0c36f832..4688004b 100644
--- a/src/vteinternal.hh
+++ b/src/vteinternal.hh
@@ -619,6 +619,8 @@ public:
/* RingView and friends */
vte::base::RingView m_ringview;
+ bool m_enable_bidi;
+ bool m_enable_shaping;
/* BiDi parameters outside of ECMA and DEC private modes */
guint m_bidi_rtl : 1;
@@ -1176,6 +1178,8 @@ public:
bool set_cursor_shape(VteCursorShape shape);
bool set_cursor_style(VteCursorStyle style);
bool set_delete_binding(VteEraseBinding binding);
+ bool set_enable_bidi(bool setting);
+ bool set_enable_shaping(bool setting);
bool set_encoding(char const* codeset);
bool set_font_desc(PangoFontDescription const* desc);
bool set_font_scale(double scale);
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]