New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
term: obtain the cursor position via termios.h #11372
Conversation
It would be better to make the function return an |
Currently it is not. |
Pure V is cleaner imho. |
So, by making the pub fn get_cursor_position() ?Coord {
if os.is_atty(1) <= 0 && os.getenv('TERM') != 'dumb' {
return Coord{}
}
info := C.CONSOLE_SCREEN_BUFFER_INFO{}
if !C.GetConsoleScreenBufferInfo(C.GetStdHandle(C.STD_OUTPUT_HANDLE), &info) {
return error(os.get_error_msg(int(C.GetLastError())))
}
return Coord{
x: info.dwCursorPosition.X
y: info.dwCursorPosition.Y
}
} But there are more functions that use the Also, In |
…to term_linux.c.v, make term_default.c.v struct declarations contain only portable field names
…ns_default.c.v etc
…one line `const` declarations for easier searching.
cc -std=gnu99 -w -o ./v ./vc/v.c -lm -lpthread |
This reverts commit af28d09.
This PR solves a TODO:
Use termios.h, C.tcgetattr and C.tcsetattr directly, instead of using
stty
...But I have a couple of doubts:
defer
block is called on panic?'cuz this implementation assumes a yes, a no might cause unwanted results
(i.e. not restoring the initial terminal state)
C.printf('\e[6n'.str)
instead ofprint('\e[6n')
? (L63)according to my tests it doesn't seem to make a difference, but I am not an expert.
('m thinking about performance here, but I think no one will call this function so many times to notice 🤷🏻)
Cheers !
😺