Allow setting the number of context lines in diff.conf
This commit is contained in:
parent
9bf2087b55
commit
196bd9c22b
@ -49,6 +49,7 @@ def syntax_aliases(raw):
|
|||||||
|
|
||||||
type_map = {
|
type_map = {
|
||||||
'syntax_aliases': syntax_aliases,
|
'syntax_aliases': syntax_aliases,
|
||||||
|
'num_context_lines': int,
|
||||||
}
|
}
|
||||||
|
|
||||||
for name in (
|
for name in (
|
||||||
|
|||||||
@ -9,6 +9,9 @@ syntax_aliases pyj:py recipe:py
|
|||||||
# for a list of schemes.
|
# for a list of schemes.
|
||||||
pygments_style default
|
pygments_style default
|
||||||
|
|
||||||
|
# The number of lines of context to show around each change.
|
||||||
|
num_context_lines 3
|
||||||
|
|
||||||
# Colors
|
# Colors
|
||||||
foreground black
|
foreground black
|
||||||
background white
|
background white
|
||||||
|
|||||||
@ -50,7 +50,9 @@ class DiffHandler(Handler):
|
|||||||
self.report_traceback_on_exit = None
|
self.report_traceback_on_exit = None
|
||||||
self.args = args
|
self.args = args
|
||||||
self.scroll_pos = self.max_scroll_pos = 0
|
self.scroll_pos = self.max_scroll_pos = 0
|
||||||
self.current_context_count = self.args.context
|
self.current_context_count = self.original_context_count = self.args.context
|
||||||
|
if self.current_context_count < 0:
|
||||||
|
self.current_context_count = self.original_context_count = self.opts.num_context_lines
|
||||||
self.highlighting_done = False
|
self.highlighting_done = False
|
||||||
self.restore_position = None
|
self.restore_position = None
|
||||||
|
|
||||||
@ -185,7 +187,7 @@ class DiffHandler(Handler):
|
|||||||
if text == 'a':
|
if text == 'a':
|
||||||
new_ctx = 100000
|
new_ctx = 100000
|
||||||
elif text == '=':
|
elif text == '=':
|
||||||
new_ctx = 3
|
new_ctx = self.original_context_count
|
||||||
else:
|
else:
|
||||||
new_ctx += (-1 if text == '-' else 1) * 5
|
new_ctx += (-1 if text == '-' else 1) * 5
|
||||||
self.change_context_count(new_ctx)
|
self.change_context_count(new_ctx)
|
||||||
@ -270,8 +272,9 @@ class DiffHandler(Handler):
|
|||||||
OPTIONS = partial('''\
|
OPTIONS = partial('''\
|
||||||
--context
|
--context
|
||||||
type=int
|
type=int
|
||||||
default=3
|
default=-1
|
||||||
Number of lines of context to show between changes.
|
Number of lines of context to show between changes. Negative values
|
||||||
|
use the number set in diff.conf
|
||||||
|
|
||||||
|
|
||||||
--config
|
--config
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user