Commit Graph

502 Commits

Author SHA1 Message Date
nick black
37ceb753bf
notcurses-view: print blitter name #805 2020-07-19 02:54:53 -04:00
Nick Black
dbc83c41b3
linuxconsole PoC (#791)
* use ioctl(KDGETMODE) to detect Linux console
* diagnostic on KDGETMODE
* add logdebug()
* unit test for notcurses_drop_planes(), add ncplane_putnstr_aligned()
* linuxconsole PoC
* linuxconsole: dump unicode->font table
* linuxconsole: explode glyphs
* linuxconsole: show 7 glyphs per 'line'
* linuxconjammer: shim console font with half blocks
* signals: handler for SIGTERM
* man pages: update notcurses_init() for options
* add NCOPTION_NO_FONT_CHANGES #201
2020-07-13 01:21:41 -04:00
nick black
5cf912feb6
ncplane_printf_stainable() and _vfprintf_stainable() #754 2020-07-10 23:58:37 -04:00
nick black
4a97c139e6
add ncplane_putstr_stainable() #754 2020-07-10 23:43:47 -04:00
nick black
a6b002fa77 add ncdirect box-drawing functions #753 2020-07-10 18:41:25 -04:00
nick black
96c6dc8e16 add ncdirect_canopen_images() and ncdirect_canutf8() #753 2020-07-10 18:41:25 -04:00
nick black
c783244185 ncdirect_hline_interp(), ncdirect_vline_interp(), dirlines PoC #753 2020-07-10 18:41:25 -04:00
nick black
750f88b70a split direct into its own header 2020-07-10 18:41:25 -04:00
nick black
3ef1a3a07d
add notcurses_version_components() 2020-07-09 02:17:55 -04:00
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
2020-07-09 02:02:23 -04:00
nick black
479dd00739
ncreel: purge {tblr}off fields; these are ncplane properties #627 2020-07-06 15:59:29 -04:00
nick black
b6330d142b
add notcurses_render_file() #491 2020-07-05 07:14:07 -04:00
nick black
b829398538 ncdirect_render_image: accept ncalign_e parameter #759 2020-07-03 21:24:00 -04:00
nick black
4863c7e3df
ncdirect_image_render: restore NCBLIT_2x2 #751 2020-07-01 01:14:42 -04:00
nick black
229079696d ncvisual refactoring to support ncdirect 2020-06-30 00:18:02 -04:00
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.
2020-06-28 01:53:42 -04:00
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`
2020-06-23 08:03:48 -04:00
nick black
4a3d436e5b
drone: update builders 2020-06-19 14:10:18 -04:00
nick black
79d3ae67e4
add notcurses_cantruecolor() 2020-06-18 11:04:29 -04:00
nick black
355021de56
ncneofetch: print ram/processes #550 2020-06-18 01:34:07 -04:00
nick black
d084513172
ncvisual_geom: account for scaling #726 2020-06-17 21:30:47 -04:00
nick black
7ca5a7e82c
ncneofetch: create info plane #550 2020-06-17 19:39:37 -04:00
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
2020-06-13 22:24:50 -04:00
nick black
70183ee283
Rewrite plot tests using C interface #703
The Plot unit tests were reaching directly into the objects,
which meant the implementations couldn't include anything
we didn't want public. This was annoying, so I've changed it.
This required adding ncdplot_sample() and ncuplot_sample(),
which we should have had anyway.
2020-06-12 00:13:01 -04:00
nick black
185742fd08
Rendering now does tripartite fallback to basecell
Each plane has a "base cell", which like all other cells is
initialized to the null glyph, opaque default foreground color,
and opaque default background color. Prior to this change, at
each cell of a plane, we decided whether to use that cell (the
"viscell") or the base cell depending on whether the viscell had
a non-null glyph. We now evaluate each component independently.
If the viscell has a null glyph, we use the base cell's glyph.
If the viscell has a default foreground, we use the base's fg.
If the viscell has a default background, we use the base's bg.
This was done because (a) it seems more intuitive (if I set a cell
to red, I expect red, not red iff there's a glyph in that cell
for this plane), and (b) because otherwise it was impossible to
do a multicolor overlay without blowing away underlying glyphs
(since without a glyph, you always reduced to the same base cell,
which could have only one fore- and background per render).

Existing code will need to change any instances where cells
lacking glyphs are colored, and those colors are not desired.
Since any such coloring had no effect before, it seems unlikely
that any ought exist (this did bring to light an instance in
the "qrcode" demo where we were staining overmuch of the plane).

This closes #395, the last big open worry regarding our API.
2020-06-11 23:10:03 -04:00
nick black
f98acad7f6
add NCPLOT_OPTIONS_DETECTMAXONLY #610 2020-06-09 12:02:42 -04:00
nick black
a10ba4dac6
highgradient: degrade to gradient #700 #696 2020-06-09 06:08:29 -04:00
nick black
af46077775
ncvisual_geom: take degradation into account #697
In order to properly determine the scaling of an ncvisual to
be rendered, ncvisual_geom() needs know the blitting method.
For this reason, it took an ncblitter_e argument. It also,
however, needs handle degradation, which means knowing whether
NCVISUAL_OPTIONS_NODEGRADE is in use. It thus really wants the
struct ncvisual_options. Pass and accept it. Closes #697, and
fixes the "yield" demo in ASCII mode (#696).
2020-06-09 05:00:08 -04:00
Nick Black
28431914a8
First go at ncplane_puttext() (#690)
Very simple take at ncplane_puttext(), a new function for linebroken text. Also some very basic unit tests. I doubt this works very well yet, but it handles the simplest cases #682. Added nclog(), internal function for logging. #520
2020-06-08 03:01:58 -04:00
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`)
2020-06-07 20:22:13 -04:00
nick black
b2dcc50606
notcurses_options: fold bools into flags 2020-06-07 05:08:46 -04:00
nick black
465f4694b8
rename pixel -> ncpixel 2020-06-06 23:14:24 -04:00
nick black
d863220e23
add pixels PoC 2020-06-06 21:38:05 -04:00
nick black
fb13b148e9
add Pixel API 2020-06-06 19:34:48 -04:00
nick black
2c417ddb0c
yield demo: punch up with polyfills 2020-06-06 05:11:45 -04:00
nick black
633ef1f76c
add beginnings of yield demo 2020-06-05 15:14:07 -04:00
nick black
b172d2b97e
NCVISUAL_OPTION_MAYDEGRADE -> NCVISUAL_OPTION_NODEGRADE, doc 'em 2020-06-05 08:05:02 -04:00
nick black
9a0f0c66fe
ncblit: accept an ncvisual_options #680 2020-06-05 03:47:13 -04:00
nick black
b72a386aa3
ncplane_dup(): adjust for marginalia #679 2020-06-05 01:30:29 -04:00
nick black
e1d34c4f43
ncplane_highgradient: only pass a single channel #676 2020-06-05 00:36:42 -04:00
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
2020-06-04 22:47:38 -04:00
nick black
a8beaf8e56
notcurses-view: switch between blitters with 0--8 #671 2020-06-03 17:00:48 -04:00
nick black
2b31d6ce4d
ncvisual/ncreel: update some documentation 2020-06-03 12:22:46 -04:00
nick black
d41c6d3627
notcurses-ncreel: add </>/* operators 2020-06-03 08:58:48 -04:00
nick black
efa51e9cf2 quadrant blitter #648
Novel blitter using Unicode quadrant glyphs. 2:1 cell aspect ratio, but
double the horizonal resolution of the half block blitter.
2020-06-02 18:33:04 -04:00
nick black
23001ab792
geomdata -> notcurses_blitters if it must be public 2020-06-01 16:18:06 -04:00
nick black
2d3fef115e ncfadectx_setup(): remove timespec param #659 2020-06-01 04:44:02 -04:00
nick black
3deeecdf2e fade: finish out proposed API, basic unit tests #659 2020-06-01 04:44:02 -04:00
nick black
74e8e9c3d9 fade: move more reproduced code into common area #659 2020-06-01 04:44:02 -04:00
nick black
3ff083b73f Fade API: move control of delays into callback 2020-06-01 04:44:02 -04:00
nick black
8793fcd876 c++ Visual: add from_plane constructor, test #654 2020-05-31 21:56:09 -04:00
nick black
6a9bbad91e
Visual C++ constructor test #538 2020-05-29 19:59:46 -04:00
nick black
0331ae4c4c
introduce NCVISUAL_OPTION_BLEND #652 2020-05-29 14:53:53 -04:00
nick black
f47bde1c4e
Graceful fallback among blitters #637
If we're in ASCII mode, no blitter except for NCBLIT_1x1 is going to
work. Whenever NCBLIT_DEFAULT is provided, select NCBLIT_1x1 if we're
in ASCII mode. Add NCVISUAL_OPTIONS_MAYDEGRADE and
NCPLOT_OPTIONS_MAYDEGRADE. Both serve to allow smooth degradation when a
blitter other than NCBLIT_DEFAULT has been provided. Closes #637.

Make calc_gradient_cell() static inline so our templated ncppplot
implementation can use it (ugh). When using NCBLIT_1x1 for plots in
ASCII mode, use space rather than full block, and invert colors.

Use NCBLIT_DEFAULT in the demo for the FPS plot.
2020-05-29 01:24:34 -04:00
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.
2020-05-28 21:16:58 -04:00
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.
2020-05-26 04:34:31 -04:00
nick black
dbc20bd5c0
add man page for ncmetric(3) #631 2020-05-24 04:48:17 -04:00
Marek Habersack
e0462ed53a
[C++] Sync API changes (#633)
Added:

  * NotCurses: can_utf8 (`notcurses_canutf8`)
  * NotCurses: debug (`notcurses_debug`)
  * Plane: center_abs (`ncplane_center_abs`)
  * Plane: set_channels (`ncplane_set_channels`)
  * Plane: set_attr (`ncplane_set_attr`)
  * Reader: clear (`ncreader_clear`)

Changed:

  * USAGE.md: clarfied when C++ throws exceptions
2020-05-24 04:07:12 -04:00
nick black
8971bda0c2 ncpp: stop() resets _instance, add unit test #538 2020-05-24 03:34:46 -04:00
Marek Habersack
9ca8d9c9c6 Correctly cast ncpp::Plane to ncplane*
Fixes: https://github.com/dankamongmen/notcurses/issues/616

SIGSEGV was caused by an invalid cast.

Short explanation: PEBKAC

Long explanation: `Selector.hh`, `Plot.hh` and `MultiSelector.hh` did
not include `Plane.hh`, they merely declared `class Plane;` because
inclusion of `Plane.hh` would cause circular dependencies to appear and
the compiler would be unhappy.  On top of that, yours truly wrenched the
compiler's hands and caused it to believe that a pointer to `Plane` is
really a pointer to `ncplane*` which was quite a silly thing to do as
the compiler, not having included `Plane.hh` and thus not knowing full
definition of the type, wasn't able to look up the type cast operator in
`Plane`.

Don't abuse `reinterpret_cast`, kids!
2020-05-23 20:26:13 -04:00
nick black
24dae2cf15
ncmetric: tighten up PREFIXFWIDTH macros 2020-05-22 09:14:21 -04:00
nick black
cce9384ab8
ncmetric: adapt PREFIXFMT to multibyte #630 2020-05-22 06:46:23 -04:00
nick black
2b5546fc4c
plot: make 8x1 the default glyph geometry 2020-05-22 01:47:23 -04:00
nick black
7215bf92ad
throw somed attributes on a few functions 2020-05-21 21:10:04 -04:00
nick black
37a4114f42
O(1) z-axis moves #623
Replace the singly-linked z-axis with a doubly-linked list,
and reimplement all z-axis moves as O(1) functions.
Eliminate ncplane_move_{above/below}_unsafe(), as there are no
longer unsafe moves.
2020-05-20 15:32:27 -04:00
nick black
0d696be0cc
ncpp: normalize Notcurses capitalization 2020-05-20 00:15:38 -04:00
nick black
99bd3fd597
recenter post-rotation in normal demo #617 2020-05-19 19:39:16 -04:00
nick black
e80ac4ddb9
normal demo: work with odd number of columns :/ 2020-05-17 10:26:48 -04:00
nick black
eb72a4612d
qprefix/bprefix: use uintmax_t for decimal 2020-05-17 02:14:27 -04:00
nick black
168ec1e71d
Update USAGE for streaming API changes #604 2020-05-16 19:47:59 -04:00
nick black
289b018612 view-demo: cleanup, opaque 2020-05-16 19:42:07 -04:00
nick black
78e30831dd move timespec 2020-05-16 19:42:07 -04:00
nick black
1c2f92b3bc
ncmetric: replace u with µ, define *COLUMNS #540 2020-05-13 10:50:42 -04:00
nick black
9a80750316
notcurses_canopen: split into images/videos #598 2020-05-12 20:10:53 -04:00
nick black
0f5333f103
subtle ncplane bugfixes
ncplane_dup(): properly set target plane attributes/channels
ncplane_move_below_unsafe(): speedup, at most one traversal
ncplane_rgba(): accept null glyph
ncvisual_from_plane(): dup the plane, own it in ncvisual
normal: spin the visual
2020-05-11 12:35:59 -04:00
nick black
7dae248a41 box demo: work in ASCII encoding #325 2020-05-11 05:59:55 -04:00
nick black
25baa10f72 special-case double/rounded boxes in ASCII #325 2020-05-11 05:59:55 -04:00
nick black
9f16034d02 add notcurses_debug() #594 2020-05-10 19:47:23 -04:00
nick black
a440382fb5 demo: use NCPLOT_OPTIONS_EXPOENTIALD #470 2020-05-09 13:35:20 -04:00
nick black
fbed12cd80
ncreel_options: add flag field #590 2020-05-09 09:19:34 -04:00
nick black
66bafd59b3
subproc, fdplane, plot, selector, mselector: flag words #590 2020-05-09 09:06:06 -04:00
nick black
eaaa36f0c8
ncreader: ncplane as first arg #590 2020-05-09 08:41:19 -04:00
nick black
9446840b97
ncmenu: move to flag field #590 2020-05-09 08:41:03 -04:00
nick black
fec423264f
selector: undo switch to notcurses from ncplane 2020-05-09 07:51:23 -04:00
nick black
d89d8c52e9
notcurses_options: add flags field 2020-05-09 04:45:51 -04:00
nick black
95ba340fba
ncplane_erase: fix bug in basecell preservation 2020-05-09 01:25:00 -04:00
nick black
d2c968b948
notcurses_init(): interpret NULL as /dev/tty #571 2020-05-08 22:33:39 -04:00
nick black
5b0d773fb5 modernize some PoC c++ according to clang-tidy 2020-05-08 21:42:04 -04:00
nick black
a859a3d652 notcurses_multiselector(3): fix up _selected 2020-05-08 21:42:04 -04:00
nick black
989ca7ff9a selector->ncselector, multiselector -> ncmultiselector #580 2020-05-08 21:42:04 -04:00
nick black
26db8a66b7 ncplane_set_attr()/ncplane_set_channels() 2020-05-08 21:42:04 -04:00
nick black
f0357ef6cb ncplane_contents(): declarations #582 2020-05-08 21:42:04 -04:00
nick black
48de25821c ncreader man page #403 2020-05-08 21:42:04 -04:00
nick black
312e42add2 ncreader: C++ wrapper 2020-05-08 21:42:04 -04:00
nick black
d174431187 ncreader_create: accept const options #403 2020-05-08 21:42:04 -04:00
nick black
7683973ee4 ncreader_options, bad options tests #403 2020-05-08 21:42:04 -04:00
nick black
4819c0e1c3 selector/multiselect: accept notcurses 2020-05-08 21:42:04 -04:00
nick black
064da8acb9 ncreader_destroy() / ncreader_plane() 2020-05-08 21:42:04 -04:00
nick black
5e1d8ccf75 ncreader introduced 2020-05-08 21:42:04 -04:00
nick black
7337280e17
ncplane_at_yx(): const ncplane argument 2020-05-06 22:21:22 -04:00