How to use the leo.core.leoGlobals.es 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 / plugins / mod_labels.py View on Github external
def delete_all_labels(self,event=None):
        """
        Delete all labels in the outline.
        Ask for confirmation before doing so!
        """
        title = 'Do you really want to delete ALL labels?'
        message_text = 'Do you really want to delete ALL labels?'

        root = self.c.frame.outerFrame
        dialog = Pmw_MessageDialog(root, title = title, message_text = message_text)
        result = dialog.doit()

        if result == 'Cancel':
            return
        if result == 'OK':
            g.es("Deleting ALL labels", color='red')
            for p in self.c.all_positions():
                labels_dict = self.get_labels_dict(p)
                if labels_dict:
                    self.set_labels_dict(p,None)
    #@+node:ekr.20050301095332.42: *4* delete_label
github leo-editor / leo-editor / leo / commands / controlCommands.py View on Github external
k = self.c.k
        try:
            p = subprocess.Popen(
                shlex.split(command),
                stdout=subprocess.PIPE,
                stderr=subprocess.DEVNULL if trace else subprocess.PIPE,
                shell=sys.platform.startswith('win'),
            )
            out, err = p.communicate()
            for line in g.splitLines(out):
                g.es_print(g.toUnicode(line.rstrip()))
        except Exception:
            g.es_exception()
        k.keyboardQuit()
            # Inits vim mode too.
        g.es(f"Done: {command}")
    #@+node:ekr.20150514063305.92: *3* print plugins info...
github leo-editor / leo-editor / leo / core / leoTkinterFrame.py View on Github external
def renameTabFromMenu (self,tabName):

        if tabName in ('Log','Completions'):
            g.es('can not rename',tabName,'tab',color='blue')
        else:
            def renameTabCallback (newName):
                return self.renameTab(tabName,newName)

            self.getTabName(renameTabCallback)
    #@-node:ekr.20051019165401:renameTabFromMenu
github leo-editor / leo-editor / leo / plugins / viewrendered2.py View on Github external
def md_exec_code(self, code, environment):
        """Execute the code, capturing the output in stdout and stderr."""
        saveout = sys.stdout # save stdout
        saveerr = sys.stderr
        sys.stdout = bufferout = StringIO()
        sys.stderr = buffererr = StringIO()
        # Protect against exceptions within exec
        try:
            exec(code, environment)
        except Exception:
            # print >> buffererr, traceback.format_exc()
            # buffererr.flush() # otherwise exception info appears too late
            g.es('Viewrendered2 exception')
            g.es_exception()
        # Restore stdout, stderr
        sys.stdout = saveout # was sys.__stdout__
        sys.stderr = saveerr # restore stderr
        return bufferout.getvalue(), buffererr.getvalue()
    #@+node:peckj.20140228100832.6399: *7* vr2.md_format_output
github leo-editor / leo-editor / leo / plugins / projectwizard.py View on Github external
""" Launch project wizard """
    import os
    c = event['c']
    table = [("All files","*"),
        ("Python files","*.py"),]

    fname = g.app.gui.runOpenFileDialog(c,
        title = "Open",filetypes = table,defaultextension = ".leo")

    pth = os.path.dirname(os.path.abspath(fname))

    g.es(pth)
    tgt = c.currentPosition().insertAsLastChild()
    c.selectPosition(tgt)
    auto_walk(c, pth, tgt)
    g.es('Import ok. Do read-at-auto-nodes to parse')
    c.redraw()
github leo-editor / leo-editor / leo / plugins / stickynotes.py View on Github external
def sn_decode(s):
        try:
            s1 = base64.b64decode(s)
            return get_AES().decrypt(s1).decode('utf8').strip()
        except Exception:
            g.es("encryption failed")
            __ENCKEY[0] = None
            return None
github leo-editor / leo-editor / leo / core / leoBeautify.py View on Github external
tag = 'beautify-files-diff'
    g.es(f"{tag}...")
    settings = orange_settings(c)
    roots = g.findRootsWithPredicate(c, c.p)
    for root in roots:
        filename = g.fullPath(c, root)
        if os.path.exists(filename):
            print('')
            print(f"{tag}: {g.shortFileName(filename)}")
            changed = leoAst.Orange(settings=settings).beautify_file_diff(filename)
            changed_s = 'changed' if changed else 'unchanged'
            g.es(f"{changed_s:>9}: {g.shortFileName(filename)}")
        else:
            print('')
            print(f"{tag}: file not found:{filename}")
            g.es(f"file not found:\n{filename}")
    t2 = time.process_time()
    print('')
    g.es_print(f"{tag}: {len(roots)} file{g.plural(len(roots))} in {t2 - t1:5.2f} sec.")
#@+node:ekr.20200107165603.1: *4* beautify-files
github leo-editor / leo-editor / leo / core / leoTkinterTree.py View on Github external
if not p: return
        c.setLog()
        self.drag_p = p.copy() # defensive programming: not needed.
        self.dragging = True
        # g.trace("*** start drag ***",theId,self.drag_p.headString())
        # Only do this once: greatly speeds drags.
        self.savedNumberOfVisibleNodes = self.numberOfVisibleNodes()
        # g.trace('self.controlDrag',self.controlDrag)
        if self.allow_clone_drags:
            self.controlDrag = c.frame.controlKeyIsDown
            if self.look_for_control_drag_on_mouse_down:
                if self.enable_drag_messages:
                    if self.controlDrag:
                        g.es("dragged node will be cloned")
                    else:
                        g.es("dragged node will be moved")
        else: self.controlDrag = False
        self.canvas['cursor'] = "hand2" # "center_ptr"
    #@-node:ekr.20041111114944:startDrag
github leo-editor / leo-editor / leo / core / leoPlugins.py View on Github external
def printPlugins(self, c):
        '''Print all enabled plugins.'''
        tabName = 'Plugins'
        c.frame.log.selectTab(tabName)
        data = []
        data.append('enabled plugins...\n')
        for z in sorted(self.loadedModules):
            data.append(z)
        lines = ['%s\n' % (s) for s in data]
        g.es('', ''.join(lines), tabName=tabName)
    #@+node:ekr.20100908125007.6027: *4* plugins.printPluginsInfo
github leo-editor / leo-editor / leo / core / leoImport.py View on Github external
last = c.lastTopLevel()
            undoData = u.beforeInsertNode(c.p)
            root = last.insertAfter()
            root.h = fileName
            p = self.import_lines(lines, root)
            if p:
                c.endEditing()
                c.validateOutline()
                p.setDirty()
                c.setChanged()
                u.afterInsertNode(root, 'Import MORE File', undoData)
                c.selectPosition(root)
                c.redraw()
                return root
        if not g.unitTesting:
            g.es("not a valid MORE file", fileName)
        return None
    #@+node:ekr.20031218072017.3215: *3* MORE.import_lines