eric6/QScintilla/Editor.py

changeset 7628
f904d0eef264
parent 7575
3ebd1db41c15
child 7635
0cdead130a81
equal deleted inserted replaced
7626:7f643d41464e 7628:f904d0eef264
1414 Private method to select a specific pygments lexer. 1414 Private method to select a specific pygments lexer.
1415 1415
1416 @return name of the selected pygments lexer (string) 1416 @return name of the selected pygments lexer (string)
1417 """ 1417 """
1418 from pygments.lexers import get_all_lexers 1418 from pygments.lexers import get_all_lexers
1419 lexerList = sorted(l[0] for l in get_all_lexers()) 1419 lexerList = sorted(lex[0] for lex in get_all_lexers())
1420 try: 1420 try:
1421 lexerSel = lexerList.index( 1421 lexerSel = lexerList.index(
1422 self.getLanguage(normalized=False, forPygments=True)) 1422 self.getLanguage(normalized=False, forPygments=True))
1423 except ValueError: 1423 except ValueError:
1424 lexerSel = 0 1424 lexerSel = 0
6496 Private method to clear warnings of a specific kind. 6496 Private method to clear warnings of a specific kind.
6497 6497
6498 @param warningKind kind of warning to clear (Editor.WarningCode, 6498 @param warningKind kind of warning to clear (Editor.WarningCode,
6499 Editor.WarningStyle) 6499 Editor.WarningStyle)
6500 """ 6500 """
6501 assert warningKind in [Editor.WarningCode, Editor.WarningStyle]
6502
6503 for handle in list(self.warnings.keys()): 6501 for handle in list(self.warnings.keys()):
6504 warnings = [] 6502 warnings = []
6505 for msg, warningType in self.warnings[handle]: 6503 for msg, warningType in self.warnings[handle]:
6506 if warningType == warningKind: 6504 if warningType == warningKind:
6507 continue 6505 continue
8082 matcher = difflib.SequenceMatcher(None, oldL, newL) 8080 matcher = difflib.SequenceMatcher(None, oldL, newL)
8083 8081
8084 formatStr = "@@{0} {1} {2} {3}" 8082 formatStr = "@@{0} {1} {2} {3}"
8085 commands = [] 8083 commands = []
8086 for token, i1, i2, j1, j2 in matcher.get_opcodes(): 8084 for token, i1, i2, j1, j2 in matcher.get_opcodes():
8087 if token == "insert": 8085 if token == "insert": # secok
8088 commands.append(formatStr.format("i", j1, j2 - j1, -1)) 8086 commands.append(formatStr.format("i", j1, j2 - j1, -1))
8089 commands.extend(newL[j1:j2]) 8087 commands.extend(newL[j1:j2])
8090 elif token == "delete": 8088 elif token == "delete": # secok
8091 commands.append(formatStr.format("d", j1, i2 - i1, -1)) 8089 commands.append(formatStr.format("d", j1, i2 - i1, -1))
8092 elif token == "replace": 8090 elif token == "replace": # secok
8093 commands.append(formatStr.format("r", j1, i2 - i1, j2 - j1)) 8091 commands.append(formatStr.format("r", j1, i2 - i1, j2 - j1))
8094 commands.extend(newL[j1:j2]) 8092 commands.extend(newL[j1:j2])
8095 8093
8096 return "\n".join(commands) + "\n" 8094 return "\n".join(commands) + "\n"
8097 8095

eric ide

mercurial