Expose some Curses APIs to the public

This commit is contained in:
Miguel de Icaza
2019-03-14 09:39:56 -04:00
parent 866411ce39
commit 82398758e2
4 changed files with 16 additions and 9 deletions

View File

@@ -16,7 +16,7 @@ namespace Terminal.Gui {
/// <summary> /// <summary>
/// This is the Curses driver for the gui.cs/Terminal framework. /// This is the Curses driver for the gui.cs/Terminal framework.
/// </summary> /// </summary>
internal class CursesDriver : ConsoleDriver { public class CursesDriver : ConsoleDriver {
Action terminalResized; Action terminalResized;
public override int Cols => Curses.Cols; public override int Cols => Curses.Cols;
@@ -70,9 +70,16 @@ namespace Terminal.Gui {
public Curses.Window window; public Curses.Window window;
static short last_color_pair = 16; static short last_color_pair = 16;
static Attribute MakeColor (short f, short b)
/// <summary>
/// Creates a curses color from the provided foreground and background colors
/// </summary>
/// <param name="foreground">Contains the curses attributes for the foreground (color, plus any attributes)</param>
/// <param name="background">Contains the curses attributes for the background (color, plus any attributes)</param>
/// <returns></returns>
public static Attribute MakeColor (short foreground, short background)
{ {
Curses.InitColorPair (++last_color_pair, f, b); Curses.InitColorPair (++last_color_pair, foreground, background);
return new Attribute () { value = Curses.ColorPair (last_color_pair) }; return new Attribute () { value = Curses.ColorPair (last_color_pair) };
} }

View File

@@ -48,9 +48,9 @@ using Mono.Terminal.Internal;
namespace Unix.Terminal { namespace Unix.Terminal {
internal partial class Curses { public partial class Curses {
[StructLayout (LayoutKind.Sequential)] [StructLayout (LayoutKind.Sequential)]
internal struct MouseEvent { public struct MouseEvent {
public short ID; public short ID;
public int X, Y, Z; public int X, Y, Z;
public Event ButtonState; public Event ButtonState;

View File

@@ -5,7 +5,7 @@
using System; using System;
namespace Unix.Terminal { namespace Unix.Terminal {
internal partial class Curses { public partial class Curses {
public const int A_NORMAL = unchecked((int)0x0); public const int A_NORMAL = unchecked((int)0x0);
public const int A_STANDOUT = unchecked((int)0x10000); public const int A_STANDOUT = unchecked((int)0x10000);
public const int A_UNDERLINE = unchecked((int)0x20000); public const int A_UNDERLINE = unchecked((int)0x20000);
@@ -49,7 +49,7 @@ namespace Unix.Terminal {
public const int COLOR_CYAN = unchecked((int)0x6); public const int COLOR_CYAN = unchecked((int)0x6);
public const int COLOR_WHITE = unchecked((int)0x7); public const int COLOR_WHITE = unchecked((int)0x7);
public const int KEY_CODE_YES = unchecked((int)0x100); public const int KEY_CODE_YES = unchecked((int)0x100);
internal enum Event : long { public enum Event : long {
Button1Pressed = unchecked((int)0x2), Button1Pressed = unchecked((int)0x2),
Button1Released = unchecked((int)0x1), Button1Released = unchecked((int)0x1),
Button1Clicked = unchecked((int)0x4), Button1Clicked = unchecked((int)0x4),

View File

@@ -30,8 +30,8 @@ using System.Runtime.InteropServices;
namespace Unix.Terminal { namespace Unix.Terminal {
internal partial class Curses { public partial class Curses {
internal class Window { public class Window {
public readonly IntPtr Handle; public readonly IntPtr Handle;
static Window curscr; static Window curscr;
static Window stdscr; static Window stdscr;