minor aestetic changes: move some contsnts to global scope
parent
eca255af1b
commit
a4ee100b53
|
@ -142,17 +142,15 @@ general_help = [
|
||||||
"dialogs or composers."
|
"dialogs or composers."
|
||||||
]
|
]
|
||||||
|
|
||||||
colornames = [
|
|
||||||
"none", "red", "yellow", "green", "blue",
|
|
||||||
"cyan", "magenta"
|
|
||||||
]
|
|
||||||
|
|
||||||
colors = [
|
colors = [
|
||||||
"\033[1;31m", "\033[1;33m", "\033[1;33m",
|
"\033[1;31m", "\033[1;33m", "\033[1;33m",
|
||||||
"\033[1;32m", "\033[1;34m", "\033[1;35m"
|
"\033[1;32m", "\033[1;34m", "\033[1;35m"
|
||||||
]
|
]
|
||||||
|
|
||||||
|
colornames = ["none", "red", "yellow", "green", "blue", "cyan", "magenta"]
|
||||||
editors = ["nano", "vim", "emacs", "vim -u NONE", "emacs -Q", "micro", "ed", "joe"]
|
editors = ["nano", "vim", "emacs", "vim -u NONE", "emacs -Q", "micro", "ed", "joe"]
|
||||||
|
|
||||||
default_prefs = {
|
default_prefs = {
|
||||||
"editor": os.getenv("EDITOR", default="nano"),
|
"editor": os.getenv("EDITOR", default="nano"),
|
||||||
"integrate_external_editor": True,
|
"integrate_external_editor": True,
|
||||||
|
@ -163,60 +161,64 @@ default_prefs = {
|
||||||
"max_text_width": 80
|
"max_text_width": 80
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bars = {
|
||||||
|
"index": "[RET]Open [C]ompose [R]efresh [O]ptions [?]Help [Q]uit",
|
||||||
|
"thread": "[C]ompose [RET]Interact [Q]Back [R]efresh [B/T]End [?]Help"
|
||||||
|
}
|
||||||
|
|
||||||
class App(object):
|
colormap = [
|
||||||
def __init__(self):
|
("default", "default", "default"),
|
||||||
self.bars = {
|
("bar", "light magenta", "default"),
|
||||||
"index": "[RET]Open [C]ompose [R]efresh [O]ptions [?]Help [Q]uit",
|
("button", "light red", "default"),
|
||||||
"thread": "[C]ompose [RET]Interact [Q]Back [R]efresh [B/T]End [?]Help"
|
("quote", "brown", "default"),
|
||||||
}
|
("opt_prompt", "black", "light gray"),
|
||||||
|
("opt_header", "light cyan", "default"),
|
||||||
colors = [
|
("hover", "light cyan", "default"),
|
||||||
("default", "default", "default"),
|
("dim", "dark gray", "default"),
|
||||||
("bar", "light magenta", "default"),
|
("bold", "default,bold", "default"),
|
||||||
("button", "light red", "default"),
|
("underline", "default,underline", "default"),
|
||||||
("quote", "brown", "default"),
|
|
||||||
("opt_prompt", "black", "light gray"),
|
|
||||||
("opt_header", "light cyan", "default"),
|
|
||||||
("hover", "light cyan", "default"),
|
|
||||||
("dim", "dark gray", "default"),
|
|
||||||
("bold", "default,bold", "default"),
|
|
||||||
("underline", "default,underline", "default"),
|
|
||||||
|
|
||||||
# map the bbj api color values for display
|
# map the bbj api color values for display
|
||||||
("0", "default", "default"),
|
("0", "default", "default"),
|
||||||
("1", "dark red", "default"),
|
("1", "dark red", "default"),
|
||||||
# sounds ugly but brown is as close as we can get to yellow without being bold
|
# sounds ugly but brown is as close as we can get to yellow without being bold
|
||||||
("2", "brown", "default"),
|
("2", "brown", "default"),
|
||||||
("3", "dark green", "default"),
|
("3", "dark green", "default"),
|
||||||
("4", "dark blue", "default"),
|
("4", "dark blue", "default"),
|
||||||
("5", "dark cyan", "default"),
|
("5", "dark cyan", "default"),
|
||||||
("6", "dark magenta", "default"),
|
("6", "dark magenta", "default"),
|
||||||
|
|
||||||
# and have the bolded colors use the same values times 10
|
# and have the bolded colors use the same values times 10
|
||||||
("10", "light red", "default"),
|
("10", "light red", "default"),
|
||||||
("20", "yellow", "default"),
|
("20", "yellow", "default"),
|
||||||
("30", "light green", "default"),
|
("30", "light green", "default"),
|
||||||
("40", "light blue", "default"),
|
("40", "light blue", "default"),
|
||||||
("50", "light cyan", "default"),
|
("50", "light cyan", "default"),
|
||||||
("60", "light magenta", "default")
|
("60", "light magenta", "default")
|
||||||
]
|
]
|
||||||
|
|
||||||
|
class App(object):
|
||||||
|
def __init__(self):
|
||||||
|
self.prefs = bbjrc("load")
|
||||||
|
|
||||||
self.mode = None
|
self.mode = None
|
||||||
self.thread = None
|
self.thread = None
|
||||||
self.usermap = {}
|
self.usermap = {}
|
||||||
self.prefs = bbjrc("load")
|
|
||||||
self.window_split = False
|
self.window_split = False
|
||||||
self.last_pos = 0
|
self.last_pos = 0
|
||||||
# self.jump_stack = []
|
|
||||||
|
# these can be changed and manipulated by other methods
|
||||||
self.walker = urwid.SimpleFocusListWalker([])
|
self.walker = urwid.SimpleFocusListWalker([])
|
||||||
self.box = ActionBox(self.walker)
|
self.box = ActionBox(self.walker)
|
||||||
self.loop = urwid.MainLoop(urwid.Frame(
|
|
||||||
urwid.LineBox(
|
self.loop = urwid.MainLoop(
|
||||||
self.box,
|
urwid.Frame(
|
||||||
title=self.prefs["frame_title"],
|
urwid.LineBox(
|
||||||
**frame_theme()
|
self.box,
|
||||||
)), colors)
|
title=self.prefs["frame_title"],
|
||||||
|
**frame_theme()
|
||||||
|
)),
|
||||||
|
colormap)
|
||||||
|
|
||||||
self.index()
|
self.index()
|
||||||
|
|
||||||
|
@ -227,13 +229,11 @@ class App(object):
|
||||||
then concat text with format_specs applied to it. Applies
|
then concat text with format_specs applied to it. Applies
|
||||||
bar formatting to it.
|
bar formatting to it.
|
||||||
"""
|
"""
|
||||||
self.loop.widget.header = \
|
header = ("{}@bbj | " + text).format(
|
||||||
urwid.AttrMap(
|
(network.user_name or "anonymous"),
|
||||||
urwid.Text(
|
*format_specs
|
||||||
("{}@bbj | " + text).format(
|
)
|
||||||
(network.user_name or "anonymous"),
|
self.loop.widget.header = urwid.AttrMap(urwid.Text(header), "bar")
|
||||||
*format_specs)),
|
|
||||||
"bar")
|
|
||||||
|
|
||||||
|
|
||||||
def set_footer(self, string):
|
def set_footer(self, string):
|
||||||
|
@ -259,7 +259,7 @@ class App(object):
|
||||||
"""
|
"""
|
||||||
Sets the footer to the default for the current screen.
|
Sets the footer to the default for the current screen.
|
||||||
"""
|
"""
|
||||||
self.set_footer(self.bars[self.mode])
|
self.set_footer(bars[self.mode])
|
||||||
|
|
||||||
|
|
||||||
def set_bars(self):
|
def set_bars(self):
|
||||||
|
@ -279,7 +279,7 @@ class App(object):
|
||||||
if self.window_split:
|
if self.window_split:
|
||||||
self.window_split = False
|
self.window_split = False
|
||||||
self.loop.widget.focus_position = "body"
|
self.loop.widget.focus_position = "body"
|
||||||
self.set_footer(self.bars["thread"])
|
self.set_footer(bars["thread"])
|
||||||
else:
|
else:
|
||||||
self.loop.widget = self.loop.widget[0]
|
self.loop.widget = self.loop.widget[0]
|
||||||
self.set_default_header()
|
self.set_default_header()
|
||||||
|
@ -603,8 +603,8 @@ class App(object):
|
||||||
self.box.set_focus(len(self.walker) - 5)
|
self.box.set_focus(len(self.walker) - 5)
|
||||||
|
|
||||||
|
|
||||||
def back(self):
|
def back(self, and_quit=True):
|
||||||
if app.mode == "index":
|
if app.mode == "index" and and_quit:
|
||||||
frilly_exit()
|
frilly_exit()
|
||||||
elif app.mode == "thread":
|
elif app.mode == "thread":
|
||||||
self.index()
|
self.index()
|
||||||
|
@ -1259,7 +1259,7 @@ class ActionBox(urwid.ListBox):
|
||||||
self._keypress_up(size)
|
self._keypress_up(size)
|
||||||
|
|
||||||
elif key in ["h", "left"]:
|
elif key in ["h", "left"]:
|
||||||
app.back()
|
app.back(False)
|
||||||
|
|
||||||
elif key in ["l", "right"]:
|
elif key in ["l", "right"]:
|
||||||
self.keypress(size, "enter")
|
self.keypress(size, "enter")
|
||||||
|
@ -1502,13 +1502,13 @@ def ignore(*_, **__):
|
||||||
|
|
||||||
def main():
|
def main():
|
||||||
global app
|
global app
|
||||||
|
app = App()
|
||||||
|
app.usermap.update(network.user)
|
||||||
run("clear", shell=True)
|
run("clear", shell=True)
|
||||||
motherfucking_rainbows(obnoxious_logo)
|
motherfucking_rainbows(obnoxious_logo)
|
||||||
print(welcome)
|
print(welcome)
|
||||||
try:
|
try:
|
||||||
log_in()
|
log_in()
|
||||||
app = App()
|
|
||||||
app.usermap.update(network.user)
|
|
||||||
app.loop.run()
|
app.loop.run()
|
||||||
except (InterruptedError, KeyboardInterrupt):
|
except (InterruptedError, KeyboardInterrupt):
|
||||||
frilly_exit()
|
frilly_exit()
|
||||||
|
|
Loading…
Reference in New Issue