コード例 #1
0
class JumpUp(plugin.MenuItem):
    capabilities = ['terminal_menu']
    last_cursor_pos = 0

    def __init__(self):
        plugin.MenuItem.__init__(self)
        self.entry = Terminator().windows[0]
        self.entry.connect('key-release-event', self.onKeyRelease)
        self.entry.connect('key-press-event', self.onKeyPress)

    def callback(self, menuitems, menu, terminal):
        item = Gtk.MenuItem(_('JumpUp!'))
        item.connect("activate", self.jumpUp)
        menuitems.append(item)

    def jumpUp(self, widget):
        t = Terminator().last_focused_term
        t.scrollbar_jump(self.last_cursor_pos)

    def onKeyRelease(self, widget, event):
        if float(APP_VERSION) <= 0.98:
            if (event.state & Gtk.gdk.MOD1_MASK == Gtk.gdk.MOD1_MASK) and (
                    event.keyval == 74
                    or event.keyval == 106):  # Alt+J or Alt+j
                self.jumpUp(widget)
        else:
            if (event.state & Gdk.ModifierType.MOD1_MASK
                    == Gdk.ModifierType.MOD1_MASK) and (
                        event.keyval == 74
                        or event.keyval == 106):  # Alt+J or Alt+j
                self.jumpUp(widget)

    def onKeyPress(self, widget, event):
        if event.keyval == 65293:
            t = Terminator().last_focused_term
            col, row = t.get_vte().get_cursor_position()
            if float(APP_VERSION) <= 0.98:
                content = t.get_vte().get_text_range(
                    row - 3, 0, row, col, lambda *a: True).split("\n")
                if re.match("\w+@\w+", content[-2].split(":")
                            [0]) and not content[-2].endswith("$ "):
                    self.last_cursor_pos = row
            else:
                content = t.get_vte().get_text_range(
                    row - 3, 0, row, col, lambda *a: True)[0].split("\n")
                if re.match("\w+@\w+", content[-1].split(":")
                            [0]) and not content[-1].endswith("$ "):
                    self.last_cursor_pos = row
コード例 #2
0
class MultiKill(plugin.MenuItem):
    capabilities = ['terminal_menu']

    def __init__(self):
        plugin.MenuItem.__init__(self)
        self.entry = Terminator().windows[0]
        self.entry.connect('key-release-event', self.onKeyPress)

    def callback(self, menuitems, menu, terminal):
        item = Gtk.MenuItem(_('MultiKill!'))
        item.connect("activate", self.multiKill)
        menuitems.append(item)

    def multiKill(self, widget):
        for t in Terminator().terminals:
            try:
                t.vte.feed_child("\x03", len("\x03"))
            except Exception, ex:
                err('\033[1;31mMultikill failed: %s\033[0m' % ex)
                pass
コード例 #3
0
class MultiSource(plugin.MenuItem):
    capabilities = ['terminal_menu']

    def __init__(self):
        plugin.MenuItem.__init__(self)
        self.entry = Terminator().windows[0]
        self.entry.connect('key-release-event', self.onKeyPress)

    def callback(self, menuitems, menu, terminal):
        item = Gtk.MenuItem(_('MultiSource!'))
        item.connect("activate", self.multiSource)
        menuitems.append(item)

    def multiSource(self, widget):
        for t in Terminator().terminals:
            try:
                command = "source ~/.bashrc\n"
                t.vte.feed_child(command, len(command))
            except Exception, ex:
                err('\033[1;31mMultisource failed: %s\033[0m' % ex)
                pass