我目前正在使用文本编辑器。 if userInput == 68
行检查用户是否按了左箭头键,我认为代码已运行,但是即使使用^[[
,noecho()
仍会打印出来。这是代码
#!/usr/bin/env python3
from unicurses import *
from sys import *
stdscr = initscr()
start_color()
use_default_colors()
noecho()
fileLines = []
fileName = "test.txt"
currentY = 0
currentX = 0
userInput = ""
for i in range(0, 256):
curses.init_pair(i + 1, i, -1)
while True:
userInput = getch()
if userInput == 68:
currentX = currentX-1
move(currentY, currentX)
elif userInput == 127:
if currentX != 0:
currentX = currentX-1
move(currentY, currentX)
addstr(" ")
move(currentY, currentX)
else:
continue
else:
addstr(chr(userInput))
currentX = currentX+1
endwin()