1271 Private method to select a specific pygments lexer. |
1271 Private method to select a specific pygments lexer. |
1272 |
1272 |
1273 @return name of the selected pygments lexer (string) |
1273 @return name of the selected pygments lexer (string) |
1274 """ |
1274 """ |
1275 from pygments.lexers import get_all_lexers |
1275 from pygments.lexers import get_all_lexers |
1276 lexerList = sorted([l[0] for l in get_all_lexers()]) |
1276 lexerList = sorted(l[0] for l in get_all_lexers()) |
1277 try: |
1277 try: |
1278 lexerSel = lexerList.index( |
1278 lexerSel = lexerList.index( |
1279 self.getLanguage(normalized=False, forPygments=True)) |
1279 self.getLanguage(normalized=False, forPygments=True)) |
1280 except ValueError: |
1280 except ValueError: |
1281 lexerSel = 0 |
1281 lexerSel = 0 |
3000 |
3000 |
3001 from . import Lexers |
3001 from . import Lexers |
3002 if self.fileName: |
3002 if self.fileName: |
3003 filterPattern = "(*{0})".format( |
3003 filterPattern = "(*{0})".format( |
3004 os.path.splitext(self.fileName)[1]) |
3004 os.path.splitext(self.fileName)[1]) |
3005 for filter in Lexers.getSaveFileFiltersList(True): |
3005 for fileFilter in Lexers.getSaveFileFiltersList(True): |
3006 if filterPattern in filter: |
3006 if filterPattern in fileFilter: |
3007 defaultFilter = filter |
3007 defaultFilter = fileFilter |
3008 break |
3008 break |
3009 else: |
3009 else: |
3010 defaultFilter = Preferences.getEditor("DefaultSaveFilter") |
3010 defaultFilter = Preferences.getEditor("DefaultSaveFilter") |
3011 else: |
3011 else: |
3012 defaultFilter = Preferences.getEditor("DefaultSaveFilter") |
3012 defaultFilter = Preferences.getEditor("DefaultSaveFilter") |
4645 elif not auto: |
4645 elif not auto: |
4646 self.autoCompleteQScintilla() |
4646 self.autoCompleteQScintilla() |
4647 elif self.autoCompletionSource() != QsciScintilla.AcsNone: |
4647 elif self.autoCompletionSource() != QsciScintilla.AcsNone: |
4648 self.autoCompleteQScintilla() |
4648 self.autoCompleteQScintilla() |
4649 |
4649 |
4650 def __completionListSelected(self, id, txt): |
4650 def __completionListSelected(self, listId, txt): |
4651 """ |
4651 """ |
4652 Private slot to handle the selection from the completion list. |
4652 Private slot to handle the selection from the completion list. |
4653 |
4653 |
4654 @param id the ID of the user list (should be 1) (integer) |
4654 @param listId the ID of the user list (should be 1 or 2) (integer) |
4655 @param txt the selected text (string) |
4655 @param txt the selected text (string) |
4656 """ |
4656 """ |
4657 if id == EditorAutoCompletionListID: |
4657 if listId == EditorAutoCompletionListID: |
4658 lst = txt.split() |
4658 lst = txt.split() |
4659 if len(lst) > 1: |
4659 if len(lst) > 1: |
4660 txt = lst[0] |
4660 txt = lst[0] |
4661 |
4661 |
4662 if Preferences.getEditor("AutoCompletionReplaceWord"): |
4662 if Preferences.getEditor("AutoCompletionReplaceWord"): |
4672 line, col = self.getCursorPosition() |
4672 line, col = self.getCursorPosition() |
4673 elif wLeft: |
4673 elif wLeft: |
4674 txt = txt[len(wLeft):] |
4674 txt = txt[len(wLeft):] |
4675 self.insert(txt) |
4675 self.insert(txt) |
4676 self.setCursorPosition(line, col + len(txt)) |
4676 self.setCursorPosition(line, col + len(txt)) |
4677 elif id == TemplateCompletionListID: |
4677 elif listId == TemplateCompletionListID: |
4678 self.__applyTemplate(txt, self.getLanguage()) |
4678 self.__applyTemplate(txt, self.getLanguage()) |
4679 |
4679 |
4680 def canProvideDynamicAutoCompletion(self): |
4680 def canProvideDynamicAutoCompletion(self): |
4681 """ |
4681 """ |
4682 Public method to test the dynamic auto-completion availability. |
4682 Public method to test the dynamic auto-completion availability. |
7335 """ |
7335 """ |
7336 Public slot to start a shared edit session for the editor. |
7336 Public slot to start a shared edit session for the editor. |
7337 """ |
7337 """ |
7338 self.__inSharedEdit = True |
7338 self.__inSharedEdit = True |
7339 self.__savedText = self.text() |
7339 self.__savedText = self.text() |
7340 hash = str( |
7340 hashStr = str( |
7341 QCryptographicHash.hash( |
7341 QCryptographicHash.hash( |
7342 Utilities.encode(self.__savedText, self.encoding)[0], |
7342 Utilities.encode(self.__savedText, self.encoding)[0], |
7343 QCryptographicHash.Sha1).toHex(), |
7343 QCryptographicHash.Sha1).toHex(), |
7344 encoding="utf-8") |
7344 encoding="utf-8") |
7345 self.__send(Editor.StartEditToken, hash) |
7345 self.__send(Editor.StartEditToken, hashStr) |
7346 |
7346 |
7347 def sendSharedEdit(self): |
7347 def sendSharedEdit(self): |
7348 """ |
7348 """ |
7349 Public slot to end a shared edit session for the editor and |
7349 Public slot to end a shared edit session for the editor and |
7350 send the changes. |
7350 send the changes. |
7430 """ |
7430 """ |
7431 if not self.__inSharedEdit and not self.__inRemoteSharedEdit: |
7431 if not self.__inSharedEdit and not self.__inRemoteSharedEdit: |
7432 self.__inRemoteSharedEdit = True |
7432 self.__inRemoteSharedEdit = True |
7433 self.setReadOnly(True) |
7433 self.setReadOnly(True) |
7434 self.__updateReadOnly() |
7434 self.__updateReadOnly() |
7435 hash = str( |
7435 hashStr = str( |
7436 QCryptographicHash.hash( |
7436 QCryptographicHash.hash( |
7437 Utilities.encode(self.text(), self.encoding)[0], |
7437 Utilities.encode(self.text(), self.encoding)[0], |
7438 QCryptographicHash.Sha1).toHex(), |
7438 QCryptographicHash.Sha1).toHex(), |
7439 encoding="utf-8") |
7439 encoding="utf-8") |
7440 if hash != argsString: |
7440 if hashStr != argsString: |
7441 # text is different to the remote site, request to sync it |
7441 # text is different to the remote site, request to sync it |
7442 self.__isSyncing = True |
7442 self.__isSyncing = True |
7443 self.__send(Editor.RequestSyncToken, argsString) |
7443 self.__send(Editor.RequestSyncToken, argsString) |
7444 |
7444 |
7445 def __calculateChanges(self, old, new): |
7445 def __calculateChanges(self, old, new): |
7513 Private slot to process a remote RequestSync command. |
7513 Private slot to process a remote RequestSync command. |
7514 |
7514 |
7515 @param argsString string containing the command parameters (string) |
7515 @param argsString string containing the command parameters (string) |
7516 """ |
7516 """ |
7517 if self.__inSharedEdit: |
7517 if self.__inSharedEdit: |
7518 hash = str( |
7518 hashStr = str( |
7519 QCryptographicHash.hash( |
7519 QCryptographicHash.hash( |
7520 Utilities.encode(self.__savedText, self.encoding)[0], |
7520 Utilities.encode(self.__savedText, self.encoding)[0], |
7521 QCryptographicHash.Sha1).toHex(), |
7521 QCryptographicHash.Sha1).toHex(), |
7522 encoding="utf-8") |
7522 encoding="utf-8") |
7523 |
7523 |
7524 if hash == argsString: |
7524 if hashStr == argsString: |
7525 self.__send(Editor.SyncToken, self.__savedText) |
7525 self.__send(Editor.SyncToken, self.__savedText) |
7526 |
7526 |
7527 def __processSyncCommand(self, argsString): |
7527 def __processSyncCommand(self, argsString): |
7528 """ |
7528 """ |
7529 Private slot to process a remote Sync command. |
7529 Private slot to process a remote Sync command. |