mirror of
https://github.com/dankamongmen/notcurses
synced 2025-03-09 17:19:03 -04:00
[notcurses_options] unsigned margins
This commit is contained in:
parent
233d32be04
commit
df689d9104
2
USAGE.md
2
USAGE.md
@ -144,7 +144,7 @@ typedef struct notcurses_options {
|
|||||||
// of the screen. If the screen is too small, we do what we can--this is
|
// of the screen. If the screen is too small, we do what we can--this is
|
||||||
// strictly best-effort. Absolute coordinates are relative to the rendering
|
// strictly best-effort. Absolute coordinates are relative to the rendering
|
||||||
// area ((0, 0) is always the origin of the rendering area).
|
// area ((0, 0) is always the origin of the rendering area).
|
||||||
int margin_t, margin_r, margin_b, margin_l;
|
unsigned margin_t, margin_r, margin_b, margin_l;
|
||||||
// General flags; see NCOPTION_*. This is expressed as a bitfield so that
|
// General flags; see NCOPTION_*. This is expressed as a bitfield so that
|
||||||
// future options can be added without reshaping the struct. Undefined bits
|
// future options can be added without reshaping the struct. Undefined bits
|
||||||
// must be set to 0.
|
// must be set to 0.
|
||||||
|
@ -36,7 +36,7 @@ typedef enum {
|
|||||||
typedef struct notcurses_options {
|
typedef struct notcurses_options {
|
||||||
const char* termtype;
|
const char* termtype;
|
||||||
ncloglevel_e loglevel;
|
ncloglevel_e loglevel;
|
||||||
int margin_t, margin_r, margin_b, margin_l;
|
unsigned margin_t, margin_r, margin_b, margin_l;
|
||||||
uint64_t flags; // from NCOPTION_* bits
|
uint64_t flags; // from NCOPTION_* bits
|
||||||
} notcurses_options;
|
} notcurses_options;
|
||||||
```
|
```
|
||||||
|
@ -920,7 +920,7 @@ typedef struct notcurses_options {
|
|||||||
// of the screen. If the screen is too small, we do what we can--this is
|
// of the screen. If the screen is too small, we do what we can--this is
|
||||||
// strictly best-effort. Absolute coordinates are relative to the rendering
|
// strictly best-effort. Absolute coordinates are relative to the rendering
|
||||||
// area ((0, 0) is always the origin of the rendering area).
|
// area ((0, 0) is always the origin of the rendering area).
|
||||||
int margin_t, margin_r, margin_b, margin_l;
|
unsigned margin_t, margin_r, margin_b, margin_l;
|
||||||
// General flags; see NCOPTION_*. This is expressed as a bitfield so that
|
// General flags; see NCOPTION_*. This is expressed as a bitfield so that
|
||||||
// future options can be added without reshaping the struct. Undefined bits
|
// future options can be added without reshaping the struct. Undefined bits
|
||||||
// must be set to 0.
|
// must be set to 0.
|
||||||
|
@ -1048,10 +1048,6 @@ notcurses_early_init(const struct notcurses_options* opts, FILE* fp, unsigned* u
|
|||||||
}
|
}
|
||||||
memset(ret, 0, sizeof(*ret));
|
memset(ret, 0, sizeof(*ret));
|
||||||
if(opts){
|
if(opts){
|
||||||
if(opts->margin_t < 0 || opts->margin_b < 0 || opts->margin_l < 0 || opts->margin_r < 0){
|
|
||||||
fprintf(stderr, "Provided an illegal negative margin, refusing to start\n");
|
|
||||||
return NULL;
|
|
||||||
}
|
|
||||||
if(opts->flags >= (NCOPTION_DRAIN_INPUT << 1u)){
|
if(opts->flags >= (NCOPTION_DRAIN_INPUT << 1u)){
|
||||||
fprintf(stderr, "Warning: unknown Notcurses options %016" PRIu64 "\n", opts->flags);
|
fprintf(stderr, "Warning: unknown Notcurses options %016" PRIu64 "\n", opts->flags);
|
||||||
}
|
}
|
||||||
@ -2801,7 +2797,7 @@ bool ncplane_scrolling_p(const ncplane* n){
|
|||||||
// extract an integer, which must be non-negative, and followed by either a
|
// extract an integer, which must be non-negative, and followed by either a
|
||||||
// comma or a NUL terminator.
|
// comma or a NUL terminator.
|
||||||
static int
|
static int
|
||||||
lex_long(const char* op, int* i, char** endptr){
|
lex_ulong(const char* op, unsigned* i, char** endptr){
|
||||||
errno = 0;
|
errno = 0;
|
||||||
long l = strtol(op, endptr, 10);
|
long l = strtol(op, endptr, 10);
|
||||||
if(l < 0 || (l == LONG_MAX && errno == ERANGE) || (l > INT_MAX)){
|
if(l < 0 || (l == LONG_MAX && errno == ERANGE) || (l > INT_MAX)){
|
||||||
@ -2850,7 +2846,7 @@ const char* notcurses_str_scalemode(ncscale_e scalemode){
|
|||||||
|
|
||||||
int notcurses_lex_margins(const char* op, notcurses_options* opts){
|
int notcurses_lex_margins(const char* op, notcurses_options* opts){
|
||||||
char* eptr;
|
char* eptr;
|
||||||
if(lex_long(op, &opts->margin_t, &eptr)){
|
if(lex_ulong(op, &opts->margin_t, &eptr)){
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
if(!*eptr){ // allow a single value to be specified for all four margins
|
if(!*eptr){ // allow a single value to be specified for all four margins
|
||||||
@ -2858,15 +2854,15 @@ int notcurses_lex_margins(const char* op, notcurses_options* opts){
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
op = ++eptr; // once here, we require four values
|
op = ++eptr; // once here, we require four values
|
||||||
if(lex_long(op, &opts->margin_r, &eptr) || !*eptr){
|
if(lex_ulong(op, &opts->margin_r, &eptr) || !*eptr){
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
op = ++eptr;
|
op = ++eptr;
|
||||||
if(lex_long(op, &opts->margin_b, &eptr) || !*eptr){
|
if(lex_ulong(op, &opts->margin_b, &eptr) || !*eptr){
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
op = ++eptr;
|
op = ++eptr;
|
||||||
if(lex_long(op, &opts->margin_l, &eptr) || *eptr){ // must end in NUL
|
if(lex_ulong(op, &opts->margin_l, &eptr) || *eptr){ // must end in NUL
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
return 0;
|
return 0;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user