Skip to content

Commit

Permalink
Swap highlight theme to default and default to legacy
Browse files Browse the repository at this point in the history
  • Loading branch information
ymattw committed Nov 10, 2024
1 parent 1c724af commit 53382e6
Show file tree
Hide file tree
Showing 11 changed files with 46 additions and 46 deletions.
13 changes: 6 additions & 7 deletions README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -24,15 +24,15 @@ Theme ``default``:
:align: center
:height: 300 px

Theme ``highlight``:
Theme ``legacy``:

.. image:: https://github.com/ymattw/ydiff/blob/master/img/side-by-side-highlight.png
:alt: side by side, theme 'highlight'
.. image:: https://github.com/ymattw/ydiff/blob/master/img/side-by-side-legacy.png
:alt: side by side, theme 'legacy'
:align: center
:height: 300 px

.. image:: https://github.com/ymattw/ydiff/blob/master/img/unified-highlight.png
:alt: unified, theme 'highlight'
.. image:: https://github.com/ymattw/ydiff/blob/master/img/unified-legacy.png
:alt: unified, theme 'legacy'
:align: center
:height: 300 px

Expand Down Expand Up @@ -157,8 +157,7 @@ Type ``ydiff -h`` to show usage::
pager application to feed output to, default is 'less'
-o OPT, --pager-options=OPT
options to supply to pager application
--theme=THEME option to pick a color theme (one of default,
highlight)
--theme=THEME option to pick a color theme (one of default, legacy)

Note:
Option parser will stop on first unknown option and pass them down to
Expand Down
Binary file modified img/side-by-side-default.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file removed img/side-by-side-highlight.png
Binary file not shown.
Binary file added img/side-by-side-legacy.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified img/unified-default.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file removed img/unified-highlight.png
Binary file not shown.
Binary file added img/unified-legacy.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
8 changes: 4 additions & 4 deletions tests/README
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@

unset YDIFF_OPTIONS

../../ydiff.py -c always -u < in.diff > out.unified
../../ydiff.py -c always -w80 --nowrap < in.diff > out.side-by-side
../../ydiff.py -c always -w70 --nowrap < in.diff > out.w70.nowrap
../../ydiff.py -c always -w70 --wrap < in.diff > out.w70.wrap
../../ydiff.py -c always --theme legacy -u < in.diff > out.unified
../../ydiff.py -c always --theme legacy -w80 --nowrap < in.diff > out.side-by-side
../../ydiff.py -c always --theme legacy -w70 --nowrap < in.diff > out.w70.nowrap
../../ydiff.py -c always --theme legacy -w70 --wrap < in.diff > out.w70.wrap
18 changes: 9 additions & 9 deletions tests/regression.sh
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ function cmp_output()
local ydiff_opt=${3:-""}
local cmd

cmd=$(printf "%-7s $YDIFF %-24s < %-30s " $PYTHON "$ydiff_opt" "$input")
cmd=$(printf "%-7s $YDIFF %-38s < %-30s " $PYTHON "$ydiff_opt" "$input")
printf "$cmd"

if [[ $TRAVIS_OS_NAME == windows ]]; then
Expand All @@ -60,14 +60,14 @@ function main()
for d in tests/*/; do
d=${d%/}
[[ -f $d/in.diff ]] || continue
cmp_output $d/in.diff $d/out.unified "-c always -u" || ((e++))
cmp_output $d/in.diff $d/out.side-by-side "-c always -w80 --nowrap" || ((e++))
cmp_output $d/in.diff $d/out.w70.nowrap "-c always -w70 --nowrap" || ((e++))
cmp_output $d/in.diff $d/out.w70.wrap "-c always -w70" || ((e++))
cmp_output $d/in.diff $d/in.diff "-c auto -u" || ((e++))
cmp_output $d/in.diff $d/in.diff "-c auto -w80" || ((e++))
cmp_output $d/in.diff $d/in.diff "-c auto -w70 --no-wrap" || ((e++))
cmp_output $d/in.diff $d/in.diff "-c auto -w70" || ((e++))
cmp_output $d/in.diff $d/out.unified "--theme=legacy -c always -u" || ((e++))
cmp_output $d/in.diff $d/out.side-by-side "--theme=legacy -c always -w80 --nowrap" || ((e++))
cmp_output $d/in.diff $d/out.w70.nowrap "--theme=legacy -c always -w70 --nowrap" || ((e++))
cmp_output $d/in.diff $d/out.w70.wrap "--theme=legacy -c always -w70" || ((e++))
cmp_output $d/in.diff $d/in.diff "--theme=legacy -c auto -u" || ((e++))
cmp_output $d/in.diff $d/in.diff "--theme=legacy -c auto -w80" || ((e++))
cmp_output $d/in.diff $d/in.diff "--theme=legacy -c auto -w70 --no-wrap" || ((e++))
cmp_output $d/in.diff $d/in.diff "--theme=legacy -c auto -w70" || ((e++))
(( total += 8 ))
done

Expand Down
19 changes: 10 additions & 9 deletions tests/test_ydiff.py
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,7 @@ def _init_diff(self):
def test_markup_traditional_hunk_header(self):
hunk = ydiff.Hunk(['hunk header\n'], '@@ -0 +0 @@\n', (0, 0), (0, 0))
diff = ydiff.UnifiedDiff([], '--- old\n', '+++ new\n', [hunk])
marker = ydiff.DiffMarker()
marker = ydiff.DiffMarker(theme='legacy')

out = list(marker.markup(diff))
self.assertEqual(len(out), 4)
Expand All @@ -116,7 +116,7 @@ def test_markup_traditional_old_changed(self):
hunk = ydiff.Hunk([], '@@ -1 +0,0 @@\n', (1, 0), (0, 0))
hunk.append(('-', 'spam\n'))
diff = ydiff.UnifiedDiff([], '--- old\n', '+++ new\n', [hunk])
marker = ydiff.DiffMarker()
marker = ydiff.DiffMarker(theme='legacy')

out = list(marker.markup(diff))
self.assertEqual(len(out), 4)
Expand All @@ -130,7 +130,7 @@ def test_markup_traditional_new_changed(self):
hunk = ydiff.Hunk([], '@@ -0,0 +1 @@\n', (0, 0), (1, 0))
hunk.append(('+', 'spam\n'))
diff = ydiff.UnifiedDiff([], '--- old\n', '+++ new\n', [hunk])
marker = ydiff.DiffMarker()
marker = ydiff.DiffMarker(theme='legacy')

out = list(marker.markup(diff))
self.assertEqual(len(out), 4)
Expand All @@ -146,7 +146,7 @@ def test_markup_traditional_both_changed(self):
hunk.append(('+', 'hell+\n'))
hunk.append((' ', 'common\n'))
diff = ydiff.UnifiedDiff([], '--- old\n', '+++ new\n', [hunk])
marker = ydiff.DiffMarker()
marker = ydiff.DiffMarker(theme='legacy')

out = list(marker.markup(diff))
self.assertEqual(len(out), 6)
Expand All @@ -166,7 +166,7 @@ def test_markup_traditional_both_changed(self):

def test_markup_side_by_side_padded(self):
diff = self._init_diff()
marker = ydiff.DiffMarker(side_by_side=True, width=7)
marker = ydiff.DiffMarker(side_by_side=True, width=7, theme='legacy')

out = list(marker.markup(diff))
self.assertEqual(len(out), 11)
Expand Down Expand Up @@ -220,7 +220,7 @@ def test_markup_side_by_side_padded(self):
# This test is not valid anymore
def __test_markup_side_by_side_neg_width(self):
diff = self._init_diff()
marker = ydiff.DiffMarker(side_by_side=True, width=-1)
marker = ydiff.DiffMarker(side_by_side=True, width=-1, theme='legacy')
out = list(marker.markup(diff))
self.assertEqual(len(out), 11)

Expand Down Expand Up @@ -264,7 +264,7 @@ def __test_markup_side_by_side_neg_width(self):

def test_markup_side_by_side_off_by_one(self):
diff = self._init_diff()
marker = ydiff.DiffMarker(side_by_side=True, width=6)
marker = ydiff.DiffMarker(side_by_side=True, width=6, theme='legacy')
out = list(marker.markup(diff))
self.assertEqual(len(out), 11)

Expand Down Expand Up @@ -315,7 +315,7 @@ def test_markup_side_by_side_off_by_one(self):

def test_markup_side_by_side_wrapped(self):
diff = self._init_diff()
marker = ydiff.DiffMarker(side_by_side=True, width=5)
marker = ydiff.DiffMarker(side_by_side=True, width=5, theme='legacy')
out = list(marker.markup(diff))
self.assertEqual(len(out), 11)

Expand Down Expand Up @@ -367,7 +367,8 @@ def test_markup_side_by_side_wrapped(self):

def test_markup_side_by_side_tabbed(self):
diff = self._init_diff()
marker = ydiff.DiffMarker(side_by_side=True, width=8, tab_width=2)
marker = ydiff.DiffMarker(side_by_side=True, width=8, tab_width=2,
theme='legacy')
out = list(marker.markup(diff))
self.assertEqual(len(out), 11)

Expand Down
34 changes: 17 additions & 17 deletions ydiff.py
Original file line number Diff line number Diff line change
Expand Up @@ -54,36 +54,36 @@ class Color(object):
'default': {
# kind: (effects,)
'header': (Color.FG_CYAN,),
'old_path': (Color.FG_YELLOW,),
'new_path': (Color.FG_YELLOW,),
'old_path': (Color.BG8_DARK_RED,),
'new_path': (Color.BG8_DARK_GREEN,),
'hunk_header': (Color.FG_CYAN,),
'hunk_meta': (Color.FG_BLUE,),
'common_line': (Color.RESET,),
'old_line': (Color.FG_RED,),
'new_line': (Color.FG_GREEN,),
'deleted_text': (Color.REVERSE, Color.FG_RED,),
'inserted_text': (Color.REVERSE, Color.FG_GREEN,),
'replaced_old_text': (Color.REVERSE, Color.FG_RED,),
'replaced_new_text': (Color.REVERSE, Color.FG_GREEN,),
'old_line': (Color.BG8_DARK_RED,),
'new_line': (Color.BG8_DARK_GREEN,),
'deleted_text': (Color.BG8_RED,),
'inserted_text': (Color.FG8_GRAY, Color.BG8_GREEN,),
'replaced_old_text': (Color.BG8_RED,),
'replaced_new_text': (Color.FG8_GRAY, Color.BG8_GREEN,),
'old_line_number': (Color.FG_YELLOW,),
'new_line_number': (Color.FG_YELLOW,),
'file_separator': (Color.FG_BRIGHT_CYAN,),
'wrap_marker': (Color.FG_BRIGHT_MAGENTA,),
},
'highlight': {
'legacy': {
# kind: (effects,)
'header': (Color.FG_CYAN,),
'old_path': (Color.BG8_DARK_RED,),
'new_path': (Color.BG8_DARK_GREEN,),
'old_path': (Color.FG_YELLOW,),
'new_path': (Color.FG_YELLOW,),
'hunk_header': (Color.FG_CYAN,),
'hunk_meta': (Color.FG_BLUE,),
'common_line': (Color.RESET,),
'old_line': (Color.BG8_DARK_RED,),
'new_line': (Color.BG8_DARK_GREEN,),
'deleted_text': (Color.BG8_RED,),
'inserted_text': (Color.FG8_GRAY, Color.BG8_GREEN,),
'replaced_old_text': (Color.BG8_RED,),
'replaced_new_text': (Color.FG8_GRAY, Color.BG8_GREEN,),
'old_line': (Color.FG_RED,),
'new_line': (Color.FG_GREEN,),
'deleted_text': (Color.REVERSE, Color.FG_RED,),
'inserted_text': (Color.REVERSE, Color.FG_GREEN,),
'replaced_old_text': (Color.REVERSE, Color.FG_RED,),
'replaced_new_text': (Color.REVERSE, Color.FG_GREEN,),
'old_line_number': (Color.FG_YELLOW,),
'new_line_number': (Color.FG_YELLOW,),
'file_separator': (Color.FG_BRIGHT_CYAN,),
Expand Down

0 comments on commit 53382e6

Please sign in to comment.