diff --git a/src/core/cli.py b/src/core/cli.py index 08f1403a..c6e9cb21 100644 --- a/src/core/cli.py +++ b/src/core/cli.py @@ -13,6 +13,7 @@ opt = [] from bt.message import * import cline.loop +import cline.addch import cline.message #import settings from bt.needle import Needle @@ -29,6 +30,11 @@ def open(): settings.set("loop",cline.loop.loop) settings.set("loopquit",cline.loop.quit) + # Initialize a dictionary for key press inputs + settings.set("keyinput", dict()) + settings.get("keyinput")[127] = cline.addch.backspace + settings.get("keyinput")[10] = cline.addch.enter + @@ -38,6 +44,7 @@ def close(): #settings.pop("loopquit")() cline.loop.quit() write("CLI has been stopped", True) + settings.delete("keyinput") #cline.loop.quit() diff --git a/src/core/cline/addch.py b/src/core/cline/addch.py index e6ed01be..90d0424c 100644 --- a/src/core/cline/addch.py +++ b/src/core/cline/addch.py @@ -17,14 +17,16 @@ def addch(input): stdscr = settings.get("stdscr") c = stdscr.getch() - if c == 10: - input = enter(input) + #if c == 10: + # input = enter(input) - elif(c >= 32 and c<= 126): + if(c >= 32 and c<= 126): input += curses.keyname(c) - elif c == 127: - input = backspace(input) + keys = settings.get("keyinput") + if (c in keys.keys()) == True: + input = keys[c](input) + return input