@@ -114,33 +114,14 @@ _copycat_enter_mode() {
114114
115115# clears selection from a previous match
116116_copycat_exit_select_mode () {
117- if tmux_is_at_least 2.4; then
118- tmux send-keys -X clear-selection
119- elif [ " $TMUX_COPY_MODE " == " vi" ]; then
120- # vi mode
121- tmux send-keys Escape
122- else
123- # emacs mode
124- tmux send-keys C-g
125- fi
117+ tmux send-keys -X clear-selection
126118}
127119
128120# "manually" go up in the scrollback for a number of lines
129121_copycat_manually_go_up () {
130122 local line_number=" $1 "
131- if tmux_is_at_least 2.4; then
132- tmux send-keys -X -N " $line_number " cursor-up
133- tmux send-keys -X start-of-line
134- elif [ " $TMUX_COPY_MODE " == " vi" ]; then
135- # vi copy mode
136- tmux send-keys " $line_number " k 0
137- else
138- # emacs copy mode
139- for (( c= 1 ; c<= "$line_number "; c++ )) ; do
140- tmux send-keys C-p
141- done
142- tmux send-keys C-a
143- fi
123+ tmux send-keys -X -N " $line_number " cursor-up
124+ tmux send-keys -X start-of-line
144125}
145126
146127_copycat_create_padding_below_result () {
@@ -161,40 +142,17 @@ _copycat_create_padding_below_result() {
161142 return
162143 fi
163144
164- if tmux_is_at_least 2.4; then
165- tmux send-keys -X -N " $padding " cursor-down
166- tmux send-keys -X -N " $padding " cursor-up
167- elif [ " $TMUX_COPY_MODE " == " vi" ]; then
168- # vi copy mode
169- tmux send-keys " $padding " j " $padding " k
170- else
171- # emacs copy mode
172- for (( c= 1 ; c<= "$padding "; c++ )) ; do
173- tmux send-keys C-n
174- done
175- for (( c= 1 ; c<= "$padding "; c++ )) ; do
176- tmux send-keys C-p
177- done
178- fi
145+ tmux send-keys -X -N " $padding " cursor-down
146+ tmux send-keys -X -N " $padding " cursor-up
179147}
180148
181149# performs a jump to go to line
182150_copycat_go_to_line_with_jump () {
183151 local line_number=" $1 "
184152 # first jumps to the "bottom" in copy mode so that jumps are consistent
185- if tmux_is_at_least 2.4; then
186- tmux send-keys -X history-bottom
187- tmux send-keys -X start-of-line
188- tmux send-keys -X goto-line $line_number
189- elif [ " $TMUX_COPY_MODE " == " vi" ]; then
190- # vi copy mode
191- tmux send-keys G 0 :
192- tmux send-keys " $line_number " C-m
193- else
194- # emacs copy mode
195- tmux send-keys " M->" C-a g
196- tmux send-keys " $line_number " C-m
197- fi
153+ tmux send-keys -X history-bottom
154+ tmux send-keys -X start-of-line
155+ tmux send-keys -X goto-line $line_number
198156}
199157
200158# maximum line number that can be reached via tmux 'jump'
@@ -247,40 +205,16 @@ _copycat_position_to_match_start() {
247205 local match_line_position=" $1 "
248206 [ " $match_line_position " -eq " 0" ] && return 0
249207
250- if tmux_is_at_least 2.4; then
251- tmux send-keys -X -N " $match_line_position " cursor-right
252- elif [ " $TMUX_COPY_MODE " == " vi" ]; then
253- # vi copy mode
254- tmux send-keys " $match_line_position " l
255- else
256- # emacs copy mode
257- # emacs doesn't have repeat, so we're manually looping :(
258- for (( c= 1 ; c<= "$match_line_position "; c++ )) ; do
259- tmux send-keys C-f
260- done
261- fi
208+ tmux send-keys -X -N " $match_line_position " cursor-right
262209}
263210
264211_copycat_select () {
265212 local match=" $1 "
266213 local length=" ${# match} "
267- if tmux_is_at_least 2.4; then
268- tmux send-keys -X begin-selection
269- tmux send-keys -X -N " $length " cursor-right
270- if [ " $TMUX_COPY_MODE " == " vi" ]; then
271- tmux send-keys -X cursor-left # selection correction for 1 char
272- fi
273- elif [ " $TMUX_COPY_MODE " == " vi" ]; then
274- # vi copy mode
275- tmux send-keys Space " $length " l h # selection correction for 1 char
276- else
277- # emacs copy mode
278- tmux send-keys C-Space
279- # emacs doesn't have repeat, so we're manually looping :(
280- for (( c= 1 ; c<= "$length "; c++ )) ; do
281- tmux send-keys C-f
282- done
283- # NO selection correction for emacs mode
214+ tmux send-keys -X begin-selection
215+ tmux send-keys -X -N " $length " cursor-right
216+ if [ " $TMUX_COPY_MODE " == " vi" ]; then
217+ tmux send-keys -X cursor-left # selection correction for 1 char
284218 fi
285219}
286220
0 commit comments