@@ -820,55 +820,6 @@ def title(self) -> str:
820820 def __repr__ (self ) -> str :
821821 return f'Window(title={ self .title } , id={ self .id } )'
822822
823- def as_dict (self , is_focused : bool = False , is_self : bool = False , is_active : bool = False ) -> WindowDict :
824- return {
825- 'id' : self .id ,
826- 'is_focused' : is_focused ,
827- 'is_active' : is_active ,
828- 'title' : self .title ,
829- 'pid' : self .child .pid ,
830- 'cwd' : self .child .current_cwd or self .child .cwd ,
831- 'cmdline' : self .child .cmdline ,
832- 'last_reported_cmdline' : self .last_cmd_cmdline ,
833- 'last_cmd_exit_status' : self .last_cmd_exit_status ,
834- 'env' : self .child .environ or self .child .final_env ,
835- 'foreground_processes' : self .child .foreground_processes ,
836- 'is_self' : is_self ,
837- 'at_prompt' : self .at_prompt ,
838- 'lines' : self .screen .lines ,
839- 'columns' : self .screen .columns ,
840- 'user_vars' : self .user_vars ,
841- 'created_at' : self .created_at ,
842- 'in_alternate_screen' : self .screen .is_using_alternate_linebuf (),
843- }
844-
845- def serialize_state (self ) -> dict [str , Any ]:
846- ans = {
847- 'version' : 1 ,
848- 'id' : self .id ,
849- 'child_title' : self .child_title ,
850- 'override_title' : self .override_title ,
851- 'default_title' : self .default_title ,
852- 'title_stack' : list (self .title_stack ),
853- 'allow_remote_control' : self .allow_remote_control ,
854- 'remote_control_passwords' : self .remote_control_passwords ,
855- 'cwd' : self .child .current_cwd or self .child .cwd ,
856- 'env' : self .child .environ ,
857- 'cmdline' : self .child .cmdline ,
858- 'last_reported_cmdline' : self .last_cmd_cmdline ,
859- 'last_cmd_exit_status' : self .last_cmd_exit_status ,
860- 'margin' : self .margin .serialize (),
861- 'user_vars' : self .user_vars ,
862- 'padding' : self .padding .serialize (),
863- }
864- if self .window_custom_type :
865- ans ['window_custom_type' ] = self .window_custom_type
866- if self .overlay_type is not OverlayType .transient :
867- ans ['overlay_type' ] = self .overlay_type .value
868- if self .user_vars :
869- ans ['user_vars' ] = self .user_vars
870- return ans
871-
872823 @property
873824 def overlay_parent (self ) -> Optional ['Window' ]:
874825 tab = self .tabref ()
@@ -1957,6 +1908,56 @@ def current_mouse_position(self) -> Optional['MousePosition']:
19571908 ' Return the last position at which a mouse event was received by this window '
19581909 return get_mouse_data_for_window (self .os_window_id , self .tab_id , self .id )
19591910
1911+ # Serialization {{{
1912+ def as_dict (self , is_focused : bool = False , is_self : bool = False , is_active : bool = False ) -> WindowDict :
1913+ return {
1914+ 'id' : self .id ,
1915+ 'is_focused' : is_focused ,
1916+ 'is_active' : is_active ,
1917+ 'title' : self .title ,
1918+ 'pid' : self .child .pid ,
1919+ 'cwd' : self .child .current_cwd or self .child .cwd ,
1920+ 'cmdline' : self .child .cmdline ,
1921+ 'last_reported_cmdline' : self .last_cmd_cmdline ,
1922+ 'last_cmd_exit_status' : self .last_cmd_exit_status ,
1923+ 'env' : self .child .environ or self .child .final_env ,
1924+ 'foreground_processes' : self .child .foreground_processes ,
1925+ 'is_self' : is_self ,
1926+ 'at_prompt' : self .at_prompt ,
1927+ 'lines' : self .screen .lines ,
1928+ 'columns' : self .screen .columns ,
1929+ 'user_vars' : self .user_vars ,
1930+ 'created_at' : self .created_at ,
1931+ 'in_alternate_screen' : self .screen .is_using_alternate_linebuf (),
1932+ }
1933+
1934+ def serialize_state (self ) -> dict [str , Any ]:
1935+ ans = {
1936+ 'version' : 1 ,
1937+ 'id' : self .id ,
1938+ 'child_title' : self .child_title ,
1939+ 'override_title' : self .override_title ,
1940+ 'default_title' : self .default_title ,
1941+ 'title_stack' : list (self .title_stack ),
1942+ 'allow_remote_control' : self .allow_remote_control ,
1943+ 'remote_control_passwords' : self .remote_control_passwords ,
1944+ 'cwd' : self .child .current_cwd or self .child .cwd ,
1945+ 'env' : self .child .environ ,
1946+ 'cmdline' : self .child .cmdline ,
1947+ 'last_reported_cmdline' : self .last_cmd_cmdline ,
1948+ 'last_cmd_exit_status' : self .last_cmd_exit_status ,
1949+ 'margin' : self .margin .serialize (),
1950+ 'user_vars' : self .user_vars ,
1951+ 'padding' : self .padding .serialize (),
1952+ }
1953+ if self .window_custom_type :
1954+ ans ['window_custom_type' ] = self .window_custom_type
1955+ if self .overlay_type is not OverlayType .transient :
1956+ ans ['overlay_type' ] = self .overlay_type .value
1957+ if self .user_vars :
1958+ ans ['user_vars' ] = self .user_vars
1959+ return ans
1960+
19601961 @property
19611962 def cwd_for_serialization (self ) -> str :
19621963 cwd = self .get_cwd_of_child (oldest = False ) or self .get_cwd_of_child (oldest = True ) or self .child .cwd
@@ -2055,7 +2056,7 @@ def make_exe_absolute(cmd: list[str], pid: int) -> None:
20552056 ans .insert (1 , unserialize_launch_flag + json .dumps (unserialize_data ))
20562057 ans .extend (cmd )
20572058 return ans
2058-
2059+ # }}}
20592060
20602061 # actions {{{
20612062
0 commit comments