@@ -1139,6 +1139,122 @@ def enter(self) -> Pane:
11391139 self .cmd ("send-keys" , "Enter" )
11401140 return self
11411141
1142+ def display_popup (
1143+ self ,
1144+ command : str | None = None ,
1145+ * ,
1146+ close_on_exit : bool | None = None ,
1147+ close_on_success : bool | None = None ,
1148+ width : int | str | None = None ,
1149+ height : int | str | None = None ,
1150+ start_directory : StrPath | None = None ,
1151+ title : str | None = None ,
1152+ border_lines : str | None = None ,
1153+ border_style : str | None = None ,
1154+ environment : dict [str , str ] | None = None ,
1155+ ) -> None :
1156+ """Display a popup overlay via ``$ tmux display-popup``.
1157+
1158+ Requires tmux 3.2+.
1159+
1160+ Parameters
1161+ ----------
1162+ command : str, optional
1163+ Shell command to run in the popup.
1164+ close_on_exit : bool, optional
1165+ Close popup when command exits (``-E`` flag).
1166+ close_on_success : bool, optional
1167+ Close popup only on success exit (``-C`` flag).
1168+ width : int or str, optional
1169+ Popup width (``-w`` flag).
1170+ height : int or str, optional
1171+ Popup height (``-h`` flag).
1172+ start_directory : str or PathLike, optional
1173+ Working directory (``-d`` flag).
1174+ title : str, optional
1175+ Popup title (``-T`` flag). Requires tmux 3.3+.
1176+ border_lines : str, optional
1177+ Border line style (``-b`` flag). Requires tmux 3.3+.
1178+ border_style : str, optional
1179+ Border style (``-s`` flag). Requires tmux 3.3+.
1180+ environment : dict, optional
1181+ Environment variables (``-e`` flag). Requires tmux 3.3+.
1182+
1183+ .. versionadded:: 0.45
1184+
1185+ Examples
1186+ --------
1187+ >>> hasattr(pane, 'display_popup')
1188+ True
1189+ """
1190+ import warnings
1191+
1192+ from libtmux .common import has_gte_version
1193+
1194+ tmux_args : tuple [str , ...] = ()
1195+
1196+ if close_on_exit :
1197+ tmux_args += ("-E" ,)
1198+
1199+ if close_on_success :
1200+ tmux_args += ("-C" ,)
1201+
1202+ if width is not None :
1203+ tmux_args += ("-w" , str (width ))
1204+
1205+ if height is not None :
1206+ tmux_args += ("-h" , str (height ))
1207+
1208+ if start_directory is not None :
1209+ start_path = pathlib .Path (start_directory ).expanduser ()
1210+ tmux_args += ("-d" , str (start_path ))
1211+
1212+ # 3.3+ flags
1213+ if title is not None :
1214+ if has_gte_version ("3.3" , tmux_bin = self .server .tmux_bin ):
1215+ tmux_args += ("-T" , title )
1216+ else :
1217+ warnings .warn (
1218+ "title requires tmux 3.3+, ignoring" ,
1219+ stacklevel = 2 ,
1220+ )
1221+
1222+ if border_lines is not None :
1223+ if has_gte_version ("3.3" , tmux_bin = self .server .tmux_bin ):
1224+ tmux_args += ("-b" , border_lines )
1225+ else :
1226+ warnings .warn (
1227+ "border_lines requires tmux 3.3+, ignoring" ,
1228+ stacklevel = 2 ,
1229+ )
1230+
1231+ if border_style is not None :
1232+ if has_gte_version ("3.3" , tmux_bin = self .server .tmux_bin ):
1233+ tmux_args += ("-s" , border_style )
1234+ else :
1235+ warnings .warn (
1236+ "border_style requires tmux 3.3+, ignoring" ,
1237+ stacklevel = 2 ,
1238+ )
1239+
1240+ if environment :
1241+ if has_gte_version ("3.3" , tmux_bin = self .server .tmux_bin ):
1242+ for k , v in environment .items ():
1243+ tmux_args += ("-e" , f"{ k } ={ v } " )
1244+ else :
1245+ warnings .warn (
1246+ "environment requires tmux 3.3+, ignoring" ,
1247+ stacklevel = 2 ,
1248+ )
1249+
1250+ if command is not None :
1251+ tmux_args += (command ,)
1252+
1253+ proc = self .cmd ("display-popup" , * tmux_args )
1254+
1255+ if proc .stderr :
1256+ raise exc .LibTmuxException (proc .stderr )
1257+
11421258 def paste_buffer (
11431259 self ,
11441260 * ,
0 commit comments