Terminal.Gui.TextFormatter.html 39 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052
  1. <!DOCTYPE html>
  2. <!--[if IE]><![endif]-->
  3. <html>
  4. <head>
  5. <meta charset="utf-8">
  6. <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
  7. <title>Class TextFormatter
  8. </title>
  9. <meta name="viewport" content="width=device-width">
  10. <meta name="title" content="Class TextFormatter
  11. ">
  12. <meta name="generator" content="docfx 2.56.2.0">
  13. <link rel="shortcut icon" href="../../favicon.ico">
  14. <link rel="stylesheet" href="../../styles/docfx.vendor.css">
  15. <link rel="stylesheet" href="../../styles/docfx.css">
  16. <link rel="stylesheet" href="../../styles/main.css">
  17. <meta property="docfx:navrel" content="../../toc.html">
  18. <meta property="docfx:tocrel" content="toc.html">
  19. <meta property="docfx:rel" content="../../">
  20. </head>
  21. <body data-spy="scroll" data-target="#affix" data-offset="120">
  22. <div id="wrapper">
  23. <header>
  24. <nav id="autocollapse" class="navbar navbar-inverse ng-scope" role="navigation">
  25. <div class="container">
  26. <div class="navbar-header">
  27. <button type="button" class="navbar-toggle" data-toggle="collapse" data-target="#navbar">
  28. <span class="sr-only">Toggle navigation</span>
  29. <span class="icon-bar"></span>
  30. <span class="icon-bar"></span>
  31. <span class="icon-bar"></span>
  32. </button>
  33. <a class="navbar-brand" href="../../index.html">
  34. <img id="logo" class="svg" src="../../images/logo48.png" alt="">
  35. </a>
  36. </div>
  37. <div class="collapse navbar-collapse" id="navbar">
  38. <form class="navbar-form navbar-right" role="search" id="search">
  39. <div class="form-group">
  40. <input type="text" class="form-control" id="search-query" placeholder="Search" autocomplete="off">
  41. </div>
  42. </form>
  43. </div>
  44. </div>
  45. </nav>
  46. <div class="subnav navbar navbar-default">
  47. <div class="container hide-when-search" id="breadcrumb">
  48. <ul class="breadcrumb">
  49. <li></li>
  50. </ul>
  51. </div>
  52. </div>
  53. </header>
  54. <div class="container body-content">
  55. <div id="search-results">
  56. <div class="search-list"></div>
  57. <div class="sr-items">
  58. <p><i class="glyphicon glyphicon-refresh index-loading"></i></p>
  59. </div>
  60. <ul id="pagination"></ul>
  61. </div>
  62. </div>
  63. <div role="main" class="container body-content hide-when-search">
  64. <div class="sidenav hide-when-search">
  65. <a class="btn toc-toggle collapse" data-toggle="collapse" href="#sidetoggle" aria-expanded="false" aria-controls="sidetoggle">Show / Hide Table of Contents</a>
  66. <div class="sidetoggle collapse" id="sidetoggle">
  67. <div id="sidetoc"></div>
  68. </div>
  69. </div>
  70. <div class="article row grid-right">
  71. <div class="col-md-10">
  72. <article class="content wrap" id="_content" data-uid="Terminal.Gui.TextFormatter">
  73. <h1 id="Terminal_Gui_TextFormatter" data-uid="Terminal.Gui.TextFormatter" class="text-break">Class TextFormatter
  74. </h1>
  75. <div class="markdown level0 summary">
  76. Provides text formatting capabilities for console apps. Supports, hotkeys, horizontal alignment, multille lines, and word-based line wrap.
  77. </div>
  78. <div class="markdown level0 conceptual"></div>
  79. <div class="inheritance">
  80. <h5>Inheritance</h5>
  81. <div class="level0"><span class="xref">System.Object</span></div>
  82. <div class="level1"><span class="xref">TextFormatter</span></div>
  83. </div>
  84. <div class="inheritedMembers">
  85. <h5>Inherited Members</h5>
  86. <div>
  87. <span class="xref">System.Object.Equals(System.Object)</span>
  88. </div>
  89. <div>
  90. <span class="xref">System.Object.Equals(System.Object, System.Object)</span>
  91. </div>
  92. <div>
  93. <span class="xref">System.Object.GetHashCode()</span>
  94. </div>
  95. <div>
  96. <span class="xref">System.Object.GetType()</span>
  97. </div>
  98. <div>
  99. <span class="xref">System.Object.MemberwiseClone()</span>
  100. </div>
  101. <div>
  102. <span class="xref">System.Object.ReferenceEquals(System.Object, System.Object)</span>
  103. </div>
  104. <div>
  105. <span class="xref">System.Object.ToString()</span>
  106. </div>
  107. </div>
  108. <h6><strong>Namespace</strong>: <a class="xref" href="Terminal.Gui.html">Terminal.Gui</a></h6>
  109. <h6><strong>Assembly</strong>: Terminal.Gui.dll</h6>
  110. <h5 id="Terminal_Gui_TextFormatter_syntax">Syntax</h5>
  111. <div class="codewrapper">
  112. <pre><code class="lang-csharp hljs">public class TextFormatter</code></pre>
  113. </div>
  114. <h3 id="properties">Properties
  115. </h3>
  116. <a id="Terminal_Gui_TextFormatter_Alignment_" data-uid="Terminal.Gui.TextFormatter.Alignment*"></a>
  117. <h4 id="Terminal_Gui_TextFormatter_Alignment" data-uid="Terminal.Gui.TextFormatter.Alignment">Alignment</h4>
  118. <div class="markdown level1 summary">
  119. Controls the horizontal text-alignment property.
  120. </div>
  121. <div class="markdown level1 conceptual"></div>
  122. <h5 class="decalaration">Declaration</h5>
  123. <div class="codewrapper">
  124. <pre><code class="lang-csharp hljs">public TextAlignment Alignment { get; set; }</code></pre>
  125. </div>
  126. <h5 class="propertyValue">Property Value</h5>
  127. <table class="table table-bordered table-striped table-condensed">
  128. <thead>
  129. <tr>
  130. <th>Type</th>
  131. <th>Description</th>
  132. </tr>
  133. </thead>
  134. <tbody>
  135. <tr>
  136. <td><a class="xref" href="Terminal.Gui.TextAlignment.html">TextAlignment</a></td>
  137. <td>The text alignment.</td>
  138. </tr>
  139. </tbody>
  140. </table>
  141. <a id="Terminal_Gui_TextFormatter_CursorPosition_" data-uid="Terminal.Gui.TextFormatter.CursorPosition*"></a>
  142. <h4 id="Terminal_Gui_TextFormatter_CursorPosition" data-uid="Terminal.Gui.TextFormatter.CursorPosition">CursorPosition</h4>
  143. <div class="markdown level1 summary">
  144. Gets the cursor position from <a class="xref" href="Terminal.Gui.TextFormatter.html#Terminal_Gui_TextFormatter_HotKey">HotKey</a>. If the <a class="xref" href="Terminal.Gui.TextFormatter.html#Terminal_Gui_TextFormatter_HotKey">HotKey</a> is defined, the cursor will be positioned over it.
  145. </div>
  146. <div class="markdown level1 conceptual"></div>
  147. <h5 class="decalaration">Declaration</h5>
  148. <div class="codewrapper">
  149. <pre><code class="lang-csharp hljs">public int CursorPosition { get; set; }</code></pre>
  150. </div>
  151. <h5 class="propertyValue">Property Value</h5>
  152. <table class="table table-bordered table-striped table-condensed">
  153. <thead>
  154. <tr>
  155. <th>Type</th>
  156. <th>Description</th>
  157. </tr>
  158. </thead>
  159. <tbody>
  160. <tr>
  161. <td><span class="xref">System.Int32</span></td>
  162. <td></td>
  163. </tr>
  164. </tbody>
  165. </table>
  166. <a id="Terminal_Gui_TextFormatter_HotKey_" data-uid="Terminal.Gui.TextFormatter.HotKey*"></a>
  167. <h4 id="Terminal_Gui_TextFormatter_HotKey" data-uid="Terminal.Gui.TextFormatter.HotKey">HotKey</h4>
  168. <div class="markdown level1 summary">
  169. Gets the hotkey. Will be an upper case letter or digit.
  170. </div>
  171. <div class="markdown level1 conceptual"></div>
  172. <h5 class="decalaration">Declaration</h5>
  173. <div class="codewrapper">
  174. <pre><code class="lang-csharp hljs">public Key HotKey { get; }</code></pre>
  175. </div>
  176. <h5 class="propertyValue">Property Value</h5>
  177. <table class="table table-bordered table-striped table-condensed">
  178. <thead>
  179. <tr>
  180. <th>Type</th>
  181. <th>Description</th>
  182. </tr>
  183. </thead>
  184. <tbody>
  185. <tr>
  186. <td><a class="xref" href="Terminal.Gui.Key.html">Key</a></td>
  187. <td></td>
  188. </tr>
  189. </tbody>
  190. </table>
  191. <a id="Terminal_Gui_TextFormatter_HotKeyPos_" data-uid="Terminal.Gui.TextFormatter.HotKeyPos*"></a>
  192. <h4 id="Terminal_Gui_TextFormatter_HotKeyPos" data-uid="Terminal.Gui.TextFormatter.HotKeyPos">HotKeyPos</h4>
  193. <div class="markdown level1 summary">
  194. The position in the text of the hotkey. The hotkey will be rendered using the hot color.
  195. </div>
  196. <div class="markdown level1 conceptual"></div>
  197. <h5 class="decalaration">Declaration</h5>
  198. <div class="codewrapper">
  199. <pre><code class="lang-csharp hljs">public int HotKeyPos { get; set; }</code></pre>
  200. </div>
  201. <h5 class="propertyValue">Property Value</h5>
  202. <table class="table table-bordered table-striped table-condensed">
  203. <thead>
  204. <tr>
  205. <th>Type</th>
  206. <th>Description</th>
  207. </tr>
  208. </thead>
  209. <tbody>
  210. <tr>
  211. <td><span class="xref">System.Int32</span></td>
  212. <td></td>
  213. </tr>
  214. </tbody>
  215. </table>
  216. <a id="Terminal_Gui_TextFormatter_HotKeySpecifier_" data-uid="Terminal.Gui.TextFormatter.HotKeySpecifier*"></a>
  217. <h4 id="Terminal_Gui_TextFormatter_HotKeySpecifier" data-uid="Terminal.Gui.TextFormatter.HotKeySpecifier">HotKeySpecifier</h4>
  218. <div class="markdown level1 summary">
  219. The specifier character for the hotkey (e.g. &apos;_&apos;). Set to &apos;\xffff&apos; to disable hotkey support for this View instance. The default is &apos;\xffff&apos;.
  220. </div>
  221. <div class="markdown level1 conceptual"></div>
  222. <h5 class="decalaration">Declaration</h5>
  223. <div class="codewrapper">
  224. <pre><code class="lang-csharp hljs">public Rune HotKeySpecifier { get; set; }</code></pre>
  225. </div>
  226. <h5 class="propertyValue">Property Value</h5>
  227. <table class="table table-bordered table-striped table-condensed">
  228. <thead>
  229. <tr>
  230. <th>Type</th>
  231. <th>Description</th>
  232. </tr>
  233. </thead>
  234. <tbody>
  235. <tr>
  236. <td><span class="xref">System.Rune</span></td>
  237. <td></td>
  238. </tr>
  239. </tbody>
  240. </table>
  241. <a id="Terminal_Gui_TextFormatter_HotKeyTagMask_" data-uid="Terminal.Gui.TextFormatter.HotKeyTagMask*"></a>
  242. <h4 id="Terminal_Gui_TextFormatter_HotKeyTagMask" data-uid="Terminal.Gui.TextFormatter.HotKeyTagMask">HotKeyTagMask</h4>
  243. <div class="markdown level1 summary">
  244. Specifies the mask to apply to the hotkey to tag it as the hotkey. The default value of <code>0x100000</code> causes
  245. the underlying Rune to be identified as a &quot;private use&quot; Unicode character.
  246. </div>
  247. <div class="markdown level1 conceptual"></div>
  248. <h5 class="decalaration">Declaration</h5>
  249. <div class="codewrapper">
  250. <pre><code class="lang-csharp hljs">public uint HotKeyTagMask { get; set; }</code></pre>
  251. </div>
  252. <h5 class="propertyValue">Property Value</h5>
  253. <table class="table table-bordered table-striped table-condensed">
  254. <thead>
  255. <tr>
  256. <th>Type</th>
  257. <th>Description</th>
  258. </tr>
  259. </thead>
  260. <tbody>
  261. <tr>
  262. <td><span class="xref">System.UInt32</span></td>
  263. <td></td>
  264. </tr>
  265. </tbody>
  266. </table>
  267. <a id="Terminal_Gui_TextFormatter_Lines_" data-uid="Terminal.Gui.TextFormatter.Lines*"></a>
  268. <h4 id="Terminal_Gui_TextFormatter_Lines" data-uid="Terminal.Gui.TextFormatter.Lines">Lines</h4>
  269. <div class="markdown level1 summary">
  270. Gets the formatted lines.
  271. </div>
  272. <div class="markdown level1 conceptual"></div>
  273. <h5 class="decalaration">Declaration</h5>
  274. <div class="codewrapper">
  275. <pre><code class="lang-csharp hljs">public List&lt;ustring&gt; Lines { get; }</code></pre>
  276. </div>
  277. <h5 class="propertyValue">Property Value</h5>
  278. <table class="table table-bordered table-striped table-condensed">
  279. <thead>
  280. <tr>
  281. <th>Type</th>
  282. <th>Description</th>
  283. </tr>
  284. </thead>
  285. <tbody>
  286. <tr>
  287. <td><span class="xref">System.Collections.Generic.List</span>&lt;<span class="xref">NStack.ustring</span>&gt;</td>
  288. <td></td>
  289. </tr>
  290. </tbody>
  291. </table>
  292. <h5 id="Terminal_Gui_TextFormatter_Lines_remarks">Remarks</h5>
  293. <div class="markdown level1 remarks">
  294. <p>
  295. Upon a &apos;get&apos; of this property, if the text needs to be formatted (if <a class="xref" href="Terminal.Gui.TextFormatter.html#Terminal_Gui_TextFormatter_NeedsFormat">NeedsFormat</a> is <code>true</code>)
  296. <a class="xref" href="Terminal.Gui.TextFormatter.html#Terminal_Gui_TextFormatter_Format_NStack_ustring_System_Int32_Terminal_Gui_TextAlignment_System_Boolean_">Format(ustring, Int32, TextAlignment, Boolean)</a> will be called internally.
  297. </p>
  298. </div>
  299. <a id="Terminal_Gui_TextFormatter_NeedsFormat_" data-uid="Terminal.Gui.TextFormatter.NeedsFormat*"></a>
  300. <h4 id="Terminal_Gui_TextFormatter_NeedsFormat" data-uid="Terminal.Gui.TextFormatter.NeedsFormat">NeedsFormat</h4>
  301. <div class="markdown level1 summary">
  302. Gets or sets whether the <a class="xref" href="Terminal.Gui.TextFormatter.html">TextFormatter</a> needs to format the text when <a class="xref" href="Terminal.Gui.TextFormatter.html#Terminal_Gui_TextFormatter_Draw_Terminal_Gui_Rect_Terminal_Gui_Attribute_Terminal_Gui_Attribute_">Draw(Rect, Attribute, Attribute)</a> is called.
  303. If it is <code>false</code> when Draw is called, the Draw call will be faster.
  304. </div>
  305. <div class="markdown level1 conceptual"></div>
  306. <h5 class="decalaration">Declaration</h5>
  307. <div class="codewrapper">
  308. <pre><code class="lang-csharp hljs">public bool NeedsFormat { get; set; }</code></pre>
  309. </div>
  310. <h5 class="propertyValue">Property Value</h5>
  311. <table class="table table-bordered table-striped table-condensed">
  312. <thead>
  313. <tr>
  314. <th>Type</th>
  315. <th>Description</th>
  316. </tr>
  317. </thead>
  318. <tbody>
  319. <tr>
  320. <td><span class="xref">System.Boolean</span></td>
  321. <td></td>
  322. </tr>
  323. </tbody>
  324. </table>
  325. <h5 id="Terminal_Gui_TextFormatter_NeedsFormat_remarks">Remarks</h5>
  326. <div class="markdown level1 remarks">
  327. <p>
  328. This is set to true when the properties of <a class="xref" href="Terminal.Gui.TextFormatter.html">TextFormatter</a> are set.
  329. </p>
  330. </div>
  331. <a id="Terminal_Gui_TextFormatter_Size_" data-uid="Terminal.Gui.TextFormatter.Size*"></a>
  332. <h4 id="Terminal_Gui_TextFormatter_Size" data-uid="Terminal.Gui.TextFormatter.Size">Size</h4>
  333. <div class="markdown level1 summary">
  334. Gets or sets the size of the area the text will be constrainted to when formatted.
  335. </div>
  336. <div class="markdown level1 conceptual"></div>
  337. <h5 class="decalaration">Declaration</h5>
  338. <div class="codewrapper">
  339. <pre><code class="lang-csharp hljs">public Size Size { get; set; }</code></pre>
  340. </div>
  341. <h5 class="propertyValue">Property Value</h5>
  342. <table class="table table-bordered table-striped table-condensed">
  343. <thead>
  344. <tr>
  345. <th>Type</th>
  346. <th>Description</th>
  347. </tr>
  348. </thead>
  349. <tbody>
  350. <tr>
  351. <td><a class="xref" href="Terminal.Gui.Size.html">Size</a></td>
  352. <td></td>
  353. </tr>
  354. </tbody>
  355. </table>
  356. <a id="Terminal_Gui_TextFormatter_Text_" data-uid="Terminal.Gui.TextFormatter.Text*"></a>
  357. <h4 id="Terminal_Gui_TextFormatter_Text" data-uid="Terminal.Gui.TextFormatter.Text">Text</h4>
  358. <div class="markdown level1 summary">
  359. The text to be displayed. This text is never modified.
  360. </div>
  361. <div class="markdown level1 conceptual"></div>
  362. <h5 class="decalaration">Declaration</h5>
  363. <div class="codewrapper">
  364. <pre><code class="lang-csharp hljs">public virtual ustring Text { get; set; }</code></pre>
  365. </div>
  366. <h5 class="propertyValue">Property Value</h5>
  367. <table class="table table-bordered table-striped table-condensed">
  368. <thead>
  369. <tr>
  370. <th>Type</th>
  371. <th>Description</th>
  372. </tr>
  373. </thead>
  374. <tbody>
  375. <tr>
  376. <td><span class="xref">NStack.ustring</span></td>
  377. <td></td>
  378. </tr>
  379. </tbody>
  380. </table>
  381. <h3 id="methods">Methods
  382. </h3>
  383. <a id="Terminal_Gui_TextFormatter_CalcRect_" data-uid="Terminal.Gui.TextFormatter.CalcRect*"></a>
  384. <h4 id="Terminal_Gui_TextFormatter_CalcRect_System_Int32_System_Int32_NStack_ustring_" data-uid="Terminal.Gui.TextFormatter.CalcRect(System.Int32,System.Int32,NStack.ustring)">CalcRect(Int32, Int32, ustring)</h4>
  385. <div class="markdown level1 summary">
  386. Calculates the rectangle required to hold text, assuming no word wrapping.
  387. </div>
  388. <div class="markdown level1 conceptual"></div>
  389. <h5 class="decalaration">Declaration</h5>
  390. <div class="codewrapper">
  391. <pre><code class="lang-csharp hljs">public static Rect CalcRect(int x, int y, ustring text)</code></pre>
  392. </div>
  393. <h5 class="parameters">Parameters</h5>
  394. <table class="table table-bordered table-striped table-condensed">
  395. <thead>
  396. <tr>
  397. <th>Type</th>
  398. <th>Name</th>
  399. <th>Description</th>
  400. </tr>
  401. </thead>
  402. <tbody>
  403. <tr>
  404. <td><span class="xref">System.Int32</span></td>
  405. <td><span class="parametername">x</span></td>
  406. <td>The x location of the rectangle</td>
  407. </tr>
  408. <tr>
  409. <td><span class="xref">System.Int32</span></td>
  410. <td><span class="parametername">y</span></td>
  411. <td>The y location of the rectangle</td>
  412. </tr>
  413. <tr>
  414. <td><span class="xref">NStack.ustring</span></td>
  415. <td><span class="parametername">text</span></td>
  416. <td>The text to measure</td>
  417. </tr>
  418. </tbody>
  419. </table>
  420. <h5 class="returns">Returns</h5>
  421. <table class="table table-bordered table-striped table-condensed">
  422. <thead>
  423. <tr>
  424. <th>Type</th>
  425. <th>Description</th>
  426. </tr>
  427. </thead>
  428. <tbody>
  429. <tr>
  430. <td><a class="xref" href="Terminal.Gui.Rect.html">Rect</a></td>
  431. <td></td>
  432. </tr>
  433. </tbody>
  434. </table>
  435. <a id="Terminal_Gui_TextFormatter_ClipAndJustify_" data-uid="Terminal.Gui.TextFormatter.ClipAndJustify*"></a>
  436. <h4 id="Terminal_Gui_TextFormatter_ClipAndJustify_NStack_ustring_System_Int32_Terminal_Gui_TextAlignment_" data-uid="Terminal.Gui.TextFormatter.ClipAndJustify(NStack.ustring,System.Int32,Terminal.Gui.TextAlignment)">ClipAndJustify(ustring, Int32, TextAlignment)</h4>
  437. <div class="markdown level1 summary">
  438. Justifies text within a specified width.
  439. </div>
  440. <div class="markdown level1 conceptual"></div>
  441. <h5 class="decalaration">Declaration</h5>
  442. <div class="codewrapper">
  443. <pre><code class="lang-csharp hljs">public static ustring ClipAndJustify(ustring text, int width, TextAlignment talign)</code></pre>
  444. </div>
  445. <h5 class="parameters">Parameters</h5>
  446. <table class="table table-bordered table-striped table-condensed">
  447. <thead>
  448. <tr>
  449. <th>Type</th>
  450. <th>Name</th>
  451. <th>Description</th>
  452. </tr>
  453. </thead>
  454. <tbody>
  455. <tr>
  456. <td><span class="xref">NStack.ustring</span></td>
  457. <td><span class="parametername">text</span></td>
  458. <td>The text to justify.</td>
  459. </tr>
  460. <tr>
  461. <td><span class="xref">System.Int32</span></td>
  462. <td><span class="parametername">width</span></td>
  463. <td>If the text length is greater that <code>width</code> it will be clipped.</td>
  464. </tr>
  465. <tr>
  466. <td><a class="xref" href="Terminal.Gui.TextAlignment.html">TextAlignment</a></td>
  467. <td><span class="parametername">talign</span></td>
  468. <td>Alignment.</td>
  469. </tr>
  470. </tbody>
  471. </table>
  472. <h5 class="returns">Returns</h5>
  473. <table class="table table-bordered table-striped table-condensed">
  474. <thead>
  475. <tr>
  476. <th>Type</th>
  477. <th>Description</th>
  478. </tr>
  479. </thead>
  480. <tbody>
  481. <tr>
  482. <td><span class="xref">NStack.ustring</span></td>
  483. <td>Justified and clipped text.</td>
  484. </tr>
  485. </tbody>
  486. </table>
  487. <a id="Terminal_Gui_TextFormatter_Draw_" data-uid="Terminal.Gui.TextFormatter.Draw*"></a>
  488. <h4 id="Terminal_Gui_TextFormatter_Draw_Terminal_Gui_Rect_Terminal_Gui_Attribute_Terminal_Gui_Attribute_" data-uid="Terminal.Gui.TextFormatter.Draw(Terminal.Gui.Rect,Terminal.Gui.Attribute,Terminal.Gui.Attribute)">Draw(Rect, Attribute, Attribute)</h4>
  489. <div class="markdown level1 summary">
  490. Draws the text held by <a class="xref" href="Terminal.Gui.TextFormatter.html">TextFormatter</a> to <a class="xref" href="Terminal.Gui.Application.html#Terminal_Gui_Application_Driver">Driver</a> using the colors specified.
  491. </div>
  492. <div class="markdown level1 conceptual"></div>
  493. <h5 class="decalaration">Declaration</h5>
  494. <div class="codewrapper">
  495. <pre><code class="lang-csharp hljs">public void Draw(Rect bounds, Attribute normalColor, Attribute hotColor)</code></pre>
  496. </div>
  497. <h5 class="parameters">Parameters</h5>
  498. <table class="table table-bordered table-striped table-condensed">
  499. <thead>
  500. <tr>
  501. <th>Type</th>
  502. <th>Name</th>
  503. <th>Description</th>
  504. </tr>
  505. </thead>
  506. <tbody>
  507. <tr>
  508. <td><a class="xref" href="Terminal.Gui.Rect.html">Rect</a></td>
  509. <td><span class="parametername">bounds</span></td>
  510. <td>Specifies the screen-relative location and maximum size for drawing the text.</td>
  511. </tr>
  512. <tr>
  513. <td><a class="xref" href="Terminal.Gui.Attribute.html">Attribute</a></td>
  514. <td><span class="parametername">normalColor</span></td>
  515. <td>The color to use for all text except the hotkey</td>
  516. </tr>
  517. <tr>
  518. <td><a class="xref" href="Terminal.Gui.Attribute.html">Attribute</a></td>
  519. <td><span class="parametername">hotColor</span></td>
  520. <td>The color to use to draw the hotkey</td>
  521. </tr>
  522. </tbody>
  523. </table>
  524. <a id="Terminal_Gui_TextFormatter_FindHotKey_" data-uid="Terminal.Gui.TextFormatter.FindHotKey*"></a>
  525. <h4 id="Terminal_Gui_TextFormatter_FindHotKey_NStack_ustring_System_Rune_System_Boolean_System_Int32__Terminal_Gui_Key__" data-uid="Terminal.Gui.TextFormatter.FindHotKey(NStack.ustring,System.Rune,System.Boolean,System.Int32@,Terminal.Gui.Key@)">FindHotKey(ustring, Rune, Boolean, out Int32, out Key)</h4>
  526. <div class="markdown level1 summary">
  527. Finds the hotkey and its location in text.
  528. </div>
  529. <div class="markdown level1 conceptual"></div>
  530. <h5 class="decalaration">Declaration</h5>
  531. <div class="codewrapper">
  532. <pre><code class="lang-csharp hljs">public static bool FindHotKey(ustring text, Rune hotKeySpecifier, bool firstUpperCase, out int hotPos, out Key hotKey)</code></pre>
  533. </div>
  534. <h5 class="parameters">Parameters</h5>
  535. <table class="table table-bordered table-striped table-condensed">
  536. <thead>
  537. <tr>
  538. <th>Type</th>
  539. <th>Name</th>
  540. <th>Description</th>
  541. </tr>
  542. </thead>
  543. <tbody>
  544. <tr>
  545. <td><span class="xref">NStack.ustring</span></td>
  546. <td><span class="parametername">text</span></td>
  547. <td>The text to look in.</td>
  548. </tr>
  549. <tr>
  550. <td><span class="xref">System.Rune</span></td>
  551. <td><span class="parametername">hotKeySpecifier</span></td>
  552. <td>The hotkey specifier (e.g. &apos;_&apos;) to look for.</td>
  553. </tr>
  554. <tr>
  555. <td><span class="xref">System.Boolean</span></td>
  556. <td><span class="parametername">firstUpperCase</span></td>
  557. <td>If <code>true</code> the legacy behavior of identifying the first upper case character as the hotkey will be eanbled.
  558. Regardless of the value of this parameter, <code>hotKeySpecifier</code> takes precidence.</td>
  559. </tr>
  560. <tr>
  561. <td><span class="xref">System.Int32</span></td>
  562. <td><span class="parametername">hotPos</span></td>
  563. <td>Outputs the Rune index into <code>text</code>.</td>
  564. </tr>
  565. <tr>
  566. <td><a class="xref" href="Terminal.Gui.Key.html">Key</a></td>
  567. <td><span class="parametername">hotKey</span></td>
  568. <td>Outputs the hotKey.</td>
  569. </tr>
  570. </tbody>
  571. </table>
  572. <h5 class="returns">Returns</h5>
  573. <table class="table table-bordered table-striped table-condensed">
  574. <thead>
  575. <tr>
  576. <th>Type</th>
  577. <th>Description</th>
  578. </tr>
  579. </thead>
  580. <tbody>
  581. <tr>
  582. <td><span class="xref">System.Boolean</span></td>
  583. <td><code>true</code> if a hotkey was found; <code>false</code> otherwise.</td>
  584. </tr>
  585. </tbody>
  586. </table>
  587. <a id="Terminal_Gui_TextFormatter_Format_" data-uid="Terminal.Gui.TextFormatter.Format*"></a>
  588. <h4 id="Terminal_Gui_TextFormatter_Format_NStack_ustring_System_Int32_Terminal_Gui_TextAlignment_System_Boolean_" data-uid="Terminal.Gui.TextFormatter.Format(NStack.ustring,System.Int32,Terminal.Gui.TextAlignment,System.Boolean)">Format(ustring, Int32, TextAlignment, Boolean)</h4>
  589. <div class="markdown level1 summary">
  590. Reformats text into lines, applying text alignment and optionally wrapping text to new lines on word boundaries.
  591. </div>
  592. <div class="markdown level1 conceptual"></div>
  593. <h5 class="decalaration">Declaration</h5>
  594. <div class="codewrapper">
  595. <pre><code class="lang-csharp hljs">public static List&lt;ustring&gt; Format(ustring text, int width, TextAlignment talign, bool wordWrap)</code></pre>
  596. </div>
  597. <h5 class="parameters">Parameters</h5>
  598. <table class="table table-bordered table-striped table-condensed">
  599. <thead>
  600. <tr>
  601. <th>Type</th>
  602. <th>Name</th>
  603. <th>Description</th>
  604. </tr>
  605. </thead>
  606. <tbody>
  607. <tr>
  608. <td><span class="xref">NStack.ustring</span></td>
  609. <td><span class="parametername">text</span></td>
  610. <td></td>
  611. </tr>
  612. <tr>
  613. <td><span class="xref">System.Int32</span></td>
  614. <td><span class="parametername">width</span></td>
  615. <td>The width to bound the text to for word wrapping and clipping.</td>
  616. </tr>
  617. <tr>
  618. <td><a class="xref" href="Terminal.Gui.TextAlignment.html">TextAlignment</a></td>
  619. <td><span class="parametername">talign</span></td>
  620. <td>Specifies how the text will be aligned horizontally.</td>
  621. </tr>
  622. <tr>
  623. <td><span class="xref">System.Boolean</span></td>
  624. <td><span class="parametername">wordWrap</span></td>
  625. <td>If <code>true</code>, the text will be wrapped to new lines as need. If <code>false</code>, forces text to fit a single line. Line breaks are converted to spaces. The text will be clipped to <code>width</code></td>
  626. </tr>
  627. </tbody>
  628. </table>
  629. <h5 class="returns">Returns</h5>
  630. <table class="table table-bordered table-striped table-condensed">
  631. <thead>
  632. <tr>
  633. <th>Type</th>
  634. <th>Description</th>
  635. </tr>
  636. </thead>
  637. <tbody>
  638. <tr>
  639. <td><span class="xref">System.Collections.Generic.List</span>&lt;<span class="xref">NStack.ustring</span>&gt;</td>
  640. <td>A list of word wrapped lines.</td>
  641. </tr>
  642. </tbody>
  643. </table>
  644. <h5 id="Terminal_Gui_TextFormatter_Format_NStack_ustring_System_Int32_Terminal_Gui_TextAlignment_System_Boolean__remarks">Remarks</h5>
  645. <div class="markdown level1 remarks">
  646. <p>
  647. An empty <code>text</code> string will result in one empty line.
  648. </p>
  649. <p>
  650. If <code>width</code> is 0, a single, empty line will be returned.
  651. </p>
  652. <p>
  653. If <code>width</code> is int.MaxValue, the text will be formatted to the maximum width possible.
  654. </p>
  655. </div>
  656. <a id="Terminal_Gui_TextFormatter_Justify_" data-uid="Terminal.Gui.TextFormatter.Justify*"></a>
  657. <h4 id="Terminal_Gui_TextFormatter_Justify_NStack_ustring_System_Int32_System_Char_" data-uid="Terminal.Gui.TextFormatter.Justify(NStack.ustring,System.Int32,System.Char)">Justify(ustring, Int32, Char)</h4>
  658. <div class="markdown level1 summary">
  659. Justifies the text to fill the width provided. Space will be added between words (demarked by spaces and tabs) to
  660. make the text just fit <code>width</code>. Spaces will not be added to the ends.
  661. </div>
  662. <div class="markdown level1 conceptual"></div>
  663. <h5 class="decalaration">Declaration</h5>
  664. <div class="codewrapper">
  665. <pre><code class="lang-csharp hljs">public static ustring Justify(ustring text, int width, char spaceChar = ' ')</code></pre>
  666. </div>
  667. <h5 class="parameters">Parameters</h5>
  668. <table class="table table-bordered table-striped table-condensed">
  669. <thead>
  670. <tr>
  671. <th>Type</th>
  672. <th>Name</th>
  673. <th>Description</th>
  674. </tr>
  675. </thead>
  676. <tbody>
  677. <tr>
  678. <td><span class="xref">NStack.ustring</span></td>
  679. <td><span class="parametername">text</span></td>
  680. <td></td>
  681. </tr>
  682. <tr>
  683. <td><span class="xref">System.Int32</span></td>
  684. <td><span class="parametername">width</span></td>
  685. <td></td>
  686. </tr>
  687. <tr>
  688. <td><span class="xref">System.Char</span></td>
  689. <td><span class="parametername">spaceChar</span></td>
  690. <td>Character to replace whitespace and pad with. For debugging purposes.</td>
  691. </tr>
  692. </tbody>
  693. </table>
  694. <h5 class="returns">Returns</h5>
  695. <table class="table table-bordered table-striped table-condensed">
  696. <thead>
  697. <tr>
  698. <th>Type</th>
  699. <th>Description</th>
  700. </tr>
  701. </thead>
  702. <tbody>
  703. <tr>
  704. <td><span class="xref">NStack.ustring</span></td>
  705. <td>The justifed text.</td>
  706. </tr>
  707. </tbody>
  708. </table>
  709. <a id="Terminal_Gui_TextFormatter_MaxLines_" data-uid="Terminal.Gui.TextFormatter.MaxLines*"></a>
  710. <h4 id="Terminal_Gui_TextFormatter_MaxLines_NStack_ustring_System_Int32_" data-uid="Terminal.Gui.TextFormatter.MaxLines(NStack.ustring,System.Int32)">MaxLines(ustring, Int32)</h4>
  711. <div class="markdown level1 summary">
  712. Computes the number of lines needed to render the specified text given the width.
  713. </div>
  714. <div class="markdown level1 conceptual"></div>
  715. <h5 class="decalaration">Declaration</h5>
  716. <div class="codewrapper">
  717. <pre><code class="lang-csharp hljs">public static int MaxLines(ustring text, int width)</code></pre>
  718. </div>
  719. <h5 class="parameters">Parameters</h5>
  720. <table class="table table-bordered table-striped table-condensed">
  721. <thead>
  722. <tr>
  723. <th>Type</th>
  724. <th>Name</th>
  725. <th>Description</th>
  726. </tr>
  727. </thead>
  728. <tbody>
  729. <tr>
  730. <td><span class="xref">NStack.ustring</span></td>
  731. <td><span class="parametername">text</span></td>
  732. <td>Text, may contain newlines.</td>
  733. </tr>
  734. <tr>
  735. <td><span class="xref">System.Int32</span></td>
  736. <td><span class="parametername">width</span></td>
  737. <td>The minimum width for the text.</td>
  738. </tr>
  739. </tbody>
  740. </table>
  741. <h5 class="returns">Returns</h5>
  742. <table class="table table-bordered table-striped table-condensed">
  743. <thead>
  744. <tr>
  745. <th>Type</th>
  746. <th>Description</th>
  747. </tr>
  748. </thead>
  749. <tbody>
  750. <tr>
  751. <td><span class="xref">System.Int32</span></td>
  752. <td>Number of lines.</td>
  753. </tr>
  754. </tbody>
  755. </table>
  756. <a id="Terminal_Gui_TextFormatter_MaxWidth_" data-uid="Terminal.Gui.TextFormatter.MaxWidth*"></a>
  757. <h4 id="Terminal_Gui_TextFormatter_MaxWidth_NStack_ustring_System_Int32_" data-uid="Terminal.Gui.TextFormatter.MaxWidth(NStack.ustring,System.Int32)">MaxWidth(ustring, Int32)</h4>
  758. <div class="markdown level1 summary">
  759. Computes the maximum width needed to render the text (single line or multple lines) given a minimum width.
  760. </div>
  761. <div class="markdown level1 conceptual"></div>
  762. <h5 class="decalaration">Declaration</h5>
  763. <div class="codewrapper">
  764. <pre><code class="lang-csharp hljs">public static int MaxWidth(ustring text, int width)</code></pre>
  765. </div>
  766. <h5 class="parameters">Parameters</h5>
  767. <table class="table table-bordered table-striped table-condensed">
  768. <thead>
  769. <tr>
  770. <th>Type</th>
  771. <th>Name</th>
  772. <th>Description</th>
  773. </tr>
  774. </thead>
  775. <tbody>
  776. <tr>
  777. <td><span class="xref">NStack.ustring</span></td>
  778. <td><span class="parametername">text</span></td>
  779. <td>Text, may contain newlines.</td>
  780. </tr>
  781. <tr>
  782. <td><span class="xref">System.Int32</span></td>
  783. <td><span class="parametername">width</span></td>
  784. <td>The minimum width for the text.</td>
  785. </tr>
  786. </tbody>
  787. </table>
  788. <h5 class="returns">Returns</h5>
  789. <table class="table table-bordered table-striped table-condensed">
  790. <thead>
  791. <tr>
  792. <th>Type</th>
  793. <th>Description</th>
  794. </tr>
  795. </thead>
  796. <tbody>
  797. <tr>
  798. <td><span class="xref">System.Int32</span></td>
  799. <td>Max width of lines.</td>
  800. </tr>
  801. </tbody>
  802. </table>
  803. <a id="Terminal_Gui_TextFormatter_RemoveHotKeySpecifier_" data-uid="Terminal.Gui.TextFormatter.RemoveHotKeySpecifier*"></a>
  804. <h4 id="Terminal_Gui_TextFormatter_RemoveHotKeySpecifier_NStack_ustring_System_Int32_System_Rune_" data-uid="Terminal.Gui.TextFormatter.RemoveHotKeySpecifier(NStack.ustring,System.Int32,System.Rune)">RemoveHotKeySpecifier(ustring, Int32, Rune)</h4>
  805. <div class="markdown level1 summary">
  806. Removes the hotkey specifier from text.
  807. </div>
  808. <div class="markdown level1 conceptual"></div>
  809. <h5 class="decalaration">Declaration</h5>
  810. <div class="codewrapper">
  811. <pre><code class="lang-csharp hljs">public static ustring RemoveHotKeySpecifier(ustring text, int hotPos, Rune hotKeySpecifier)</code></pre>
  812. </div>
  813. <h5 class="parameters">Parameters</h5>
  814. <table class="table table-bordered table-striped table-condensed">
  815. <thead>
  816. <tr>
  817. <th>Type</th>
  818. <th>Name</th>
  819. <th>Description</th>
  820. </tr>
  821. </thead>
  822. <tbody>
  823. <tr>
  824. <td><span class="xref">NStack.ustring</span></td>
  825. <td><span class="parametername">text</span></td>
  826. <td>The text to manipulate.</td>
  827. </tr>
  828. <tr>
  829. <td><span class="xref">System.Int32</span></td>
  830. <td><span class="parametername">hotPos</span></td>
  831. <td>Returns the position of the hot-key in the text. -1 if not found.</td>
  832. </tr>
  833. <tr>
  834. <td><span class="xref">System.Rune</span></td>
  835. <td><span class="parametername">hotKeySpecifier</span></td>
  836. <td>The hot-key specifier (e.g. &apos;_&apos;) to look for.</td>
  837. </tr>
  838. </tbody>
  839. </table>
  840. <h5 class="returns">Returns</h5>
  841. <table class="table table-bordered table-striped table-condensed">
  842. <thead>
  843. <tr>
  844. <th>Type</th>
  845. <th>Description</th>
  846. </tr>
  847. </thead>
  848. <tbody>
  849. <tr>
  850. <td><span class="xref">NStack.ustring</span></td>
  851. <td>The input text with the hotkey specifier (&apos;_&apos;) removed.</td>
  852. </tr>
  853. </tbody>
  854. </table>
  855. <a id="Terminal_Gui_TextFormatter_ReplaceHotKeyWithTag_" data-uid="Terminal.Gui.TextFormatter.ReplaceHotKeyWithTag*"></a>
  856. <h4 id="Terminal_Gui_TextFormatter_ReplaceHotKeyWithTag_NStack_ustring_System_Int32_" data-uid="Terminal.Gui.TextFormatter.ReplaceHotKeyWithTag(NStack.ustring,System.Int32)">ReplaceHotKeyWithTag(ustring, Int32)</h4>
  857. <div class="markdown level1 summary">
  858. Replaces the Rune at the index specfiied by the <code>hotPos</code> parameter with a tag identifying
  859. it as the hotkey.
  860. </div>
  861. <div class="markdown level1 conceptual"></div>
  862. <h5 class="decalaration">Declaration</h5>
  863. <div class="codewrapper">
  864. <pre><code class="lang-csharp hljs">public ustring ReplaceHotKeyWithTag(ustring text, int hotPos)</code></pre>
  865. </div>
  866. <h5 class="parameters">Parameters</h5>
  867. <table class="table table-bordered table-striped table-condensed">
  868. <thead>
  869. <tr>
  870. <th>Type</th>
  871. <th>Name</th>
  872. <th>Description</th>
  873. </tr>
  874. </thead>
  875. <tbody>
  876. <tr>
  877. <td><span class="xref">NStack.ustring</span></td>
  878. <td><span class="parametername">text</span></td>
  879. <td>The text to tag the hotkey in.</td>
  880. </tr>
  881. <tr>
  882. <td><span class="xref">System.Int32</span></td>
  883. <td><span class="parametername">hotPos</span></td>
  884. <td>The Rune index of the hotkey in <code>text</code>.</td>
  885. </tr>
  886. </tbody>
  887. </table>
  888. <h5 class="returns">Returns</h5>
  889. <table class="table table-bordered table-striped table-condensed">
  890. <thead>
  891. <tr>
  892. <th>Type</th>
  893. <th>Description</th>
  894. </tr>
  895. </thead>
  896. <tbody>
  897. <tr>
  898. <td><span class="xref">NStack.ustring</span></td>
  899. <td>The text with the hotkey tagged.</td>
  900. </tr>
  901. </tbody>
  902. </table>
  903. <h5 id="Terminal_Gui_TextFormatter_ReplaceHotKeyWithTag_NStack_ustring_System_Int32__remarks">Remarks</h5>
  904. <div class="markdown level1 remarks">
  905. The returned string will not render correctly without first un-doing the tag. To undo the tag, search for
  906. Runes with a bitmask of <code>otKeyTagMask</code> and remove that bitmask.
  907. </div>
  908. <a id="Terminal_Gui_TextFormatter_WordWrap_" data-uid="Terminal.Gui.TextFormatter.WordWrap*"></a>
  909. <h4 id="Terminal_Gui_TextFormatter_WordWrap_NStack_ustring_System_Int32_" data-uid="Terminal.Gui.TextFormatter.WordWrap(NStack.ustring,System.Int32)">WordWrap(ustring, Int32)</h4>
  910. <div class="markdown level1 summary">
  911. Formats the provided text to fit within the width provided using word wrapping.
  912. </div>
  913. <div class="markdown level1 conceptual"></div>
  914. <h5 class="decalaration">Declaration</h5>
  915. <div class="codewrapper">
  916. <pre><code class="lang-csharp hljs">public static List&lt;ustring&gt; WordWrap(ustring text, int width)</code></pre>
  917. </div>
  918. <h5 class="parameters">Parameters</h5>
  919. <table class="table table-bordered table-striped table-condensed">
  920. <thead>
  921. <tr>
  922. <th>Type</th>
  923. <th>Name</th>
  924. <th>Description</th>
  925. </tr>
  926. </thead>
  927. <tbody>
  928. <tr>
  929. <td><span class="xref">NStack.ustring</span></td>
  930. <td><span class="parametername">text</span></td>
  931. <td>The text to word wrap</td>
  932. </tr>
  933. <tr>
  934. <td><span class="xref">System.Int32</span></td>
  935. <td><span class="parametername">width</span></td>
  936. <td>The width to contrain the text to</td>
  937. </tr>
  938. </tbody>
  939. </table>
  940. <h5 class="returns">Returns</h5>
  941. <table class="table table-bordered table-striped table-condensed">
  942. <thead>
  943. <tr>
  944. <th>Type</th>
  945. <th>Description</th>
  946. </tr>
  947. </thead>
  948. <tbody>
  949. <tr>
  950. <td><span class="xref">System.Collections.Generic.List</span>&lt;<span class="xref">NStack.ustring</span>&gt;</td>
  951. <td>Returns a list of word wrapped lines.</td>
  952. </tr>
  953. </tbody>
  954. </table>
  955. <h5 id="Terminal_Gui_TextFormatter_WordWrap_NStack_ustring_System_Int32__remarks">Remarks</h5>
  956. <div class="markdown level1 remarks">
  957. <p>
  958. This method does not do any justification.
  959. </p>
  960. <p>
  961. This method strips Newline (&apos;\n&apos; and &apos;\r\n&apos;) sequences before processing.
  962. </p>
  963. </div>
  964. </article>
  965. </div>
  966. <div class="hidden-sm col-md-2" role="complementary">
  967. <div class="sideaffix">
  968. <div class="contribution">
  969. <ul class="nav">
  970. </ul>
  971. </div>
  972. <nav class="bs-docs-sidebar hidden-print hidden-xs hidden-sm affix" id="affix">
  973. <!-- <p><a class="back-to-top" href="#top">Back to top</a><p> -->
  974. </nav>
  975. </div>
  976. </div>
  977. </div>
  978. </div>
  979. <footer>
  980. <div class="grad-bottom"></div>
  981. <div class="footer">
  982. <div class="container">
  983. <span class="pull-right">
  984. <a href="#top">Back to top</a>
  985. </span>
  986. <span>Generated by <strong>DocFX</strong></span>
  987. </div>
  988. </div>
  989. </footer>
  990. </div>
  991. <script type="text/javascript" src="../../styles/docfx.vendor.js"></script>
  992. <script type="text/javascript" src="../../styles/docfx.js"></script>
  993. <script type="text/javascript" src="../../styles/main.js"></script>
  994. </body>
  995. </html>