editors/CodeFileEditor.py
changeset 1139 f9cf74053b7d
parent 1138 cf2a6a7c87e8
child 1146 510d1ea1f6c1
equal deleted inserted replaced
1138:cf2a6a7c87e8 1139:f9cf74053b7d
   289         key = event.GetKeyCode()
   289         key = event.GetKeyCode()
   290         current_pos = self.GetCurrentPos()
   290         current_pos = self.GetCurrentPos()
   291         selected = self.GetSelection()
   291         selected = self.GetSelection()
   292         text_selected = selected[0] != selected[1]
   292         text_selected = selected[0] != selected[1]
   293         
   293         
       
   294         # Test if caret is before Windows like new line
       
   295         text = self.GetText()
       
   296         if ord(text[current_pos]) == 13:
       
   297             newline_size = 2
       
   298         else:
       
   299             newline_size = 1
       
   300         
   294         # Disable to type any character in section header lines
   301         # Disable to type any character in section header lines
   295         if (self.GetLineState(self.LineFromPosition(current_pos)) and
   302         if (self.GetLineState(self.LineFromPosition(current_pos)) and
   296             not text_selected and
   303             not text_selected and
   297             key not in NAVIGATION_KEYS + [
   304             key not in NAVIGATION_KEYS + [
   298                 wx.WXK_RETURN,
   305                 wx.WXK_RETURN,
   302         # Disable to delete line between code and header lines
   309         # Disable to delete line between code and header lines
   303         elif (self.GetCurLine()[0].strip() != "" and not text_selected and
   310         elif (self.GetCurLine()[0].strip() != "" and not text_selected and
   304               (key == wx.WXK_BACK and
   311               (key == wx.WXK_BACK and
   305                self.GetLineState(self.LineFromPosition(max(0, current_pos - 1))) or
   312                self.GetLineState(self.LineFromPosition(max(0, current_pos - 1))) or
   306                key in [wx.WXK_DELETE, wx.WXK_NUMPAD_DELETE] and
   313                key in [wx.WXK_DELETE, wx.WXK_NUMPAD_DELETE] and
   307                self.GetLineState(self.LineFromPosition(min(len(self.GetText()), current_pos + 1))))):
   314                self.GetLineState(self.LineFromPosition(min(len(text), current_pos + newline_size))))):
   308             return
   315             return
   309         
   316         
   310         elif key == 32 and event.ControlDown():
   317         elif key == 32 and event.ControlDown():
   311             pos = self.GetCurrentPos()
   318             pos = self.GetCurrentPos()
   312 
   319