<?xml version="1.0" encoding="UTF-8"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0"><channel><title><![CDATA[How to check if NPP is in rtl or ltr direction?]]></title><description><![CDATA[<p dir="auto">Hi<br />
I’m in the middle of developing a plugin that will remember the text direction for each tab/file and will switch to the right direction when the file is reopened or the user switches back to the tab.<br />
In order to do that my plugin needs to know at a given moment whether NPP is currently in rtl or ltr.<br />
I tried to ‘steal’ the following function form NPP’s source code:<br />
bool isTextDirectionRTL()<br />
{<br />
long exStyle = static_cast&lt;long&gt;(::GetWindowLongPtr(nppData._scintillaMainHandle, GWL_EXSTYLE));<br />
return (exStyle &amp; WS_EX_LAYOUTRTL) != 0;<br />
}<br />
It worked for a while but after doing some additional tests I saw that it doesn’t always work. (I guess it has something to do with the fact that the ‘main handle’ doesn’t always point to the required scintilla or something like that)</p>
<p dir="auto">For now I’ve decided to create a keyboard shortcut that will call a function in my plugin that will change the text direction (and ask the user to change text direction only this way), this way my plugin can monitor and keep track of the text direction, if anybody knows about a better solution I’d be glad to here.</p>
]]></description><link>https://community.notepad-plus-plus.org/topic/13611/how-to-check-if-npp-is-in-rtl-or-ltr-direction</link><generator>RSS for Node</generator><lastBuildDate>Sun, 16 Aug 2026 22:09:44 GMT</lastBuildDate><atom:link href="https://community.notepad-plus-plus.org/topic/13611.rss" rel="self" type="application/rss+xml"/><pubDate>Sat, 08 Apr 2017 18:59:07 GMT</pubDate><ttl>60</ttl><item><title><![CDATA[Reply to How to check if NPP is in rtl or ltr direction? on Mon, 10 Apr 2017 01:46:09 GMT]]></title><description><![CDATA[<p dir="auto">Great.<br />
You’re welcome.</p>
]]></description><link>https://community.notepad-plus-plus.org/post/23457</link><guid isPermaLink="true">https://community.notepad-plus-plus.org/post/23457</guid><dc:creator><![CDATA[Yaron]]></dc:creator><pubDate>Mon, 10 Apr 2017 01:46:09 GMT</pubDate></item><item><title><![CDATA[Reply to How to check if NPP is in rtl or ltr direction? on Sun, 09 Apr 2017 21:01:27 GMT]]></title><description><![CDATA[<p dir="auto">Thanks, that worked!</p>
]]></description><link>https://community.notepad-plus-plus.org/post/23443</link><guid isPermaLink="true">https://community.notepad-plus-plus.org/post/23443</guid><dc:creator><![CDATA[Ezra Steinmetz]]></dc:creator><pubDate>Sun, 09 Apr 2017 21:01:27 GMT</pubDate></item><item><title><![CDATA[Reply to How to check if NPP is in rtl or ltr direction? on Sat, 08 Apr 2017 21:47:52 GMT]]></title><description><![CDATA[<p dir="auto">Hello Ezra,</p>
<p dir="auto">You should check first whether the current view is <code>MAIN_VIEW</code> or <code>SUB_VIEW</code>.</p>
<pre><code>inline HWND getCurrentView()
{
	return (::SendMessage(nppData._nppHandle, NPPM_GETCURRENTVIEW, 0, 0) == MAIN_VIEW) ?
			nppData._scintillaMainHandle : nppData._scintillaSecondHandle;
}
</code></pre>
<p dir="auto">(From <code>NppHelpers.h</code> in <a href="https://github.com/pnedev/compare-plugin" rel="nofollow ugc">Compare Plugin</a>. Thank you <a class="plugin-mentions-user plugin-mentions-a" href="/user/pnedev" aria-label="Profile: pnedev">@<bdi>pnedev</bdi></a>).</p>
<p dir="auto">And then:</p>
<pre><code>bool isTextDirectionRTL() const
{
	long exStyle = static_cast&lt;long&gt;(::GetWindowLongPtr(getCurrentView(), GWL_EXSTYLE));
	return (exStyle &amp; WS_EX_LAYOUTRTL) != 0;
}
</code></pre>
<p dir="auto">This plugin would be important to RTL users.<br />
Thank you and best of luck.</p>
<hr />
<p dir="auto">How about adding an option to set the default text direction to LTR even if NPP layout is RTL?</p>
]]></description><link>https://community.notepad-plus-plus.org/post/23433</link><guid isPermaLink="true">https://community.notepad-plus-plus.org/post/23433</guid><dc:creator><![CDATA[Yaron]]></dc:creator><pubDate>Sat, 08 Apr 2017 21:47:52 GMT</pubDate></item></channel></rss>