2005-10-17 23:24:12 +10:00
/** \file output.h
2012-11-18 11:23:22 +01:00
Generic output functions
2005-10-17 23:24:12 +10:00
*/
2005-09-20 23:26:39 +10:00
/**
Constants for various character classifications . Each character of a command string can be classified as one of the following types .
*/
2005-10-05 01:11:39 +10:00
# ifndef FISH_OUTPUT_H
# define FISH_OUTPUT_H
# include <wchar.h>
2012-02-11 17:07:56 -08:00
# include "screen.h"
2012-02-12 18:05:59 -08:00
# include "color.h"
2005-10-05 01:11:39 +10:00
2005-09-20 23:26:39 +10:00
/**
2012-11-18 11:23:22 +01:00
Constants for various colors as used by the set_color function .
2005-09-20 23:26:39 +10:00
*/
enum
{
2012-11-18 16:30:30 -08:00
FISH_COLOR_BLACK ,
FISH_COLOR_RED ,
FISH_COLOR_GREEN ,
FISH_COLOR_YELLOW ,
FISH_COLOR_BLUE ,
FISH_COLOR_MAGENTA ,
FISH_COLOR_CYAN ,
FISH_COLOR_WHITE ,
/** The default fg color of the terminal */
FISH_COLOR_NORMAL ,
FISH_COLOR_IGNORE ,
FISH_COLOR_RESET
2005-09-20 23:26:39 +10:00
}
;
2006-05-27 23:39:30 +10:00
2006-06-20 10:50:10 +10:00
/**
The value to send to set_color to tell it to use a bold font
*/
2006-05-27 23:39:30 +10:00
# define FISH_COLOR_BOLD 0x80
2006-06-20 10:50:10 +10:00
/**
The value to send to set_color to tell it to underline the text
*/
2006-06-14 23:22:40 +10:00
# define FISH_COLOR_UNDERLINE 0x100
2005-09-20 23:26:39 +10:00
/**
Sets the fg and bg color . May be called as often as you like , since
if the new color is the same as the previous , nothing will be
written . Negative values for set_color will also be ignored . Since
the terminfo string this function emits can potentially cause the
screen to flicker , the function takes care to write as little as
possible .
Possible values for color are any form the FISH_COLOR_ * enum ,
FISH_COLOR_IGNORE and FISH_COLOR_RESET . FISH_COLOR_IGNORE will
leave the color unchanged , and FISH_COLOR_RESET will perform an
exit_attribute_mode , even if set_color thinks it is already in
FISH_COLOR_NORMAL mode .
In order to set the color to normal , three terminfo strings may
have to be written .
- First a string to set the color , such as set_a_foreground . This
is needed because otherwise the previous strings colors might be
removed as well .
- After that we write the exit_attribute_mode string to reset all
color attributes .
- Lastly we may need to write set_a_background or set_a_foreground
to set the other half of the color pair to what it should be .
\ param c Foreground color .
\ param c2 Background color .
*/
2012-02-11 17:07:56 -08:00
void set_color ( rgb_color_t c , rgb_color_t c2 ) ;
2005-09-20 23:26:39 +10:00
2008-01-14 02:47:47 +10:00
/**
Write specified multibyte string
*/
2014-05-09 14:37:23 -07:00
void writembs_check ( char * mbs , const char * mbs_name , const char * file , long line ) ;
# define writembs(mbs) writembs_check((mbs), #mbs, __FILE__, __LINE__)
2005-09-20 23:26:39 +10:00
2005-10-17 23:24:12 +10:00
/**
2006-10-02 01:59:18 +10:00
Write a wide character using the output method specified using output_set_writer ( ) .
2005-10-17 23:24:12 +10:00
*/
2012-11-18 16:30:30 -08:00
int writech ( wint_t ch ) ;
2005-09-20 23:26:39 +10:00
2005-10-17 23:24:12 +10:00
/**
Write a wide character string to FD 1.
*/
2012-11-18 16:30:30 -08:00
void writestr ( const wchar_t * str ) ;
2005-09-20 23:26:39 +10:00
2012-11-05 00:05:42 -08:00
/**
Write a wide character string to FD 1. If the string is wider than
the specified maximum , truncate and ellipsize it .
*/
2012-11-18 16:30:30 -08:00
void writestr_ellipsis ( const wchar_t * str , int max_width ) ;
2012-11-05 00:05:42 -08:00
2005-10-17 23:24:12 +10:00
/**
Escape and write a string to fd 1
*/
2012-11-18 16:30:30 -08:00
int write_escaped_str ( const wchar_t * str , int max_len ) ;
2005-09-20 23:26:39 +10:00
2005-10-17 23:24:12 +10:00
/**
Return the internal color code representing the specified color
*/
2012-11-18 16:30:30 -08:00
int output_color_code ( const wcstring & val , bool is_background ) ;
rgb_color_t parse_color ( const wcstring & val , bool is_background ) ;
2005-09-20 23:26:39 +10:00
2006-02-16 23:40:25 +10:00
/**
This is for writing process notification messages . Has to write to
stdout , so clr_eol and such functions will work correctly . Not an
issue since this function is only used in interactive mode anyway .
*/
2012-11-18 16:30:30 -08:00
int writeb ( tputs_arg_t b ) ;
2006-02-16 23:40:25 +10:00
/**
Set the function used for writing in move_cursor , writespace and
2006-02-20 23:11:46 +10:00
set_color and all other output functions in this library . By
default , the write call is used to give completely unbuffered
output to stdout .
2006-02-16 23:40:25 +10:00
*/
2012-11-18 16:30:30 -08:00
void output_set_writer ( int ( * writer ) ( char ) ) ;
2006-02-16 23:40:25 +10:00
2008-01-14 02:47:47 +10:00
/**
Return the current output writer
*/
2006-10-02 02:02:58 +10:00
int ( * output_get_writer ( ) ) ( char ) ;
2012-03-05 10:44:08 -08:00
/** Set the terminal name */
2012-12-19 13:31:06 -08:00
void output_set_term ( const wcstring & term ) ;
2012-03-05 10:44:08 -08:00
/** Return the terminal name */
2012-02-09 16:06:24 -08:00
const wchar_t * output_get_term ( ) ;
2007-09-10 00:04:36 +10:00
2012-03-05 10:44:08 -08:00
/** Sets whether term256 colors are supported */
bool output_get_supports_term256 ( ) ;
void output_set_supports_term256 ( bool val ) ;
2012-02-13 09:52:17 -08:00
2013-02-14 15:50:24 -08:00
/* Exported for builtin_set_color's usage only */
bool write_foreground_color ( unsigned char idx ) ;
bool write_background_color ( unsigned char idx ) ;
unsigned char index_for_color ( rgb_color_t c ) ;
2005-10-05 01:11:39 +10:00
# endif