ocarina/src/core/cline/addch.py

45 lines
684 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 run import run
# (Sometimes) add a character to the input string
def addch(input):
stdscr = settings.get("stdscr")
c = stdscr.getch()
if c == 10:
enter(input)
elif c == 127:
input = backspace(input)
elif(c >= 32 and c<= 126):
input += curses.keyname(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):
run(input)