minor aestetic changes: move some contsnts to global scope

pull/4/head
Blake DeMarcy 2017-04-13 01:21:29 -05:00
parent eca255af1b
commit a4ee100b53
1 changed files with 56 additions and 56 deletions

View File

@ -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,15 +161,12 @@ default_prefs = {
"max_text_width": 80 "max_text_width": 80
} }
bars = {
class App(object):
def __init__(self):
self.bars = {
"index": "[RET]Open [C]ompose [R]efresh [O]ptions [?]Help [Q]uit", "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" "thread": "[C]ompose [RET]Interact [Q]Back [R]efresh [B/T]End [?]Help"
} }
colors = [ colormap = [
("default", "default", "default"), ("default", "default", "default"),
("bar", "light magenta", "default"), ("bar", "light magenta", "default"),
("button", "light red", "default"), ("button", "light red", "default"),
@ -202,21 +197,28 @@ class App(object):
("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(
self.loop = urwid.MainLoop(
urwid.Frame(
urwid.LineBox( urwid.LineBox(
self.box, self.box,
title=self.prefs["frame_title"], title=self.prefs["frame_title"],
**frame_theme() **frame_theme()
)), colors) )),
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(
urwid.Text(
("{}@bbj | " + text).format(
(network.user_name or "anonymous"), (network.user_name or "anonymous"),
*format_specs)), *format_specs
"bar") )
self.loop.widget.header = urwid.AttrMap(urwid.Text(header), "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()