extract escape_amp() method

This commit is contained in:
me 2020-01-31 12:27:39 +02:00
parent beff99888b
commit 64c675150e

View file

@ -374,6 +374,11 @@ class WidgetDrawer(object):
if self._suffix: if self._suffix:
self._full_text = u"{}{}".format(self._full_text, self._suffix) self._full_text = u"{}{}".format(self._full_text, self._suffix)
def escape_amp(self):
"""escape & in full_text, because pango requires it"""
if self._markup == "pango":
self._full_text = self._full_text.replace("&", "&")
def draw(self, widget, module=None, engine=None): def draw(self, widget, module=None, engine=None):
""" """
Keep the same argument signature as I3BarOutput.draw() Keep the same argument signature as I3BarOutput.draw()
@ -406,8 +411,7 @@ class WidgetDrawer(object):
if width: if width:
self._full_text = self._full_text.ljust(len(width) + len(self._prefix) + len(self._suffix)) self._full_text = self._full_text.ljust(len(width) + len(self._prefix) + len(self._suffix))
if self._markup == "pango": self.escape_amp()
self._full_text = self._full_text.replace("&", "&")
self._widgets.append({ self._widgets.append({
u"full_text": self._full_text, u"full_text": self._full_text,