Пример #1
0
 def _show_follow_mode(self):
     if type(self._tabs.obtain_editor()) is not Editor:
         return
     if self._tabs2.isVisible() and not self._follow_mode:
         self.show_split(self.orientation())
     if self._follow_mode:
         self._follow_mode = False
         self._tabs2._close_tab(0)
         self._tabs2.hide()
         self._tabs2.setTabsClosable(True)
         self._tabs._follow_mode = False
         self._tabs2._follow_mode = False
     else:
         #check if is instance of Editor
         self._follow_mode = True
         self.setOrientation(Qt.Horizontal)
         editor = self._tabs.obtain_editor()
         name = str(self._tabs.tabText(self._tabs.currentIndex()))
         editor2 = factory_editor(
             manage_files.get_file_extension(name)[1:], self._tabs2)
         editor2.setPlainText(editor.get_text())
         editor2.setReadOnly(True)
         self._tabs2.add_tab(editor2, name)
         if editor.textModified:
             self._tabs2.mark_as_changed(True)
         self._tabs._follow_mode = True
         self._tabs2._follow_mode = True
         self._tabs2.show()
         editor2.verticalScrollBar().setRange(editor.sidebarWidget.highest_line - 2, 0)
         self._tabs2.setTabsClosable(False)
         self.setSizes([1, 1])
Пример #2
0
 def open_document(self, fileName, project=None):
     try:
         if not self._central.actual_tab().is_open(fileName):
             self._central.actual_tab().notOpening = False
             editor = factory_editor(fileName, self._central.actual_tab(), project)
             content = self.read_file_content(fileName)
             editor.setPlainText(content)
             editor.path = fileName
             editor.ask_if_externally_modified = True
             #self.add_tab(editor, self.get_file_name(fileName))
             if not editor.has_write_permission():
                 fileName += ' (Read-Only)'
             self.add_tab(editor, self.get_file_name(fileName))
             self.change_window_title(fileName)
             editor.find_errors_and_check_style()
         else:
             self._central.actual_tab().move_to_open(fileName)
     except Exception, reason:
         print reason
         QMessageBox.information(self, 'Incorrect File', 'The file couldn\'t be open')
Пример #3
0
 def open_file(self):
     fileName = unicode(QFileDialog.getOpenFileName(self, 'Open File',
                         resources.workspace, '(*.py);;(*.*)'))
     if not fileName:
         return
     try:
         if not self._central.actual_tab().is_open(fileName):
             self._central.actual_tab().notOpening = False
             content = self.read_file_content(fileName)
             editor = factory_editor(fileName, self._central.actual_tab())
             editor.setPlainText(content)
             editor.path = fileName
             #self.add_tab(editor, self.get_file_name(fileName))
             if not editor.has_write_permission():
                 fileName += ' (Read-Only)'
             self.add_tab(editor, self.get_file_name(fileName))
             self.change_window_title(fileName)
         else:
             self._central.actual_tab().move_to_open(fileName)
     except Exception, reason:
         print reason
         QMessageBox.information(self, 'Incorrect File', 'The file does not exist!')
Пример #4
0
 def new_editor(self, lang='py'):
     if not self._reloading:
         editor = factory_editor(lang, self._central.actual_tab())
         self.add_tab(editor, 'New Document')