Add the Slipnet to the curses reporter.
This isn't terribly useful to the human observer, actually. It seems like the most useful factors that ought to be displayed are really the groups/bonds in the workspace and the current "rule" (if any). Particularly, with the current design of Copycat, it seems like the "rule" should be part of the displayed output just the same as the modified target string.
This commit is contained in:
@ -1,6 +1,7 @@
|
||||
import curses
|
||||
from copycat import Reporter
|
||||
|
||||
|
||||
class CursesReporter(Reporter):
|
||||
def __init__(self, window):
|
||||
curses.curs_set(0) # hide the cursor
|
||||
@ -98,7 +99,40 @@ class CursesReporter(Reporter):
|
||||
w.refresh()
|
||||
|
||||
def report_slipnet(self, slipnet):
|
||||
pass
|
||||
w = self.slipnetWindow
|
||||
pageHeight, pageWidth = w.getmaxyx()
|
||||
w.erase()
|
||||
w.addstr(1, 2, 'Total: %d slipnodes and %d sliplinks' % (
|
||||
len(slipnet.slipnodes),
|
||||
len(slipnet.sliplinks),
|
||||
))
|
||||
|
||||
def name_and_attr(node):
|
||||
if node.activation == 100:
|
||||
return (node.name.upper(), curses.A_STANDOUT)
|
||||
if node.activation > 50:
|
||||
return (node.name.upper(), curses.A_BOLD)
|
||||
else:
|
||||
return (node.name.lower(), curses.A_NORMAL)
|
||||
|
||||
for c, node in enumerate(slipnet.letters):
|
||||
s, attr = name_and_attr(node)
|
||||
w.addstr(2, 2 * c + 2, s, attr)
|
||||
for c, node in enumerate(slipnet.numbers):
|
||||
s, attr = name_and_attr(node)
|
||||
w.addstr(3, 2 * c + 2, s, attr)
|
||||
row = 4
|
||||
column = 2
|
||||
for node in slipnet.slipnodes:
|
||||
if node not in slipnet.letters + slipnet.numbers:
|
||||
s, attr = name_and_attr(node)
|
||||
if column + len(s) > pageWidth - 1:
|
||||
row += 1
|
||||
column = 2
|
||||
w.addstr(row, column, s, attr)
|
||||
column += len(s) + 1
|
||||
w.border()
|
||||
w.refresh()
|
||||
|
||||
def report_temperature(self, temperature):
|
||||
height = self.temperatureWindow.getmaxyx()[0]
|
||||
|
||||
Reference in New Issue
Block a user