-/* $OpenBSD: cmd-detach-client.c,v 1.36 2021/08/21 10:22:38 nicm Exp $ */
+/* $OpenBSD: cmd-detach-client.c,v 1.37 2024/03/21 11:26:28 nicm Exp $ */
/*
* Copyright (c) 2007 Nicholas Marriott <nicholas.marriott@gmail.com>
{
struct args *args = cmd_get_args(self);
struct cmd_find_state *source = cmdq_get_source(item);
+ struct client *c = cmdq_get_client(item);
struct client *tc = cmdq_get_target_client(item), *loop;
struct session *s;
enum msgtype msgtype;
return (CMD_RETURN_NORMAL);
}
- if (cmd != NULL)
+ if (cmd != NULL) {
+ if (c == NULL || c->session == NULL) {
+ cmdq_error(item, "must be attached for -E");
+ return (CMD_RETURN_ERROR);
+ }
server_client_exec(tc, cmd);
- else
+ } else
server_client_detach(tc, msgtype);
return (CMD_RETURN_STOP);
}
-/* $OpenBSD: window-copy.c,v 1.345 2023/11/02 10:38:14 nicm Exp $ */
+/* $OpenBSD: window-copy.c,v 1.346 2024/03/21 11:26:28 nicm Exp $ */
/*
* Copyright (c) 2007 Nicholas Marriott <nicholas.marriott@gmail.com>
format_add(ft, "copy_cursor_x", "%d", data->cx);
format_add(ft, "copy_cursor_y", "%d", data->cy);
- format_add(ft, "selection_present", "%d", data->screen.sel != NULL);
if (data->screen.sel != NULL) {
format_add(ft, "selection_start_x", "%d", data->selx);
format_add(ft, "selection_start_y", "%d", data->sely);
format_add(ft, "selection_end_x", "%d", data->endselx);
format_add(ft, "selection_end_y", "%d", data->endsely);
- format_add(ft, "selection_active", "%d",
- data->cursordrag != CURSORDRAG_NONE);
- } else
- format_add(ft, "selection_active", "%d", 0);
+
+ if (data->cursordrag != CURSORDRAG_NONE)
+ format_add(ft, "selection_active", "1");
+ else
+ format_add(ft, "selection_active", "0");
+ if (data->endselx != data->selx && data->endsely != data->sely)
+ format_add(ft, "selection_present", "1");
+ else
+ format_add(ft, "selection_present", "0");
+ } else {
+ format_add(ft, "selection_active", "0");
+ format_add(ft, "selection_present", "0");
+ }
format_add(ft, "search_present", "%d", data->searchmark != NULL);
format_add_cb(ft, "search_match", window_copy_search_match_cb);