예제 #1
0
def init():
    '''Return True if the plugin has loaded successfully.'''
    ok = not g.unitTesting
    if ok:
        g.registerHandler("open1", onOpen)
        g.plugin_signon(__name__)
    return ok
예제 #2
0
def init ():

    # This plugin is now gui independent.
    g.registerHandler(("new2","menu2"), onCreate)
    g.plugin_signon(__name__)

    return True
예제 #3
0
def init():
    """Leo plugin init. function"""
    g.registerHandler('after-create-leo-frame',onCreate)

    g.plugin_signon(__name__)

    return True
예제 #4
0
def init():
    '''Return True if the plugin has loaded successfully.'''
    ok = not g.app.unitTesting # Not for unit tests.
    if ok: # Register the handlers...
        g.registerHandler("start2", onStart)
        g.plugin_signon(__name__)
    return ok
예제 #5
0
def install_handlers():
    """ Install all the wanted handlers (menu creators) """

    hnd = [
        openwith_rclick, refresh_rclick, editnode_rclick,
        nextclone_rclick, marknodes_rclick,
        configuredcommands_rclick, deletenodes_rclick,
        openurl_rclick]

    g.tree_popup_handlers.extend(hnd)
    g.registerHandler("idle", editnode_on_idle)

    # just for kicks, the @commands

    #@+<< Add commands >>
    #@+node:ville.20090701224704.9805: *3* << Add commands >>
    # cm is 'contextmenu' prefix
    @g.command('cm-external-editor')
    def cm_external_editor_f(event):    
        """ Open node in external editor 

        Set LEO_EDITOR/EDITOR environment variable to get the editor you want.
        """
        c = event['c']
        pos = c.currentPosition()
        editor = g.guessExternalEditor()

        # c.openWith(data = ('subprocess.Popen', editor, None))
        d = {'kind':'subprocess.Popen','args':[editor],'ext':None}
        c.openWith(d=d)
예제 #6
0
def init():
    '''Return True if the plugin has loaded successfully.'''
    ok = not g.app.unitTesting # Not for unit testing.
    if ok:
        g.registerHandler(("bodykey1","bodykey2","headkey1","headkey2"), onKey)
        g.plugin_signon(__name__)
    return ok
예제 #7
0
        def __init__(self, *args, **kwargs):

            self.c = kwargs['c']
            del kwargs['c']
            QtWidgets.QWidget.__init__(self, *args, **kwargs)
            # were we opened by an @ rich node? Calling code will set
            self.at_rich = False
            # are we being closed by leaving an @ rich node? Calling code will set
            self.at_rich_close = False
            # read settings.
            self.reloadSettings()
            # load HTML template
            template_path = g.os_path_join(g.computeLeoDir(), 'plugins', 'cke_template.html')
            self.template = open(template_path).read()
            path = g.os_path_join(g.computeLeoDir(), 'external', 'ckeditor')
            self.template = self.template.replace(
                '[CKEDITOR]', QtCore.QUrl.fromLocalFile(path).toString())
            # make widget containing QWebView
            self.setLayout(QtWidgets.QVBoxLayout())
            self.layout().setSpacing(0)
            self.layout().setContentsMargins(0,0,0,0)
            # enable inspector, if this really is QtWebKit
            if real_webkit:
                QtWebKit.QWebSettings.globalSettings().setAttribute(
                    QtWebKit.QWebSettings.DeveloperExtrasEnabled, True)
            self.webview = QtWebKitWidgets.QWebView()
            self.layout().addWidget(self.webview)
            g.registerHandler('select3', self.select_node)
            g.registerHandler('unselect1', self.unselect_node)
            # load current node
            self.select_node('', {'c': self.c, 'new_p': self.c.p})
예제 #8
0
def init():
    if 1: # OK for unit testing.

        g.registerHandler("after-create-leo-frame", on_create)
        g.plugin_signon(__name__)

        return True
예제 #9
0
def init ():
    '''Return True if the plugin has loaded successfully.'''
    ok = not g.app.unitTesting
    if ok:
        g.registerHandler("all",trace_tags)
        g.plugin_signon(__name__)
    return ok
예제 #10
0
    def __init__(self,  parent, c):
        super(PyInterp,  self).__init__(parent)

        # this widget swallows stdout + stderr while focused, 
        # but resets them upon losing focus

        if not g.user_dict.get('old_stdout', None):
            g.user_dict['old_stdout'] = sys.stdout
        if not g.user_dict.get('old_stderr', None):
            g.user_dict['old_stderr'] = sys.stderr
        
        self.refreshMarker      = False # to change back to >>> from ...
        self.multiLine          = False # code spans more than one line
        self.command            = ''    # command to be ran
        self.printBanner()              # print sys info
        self.marker()                   # make the >>> or ... marker        
        self.history            = []    # list of commands entered
        self.historyIndex       = -1
        self.interpreterLocals  = {}
        
        self.c = c

        # initilize interpreter with self locals
        self.initInterpreter(locals())
        
        # update p when new node selected
        g.registerHandler('select2', self.select2_hook)
예제 #11
0
def onCreate(tag, keywords):

    """Handle the per-Leo-file settings."""

    global gDict

    c = keywords.get('c')
    if g.app.killed or not c or not c.exists: return
    if g.unitTesting: return  # 2011/02/28
    
    # 2011/02/28: do nothing here if we already have registered the idle-time hook.
    d = gDict.get(c.hash())
    if d: return

    active = c.config.getBool('mod_autosave_active',default=False)
    interval = c.config.getInt('mod_autosave_interval')

    if active:
        # Create an entry in the global settings dict.
        d = {
            'last':time.time(),
            'interval':interval,
        }
        gDict[c.hash()] = d
        g.es("auto save enabled every %s sec." % (
            interval),color="orange")
        g.registerHandler('idle',onIdle)
        g.enableIdleTimeHook()
    else:
        g.es("@bool mod_autosave_active=False",color='orange')
예제 #12
0
def init ():
    '''Return True if the plugin has loaded successfully.'''
    g.registerHandler("create-optional-menus",createExportMenus)
    g.registerHandler('after-create-leo-frame', onCreate)
    g.plugin_signon(__name__)
    # I think this should be ok for unit testing.
    return True
예제 #13
0
def init():
    '''Return True if the plugin has loaded successfully.'''
    ok = g.app.gui.guiName() == "qt"
    if ok:
        g.registerHandler('select1', onSelect)
        g.plugin_signon(__name__)
    return ok
예제 #14
0
 def __init__(self, c):
     '''Ctor for WikiView class.'''
     self.c = c
     c._wikiview = self
     leadins, self.urlpats = self.parse_options()
     assert len(leadins) == len(self.urlpats), (leadins, self.urlpats)
     self.colorizer = c.frame.body.colorizer
     if hasattr(self.colorizer, 'set_wikiview_patterns'):
         self.colorizer.set_wikiview_patterns(leadins, self.urlpats)
     self.select = 'select3'  # Leo hook to hide text
     self.pts=1  # hidden text size (0.1 does not work!)
     self.pct=1  # hidden text letter spacing
     self.active = c.config.getBool('wikiview-active')
         # This setting is True by default, so the redundancy is harmless.
     w = c.frame.body.widget
     if not w:
         return # w may not exist during unit testing.
     g.registerHandler(self.select,self.hide)
     w.cursorPositionChanged.connect(self.unhide)
     # size to restore text to when unhiding,
     # w.currentFont().pointSize() is -1 which doesn't work, hence QFontInfo
     self.size = QtGui.QFontInfo(w.currentFont()).pointSize()
     # apply hiding for initial load (`after-create-leo-frame` from module level
     # init() / onCreate())
     self.hide(self.select, {'c': c})
예제 #15
0
def init():
    '''Return True if the plugin has loaded successfully.'''
    ok = g.app.gui.guiName() in ('qt', 'qttabs')
    if ok:
        g.registerHandler('after-create-leo-frame', onCreate)
        g.plugin_signon(__name__)
    return ok
예제 #16
0
def init ():
    '''Return True if the plugin has loaded successfully.'''
    # Note: call onCreate _after_ reading the .leo file.
    # That is, the 'after-create-leo-frame' hook is too early!
    g.registerHandler(('new','open2'),onCreate)
    g.plugin_signon(__name__)
    return True
예제 #17
0
def attachToCommander(t,k):
    c = k.get('c')
    event = c.config.getString('active_path_event') or "headdclick1"
    # pylint: disable=unnecessary-lambda
    g.registerHandler(event, lambda t,k: onSelect(t,k))

    # not using a proper class, so
    c.__active_path = {'ignore': [], 'autoload': []}

    if c.config.getData('active_path_ignore'):
        c.__active_path['ignore'] = [re.compile(i, re.IGNORECASE)
            for i in c.config.getData('active_path_ignore')]

    if c.config.getData('active_path_autoload'):
        c.__active_path['autoload'] = [re.compile(i, re.IGNORECASE)
            for i in c.config.getData('active_path_autoload')]

    if c.config.getBool('active_path_load_docstring'):
        c.__active_path['load_docstring'] = True
    else:
        c.__active_path['load_docstring'] = False

    if c.config.getFloat('active_path_timeout_seconds'):
        c.__active_path['timeout'] = c.config.getFloat('active_path_timeout_seconds')
    else:
        c.__active_path['timeout'] = 10.

    if c.config.getInt('active_path_max_size'):
        c.__active_path['max_size'] = c.config.getInt('active_path_max_size')
    else:
        c.__active_path['max_size'] = 1000000

    c.__active_path['DS_SENTINEL'] = "@language rest # AUTOLOADED DOCSTRING"
예제 #18
0
    def __init__ (self, c):

        self.c = c
        c.attribEditor = self
        self.pname = "_attrib_edit_frame"  # used to tag out panel
        self.reloadSettings()
        self.attrPaths = set()  # set of tuples (getter-class, path)
        self.handlers = [
           ('select3', self.updateEditor),
        ]
        for i in self.handlers:
            g.registerHandler(i[0], i[1])
        # 'body' or 'tab' mode
        # self.guiMode = c.config.getString('attrib_edit_placement') or 'tab'
        self.guiMode = 'tab'
        # body mode in not compatible with nested_splitter, causes hard crash
        if self.guiMode == 'body':
            self.holder = QtWidgets.QSplitter(QtCore.Qt.Vertical)
            self.holder.setMinimumWidth(300)
            parent = c.frame.top.leo_body_frame.parent()
            self.holder.addWidget(c.frame.top.leo_body_frame)
            parent.addWidget(self.holder)
            self.parent = self.holder
        elif self.guiMode == 'tab':
            self.parent = QtWidgets.QFrame()
            self.holder = QtWidgets.QHBoxLayout()
            self.parent.setLayout(self.holder)
            c.frame.log.createTab('Attribs', widget = self.parent)
예제 #19
0
    def __init__(self, c, v=None):
        
        self.c = c
        self.v = v if v is not None else c.p.v
        
        # if hasattr(c, 'free_layout') and hasattr(c.free_layout, 'get_top_splitter'):
            # Second hasattr temporary until free_layout merges with trunk
            
        self.w = QtGui.QWidget()
        
        # stuff for pane persistence
        self.w._ns_id = '_leo_bookmarks_show:'
        c.db['_leo_bookmarks_show'] = str(self.v.gnx)
            
        # else:
            # c.frame.log.createTab(c.p.h[:10])
            # tabWidget = c.frame.log.tabWidget
            # self.w = tabWidget.widget(tabWidget.count()-1)
        
        self.w.setObjectName('show_bookmarks')
        self.w.setMinimumSize(10, 10)
        self.w.setLayout(QtGui.QVBoxLayout())
        self.w.layout().setContentsMargins(0,0,0,0)

        self.current_list = self.get_list()
        
        self.show_list(self.current_list)
        
        g.registerHandler('select1', self.update)
예제 #20
0
def init ():
        
    ok = g.app.gui.guiName() in ('qt','qttabs')
    if ok:
        g.registerHandler('after-create-leo-frame',onCreate)
        g.plugin_signon(__file__)
    return ok
예제 #21
0
def attachToCommander(t, k):
    c = k.get("c")
    event = c.config.getString("active_path_event") or "headdclick1"
    # pylint: disable=unnecessary-lambda
    g.registerHandler(event, lambda t, k: onSelect(t, k))

    # not using a proper class, so
    c.__active_path = {"ignore": [], "autoload": []}

    if c.config.getData("active_path_ignore"):
        c.__active_path["ignore"] = [re.compile(i, re.IGNORECASE) for i in c.config.getData("active_path_ignore")]

    if c.config.getData("active_path_autoload"):
        c.__active_path["autoload"] = [re.compile(i, re.IGNORECASE) for i in c.config.getData("active_path_autoload")]

    if c.config.getBool("active_path_load_docstring"):
        c.__active_path["load_docstring"] = True
    else:
        c.__active_path["load_docstring"] = False

    if c.config.getFloat("active_path_timeout_seconds"):
        c.__active_path["timeout"] = c.config.getFloat("active_path_timeout_seconds")
    else:
        c.__active_path["timeout"] = 10.0

    if c.config.getInt("active_path_max_size"):
        c.__active_path["max_size"] = c.config.getInt("active_path_max_size")
    else:
        c.__active_path["max_size"] = 1000000

    c.__active_path["DS_SENTINEL"] = "@language rest # AUTOLOADED DOCSTRING"
예제 #22
0
def init():
    '''Return True if the plugin has loaded successfully.'''
    ok = Ft
    if ok:
        g.registerHandler(('menu2',"new"),addMenu)
        g.plugin_signon(__name__)
    return ok
예제 #23
0
def init ():

    # Ok for unit testing: adds command to Outline menu.
    g.registerHandler( ('new','menu2') ,onCreate)
    g.plugin_signon(__name__)

    return True
예제 #24
0
def init():
    '''Return True if the plugin has loaded successfully.'''
    g.registerHandler('after-create-leo-frame', onCreate)
    g.plugin_signon(__name__)
    if '_quickmove' not in g.app.db:
        g.app.db['_quickmove'] = {'global_targets': []}
    return True
예제 #25
0
def init():
    '''Return True if the plugin has loaded successfully.'''
    ok = bool(QtSvg and QtWebKitWidgets)
    g.plugin_signon(__name__)
    g.registerHandler('after-create-leo-frame', onCreate)
    g.registerHandler('scrolledMessage', show_scrolled_message)
    return ok
예제 #26
0
def init():
    '''Return True if the plugin has loaded successfully.'''
    ok = not g.app.unitTesting # Dangerous for unit testing.
    if ok:
        g.registerHandler("icondclick1", onIconDoubleClick)
        g.plugin_signon(__name__)
    return ok
예제 #27
0
    def __init__(self, c, v=None):

        self.c = c
        c._bookmarks = self
        # self.v - where the bookmarks for c are kept, may not be in c
        if v is None:
            v = self.v = c.p.v
        else:
            self.v = v
        self.current = None  # current (last used) bookmark
        self.previous = None  # position in outline, for outline / bookmarks switch
        self.levels = c.config.getInt('bookmarks-levels') or 1
        # levels to show in hierarchical display
        self.second = False  # second click of current bookmark?
        self.upwards = False  # moving upwards through hierarchy
        self.w = QtWidgets.QWidget()
        self.reloadSettings()
        # stuff for pane persistence
        self.w._ns_id = '_leo_bookmarks_show:'
        # v might not be in this outline
        c.db['_leo_bookmarks_show'] = v.context.vnode2position(v).get_UNL()
        # else:
            # c.frame.log.createTab(c.p.h[:10])
            # tabWidget = c.frame.log.tabWidget
            # self.w = tabWidget.widget(tabWidget.count()-1)
        self.w.setObjectName('show_bookmarks')
        self.w.setMinimumSize(10, 10)
        self.w.setLayout(QtWidgets.QVBoxLayout())
        self.w.layout().setContentsMargins(0,0,0,0)
        self.current_list = self.get_list()
        self.show_list(self.current_list)
        g.registerHandler('select1', self.update)
예제 #28
0
def init():

    ok = not g.app.unitTesting # Dangerous for unit testing.
    if ok:
        g.registerHandler("icondclick1", onIconDoubleClick)
        g.plugin_signon(__name__)
    return ok
예제 #29
0
def init():
    '''Return True if the plugin has loaded successfully.'''
    if g.unitTesting or not asttools:
        return False
    else:
        g.registerHandler('after-create-leo-frame', onCreate)
        g.plugin_signon(__name__)
        return True
예제 #30
0
def init():
    '''Return True if the plugin has loaded successfully.'''
    if g.app.gui.guiName() != "qt":
        print('attrib_edit.py plugin not loading because gui is not Qt')
        return False
    g.registerHandler('after-create-leo-frame',onCreate)
    g.plugin_signon(__name__)
    return True
예제 #31
0
def init():
    '''Return True if the plugin has loaded successfully.'''
    g.registerHandler("command1", timestamp)
    g.plugin_signon(__name__)
    return True  # OK for unit testing.
예제 #32
0
def init():
    ok = not g.app.unitTesting  # Not for unit tests.
    if ok:  # Register the handlers...
        g.registerHandler("start2", onStart)
        g.plugin_signon(__name__)
    return ok
예제 #33
0
파일: at_folder.py 프로젝트: AG4GitHub/leo
def init():
    g.registerHandler("select1", onSelect)
    g.plugin_signon(__name__)
예제 #34
0
def init():
    """Return True if the plugin has loaded successfully."""
    g.registerHandler('save1', beforeSave)
    g.plugin_signon(__name__)
    return True
예제 #35
0
def init():

    g.registerHandler('after-create-leo-frame', onCreate)
    g.plugin_signon(__name__)

    return True
예제 #36
0
def init ():
    '''Return True if the plugin has loaded successfully.'''
    g.registerHandler('after-create-leo-frame', DT)
    g.plugin_signon(__name__)
    return True
예제 #37
0
 def _register_handlers(self):
     """_register_handlers - attach to Leo signals"""
     for hook, handler in self.handlers:
         g.registerHandler(hook, handler)
예제 #38
0
def init():
    '''Return True if the plugin has loaded successfully.'''
    # Ok for unit testing: creates menu.
    g.registerHandler("create-optional-menus", createExportMenu)
    g.plugin_signon(__name__)
    return True
예제 #39
0
def init():
    g.registerHandler(('new', 'open2'), onCreate)
    g.registerHandler(('save1'), onSave)
    g.plugin_signon(__name__)
    return True
def init ():
    '''Return True if the plugin has loaded successfully.'''
    # This plugin is gui-independent.
    g.registerHandler(('new','menu2'),create_import_cisco_menu)
    g.plugin_signon(__name__)
    return True
예제 #41
0
def init():
    '''Return True if the plugin has loaded successfully.'''
    # Ok for unit testing: creates a new menu.
    g.registerHandler("after-create-leo-frame", onCreate)
    g.plugin_signon(__name__)
    return True
예제 #42
0
def init():
    """Return True if the plugin has loaded successfully."""
    g.registerHandler('after-create-leo-frame', onCreate)
    g.plugin_signon(__name__)
    return True
예제 #43
0
def init():
    '''Top-level init function for qt_commands.py.'''
    ok = True
    g.plugin_signon(__name__)
    g.registerHandler("select2", onSelect)
    return ok
예제 #44
0
def init():
    '''Return True if the plugin has loaded successfully.'''
    g.registerHandler("start2", onStart)
    g.plugin_signon(__name__)
    return True
예제 #45
0
def init():
    g.registerHandler("start2", onStart)
        # Needed to have the plugin show in the Plugin Manager list.
    g.plugin_signon(__name__)
    return True
예제 #46
0
def init():
    '''Return True if the plugin has loaded successfully.'''
    # This plugin is now gui independent.
    g.registerHandler(("new2", "menu2"), onCreate)
    g.plugin_signon(__name__)
    return True
예제 #47
0
def init():
    '''Return True if the plugin has loaded successfully.'''
    g.registerHandler("select1", onSelect)
    g.plugin_signon(__name__)
    # Fix https://bugs.launchpad.net/leo-editor/+bug/1335310
    return True
예제 #48
0
 def __init__(self, c):
     """Ctor for FreeLayoutController class."""
     self.c = c
     g.registerHandler('after-create-leo-frame', self.init)
     # Plugins must be loaded first to provide their widgets in panels etc.
     g.registerHandler('after-create-leo-frame2', self.loadLayouts)
예제 #49
0
def init():
    '''Return True if this plugin loaded correctly.'''
    # Ok for unit testing: adds command to Outline menu.
    g.registerHandler(('new', 'menu2'), onCreate)
    g.plugin_signon(__name__)
    return True
예제 #50
0
def init():
    """Return True if the plugin has loaded successfully."""
    g.registerHandler(('open2', 'new2'), onCreate)
    g.plugin_signon(__name__)
    return True
예제 #51
0
def init():
    '''Return True if the plugin has loaded successfully.'''
    g.registerHandler("start1", addPluginDirectives)
    return True
예제 #52
0
def init():
    """Return True if the plugin has loaded successfully."""
    # 2031: Allow this plugin to run without Qt.
    g.registerHandler('after-create-leo-frame', onCreate)
    g.plugin_signon(__name__)
    return True