binding.cs 30 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760
  1. //
  2. // TODO:
  3. // * FindNCurses needs to remove the old probing code
  4. // * Removal of that proxy code
  5. // * Need to implement reading pointers with the new API
  6. // * Can remove the manual Dlopen features
  7. // * initscr() diagnostics based on DLL can be fixed
  8. //
  9. // binding.cs.in: Core binding for curses.
  10. //
  11. // This file attempts to call into ncurses without relying on Mono's
  12. // dllmap, so it will work with .NET Core. This means that it needs
  13. // two sets of bindings, one for "ncurses" which works on OSX, and one
  14. // that works against "libncursesw.so.5" which is what you find on
  15. // assorted Linux systems.
  16. //
  17. // Additionally, I do not want to rely on an external native library
  18. // which is why all this pain to bind two separate ncurses is here.
  19. //
  20. // Authors:
  21. // Miguel de Icaza ([email protected])
  22. //
  23. // Copyright (C) 2007 Novell (http://www.novell.com)
  24. //
  25. // Permission is hereby granted, free of charge, to any person obtaining
  26. // a copy of this software and associated documentation files (the
  27. // "Software"), to deal in the Software without restriction, including
  28. // without limitation the rights to use, copy, modify, merge, publish,
  29. // distribute, sublicense, and/or sell copies of the Software, and to
  30. // permit persons to whom the Software is furnished to do so, subject to
  31. // the following conditions:
  32. //
  33. // The above copyright notice and this permission notice shall be
  34. // included in all copies or substantial portions of the Software.
  35. //
  36. // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
  37. // EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
  38. // MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
  39. // NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
  40. // LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
  41. // OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
  42. // WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
  43. //
  44. using System.Runtime.InteropServices;
  45. using Terminal.Gui;
  46. namespace Unix.Terminal;
  47. #pragma warning disable CS1591 // Missing XML comment for publicly visible type or member
  48. public partial class Curses
  49. {
  50. // We encode ESC + char (what Alt-char generates) as 0x2000 + char
  51. public const int KeyAlt = 0x2000;
  52. private static nint curses_handle, curscr_ptr, lines_ptr, cols_ptr;
  53. // If true, uses the DllImport into "ncurses", otherwise "libncursesw.so.5"
  54. //static bool use_naked_driver;
  55. private static UnmanagedLibrary curses_library;
  56. private static int lines, cols;
  57. private static Window main_window;
  58. private static NativeMethods methods;
  59. private static char [] r = new char [1];
  60. private static nint stdscr;
  61. public static int ColorPairs => methods.COLOR_PAIRS ();
  62. public static int Cols
  63. {
  64. get => cols;
  65. internal set =>
  66. // For unit tests
  67. cols = value;
  68. }
  69. public static bool HasColors => methods.has_colors ();
  70. public static int Lines
  71. {
  72. get => lines;
  73. internal set =>
  74. // For unit tests
  75. lines = value;
  76. }
  77. //
  78. // Have to wrap the native addch, as it can not
  79. // display unicode characters, we have to use addstr
  80. // for that. but we need addch to render special ACS
  81. // characters
  82. //
  83. public static int addch (int ch)
  84. {
  85. if (ch < 127 || ch > 0xffff)
  86. {
  87. return methods.addch (ch);
  88. }
  89. var c = (char)ch;
  90. return addwstr (new string (c, 1));
  91. }
  92. public static int addstr (string format, params object [] args)
  93. {
  94. string s = string.Format (format, args);
  95. return addwstr (s);
  96. }
  97. public static int addwstr (string s) { return methods.addwstr (s); }
  98. public static int attroff (int attrs) { return methods.attroff (attrs); }
  99. //static public int wechochar (IntPtr win, int ch) => methods.wechochar (win, ch);
  100. public static int attron (int attrs) { return methods.attron (attrs); }
  101. public static int attrset (int attrs) { return methods.attrset (attrs); }
  102. public static int cbreak () { return methods.cbreak (); }
  103. //
  104. // Returns true if the window changed since the last invocation, as a
  105. // side effect, the Lines and Cols properties are updated
  106. //
  107. public static bool CheckWinChange ()
  108. {
  109. int l, c;
  110. console_sharp_get_dims (out l, out c);
  111. if (l < 1)
  112. {
  113. l = 1;
  114. }
  115. if (l != lines || c != cols)
  116. {
  117. lines = l;
  118. cols = c;
  119. return true;
  120. }
  121. return false;
  122. }
  123. public static bool ChangeWindowSize (int l, int c)
  124. {
  125. if (l != lines || c != cols)
  126. {
  127. lines = l;
  128. cols = c;
  129. return true;
  130. }
  131. return false;
  132. }
  133. public static int clearok (nint win, bool bf) { return methods.clearok (win, bf); }
  134. public static int COLOR_PAIRS () { return methods.COLOR_PAIRS (); }
  135. public static int curs_set (int visibility) { return methods.curs_set (visibility); }
  136. public static string curses_version ()
  137. {
  138. nint v = methods.curses_version ();
  139. return $"{Marshal.PtrToStringAnsi (v)}, {curses_library.LibraryPath}";
  140. }
  141. public static int def_prog_mode () { return methods.def_prog_mode (); }
  142. public static int def_shell_mode () { return methods.def_shell_mode (); }
  143. public static int doupdate () { return methods.doupdate (); }
  144. public static int echo () { return methods.echo (); }
  145. //static public int addch (int ch) => methods.addch (ch);
  146. public static int echochar (int ch) { return methods.echochar (ch); }
  147. //
  148. // The proxy methods to call into each version
  149. //
  150. public static int endwin () { return methods.endwin (); }
  151. public static int flushinp () { return methods.flushinp (); }
  152. public static int get_wch (out int sequence) { return methods.get_wch (out sequence); }
  153. public static int getch () { return methods.getch (); }
  154. public static uint getmouse (out MouseEvent ev) { return methods.getmouse (out ev); }
  155. public static int halfdelay (int t) { return methods.halfdelay (t); }
  156. public static bool has_colors () { return methods.has_colors (); }
  157. public static void idcok (nint win, bool bf) { methods.idcok (win, bf); }
  158. public static int idlok (nint win, bool bf) { return methods.idlok (win, bf); }
  159. public static void immedok (nint win, bool bf) { methods.immedok (win, bf); }
  160. public static int init_pair (short pair, short f, short b) { return methods.init_pair (pair, f, b); }
  161. /// <summary>
  162. /// The init_pair routine changes the definition of a color-pair.It takes three arguments: the number of the
  163. /// color-pair to be changed, the fore- ground color number, and the background color number.For portable ap-
  164. /// plications: o The first argument must be a legal color pair value.If default colors are used (see
  165. /// use_default_colors(3x)) the upper limit is ad- justed to allow for extra pairs which use a default color in fore-
  166. /// ground and/or background. o The second and third arguments must be legal color values. If the color-pair was
  167. /// previously initialized, the screen is refreshed and all occurrences of that color-pair are changed to the new
  168. /// defini- tion. As an extension, ncurses allows you to set color pair 0 via the as- sume_default_colors (3x)
  169. /// routine, or to specify the use of default col- ors (color number -1) if you first invoke the use_default_colors
  170. /// (3x) routine.
  171. /// </summary>
  172. /// <param name="pair"></param>
  173. /// <param name="foreground"></param>
  174. /// <param name="background"></param>
  175. /// <returns></returns>
  176. public static int InitColorPair (short pair, short foreground, short background) { return methods.init_pair (pair, foreground, background); }
  177. public static Window initscr ()
  178. {
  179. setlocale (LC_ALL, "");
  180. FindNCurses ();
  181. // Prevents the terminal from being locked after exiting.
  182. reset_shell_mode ();
  183. main_window = new Window (methods.initscr ());
  184. try
  185. {
  186. console_sharp_get_dims (out lines, out cols);
  187. }
  188. catch (DllNotFoundException)
  189. {
  190. endwin ();
  191. Console.Error.WriteLine (
  192. "Unable to find the @MONO_CURSES@ native library\n"
  193. + "this is different than the managed mono-curses.dll\n\n"
  194. + "Typically you need to install to a LD_LIBRARY_PATH directory\n"
  195. + "or DYLD_LIBRARY_PATH directory or run /sbin/ldconfig"
  196. );
  197. Environment.Exit (1);
  198. }
  199. //Console.Error.WriteLine ($"using curses {Curses.curses_version ()}");
  200. return main_window;
  201. }
  202. public static int intrflush (nint win, bool bf) { return methods.intrflush (win, bf); }
  203. public static bool is_term_resized (int lines, int columns) { return methods.is_term_resized (lines, columns); }
  204. public static int IsAlt (int key)
  205. {
  206. if ((key & KeyAlt) != 0)
  207. {
  208. return key & ~KeyAlt;
  209. }
  210. return 0;
  211. }
  212. public static bool isendwin () { return methods.isendwin (); }
  213. public static int keypad (nint win, bool bf) { return methods.keypad (win, bf); }
  214. public static int leaveok (nint win, bool bf) { return methods.leaveok (win, bf); }
  215. public static int meta (nint win, bool bf) { return methods.meta (win, bf); }
  216. public static int mouseinterval (int interval) { return methods.mouseinterval (interval); }
  217. public static Event mousemask (Event newmask, out Event oldmask)
  218. {
  219. nint e;
  220. var ret = (Event)methods.mousemask ((nint)newmask, out e);
  221. oldmask = (Event)e;
  222. return ret;
  223. }
  224. public static int move (int line, int col) { return methods.move (line, col); }
  225. public static int mvaddch (int y, int x, int ch)
  226. {
  227. if (ch < 127 || ch > 0xffff)
  228. {
  229. return methods.mvaddch (y, x, ch);
  230. }
  231. var c = (char)ch;
  232. return mvaddwstr (y, x, new string (c, 1));
  233. }
  234. public static int mvaddwstr (int y, int x, string s) { return methods.mvaddwstr (y, x, s); }
  235. public static int mvgetch (int y, int x) { return methods.mvgetch (y, x); }
  236. public static int nl () { return methods.nl (); }
  237. public static int nocbreak () { return methods.nocbreak (); }
  238. public static int noecho () { return methods.noecho (); }
  239. public static int nonl () { return methods.nonl (); }
  240. public static void noqiflush () { methods.noqiflush (); }
  241. public static int noraw () { return methods.noraw (); }
  242. public static int notimeout (nint win, bool bf) { return methods.notimeout (win, bf); }
  243. public static void qiflush () { methods.qiflush (); }
  244. public static int raw () { return methods.raw (); }
  245. public static int redrawwin (nint win) { return methods.redrawwin (win); }
  246. public static int refresh () { return methods.refresh (); }
  247. public static int reset_prog_mode () { return methods.reset_prog_mode (); }
  248. public static int reset_shell_mode () { return methods.reset_shell_mode (); }
  249. public static int resetty () { return methods.resetty (); }
  250. public static int resize_term (int lines, int columns) { return methods.resize_term (lines, columns); }
  251. public static int resizeterm (int lines, int columns) { return methods.resizeterm (lines, columns); }
  252. public static int savetty () { return methods.savetty (); }
  253. public static int scrollok (nint win, bool bf) { return methods.scrollok (win, bf); }
  254. public static int set_escdelay (int size) { return methods.set_escdelay (size); }
  255. [DllImport ("libc")]
  256. public static extern int setlocale (int cate, [MarshalAs (UnmanagedType.LPStr)] string locale);
  257. public static int setscrreg (int top, int bot) { return methods.setscrreg (top, bot); }
  258. public static int start_color () { return methods.start_color (); }
  259. public static int StartColor () { return methods.start_color (); }
  260. public static int timeout (int delay) { return methods.timeout (delay); }
  261. public static int typeahead (nint fd) { return methods.typeahead (fd); }
  262. public static int ungetch (int ch) { return methods.ungetch (ch); }
  263. public static uint ungetmouse (ref MouseEvent ev) { return methods.ungetmouse (ref ev); }
  264. public static int use_default_colors () { return methods.use_default_colors (); }
  265. public static void use_env (bool f) { methods.use_env (f); }
  266. // TODO: Upgrade to ncurses 6.1 and use the extended version
  267. //public static int InitExtendedPair (int pair, int foreground, int background) => methods.init_extended_pair (pair, foreground, background);
  268. public static int UseDefaultColors () { return methods.use_default_colors (); }
  269. public static int waddch (nint win, int ch) { return methods.waddch (win, ch); }
  270. public static int wmove (nint win, int line, int col) { return methods.wmove (win, line, col); }
  271. //static public int wredrawwin (IntPtr win, int beg_line, int num_lines) => methods.wredrawwin (win, beg_line, num_lines);
  272. public static int wnoutrefresh (nint win) { return methods.wnoutrefresh (win); }
  273. public static int wrefresh (nint win) { return methods.wrefresh (win); }
  274. public static int wsetscrreg (nint win, int top, int bot) { return methods.wsetscrreg (win, top, bot); }
  275. public static int wtimeout (nint win, int delay) { return methods.wtimeout (win, delay); }
  276. internal static nint console_sharp_get_curscr () { return Marshal.ReadIntPtr (curscr_ptr); }
  277. internal static void console_sharp_get_dims (out int lines, out int cols)
  278. {
  279. lines = Marshal.ReadInt32 (lines_ptr);
  280. cols = Marshal.ReadInt32 (cols_ptr);
  281. //int cmd;
  282. //if (UnmanagedLibrary.IsMacOSPlatform) {
  283. // cmd = TIOCGWINSZ_MAC;
  284. //} else {
  285. // cmd = TIOCGWINSZ;
  286. //}
  287. //if (ioctl (1, cmd, out winsize ws) == 0) {
  288. // lines = ws.ws_row;
  289. // cols = ws.ws_col;
  290. // if (lines == Lines && cols == Cols) {
  291. // return;
  292. // }
  293. // resizeterm (lines, cols);
  294. //} else {
  295. // lines = Lines;
  296. // cols = Cols;
  297. //}
  298. }
  299. internal static nint console_sharp_get_stdscr () { return stdscr; }
  300. internal static nint read_static_ptr (string key)
  301. {
  302. nint ptr = get_ptr (key);
  303. return Marshal.ReadIntPtr (ptr);
  304. }
  305. private static void FindNCurses ()
  306. {
  307. LoadMethods ();
  308. curses_handle = methods.UnmanagedLibrary.NativeLibraryHandle;
  309. stdscr = read_static_ptr ("stdscr");
  310. curscr_ptr = get_ptr ("curscr");
  311. lines_ptr = get_ptr ("LINES");
  312. cols_ptr = get_ptr ("COLS");
  313. }
  314. private static nint get_ptr (string key)
  315. {
  316. nint ptr = curses_library.LoadSymbol (key);
  317. if (ptr == nint.Zero)
  318. {
  319. throw new Exception ("Could not load the key " + key);
  320. }
  321. return ptr;
  322. }
  323. //[DllImport ("libc")]
  324. //public extern static int ioctl (int fd, int cmd, out winsize argp);
  325. private static void LoadMethods ()
  326. {
  327. string [] libs = OperatingSystem.IsMacOS()
  328. ? ["libncurses.dylib"]
  329. : ["libncursesw.so.6", "libncursesw.so.5"];
  330. var attempts = 1;
  331. while (true)
  332. {
  333. try
  334. {
  335. curses_library = new UnmanagedLibrary (libs, false);
  336. methods = new NativeMethods (curses_library);
  337. break;
  338. }
  339. catch (Exception ex)
  340. {
  341. if (attempts == 1)
  342. {
  343. attempts++;
  344. (int exitCode, string result) =
  345. ClipboardProcessRunner.Bash ("cat /etc/os-release", waitForOutput: true);
  346. if (exitCode == 0 && result.Contains ("opensuse"))
  347. {
  348. libs [0] = "libncursesw.so.5";
  349. }
  350. }
  351. else
  352. {
  353. throw ex.GetBaseException ();
  354. }
  355. }
  356. }
  357. }
  358. //[StructLayout (LayoutKind.Sequential)]
  359. //public struct winsize {
  360. // public ushort ws_row;
  361. // public ushort ws_col;
  362. // public ushort ws_xpixel; /* unused */
  363. // public ushort ws_ypixel; /* unused */
  364. //};
  365. [StructLayout (LayoutKind.Sequential)]
  366. public struct MouseEvent
  367. {
  368. public short ID;
  369. public int X, Y, Z;
  370. public Event ButtonState;
  371. }
  372. }
  373. #pragma warning disable RCS1102 // Make class static.'
  374. internal class Delegates
  375. {
  376. #pragma warning restore RCS1102 // Make class static.
  377. #pragma warning disable CS8981 // The type name only contains lower-cased ascii characters. Such names may become reserved for the language.
  378. public delegate nint initscr ();
  379. public delegate int endwin ();
  380. public delegate bool isendwin ();
  381. public delegate int cbreak ();
  382. public delegate int nocbreak ();
  383. public delegate int echo ();
  384. public delegate int noecho ();
  385. public delegate int halfdelay (int t);
  386. public delegate int raw ();
  387. public delegate int noraw ();
  388. public delegate void noqiflush ();
  389. public delegate void qiflush ();
  390. public delegate int typeahead (nint fd);
  391. public delegate int timeout (int delay);
  392. public delegate int wtimeout (nint win, int delay);
  393. public delegate int notimeout (nint win, bool bf);
  394. public delegate int keypad (nint win, bool bf);
  395. public delegate int meta (nint win, bool bf);
  396. public delegate int intrflush (nint win, bool bf);
  397. public delegate int clearok (nint win, bool bf);
  398. public delegate int idlok (nint win, bool bf);
  399. public delegate void idcok (nint win, bool bf);
  400. public delegate void immedok (nint win, bool bf);
  401. public delegate int leaveok (nint win, bool bf);
  402. public delegate int wsetscrreg (nint win, int top, int bot);
  403. public delegate int scrollok (nint win, bool bf);
  404. public delegate int nl ();
  405. public delegate int nonl ();
  406. public delegate int setscrreg (int top, int bot);
  407. public delegate int refresh ();
  408. public delegate int doupdate ();
  409. public delegate int wrefresh (nint win);
  410. public delegate int redrawwin (nint win);
  411. //public delegate int wredrawwin (IntPtr win, int beg_line, int num_lines);
  412. public delegate int wnoutrefresh (nint win);
  413. public delegate int move (int line, int col);
  414. public delegate int curs_set (int visibility);
  415. public delegate int addch (int ch);
  416. public delegate int echochar (int ch);
  417. public delegate int mvaddch (int y, int x, int ch);
  418. public delegate int addwstr ([MarshalAs (UnmanagedType.LPWStr)] string s);
  419. public delegate int mvaddwstr (int y, int x, [MarshalAs (UnmanagedType.LPWStr)] string s);
  420. public delegate int wmove (nint win, int line, int col);
  421. public delegate int waddch (nint win, int ch);
  422. public delegate int attron (int attrs);
  423. public delegate int attroff (int attrs);
  424. public delegate int attrset (int attrs);
  425. public delegate int getch ();
  426. public delegate int get_wch (out int sequence);
  427. public delegate int ungetch (int ch);
  428. public delegate int mvgetch (int y, int x);
  429. public delegate bool has_colors ();
  430. public delegate int start_color ();
  431. public delegate int init_pair (short pair, short f, short b);
  432. public delegate int use_default_colors ();
  433. public delegate int COLOR_PAIRS ();
  434. public delegate uint getmouse (out Curses.MouseEvent ev);
  435. public delegate uint ungetmouse (ref Curses.MouseEvent ev);
  436. public delegate int mouseinterval (int interval);
  437. public delegate nint mousemask (nint newmask, out nint oldMask);
  438. public delegate bool is_term_resized (int lines, int columns);
  439. public delegate int resize_term (int lines, int columns);
  440. public delegate int resizeterm (int lines, int columns);
  441. public delegate void use_env (bool f);
  442. public delegate int flushinp ();
  443. public delegate int def_prog_mode ();
  444. public delegate int def_shell_mode ();
  445. public delegate int reset_prog_mode ();
  446. public delegate int reset_shell_mode ();
  447. public delegate int savetty ();
  448. public delegate int resetty ();
  449. public delegate int set_escdelay (int size);
  450. public delegate nint curses_version ();
  451. }
  452. internal class NativeMethods
  453. {
  454. public readonly Delegates.addch addch;
  455. public readonly Delegates.addwstr addwstr;
  456. public readonly Delegates.attroff attroff;
  457. //public readonly Delegates.wechochar wechochar;
  458. public readonly Delegates.attron attron;
  459. public readonly Delegates.attrset attrset;
  460. public readonly Delegates.cbreak cbreak;
  461. public readonly Delegates.clearok clearok;
  462. public readonly Delegates.COLOR_PAIRS COLOR_PAIRS;
  463. public readonly Delegates.curs_set curs_set;
  464. public readonly Delegates.curses_version curses_version;
  465. public readonly Delegates.def_prog_mode def_prog_mode;
  466. public readonly Delegates.def_shell_mode def_shell_mode;
  467. public readonly Delegates.doupdate doupdate;
  468. public readonly Delegates.echo echo;
  469. public readonly Delegates.echochar echochar;
  470. public readonly Delegates.endwin endwin;
  471. public readonly Delegates.flushinp flushinp;
  472. public readonly Delegates.get_wch get_wch;
  473. public readonly Delegates.getch getch;
  474. public readonly Delegates.getmouse getmouse;
  475. public readonly Delegates.halfdelay halfdelay;
  476. public readonly Delegates.has_colors has_colors;
  477. public readonly Delegates.idcok idcok;
  478. public readonly Delegates.idlok idlok;
  479. public readonly Delegates.immedok immedok;
  480. public readonly Delegates.init_pair init_pair;
  481. public readonly Delegates.initscr initscr;
  482. public readonly Delegates.intrflush intrflush;
  483. public readonly Delegates.is_term_resized is_term_resized;
  484. public readonly Delegates.isendwin isendwin;
  485. public readonly Delegates.keypad keypad;
  486. public readonly Delegates.leaveok leaveok;
  487. public readonly Delegates.meta meta;
  488. public readonly Delegates.mouseinterval mouseinterval;
  489. public readonly Delegates.mousemask mousemask;
  490. public readonly Delegates.move move;
  491. public readonly Delegates.mvaddch mvaddch;
  492. public readonly Delegates.mvaddwstr mvaddwstr;
  493. public readonly Delegates.mvgetch mvgetch;
  494. public readonly Delegates.nl nl;
  495. public readonly Delegates.nocbreak nocbreak;
  496. public readonly Delegates.noecho noecho;
  497. public readonly Delegates.nonl nonl;
  498. public readonly Delegates.noqiflush noqiflush;
  499. public readonly Delegates.noraw noraw;
  500. public readonly Delegates.notimeout notimeout;
  501. public readonly Delegates.qiflush qiflush;
  502. public readonly Delegates.raw raw;
  503. public readonly Delegates.redrawwin redrawwin;
  504. public readonly Delegates.refresh refresh;
  505. public readonly Delegates.reset_prog_mode reset_prog_mode;
  506. public readonly Delegates.reset_shell_mode reset_shell_mode;
  507. public readonly Delegates.resetty resetty;
  508. public readonly Delegates.resize_term resize_term;
  509. public readonly Delegates.resizeterm resizeterm;
  510. public readonly Delegates.savetty savetty;
  511. public readonly Delegates.scrollok scrollok;
  512. public readonly Delegates.set_escdelay set_escdelay;
  513. public readonly Delegates.setscrreg setscrreg;
  514. public readonly Delegates.start_color start_color;
  515. public readonly Delegates.timeout timeout;
  516. public readonly Delegates.typeahead typeahead;
  517. public readonly Delegates.ungetch ungetch;
  518. public readonly Delegates.ungetmouse ungetmouse;
  519. public readonly Delegates.use_default_colors use_default_colors;
  520. public readonly Delegates.use_env use_env;
  521. public readonly Delegates.waddch waddch;
  522. public readonly Delegates.wmove wmove;
  523. //public readonly Delegates.wredrawwin wredrawwin;
  524. public readonly Delegates.wnoutrefresh wnoutrefresh;
  525. public readonly Delegates.wrefresh wrefresh;
  526. public readonly Delegates.wsetscrreg wsetscrreg;
  527. public readonly Delegates.wtimeout wtimeout;
  528. public UnmanagedLibrary UnmanagedLibrary;
  529. public NativeMethods (UnmanagedLibrary lib)
  530. {
  531. UnmanagedLibrary = lib;
  532. initscr = lib.GetNativeMethodDelegate<Delegates.initscr> ("initscr");
  533. endwin = lib.GetNativeMethodDelegate<Delegates.endwin> ("endwin");
  534. isendwin = lib.GetNativeMethodDelegate<Delegates.isendwin> ("isendwin");
  535. cbreak = lib.GetNativeMethodDelegate<Delegates.cbreak> ("cbreak");
  536. nocbreak = lib.GetNativeMethodDelegate<Delegates.nocbreak> ("nocbreak");
  537. echo = lib.GetNativeMethodDelegate<Delegates.echo> ("echo");
  538. noecho = lib.GetNativeMethodDelegate<Delegates.noecho> ("noecho");
  539. halfdelay = lib.GetNativeMethodDelegate<Delegates.halfdelay> ("halfdelay");
  540. raw = lib.GetNativeMethodDelegate<Delegates.raw> ("raw");
  541. noraw = lib.GetNativeMethodDelegate<Delegates.noraw> ("noraw");
  542. noqiflush = lib.GetNativeMethodDelegate<Delegates.noqiflush> ("noqiflush");
  543. qiflush = lib.GetNativeMethodDelegate<Delegates.qiflush> ("qiflush");
  544. typeahead = lib.GetNativeMethodDelegate<Delegates.typeahead> ("typeahead");
  545. timeout = lib.GetNativeMethodDelegate<Delegates.timeout> ("timeout");
  546. wtimeout = lib.GetNativeMethodDelegate<Delegates.wtimeout> ("wtimeout");
  547. notimeout = lib.GetNativeMethodDelegate<Delegates.notimeout> ("notimeout");
  548. keypad = lib.GetNativeMethodDelegate<Delegates.keypad> ("keypad");
  549. meta = lib.GetNativeMethodDelegate<Delegates.meta> ("meta");
  550. intrflush = lib.GetNativeMethodDelegate<Delegates.intrflush> ("intrflush");
  551. clearok = lib.GetNativeMethodDelegate<Delegates.clearok> ("clearok");
  552. idlok = lib.GetNativeMethodDelegate<Delegates.idlok> ("idlok");
  553. idcok = lib.GetNativeMethodDelegate<Delegates.idcok> ("idcok");
  554. immedok = lib.GetNativeMethodDelegate<Delegates.immedok> ("immedok");
  555. leaveok = lib.GetNativeMethodDelegate<Delegates.leaveok> ("leaveok");
  556. wsetscrreg = lib.GetNativeMethodDelegate<Delegates.wsetscrreg> ("wsetscrreg");
  557. scrollok = lib.GetNativeMethodDelegate<Delegates.scrollok> ("scrollok");
  558. nl = lib.GetNativeMethodDelegate<Delegates.nl> ("nl");
  559. nonl = lib.GetNativeMethodDelegate<Delegates.nonl> ("nonl");
  560. setscrreg = lib.GetNativeMethodDelegate<Delegates.setscrreg> ("setscrreg");
  561. refresh = lib.GetNativeMethodDelegate<Delegates.refresh> ("refresh");
  562. doupdate = lib.GetNativeMethodDelegate<Delegates.doupdate> ("doupdate");
  563. wrefresh = lib.GetNativeMethodDelegate<Delegates.wrefresh> ("wrefresh");
  564. redrawwin = lib.GetNativeMethodDelegate<Delegates.redrawwin> ("redrawwin");
  565. //wredrawwin = lib.GetNativeMethodDelegate<Delegates.wredrawwin> ("wredrawwin");
  566. wnoutrefresh = lib.GetNativeMethodDelegate<Delegates.wnoutrefresh> ("wnoutrefresh");
  567. move = lib.GetNativeMethodDelegate<Delegates.move> ("move");
  568. curs_set = lib.GetNativeMethodDelegate<Delegates.curs_set> ("curs_set");
  569. addch = lib.GetNativeMethodDelegate<Delegates.addch> ("addch");
  570. echochar = lib.GetNativeMethodDelegate<Delegates.echochar> ("echochar");
  571. mvaddch = lib.GetNativeMethodDelegate<Delegates.mvaddch> ("mvaddch");
  572. addwstr = lib.GetNativeMethodDelegate<Delegates.addwstr> ("addwstr");
  573. mvaddwstr = lib.GetNativeMethodDelegate<Delegates.mvaddwstr> ("mvaddwstr");
  574. wmove = lib.GetNativeMethodDelegate<Delegates.wmove> ("wmove");
  575. waddch = lib.GetNativeMethodDelegate<Delegates.waddch> ("waddch");
  576. attron = lib.GetNativeMethodDelegate<Delegates.attron> ("attron");
  577. attroff = lib.GetNativeMethodDelegate<Delegates.attroff> ("attroff");
  578. attrset = lib.GetNativeMethodDelegate<Delegates.attrset> ("attrset");
  579. getch = lib.GetNativeMethodDelegate<Delegates.getch> ("getch");
  580. get_wch = lib.GetNativeMethodDelegate<Delegates.get_wch> ("get_wch");
  581. ungetch = lib.GetNativeMethodDelegate<Delegates.ungetch> ("ungetch");
  582. mvgetch = lib.GetNativeMethodDelegate<Delegates.mvgetch> ("mvgetch");
  583. has_colors = lib.GetNativeMethodDelegate<Delegates.has_colors> ("has_colors");
  584. start_color = lib.GetNativeMethodDelegate<Delegates.start_color> ("start_color");
  585. init_pair = lib.GetNativeMethodDelegate<Delegates.init_pair> ("init_pair");
  586. use_default_colors = lib.GetNativeMethodDelegate<Delegates.use_default_colors> ("use_default_colors");
  587. COLOR_PAIRS = lib.GetNativeMethodDelegate<Delegates.COLOR_PAIRS> ("COLOR_PAIRS");
  588. getmouse = lib.GetNativeMethodDelegate<Delegates.getmouse> ("getmouse");
  589. ungetmouse = lib.GetNativeMethodDelegate<Delegates.ungetmouse> ("ungetmouse");
  590. mouseinterval = lib.GetNativeMethodDelegate<Delegates.mouseinterval> ("mouseinterval");
  591. mousemask = lib.GetNativeMethodDelegate<Delegates.mousemask> ("mousemask");
  592. is_term_resized = lib.GetNativeMethodDelegate<Delegates.is_term_resized> ("is_term_resized");
  593. resize_term = lib.GetNativeMethodDelegate<Delegates.resize_term> ("resize_term");
  594. resizeterm = lib.GetNativeMethodDelegate<Delegates.resizeterm> ("resizeterm");
  595. use_env = lib.GetNativeMethodDelegate<Delegates.use_env> ("use_env");
  596. flushinp = lib.GetNativeMethodDelegate<Delegates.flushinp> ("flushinp");
  597. def_prog_mode = lib.GetNativeMethodDelegate<Delegates.def_prog_mode> ("def_prog_mode");
  598. def_shell_mode = lib.GetNativeMethodDelegate<Delegates.def_shell_mode> ("def_shell_mode");
  599. reset_prog_mode = lib.GetNativeMethodDelegate<Delegates.reset_prog_mode> ("reset_prog_mode");
  600. reset_shell_mode = lib.GetNativeMethodDelegate<Delegates.reset_shell_mode> ("reset_shell_mode");
  601. savetty = lib.GetNativeMethodDelegate<Delegates.savetty> ("savetty");
  602. resetty = lib.GetNativeMethodDelegate<Delegates.resetty> ("resetty");
  603. set_escdelay = lib.GetNativeMethodDelegate<Delegates.set_escdelay> ("set_escdelay");
  604. curses_version = lib.GetNativeMethodDelegate<Delegates.curses_version> ("curses_version");
  605. }
  606. }
  607. #pragma warning restore CS1591 // Missing XML comment for publicly visible type or member
  608. #pragma warning restore CS8981 // The type name only contains lower-cased ascii characters. Such names may become reserved for the language.