ConsoleDriver.cs 41 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252
  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. // The format is rows, columns and 3 values on the last column: Rune, Attribute and Dirty Flag
  602. internal abstract int [,,] Contents { get; }
  603. /// <summary>
  604. /// Initializes the driver
  605. /// </summary>
  606. /// <param name="terminalResized">Method to invoke when the terminal is resized.</param>
  607. public abstract void Init (Action terminalResized);
  608. /// <summary>
  609. /// Moves the cursor to the specified column and row.
  610. /// </summary>
  611. /// <param name="col">Column to move the cursor to.</param>
  612. /// <param name="row">Row to move the cursor to.</param>
  613. public abstract void Move (int col, int row);
  614. /// <summary>
  615. /// Adds the specified rune to the display at the current cursor position
  616. /// </summary>
  617. /// <param name="rune">Rune to add.</param>
  618. public abstract void AddRune (Rune rune);
  619. /// <summary>
  620. /// Ensures a Rune is not a control character and can be displayed by translating characters below 0x20
  621. /// to equivalent, printable, Unicode chars.
  622. /// </summary>
  623. /// <param name="c">Rune to translate</param>
  624. /// <returns></returns>
  625. public static Rune MakePrintable (Rune c)
  626. {
  627. if (c <= 0x1F || (c >= 0x80 && c <= 0x9F)) {
  628. // ASCII (C0) control characters.
  629. // C1 control characters (https://www.aivosto.com/articles/control-characters.html#c1)
  630. return new Rune (c + 0x2400);
  631. } else {
  632. return c;
  633. }
  634. }
  635. /// <summary>
  636. /// Adds the specified
  637. /// </summary>
  638. /// <param name="str">String.</param>
  639. public abstract void AddStr (ustring str);
  640. /// <summary>
  641. /// Prepare the driver and set the key and mouse events handlers.
  642. /// </summary>
  643. /// <param name="mainLoop">The main loop.</param>
  644. /// <param name="keyHandler">The handler for ProcessKey</param>
  645. /// <param name="keyDownHandler">The handler for key down events</param>
  646. /// <param name="keyUpHandler">The handler for key up events</param>
  647. /// <param name="mouseHandler">The handler for mouse events</param>
  648. public abstract void PrepareToRun (MainLoop mainLoop, Action<KeyEvent> keyHandler, Action<KeyEvent> keyDownHandler, Action<KeyEvent> keyUpHandler, Action<MouseEvent> mouseHandler);
  649. /// <summary>
  650. /// Updates the screen to reflect all the changes that have been done to the display buffer
  651. /// </summary>
  652. public abstract void Refresh ();
  653. /// <summary>
  654. /// Updates the location of the cursor position
  655. /// </summary>
  656. public abstract void UpdateCursor ();
  657. /// <summary>
  658. /// Retreive the cursor caret visibility
  659. /// </summary>
  660. /// <param name="visibility">The current <see cref="CursorVisibility"/></param>
  661. /// <returns>true upon success</returns>
  662. public abstract bool GetCursorVisibility (out CursorVisibility visibility);
  663. /// <summary>
  664. /// Change the cursor caret visibility
  665. /// </summary>
  666. /// <param name="visibility">The wished <see cref="CursorVisibility"/></param>
  667. /// <returns>true upon success</returns>
  668. public abstract bool SetCursorVisibility (CursorVisibility visibility);
  669. /// <summary>
  670. /// Ensure the cursor visibility
  671. /// </summary>
  672. /// <returns>true upon success</returns>
  673. public abstract bool EnsureCursorVisibility ();
  674. /// <summary>
  675. /// Ends the execution of the console driver.
  676. /// </summary>
  677. public abstract void End ();
  678. /// <summary>
  679. /// Redraws the physical screen with the contents that have been queued up via any of the printing commands.
  680. /// </summary>
  681. public abstract void UpdateScreen ();
  682. /// <summary>
  683. /// Selects the specified attribute as the attribute to use for future calls to AddRune, AddString.
  684. /// </summary>
  685. /// <param name="c">C.</param>
  686. public abstract void SetAttribute (Attribute c);
  687. /// <summary>
  688. /// Set Colors from limit sets of colors.
  689. /// </summary>
  690. /// <param name="foreground">Foreground.</param>
  691. /// <param name="background">Background.</param>
  692. public abstract void SetColors (ConsoleColor foreground, ConsoleColor background);
  693. // Advanced uses - set colors to any pre-set pairs, you would need to init_color
  694. // that independently with the R, G, B values.
  695. /// <summary>
  696. /// Advanced uses - set colors to any pre-set pairs, you would need to init_color
  697. /// that independently with the R, G, B values.
  698. /// </summary>
  699. /// <param name="foregroundColorId">Foreground color identifier.</param>
  700. /// <param name="backgroundColorId">Background color identifier.</param>
  701. public abstract void SetColors (short foregroundColorId, short backgroundColorId);
  702. /// <summary>
  703. /// Gets the foreground and background colors based on the value.
  704. /// </summary>
  705. /// <param name="value">The value.</param>
  706. /// <param name="foreground">The foreground.</param>
  707. /// <param name="background">The background.</param>
  708. /// <returns></returns>
  709. public abstract bool GetColors (int value, out Color foreground, out Color background);
  710. /// <summary>
  711. /// Allows sending keys without typing on a keyboard.
  712. /// </summary>
  713. /// <param name="keyChar">The character key.</param>
  714. /// <param name="key">The key.</param>
  715. /// <param name="shift">If shift key is sending.</param>
  716. /// <param name="alt">If alt key is sending.</param>
  717. /// <param name="control">If control key is sending.</param>
  718. public abstract void SendKeys (char keyChar, ConsoleKey key, bool shift, bool alt, bool control);
  719. /// <summary>
  720. /// Set the handler when the terminal is resized.
  721. /// </summary>
  722. /// <param name="terminalResized"></param>
  723. public void SetTerminalResized (Action terminalResized)
  724. {
  725. TerminalResized = terminalResized;
  726. }
  727. /// <summary>
  728. /// Draws the title for a Window-style view incorporating padding.
  729. /// </summary>
  730. /// <param name="region">Screen relative region where the frame will be drawn.</param>
  731. /// <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>
  732. /// <param name="paddingLeft">Number of columns to pad on the left (if 0 the border will not appear on the left).</param>
  733. /// <param name="paddingTop">Number of rows to pad on the top (if 0 the border and title will not appear on the top).</param>
  734. /// <param name="paddingRight">Number of columns to pad on the right (if 0 the border will not appear on the right).</param>
  735. /// <param name="paddingBottom">Number of rows to pad on the bottom (if 0 the border will not appear on the bottom).</param>
  736. /// <param name="textAlignment">Not yet implemented.</param>
  737. /// <remarks></remarks>
  738. public virtual void DrawWindowTitle (Rect region, ustring title, int paddingLeft, int paddingTop, int paddingRight, int paddingBottom, TextAlignment textAlignment = TextAlignment.Left)
  739. {
  740. var width = region.Width - (paddingLeft + 2) * 2;
  741. if (!ustring.IsNullOrEmpty (title) && width > 4 && region.Y + paddingTop <= region.Y + paddingBottom) {
  742. Move (region.X + 1 + paddingLeft, region.Y + paddingTop);
  743. AddRune (' ');
  744. var str = title.RuneCount >= width ? title [0, width - 2] : title;
  745. AddStr (str);
  746. AddRune (' ');
  747. }
  748. }
  749. /// <summary>
  750. /// Enables diagnostic functions
  751. /// </summary>
  752. [Flags]
  753. public enum DiagnosticFlags : uint {
  754. /// <summary>
  755. /// All diagnostics off
  756. /// </summary>
  757. Off = 0b_0000_0000,
  758. /// <summary>
  759. /// When enabled, <see cref="DrawWindowFrame(Rect, int, int, int, int, bool, bool, Border)"/> will draw a
  760. /// ruler in the frame for any side with a padding value greater than 0.
  761. /// </summary>
  762. FrameRuler = 0b_0000_0001,
  763. /// <summary>
  764. /// When Enabled, <see cref="DrawWindowFrame(Rect, int, int, int, int, bool, bool, Border)"/> will use
  765. /// 'L', 'R', 'T', and 'B' for padding instead of ' '.
  766. /// </summary>
  767. FramePadding = 0b_0000_0010,
  768. }
  769. /// <summary>
  770. /// Set flags to enable/disable <see cref="ConsoleDriver"/> diagnostics.
  771. /// </summary>
  772. public static DiagnosticFlags Diagnostics { get; set; }
  773. /// <summary>
  774. /// Draws a frame for a window with padding and an optional visible border inside the padding.
  775. /// </summary>
  776. /// <param name="region">Screen relative region where the frame will be drawn.</param>
  777. /// <param name="paddingLeft">Number of columns to pad on the left (if 0 the border will not appear on the left).</param>
  778. /// <param name="paddingTop">Number of rows to pad on the top (if 0 the border and title will not appear on the top).</param>
  779. /// <param name="paddingRight">Number of columns to pad on the right (if 0 the border will not appear on the right).</param>
  780. /// <param name="paddingBottom">Number of rows to pad on the bottom (if 0 the border will not appear on the bottom).</param>
  781. /// <param name="border">If set to <c>true</c> and any padding dimension is > 0 the border will be drawn.</param>
  782. /// <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>
  783. /// <param name="borderContent">The <see cref="Border"/> to be used if defined.</param>
  784. public virtual void DrawWindowFrame (Rect region, int paddingLeft = 0, int paddingTop = 0, int paddingRight = 0,
  785. int paddingBottom = 0, bool border = true, bool fill = false, Border borderContent = null)
  786. {
  787. char clearChar = ' ';
  788. char leftChar = clearChar;
  789. char rightChar = clearChar;
  790. char topChar = clearChar;
  791. char bottomChar = clearChar;
  792. if ((Diagnostics & DiagnosticFlags.FramePadding) == DiagnosticFlags.FramePadding) {
  793. leftChar = 'L';
  794. rightChar = 'R';
  795. topChar = 'T';
  796. bottomChar = 'B';
  797. clearChar = 'C';
  798. }
  799. void AddRuneAt (int col, int row, Rune ch)
  800. {
  801. Move (col, row);
  802. AddRune (ch);
  803. }
  804. // fwidth is count of hLine chars
  805. int fwidth = (int)(region.Width - (paddingRight + paddingLeft));
  806. // fheight is count of vLine chars
  807. int fheight = (int)(region.Height - (paddingBottom + paddingTop));
  808. // fleft is location of left frame line
  809. int fleft = region.X + paddingLeft - 1;
  810. // fright is location of right frame line
  811. int fright = fleft + fwidth + 1;
  812. // ftop is location of top frame line
  813. int ftop = region.Y + paddingTop - 1;
  814. // fbottom is location of bottom frame line
  815. int fbottom = ftop + fheight + 1;
  816. var borderStyle = borderContent == null ? BorderStyle.Single : borderContent.BorderStyle;
  817. Rune hLine = border ? (borderStyle == BorderStyle.Single ? HLine : HDLine) : clearChar;
  818. Rune vLine = border ? (borderStyle == BorderStyle.Single ? VLine : VDLine) : clearChar;
  819. Rune uRCorner = border ? (borderStyle == BorderStyle.Single ? URCorner : URDCorner) : clearChar;
  820. Rune uLCorner = border ? (borderStyle == BorderStyle.Single ? ULCorner : ULDCorner) : clearChar;
  821. Rune lLCorner = border ? (borderStyle == BorderStyle.Single ? LLCorner : LLDCorner) : clearChar;
  822. Rune lRCorner = border ? (borderStyle == BorderStyle.Single ? LRCorner : LRDCorner) : clearChar;
  823. // Outside top
  824. if (paddingTop > 1) {
  825. for (int r = region.Y; r < ftop; r++) {
  826. for (int c = region.X; c < region.X + region.Width; c++) {
  827. AddRuneAt (c, r, topChar);
  828. }
  829. }
  830. }
  831. // Outside top-left
  832. for (int c = region.X; c < fleft; c++) {
  833. AddRuneAt (c, ftop, leftChar);
  834. }
  835. // Frame top-left corner
  836. AddRuneAt (fleft, ftop, paddingTop >= 0 ? (paddingLeft >= 0 ? uLCorner : hLine) : leftChar);
  837. // Frame top
  838. for (int c = fleft + 1; c < fleft + 1 + fwidth; c++) {
  839. AddRuneAt (c, ftop, paddingTop > 0 ? hLine : topChar);
  840. }
  841. // Frame top-right corner
  842. if (fright > fleft) {
  843. AddRuneAt (fright, ftop, paddingTop >= 0 ? (paddingRight >= 0 ? uRCorner : hLine) : rightChar);
  844. }
  845. // Outside top-right corner
  846. for (int c = fright + 1; c < fright + paddingRight; c++) {
  847. AddRuneAt (c, ftop, rightChar);
  848. }
  849. // Left, Fill, Right
  850. if (fbottom > ftop) {
  851. for (int r = ftop + 1; r < fbottom; r++) {
  852. // Outside left
  853. for (int c = region.X; c < fleft; c++) {
  854. AddRuneAt (c, r, leftChar);
  855. }
  856. // Frame left
  857. AddRuneAt (fleft, r, paddingLeft > 0 ? vLine : leftChar);
  858. // Fill
  859. if (fill) {
  860. for (int x = fleft + 1; x < fright; x++) {
  861. AddRuneAt (x, r, clearChar);
  862. }
  863. }
  864. // Frame right
  865. if (fright > fleft) {
  866. var v = vLine;
  867. if ((Diagnostics & DiagnosticFlags.FrameRuler) == DiagnosticFlags.FrameRuler) {
  868. v = (char)(((int)'0') + ((r - ftop) % 10)); // vLine;
  869. }
  870. AddRuneAt (fright, r, paddingRight > 0 ? v : rightChar);
  871. }
  872. // Outside right
  873. for (int c = fright + 1; c < fright + paddingRight; c++) {
  874. AddRuneAt (c, r, rightChar);
  875. }
  876. }
  877. // Outside Bottom
  878. for (int c = region.X; c < region.X + region.Width; c++) {
  879. AddRuneAt (c, fbottom, leftChar);
  880. }
  881. // Frame bottom-left
  882. AddRuneAt (fleft, fbottom, paddingLeft > 0 ? lLCorner : leftChar);
  883. if (fright > fleft) {
  884. // Frame bottom
  885. for (int c = fleft + 1; c < fright; c++) {
  886. var h = hLine;
  887. if ((Diagnostics & DiagnosticFlags.FrameRuler) == DiagnosticFlags.FrameRuler) {
  888. h = (char)(((int)'0') + ((c - fleft) % 10)); // hLine;
  889. }
  890. AddRuneAt (c, fbottom, paddingBottom > 0 ? h : bottomChar);
  891. }
  892. // Frame bottom-right
  893. AddRuneAt (fright, fbottom, paddingRight > 0 ? (paddingBottom > 0 ? lRCorner : hLine) : rightChar);
  894. }
  895. // Outside right
  896. for (int c = fright + 1; c < fright + paddingRight; c++) {
  897. AddRuneAt (c, fbottom, rightChar);
  898. }
  899. }
  900. // Out bottom - ensure top is always drawn if we overlap
  901. if (paddingBottom > 0) {
  902. for (int r = fbottom + 1; r < fbottom + paddingBottom; r++) {
  903. for (int c = region.X; c < region.X + region.Width; c++) {
  904. AddRuneAt (c, r, bottomChar);
  905. }
  906. }
  907. }
  908. }
  909. /// <summary>
  910. /// Draws a frame on the specified region with the specified padding around the frame.
  911. /// </summary>
  912. /// <param name="region">Screen relative region where the frame will be drawn.</param>
  913. /// <param name="padding">Padding to add on the sides.</param>
  914. /// <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>
  915. /// <remarks>This API has been superseded by <see cref="DrawWindowFrame(Rect, int, int, int, int, bool, bool, Border)"/>.</remarks>
  916. /// <remarks>This API is equivalent to calling <c>DrawWindowFrame(Rect, p - 1, p - 1, p - 1, p - 1)</c>. In other words,
  917. /// A padding value of 0 means there is actually a one cell border.
  918. /// </remarks>
  919. public virtual void DrawFrame (Rect region, int padding, bool fill)
  920. {
  921. // DrawFrame assumes the border is always at least one row/col thick
  922. // DrawWindowFrame assumes a padding of 0 means NO padding and no frame
  923. DrawWindowFrame (new Rect (region.X, region.Y, region.Width, region.Height),
  924. padding + 1, padding + 1, padding + 1, padding + 1, border: false, fill: fill);
  925. }
  926. /// <summary>
  927. /// Suspend the application, typically needs to save the state, suspend the app and upon return, reset the console driver.
  928. /// </summary>
  929. public abstract void Suspend ();
  930. Rect clip;
  931. /// <summary>
  932. /// Controls the current clipping region that AddRune/AddStr is subject to.
  933. /// </summary>
  934. /// <value>The clip.</value>
  935. public Rect Clip {
  936. get => clip;
  937. set => this.clip = value;
  938. }
  939. /// <summary>
  940. /// Start of mouse moves.
  941. /// </summary>
  942. public abstract void StartReportingMouseMoves ();
  943. /// <summary>
  944. /// Stop reporting mouses moves.
  945. /// </summary>
  946. public abstract void StopReportingMouseMoves ();
  947. /// <summary>
  948. /// Disables the cooked event processing from the mouse driver. At startup, it is assumed mouse events are cooked.
  949. /// </summary>
  950. public abstract void UncookMouse ();
  951. /// <summary>
  952. /// Enables the cooked event processing from the mouse driver
  953. /// </summary>
  954. public abstract void CookMouse ();
  955. /// <summary>
  956. /// Horizontal line character.
  957. /// </summary>
  958. public Rune HLine = '\u2500';
  959. /// <summary>
  960. /// Vertical line character.
  961. /// </summary>
  962. public Rune VLine = '\u2502';
  963. /// <summary>
  964. /// Stipple pattern
  965. /// </summary>
  966. public Rune Stipple = '\u2591';
  967. /// <summary>
  968. /// Diamond character
  969. /// </summary>
  970. public Rune Diamond = '\u25ca';
  971. /// <summary>
  972. /// Upper left corner
  973. /// </summary>
  974. public Rune ULCorner = '\u250C';
  975. /// <summary>
  976. /// Lower left corner
  977. /// </summary>
  978. public Rune LLCorner = '\u2514';
  979. /// <summary>
  980. /// Upper right corner
  981. /// </summary>
  982. public Rune URCorner = '\u2510';
  983. /// <summary>
  984. /// Lower right corner
  985. /// </summary>
  986. public Rune LRCorner = '\u2518';
  987. /// <summary>
  988. /// Left tee
  989. /// </summary>
  990. public Rune LeftTee = '\u251c';
  991. /// <summary>
  992. /// Right tee
  993. /// </summary>
  994. public Rune RightTee = '\u2524';
  995. /// <summary>
  996. /// Top tee
  997. /// </summary>
  998. public Rune TopTee = '\u252c';
  999. /// <summary>
  1000. /// The bottom tee.
  1001. /// </summary>
  1002. public Rune BottomTee = '\u2534';
  1003. /// <summary>
  1004. /// Checkmark.
  1005. /// </summary>
  1006. public Rune Checked = '\u221a';
  1007. /// <summary>
  1008. /// Un-checked checkmark.
  1009. /// </summary>
  1010. public Rune UnChecked = '\u2574';
  1011. /// <summary>
  1012. /// Selected mark.
  1013. /// </summary>
  1014. public Rune Selected = '\u25cf';
  1015. /// <summary>
  1016. /// Un-selected selected mark.
  1017. /// </summary>
  1018. public Rune UnSelected = '\u25cc';
  1019. /// <summary>
  1020. /// Right Arrow.
  1021. /// </summary>
  1022. public Rune RightArrow = '\u25ba';
  1023. /// <summary>
  1024. /// Left Arrow.
  1025. /// </summary>
  1026. public Rune LeftArrow = '\u25c4';
  1027. /// <summary>
  1028. /// Down Arrow.
  1029. /// </summary>
  1030. public Rune DownArrow = '\u25bc';
  1031. /// <summary>
  1032. /// Up Arrow.
  1033. /// </summary>
  1034. public Rune UpArrow = '\u25b2';
  1035. /// <summary>
  1036. /// Left indicator for default action (e.g. for <see cref="Button"/>).
  1037. /// </summary>
  1038. public Rune LeftDefaultIndicator = '\u25e6';
  1039. /// <summary>
  1040. /// Right indicator for default action (e.g. for <see cref="Button"/>).
  1041. /// </summary>
  1042. public Rune RightDefaultIndicator = '\u25e6';
  1043. /// <summary>
  1044. /// Left frame/bracket (e.g. '[' for <see cref="Button"/>).
  1045. /// </summary>
  1046. public Rune LeftBracket = '[';
  1047. /// <summary>
  1048. /// Right frame/bracket (e.g. ']' for <see cref="Button"/>).
  1049. /// </summary>
  1050. public Rune RightBracket = ']';
  1051. /// <summary>
  1052. /// Blocks Segment indicator for meter views (e.g. <see cref="ProgressBar"/>.
  1053. /// </summary>
  1054. public Rune BlocksMeterSegment = '\u258c';
  1055. /// <summary>
  1056. /// Continuous Segment indicator for meter views (e.g. <see cref="ProgressBar"/>.
  1057. /// </summary>
  1058. public Rune ContinuousMeterSegment = '\u2588';
  1059. /// <summary>
  1060. /// Horizontal double line character.
  1061. /// </summary>
  1062. public Rune HDLine = '\u2550';
  1063. /// <summary>
  1064. /// Vertical double line character.
  1065. /// </summary>
  1066. public Rune VDLine = '\u2551';
  1067. /// <summary>
  1068. /// Upper left double corner
  1069. /// </summary>
  1070. public Rune ULDCorner = '\u2554';
  1071. /// <summary>
  1072. /// Lower left double corner
  1073. /// </summary>
  1074. public Rune LLDCorner = '\u255a';
  1075. /// <summary>
  1076. /// Upper right double corner
  1077. /// </summary>
  1078. public Rune URDCorner = '\u2557';
  1079. /// <summary>
  1080. /// Lower right double corner
  1081. /// </summary>
  1082. public Rune LRDCorner = '\u255d';
  1083. /// <summary>
  1084. /// Make the attribute for the foreground and background colors.
  1085. /// </summary>
  1086. /// <param name="fore">Foreground.</param>
  1087. /// <param name="back">Background.</param>
  1088. /// <returns></returns>
  1089. public abstract Attribute MakeAttribute (Color fore, Color back);
  1090. /// <summary>
  1091. /// Gets the current <see cref="Attribute"/>.
  1092. /// </summary>
  1093. /// <returns>The current attribute.</returns>
  1094. public abstract Attribute GetAttribute ();
  1095. }
  1096. }