# Path: fuzzinator/ui/tui/button.py
# class FormattedButton(WidgetWrap):
#     signals = ['click']
#     _selectable = True
# 
#     def __init__(self, label, on_press=None, user_data=None, style='button'):
#         self.text_len = len(label)
#         self.btn = ShortButton(label, on_press, user_data)
#         super().__init__(AttrMap(self.btn, style))
#         connect_signal(self.btn, 'click', lambda btn: self._emit('click'))
# 
#     def sizing(self):
#         return frozenset(['fixed'])
# 
#     def pack(self, size=None, focus=None):
#         return self.text_len + 6, 1
# 
# Path: fuzzinator/ui/tui/dialogs.py
# class BugEditor(Edit):
# 
#     def keypress(self, size, key):
#         if key == 'ctrl k':
#             lines = self._edit_text.splitlines(keepends=True)
#             line_cnt = self._edit_text[:self.edit_pos].count('\n')
#             before = ''.join(lines[:line_cnt])
#             after = ''.join(lines[line_cnt + 1:]) if line_cnt + 1 < len(lines) else ''
#             self.set_edit_text(before + after)
#             self.set_edit_pos(len(before))
#             return None
#         return super().keypress(size, key)


import logging
from urwid import *
from ...config import config_get_object
from ...formatter import JsonFormatter
from ...tracker import TrackerError
from .button import FormattedButton
from .decor_widgets import PatternBox
from .dialogs import BugEditor
from .graphics import fz_box_pattern
        self.tracker = config_get_object(config, 'sut.' + issue['sut'], 'tracker')
        self.settings = self.tracker.settings()

        formatter = config_get_object(config, 'sut.' + issue['sut'], 'formatter') or JsonFormatter()
        self.issue_title = BugEditor(edit_text=formatter.summary(issue=issue))
        self.issue_desc = BugEditor(edit_text=formatter(issue=issue), multiline=True, wrap='clip')

        self.duplicate = None
        self.edit_dups = BugEditor()
        dups_walker = SimpleListWalker([self.edit_dups])
        dups = []
        try:
            for dup_url, _ in self.tracker.find_duplicates(title=self.issue_title.get_text()[0]):
                radio_btn = RadioButton(dups, dup_url, on_state_change=self.set_duplicate)
                # Select the first suggested bug if there is not set any.
                if self.duplicate is None:
                    self.duplicate = radio_btn.label
                dups_walker.append(radio_btn)
        except TrackerError as e:
            logger.warning(str(e), exc_info=e)
        body = SimpleListWalker([Columns([('fixed', 13, Text(('dialog_secondary', 'Duplicates: '))),
                                          ('weight', 10, BoxAdapter(ListBox(dups_walker), height=len(dups_walker)))]),
                                 Columns([('fixed', 13, Text(('dialog_secondary', 'Summary: '))),
                                          ('weight', 10, self.issue_title)], dividechars=1),
                                 Columns([('fixed', 13, Text(('dialog_secondary', 'Description: '))),
                                          ('weight', 10, self.issue_desc)], dividechars=1)])
        self.settings_walker = SimpleListWalker([])
        frame = Frame(body=AttrMap(Columns([('weight', 10, ListBox(body)),
                                            ('weight', 3, AttrMap(ListBox(self.settings_walker), attr_map='dialog_secondary'))]),
                                   'dialog'),

# Path: fuzzinator/ui/tui/button.py
# class FormattedButton(WidgetWrap):
#     signals = ['click']
#     _selectable = True
# 
#     def __init__(self, label, on_press=None, user_data=None, style='button'):
#         self.text_len = len(label)
#         self.btn = ShortButton(label, on_press, user_data)
#         super().__init__(AttrMap(self.btn, style))
#         connect_signal(self.btn, 'click', lambda btn: self._emit('click'))
# 
#     def sizing(self):
#         return frozenset(['fixed'])
# 
#     def pack(self, size=None, focus=None):
#         return self.text_len + 6, 1
# 
# Path: fuzzinator/ui/tui/dialogs.py
# class BugEditor(Edit):
# 
#     def keypress(self, size, key):
#         if key == 'ctrl k':
#             lines = self._edit_text.splitlines(keepends=True)
#             line_cnt = self._edit_text[:self.edit_pos].count('\n')
#             before = ''.join(lines[:line_cnt])
#             after = ''.join(lines[line_cnt + 1:]) if line_cnt + 1 < len(lines) else ''
#             self.set_edit_text(before + after)
#             self.set_edit_pos(len(before))
#             return None
#         return super().keypress(size, key)


# Path: fuzzinator/ui/tui/reporter_dialogs.py
import logging
from urwid import *
from ...config import config_get_object
from ...formatter import JsonFormatter
from ...tracker import TrackerError
from .button import FormattedButton
from .decor_widgets import PatternBox
from .dialogs import BugEditor
from .graphics import fz_box_pattern

        self.tracker = config_get_object(config, 'sut.' + issue['sut'], 'tracker')
        self.settings = self.tracker.settings()

        formatter = config_get_object(config, 'sut.' + issue['sut'], 'formatter') or JsonFormatter()
        self.issue_title = BugEditor(edit_text=formatter.summary(issue=issue))
        self.issue_desc = BugEditor(edit_text=formatter(issue=issue), multiline=True, wrap='clip')

        self.duplicate = None
        self.edit_dups = BugEditor()
        dups_walker = SimpleListWalker([self.edit_dups])
        dups = []
        try:
            for dup_url, _ in self.tracker.find_duplicates(title=self.issue_title.get_text()[0]):
                radio_btn = RadioButton(dups, dup_url, on_state_change=self.set_duplicate)
                # Select the first suggested bug if there is not set any.
                if self.duplicate is None:
                    self.duplicate = radio_btn.label
                dups_walker.append(radio_btn)
        except TrackerError as e:
            logger.warning(str(e), exc_info=e)
        body = SimpleListWalker([Columns([('fixed', 13, Text(('dialog_secondary', 'Duplicates: '))),
                                          ('weight', 10, BoxAdapter(ListBox(dups_walker), height=len(dups_walker)))]),
                                 Columns([('fixed', 13, Text(('dialog_secondary', 'Summary: '))),
                                          ('weight', 10, self.issue_title)], dividechars=1),
                                 Columns([('fixed', 13, Text(('dialog_secondary', 'Description: '))),
                                          ('weight', 10, self.issue_desc)], dividechars=1)])
        self.settings_walker = SimpleListWalker([])
        frame = Frame(body=AttrMap(Columns([('weight', 10, ListBox(body)),
                                            ('weight', 3, AttrMap(ListBox(self.settings_walker), attr_map='dialog_secondary'))]),
                                   'dialog'),

                      footer=Columns([('pack', FormattedButton('Close', lambda button: self._emit('close_reporter'))),