[C++] Linux API - get Console Font Color
Hi Folks,
I've coma across a problem I have not been able to solve myself. Is there a function in the linux API similar to GetConsoleScreenBufferInfo() on Windows? refer to: http://msdn.microsoft.com/en-us/libr...=vs.85%29.aspx I only need to get the current color settings of the active terminal. thanks, TJ |
can't give much details but you can refer to linux/fb.h for that: http://lxr.free-electrons.com/source/include/linux/fb.h
perhaps you can take a look at linux/vt.h as well. ---- edit ---- i think you can start with the structure fb_info and these functions: struct fb_info *framebuffer_alloc(size_t size, struct device *dev); void framebuffer_release(struct fb_info *info); int fb_init_device(struct fb_info *fb_info); void fb_cleanup_device(struct fb_info *head); |
Holy shit!
I's gonna take me some time to read through these. I'll drop a comment here, when I found what I need. thanks :) |
Reading virtual terminal contents is AFAIK impossible. Size and current cursor position, however, is rather easy. Using the ncurses library:
Code:
#include <ncurses.h> TIOCGWINSZ ioctl to the controlling terminal (stdout or stderr, whichever is a tty) will fill in a struct winsize, which contains the number of rows and columns in the terminal at that point. Install a SIGWINCH signal handler which does that ioctl again, if you want to be notified of changes. ANSI escape sequence \033[6n (4 bytes) to the controlling terminal should inject the cursor position as \033[row;colR into standard input. In order to hide that sequence from the terminal, you'll need to manipulate the terminal attributes. Here is a program which seems to work. I just threw it together, so there may be bugs lurking in it. Code:
#include <termios.h> If you call terminal_specs() first, before reading from standard input, standard input should be kept untouched. Hope this helps. |
All times are GMT -5. The time now is 09:03 PM. |