diff --git a/DotNet/Cucul.cs b/DotNet/Cucul.cs index 8fedb71..89f8fde 100644 --- a/DotNet/Cucul.cs +++ b/DotNet/Cucul.cs @@ -18,13 +18,13 @@ using System.Runtime.InteropServices; using System.Security; - namespace libCucul { - public unsafe class Cucul : IDisposable + + public unsafe class Cucul : IDisposable { /* Fixme */ - [DllImport("libCucul.dll", CallingConvention=CallingConvention.Cdecl), SuppressUnmanagedCodeSecurity] + [DllImport("libCucul.dll", CallingConvention=CallingConvention.Cdecl), SuppressUnmanagedCodeSecurity] public static extern IntPtr cucul_create_canvas(int w, int h); [DllImport("libCucul.dll", CallingConvention=CallingConvention.Cdecl), SuppressUnmanagedCodeSecurity] public static extern Int32 cucul_get_canvas_width(IntPtr qq); @@ -42,8 +42,9 @@ namespace libCucul public static extern Int32 cucul_set_truecolor(IntPtr qq, Int32 fg, Int32 bg); [DllImport("libCucul.dll", CallingConvention=CallingConvention.Cdecl), SuppressUnmanagedCodeSecurity] public static extern Int32 cucul_putchar(IntPtr qq, int x, int y, char c); - /* [DllImport("libCucul.dll", CallingConvention=CallingConvention.Cdecl), SuppressUnmanagedCodeSecurity] - public static extern Int32 cucul_putstr(IntPtr qq, int, int, String);*/ + [DllImport("libCucul.dll", CallingConvention=CallingConvention.Cdecl), SuppressUnmanagedCodeSecurity] + public static extern Int32 cucul_putstr(IntPtr qq, int x , int y, String c); + [DllImport("libCucul.dll", CallingConvention=CallingConvention.Cdecl), SuppressUnmanagedCodeSecurity] public static extern Int32 cucul_clear_canvas(IntPtr qq); [DllImport("libCucul.dll", CallingConvention=CallingConvention.Cdecl), SuppressUnmanagedCodeSecurity] @@ -57,16 +58,81 @@ namespace libCucul [DllImport("libCucul.dll", CallingConvention=CallingConvention.Cdecl), SuppressUnmanagedCodeSecurity] public static extern Int32 cucul_draw_thin_polyline(IntPtr qq, Int32[] x, Int32[] y, Int32 n); + [DllImport("libCucul.dll", CallingConvention=CallingConvention.Cdecl), SuppressUnmanagedCodeSecurity] + public static extern Int32 cucul_gotoxy(IntPtr qq, Int32 x, Int32 y); + [DllImport("libCucul.dll", CallingConvention=CallingConvention.Cdecl), SuppressUnmanagedCodeSecurity] + public static extern Int32 cucul_get_cursor_x(IntPtr qq); + [DllImport("libCucul.dll", CallingConvention=CallingConvention.Cdecl), SuppressUnmanagedCodeSecurity] + public static extern Int32 cucul_get_cursor_y(IntPtr qq); + [DllImport("libCucul.dll", CallingConvention=CallingConvention.Cdecl), SuppressUnmanagedCodeSecurity] + public static extern Int32 cucul_put_char(IntPtr qq, Int32 x, Int32 y, Int32 c); + [DllImport("libCucul.dll", CallingConvention=CallingConvention.Cdecl), SuppressUnmanagedCodeSecurity] + public static extern Int32 cucul_get_char(IntPtr qq, Int32 x, Int32 y); + [DllImport("libCucul.dll", CallingConvention=CallingConvention.Cdecl), SuppressUnmanagedCodeSecurity] + public static extern Int32 cucul_put_str(IntPtr qq, Int32 x, Int32 y, string c); + [DllImport("libCucul.dll", CallingConvention=CallingConvention.Cdecl), SuppressUnmanagedCodeSecurity] + public static extern Int32 cucul_get_attr(IntPtr qq, Int32 x, Int32 y); + [DllImport("libCucul.dll", CallingConvention=CallingConvention.Cdecl), SuppressUnmanagedCodeSecurity] + public static extern Int32 cucul_set_attr(IntPtr qq, Int32 a); + [DllImport("libCucul.dll", CallingConvention=CallingConvention.Cdecl), SuppressUnmanagedCodeSecurity] + public static extern Int32 cucul_put_attr(IntPtr qq, Int32 x, Int32 y, Int32 a); + [DllImport("libCucul.dll", CallingConvention=CallingConvention.Cdecl), SuppressUnmanagedCodeSecurity] + public static extern Int32 cucul_set_color_ansi(IntPtr qq, Int32 fg, Int32 bg); + [DllImport("libCucul.dll", CallingConvention=CallingConvention.Cdecl), SuppressUnmanagedCodeSecurity] + public static extern Int32 cucul_set_color_argb(IntPtr qq, Int32 fg, Int32 bg); + [DllImport("libCucul.dll", CallingConvention=CallingConvention.Cdecl), SuppressUnmanagedCodeSecurity] + public static extern Int32 cucul_set_canvas_handle(IntPtr qq, Int32 x, Int32 y); + [DllImport("libCucul.dll", CallingConvention=CallingConvention.Cdecl), SuppressUnmanagedCodeSecurity] + public static extern Int32 cucul_get_canvas_handle_x(IntPtr qq); + [DllImport("libCucul.dll", CallingConvention=CallingConvention.Cdecl), SuppressUnmanagedCodeSecurity] + public static extern Int32 cucul_get_canvas_handle_y(IntPtr qq); + [DllImport("libCucul.dll", CallingConvention=CallingConvention.Cdecl), SuppressUnmanagedCodeSecurity] + public static extern Int32 cucul_set_canvas_boundaries(IntPtr qq, Int32 x, Int32 y, + Int32 h, Int32 w); + + [DllImport("libCucul.dll", CallingConvention=CallingConvention.Cdecl), SuppressUnmanagedCodeSecurity] + public static extern Int32 cucul_invert(IntPtr qq); + [DllImport("libCucul.dll", CallingConvention=CallingConvention.Cdecl), SuppressUnmanagedCodeSecurity] + public static extern Int32 cucul_flip(IntPtr qq); + [DllImport("libCucul.dll", CallingConvention=CallingConvention.Cdecl), SuppressUnmanagedCodeSecurity] + public static extern Int32 cucul_flop(IntPtr qq); + [DllImport("libCucul.dll", CallingConvention=CallingConvention.Cdecl), SuppressUnmanagedCodeSecurity] + public static extern Int32 cucul_rotate(IntPtr qq); + + [DllImport("libCucul.dll", CallingConvention=CallingConvention.Cdecl), SuppressUnmanagedCodeSecurity] + public static extern Int32 cucul_attr_to_ansi(Int64 a); + [DllImport("libCucul.dll", CallingConvention=CallingConvention.Cdecl), SuppressUnmanagedCodeSecurity] + public static extern Int32 cucul_attr_to_ansi_fg(Int64 a); + [DllImport("libCucul.dll", CallingConvention=CallingConvention.Cdecl), SuppressUnmanagedCodeSecurity] + public static extern Int32 cucul_attr_to_ansi_bg(Int64 a); + /* Constants */ - /* - char const *cucul_get_color_name(unsigned int); - int cucul_putstr(IntPtr *, int, int, char const *); - int cucul_printf(IntPtr *, int, int, char const *, ...); - */ + public const Int32 CUCUL_BLACK = 0x00; /**< The colour index for black. */ + public const Int32 CUCUL_BLUE = 0x01; /**< The colour index for blue. */ + public const Int32 CUCUL_GREEN = 0x02; /**< The colour index for green. */ + public const Int32 CUCUL_CYAN = 0x03; /**< The colour index for cyan. */ + public const Int32 CUCUL_RED = 0x04; /**< The colour index for red. */ + public const Int32 CUCUL_MAGENTA = 0x05; /**< The colour index for magenta. */ + public const Int32 CUCUL_BROWN = 0x06; /**< The colour index for brown. */ + public const Int32 CUCUL_LIGHTGRAY = 0x07; /**< The colour index for light gray. */ + public const Int32 CUCUL_DARKGRAY = 0x08; /**< The colour index for dark gray. */ + public const Int32 CUCUL_LIGHTBLUE = 0x09; /**< The colour index for blue. */ + public const Int32 CUCUL_LIGHTGREEN = 0x0a; /**< The colour index for light green. */ + public const Int32 CUCUL_LIGHTCYAN = 0x0b; /**< The colour index for light cyan. */ + public const Int32 CUCUL_LIGHTRED = 0x0c; /**< The colour index for light red. */ + public const Int32 CUCUL_LIGHTMAGENTA = 0x0d; /**< The colour index for light magenta. */ + public const Int32 CUCUL_YELLOW = 0x0e; /**< The colour index for yellow. */ + public const Int32 CUCUL_WHITE = 0x0f; /**< The colour index for white. */ + public const Int32 CUCUL_DEFAULT = 0x10; /**< The output driver's default colour. */ + public const Int32 CUCUL_TRANSPARENT = 0x20; /**< The transparent colour. */ + public const Int32 CUCUL_BOLD = 0x01; /**< The style mask for bold. */ + public const Int32 CUCUL_ITALICS = 0x02; /**< The style mask for italics. */ + public const Int32 CUCUL_UNDERLINE = 0x04; /**< The style mask for underline. */ + public const Int32 CUCUL_BLINK = 0x08; /**< The style mask for blink. */ IntPtr qq; @@ -124,20 +190,100 @@ namespace libCucul { return cucul_draw_line(qq, x1, y1, x2, y2, c); } + public Int32 putStr(Int32 x, Int32 y, string c) + { + return cucul_putstr(qq, x, y, c); + } + public Int32 gotoXY(Int32 x, Int32 y) + { + return cucul_gotoxy(qq, x, y); + } + public Int32 getCursorX() + { + return cucul_get_cursor_x(qq); + } + public Int32 getCursorY() + { + return cucul_get_cursor_y(qq); + } + public Int32 getChar(Int32 x, Int32 y) + { + return cucul_get_char(qq, x, y); + } + public Int32 getAttr(Int32 x, Int32 y) + { + return cucul_get_attr(qq, x, y); + } + public Int32 setAttr(Int32 a) + { + return cucul_set_attr(qq, a); + } + public Int32 setAttr(Int32 x, Int32 y, Int32 a) + { + return cucul_put_attr(qq, x, y, a); + } + public Int32 setColorANSI(Int32 fg, Int32 bg) + { + return cucul_set_color_ansi(qq, fg, bg); + } + public Int32 setColorARGB(Int32 fg, Int32 bg) + { + return cucul_set_color_ansi(qq, fg, bg); + } + public Int32 setCanvasHandle(Int32 x, Int32 y) + { + return cucul_set_canvas_handle(qq, x, y); + } + public Int32 getCanvasHandleX() + { + return cucul_get_canvas_handle_x(qq); + } + public Int32 getCanvasHandleY() + { + return cucul_get_canvas_handle_y(qq); + } + public Int32 setCanvasHandleY(Int32 x, Int32 y, Int32 h, Int32 w) + { + return cucul_set_canvas_boundaries(qq, x, y, h, w); + } + + + public Int32 Invert() + { + return cucul_invert(qq); + } + public Int32 Flip() + { + return cucul_flip(qq); + } + public Int32 Flop() + { + return cucul_flop(qq); + } + public Int32 Rotate() + { + return cucul_rotate(qq); + } + + public Int32 AttrToANSI(Int64 a) + { + return cucul_attr_to_ansi(a); + } + public Int32 AttrToANSIFg(Int64 a) + { + return cucul_attr_to_ansi_fg(a); + } + public Int32 AttrToANSIBg(Int64 a) + { + return cucul_attr_to_ansi_bg(a); + } + - /* - [DllImport("libCucul.dll", CallingConvention=CallingConvention.Cdecl), SuppressUnmanagedCodeSecurity] - public static extern Int32 cucul_draw_polyline(IntPtr qq, Int32[] x, Int32[] y, Int32 n, IntPtr c); - [DllImport("libCucul.dll", CallingConvention=CallingConvention.Cdecl), SuppressUnmanagedCodeSecurity] - public static extern Int32 cucul_draw_thin_line(IntPtr qq, Int32 x1, Int32 y1, Int32 x2, Int32 y2); - [DllImport("libCucul.dll", CallingConvention=CallingConvention.Cdecl), SuppressUnmanagedCodeSecurity] - public static extern Int32 cucul_draw_thin_polyline(IntPtr qq, Int32[] x, Int32[] y, Int32 n); - */ diff --git a/DotNet/test.cs b/DotNet/test.cs index 5747fd3..177aeaf 100644 --- a/DotNet/test.cs +++ b/DotNet/test.cs @@ -39,10 +39,16 @@ class Test { qq.putChar(0,0, 'J'); + qq.setColor(Cucul.CUCUL_BLUE, Cucul.CUCUL_RED); qq.drawLine(10, 15, 45, 27, "#"); + qq.putStr(10, 10, "Hello from .NET"); + Console.WriteLine("Char at 0,0 : {0}", qq.getChar(0,0)); + + qq.Flip(); + /* We have a proper canvas, let's display it using Caca */ Caca kk = new Caca(qq); kk.setDisplayTime(2000000); // Refresh every 2 seconds