You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
56 lines
1.4 KiB
56 lines
1.4 KiB
using Mindmagma.Curses;
|
|
|
|
namespace SCI.CursesWrapper;
|
|
|
|
public class CursesWrapper {
|
|
/// <summary>
|
|
/// Initializes NCurses and creates a screen
|
|
/// </summary>
|
|
public static nint InitNCurses () {
|
|
var screen = NCurses.InitScreen ();
|
|
NCurses.SetCursor (0);
|
|
NCurses.UseDefaultColors ();
|
|
NCurses.NoEcho ();
|
|
NCurses.Raw ();
|
|
NCurses.Keypad (screen, true);
|
|
NCurses.NoDelay (screen, false);
|
|
|
|
if (NCurses.HasColors ()) {
|
|
NCurses.StartColor ();
|
|
ColorSchemes.InitAll ();
|
|
}
|
|
|
|
return screen;
|
|
}
|
|
|
|
/// <summary>
|
|
/// Get the total width of a window/screen
|
|
/// </summary>
|
|
/// <param name="window">Window to query</param>
|
|
/// <returns>Width of window in columns</returns>
|
|
public static int GetWidth (nint window) {
|
|
NCurses.GetMaxYX (window, out int _, out int width);
|
|
return width;
|
|
}
|
|
|
|
/// <summary>
|
|
/// Get the total height of a window
|
|
/// </summary>
|
|
/// <param name="window">Window to query</param>
|
|
/// <returns>Height of window in rows</returns>
|
|
public static int GetHeight (nint window) {
|
|
NCurses.GetMaxYX (window, out int height, out int _);
|
|
return height;
|
|
}
|
|
|
|
/// <summary>
|
|
/// Compares a key code to a character to test for a held
|
|
/// Control key during the key press event
|
|
/// </summary>
|
|
/// <param name="keyCode"></param>
|
|
/// <param name="testChar"></param>
|
|
/// <returns></returns>
|
|
public static bool KeyPressIsCtrl (int keyCode, int testChar) {
|
|
return keyCode == (testChar & 0x1f);
|
|
}
|
|
} |