@@ -114,28 +114,14 @@ _copycat_enter_mode() {
114
114
115
115
# clears selection from a previous match
116
116
_copycat_exit_select_mode () {
117
- if [ " $TMUX_COPY_MODE " == " vi" ]; then
118
- # vi mode
119
- tmux send-keys Escape
120
- else
121
- # emacs mode
122
- tmux send-keys C-g
123
- fi
117
+ tmux send-keys -X clear-selection
124
118
}
125
119
126
120
# "manually" go up in the scrollback for a number of lines
127
121
_copycat_manually_go_up () {
128
122
local line_number=" $1 "
129
- if [ " $TMUX_COPY_MODE " == " vi" ]; then
130
- # vi copy mode
131
- tmux send-keys " $line_number " k 0
132
- else
133
- # emacs copy mode
134
- for (( c= 1 ; c<= "$line_number "; c++ )) ; do
135
- tmux send-keys C-p
136
- done
137
- tmux send-keys C-a
138
- fi
123
+ tmux send-keys -X -N " $line_number " cursor-up
124
+ tmux send-keys -X start-of-line
139
125
}
140
126
141
127
_copycat_create_padding_below_result () {
@@ -156,32 +142,17 @@ _copycat_create_padding_below_result() {
156
142
return
157
143
fi
158
144
159
- if [ " $TMUX_COPY_MODE " == " vi" ]; then
160
- # vi copy mode
161
- tmux send-keys " $padding " j " $padding " k
162
- else
163
- # emacs copy mode
164
- for (( c= 1 ; c<= "$padding "; c++ )) ; do
165
- tmux send-keys C-n
166
- done
167
- for (( c= 1 ; c<= "$padding "; c++ )) ; do
168
- tmux send-keys C-p
169
- done
170
- fi
145
+ tmux send-keys -X -N " $padding " cursor-down
146
+ tmux send-keys -X -N " $padding " cursor-up
171
147
}
172
148
173
149
# performs a jump to go to line
174
150
_copycat_go_to_line_with_jump () {
175
151
local line_number=" $1 "
176
152
# first jumps to the "bottom" in copy mode so that jumps are consistent
177
- if [ " $TMUX_COPY_MODE " == " vi" ]; then
178
- # vi copy mode
179
- tmux send-keys G 0 :
180
- else
181
- # emacs copy mode
182
- tmux send-keys " M->" C-a g
183
- fi
184
- tmux send-keys " $line_number " C-m
153
+ tmux send-keys -X history-bottom
154
+ tmux send-keys -X start-of-line
155
+ tmux send-keys -X goto-line $line_number
185
156
}
186
157
187
158
# maximum line number that can be reached via tmux 'jump'
@@ -234,32 +205,16 @@ _copycat_position_to_match_start() {
234
205
local match_line_position=" $1 "
235
206
[ " $match_line_position " -eq " 0" ] && return 0
236
207
237
- if [ " $TMUX_COPY_MODE " == " vi" ]; then
238
- # vi copy mode
239
- tmux send-keys " $match_line_position " l
240
- else
241
- # emacs copy mode
242
- # emacs doesn't have repeat, so we're manually looping :(
243
- for (( c= 1 ; c<= "$match_line_position "; c++ )) ; do
244
- tmux send-keys C-f
245
- done
246
- fi
208
+ tmux send-keys -X -N " $match_line_position " cursor-right
247
209
}
248
210
249
211
_copycat_select () {
250
212
local match=" $1 "
251
213
local length=" ${# match} "
214
+ tmux send-keys -X begin-selection
215
+ tmux send-keys -X -N " $length " cursor-right
252
216
if [ " $TMUX_COPY_MODE " == " vi" ]; then
253
- # vi copy mode
254
- tmux send-keys Space " $length " l h # selection correction for 1 char
255
- else
256
- # emacs copy mode
257
- tmux send-keys C-Space
258
- # emacs doesn't have repeat, so we're manually looping :(
259
- for (( c= 1 ; c<= "$length "; c++ )) ; do
260
- tmux send-keys C-f
261
- done
262
- # NO selection correction for emacs mode
217
+ tmux send-keys -X cursor-left # selection correction for 1 char
263
218
fi
264
219
}
265
220
0 commit comments