Ejemplo n.º 1
0
Archivo: run.py Proyecto: 343max/Stino
	def on_done(self, index):
		if index == -1:
			return

		sel_path = self.path_list[index]
		if os.path.isfile(sel_path):
			active_file = self.window.active_view().file_name()
			sketch_folder = os.path.split(active_file)[0]
			is_new = True
			basename = os.path.split(sel_path)[1]
			basename = utils.regFilename(basename)
			file_path = os.path.join(sketch_folder, basename)
			if os.path.exists(file_path):
				is_new = False
			if is_new:
				content = utils.readFile(sel_path)
				utils.writeFile(file_path, content)
				view = self.window.open_file(file_path)
			else:
				org_msg = '%(File_Exists)s'
				msg = org_msg % cur_lang.getDisplayTextDict()
				is_new = sublime.message_dialog(msg)
		else:		
			(self.level, self.path_list) = utils.enterNext(index, self.level, self.top_path_list, sel_path)
			file_list = utils.getFileList(self.path_list)
			self.window.show_quick_panel(file_list, self.on_done)
Ejemplo n.º 2
0
Archivo: run.py Proyecto: 343max/Stino
	def on_done(self, input_text):
		active_file = self.window.active_view().file_name()
		sketch_folder = os.path.split(active_file)[0]
		is_new = True
		file_name = utils.regFilename(input_text)
		if file_name:
			file_path = os.path.join(sketch_folder, file_name)
			if os.path.exists(file_path):
				is_new = False
		if is_new:
			text = '// %s\n\n' % file_name
			utils.writeFile(file_path, text)
			view = self.window.open_file(file_path)
		else:
			org_msg = '%(File_Exists)s'
			msg = org_msg % cur_lang.getDisplayTextDict()
			is_new = sublime.message_dialog(msg)
Ejemplo n.º 3
0
Archivo: run.py Proyecto: 343max/Stino
	def on_done(self, input_text):
		sketchbook_root = arduino_info.getSketchbookRoot()
		is_new = True
		sketch_name = utils.regFilename(input_text)
		if sketch_name:
			sketch_folder_path = os.path.join(sketchbook_root, sketch_name)
			if os.path.exists(sketch_folder_path):
				org_msg = '%(Sketch_Exists)s'
				msg = org_msg % cur_lang.getDisplayTextDict()
				is_new = sublime.ok_cancel_dialog(msg)
		else:
			is_new = False

		if is_new:
			if not os.path.exists(sketch_folder_path):
				os.mkdir(sketch_folder_path)
			sketch_file_name = '%s.ino' % sketch_name
			sketch_file_path = os.path.join(sketch_folder_path, sketch_file_name)

			# Write Sketch File
			plugin_root = utils.getPluginRoot()
			template_dir = os.path.join(plugin_root, 'template')
			temp_path = os.path.join(template_dir, 'sketch')
			temp_file = open(temp_path, 'r')
			sketch = temp_file.read()
			temp_file.close()

			utils.writeFile(sketch_file_path, sketch)
			cur_menu.sketchbookUpdate()

			#open a new window for new project
			utils.openSketch(sketch_folder_path)	
		else:
			org_caption = '%(Name_for_new_sketch:)s'
			caption = org_caption % cur_lang.getDisplayTextDict()
			self.window.show_input_panel(caption, '', self.on_done, None, self.on_cancel)