binding.cs 27 KB

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