parent
dff8f73a11
commit
33dff70357
@ -414,13 +414,16 @@ Delete a session.
|
|||||||
|
|
||||||
[[session-load]]
|
[[session-load]]
|
||||||
=== session-load
|
=== session-load
|
||||||
Syntax: +:session-load 'name'+
|
Syntax: +:session-load [*--clear*] 'name'+
|
||||||
|
|
||||||
Load a session.
|
Load a session.
|
||||||
|
|
||||||
==== positional arguments
|
==== positional arguments
|
||||||
* +'name'+: The name of the session.
|
* +'name'+: The name of the session.
|
||||||
|
|
||||||
|
==== optional arguments
|
||||||
|
* +*-c*+, +*--clear*+: Close all existing windows.
|
||||||
|
|
||||||
[[session-save]]
|
[[session-save]]
|
||||||
=== session-save
|
=== session-save
|
||||||
Syntax: +:session-save [*--quiet*] ['name']+
|
Syntax: +:session-save [*--quiet*] ['name']+
|
||||||
|
@ -266,12 +266,14 @@ class SessionManager(QObject):
|
|||||||
|
|
||||||
@cmdutils.register(completion=[usertypes.Completion.sessions],
|
@cmdutils.register(completion=[usertypes.Completion.sessions],
|
||||||
instance='session-manager')
|
instance='session-manager')
|
||||||
def session_load(self, name):
|
def session_load(self, name, clear=False):
|
||||||
"""Load a session.
|
"""Load a session.
|
||||||
|
|
||||||
Args:
|
Args:
|
||||||
name: The name of the session.
|
name: The name of the session.
|
||||||
|
clear: Close all existing windows.
|
||||||
"""
|
"""
|
||||||
|
old_windows = list(objreg.window_registry.values())
|
||||||
try:
|
try:
|
||||||
self.load(name)
|
self.load(name)
|
||||||
except SessionNotFoundError:
|
except SessionNotFoundError:
|
||||||
@ -279,6 +281,10 @@ class SessionManager(QObject):
|
|||||||
except SessionError as e:
|
except SessionError as e:
|
||||||
raise cmdexc.CommandError("Error while loading session: {}"
|
raise cmdexc.CommandError("Error while loading session: {}"
|
||||||
.format(e))
|
.format(e))
|
||||||
|
else:
|
||||||
|
if clear:
|
||||||
|
for win in old_windows:
|
||||||
|
win.close()
|
||||||
|
|
||||||
@cmdutils.register(name=['session-save', 'w'],
|
@cmdutils.register(name=['session-save', 'w'],
|
||||||
completion=[usertypes.Completion.sessions],
|
completion=[usertypes.Completion.sessions],
|
||||||
|
Loading…
Reference in New Issue
Block a user