editors/CodeFileEditor.py
changeset 1117 1aef6a7db08d
parent 1115 a4e58715ae41
child 1124 b1705000eba1
equal deleted inserted replaced
1116:300f98a8d4c6 1117:1aef6a7db08d
   204         parts = self.Controler.GetTextParts()
   204         parts = self.Controler.GetTextParts()
   205         text = ""
   205         text = ""
   206         for section in SECTIONS_NAMES:
   206         for section in SECTIONS_NAMES:
   207             section_comments = self.SectionsComments[section]
   207             section_comments = self.SectionsComments[section]
   208             text += section_comments["comment"]
   208             text += section_comments["comment"]
   209             if not parts[section].startswith("\n") or parts[section] == "\n":
   209             if parts[section] == "":
   210                 text += "\n"
   210                 text += "\n"
   211             text += parts[section]
   211             else:
   212             if not parts[section].endswith("\n"):
   212                 if not parts[section].startswith("\n"):
   213                 text += "\n"
   213                     text += "\n"
       
   214                 text += parts[section]
       
   215                 if not parts[section].endswith("\n"):
       
   216                     text += "\n"
   214         return text
   217         return text
   215 
   218 
   216     def RefreshView(self, scroll_to_highlight=False):
   219     def RefreshView(self, scroll_to_highlight=False):
   217         self.ResetBuffer()
   220         self.ResetBuffer()
   218         self.DisableEvents = True
   221         self.DisableEvents = True
   271 
   274 
   272     def OnKeyPressed(self, event):
   275     def OnKeyPressed(self, event):
   273         if self.CallTipActive():
   276         if self.CallTipActive():
   274             self.CallTipCancel()
   277             self.CallTipCancel()
   275         key = event.GetKeyCode()
   278         key = event.GetKeyCode()
   276         caret = self.GetSelection()[0]
   279         current_pos = self.GetSelection()[0]
   277         print (key in [wx.WXK_DELETE, wx.WXK_NUMPAD_DELETE], 
   280         
   278                self.GetLineState(self.LineFromPosition(min(len(self.GetText()), caret + 1))))
   281         if (self.GetLineState(self.LineFromPosition(current_pos)) and
   279         
   282             key not in NAVIGATION_KEYS + [
   280         if (self.GetLineState(self.LineFromPosition(caret)) and
   283                 wx.WXK_RETURN,
   281             key not in NAVIGATION_KEYS or
   284                 wx.WXK_NUMPAD_ENTER]):
   282             key == wx.WXK_BACK and
       
   283             self.GetLineState(self.LineFromPosition(max(0, caret - 1))) or
       
   284             key in [wx.WXK_DELETE, wx.WXK_NUMPAD_DELETE] and
       
   285             self.GetLineState(self.LineFromPosition(min(len(self.GetText()), caret + 1)))):
       
   286             return
   285             return
   287         
   286         
   288         elif key == 32 and event.ControlDown():
   287         elif key == 32 and event.ControlDown():
   289             pos = self.GetCurrentPos()
   288             pos = self.GetCurrentPos()
   290 
   289