def display_edited_lines():
	diffmodel = FakeDiffModel()
	diffmodel.lines = [
		DiffLine( "left 01", "right 01", difflinetypes.DIFFERENT, False, True ),
		DiffLine( "left 02", "right 02", difflinetypes.DIFFERENT, True,  True ),
		DiffLine( "left 03", "right 03", difflinetypes.DIFFERENT, True, False ),
		DiffLine( "line 04", "line 04",  difflinetypes.IDENTICAL, False, True ),
		DiffLine( "line 05", "line 05",  difflinetypes.IDENTICAL, True,  True ),
		DiffLine( "line 06", "line 06",  difflinetypes.IDENTICAL, True, False ),
	]

	view = NCursesView( diffmodel )
	view.win_width  = 40
	view.win_height = 6

	actions = []

	assert_strings_equal( view.show( actions )[0],
"""[di]left 01           [ei] * [e]right 01           
left 02           [ei] * [e]right 02           
left 03           [ei] * [d]right 03           
[n]line 04           [ei]   [e]line 04            
line 05           [ei]   [e]line 05            
line 06           [ei]   [n]line 06            
""" )
def down_emptyfile():
    diffmodel = FakeDiffModel()
    diffmodel.lines = [
        DiffLine(None, "line 1 here", difflinetypes.ADD),
        DiffLine(None, "line 2 here", difflinetypes.ADD),
    ]

    view = NCursesView(diffmodel)
    view.win_width = 40
    view.win_height = 3

    actions = [
        curses.KEY_DOWN,
        curses.KEY_DOWN,
        curses.KEY_DOWN,
        curses.KEY_DOWN,
        curses.KEY_DOWN,
        curses.KEY_DOWN,
        curses.KEY_DOWN,
        curses.KEY_DOWN,
        curses.KEY_DOWN,
        curses.KEY_DOWN,
        curses.KEY_DOWN,
    ]

    assert_strings_equal(
        view.show(actions)[0],
        """[m]..................[ai] + [a]line 1 here        
[mi]..................[ai] + [a]line 2 here        
[n]                                        
""",
    )
Пример #3
0
def differences():

	diffmodel = FakeDiffModel()
	diffmodel.lines = [
		DiffLine( "line 1 here", "line 1 here different",
			difflinetypes.DIFFERENT ),
		DiffLine( "line 2 here", "line 2 here different",
			difflinetypes.DIFFERENT ),
		]

	listview = ListView( diffmodel )

	listview.set_columns( 80 )

	assert_strings_equal( listview.get_string(),
"""line 1 here                            |  line 1 here different
line 2 here                            |  line 2 here different
""" )

	listview.set_columns( 60 )

	assert_strings_equal( listview.get_string(),
"""line 1 here                  |  line 1 here different
line 2 here                  |  line 2 here different
""" )
def _make_view():
	diffmodel = FakeDiffModel()
	diffmodel.lines = [
		DiffLine( "line 01", "line 01", difflinetypes.IDENTICAL ),
		DiffLine( "line 02", "line 02", difflinetypes.IDENTICAL ),
		DiffLine( "line 03", "line 03", difflinetypes.IDENTICAL ),
		DiffLine( "line 04", "line 04", difflinetypes.IDENTICAL ),
		DiffLine( "line 05", "line 05", difflinetypes.IDENTICAL ),
		DiffLine( "line 06", "line 06", difflinetypes.IDENTICAL ),
		DiffLine( "line 07", "line 07", difflinetypes.IDENTICAL ),
		DiffLine( "line 08", "line 08", difflinetypes.IDENTICAL ),
		DiffLine( "line 09", "line 09", difflinetypes.IDENTICAL ),
		DiffLine( "line 10", "line 10 different", difflinetypes.DIFFERENT ),
		DiffLine( "line 11", "line 11 different", difflinetypes.DIFFERENT ),
		DiffLine( "line 12", "line 12", difflinetypes.IDENTICAL ),
		DiffLine( "line 13", "line 13", difflinetypes.IDENTICAL ),
		DiffLine( None,      "line 14", difflinetypes.ADD ),
		DiffLine( None,      "line 15", difflinetypes.ADD ),
	]

	view = NCursesView( diffmodel )
	view.win_width = 20
	view.win_height = 7

	return view
Пример #5
0
def mixture():

	diffmodel = FakeDiffModel()
	diffmodel.lines = [
		DiffLine( "line 1 here", "line 1 here", difflinetypes.IDENTICAL ),
		DiffLine( None, "line 2 here",
			difflinetypes.ADD ),
		DiffLine( "line 3 here", "line 3 here", difflinetypes.IDENTICAL ),
		DiffLine( "line 4 here", "line 4 here different",
			difflinetypes.DIFFERENT ),
		DiffLine( "line 5 here", None,
			difflinetypes.REMOVE ),
		DiffLine( "line 6 here", "line 6 here", difflinetypes.IDENTICAL ),
		]

	view = NCursesView( diffmodel )
	view.win_width  = 40
	view.win_height = 5

	actions = []

	assert_strings_equal( view.show( actions )[0],
"""[ni]line 1 here       [n]   line 1 here        
[m]..................[ai] + [a]line 2 here        
[n]line 3 here          line 3 here        
[d]line 4 here       [di] * [d]line 4 here differe
[r]line 5 here       [ri] - [m]...................
""" )
def _make_manydiffs_view():
	diffmodel = FakeDiffModel()
	diffmodel.lines = [
		DiffLine( "line 01", "line 01", difflinetypes.IDENTICAL ),
		DiffLine( "line 02", "diff 02", difflinetypes.DIFFERENT ),
		DiffLine( "line 03", "diff 03", difflinetypes.DIFFERENT ),
		DiffLine( "line 04", "diff 04", difflinetypes.DIFFERENT ),
		DiffLine( "line 05", "line 05", difflinetypes.IDENTICAL ),
		DiffLine( "line 06", "diff 06", difflinetypes.DIFFERENT ),
		DiffLine( "line 07", "line 07", difflinetypes.IDENTICAL ),
		DiffLine( "line 08", "diff 08", difflinetypes.DIFFERENT ),
		DiffLine( "line 09", "diff 09", difflinetypes.DIFFERENT ),
		DiffLine( "line 10", "diff 10", difflinetypes.DIFFERENT ),
		DiffLine( "line 11", "line 11", difflinetypes.IDENTICAL ),
		DiffLine( "line 12", "diff 12", difflinetypes.DIFFERENT ),
		DiffLine( "line 13", "line 13", difflinetypes.IDENTICAL ),
		DiffLine( "line 14", "line 14", difflinetypes.IDENTICAL ),
		DiffLine( "line 15", "line 15", difflinetypes.IDENTICAL ),
		DiffLine( "line 16", "line 16", difflinetypes.IDENTICAL ),
		DiffLine( "line 17", "line 17", difflinetypes.IDENTICAL ),
	]

	view = NCursesView( diffmodel )
	view.win_width = 20
	view.win_height = 10

	return view
def _make_view():
	diffmodel = FakeDiffModel()
	diffmodel.lines = [
		DiffLine( "line 1 here", "line 1 here", difflinetypes.IDENTICAL ),
	]

	view = NCursesView( diffmodel )
	view.win_width  = 80
	view.win_height = 20

	return view
def _make_short_diff_view():
    diffmodel = FakeDiffModel()
    diffmodel.lines = [
        DiffLine("line 01", "line 01", difflinetypes.IDENTICAL),
        DiffLine("line 02", "line 02", difflinetypes.IDENTICAL),
    ]

    view = NCursesView(diffmodel)
    view.win_width = 20
    view.win_height = 4

    return view
def default_message_at_start():

	diffmodel = FakeDiffModel()
	diffmodel.lines = []

	view = NCursesView( diffmodel )
	view.win_width  = 40
	view.win_height = 5

	actions = []

	assert_strings_equal( view.show( actions )[2],
"""[ni]         Press SHIFT-H for help         
""" )
def help():

	diffmodel = FakeDiffModel()
	diffmodel.lines = []

	view = NCursesView( diffmodel )
	view.win_width  = 40
	view.win_height = 40

	actions = [ "H" ]

	assert_strings_equal( view.show( actions )[2],
"""[ni]       Press any key to continue        
""" )
def header_long_names():

	diffmodel = FakeDiffModel()
	diffmodel.lines = []

	view = NCursesView( diffmodel,
		"dir1/dir2/dir3/dir4/dir5/file1.txt", "dira/dirb/dirc/dird/dire/file2.txt" )
	view.win_width  = 40
	view.win_height = 5

	actions = []

	assert_strings_equal( view.show( actions )[1],
"""[ni].../dir5/file1.txt   ...d/dire/file2.txt
""" )
def default_message_after_move():

	diffmodel = FakeDiffModel()
	diffmodel.lines = []

	filemanager = AlwaysSaveFileManager()
	view = NCursesView( diffmodel, None, None, filemanager )
	view.win_width  = 40
	view.win_height = 5

	actions = [ "s", "j" ]

	assert_strings_equal( view.show( actions )[2],
"""[ni]         Press SHIFT-H for help         
""" )
def no_need_to_save():

	diffmodel = FakeDiffModel()
	diffmodel.lines = []

	filemanager = NeverSaveFileManager()
	view = NCursesView( diffmodel, None, None, filemanager )
	view.win_width  = 40
	view.win_height = 5

	actions = [ "s" ]

	assert_strings_equal( view.show( actions )[2],
"""[mi]   No changes were made in this file.   
""" )
def file_saved():

	diffmodel = FakeDiffModel()
	diffmodel.lines = []

	filemanager = AlwaysSaveFileManager()
	view = NCursesView( diffmodel, None, None, filemanager )
	view.win_width  = 40
	view.win_height = 5

	actions = [ "s" ]

	assert_strings_equal( view.show( actions )[2],
"""[mi]              File saved.               
""" )
def header_short_names():

	diffmodel = FakeDiffModel()
	diffmodel.lines = []

	view = NCursesView( diffmodel,
		"dir1/file1.txt", "dir2/file2.txt" )
	view.win_width  = 40
	view.win_height = 5

	actions = []

	assert_strings_equal( view.show( actions )[1],
"""[ni]dir1/file1.txt       dir2/file2.txt     
""" )
def _make_wide_view():
    diffmodel = FakeDiffModel()
    diffmodel.lines = [
        DiffLine("0-23456789abcdef", "0-23456789abcdef", difflinetypes.IDENTICAL),
        DiffLine("1-23456789abcdef", "1-23456789abcdef plus extr", difflinetypes.DIFFERENT),
        DiffLine(None, "2-23456789abcdef plus extr", difflinetypes.ADD),
        DiffLine("3-23456789abcdef", None, difflinetypes.REMOVE),
        DiffLine("4-23456789abcdef", "4-23456789abcdef", difflinetypes.IDENTICAL),
        DiffLine("5-23456789abcdef", "5-23456789abcdef plus ext", difflinetypes.DIFFERENT),
    ]

    view = NCursesView(diffmodel)
    view.win_width = 23
    view.win_height = 2

    return view
Пример #17
0
def removes():

	diffmodel = FakeDiffModel()
	diffmodel.lines = [
		DiffLine( "line 1 here", None, difflinetypes.REMOVE ),
		DiffLine( "line 2 here", None, difflinetypes.REMOVE ),
		]

	listview = ListView( diffmodel )

	listview.set_columns( 80 )

	assert_strings_equal( listview.get_string(),
"""line 1 here                            <
line 2 here                            <
""" )
Пример #18
0
def adds():

	diffmodel = FakeDiffModel()
	diffmodel.lines = [
		DiffLine( None, "line 1 here", difflinetypes.ADD ),
		DiffLine( None, "line 2 here", difflinetypes.ADD ),
		]

	listview = ListView( diffmodel )

	listview.set_columns( 80 )

	assert_strings_equal( listview.get_string(),
"""                                       >  line 1 here
                                       >  line 2 here
""" )
Пример #19
0
def same():

	diffmodel = FakeDiffModel()
	diffmodel.lines = [
		DiffLine( "line 1 here", "line 1 here", difflinetypes.IDENTICAL ),
		DiffLine( "line 2 here", "line 2 here", difflinetypes.IDENTICAL ),
		]

	listview = ListView( diffmodel )

	listview.set_columns( 80 )

	assert_strings_equal( listview.get_string(),
"""line 1 here                               line 1 here
line 2 here                               line 2 here
""" )
Пример #20
0
def _make_static_diffmodel():
	staticdiffmodel = FakeDiffModel()
	staticdiffmodel.lines = [
		DiffLine( "line 1 here", "line 1 here", difflinetypes.IDENTICAL ),
		DiffLine( "line 2 here", "line 2 here", difflinetypes.IDENTICAL ),
		DiffLine( "line 3 here", "line 3 here", difflinetypes.IDENTICAL ),
		DiffLine( "line 4 here", "line 4 here", difflinetypes.IDENTICAL ),
		DiffLine( "line 5 here", "line 5 here different",
			difflinetypes.DIFFERENT ),
		DiffLine( "line 6 here", "line 6 here", difflinetypes.IDENTICAL ),
		DiffLine( "line 7 here", "line 7 here", difflinetypes.IDENTICAL ),
		DiffLine( "line 8 here", "line 8 here", difflinetypes.IDENTICAL ),
		DiffLine( "line 9 here", "line 9 here", difflinetypes.IDENTICAL ),
		DiffLine( "previous 10", "line 10 here", difflinetypes.DIFFERENT ),
		]

	return staticdiffmodel
def at_first_difference():

	diffmodel = FakeDiffModel()
	diffmodel.lines = [
		DiffLine( "line 01", "line 01", difflinetypes.IDENTICAL ),
		DiffLine( "line 02", "line 02", difflinetypes.DIFFERENT ),
		DiffLine( "line 03", "line 03", difflinetypes.IDENTICAL ),
	]

	view = NCursesView( diffmodel )
	view.win_width  = 40
	view.win_height = 5

	actions = [ "n", "p" ]

	assert_strings_equal( view.show( actions )[2],
"""[mi]          At first difference           
""" )
def _make_view():
	diffmodel = FakeDiffModel()
	diffmodel.lines = [
		DiffLine( "line 1 here", "line 1 here", difflinetypes.IDENTICAL ),
		DiffLine( "line 2 here", "line 2 here", difflinetypes.IDENTICAL ),
		DiffLine( "line 3 here", "line 3 here", difflinetypes.IDENTICAL ),
		DiffLine( "line 4 here", "line 4 here", difflinetypes.IDENTICAL ),
		DiffLine( "line 5 here", "line 5 here different",
			difflinetypes.DIFFERENT ),
		DiffLine( "line 6 here", "line 6 here", difflinetypes.IDENTICAL ),
		DiffLine( "line 7 here", "line 7 here", difflinetypes.IDENTICAL ),
		DiffLine( "line 8 here", "line 8 here", difflinetypes.IDENTICAL ),
		DiffLine( "line 9 here", "line 9 here", difflinetypes.IDENTICAL ),
		DiffLine( "line 10 here", "line 10 here", difflinetypes.IDENTICAL ),
		]

	view = NCursesView( diffmodel )
	view.win_width  = 40
	view.win_height = 5

	return view
Пример #23
0
def same():

	diffmodel = FakeDiffModel()
	diffmodel.lines = [
		DiffLine( "line 1 here", "line 1 here", difflinetypes.IDENTICAL ),
		DiffLine( "line 2 here", "line 2 here", difflinetypes.IDENTICAL ),
		]

	view = NCursesView( diffmodel )
	view.win_width  = 40
	view.win_height = 5

	actions = []

	assert_strings_equal( view.show( actions )[0],
"""[ni]line 1 here       [n]   line 1 here        
line 2 here          line 2 here        
                                        
                                        
                                        
""" )
Пример #24
0
def removes():

	diffmodel = FakeDiffModel()
	diffmodel.lines = [
		DiffLine( "line 1 here", None,
			difflinetypes.REMOVE ),
		DiffLine( "line 2 here", None,
			difflinetypes.REMOVE ),
		]

	view = NCursesView( diffmodel )
	view.win_width  = 39
	view.win_height = 5

	actions = []

	assert_strings_equal( view.show( actions )[0],
"""[ri]line 1 here        - [m]..................
[r]line 2 here       [ri] - [m]..................
[n]                                       
                                       
                                       
""" )
Пример #25
0
def differences():

	diffmodel = FakeDiffModel()
	diffmodel.lines = [
		DiffLine( "line 1 here", "line 1 here different",
			difflinetypes.DIFFERENT ),
		DiffLine( "line 2 here", "line 2 here different",
			difflinetypes.DIFFERENT ),
		]

	view = NCursesView( diffmodel )
	view.win_width  = 40
	view.win_height = 5

	actions = []

	assert_strings_equal( view.show( actions )[0],
"""[di]line 1 here        * [d]line 1 here differe
line 2 here       [di] * [d]line 2 here differe
[n]                                        
                                        
                                        
""" )
Пример #26
0
def adds():

	diffmodel = FakeDiffModel()
	diffmodel.lines = [
		DiffLine( None, "line 1 here",
			difflinetypes.ADD ),
		DiffLine( None, "line 2 here",
			difflinetypes.ADD ),
		]

	view = NCursesView( diffmodel )
	view.win_width  = 40
	view.win_height = 5

	actions = []

	assert_strings_equal( view.show( actions )[0],
"""[mi]..................[ai] + [a]line 1 here        
[m]..................[ai] + [a]line 2 here        
[n]                                        
                                        
                                        
""" )