mirror of
https://github.com/dankamongmen/notcurses.git
synced 2024-11-18 03:25:55 +00:00
bring hpa and vpa into escape table #1525
This commit is contained in:
parent
a5b597cfef
commit
317c09d87d
@ -44,7 +44,9 @@ tinfo_debug_caps(const tinfo* ti, FILE* debugfp, int rows, int cols,
|
|||||||
fprintf(debugfp, "%sbackground isn't interpreted as transparent\n", indent);
|
fprintf(debugfp, "%sbackground isn't interpreted as transparent\n", indent);
|
||||||
}
|
}
|
||||||
fprintf(debugfp, "%scup: %c vpa: %c hpa: %c\n",
|
fprintf(debugfp, "%scup: %c vpa: %c hpa: %c\n",
|
||||||
indent, capyn(get_escape(ti, ESCAPE_CUP)), capyn(ti->vpa), capyn(ti->hpa));
|
indent, capyn(get_escape(ti, ESCAPE_CUP)),
|
||||||
|
capyn(get_escape(ti, ESCAPE_VPA)),
|
||||||
|
capyn(get_escape(ti, ESCAPE_HPA)));
|
||||||
}
|
}
|
||||||
|
|
||||||
void notcurses_debug_caps(const notcurses* nc, FILE* debugfp){
|
void notcurses_debug_caps(const notcurses* nc, FILE* debugfp){
|
||||||
|
@ -211,9 +211,11 @@ int ncdirect_cursor_disable(ncdirect* nc){
|
|||||||
// tests under TERM=vt100. if we need to truly rigourize things, we could
|
// tests under TERM=vt100. if we need to truly rigourize things, we could
|
||||||
// cub/cub1 the width or cuu/cuu1 the height, then cuf/cub back? FIXME
|
// cub/cub1 the width or cuu/cuu1 the height, then cuf/cub back? FIXME
|
||||||
int ncdirect_cursor_move_yx(ncdirect* n, int y, int x){
|
int ncdirect_cursor_move_yx(ncdirect* n, int y, int x){
|
||||||
|
const char* hpa = get_escape(&n->tcache, ESCAPE_HPA);
|
||||||
|
const char* vpa = get_escape(&n->tcache, ESCAPE_VPA);
|
||||||
if(y == -1){ // keep row the same, horizontal move only
|
if(y == -1){ // keep row the same, horizontal move only
|
||||||
if(n->tcache.hpa){
|
if(hpa){
|
||||||
return term_emit(tiparm(n->tcache.hpa, x), n->ttyfp, false);
|
return term_emit(tiparm(hpa, x), n->ttyfp, false);
|
||||||
}else if(n->ctermfd >= 0){
|
}else if(n->ctermfd >= 0){
|
||||||
if(cursor_yx_get(n->ctermfd, &y, NULL)){
|
if(cursor_yx_get(n->ctermfd, &y, NULL)){
|
||||||
return -1;
|
return -1;
|
||||||
@ -222,8 +224,8 @@ int ncdirect_cursor_move_yx(ncdirect* n, int y, int x){
|
|||||||
y = 0;
|
y = 0;
|
||||||
}
|
}
|
||||||
}else if(x == -1){ // keep column the same, vertical move only
|
}else if(x == -1){ // keep column the same, vertical move only
|
||||||
if(!n->tcache.vpa){
|
if(!vpa){
|
||||||
return term_emit(tiparm(n->tcache.vpa, y), n->ttyfp, false);
|
return term_emit(tiparm(vpa, y), n->ttyfp, false);
|
||||||
}else if(n->ctermfd >= 0){
|
}else if(n->ctermfd >= 0){
|
||||||
if(cursor_yx_get(n->ctermfd, NULL, &x)){
|
if(cursor_yx_get(n->ctermfd, NULL, &x)){
|
||||||
return -1;
|
return -1;
|
||||||
@ -235,9 +237,9 @@ int ncdirect_cursor_move_yx(ncdirect* n, int y, int x){
|
|||||||
const char* cup = get_escape(&n->tcache, ESCAPE_CUP);
|
const char* cup = get_escape(&n->tcache, ESCAPE_CUP);
|
||||||
if(cup){
|
if(cup){
|
||||||
return term_emit(tiparm(cup, y, x), n->ttyfp, false);
|
return term_emit(tiparm(cup, y, x), n->ttyfp, false);
|
||||||
}else if(n->tcache.vpa && n->tcache.hpa){
|
}else if(vpa && hpa){
|
||||||
if(term_emit(tiparm(n->tcache.hpa, x), n->ttyfp, false) == 0 &&
|
if(term_emit(tiparm(hpa, x), n->ttyfp, false) == 0 &&
|
||||||
term_emit(tiparm(n->tcache.vpa, y), n->ttyfp, false) == 0){
|
term_emit(tiparm(vpa, y), n->ttyfp, false) == 0){
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -809,7 +809,7 @@ init_banner_warnings(const notcurses* nc, FILE* out){
|
|||||||
if(!notcurses_canutf8(nc)){
|
if(!notcurses_canutf8(nc)){
|
||||||
fprintf(out, "\n Warning! Encoding is not UTF-8; output may be degraded.\n");
|
fprintf(out, "\n Warning! Encoding is not UTF-8; output may be degraded.\n");
|
||||||
}
|
}
|
||||||
if(!nc->tcache.hpa){
|
if(!get_escape(&nc->tcache, ESCAPE_HPA)){
|
||||||
fprintf(out, "\n Warning! No absolute horizontal placement.\n");
|
fprintf(out, "\n Warning! No absolute horizontal placement.\n");
|
||||||
}
|
}
|
||||||
if(nc->tcache.sgr0){
|
if(nc->tcache.sgr0){
|
||||||
@ -1189,9 +1189,11 @@ int notcurses_stop(notcurses* nc){
|
|||||||
// if we were not using the alternate screen, our cursor's wherever we last
|
// if we were not using the alternate screen, our cursor's wherever we last
|
||||||
// wrote. move it to the bottom left of the screen.
|
// wrote. move it to the bottom left of the screen.
|
||||||
if(!nc->tcache.smcup){
|
if(!nc->tcache.smcup){
|
||||||
tty_emit(tiparm(nc->tcache.hpa, 0), nc->ttyfd);
|
// if ldimy is 0, we've not yet written anything; leave it untouched
|
||||||
if(nc->lfdimy){
|
if(nc->lfdimy){
|
||||||
tty_emit(tiparm(nc->tcache.vpa, nc->lfdimy + nc->margin_t - 1), nc->ttyfd);
|
int targy = nc->lfdimy + nc->margin_t - 1;
|
||||||
|
// cup is required, no need to test for existence
|
||||||
|
tty_emit(tiparm(get_escape(&nc->tcache, ESCAPE_CUP), targy, 0), nc->ttyfd);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if(nc->ttyfd >= 0){
|
if(nc->ttyfd >= 0){
|
||||||
|
@ -811,14 +811,15 @@ goto_location(notcurses* nc, FILE* out, int y, int x){
|
|||||||
// if we don't have hpa, force a cup even if we're only 1 char away. the only
|
// if we don't have hpa, force a cup even if we're only 1 char away. the only
|
||||||
// terminal i know supporting cup sans hpa is vt100, and vt100 can suck it.
|
// terminal i know supporting cup sans hpa is vt100, and vt100 can suck it.
|
||||||
// you can't use cuf for backwards moves anyway; again, vt100 can suck it.
|
// you can't use cuf for backwards moves anyway; again, vt100 can suck it.
|
||||||
if(nc->rstate.y == y && nc->tcache.hpa && !nc->rstate.hardcursorpos){ // only need move x
|
const char* hpa = get_escape(&nc->tcache, ESCAPE_HPA);
|
||||||
|
if(nc->rstate.y == y && hpa && !nc->rstate.hardcursorpos){ // only need move x
|
||||||
if(nc->rstate.x == x){ // needn't move shit
|
if(nc->rstate.x == x){ // needn't move shit
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
if(x == nc->rstate.x + 1 && nc->tcache.cuf1){
|
if(x == nc->rstate.x + 1 && nc->tcache.cuf1){
|
||||||
ret = term_emit(nc->tcache.cuf1, out, false);
|
ret = term_emit(nc->tcache.cuf1, out, false);
|
||||||
}else{
|
}else{
|
||||||
ret = term_emit(tiparm(nc->tcache.hpa, x), out, false);
|
ret = term_emit(tiparm(hpa, x), out, false);
|
||||||
}
|
}
|
||||||
}else{
|
}else{
|
||||||
// cup is required, no need to verify existence
|
// cup is required, no need to verify existence
|
||||||
|
@ -45,8 +45,6 @@ typedef enum {
|
|||||||
typedef struct tinfo {
|
typedef struct tinfo {
|
||||||
uint16_t escindices[ESCAPE_MAX]; // table of 1-biased indices into esctable
|
uint16_t escindices[ESCAPE_MAX]; // table of 1-biased indices into esctable
|
||||||
char* esctable; // packed table of escape sequences
|
char* esctable; // packed table of escape sequences
|
||||||
char* hpa; // horizontal position adjusment (move cursor on row)
|
|
||||||
char* vpa; // vertical position adjustment (move cursor on column)
|
|
||||||
char* setaf; // set foreground color (ANSI)
|
char* setaf; // set foreground color (ANSI)
|
||||||
char* setab; // set background color (ANSI)
|
char* setab; // set background color (ANSI)
|
||||||
char* op; // set foreground and background color to default
|
char* op; // set foreground and background color to default
|
||||||
@ -138,7 +136,7 @@ typedef struct tinfo {
|
|||||||
} tinfo;
|
} tinfo;
|
||||||
|
|
||||||
// retrieve the terminfo(5)-style escape 'e' from tdesc (NULL if undefined).
|
// retrieve the terminfo(5)-style escape 'e' from tdesc (NULL if undefined).
|
||||||
static inline const char*
|
static inline __attribute__ ((pure)) const char*
|
||||||
get_escape(const tinfo* tdesc, escape_e e){
|
get_escape(const tinfo* tdesc, escape_e e){
|
||||||
unsigned idx = tdesc->escindices[e];
|
unsigned idx = tdesc->escindices[e];
|
||||||
if(idx){
|
if(idx){
|
||||||
|
@ -196,6 +196,8 @@ int interrogate_terminfo(tinfo* ti, int fd, const char* termname,
|
|||||||
const char* tinfo;
|
const char* tinfo;
|
||||||
} strtdescs[] = {
|
} strtdescs[] = {
|
||||||
{ ESCAPE_CUP, "cup", },
|
{ ESCAPE_CUP, "cup", },
|
||||||
|
{ ESCAPE_HPA, "hpa", },
|
||||||
|
{ ESCAPE_VPA, "vpa", },
|
||||||
{ ESCAPE_MAX, NULL, },
|
{ ESCAPE_MAX, NULL, },
|
||||||
};
|
};
|
||||||
size_t tablelen = 0;
|
size_t tablelen = 0;
|
||||||
@ -248,8 +250,6 @@ int interrogate_terminfo(tinfo* ti, int fd, const char* termname,
|
|||||||
terminfostr(&ti->clearscr, "clear");// clear screen, home cursor
|
terminfostr(&ti->clearscr, "clear");// clear screen, home cursor
|
||||||
terminfostr(&ti->cuu, "cuu"); // move N up
|
terminfostr(&ti->cuu, "cuu"); // move N up
|
||||||
terminfostr(&ti->cud, "cud"); // move N down
|
terminfostr(&ti->cud, "cud"); // move N down
|
||||||
terminfostr(&ti->hpa, "hpa"); // set horizontal position
|
|
||||||
terminfostr(&ti->vpa, "vpa"); // set verical position
|
|
||||||
terminfostr(&ti->cuf, "cuf"); // n non-destructive spaces
|
terminfostr(&ti->cuf, "cuf"); // n non-destructive spaces
|
||||||
terminfostr(&ti->cub, "cub"); // n non-destructive backspaces
|
terminfostr(&ti->cub, "cub"); // n non-destructive backspaces
|
||||||
terminfostr(&ti->cuf1, "cuf1"); // non-destructive space
|
terminfostr(&ti->cuf1, "cuf1"); // non-destructive space
|
||||||
|
Loading…
Reference in New Issue
Block a user