src/eric7/ViewManager/ViewManager.py

branch
server
changeset 10704
27d21e5163b8
parent 10680
306373ccf8fd
parent 10692
9becf9ca115c
child 10738
37101524dd76
equal deleted inserted replaced
10680:306373ccf8fd 10704:27d21e5163b8
146 self.__lastFocusWidget = None 146 self.__lastFocusWidget = None
147 147
148 # initialize the file system watcher 148 # initialize the file system watcher
149 watcher = EricFileSystemWatcher.instance() 149 watcher = EricFileSystemWatcher.instance()
150 watcher.fileModified.connect(self.__watchedFileChanged) 150 watcher.fileModified.connect(self.__watchedFileChanged)
151 watcher.error.connect(self.__watcherError)
151 152
152 self.__watchedFilePaths = [] 153 self.__watchedFilePaths = []
153 154
154 def setReferences(self, ui, dbs, remoteServerInterface): 155 def setReferences(self, ui, dbs, remoteServerInterface):
155 """ 156 """
5823 5824
5824 if newWin: 5825 if newWin:
5825 self._modificationStatusChanged(editor.isModified(), editor) 5826 self._modificationStatusChanged(editor.isModified(), editor)
5826 self._checkActions(editor) 5827 self._checkActions(editor)
5827 5828
5828 cline, cindex = editor.getCursorPosition() 5829 cline, _cindex = editor.getCursorPosition()
5829 cline += 1 5830 cline += 1
5830 if isinstance(lineno, list): 5831 if isinstance(lineno, list):
5831 if len(lineno) > 1: 5832 if len(lineno) > 1:
5832 for line in lineno: 5833 for line in lineno:
5833 if line > cline: 5834 if line > cline:
5995 """ 5996 """
5996 if not fn.startswith("<"): 5997 if not fn.startswith("<"):
5997 self.openSourceFile(fn, line) 5998 self.openSourceFile(fn, line)
5998 self.setFileLine(fn, line) 5999 self.setFileLine(fn, line)
5999 6000
6000 def setFileLine(self, fn, line, error=False, syntaxError=False): 6001 def setFileLine(self, fn, line, error=False):
6001 """ 6002 """
6002 Public method to update the user interface when the current program 6003 Public method to update the user interface when the current program
6003 or line changes. 6004 or line changes.
6004 6005
6005 @param fn filename of editor to update 6006 @param fn filename of editor to update
6006 @type str 6007 @type str
6007 @param line line number to highlight 6008 @param line line number to highlight
6008 @type int 6009 @type int
6009 @param error flag indicating an error highlight 6010 @param error flag indicating an error highlight
6010 @type bool 6011 @type bool
6011 @param syntaxError flag indicating a syntax error
6012 @type bool
6013 """ 6012 """
6014 try: 6013 try:
6015 newWin, self.currentEditor = self.getEditor(fn) 6014 newWin, self.currentEditor = self.getEditor(fn)
6016 except (OSError, UnicodeDecodeError): 6015 except (OSError, UnicodeDecodeError):
6017 return 6016 return
6021 eol = self.currentEditor.getEolIndicator() 6020 eol = self.currentEditor.getEolIndicator()
6022 zoom = self.currentEditor.getZoom() 6021 zoom = self.currentEditor.getZoom()
6023 self.__setSbFile(fn, line, encoding=enc, language=lang, eol=eol, zoom=zoom) 6022 self.__setSbFile(fn, line, encoding=enc, language=lang, eol=eol, zoom=zoom)
6024 6023
6025 # Change the highlighted line. 6024 # Change the highlighted line.
6026 self.currentEditor.highlight(line, error, syntaxError) 6025 self.currentEditor.highlight(line=line, error=error)
6027 6026
6028 self.currentEditor.highlightVisible() 6027 self.currentEditor.highlightVisible()
6029 self._checkActions(self.currentEditor, False) 6028 self._checkActions(self.currentEditor, False)
6030 6029
6031 if newWin: 6030 if newWin:
6217 fn, 6216 fn,
6218 self, 6217 self,
6219 filetype=filetype, 6218 filetype=filetype,
6220 tv=ericApp().getObject("TaskViewer"), 6219 tv=ericApp().getObject("TaskViewer"),
6221 ) 6220 )
6221
6222 self.addWatchedFilePath(fn)
6223
6222 editor = assembly.getEditor() 6224 editor = assembly.getEditor()
6223 self.editors.append(editor) 6225 self.editors.append(editor)
6224 self.__connectEditor(editor) 6226 self.__connectEditor(editor)
6225 self.__editorOpened() 6227 self.__editorOpened()
6226 self.editorOpened.emit(fn) 6228 self.editorOpened.emit(fn)
6227 self.editorOpenedEd.emit(editor) 6229 self.editorOpenedEd.emit(editor)
6228 self.editorCountChanged.emit(len(self.editors)) 6230 self.editorCountChanged.emit(len(self.editors))
6229
6230 self.addWatchedFilePath(fn)
6231 6231
6232 newWin = True 6232 newWin = True
6233 6233
6234 if newWin: 6234 if newWin:
6235 self._addView(assembly, fn, addNext=addNext, indexes=indexes) 6235 self._addView(assembly, fn, addNext=addNext, indexes=indexes)
8198 8198
8199 # for all other views record the modification time only 8199 # for all other views record the modification time only
8200 for editor in editorList: 8200 for editor in editorList:
8201 editor.recordModificationTime() 8201 editor.recordModificationTime()
8202 8202
8203 @pyqtSlot(int, str)
8204 def __watcherError(self, errno, strerror):
8205 """
8206 Private slot to handle an error of the file system watcher.
8207
8208 @param errno numeric error code
8209 @type int
8210 @param strerror error message as provided by the operating system
8211 @type str
8212 """
8213 if errno == 24:
8214 EricMessageBox.critical(
8215 self,
8216 self.tr("File System Watcher Error"),
8217 self.tr(
8218 """<p>The operating system resources for file system watches"""
8219 """ are exhausted. This limit should be increased. On a Linux"""
8220 """ system you should """
8221 """<ul>"""
8222 """<li>sudo nano /etc/sysctl.conf</li>"""
8223 """<li>add to the bottom "fs.inotify.max_user_instances"""
8224 """ = 1024"</li>"""
8225 """<li>save and close the editor</li>"""
8226 """<li>sudo sysctl -p</li>"""
8227 """</ul></p><p>Error Message: {0}</p>"""
8228 ).format(strerror),
8229 )
8230 else:
8231 EricMessageBox.critical(
8232 self,
8233 self.tr("File System Watcher Error"),
8234 self.tr(
8235 "The file system watcher reported an error with code <b>{0}</b>."
8236 "</p><p>Error Message: {1}</p>"
8237 ).format(errno, strerror),
8238 )
8239
8203 def addWatchedFilePath(self, filePath): 8240 def addWatchedFilePath(self, filePath):
8204 """ 8241 """
8205 Public method to add a file to the list of monitored files. 8242 Public method to add a file to the list of monitored files.
8206 8243
8207 @param filePath path of the file to be added 8244 @param filePath path of the file to be added

eric ide

mercurial