Browse Source

* Refresh the .NET bindings. Still not complete, but quite useful already.

tags/v0.99.beta14
Sam Hocevar sam 16 years ago
parent
commit
e6e490ea58
3 changed files with 61 additions and 60 deletions
  1. +9
    -9
      csharp/Caca.cs
  2. +51
    -50
      csharp/Cucul.cs
  3. +1
    -1
      csharp/test.cs

+ 9
- 9
csharp/Caca.cs View File

@@ -146,8 +146,8 @@ namespace Caca

[DllImport("libcaca.dll", CallingConvention=CallingConvention.Cdecl),
SuppressUnmanagedCodeSecurity]
private static extern int caca_get_event_key_utf32(IntPtr ev);
public int KeyUtf32
private static extern uint caca_get_event_key_utf32(IntPtr ev);
public uint KeyUtf32
{
get { return caca_get_event_key_utf32(cevent); }
}
@@ -228,7 +228,7 @@ namespace Caca

[DllImport("libcaca.dll", CallingConvention=CallingConvention.Cdecl),
SuppressUnmanagedCodeSecurity]
private static extern void caca_free_display(IntPtr dp);
private static extern int caca_free_display(IntPtr dp);
public void Dispose()
{
caca_free_display(_c_dp);
@@ -237,7 +237,7 @@ namespace Caca

[DllImport("libcaca.dll", CallingConvention=CallingConvention.Cdecl),
SuppressUnmanagedCodeSecurity]
private static extern void caca_refresh_display(IntPtr dp);
private static extern int caca_refresh_display(IntPtr dp);
public void Refresh()
{
caca_refresh_display(_c_dp);
@@ -245,7 +245,7 @@ namespace Caca

[DllImport("libcaca.dll", CallingConvention=CallingConvention.Cdecl),
SuppressUnmanagedCodeSecurity]
private static extern void caca_set_display_time(IntPtr dp, int d);
private static extern int caca_set_display_time(IntPtr dp, int d);
[DllImport("libcaca.dll", CallingConvention=CallingConvention.Cdecl),
SuppressUnmanagedCodeSecurity]
private static extern int caca_get_display_time(IntPtr dp);
@@ -257,13 +257,13 @@ namespace Caca

[DllImport("libcaca.dll", CallingConvention=CallingConvention.Cdecl),
SuppressUnmanagedCodeSecurity]
private static extern int caca_get_event(IntPtr dp, int t,
private static extern int caca_get_event(IntPtr dp, uint t,
IntPtr cevent,
int timeout);
public CacaEvent getEvent(CacaEventType t, int timeout)
{
CacaEvent e = new CacaEvent();
caca_get_event(_c_dp, (int)t, e.cevent, timeout);
caca_get_event(_c_dp, (uint)t, e.cevent, timeout);
return e;
}

@@ -289,7 +289,7 @@ namespace Caca

[DllImport("libcaca.dll", CallingConvention=CallingConvention.Cdecl),
SuppressUnmanagedCodeSecurity]
private static extern void caca_set_mouse(IntPtr k, bool status);
private static extern int caca_set_mouse(IntPtr k, bool status);
public bool Mouse
{
set { caca_set_mouse(_c_dp, value); }
@@ -309,7 +309,7 @@ namespace Caca

[DllImport("libcaca.dll", CallingConvention=CallingConvention.Cdecl),
SuppressUnmanagedCodeSecurity]
private static extern void caca_set_cursor(IntPtr k, bool status);
private static extern int caca_set_cursor(IntPtr k, bool status);
public bool Cursor
{
set { caca_set_cursor(_c_dp, value); }


+ 51
- 50
csharp/Cucul.cs View File

@@ -39,29 +39,29 @@ namespace Cucul
return Marshal.PtrToStringAnsi(cucul_get_version());
}

public const int BLACK = 0x00,
BLUE = 0x01,
GREEN = 0x02,
CYAN = 0x03,
RED = 0x04,
MAGENTA = 0x05,
BROWN = 0x06,
LIGHTGRAY = 0x07,
DARKGRAY = 0x08,
LIGHTBLUE = 0x09,
LIGHTGREEN = 0x0a,
LIGHTCYAN = 0x0b,
LIGHTRED = 0x0c,
LIGHTMAGENTA = 0x0d,
YELLOW = 0x0e,
WHITE = 0x0f,
DEFAULT = 0x10,
TRANSPARENT = 0x20;
public const int BOLD = 0x01,
ITALICS = 0x02,
UNDERLINE = 0x04,
BLINK = 0x08;
public const uint BLACK = 0x00,
BLUE = 0x01,
GREEN = 0x02,
CYAN = 0x03,
RED = 0x04,
MAGENTA = 0x05,
BROWN = 0x06,
LIGHTGRAY = 0x07,
DARKGRAY = 0x08,
LIGHTBLUE = 0x09,
LIGHTGREEN = 0x0a,
LIGHTCYAN = 0x0b,
LIGHTRED = 0x0c,
LIGHTMAGENTA = 0x0d,
YELLOW = 0x0e,
WHITE = 0x0f,
DEFAULT = 0x10,
TRANSPARENT = 0x20;
public const uint BOLD = 0x01,
ITALICS = 0x02,
UNDERLINE = 0x04,
BLINK = 0x08;
}

public class CuculCanvas : IDisposable
@@ -143,26 +143,26 @@ namespace Cucul
[DllImport("libcucul.dll", CallingConvention=CallingConvention.Cdecl),
SuppressUnmanagedCodeSecurity]
private static extern int cucul_put_char(IntPtr cv,
int x, int y, int c);
public int putChar(Point p, int c)
int x, int y, uint c);
public int putChar(Point p, uint c)
{
return cucul_put_char(_c_cv, p.X, p.Y, c);
}

public int putChar(int x, int y, int c)
public int putChar(int x, int y, uint c)
{
return cucul_put_char(_c_cv, x, y, c);
}

[DllImport("libcucul.dll", CallingConvention=CallingConvention.Cdecl),
SuppressUnmanagedCodeSecurity]
private static extern int cucul_get_char(IntPtr cv, int x, int y);
public int getChar(Point p)
private static extern uint cucul_get_char(IntPtr cv, int x, int y);
public uint getChar(Point p)
{
return cucul_get_char(_c_cv, p.X, p.Y);
}

public int getChar(int x, int y)
public uint getChar(int x, int y)
{
return cucul_get_char(_c_cv, x, y);
}
@@ -196,8 +196,8 @@ namespace Cucul

[DllImport("libcucul.dll", CallingConvention=CallingConvention.Cdecl),
SuppressUnmanagedCodeSecurity]
private static extern int cucul_set_attr(IntPtr cv, int a);
public int setAttr(int a)
private static extern int cucul_set_attr(IntPtr cv, uint a);
public int setAttr(uint a)
{
return cucul_set_attr(_c_cv, a);
}
@@ -205,13 +205,13 @@ namespace Cucul
[DllImport("libcucul.dll", CallingConvention=CallingConvention.Cdecl),
SuppressUnmanagedCodeSecurity]
private static extern int cucul_put_attr(IntPtr cv,
int x, int y, int a);
public int putAttr(Point p, int a)
int x, int y, uint a);
public int putAttr(Point p, uint a)
{
return cucul_put_attr(_c_cv, p.X, p.Y, a);
}

public int putAttr(int x, int y, int a)
public int putAttr(int x, int y, uint a)
{
return cucul_put_attr(_c_cv, x, y, a);
}
@@ -220,7 +220,7 @@ namespace Cucul
SuppressUnmanagedCodeSecurity]
private static extern int cucul_set_color_ansi(IntPtr cv,
byte fg, byte bg);
public int setColorAnsi(int fg, int bg)
public int setColorAnsi(uint fg, uint bg)
{
return cucul_set_color_ansi(_c_cv, (byte)fg, (byte)bg);
}
@@ -228,8 +228,8 @@ namespace Cucul
[DllImport("libcucul.dll", CallingConvention=CallingConvention.Cdecl),
SuppressUnmanagedCodeSecurity]
private static extern int cucul_set_color_argb(IntPtr cv,
int fg, int bg);
public int setColorArgb(int fg, int bg)
uint fg, uint bg);
public int setColorArgb(uint fg, uint bg)
{
return cucul_set_color_argb(_c_cv, fg, bg);
}
@@ -683,16 +683,16 @@ namespace Cucul

public class CuculAttr
{
private int _attr;
private uint _attr;

public CuculAttr(int attr)
public CuculAttr(uint attr)
{
_attr = attr;
}

[DllImport("libcucul.dll", CallingConvention=CallingConvention.Cdecl),
SuppressUnmanagedCodeSecurity]
private static extern byte cucul_attr_to_ansi(Int32 a);
private static extern byte cucul_attr_to_ansi(uint a);
public byte toAnsi()
{
return cucul_attr_to_ansi(_attr);
@@ -700,7 +700,7 @@ namespace Cucul

[DllImport("libcucul.dll", CallingConvention=CallingConvention.Cdecl),
SuppressUnmanagedCodeSecurity]
private static extern byte cucul_attr_to_ansi_fg(Int32 a);
private static extern byte cucul_attr_to_ansi_fg(uint a);
public byte toAnsiFg()
{
return cucul_attr_to_ansi_fg(_attr);
@@ -708,7 +708,7 @@ namespace Cucul

[DllImport("libcucul.dll", CallingConvention=CallingConvention.Cdecl),
SuppressUnmanagedCodeSecurity]
private static extern byte cucul_attr_to_ansi_bg(Int32 a);
private static extern byte cucul_attr_to_ansi_bg(uint a);
public byte toAnsiBg()
{
return cucul_attr_to_ansi_bg(_attr);
@@ -723,10 +723,10 @@ namespace Cucul
SuppressUnmanagedCodeSecurity]
private static extern IntPtr cucul_create_dither(int bpp, int w,
int h, int pitch,
ulong rmask,
ulong gmask,
ulong bmask,
ulong amask);
uint rmask,
uint gmask,
uint bmask,
uint amask);
public CuculDither(int bpp, Size s, int pitch,
uint rmask, uint gmask, uint bmask, uint amask)
{
@@ -748,8 +748,8 @@ namespace Cucul
[DllImport("libcucul.dll", CallingConvention=CallingConvention.Cdecl),
SuppressUnmanagedCodeSecurity]
private static extern int cucul_set_dither_palette(IntPtr d,
int[] r, int[] g,
int[] b, int[] a);
uint[] r, uint[] g,
uint[] b, uint[] a);
[DllImport("libcucul.dll", CallingConvention=CallingConvention.Cdecl),
SuppressUnmanagedCodeSecurity]
private static extern int cucul_set_dither_brightness(IntPtr d, float b);
@@ -859,7 +859,7 @@ namespace Cucul

[DllImport("libcucul.dll", CallingConvention=CallingConvention.Cdecl),
SuppressUnmanagedCodeSecurity]
private static extern IntPtr cucul_load_font(IntPtr data, int len);
private static extern IntPtr cucul_load_font(IntPtr data, uint len);
public CuculFont(string s)
{
IntPtr name = Marshal.StringToHGlobalAnsi(s);
@@ -870,7 +870,8 @@ namespace Cucul
public CuculFont(byte[] buf)
{
GCHandle _gch = GCHandle.Alloc(buf, GCHandleType.Pinned);
_font = cucul_load_font(_gch.AddrOfPinnedObject(), buf.Length);
_font = cucul_load_font(_gch.AddrOfPinnedObject(),
(uint)buf.Length);
}

[DllImport("libcucul.dll", CallingConvention=CallingConvention.Cdecl),


+ 1
- 1
csharp/test.cs View File

@@ -63,7 +63,7 @@ class DemoCanvas : CuculCanvas
Point p1 = new Point(0, (int)v);
Point p2 = new Point(Size.Width - 1, (int)v);

setColorAnsi(i + 9, Libcucul.BLACK);
setColorAnsi((uint)(i + 9), Libcucul.BLACK);
/* drawLine is already clipped, we don't care about overflows */
drawLine(p1 + new Size(0, -2), p2 + new Size(0, -2), '-');
drawLine(p1 + new Size(0, -1), p2 + new Size(0, -1), '*');


Loading…
Cancel
Save