parent
ce0b9eab58
commit
17ebbc37c5
@ -433,7 +433,7 @@ Load a session.
|
|||||||
|
|
||||||
[[session-save]]
|
[[session-save]]
|
||||||
=== session-save
|
=== session-save
|
||||||
Syntax: +:session-save [*--quiet*] [*--force*] ['name']+
|
Syntax: +:session-save [*--current*] [*--quiet*] [*--force*] ['name']+
|
||||||
|
|
||||||
Save a session.
|
Save a session.
|
||||||
|
|
||||||
@ -441,6 +441,7 @@ Save a session.
|
|||||||
* +'name'+: The name of the session.
|
* +'name'+: The name of the session.
|
||||||
|
|
||||||
==== optional arguments
|
==== optional arguments
|
||||||
|
* +*-c*+, +*--current*+: Save the current session instead of the default.
|
||||||
* +*-q*+, +*--quiet*+: Don't show confirmation message.
|
* +*-q*+, +*--quiet*+: Don't show confirmation message.
|
||||||
* +*-f*+, +*--force*+: Force saving internal sessions (starting with an underline).
|
* +*-f*+, +*--force*+: Force saving internal sessions (starting with an underline).
|
||||||
|
|
||||||
|
@ -55,6 +55,7 @@ class SessionManager(QObject):
|
|||||||
_base_path: The path to store sessions under.
|
_base_path: The path to store sessions under.
|
||||||
_last_window_session: The session data of the last window which was
|
_last_window_session: The session data of the last window which was
|
||||||
closed.
|
closed.
|
||||||
|
_current: The name of the currently loaded session, or None.
|
||||||
did_load: Set when a session was loaded.
|
did_load: Set when a session was loaded.
|
||||||
|
|
||||||
Signals:
|
Signals:
|
||||||
@ -66,6 +67,7 @@ class SessionManager(QObject):
|
|||||||
|
|
||||||
def __init__(self, parent=None):
|
def __init__(self, parent=None):
|
||||||
super().__init__(parent)
|
super().__init__(parent)
|
||||||
|
self._current = None
|
||||||
self._base_path = os.path.join(standarddir.data(), 'sessions')
|
self._base_path = os.path.join(standarddir.data(), 'sessions')
|
||||||
self._last_window_session = None
|
self._last_window_session = None
|
||||||
self.did_load = False
|
self.did_load = False
|
||||||
@ -243,6 +245,8 @@ class SessionManager(QObject):
|
|||||||
if win.get('active', False):
|
if win.get('active', False):
|
||||||
QTimer.singleShot(0, tabbed_browser.activateWindow)
|
QTimer.singleShot(0, tabbed_browser.activateWindow)
|
||||||
self.did_load = True
|
self.did_load = True
|
||||||
|
if not name.startswith('_'):
|
||||||
|
self._current = name
|
||||||
|
|
||||||
def delete(self, name):
|
def delete(self, name):
|
||||||
"""Delete a session."""
|
"""Delete a session."""
|
||||||
@ -290,18 +294,24 @@ class SessionManager(QObject):
|
|||||||
completion=[usertypes.Completion.sessions],
|
completion=[usertypes.Completion.sessions],
|
||||||
instance='session-manager')
|
instance='session-manager')
|
||||||
def session_save(self, win_id: {'special': 'win_id'}, name='default',
|
def session_save(self, win_id: {'special': 'win_id'}, name='default',
|
||||||
quiet=False, force=False):
|
current=False, quiet=False, force=False):
|
||||||
"""Save a session.
|
"""Save a session.
|
||||||
|
|
||||||
Args:
|
Args:
|
||||||
win_id: The current window ID.
|
win_id: The current window ID.
|
||||||
name: The name of the session.
|
name: The name of the session.
|
||||||
|
current: Save the current session instead of the default.
|
||||||
quiet: Don't show confirmation message.
|
quiet: Don't show confirmation message.
|
||||||
force: Force saving internal sessions (starting with an underline).
|
force: Force saving internal sessions (starting with an underline).
|
||||||
"""
|
"""
|
||||||
if name.startswith('_') and not force:
|
if name.startswith('_') and not force:
|
||||||
raise cmdexc.CommandError("{!r} is an internal session, use "
|
raise cmdexc.CommandError("{!r} is an internal session, use "
|
||||||
"--force to save anyways.".format(name))
|
"--force to save anyways.".format(name))
|
||||||
|
if current:
|
||||||
|
if self._current is None:
|
||||||
|
raise cmdexc.CommandError("No session loaded currently!")
|
||||||
|
name = self._current
|
||||||
|
assert not name.startswith('_')
|
||||||
try:
|
try:
|
||||||
self.save(name)
|
self.save(name)
|
||||||
except SessionError as e:
|
except SessionError as e:
|
||||||
|
Loading…
Reference in New Issue
Block a user