Sat, 20 Jan 2018 16:26:30 +0100
Added file type detection base on the first line being a mode line (i.e. -*- mode: python -*-)
QScintilla/Editor.py | file | annotate | diff | comparison | revisions | |
QScintilla/MiniEditor.py | file | annotate | diff | comparison | revisions |
--- a/QScintilla/Editor.py Thu Jan 18 18:57:40 2018 +0100 +++ b/QScintilla/Editor.py Sat Jan 20 16:26:30 2018 +0100 @@ -629,6 +629,15 @@ elif "python" in line0: bindName = "dummy.py" self.filetype = "Python2" + elif "pypy3" in line0: + bindName = "dummy.py" + self.filetype = "Python3" + elif "pypy2" in line0: + bindName = "dummy.py" + self.filetype = "Python2" + elif "pypy" in line0: + bindName = "dummy.py" + self.filetype = "Python2" elif ("/bash" in line0 or "/sh" in line0): bindName = "dummy.sh" elif "ruby" in line0: @@ -643,6 +652,28 @@ self.filetype = "D" if not bindName: + # mode line detection: -*- mode: python -*- + match = re.search(r"mode[:=]\s*([-\w_.]+)", line0) + if match: + mode = match.group(1).lower() + if mode in ["python3", "pypy3"]: + bindName = "dummy.py" + self.filetype = "Python3" + elif mode in ["python2", "pypy2", "python", "pypy"]: + bindName = "dummy.py" + self.filetype = "Python2" + elif mode == "ruby": + bindName = "dummy.rb" + self.filetype = "Ruby" + elif mode == "perl": + bindName = "dummy.pl" + elif mode == "lua": + bindName = "dummy.lua" + elif mode in ["dmd", "d"]: + bindName = "dummy.d" + self.filetype = "D" + + if not bindName: bindName = self.fileName return bindName
--- a/QScintilla/MiniEditor.py Thu Jan 18 18:57:40 2018 +0100 +++ b/QScintilla/MiniEditor.py Sat Jan 20 16:26:30 2018 +0100 @@ -3037,6 +3037,28 @@ elif "dmd" in line0: bindName = "dummy.d" self.filetype = "D" + + # mode line detection: -*- mode: python -*- + match = re.search(r"mode[:=]\s*([-\w_.]+)", line0) + if match: + mode = match.group(1).lower() + if mode in ["python3", "pypy3"]: + bindName = "dummy.py" + self.filetype = "Python3" + elif mode in ["python2", "pypy2", "python", "pypy"]: + bindName = "dummy.py" + self.filetype = "Python2" + elif mode == "ruby": + bindName = "dummy.rb" + self.filetype = "Ruby" + elif mode == "perl": + bindName = "dummy.pl" + elif mode == "lua": + bindName = "dummy.lua" + elif mode in ["dmd", "d"]: + bindName = "dummy.d" + self.filetype = "D" + return bindName ##########################################################