mirror of
https://github.com/powerline/powerline.git
synced 2025-07-31 01:35:40 +02:00
Make workspace(strip) strip {number}:
prefix if true
This commit is contained in:
parent
db99ad1d90
commit
10243ad89f
@ -1,10 +1,15 @@
|
|||||||
# vim:fileencoding=utf-8:noet
|
# vim:fileencoding=utf-8:noet
|
||||||
from __future__ import (unicode_literals, division, absolute_import, print_function)
|
from __future__ import (unicode_literals, division, absolute_import, print_function)
|
||||||
|
|
||||||
|
import re
|
||||||
|
|
||||||
from powerline.theme import requires_segment_info
|
from powerline.theme import requires_segment_info
|
||||||
from powerline.bindings.wm import get_i3_connection
|
from powerline.bindings.wm import get_i3_connection
|
||||||
|
|
||||||
|
|
||||||
|
WORKSPACE_REGEX = re.compile(r'^[0-9]+: ?')
|
||||||
|
|
||||||
|
|
||||||
def calcgrp(w):
|
def calcgrp(w):
|
||||||
group = []
|
group = []
|
||||||
if w['focused']:
|
if w['focused']:
|
||||||
@ -17,6 +22,12 @@ def calcgrp(w):
|
|||||||
return group
|
return group
|
||||||
|
|
||||||
|
|
||||||
|
def format_name(name, strip=False):
|
||||||
|
if strip:
|
||||||
|
return WORKSPACE_REGEX.sub('', name, count=1)
|
||||||
|
return name
|
||||||
|
|
||||||
|
|
||||||
@requires_segment_info
|
@requires_segment_info
|
||||||
def workspaces(pl, segment_info, only_show=None, output=None, strip=0):
|
def workspaces(pl, segment_info, only_show=None, output=None, strip=0):
|
||||||
'''Return list of used workspaces
|
'''Return list of used workspaces
|
||||||
@ -51,7 +62,7 @@ def workspaces(pl, segment_info, only_show=None, output=None, strip=0):
|
|||||||
|
|
||||||
|
|
||||||
@requires_segment_info
|
@requires_segment_info
|
||||||
def workspace(pl, segment_info, workspace=None, strip=0):
|
def workspace(pl, segment_info, workspace=None, strip=False):
|
||||||
'''Return the specified workspace name
|
'''Return the specified workspace name
|
||||||
|
|
||||||
:param str workspace:
|
:param str workspace:
|
||||||
@ -59,9 +70,9 @@ def workspace(pl, segment_info, workspace=None, strip=0):
|
|||||||
``list_workspaces`` lister if used, otherwise falls back to
|
``list_workspaces`` lister if used, otherwise falls back to
|
||||||
currently focused workspace.
|
currently focused workspace.
|
||||||
|
|
||||||
:param int strip:
|
:param bool strip:
|
||||||
Specifies how many characters from the front of each workspace name
|
Specifies whether workspace numbers (in the ``1: name`` format) should
|
||||||
should be stripped (e.g. to remove workspace numbers). Defaults to zero.
|
be stripped from workspace names before being displayed. Defaults to false.
|
||||||
|
|
||||||
Highlight groups used: ``workspace`` or ``w_visible``, ``workspace`` or ``w_focused``, ``workspace`` or ``w_urgent``.
|
Highlight groups used: ``workspace`` or ``w_visible``, ``workspace`` or ``w_focused``, ``workspace`` or ``w_urgent``.
|
||||||
'''
|
'''
|
||||||
@ -85,7 +96,7 @@ def workspace(pl, segment_info, workspace=None, strip=0):
|
|||||||
return None
|
return None
|
||||||
|
|
||||||
return [{
|
return [{
|
||||||
'contents': w['name'][min(len(w['name']), strip):],
|
'contents': format_name(w['name'], strip=strip),
|
||||||
'highlight_groups': calcgrp(w)
|
'highlight_groups': calcgrp(w)
|
||||||
}]
|
}]
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user