conf: use shutil.move instead of os.rename for saving
[urk.git] / scripts / history.py
blob379ad5e3eb5c26d0ecbac70ef2c6736f4a14c9bb
1 def onKeyPress(e):
2 if not hasattr(e.window, 'history'):
3 e.window.history = [], -1
5 if e.key in ('Up', 'Down'):
6 h, i = e.window.history
8 if i == -1 and e.window.input.text:
9 h.insert(0, e.window.input.text)
10 i = 0
12 if e.key == 'Up':
13 i += 1
15 if i < len(h):
16 e.window.history = h, i
18 e.window.input.text = h[i]
19 e.window.input.cursor = -1
21 else: # e.key == 'Up'
22 i -= 1
24 if i > -1:
25 e.window.history = h, i
27 e.window.input.text = h[i]
28 e.window.input.cursor = -1
30 elif i == -1:
31 e.window.history = h, i
33 e.window.input.text = ''
34 e.window.input.cursor = -1
36 def onInput(e):
37 if not hasattr(e.window, 'history'):
38 e.window.history = [], -1
40 if e.text:
41 h, i = e.window.history
43 h.insert(0, e.text)
45 e.window.history = h, -1