summary refs log blame commit diff stats
path: root/doc/pydoc/ranger.gui.widgets.taskview.html
blob: 5ee068142fddd65f5d806aeb3607289953f0e93c (plain) (tree)
1
2
3
4
5
6
7
8
9
10
 

                                                                     






                                                                                                                                                                                                                                                                                                                          
                                                                                                                                                                                                                   
















                                                                                                                                                         
                                                                                                                                                                                    




























                                                                                                                                                                                                                                                                                       
                                                                 






                                                                                      

                                                                                 



                                                                                 
                                                                                                                            








                                                                                                                            

                                                                                                                                 















                                                                                                                                                                                                                        

























                                                                                                                                                                                                              
                                                                                                                                                           
 
                                                                                                                                                                                              




                                                                                                                                                                              
                                           






                                                                                                                         
                                                                                                                             








                                                                                                                                    
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<html><head><title>Python: module ranger.gui.widgets.taskview</title>
</head><body bgcolor="#f0f0f8">

<table width="100%" cellspacing=0 cellpadding=2 border=0 summary="heading">
<tr bgcolor="#7799ee">
<td valign=bottom>&nbsp;<br>
<font color="#ffffff" face="helvetica, arial">&nbsp;<br><big><big><strong><a href="ranger.html"><font color="#ffffff">ranger</font></a>.<a href="ranger.gui.html"><font color="#ffffff">gui</font></a>.<a href="ranger.gui.widgets.html"><font color="#ffffff">widgets</font></a>.taskview</strong></big></big></font></td
><td align=right valign=bottom
><font color="#ffffff" face="helvetica, arial"><a href=".">index</a><br><a href="file:/home/hut/ranger/ranger/gui/widgets/taskview.py">/home/hut/ranger/ranger/gui/widgets/taskview.py</a></font></td></tr></table>
    <p><tt>The&nbsp;<a href="#TaskView">TaskView</a>&nbsp;allows&nbsp;you&nbsp;to&nbsp;modify&nbsp;what&nbsp;the&nbsp;loader&nbsp;is&nbsp;doing.</tt></p>
<p>
<table width="100%" cellspacing=0 cellpadding=2 border=0 summary="section">
<tr bgcolor="#aa55cc">
<td colspan=3 valign=bottom>&nbsp;<br>
<font color="#ffffff" face="helvetica, arial"><big><strong>Modules</strong></big></font></td></tr>
    
<tr><td bgcolor="#aa55cc"><tt>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</tt></td><td>&nbsp;</td>
<td width="100%"><table width="100%" summary="list"><tr><td width="25%" valign=top><a href="curses.html">curses</a><br>
</td><td width="25%" valign=top></td><td width="25%" valign=top></td><td width="25%" valign=top></td></tr></table></td></tr></table><p>
<table width="100%" cellspacing=0 cellpadding=2 border=0 summary="section">
<tr bgcolor="#ee77aa">
<td colspan=3 valign=bottom>&nbsp;<br>
<font color="#ffffff" face="helvetica, arial"><big><strong>Classes</strong></big></font></td></tr>
    
<tr><td bgcolor="#ee77aa"><tt>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</tt></td><td>&nbsp;</td>
<td width="100%"><dl>
<dt><font face="helvetica, arial"><a href="ranger.ext.accumulator.html#Accumulator">ranger.ext.accumulator.Accumulator</a>(<a href="__builtin__.html#object">__builtin__.object</a>)
</font></dt><dd>
<dl>
<dt><font face="helvetica, arial"><a href="ranger.gui.widgets.taskview.html#TaskView">TaskView</a>(<a href="ranger.gui.widgets.html#Widget">ranger.gui.widgets.Widget</a>, <a href="ranger.ext.accumulator.html#Accumulator">ranger.ext.accumulator.Accumulator</a>)
</font></dt></dl>
</dd>
<dt><font face="helvetica, arial"><a href="ranger.gui.widgets.html#Widget">ranger.gui.widgets.Widget</a>(<a href="ranger.gui.displayable.html#Displayable">ranger.gui.displayable.Displayable</a>)
</font></dt><dd>
<dl>
<dt><font face="helvetica, arial"><a href="ranger.gui.widgets.taskview.html#TaskView">TaskView</a>(<a href="ranger.gui.widgets.html#Widget">ranger.gui.widgets.Widget</a>, <a href="ranger.ext.accumulator.html#Accumulator">ranger.ext.accumulator.Accumulator</a>)
</font></dt></dl>
</dd>
</dl>
 <p>
<table width="100%" cellspacing=0 cellpadding=2 border=0 summary="section">
<tr bgcolor="#ffc8d8">
<td colspan=3 valign=bottom>&nbsp;<br>
<font color="#000000" face="helvetica, arial"><a name="TaskView">class <strong>TaskView</strong></a>(<a href="ranger.gui.widgets.html#Widget">ranger.gui.widgets.Widget</a>, <a href="ranger.ext.accumulator.html#Accumulator">ranger.ext.accumulator.Accumulator</a>)</font></td></tr>
    
<tr><td bgcolor="#ffc8d8"><tt>&nbsp;&nbsp;&nbsp;</tt></td><td>&nbsp;</td>
<td width="100%"><dl><dt>Method resolution order:</dt>
<dd><a href="ranger.gui.widgets.taskview.html#TaskView">TaskView</a></dd>
<dd><a href="ranger.gui.widgets.html#Widget">ranger.gui.widgets.Widget</a></dd>
<dd><a href="ranger.gui.displayable.html#Displayable">ranger.gui.displayable.Displayable</a></dd>
<dd><a href="ranger.shared.html#EnvironmentAware">ranger.shared.EnvironmentAware</a></dd>
<dd><a href="ranger.shared.html#FileManagerAware">ranger.shared.FileManagerAware</a></dd>
<dd><a href="ranger.shared.html#Awareness">ranger.shared.Awareness</a></dd>
<dd><a href="ranger.gui.curses_shortcuts.html#CursesShortcuts">ranger.gui.curses_shortcuts.CursesShortcuts</a></dd>
<dd><a href="ranger.shared.settings.html#SettingsAware">ranger.shared.settings.SettingsAware</a></dd>
<dd><a href="ranger.ext.accumulator.html#Accumulator">ranger.ext.accumulator.Accumulator</a></dd>
<dd><a href="__builtin__.html#object">__builtin__.object</a></dd>
</dl>
<hr>
Methods defined here:<br>
<dl><dt><a name="TaskView-__init__"><strong>__init__</strong></a>(self, win)</dt></dl>

<dl><dt><a name="TaskView-draw"><strong>draw</strong></a>(self)</dt></dl>

<dl><dt><a name="TaskView-finalize"><strong>finalize</strong></a>(self)</dt></dl>

<dl><dt><a name="TaskView-get_list"><strong>get_list</strong></a>(self)</dt></dl>

<dl><dt><a name="TaskView-press"><strong>press</strong></a>(self, key)</dt></dl>

<dl><dt><a name="TaskView-task_move"><strong>task_move</strong></a>(self, to, i<font color="#909090">=None</font>)</dt></dl>

<dl><dt><a name="TaskView-task_remove"><strong>task_remove</strong></a>(self, i<font color="#909090">=None</font>)</dt></dl>

<hr>
Data and other attributes defined here:<br>
<dl><dt><strong>old_lst</strong> = None</dl>

<hr>
Methods inherited from <a href="ranger.gui.displayable.html#Displayable">ranger.gui.displayable.Displayable</a>:<br>
<dl><dt><a name="TaskView-__bool__"><strong>__bool__</strong></a> = __nonzero__(self)</dt><dd><tt>Always&nbsp;True</tt></dd></dl>

<dl><dt><a name="TaskView-__contains__"><strong>__contains__</strong></a>(self, item)</dt><dd><tt>Is&nbsp;item&nbsp;inside&nbsp;the&nbsp;boundaries?<br>
item&nbsp;can&nbsp;be&nbsp;an&nbsp;iterable&nbsp;like&nbsp;[y,&nbsp;x]&nbsp;or&nbsp;an&nbsp;object&nbsp;with&nbsp;x&nbsp;and&nbsp;y&nbsp;methods.</tt></dd></dl>

<dl><dt><a name="TaskView-__nonzero__"><strong>__nonzero__</strong></a>(self)</dt><dd><tt>Always&nbsp;True</tt></dd></dl>

<dl><dt><a name="TaskView-__str__"><strong>__str__</strong></a>(self)</dt></dl>

<dl><dt><a name="TaskView-click"><strong>click</strong></a>(self, event)</dt><dd><tt>Called&nbsp;when&nbsp;a&nbsp;mouse&nbsp;key&nbsp;is&nbsp;pressed&nbsp;and&nbsp;self.<strong>focused</strong>&nbsp;is&nbsp;True.<br>
Override&nbsp;this!</tt></dd></dl>

<dl><dt><a name="TaskView-contains_point"><strong>contains_point</strong></a>(self, y, x)</dt><dd><tt>Test&nbsp;whether&nbsp;the&nbsp;point&nbsp;(with&nbsp;absolute&nbsp;coordinates)&nbsp;lies<br>
within&nbsp;the&nbsp;boundaries&nbsp;of&nbsp;this&nbsp;object.</tt></dd></dl>

<dl><dt><a name="TaskView-destroy"><strong>destroy</strong></a>(self)</dt><dd><tt>Called&nbsp;when&nbsp;the&nbsp;object&nbsp;is&nbsp;destroyed.<br>
Override&nbsp;this!</tt></dd></dl>

<dl><dt><a name="TaskView-poke"><strong>poke</strong></a>(self)</dt><dd><tt>Called&nbsp;before&nbsp;drawing,&nbsp;even&nbsp;if&nbsp;invisible</tt></dd></dl>

<dl><dt><a name="TaskView-resize"><strong>resize</strong></a>(self, y, x, hei<font color="#909090">=None</font>, wid<font color="#909090">=None</font>)</dt><dd><tt>Resize&nbsp;the&nbsp;widget</tt></dd></dl>

<hr>
Data and other attributes inherited from <a href="ranger.shared.html#EnvironmentAware">ranger.shared.EnvironmentAware</a>:<br>
<dl><dt><strong>env</strong> = None</dl>

<hr>
Data and other attributes inherited from <a href="ranger.shared.html#FileManagerAware">ranger.shared.FileManagerAware</a>:<br>
<dl><dt><strong>fm</strong> = None</dl>

<hr>
Data descriptors inherited from <a href="ranger.shared.html#Awareness">ranger.shared.Awareness</a>:<br>
<dl><dt><strong>__dict__</strong></dt>
<dd><tt>dictionary&nbsp;for&nbsp;instance&nbsp;variables&nbsp;(if&nbsp;defined)</tt></dd>
</dl>
<dl><dt><strong>__weakref__</strong></dt>
<dd><tt>list&nbsp;of&nbsp;weak&nbsp;references&nbsp;to&nbsp;the&nbsp;object&nbsp;(if&nbsp;defined)</tt></dd>
</dl>
<hr>
Methods inherited from <a href="ranger.gui.curses_shortcuts.html#CursesShortcuts">ranger.gui.curses_shortcuts.CursesShortcuts</a>:<br>
<dl><dt><a name="TaskView-addnstr"><strong>addnstr</strong></a>(self, *args)</dt></dl>

<dl><dt><a name="TaskView-addstr"><strong>addstr</strong></a>(self, *args)</dt></dl>

<dl><dt><a name="TaskView-color"><strong>color</strong></a>(self, *keys)</dt><dd><tt>Change&nbsp;the&nbsp;colors&nbsp;from&nbsp;now&nbsp;on.</tt></dd></dl>

<dl><dt><a name="TaskView-color_at"><strong>color_at</strong></a>(self, y, x, wid, *keys)</dt><dd><tt>Change&nbsp;the&nbsp;colors&nbsp;at&nbsp;the&nbsp;specified&nbsp;position</tt></dd></dl>

<dl><dt><a name="TaskView-color_reset"><strong>color_reset</strong></a>(self)</dt><dd><tt>Change&nbsp;the&nbsp;colors&nbsp;to&nbsp;the&nbsp;default&nbsp;colors</tt></dd></dl>

<hr>
Data and other attributes inherited from <a href="ranger.shared.settings.html#SettingsAware">ranger.shared.settings.SettingsAware</a>:<br>
<dl><dt><strong>settings</strong> = {}</dl>

<hr>
Methods inherited from <a href="ranger.ext.accumulator.html#Accumulator">ranger.ext.accumulator.Accumulator</a>:<br>
<dl><dt><a name="TaskView-correct_pointer"><strong>correct_pointer</strong></a>(self)</dt></dl>

<dl><dt><a name="TaskView-get_height"><strong>get_height</strong></a>(self)</dt><dd><tt>OVERRIDE&nbsp;THIS</tt></dd></dl>

<dl><dt><a name="TaskView-move"><strong>move</strong></a>(self, narg<font color="#909090">=None</font>, **keywords)</dt></dl>

<dl><dt><a name="TaskView-move_to_obj"><strong>move_to_obj</strong></a>(self, arg, attr<font color="#909090">=None</font>)</dt></dl>

<dl><dt><a name="TaskView-pointer_is_synced"><strong>pointer_is_synced</strong></a>(self)</dt></dl>

<dl><dt><a name="TaskView-sync_index"><strong>sync_index</strong></a>(self, **kw)</dt></dl>

</td></tr></table></td></tr></table>
</body></html>
; products.at(0).push_back(trace_app_contents()); break; } :(before "End Primitive Recipe Declarations") _CLEANUP_RUN_SANDBOXED, :(before "End Primitive Recipe Numbers") put(Recipe_ordinal, "$cleanup-run-sandboxed", _CLEANUP_RUN_SANDBOXED); :(before "End Primitive Recipe Checks") case _CLEANUP_RUN_SANDBOXED: { break; } :(before "End Primitive Recipe Implementations") case _CLEANUP_RUN_SANDBOXED: { run_code_end(); break; } :(code) void test_run_interactive_converts_result_to_text() { // try to interactively add 2 and 2 run( "def main [\n" " 10:text <- new [add 2, 2]\n" " 20:text <- run-sandboxed 10:text\n" " 30:@:char <- copy *20:text\n" "]\n" ); // first letter in the output should be '4' in utf-8 CHECK_TRACE_CONTENTS( "mem: storing 52 in location 31\n" ); } void test_run_interactive_ignores_products_in_nested_functions() { run( "def main [\n" " 10:text <- new [foo]\n" " 20:text <- run-sandboxed 10:text\n" " 30:@:char <- copy *20:text\n" "]\n" "def foo [\n" " 40:num <- copy 1234\n" " {\n" " break\n" " reply 5678\n" " }\n" "]\n" ); // no product should have been tracked CHECK_TRACE_CONTENTS( "mem: storing 0 in location 30\n" ); } void test_run_interactive_ignores_products_in_previous_instructions() { run( "def main [\n" " 10:text <- new [\n" " add 1, 1\n" // generates a product " foo]\n" // no products " 20:text <- run-sandboxed 10:text\n" " 30:@:char <- copy *20:text\n" "]\n" "def foo [\n" " 40:num <- copy 1234\n" " {\n" " break\n" " reply 5678\n" " }\n" "]\n" ); // no product should have been tracked CHECK_TRACE_CONTENTS( "mem: storing 0 in location 30\n" ); } void test_run_interactive_remembers_products_before_final_label() { run( "def main [\n" " 10:text <- new [\n" " add 1, 1\n" // generates a product " +foo]\n" // no products " 20:text <- run-sandboxed 10:text\n" " 30:@:char <- copy *20:text\n" "]\n" "def foo [\n" " 40:num <- copy 1234\n" " {\n" " break\n" " reply 5678\n" " }\n" "]\n" ); // product tracked CHECK_TRACE_CONTENTS( "mem: storing 50 in location 31\n" ); } void test_run_interactive_returns_text() { // try to interactively add 2 and 2 run( "def main [\n" " 1:text <- new [\n" " x:text <- new [a]\n" " y:text <- new [b]\n" " z:text <- append x:text, y:text\n" " ]\n" " 10:text <- run-sandboxed 1:text\n" //? " $print 10:text 10/newline\n" " 20:@:char <- copy *10:text\n" "]\n" ); // output contains "ab" CHECK_TRACE_CONTENTS( "mem: storing 97 in location 21\n" "mem: storing 98 in location 22\n" ); } void test_run_interactive_returns_errors() { run( "def main [\n" // run a command that generates an error " 10:text <- new [x:num <- copy 34\n" "get x:num, foo:offset]\n" " 20:text, 30:text <- run-sandboxed 10:text\n" " 40:@:char <- copy *30:text\n" "]\n" ); // error should be "unknown element foo in container number" CHECK_TRACE_CONTENTS( "mem: storing 117 in location 41\n" "mem: storing 110 in location 42\n" "mem: storing 107 in location 43\n" "mem: storing 110 in location 44\n" // ... ); } void test_run_interactive_with_comment() { run( "def main [\n" // 2 instructions, with a comment after the first " 10:text <- new [a:num <- copy 0 # abc\n" "b:num <- copy 0\n" "]\n" " 20:text, 30:text <- run-sandboxed 10:text\n" "]\n" ); // no errors // skip alloc id CHECK_TRACE_CONTENTS( "mem: storing 0 in location 30\n" "mem: storing 0 in location 31\n" ); } :(after "Running One Instruction") if (Track_most_recent_products && SIZE(Current_routine->calls) == Call_depth_to_track_most_recent_products_at && !current_instruction().is_label && current_instruction().name != "$stop-tracking-products") { Most_recent_products = ""; } :(before "End Running One Instruction") if (Track_most_recent_products && SIZE(Current_routine->calls) == Call_depth_to_track_most_recent_products_at) { Most_recent_products = track_most_recent_products(current_instruction(), products); //? cerr << "most recent products: " << Most_recent_products << '\n'; } :(code) string track_most_recent_products(const instruction& instruction, const vector<vector<double> >& products) { ostringstream out; for (int i = 0; i < SIZE(products); ++i) { // A sandbox can print a string result, but only if it is actually saved // to a variable in the sandbox, because otherwise the results are // reclaimed before the sandbox sees them. So you get these interactions // in the sandbox: // // new [abc] // => <address> // // x:text <- new [abc] // => abc if (i < SIZE(instruction.products)) { if (is_mu_text(instruction.products.at(i))) { if (SIZE(products.at(i)) != 2) continue; // weak silent check for address out << read_mu_text(products.at(i).at(/*skip alloc id*/1)) << '\n'; continue; } } for (int j = 0; j < SIZE(products.at(i)); ++j) out << no_scientific(products.at(i).at(j)) << ' '; out << '\n'; } return out.str(); } :(code) string strip_comments(string in) { ostringstream result; for (int i = 0; i < SIZE(in); ++i) { if (in.at(i) != '#') { result << in.at(i); } else { while (i+1 < SIZE(in) && in.at(i+1) != '\n') ++i; } } return result.str(); } int stringified_value_of_location(int address) { // convert to string ostringstream out; out << no_scientific(get_or_insert(Memory, address)); return new_mu_text(out.str()); } int trace_error_contents() { if (!Trace_stream) return 0; ostringstream out; for (vector<trace_line>::iterator p = Trace_stream->past_lines.begin(); p != Trace_stream->past_lines.end(); ++p) { if (p->label != "error") continue; out << p->contents; if (*--p->contents.end() != '\n') out << '\n'; } string result = out.str(); truncate(result); if (result.empty()) return 0; return new_mu_text(result); } int trace_app_contents() { if (!Trace_stream) return 0; ostringstream out; for (vector<trace_line>::iterator p = Trace_stream->past_lines.begin(); p != Trace_stream->past_lines.end(); ++p) { if (p->depth != App_depth) continue; out << p->contents; if (*--p->contents.end() != '\n') out << '\n'; } string result = out.str(); if (result.empty()) return 0; truncate(result); return new_mu_text(result); } void truncate(string& x) { if (SIZE(x) > 1024) { x.erase(1024); *x.rbegin() = '\n'; *++x.rbegin() = '.'; *++++x.rbegin() = '.'; } } //: simpler version of run-sandboxed: doesn't do any running, just loads //: recipes and reports errors. :(before "End Primitive Recipe Declarations") RELOAD, :(before "End Primitive Recipe Numbers") put(Recipe_ordinal, "reload", RELOAD); :(before "End Primitive Recipe Checks") case RELOAD: { if (SIZE(inst.ingredients) != 1) { raise << maybe(get(Recipe, r).name) << "'reload' requires exactly one ingredient, but got '" << inst.original_string << "'\n" << end(); break; } if (!is_mu_text(inst.ingredients.at(0))) { raise << maybe(get(Recipe, r).name) << "first ingredient of 'reload' should be a string, but got '" << inst.ingredients.at(0).original_string << "'\n" << end(); break; } break; } :(before "End Primitive Recipe Implementations") case RELOAD: { restore_non_recipe_snapshots(); string code = read_mu_text(ingredients.at(0).at(/*skip alloc id*/1)); run_code_begin(/*should_stash_snapshots*/false); routine* save_current_routine = Current_routine; Current_routine = NULL; Sandbox_mode = true; vector<recipe_ordinal> recipes_reloaded = load(code); transform_all(); Trace_stream->newline(); // flush trace Sandbox_mode = false; Current_routine = save_current_routine; products.resize(1); products.at(0).push_back(/*alloc id*/0); products.at(0).push_back(trace_error_contents()); run_code_end(); // wait until we're done with the trace contents break; } :(code) void test_reload_loads_function_definitions() { run( "def main [\n" " local-scope\n" " x:text <- new [recipe foo [\n" " 1:num/raw <- copy 34\n" " ]]\n" " reload x\n" " run-sandboxed [foo]\n" " 2:num/raw <- copy 1:num/raw\n" "]\n" ); CHECK_TRACE_CONTENTS( "mem: storing 34 in location 2\n" ); } void test_reload_continues_past_error() { run( "def main [\n" " local-scope\n" " x:text <- new [recipe foo [\n" " get 1234:num, foo:offset\n" " ]]\n" " reload x\n" " 1:num/raw <- copy 34\n" "]\n" ); CHECK_TRACE_CONTENTS( "mem: storing 34 in location 1\n" ); } void test_reload_can_repeatedly_load_container_definitions() { // define a container and try to create it (merge requires knowing container size) run( "def main [\n" " local-scope\n" " x:text <- new [\n" " container foo [\n" " x:num\n" " y:num\n" " ]\n" " recipe bar [\n" " local-scope\n" " x:foo <- merge 34, 35\n" " ]\n" " ]\n" // save warning addresses in locations of type 'number' to avoid // spurious changes to them due to 'abandon' " 10:text/raw <- reload x\n" " 20:text/raw <- reload x\n" "]\n" ); // no errors on either load CHECK_TRACE_CONTENTS( "mem: storing 0 in location 10\n" "mem: storing 0 in location 11\n" "mem: storing 0 in location 20\n" "mem: storing 0 in location 21\n" ); }