当前位置: 首页>>代码示例>>Python>>正文


Python History.move方法代码示例

本文整理汇总了Python中history.History.move方法的典型用法代码示例。如果您正苦于以下问题:Python History.move方法的具体用法?Python History.move怎么用?Python History.move使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在history.History的用法示例。


在下文中一共展示了History.move方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: Entry

# 需要导入模块: from history import History [as 别名]
# 或者: from history.History import move [as 别名]
class Entry(gtk.EventBox):
	def __init__(self, view):
		gtk.EventBox.__init__(self)
		self._view = view
		
		hbox = gtk.HBox(False, 3)
		hbox.show()
		hbox.set_border_width(3)
		
		self._entry = gtk.Entry()
		self._entry.modify_font(self._view.style.font_desc)
		self._entry.set_has_frame(False)
		self._entry.set_name('command-bar')
		self._entry.modify_text(gtk.STATE_NORMAL, self._view.style.text[gtk.STATE_NORMAL])
		self._entry.set_app_paintable(True)
		
		self._entry.connect('realize', self.on_realize)
		self._entry.connect('expose-event', self.on_entry_expose)

		self._entry.show()

		self._prompt_label = gtk.Label('<b>&gt;&gt;&gt;</b>')
		self._prompt_label.set_use_markup(True)
		self._prompt_label.modify_font(self._view.style.font_desc)
		self._prompt_label.show()
		self._prompt_label.modify_fg(gtk.STATE_NORMAL, self._view.style.text[gtk.STATE_NORMAL])
		
		self.modify_bg(gtk.STATE_NORMAL, self.background_gdk())
		self._entry.modify_base(gtk.STATE_NORMAL, self.background_gdk())
		
		self._entry.connect('focus-out-event', self.on_entry_focus_out)
		self._entry.connect('key-press-event', self.on_entry_key_press)
		
		self.connect_after('size-allocate', self.on_size_allocate)
		self.connect_after('expose-event', self.on_expose)
		self.connect_after('realize', self.on_realize)
		
		self._history = History(os.path.expanduser('~/.gnome2/gedit/commander/history'))
		self._prompt = None
		
		hbox.pack_start(self._prompt_label, False, False, 0)
		hbox.pack_start(self._entry, True, True, 0)
		
		self.add(hbox)
		self.attach()

		self._entry.grab_focus()
		self._wait_timeout = 0
		self._info_window = None
		
		self.connect('destroy', self.on_destroy)
		
		self._history_prefix = None		
		self._suspended = None
		self._handlers = [
			[0, gtk.keysyms.Up, self.on_history_move, -1],
			[0, gtk.keysyms.Down, self.on_history_move, 1],
			[None, gtk.keysyms.Return, self.on_execute, None],
			[None, gtk.keysyms.KP_Enter, self.on_execute, None],
			[0, gtk.keysyms.Tab, self.on_complete, None],
			[0, gtk.keysyms.ISO_Left_Tab, self.on_complete, None]
		]
		
		self._re_complete = re.compile('("((?:\\\\"|[^"])*)"?|\'((?:\\\\\'|[^\'])*)\'?|[^\s]+)')
		self._command_state = commands.Commands.State()
	
	def view(self):
		return self._view

	def on_realize(self, widget):
		widget.window.set_back_pixmap(None, False)
	
	def on_entry_expose(self, widget, evnt):
		ct = evnt.window.cairo_create()
		ct.rectangle(evnt.area.x, evnt.area.y, evnt.area.width, evnt.area.height)
		
		bg = self.background_color()
		ct.set_source_rgb(bg[0], bg[1], bg[1])
		ct.fill()
		return False

	def on_expose(self, widget, evnt):
		ct = evnt.window.cairo_create()
		color = self.background_color()
		
		ct.rectangle(evnt.area.x, evnt.area.y, evnt.area.width, evnt.area.height)
		ct.clip()
		
		# Draw separator line
		ct.move_to(0, 0)
		ct.set_line_width(1)
		ct.line_to(self.allocation.width, 0)

		ct.set_source_rgb(1 - color[0], 1 - color[1], 1 - color[2])
		ct.stroke()
		return False
		
	def on_size_allocate(self, widget, alloc):
		vwwnd = self._view.get_window(gtk.TEXT_WINDOW_BOTTOM).get_parent()
		size = vwwnd.get_size()
#.........这里部分代码省略.........
开发者ID:alexkv,项目名称:gedit-commander,代码行数:103,代码来源:entry.py

示例2: Entry

# 需要导入模块: from history import History [as 别名]
# 或者: from history.History import move [as 别名]
class Entry(Gtk.Box):
    __gtype_name__ = "CommanderEntry"

    def _show(self):
        self._reveal.set_reveal_child(True)

    def _hide(self):
        self._reveal.set_reveal_child(False)

    def __init__(self, view):
        super(Entry, self).__init__()

        self._view = view
        view.connect("destroy", self._on_view_destroyed)

        self._history = History(os.path.join(GLib.get_user_config_dir(), 'gedit/commander/history'))
        self._history_prefix = None

        self._prompt_text = None
        self._accel_group = None

        self._wait_timeout = 0
        self._cancel_button = None
        self._info = None
        self._info_revealer = None

        self._suspended = None

        self._handlers = [
            [0, Gdk.KEY_Up, self._on_history_move, -1],
            [0, Gdk.KEY_Down, self._on_history_move, 1],
            [None, Gdk.KEY_Return, self._on_execute, None],
            [None, Gdk.KEY_KP_Enter, self._on_execute, None],
            [0, Gdk.KEY_Tab, self._on_complete, None],
            [0, Gdk.KEY_ISO_Left_Tab, self._on_complete, None]
        ]

        self._re_complete = re.compile('("((?:\\\\"|[^"])*)"?|\'((?:\\\\\'|[^\'])*)\'?|[^\s]+)')
        self._command_state = commands.Commands.State()

        self.connect('destroy', self._on_destroy)

        self._build_ui()
        self._setup_keybindings()

        self._attach()

    def view(self):
        return self._view

    def _setup_keybindings(self):
        css = Gtk.CssProvider()
        css.load_from_data(bytes("""
@binding-set terminal-like-bindings {
    unbind "<Control>A";

    bind "<Control>W" { "delete-from-cursor" (word-ends, -1) };
    bind "<Control>A" { "move-cursor" (buffer-ends, -1, 0) };
    bind "<Control>U" { "delete-from-cursor" (display-line-ends, -1) };
    bind "<Control>K" { "delete-from-cursor" (display-line-ends, 1) };
    bind "<Control>E" { "move-cursor" (buffer-ends, 1, 0) };
    bind "Escape" { "delete-from-cursor" (display-lines, 1) };
}

GtkEntry#gedit-commander-entry {
    gtk-key-bindings: terminal-like-bindings;

    background-image: none;
    box-shadow: 0 0;
    transition: none;
    border: 0;
}

""", 'utf-8'))

        self._entry.get_style_context().add_provider(css, Gtk.STYLE_PROVIDER_PRIORITY_APPLICATION)

    def _find_overlay(self, view):
        parent = view.get_parent()

        while not isinstance(parent, Gtk.Overlay):
            parent = parent.get_parent()

        return parent

    def _build_ui(self):
        self.set_orientation(Gtk.Orientation.VERTICAL)

        self._overlay = self._find_overlay(self._view)

        hbox = Gtk.Box(orientation=Gtk.Orientation.HORIZONTAL, spacing=6)
        hbox.show()

        self.pack_end(hbox, False, False, 0)

        self._info_revealer = Gtk.Revealer()

        self._info_revealer.set_transition_type(Gtk.RevealerTransitionType.SLIDE_UP)
        self._info_revealer.set_transition_duration(150)

#.........这里部分代码省略.........
开发者ID:GNOME,项目名称:gedit-plugins,代码行数:103,代码来源:entry.py

示例3: Entry

# 需要导入模块: from history import History [as 别名]
# 或者: from history.History import move [as 别名]
class Entry(Gtk.EventBox):
    __gtype_name__ = "CommanderEntry"

    def __init__(self, view):
        Gtk.EventBox.__init__(self)
        self._view = view

        self.set_visible_window(False)

        hbox = Gtk.Box.new(Gtk.Orientation.HORIZONTAL, 3)
        hbox.show()
        hbox.set_border_width(3)

        # context for the view
        self._entry = Gtk.Entry()
        self._entry.set_has_frame(False)
        self._entry.set_name("gedit-commander-entry")
        self._entry.show()

        css = Gtk.CssProvider()
        css.load_from_data(
            bytes(
                """
@binding-set terminal-like-bindings {
    unbind "<Control>A";

    bind "<Control>W" { "delete-from-cursor" (word-ends, -1) };
    bind "<Control>A" { "move-cursor" (buffer-ends, -1, 0) };
    bind "<Control>U" { "delete-from-cursor" (display-line-ends, -1) };
    bind "<Control>K" { "delete-from-cursor" (display-line-ends, 1) };
    bind "<Control>E" { "move-cursor" (buffer-ends, 1, 0) };
    bind "Escape" { "delete-from-cursor" (display-lines, 1) };
}

GtkEntry#gedit-commander-entry {
    gtk-key-bindings: terminal-like-bindings;

    /* Override background to anything. This is weird, but doing this we can
       then in code use widget.override_background to set the color dynamically
       to the same color as the gedit view */
    background: transparent;
    border-width: 0;
    box-shadow: 0 0 transparent;
    transition: none;
}
""",
                "utf-8",
            )
        )

        # FIXME: remove hardcopy of 600 (GTK_STYLE_PROVIDER_PRIORITY_APPLICATION)
        # https://bugzilla.gnome.org/show_bug.cgi?id=646860
        self._entry.get_style_context().add_provider(css, 600)

        self._prompt_label = Gtk.Label(label="<b>&gt;&gt;&gt;</b>", use_markup=True)
        self._prompt_label.show()

        self._entry.connect("focus-out-event", self.on_entry_focus_out)
        self._entry.connect("key-press-event", self.on_entry_key_press)

        self._history = History(os.path.join(GLib.get_user_config_dir(), "gedit/commander/history"))
        self._prompt = None

        self._accel_group = None

        hbox.pack_start(self._prompt_label, False, False, 0)
        hbox.pack_start(self._entry, True, True, 0)

        self.copy_style_from_view()
        self.view_style_updated_id = self._view.connect("style-updated", self.on_view_style_updated)

        self.add(hbox)
        self.attach()
        self._entry.grab_focus()

        self._wait_timeout = 0
        self._info_window = None

        self.connect("destroy", self.on_destroy)
        self.connect_after("size-allocate", self.on_size_allocate)
        self.view_draw_id = self._view.connect_after("draw", self.on_draw)

        self._history_prefix = None
        self._suspended = None
        self._handlers = [
            [0, Gdk.KEY_Up, self.on_history_move, -1],
            [0, Gdk.KEY_Down, self.on_history_move, 1],
            [None, Gdk.KEY_Return, self.on_execute, None],
            [None, Gdk.KEY_KP_Enter, self.on_execute, None],
            [0, Gdk.KEY_Tab, self.on_complete, None],
            [0, Gdk.KEY_ISO_Left_Tab, self.on_complete, None],
        ]

        self._re_complete = re.compile("(\"((?:\\\\\"|[^\"])*)\"?|'((?:\\\\'|[^'])*)'?|[^\s]+)")
        self._command_state = commands.Commands.State()

    def on_view_style_updated(self, widget):
        self.copy_style_from_view()

    def get_border_color(self):
#.........这里部分代码省略.........
开发者ID:purpleidea,项目名称:gedit-plugins,代码行数:103,代码来源:entry.py

示例4: Entry

# 需要导入模块: from history import History [as 别名]
# 或者: from history.History import move [as 别名]
class Entry(Gtk.EventBox):
    __gtype_name__ = "CommanderEntry"

    def __init__(self, view):
        Gtk.EventBox.__init__(self)
        self._view = view

        self.set_visible_window(False)

        hbox = Gtk.Box.new(Gtk.Orientation.HORIZONTAL, 3)
        hbox.show()
        hbox.set_border_width(3)

        # context for the view
        self._entry = Gtk.Entry()
        self._entry.set_has_frame(False)
        self._entry.set_name('gedit-commander-entry')
        self._entry.show()

        css = Gtk.CssProvider()
        css.load_from_data("""
@binding-set terminal-like-bindings {
    unbind "<Control>A";

    bind "<Control>W" { "delete-from-cursor" (word-ends, -1) };
    bind "<Control>A" { "move-cursor" (buffer-ends, -1, 0) };
    bind "<Control>U" { "delete-from-cursor" (display-line-ends, -1) };
    bind "<Control>K" { "delete-from-cursor" (display-line-ends, 1) };
    bind "<Control>E" { "move-cursor" (buffer-ends, 1, 0) };
    bind "Escape" { "delete-from-cursor" (display-lines, 1) };
}

GtkEntry#gedit-commander-entry {
    gtk-key-bindings: terminal-like-bindings;

    /* Override background to anything. This is weird, but doing this we can
       then in code use widget.override_background to set the color dynamically
       to the same color as the gedit view */
    background: transparent;
    border-width: 0;
    box-shadow: 0 0 transparent;
}
""")

        # FIXME: remove hardcopy of 600 (GTK_STYLE_PROVIDER_PRIORITY_APPLICATION)
        # https://bugzilla.gnome.org/show_bug.cgi?id=646860
        self._entry.get_style_context().add_provider(css, 600)

        self._prompt_label = Gtk.Label(label='<b>&gt;&gt;&gt;</b>', use_markup=True)
        self._prompt_label.show()

        self._entry.connect('focus-out-event', self.on_entry_focus_out)
        self._entry.connect('key-press-event', self.on_entry_key_press)

        self._history = History(os.path.join(GLib.get_user_config_dir(), 'gedit/commander/history'))
        self._prompt = None

        self._accel_group = None

        hbox.pack_start(self._prompt_label, False, False, 0)
        hbox.pack_start(self._entry, True, True, 0)

        self.copy_style_from_view()
        self.view_style_updated_id = self._view.connect('style-updated', self.on_view_style_updated)

        self.add(hbox)
        self.attach()
        self._entry.grab_focus()

        self._wait_timeout = 0
        self._info_window = None

        self.connect('destroy', self.on_destroy)
        self.connect_after('size-allocate', self.on_size_allocate)
        self.view_draw_id = self._view.connect_after('draw', self.on_draw)

        self._history_prefix = None
        self._suspended = None
        self._handlers = [
            [0, Gdk.KEY_Up, self.on_history_move, -1],
            [0, Gdk.KEY_Down, self.on_history_move, 1],
            [None, Gdk.KEY_Return, self.on_execute, None],
            [None, Gdk.KEY_KP_Enter, self.on_execute, None],
            [0, Gdk.KEY_Tab, self.on_complete, None],
            [0, Gdk.KEY_ISO_Left_Tab, self.on_complete, None]
        ]

        self._re_complete = re.compile('("((?:\\\\"|[^"])*)"?|\'((?:\\\\\'|[^\'])*)\'?|[^\s]+)')
        self._command_state = commands.Commands.State()

    def on_view_style_updated(self, widget):
        self.copy_style_from_view()

    def get_border_color(self):
        color = self.get_background_color().copy()
        color.red = 1 - color.red
        color.green = 1 - color.green
        color.blue = 1 - color.blue
        color.alpha = 0.5

#.........这里部分代码省略.........
开发者ID:onia,项目名称:pygi,代码行数:103,代码来源:entry.py


注:本文中的history.History.move方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。