More quickcopy

This commit is contained in:
Chris Breneman 2021-01-16 15:04:13 -05:00
parent 8520274cd5
commit 51b67b8809
2 changed files with 8 additions and 3 deletions

View file

@ -591,6 +591,7 @@ class PaneJumpAction:
def _redraw_highlight_ranges(self):
if not self.highlight_ranges: return
line_width = min(self.curses_size[1], self.orig_pane['pane_size'][0])
hlattr = curses.color_pair(3)
for rng in self.highlight_ranges:
log('Drawing hl range: ' + str(rng))
@ -599,11 +600,11 @@ class PaneJumpAction:
if i < rng[0][1] or i > rng[1][1]: # whole line not hl
continue
elif i > rng[0][1] and i < rng[1][1]: # whole line hl
self.addstr(i, 0, line, hlattr)
self.addstr(i, 0, line.ljust(line_width), hlattr)
elif i == rng[0][1] and i == rng[1][1]: # range starts and stops on this line
self.addstr(i, rng[0][0], line[rng[0][0]:rng[1][0]+1], hlattr)
elif i == rng[0][1]: # range starts on this line
self.addstr(i, rng[0][0], line[rng[0][0]:], hlattr)
self.addstr(i, rng[0][0], line.ljust(line_width)[rng[0][0]:], hlattr)
elif i == rng[1][1]: # range ends on this line
self.addstr(i, 0, line[0:rng[1][0]+1], hlattr)
else:
@ -1030,7 +1031,7 @@ class QuickCopyAction(PaneJumpAction):
for batch in batches:
selected = self.run_batch(batch)
if selected: break
if not selected: return
if not selected: raise ActionCanceled()
# Got result. Do copy.
selected_data = selected[0][2]

View file

@ -18,7 +18,11 @@ tmux bind-key -T copytk Y run-shell -b "python3 $CURRENT_DIR/copytk.py easycopy
# tmux prefix: easycopy action bindings
tmux bind-key -T prefix S run-shell -b "python3 $CURRENT_DIR/copytk.py easycopy --search-nkeys 1"
tmux bind-key -T prefix C-s run-shell -b "python3 $CURRENT_DIR/copytk.py easycopy --search-nkeys 1"
# tmux prefix: quickcopy action bindings
tmux bind-key -T prefix Q run-shell -b "python3 $CURRENT_DIR/copytk.py quickcopy"
tmux bind-key -T prefix C-q run-shell -b "python3 $CURRENT_DIR/copytk.py quickcopy"
# bindings to enter copytk prefix
tmux bind-key -T copy-mode-vi S switch-client -T copytk