Coverage Report

Created: 2026-07-16 06:55

next uncovered line (L), next uncovered region (R), next uncovered branch (B)
/src/tmux/window-client.c
Line
Count
Source
1
/* $OpenBSD: window-client.c,v 1.47 2026/07/14 17:17:18 nicm Exp $ */
2
3
/*
4
 * Copyright (c) 2017 Nicholas Marriott <nicholas.marriott@gmail.com>
5
 *
6
 * Permission to use, copy, modify, and distribute this software for any
7
 * purpose with or without fee is hereby granted, provided that the above
8
 * copyright notice and this permission notice appear in all copies.
9
 *
10
 * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
11
 * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
12
 * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
13
 * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
14
 * WHATSOEVER RESULTING FROM LOSS OF MIND, USE, DATA OR PROFITS, WHETHER
15
 * IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING
16
 * OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
17
 */
18
19
#include <sys/types.h>
20
#include <sys/time.h>
21
22
#include <stdlib.h>
23
#include <string.h>
24
#include <time.h>
25
26
#include "tmux.h"
27
28
static struct screen  *window_client_init(struct window_mode_entry *,
29
           struct cmdq_item *, struct cmd_find_state *,
30
           struct args *);
31
static void    window_client_free(struct window_mode_entry *);
32
static void    window_client_resize(struct window_mode_entry *, u_int,
33
           u_int);
34
static void    window_client_update(struct window_mode_entry *);
35
static void    window_client_key(struct window_mode_entry *,
36
           struct client *, struct session *,
37
           struct winlink *, key_code, struct mouse_event *);
38
39
0
#define WINDOW_CLIENT_DEFAULT_COMMAND "detach-client -t '%%'"
40
41
#define WINDOW_CLIENT_DEFAULT_FORMAT \
42
0
  "#[fg=themelightgrey]#{t/p:client_activity}: session #[default]#{session_name}"
43
44
#define WINDOW_CLIENT_DEFAULT_KEY_FORMAT \
45
0
  "#{?#{e|<:#{line},10}," \
46
0
    "#{line}" \
47
0
  ",#{e|<:#{line},36}," \
48
0
    "M-#{a:#{e|+:97,#{e|-:#{line},10}}}" \
49
0
  "}"
50
51
#define WINDOW_CLIENT_FEATURE(f) \
52
  "#{?#{I/f:" #f "}," \
53
  "#[fg=themegreen],#[fg=themelightgrey]}#{p/15:#{l:" #f "}}" \
54
  "#[default]"
55
static const char *window_client_info_lines[] = {
56
  "#[fg=themelightgrey]Client Name   #[#{E:tree-mode-border-style},acs]x#[default] "
57
  "#{client_name} #[fg=themelightgrey]"
58
  "#[fg=themelightgrey](PID #{client_pid})#[default]",
59
  "#[fg=themelightgrey]Session       #[#{E:tree-mode-border-style},acs]x#[default] "
60
  "#{session_name}",
61
  "#[fg=themelightgrey]Attach Time   #[#{E:tree-mode-border-style},acs]x#[default] "
62
  "#{t:client_created} "
63
  "#[fg=themelightgrey](#{t/r:client_created})#[default]",
64
  "#[fg=themelightgrey]Activity Time #[#{E:tree-mode-border-style},acs]x#[default] "
65
  "#{t:client_activity} "
66
  "#[fg=themelightgrey](#{t/r:client_activity})#[default]",
67
  "#[fg=themelightgrey]Terminal Type #[#{E:tree-mode-border-style},acs]x#[default] "
68
  "#{?client_termtype,#{client_termtype},Unknown}",
69
  "#[fg=themelightgrey]TERM          #[#{E:tree-mode-border-style},acs]x#[default] "
70
  "#{client_termname}",
71
  "#[fg=themelightgrey]Size          #[#{E:tree-mode-border-style},acs]x#[default] "
72
  "#{client_width}x#{client_height} "
73
  "#[fg=themelightgrey](cell #{client_cell_width}x"
74
  "#{client_cell_height})#[default]",
75
  "#[fg=themelightgrey]Bytes Written #[#{E:tree-mode-border-style},acs]x#[default] "
76
  "#{client_written} "
77
  "#[fg=themelightgrey](#{client_discarded} discarded)#[default]",
78
79
  "#[fg=themelightgrey]Features      #[#{E:tree-mode-border-style},acs]x#[default] "
80
  WINDOW_CLIENT_FEATURE(256) " "
81
  WINDOW_CLIENT_FEATURE(RGB) " "
82
  WINDOW_CLIENT_FEATURE(bpaste) " "
83
  WINDOW_CLIENT_FEATURE(ccolour),
84
  "              #[#{E:tree-mode-border-style},acs]x#[default] "
85
  WINDOW_CLIENT_FEATURE(clipboard) " "
86
  WINDOW_CLIENT_FEATURE(cstyle) " "
87
  WINDOW_CLIENT_FEATURE(extkeys) " "
88
  WINDOW_CLIENT_FEATURE(focus),
89
  "              #[#{E:tree-mode-border-style},acs]x#[default] "
90
  WINDOW_CLIENT_FEATURE(hyperlinks) " "
91
  WINDOW_CLIENT_FEATURE(ignorefkeys) " "
92
  WINDOW_CLIENT_FEATURE(margins) " "
93
  WINDOW_CLIENT_FEATURE(mouse),
94
  "              #[#{E:tree-mode-border-style},acs]x#[default] "
95
  WINDOW_CLIENT_FEATURE(osc7) " "
96
  WINDOW_CLIENT_FEATURE(overline) " "
97
  WINDOW_CLIENT_FEATURE(progressbar) " "
98
  WINDOW_CLIENT_FEATURE(rectfill),
99
  "              #[#{E:tree-mode-border-style},acs]x#[default] "
100
  WINDOW_CLIENT_FEATURE(sixel) " "
101
  WINDOW_CLIENT_FEATURE(strikethrough) " "
102
  WINDOW_CLIENT_FEATURE(sync) " "
103
  WINDOW_CLIENT_FEATURE(title),
104
  "              #[#{E:tree-mode-border-style},acs]x#[default] "
105
  WINDOW_CLIENT_FEATURE(usstyle),
106
  "#[#{E:tree-mode-border-style},acs]qqqqqqqqqqqqqqn#{R:q,#{window_width}}#[default]",
107
108
  "#[fg=themelightgrey]prefix        #[#{E:tree-mode-border-style},acs]x#[default] "
109
  "#{prefix}",
110
111
  "#[fg=themelightgrey]mouse         #[#{E:tree-mode-border-style},acs]x#[default] "
112
  "#{?mouse,#{?#{I/c:kmous},,#[fg=themered]}on,#[fg=themelightgrey]off} "
113
  "#{?#{I/c:kmous},,#[align=right]unavailable: [kmous] missing}",
114
115
  "#[fg=themelightgrey]set-clipboard #[#{E:tree-mode-border-style},acs]x#[default] "
116
  "#{?#{!=:#{set-clipboard},off},#{?#{I/f:clipboard},,"
117
  "#[fg=themered]}#{set-clipboard},#[fg=themelightgrey]off} "
118
  "#{?#{I/f:clipboard},,#[align=right]unavailable: [Ms] missing}",
119
120
  "#[fg=themelightgrey]get-clipboard #[#{E:tree-mode-border-style},acs]x#[default] "
121
  "#{?#{!=:#{get-clipboard},off},#{?#{I/f:clipboard},,"
122
  "#[fg=themered]}#{get-clipboard},#[fg=themelightgrey]off} "
123
  "#{?#{I/f:clipboard},,#[align=right]unavailable: [Ms] missing}",
124
125
  "#[fg=themelightgrey]focus-events  #[#{E:tree-mode-border-style},acs]x#[default] "
126
  "#{?focus-events,#{?#{I/f:focus},,#[fg=themered]}on,#[fg=themelightgrey]off} "
127
  "#{?#{I/f:focus},,#[align=right]unavailable: [Enfcs] or [Dcfcs] missing}",
128
129
  "#[fg=themelightgrey]extended-keys #[#{E:tree-mode-border-style},acs]x#[default] "
130
  "#{?#{!=:#{extended-keys},off},#{?#{I/f:extkeys},,"
131
  "#[fg=themered]}#{extended-keys},#[fg=themelightgrey]off} "
132
  "#{?#{I/f:extkeys},,#[align=right]unavailable: [Eneks] or [Dseks] missing}",
133
134
  "#[fg=themelightgrey]set-titles    #[#{E:tree-mode-border-style},acs]x#[default] "
135
  "#{?set-titles,on,#[fg=themelightgrey]off}",
136
137
  "#[fg=themelightgrey]escape-time   #[#{E:tree-mode-border-style},acs]x#[default] "
138
  "#{escape-time} ms",
139
};
140
141
142
static const struct menu_item window_client_menu_items[] = {
143
  { "Detach", 'd', NULL },
144
  { "Detach Tagged", 'D', NULL },
145
  { "", KEYC_NONE, NULL },
146
  { "Tag", 't', NULL },
147
  { "Tag All", '\024', NULL },
148
  { "Tag None", 'T', NULL },
149
  { "", KEYC_NONE, NULL },
150
  { "Cancel", 'q', NULL },
151
152
  { NULL, KEYC_NONE, NULL }
153
};
154
155
const struct window_mode window_client_mode = {
156
  .name = "client-mode",
157
  .default_format = WINDOW_CLIENT_DEFAULT_FORMAT,
158
159
  .init = window_client_init,
160
  .free = window_client_free,
161
  .resize = window_client_resize,
162
  .update = window_client_update,
163
  .key = window_client_key,
164
};
165
166
struct window_client_itemdata {
167
  struct client *c;
168
  char    *ttyname;
169
};
170
171
struct window_client_modedata {
172
  struct window_pane     *wp;
173
174
  struct mode_tree_data    *data;
175
  char         *format;
176
  char         *key_format;
177
  char         *command;
178
179
  int         hide_preview_this_pane;
180
  int         preview_is_info;
181
182
  struct window_client_itemdata **item_list;
183
  u_int         item_size;
184
};
185
186
static enum sort_order window_client_order_seq[] = {
187
  SORT_NAME,
188
  SORT_SIZE,
189
  SORT_CREATION,
190
  SORT_ACTIVITY,
191
  SORT_END,
192
};
193
194
static struct window_client_itemdata *
195
window_client_add_item(struct window_client_modedata *data)
196
0
{
197
0
  struct window_client_itemdata *item;
198
199
0
  data->item_list = xreallocarray(data->item_list, data->item_size + 1,
200
0
      sizeof *data->item_list);
201
0
  item = data->item_list[data->item_size++] = xcalloc(1, sizeof *item);
202
0
  return (item);
203
0
}
204
205
static void
206
window_client_free_item(struct window_client_itemdata *item)
207
0
{
208
0
  server_client_unref(item->c);
209
0
  free(item->ttyname);
210
0
  free(item);
211
0
}
212
213
static void
214
window_client_build(void *modedata, struct sort_criteria *sort_crit,
215
    __unused uint64_t *tag, const char *filter)
216
0
{
217
0
  struct window_client_modedata *data = modedata;
218
0
  struct window_client_itemdata *item;
219
0
  u_int        i, n;
220
0
  struct client     *c, **l;
221
0
  char        *text, *cp;
222
223
0
  for (i = 0; i < data->item_size; i++)
224
0
    window_client_free_item(data->item_list[i]);
225
0
  free(data->item_list);
226
0
  data->item_list = NULL;
227
0
  data->item_size = 0;
228
229
0
  l = sort_get_clients(&n, sort_crit);
230
0
  for (i = 0; i < n; i++) {
231
0
    if (l[i]->session == NULL ||
232
0
        (l[i]->flags & CLIENT_UNATTACHEDFLAGS))
233
0
      continue;
234
235
0
    item = window_client_add_item(data);
236
0
    item->c = l[i];
237
0
    item->ttyname = xstrdup(l[i]->ttyname);
238
239
0
    l[i]->references++;
240
0
  }
241
242
0
  for (i = 0; i < data->item_size; i++) {
243
0
    item = data->item_list[i];
244
0
    c = item->c;
245
246
0
    if (filter != NULL) {
247
0
      cp = format_single(NULL, filter, c, NULL, NULL, NULL);
248
0
      if (!format_true(cp)) {
249
0
        free(cp);
250
0
        continue;
251
0
      }
252
0
      free(cp);
253
0
    }
254
255
0
    text = format_single(NULL, data->format, c, NULL, NULL, NULL);
256
0
    mode_tree_add(data->data, NULL, item, (uint64_t)c, c->name,
257
0
        text, -1);
258
0
    free(text);
259
0
  }
260
0
}
261
262
static void
263
window_client_draw_info(__unused void *modedata, void *itemdata,
264
    struct screen_write_ctx *ctx, u_int sx, u_int sy)
265
0
{
266
0
  struct window_client_itemdata *item = itemdata;
267
0
  struct client     *c = item->c;
268
0
  struct screen     *s = ctx->s;
269
0
  struct window     *w = c->session->curw->window;
270
0
  struct grid_cell     gc;
271
0
  u_int        cx = s->cx, cy = s->cy, i;
272
0
  struct format_tree    *ft;
273
0
  char        *expanded;
274
275
0
  ft = format_create_defaults(NULL, c, NULL, NULL, NULL);
276
277
0
  screen_write_cursormove(ctx, cx, cy, 0);
278
0
  for (i = 0; i < nitems(window_client_info_lines); i++) {
279
0
    if (i == sy)
280
0
      break;
281
0
    expanded = format_expand(ft, window_client_info_lines[i]);
282
0
    screen_write_cursormove(ctx, cx, cy + i, 0);
283
0
    format_draw(ctx, &grid_default_cell, sx, expanded, NULL, 0);
284
0
    free(expanded);
285
0
  }
286
0
  if (sx > 14 && i < sy) {
287
0
    memcpy(&gc, &grid_default_cell, sizeof gc);
288
0
    style_apply(&gc, w->options, "tree-mode-border-style", NULL);
289
0
    screen_write_cursormove(ctx, cx + 14, cy + i, 0);
290
0
    screen_write_vline(ctx, sy - i, 0, 0, &gc);
291
0
  }
292
293
0
  format_free(ft);
294
0
}
295
296
static void
297
window_client_draw(void *modedata, void *itemdata,
298
    struct screen_write_ctx *ctx, u_int sx, u_int sy)
299
0
{
300
0
  struct window_client_modedata *data = modedata;
301
0
  struct window_client_itemdata *item = itemdata;
302
0
  struct client     *c = item->c;
303
0
  struct session      *session = c->session;
304
0
  struct screen     *s = ctx->s;
305
0
  struct window     *w;
306
0
  struct window_pane    *wp;
307
0
  struct grid_cell     gc;
308
0
  u_int        cx = s->cx, cy = s->cy, lines, at;
309
310
0
  if (session == NULL || (c->flags & CLIENT_UNATTACHEDFLAGS))
311
0
    return;
312
0
  if (data->preview_is_info) {
313
0
    window_client_draw_info(modedata, itemdata, ctx, sx, sy);
314
0
    return;
315
0
  }
316
0
  w = session->curw->window;
317
0
  wp = w->active;
318
0
  if (data->hide_preview_this_pane && wp == data->wp) {
319
0
    if (!TAILQ_EMPTY(&w->last_panes))
320
0
      wp = TAILQ_FIRST(&w->last_panes);
321
0
    else
322
0
      wp = NULL;
323
0
  }
324
325
0
  lines = status_line_size(c);
326
0
  if (lines >= sy)
327
0
    lines = 0;
328
0
  if (status_at_line(c) == 0)
329
0
    at = lines;
330
0
  else
331
0
    at = 0;
332
333
0
  screen_write_cursormove(ctx, cx, cy + at, 0);
334
0
  if (wp != NULL)
335
0
    screen_write_preview(ctx, &wp->base, sx, sy - 2 - lines);
336
337
0
  if (at != 0)
338
0
    screen_write_cursormove(ctx, cx, cy + 2, 0);
339
0
  else
340
0
    screen_write_cursormove(ctx, cx, cy + sy - 1 - lines, 0);
341
0
  memcpy(&gc, &grid_default_cell, sizeof gc);
342
0
  style_apply(&gc, w->options, "tree-mode-border-style", NULL);
343
0
  screen_write_hline(ctx, sx, 0, 0, BOX_LINES_DEFAULT, &gc);
344
345
0
  if (at != 0)
346
0
    screen_write_cursormove(ctx, cx, cy, 0);
347
0
  else
348
0
    screen_write_cursormove(ctx, cx, cy + sy - lines, 0);
349
0
  screen_write_fast_copy(ctx, &c->status.screen, 0, 0, sx, lines);
350
0
}
351
352
static void
353
window_client_menu(void *modedata, struct client *c, key_code key)
354
0
{
355
0
  struct window_client_modedata *data = modedata;
356
0
  struct window_pane    *wp = data->wp;
357
0
  struct window_mode_entry  *wme;
358
359
0
  wme = TAILQ_FIRST(&wp->modes);
360
0
  if (wme == NULL || wme->data != modedata)
361
0
    return;
362
0
  window_client_key(wme, c, NULL, NULL, key, NULL);
363
0
}
364
365
static key_code
366
window_client_get_key(void *modedata, void *itemdata, u_int line)
367
0
{
368
0
  struct window_client_modedata *data = modedata;
369
0
  struct window_client_itemdata *item = itemdata;
370
0
  struct format_tree    *ft;
371
0
  char        *expanded;
372
0
  key_code       key;
373
374
0
  ft = format_create(NULL, NULL, FORMAT_NONE, 0);
375
0
  format_defaults(ft, item->c, NULL, 0, NULL);
376
0
  format_add(ft, "line", "%u", line);
377
378
0
  expanded = format_expand(ft, data->key_format);
379
0
  key = key_string_lookup_string(expanded);
380
0
  free(expanded);
381
0
  format_free(ft);
382
0
  return (key);
383
0
}
384
385
static void
386
window_client_sort(struct sort_criteria *sort_crit)
387
0
{
388
0
  sort_crit->order_seq = window_client_order_seq;
389
0
  if (sort_crit->order == SORT_END)
390
0
    sort_crit->order = sort_crit->order_seq[0];
391
0
}
392
393
static const char* window_client_help_lines[] = {
394
  "#[fg=themelightgrey]"
395
  "          i #[#{E:tree-mode-border-style},acs]x#[default] Toggle info view",
396
  "#[fg=themelightgrey]"
397
  "      Enter #[#{E:tree-mode-border-style},acs]x#[default] Choose selected %1",
398
  "#[fg=themelightgrey]"
399
  "          d #[#{E:tree-mode-border-style},acs]x#[default] Detach selected %1",
400
  "#[fg=themelightgrey]"
401
  "          D #[#{E:tree-mode-border-style},acs]x#[default] Detach tagged %1s",
402
  "#[fg=themelightgrey]"
403
  "          x #[#{E:tree-mode-border-style},acs]x#[default] Detach selected %1",
404
  "#[fg=themelightgrey]"
405
  "          X #[#{E:tree-mode-border-style},acs]x#[default] Detach tagged %1s",
406
  "#[fg=themelightgrey]"
407
  "          z #[#{E:tree-mode-border-style},acs]x#[default] Suspend selected %1",
408
  "#[fg=themelightgrey]"
409
  "          Z #[#{E:tree-mode-border-style},acs]x#[default] Suspend tagged %1s",
410
  "#[fg=themelightgrey]"
411
  "          f #[#{E:tree-mode-border-style},acs]x#[default] Enter a filter",
412
  NULL
413
};
414
415
static const char**
416
window_client_help(u_int *width, const char **item)
417
0
{
418
0
  *width = 0;
419
0
  *item = "client";
420
0
  return (window_client_help_lines);
421
0
}
422
423
static struct screen *
424
window_client_init(struct window_mode_entry *wme,
425
    __unused struct cmdq_item *item, __unused struct cmd_find_state *fs,
426
    struct args *args)
427
0
{
428
0
  struct window_pane    *wp = wme->wp;
429
0
  struct window_client_modedata *data;
430
0
  struct screen     *s;
431
432
0
  wme->data = data = xcalloc(1, sizeof *data);
433
0
  data->wp = wp;
434
0
  data->hide_preview_this_pane = args != NULL && args_has(args, 'h');
435
0
  data->preview_is_info = args != NULL && args_has(args, 'i');
436
437
0
  if (args == NULL || !args_has(args, 'F'))
438
0
    data->format = xstrdup(WINDOW_CLIENT_DEFAULT_FORMAT);
439
0
  else
440
0
    data->format = xstrdup(args_get(args, 'F'));
441
0
  if (args == NULL || !args_has(args, 'K'))
442
0
    data->key_format = xstrdup(WINDOW_CLIENT_DEFAULT_KEY_FORMAT);
443
0
  else
444
0
    data->key_format = xstrdup(args_get(args, 'K'));
445
0
  if (args == NULL || args_count(args) == 0)
446
0
    data->command = xstrdup(WINDOW_CLIENT_DEFAULT_COMMAND);
447
0
  else
448
0
    data->command = xstrdup(args_string(args, 0));
449
450
0
  data->data = mode_tree_start(wp, args, window_client_build,
451
0
      window_client_draw, NULL, window_client_menu, NULL,
452
0
      window_client_get_key, NULL, window_client_sort,
453
0
      window_client_help, data, window_client_menu_items, &s);
454
0
  mode_tree_zoom(data->data, args);
455
456
0
  if (data->preview_is_info)
457
0
    mode_tree_view_name(data->data, "info");
458
0
  else
459
0
    mode_tree_view_name(data->data, "preview");
460
461
0
  mode_tree_build(data->data);
462
0
  mode_tree_draw(data->data);
463
464
0
  return (s);
465
0
}
466
467
static void
468
window_client_free(struct window_mode_entry *wme)
469
0
{
470
0
  struct window_client_modedata *data = wme->data;
471
0
  u_int        i;
472
473
0
  if (data == NULL)
474
0
    return;
475
476
0
  mode_tree_free(data->data);
477
478
0
  for (i = 0; i < data->item_size; i++)
479
0
    window_client_free_item(data->item_list[i]);
480
0
  free(data->item_list);
481
482
0
  free(data->format);
483
0
  free(data->key_format);
484
0
  free(data->command);
485
486
0
  free(data);
487
0
}
488
489
static void
490
window_client_resize(struct window_mode_entry *wme, u_int sx, u_int sy)
491
0
{
492
0
  struct window_client_modedata *data = wme->data;
493
494
0
  mode_tree_resize(data->data, sx, sy);
495
0
}
496
497
static void
498
window_client_update(struct window_mode_entry *wme)
499
0
{
500
0
  struct window_client_modedata *data = wme->data;
501
502
0
  mode_tree_build(data->data);
503
0
  mode_tree_draw(data->data);
504
0
  data->wp->flags |= PANE_REDRAW;
505
0
}
506
507
static void
508
window_client_do_detach(void *modedata, void *itemdata,
509
    __unused struct client *c, key_code key)
510
0
{
511
0
  struct window_client_modedata *data = modedata;
512
0
  struct window_client_itemdata *item = itemdata;
513
514
0
  if (item == mode_tree_get_current(data->data))
515
0
    mode_tree_down(data->data, 0);
516
0
  if (key == 'd' || key == 'D')
517
0
    server_client_detach(item->c, MSG_DETACH);
518
0
  else if (key == 'x' || key == 'X')
519
0
    server_client_detach(item->c, MSG_DETACHKILL);
520
0
  else if (key == 'z' || key == 'Z')
521
0
    server_client_suspend(item->c);
522
0
}
523
524
static void
525
window_client_key(struct window_mode_entry *wme, struct client *c,
526
    __unused struct session *s, __unused struct winlink *wl, key_code key,
527
    struct mouse_event *m)
528
0
{
529
0
  struct window_pane    *wp = wme->wp;
530
0
  struct window_client_modedata *data = wme->data;
531
0
  struct mode_tree_data   *mtd = data->data;
532
0
  struct window_client_itemdata *item;
533
0
  int        finished;
534
535
0
  finished = mode_tree_key(mtd, c, &key, m, NULL, NULL);
536
0
  switch (key) {
537
0
  case 'd':
538
0
  case 'x':
539
0
  case 'z':
540
0
    item = mode_tree_get_current(mtd);
541
0
    window_client_do_detach(data, item, c, key);
542
0
    mode_tree_build(mtd);
543
0
    break;
544
0
  case 'D':
545
0
  case 'X':
546
0
  case 'Z':
547
0
    mode_tree_each_tagged(mtd, window_client_do_detach, c, key, 0);
548
0
    mode_tree_build(mtd);
549
0
    break;
550
0
  case 'i':
551
0
    data->preview_is_info = !data->preview_is_info;
552
0
    if (data->preview_is_info)
553
0
      mode_tree_view_name(mtd, "info");
554
0
    else
555
0
      mode_tree_view_name(mtd, "preview");
556
0
    mode_tree_build(mtd);
557
0
    break;
558
0
  case '\r':
559
0
    item = mode_tree_get_current(mtd);
560
0
    mode_tree_run_command(c, NULL, data->command, item->ttyname);
561
0
    finished = 1;
562
0
    break;
563
0
  }
564
0
  if (finished || server_client_how_many() == 0)
565
0
    window_pane_reset_mode(wp);
566
0
  else {
567
0
    mode_tree_draw(mtd);
568
0
    wp->flags |= PANE_REDRAW;
569
0
  }
570
0
}