improve rainbow vomit

pull/4/head
Blake DeMarcy 2017-04-05 17:09:13 -05:00
parent ef5d1a2869
commit 65de379982
1 changed files with 22 additions and 8 deletions

View File

@ -1,7 +1,7 @@
from time import time, sleep, localtime from time import time, sleep, localtime
from random import choice, randrange
from string import punctuation from string import punctuation
from subprocess import run from subprocess import run
from random import choice
from network import BBJ from network import BBJ
import urwid import urwid
@ -37,6 +37,8 @@ colors = [
class App: class App:
def __init__(self): def __init__(self):
self.mode = None self.mode = None
self.thread = None
self.usermap = {}
colors = [ colors = [
("bar", "light magenta", "default"), ("bar", "light magenta", "default"),
("button", "light red", "default"), ("button", "light red", "default"),
@ -93,9 +95,11 @@ class App:
def index(self): def index(self):
self.mode = "index" self.mode = "index"
self.thread = None
threads, usermap = network.thread_index() threads, usermap = network.thread_index()
self.usermap.update(usermap)
self.set_header("{} threads", len(threads)) self.set_header("{} threads", len(threads))
self.set_footer("Refresh", "Compose", "/Search", "?Help") self.set_footer("Refresh", "Compose", "Quit", "/Search", "?Help")
walker = self.loop.widget.body.base_widget.body walker = self.loop.widget.body.base_widget.body
walker.clear() walker.clear()
for thread in threads: for thread in threads:
@ -121,10 +125,13 @@ class App:
def thread_load(self, button, thread_id): def thread_load(self, button, thread_id):
self.mode = "thread" self.mode = "thread"
thread, usermap = network.thread_load(thread_id) thread, usermap = network.thread_load(thread_id)
self.usermap.update(usermap)
self.thread = thread
walker = self.loop.widget.body.base_widget.body walker = self.loop.widget.body.base_widget.body
walker.clear() walker.clear()
self.set_header("~{}: {}", self.set_header("~{}: {}",
usermap[thread["author"]]["user_name"], thread["title"]) usermap[thread["author"]]["user_name"], thread["title"])
self.set_footer("Compose", "Refresh", "\"Quote", "/Search", "<Top", ">End", "QBack")
for message in thread["messages"]: for message in thread["messages"]:
name = urwid.Text("~{}".format(usermap[message["author"]]["user_name"])) name = urwid.Text("~{}".format(usermap[message["author"]]["user_name"]))
info = "@ " + self.date_format.format(*localtime(message["created"])) info = "@ " + self.date_format.format(*localtime(message["created"]))
@ -143,6 +150,13 @@ class App:
]] ]]
# def compose(self):
# if self.mode == "index":
# feedback = "Starting a new thread..."
# elif self.mode == "thread":
# feedback = "Replying in "
class ActionBox(urwid.ListBox): class ActionBox(urwid.ListBox):
@ -156,13 +170,13 @@ class ActionBox(urwid.ListBox):
if app.mode == "index": if app.mode == "index":
app.loop.stop() app.loop.stop()
# run("clear", shell=True) # run("clear", shell=True)
width, height = urwid.raw_display.Screen().get_cols_rows() width, height = app.loop.screen_size
for x in range(height - 1): for x in range(height - 1):
line = str() motherfucking_rainbows(
for x in range(width): "".join([choice([" ", choice(punctuation)]) for x in range(width)])
line += choice([" ", choice(punctuation)]) )
motherfucking_rainbows(line) out = " ~~CoMeE BaCkK SooOn~~ 0000000"
sleep(0.008) motherfucking_rainbows(out.zfill(width))
exit() exit()
else: app.index() else: app.index()