[vte/wip/egmont/bidi: 5/6] emulation, bidi: Add keyboard swapping mode
- From: Egmont Koblinger <egmontkob src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [vte/wip/egmont/bidi: 5/6] emulation, bidi: Add keyboard swapping mode
- Date: Sat, 1 Jun 2019 14:05:00 +0000 (UTC)
commit 9b10085dee8295e05d0b065b2f779ec0db0f6566
Author: Egmont Koblinger <egmont gmail com>
Date: Sat Jun 1 15:58:52 2019 +0200
emulation,bidi: Add keyboard swapping mode
If the corresponding mode is enabled and the cursor stands within an
RTL paragraph, the Left and Right keys of the keyboard swap their
generated escape sequence.
src/vte.cc | 32 ++++++++++++++++++++++++++++++++
1 file changed, 32 insertions(+)
---
diff --git a/src/vte.cc b/src/vte.cc
index 8c95a760..0fd46d10 100644
--- a/src/vte.cc
+++ b/src/vte.cc
@@ -5077,6 +5077,38 @@ Terminal::widget_key_press(GdkEventKey *event)
/* If the above switch statement didn't do the job, try mapping
* it to a literal or capability name. */
if (handled == FALSE) {
+ if (G_UNLIKELY (m_modes_private.VTE_BIDI_SWAP_ARROW_KEYS() &&
+ (keyval == GDK_KEY_Left ||
+ keyval == GDK_KEY_Right ||
+ keyval == GDK_KEY_KP_Left ||
+ keyval == GDK_KEY_KP_Right))) {
+ /* In keyboard arrow swapping mode, the left and right arrows are swapped
+ * if the cursor stands inside a (possibly autodetected) RTL paragraph.
+ * m_ringview is for the onscreen contents and the cursor may be offscreen.
+ * Better leave that alone and use a temporary ringview for the cursor's
row. */
+ vte::base::RingView ringview;
+ ringview.set_ring(m_screen->row_data);
+ ringview.set_rows(m_screen->cursor.row, 1);
+ ringview.set_width(m_column_count);
+ ringview.update();
+ if (ringview.get_bidirow(m_screen->cursor.row)->base_is_rtl()) {
+ switch (keyval) {
+ case GDK_KEY_Left:
+ keyval = GDK_KEY_Right;
+ break;
+ case GDK_KEY_Right:
+ keyval = GDK_KEY_Left;
+ break;
+ case GDK_KEY_KP_Left:
+ keyval = GDK_KEY_KP_Right;
+ break;
+ case GDK_KEY_KP_Right:
+ keyval = GDK_KEY_KP_Left;
+ break;
+ }
+ }
+ }
+
_vte_keymap_map(keyval, m_modifiers,
m_modes_private.DEC_APPLICATION_CURSOR_KEYS(),
m_modes_private.DEC_APPLICATION_KEYPAD(),
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]