mirror of
https://github.com/dankamongmen/notcurses.git
synced 2024-11-02 09:40:15 +00:00
windows: hack together cursor location report in direct mode #2094
This commit is contained in:
parent
3e29d3f182
commit
db5b3e062c
@ -195,7 +195,12 @@ cursor_yx_get(int ttyfd, const char* u7, int* y, int* x){
|
|||||||
int r;
|
int r;
|
||||||
char in;
|
char in;
|
||||||
do{
|
do{
|
||||||
|
#ifndef __MINGW64__
|
||||||
while((r = read(ttyfd, &in, 1)) == 1){
|
while((r = read(ttyfd, &in, 1)) == 1){
|
||||||
|
#else
|
||||||
|
while((r = getc(stdin)) >= 0){ // FIXME
|
||||||
|
in = r;
|
||||||
|
#endif
|
||||||
bool valid = false;
|
bool valid = false;
|
||||||
switch(state){
|
switch(state){
|
||||||
case CURSOR_ESC: valid = (in == NCKEY_ESC); state = CURSOR_LSQUARE; break;
|
case CURSOR_ESC: valid = (in == NCKEY_ESC); state = CURSOR_LSQUARE; break;
|
||||||
@ -244,6 +249,7 @@ cursor_yx_get(int ttyfd, const char* u7, int* y, int* x){
|
|||||||
if(x){
|
if(x){
|
||||||
*x = column;
|
*x = column;
|
||||||
}
|
}
|
||||||
|
loginfo("cursor at y=%d x=%d\n", row, column);
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -315,6 +321,8 @@ detect_cursor_inversion(ncdirect* n, const char* u7, int rows, int cols, int* y,
|
|||||||
// do not use normal ncdirect_cursor_*() commands, because those go to ttyfp
|
// do not use normal ncdirect_cursor_*() commands, because those go to ttyfp
|
||||||
// instead of tcache.ttyfd. since we always talk directly to the terminal, we need
|
// instead of tcache.ttyfd. since we always talk directly to the terminal, we need
|
||||||
// to move the cursor directly via the terminal.
|
// to move the cursor directly via the terminal.
|
||||||
|
// FIXME since we're always moving 1, we could also just use cuu1 etc (which
|
||||||
|
// i believe to be the only form implemented by Windows Terminal?...)
|
||||||
const char* cuu = get_escape(&n->tcache, ESCAPE_CUU);
|
const char* cuu = get_escape(&n->tcache, ESCAPE_CUU);
|
||||||
const char* cuf = get_escape(&n->tcache, ESCAPE_CUF);
|
const char* cuf = get_escape(&n->tcache, ESCAPE_CUF);
|
||||||
const char* cub = get_escape(&n->tcache, ESCAPE_CUB);
|
const char* cub = get_escape(&n->tcache, ESCAPE_CUB);
|
||||||
|
@ -475,7 +475,7 @@ int get_tty_fd(FILE* ttyfp){
|
|||||||
if(isatty(fd)){
|
if(isatty(fd)){
|
||||||
fd = dup(fd);
|
fd = dup(fd);
|
||||||
}else{
|
}else{
|
||||||
loginfo("File descriptor %d was not a TTY\n", fd);
|
loginfo("fd %d not a TTY\n", fd);
|
||||||
fd = -1;
|
fd = -1;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user