@@ -104,11 +104,13 @@ def scroll_region(self, stop):
104
104
def scroll_up (self , scrolling ):
105
105
self .scrbuf [scrolling :] = self .scrbuf [:- scrolling ]
106
106
self .scrbuf [:scrolling ] = ['' ] * scrolling
107
+ self .cursor (False )
107
108
self .goto (0 , 0 )
108
109
self .wr ("\x1b M" * scrolling )
109
110
def scroll_down (self , scrolling ):
110
111
self .scrbuf [:- scrolling ] = self .scrbuf [scrolling :]
111
112
self .scrbuf [- scrolling :] = ['' ] * scrolling
113
+ self .cursor (False )
112
114
self .goto (self .height - 1 , 0 )
113
115
self .wr ("\x1b D " * scrolling )
114
116
def set_screen_parms (self ):
@@ -291,8 +293,8 @@ def handle_cursor_keys(self, key):
291
293
except :
292
294
pass
293
295
elif key == 0x01 :
294
- self . autoindent = 'y' if self . autoindent != 'y' else 'n'
295
- self . autoindent = 'y' if self . autoindent != 'y' else 'n'
296
+
297
+
296
298
pat = self .line_edit ("Case Sensitive Search {}, Autoindent {}, Tab Size {}, Write Tabs {}: " .format (self .case , self .autoindent , self .tab_size , self .write_tabs ), "" )
297
299
try :
298
300
res = [i .strip ().lower () for i in pat .split ("," )]
@@ -320,7 +322,14 @@ def handle_cursor_keys(self, key):
320
322
self .top_line = min (self .top_line + 3 , self .total_lines - 1 )
321
323
self .cur_line = max (self .cur_line , self .top_line )
322
324
self .scroll_down (3 )
325
+ elif key == 0x14 :
326
+ self .cur_line = 0
327
+ elif key == 0x02 :
328
+ self .cur_line = self .total_lines - 1
329
+ self .row = self .height - 1
323
330
elif key == 0xfffe :
331
+ if self .col >= len (self .content [self .cur_line ]):
332
+ return True
324
333
opening = "([{<"
325
334
closing = ")]}>"
326
335
level = 0
@@ -360,11 +369,6 @@ def handle_cursor_keys(self, key):
360
369
level += 1
361
370
if i > 0 :
362
371
pos = len (self .content [i - 1 ]) - 1
363
- elif key == 0x14 :
364
- self .cur_line = 0
365
- elif key == 0x02 :
366
- self .cur_line = self .total_lines - 1
367
- self .row = self .height - 1
368
372
elif key == 0x0c :
369
373
self .mark = self .cur_line if self .mark == None else None
370
374
else :
@@ -573,25 +577,28 @@ def edit_loop(self):
573
577
self .display_window ()
574
578
key = self .get_input ()
575
579
self .message = ''
576
- if key == 0x11 :
577
- if self .changed != ' ' :
578
- res = self .line_edit ("Content changed! Quit without saving (y/N)? " , "N" )
579
- if not res or res [0 ].upper () != 'Y' :
580
- continue
581
- self .mouse_reporting (False )
582
- self .scroll_region (0 )
583
- self .goto (self .height , 0 )
584
- self .clear_to_eol ()
585
- return None
586
- elif key == 0x05 :
587
- self .set_screen_parms ()
588
- self .row = min (self .height - 1 , self .row )
589
- if sys .implementation .name == "micropython" :
590
- gc .collect ()
591
- self .message = "{} Bytes Memory available" .format (gc .mem_free ())
592
- elif self .handle_cursor_keys (key ):
593
- pass
594
- else : self .handle_edit_key (key )
580
+ try :
581
+ if key == 0x11 :
582
+ if self .changed != ' ' :
583
+ res = self .line_edit ("Content changed! Quit without saving (y/N)? " , "N" )
584
+ if not res or res [0 ].upper () != 'Y' :
585
+ continue
586
+ self .mouse_reporting (False )
587
+ self .scroll_region (0 )
588
+ self .goto (self .height , 0 )
589
+ self .clear_to_eol ()
590
+ return None
591
+ elif key == 0x05 :
592
+ self .set_screen_parms ()
593
+ self .row = min (self .height - 1 , self .row )
594
+ if sys .implementation .name == "micropython" :
595
+ gc .collect ()
596
+ self .message = "{} Bytes Memory available" .format (gc .mem_free ())
597
+ elif self .handle_cursor_keys (key ):
598
+ pass
599
+ else : self .handle_edit_key (key )
600
+ except Exception as err :
601
+ self .message = "Internal error: {}" .format (err )
595
602
def packtabs (self , s ):
596
603
from _io import StringIO
597
604
sb = StringIO ()
0 commit comments