Commit Graph

109 Commits (b56f5989bdc9167606706e21166b77e0e9d6fae5)

Author SHA1 Message Date
nick black 1609b00b77 C++ decode_loop() #1066 4 years ago
nick black 6623fc92a0
ncmenu_item_set_status: man page, NEWS, python, c++ #1057 4 years ago
nick black be0136874f rename Plane::putwc -> Plane::putwch to not conflict with stdlib macro #1046 4 years ago
nick black fa92e0ffe8
purge stray #undef #1046 4 years ago
nick black 0a3f697bc7
c++ ncplane: braces around initializer 4 years ago
nick black f9e2c7863b
add notcurses_stats_alloc #1043 4 years ago
nick black 270b1b20ee implement notcurses_render_to_buffer() #214 4 years ago
Marek Habersack a29bfe9c42 [C++] Deal with widgets grabbing full ownership of Panel
Fixes: https://github.com/dankamongmen/notcurses/issues/1009

Whenever a widget is created with its `*_create` function it currently
claims full ownership of the passed panel, including its destruction.
However, the C++ wrapper around the panel is not aware of this and will
attempt to destroy the native panel in the destructor, leading to
segfaults.

Fix this by introduction of a `Widget` class which contains the logic to
properly modify the `Panel` instance to not double-destroy the native
panel.  The solution is a bit fragile since the `Panel` instance is left
intact (we can't free it for the user) in a state that's safe for the
C++ wrapper, but calling any C function via the wrapper **will** pass a
`NULL` pointer in the panel argument - therefore the C functions MUST be
proofed against this.  The proofing belongs in the C backend code since
this protects also C and other language binding users from such abuse.

The Widget class will first verify that the passed `Plane` instance
hasn't already been "disowned" and will throw an exception to the effect
if it was.  Next, it will proceed to take over ownership of the native
panel instance and mark the passed `Panel` as "invalid" (i.e. not owning
any native panel instance anymore)

The above changes require modification of `Panel` instances and so all
the widget constructors taking `const*` or `const&` have been removed
from widget classes.
4 years ago
nick black 683217ef07 normalize style setters #1034 4 years ago
Marek Habersack 943e23535f [C++] API sync
Fixes: https://github.com/dankamongmen/notcurses/issues/1025

Added:
  * Direct: flush (`ncdirect_flush`)
  * Direct: getc (`ncdirect_getc_blocking` and `ncdirect_getc_nblock`)
  * Direct: getc (`ncdirect_getc`)
  * Direct: get_inputready_fd (`ncdirect_inputready_fd`)
  * NotCurses: align (`notcurses_align`)
  * NotCurses: ucs32_to_utf8 (`notcurses_ucs32_to_utf8`)
  * NotCurses: get_bottom (`notcurses_bottom`)
  * Plane: resize_realign (`ncplane_resize_realign`)
  * Plane: get_x (`ncplane_x`)
  * Plane: get_y (`ncplane_y`)
  * Plane: mergedown (`ncplane_mergedown`)
  * Plane: putwc_stained (`ncplane_putwc_stained`)
  * Plane: putstr_stained (`ncplane_putstr_stained`)
  * Plane: set_fchannel (`ncplane_set_fchannel`)
  * Plane: set_bchannel (`ncplane_set_bchannel`)
  * Plane: get_styles (`ncplane_styles`)
  * Plane: get_above (`ncplane_above`)
  * Reader: move_left (`ncreader_move_left`)
  * Reader: move_right (`ncreader_move_right`)
  * Reader: move_up (`ncreader_move_up`)
  * Reader: move_down (`ncreader_move_down`)
  * Reader: write_egc (`ncreader_write_egc`)
  * Visual: get_default_blitter (`ncvisual_default_blitter`)

Fixed:
  * NotCurses: `cursor_{enable,disable}` must use `NOEXCEPT_MAYBE`
  * Plane: renamed `putcw` to `putwc`
4 years ago
nick black 7b51bab79a add resizecb to ncplane_options struct #869 4 years ago
nick black 73f9973a2c Plane.hh: fix up indentation #1020 4 years ago
nick black 36aed3c521 add ncplane_create() + ncplane_options #1020 4 years ago
nick black 607c03edc4
rename _rgb_clipped functions rgb8_clipped 4 years ago
nick black a4367fcfb5 rip out ncplane_ creation functions #985 4 years ago
nick black e42dbdfd60 _stainable() -> _stained() #985 4 years ago
nick black b7a57eaab7 convert all channel rgb calls #985 4 years ago
nick black c3e5e47a2a
ncreader: conform to the New Way #627 4 years ago
nick black 306948507f ncmultiselect: normalize per new widget API #627 #1006 4 years ago
nick black 8839d44454 selector: transfer ownership of ncplane #1006 #627 4 years ago
nick black 2f28420034 rename ncplane_putsimple() -> ncplane_putchar() #912 4 years ago
nick black 4c7a1d0427 ncdirect_init: add flags parameter #976 4 years ago
nick black 7cbb2e9110 zoo demo: show cursor in reader box #835 4 years ago
nick black cab19cf790 Cursor work (placement, drop RETAIN_CURSOR) #953
notcurses_enable_cursor() now accepts placement arguments.
both it and notcurses_disable_cursor() now return int rather
than void. add notcurses_cursor_move_yx().
4 years ago
nick black df33f381e5 c++ wrappers: cursor_{en,dis}able, iprefix() #952 4 years ago
nick black 4dd1d6a4c8 Annihilate nc_err_e and all infrastructure #948 4 years ago
Nick Black 359ad1d36d
Generalized mergedown #779 (#932)
* Rename ncplane_mergedown -> ncplane_mergedown_simple()
* New ncplane_mergedown(), fully general projection of src to dst
4 years ago
nick black 05da44b06b
hide blending functions #917 4 years ago
nick black a2c95814b7 Remove cell_simple_p()
Get notcurses-tetris working again, since its collision
detection relied on simple vs non-simple EGCs, which are
no longer an operative concept. Closes #899.
4 years ago
nick black f9eed1c412 palette_size is unsigned #891 4 years ago
nick black 16ff667325 blissful endianness-opacity
not caring about endianness is the opiate of the masses.
happy, happy masses. remove endianness.h and all its baleful
influence by explicitly breaking up the cell structure. #892
4 years ago
nick black ead60d06cc
unexport cell_egc_idx() 4 years ago
Marek Habersack 2fabe85e6a [C++] API sync
Been a while, apologies :)

Added:
  * Direct: fg_palindex (`ncdirect_fg_palindex`)
  * Direct: bg_palindex (`ncdirect_bg_palindex`)
  * Direct: get_palette_size (`ncdirect_palette_size`)
  * Direct: putstr (`ncdirect_putstr`)
  * Direct: hline_interp (`ncdirect_hline_interp`)
  * Direct: vline_interp (`ncdirect_vline_interp`)
  * Direct: box (`ncdirect_box`)
  * Direct: rounded_box (`ncdirect_rounded_box`)
  * Direct: double_box (`ncdirect_double_box`)
  * Direct: canopen_images (`ncdirect_canopen_images`)
  * Direct: canutf8 (`ncdirect_canutf8`)
  * Menu: get_mouse_selected (`ncmenu_mouse_selected`)
  * NotCurses: version_components (`notcurses_version_components`)
  * NotCurses: str_blitter (`notcurses_str_blitter`)
  * NotCurses: str_scalemode (`notcurses_str_scalemode`)
  * NotCurses: lex_margins (`notcurses_lex_margins`)
  * NotCurses: lex_blitter (`notcurses_lex_blitter`)
  * NotCurses: lex_scalemode (`notcurses_lex_scalemode`)
  * NotCurses: render_to_file (`notcurses_render_to_file`)
  * Plane: putstr_stainable (`ncplane_putstr_stainable`)
  * Plane: printf_stainable (`ncplane_printf_stainable`)
  * Plane: vprintf_stainable (`ncplane_vprintf_stainable`)
  * Reel: offer_input (`ncreel_offer_input`)

Changed:
  * Direct: set_fg_alpha uses `unsigned alpha`
  * Direct: set_bg_alpha uses `unsigned alpha`
  * Plane: set_fg_alpha uses `unsigned alpha`
  * Plane: set_bg_alpha uses `unsigned alpha`
  * Root: made `error_guard` and `error_guard_cond` static
4 years ago
nick black 7174a84e94 zoo: add multiselector 4 years ago
nick black 17e8f62eb9
cell_no{fore/back}ground() was never intended for export 4 years ago
nick black 750f88b70a split direct into its own header 4 years ago
Nick Black 162f9910c2
Tons of work on ncreel (#776)
Tons of work on ncreel (#627, #749, #694)
Improve reel demo: get input wired up once more, avoid the FPS demo at bottom, print pointer and line count in each tablet, use new ncreel API. Improve notcurses-ncreel explorer: kill memory leaks (#694), draw tablets better, use new ncreel API. Fix bug in ncreel core where cruft could be left on the screen, via a very gross brute force algorithm. I'll likely come back and make this a bit less ghastly in the future #749. Remove weird one-off input system from ncreel, residue from outcurses. Make some of the normalizing changes speced out in #627

* ncreel: give each tablet an index, and print it #749
* reel: eliminate FIXME + param to insert_tabler() #749
* ncreel: label tablets with their adress to correlate against debugging logs #749
* more terminal environment variable notes
* TERMS.md: add Sakura, st
* ncreel: move legend out of reel proper
* ncreel_options: dump min/max_supported_rows/cols #627
* ncreel: remove weird one-off input layer #627
* ncreel: add ncreel_offer_input()
* reel demo: call demo_getc()
* reel demo: rig up input to demo main
* ncreel: drop ncreel_del_focused(), properly bind tablets
* reel demo: don't free up necessary plane
* ncreel: don't pull absolute locations of tablets
* ncreel: place tablets correctly in boundrel
* reel demo: add back support for left/right
* reel demo: restore thread movement
* ncreel: remove a great deal of complexity
* reel demo: stay out of FPS graph's way
* ncreel: give each tablet an index, and print it #749
* reel: eliminate FIXME + param to insert_tabler() #749
* ncreel: label tablets with their adress to correlate against debugging logs #749
* ncreel: move legend out of reel proper
* ncreel_options: dump min/max_supported_rows/cols #627
* ncreel: remove weird one-off input layer #627
* ncreel: add ncreel_offer_input()
* reel demo: call demo_getc()
* reel demo: rig up input to demo main
* ncreel: drop ncreel_del_focused(), properly bind tablets
* reel demo: don't free up necessary plane
* ncreel: don't pull absolute locations of tablets
* ncreel: place tablets correctly in boundrel
* reel demo: add back support for left/right
* reel demo: restore thread movement
* ncreel: remove a great deal of complexity
* reel demo: stay out of FPS graph's way
* reel: tighten up reel following redraw
* reel: fix upper-left corner of topless perimeter
* ncreel: print linecount, return clipped value
* reel: draw focused tablet relative to reel
* reel: brute force decruftification, how embarrassing #749
4 years ago
nick black b829398538 ncdirect_render_image: accept ncalign_e parameter #759 4 years ago
nick black 4863c7e3df
ncdirect_image_render: restore NCBLIT_2x2 #751 4 years ago
nick black 354152b48b
Redefine CELL_ALPHA_ in their natural forms
CELL_ALPHA_OPAQUE et al were defined as 0..3, meaning
CELL_ALPHA_SHIFT had to be used to compare them to their
channel representations. Instead, define them in said
representation outright, eliminating the need to shift while
retaining arithmetic properties, and zero initialization for
CELL_ALPHA_OPAQUE. Eliminate CELL_ALPHA_SHIFT #738.
4 years ago
Marek Habersack 63b64ff624 [C++] API sync
Added:
  * Direct: render_image (`ncdirect_render_image`)
  * NotCurses: can_truecolor (`notcurses_cantruecolor`)
  * Plane: home (`ncplane_home`)
  * Plane: perimeter_rounded (`ncplane_perimeter_rounded`)
  * Plane: perimeter_double (`ncplane_perimeter_double`)
  * Plane: is_fg_default (`ncplane_fg_default_p`)
  * Plane: is_bg_default (`ncplane_bg_default_p`)
  * Plot: sample (`nc{d,u}plot_sample`)
  * Visual: geom (`ncvisual_geom`)

Fixed:
  * Plot: {set,add}_sample - `x` coord is always `uint64_t`
4 years ago
Nick Black 0084dbaa6d
qrcode generalization #699 (#713)
Add convenience function ncplane_home(). Add an ncblitter_e param
to ncplane_qrcode(), and split int maxversion into value-result
int* ymax and int* xmax. Write the actual sizes of the resulting
visual into these parameters. Update the qrcode demo. Add the
qrcode PoC. Update demos to ncplane_home(), where possible.

ncplane_qrcode() now takes an ncblitter_e and two value-result int*s
in the place of a single value int. The final size of the displayed qrcode
is written to *ymax and *xmax. If the code can't fit within the specified
dimensions, an error is returned. Standard rules for pluggable blitters
apply regarding fallback etc. #699
4 years ago
Marek Habersack 4d2e4e82d3 [C++] API sync
Changed:

 * Visual: tiny reformatting to fit the overall ncpp style
 * Visual: added error guard in `render`
 * Visual: error_guard update in `rotate`

Added:

 * Visual: simple_streamer (`ncvisual_simple_streamer`)
 * Visual: polyfill (`ncvisual_polyfill_yx`)
 * Visual: at (`ncvisual_at_yx`)
 * Visual: set (`ncvisual_set_yx`)
4 years ago
nick black 2c417ddb0c
yield demo: punch up with polyfills 4 years ago
nick black 9a0f0c66fe
ncblit: accept an ncvisual_options #680 4 years ago
nick black e1d34c4f43
ncplane_highgradient: only pass a single channel #676 4 years ago
Nick Black de23139111
Open some whoopass on ncvisual rotation (#677)
Whip the ol' llama's ass (fix ncvisual rotation)

* notcurses: flush cursor change requests #673
* rotator: verify ncplane_rgba and ncblit_rgba
* ncblit: rename, accept ncblitter_e #674
* rotator: render from rgba
* rotator: get to rotation
* rotator: add a pi/4 turn at the end
* normal: reuse incoming plane for rendering #672
* rotator poc: rotate a fullplane gradient #672
* normal demo: place visual correctly
* rotator: verify ncplane_rgba and ncblit_rgba
* ncblit: rename, accept ncblitter_e #674
* rotator: render from rgba
* rotator: add a pi/4 turn at the end
* normal: reuse incoming plane for rendering #672
* rotator poc: rotate a fullplane gradient #672
* normal demo: place visual correctly
* rotator poc: throw some red into gradient
* rotator poc: done #662
* oiio: ncvisual_resize() needs set ibuf pointer #662
* normal: only need erase at top of loop
* visual poc: shorter delay
* normal demo: center rendered visual
* comment ncvisual_resize() call
* ncvisual_rotate: call ncvisual_details_seed()
* ffmpeg ncvisual: fix rotation #662
4 years ago
nick black 8793fcd876 c++ Visual: add from_plane constructor, test #654 4 years ago
Nick Black ebcba82d4b
Fully general ncvisual layer (#647)
This represents an essentially complete rewrite of ncvisual and associated code. It had two major goals:

Improve the ncvisual API based off lessons learned, pursuant to the upcoming API freeze. In particular, I wanted to:

decouple ncvisuals from ncplanes. It should be possible to render a ncvisual to multiple planes, with different scaling each time. It should be possible to create an ncvisual without a plane, etc.
normalize the various ways of constructing an ncvisual -- file, memory, plane, etc.
Support multiple blitters, from 7-bit ASCII to Sixel. This required writing the blitters in several cases, and they're not yet in their final implementations (but the API is fine)
I have not yet unified Plots and Visuals, and might not, given that the Plot code works fine. We could at this point implement Plots in terms of Visuals, though -- the blitter backend range has been unified. Sixel is not yet implemented, though it is listed.

There is a new POC tool, blitter. It renders its arguments using all possible blitter+scaling combinations. Another new POC, resize, displays its argument, then resizes it to the screen size and displays that, explicitly making use of ncvisual_resize() rather than a scaling parameter to ncvisual_render().

This also eliminates some memory leaks and bugs we were seeing in trunk, and brings in Sixel scaffolding.

The C++ wrapper will also need patching back up; I cut most of it down while wrestling with this crap, urk.

Closes #638, #562, and #622.
4 years ago
Marek Habersack b5d8549bb3 [C++] Allow multiple instances of `NotCurses`
This is to make it possible, in the future, to create multiple instances
of `NotCurses` for multiple terminals.  The first instance of
`NotCurses` becomes the default one, so that any instances of other
classes that aren't explicitly created with a pointer to another
`NotCurses` instance still work as expected.

Note that currently trying to call `notcurses_init` twice results in the
following error for me:

    0x55555559bfc0 is already registered for signals
    Couldn't drop signals: 0x55555559bfc0 != 0x5555555b6720
    terminate called after throwing an instance of 'ncpp::init_error*'

    Program received signal SIGABRT, Aborted.

The error is signalled by `setup_signals` and the pointer shown in the
message points to the first `struct notcurses` instance created.
4 years ago