def start(self, files_to_open): opened_files = set() if not self.conf['WINDOWS']: self.conf['WINDOWS'].append({'name':'main'}) main_window = None for window_conf in self.conf['WINDOWS']: files = [r['uri'] for r in window_conf.get('files', []) if os.path.exists(r['uri']) and os.path.isfile(r['uri'])] if files: w = snaked.core.window.Window(self, window_conf) self.windows.append(w) main_window = main_window or w for f in files: e = self.open(f) w.attach_editor(e) opened_files.add(f) else: self.windows.append(False) window = main_window or self.get_free_window() for f in files_to_open: f = os.path.abspath(f) window.window_conf['active-uri'] = f if f not in opened_files: e = self.open(f) window.attach_editor(e) opened_files.add(f) for w in self.windows: if w: if w.window_conf.get('active-uri', None): w.open_or_activate(w.window_conf['active-uri']) if not self.buffers: snaked.core.quick_open.quick_open(window)
def open_or_activate(self, uri, window=None, line=None): buf = self.get_buffer_for_uri(uri) if buf: if window: for e in window.editors: if e.buffer is buf: if line is not None: e.goto_line(line) e.focus() return e for e in self.get_editors(): if e.buffer is buf: if line is not None: e.goto_line(line) e.focus() return e else: window = window or [w for w in self.windows if w][0] e = self.open(uri, line) window.attach_editor(e) return e