kopia lustrzana https://github.com/ihabunek/toot
CONFIG WIP
rodzic
abcd4939f2
commit
95f0cab59f
|
@ -0,0 +1,29 @@
|
|||
import configparser
|
||||
import os
|
||||
from os.path import join
|
||||
|
||||
from toot.config import get_config_dir
|
||||
|
||||
TOOT_SETTINGS_FILE_NAME = "settings.ini"
|
||||
|
||||
DEAFAULT_SETTINGS = {
|
||||
|
||||
}
|
||||
|
||||
def get_config_file_path():
|
||||
"""Returns the path to toot config file."""
|
||||
return join(get_config_dir(), TOOT_SETTINGS_FILE_NAME)
|
||||
|
||||
|
||||
def load_settings():
|
||||
path = get_config_file_path()
|
||||
if not os.path.exists(path):
|
||||
return
|
||||
|
||||
config = configparser.ConfigParser()
|
||||
with open(path, "r") as f:
|
||||
config.read_file(f)
|
||||
return config
|
||||
|
||||
print("loading")
|
||||
settings = load_settings()
|
|
@ -1,9 +1,11 @@
|
|||
import logging
|
||||
import urwid
|
||||
import pprint
|
||||
|
||||
from concurrent.futures import ThreadPoolExecutor
|
||||
|
||||
from toot import api, config, __version__
|
||||
from toot.settings import settings
|
||||
|
||||
from .compose import StatusComposer
|
||||
from .constants import PALETTE
|
||||
|
@ -17,7 +19,6 @@ logger = logging.getLogger(__name__)
|
|||
|
||||
urwid.set_encoding('UTF-8')
|
||||
|
||||
|
||||
class Header(urwid.WidgetWrap):
|
||||
def __init__(self, app, user):
|
||||
self.app = app
|
||||
|
@ -46,7 +47,7 @@ class Footer(urwid.Pile):
|
|||
self.status = urwid.Text("")
|
||||
self.message = urwid.Text("")
|
||||
|
||||
return super().__init__([
|
||||
super().__init__([
|
||||
urwid.AttrMap(self.status, "footer_status"),
|
||||
urwid.AttrMap(self.message, "footer_message"),
|
||||
])
|
||||
|
@ -81,6 +82,7 @@ class TUI(urwid.Frame):
|
|||
event_loop=urwid.AsyncioEventLoop(),
|
||||
unhandled_input=tui.unhandled_input,
|
||||
)
|
||||
loop.screen.set_terminal_properties(colors=256)
|
||||
tui.loop = loop
|
||||
|
||||
return tui
|
||||
|
|
|
@ -1,41 +1,51 @@
|
|||
from toot.settings import settings
|
||||
|
||||
def palette():
|
||||
palette = settings["toot.tui.palette"]
|
||||
for name, colors in palette.items():
|
||||
colors = [c.strip() for c in colors.split("/")]
|
||||
yield tuple([name] + colors)
|
||||
|
||||
PALETTE = list(palette())
|
||||
|
||||
# name, fg, bg, mono, fg_h, bg_h
|
||||
PALETTE = [
|
||||
# Components
|
||||
('button', 'white', 'black'),
|
||||
('button_focused', 'light gray', 'dark magenta'),
|
||||
('columns_divider', 'white', 'dark blue'),
|
||||
('content_warning', 'white', 'dark magenta'),
|
||||
('editbox', 'white', 'black'),
|
||||
('editbox_focused', 'white', 'dark magenta'),
|
||||
('footer_message', 'dark green', ''),
|
||||
('footer_message_error', 'light red', ''),
|
||||
('footer_status', 'white', 'dark blue'),
|
||||
('footer_status_bold', 'white, bold', 'dark blue'),
|
||||
('header', 'white', 'dark blue'),
|
||||
('header_bold', 'white,bold', 'dark blue'),
|
||||
('intro_bigtext', 'yellow', ''),
|
||||
('intro_smalltext', 'light blue', ''),
|
||||
('poll_bar', 'white', 'dark blue'),
|
||||
# PALETTE = [
|
||||
# # Components
|
||||
# ('button', 'white', 'black'),
|
||||
# ('button_focused', 'light gray', 'dark magenta'),
|
||||
# ('columns_divider', 'white', 'dark blue'),
|
||||
# ('content_warning', 'white', 'dark magenta'),
|
||||
# ('editbox', 'white', 'black'),
|
||||
# ('editbox_focused', 'white', 'dark magenta'),
|
||||
# ('footer_message', 'dark green', ''),
|
||||
# ('footer_message_error', 'light red', ''),
|
||||
# ('footer_status', 'white', 'dark blue'),
|
||||
# ('footer_status_bold', 'white, bold', 'dark blue'),
|
||||
# ('header', 'white', 'dark blue'),
|
||||
# ('header_bold', 'white,bold', 'dark blue'),
|
||||
# ('intro_bigtext', 'yellow', ''),
|
||||
# ('intro_smalltext', 'light blue', ''),
|
||||
# ('poll_bar', 'white', 'dark blue'),
|
||||
|
||||
# Functional
|
||||
('hashtag', 'light cyan,bold', ''),
|
||||
('link', ',italics', ''),
|
||||
('link_focused', ',italics', 'dark magenta'),
|
||||
# # Functional
|
||||
# ('hashtag', 'light cyan,bold', ''),
|
||||
# ('link', ',italics', ''),
|
||||
# ('link_focused', ',italics', 'dark magenta'),
|
||||
|
||||
# Colors
|
||||
('bold', ',bold', ''),
|
||||
('blue', 'light blue', ''),
|
||||
('blue_bold', 'light blue, bold', ''),
|
||||
('blue_selected', 'white', 'dark blue'),
|
||||
('cyan', 'dark cyan', ''),
|
||||
('cyan_bold', 'dark cyan,bold', ''),
|
||||
('gray', 'dark gray', ''),
|
||||
('green', 'dark green', ''),
|
||||
('green_selected', 'white,bold', 'dark green'),
|
||||
('yellow', 'yellow', ''),
|
||||
('yellow_bold', 'yellow,bold', ''),
|
||||
('warning', 'light red', ''),
|
||||
]
|
||||
# # Colors
|
||||
# ('bold', ',bold', ''),
|
||||
# ('blue', 'light blue', ''),
|
||||
# ('blue_bold', 'light blue, bold', ''),
|
||||
# ('blue_selected', 'white', 'dark blue'),
|
||||
# ('cyan', 'dark cyan', ''),
|
||||
# ('cyan_bold', 'dark cyan,bold', ''),
|
||||
# ('gray', 'dark gray', ''),
|
||||
# ('green', 'dark green', ''),
|
||||
# ('green_selected', 'white,bold', 'dark green'),
|
||||
# ('yellow', 'yellow', ''),
|
||||
# ('yellow_bold', 'yellow,bold', ''),
|
||||
# ('warning', 'light red', ''),
|
||||
# ]
|
||||
|
||||
VISIBILITY_OPTIONS = [
|
||||
("public", "Public", "Post to public timelines"),
|
||||
|
|
|
@ -43,7 +43,7 @@ class Timeline(urwid.Columns):
|
|||
|
||||
super().__init__([
|
||||
("weight", 40, self.status_list),
|
||||
("weight", 0, urwid.AttrWrap(urwid.SolidFill("│"), "blue_selected")),
|
||||
("weight", 0, urwid.AttrWrap(urwid.SolidFill("│"), "columns_divider")),
|
||||
("weight", 60, urwid.Padding(self.status_details, left=1)),
|
||||
])
|
||||
|
||||
|
@ -59,11 +59,11 @@ class Timeline(urwid.Columns):
|
|||
urwid.connect_signal(item, "click", lambda *args:
|
||||
self._emit("menu", status))
|
||||
return urwid.AttrMap(item, None, focus_map={
|
||||
"blue": "green_selected",
|
||||
"green": "green_selected",
|
||||
"yellow": "green_selected",
|
||||
"cyan": "green_selected",
|
||||
None: "green_selected",
|
||||
"timeline_datetime": "timeline_selected",
|
||||
"green": "timeline_selected",
|
||||
"yellow": "timeline_selected",
|
||||
"cyan": "timeline_selected",
|
||||
None: "timeline_selected",
|
||||
})
|
||||
|
||||
def get_focused_status(self):
|
||||
|
@ -237,7 +237,7 @@ class StatusDetails(urwid.Pile):
|
|||
reblogged_by = status.author if status and status.reblog else None
|
||||
widget_list = list(self.content_generator(status.original, reblogged_by)
|
||||
if status else ())
|
||||
return super().__init__(widget_list)
|
||||
super().__init__(widget_list)
|
||||
|
||||
def content_generator(self, status, reblogged_by):
|
||||
if reblogged_by:
|
||||
|
@ -352,8 +352,8 @@ class StatusListItem(SelectableColumns):
|
|||
is_reblog = ("cyan", "♺") if status.reblog else " "
|
||||
is_reply = ("cyan", "⤶") if status.original.in_reply_to else " "
|
||||
|
||||
return super().__init__([
|
||||
("pack", SelectableText(("blue", created_at), wrap="clip")),
|
||||
super().__init__([
|
||||
("pack", SelectableText(("timeline_datetime", created_at), wrap="clip")),
|
||||
("pack", urwid.Text(" ")),
|
||||
("pack", urwid.Text(favourited)),
|
||||
("pack", urwid.Text(" ")),
|
||||
|
|
|
@ -33,7 +33,7 @@ class EditBox(urwid.AttrWrap):
|
|||
"""Styled edit box."""
|
||||
def __init__(self, *args, **kwargs):
|
||||
self.edit = urwid.Edit(*args, **kwargs)
|
||||
return super().__init__(self.edit, "editbox", "editbox_focused")
|
||||
super().__init__(self.edit, "editbox", "editbox_focused")
|
||||
|
||||
|
||||
class Button(urwid.AttrWrap):
|
||||
|
@ -41,7 +41,7 @@ class Button(urwid.AttrWrap):
|
|||
def __init__(self, *args, **kwargs):
|
||||
button = urwid.Button(*args, **kwargs)
|
||||
padding = urwid.Padding(button, width=len(args[0]) + 4)
|
||||
return super().__init__(padding, "button", "button_focused")
|
||||
super().__init__(padding, "button", "button_focused")
|
||||
|
||||
def set_label(self, *args, **kwargs):
|
||||
self.original_widget.original_widget.set_label(*args, **kwargs)
|
||||
|
|
Ładowanie…
Reference in New Issue