How to use the leo.core.leoGlobals.callers 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 / core / leoFrame.py View on Github external
Officially change a headline.
        Set the old undo text to the previous revert point.
        '''
        trace = False and not g.unitTesting
        c = self.c; u = c.undoer
        w = self.edit_widget(p)
        if c.suppressHeadChanged:
            if trace: g.trace('c.suppressHeadChanged')
            return
        if not w:
            if trace: g.trace('****** no w for p: %s', repr(p))
            return
        ch = '\n' # New in 4.4: we only report the final keystroke.
        if s is None: s = w.getAllText()
        if trace:
            g.trace('*** LeoTree', g.callers(5))
            g.trace(p and p.h, 'w', repr(w), 's', repr(s))
        #@+<< truncate s if it has multiple lines >>
        #@+node:ekr.20040803072955.94: *5* << truncate s if it has multiple lines >>
        # Remove one or two trailing newlines before warning of truncation.
        # for i in (0,1):
            # if s and s[-1] == '\n':
                # if len(s) > 1: s = s[:-1]
                # else: s = ''
        while s and s[-1] == '\n':
            s = s[: -1]
        # Warn if there are multiple lines.
        i = s.find('\n')
        if i > -1:
            # g.trace(i,len(s),repr(s))
            g.warning("truncating headline to one line")
            s = s[: i]
github leo-editor / leo-editor / leo / plugins / threading_colorizer.py View on Github external
def match_regexp_helper (self,s,i,pattern):

        '''Return the length of the matching text if seq (a regular expression) matches the present position.'''

        if self.verbose: g.trace(g.callers(1),i,repr(s[i:i+20]),'pattern',pattern)
        trace = False

        try:
            flags = re.MULTILINE
            if self.ignore_case: flags|= re.IGNORECASE
            re_obj = re.compile(pattern,flags)
        except Exception:
            # Bug fix: 2007/11/07: do not call g.es here!
            g.trace('Invalid regular expression: %s' % (pattern))
            return 0

        # Match succeeds or fails more quickly than search.
        # g.trace('before')
        self.match_obj = mo = re_obj.match(s,i) # re_obj.search(s,i) 
        # g.trace('after')
github leo-editor / leo-editor / leo / plugins / mod_tempfname.py View on Github external
def cleanFileName(c,v,ext):
    '''Compute the file name when subdirectories mirror the node's hierarchy in Leo.'''
    trace = False and not g.unitTesting
    g.trace(g.callers())
    p = c.p
    use_extentions = c.config.getBool('open_with_uses_derived_file_extensions')
    ancestors,found = [],False
    for p in p.self_and_parents():
        h = p.anyAtFileNodeName()
        if not h:
            h = p.h  # Not an @file node: use the entire header
        elif use_extentions and not found:
            # Found the nearest ancestor @ node.
            found = True
            base,ext2 = g.os_path_splitext(h)
            if p == c.p: h = base
            if ext2: ext = ext2
        ancestors.append(g.sanitize_filename(h))

    # The base directory is /Leo.
github leo-editor / leo-editor / leo / plugins / importers / rst.py View on Github external
def endGen (self,s):

        '''Remember the underlining characters in the root's uA.'''

        trace = False and not g.unitTesting
        p = self.root
        if p:
            tag = 'rst-import'
            d = p.v.u.get(tag,{})
            underlines1 = ''.join([str(z) for z in self.underlines1])
            underlines2 = ''.join([str(z) for z in self.underlines2])
            d ['underlines1'] = underlines1
            d ['underlines2'] = underlines2
            self.underlines1 = underlines1
            self.underlines2 = underlines2
            if trace: g.trace(repr(underlines1),repr(underlines2),g.callers(4))
            p.v.u [tag] = d

        # Append a warning to the root node.
        warningLines = (
            'Warning: this node is ignored when writing this file.',
            'However, @ @rst-options are recognized in this node.',
        )
        lines = ['.. %s' % (z) for z in warningLines]
        warning = '\n%s\n' % '\n'.join(lines)
        self.root.b = self.root.b + warning
    #@+node:ekr.20140723122936.18106: *3* isUnderLine
github leo-editor / leo-editor / leo / core / leoFrame.py View on Github external
def oops(self):
        g.pr("LeoTreeTree oops:", g.callers(4), "should be overridden in subclass")
    #@-others
github leo-editor / leo-editor / leo / plugins / importers / basescanner.py View on Github external
def append_to_body(self, p, s):
        '''
        Similar to c.appendStringToBody,
        but does not recolor the text or redraw the screen.
        '''
        assert g.isString(s), (repr(s), g.callers())
        assert g.isString(p.b), (repr(p.b), g.callers())
        p.b = p.b + s
    #@+node:ekr.20161101094729.1: *3* IC.V1: Scanning & code generation
github leo-editor / leo-editor / leo / plugins / threading_colorizer.py View on Github external
def trace_match(self,kind,s,i,j):

        if j != i and self.trace_match_flag:
            g.trace(kind,i,j,g.callers(2),self.dump(s[i:j]))
    #@-others
github leo-editor / leo-editor / leo / core / leoMarkup.py View on Github external
def run_pandoc(self, i_path, o_path):
        """
         Process the input file given by i_path with pandoc.
        """
        global pandoc_exec
        assert pandoc_exec, g.callers()
        # Call pandoc to write the output file.
        command = f"pandoc {i_path} -t html5 -o {o_path}"
            # --quiet does no harm.
        g.execute_shell_commands(command)
    #@+node:ekr.20191017165427.1: *4* markup.run_sphinx
github leo-editor / leo-editor / leo / plugins / qt_tree.py View on Github external
return None
        if self.busy:
            return None
        # Cancel the delayed redraw request.
        c.requestLaterRedraw = False
        if not p:
            p = c.currentPosition()
        elif c.hoistStack and p.h.startswith('@chapter') and p.hasChildren():
            # Make sure the current position is visible.
            # Part of fix of bug 875323: Hoist an @chapter node leaves a non-visible node selected.
            p = p.firstChild()
            c.frame.tree.select(p)
            c.setCurrentPosition(p)
        else:
            c.setCurrentPosition(p)
        assert not self.busy, g.callers()
        self.redrawCount += 1
        self.initData()
        try:
            self.busy = True
            self.drawTopTree(p)
        finally:
            self.busy = False
        self.setItemForCurrentPosition()
        return p  # Return the position, which may have changed.