97 lines
1.7 KiB
Python
97 lines
1.7 KiB
Python
#! /usr/bin/python
|
|
|
|
# To change this template, choose Tools | Templates
|
|
# and open the template in the editor.
|
|
|
|
__author__="bjschuma"
|
|
__date__ ="$Dec 19, 2009 9:39:37 PM$"
|
|
|
|
|
|
from bt.message import write
|
|
import manager
|
|
import settings
|
|
|
|
# Command line related imports
|
|
from addch import addch
|
|
from message import *
|
|
|
|
global halt
|
|
halt = True
|
|
|
|
|
|
|
|
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(10)
|
|
|
|
# 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)
|
|
settings.set("write", insert)
|
|
#settings.set("everyloop")
|
|
|
|
|
|
|
|
def quit():
|
|
# Halt our loop
|
|
global halt
|
|
|
|
if halt == True:
|
|
return
|
|
|
|
halt = True
|
|
|
|
# Undo ncurses initialization
|
|
curses.nocbreak()
|
|
curses.echo()
|
|
settings.get("stdscr").keypad(0)
|
|
curses.endwin()
|
|
|
|
# Delete keys that settings no longer needs
|
|
settings.delete("stdscr")
|
|
settings.delete("maxyx")
|
|
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():
|
|
global halt
|
|
|
|
halt = False
|
|
|
|
init()
|
|
|
|
stdscr = settings.get("stdscr")
|
|
input = settings.get("prompt")
|
|
disp(input)
|
|
|
|
while halt == False:
|
|
list = settings.get("everyloop",True)
|
|
if not list == None:
|
|
for func in list:
|
|
func()
|
|
try:
|
|
input = addch(input)
|
|
disp(input)
|
|
except:
|
|
pass
|
|
|
|
|