185 |
# Keys to move around |
# Keys to move around |
186 |
if key == "Left" or key == "Right" \ |
if key == "Left" or key == "Right" \ |
187 |
or key == "Up" or key == "Down" \ |
or key == "Up" or key == "Down" \ |
188 |
or key == "Home" or key == "End": |
or key == "Home" or key == "End" \ |
189 |
|
or key == "Ctrl-HomE" or key == "Ctrl-EnD": |
190 |
|
|
191 |
self.ppv.viewMode = self.ppv.TEXT_EDITING |
self.ppv.viewMode = self.ppv.TEXT_EDITING |
192 |
self.ppv.showLinkbuoys = 0 |
self.ppv.showLinkbuoys = 0 |
204 |
if key == "Right": |
if key == "Right": |
205 |
if offs < len(c.t()): |
if offs < len(c.t()): |
206 |
self.avc.setCursorOffset(offs+1) |
self.avc.setCursorOffset(offs+1) |
207 |
|
if key == "Ctrl-HomE": |
208 |
|
self.avc.setCursorOffset(0) |
209 |
|
if key == "Ctrl-EnD": |
210 |
|
self.avc.setCursorOffset(len(c.t())) |
211 |
|
if key == "Home": |
212 |
|
pre_breaks = c.t()[0:offs].count("\n") |
213 |
|
if pre_breaks == 0: |
214 |
|
self.avc.setCursorOffset(0) |
215 |
|
else: |
216 |
|
lines = c.t()[0:offs].split("\n") |
217 |
|
self.avc.setCursorOffset(offs - len(lines[len(lines)-1])) |
218 |
|
if key == "End": |
219 |
|
post_breaks = c.t()[offs:].count("\n") |
220 |
|
if post_breaks == 0: |
221 |
|
self.avc.setCursorOffset(len(c.t())) |
222 |
|
else: |
223 |
|
lines = c.t()[offs:].split("\n") |
224 |
|
self.avc.setCursorOffset(offs + len(lines[0])) |
225 |
if key == "Up": |
if key == "Up": |
226 |
self.avc.setCursorOffset(0) |
pre_breaks = c.t()[0:offs].count("\n") |
227 |
|
if pre_breaks == 0: |
228 |
|
self.avc.setCursorOffset(0) |
229 |
|
else: |
230 |
|
lines = c.t()[0:offs].split("\n") |
231 |
|
lineoffs = len(lines[len(lines)-1]) |
232 |
|
if len(lines[pre_breaks-1]) >= lineoffs: |
233 |
|
self.avc.setCursorOffset(offs - (lineoffs+1) \ |
234 |
|
- (len(lines[pre_breaks-1]) - lineoffs)) |
235 |
|
else: |
236 |
|
self.avc.setCursorOffset(offs - (lineoffs+1)) |
237 |
if key == "Down": |
if key == "Down": |
238 |
self.avc.setCursorOffset(len(c.t())) |
post_breaks = c.t()[offs:].count("\n") |
239 |
|
if post_breaks == 0: |
240 |
|
self.avc.setCursorOffset(len(c.t())) |
241 |
|
else: |
242 |
|
lines = c.t()[0:offs].split("\n") |
243 |
|
lineoffs = len(lines[len(lines)-1]) |
244 |
|
lines = c.t()[offs:].split("\n") |
245 |
|
print "Lineoffs: %s" % (lineoffs) |
246 |
|
if len(lines[1]) >= lineoffs: |
247 |
|
self.avc.setCursorOffset(offs + (len(lines[0])+1) \ |
248 |
|
+ lineoffs) |
249 |
|
else: |
250 |
|
self.avc.setCursorOffset(offs + (len(lines[0])+1) \ |
251 |
|
+ len(lines[1])) |
252 |
# Keys to edit text |
# Keys to edit text |
253 |
if len(key) == 1 or key == "Backspace" or \ |
if len(key) == 1 or key == "Backspace" or \ |
254 |
key == "Delete" or key == "Return": |
key == "Delete" or key == "Return": |