Created a way to call a list of functions for every iteration of the command

line loop
This commit is contained in:
bjschuma 2010-01-09 15:25:07 -05:00
parent c6ba496794
commit 27bcf9f341
4 changed files with 19 additions and 6 deletions

View File

@ -82,6 +82,7 @@ class Manager:
# Disable all plugins
def shutdown(self):
settings.get("loopquit")()
write("Shutting down manager, disabling all active plugins", True)
self.savesession()
keys = self.enabled.keys()

View File

@ -119,6 +119,7 @@ def clean():
delete("plugpath")
delete("verbose")
delete("loop")
delete("loopquit")
def save(path):

View File

@ -23,14 +23,12 @@ def open():
write("Starting CLI", True)
# Tell settings to run this loop
settings.set("loop",cline.loop.loop)
settings.set("loopquit",cline.loop.quit)
# Called every time the plugin is stopped
def close():
# Stop loop
cline.loop.quit()
settings.pop("loop")
write("CLI has been stopped", True)

View File

@ -21,12 +21,14 @@ halt = False
def init():
write("Beginning command line loop",True)
# Initialize ncurses screen
stdscr = curses.initscr()
maxyx = stdscr.getmaxyx()
curses.cbreak()
curses.noecho()
stdscr.keypad(1)
curses.halfdelay(100)
# Set these values in settings class for use elsewhere
settings.set("stdscr", stdscr)
@ -35,6 +37,7 @@ def init():
settings.set("clinex", 0)
settings.set("cliney", 0)
settings.set("write", insert)
#settings.set("everyloop")
@ -56,15 +59,16 @@ def quit():
settings.delete("prompt")
settings.delete("clinex")
settings.delete("cliney")
settings.delete("everyloop")
# Return to previous write function
settings.pop("write")
write("Command line loop has ended",True)
# Loop around until the plugin manager calls shutdown
def loop():
write("Beginning command line loop",True)
global halt
init()
@ -75,7 +79,16 @@ def loop():
disp(input)
while halt == False:
input = addch(input)
disp(input)
list = settings.get("everyloop",True)
#print list
if not list == None:
for func in list:
#write("here!")
func()
try:
input = addch(input)
disp(input)
except:
pass