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 # Disable all plugins
def shutdown(self): def shutdown(self):
settings.get("loopquit")()
write("Shutting down manager, disabling all active plugins", True) write("Shutting down manager, disabling all active plugins", True)
self.savesession() self.savesession()
keys = self.enabled.keys() keys = self.enabled.keys()

View File

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

View File

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

View File

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