def __init__(self, file_to_open=""): super().__init__() self.setWindowTitle("New file") self.force_quit_flag = False self.config = read_config() self.setStyleSheet("background: " + self.config["theme"]["background"]) layout = QtGui.QVBoxLayout(self) common.kill_theming(layout) scene_container = QtGui.QScrollArea(self) layout.addWidget(scene_container, stretch=1) self.scene = Scene( self.config, scene_container.horizontalScrollBar().value, scene_container.verticalScrollBar().value ) scene_container.setWidget(self.scene) self.terminal = Terminal(self, lambda: self.scene.file_path) layout.addWidget(self.terminal) self.connect_signals(self.scene, self.terminal) common.set_hotkey("Escape", self, self.terminal.toggle) if file_to_open: self.scene.open_file(file_to_open) self.show()
def set_key_shortcuts(mainwindow, textarea, terminal, plugin_hotkeys): hotkeys = { 'Ctrl+N': textarea.request_new_file, 'Ctrl+O': lambda:terminal.prompt('o '), 'Ctrl+S': textarea.request_save_file, 'Ctrl+Shift+S': lambda:terminal.prompt('s '), 'F3': textarea.search_next, } hotkeys.update(plugin_hotkeys) for key, function in hotkeys.items(): common.set_hotkey(key, mainwindow, function)
def __init__(self, file_to_open=''): super().__init__() self.setWindowTitle('New file') self.force_quit_flag = False self.config = read_config() self.setStyleSheet('background: '+self.config['theme']['background']) layout = QtGui.QVBoxLayout(self) common.kill_theming(layout) self.scene_container = QtGui.QScrollArea(self) layout.addWidget(self.scene_container, stretch=1) self.scene = Scene(self.config, self.scene_container.horizontalScrollBar().value, self.scene_container.verticalScrollBar().value) self.scene_container.setWidget(self.scene) self.scene_container.setDisabled(True) self.terminal = Terminal(self, lambda: self.scene.file_path) layout.addWidget(self.terminal) self.connect_signals(self.scene, self.terminal) # common.set_hotkey('Escape', self, self.terminal.toggle) common.set_hotkey('Ctrl+N', self, self.scene.request_new_file) common.set_hotkey('Ctrl+O', self, lambda:self.terminal.prompt('o ')) common.set_hotkey('Ctrl+S', self, self.scene.request_save_file) common.set_hotkey('Ctrl+Shift+S', self, lambda:self.terminal.prompt('s ')) if file_to_open: self.scene.open_file(file_to_open) self.show()