<!doctype html>
<html lang="en">
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<title>docs/config/lua/pane/get_semantic_zone_at.md - fork/wezterm @ termwiz-0.23.2</title>
<meta name="description" content="docs/config/lua/pane/get_semantic_zone_at.md in fork/wezterm at termwiz-0.23.2.">
<meta property="og:title" content="docs/config/lua/pane/get_semantic_zone_at.md - fork/wezterm @ termwiz-0.23.2">
<meta property="og:description" content="docs/config/lua/pane/get_semantic_zone_at.md in fork/wezterm at termwiz-0.23.2.">
<meta property="og:type" content="website">
<meta property="og:site_name" content="git.julia.blue">
<link rel="stylesheet" href="/css/style.css?v=62">
<script type="module" src="/js/main.js?v=62"></script>
</head>
<body>
<main data-ref="termwiz-0.23.2" data-tip="8b7ca454b5e0a65b69b1b736db54eae3c195384b">
<noscript>
  <div class="callout">
    <p>
      hey! this is a static git repo viewer. commit diffs, file history,
      older commits and other revisions won't load without javascript.
    </p>
    <p>
      you are still able to view source files on branch/tag tips,
      but the experience is degraded.
    </p>
  </div>
</noscript>
<header class="repo"><div>
<h1>fork/wezterm</h1>
</div>
<pre class="clone">git clone https://git.julia.blue/fork/wezterm</pre>
</header>
<p class="snapshot-commit"><span class="commit-author">Wez Furlong</span><span class="commit-message" data-commit="3b8551e03c1092291f4cc5e1a0aab9e980550374">docs: update nightly features -&gt; current release</span><span class="snapshot-sha sha" data-commit="3b8551e03c1092291f4cc5e1a0aab9e980550374">3b8551e03</span><time datetime="2023-03-20T21:29:43-07:00" title="2023-03-20 21:29:43 -0700">2023-03-20</time></p>
<header class="topbar"><details class="switcher"><summary>termwiz-0.23.2</summary><div class="menu"><strong>branches</strong><a href="/fork/wezterm/ref/main/">main</a><strong>tags</strong><a href="/fork/wezterm/ref/termiz-0.23.1/">termiz-0.23.1</a><a href="/fork/wezterm/ref/termiz-0.23.2/">termiz-0.23.2</a><a href="/fork/wezterm/ref/termiz-0.23.3/">termiz-0.23.3</a><a href="/fork/wezterm/ref/termwiz-0.23.0/">termwiz-0.23.0</a><a href="/fork/wezterm/ref/termwiz-0.23.1/">termwiz-0.23.1</a><a class="current" href="/fork/wezterm/ref/termwiz-0.23.2/">termwiz-0.23.2</a><a href="/fork/wezterm/ref/termwiz-0.23.3/">termwiz-0.23.3</a><a href="/fork/wezterm/ref/vtparse-0.7.0/">vtparse-0.7.0</a><a class="all" href="/fork/wezterm/refs">all refs →</a></div></details><nav class="crumbs"><a href="/fork/wezterm/">wezterm</a> / <a href="/fork/wezterm/ref/termwiz-0.23.2/tree/docs/">docs</a> / <a href="/fork/wezterm/ref/termwiz-0.23.2/tree/docs/config/">config</a> / <a href="/fork/wezterm/ref/termwiz-0.23.2/tree/docs/config/lua/">lua</a> / <a href="/fork/wezterm/ref/termwiz-0.23.2/tree/docs/config/lua/pane/">pane</a> / <span class="cur">get_semantic_zone_at.md</span></nav>
<span class="view-stats"><span>918 B</span><span>30 lines</span></span><span class="actions"><a class="raw" href="/fork/wezterm/raw/bd00c57d75c5231ff7909a943bf9a7b209d1a790/docs/config/lua/pane/get_semantic_zone_at.md">raw</a></span></header>
<div class="markdown-view"><input type="radio" name="markdown-view" id="markdown-rendered" checked><label for="markdown-rendered">rendered</label><input type="radio" name="markdown-view" id="markdown-code"><label for="markdown-code">code</label><section class="readme rendered"><h1><code>pane:get_semantic_zone_at(x, y)</code></h1>
<p>{{since('20230320-124340-559cb7b0')}}</p>
<p>Resolves the semantic zone that encapsulates the supplied <em>x</em> and <em>y</em> coordinates.</p>
<p><em>x</em> is the cell column index, where 0 is the left-most column.
<em>y</em> is the stable row index.</p>
<p>Use <a href="/fork/wezterm/ref/termwiz-0.23.2/blob/docs/config/lua/pane/get_dimensions.md">pane:get_dimensions()</a> to
retrieve the currently valid stable index values for the top of scrollback and
top of viewport.</p>
<pre class="language-lua"><a-c>-- If you have shell integration configured, returns the zone around</a-c>
<a-c>-- the current cursor position</a-c>
<a-k>function</a-k> <a-f>get_zone_around_cursor</a-f><a-p>(</a-p><a-v>pane</a-v><a-p>)</a-p>
  <a-k>local</a-k> <a-v>cursor</a-v> = <a-v>pane</a-v><a-p>:</a-p><a-f>get_cursor_position</a-f><a-p>()</a-p>
  <a-c>-- using x-1 here because the cursor may be one cell outside the zone</a-c>
  <a-k>local</a-k> <a-v>zone</a-v> = <a-v>pane</a-v><a-p>:</a-p><a-f>get_semantic_zone_at</a-f><a-p>(</a-p><a-v>cursor</a-v><a-p>.</a-p><a-v>x</a-v> <a-o>-</a-o> <a-n>1</a-n><a-p>,</a-p> <a-v>cursor</a-v><a-p>.</a-p><a-v>y</a-v><a-p>)</a-p>
  <a-k>if</a-k> <a-v>zone</a-v> <a-k>then</a-k>
    <a-k>return</a-k> <a-v>pane</a-v><a-p>:</a-p><a-f>get_text_from_semantic_zone</a-f><a-p>(</a-p><a-v>zone</a-v><a-p>)</a-p>
  <a-k>end</a-k>
  <a-k>return</a-k> <a-co>nil</a-co>
<a-k>end</a-k></pre>
<p>See <a href="/fork/wezterm/ref/termwiz-0.23.2/blob/docs/shell-integration.md">Shell Integration</a> for more information
about semantic zones.</p>
</section><div class="code-panel"><pre class="code src language-markdown"><span class="code-line"><a class="ln" id="L1" href="#L1">1</a><span class="code-text"><a-p>#</a-p> <a-tt>`pane:get_semantic_zone_at(x, y)`</a-tt></span><span class="code-break">
</span></span><span class="code-line"><a class="ln" id="L2" href="#L2">2</a><span class="code-text"></span><span class="code-break">
</span></span><span class="code-line"><a class="ln" id="L3" href="#L3">3</a><span class="code-text">{{since(&#39;20230320-124340-559cb7b0&#39;)}}</span><span class="code-break">
</span></span><span class="code-line"><a class="ln" id="L4" href="#L4">4</a><span class="code-text"></span><span class="code-break">
</span></span><span class="code-line"><a class="ln" id="L5" href="#L5">5</a><span class="code-text">Resolves the semantic zone that encapsulates the supplied *x* and *y* coordinates.</span><span class="code-break">
</span></span><span class="code-line"><a class="ln" id="L6" href="#L6">6</a><span class="code-text"></span><span class="code-break">
</span></span><span class="code-line"><a class="ln" id="L7" href="#L7">7</a><span class="code-text">*x* is the cell column index, where 0 is the left-most column.</span><span class="code-break">
</span></span><span class="code-line"><a class="ln" id="L8" href="#L8">8</a><span class="code-text">*y* is the stable row index.</span><span class="code-break">
</span></span><span class="code-line"><a class="ln" id="L9" href="#L9">9</a><span class="code-text"></span><span class="code-break">
</span></span><span class="code-line"><a class="ln" id="L10" href="#L10">10</a><span class="code-text">Use [pane:get_dimensions()](get_dimensions.md) to</span><span class="code-break">
</span></span><span class="code-line"><a class="ln" id="L11" href="#L11">11</a><span class="code-text">retrieve the currently valid stable index values for the top of scrollback and</span><span class="code-break">
</span></span><span class="code-line"><a class="ln" id="L12" href="#L12">12</a><span class="code-text">top of viewport.</span><span class="code-break">
</span></span><span class="code-line"><a class="ln" id="L13" href="#L13">13</a><span class="code-text"></span><span class="code-break">
</span></span><span class="code-line"><a class="ln" id="L14" href="#L14">14</a><span class="code-text"><a-p>```</a-p><a-tl>lua</a-tl></span><span class="code-break">
</span></span><span class="code-line"><a class="ln" id="L15" href="#L15">15</a><span class="code-text"><a-p>-- If you have shell integration configured, returns the zone around</a-p></span><span class="code-break">
</span></span><span class="code-line"><a class="ln" id="L16" href="#L16">16</a><span class="code-text"><a-p>-- the current cursor position</a-p></span><span class="code-break">
</span></span><span class="code-line"><a class="ln" id="L17" href="#L17">17</a><span class="code-text"><a-p>function </a-p><a-f>get_zone_around_cursor</a-f><a-p>(</a-p><a-v>pane</a-v><a-p>)</a-p></span><span class="code-break">
</span></span><span class="code-line"><a class="ln" id="L18" href="#L18">18</a><span class="code-text"><a-p>  </a-p><a-k>local</a-k><a-p> </a-p><a-v>cursor</a-v><a-p> = </a-p><a-v>pane</a-v><a-p>:</a-p><a-f>get_cursor_position</a-f><a-p>()</a-p></span><span class="code-break">
</span></span><span class="code-line"><a class="ln" id="L19" href="#L19">19</a><span class="code-text"><a-p>  </a-p><a-c>-- using x-1 here because the cursor may be one cell outside the zone</a-c></span><span class="code-break">
</span></span><span class="code-line"><a class="ln" id="L20" href="#L20">20</a><span class="code-text"><a-p>  </a-p><a-k>local</a-k><a-p> </a-p><a-v>zone</a-v><a-p> = </a-p><a-v>pane</a-v><a-p>:</a-p><a-f>get_semantic_zone_at</a-f><a-p>(</a-p><a-v>cursor</a-v><a-p>.</a-p><a-v>x</a-v><a-p> </a-p><a-o>-</a-o><a-p> </a-p><a-n>1</a-n><a-p>, </a-p><a-v>cursor</a-v><a-p>.</a-p><a-v>y</a-v><a-p>)</a-p></span><span class="code-break">
</span></span><span class="code-line"><a class="ln" id="L21" href="#L21">21</a><span class="code-text"><a-p>  </a-p><a-k>if</a-k><a-p> </a-p><a-v>zone</a-v><a-p> </a-p><a-k>then</a-k></span><span class="code-break">
</span></span><span class="code-line"><a class="ln" id="L22" href="#L22">22</a><span class="code-text"><a-p>    </a-p><a-k>return</a-k><a-p> </a-p><a-v>pane</a-v><a-p>:</a-p><a-f>get_text_from_semantic_zone</a-f><a-p>(</a-p><a-v>zone</a-v><a-p>)</a-p></span><span class="code-break">
</span></span><span class="code-line"><a class="ln" id="L23" href="#L23">23</a><span class="code-text"><a-p>  </a-p><a-k>end</a-k></span><span class="code-break">
</span></span><span class="code-line"><a class="ln" id="L24" href="#L24">24</a><span class="code-text"><a-p>  </a-p><a-k>return</a-k><a-p> </a-p><a-co>nil</a-co></span><span class="code-break">
</span></span><span class="code-line"><a class="ln" id="L25" href="#L25">25</a><span class="code-text"><a-p>end</a-p></span><span class="code-break">
</span></span><span class="code-line"><a class="ln" id="L26" href="#L26">26</a><span class="code-text"><a-p>```</a-p></span><span class="code-break">
</span></span><span class="code-line"><a class="ln" id="L27" href="#L27">27</a><span class="code-text"></span><span class="code-break">
</span></span><span class="code-line"><a class="ln" id="L28" href="#L28">28</a><span class="code-text">See [Shell Integration](../../../shell-integration.md) for more information</span><span class="code-break">
</span></span><span class="code-line"><a class="ln" id="L29" href="#L29">29</a><span class="code-text">about semantic zones.</span><span class="code-break">
</span></span><span class="code-line"><a class="ln" id="L30" href="#L30">30</a><span class="code-text"></span></span></pre></div></div>
</main>
</body>
</html>
