mirror of
https://github.com/ahwootech/BRUTAL.git
synced 2026-11-26 04:58:24 +01:00
SOURCE DUMP v1
This commit is contained in:
parent
bd62d51ec9
commit
fb20299e9d
25 changed files with 768360 additions and 0 deletions
|
|
@ -0,0 +1,20 @@
|
|||
using System.Runtime.InteropServices.Marshalling;
|
||||
using Brutal;
|
||||
using Brutal.Interop;
|
||||
using Brutal.Pointers;
|
||||
namespace Brutal.NotCursesApi
|
||||
{
|
||||
/// Capabilities, derived from terminfo, environment variables, and queries
|
||||
public unsafe partial struct NcCapabilities
|
||||
{
|
||||
public uint Colors; // size of palette for indexed colors
|
||||
public Bool8 Utf8; // are we using utf-8 encoding? from nl_langinfo(3)
|
||||
public Bool8 Rgb; // 24bit color? COLORTERM/heuristics/terminfo 'rgb'
|
||||
public Bool8 CanChangeColors; // can we change the palette? terminfo 'ccc'
|
||||
public Bool8 Halfblocks; // we assume halfblocks, but some are known to lack them
|
||||
public Bool8 Quadrants; // do we have (good, vetted) Unicode 1 quadrant support?
|
||||
public Bool8 Sextants; // do we have (good, vetted) Unicode 13 sextant support?
|
||||
public Bool8 Octants; // do we have (good, vetted) Unicode 16 octant support?
|
||||
public Bool8 Braille; // do we have Braille support? (linux console does not)
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,65 @@
|
|||
using System.Runtime.InteropServices.Marshalling;
|
||||
using Brutal;
|
||||
using Brutal.Interop;
|
||||
using Brutal.Pointers;
|
||||
namespace Brutal.NotCursesApi
|
||||
{
|
||||
/// An nccell corresponds to a single character cell on some plane, which can be
|
||||
/// occupied by a single grapheme cluster (some root spacing glyph, along with
|
||||
/// possible combining characters, which might span multiple columns). At any
|
||||
/// cell, we can have a theoretically arbitrarily long UTF-8 EGC, a foreground
|
||||
/// color, a background color, and an attribute set. Valid grapheme cluster
|
||||
/// contents include:
|
||||
///
|
||||
/// * A NUL terminator,
|
||||
/// * A single control character, followed by a NUL terminator,
|
||||
/// * At most one spacing character, followed by zero or more nonspacing
|
||||
/// characters, followed by a NUL terminator.
|
||||
///
|
||||
/// Multi-column characters can only have a single style/color throughout.
|
||||
/// Existence is suffering, and thus wcwidth() is not reliable. It's just
|
||||
/// quoting whether or not the EGC contains a "Wide Asian" double-width
|
||||
/// character. This is set for some things, like most emoji, and not set for
|
||||
/// other things, like cuneiform. True display width is a *function of the
|
||||
/// font and terminal*. Among the longest Unicode codepoints is
|
||||
///
|
||||
/// U+FDFD ARABIC LIGATURE BISMILLAH AR-RAHMAN AR-RAHEEM ﷽
|
||||
///
|
||||
/// wcwidth() rather optimistically claims this most exalted glyph to occupy
|
||||
/// a single column. BiDi text is too complicated for me to even get into here.
|
||||
/// Be assured there are no easy answers; ours is indeed a disturbing Universe.
|
||||
///
|
||||
/// Each nccell occupies 16 static bytes (128 bits). The surface is thus ~1.6MB
|
||||
/// for a (pretty large) 500x200 terminal. At 80x43, it's less than 64KB.
|
||||
/// Dynamic requirements (the egcpool) can add up to 16MB to an ncplane, but
|
||||
/// such large pools are unlikely in common use.
|
||||
///
|
||||
/// We implement some small alpha compositing. Foreground and background both
|
||||
/// have two bits of inverted alpha. The actual grapheme written to a cell is
|
||||
/// the topmost non-zero grapheme. If its alpha is 00, its foreground color is
|
||||
/// used unchanged. If its alpha is 10, its foreground color is derived entirely
|
||||
/// from cells underneath it. Otherwise, the result will be a composite.
|
||||
/// Likewise for the background. If the bottom of a coordinate's zbuffer is
|
||||
/// reached with a cumulative alpha of zero, the default is used. In this way,
|
||||
/// a terminal configured with transparent background can be supported through
|
||||
/// multiple occluding ncplanes. A foreground alpha of 11 requests high-contrast
|
||||
/// text (relative to the computed background). A background alpha of 11 is
|
||||
/// currently forbidden.
|
||||
///
|
||||
/// Default color takes precedence over palette or RGB, and cannot be used with
|
||||
/// transparency. Indexed palette takes precedence over RGB. It cannot
|
||||
/// meaningfully set transparency, but it can be mixed into a cascading color.
|
||||
/// RGB is used if neither default terminal colors nor palette indexing are in
|
||||
/// play, and fully supports all transparency options.
|
||||
///
|
||||
/// This structure is exposed only so that most functions can be inlined. Do not
|
||||
/// directly modify or access the fields of this structure; use the API.
|
||||
public unsafe partial struct NcCell
|
||||
{
|
||||
public uint Gcluster; // 4B → 4B little endian EGC
|
||||
public byte GclusterBackstop; // 1B → 5B (8 bits of zero)
|
||||
public byte Width; // 1B → 6B (8 bits of EGC column width)
|
||||
public ushort Stylemask; // 2B → 8B (16 bits of NCSTYLE_* attributes)
|
||||
public ulong Channels; // + 8B == 16B
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,18 @@
|
|||
using System.Runtime.InteropServices.Marshalling;
|
||||
using Brutal;
|
||||
using Brutal.Interop;
|
||||
using Brutal.Pointers;
|
||||
namespace Brutal.NotCursesApi
|
||||
{
|
||||
/// read from an fd until EOF (or beyond, if follow is set), invoking the user's
|
||||
/// callback each time. runs in its own context. on EOF or error, the finalizer
|
||||
/// callback will be invoked, and the user ought destroy the ncfdplane. the
|
||||
/// data is *not* guaranteed to be nul-terminated, and may contain arbitrary
|
||||
/// zeroes.
|
||||
public unsafe partial struct NcFdPlaneOptions
|
||||
{
|
||||
public Ptr Curry; // parameter provided to callbacks
|
||||
public Bool8 Follow; // keep reading after hitting end? (think tail -f)
|
||||
public ulong Flags; // bitfield over NCOPTION_FDPLANE_*
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,27 @@
|
|||
using System.Runtime.InteropServices.Marshalling;
|
||||
using Brutal;
|
||||
using Brutal.Interop;
|
||||
using Brutal.Pointers;
|
||||
namespace Brutal.NotCursesApi
|
||||
{
|
||||
/// An input event. Cell coordinates are currently defined only for mouse
|
||||
/// events. It is not guaranteed that we can set the modifiers for a given
|
||||
/// ncinput. We encompass single Unicode codepoints, not complete EGCs.
|
||||
/// FIXME for abi4, combine the bools into |modifiers|
|
||||
public unsafe partial struct NcInput
|
||||
{
|
||||
public uint Id; // Unicode codepoint or synthesized NCKEY event
|
||||
public int Y; // y/x cell coordinate of event, -1 for undefined
|
||||
public int X; // y/x cell coordinate of event, -1 for undefined
|
||||
public fixed byte Utf8[5]; // utf8 representation, if one exists
|
||||
public Bool8 Alt; // was alt held?
|
||||
public Bool8 Shift; // was shift held?
|
||||
public Bool8 Ctrl; // was ctrl held?
|
||||
/// END DEPRECATION
|
||||
public NcInType Evtype;
|
||||
public uint Modifiers; // bitmask over NCKEY_MOD_*
|
||||
public int Ypx; // pixel offsets within cell, -1 for undefined
|
||||
public int Xpx; // pixel offsets within cell, -1 for undefined
|
||||
public fixed uint EffText[4]; // Effective
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,13 @@
|
|||
using System.Runtime.InteropServices.Marshalling;
|
||||
using Brutal;
|
||||
using Brutal.Interop;
|
||||
using Brutal.Pointers;
|
||||
namespace Brutal.NotCursesApi
|
||||
{
|
||||
public unsafe partial struct NcMSelectorItem
|
||||
{
|
||||
public Ptr<byte> Option;
|
||||
public Ptr<byte> Desc;
|
||||
public Bool8 Selected;
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,17 @@
|
|||
using System.Runtime.InteropServices.Marshalling;
|
||||
using Brutal;
|
||||
using Brutal.Interop;
|
||||
using Brutal.Pointers;
|
||||
namespace Brutal.NotCursesApi
|
||||
{
|
||||
/// Menus. Horizontal menu bars are supported, on the top and/or bottom rows.
|
||||
/// If the menu bar is longer than the screen, it will be only partially
|
||||
/// visible. Menus may be either visible or invisible by default. In the event of
|
||||
/// a plane resize, menus will be automatically moved/resized. Elements can be
|
||||
/// dynamically enabled or disabled at all levels (menu, section, and item),
|
||||
public unsafe partial struct NcMenuItem
|
||||
{
|
||||
public Ptr<byte> Desc; // utf-8 menu item, NULL for horizontal separator
|
||||
public NcInput Shortcut; // shortcut, all should be distinct
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,15 @@
|
|||
using System.Runtime.InteropServices.Marshalling;
|
||||
using Brutal;
|
||||
using Brutal.Interop;
|
||||
using Brutal.Pointers;
|
||||
namespace Brutal.NotCursesApi
|
||||
{
|
||||
public unsafe partial struct NcMenuOptions
|
||||
{
|
||||
public Ptr<NcMenuSection> Sections; // array of 'sectioncount' menu_sections
|
||||
public int Sectioncount; // must be positive
|
||||
public ulong Headerchannels; // styling for header
|
||||
public ulong Sectionchannels; // styling for sections
|
||||
public NcMenuOption Flags; // flag word of NCMENU_OPTION_*
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,14 @@
|
|||
using System.Runtime.InteropServices.Marshalling;
|
||||
using Brutal;
|
||||
using Brutal.Interop;
|
||||
using Brutal.Pointers;
|
||||
namespace Brutal.NotCursesApi
|
||||
{
|
||||
public unsafe partial struct NcMenuSection
|
||||
{
|
||||
public Ptr<byte> Name; // utf-8 c string
|
||||
public int Itemcount;
|
||||
public Ptr<NcMenuItem> Items;
|
||||
public NcInput Shortcut; // shortcut, will be underlined if present in name
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,26 @@
|
|||
using System.Runtime.InteropServices.Marshalling;
|
||||
using Brutal;
|
||||
using Brutal.Interop;
|
||||
using Brutal.Pointers;
|
||||
namespace Brutal.NotCursesApi
|
||||
{
|
||||
/// multiselection widget -- a selector supporting multiple selections.
|
||||
///
|
||||
/// Unlike the selector widget, zero to all of the items can be selected, but
|
||||
/// also the widget does not support adding or removing items at runtime.
|
||||
public unsafe partial struct NcMultiSelectorOptions
|
||||
{
|
||||
public Ptr<byte> Title; // title may be NULL, inhibiting riser, saving two rows.
|
||||
public Ptr<byte> Secondary; // secondary may be NULL
|
||||
public Ptr<byte> Footer; // footer may be NULL
|
||||
public Ptr<NcMSelectorItem> Items; // initial items, descriptions, and statuses
|
||||
/// maximum number of options to display at once, 0 to use all available space
|
||||
public uint Maxdisplay;
|
||||
public ulong Opchannels; // option channels
|
||||
public ulong Descchannels; // description channels
|
||||
public ulong Titlechannels; // title channels
|
||||
public ulong Footchannels; // secondary and footer channels
|
||||
public ulong Boxchannels; // border channels
|
||||
public ulong Flags; // bitfield of NCMULTISELECTOR_OPTION_*, currently unused
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,15 @@
|
|||
using System.Runtime.InteropServices.Marshalling;
|
||||
using Brutal;
|
||||
using Brutal.Interop;
|
||||
using Brutal.Pointers;
|
||||
namespace Brutal.NotCursesApi
|
||||
{
|
||||
/// Palette API. Some terminals only support 256 colors, but allow the full
|
||||
/// palette to be specified with arbitrary RGB colors. In all cases, it's more
|
||||
/// performant to use indexed colors, since it's much less data to write to the
|
||||
/// terminal. If you can limit yourself to 256 colors, that's probably best.
|
||||
public unsafe partial struct NcPalette
|
||||
{
|
||||
public fixed uint Chans[256]; // RGB values as regular ol' channels
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,20 @@
|
|||
using System.Runtime.InteropServices.Marshalling;
|
||||
using Brutal;
|
||||
using Brutal.Interop;
|
||||
using Brutal.Pointers;
|
||||
namespace Brutal.NotCursesApi
|
||||
{
|
||||
public unsafe partial struct NcPlaneOptions
|
||||
{
|
||||
public int Y; // vertical placement relative to parent plane
|
||||
public int X; // horizontal placement relative to parent plane
|
||||
public uint Rows; // rows, must be >0 unless NCPLANE_OPTION_MARGINALIZED
|
||||
public uint Cols; // columns, must be >0 unless NCPLANE_OPTION_MARGINALIZED
|
||||
public Ptr UserPtr; // user curry, may be NULL
|
||||
public Ptr<byte> Name; // name (used only for debugging), may be NULL
|
||||
public delegate* unmanaged[Cdecl]<NcPlaneHandle, int> ResizeCb; // callback when parent is resized
|
||||
public NcPlaneOption Flags; // closure over NCPLANE_OPTION_*
|
||||
public uint MarginB; // margins (require NCPLANE_OPTION_MARGINALIZED)
|
||||
public uint MarginR; // margins (require NCPLANE_OPTION_MARGINALIZED)
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,24 @@
|
|||
using System.Runtime.InteropServices.Marshalling;
|
||||
using Brutal;
|
||||
using Brutal.Interop;
|
||||
using Brutal.Pointers;
|
||||
namespace Brutal.NotCursesApi
|
||||
{
|
||||
public unsafe partial struct NcPlotOptions
|
||||
{
|
||||
/// channels for the maximum and minimum levels. linear or exponential
|
||||
/// interpolation will be applied across the domain between these two.
|
||||
public ulong Maxchannels;
|
||||
public ulong Minchannels;
|
||||
/// styling used for the legend, if NCPLOT_OPTION_LABELTICKSD is set
|
||||
public ushort Legendstyle;
|
||||
public NcBlitter Gridtype; // number of "pixels" per row x column
|
||||
/// independent variable can either be a contiguous range, or a finite set
|
||||
/// of keys. for a time range, say the previous hour sampled with second
|
||||
/// resolution, the independent variable would be the range [0..3600): 3600.
|
||||
/// if rangex is 0, it is dynamically set to the number of columns.
|
||||
public int Rangex;
|
||||
public Ptr<byte> Title; // optional, printed by the labels
|
||||
public NcPlotOption Flags; // bitfield over NCPLOT_OPTION_*
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,15 @@
|
|||
using System.Runtime.InteropServices.Marshalling;
|
||||
using Brutal;
|
||||
using Brutal.Interop;
|
||||
using Brutal.Pointers;
|
||||
namespace Brutal.NotCursesApi
|
||||
{
|
||||
public unsafe partial struct NcProgBarOptions
|
||||
{
|
||||
public uint Ulchannel; // upper-left channel. in the context of a progress bar,
|
||||
public uint Urchannel; // "up" is the direction we are progressing towards, and
|
||||
public uint Blchannel; // "bottom" is the direction of origin. for monochromatic
|
||||
public uint Brchannel; // bar, all four channels ought be the same.
|
||||
public NcProgbarOption Flags;
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,13 @@
|
|||
using System.Runtime.InteropServices.Marshalling;
|
||||
using Brutal;
|
||||
using Brutal.Interop;
|
||||
using Brutal.Pointers;
|
||||
namespace Brutal.NotCursesApi
|
||||
{
|
||||
public unsafe partial struct NcReaderOptions
|
||||
{
|
||||
public ulong Tchannels; // channels used for input
|
||||
public uint Tattrword; // attributes used for input
|
||||
public NcReaderOption Flags; // bitfield of NCREADER_OPTION_*
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,16 @@
|
|||
using System.Runtime.InteropServices.Marshalling;
|
||||
using Brutal;
|
||||
using Brutal.Interop;
|
||||
using Brutal.Pointers;
|
||||
namespace Brutal.NotCursesApi
|
||||
{
|
||||
public unsafe partial struct NcReelOptions
|
||||
{
|
||||
public uint Bordermask; // bitfield; 1s will not be drawn (see bordermaskbits)
|
||||
public ulong Borderchan; // attributes used for ncreel border
|
||||
public uint Tabletmask; // bitfield; same as bordermask but for tablet borders
|
||||
public ulong Tabletchan; // tablet border styling channel
|
||||
public ulong Focusedchan; // focused tablet border styling channel
|
||||
public NcReelOption Flags; // bitfield over NCREEL_OPTION_*
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,16 @@
|
|||
using System.Runtime.InteropServices.Marshalling;
|
||||
using Brutal;
|
||||
using Brutal.Interop;
|
||||
using Brutal.Pointers;
|
||||
namespace Brutal.NotCursesApi
|
||||
{
|
||||
/// selection widget -- an ncplane with a title header and a body section. the
|
||||
/// body section supports infinite scrolling up and down.
|
||||
///
|
||||
/// At all times, exactly one item is selected.
|
||||
public unsafe partial struct NcSelectorItem
|
||||
{
|
||||
public Ptr<byte> Option;
|
||||
public Ptr<byte> Desc;
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,25 @@
|
|||
using System.Runtime.InteropServices.Marshalling;
|
||||
using Brutal;
|
||||
using Brutal.Interop;
|
||||
using Brutal.Pointers;
|
||||
namespace Brutal.NotCursesApi
|
||||
{
|
||||
public unsafe partial struct NcSelectorOptions
|
||||
{
|
||||
public Ptr<byte> Title; // title may be NULL, inhibiting riser, saving two rows.
|
||||
public Ptr<byte> Secondary; // secondary may be NULL
|
||||
public Ptr<byte> Footer; // footer may be NULL
|
||||
public Ptr<NcSelectorItem> Items; // initial items and descriptions
|
||||
/// default item (selected at start), must be < itemcount unless itemcount is
|
||||
/// 0, in which case 'defidx' must also be 0
|
||||
public uint Defidx;
|
||||
/// maximum number of options to display at once, 0 to use all available space
|
||||
public uint Maxdisplay;
|
||||
public ulong Opchannels; // option channels
|
||||
public ulong Descchannels; // description channels
|
||||
public ulong Titlechannels; // title channels
|
||||
public ulong Footchannels; // secondary and footer channels
|
||||
public ulong Boxchannels; // border channels
|
||||
public ulong Flags; // bitfield of NCSELECTOR_OPTION_*, currently unused
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,48 @@
|
|||
using System.Runtime.InteropServices.Marshalling;
|
||||
using Brutal;
|
||||
using Brutal.Interop;
|
||||
using Brutal.Pointers;
|
||||
namespace Brutal.NotCursesApi
|
||||
{
|
||||
/// whenever a new field is added here, ensure we add the proper rule to
|
||||
/// notcurses_stats_reset(), so that values are preserved in the stash stats.
|
||||
public unsafe partial struct NcStats
|
||||
{
|
||||
public ulong Renders; // successful ncpile_render() runs
|
||||
public ulong Writeouts; // successful ncpile_rasterize() runs
|
||||
public ulong FailedRenders; // aborted renders, should be 0
|
||||
public ulong FailedWriteouts; // aborted writes
|
||||
public ulong RasterBytes; // bytes emitted to ttyfp
|
||||
public long RasterMaxBytes; // max bytes emitted for a frame
|
||||
public long RasterMinBytes; // min bytes emitted for a frame
|
||||
public ulong RenderNs; // nanoseconds spent rendering
|
||||
public long RenderMaxNs; // max ns spent in render for a frame
|
||||
public long RenderMinNs; // min ns spent in render for a frame
|
||||
public ulong RasterNs; // nanoseconds spent rasterizing
|
||||
public long RasterMaxNs; // max ns spent in raster for a frame
|
||||
public long RasterMinNs; // min ns spent in raster for a frame
|
||||
public ulong WriteoutNs; // nanoseconds spent writing frames to terminal
|
||||
public long WriteoutMaxNs; // max ns spent writing out a frame
|
||||
public long WriteoutMinNs; // min ns spent writing out a frame
|
||||
public ulong Cellelisions; // cells we elided entirely thanks to damage maps
|
||||
public ulong Cellemissions; // total number of cells emitted to terminal
|
||||
public ulong Fgelisions; // RGB fg elision count
|
||||
public ulong Fgemissions; // RGB fg emissions
|
||||
public ulong Bgelisions; // RGB bg elision count
|
||||
public ulong Bgemissions; // RGB bg emissions
|
||||
public ulong Defaultelisions; // default color was emitted
|
||||
public ulong Defaultemissions; // default color was elided
|
||||
public ulong Refreshes; // refresh requests (non-optimized redraw)
|
||||
public ulong Sprixelemissions; // sprixel draw count
|
||||
public ulong Sprixelelisions; // sprixel elision count
|
||||
public ulong Sprixelbytes; // sprixel bytes emitted
|
||||
public ulong AppsyncUpdates; // how many application-synchronized updates?
|
||||
public ulong InputErrors; // errors processing control sequences/utf8
|
||||
public ulong InputEvents; // characters returned to userspace
|
||||
public ulong HpaGratuitous; // unnecessary hpas issued
|
||||
public ulong CellGeoChanges; // cell geometry changes (resizes)
|
||||
public ulong PixelGeoChanges; // pixel geometry changes (font resize)
|
||||
public ulong Fbbytes; // total bytes devoted to all active framebuffers
|
||||
public uint Planes; // number of planes currently in existence
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,13 @@
|
|||
using System.Runtime.InteropServices.Marshalling;
|
||||
using Brutal;
|
||||
using Brutal.Interop;
|
||||
using Brutal.Pointers;
|
||||
namespace Brutal.NotCursesApi
|
||||
{
|
||||
public unsafe partial struct NcSubProcOptions
|
||||
{
|
||||
public Ptr Curry;
|
||||
public ulong RestartPeriod; // restart this many seconds after an exit (watch)
|
||||
public ulong Flags; // bitfield over NCOPTION_SUBPROC_*
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,15 @@
|
|||
using System.Runtime.InteropServices.Marshalling;
|
||||
using Brutal;
|
||||
using Brutal.Interop;
|
||||
using Brutal.Pointers;
|
||||
namespace Brutal.NotCursesApi
|
||||
{
|
||||
public unsafe partial struct NcTabbedOptions
|
||||
{
|
||||
public ulong SelChan; // channel for the selected tab header
|
||||
public ulong HdrChan; // channel for unselected tab headers
|
||||
public ulong SepChan; // channel for the tab separator
|
||||
public Ptr<byte> Separator; // separator string (copied by nctabbed_create())
|
||||
public NcTabbedOption Flags; // bitmask of NCTABBED_OPTION_*
|
||||
}
|
||||
}
|
||||
Some files were not shown because too many files have changed in this diff Show more
Loading…
Reference in a new issue