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."
]
colornames = [
"none", "red", "yellow", "green", "blue",
"cyan", "magenta"
]
colors = [
"\033[1;31m", "\033[1;33m", "\033[1;33m",
"\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"]
default_prefs = {
"editor": os.getenv("EDITOR", default="nano"),
"integrate_external_editor": True,
@ -163,15 +161,12 @@ default_prefs = {
"max_text_width": 80
}
class App(object):
def __init__(self):
self.bars = {
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"
}
colors = [
colormap = [
("default", "default", "default"),
("bar", "light magenta", "default"),
("button", "light red", "default"),
@ -202,21 +197,28 @@ class App(object):
("60", "light magenta", "default")
]
class App(object):
def __init__(self):
self.prefs = bbjrc("load")
self.mode = None
self.thread = None
self.usermap = {}
self.prefs = bbjrc("load")
self.window_split = False
self.last_pos = 0
# self.jump_stack = []
# these can be changed and manipulated by other methods
self.walker = urwid.SimpleFocusListWalker([])
self.box = ActionBox(self.walker)
self.loop = urwid.MainLoop(urwid.Frame(
self.loop = urwid.MainLoop(
urwid.Frame(
urwid.LineBox(
self.box,
title=self.prefs["frame_title"],
**frame_theme()
)), colors)
)),
colormap)
self.index()
@ -227,13 +229,11 @@ class App(object):
then concat text with format_specs applied to it. Applies
bar formatting to it.
"""
self.loop.widget.header = \
urwid.AttrMap(
urwid.Text(
("{}@bbj | " + text).format(
header = ("{}@bbj | " + text).format(
(network.user_name or "anonymous"),
*format_specs)),
"bar")
*format_specs
)
self.loop.widget.header = urwid.AttrMap(urwid.Text(header), "bar")
def set_footer(self, string):
@ -259,7 +259,7 @@ class App(object):
"""
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):
@ -279,7 +279,7 @@ class App(object):
if self.window_split:
self.window_split = False
self.loop.widget.focus_position = "body"
self.set_footer(self.bars["thread"])
self.set_footer(bars["thread"])
else:
self.loop.widget = self.loop.widget[0]
self.set_default_header()
@ -603,8 +603,8 @@ class App(object):
self.box.set_focus(len(self.walker) - 5)
def back(self):
if app.mode == "index":
def back(self, and_quit=True):
if app.mode == "index" and and_quit:
frilly_exit()
elif app.mode == "thread":
self.index()
@ -1259,7 +1259,7 @@ class ActionBox(urwid.ListBox):
self._keypress_up(size)
elif key in ["h", "left"]:
app.back()
app.back(False)
elif key in ["l", "right"]:
self.keypress(size, "enter")
@ -1502,13 +1502,13 @@ def ignore(*_, **__):
def main():
global app
app = App()
app.usermap.update(network.user)
run("clear", shell=True)
motherfucking_rainbows(obnoxious_logo)
print(welcome)
try:
log_in()
app = App()
app.usermap.update(network.user)
app.loop.run()
except (InterruptedError, KeyboardInterrupt):
frilly_exit()