示例#1
0
 def __init__(self,
              c,
              char,
              event,
              binding,
              w,
              x=None,
              y=None,
              x_root=None,
              y_root=None):
     '''Ctor for LeoKeyEvent class.'''
     trace = False and not g.unitTesting
     if g.isStroke(binding):
         g.trace('***** (LeoKeyEvent) oops: already a stroke', binding,
                 g.callers())
         stroke = binding
     else:
         stroke = g.KeyStroke(binding) if binding else None
     assert g.isStrokeOrNone(stroke), '(LeoKeyEvent) %s %s' % (repr(stroke),
                                                               g.callers())
     if trace: g.trace('(LeoKeyEvent) stroke', stroke)
     self.c = c
     self.char = char or ''
     self.event = event  # New in Leo 4.11.
     self.stroke = stroke
     self.w = self.widget = w
     # Optional ivars
     self.x = x
     self.y = y
     # Support for fastGotoNode plugin
     self.x_root = x_root
     self.y_root = y_root
示例#2
0
    def __init__(self, c, char, shortcut, w, x, y, x_root, y_root):

        trace = False and not g.unitTesting
        k = c.k

        if g.isStroke(shortcut):
            g.trace('***** (leoKeyEvent) oops: already a stroke', shortcut,
                    g.callers())
            stroke = shortcut
        else:
            stroke = g.KeyStroke(shortcut) if shortcut else None

        assert g.isStrokeOrNone(stroke), '(leoKeyEvent) %s %s' % (repr(stroke),
                                                                  g.callers())

        if trace: g.trace('(leoKeyEvent) stroke', stroke)

        self.c = c
        self.char = char or ''
        self.stroke = stroke
        self.w = self.widget = w

        # Optional ivars
        self.x = x
        self.y = y

        # Support for fastGotoNode plugin
        self.x_root = x_root
        self.y_root = y_root
示例#3
0
    def __init__ (self,c,char,event,shortcut,w,x,y,x_root,y_root):

        trace = False and not g.unitTesting

        if g.isStroke(shortcut):
            g.trace('***** (leoKeyEvent) oops: already a stroke',shortcut,g.callers())
            stroke = shortcut
        else:
            stroke = g.KeyStroke(shortcut) if shortcut else None

        assert g.isStrokeOrNone(stroke),'(leoKeyEvent) %s %s' % (
            repr(stroke),g.callers())

        if trace: g.trace('(leoKeyEvent) stroke',stroke)

        self.c = c
        self.char = char or ''
        self.event = event # New in Leo 4.11.
        self.stroke = stroke
        self.w = self.widget = w

        # Optional ivars
        self.x = x
        self.y = y

        # Support for fastGotoNode plugin
        self.x_root = x_root
        self.y_root = y_root
示例#4
0
 def __init__(self,
              c,
              char,
              event,
              binding,
              w,
              x=None,
              y=None,
              x_root=None,
              y_root=None):
     '''Ctor for LeoKeyEvent class.'''
     if g.isStroke(binding):
         g.trace('***** (LeoKeyEvent) oops: already a stroke', binding,
                 g.callers())
         stroke = binding
     else:
         stroke = g.KeyStroke(binding) if binding else None
     assert g.isStrokeOrNone(stroke), '(LeoKeyEvent) %s %s' % (repr(stroke),
                                                               g.callers())
     if 'keys' in g.app.debug:
         print('LeoKeyEvent: binding: %s, stroke: %s, char: %r' %
               (binding, stroke, char))
     self.c = c
     self.char = char or ''
     self.event = event  # New in Leo 4.11.
     self.stroke = stroke
     self.w = self.widget = w
     # Optional ivars
     self.x = x
     self.y = y
     # Support for fastGotoNode plugin
     self.x_root = x_root
     self.y_root = y_root
示例#5
0
 def __init__(self, c, char, event, binding, w,
     x=None, y=None, x_root=None, y_root=None
 ):
     '''Ctor for LeoKeyEvent class.'''
     if g.isStroke(binding):
         g.trace('***** (LeoKeyEvent) oops: already a stroke', binding, g.callers())
         stroke = binding
     else:
         stroke = g.KeyStroke(binding) if binding else None
     assert g.isStrokeOrNone(stroke), '(LeoKeyEvent) %s %s' % (
         repr(stroke), g.callers())
     if 'keys' in g.app.debug:
         print('LeoKeyEvent: binding: %s, stroke: %s, char: %r' % (
             binding, stroke, char))
     self.c = c
     self.char = char or ''
     self.event = event # New in Leo 4.11.
     self.stroke = stroke
     self.w = self.widget = w
     # Optional ivars
     self.x = x
     self.y = y
     # Support for fastGotoNode plugin
     self.x_root = x_root
     self.y_root = y_root
示例#6
0
 def __init__(self,
              c,
              char,
              event,
              binding,
              w,
              x=None,
              y=None,
              x_root=None,
              y_root=None):
     """Ctor for LeoKeyEvent class."""
     if g.isStroke(binding):
         g.trace('***** (LeoKeyEvent) oops: already a stroke', binding,
                 g.callers())
         stroke = binding
     else:
         stroke = g.KeyStroke(binding) if binding else None
     assert g.isStrokeOrNone(
         stroke), f"(LeoKeyEvent) {stroke!r} {g.callers()}"
     if 'keys' in g.app.debug:
         print(
             f"LeoKeyEvent: binding: {binding}, stroke: {stroke}, char: {char!r}"
         )
     self.c = c
     self.char = char or ''
     self.event = event  # New in Leo 4.11.
     self.stroke = stroke
     self.w = self.widget = w
     # Optional ivars
     self.x = x
     self.y = y
     # Support for fastGotoNode plugin
     self.x_root = x_root
     self.y_root = y_root
示例#7
0
 def getBindingsForCommand(self, commandName):
     k = self.c.k
     data = []
     n1, n2 = 4, 20
     d = k.bindingsDict
     for stroke in sorted(d):
         assert g.isStroke(stroke), repr(stroke)
         aList = d.get(stroke, [])
         for bi in aList:
             if bi.commandName == commandName:
                 pane = '' if bi.pane == 'all' else f" {bi.pane}:"
                 s1 = pane
                 s2 = k.prettyPrintKey(stroke)
                 s3 = bi.commandName
                 n1 = max(n1, len(s1))
                 n2 = max(n2, len(s2))
                 data.append((s1, s2, s3),)
     data.sort(key=lambda x: x[1])
     return ','.join([f"{z1} {z2}" for z1, z2, z3 in data]).strip()
示例#8
0
 def getBindingsForCommand(self, commandName):
     k = self.c.k
     data = []
     n1, n2 = 4, 20
     d = k.bindingsDict
     for stroke in sorted(d):
         assert g.isStroke(stroke), repr(stroke)
         aList = d.get(stroke, [])
         for bi in aList:
             if bi.commandName == commandName:
                 pane = '' if bi.pane == 'all' else ' %s:' % (bi.pane)
                 s1 = pane
                 s2 = k.prettyPrintKey(stroke)
                 s3 = bi.commandName
                 n1 = max(n1, len(s1))
                 n2 = max(n2, len(s2))
                 data.append((s1, s2, s3),)
     data.sort(key=lambda x: x[1])
     return ','.join(['%s %s' % (z1, z2) for z1, z2, z3 in data]).strip()
示例#9
0
 def getBindingsForCommand(self, commandName):
     c, k = self.c, self.c.k
     data = []
     n1, n2 = 4, 20
     d = k.bindingsDict
     for stroke in sorted(d):
         assert g.isStroke(stroke), repr(stroke)
         aList = d.get(stroke, [])
         for si in aList:
             assert g.isShortcutInfo(si), si
             if si.commandName == commandName:
                 pane = '' if si.pane == 'all' else ' %s:' % (si.pane)
                 s1 = pane
                 s2 = k.prettyPrintKey(stroke)
                 s3 = si.commandName
                 n1 = max(n1, len(s1))
                 n2 = max(n2, len(s2))
                 data.append((s1, s2, s3), )
     data.sort(key=lambda x: x[1])
     return ','.join(['%s %s' % (s1, s2) for s1, s2, s3 in data]).strip()