本文整理汇总了Python中ranger.ext.keybinding_parser.KeyMaps.use_keymap方法的典型用法代码示例。如果您正苦于以下问题:Python KeyMaps.use_keymap方法的具体用法?Python KeyMaps.use_keymap怎么用?Python KeyMaps.use_keymap使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ranger.ext.keybinding_parser.KeyMaps
的用法示例。
在下文中一共展示了KeyMaps.use_keymap方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: UI
# 需要导入模块: from ranger.ext.keybinding_parser import KeyMaps [as 别名]
# 或者: from ranger.ext.keybinding_parser.KeyMaps import use_keymap [as 别名]
class UI(DisplayableContainer):
is_set_up = False
load_mode = False
is_on = False
termsize = None
def __init__(self, env=None, fm=None):
self.keybuffer = KeyBuffer()
self.keymaps = KeyMaps(self.keybuffer)
if fm is not None:
self.fm = fm
def setup_curses(self):
os.environ['ESCDELAY'] = '25' # don't know a cleaner way
try:
self.win = curses.initscr()
except _curses.error as e:
if e.args[0] == "setupterm: could not find terminal":
os.environ['TERM'] = 'linux'
self.win = curses.initscr()
self.keymaps.use_keymap('browser')
DisplayableContainer.__init__(self, None)
def initialize(self):
"""initialize curses, then call setup (at the first time) and resize."""
self.win.leaveok(0)
self.win.keypad(1)
self.load_mode = False
curses.cbreak()
curses.noecho()
curses.halfdelay(20)
try:
curses.curs_set(int(bool(self.settings.show_cursor)))
except:
pass
curses.start_color()
curses.use_default_colors()
self.settings.signal_bind('setopt.mouse_enabled', _setup_mouse)
_setup_mouse(dict(value=self.settings.mouse_enabled))
if not self.is_set_up:
self.is_set_up = True
self.setup()
self.win.addstr("loading...")
self.win.refresh()
self._draw_title = curses.tigetflag('hs') # has_status_line
self.update_size()
self.is_on = True
if self.settings.update_tmux_title:
sys.stdout.write("\033kranger\033\\")
sys.stdout.flush()
def suspend(self):
"""Turn off curses"""
self.win.keypad(0)
curses.nocbreak()
curses.echo()
try:
curses.curs_set(1)
except:
pass
if self.settings.mouse_enabled:
_setup_mouse(dict(value=False))
curses.endwin()
self.is_on = False
def set_load_mode(self, boolean):
boolean = bool(boolean)
if boolean != self.load_mode:
self.load_mode = boolean
if boolean:
# don't wait for key presses in the load mode
curses.cbreak()
self.win.nodelay(1)
else:
self.win.nodelay(0)
curses.halfdelay(20)
def destroy(self):
"""Destroy all widgets and turn off curses"""
DisplayableContainer.destroy(self)
self.suspend()
def handle_mouse(self):
"""Handles mouse input"""
try:
event = MouseEvent(curses.getmouse())
except _curses.error:
return
if not self.console.visible:
DisplayableContainer.click(self, event)
def handle_key(self, key):
"""Handles key input"""
#.........这里部分代码省略.........
示例2: UI
# 需要导入模块: from ranger.ext.keybinding_parser import KeyMaps [as 别名]
# 或者: from ranger.ext.keybinding_parser.KeyMaps import use_keymap [as 别名]
class UI( # pylint: disable=too-many-instance-attributes,too-many-public-methods
DisplayableContainer):
ALLOWED_VIEWMODES = 'miller', 'multipane'
is_set_up = False
load_mode = False
is_on = False
termsize = None
def __init__(self, env=None, fm=None): # pylint: disable=super-init-not-called
self.keybuffer = KeyBuffer()
self.keymaps = KeyMaps(self.keybuffer)
self.redrawlock = threading.Event()
self.redrawlock.set()
self.titlebar = None
self._viewmode = None
self.taskview = None
self.status = None
self.console = None
self.pager = None
self._draw_title = None
self._tmux_automatic_rename = None
self.browser = None
if fm is not None:
self.fm = fm
def setup_curses(self):
os.environ['ESCDELAY'] = '25' # don't know a cleaner way
try:
self.win = curses.initscr()
except curses.error as ex:
if ex.args[0] == "setupterm: could not find terminal":
os.environ['TERM'] = 'linux'
self.win = curses.initscr()
self.keymaps.use_keymap('browser')
DisplayableContainer.__init__(self, None)
def initialize(self):
"""initialize curses, then call setup (at the first time) and resize."""
self.win.leaveok(0)
self.win.keypad(1)
self.load_mode = False
curses.cbreak()
curses.noecho()
curses.halfdelay(20)
try:
curses.curs_set(int(bool(self.settings.show_cursor)))
except curses.error:
pass
curses.start_color()
try:
curses.use_default_colors()
except curses.error:
pass
self.settings.signal_bind('setopt.mouse_enabled', _setup_mouse)
self.settings.signal_bind('setopt.freeze_files', self.redraw_statusbar)
_setup_mouse(dict(value=self.settings.mouse_enabled))
if not self.is_set_up:
self.is_set_up = True
self.setup()
self.win.addstr("loading...")
self.win.refresh()
self._draw_title = curses.tigetflag('hs') # has_status_line
# Save tmux setting `automatic-rename`
if self.settings.update_tmux_title and 'TMUX' in os.environ:
try:
self._tmux_automatic_rename = check_output(
['tmux', 'show-window-options', '-v', 'automatic-rename']).strip()
except CalledProcessError:
self._tmux_automatic_rename = None
self.update_size()
self.is_on = True
if self.settings.update_tmux_title and 'TMUX' in os.environ:
sys.stdout.write("\033kranger\033\\")
sys.stdout.flush()
if 'vcsthread' in self.__dict__:
self.vcsthread.unpause()
def suspend(self):
"""Turn off curses"""
if 'vcsthread' in self.__dict__:
self.vcsthread.pause()
self.vcsthread.paused.wait()
self.win.keypad(0)
curses.nocbreak()
curses.echo()
try:
curses.curs_set(1)
except curses.error:
pass
#.........这里部分代码省略.........