mirror of
https://github.com/ahwootech/BRUTAL.git
synced 2026-11-26 04:58:24 +01:00
first
This commit is contained in:
parent
bd62d51ec9
commit
b578433e37
1 changed files with 784842 additions and 0 deletions
36
Brutal.NotCurses/NotCursesHandle.cs
Normal file
36
Brutal.NotCurses/NotCursesHandle.cs
Normal file
|
|
@ -0,0 +1,36 @@
|
|||
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));
|
||||
}
|
||||
Loading…
Reference in a new issue