# Path: sen/tui/constants.py
# MAIN_LIST_FOCUS = "main_list_focus"
# 
# Path: sen/tui/widgets/responsive_column.py
# class ResponsiveColumns(urwid.Columns):
#     """
#     Widgets arranged horizontally in columns from left to right
#     """
# 
#     def column_widths(self, size, focus=False):
#         """
#         Return a list of column widths.
# 
#         0 values in the list mean hide corresponding column completely
#         """
#         maxcol = size[0]
#         self._cache_maxcol = maxcol
#         widths = [width for i, (w, (t, width, b)) in enumerate(self.contents)]
#         self._cache_column_widths = widths
# 
#         return widths
# 
# Path: sen/tui/widgets/util.py
# class SelectableText(ColorTextMixin, AdHocAttrMap):
#     def __init__(self, text, maps=None):
#         maps = maps or get_map()
#         super().__init__(urwid.Text(text, align="left", wrap="clip"), maps)
# 
# def get_map(defult="main_list_dg"):
#     return {"normal": defult, "focus": MAIN_LIST_FOCUS}


import datetime
import logging
import urwid
from sen.tui.constants import MAIN_LIST_FOCUS
from sen.tui.widgets.responsive_column import ResponsiveColumns
from sen.tui.widgets.util import SelectableText, get_map


class UnselectableRowWidget(urwid.AttrMap):
    def __init__(self, columns, attr="main_list_dg", focus_map=MAIN_LIST_FOCUS, dividechars=1):
        self.widgets = columns
        self.columns = urwid.Columns(columns, dividechars=dividechars)
        super().__init__(self.columns, attr, focus_map=focus_map)

    @property
    def contents(self):
        return self.columns.contents

    def render(self, size, focus=False):
        for w in self.columns.widget_list:
            if hasattr(w, "set_map"):
                w.set_map('focus' if focus else 'normal')
        return urwid.AttrMap.render(self, size, focus)


class RowWidget(UnselectableRowWidget):
    def selectable(self):
        return True


class SingleTextRow(RowWidget):
    def __init__(self, text_markup, maps=None):
        super().__init__([SelectableText(text_markup, maps=maps)])


class ResponsiveRowWidget(RowWidget):

# Path: sen/tui/constants.py
# MAIN_LIST_FOCUS = "main_list_focus"
# 
# Path: sen/tui/widgets/responsive_column.py
# class ResponsiveColumns(urwid.Columns):
#     """
#     Widgets arranged horizontally in columns from left to right
#     """
# 
#     def column_widths(self, size, focus=False):
#         """
#         Return a list of column widths.
# 
#         0 values in the list mean hide corresponding column completely
#         """
#         maxcol = size[0]
#         self._cache_maxcol = maxcol
#         widths = [width for i, (w, (t, width, b)) in enumerate(self.contents)]
#         self._cache_column_widths = widths
# 
#         return widths
# 
# Path: sen/tui/widgets/util.py
# class SelectableText(ColorTextMixin, AdHocAttrMap):
#     def __init__(self, text, maps=None):
#         maps = maps or get_map()
#         super().__init__(urwid.Text(text, align="left", wrap="clip"), maps)
# 
# def get_map(defult="main_list_dg"):
#     return {"normal": defult, "focus": MAIN_LIST_FOCUS}


# Path: sen/tui/widgets/list/util.py
import datetime
import logging
import urwid
from sen.tui.constants import MAIN_LIST_FOCUS
from sen.tui.widgets.responsive_column import ResponsiveColumns
from sen.tui.widgets.util import SelectableText, get_map



class UnselectableRowWidget(urwid.AttrMap):
    def __init__(self, columns, attr="main_list_dg", focus_map=MAIN_LIST_FOCUS, dividechars=1):
        self.widgets = columns
        self.columns = urwid.Columns(columns, dividechars=dividechars)
        super().__init__(self.columns, attr, focus_map=focus_map)

    @property
    def contents(self):
        return self.columns.contents

    def render(self, size, focus=False):
        for w in self.columns.widget_list:
            if hasattr(w, "set_map"):
                w.set_map('focus' if focus else 'normal')
        return urwid.AttrMap.render(self, size, focus)


class RowWidget(UnselectableRowWidget):
    def selectable(self):
        return True


class SingleTextRow(RowWidget):
    def __init__(self, text_markup, maps=None):
        super().__init__([SelectableText(text_markup, maps=maps)])


class ResponsiveRowWidget(RowWidget):

    def __init__(self, columns, attr="main_list_dg", focus_map=MAIN_LIST_FOCUS, dividechars=1):