Terminal.Gui.TextFormatter.html 37 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025
  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.1.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_HotKey_" data-uid="Terminal.Gui.TextFormatter.HotKey*"></a>
  142. <h4 id="Terminal_Gui_TextFormatter_HotKey" data-uid="Terminal.Gui.TextFormatter.HotKey">HotKey</h4>
  143. <div class="markdown level1 summary">
  144. Gets the hotkey. Will be an upper case letter or digit.
  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 Key HotKey { get; }</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><a class="xref" href="Terminal.Gui.Key.html">Key</a></td>
  162. <td></td>
  163. </tr>
  164. </tbody>
  165. </table>
  166. <a id="Terminal_Gui_TextFormatter_HotKeyPos_" data-uid="Terminal.Gui.TextFormatter.HotKeyPos*"></a>
  167. <h4 id="Terminal_Gui_TextFormatter_HotKeyPos" data-uid="Terminal.Gui.TextFormatter.HotKeyPos">HotKeyPos</h4>
  168. <div class="markdown level1 summary">
  169. The position in the text of the hotkey. The hotkey will be rendered using the hot color.
  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 int HotKeyPos { get; set; }</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><span class="xref">System.Int32</span></td>
  187. <td></td>
  188. </tr>
  189. </tbody>
  190. </table>
  191. <a id="Terminal_Gui_TextFormatter_HotKeySpecifier_" data-uid="Terminal.Gui.TextFormatter.HotKeySpecifier*"></a>
  192. <h4 id="Terminal_Gui_TextFormatter_HotKeySpecifier" data-uid="Terminal.Gui.TextFormatter.HotKeySpecifier">HotKeySpecifier</h4>
  193. <div class="markdown level1 summary">
  194. 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;.
  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 Rune HotKeySpecifier { 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.Rune</span></td>
  212. <td></td>
  213. </tr>
  214. </tbody>
  215. </table>
  216. <a id="Terminal_Gui_TextFormatter_HotKeyTagMask_" data-uid="Terminal.Gui.TextFormatter.HotKeyTagMask*"></a>
  217. <h4 id="Terminal_Gui_TextFormatter_HotKeyTagMask" data-uid="Terminal.Gui.TextFormatter.HotKeyTagMask">HotKeyTagMask</h4>
  218. <div class="markdown level1 summary">
  219. Specifies the mask to apply to the hotkey to tag it as the hotkey. The default value of <code>0x100000</code> causes
  220. the underlying Rune to be identified as a &quot;private use&quot; Unicode character.
  221. </div>
  222. <div class="markdown level1 conceptual"></div>
  223. <h5 class="decalaration">Declaration</h5>
  224. <div class="codewrapper">
  225. <pre><code class="lang-csharp hljs">public uint HotKeyTagMask { get; set; }</code></pre>
  226. </div>
  227. <h5 class="propertyValue">Property Value</h5>
  228. <table class="table table-bordered table-striped table-condensed">
  229. <thead>
  230. <tr>
  231. <th>Type</th>
  232. <th>Description</th>
  233. </tr>
  234. </thead>
  235. <tbody>
  236. <tr>
  237. <td><span class="xref">System.UInt32</span></td>
  238. <td></td>
  239. </tr>
  240. </tbody>
  241. </table>
  242. <a id="Terminal_Gui_TextFormatter_Lines_" data-uid="Terminal.Gui.TextFormatter.Lines*"></a>
  243. <h4 id="Terminal_Gui_TextFormatter_Lines" data-uid="Terminal.Gui.TextFormatter.Lines">Lines</h4>
  244. <div class="markdown level1 summary">
  245. Gets the formatted lines.
  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 List&lt;ustring&gt; Lines { get; }</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.Collections.Generic.List</span>&lt;<span class="xref">NStack.ustring</span>&gt;</td>
  263. <td></td>
  264. </tr>
  265. </tbody>
  266. </table>
  267. <h5 id="Terminal_Gui_TextFormatter_Lines_remarks">Remarks</h5>
  268. <div class="markdown level1 remarks">
  269. <p>
  270. 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>)
  271. <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.
  272. </p>
  273. </div>
  274. <a id="Terminal_Gui_TextFormatter_NeedsFormat_" data-uid="Terminal.Gui.TextFormatter.NeedsFormat*"></a>
  275. <h4 id="Terminal_Gui_TextFormatter_NeedsFormat" data-uid="Terminal.Gui.TextFormatter.NeedsFormat">NeedsFormat</h4>
  276. <div class="markdown level1 summary">
  277. 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.
  278. If it is <code>false</code> when Draw is called, the Draw call will be faster.
  279. </div>
  280. <div class="markdown level1 conceptual"></div>
  281. <h5 class="decalaration">Declaration</h5>
  282. <div class="codewrapper">
  283. <pre><code class="lang-csharp hljs">public bool NeedsFormat { get; set; }</code></pre>
  284. </div>
  285. <h5 class="propertyValue">Property Value</h5>
  286. <table class="table table-bordered table-striped table-condensed">
  287. <thead>
  288. <tr>
  289. <th>Type</th>
  290. <th>Description</th>
  291. </tr>
  292. </thead>
  293. <tbody>
  294. <tr>
  295. <td><span class="xref">System.Boolean</span></td>
  296. <td></td>
  297. </tr>
  298. </tbody>
  299. </table>
  300. <h5 id="Terminal_Gui_TextFormatter_NeedsFormat_remarks">Remarks</h5>
  301. <div class="markdown level1 remarks">
  302. <p>
  303. This is set to true when the properties of <a class="xref" href="Terminal.Gui.TextFormatter.html">TextFormatter</a> are set.
  304. </p>
  305. </div>
  306. <a id="Terminal_Gui_TextFormatter_Size_" data-uid="Terminal.Gui.TextFormatter.Size*"></a>
  307. <h4 id="Terminal_Gui_TextFormatter_Size" data-uid="Terminal.Gui.TextFormatter.Size">Size</h4>
  308. <div class="markdown level1 summary">
  309. Gets or sets the size of the area the text will be constrainted to when formatted.
  310. </div>
  311. <div class="markdown level1 conceptual"></div>
  312. <h5 class="decalaration">Declaration</h5>
  313. <div class="codewrapper">
  314. <pre><code class="lang-csharp hljs">public Size Size { get; set; }</code></pre>
  315. </div>
  316. <h5 class="propertyValue">Property Value</h5>
  317. <table class="table table-bordered table-striped table-condensed">
  318. <thead>
  319. <tr>
  320. <th>Type</th>
  321. <th>Description</th>
  322. </tr>
  323. </thead>
  324. <tbody>
  325. <tr>
  326. <td><a class="xref" href="Terminal.Gui.Size.html">Size</a></td>
  327. <td></td>
  328. </tr>
  329. </tbody>
  330. </table>
  331. <a id="Terminal_Gui_TextFormatter_Text_" data-uid="Terminal.Gui.TextFormatter.Text*"></a>
  332. <h4 id="Terminal_Gui_TextFormatter_Text" data-uid="Terminal.Gui.TextFormatter.Text">Text</h4>
  333. <div class="markdown level1 summary">
  334. The text to be displayed. This text is never modified.
  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 virtual ustring Text { 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><span class="xref">NStack.ustring</span></td>
  352. <td></td>
  353. </tr>
  354. </tbody>
  355. </table>
  356. <h3 id="methods">Methods
  357. </h3>
  358. <a id="Terminal_Gui_TextFormatter_CalcRect_" data-uid="Terminal.Gui.TextFormatter.CalcRect*"></a>
  359. <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>
  360. <div class="markdown level1 summary">
  361. Calculates the rectangle required to hold text, assuming no word wrapping.
  362. </div>
  363. <div class="markdown level1 conceptual"></div>
  364. <h5 class="decalaration">Declaration</h5>
  365. <div class="codewrapper">
  366. <pre><code class="lang-csharp hljs">public static Rect CalcRect(int x, int y, ustring text)</code></pre>
  367. </div>
  368. <h5 class="parameters">Parameters</h5>
  369. <table class="table table-bordered table-striped table-condensed">
  370. <thead>
  371. <tr>
  372. <th>Type</th>
  373. <th>Name</th>
  374. <th>Description</th>
  375. </tr>
  376. </thead>
  377. <tbody>
  378. <tr>
  379. <td><span class="xref">System.Int32</span></td>
  380. <td><span class="parametername">x</span></td>
  381. <td>The x location of the rectangle</td>
  382. </tr>
  383. <tr>
  384. <td><span class="xref">System.Int32</span></td>
  385. <td><span class="parametername">y</span></td>
  386. <td>The y location of the rectangle</td>
  387. </tr>
  388. <tr>
  389. <td><span class="xref">NStack.ustring</span></td>
  390. <td><span class="parametername">text</span></td>
  391. <td>The text to measure</td>
  392. </tr>
  393. </tbody>
  394. </table>
  395. <h5 class="returns">Returns</h5>
  396. <table class="table table-bordered table-striped table-condensed">
  397. <thead>
  398. <tr>
  399. <th>Type</th>
  400. <th>Description</th>
  401. </tr>
  402. </thead>
  403. <tbody>
  404. <tr>
  405. <td><a class="xref" href="Terminal.Gui.Rect.html">Rect</a></td>
  406. <td></td>
  407. </tr>
  408. </tbody>
  409. </table>
  410. <a id="Terminal_Gui_TextFormatter_ClipAndJustify_" data-uid="Terminal.Gui.TextFormatter.ClipAndJustify*"></a>
  411. <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>
  412. <div class="markdown level1 summary">
  413. Justifies text within a specified width.
  414. </div>
  415. <div class="markdown level1 conceptual"></div>
  416. <h5 class="decalaration">Declaration</h5>
  417. <div class="codewrapper">
  418. <pre><code class="lang-csharp hljs">public static ustring ClipAndJustify(ustring text, int width, TextAlignment talign)</code></pre>
  419. </div>
  420. <h5 class="parameters">Parameters</h5>
  421. <table class="table table-bordered table-striped table-condensed">
  422. <thead>
  423. <tr>
  424. <th>Type</th>
  425. <th>Name</th>
  426. <th>Description</th>
  427. </tr>
  428. </thead>
  429. <tbody>
  430. <tr>
  431. <td><span class="xref">NStack.ustring</span></td>
  432. <td><span class="parametername">text</span></td>
  433. <td>The text to justify.</td>
  434. </tr>
  435. <tr>
  436. <td><span class="xref">System.Int32</span></td>
  437. <td><span class="parametername">width</span></td>
  438. <td>If the text length is greater that <code>width</code> it will be clipped.</td>
  439. </tr>
  440. <tr>
  441. <td><a class="xref" href="Terminal.Gui.TextAlignment.html">TextAlignment</a></td>
  442. <td><span class="parametername">talign</span></td>
  443. <td>Alignment.</td>
  444. </tr>
  445. </tbody>
  446. </table>
  447. <h5 class="returns">Returns</h5>
  448. <table class="table table-bordered table-striped table-condensed">
  449. <thead>
  450. <tr>
  451. <th>Type</th>
  452. <th>Description</th>
  453. </tr>
  454. </thead>
  455. <tbody>
  456. <tr>
  457. <td><span class="xref">NStack.ustring</span></td>
  458. <td>Justified and clipped text.</td>
  459. </tr>
  460. </tbody>
  461. </table>
  462. <a id="Terminal_Gui_TextFormatter_Draw_" data-uid="Terminal.Gui.TextFormatter.Draw*"></a>
  463. <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>
  464. <div class="markdown level1 summary">
  465. 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.
  466. </div>
  467. <div class="markdown level1 conceptual"></div>
  468. <h5 class="decalaration">Declaration</h5>
  469. <div class="codewrapper">
  470. <pre><code class="lang-csharp hljs">public void Draw(Rect bounds, Attribute normalColor, Attribute hotColor)</code></pre>
  471. </div>
  472. <h5 class="parameters">Parameters</h5>
  473. <table class="table table-bordered table-striped table-condensed">
  474. <thead>
  475. <tr>
  476. <th>Type</th>
  477. <th>Name</th>
  478. <th>Description</th>
  479. </tr>
  480. </thead>
  481. <tbody>
  482. <tr>
  483. <td><a class="xref" href="Terminal.Gui.Rect.html">Rect</a></td>
  484. <td><span class="parametername">bounds</span></td>
  485. <td>Specifies the screen-relative location and maximum size for drawing the text.</td>
  486. </tr>
  487. <tr>
  488. <td><a class="xref" href="Terminal.Gui.Attribute.html">Attribute</a></td>
  489. <td><span class="parametername">normalColor</span></td>
  490. <td>The color to use for all text except the hotkey</td>
  491. </tr>
  492. <tr>
  493. <td><a class="xref" href="Terminal.Gui.Attribute.html">Attribute</a></td>
  494. <td><span class="parametername">hotColor</span></td>
  495. <td>The color to use to draw the hotkey</td>
  496. </tr>
  497. </tbody>
  498. </table>
  499. <a id="Terminal_Gui_TextFormatter_FindHotKey_" data-uid="Terminal.Gui.TextFormatter.FindHotKey*"></a>
  500. <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>
  501. <div class="markdown level1 summary">
  502. Finds the hotkey and its location in text.
  503. </div>
  504. <div class="markdown level1 conceptual"></div>
  505. <h5 class="decalaration">Declaration</h5>
  506. <div class="codewrapper">
  507. <pre><code class="lang-csharp hljs">public static bool FindHotKey(ustring text, Rune hotKeySpecifier, bool firstUpperCase, out int hotPos, out Key hotKey)</code></pre>
  508. </div>
  509. <h5 class="parameters">Parameters</h5>
  510. <table class="table table-bordered table-striped table-condensed">
  511. <thead>
  512. <tr>
  513. <th>Type</th>
  514. <th>Name</th>
  515. <th>Description</th>
  516. </tr>
  517. </thead>
  518. <tbody>
  519. <tr>
  520. <td><span class="xref">NStack.ustring</span></td>
  521. <td><span class="parametername">text</span></td>
  522. <td>The text to look in.</td>
  523. </tr>
  524. <tr>
  525. <td><span class="xref">System.Rune</span></td>
  526. <td><span class="parametername">hotKeySpecifier</span></td>
  527. <td>The hotkey specifier (e.g. &apos;_&apos;) to look for.</td>
  528. </tr>
  529. <tr>
  530. <td><span class="xref">System.Boolean</span></td>
  531. <td><span class="parametername">firstUpperCase</span></td>
  532. <td>If <code>true</code> the legacy behavior of identifying the first upper case character as the hotkey will be eanbled.
  533. Regardless of the value of this parameter, <code>hotKeySpecifier</code> takes precidence.</td>
  534. </tr>
  535. <tr>
  536. <td><span class="xref">System.Int32</span></td>
  537. <td><span class="parametername">hotPos</span></td>
  538. <td>Outputs the Rune index into <code>text</code>.</td>
  539. </tr>
  540. <tr>
  541. <td><a class="xref" href="Terminal.Gui.Key.html">Key</a></td>
  542. <td><span class="parametername">hotKey</span></td>
  543. <td>Outputs the hotKey.</td>
  544. </tr>
  545. </tbody>
  546. </table>
  547. <h5 class="returns">Returns</h5>
  548. <table class="table table-bordered table-striped table-condensed">
  549. <thead>
  550. <tr>
  551. <th>Type</th>
  552. <th>Description</th>
  553. </tr>
  554. </thead>
  555. <tbody>
  556. <tr>
  557. <td><span class="xref">System.Boolean</span></td>
  558. <td><code>true</code> if a hotkey was found; <code>false</code> otherwise.</td>
  559. </tr>
  560. </tbody>
  561. </table>
  562. <a id="Terminal_Gui_TextFormatter_Format_" data-uid="Terminal.Gui.TextFormatter.Format*"></a>
  563. <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>
  564. <div class="markdown level1 summary">
  565. Reformats text into lines, applying text alignment and optionally wrapping text to new lines on word boundaries.
  566. </div>
  567. <div class="markdown level1 conceptual"></div>
  568. <h5 class="decalaration">Declaration</h5>
  569. <div class="codewrapper">
  570. <pre><code class="lang-csharp hljs">public static List&lt;ustring&gt; Format(ustring text, int width, TextAlignment talign, bool wordWrap)</code></pre>
  571. </div>
  572. <h5 class="parameters">Parameters</h5>
  573. <table class="table table-bordered table-striped table-condensed">
  574. <thead>
  575. <tr>
  576. <th>Type</th>
  577. <th>Name</th>
  578. <th>Description</th>
  579. </tr>
  580. </thead>
  581. <tbody>
  582. <tr>
  583. <td><span class="xref">NStack.ustring</span></td>
  584. <td><span class="parametername">text</span></td>
  585. <td></td>
  586. </tr>
  587. <tr>
  588. <td><span class="xref">System.Int32</span></td>
  589. <td><span class="parametername">width</span></td>
  590. <td>The width to bound the text to for word wrapping and clipping.</td>
  591. </tr>
  592. <tr>
  593. <td><a class="xref" href="Terminal.Gui.TextAlignment.html">TextAlignment</a></td>
  594. <td><span class="parametername">talign</span></td>
  595. <td>Specifies how the text will be aligned horizontally.</td>
  596. </tr>
  597. <tr>
  598. <td><span class="xref">System.Boolean</span></td>
  599. <td><span class="parametername">wordWrap</span></td>
  600. <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>
  601. </tr>
  602. </tbody>
  603. </table>
  604. <h5 class="returns">Returns</h5>
  605. <table class="table table-bordered table-striped table-condensed">
  606. <thead>
  607. <tr>
  608. <th>Type</th>
  609. <th>Description</th>
  610. </tr>
  611. </thead>
  612. <tbody>
  613. <tr>
  614. <td><span class="xref">System.Collections.Generic.List</span>&lt;<span class="xref">NStack.ustring</span>&gt;</td>
  615. <td>A list of word wrapped lines.</td>
  616. </tr>
  617. </tbody>
  618. </table>
  619. <h5 id="Terminal_Gui_TextFormatter_Format_NStack_ustring_System_Int32_Terminal_Gui_TextAlignment_System_Boolean__remarks">Remarks</h5>
  620. <div class="markdown level1 remarks">
  621. <p>
  622. An empty <code>text</code> string will result in one empty line.
  623. </p>
  624. <p>
  625. If <code>width</code> is 0, a single, empty line will be returned.
  626. </p>
  627. <p>
  628. If <code>width</code> is int.MaxValue, the text will be formatted to the maximum width possible.
  629. </p>
  630. </div>
  631. <a id="Terminal_Gui_TextFormatter_Justify_" data-uid="Terminal.Gui.TextFormatter.Justify*"></a>
  632. <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>
  633. <div class="markdown level1 summary">
  634. Justifies the text to fill the width provided. Space will be added between words (demarked by spaces and tabs) to
  635. make the text just fit <code>width</code>. Spaces will not be added to the ends.
  636. </div>
  637. <div class="markdown level1 conceptual"></div>
  638. <h5 class="decalaration">Declaration</h5>
  639. <div class="codewrapper">
  640. <pre><code class="lang-csharp hljs">public static ustring Justify(ustring text, int width, char spaceChar = ' ')</code></pre>
  641. </div>
  642. <h5 class="parameters">Parameters</h5>
  643. <table class="table table-bordered table-striped table-condensed">
  644. <thead>
  645. <tr>
  646. <th>Type</th>
  647. <th>Name</th>
  648. <th>Description</th>
  649. </tr>
  650. </thead>
  651. <tbody>
  652. <tr>
  653. <td><span class="xref">NStack.ustring</span></td>
  654. <td><span class="parametername">text</span></td>
  655. <td></td>
  656. </tr>
  657. <tr>
  658. <td><span class="xref">System.Int32</span></td>
  659. <td><span class="parametername">width</span></td>
  660. <td></td>
  661. </tr>
  662. <tr>
  663. <td><span class="xref">System.Char</span></td>
  664. <td><span class="parametername">spaceChar</span></td>
  665. <td>Character to replace whitespace and pad with. For debugging purposes.</td>
  666. </tr>
  667. </tbody>
  668. </table>
  669. <h5 class="returns">Returns</h5>
  670. <table class="table table-bordered table-striped table-condensed">
  671. <thead>
  672. <tr>
  673. <th>Type</th>
  674. <th>Description</th>
  675. </tr>
  676. </thead>
  677. <tbody>
  678. <tr>
  679. <td><span class="xref">NStack.ustring</span></td>
  680. <td>The justifed text.</td>
  681. </tr>
  682. </tbody>
  683. </table>
  684. <a id="Terminal_Gui_TextFormatter_MaxLines_" data-uid="Terminal.Gui.TextFormatter.MaxLines*"></a>
  685. <h4 id="Terminal_Gui_TextFormatter_MaxLines_NStack_ustring_System_Int32_" data-uid="Terminal.Gui.TextFormatter.MaxLines(NStack.ustring,System.Int32)">MaxLines(ustring, Int32)</h4>
  686. <div class="markdown level1 summary">
  687. Computes the number of lines needed to render the specified text given the width.
  688. </div>
  689. <div class="markdown level1 conceptual"></div>
  690. <h5 class="decalaration">Declaration</h5>
  691. <div class="codewrapper">
  692. <pre><code class="lang-csharp hljs">public static int MaxLines(ustring text, int width)</code></pre>
  693. </div>
  694. <h5 class="parameters">Parameters</h5>
  695. <table class="table table-bordered table-striped table-condensed">
  696. <thead>
  697. <tr>
  698. <th>Type</th>
  699. <th>Name</th>
  700. <th>Description</th>
  701. </tr>
  702. </thead>
  703. <tbody>
  704. <tr>
  705. <td><span class="xref">NStack.ustring</span></td>
  706. <td><span class="parametername">text</span></td>
  707. <td>Text, may contain newlines.</td>
  708. </tr>
  709. <tr>
  710. <td><span class="xref">System.Int32</span></td>
  711. <td><span class="parametername">width</span></td>
  712. <td>The minimum width for the text.</td>
  713. </tr>
  714. </tbody>
  715. </table>
  716. <h5 class="returns">Returns</h5>
  717. <table class="table table-bordered table-striped table-condensed">
  718. <thead>
  719. <tr>
  720. <th>Type</th>
  721. <th>Description</th>
  722. </tr>
  723. </thead>
  724. <tbody>
  725. <tr>
  726. <td><span class="xref">System.Int32</span></td>
  727. <td>Number of lines.</td>
  728. </tr>
  729. </tbody>
  730. </table>
  731. <a id="Terminal_Gui_TextFormatter_MaxWidth_" data-uid="Terminal.Gui.TextFormatter.MaxWidth*"></a>
  732. <h4 id="Terminal_Gui_TextFormatter_MaxWidth_NStack_ustring_System_Int32_" data-uid="Terminal.Gui.TextFormatter.MaxWidth(NStack.ustring,System.Int32)">MaxWidth(ustring, Int32)</h4>
  733. <div class="markdown level1 summary">
  734. Computes the maximum width needed to render the text (single line or multple lines) given a minimum width.
  735. </div>
  736. <div class="markdown level1 conceptual"></div>
  737. <h5 class="decalaration">Declaration</h5>
  738. <div class="codewrapper">
  739. <pre><code class="lang-csharp hljs">public static int MaxWidth(ustring text, int width)</code></pre>
  740. </div>
  741. <h5 class="parameters">Parameters</h5>
  742. <table class="table table-bordered table-striped table-condensed">
  743. <thead>
  744. <tr>
  745. <th>Type</th>
  746. <th>Name</th>
  747. <th>Description</th>
  748. </tr>
  749. </thead>
  750. <tbody>
  751. <tr>
  752. <td><span class="xref">NStack.ustring</span></td>
  753. <td><span class="parametername">text</span></td>
  754. <td>Text, may contain newlines.</td>
  755. </tr>
  756. <tr>
  757. <td><span class="xref">System.Int32</span></td>
  758. <td><span class="parametername">width</span></td>
  759. <td>The minimum width for the text.</td>
  760. </tr>
  761. </tbody>
  762. </table>
  763. <h5 class="returns">Returns</h5>
  764. <table class="table table-bordered table-striped table-condensed">
  765. <thead>
  766. <tr>
  767. <th>Type</th>
  768. <th>Description</th>
  769. </tr>
  770. </thead>
  771. <tbody>
  772. <tr>
  773. <td><span class="xref">System.Int32</span></td>
  774. <td>Max width of lines.</td>
  775. </tr>
  776. </tbody>
  777. </table>
  778. <a id="Terminal_Gui_TextFormatter_RemoveHotKeySpecifier_" data-uid="Terminal.Gui.TextFormatter.RemoveHotKeySpecifier*"></a>
  779. <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>
  780. <div class="markdown level1 summary">
  781. Removes the hotkey specifier from text.
  782. </div>
  783. <div class="markdown level1 conceptual"></div>
  784. <h5 class="decalaration">Declaration</h5>
  785. <div class="codewrapper">
  786. <pre><code class="lang-csharp hljs">public static ustring RemoveHotKeySpecifier(ustring text, int hotPos, Rune hotKeySpecifier)</code></pre>
  787. </div>
  788. <h5 class="parameters">Parameters</h5>
  789. <table class="table table-bordered table-striped table-condensed">
  790. <thead>
  791. <tr>
  792. <th>Type</th>
  793. <th>Name</th>
  794. <th>Description</th>
  795. </tr>
  796. </thead>
  797. <tbody>
  798. <tr>
  799. <td><span class="xref">NStack.ustring</span></td>
  800. <td><span class="parametername">text</span></td>
  801. <td>The text to manipulate.</td>
  802. </tr>
  803. <tr>
  804. <td><span class="xref">System.Int32</span></td>
  805. <td><span class="parametername">hotPos</span></td>
  806. <td>Returns the position of the hot-key in the text. -1 if not found.</td>
  807. </tr>
  808. <tr>
  809. <td><span class="xref">System.Rune</span></td>
  810. <td><span class="parametername">hotKeySpecifier</span></td>
  811. <td>The hot-key specifier (e.g. &apos;_&apos;) to look for.</td>
  812. </tr>
  813. </tbody>
  814. </table>
  815. <h5 class="returns">Returns</h5>
  816. <table class="table table-bordered table-striped table-condensed">
  817. <thead>
  818. <tr>
  819. <th>Type</th>
  820. <th>Description</th>
  821. </tr>
  822. </thead>
  823. <tbody>
  824. <tr>
  825. <td><span class="xref">NStack.ustring</span></td>
  826. <td>The input text with the hotkey specifier (&apos;_&apos;) removed.</td>
  827. </tr>
  828. </tbody>
  829. </table>
  830. <a id="Terminal_Gui_TextFormatter_ReplaceHotKeyWithTag_" data-uid="Terminal.Gui.TextFormatter.ReplaceHotKeyWithTag*"></a>
  831. <h4 id="Terminal_Gui_TextFormatter_ReplaceHotKeyWithTag_NStack_ustring_System_Int32_" data-uid="Terminal.Gui.TextFormatter.ReplaceHotKeyWithTag(NStack.ustring,System.Int32)">ReplaceHotKeyWithTag(ustring, Int32)</h4>
  832. <div class="markdown level1 summary">
  833. Replaces the Rune at the index specfiied by the <code>hotPos</code> parameter with a tag identifying
  834. it as the hotkey.
  835. </div>
  836. <div class="markdown level1 conceptual"></div>
  837. <h5 class="decalaration">Declaration</h5>
  838. <div class="codewrapper">
  839. <pre><code class="lang-csharp hljs">public ustring ReplaceHotKeyWithTag(ustring text, int hotPos)</code></pre>
  840. </div>
  841. <h5 class="parameters">Parameters</h5>
  842. <table class="table table-bordered table-striped table-condensed">
  843. <thead>
  844. <tr>
  845. <th>Type</th>
  846. <th>Name</th>
  847. <th>Description</th>
  848. </tr>
  849. </thead>
  850. <tbody>
  851. <tr>
  852. <td><span class="xref">NStack.ustring</span></td>
  853. <td><span class="parametername">text</span></td>
  854. <td>The text to tag the hotkey in.</td>
  855. </tr>
  856. <tr>
  857. <td><span class="xref">System.Int32</span></td>
  858. <td><span class="parametername">hotPos</span></td>
  859. <td>The Rune index of the hotkey in <code>text</code>.</td>
  860. </tr>
  861. </tbody>
  862. </table>
  863. <h5 class="returns">Returns</h5>
  864. <table class="table table-bordered table-striped table-condensed">
  865. <thead>
  866. <tr>
  867. <th>Type</th>
  868. <th>Description</th>
  869. </tr>
  870. </thead>
  871. <tbody>
  872. <tr>
  873. <td><span class="xref">NStack.ustring</span></td>
  874. <td>The text with the hotkey tagged.</td>
  875. </tr>
  876. </tbody>
  877. </table>
  878. <h5 id="Terminal_Gui_TextFormatter_ReplaceHotKeyWithTag_NStack_ustring_System_Int32__remarks">Remarks</h5>
  879. <div class="markdown level1 remarks">
  880. The returned string will not render correctly without first un-doing the tag. To undo the tag, search for
  881. Runes with a bitmask of <code>otKeyTagMask</code> and remove that bitmask.
  882. </div>
  883. <a id="Terminal_Gui_TextFormatter_WordWrap_" data-uid="Terminal.Gui.TextFormatter.WordWrap*"></a>
  884. <h4 id="Terminal_Gui_TextFormatter_WordWrap_NStack_ustring_System_Int32_" data-uid="Terminal.Gui.TextFormatter.WordWrap(NStack.ustring,System.Int32)">WordWrap(ustring, Int32)</h4>
  885. <div class="markdown level1 summary">
  886. Formats the provided text to fit within the width provided using word wrapping.
  887. </div>
  888. <div class="markdown level1 conceptual"></div>
  889. <h5 class="decalaration">Declaration</h5>
  890. <div class="codewrapper">
  891. <pre><code class="lang-csharp hljs">public static List&lt;ustring&gt; WordWrap(ustring text, int width)</code></pre>
  892. </div>
  893. <h5 class="parameters">Parameters</h5>
  894. <table class="table table-bordered table-striped table-condensed">
  895. <thead>
  896. <tr>
  897. <th>Type</th>
  898. <th>Name</th>
  899. <th>Description</th>
  900. </tr>
  901. </thead>
  902. <tbody>
  903. <tr>
  904. <td><span class="xref">NStack.ustring</span></td>
  905. <td><span class="parametername">text</span></td>
  906. <td>The text to word wrap</td>
  907. </tr>
  908. <tr>
  909. <td><span class="xref">System.Int32</span></td>
  910. <td><span class="parametername">width</span></td>
  911. <td>The width to contrain the text to</td>
  912. </tr>
  913. </tbody>
  914. </table>
  915. <h5 class="returns">Returns</h5>
  916. <table class="table table-bordered table-striped table-condensed">
  917. <thead>
  918. <tr>
  919. <th>Type</th>
  920. <th>Description</th>
  921. </tr>
  922. </thead>
  923. <tbody>
  924. <tr>
  925. <td><span class="xref">System.Collections.Generic.List</span>&lt;<span class="xref">NStack.ustring</span>&gt;</td>
  926. <td>Returns a list of word wrapped lines.</td>
  927. </tr>
  928. </tbody>
  929. </table>
  930. <h5 id="Terminal_Gui_TextFormatter_WordWrap_NStack_ustring_System_Int32__remarks">Remarks</h5>
  931. <div class="markdown level1 remarks">
  932. <p>
  933. This method does not do any justification.
  934. </p>
  935. <p>
  936. This method strips Newline (&apos;\n&apos; and &apos;\r\n&apos;) sequences before processing.
  937. </p>
  938. </div>
  939. </article>
  940. </div>
  941. <div class="hidden-sm col-md-2" role="complementary">
  942. <div class="sideaffix">
  943. <div class="contribution">
  944. <ul class="nav">
  945. </ul>
  946. </div>
  947. <nav class="bs-docs-sidebar hidden-print hidden-xs hidden-sm affix" id="affix">
  948. <!-- <p><a class="back-to-top" href="#top">Back to top</a><p> -->
  949. </nav>
  950. </div>
  951. </div>
  952. </div>
  953. </div>
  954. <footer>
  955. <div class="grad-bottom"></div>
  956. <div class="footer">
  957. <div class="container">
  958. <span class="pull-right">
  959. <a href="#top">Back to top</a>
  960. </span>
  961. <span>Generated by <strong>DocFX</strong></span>
  962. </div>
  963. </div>
  964. </footer>
  965. </div>
  966. <script type="text/javascript" src="../../styles/docfx.vendor.js"></script>
  967. <script type="text/javascript" src="../../styles/docfx.js"></script>
  968. <script type="text/javascript" src="../../styles/main.js"></script>
  969. </body>
  970. </html>