ocarina/src/plugins/cline/addch.py

48 lines
799 B
Python

#! /usr/bin/python
# To change this template, choose Tools | Templates
# and open the template in the editor.
__author__="bjschuma"
__date__ ="$Dec 19, 2009 11:19:43 PM$"
import curses
import settings
from bt.message import write
import message
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):
input += curses.keyname(c)
keys = settings.get("keyinput")
if (c in keys.keys()) == True:
input = keys[c](input)
#else:
# write(c)
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):
write(input)
input = run(input)
return input