@@ -12,10 +12,12 @@ class DiffApp(App):
1212 BINDINGS = [
1313 ("space" , "toggle('split')" , "Toggle split" ),
1414 ("a" , "toggle('annotations')" , "Toggle annotations" ),
15+ ("w" , "toggle('wrap')" , "Toggle wrap" ),
1516 ]
1617
1718 split = var (True )
1819 annotations = var (True )
20+ wrap = var (True )
1921
2022 def __init__ (self , original : str , modified : str ) -> None :
2123 self .original = original
@@ -28,19 +30,27 @@ def compose(self) -> ComposeResult:
2830
2931 async def on_mount (self ) -> None :
3032 try :
31- diff_view = await DiffView .load (self .original , self .modified )
33+ diff_view = await DiffView .load (
34+ self .original ,
35+ self .modified ,
36+ split = self .split ,
37+ annotations = self .annotations ,
38+ wrap = self .wrap ,
39+ )
3240 except LoadError as error :
3341 self .notify (str (error ), title = "Failed to load code" , severity = "error" )
3442 else :
35- diff_view .data_bind (DiffApp .split , DiffApp .annotations )
43+ diff_view .data_bind (DiffApp .split , DiffApp .annotations , DiffApp . wrap )
3644 await self .query_one ("#diff-container" ).mount (diff_view )
3745
3846
3947if __name__ == "__main__" :
4048 import sys
4149
4250 if len (sys .argv ) != 3 :
43- print ("Usage python tdiff.py PATH1 PATH2\n Try: python tdiff.py example1.rs example2.rs" )
51+ print (
52+ "Usage python tdiff.py PATH1 PATH2\n Try: python tdiff.py example1.rs example2.rs"
53+ )
4454 else :
4555 app = DiffApp (sys .argv [1 ], sys .argv [2 ])
4656 app .run ()
0 commit comments