mirror of
https://github.com/ahwootech/BRUTAL.git
synced 2026-11-25 12:38:24 +01:00
36 lines
1.7 KiB
C#
36 lines
1.7 KiB
C#
using Brutal.Pointers;
|
|
|
|
namespace Brutal.NotCursesApi;
|
|
|
|
/// <summary>
|
|
/// Hand-written ergonomics for the notcurses fullscreen-mode handle. Most methods on this handle
|
|
/// are auto-generated by <c>Brutal.NotCurses.Generate</c> (see <c>Generated/Wrappers.gen.cs</c>);
|
|
/// only the things the generator can't infer (static factories, the IDisposable contract) live here.
|
|
/// </summary>
|
|
public readonly unsafe partial struct NotCursesHandle : IDisposable
|
|
{
|
|
/// <summary>
|
|
/// Initializes notcurses in fullscreen mode, writing to <c>stdout</c>. Throws if the terminal
|
|
/// is incompatible. Dispose (or call <see cref="Stop"/>) to restore the terminal.
|
|
/// </summary>
|
|
public static NotCursesHandle Init(NotCursesOptions options = default)
|
|
{
|
|
var nc = NotCurses.PInvoke.notcurses_core_init(new Ptr<NotCursesOptions>(&options), default);
|
|
if (nc.IsNull())
|
|
throw new InvalidOperationException(
|
|
"notcurses_core_init failed (terminal incompatible or already in fullscreen mode)."
|
|
);
|
|
return nc;
|
|
}
|
|
|
|
/// <summary>Restores the terminal and tears down notcurses state. Calls <see cref="Stop"/>.</summary>
|
|
public void Dispose() => Stop();
|
|
|
|
/// <summary>
|
|
/// Blits <paramref name="visual"/> to a fresh child plane and returns that plane. Auto-generation
|
|
/// skipped this one because its C name (<c>ncvisual_blit</c>) doesn't carry the <c>notcurses_</c>
|
|
/// owner prefix even though it takes a notcurses handle first.
|
|
/// </summary>
|
|
public NcPlaneHandle Blit(NcVisualHandle visual, NcVisualOptions options = default) =>
|
|
NotCurses.PInvoke.ncvisual_blit(this, visual, new Ptr<NcVisualOptions>(&options));
|
|
}
|