ConsoleDriver.cs 43 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337
  1. //
  2. // ConsoleDriver.cs: Definition for the Console Driver API
  3. //
  4. // Authors:
  5. // Miguel de Icaza ([email protected])
  6. //
  7. // Define this to enable diagnostics drawing for Window Frames
  8. using NStack;
  9. using System;
  10. using System.Collections.Generic;
  11. using System.Linq;
  12. using System.Runtime.CompilerServices;
  13. namespace Terminal.Gui {
  14. /// <summary>
  15. /// Basic colors that can be used to set the foreground and background colors in console applications.
  16. /// </summary>
  17. public enum Color {
  18. /// <summary>
  19. /// The black color.
  20. /// </summary>
  21. Black,
  22. /// <summary>
  23. /// The blue color.
  24. /// </summary>
  25. Blue,
  26. /// <summary>
  27. /// The green color.
  28. /// </summary>
  29. Green,
  30. /// <summary>
  31. /// The cyan color.
  32. /// </summary>
  33. Cyan,
  34. /// <summary>
  35. /// The red color.
  36. /// </summary>
  37. Red,
  38. /// <summary>
  39. /// The magenta color.
  40. /// </summary>
  41. Magenta,
  42. /// <summary>
  43. /// The brown color.
  44. /// </summary>
  45. Brown,
  46. /// <summary>
  47. /// The gray color.
  48. /// </summary>
  49. Gray,
  50. /// <summary>
  51. /// The dark gray color.
  52. /// </summary>
  53. DarkGray,
  54. /// <summary>
  55. /// The bright bBlue color.
  56. /// </summary>
  57. BrightBlue,
  58. /// <summary>
  59. /// The bright green color.
  60. /// </summary>
  61. BrightGreen,
  62. /// <summary>
  63. /// The bright cyan color.
  64. /// </summary>
  65. BrightCyan,
  66. /// <summary>
  67. /// The bright red color.
  68. /// </summary>
  69. BrightRed,
  70. /// <summary>
  71. /// The bright magenta color.
  72. /// </summary>
  73. BrightMagenta,
  74. /// <summary>
  75. /// The bright yellow color.
  76. /// </summary>
  77. BrightYellow,
  78. /// <summary>
  79. /// The White color.
  80. /// </summary>
  81. White
  82. }
  83. /// <summary>
  84. /// Attributes are used as elements that contain both a foreground and a background or platform specific features
  85. /// </summary>
  86. /// <remarks>
  87. /// <see cref="Attribute"/>s are needed to map colors to terminal capabilities that might lack colors, on color
  88. /// scenarios, they encode both the foreground and the background color and are used in the <see cref="ColorScheme"/>
  89. /// class to define color schemes that can be used in your application.
  90. /// </remarks>
  91. public struct Attribute {
  92. /// <summary>
  93. /// The color attribute value.
  94. /// </summary>
  95. public int Value { get; }
  96. /// <summary>
  97. /// The foreground color.
  98. /// </summary>
  99. public Color Foreground { get; }
  100. /// <summary>
  101. /// The background color.
  102. /// </summary>
  103. public Color Background { get; }
  104. /// <summary>
  105. /// Initializes a new instance of the <see cref="Attribute"/> struct with only the value passed to
  106. /// and trying to get the colors if defined.
  107. /// </summary>
  108. /// <param name="value">Value.</param>
  109. public Attribute (int value)
  110. {
  111. Color foreground = default;
  112. Color background = default;
  113. if (Application.Driver != null) {
  114. Application.Driver.GetColors (value, out foreground, out background);
  115. }
  116. Value = value;
  117. Foreground = foreground;
  118. Background = background;
  119. }
  120. /// <summary>
  121. /// Initializes a new instance of the <see cref="Attribute"/> struct.
  122. /// </summary>
  123. /// <param name="value">Value.</param>
  124. /// <param name="foreground">Foreground</param>
  125. /// <param name="background">Background</param>
  126. public Attribute (int value, Color foreground, Color background)
  127. {
  128. Value = value;
  129. Foreground = foreground;
  130. Background = background;
  131. }
  132. /// <summary>
  133. /// Initializes a new instance of the <see cref="Attribute"/> struct.
  134. /// </summary>
  135. /// <param name="foreground">Foreground</param>
  136. /// <param name="background">Background</param>
  137. public Attribute (Color foreground = new Color (), Color background = new Color ())
  138. {
  139. Value = Make (foreground, background).Value;
  140. Foreground = foreground;
  141. Background = background;
  142. }
  143. /// <summary>
  144. /// Initializes a new instance of the <see cref="Attribute"/> struct
  145. /// with the same colors for the foreground and background.
  146. /// </summary>
  147. /// <param name="color">The color.</param>
  148. public Attribute (Color color) : this (color, color) { }
  149. /// <summary>
  150. /// Implicit conversion from an <see cref="Attribute"/> to the underlying Int32 representation
  151. /// </summary>
  152. /// <returns>The integer value stored in the attribute.</returns>
  153. /// <param name="c">The attribute to convert</param>
  154. public static implicit operator int (Attribute c) => c.Value;
  155. /// <summary>
  156. /// Implicitly convert an integer value into an <see cref="Attribute"/>
  157. /// </summary>
  158. /// <returns>An attribute with the specified integer value.</returns>
  159. /// <param name="v">value</param>
  160. public static implicit operator Attribute (int v) => new Attribute (v);
  161. /// <summary>
  162. /// Creates an <see cref="Attribute"/> from the specified foreground and background.
  163. /// </summary>
  164. /// <returns>The make.</returns>
  165. /// <param name="foreground">Foreground color to use.</param>
  166. /// <param name="background">Background color to use.</param>
  167. public static Attribute Make (Color foreground, Color background)
  168. {
  169. if (Application.Driver == null)
  170. throw new InvalidOperationException ("The Application has not been initialized");
  171. return Application.Driver.MakeAttribute (foreground, background);
  172. }
  173. /// <summary>
  174. /// Gets the current <see cref="Attribute"/> from the driver.
  175. /// </summary>
  176. /// <returns>The current attribute.</returns>
  177. public static Attribute Get ()
  178. {
  179. if (Application.Driver == null)
  180. throw new InvalidOperationException ("The Application has not been initialized");
  181. return Application.Driver.GetAttribute ();
  182. }
  183. }
  184. /// <summary>
  185. /// Color scheme definitions, they cover some common scenarios and are used
  186. /// typically in containers such as <see cref="Window"/> and <see cref="FrameView"/> to set the scheme that is used by all the
  187. /// views contained inside.
  188. /// </summary>
  189. public class ColorScheme : IEquatable<ColorScheme> {
  190. Attribute _normal;
  191. Attribute _focus;
  192. Attribute _hotNormal;
  193. Attribute _hotFocus;
  194. Attribute _disabled;
  195. internal string caller = "";
  196. /// <summary>
  197. /// The default color for text, when the view is not focused.
  198. /// </summary>
  199. public Attribute Normal { get { return _normal; } set { _normal = SetAttribute (value); } }
  200. /// <summary>
  201. /// The color for text when the view has the focus.
  202. /// </summary>
  203. public Attribute Focus { get { return _focus; } set { _focus = SetAttribute (value); } }
  204. /// <summary>
  205. /// The color for the hotkey when a view is not focused
  206. /// </summary>
  207. public Attribute HotNormal { get { return _hotNormal; } set { _hotNormal = SetAttribute (value); } }
  208. /// <summary>
  209. /// The color for the hotkey when the view is focused.
  210. /// </summary>
  211. public Attribute HotFocus { get { return _hotFocus; } set { _hotFocus = SetAttribute (value); } }
  212. /// <summary>
  213. /// The default color for text, when the view is disabled.
  214. /// </summary>
  215. public Attribute Disabled { get { return _disabled; } set { _disabled = SetAttribute (value); } }
  216. bool preparingScheme = false;
  217. Attribute SetAttribute (Attribute attribute, [CallerMemberName] string callerMemberName = null)
  218. {
  219. if (!Application._initialized && !preparingScheme)
  220. return attribute;
  221. if (preparingScheme)
  222. return attribute;
  223. preparingScheme = true;
  224. switch (caller) {
  225. case "TopLevel":
  226. switch (callerMemberName) {
  227. case "Normal":
  228. HotNormal = Application.Driver.MakeAttribute (HotNormal.Foreground, attribute.Background);
  229. break;
  230. case "Focus":
  231. HotFocus = Application.Driver.MakeAttribute (HotFocus.Foreground, attribute.Background);
  232. break;
  233. case "HotNormal":
  234. HotFocus = Application.Driver.MakeAttribute (attribute.Foreground, HotFocus.Background);
  235. break;
  236. case "HotFocus":
  237. HotNormal = Application.Driver.MakeAttribute (attribute.Foreground, HotNormal.Background);
  238. if (Focus.Foreground != attribute.Background)
  239. Focus = Application.Driver.MakeAttribute (Focus.Foreground, attribute.Background);
  240. break;
  241. }
  242. break;
  243. case "Base":
  244. switch (callerMemberName) {
  245. case "Normal":
  246. HotNormal = Application.Driver.MakeAttribute (HotNormal.Foreground, attribute.Background);
  247. break;
  248. case "Focus":
  249. HotFocus = Application.Driver.MakeAttribute (HotFocus.Foreground, attribute.Background);
  250. break;
  251. case "HotNormal":
  252. HotFocus = Application.Driver.MakeAttribute (attribute.Foreground, HotFocus.Background);
  253. Normal = Application.Driver.MakeAttribute (Normal.Foreground, attribute.Background);
  254. break;
  255. case "HotFocus":
  256. HotNormal = Application.Driver.MakeAttribute (attribute.Foreground, HotNormal.Background);
  257. if (Focus.Foreground != attribute.Background)
  258. Focus = Application.Driver.MakeAttribute (Focus.Foreground, attribute.Background);
  259. break;
  260. }
  261. break;
  262. case "Menu":
  263. switch (callerMemberName) {
  264. case "Normal":
  265. if (Focus.Background != attribute.Background)
  266. Focus = Application.Driver.MakeAttribute (attribute.Foreground, Focus.Background);
  267. HotNormal = Application.Driver.MakeAttribute (HotNormal.Foreground, attribute.Background);
  268. Disabled = Application.Driver.MakeAttribute (Disabled.Foreground, attribute.Background);
  269. break;
  270. case "Focus":
  271. Normal = Application.Driver.MakeAttribute (attribute.Foreground, Normal.Background);
  272. HotFocus = Application.Driver.MakeAttribute (HotFocus.Foreground, attribute.Background);
  273. break;
  274. case "HotNormal":
  275. if (Focus.Background != attribute.Background)
  276. HotFocus = Application.Driver.MakeAttribute (attribute.Foreground, HotFocus.Background);
  277. Normal = Application.Driver.MakeAttribute (Normal.Foreground, attribute.Background);
  278. Disabled = Application.Driver.MakeAttribute (Disabled.Foreground, attribute.Background);
  279. break;
  280. case "HotFocus":
  281. HotNormal = Application.Driver.MakeAttribute (attribute.Foreground, HotNormal.Background);
  282. if (Focus.Foreground != attribute.Background)
  283. Focus = Application.Driver.MakeAttribute (Focus.Foreground, attribute.Background);
  284. break;
  285. case "Disabled":
  286. if (Focus.Background != attribute.Background)
  287. HotFocus = Application.Driver.MakeAttribute (attribute.Foreground, HotFocus.Background);
  288. Normal = Application.Driver.MakeAttribute (Normal.Foreground, attribute.Background);
  289. HotNormal = Application.Driver.MakeAttribute (HotNormal.Foreground, attribute.Background);
  290. break;
  291. }
  292. break;
  293. case "Dialog":
  294. switch (callerMemberName) {
  295. case "Normal":
  296. if (Focus.Background != attribute.Background)
  297. Focus = Application.Driver.MakeAttribute (attribute.Foreground, Focus.Background);
  298. HotNormal = Application.Driver.MakeAttribute (HotNormal.Foreground, attribute.Background);
  299. break;
  300. case "Focus":
  301. Normal = Application.Driver.MakeAttribute (attribute.Foreground, Normal.Background);
  302. HotFocus = Application.Driver.MakeAttribute (HotFocus.Foreground, attribute.Background);
  303. break;
  304. case "HotNormal":
  305. if (Focus.Background != attribute.Background)
  306. HotFocus = Application.Driver.MakeAttribute (attribute.Foreground, HotFocus.Background);
  307. if (Normal.Foreground != attribute.Background)
  308. Normal = Application.Driver.MakeAttribute (Normal.Foreground, attribute.Background);
  309. break;
  310. case "HotFocus":
  311. HotNormal = Application.Driver.MakeAttribute (attribute.Foreground, HotNormal.Background);
  312. if (Focus.Foreground != attribute.Background)
  313. Focus = Application.Driver.MakeAttribute (Focus.Foreground, attribute.Background);
  314. break;
  315. }
  316. break;
  317. case "Error":
  318. switch (callerMemberName) {
  319. case "Normal":
  320. HotNormal = Application.Driver.MakeAttribute (HotNormal.Foreground, attribute.Background);
  321. HotFocus = Application.Driver.MakeAttribute (HotFocus.Foreground, attribute.Background);
  322. break;
  323. case "HotNormal":
  324. case "HotFocus":
  325. HotFocus = Application.Driver.MakeAttribute (attribute.Foreground, attribute.Background);
  326. Normal = Application.Driver.MakeAttribute (Normal.Foreground, attribute.Background);
  327. break;
  328. }
  329. break;
  330. }
  331. preparingScheme = false;
  332. return attribute;
  333. }
  334. /// <summary>
  335. /// Compares two <see cref="ColorScheme"/> objects for equality.
  336. /// </summary>
  337. /// <param name="obj"></param>
  338. /// <returns>true if the two objects are equal</returns>
  339. public override bool Equals (object obj)
  340. {
  341. return Equals (obj as ColorScheme);
  342. }
  343. /// <summary>
  344. /// Compares two <see cref="ColorScheme"/> objects for equality.
  345. /// </summary>
  346. /// <param name="other"></param>
  347. /// <returns>true if the two objects are equal</returns>
  348. public bool Equals (ColorScheme other)
  349. {
  350. return other != null &&
  351. EqualityComparer<Attribute>.Default.Equals (_normal, other._normal) &&
  352. EqualityComparer<Attribute>.Default.Equals (_focus, other._focus) &&
  353. EqualityComparer<Attribute>.Default.Equals (_hotNormal, other._hotNormal) &&
  354. EqualityComparer<Attribute>.Default.Equals (_hotFocus, other._hotFocus) &&
  355. EqualityComparer<Attribute>.Default.Equals (_disabled, other._disabled);
  356. }
  357. /// <summary>
  358. /// Returns a hashcode for this instance.
  359. /// </summary>
  360. /// <returns>hashcode for this instance</returns>
  361. public override int GetHashCode ()
  362. {
  363. int hashCode = -1242460230;
  364. hashCode = hashCode * -1521134295 + _normal.GetHashCode ();
  365. hashCode = hashCode * -1521134295 + _focus.GetHashCode ();
  366. hashCode = hashCode * -1521134295 + _hotNormal.GetHashCode ();
  367. hashCode = hashCode * -1521134295 + _hotFocus.GetHashCode ();
  368. hashCode = hashCode * -1521134295 + _disabled.GetHashCode ();
  369. return hashCode;
  370. }
  371. /// <summary>
  372. /// Compares two <see cref="ColorScheme"/> objects for equality.
  373. /// </summary>
  374. /// <param name="left"></param>
  375. /// <param name="right"></param>
  376. /// <returns><c>true</c> if the two objects are equivalent</returns>
  377. public static bool operator == (ColorScheme left, ColorScheme right)
  378. {
  379. return EqualityComparer<ColorScheme>.Default.Equals (left, right);
  380. }
  381. /// <summary>
  382. /// Compares two <see cref="ColorScheme"/> objects for inequality.
  383. /// </summary>
  384. /// <param name="left"></param>
  385. /// <param name="right"></param>
  386. /// <returns><c>true</c> if the two objects are not equivalent</returns>
  387. public static bool operator != (ColorScheme left, ColorScheme right)
  388. {
  389. return !(left == right);
  390. }
  391. }
  392. /// <summary>
  393. /// The default <see cref="ColorScheme"/>s for the application.
  394. /// </summary>
  395. public static class Colors {
  396. static Colors ()
  397. {
  398. // Use reflection to dynamically create the default set of ColorSchemes from the list defined
  399. // by the class.
  400. ColorSchemes = typeof (Colors).GetProperties ()
  401. .Where (p => p.PropertyType == typeof (ColorScheme))
  402. .Select (p => new KeyValuePair<string, ColorScheme> (p.Name, new ColorScheme ())) // (ColorScheme)p.GetValue (p)))
  403. .ToDictionary (t => t.Key, t => t.Value);
  404. }
  405. /// <summary>
  406. /// The application toplevel color scheme, for the default toplevel views.
  407. /// </summary>
  408. /// <remarks>
  409. /// <para>
  410. /// This API will be deprecated in the future. Use <see cref="Colors.ColorSchemes"/> instead (e.g. <c>edit.ColorScheme = Colors.ColorSchemes["TopLevel"];</c>
  411. /// </para>
  412. /// </remarks>
  413. public static ColorScheme TopLevel { get => GetColorScheme (); set => SetColorScheme (value); }
  414. /// <summary>
  415. /// The base color scheme, for the default toplevel views.
  416. /// </summary>
  417. /// <remarks>
  418. /// <para>
  419. /// This API will be deprecated in the future. Use <see cref="Colors.ColorSchemes"/> instead (e.g. <c>edit.ColorScheme = Colors.ColorSchemes["Base"];</c>
  420. /// </para>
  421. /// </remarks>
  422. public static ColorScheme Base { get => GetColorScheme (); set => SetColorScheme (value); }
  423. /// <summary>
  424. /// The dialog color scheme, for standard popup dialog boxes
  425. /// </summary>
  426. /// <remarks>
  427. /// <para>
  428. /// This API will be deprecated in the future. Use <see cref="Colors.ColorSchemes"/> instead (e.g. <c>edit.ColorScheme = Colors.ColorSchemes["Dialog"];</c>
  429. /// </para>
  430. /// </remarks>
  431. public static ColorScheme Dialog { get => GetColorScheme (); set => SetColorScheme (value); }
  432. /// <summary>
  433. /// The menu bar color
  434. /// </summary>
  435. /// <remarks>
  436. /// <para>
  437. /// This API will be deprecated in the future. Use <see cref="Colors.ColorSchemes"/> instead (e.g. <c>edit.ColorScheme = Colors.ColorSchemes["Menu"];</c>
  438. /// </para>
  439. /// </remarks>
  440. public static ColorScheme Menu { get => GetColorScheme (); set => SetColorScheme (value); }
  441. /// <summary>
  442. /// The color scheme for showing errors.
  443. /// </summary>
  444. /// <remarks>
  445. /// <para>
  446. /// This API will be deprecated in the future. Use <see cref="Colors.ColorSchemes"/> instead (e.g. <c>edit.ColorScheme = Colors.ColorSchemes["Error"];</c>
  447. /// </para>
  448. /// </remarks>
  449. public static ColorScheme Error { get => GetColorScheme (); set => SetColorScheme (value); }
  450. static ColorScheme GetColorScheme ([CallerMemberName] string callerMemberName = null)
  451. {
  452. return ColorSchemes [callerMemberName];
  453. }
  454. static void SetColorScheme (ColorScheme colorScheme, [CallerMemberName] string callerMemberName = null)
  455. {
  456. ColorSchemes [callerMemberName] = colorScheme;
  457. colorScheme.caller = callerMemberName;
  458. }
  459. /// <summary>
  460. /// Provides the defined <see cref="ColorScheme"/>s.
  461. /// </summary>
  462. public static Dictionary<string, ColorScheme> ColorSchemes { get; }
  463. }
  464. /// <summary>
  465. /// Cursors Visibility that are displayed
  466. /// </summary>
  467. //
  468. // Hexa value are set as 0xAABBCCDD where :
  469. //
  470. // AA stand for the TERMINFO DECSUSR parameter value to be used under Linux & MacOS
  471. // BB stand for the NCurses curs_set parameter value to be used under Linux & MacOS
  472. // CC stand for the CONSOLE_CURSOR_INFO.bVisible parameter value to be used under Windows
  473. // DD stand for the CONSOLE_CURSOR_INFO.dwSize parameter value to be used under Windows
  474. //
  475. public enum CursorVisibility {
  476. /// <summary>
  477. /// Cursor caret has default
  478. /// </summary>
  479. /// <remarks>Works under Xterm-like terminal otherwise this is equivalent to <see ref="Underscore"/>. This default directly depends of the XTerm user configuration settings so it could be Block, I-Beam, Underline with possible blinking.</remarks>
  480. Default = 0x00010119,
  481. /// <summary>
  482. /// Cursor caret is hidden
  483. /// </summary>
  484. Invisible = 0x03000019,
  485. /// <summary>
  486. /// Cursor caret is normally shown as a blinking underline bar _
  487. /// </summary>
  488. Underline = 0x03010119,
  489. /// <summary>
  490. /// Cursor caret is normally shown as a underline bar _
  491. /// </summary>
  492. /// <remarks>Under Windows, this is equivalent to <see ref="UnderscoreBlinking"/></remarks>
  493. UnderlineFix = 0x04010119,
  494. /// <summary>
  495. /// Cursor caret is displayed a blinking vertical bar |
  496. /// </summary>
  497. /// <remarks>Works under Xterm-like terminal otherwise this is equivalent to <see ref="Underscore"/></remarks>
  498. Vertical = 0x05010119,
  499. /// <summary>
  500. /// Cursor caret is displayed a blinking vertical bar |
  501. /// </summary>
  502. /// <remarks>Works under Xterm-like terminal otherwise this is equivalent to <see ref="Underscore"/></remarks>
  503. VerticalFix = 0x06010119,
  504. /// <summary>
  505. /// Cursor caret is displayed as a blinking block ▉
  506. /// </summary>
  507. Box = 0x01020164,
  508. /// <summary>
  509. /// Cursor caret is displayed a block ▉
  510. /// </summary>
  511. /// <remarks>Works under Xterm-like terminal otherwise this is equivalent to <see ref="Block"/></remarks>
  512. BoxFix = 0x02020164,
  513. }
  514. ///// <summary>
  515. ///// Special characters that can be drawn with
  516. ///// </summary>
  517. //public enum SpecialChar {
  518. // /// <summary>
  519. // /// Horizontal line character.
  520. // /// </summary>
  521. // HLine,
  522. // /// <summary>
  523. // /// Vertical line character.
  524. // /// </summary>
  525. // VLine,
  526. // /// <summary>
  527. // /// Stipple pattern
  528. // /// </summary>
  529. // Stipple,
  530. // /// <summary>
  531. // /// Diamond character
  532. // /// </summary>
  533. // Diamond,
  534. // /// <summary>
  535. // /// Upper left corner
  536. // /// </summary>
  537. // ULCorner,
  538. // /// <summary>
  539. // /// Lower left corner
  540. // /// </summary>
  541. // LLCorner,
  542. // /// <summary>
  543. // /// Upper right corner
  544. // /// </summary>
  545. // URCorner,
  546. // /// <summary>
  547. // /// Lower right corner
  548. // /// </summary>
  549. // LRCorner,
  550. // /// <summary>
  551. // /// Left tee
  552. // /// </summary>
  553. // LeftTee,
  554. // /// <summary>
  555. // /// Right tee
  556. // /// </summary>
  557. // RightTee,
  558. // /// <summary>
  559. // /// Top tee
  560. // /// </summary>
  561. // TopTee,
  562. // /// <summary>
  563. // /// The bottom tee.
  564. // /// </summary>
  565. // BottomTee,
  566. //}
  567. /// <summary>
  568. /// ConsoleDriver is an abstract class that defines the requirements for a console driver.
  569. /// There are currently three implementations: <see cref="CursesDriver"/> (for Unix and Mac), <see cref="WindowsDriver"/>, and <see cref="NetDriver"/> that uses the .NET Console API.
  570. /// </summary>
  571. public abstract class ConsoleDriver {
  572. /// <summary>
  573. /// The handler fired when the terminal is resized.
  574. /// </summary>
  575. protected Action TerminalResized;
  576. /// <summary>
  577. /// The current number of columns in the terminal.
  578. /// </summary>
  579. public abstract int Cols { get; }
  580. /// <summary>
  581. /// The current number of rows in the terminal.
  582. /// </summary>
  583. public abstract int Rows { get; }
  584. /// <summary>
  585. /// The current left in the terminal.
  586. /// </summary>
  587. public abstract int Left { get; }
  588. /// <summary>
  589. /// The current top in the terminal.
  590. /// </summary>
  591. public abstract int Top { get; }
  592. /// <summary>
  593. /// Get the operation system clipboard.
  594. /// </summary>
  595. public abstract IClipboard Clipboard { get; }
  596. /// <summary>
  597. /// If false height is measured by the window height and thus no scrolling.
  598. /// If true then height is measured by the buffer height, enabling scrolling.
  599. /// </summary>
  600. public abstract bool HeightAsBuffer { get; set; }
  601. /// <summary>
  602. /// The format is rows, columns and 3 values on the last column: Rune, Attribute and Dirty Flag
  603. /// </summary>
  604. public virtual int [,,] Contents { get; }
  605. /// <summary>
  606. /// Initializes the driver
  607. /// </summary>
  608. /// <param name="terminalResized">Method to invoke when the terminal is resized.</param>
  609. public abstract void Init (Action terminalResized);
  610. /// <summary>
  611. /// Moves the cursor to the specified column and row.
  612. /// </summary>
  613. /// <param name="col">Column to move the cursor to.</param>
  614. /// <param name="row">Row to move the cursor to.</param>
  615. public abstract void Move (int col, int row);
  616. /// <summary>
  617. /// Adds the specified rune to the display at the current cursor position
  618. /// </summary>
  619. /// <param name="rune">Rune to add.</param>
  620. public abstract void AddRune (Rune rune);
  621. /// <summary>
  622. /// Ensures a Rune is not a control character and can be displayed by translating characters below 0x20
  623. /// to equivalent, printable, Unicode chars.
  624. /// </summary>
  625. /// <param name="c">Rune to translate</param>
  626. /// <returns></returns>
  627. public static Rune MakePrintable (Rune c)
  628. {
  629. var controlChars = gethexaformat (c, 4);
  630. if (controlChars <= 0x1F || (controlChars >= 0X7F && controlChars <= 0x9F)) {
  631. // ASCII (C0) control characters.
  632. // C1 control characters (https://www.aivosto.com/articles/control-characters.html#c1)
  633. return new Rune (controlChars + 0x2400);
  634. } else {
  635. return c;
  636. }
  637. }
  638. static uint gethexaformat (uint rune, int length)
  639. {
  640. var hex = rune.ToString ($"x{length}");
  641. var hexstr = hex.Substring (hex.Length - length, length);
  642. return (uint)int.Parse (hexstr, System.Globalization.NumberStyles.HexNumber);
  643. }
  644. /// <summary>
  645. /// Ensures that the column and line are in a valid range from the size of the driver.
  646. /// </summary>
  647. /// <param name="col">The column.</param>
  648. /// <param name="row">The row.</param>
  649. /// <param name="clip">The clip.</param>
  650. /// <returns><c>true</c>if it's a valid range,<c>false</c>otherwise.</returns>
  651. public bool IsValidContent (int col, int row, Rect clip) =>
  652. col >= 0 && row >= 0 && col < Cols && row < Rows && clip.Contains (col, row);
  653. /// <summary>
  654. /// Adds the specified
  655. /// </summary>
  656. /// <param name="str">String.</param>
  657. public abstract void AddStr (ustring str);
  658. /// <summary>
  659. /// Prepare the driver and set the key and mouse events handlers.
  660. /// </summary>
  661. /// <param name="mainLoop">The main loop.</param>
  662. /// <param name="keyHandler">The handler for ProcessKey</param>
  663. /// <param name="keyDownHandler">The handler for key down events</param>
  664. /// <param name="keyUpHandler">The handler for key up events</param>
  665. /// <param name="mouseHandler">The handler for mouse events</param>
  666. public abstract void PrepareToRun (MainLoop mainLoop, Action<KeyEvent> keyHandler, Action<KeyEvent> keyDownHandler, Action<KeyEvent> keyUpHandler, Action<MouseEvent> mouseHandler);
  667. /// <summary>
  668. /// Updates the screen to reflect all the changes that have been done to the display buffer
  669. /// </summary>
  670. public abstract void Refresh ();
  671. /// <summary>
  672. /// Updates the location of the cursor position
  673. /// </summary>
  674. public abstract void UpdateCursor ();
  675. /// <summary>
  676. /// Retreive the cursor caret visibility
  677. /// </summary>
  678. /// <param name="visibility">The current <see cref="CursorVisibility"/></param>
  679. /// <returns>true upon success</returns>
  680. public abstract bool GetCursorVisibility (out CursorVisibility visibility);
  681. /// <summary>
  682. /// Change the cursor caret visibility
  683. /// </summary>
  684. /// <param name="visibility">The wished <see cref="CursorVisibility"/></param>
  685. /// <returns>true upon success</returns>
  686. public abstract bool SetCursorVisibility (CursorVisibility visibility);
  687. /// <summary>
  688. /// Ensure the cursor visibility
  689. /// </summary>
  690. /// <returns>true upon success</returns>
  691. public abstract bool EnsureCursorVisibility ();
  692. /// <summary>
  693. /// Ends the execution of the console driver.
  694. /// </summary>
  695. public abstract void End ();
  696. /// <summary>
  697. /// Reset and recreate the contents and the driver buffer.
  698. /// </summary>
  699. public abstract void UpdateOffScreen ();
  700. /// <summary>
  701. /// Redraws the physical screen with the contents that have been queued up via any of the printing commands.
  702. /// </summary>
  703. public abstract void UpdateScreen ();
  704. /// <summary>
  705. /// Selects the specified attribute as the attribute to use for future calls to AddRune, AddString.
  706. /// </summary>
  707. /// <param name="c">C.</param>
  708. public abstract void SetAttribute (Attribute c);
  709. /// <summary>
  710. /// Set Colors from limit sets of colors.
  711. /// </summary>
  712. /// <param name="foreground">Foreground.</param>
  713. /// <param name="background">Background.</param>
  714. public abstract void SetColors (ConsoleColor foreground, ConsoleColor background);
  715. // Advanced uses - set colors to any pre-set pairs, you would need to init_color
  716. // that independently with the R, G, B values.
  717. /// <summary>
  718. /// Advanced uses - set colors to any pre-set pairs, you would need to init_color
  719. /// that independently with the R, G, B values.
  720. /// </summary>
  721. /// <param name="foregroundColorId">Foreground color identifier.</param>
  722. /// <param name="backgroundColorId">Background color identifier.</param>
  723. public abstract void SetColors (short foregroundColorId, short backgroundColorId);
  724. /// <summary>
  725. /// Gets the foreground and background colors based on the value.
  726. /// </summary>
  727. /// <param name="value">The value.</param>
  728. /// <param name="foreground">The foreground.</param>
  729. /// <param name="background">The background.</param>
  730. /// <returns></returns>
  731. public abstract bool GetColors (int value, out Color foreground, out Color background);
  732. /// <summary>
  733. /// Allows sending keys without typing on a keyboard.
  734. /// </summary>
  735. /// <param name="keyChar">The character key.</param>
  736. /// <param name="key">The key.</param>
  737. /// <param name="shift">If shift key is sending.</param>
  738. /// <param name="alt">If alt key is sending.</param>
  739. /// <param name="control">If control key is sending.</param>
  740. public abstract void SendKeys (char keyChar, ConsoleKey key, bool shift, bool alt, bool control);
  741. /// <summary>
  742. /// Set the handler when the terminal is resized.
  743. /// </summary>
  744. /// <param name="terminalResized"></param>
  745. public void SetTerminalResized (Action terminalResized)
  746. {
  747. TerminalResized = terminalResized;
  748. }
  749. /// <summary>
  750. /// Draws the title for a Window-style view incorporating padding.
  751. /// </summary>
  752. /// <param name="region">Screen relative region where the frame will be drawn.</param>
  753. /// <param name="title">The title for the window. The title will only be drawn if <c>title</c> is not null or empty and paddingTop is greater than 0.</param>
  754. /// <param name="paddingLeft">Number of columns to pad on the left (if 0 the border will not appear on the left).</param>
  755. /// <param name="paddingTop">Number of rows to pad on the top (if 0 the border and title will not appear on the top).</param>
  756. /// <param name="paddingRight">Number of columns to pad on the right (if 0 the border will not appear on the right).</param>
  757. /// <param name="paddingBottom">Number of rows to pad on the bottom (if 0 the border will not appear on the bottom).</param>
  758. /// <param name="textAlignment">Not yet implemented.</param>
  759. /// <remarks></remarks>
  760. public virtual void DrawWindowTitle (Rect region, ustring title, int paddingLeft, int paddingTop, int paddingRight, int paddingBottom, TextAlignment textAlignment = TextAlignment.Left)
  761. {
  762. var width = region.Width - (paddingLeft + 2) * 2;
  763. if (!ustring.IsNullOrEmpty (title) && width > 4 && region.Y + paddingTop <= region.Y + paddingBottom) {
  764. Move (region.X + 1 + paddingLeft, region.Y + paddingTop);
  765. AddRune (' ');
  766. var str = title.Sum (r => Math.Max (Rune.ColumnWidth (r), 1)) >= width
  767. ? TextFormatter.Format (title, width - 2, false, false) [0] : title;
  768. AddStr (str);
  769. AddRune (' ');
  770. }
  771. }
  772. /// <summary>
  773. /// Enables diagnostic functions
  774. /// </summary>
  775. [Flags]
  776. public enum DiagnosticFlags : uint {
  777. /// <summary>
  778. /// All diagnostics off
  779. /// </summary>
  780. Off = 0b_0000_0000,
  781. /// <summary>
  782. /// When enabled, <see cref="DrawWindowFrame(Rect, int, int, int, int, bool, bool, Border)"/> will draw a
  783. /// ruler in the frame for any side with a padding value greater than 0.
  784. /// </summary>
  785. FrameRuler = 0b_0000_0001,
  786. /// <summary>
  787. /// When Enabled, <see cref="DrawWindowFrame(Rect, int, int, int, int, bool, bool, Border)"/> will use
  788. /// 'L', 'R', 'T', and 'B' for padding instead of ' '.
  789. /// </summary>
  790. FramePadding = 0b_0000_0010,
  791. }
  792. /// <summary>
  793. /// Set flags to enable/disable <see cref="ConsoleDriver"/> diagnostics.
  794. /// </summary>
  795. public static DiagnosticFlags Diagnostics { get; set; }
  796. /// <summary>
  797. /// Draws a frame for a window with padding and an optional visible border inside the padding.
  798. /// </summary>
  799. /// <param name="region">Screen relative region where the frame will be drawn.</param>
  800. /// <param name="paddingLeft">Number of columns to pad on the left (if 0 the border will not appear on the left).</param>
  801. /// <param name="paddingTop">Number of rows to pad on the top (if 0 the border and title will not appear on the top).</param>
  802. /// <param name="paddingRight">Number of columns to pad on the right (if 0 the border will not appear on the right).</param>
  803. /// <param name="paddingBottom">Number of rows to pad on the bottom (if 0 the border will not appear on the bottom).</param>
  804. /// <param name="border">If set to <c>true</c> and any padding dimension is > 0 the border will be drawn.</param>
  805. /// <param name="fill">If set to <c>true</c> it will clear the content area (the area inside the padding) with the current color, otherwise the content area will be left untouched.</param>
  806. /// <param name="borderContent">The <see cref="Border"/> to be used if defined.</param>
  807. public virtual void DrawWindowFrame (Rect region, int paddingLeft = 0, int paddingTop = 0, int paddingRight = 0,
  808. int paddingBottom = 0, bool border = true, bool fill = false, Border borderContent = null)
  809. {
  810. char clearChar = ' ';
  811. char leftChar = clearChar;
  812. char rightChar = clearChar;
  813. char topChar = clearChar;
  814. char bottomChar = clearChar;
  815. if ((Diagnostics & DiagnosticFlags.FramePadding) == DiagnosticFlags.FramePadding) {
  816. leftChar = 'L';
  817. rightChar = 'R';
  818. topChar = 'T';
  819. bottomChar = 'B';
  820. clearChar = 'C';
  821. }
  822. void AddRuneAt (int col, int row, Rune ch)
  823. {
  824. Move (col, row);
  825. AddRune (ch);
  826. }
  827. // fwidth is count of hLine chars
  828. int fwidth = (int)(region.Width - (paddingRight + paddingLeft));
  829. // fheight is count of vLine chars
  830. int fheight = (int)(region.Height - (paddingBottom + paddingTop));
  831. // fleft is location of left frame line
  832. int fleft = region.X + paddingLeft - 1;
  833. // fright is location of right frame line
  834. int fright = fleft + fwidth + 1;
  835. // ftop is location of top frame line
  836. int ftop = region.Y + paddingTop - 1;
  837. // fbottom is location of bottom frame line
  838. int fbottom = ftop + fheight + 1;
  839. var borderStyle = borderContent == null ? BorderStyle.Single : borderContent.BorderStyle;
  840. Rune hLine = default, vLine = default,
  841. uRCorner = default, uLCorner = default, lLCorner = default, lRCorner = default;
  842. if (border) {
  843. switch (borderStyle) {
  844. case BorderStyle.None:
  845. break;
  846. case BorderStyle.Single:
  847. hLine = HLine;
  848. vLine = VLine;
  849. uRCorner = URCorner;
  850. uLCorner = ULCorner;
  851. lLCorner = LLCorner;
  852. lRCorner = LRCorner;
  853. break;
  854. case BorderStyle.Double:
  855. hLine = HDLine;
  856. vLine = VDLine;
  857. uRCorner = URDCorner;
  858. uLCorner = ULDCorner;
  859. lLCorner = LLDCorner;
  860. lRCorner = LRDCorner;
  861. break;
  862. case BorderStyle.Rounded:
  863. hLine = HRLine;
  864. vLine = VRLine;
  865. uRCorner = URRCorner;
  866. uLCorner = ULRCorner;
  867. lLCorner = LLRCorner;
  868. lRCorner = LRRCorner;
  869. break;
  870. }
  871. } else {
  872. hLine = vLine = uRCorner = uLCorner = lLCorner = lRCorner = clearChar;
  873. }
  874. // Outside top
  875. if (paddingTop > 1) {
  876. for (int r = region.Y; r < ftop; r++) {
  877. for (int c = region.X; c < region.X + region.Width; c++) {
  878. AddRuneAt (c, r, topChar);
  879. }
  880. }
  881. }
  882. // Outside top-left
  883. for (int c = region.X; c < fleft; c++) {
  884. AddRuneAt (c, ftop, leftChar);
  885. }
  886. // Frame top-left corner
  887. AddRuneAt (fleft, ftop, paddingTop >= 0 ? (paddingLeft >= 0 ? uLCorner : hLine) : leftChar);
  888. // Frame top
  889. for (int c = fleft + 1; c < fleft + 1 + fwidth; c++) {
  890. AddRuneAt (c, ftop, paddingTop > 0 ? hLine : topChar);
  891. }
  892. // Frame top-right corner
  893. if (fright > fleft) {
  894. AddRuneAt (fright, ftop, paddingTop >= 0 ? (paddingRight >= 0 ? uRCorner : hLine) : rightChar);
  895. }
  896. // Outside top-right corner
  897. for (int c = fright + 1; c < fright + paddingRight; c++) {
  898. AddRuneAt (c, ftop, rightChar);
  899. }
  900. // Left, Fill, Right
  901. if (fbottom > ftop) {
  902. for (int r = ftop + 1; r < fbottom; r++) {
  903. // Outside left
  904. for (int c = region.X; c < fleft; c++) {
  905. AddRuneAt (c, r, leftChar);
  906. }
  907. // Frame left
  908. AddRuneAt (fleft, r, paddingLeft > 0 ? vLine : leftChar);
  909. // Fill
  910. if (fill) {
  911. for (int x = fleft + 1; x < fright; x++) {
  912. AddRuneAt (x, r, clearChar);
  913. }
  914. }
  915. // Frame right
  916. if (fright > fleft) {
  917. var v = vLine;
  918. if ((Diagnostics & DiagnosticFlags.FrameRuler) == DiagnosticFlags.FrameRuler) {
  919. v = (char)(((int)'0') + ((r - ftop) % 10)); // vLine;
  920. }
  921. AddRuneAt (fright, r, paddingRight > 0 ? v : rightChar);
  922. }
  923. // Outside right
  924. for (int c = fright + 1; c < fright + paddingRight; c++) {
  925. AddRuneAt (c, r, rightChar);
  926. }
  927. }
  928. // Outside Bottom
  929. for (int c = region.X; c < region.X + region.Width; c++) {
  930. AddRuneAt (c, fbottom, leftChar);
  931. }
  932. // Frame bottom-left
  933. AddRuneAt (fleft, fbottom, paddingLeft > 0 ? lLCorner : leftChar);
  934. if (fright > fleft) {
  935. // Frame bottom
  936. for (int c = fleft + 1; c < fright; c++) {
  937. var h = hLine;
  938. if ((Diagnostics & DiagnosticFlags.FrameRuler) == DiagnosticFlags.FrameRuler) {
  939. h = (char)(((int)'0') + ((c - fleft) % 10)); // hLine;
  940. }
  941. AddRuneAt (c, fbottom, paddingBottom > 0 ? h : bottomChar);
  942. }
  943. // Frame bottom-right
  944. AddRuneAt (fright, fbottom, paddingRight > 0 ? (paddingBottom > 0 ? lRCorner : hLine) : rightChar);
  945. }
  946. // Outside right
  947. for (int c = fright + 1; c < fright + paddingRight; c++) {
  948. AddRuneAt (c, fbottom, rightChar);
  949. }
  950. }
  951. // Out bottom - ensure top is always drawn if we overlap
  952. if (paddingBottom > 0) {
  953. for (int r = fbottom + 1; r < fbottom + paddingBottom; r++) {
  954. for (int c = region.X; c < region.X + region.Width; c++) {
  955. AddRuneAt (c, r, bottomChar);
  956. }
  957. }
  958. }
  959. }
  960. /// <summary>
  961. /// Draws a frame on the specified region with the specified padding around the frame.
  962. /// </summary>
  963. /// <param name="region">Screen relative region where the frame will be drawn.</param>
  964. /// <param name="padding">Padding to add on the sides.</param>
  965. /// <param name="fill">If set to <c>true</c> it will clear the contents with the current color, otherwise the contents will be left untouched.</param>
  966. /// <remarks>This API has been superseded by <see cref="DrawWindowFrame(Rect, int, int, int, int, bool, bool, Border)"/>.</remarks>
  967. /// <remarks>This API is equivalent to calling <c>DrawWindowFrame(Rect, p - 1, p - 1, p - 1, p - 1)</c>. In other words,
  968. /// A padding value of 0 means there is actually a one cell border.
  969. /// </remarks>
  970. public virtual void DrawFrame (Rect region, int padding, bool fill)
  971. {
  972. // DrawFrame assumes the border is always at least one row/col thick
  973. // DrawWindowFrame assumes a padding of 0 means NO padding and no frame
  974. DrawWindowFrame (new Rect (region.X, region.Y, region.Width, region.Height),
  975. padding + 1, padding + 1, padding + 1, padding + 1, border: false, fill: fill);
  976. }
  977. /// <summary>
  978. /// Suspend the application, typically needs to save the state, suspend the app and upon return, reset the console driver.
  979. /// </summary>
  980. public abstract void Suspend ();
  981. Rect clip;
  982. /// <summary>
  983. /// Controls the current clipping region that AddRune/AddStr is subject to.
  984. /// </summary>
  985. /// <value>The clip.</value>
  986. public Rect Clip {
  987. get => clip;
  988. set => this.clip = value;
  989. }
  990. /// <summary>
  991. /// Start of mouse moves.
  992. /// </summary>
  993. public abstract void StartReportingMouseMoves ();
  994. /// <summary>
  995. /// Stop reporting mouses moves.
  996. /// </summary>
  997. public abstract void StopReportingMouseMoves ();
  998. /// <summary>
  999. /// Disables the cooked event processing from the mouse driver. At startup, it is assumed mouse events are cooked.
  1000. /// </summary>
  1001. public abstract void UncookMouse ();
  1002. /// <summary>
  1003. /// Enables the cooked event processing from the mouse driver
  1004. /// </summary>
  1005. public abstract void CookMouse ();
  1006. /// <summary>
  1007. /// Horizontal line character.
  1008. /// </summary>
  1009. public Rune HLine = '\u2500';
  1010. /// <summary>
  1011. /// Vertical line character.
  1012. /// </summary>
  1013. public Rune VLine = '\u2502';
  1014. /// <summary>
  1015. /// Stipple pattern
  1016. /// </summary>
  1017. public Rune Stipple = '\u2591';
  1018. /// <summary>
  1019. /// Diamond character
  1020. /// </summary>
  1021. public Rune Diamond = '\u25ca';
  1022. /// <summary>
  1023. /// Upper left corner
  1024. /// </summary>
  1025. public Rune ULCorner = '\u250C';
  1026. /// <summary>
  1027. /// Lower left corner
  1028. /// </summary>
  1029. public Rune LLCorner = '\u2514';
  1030. /// <summary>
  1031. /// Upper right corner
  1032. /// </summary>
  1033. public Rune URCorner = '\u2510';
  1034. /// <summary>
  1035. /// Lower right corner
  1036. /// </summary>
  1037. public Rune LRCorner = '\u2518';
  1038. /// <summary>
  1039. /// Left tee
  1040. /// </summary>
  1041. public Rune LeftTee = '\u251c';
  1042. /// <summary>
  1043. /// Right tee
  1044. /// </summary>
  1045. public Rune RightTee = '\u2524';
  1046. /// <summary>
  1047. /// Top tee
  1048. /// </summary>
  1049. public Rune TopTee = '\u252c';
  1050. /// <summary>
  1051. /// The bottom tee.
  1052. /// </summary>
  1053. public Rune BottomTee = '\u2534';
  1054. /// <summary>
  1055. /// Checkmark.
  1056. /// </summary>
  1057. public Rune Checked = '\u221a';
  1058. /// <summary>
  1059. /// Un-checked checkmark.
  1060. /// </summary>
  1061. public Rune UnChecked = '\u2574';
  1062. /// <summary>
  1063. /// Selected mark.
  1064. /// </summary>
  1065. public Rune Selected = '\u25cf';
  1066. /// <summary>
  1067. /// Un-selected selected mark.
  1068. /// </summary>
  1069. public Rune UnSelected = '\u25cc';
  1070. /// <summary>
  1071. /// Right Arrow.
  1072. /// </summary>
  1073. public Rune RightArrow = '\u25ba';
  1074. /// <summary>
  1075. /// Left Arrow.
  1076. /// </summary>
  1077. public Rune LeftArrow = '\u25c4';
  1078. /// <summary>
  1079. /// Down Arrow.
  1080. /// </summary>
  1081. public Rune DownArrow = '\u25bc';
  1082. /// <summary>
  1083. /// Up Arrow.
  1084. /// </summary>
  1085. public Rune UpArrow = '\u25b2';
  1086. /// <summary>
  1087. /// Left indicator for default action (e.g. for <see cref="Button"/>).
  1088. /// </summary>
  1089. public Rune LeftDefaultIndicator = '\u25e6';
  1090. /// <summary>
  1091. /// Right indicator for default action (e.g. for <see cref="Button"/>).
  1092. /// </summary>
  1093. public Rune RightDefaultIndicator = '\u25e6';
  1094. /// <summary>
  1095. /// Left frame/bracket (e.g. '[' for <see cref="Button"/>).
  1096. /// </summary>
  1097. public Rune LeftBracket = '[';
  1098. /// <summary>
  1099. /// Right frame/bracket (e.g. ']' for <see cref="Button"/>).
  1100. /// </summary>
  1101. public Rune RightBracket = ']';
  1102. /// <summary>
  1103. /// Blocks Segment indicator for meter views (e.g. <see cref="ProgressBar"/>.
  1104. /// </summary>
  1105. public Rune BlocksMeterSegment = '\u258c';
  1106. /// <summary>
  1107. /// Continuous Segment indicator for meter views (e.g. <see cref="ProgressBar"/>.
  1108. /// </summary>
  1109. public Rune ContinuousMeterSegment = '\u2588';
  1110. /// <summary>
  1111. /// Horizontal double line character.
  1112. /// </summary>
  1113. public Rune HDLine = '\u2550';
  1114. /// <summary>
  1115. /// Vertical double line character.
  1116. /// </summary>
  1117. public Rune VDLine = '\u2551';
  1118. /// <summary>
  1119. /// Upper left double corner
  1120. /// </summary>
  1121. public Rune ULDCorner = '\u2554';
  1122. /// <summary>
  1123. /// Lower left double corner
  1124. /// </summary>
  1125. public Rune LLDCorner = '\u255a';
  1126. /// <summary>
  1127. /// Upper right double corner
  1128. /// </summary>
  1129. public Rune URDCorner = '\u2557';
  1130. /// <summary>
  1131. /// Lower right double corner
  1132. /// </summary>
  1133. public Rune LRDCorner = '\u255d';
  1134. /// <summary>
  1135. /// Horizontal line character for rounded corners.
  1136. /// </summary>
  1137. public Rune HRLine = '\u2500';
  1138. /// <summary>
  1139. /// Vertical line character for rounded corners.
  1140. /// </summary>
  1141. public Rune VRLine = '\u2502';
  1142. /// <summary>
  1143. /// Upper left rounded corner
  1144. /// </summary>
  1145. public Rune ULRCorner = '\u256d';
  1146. /// <summary>
  1147. /// Lower left rounded corner
  1148. /// </summary>
  1149. public Rune LLRCorner = '\u2570';
  1150. /// <summary>
  1151. /// Upper right rounded corner
  1152. /// </summary>
  1153. public Rune URRCorner = '\u256e';
  1154. /// <summary>
  1155. /// Lower right rounded corner
  1156. /// </summary>
  1157. public Rune LRRCorner = '\u256f';
  1158. /// <summary>
  1159. /// Make the attribute for the foreground and background colors.
  1160. /// </summary>
  1161. /// <param name="fore">Foreground.</param>
  1162. /// <param name="back">Background.</param>
  1163. /// <returns></returns>
  1164. public abstract Attribute MakeAttribute (Color fore, Color back);
  1165. /// <summary>
  1166. /// Gets the current <see cref="Attribute"/>.
  1167. /// </summary>
  1168. /// <returns>The current attribute.</returns>
  1169. public abstract Attribute GetAttribute ();
  1170. }
  1171. }