diff --git a/src/base/manager.py b/src/base/manager.py index 2192f2bf..53f9e45b 100644 --- a/src/base/manager.py +++ b/src/base/manager.py @@ -82,5 +82,9 @@ class Manager: self.disablePlugin(plugin) + def run(self,name,args=None): + self.enabled[name].run(args) + + global manager manager = Manager() \ No newline at end of file diff --git a/src/core/cli.py b/src/core/cli.py index 0b46167d..7475f421 100644 --- a/src/core/cli.py +++ b/src/core/cli.py @@ -37,8 +37,9 @@ def open(): # 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) + settings.set("prompt", ">>> ") + #settings.set("clinex", 0) + #settings.set("cliney", 0) # Start loop in new thread thread = bt.needle.Needle(cline.loop.loop) @@ -60,5 +61,5 @@ def close(): # Called when the plugin needs to perform some action -def run(): +def run(args=None): pass diff --git a/src/core/cline/__init__.py b/src/core/cline/__init__.py index 008ac991..5a4040fe 100644 --- a/src/core/cline/__init__.py +++ b/src/core/cline/__init__.py @@ -2,4 +2,4 @@ __author__="bjschuma" __date__ ="$Dec 19, 2009 9:13:05 PM$" -__all__ = ["addch", "loop"] \ No newline at end of file +__all__ = ["addch", "check", "loop", "message"] \ No newline at end of file diff --git a/src/core/cline/addch.py b/src/core/cline/addch.py index 0c09eceb..3d360fe0 100644 --- a/src/core/cline/addch.py +++ b/src/core/cline/addch.py @@ -10,12 +10,36 @@ __date__ ="$Dec 19, 2009 11:19:43 PM$" import curses import settings +from run import run +# (Sometimes) add a character to the input string def addch(input): stdscr = settings.get("stdscr") c = stdscr.getch() - if(c >= 32 and c<= 126): + if c == 10: + enter(input) + + elif c == 127: + input = backspace(input) + + elif(c >= 32 and c<= 126): input += curses.keyname(c) - return input \ No newline at end of file + return input + + + +# Remove the last character in input +def backspace(input): + l = len(input) + if(l>4): + return input[:l-1] + else: + return input + + + +# Attempt to run a command +def enter(input): + run(input) \ No newline at end of file diff --git a/src/core/cline/loop.py b/src/core/cline/loop.py index eee3ae35..37d5e15e 100644 --- a/src/core/cline/loop.py +++ b/src/core/cline/loop.py @@ -9,30 +9,31 @@ __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 insert global halt halt = False + +# Loop around until the plugin manager calls shutdown def loop(): write("Beginning command line loop",True) global halt #stdscr = settings.get("stdscr") - input = "" + input = settings.get("prompt") + (y, x) = settings.get("stdscr").getyx() + insert(input, y) while halt == False: input = addch(input) - - #input=input[:x-4]+curses.keyname(c)+input[x-4:] - #self.changeLine(y) - #self.stdscr.move(y,x+1) - if input == "exit": - manager.manager.shutdown() - halt = True + #check(input) + insert(input, y) def quit(): diff --git a/src/core/cline/message.py b/src/core/cline/message.py new file mode 100644 index 00000000..fcc3fa4a --- /dev/null +++ b/src/core/cline/message.py @@ -0,0 +1,15 @@ +#! /usr/bin/python + +# To change this template, choose Tools | Templates +# and open the template in the editor. + +__author__="bjschuma" +__date__ ="$Dec 19, 2009 11:57:19 PM$" + +import settings + +def insert(string, y): + stdscr = settings.get("stdscr") + + stdscr.deleteln() + stdscr.addstr(y, 0, string) diff --git a/src/core/cline/run.py b/src/core/cline/run.py new file mode 100644 index 00000000..cd53034f --- /dev/null +++ b/src/core/cline/run.py @@ -0,0 +1,19 @@ +#! /usr/bin/python + +# To change this template, choose Tools | Templates +# and open the template in the editor. + +__author__="bjschuma" +__date__ ="$Dec 19, 2009 11:38:46 PM$" + +from manager import manager + + +# Check for valid input +def run(input): + input = input[4:] + split = input.split() + if len(split)>1: + manager.run(split[0],split[1:]) + else: + manager.run(input) diff --git a/src/core/example.py b/src/core/example.py index 443e2749..5e9ea0dd 100644 --- a/src/core/example.py +++ b/src/core/example.py @@ -26,5 +26,5 @@ def close(): # Called when the plugin needs to perform some action -def run(): +def run(args=None): pass diff --git a/src/core/exit.py b/src/core/exit.py new file mode 100644 index 00000000..8ed2fb62 --- /dev/null +++ b/src/core/exit.py @@ -0,0 +1,34 @@ +#! /usr/bin/python + +# To change this template, choose Tools | Templates +# and open the template in the editor. + +__author__="bjschuma" +__date__ ="$Dec 20, 2009 12:24:44 AM$" + + + +global name, app, type, path, opt +name = "exit" +app = "scion" +type = "core" +path = "" +opt = [] + + +from manager import manager + + +# Called every time the plugin is enabled +def open(): + pass + + +# Called every time the plugin is stopped +def close(): + pass + + +# Called when the plugin needs to perform some action +def run(args=None): + manager.shutdown() diff --git a/src/core/reload.py b/src/core/reload.py new file mode 100644 index 00000000..b5bfd5a3 --- /dev/null +++ b/src/core/reload.py @@ -0,0 +1,34 @@ +#! /usr/bin/python + +# To change this template, choose Tools | Templates +# and open the template in the editor. + +__author__="bjschuma" +__date__ ="$Dec 20, 2009 12:30:00 AM$" + + +global name, app, type, path, opt +name = "reload" +app = "scion" +type = "core" +path = "" +opt = [] + + +from manager import manager + + +# Called every time the plugin is enabled +def open(): + pass + + +# Called every time the plugin is stopped +def close(): + pass + + +# Called when the plugin needs to perform some action +def run(args=None): + for plugin in args: + manager.reloadPlugin(plugin)