binding.cs 30 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747
  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 int clearok (nint win, bool bf) { return methods.clearok (win, bf); }
  124. public static int COLOR_PAIRS () { return methods.COLOR_PAIRS (); }
  125. public static int curs_set (int visibility) { return methods.curs_set (visibility); }
  126. public static string curses_version ()
  127. {
  128. nint v = methods.curses_version ();
  129. return $"{Marshal.PtrToStringAnsi (v)}, {curses_library.LibraryPath}";
  130. }
  131. public static int def_prog_mode () { return methods.def_prog_mode (); }
  132. public static int def_shell_mode () { return methods.def_shell_mode (); }
  133. public static int doupdate () { return methods.doupdate (); }
  134. public static int echo () { return methods.echo (); }
  135. //static public int addch (int ch) => methods.addch (ch);
  136. public static int echochar (int ch) { return methods.echochar (ch); }
  137. //
  138. // The proxy methods to call into each version
  139. //
  140. public static int endwin () { return methods.endwin (); }
  141. public static int flushinp () { return methods.flushinp (); }
  142. public static int get_wch (out int sequence) { return methods.get_wch (out sequence); }
  143. public static int getch () { return methods.getch (); }
  144. public static uint getmouse (out MouseEvent ev) { return methods.getmouse (out ev); }
  145. public static int halfdelay (int t) { return methods.halfdelay (t); }
  146. public static bool has_colors () { return methods.has_colors (); }
  147. public static void idcok (nint win, bool bf) { methods.idcok (win, bf); }
  148. public static int idlok (nint win, bool bf) { return methods.idlok (win, bf); }
  149. public static void immedok (nint win, bool bf) { methods.immedok (win, bf); }
  150. public static int init_pair (short pair, short f, short b) { return methods.init_pair (pair, f, b); }
  151. /// <summary>
  152. /// The init_pair routine changes the definition of a color-pair.It takes three arguments: the number of the
  153. /// color-pair to be changed, the fore- ground color number, and the background color number.For portable ap-
  154. /// plications: o The first argument must be a legal color pair value.If default colors are used (see
  155. /// use_default_colors(3x)) the upper limit is ad- justed to allow for extra pairs which use a default color in fore-
  156. /// ground and/or background. o The second and third arguments must be legal color values. If the color-pair was
  157. /// previously initialized, the screen is refreshed and all occurrences of that color-pair are changed to the new
  158. /// defini- tion. As an extension, ncurses allows you to set color pair 0 via the as- sume_default_colors (3x)
  159. /// routine, or to specify the use of default col- ors (color number -1) if you first invoke the use_default_colors
  160. /// (3x) routine.
  161. /// </summary>
  162. /// <param name="pair"></param>
  163. /// <param name="foreground"></param>
  164. /// <param name="background"></param>
  165. /// <returns></returns>
  166. public static int InitColorPair (short pair, short foreground, short background) { return methods.init_pair (pair, foreground, background); }
  167. public static Window initscr ()
  168. {
  169. setlocale (LC_ALL, "");
  170. FindNCurses ();
  171. // Prevents the terminal from being locked after exiting.
  172. reset_shell_mode ();
  173. main_window = new Window (methods.initscr ());
  174. try
  175. {
  176. console_sharp_get_dims (out lines, out cols);
  177. }
  178. catch (DllNotFoundException)
  179. {
  180. endwin ();
  181. Console.Error.WriteLine (
  182. "Unable to find the @MONO_CURSES@ native library\n"
  183. + "this is different than the managed mono-curses.dll\n\n"
  184. + "Typically you need to install to a LD_LIBRARY_PATH directory\n"
  185. + "or DYLD_LIBRARY_PATH directory or run /sbin/ldconfig"
  186. );
  187. Environment.Exit (1);
  188. }
  189. //Console.Error.WriteLine ($"using curses {Curses.curses_version ()}");
  190. return main_window;
  191. }
  192. public static int intrflush (nint win, bool bf) { return methods.intrflush (win, bf); }
  193. public static bool is_term_resized (int lines, int columns) { return methods.is_term_resized (lines, columns); }
  194. public static int IsAlt (int key)
  195. {
  196. if ((key & KeyAlt) != 0)
  197. {
  198. return key & ~KeyAlt;
  199. }
  200. return 0;
  201. }
  202. public static bool isendwin () { return methods.isendwin (); }
  203. public static int keypad (nint win, bool bf) { return methods.keypad (win, bf); }
  204. public static int leaveok (nint win, bool bf) { return methods.leaveok (win, bf); }
  205. public static int meta (nint win, bool bf) { return methods.meta (win, bf); }
  206. public static int mouseinterval (int interval) { return methods.mouseinterval (interval); }
  207. public static Event mousemask (Event newmask, out Event oldmask)
  208. {
  209. nint e;
  210. var ret = (Event)methods.mousemask ((nint)newmask, out e);
  211. oldmask = (Event)e;
  212. return ret;
  213. }
  214. public static int move (int line, int col) { return methods.move (line, col); }
  215. public static int mvaddch (int y, int x, int ch)
  216. {
  217. if (ch < 127 || ch > 0xffff)
  218. {
  219. return methods.mvaddch (y, x, ch);
  220. }
  221. var c = (char)ch;
  222. return mvaddwstr (y, x, new string (c, 1));
  223. }
  224. public static int mvaddwstr (int y, int x, string s) { return methods.mvaddwstr (y, x, s); }
  225. public static int mvgetch (int y, int x) { return methods.mvgetch (y, x); }
  226. public static int nl () { return methods.nl (); }
  227. public static int nocbreak () { return methods.nocbreak (); }
  228. public static int noecho () { return methods.noecho (); }
  229. public static int nonl () { return methods.nonl (); }
  230. public static void noqiflush () { methods.noqiflush (); }
  231. public static int noraw () { return methods.noraw (); }
  232. public static int notimeout (nint win, bool bf) { return methods.notimeout (win, bf); }
  233. public static void qiflush () { methods.qiflush (); }
  234. public static int raw () { return methods.raw (); }
  235. public static int redrawwin (nint win) { return methods.redrawwin (win); }
  236. public static int refresh () { return methods.refresh (); }
  237. public static int reset_prog_mode () { return methods.reset_prog_mode (); }
  238. public static int reset_shell_mode () { return methods.reset_shell_mode (); }
  239. public static int resetty () { return methods.resetty (); }
  240. public static int resize_term (int lines, int columns) { return methods.resize_term (lines, columns); }
  241. public static int resizeterm (int lines, int columns) { return methods.resizeterm (lines, columns); }
  242. public static int savetty () { return methods.savetty (); }
  243. public static int scrollok (nint win, bool bf) { return methods.scrollok (win, bf); }
  244. public static int set_escdelay (int size) { return methods.set_escdelay (size); }
  245. [DllImport ("libc")]
  246. public static extern int setlocale (int cate, [MarshalAs (UnmanagedType.LPStr)] string locale);
  247. public static int setscrreg (int top, int bot) { return methods.setscrreg (top, bot); }
  248. public static int start_color () { return methods.start_color (); }
  249. public static int StartColor () { return methods.start_color (); }
  250. public static int timeout (int delay) { return methods.timeout (delay); }
  251. public static int typeahead (nint fd) { return methods.typeahead (fd); }
  252. public static int ungetch (int ch) { return methods.ungetch (ch); }
  253. public static uint ungetmouse (ref MouseEvent ev) { return methods.ungetmouse (ref ev); }
  254. public static int use_default_colors () { return methods.use_default_colors (); }
  255. public static void use_env (bool f) { methods.use_env (f); }
  256. // TODO: Upgrade to ncurses 6.1 and use the extended version
  257. //public static int InitExtendedPair (int pair, int foreground, int background) => methods.init_extended_pair (pair, foreground, background);
  258. public static int UseDefaultColors () { return methods.use_default_colors (); }
  259. public static int waddch (nint win, int ch) { return methods.waddch (win, ch); }
  260. public static int wmove (nint win, int line, int col) { return methods.wmove (win, line, col); }
  261. //static public int wredrawwin (IntPtr win, int beg_line, int num_lines) => methods.wredrawwin (win, beg_line, num_lines);
  262. public static int wnoutrefresh (nint win) { return methods.wnoutrefresh (win); }
  263. public static int wrefresh (nint win) { return methods.wrefresh (win); }
  264. public static int wsetscrreg (nint win, int top, int bot) { return methods.wsetscrreg (win, top, bot); }
  265. public static int wtimeout (nint win, int delay) { return methods.wtimeout (win, delay); }
  266. internal static nint console_sharp_get_curscr () { return Marshal.ReadIntPtr (curscr_ptr); }
  267. internal static void console_sharp_get_dims (out int lines, out int cols)
  268. {
  269. lines = Marshal.ReadInt32 (lines_ptr);
  270. cols = Marshal.ReadInt32 (cols_ptr);
  271. //int cmd;
  272. //if (UnmanagedLibrary.IsMacOSPlatform) {
  273. // cmd = TIOCGWINSZ_MAC;
  274. //} else {
  275. // cmd = TIOCGWINSZ;
  276. //}
  277. //if (ioctl (1, cmd, out winsize ws) == 0) {
  278. // lines = ws.ws_row;
  279. // cols = ws.ws_col;
  280. // if (lines == Lines && cols == Cols) {
  281. // return;
  282. // }
  283. // resizeterm (lines, cols);
  284. //} else {
  285. // lines = Lines;
  286. // cols = Cols;
  287. //}
  288. }
  289. internal static nint console_sharp_get_stdscr () { return stdscr; }
  290. internal static nint read_static_ptr (string key)
  291. {
  292. nint ptr = get_ptr (key);
  293. return Marshal.ReadIntPtr (ptr);
  294. }
  295. private static void FindNCurses ()
  296. {
  297. LoadMethods ();
  298. curses_handle = methods.UnmanagedLibrary.NativeLibraryHandle;
  299. stdscr = read_static_ptr ("stdscr");
  300. curscr_ptr = get_ptr ("curscr");
  301. lines_ptr = get_ptr ("LINES");
  302. cols_ptr = get_ptr ("COLS");
  303. }
  304. private static nint get_ptr (string key)
  305. {
  306. nint ptr = curses_library.LoadSymbol (key);
  307. if (ptr == nint.Zero)
  308. {
  309. throw new Exception ("Could not load the key " + key);
  310. }
  311. return ptr;
  312. }
  313. //[DllImport ("libc")]
  314. //public extern static int ioctl (int fd, int cmd, out winsize argp);
  315. private static void LoadMethods ()
  316. {
  317. string [] libs = UnmanagedLibrary.IsMacOSPlatform
  318. ? new [] { "libncurses.dylib" }
  319. : new [] { "libncursesw.so.6", "libncursesw.so.5" };
  320. var attempts = 1;
  321. while (true)
  322. {
  323. try
  324. {
  325. curses_library = new UnmanagedLibrary (libs, false);
  326. methods = new NativeMethods (curses_library);
  327. break;
  328. }
  329. catch (Exception ex)
  330. {
  331. if (attempts == 1)
  332. {
  333. attempts++;
  334. (int exitCode, string result) =
  335. ClipboardProcessRunner.Bash ("cat /etc/os-release", waitForOutput: true);
  336. if (exitCode == 0 && result.Contains ("opensuse"))
  337. {
  338. libs [0] = "libncursesw.so.5";
  339. }
  340. }
  341. else
  342. {
  343. throw ex.GetBaseException ();
  344. }
  345. }
  346. }
  347. }
  348. //[StructLayout (LayoutKind.Sequential)]
  349. //public struct winsize {
  350. // public ushort ws_row;
  351. // public ushort ws_col;
  352. // public ushort ws_xpixel; /* unused */
  353. // public ushort ws_ypixel; /* unused */
  354. //};
  355. [StructLayout (LayoutKind.Sequential)]
  356. public struct MouseEvent
  357. {
  358. public short ID;
  359. public int X, Y, Z;
  360. public Event ButtonState;
  361. }
  362. }
  363. #pragma warning disable RCS1102 // Make class static.'
  364. internal class Delegates
  365. {
  366. #pragma warning restore RCS1102 // Make class static.
  367. #pragma warning disable CS8981 // The type name only contains lower-cased ascii characters. Such names may become reserved for the language.
  368. public delegate nint initscr ();
  369. public delegate int endwin ();
  370. public delegate bool isendwin ();
  371. public delegate int cbreak ();
  372. public delegate int nocbreak ();
  373. public delegate int echo ();
  374. public delegate int noecho ();
  375. public delegate int halfdelay (int t);
  376. public delegate int raw ();
  377. public delegate int noraw ();
  378. public delegate void noqiflush ();
  379. public delegate void qiflush ();
  380. public delegate int typeahead (nint fd);
  381. public delegate int timeout (int delay);
  382. public delegate int wtimeout (nint win, int delay);
  383. public delegate int notimeout (nint win, bool bf);
  384. public delegate int keypad (nint win, bool bf);
  385. public delegate int meta (nint win, bool bf);
  386. public delegate int intrflush (nint win, bool bf);
  387. public delegate int clearok (nint win, bool bf);
  388. public delegate int idlok (nint win, bool bf);
  389. public delegate void idcok (nint win, bool bf);
  390. public delegate void immedok (nint win, bool bf);
  391. public delegate int leaveok (nint win, bool bf);
  392. public delegate int wsetscrreg (nint win, int top, int bot);
  393. public delegate int scrollok (nint win, bool bf);
  394. public delegate int nl ();
  395. public delegate int nonl ();
  396. public delegate int setscrreg (int top, int bot);
  397. public delegate int refresh ();
  398. public delegate int doupdate ();
  399. public delegate int wrefresh (nint win);
  400. public delegate int redrawwin (nint win);
  401. //public delegate int wredrawwin (IntPtr win, int beg_line, int num_lines);
  402. public delegate int wnoutrefresh (nint win);
  403. public delegate int move (int line, int col);
  404. public delegate int curs_set (int visibility);
  405. public delegate int addch (int ch);
  406. public delegate int echochar (int ch);
  407. public delegate int mvaddch (int y, int x, int ch);
  408. public delegate int addwstr ([MarshalAs (UnmanagedType.LPWStr)] string s);
  409. public delegate int mvaddwstr (int y, int x, [MarshalAs (UnmanagedType.LPWStr)] string s);
  410. public delegate int wmove (nint win, int line, int col);
  411. public delegate int waddch (nint win, int ch);
  412. public delegate int attron (int attrs);
  413. public delegate int attroff (int attrs);
  414. public delegate int attrset (int attrs);
  415. public delegate int getch ();
  416. public delegate int get_wch (out int sequence);
  417. public delegate int ungetch (int ch);
  418. public delegate int mvgetch (int y, int x);
  419. public delegate bool has_colors ();
  420. public delegate int start_color ();
  421. public delegate int init_pair (short pair, short f, short b);
  422. public delegate int use_default_colors ();
  423. public delegate int COLOR_PAIRS ();
  424. public delegate uint getmouse (out Curses.MouseEvent ev);
  425. public delegate uint ungetmouse (ref Curses.MouseEvent ev);
  426. public delegate int mouseinterval (int interval);
  427. public delegate nint mousemask (nint newmask, out nint oldMask);
  428. public delegate bool is_term_resized (int lines, int columns);
  429. public delegate int resize_term (int lines, int columns);
  430. public delegate int resizeterm (int lines, int columns);
  431. public delegate void use_env (bool f);
  432. public delegate int flushinp ();
  433. public delegate int def_prog_mode ();
  434. public delegate int def_shell_mode ();
  435. public delegate int reset_prog_mode ();
  436. public delegate int reset_shell_mode ();
  437. public delegate int savetty ();
  438. public delegate int resetty ();
  439. public delegate int set_escdelay (int size);
  440. public delegate nint curses_version ();
  441. }
  442. internal class NativeMethods
  443. {
  444. public readonly Delegates.addch addch;
  445. public readonly Delegates.addwstr addwstr;
  446. public readonly Delegates.attroff attroff;
  447. //public readonly Delegates.wechochar wechochar;
  448. public readonly Delegates.attron attron;
  449. public readonly Delegates.attrset attrset;
  450. public readonly Delegates.cbreak cbreak;
  451. public readonly Delegates.clearok clearok;
  452. public readonly Delegates.COLOR_PAIRS COLOR_PAIRS;
  453. public readonly Delegates.curs_set curs_set;
  454. public readonly Delegates.curses_version curses_version;
  455. public readonly Delegates.def_prog_mode def_prog_mode;
  456. public readonly Delegates.def_shell_mode def_shell_mode;
  457. public readonly Delegates.doupdate doupdate;
  458. public readonly Delegates.echo echo;
  459. public readonly Delegates.echochar echochar;
  460. public readonly Delegates.endwin endwin;
  461. public readonly Delegates.flushinp flushinp;
  462. public readonly Delegates.get_wch get_wch;
  463. public readonly Delegates.getch getch;
  464. public readonly Delegates.getmouse getmouse;
  465. public readonly Delegates.halfdelay halfdelay;
  466. public readonly Delegates.has_colors has_colors;
  467. public readonly Delegates.idcok idcok;
  468. public readonly Delegates.idlok idlok;
  469. public readonly Delegates.immedok immedok;
  470. public readonly Delegates.init_pair init_pair;
  471. public readonly Delegates.initscr initscr;
  472. public readonly Delegates.intrflush intrflush;
  473. public readonly Delegates.is_term_resized is_term_resized;
  474. public readonly Delegates.isendwin isendwin;
  475. public readonly Delegates.keypad keypad;
  476. public readonly Delegates.leaveok leaveok;
  477. public readonly Delegates.meta meta;
  478. public readonly Delegates.mouseinterval mouseinterval;
  479. public readonly Delegates.mousemask mousemask;
  480. public readonly Delegates.move move;
  481. public readonly Delegates.mvaddch mvaddch;
  482. public readonly Delegates.mvaddwstr mvaddwstr;
  483. public readonly Delegates.mvgetch mvgetch;
  484. public readonly Delegates.nl nl;
  485. public readonly Delegates.nocbreak nocbreak;
  486. public readonly Delegates.noecho noecho;
  487. public readonly Delegates.nonl nonl;
  488. public readonly Delegates.noqiflush noqiflush;
  489. public readonly Delegates.noraw noraw;
  490. public readonly Delegates.notimeout notimeout;
  491. public readonly Delegates.qiflush qiflush;
  492. public readonly Delegates.raw raw;
  493. public readonly Delegates.redrawwin redrawwin;
  494. public readonly Delegates.refresh refresh;
  495. public readonly Delegates.reset_prog_mode reset_prog_mode;
  496. public readonly Delegates.reset_shell_mode reset_shell_mode;
  497. public readonly Delegates.resetty resetty;
  498. public readonly Delegates.resize_term resize_term;
  499. public readonly Delegates.resizeterm resizeterm;
  500. public readonly Delegates.savetty savetty;
  501. public readonly Delegates.scrollok scrollok;
  502. public readonly Delegates.set_escdelay set_escdelay;
  503. public readonly Delegates.setscrreg setscrreg;
  504. public readonly Delegates.start_color start_color;
  505. public readonly Delegates.timeout timeout;
  506. public readonly Delegates.typeahead typeahead;
  507. public readonly Delegates.ungetch ungetch;
  508. public readonly Delegates.ungetmouse ungetmouse;
  509. public readonly Delegates.use_default_colors use_default_colors;
  510. public readonly Delegates.use_env use_env;
  511. public readonly Delegates.waddch waddch;
  512. public readonly Delegates.wmove wmove;
  513. //public readonly Delegates.wredrawwin wredrawwin;
  514. public readonly Delegates.wnoutrefresh wnoutrefresh;
  515. public readonly Delegates.wrefresh wrefresh;
  516. public readonly Delegates.wsetscrreg wsetscrreg;
  517. public readonly Delegates.wtimeout wtimeout;
  518. public UnmanagedLibrary UnmanagedLibrary;
  519. public NativeMethods (UnmanagedLibrary lib)
  520. {
  521. UnmanagedLibrary = lib;
  522. initscr = lib.GetNativeMethodDelegate<Delegates.initscr> ("initscr");
  523. endwin = lib.GetNativeMethodDelegate<Delegates.endwin> ("endwin");
  524. isendwin = lib.GetNativeMethodDelegate<Delegates.isendwin> ("isendwin");
  525. cbreak = lib.GetNativeMethodDelegate<Delegates.cbreak> ("cbreak");
  526. nocbreak = lib.GetNativeMethodDelegate<Delegates.nocbreak> ("nocbreak");
  527. echo = lib.GetNativeMethodDelegate<Delegates.echo> ("echo");
  528. noecho = lib.GetNativeMethodDelegate<Delegates.noecho> ("noecho");
  529. halfdelay = lib.GetNativeMethodDelegate<Delegates.halfdelay> ("halfdelay");
  530. raw = lib.GetNativeMethodDelegate<Delegates.raw> ("raw");
  531. noraw = lib.GetNativeMethodDelegate<Delegates.noraw> ("noraw");
  532. noqiflush = lib.GetNativeMethodDelegate<Delegates.noqiflush> ("noqiflush");
  533. qiflush = lib.GetNativeMethodDelegate<Delegates.qiflush> ("qiflush");
  534. typeahead = lib.GetNativeMethodDelegate<Delegates.typeahead> ("typeahead");
  535. timeout = lib.GetNativeMethodDelegate<Delegates.timeout> ("timeout");
  536. wtimeout = lib.GetNativeMethodDelegate<Delegates.wtimeout> ("wtimeout");
  537. notimeout = lib.GetNativeMethodDelegate<Delegates.notimeout> ("notimeout");
  538. keypad = lib.GetNativeMethodDelegate<Delegates.keypad> ("keypad");
  539. meta = lib.GetNativeMethodDelegate<Delegates.meta> ("meta");
  540. intrflush = lib.GetNativeMethodDelegate<Delegates.intrflush> ("intrflush");
  541. clearok = lib.GetNativeMethodDelegate<Delegates.clearok> ("clearok");
  542. idlok = lib.GetNativeMethodDelegate<Delegates.idlok> ("idlok");
  543. idcok = lib.GetNativeMethodDelegate<Delegates.idcok> ("idcok");
  544. immedok = lib.GetNativeMethodDelegate<Delegates.immedok> ("immedok");
  545. leaveok = lib.GetNativeMethodDelegate<Delegates.leaveok> ("leaveok");
  546. wsetscrreg = lib.GetNativeMethodDelegate<Delegates.wsetscrreg> ("wsetscrreg");
  547. scrollok = lib.GetNativeMethodDelegate<Delegates.scrollok> ("scrollok");
  548. nl = lib.GetNativeMethodDelegate<Delegates.nl> ("nl");
  549. nonl = lib.GetNativeMethodDelegate<Delegates.nonl> ("nonl");
  550. setscrreg = lib.GetNativeMethodDelegate<Delegates.setscrreg> ("setscrreg");
  551. refresh = lib.GetNativeMethodDelegate<Delegates.refresh> ("refresh");
  552. doupdate = lib.GetNativeMethodDelegate<Delegates.doupdate> ("doupdate");
  553. wrefresh = lib.GetNativeMethodDelegate<Delegates.wrefresh> ("wrefresh");
  554. redrawwin = lib.GetNativeMethodDelegate<Delegates.redrawwin> ("redrawwin");
  555. //wredrawwin = lib.GetNativeMethodDelegate<Delegates.wredrawwin> ("wredrawwin");
  556. wnoutrefresh = lib.GetNativeMethodDelegate<Delegates.wnoutrefresh> ("wnoutrefresh");
  557. move = lib.GetNativeMethodDelegate<Delegates.move> ("move");
  558. curs_set = lib.GetNativeMethodDelegate<Delegates.curs_set> ("curs_set");
  559. addch = lib.GetNativeMethodDelegate<Delegates.addch> ("addch");
  560. echochar = lib.GetNativeMethodDelegate<Delegates.echochar> ("echochar");
  561. mvaddch = lib.GetNativeMethodDelegate<Delegates.mvaddch> ("mvaddch");
  562. addwstr = lib.GetNativeMethodDelegate<Delegates.addwstr> ("addwstr");
  563. mvaddwstr = lib.GetNativeMethodDelegate<Delegates.mvaddwstr> ("mvaddwstr");
  564. wmove = lib.GetNativeMethodDelegate<Delegates.wmove> ("wmove");
  565. waddch = lib.GetNativeMethodDelegate<Delegates.waddch> ("waddch");
  566. attron = lib.GetNativeMethodDelegate<Delegates.attron> ("attron");
  567. attroff = lib.GetNativeMethodDelegate<Delegates.attroff> ("attroff");
  568. attrset = lib.GetNativeMethodDelegate<Delegates.attrset> ("attrset");
  569. getch = lib.GetNativeMethodDelegate<Delegates.getch> ("getch");
  570. get_wch = lib.GetNativeMethodDelegate<Delegates.get_wch> ("get_wch");
  571. ungetch = lib.GetNativeMethodDelegate<Delegates.ungetch> ("ungetch");
  572. mvgetch = lib.GetNativeMethodDelegate<Delegates.mvgetch> ("mvgetch");
  573. has_colors = lib.GetNativeMethodDelegate<Delegates.has_colors> ("has_colors");
  574. start_color = lib.GetNativeMethodDelegate<Delegates.start_color> ("start_color");
  575. init_pair = lib.GetNativeMethodDelegate<Delegates.init_pair> ("init_pair");
  576. use_default_colors = lib.GetNativeMethodDelegate<Delegates.use_default_colors> ("use_default_colors");
  577. COLOR_PAIRS = lib.GetNativeMethodDelegate<Delegates.COLOR_PAIRS> ("COLOR_PAIRS");
  578. getmouse = lib.GetNativeMethodDelegate<Delegates.getmouse> ("getmouse");
  579. ungetmouse = lib.GetNativeMethodDelegate<Delegates.ungetmouse> ("ungetmouse");
  580. mouseinterval = lib.GetNativeMethodDelegate<Delegates.mouseinterval> ("mouseinterval");
  581. mousemask = lib.GetNativeMethodDelegate<Delegates.mousemask> ("mousemask");
  582. is_term_resized = lib.GetNativeMethodDelegate<Delegates.is_term_resized> ("is_term_resized");
  583. resize_term = lib.GetNativeMethodDelegate<Delegates.resize_term> ("resize_term");
  584. resizeterm = lib.GetNativeMethodDelegate<Delegates.resizeterm> ("resizeterm");
  585. use_env = lib.GetNativeMethodDelegate<Delegates.use_env> ("use_env");
  586. flushinp = lib.GetNativeMethodDelegate<Delegates.flushinp> ("flushinp");
  587. def_prog_mode = lib.GetNativeMethodDelegate<Delegates.def_prog_mode> ("def_prog_mode");
  588. def_shell_mode = lib.GetNativeMethodDelegate<Delegates.def_shell_mode> ("def_shell_mode");
  589. reset_prog_mode = lib.GetNativeMethodDelegate<Delegates.reset_prog_mode> ("reset_prog_mode");
  590. reset_shell_mode = lib.GetNativeMethodDelegate<Delegates.reset_shell_mode> ("reset_shell_mode");
  591. savetty = lib.GetNativeMethodDelegate<Delegates.savetty> ("savetty");
  592. resetty = lib.GetNativeMethodDelegate<Delegates.resetty> ("resetty");
  593. set_escdelay = lib.GetNativeMethodDelegate<Delegates.set_escdelay> ("set_escdelay");
  594. curses_version = lib.GetNativeMethodDelegate<Delegates.curses_version> ("curses_version");
  595. }
  596. }
  597. #pragma warning restore CS1591 // Missing XML comment for publicly visible type or member
  598. #pragma warning restore CS8981 // The type name only contains lower-cased ascii characters. Such names may become reserved for the language.