Ejemplo n.º 1
0
Archivo: run.py Proyecto: 343max/Stino
	def run(self):
		region_list = self.window.active_view().sel()
		for region in region_list:
			operator_list = []
			keyword_list = arduino_info.getKeywordList()
			for keyword in keyword_list:
				keyword_type = arduino_info.getKeywordType(keyword)
				keyword_ref = arduino_info.getKeywordRef(keyword)
				if (not keyword_type) and keyword_ref:
					if (not '[]' in keyword) and (not '()' in keyword) and (not '{}' in keyword):
						operator_list.append(keyword)

			regx_keyword_list = ['.', '^', '$', '*', '+', '?', '{', '[', ']', '\\', '|', '(', ')']
			word_region = self.window.active_view().word(region)
			words = self.window.active_view().substr(word_region)
			pattern_text = r'(\w+'
			for operator in operator_list:
				new_operator = ''
				for letter in operator:
					if letter in regx_keyword_list:
						letter = '\\' + letter
					new_operator += letter
				pattern_text += '|'
				pattern_text += new_operator
			pattern_text += ')'
			pattern = re.compile(pattern_text)
			match = pattern.search(words)
			word_list = []
			if match:
				word_list = pattern.findall(words)
		
			url_list = []
			msg_list = []
			for word in word_list:
				ref = arduino_info.getKeywordRef(word)
				if ref:
					if ref[0].isupper():
						if not ref in url_list:
							url_list.append(ref)
					else:
						msg = '"%s": %s\n' % (word, ref)
						if not msg in msg_list:
							msg_list.append(msg)
						
			msg_text = ''
			for msg in msg_list:
				msg_text += msg
			for url in url_list:
				utils.openUrl(url)
			if msg_text:
				sublime.message_dialog(msg_text)
Ejemplo n.º 2
0
Archivo: run.py Proyecto: 343max/Stino
	def run(self, menu_str):
		utils.openUrl(menu_str)