515 lines
18 KiB
HTML
515 lines
18 KiB
HTML
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
|
|
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
|
|
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
|
|
<head>
|
|
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
|
|
<title>
|
|
Class: Teamocil::Layout
|
|
|
|
— Teamocil
|
|
|
|
</title>
|
|
|
|
<link rel="stylesheet" href="../css/style.css" type="text/css" media="screen" charset="utf-8" />
|
|
|
|
<link rel="stylesheet" href="../css/common.css" type="text/css" media="screen" charset="utf-8" />
|
|
|
|
<script type="text/javascript" charset="utf-8">
|
|
relpath = '..';
|
|
if (relpath != '') relpath += '/';
|
|
</script>
|
|
|
|
<script type="text/javascript" charset="utf-8" src="../js/jquery.js"></script>
|
|
|
|
<script type="text/javascript" charset="utf-8" src="../js/app.js"></script>
|
|
|
|
|
|
</head>
|
|
<body>
|
|
<script type="text/javascript" charset="utf-8">
|
|
if (window.top.frames.main) document.body.className = 'frames';
|
|
</script>
|
|
|
|
<div id="header">
|
|
<div id="menu">
|
|
|
|
<a href="../_index.html">Index (L)</a> »
|
|
<span class='title'><span class='object_link'><a href="../Teamocil.html" title="Teamocil (module)">Teamocil</a></span></span>
|
|
»
|
|
<span class="title">Layout</span>
|
|
|
|
|
|
<div class="noframes"><span class="title">(</span><a href="." target="_top">no frames</a><span class="title">)</span></div>
|
|
</div>
|
|
|
|
<div id="search">
|
|
|
|
<a id="class_list_link" href="#">Class List</a>
|
|
|
|
<a id="method_list_link" href="#">Method List</a>
|
|
|
|
<a id="file_list_link" href="#">File List</a>
|
|
|
|
</div>
|
|
<div class="clear"></div>
|
|
</div>
|
|
|
|
<iframe id="search_frame"></iframe>
|
|
|
|
<div id="content"><h1>Class: Teamocil::Layout
|
|
|
|
|
|
|
|
</h1>
|
|
|
|
<dl class="box">
|
|
|
|
<dt class="r1">Inherits:</dt>
|
|
<dd class="r1">
|
|
<span class="inheritName">Object</span>
|
|
|
|
<ul class="fullTree">
|
|
<li>Object</li>
|
|
|
|
<li class="next">Teamocil::Layout</li>
|
|
|
|
</ul>
|
|
<a href="#" class="inheritanceTree">show all</a>
|
|
|
|
</dd>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
<dt class="r2 last">Defined in:</dt>
|
|
<dd class="r2 last">lib/teamocil/layout.rb</dd>
|
|
|
|
</dl>
|
|
<div class="clear"></div>
|
|
|
|
<h2>Overview</h2><div class="docstring">
|
|
<div class="discussion">
|
|
<p>This class act as a wrapper around a tmux YAML layout file.</p>
|
|
|
|
</div>
|
|
</div>
|
|
<div class="tags">
|
|
|
|
</div>
|
|
|
|
|
|
|
|
|
|
|
|
<h2>
|
|
Instance Method Summary
|
|
<small>(<a href="#" class="summary_toggle">collapse</a>)</small>
|
|
</h2>
|
|
|
|
<ul class="summary">
|
|
|
|
<li class="public ">
|
|
<span class="summary_signature">
|
|
|
|
<a href="#execute_commands-instance_method" title="#execute_commands (instance method)">- (Object) <strong>execute_commands</strong>(commands) </a>
|
|
|
|
|
|
|
|
</span>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
<span class="summary_desc"><div class='inline'><p>Execute each command in the shell.</p></div></span>
|
|
|
|
</li>
|
|
|
|
|
|
<li class="public ">
|
|
<span class="summary_signature">
|
|
|
|
<a href="#generate_commands-instance_method" title="#generate_commands (instance method)">- (Object) <strong>generate_commands</strong> </a>
|
|
|
|
|
|
|
|
</span>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
<span class="summary_desc"><div class='inline'><p>Generate tmux commands based on the data found in the layout file.</p></div></span>
|
|
|
|
</li>
|
|
|
|
|
|
<li class="public ">
|
|
<span class="summary_signature">
|
|
|
|
<a href="#initialize-instance_method" title="#initialize (instance method)">- (Layout) <strong>initialize</strong>(file, options) </a>
|
|
|
|
|
|
|
|
</span>
|
|
|
|
<span class="note title constructor">constructor</span>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
<span class="summary_desc"><div class='inline'><p>Initialize a new layout from a file.</p></div></span>
|
|
|
|
</li>
|
|
|
|
|
|
<li class="public ">
|
|
<span class="summary_signature">
|
|
|
|
<a href="#to_tmux-instance_method" title="#to_tmux (instance method)">- (Object) <strong>to_tmux</strong> </a>
|
|
|
|
|
|
|
|
</span>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
<span class="summary_desc"><div class='inline'><p>Generate commands and sends them to tmux.</p></div></span>
|
|
|
|
</li>
|
|
|
|
|
|
</ul>
|
|
|
|
|
|
<div id="constructor_details" class="method_details_list">
|
|
<h2>Constructor Details</h2>
|
|
|
|
<div class="method_details first">
|
|
<p class="signature first" id="initialize-instance_method">
|
|
|
|
- (<tt><span class='object_link'><a href="" title="Teamocil::Layout (class)">Layout</a></span></tt>) <strong>initialize</strong>(file, options)
|
|
|
|
|
|
|
|
</p><div class="docstring">
|
|
<div class="discussion">
|
|
<p>Initialize a new layout from a file</p>
|
|
|
|
</div>
|
|
</div>
|
|
<div class="tags">
|
|
<h3>Parameters:</h3>
|
|
<ul class="param">
|
|
|
|
<li>
|
|
|
|
<span class='name'>file</span>
|
|
|
|
|
|
<span class='type'>(<tt>String</tt>)</span>
|
|
|
|
|
|
|
|
—
|
|
<div class='inline'><p>the complete layout file path</p></div>
|
|
|
|
</li>
|
|
|
|
<li>
|
|
|
|
<span class='name'>options</span>
|
|
|
|
|
|
<span class='type'>(<tt>Hash</tt>)</span>
|
|
|
|
|
|
|
|
</li>
|
|
|
|
</ul>
|
|
|
|
</div><table class="source_code">
|
|
<tr>
|
|
<td>
|
|
<pre class="lines">
|
|
|
|
|
|
9
|
|
10
|
|
11
|
|
12</pre>
|
|
</td>
|
|
<td>
|
|
<pre class="code"><span class="info file"># File 'lib/teamocil/layout.rb', line 9</span>
|
|
|
|
<span class='def def kw'>def</span> <span class='initialize identifier id'>initialize</span><span class='lparen token'>(</span><span class='file identifier id'>file</span><span class='comma token'>,</span> <span class='options identifier id'>options</span><span class='rparen token'>)</span> <span class='comment val'># {{{</span>
|
|
<span class='@layout ivar id'>@layout</span> <span class='assign token'>=</span> <span class='YAML constant id'>YAML</span><span class='dot token'>.</span><span class='load_file identifier id'>load_file</span><span class='lparen token'>(</span><span class='file identifier id'>file</span><span class='rparen token'>)</span>
|
|
<span class='@options ivar id'>@options</span> <span class='assign token'>=</span> <span class='options identifier id'>options</span>
|
|
<span class='end end kw'>end</span>
|
|
</pre>
|
|
</td>
|
|
</tr>
|
|
</table>
|
|
</div>
|
|
|
|
</div>
|
|
|
|
|
|
<div id="instance_method_details" class="method_details_list">
|
|
<h2>Instance Method Details</h2>
|
|
|
|
|
|
<div class="method_details first">
|
|
<p class="signature first" id="execute_commands-instance_method">
|
|
|
|
- (<tt>Object</tt>) <strong>execute_commands</strong>(commands)
|
|
|
|
|
|
|
|
</p><div class="docstring">
|
|
<div class="discussion">
|
|
<p>Execute each command in the shell</p>
|
|
|
|
</div>
|
|
</div>
|
|
<div class="tags">
|
|
<h3>Parameters:</h3>
|
|
<ul class="param">
|
|
|
|
<li>
|
|
|
|
<span class='name'>commands</span>
|
|
|
|
|
|
<span class='type'>(<tt>Array</tt>)</span>
|
|
|
|
|
|
|
|
—
|
|
<div class='inline'><p>an array of complete commands to send to the shell</p></div>
|
|
|
|
</li>
|
|
|
|
</ul>
|
|
|
|
</div><table class="source_code">
|
|
<tr>
|
|
<td>
|
|
<pre class="lines">
|
|
|
|
|
|
73
|
|
74
|
|
75</pre>
|
|
</td>
|
|
<td>
|
|
<pre class="code"><span class="info file"># File 'lib/teamocil/layout.rb', line 73</span>
|
|
|
|
<span class='def def kw'>def</span> <span class='execute_commands identifier id'>execute_commands</span><span class='lparen token'>(</span><span class='commands identifier id'>commands</span><span class='rparen token'>)</span> <span class='comment val'># {{{</span>
|
|
<span class='dxstring node'>`#{commands.join("; ")}`</span>
|
|
<span class='end end kw'>end</span>
|
|
</pre>
|
|
</td>
|
|
</tr>
|
|
</table>
|
|
</div>
|
|
|
|
<div class="method_details ">
|
|
<p class="signature " id="generate_commands-instance_method">
|
|
|
|
- (<tt>Object</tt>) <strong>generate_commands</strong>
|
|
|
|
|
|
|
|
</p><div class="docstring">
|
|
<div class="discussion">
|
|
<p>Generate tmux commands based on the data found in the layout file</p>
|
|
|
|
</div>
|
|
</div>
|
|
<div class="tags">
|
|
|
|
</div><table class="source_code">
|
|
<tr>
|
|
<td>
|
|
<pre class="lines">
|
|
|
|
|
|
21
|
|
22
|
|
23
|
|
24
|
|
25
|
|
26
|
|
27
|
|
28
|
|
29
|
|
30
|
|
31
|
|
32
|
|
33
|
|
34
|
|
35
|
|
36
|
|
37
|
|
38
|
|
39
|
|
40
|
|
41
|
|
42
|
|
43
|
|
44
|
|
45
|
|
46
|
|
47
|
|
48
|
|
49
|
|
50
|
|
51
|
|
52
|
|
53
|
|
54
|
|
55
|
|
56
|
|
57
|
|
58
|
|
59
|
|
60
|
|
61
|
|
62
|
|
63
|
|
64
|
|
65
|
|
66
|
|
67
|
|
68</pre>
|
|
</td>
|
|
<td>
|
|
<pre class="code"><span class="info file"># File 'lib/teamocil/layout.rb', line 21</span>
|
|
|
|
<span class='def def kw'>def</span> <span class='generate_commands identifier id'>generate_commands</span>
|
|
<span class='output identifier id'>output</span> <span class='assign token'>=</span> <span class='lbrack token'>[</span><span class='rbrack token'>]</span>
|
|
|
|
<span class='if if kw'>if</span> <span class='@layout ivar id'>@layout</span><span class='lbrack token'>[</span><span class='string val'>"session"</span><span class='rbrack token'>]</span><span class='dot token'>.</span><span class='nil? fid id'>nil?</span>
|
|
<span class='windows identifier id'>windows</span> <span class='assign token'>=</span> <span class='@layout ivar id'>@layout</span><span class='lbrack token'>[</span><span class='string val'>"windows"</span><span class='rbrack token'>]</span>
|
|
<span class='else else kw'>else</span>
|
|
<span class='output identifier id'>output</span> <span class='lshft op'><<</span> <span class='dstring node'>"tmux rename-session #{@layout["session"]["name"]}"</span> <span class='if if_mod kw'>if</span> <span class='@layout ivar id'>@layout</span><span class='lbrack token'>[</span><span class='string val'>"session"</span><span class='rbrack token'>]</span><span class='lbrack token'>[</span><span class='string val'>"name"</span><span class='rbrack token'>]</span>
|
|
<span class='windows identifier id'>windows</span> <span class='assign token'>=</span> <span class='@layout ivar id'>@layout</span><span class='lbrack token'>[</span><span class='string val'>"session"</span><span class='rbrack token'>]</span><span class='lbrack token'>[</span><span class='string val'>"windows"</span><span class='rbrack token'>]</span>
|
|
<span class='end end kw'>end</span>
|
|
|
|
<span class='windows identifier id'>windows</span><span class='dot token'>.</span><span class='each_with_index identifier id'>each_with_index</span> <span class='do do kw'>do</span> <span class='bitor op'>|</span><span class='window identifier id'>window</span><span class='comma token'>,</span> <span class='window_index identifier id'>window_index</span><span class='bitor op'>|</span>
|
|
|
|
<span class='if if kw'>if</span> <span class='@options ivar id'>@options</span><span class='dot token'>.</span><span class='include? fid id'>include?</span><span class='lparen token'>(</span><span class='symbol val'>:here</span><span class='rparen token'>)</span> <span class='and and kw'>and</span> <span class='window_index identifier id'>window_index</span> <span class='eq op'>==</span> <span class='integer val'>0</span>
|
|
<span class='output identifier id'>output</span> <span class='lshft op'><<</span> <span class='dstring node'>"tmux rename-window \"#{window["name"]}\""</span>
|
|
<span class='else else kw'>else</span>
|
|
<span class='output identifier id'>output</span> <span class='lshft op'><<</span> <span class='dstring node'>"tmux new-window -n \"#{window["name"]}\""</span>
|
|
<span class='end end kw'>end</span>
|
|
|
|
<span class='window identifier id'>window</span><span class='lbrack token'>[</span><span class='string val'>"splits"</span><span class='rbrack token'>]</span><span class='dot token'>.</span><span class='each_with_index identifier id'>each_with_index</span> <span class='do do kw'>do</span> <span class='bitor op'>|</span><span class='split identifier id'>split</span><span class='comma token'>,</span> <span class='index identifier id'>index</span><span class='bitor op'>|</span>
|
|
<span class='unless unless kw'>unless</span> <span class='index identifier id'>index</span> <span class='eq op'>==</span> <span class='integer val'>0</span>
|
|
<span class='if if kw'>if</span> <span class='split identifier id'>split</span><span class='dot token'>.</span><span class='include? fid id'>include?</span><span class='lparen token'>(</span><span class='string val'>"width"</span><span class='rparen token'>)</span>
|
|
<span class='cmd identifier id'>cmd</span> <span class='assign token'>=</span> <span class='dstring node'>"tmux split-window -h -p #{split["width"]}"</span>
|
|
<span class='elsif elsif kw'>elsif</span> <span class='split identifier id'>split</span><span class='dot token'>.</span><span class='include? fid id'>include?</span><span class='lparen token'>(</span><span class='string val'>"height"</span><span class='rparen token'>)</span>
|
|
<span class='cmd identifier id'>cmd</span> <span class='assign token'>=</span> <span class='dstring node'>"tmux split-window -p #{split["height"]}"</span>
|
|
<span class='else else kw'>else</span>
|
|
<span class='cmd identifier id'>cmd</span> <span class='assign token'>=</span> <span class='string val'>"tmux split-window"</span>
|
|
<span class='end end kw'>end</span>
|
|
<span class='cmd identifier id'>cmd</span> <span class='lshft op'><<</span> <span class='dstring node'>" -t #{split["target"]}"</span> <span class='if if_mod kw'>if</span> <span class='split identifier id'>split</span><span class='dot token'>.</span><span class='include? fid id'>include?</span><span class='lparen token'>(</span><span class='string val'>"target"</span><span class='rparen token'>)</span>
|
|
<span class='output identifier id'>output</span> <span class='lshft op'><<</span> <span class='cmd identifier id'>cmd</span>
|
|
<span class='end end kw'>end</span>
|
|
|
|
<span class='comment val'># Support single command splits, but treat it as an array nevertheless</span>
|
|
<span class='split identifier id'>split</span><span class='lbrack token'>[</span><span class='string val'>"cmd"</span><span class='rbrack token'>]</span> <span class='assign token'>=</span> <span class='lbrack token'>[</span><span class='split identifier id'>split</span><span class='lbrack token'>[</span><span class='string val'>"cmd"</span><span class='rbrack token'>]</span><span class='rbrack token'>]</span> <span class='unless unless_mod kw'>unless</span> <span class='split identifier id'>split</span><span class='lbrack token'>[</span><span class='string val'>"cmd"</span><span class='rbrack token'>]</span><span class='dot token'>.</span><span class='is_a? fid id'>is_a?</span> <span class='Array constant id'>Array</span>
|
|
|
|
<span class='comment val'># If a `root` key exist, start each split in this directory</span>
|
|
<span class='split identifier id'>split</span><span class='lbrack token'>[</span><span class='string val'>"cmd"</span><span class='rbrack token'>]</span> <span class='assign token'>=</span> <span class='lbrack token'>[</span><span class='dstring node'>"cd \"#{window["root"]}\""</span><span class='rbrack token'>]</span> <span class='plus op'>+</span> <span class='split identifier id'>split</span><span class='lbrack token'>[</span><span class='string val'>"cmd"</span><span class='rbrack token'>]</span> <span class='if if_mod kw'>if</span> <span class='window identifier id'>window</span><span class='dot token'>.</span><span class='include? fid id'>include?</span><span class='lparen token'>(</span><span class='string val'>"root"</span><span class='rparen token'>)</span>
|
|
|
|
<span class='comment val'># Execute each split command</span>
|
|
<span class='split identifier id'>split</span><span class='lbrack token'>[</span><span class='string val'>"cmd"</span><span class='rbrack token'>]</span><span class='dot token'>.</span><span class='each identifier id'>each</span> <span class='do do kw'>do</span> <span class='bitor op'>|</span><span class='command identifier id'>command</span><span class='bitor op'>|</span>
|
|
<span class='output identifier id'>output</span> <span class='lshft op'><<</span> <span class='dstring node'>"tmux send-keys -t #{index} \"#{command}\""</span>
|
|
<span class='output identifier id'>output</span> <span class='lshft op'><<</span> <span class='dstring node'>"tmux send-keys -t #{index} Enter"</span>
|
|
<span class='end end kw'>end</span>
|
|
<span class='end end kw'>end</span>
|
|
|
|
<span class='end end kw'>end</span>
|
|
|
|
<span class='output identifier id'>output</span> <span class='lshft op'><<</span> <span class='string val'>"tmux select-pane -t 0"</span>
|
|
<span class='end end kw'>end</span>
|
|
</pre>
|
|
</td>
|
|
</tr>
|
|
</table>
|
|
</div>
|
|
|
|
<div class="method_details ">
|
|
<p class="signature " id="to_tmux-instance_method">
|
|
|
|
- (<tt>Object</tt>) <strong>to_tmux</strong>
|
|
|
|
|
|
|
|
</p><div class="docstring">
|
|
<div class="discussion">
|
|
<p>Generate commands and sends them to tmux</p>
|
|
|
|
</div>
|
|
</div>
|
|
<div class="tags">
|
|
|
|
</div><table class="source_code">
|
|
<tr>
|
|
<td>
|
|
<pre class="lines">
|
|
|
|
|
|
15
|
|
16
|
|
17
|
|
18</pre>
|
|
</td>
|
|
<td>
|
|
<pre class="code"><span class="info file"># File 'lib/teamocil/layout.rb', line 15</span>
|
|
|
|
<span class='def def kw'>def</span> <span class='to_tmux identifier id'>to_tmux</span>
|
|
<span class='commands identifier id'>commands</span> <span class='assign token'>=</span> <span class='generate_commands identifier id'>generate_commands</span>
|
|
<span class='execute_commands identifier id'>execute_commands</span><span class='lparen token'>(</span><span class='commands identifier id'>commands</span><span class='rparen token'>)</span>
|
|
<span class='end end kw'>end</span>
|
|
</pre>
|
|
</td>
|
|
</tr>
|
|
</table>
|
|
</div>
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
<div id="footer">
|
|
Generated on Mon Sep 26 08:42:34 2011 by
|
|
<a href="http://yardoc.org" title="Yay! A Ruby Documentation Tool" target="_parent">yard</a>
|
|
0.7.2 (ruby-1.8.7).
|
|
</div>
|
|
|
|
</body>
|
|
</html> |