How to use the leo.core.leoGlobals.es_print function in leo

To help you get started, we’ve selected a few leo examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github leo-editor / leo-editor / leo / commands / abbrevCommands.py View on Github external
return val, False
        # Perform all scripting substitutions.
        self.save_ins = None
        self.save_sel = None
        while c.abbrev_subst_start in val:
            prefix, rest = val.split(c.abbrev_subst_start, 1)
            content = rest.split(c.abbrev_subst_end, 1)
            if len(content) != 2:
                break
            content, rest = content
            try:
                self.expanding = True
                c.abbrev_subst_env['x'] = ''
                exec(content, c.abbrev_subst_env, c.abbrev_subst_env)
            except Exception:
                g.es_print('exception evaluating', content)
                g.es_exception()
            finally:
                self.expanding = False
            x = c.abbrev_subst_env.get('x')
            if x is None: x = ''
            val = f"{prefix}{x}{rest}"
            # Save the selection range.
            w = c.frame.body.wrapper
            self.save_ins = w.getInsertPoint()
            self.save_sel = w.getSelectionRange()
        if val == "__NEXT_PLACEHOLDER":
            # user explicitly called for next placeholder in an abbrev.
            # inserted previously
            val = ''
            do_placeholder = True
        else:
github leo-editor / leo-editor / leo / core / leoRst.py View on Github external
if ext != '.pdf':
                overrides['stylesheet'] = path
                overrides['stylesheet_path'] = None
        elif styleSheetArgsDict:
            g.es_print('using publish_argv_for_missing_stylesheets',
                styleSheetArgsDict)
            overrides.update(styleSheetArgsDict)
                # MWC add args to settings
        elif rel_stylesheet_path == stylesheet_path:
            g.error(f"stylesheet not found: {path}")
        else:
            g.error('stylesheet not found\n', path)
            if self.path: g.es_print('@path:', self.path)
            g.es_print('open path:', openDirectory)
            if rel_stylesheet_path:
                g.es_print('relative path:', rel_stylesheet_path)
        try:
            # All paths now come through here.
            result = None  # Ensure that result is defined.
            # #1454: This call may print a -Wd warning:
                # site-packages\docutils\io.py:245:
                # DeprecationWarning: 'U' mode is deprecated
                #
                # The actual culprit is 'rU' mode at line 207.
            result = docutils.core.publish_string(source=s,
                    reader_name='standalone',
                    parser_name='restructuredtext',
                    writer=writer,
                    writer_name=writer_name,
                    settings_overrides=overrides)
            if isinstance(result, bytes):
                result = g.toUnicode(result)
github leo-editor / leo-editor / leo / core / leoTkinterTree.py View on Github external
if not item: return None

        # Item may be a tuple, possibly empty.
        try:    theId = item[0]
        except: theId = item
        if not theId: return None

        p = self.ids.get(theId)

        # A kludge: p will be None for vertical lines.
        if not p:
            item = canvas.find_overlapping(x+1,y,x+1,y)
            try:    theId = item[0]
            except: theId = item
            if not theId:
                g.es_print('oops:','eventToPosition','failed')
                return None
            p = self.ids.get(theId)
            # g.trace("was vertical line",p)

        if self.trace and self.verbose:
            if p:
                w = self.findEditWidget(p)
                g.trace("%3d %3d %3d %d" % (theId,x,y,id(w)),p.headString())
            else:
                g.trace("%3d %3d %3d" % (theId,x,y),None)

        # defensive programming: this copy is not needed.
        if p: return p.copy() # Make _sure_ nobody changes this table!
        else: return None
    #@-node:ekr.20040803072955.74:eventToPosition
github leo-editor / leo-editor / leo / core / leoColorizer.py View on Github external
def show(setting, val):
            if trace:
                g.es_print(f"{setting:35}: {val}")
        #
        # Set self.use_pygments only once: it can't be changed later.
        # There is no easy way to re-instantiate classes created by make_colorizer.

        use_pygments = c.config.getBool('use-pygments', default=False)
        if self.prev_use_pygments is None:
            self.use_pygments = self.prev_use_pygments = use_pygments
            show('@bool use-pygments', use_pygments)
        elif use_pygments == self.prev_use_pygments:
            show('@bool use-pygments', use_pygments)
        else:
            g.es_print(
                f"{'Can not change @bool use-pygments':35}: "
                f"{self.prev_use_pygments}",
                color='red')
        #
        # Report everything if we are tracing.
        style_name = c.config.getString('pygments-style-name') or 'default'
            # Don't set an ivar. It's not used in this class.
            # This setting is used only in the LeoHighlighter class
        show('@bool use-pytments-styles', self.use_pygments_styles)
        show('@string pygments-style-name', style_name)
        #
        # Report other changes only if we are using pygments.
        if not use_pygments:
            if trace: print('')
            return
        #
github leo-editor / leo-editor / leo / plugins / bigdash.py View on Github external
def open_index(self, idx_dir):
        global index_error_given
        if os.path.exists(idx_dir):
            try:
                return open_dir(idx_dir)
            except ValueError:
                if not index_error_given:
                    index_error_given = True
                    g.es_print('bigdash.py: exception in whoosh.open_dir')
                    g.es_print('please remove this directory:', g.os_path_normpath(idx_dir))
                return None
                # Doesn't work: open_dir apparently leaves resources open,
                # so shutil.rmtree(idx_dir) fails.
                    # g.es_print('re-creating', repr(idx_dir))
                    # try:
                        # import shutil
                        # shutil.rmtree(idx_dir)
                        # os.mkdir(idx_dir)
                        # self.create()
                        # return open_dir(idx_dir)
                    # except Exception as why:
                        # g.es_print(why)
                        # return None
        else:
            try:
                os.mkdir(idx_dir)
github leo-editor / leo-editor / leo / plugins / viewrendered3.py View on Github external
def update_latex(self, s, keywords):
        '''Update latex in the vr3 pane.'''
        import sys
        pc = self
        c = pc.c
        if sys.platform.startswith('win'):
            g.es_print('latex rendering not ready for Python 3')
            w = pc.ensure_text_widget()
            pc.show()
            w.setPlainText(s)
            c.bodyWantsFocusNow()
            return
        if pc.must_change_widget(BaseTextWidget):
            w = self.create_base_text_widget()
            pc.embed_widget(w)
            assert(w == pc.w)
        else:
            w = pc.w
        w.hide() # This forces a proper update.
        s = self.create_latex_html(s)
        w.setHtml(s)
        w.show()
        c.bodyWantsFocusNow()
github leo-editor / leo-editor / leo / plugins / viewrendered3.py View on Github external
'''Close the rendering pane.'''
    vr3 = getVr3(event)
    if not vr3: return

    c = event.get('c')
    if g.app.dock:
        if vr3.external_dock:
            return # Can't hide a top-level dock.
        dock = vr3.leo_dock
        if dock:
            dock.hide()
        return
    #
    # Legacy code.
    if vr3.pyplot_active:
        g.es_print('can not close vr3 pane after using pyplot')
        return
    vr3.store_layout('open')
    vr3.deactivate()
    vr3.deleteLater()

    def at_idle(c=c, _vr3=vr3):
        c = event.get('c')
        _vr3.adjust_layout('closed')
        c.bodyWantsFocusNow()

    QtCore.QTimer.singleShot(0, at_idle)
    h = c.hash()
    c.bodyWantsFocus()
    if vr3 == controllers.get(h):
        del controllers[h]
    else:
github leo-editor / leo-editor / leo / plugins / pyzo_support.py View on Github external
def patch_pyzo(self):
        '''
        Called at the end of pyzo.start() to embed Leo into pyzo.
        '''
        import pyzo
        if not pyzo:
            g.es_print('Can not import pyzo')
            return
        g.trace() ; print('')
        bridge = leoBridge.controller(
            gui='nullGui',
            loadPlugins=False, 
                # Essential: some plugins import Qt, which causes this message:
                    # Qt WebEngine seems to be initialized from a plugin.
                    # Please set Qt::AA_ShareOpenGLContexts using QCoreApplication::setAttribute
                    # before constructing QGuiApplication.
            readSettings=True, # Debatable.
            verbose=False,
        )
        if bridge.isOpen():
            self.g = bridge.globals()
            # c = bridge.openLeoFile(path)
github leo-editor / leo-editor / leo / core / leoVim.py View on Github external
def print_dot(self, event=None):
        '''Print the dot.'''
        aList = [z.stroke if isinstance(z, VimEvent) else z for z in self.dot_list]
        aList = [show_stroke(self.c.k.stroke2char(z)) for z in aList]
        if self.n1 > 1:
            g.es_print('dot repeat count:', self.n1)
        i, n = 0, 0
        while i < len(aList):
            g.es_print('dot[%s]:' % (n), ''.join(aList[i: i + 10]))
            i += 10
            n += 1
    #@+node:ekr.20140815160132.18825: *4* vc.q/qa_command & quit_now (:q & q! & :qa)