Command line shows multiple lines

This commit is contained in:
bjschuma 2009-12-20 18:23:02 -05:00
parent 1dd9f79553
commit 69fc5db07d
6 changed files with 47 additions and 11 deletions

View File

@ -37,6 +37,24 @@ def get(key, all=False):
return settings[key.upper()] return settings[key.upper()]
#def replace(key,value):
# global settings
# if (key in settings) == True:
# del settings[key]
# set(key,value)
def pop(key):
global settings
value = None
if (key in settings) == True:
values = settings[key]
if len(values) > 0:
value = values.pop(0)
return value
# Read settings from file # Read settings from file
def readfile(file): def readfile(file):
write("Reading file: "+file,True) write("Reading file: "+file,True)

View File

@ -17,6 +17,7 @@ from bt.message import *
import bt.needle import bt.needle
import cline.loop import cline.loop
import cline.message
import settings import settings
global maxxy, stdscr, thread global maxxy, stdscr, thread
@ -38,8 +39,9 @@ def open():
settings.set("stdscr", stdscr) settings.set("stdscr", stdscr)
settings.set("maxxy", maxxy) settings.set("maxxy", maxxy)
settings.set("prompt", ">>> ") settings.set("prompt", ">>> ")
#settings.set("clinex", 0) settings.set("clinex", 0)
#settings.set("cliney", 0) settings.set("cliney", 0)
settings.set("write", cline.message.insert)
# Start loop in new thread # Start loop in new thread
thread = bt.needle.Needle(cline.loop.loop) thread = bt.needle.Needle(cline.loop.loop)

View File

@ -20,18 +20,20 @@ def addch(input):
if c == 10: if c == 10:
input = enter(input) input = enter(input)
elif c == 127:
input = backspace(input)
elif(c >= 32 and c<= 126): elif(c >= 32 and c<= 126):
input += curses.keyname(c) input += curses.keyname(c)
elif c == 127:
input = backspace(input)
return input return input
# Remove the last character in input # Remove the last character in input
def backspace(input): def backspace(input):
stdscr = settings.get("stdscr")
stdscr.deleteln()
l = len(input) l = len(input)
if(l>4): if(l>4):
return input[:l-1] return input[:l-1]

View File

@ -13,7 +13,7 @@ import settings
# Command line related imports # Command line related imports
from addch import addch from addch import addch
from message import insert from message import *
global halt global halt
@ -28,11 +28,11 @@ def loop():
#stdscr = settings.get("stdscr") #stdscr = settings.get("stdscr")
input = settings.get("prompt") input = settings.get("prompt")
(y, x) = settings.get("stdscr").getyx() (y, x) = settings.get("stdscr").getyx()
insert(input, y) disp(input)
while halt == False: while halt == False:
input = addch(input) input = addch(input)
insert(input, y) disp(input)
def quit(): def quit():

View File

@ -8,8 +8,18 @@ __date__ ="$Dec 19, 2009 11:57:19 PM$"
import settings import settings
def insert(string, y):
stdscr = settings.get("stdscr")
stdscr.deleteln() # Add string to line y
def insert(string):
stdscr = settings.get("stdscr")
y = settings.pop("cliney")
y+=1
settings.set("cliney", y)
stdscr.addstr(y, 0, string) stdscr.addstr(y, 0, string)
# Replace the string on the current line
def disp(string):
stdscr = settings.get("stdscr")
stdscr.addstr(settings.get("cliney"), 0, string)
#insert(string, settings.get("cliney"))

View File

@ -7,6 +7,7 @@ __author__="bjschuma"
__date__ ="$Dec 19, 2009 11:38:46 PM$" __date__ ="$Dec 19, 2009 11:38:46 PM$"
from manager import manager from manager import manager
import settings
# Check for valid input # Check for valid input
@ -18,4 +19,7 @@ def run(input):
manager.run(split[0],split[1:]) manager.run(split[0],split[1:])
else: else:
manager.run(input) manager.run(input)
y = settings.get("cliney")
settings.replace("cliney", y+1)
return prompt return prompt