@@ -22,36 +22,32 @@ def _initialize():
2222 class ShellIntegrationSequence :
2323 soh = "\001 "
2424 stx = "\002 "
25-
26- @staticmethod
27- def _create (code : str , * arguments : object ) -> str :
28- parameters = "" .join (f";{ argument } " for argument in arguments )
29- return f"\x1b ]633;{ code } { parameters } \x07 "
25+ template = "\x1b ]633;{}\x07 "
3026
3127 # Before the prompt (>>>) is displayed
3228 @classmethod
3329 def prompt_start (cls ) -> str :
34- return cls ._create ("A" )
30+ return cls .template . format ("A" )
3531
3632 # After the prompt (>>>) is displayed
3733 @classmethod
3834 def prompt_end (cls ) -> str :
39- return cls ._create ("B" )
35+ return cls .template . format ("B" )
4036
4137 # After the user has typed a command but before it is executed
4238 @classmethod
4339 def pre_execution (cls ) -> str :
44- return cls ._create ("C" )
40+ return cls .template . format ("C" )
4541
4642 @classmethod
4743 def execution_finished (cls , exit_code : int ) -> str :
4844 """Mark execution as finished with its exit code."""
49- return cls ._create ( "D" , exit_code )
45+ return cls .template . format ( f"D; { exit_code } " )
5046
5147 @classmethod
5248 def command_line (cls , command : object ) -> str :
5349 """Explicitly set the command line interpreted by the shell."""
54- return cls ._create ( "E" , command )
50+ return cls .template . format ( f"E; { command } " )
5551
5652 class REPLHooks :
5753 def __init__ (self ):
0 commit comments