Skip to content

Commit

Permalink
Merge branch 'wavexx-skip_to_value_change'
Browse files Browse the repository at this point in the history
Closes #110
  • Loading branch information
firecat53 committed Feb 11, 2015
2 parents 6249938 + 76bbb7d commit 7a0fba2
Show file tree
Hide file tree
Showing 2 changed files with 35 additions and 0 deletions.
4 changes: 4 additions & 0 deletions README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -141,4 +141,8 @@ Keybindings:
**[num]c** Toggle variable column width mode (mode/max),
or set width to [num]
**[num]C** Maximize current column, or set width to [num]
**[num][** Skip to (nth) change in row value (backward)
**[num]]** Skip to (nth) change in row value (forward)
**[num]{** Skip to (nth) change in column value (backward)
**[num]}** Skip to (nth) change in column value (forward)
========================== =================================================
31 changes: 31 additions & 0 deletions tabview/tabview.py
Original file line number Diff line number Diff line change
Expand Up @@ -554,6 +554,10 @@ def define_keys(self):
'r': self.reload,
'c': self.toggle_column_width,
'C': self.set_current_column_width,
']': self.skip_to_row_change,
'[': self.skip_to_row_change_reverse,
'}': self.skip_to_col_change,
'{': self.skip_to_col_change_reverse,
'?': self.help,
curses.KEY_F1: self.help,
curses.KEY_UP: self.up,
Expand Down Expand Up @@ -858,6 +862,33 @@ def _get_column_widths_max(self, d):
return [max(1, min(250, max(set(self._cell_len(j) for j in i))))
for i in d]

def _skip_to_value_change(self, x_inc, y_inc):
m = self.consume_modifier()
for _ in range(m):
x = self.win_x + self.x
y = self.win_y + self.y
v = self.data[y][x]
y += y_inc
x += x_inc
while y >= 0 and y < len(self.data) \
and x >= 0 and x < self.num_data_columns \
and self.data[y][x] == v:
y += y_inc
x += x_inc
self.goto_yx(y + 1, x + 1)

def skip_to_row_change(self):
self._skip_to_value_change(0, 1)

def skip_to_row_change_reverse(self):
self._skip_to_value_change(0, -1)

def skip_to_col_change(self):
self._skip_to_value_change(1, 0)

def skip_to_col_change_reverse(self):
self._skip_to_value_change(-1, 0)


def csv_sniff(data, enc):
"""Given a list, sniff the dialect of the data and return it.
Expand Down

0 comments on commit 7a0fba2

Please sign in to comment.