ranger.gui.widgets.console
index
/home/hut/code/ranger/ranger/gui/widgets/console.py

The Console widget implements a vim-like console for entering
commands, searching and executing files.

 
Modules
       
curses
ranger
string

 
Classes
       
ranger.gui.widgets.Widget(ranger.gui.displayable.Displayable)
Console
ConsoleWithTab
CommandConsole
QuickCommandConsole
OpenConsole
QuickOpenConsole
SearchConsole

 
class CommandConsole(ConsoleWithTab)
    
Method resolution order:
CommandConsole
ConsoleWithTab
Console
ranger.gui.widgets.Widget
ranger.gui.displayable.Displayable
ranger.shared.EnvironmentAware
ranger.shared.FileManagerAware
ranger.shared.Awareness
ranger.gui.curses_shortcuts.CursesShortcuts
ranger.shared.settings.SettingsAware
builtins.object

Methods defined here:
execute(self, cmd=None)

Data and other attributes defined here:
prompt = ':'

Methods inherited from ConsoleWithTab:
tab(self, n=1)

Methods inherited from Console:
__init__(self, win)
add_to_history(self)
clear(self)
close(self)
delete(self, mod)
delete_rest(self, direction)
delete_word(self)
destroy(self)
draw(self)
finalize(self)
history_move(self, n)
init(self)
override this. Called directly after class change
move(self, **keywords)
on_line_change(self)
open(self, mode, string='', prompt=None)
paste(self)
press(self, key)
type_key(self, key)

Data and other attributes inherited from Console:
allow_close = False
copy = ''
histories = None
history = None
historypaths = []
last_cursor_mode = None
mode = None
original_line = None
override = None
tab_deque = None
visible = False

Methods inherited from ranger.gui.displayable.Displayable:
__bool__ = __nonzero__(self)
Always True
__contains__(self, item)
Is item inside the boundaries?
item can be an iterable like [y, x] or an object with x and y methods.
__nonzero__(self)
Always True
__str__(self)
click(self, event)
Called when a mouse key is pressed and self.focused is True.
Override this!
contains_point(self, y, x)
Test whether the point (with absolute coordinates) lies
within the boundaries of this object.
poke(self)
Called before drawing, even if invisible
resize(self, y, x, hei=None, wid=None)
Resize the widget

Data and other attributes inherited from ranger.shared.EnvironmentAware:
env = None

Data and other attributes inherited from ranger.shared.FileManagerAware:
fm = None

Data descriptors inherited from ranger.shared.Awareness:
__dict__
dictionary for instance variables (if defined)
__weakref__
list of weak references to the object (if defined)

Methods inherited from ranger.gui.curses_shortcuts.CursesShortcuts:
addch(self, *args)
addnstr(self, *args)
addstr(self, *args)
color(self, *keys)
Change the colors from now on.
color_at(self, y, x, wid, *keys)
Change the colors at the specified position
color_reset(self)
Change the colors to the default colors

Data and other attributes inherited from ranger.shared.settings.SettingsAware:
settings = {}

 
class Console(ranger.gui.widgets.Widget)
    
Method resolution order:
Console
ranger.gui.widgets.Widget
ranger.gui.displayable.Displayable
ranger.shared.EnvironmentAware
ranger.shared.FileManagerAware
ranger.shared.Awareness
ranger.gui.curses_shortcuts.CursesShortcuts
ranger.shared.settings.SettingsAware
builtins.object

Methods defined here:
__init__(self, win)
add_to_history(self)
clear(self)
close(self)
delete(self, mod)
delete_rest(self, direction)
delete_word(self)
destroy(self)
draw(self)
execute(self)
finalize(self)
history_move(self, n)
init(self)
override this. Called directly after class change
move(self, **keywords)
on_line_change(self)
open(self, mode, string='', prompt=None)
paste(self)
press(self, key)
tab(self)
type_key(self, key)

Data and other attributes defined here:
allow_close = False
copy = ''
histories = None
history = None
historypaths = []
last_cursor_mode = None
mode = None
original_line = None
override = None
prompt = ':'
tab_deque = None
visible = False

Methods inherited from ranger.gui.displayable.Displayable:
__bool__ = __nonzero__(self)
Always True
__contains__(self, item)
Is item inside the boundaries?
item can be an iterable like [y, x] or an object with x and y methods.
__nonzero__(self)
Always True
__str__(self)
click(self, event)
Called when a mouse key is pressed and self.focused is True.
Override this!
contains_point(self, y, x)
Test whether the point (with absolute coordinates) lies
within the boundaries of this object.
poke(self)
Called before drawing, even if invisible
resize(self, y, x, hei=None, wid=None)
Resize the widget

Data and other attributes inherited from ranger.shared.EnvironmentAware:
env = None

Data and other attributes inherited from ranger.shared.FileManagerAware:
fm = None

Data descriptors inherited from ranger.shared.Awareness:
__dict__
dictionary for instance variables (if defined)
__weakref__
list of weak references to the object (if defined)

Methods inherited from ranger.gui.curses_shortcuts.CursesShortcuts:
addch(self, *args)
addnstr(self, *args)
addstr(self, *args)
color(self, *keys)
Change the colors from now on.
color_at(self, y, x, wid, *keys)
Change the colors at the specified position
color_reset(self)
Change the colors to the default colors

Data and other attributes inherited from ranger.shared.settings.SettingsAware:
settings = {}

 
class ConsoleWithTab(Console)
    
Method resolution order:
ConsoleWithTab
Console
ranger.gui.widgets.Widget
ranger.gui.displayable.Displayable
ranger.shared.EnvironmentAware
ranger.shared.FileManagerAware
ranger.shared.Awareness
ranger.gui.curses_shortcuts.CursesShortcuts
ranger.shared.settings.SettingsAware
builtins.object

Methods defined here:
tab(self, n=1)

Methods inherited from Console:
__init__(self, win)
add_to_history(self)
clear(self)
close(self)
delete(self, mod)
delete_rest(self, direction)
delete_word(self)
destroy(self)
draw(self)
execute(self)
finalize(self)
history_move(self, n)
init(self)
override this. Called directly after class change
move(self, **keywords)
on_line_change(self)
open(self, mode, string='', prompt=None)
paste(self)
press(self, key)
type_key(self, key)

Data and other attributes inherited from Console:
allow_close = False
copy = ''
histories = None
history = None
historypaths = []
last_cursor_mode = None
mode = None
original_line = None
override = None
prompt = ':'
tab_deque = None
visible = False

Methods inherited from ranger.gui.displayable.Displayable:
__bool__ = __nonzero__(self)
Always True
__contains__(self, item)
Is item inside the boundaries?
item can be an iterable like [y, x] or an object with x and y methods.
__nonzero__(self)
Always True
__str__(self)
click(self, event)
Called when a mouse key is pressed and self.focused is True.
Override this!
contains_point(self, y, x)
Test whether the point (with absolute coordinates) lies
within the boundaries of this object.
poke(self)
Called before drawing, even if invisible
resize(self, y, x, hei=None, wid=None)
Resize the widget

Data and other attributes inherited from ranger.shared.EnvironmentAware:
env = None

Data and other attributes inherited from ranger.shared.FileManagerAware:
fm = None

Data descriptors inherited from ranger.shared.Awareness:
__dict__
dictionary for instance variables (if defined)
__weakref__
list of weak references to the object (if defined)

Methods inherited from ranger.gui.curses_shortcuts.CursesShortcuts:
addch(self, *args)
addnstr(self, *args)
addstr(self, *args)
color(self, *keys)
Change the colors from now on.
color_at(self, y, x, wid, *keys)
Change the colors at the specified position
color_reset(self)
Change the colors to the default colors

Data and other attributes inherited from ranger.shared.settings.SettingsAware:
settings = {}

 
class OpenConsole(ConsoleWithTab)
    The Open Console allows you to execute shell commands:
!vim *         will run vim and open all files in the directory.
 
%f will be replaced with the basename of the highlighted file
%s will be selected with all files in the selection
 
There is a special syntax for more control:
 
!d! mplayer    will run mplayer with flags (d means detached)
!@ mplayer     will open the selected files with mplayer
                   (equivalent to !mplayer %s)
 
Those two can be combinated:
 
!d!@mplayer    will open the selection with a detached mplayer
                           (again, this is equivalent to !d!mplayer %s)
 
For a list of other flags than "d", check chapter 2.5 of the documentation
 
 
Method resolution order:
OpenConsole
ConsoleWithTab
Console
ranger.gui.widgets.Widget
ranger.gui.displayable.Displayable
ranger.shared.EnvironmentAware
ranger.shared.FileManagerAware
ranger.shared.Awareness
ranger.gui.curses_shortcuts.CursesShortcuts
ranger.shared.settings.SettingsAware
builtins.object

Methods defined here:
execute(self)
init(self)

Data and other at
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
<html>
<head>
<meta http-equiv="content-type" content="text/html; charset=UTF-8">
<title>Mu - 071rewrite_stash.cc</title>
<meta name="Generator" content="Vim/7.4">
<meta name="plugin-version" content="vim7.4_v2">
<meta name="syntax" content="cpp">
<meta name="settings" content="use_css,pre_wrap,no_foldcolumn,expand_tabs,prevent_copy=">
<meta name="colorscheme" content="minimal">
<style type="text/css">
<!--
pre { white-space: pre-wrap; font-family: monospace; color: #eeeeee; background-color: #080808; }
body { font-size: 12pt; font-family: monospace; color: #eeeeee; background-color: #080808; }
* { font-size: 12pt; font-size: 1em; }
.Constant { color: #00a0a0; }
.cSpecial { color: #008000; }
.traceContains { color: #008000; }
.Comment { color: #9090ff; }
.Delimiter { color: #800080; }
.Special { color: #c00000; }
.Identifier { color: #fcb165; }
.Normal { color: #eeeeee; background-color: #080808; padding-bottom: 1px; }
-->
</style>

<script type='text/javascript'>
<!--

-->
</script>
</head>
<body>
<pre id='vimCodeElement'>
<span class="Comment">//: when encountering other types, try to convert them to strings using</span>
<span class="Comment">//: 'to-text'</span>

<span class="Delimiter">:(scenarios transform)</span>
<span class="Delimiter">:(scenario rewrite_stashes_to_text)</span>
recipe main [
  local-scope
  <span class="Normal">n</span>:number<span class="Special"> &lt;- </span>copy <span class="Constant">34</span>
  stash n
]
<span class="traceContains">+transform: {stash_2_0: (&quot;address&quot; &quot;array&quot; &quot;character&quot;)} &lt;- to-text-line {n: &quot;number&quot;}</span>
<span class="traceContains">+transform: stash {stash_2_0: (&quot;address&quot; &quot;array&quot; &quot;character&quot;)}</span>

<span class="Comment">//: special case: rewrite attempts to stash contents of most arrays to avoid</span>
<span class="Comment">//: passing addresses around</span>

<span class="Delimiter">:(scenario rewrite_stashes_of_arrays)</span>
recipe main [
  local-scope
  <span class="Normal">n</span>:address:array:number<span class="Special"> &lt;- </span><span class="Normal">new</span> number:type<span class="Delimiter">,</span> <span class="Constant">3</span>
  stash *n
]
<span class="traceContains">+transform: {stash_2_0: (&quot;address&quot; &quot;array&quot; &quot;character&quot;)} &lt;- array-to-text-line {n: (&quot;address&quot; &quot;array&quot; &quot;number&quot;)}</span>
<span class="traceContains">+transform: stash {stash_2_0: (&quot;address&quot; &quot;array&quot; &quot;character&quot;)}</span>

<span class="Delimiter">:(scenario ignore_stashes_of_static_arrays)</span>
recipe main [
  local-scope
  <span class="Normal">n</span>:array:number:<span class="Constant">3</span><span class="Special"> &lt;- </span>create-array
  stash n
]
<span class="traceContains">+transform: stash {n: (&quot;array&quot; &quot;number&quot; &quot;3&quot;)}</span>

<span class="Delimiter">:(before &quot;End Instruction Inserting/Deleting Transforms&quot;)</span>
Transform<span class="Delimiter">.</span>push_back<span class="Delimiter">(</span>rewrite_stashes_to_text<span class="Delimiter">);</span>

<span class="Delimiter">:(code)</span>
<span class="Normal">void</span> rewrite_stashes_to_text<span class="Delimiter">(</span>recipe_ordinal r<span class="Delimiter">)</span> <span class="Delimiter">{</span>
  recipe&amp; caller = get<span class="Delimiter">(</span>Recipe<span class="Delimiter">,</span> r<span class="Delimiter">);</span>
  trace<span class="Delimiter">(</span><span class="Constant">9991</span><span class="Delimiter">,</span> <span class="Constant">&quot;transform&quot;</span><span class="Delimiter">)</span> &lt;&lt; <span class="Constant">&quot;--- rewrite 'stash' instructions in recipe &quot;</span> &lt;&lt; caller<span class="Delimiter">.</span>name &lt;&lt; end<span class="Delimiter">();</span>
  <span class="Comment">// in recipes without named locations, 'stash' is still not extensible</span>
  <span class="Normal">if</span> <span class="Delimiter">(</span>contains_numeric_locations<span class="Delimiter">(</span>caller<span class="Delimiter">))</span> <span class="Identifier">return</span><span class="Delimiter">;</span>
  check_or_set_types_by_name<span class="Delimiter">(</span>r<span class="Delimiter">);</span>  <span class="Comment">// prerequisite</span>
  rewrite_stashes_to_text<span class="Delimiter">(</span>caller<span class="Delimiter">);</span>
<span class="Delimiter">}</span>

<span class="Normal">void</span> rewrite_stashes_to_text<span class="Delimiter">(</span>recipe&amp; caller<span class="Delimiter">)</span> <span class="Delimiter">{</span>
  vector&lt;instruction&gt; new_instructions<span class="Delimiter">;</span>
  <span class="Normal">for</span> <span class="Delimiter">(</span><span class="Normal">int</span> i = <span class="Constant">0</span><span class="Delimiter">;</span> i &lt; SIZE<span class="Delimiter">