def __init__(self, parent): super(ConsoleToolView, self).__init__(parent) self.toolView = kate.mainInterfaceWindow().createToolView( 'ipython_console', kate.Kate.MainWindow.Bottom, KIcon('text-x-python').pixmap(32,32), i18nc('@title:tab', 'IPython Console') ) self.toolView.installEventFilter(self) self.console = make_terminal_widget(parent=self.toolView, kate=kate) # Load CSS from file '${appdir}/ipython_console.css' css_string = None search_dirs = kate.applicationDirectories() + [os.path.dirname(__file__)] for appdir in search_dirs: # TODO Make a CSS file configurable? css_file = os.path.join(appdir, _CONSOLE_CSS) try: with open(css_file, 'r') as f: css_string = f.read() break except IOError: pass if css_string: self.console.style_sheet = css_string if ipython_1: # For seamless borders self.console.setStyleSheet(css_string) if _SCROLLBACK_LINES_COUNT_CFG in kate.configuration: self.console.buffer_size = kate.configuration[_SCROLLBACK_LINES_COUNT_CFG]
def _collectExpansionsForType(mime): expansions = {} # TODO What about other (prohibited in filesystem) symbols? mime_filename = mime.replace('/', '_') + EXPANDS_EXT for directory in kate.applicationDirectories(EXPANDS_BASE_DIR): if os.path.exists(os.path.join(directory, mime_filename)): expansions = _mergeExpansions( expansions , _loadExpansionsFromFile(os.path.join(directory, mime_filename)) ) return expansions
def loadExpansions(mime): if mime not in expansionCache: expansions = {} # explicit is better than implicit mimeFileName = mime.replace('/', '_') + '.expand' for directory in kate.applicationDirectories('expand'): if os.path.exists(os.path.join(directory, mimeFileName)): expansions.update(loadFileExpansions(os.path.join(directory, mimeFileName))) # load global expansions if necessary`` expansionCache[mime] = loadExpansions('all') if mime != 'all' else {} expansionCache[mime].update(expansions) return expansionCache[mime]
def loadExpansions(mime): if mime not in expansionCache: expansions = {} # explicit is better than implicit mimeFileName = mime.replace('/', '_') + '.expand' for directory in kate.applicationDirectories('expand'): if os.path.exists(os.path.join(directory, mimeFileName)): expansions.update( loadFileExpansions(os.path.join(directory, mimeFileName))) # load global expansions if necessary`` expansionCache[mime] = loadExpansions('all') if mime != 'all' else {} expansionCache[mime].update(expansions) return expansionCache[mime]
def _loadCompleters(self): # Load available command completers for directory in kate.applicationDirectories('cmake_utils/command_completers'): kate.kDebug('CMakeCC: directory={}'.format(directory)) sys.path.append(directory) for completer in glob.glob(os.path.join(directory, '*_cc.py')): kate.kDebug('CMakeCC: completer={}'.format(completer)) cc_name = os.path.basename(completer).split('.')[0] module = importlib.import_module(cc_name, "cmake_utils.command_completers") if hasattr(module, self._cc_registrar_fn_name): r = getattr(module, self._cc_registrar_fn_name) if isinstance(r, types.FunctionType): r(self.__command_completers)
def init(): kate_window = kate.mainInterfaceWindow() v = kate_window.createToolView('ipython_console', kate_window.Bottom, kate.gui.loadIcon('text-x-python'), 'IPython Console') console = terminal_widget(parent=v, kate=kate) # Load CSS from file '${appdir}/ipython_console.css' css_string = None search_dirs = kate.applicationDirectories() + [os.path.dirname(__file__)] for appdir in search_dirs: # TODO Make a CSS file configurable? css_file = os.path.join(appdir, _CONSOLE_CSS) if os.path.isfile(css_file): try: with open(css_file, 'r') as f: css_string = f.read() break except IOError: pass if css_string: console.style_sheet = css_string if _SCROLLBACK_LINES_COUNT_CFG in kate.configuration: console.buffer_size = kate.configuration[_SCROLLBACK_LINES_COUNT_CFG]