Skip to contentSkip to conversation

readline: Handle xterm escape sequences for Home/End keys

PATCH Applied Kevin Wolf 3 participants 3 messages May 14, 2013

lore
Share & tools
lore

Kevin Wolf

author
#0 lore raw

PATCH 1/1 readline: Handle xterm escape sequences for Home/End keys

This fixes the Home/End keys in the monitor using the GTK frontend.

---
 readline.c | 15 +++++++++++++++
 1 file changed, 15 insertions(+)
readline.c +15 -0
index d6e04d4..1c0f7ee 100644
@@ -27,6 +27,7 @@
 #define IS_NORM 0
 #define IS_ESC  1
 #define IS_CSI  2
+#define IS_SS3  3
 
 #undef printf
 #define printf do_not_use_printf
@@ -397,6 +398,9 @@ void readline_handle_byte(ReadLineState *rs, int ch)
         if (ch == '[') {
             rs->esc_state = IS_CSI;
             rs->esc_param = 0;
+        } else if (ch == 'O') {
+            rs->esc_state = IS_SS3;
+            rs->esc_param = 0;
         } else {
             rs->esc_state = IS_NORM;
         }
@@ -439,6 +443,17 @@ void readline_handle_byte(ReadLineState *rs, int ch)
         rs->esc_state = IS_NORM;
     the_end:
         break;
+    case IS_SS3:
+        switch(ch) {
+        case 'F':
+            readline_eol(rs);
+            break;
+        case 'H':
+            readline_bol(rs);
+            break;
+        }
+        rs->esc_state = IS_NORM;
+        break;
     }
     readline_update(rs);
 }
Signature · 1 line
1.8.1.4
#1 lore raw

Hi,

Looks good, ack.

Regards,

Hans

Quoted 48 lines · Kevin Wolf

This fixes the Home/End keys in the monitor using the GTK frontend.

---
  readline.c | 15 +++++++++++++++
  1 file changed, 15 insertions(+)
readline.c +15 -0
index d6e04d4..1c0f7ee 100644
@@ -27,6 +27,7 @@
  #define IS_NORM 0
  #define IS_ESC  1
  #define IS_CSI  2
+#define IS_SS3  3
 
  #undef printf
  #define printf do_not_use_printf
@@ -397,6 +398,9 @@ void readline_handle_byte(ReadLineState *rs, int ch)
          if (ch == '[') {
              rs->esc_state = IS_CSI;
              rs->esc_param = 0;
+        } else if (ch == 'O') {
+            rs->esc_state = IS_SS3;
+            rs->esc_param = 0;
          } else {
              rs->esc_state = IS_NORM;
          }
@@ -439,6 +443,17 @@ void readline_handle_byte(ReadLineState *rs, int ch)
          rs->esc_state = IS_NORM;
      the_end:
          break;
+    case IS_SS3:
+        switch(ch) {
+        case 'F':
+            readline_eol(rs);
+            break;
+        case 'H':
+            readline_bol(rs);
+            break;
+        }
+        rs->esc_state = IS_NORM;
+        break;
      }
      readline_update(rs);
  }