This patch adds a -h argument to send-keys. It is intended for control mode
to avoid any running into problems with transmitting certain bytes over a
transport with inband signaling (e.g., telnet) or for sending special keys
that the terminal driver might affect (like newlines). Example usage to
send ^]:

send-keys -h 1d


Index: cmd-send-keys.c
===================================================================
--- cmd-send-keys.c (revision 2710)
+++ cmd-send-keys.c (working copy)
@@ -31,14 +31,32 @@

 const struct cmd_entry cmd_send_keys_entry = {
  "send-keys", "send",
- "lRt:", 0, -1,
- "[-lR] [-t target-pane] key ...",
+ "hlRt:", 0, -1,
+ "[-hlR] [-t target-pane] key ...",
  0,
  NULL,
  NULL,
  cmd_send_keys_exec
 };

+static int
+hex_char_to_int(char hex)
+{
+ if (hex >= '0' && hex <= '9')
+ return hex - '0';
+ if (hex >= 'a' && hex <= 'f')
+ return hex - 'a' + 10;
+ if (hex >= 'A' && hex <= 'F')
+ return hex - 'A' + 10;
+ return 0;
+}
+
+static int
+decode_hex_octet(char *hex)
+{
+ return hex_char_to_int(hex[0]) * 16 + hex_char_to_int(hex[1]);
+}
+
 int
 cmd_send_keys_exec(struct cmd *self, struct cmd_ctx *ctx)
 {
@@ -71,8 +89,14 @@
  for (i = 0; i < args->argc; i++) {
  str = args->argv[i];

- if (!args_has(args, 'l') &&
-    (key = key_string_lookup_string(str)) != KEYC_NONE) {
+ if (args_has(args, 'h')) {
+ int arglen = strlen(args->argv[i]);
+ for (int j = 0; j < arglen - 1; j += 2) {
+ window_pane_key(
+    wp, s, decode_hex_octet(args->argv[i] + j));
+ }
+ } else if (!args_has(args, 'l') &&
+   (key = key_string_lookup_string(str)) != KEYC_NONE) {
     window_pane_key(wp, s, key);
  } else {
  for (; *str != '\0'; str++)
Index: tmux.1
===================================================================
--- tmux.1 (revision 2710)
+++ tmux.1 (working copy)
@@ -1672,7 +1672,7 @@
 or
 .Em emacs-copy .
 .It Xo Ic send-keys
-.Op Fl lR
+.Op Fl lhR
 .Op Fl t Ar target-pane
 .Ar key Ar ...
 .Xc
@@ -1690,6 +1690,15 @@
 .Fl l
 flag disables key name lookup and sends the keys literally.
 All arguments are sent sequentially from first to last.
+.Pp
+If
+.Fl h
+is present, the
+.Ar key
+arguments should each be formatted as a string of two-digit
+hexadecimal values. They must encode a valid sequence of bytes for the
character
+encoding used by
+.Ar target-pane .
 The
 .Fl R
 flag causes the terminal state to be reset.
------------------------------------------------------------------------------
Virtualization & Cloud Management Using Capacity Planning
Cloud computing makes use of virtualization - but cloud computing 
also focuses on allowing computing to be delivered as a service.
http://www.accelacomm.com/jaw/sfnl/114/51521223/
_______________________________________________
tmux-users mailing list
tmux-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/tmux-users

Reply via email to