prompt: You will be provided with a partial code base and an issue statement explaining a problem to resolve.
  <issue>
  Ampersands need to be escaped in WindowName widget
  # Issue description
  Ampersands in window names need to be changed in WindowName widget to "&amp;" before being passed to Pango/Cairo
  
  # Qtile version
  0.15.1
  
  # Stack traces
  Exception: parse_markup() failed for b'Seth Lakeman - King & Country'
  2020-04-27 19:12:00,744 ERROR libqtile hook.py:fire():L373 Error in hook focus_change
  Traceback (most recent call last):
    File "/usr/lib/python3.8/site-packages/libqtile/hook.py", line 371, in fire
      i(*args, **kwargs)
    File "/usr/lib/python3.8/site-packages/libqtile/widget/windowname.py", line 67, in update
      self.text = "%s%s" % (state, w.name if w and w.name else " ")
    File "/usr/lib/python3.8/site-packages/libqtile/widget/base.py", line 323, in text
      self.layout.text = self.formatted_text
    File "/usr/lib/python3.8/site-packages/libqtile/drawer.py", line 70, in text
      attrlist, value, accel_char = pangocffi.parse_markup(value)
    File "/usr/lib/python3.8/site-packages/libqtile/pangocffi.py", line 173, in parse_markup
      raise Exception("parse_markup() failed for %s" % value)
  Exception: parse_markup() failed for b'Seth Lakeman - King & Country'
  
  # Configuration
  N/A
  
  </issue>
  <code>
  [start of libqtile/widget/windowname.py]
  1 # Copyright (c) 2008, 2010 Aldo Cortesi
  2 # Copyright (c) 2010 matt
  3 # Copyright (c) 2011 Mounier Florian
  4 # Copyright (c) 2012 Tim Neumann
  5 # Copyright (c) 2013 Craig Barnes
  6 # Copyright (c) 2014 Sean Vig
  7 # Copyright (c) 2014 Tycho Andersen
  8 #
  9 # Permission is hereby granted, free of charge, to any person obtaining a copy
  10 # of this software and associated documentation files (the "Software"), to deal
  11 # in the Software without restriction, including without limitation the rights
  12 # to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
  13 # copies of the Software, and to permit persons to whom the Software is
  14 # furnished to do so, subject to the following conditions:
  15 #
  16 # The above copyright notice and this permission notice shall be included in
  17 # all copies or substantial portions of the Software.
  18 #
  19 # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
  20 # IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
  21 # FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
  22 # AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
  23 # LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
  24 # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
  25 # SOFTWARE.
  26 
  27 from libqtile import bar, hook
  28 from libqtile.widget import base
  29 
  30 
  31 class WindowName(base._TextBox):
  32     """Displays the name of the window that currently has focus"""
  33     orientations = base.ORIENTATION_HORIZONTAL
  34     defaults = [
  35         ('show_state', True, 'show window status before window name'),
  36         ('for_current_screen', False, 'instead of this bars screen use currently active screen')
  37     ]
  38 
  39     def __init__(self, width=bar.STRETCH, **config):
  40         base._TextBox.__init__(self, width=width, **config)
  41         self.add_defaults(WindowName.defaults)
  42 
  43     def _configure(self, qtile, bar):
  44         base._TextBox._configure(self, qtile, bar)
  45         hook.subscribe.client_name_updated(self.update)
  46         hook.subscribe.focus_change(self.update)
  47         hook.subscribe.float_change(self.update)
  48 
  49         @hook.subscribe.current_screen_change
  50         def on_screen_changed():
  51             if self.for_current_screen:
  52                 self.update()
  53 
  54     def update(self, *args):
  55         if self.for_current_screen:
  56             w = self.qtile.current_screen.group.current_window
  57         else:
  58             w = self.bar.screen.group.current_window
  59         state = ''
  60         if self.show_state and w is not None:
  61             if w.maximized:
  62                 state = '[] '
  63             elif w.minimized:
  64                 state = '_ '
  65             elif w.floating:
  66                 state = 'V '
  67         self.text = "%s%s" % (state, w.name if w and w.name else " ")
  68         self.bar.draw()
  69
  [end of libqtile/widget/windowname.py]
  </code>
  
  I need you to solve this issue by generating a single patch file that I can apply directly to this repository using git apply. Please respond with a single patch file in the following format.
  <patch>
  diff --git a/file.py b/file.py
  --- a/file.py
  +++ b/file.py
  @@ -1,27 +1,35 @@
   def euclidean(a, b):
  -    while b:
  -        a, b = b, a % b
  -    return a
  +    if b == 0:
  +        return a
  +    return euclidean(b, a % b)
   
   
   def bresenham(x0, y0, x1, y1):
       points = []
       dx = abs(x1 - x0)
       dy = abs(y1 - y0)
  -    sx = 1 if x0 < x1 else -1
  -    sy = 1 if y0 < y1 else -1
  -    err = dx - dy
  +    x, y = x0, y0
  +    sx = -1 if x0 > x1 else 1
  +    sy = -1 if y0 > y1 else 1
   
  -    while True:
  -        points.append((x0, y0))
  -        if x0 == x1 and y0 == y1:
  -            break
  -        e2 = 2 * err
  -        if e2 > -dy:
  -            err -= dy
  -            x0 += sx
  -        if e2 < dx:
  -            err += dx
  -            y0 += sy
  +    if dx > dy:
  +        err = dx / 2.0
  +        while x != x1:
  +            points.append((x, y))
  +            err -= dy
  +            if err < 0:
  +                y += sy
  +                err += dx
  +            x += sx
  +    else:
  +        err = dy / 2.0
  +        while y != y1:
  +            points.append((x, y))
  +            err -= dx
  +            if err < 0:
  +                x += sx
  +                err += dy
  +            y += sy
  +
  +    points.append((x, y))
       return points
  
  </patch>
golden_diff: diff --git a/libqtile/widget/windowname.py b/libqtile/widget/windowname.py
  --- a/libqtile/widget/windowname.py
  +++ b/libqtile/widget/windowname.py
  @@ -24,7 +24,7 @@
   # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
   # SOFTWARE.
   
  -from libqtile import bar, hook
  +from libqtile import bar, hook, pangocffi
   from libqtile.widget import base
   
   
  @@ -64,5 +64,6 @@
                   state = '_ '
               elif w.floating:
                   state = 'V '
  -        self.text = "%s%s" % (state, w.name if w and w.name else " ")
  +        unescaped = "%s%s" % (state, w.name if w and w.name else " ")
  +        self.text = pangocffi.markup_escape_text(unescaped)
           self.bar.draw()
  
verification_info: {"golden_diff": "diff --git a/libqtile/widget/windowname.py b/libqtile/widget/windowname.py\n--- a/libqtile/widget/windowname.py\n+++ b/libqtile/widget/windowname.py\n@@ -24,7 +24,7 @@\n # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE\n # SOFTWARE.\n \n-from libqtile import bar, hook\n+from libqtile import bar, hook, pangocffi\n from libqtile.widget import base\n \n \n@@ -64,5 +64,6 @@\n                 state = '_ '\n             elif w.floating:\n                 state = 'V '\n-        self.text = \"%s%s\" % (state, w.name if w and w.name else \" \")\n+        unescaped = \"%s%s\" % (state, w.name if w and w.name else \" \")\n+        self.text = pangocffi.markup_escape_text(unescaped)\n         self.bar.draw()\n", "issue": "Ampersands need to be escaped in WindowName widget\n# Issue description\r\nAmpersands in window names need to be changed in WindowName widget to \"&amp;\" before being passed to Pango/Cairo\r\n\r\n# Qtile version\r\n0.15.1\r\n\r\n# Stack traces\r\nException: parse_markup() failed for b'Seth Lakeman - King & Country'\r\n2020-04-27 19:12:00,744 ERROR libqtile hook.py:fire():L373 Error in hook focus_change\r\nTraceback (most recent call last):\r\n  File \"/usr/lib/python3.8/site-packages/libqtile/hook.py\", line 371, in fire\r\n    i(*args, **kwargs)\r\n  File \"/usr/lib/python3.8/site-packages/libqtile/widget/windowname.py\", line 67, in update\r\n    self.text = \"%s%s\" % (state, w.name if w and w.name else \" \")\r\n  File \"/usr/lib/python3.8/site-packages/libqtile/widget/base.py\", line 323, in text\r\n    self.layout.text = self.formatted_text\r\n  File \"/usr/lib/python3.8/site-packages/libqtile/drawer.py\", line 70, in text\r\n    attrlist, value, accel_char = pangocffi.parse_markup(value)\r\n  File \"/usr/lib/python3.8/site-packages/libqtile/pangocffi.py\", line 173, in parse_markup\r\n    raise Exception(\"parse_markup() failed for %s\" % value)\r\nException: parse_markup() failed for b'Seth Lakeman - King & Country'\r\n\r\n# Configuration\r\nN/A\n", "before_files": [{"content": "# Copyright (c) 2008, 2010 Aldo Cortesi\n# Copyright (c) 2010 matt\n# Copyright (c) 2011 Mounier Florian\n# Copyright (c) 2012 Tim Neumann\n# Copyright (c) 2013 Craig Barnes\n# Copyright (c) 2014 Sean Vig\n# Copyright (c) 2014 Tycho Andersen\n#\n# Permission is hereby granted, free of charge, to any person obtaining a copy\n# of this software and associated documentation files (the \"Software\"), to deal\n# in the Software without restriction, including without limitation the rights\n# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\n# copies of the Software, and to permit persons to whom the Software is\n# furnished to do so, subject to the following conditions:\n#\n# The above copyright notice and this permission notice shall be included in\n# all copies or substantial portions of the Software.\n#\n# THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE\n# SOFTWARE.\n\nfrom libqtile import bar, hook\nfrom libqtile.widget import base\n\n\nclass WindowName(base._TextBox):\n    \"\"\"Displays the name of the window that currently has focus\"\"\"\n    orientations = base.ORIENTATION_HORIZONTAL\n    defaults = [\n        ('show_state', True, 'show window status before window name'),\n        ('for_current_screen', False, 'instead of this bars screen use currently active screen')\n    ]\n\n    def __init__(self, width=bar.STRETCH, **config):\n        base._TextBox.__init__(self, width=width, **config)\n        self.add_defaults(WindowName.defaults)\n\n    def _configure(self, qtile, bar):\n        base._TextBox._configure(self, qtile, bar)\n        hook.subscribe.client_name_updated(self.update)\n        hook.subscribe.focus_change(self.update)\n        hook.subscribe.float_change(self.update)\n\n        @hook.subscribe.current_screen_change\n        def on_screen_changed():\n            if self.for_current_screen:\n                self.update()\n\n    def update(self, *args):\n        if self.for_current_screen:\n            w = self.qtile.current_screen.group.current_window\n        else:\n            w = self.bar.screen.group.current_window\n        state = ''\n        if self.show_state and w is not None:\n            if w.maximized:\n                state = '[] '\n            elif w.minimized:\n                state = '_ '\n            elif w.floating:\n                state = 'V '\n        self.text = \"%s%s\" % (state, w.name if w and w.name else \" \")\n        self.bar.draw()\n", "path": "libqtile/widget/windowname.py"}]}