ocarina/src/core/cli.py

72 lines
1.3 KiB
Python

#! /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 cline.message
import settings
global maxyx, stdscr, thread
threads = []
# Called every time the plugin is enabled
def open():
write("Starting CLI", True)
global maxyx, stdscr, thread
# Initialize ncurses screen
stdscr = curses.initscr()
maxyx = stdscr.getmaxyx()
curses.cbreak()
curses.noecho()
stdscr.keypad(1)
# Set these values in settings class for use elsewhere
settings.set("stdscr", stdscr)
settings.set("maxyx", maxyx)
settings.set("prompt", ">>> ")
settings.set("clinex", 0)
settings.set("cliney", 0)
# Start loop in new thread
thread = bt.needle.Needle(cline.loop.loop)
thread.start()
settings.set("write", cline.message.insert)
# Called every time the plugin is stopped
def close():
global stdscr, thread
settings.pop("write")
# Stop looping
cline.loop.quit()
# Undo ncurses initialization
curses.nocbreak()
curses.echo()
stdscr.keypad(0)
curses.endwin()
#thread.join()
write("CLI has been stopped", True)
# Called when the plugin needs to perform some action
def run(args=None):
pass