#! /usr/bin/python __author__="bjschuma" __date__ ="$Dec 18, 2009 12:08:57 AM$" global name, app, type, path, opt name = "cli" app = "scion" type = "core" path = "" opt = [] import curses from bt.message import * #from bt.needle import Needle import bt.needle import cline.loop import settings global maxxy, stdscr, thread threads = [] # Called every time the plugin is enabled def open(): write("Starting CLI", True) global maxxy, stdscr, thread # Initialize ncurses screen stdscr = curses.initscr() maxxy = stdscr.getmaxyx() curses.cbreak() curses.noecho() stdscr.keypad(1) # Set these values in settings class for use elsewhere settings.set("stdscr", stdscr) settings.set("maxxy", maxxy) settings.set("clinex", 0) settings.set("cliney", 0) # Start loop in new thread thread = bt.needle.Needle(cline.loop.loop) thread.start() # Called every time the plugin is stopped def close(): global stdscr, thread # Undo ncurses initialization curses.nocbreak() curses.echo() stdscr.keypad(0) curses.endwin() # Stop looping cline.loop.quit() #thread.join() write("CLI has been stopped", True) # Called when the plugin needs to perform some action def run(): pass