Take a look at this instead which a) uses a function like CSI, SM etc b)
don't increment m inside function arguments.
Index: input.c
===================================================================
RCS file: /cvs/src/usr.bin/tmux/input.c,v
retrieving revision 1.64
diff -u -p -r1.64 input.c
--- input.c 10 Oct 2013 11:57:14 -0000 1.64
+++ input.c 29 Jan 2014 18:50:15 -0000
@@ -74,6 +74,7 @@ void input_csi_dispatch_rm(struct input_
void input_csi_dispatch_rm_private(struct input_ctx *);
void input_csi_dispatch_sm(struct input_ctx *);
void input_csi_dispatch_sm_private(struct input_ctx *);
+void input_csi_dispatch_winops(struct input_ctx *);
void input_csi_dispatch_sgr(struct input_ctx *);
int input_dcs_dispatch(struct input_ctx *);
int input_utf8_open(struct input_ctx *);
@@ -154,6 +155,7 @@ enum input_csi_type {
INPUT_CSI_SM_PRIVATE,
INPUT_CSI_TBC,
INPUT_CSI_VPA,
+ INPUT_CSI_WINOPS,
};
/* Control (CSI) command table. */
@@ -188,6 +190,7 @@ const struct input_table_entry input_csi
{ 'q', " ", INPUT_CSI_DECSCUSR },
{ 'r', "", INPUT_CSI_DECSTBM },
{ 's', "", INPUT_CSI_SCP },
+ { 't', "", INPUT_CSI_WINOPS },
{ 'u', "", INPUT_CSI_RCP },
};
@@ -1077,7 +1080,7 @@ input_csi_dispatch(struct input_ctx *ict
struct screen_write_ctx *sctx = &ictx->ctx;
struct screen *s = sctx->s;
struct input_table_entry *entry;
- int n, m;
+ int n, m;
if (ictx->flags & INPUT_DISCARD)
return (0);
@@ -1117,6 +1120,9 @@ input_csi_dispatch(struct input_ctx *ict
m = input_get(ictx, 1, 1, 1);
screen_write_cursormove(sctx, m - 1, n - 1);
break;
+ case INPUT_CSI_WINOPS:
+ input_csi_dispatch_winops(ictx);
+ break;
case INPUT_CSI_CUU:
screen_write_cursorup(sctx, input_get(ictx, 0, 1, 1));
break;
@@ -1427,6 +1433,51 @@ input_csi_dispatch_sm_private(struct inp
log_debug("%s: unknown '%c'", __func__, ictx->ch);
break;
}
+ }
+}
+
+/* Handle CSI window operations. */
+void
+input_csi_dispatch_winops(struct input_ctx *ictx)
+{
+ struct window_pane *wp = ictx->wp;
+ int n, m;
+
+ m = 0;
+ while ((n = input_get(ictx, m, 0, -1)) != -1) {
+ switch (n) {
+ case 1:
+ case 2:
+ case 5:
+ case 6:
+ case 7:
+ case 11:
+ case 13:
+ case 14:
+ case 19:
+ case 20:
+ case 21:
+ case 24:
+ break;
+ case 3:
+ case 4:
+ case 8:
+ m += 2;
+ break;
+ case 9:
+ case 10:
+ case 22:
+ case 23:
+ m++;
+ break;
+ case 18:
+ input_reply(ictx, "\033[8;%d;%d", wp->sy, wp->sx);
+ break;
+ default:
+ log_debug("%s: unknown '%c'", __func__, ictx->ch);
+ break;
+ }
+ m++;
}
}
On Wed, Jan 29, 2014 at 09:08:07AM -0600, J Raynor wrote:
> > How about WINOPS instead of WMN? This matches xterm src and seems a bit
> > more readable. Otherwise looks good.
>
> Sure. I've attached an updated patch with WINOPS instead of WMN.
> diff --git a/input.c b/input.c
> index 259fad1..bc4f912 100644
> --- a/input.c
> +++ b/input.c
> @@ -154,6 +154,7 @@ enum input_csi_type {
> INPUT_CSI_SM_PRIVATE,
> INPUT_CSI_TBC,
> INPUT_CSI_VPA,
> + INPUT_CSI_WINOPS,
> };
>
> /* Control (CSI) command table. */
> @@ -188,6 +189,7 @@ const struct input_table_entry input_csi_table[] = {
> { 'q', " ", INPUT_CSI_DECSCUSR },
> { 'r', "", INPUT_CSI_DECSTBM },
> { 's', "", INPUT_CSI_SCP },
> + { 't', "", INPUT_CSI_WINOPS },
> { 'u', "", INPUT_CSI_RCP },
> };
>
> @@ -1117,6 +1119,43 @@ input_csi_dispatch(struct input_ctx *ictx)
> m = input_get(ictx, 1, 1, 1);
> screen_write_cursormove(sctx, m - 1, n - 1);
> break;
> + case INPUT_CSI_WINOPS:
> + m = 0;
> + while ((n = input_get(ictx, m++, 0, -1)) != -1) {
> + switch (n) {
> + case 1:
> + case 2:
> + case 5:
> + case 6:
> + case 7:
> + case 11:
> + case 13:
> + case 14:
> + case 19:
> + case 20:
> + case 21:
> + case 24:
> + break;
> + case 3:
> + case 4:
> + case 8:
> + m += 2;
> + break;
> + case 9:
> + case 10:
> + case 22:
> + case 23:
> + m++;
> + break;
> + case 18:
> + input_reply(ictx, "\033[8;%d;%d", ictx->wp->sy,
> ictx->wp->sx);
> + break;
> + default:
> + log_debug("%s: unknown '%c'", __func__,
> ictx->ch);
> + break;
> + }
> + }
> + break;
> case INPUT_CSI_CUU:
> screen_write_cursorup(sctx, input_get(ictx, 0, 1, 1));
> break;
------------------------------------------------------------------------------
WatchGuard Dimension instantly turns raw network data into actionable
security intelligence. It gives you real-time visual feedback on key
security issues and trends. Skip the complicated setup - simply import
a virtual appliance and go from zero to informed in seconds.
http://pubads.g.doubleclick.net/gampad/clk?id=123612991&iu=/4140/ostg.clktrk
_______________________________________________
tmux-users mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/tmux-users