termcap

Termcap “cl” command doesn't clear screen

寵の児 提交于 2021-01-28 07:05:42
问题 I can't seem to get termcap 's "cl" command to work, but the terminal escape code does. For example: #include <termcap.h> #include <stdio.h> int main() { tputs(tgetstr("cl", NULL), 1, putchar); } This doesn't change the terminal. But when I run: #include <stdio.h> int main() { printf("\e[2J"); } or if I call echo `tput cl` The terminal is cleared. Why does this happen? Shouldn't termcap give that same escape code? EDIT: Fixed writing characters EDIT2: It's because i didn't call tgetent()

Why can't I retrieve my program that was suspended from inside backticks?

孤人 提交于 2020-03-05 04:28:46
问题 I created a program that takes a list of arguments and put them in a grid on a new tty where I can move around and select from it what I want. When I run the program without backticks like this... $> ./ft_select arg_1 arg_2 ... arg_N A new tty is opened and a grid is shown... arg_1 arg_2 arg_3 arg_4 arg_5 arg_6 arg_7 ... arg_N I hit ctrl+z and the program gets suspended with no problem and fg command puts it back. My problem is that when I put the command between backticks and I try to

Why can't I retrieve my program that was suspended from inside backticks?

三世轮回 提交于 2020-03-05 04:28:07
问题 I created a program that takes a list of arguments and put them in a grid on a new tty where I can move around and select from it what I want. When I run the program without backticks like this... $> ./ft_select arg_1 arg_2 ... arg_N A new tty is opened and a grid is shown... arg_1 arg_2 arg_3 arg_4 arg_5 arg_6 arg_7 ... arg_N I hit ctrl+z and the program gets suspended with no problem and fg command puts it back. My problem is that when I put the command between backticks and I try to

How do I determine if a terminal is color-capable?

99封情书 提交于 2020-01-20 01:35:45
问题 I would like to change a program to automatically detect whether a terminal is color-capable or not, so when I run said program from within a non-color capable terminal (say M-x shell in (X)Emacs), color is automatically turned off. I don't want to hardcode the program to detect TERM={emacs,dumb}. I am thinking that termcap/terminfo should be able to help with this, but so far I've only managed to cobble together this (n)curses-using snippet of code, which fails badly when it can't find the

How do I determine if a terminal is color-capable?

旧时模样 提交于 2020-01-20 01:35:01
问题 I would like to change a program to automatically detect whether a terminal is color-capable or not, so when I run said program from within a non-color capable terminal (say M-x shell in (X)Emacs), color is automatically turned off. I don't want to hardcode the program to detect TERM={emacs,dumb}. I am thinking that termcap/terminfo should be able to help with this, but so far I've only managed to cobble together this (n)curses-using snippet of code, which fails badly when it can't find the

Where to obtain termios.h

a 夏天 提交于 2020-01-03 09:55:33
问题 In my particular situation I am using MinGW/MSys . It doesn't contain termios.h . Turns out it isn't a library that can be downloaded and installed (google didn't found any). Termcap also doesn't include termios.h . Where from to get this file? 回答1: MinGW doesnt fully support POSIX and therefore termios.h is missing. On the other side, Cygwin is capable of POSIX and termios.h. 来源: https://stackoverflow.com/questions/20772965/where-to-obtain-termios-h

Where to obtain termios.h

99封情书 提交于 2020-01-03 09:55:12
问题 In my particular situation I am using MinGW/MSys . It doesn't contain termios.h . Turns out it isn't a library that can be downloaded and installed (google didn't found any). Termcap also doesn't include termios.h . Where from to get this file? 回答1: MinGW doesnt fully support POSIX and therefore termios.h is missing. On the other side, Cygwin is capable of POSIX and termios.h. 来源: https://stackoverflow.com/questions/20772965/where-to-obtain-termios-h

How to get the cursor position in a C program using termcap, without writing a character?

好久不见. 提交于 2019-12-30 23:59:12
问题 I would like to know how to get the cursor position (x, y) in my program, without writing anything on the screen neither tracking it all the time. I found out a way to get its position with this function (I don't check the return of read, write, etc here to write a smaller code on this subject but I do it in my program) : void get_cursor_position(int *col, int *rows) { int a = 0; int i = 0; char buf[4] write(1, "\033[6n", 4); // string asking for the cursor position read(1, buf, 4); while

ncurses support for italics?

梦想与她 提交于 2019-12-24 11:59:13
问题 Some terminals, such as urxvt, support display text in italics via the sitm and ritm terminfo entries: echo `tput sitm`italics`tput ritm` I'd like to use this in an application I've got which wants to render real italics into the console. Unfortunately the application is ncurses-based, and ncurses doesn't seem to have a attribute for italics --- it's got a whole bunch, including invisible text (which I'm sure is useful for something), but no italics. Does anyone know of a way to trick ncurses

Print embedded Pod as formatted text with termcap escapes

落花浮王杯 提交于 2019-12-23 10:25:50
问题 I am trying to output embedded Pod as ANSI text to the terminal. In Perl 5 I can use Pod::Text::Termcap: use strict; use warnings; use Pod::Text::Termcap; my $str = do {local $/; <DATA>}; my $parser = Pod::Text::Termcap->new(); $parser->parse_string_document( $str, \*STDERR ); __DATA__ =head1 SYNOPSIS my_test_command I<filename> [OPTIONS] =head1 ARGUMENTS =over 4 =item I<filename> File name to test =back =head1 OPTIONS =over 4 =item B<--help> Prints help =back =head1 DESCRIPTION A sample test