QScintilla/MiniEditor.py

branch
maintenance
changeset 6826
c6dda2cbe081
parent 6721
48c3ca1ac264
child 6842
c83dcb7c6147
equal deleted inserted replaced
6764:d14ddbfbbd36 6826:c6dda2cbe081
3075 3075
3076 @param line0 first line of text to use in the generation process 3076 @param line0 first line of text to use in the generation process
3077 (string) 3077 (string)
3078 @return dummy file name to be used for binding a lexer (string) 3078 @return dummy file name to be used for binding a lexer (string)
3079 """ 3079 """
3080 bindName = self.__curFile 3080 bindName = ""
3081 line0 = line0.lower() 3081 line0 = line0.lower()
3082 3082
3083 # check first line if it does not start with #! 3083 # check first line if it does not start with #!
3084 if line0.startswith(("<html", "<!doctype html", "<?php")): 3084 if line0.startswith(("<html", "<!doctype html", "<?php")):
3085 bindName = "dummy.html" 3085 bindName = "dummy.html"
3088 elif line0.startswith("index: "): 3088 elif line0.startswith("index: "):
3089 bindName = "dummy.diff" 3089 bindName = "dummy.diff"
3090 elif line0.startswith("\\documentclass"): 3090 elif line0.startswith("\\documentclass"):
3091 bindName = "dummy.tex" 3091 bindName = "dummy.tex"
3092 3092
3093 # check filetype 3093 if not bindName and self.filetype:
3094 if self.filetype in ["Python", "Python2", "Python3"]: 3094 # check filetype
3095 bindName = "dummy.py" 3095 from . import Lexers
3096 elif self.filetype == "Ruby": 3096 supportedLanguages = Lexers.getSupportedLanguages()
3097 bindName = "dummy.rb" 3097 if self.filetype in supportedLanguages:
3098 elif self.filetype == "D": 3098 bindName = supportedLanguages[self.filetype][1]
3099 bindName = "dummy.d" 3099 elif self.filetype in ["Python", "Python2", "Python3"]:
3100 elif self.filetype == "Properties": 3100 bindName = "dummy.py"
3101 bindName = "dummy.ini" 3101
3102 3102 if not bindName and line0.startswith("#!"):
3103 # #! marker detection 3103 # #! marker detection
3104 if line0.startswith("#!"):
3105 if "python3" in line0: 3104 if "python3" in line0:
3106 bindName = "dummy.py" 3105 bindName = "dummy.py"
3107 self.filetype = "Python3" 3106 self.filetype = "Python3"
3108 elif "python2" in line0: 3107 elif "python2" in line0:
3109 bindName = "dummy.py" 3108 bindName = "dummy.py"
3122 bindName = "dummy.lua" 3121 bindName = "dummy.lua"
3123 elif "dmd" in line0: 3122 elif "dmd" in line0:
3124 bindName = "dummy.d" 3123 bindName = "dummy.d"
3125 self.filetype = "D" 3124 self.filetype = "D"
3126 3125
3127 # mode line detection: -*- mode: python -*- 3126 if not bindName:
3128 match = re.search(r"mode[:=]\s*([-\w_.]+)", line0) 3127 # mode line detection: -*- mode: python -*-
3129 if match: 3128 match = re.search(r"mode[:=]\s*([-\w_.]+)", line0)
3130 mode = match.group(1).lower() 3129 if match:
3131 if mode in ["python3", "pypy3"]: 3130 mode = match.group(1).lower()
3132 bindName = "dummy.py" 3131 if mode in ["python3", "pypy3"]:
3133 self.filetype = "Python3" 3132 bindName = "dummy.py"
3134 elif mode in ["python2", "pypy2", "python", "pypy"]: 3133 self.filetype = "Python3"
3135 bindName = "dummy.py" 3134 elif mode in ["python2", "pypy2", "python", "pypy"]:
3136 self.filetype = "Python2" 3135 bindName = "dummy.py"
3137 elif mode == "ruby": 3136 self.filetype = "Python2"
3138 bindName = "dummy.rb" 3137 elif mode == "ruby":
3139 self.filetype = "Ruby" 3138 bindName = "dummy.rb"
3140 elif mode == "perl": 3139 self.filetype = "Ruby"
3141 bindName = "dummy.pl" 3140 elif mode == "perl":
3142 elif mode == "lua": 3141 bindName = "dummy.pl"
3143 bindName = "dummy.lua" 3142 elif mode == "lua":
3144 elif mode in ["dmd", "d"]: 3143 bindName = "dummy.lua"
3145 bindName = "dummy.d" 3144 elif mode in ["dmd", "d"]:
3146 self.filetype = "D" 3145 bindName = "dummy.d"
3146 self.filetype = "D"
3147
3148 if not bindName:
3149 bindName = self.__curFile
3147 3150
3148 return bindName 3151 return bindName
3149 3152
3150 ########################################################## 3153 ##########################################################
3151 ## Methods needed for the search functionality 3154 ## Methods needed for the search functionality

eric ide

mercurial