mirror of
https://github.com/tmux/tmux.git
synced 2025-11-24 19:06:07 +00:00
Add a command to explcitly set the selection mode in copy mode, GitHub
issue 3842.
This commit is contained in:
5
tmux.1
5
tmux.1
@@ -2293,6 +2293,11 @@ Select the current line.
|
|||||||
.Xc
|
.Xc
|
||||||
Select the current word.
|
Select the current word.
|
||||||
.It Xo
|
.It Xo
|
||||||
|
.Ic selection-mode
|
||||||
|
.Op Ic char | word | line
|
||||||
|
.Xc
|
||||||
|
Change the selection mode.
|
||||||
|
.It Xo
|
||||||
.Ic set-mark
|
.Ic set-mark
|
||||||
(vi: X)
|
(vi: X)
|
||||||
(emacs: X)
|
(emacs: X)
|
||||||
|
|||||||
@@ -1970,6 +1970,24 @@ window_copy_cmd_other_end(struct window_copy_cmd_state *cs)
|
|||||||
return (WINDOW_COPY_CMD_NOTHING);
|
return (WINDOW_COPY_CMD_NOTHING);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static enum window_copy_cmd_action
|
||||||
|
window_copy_cmd_selection_mode(struct window_copy_cmd_state *cs)
|
||||||
|
{
|
||||||
|
struct window_mode_entry *wme = cs->wme;
|
||||||
|
struct options *so = cs->s->options;
|
||||||
|
struct window_copy_mode_data *data = wme->data;
|
||||||
|
const char *s = args_string(cs->wargs, 0);
|
||||||
|
|
||||||
|
if (s == NULL || strcasecmp(s, "char") == 0 || strcasecmp(s, "c") == 0)
|
||||||
|
data->selflag = SEL_CHAR;
|
||||||
|
else if (strcasecmp(s, "word") == 0 || strcasecmp(s, "w") == 0) {
|
||||||
|
data->separators = options_get_string(so, "word-separators");
|
||||||
|
data->selflag = SEL_WORD;
|
||||||
|
} else if (strcasecmp(s, "line") == 0 || strcasecmp(s, "l") == 0)
|
||||||
|
data->selflag = SEL_LINE;
|
||||||
|
return (WINDOW_COPY_CMD_NOTHING);
|
||||||
|
}
|
||||||
|
|
||||||
static enum window_copy_cmd_action
|
static enum window_copy_cmd_action
|
||||||
window_copy_cmd_page_down(struct window_copy_cmd_state *cs)
|
window_copy_cmd_page_down(struct window_copy_cmd_state *cs)
|
||||||
{
|
{
|
||||||
@@ -2186,7 +2204,7 @@ static enum window_copy_cmd_action
|
|||||||
window_copy_cmd_select_word(struct window_copy_cmd_state *cs)
|
window_copy_cmd_select_word(struct window_copy_cmd_state *cs)
|
||||||
{
|
{
|
||||||
struct window_mode_entry *wme = cs->wme;
|
struct window_mode_entry *wme = cs->wme;
|
||||||
struct options *session_options = cs->s->options;
|
struct options *so = cs->s->options;
|
||||||
struct window_copy_mode_data *data = wme->data;
|
struct window_copy_mode_data *data = wme->data;
|
||||||
u_int px, py, nextx, nexty;
|
u_int px, py, nextx, nexty;
|
||||||
|
|
||||||
@@ -2196,8 +2214,7 @@ window_copy_cmd_select_word(struct window_copy_cmd_state *cs)
|
|||||||
data->dx = data->cx;
|
data->dx = data->cx;
|
||||||
data->dy = screen_hsize(data->backing) + data->cy - data->oy;
|
data->dy = screen_hsize(data->backing) + data->cy - data->oy;
|
||||||
|
|
||||||
data->separators = options_get_string(session_options,
|
data->separators = options_get_string(so, "word-separators");
|
||||||
"word-separators");
|
|
||||||
window_copy_cursor_previous_word(wme, data->separators, 0);
|
window_copy_cursor_previous_word(wme, data->separators, 0);
|
||||||
px = data->cx;
|
px = data->cx;
|
||||||
py = screen_hsize(data->backing) + data->cy - data->oy;
|
py = screen_hsize(data->backing) + data->cy - data->oy;
|
||||||
@@ -3087,6 +3104,11 @@ static const struct {
|
|||||||
.clear = WINDOW_COPY_CMD_CLEAR_ALWAYS,
|
.clear = WINDOW_COPY_CMD_CLEAR_ALWAYS,
|
||||||
.f = window_copy_cmd_select_word
|
.f = window_copy_cmd_select_word
|
||||||
},
|
},
|
||||||
|
{ .command = "selection-mode",
|
||||||
|
.args = { "", 0, 1, NULL },
|
||||||
|
.clear = 0,
|
||||||
|
.f = window_copy_cmd_selection_mode
|
||||||
|
},
|
||||||
{ .command = "set-mark",
|
{ .command = "set-mark",
|
||||||
.args = { "", 0, 0, NULL },
|
.args = { "", 0, 0, NULL },
|
||||||
.clear = WINDOW_COPY_CMD_CLEAR_ALWAYS,
|
.clear = WINDOW_COPY_CMD_CLEAR_ALWAYS,
|
||||||
|
|||||||
Reference in New Issue
Block a user