@@ -85,12 +85,7 @@ def tmux(self, cmd, *args, **kwargs):
85
85
return self .server .tmux (cmd , * args , ** kwargs )
86
86
87
87
def select_layout (self , layout = None ):
88
- '''
89
- wrapper for ``tmux(1)``.
90
-
91
- .. code-block: bash
92
-
93
- $ tmux select-layout <layout>
88
+ """Wrapper for ``$ tmux select-layout <layout>``.
94
89
95
90
even-horizontal: Panes are spread out evenly from left to right across
96
91
the window.
@@ -111,8 +106,8 @@ def select_layout(self, layout=None):
111
106
112
107
:param layout: string of the layout, 'even-horizontal', 'tiled', etc.
113
108
:type layout: string
114
- '''
115
109
110
+ """
116
111
117
112
proc = self .tmux (
118
113
'select-layout' ,
@@ -123,21 +118,13 @@ def select_layout(self, layout=None):
123
118
if proc .stderr :
124
119
raise Exception (proc .stderr )
125
120
126
- @property
127
- def target (self ):
128
- return "%s:%s" % (self .session .get ('session_id' ), self .get ('window_id' ))
129
-
130
121
def set_window_option (self , option , value ):
131
- '''
132
- wrapper for ``tmux(1)``.
133
-
134
- .. code-block: bash
135
-
136
- $ tmux set-window-option <option> <value>
122
+ """Wrapper for ``$ tmux set-window-option <option> <value>``.
137
123
138
124
:param value: window value. True/False will turn in 'on' and 'off'.
139
125
:type value: string or bool
140
- '''
126
+
127
+ """
141
128
142
129
self .server ._update_windows ()
143
130
@@ -153,27 +140,30 @@ def set_window_option(self, option, value):
153
140
option , value
154
141
)
155
142
156
- # tmuxp set-window-option version 1.8 has a quirk where
157
- # -t@2 window id won't work as ``target-pane``.
158
-
159
143
if process .stderr :
160
144
if isinstance (process .stderr , list ) and len (process .stderr ) == int (1 ):
161
145
process .stderr = process .stderr [0 ]
162
146
raise ValueError (
163
- 'tmux set-window-option -t%s:%s %s %s\n ' % (self .get ('session_id' ), self .get ('window_index' ), option , value ) +
164
- process .stderr )
147
+ 'tmux set-window-option -t%s:%s %s %s\n ' % (
148
+ self .get ('session_id' ),
149
+ self .get ('window_index' ),
150
+ option ,
151
+ value
152
+ ) +
153
+ process .stderr
154
+ )
165
155
166
156
def show_window_options (self , option = None ):
167
- '''
168
- return a dict of options for the window.
157
+ """Return a dict of options for the window.
169
158
170
159
For familiarity with tmux, the option ``option`` param forwards to pick
171
160
a single option, forwarding to :meth:`Window.show_window_option`.
172
161
173
162
:param option: optional. show a single option.
174
163
:type option: string
175
164
:rtype: :py:obj:`dict`
176
- '''
165
+
166
+ """
177
167
178
168
if option :
179
169
return self .show_window_option (option )
@@ -193,15 +183,15 @@ def show_window_options(self, option=None):
193
183
return window_options
194
184
195
185
def show_window_option (self , option ):
196
- '''
197
- return a list of options for the window
186
+ """Return a list of options for the window.
198
187
199
188
todo: test and return True/False for on/off string
200
189
201
190
:param option: option to return.
202
191
:type option: string
203
192
:rtype: string, int
204
- '''
193
+
194
+ """
205
195
206
196
window_option = self .tmux (
207
197
'show-window-options' , option
@@ -219,20 +209,19 @@ def show_window_option(self, option):
219
209
return window_option [1 ]
220
210
221
211
def rename_window (self , new_name ):
222
- '''rename window and return new window object::
223
212
224
- $ tmux rename-window <new_name>
213
+ """Return :class:`Window` object `` $ tmux rename-window <new_name>``.
225
214
226
215
:param new_name: name of the window
227
216
:type new_name: string
228
- '''
217
+
218
+ """
229
219
# new_name = pipes.quote(new_name)
230
220
231
221
import shlex
232
222
lex = shlex .shlex (new_name )
233
223
lex .escape = ' '
234
224
lex .whitespace_split = False
235
- # new_name = '\ '.join(new_name.split())
236
225
237
226
try :
238
227
self .tmux (
@@ -248,12 +237,7 @@ def rename_window(self, new_name):
248
237
return self
249
238
250
239
def kill_window (self ):
251
- '''
252
- ``$ tmux kill-window``
253
-
254
- Kill the current :class:`Window` object.
255
-
256
- '''
240
+ """Kill the current :class:`Window` object. ``$ tmux kill-window``."""
257
241
258
242
proc = self .tmux (
259
243
'kill-window' ,
@@ -267,15 +251,13 @@ def kill_window(self):
267
251
self .server ._update_windows ()
268
252
269
253
def move_window (self , destination ):
270
- '''
271
- ``$ tmux move-window``
272
-
273
- move the current :class:`Window` object.
254
+ """Move the current :class:`Window` object ``$ tmux move-window``.
274
255
275
256
:param destination: the ``target window`` or index to move the window
276
257
to.
277
258
:type target_window: string
278
- '''
259
+
260
+ """
279
261
280
262
proc = self .tmux (
281
263
'move-window' ,
@@ -289,15 +271,14 @@ def move_window(self, destination):
289
271
self .server ._update_windows ()
290
272
291
273
def select_pane (self , target_pane ):
292
- '''
293
- ``$ tmux select-pane``
274
+ """Return selected :class:`Pane` through ``$ tmux select-pane``.
294
275
295
276
:param target_pane: ``target_pane``, or ``-U``,``-D``, ``-L``, ``-R``
296
277
or ``-l``.
297
278
:type target_pane: string
298
279
:rtype: :class:`Pane`
299
280
300
- '''
281
+ """
301
282
302
283
if target_pane in ['-l' , '-U' , '-D' , '-L' , '-R' ]:
303
284
proc = self .tmux ('select-pane' , '-t%s' % self .get ('window_id' ), target_pane )
@@ -310,8 +291,7 @@ def select_pane(self, target_pane):
310
291
return self .attached_pane ()
311
292
312
293
def split_window (self , attach = True ):
313
- '''
314
- Splits window. Returns the created :class:`Pane`.
294
+ """Split window and return the created :class:`Pane`.
315
295
316
296
.. note::
317
297
@@ -332,7 +312,8 @@ def split_window(self, attach=True):
332
312
:param type: bool
333
313
334
314
:rtype: :class:`Pane`
335
- '''
315
+
316
+ """
336
317
337
318
pformats = ['session_name' , 'session_id' ,
338
319
'window_index' , 'window_id' ] + formats .PANE_FORMATS
@@ -372,11 +353,11 @@ def split_window(self, attach=True):
372
353
return Pane (window = self , ** pane )
373
354
374
355
def attached_pane (self ):
375
- '''
376
- Return the attached :class:`Pane`.
356
+ """Return the attached :class:`Pane`.
377
357
378
358
:rtype: :class:`Pane`
379
- '''
359
+
360
+ """
380
361
for pane in self ._panes :
381
362
if 'pane_active' in pane :
382
363
# for now pane_active is a unicode
@@ -404,10 +385,11 @@ def _panes(self):
404
385
return self ._list_panes ()
405
386
406
387
def list_panes (self ):
407
- ''' Return list of :class:`Pane` for the window.
388
+ """ Return list of :class:`Pane` for the window.
408
389
409
390
:rtype: list of :class:`Pane`
410
- '''
391
+
392
+ """
411
393
412
394
return [Pane (window = self , ** pane ) for pane in self ._panes ]
413
395
0 commit comments