Oyranos  git-devel
Oyranos is a full featured Color Management System
Modules | Macros | Typedefs | Enumerations | Functions

Internationalisation, Terminal colors, I/O and String Handling. More...

Collaboration diagram for OyjlCore:

Modules

 OyjlCore Internationalisation
 Language support and Translations for UI's.
 
 OyjlCore I/O
 File I/O.
 
 OyjlCore String
 String Handling.
 

Macros

#define OYJL_NO_BACKTRACE   0x02
 skip oyjlBT() output More...
 
#define OYJL_WRAP   0x1000
 wrap into format specifix code More...
 
#define OYJL_FORCE_COLORTERM   0x01
 skip environment checks and mark More...
 
#define OYJL_FORCE_NO_COLORTERM   0x02
 skip environment checks and do not mark More...
 
#define OYJL_RESET_COLORTERM   0x04
 skip cached checks and init again More...
 

Typedefs

typedef int(* oyjlMessage_f) (int error_code, const void *context, const char *format,...)
 custom message function type More...
 

Enumerations

enum  oyjlTEXTMARK_e { ,
  oyjlNO_MARK = 1, oyjlRED, oyjlGREEN, oyjlBLUE,
  oyjlBOLD, oyjlITALIC, oyjlUNDERLINE
}
 types of terminal color markers More...
 
enum  oyjlMSG_e { ,
  oyjlMSG_INFO = 400, oyjlMSG_CLIENT_CANCELED, oyjlMSG_INSUFFICIENT_DATA, oyjlMSG_ERROR,
  oyjlMSG_PROGRAM_ERROR, oyjlMSG_SECURITY_ALERT
}
 message type More...
 

Functions

int oyjlTermColorInit (int flags)
 setup formating for terminals More...
 
const char * oyjlTermColor (oyjlTEXTMARK_e rgb, const char *text)
 text formating for terminals More...
 
const char * oyjlTermColorF (oyjlTEXTMARK_e rgb, const char *format,...)
 variable text formating for terminals More...
 
const char * oyjlTermColorFPtr (oyjlTEXTMARK_e rgb, char **color_text, const char *format,...)
 variable text formating for terminals More...
 
const char * oyjlTermColorFromHtml (const char *text, int flags)
 convert a subset of HTML to terminal colors More...
 
const char * oyjlTermColorToHtml (const char *text, int flags)
 convert internal used terminal colors to HTML More...
 
void oyjlDebugVariableSet (int *debug)
 set own debug variable More...
 
char * oyjlBT (int stack_limit OYJL_UNUSED)
 backtrace More...
 
const char * oyjlPrintTime (int flags, oyjlTEXTMARK_e mark)
 print current date time More...
 
const char * oyjlTermColorToPlain (const char *text, int flags)
 remove term color marks More...
 
int oyjlMessageFuncSet (oyjlMessage_f message_func)
 set a custom message listener More...
 
int oyjlMessageFunc (int error_code, const void *context_object OYJL_UNUSED, const char *format,...)
 the default message handler to stderr More...
 

Detailed Description

Internationalisation, Terminal colors, I/O and String Handling.

The oyjlTermColor() function family provides text marking on terminal for command line interfaces.

A custom message function can be set by oyjlMessageFuncSet(). The default error function will print to stderr.

Macro Definition Documentation

◆ OYJL_FORCE_COLORTERM

#define OYJL_FORCE_COLORTERM   0x01

skip environment checks and mark

◆ OYJL_FORCE_NO_COLORTERM

#define OYJL_FORCE_NO_COLORTERM   0x02

skip environment checks and do not mark

◆ OYJL_NO_BACKTRACE

#define OYJL_NO_BACKTRACE   0x02

skip oyjlBT() output

◆ OYJL_RESET_COLORTERM

#define OYJL_RESET_COLORTERM   0x04

skip cached checks and init again

Referenced by oyjlTermColorInit().

◆ OYJL_WRAP

#define OYJL_WRAP   0x1000

wrap into format specifix code

Typedef Documentation

◆ oyjlMessage_f

typedef int(* oyjlMessage_f) (int error_code, const void *context, const char *format,...)

custom message function type

Parameters
error_codeoyjlMSG_e codes and possibly own defined ones
contextuser defined data
formatyour text
Returns
error

Enumeration Type Documentation

◆ oyjlMSG_e

enum oyjlMSG_e

message type

Enumerator
oyjlMSG_INFO 

informational, for debugging

oyjlMSG_CLIENT_CANCELED 

user side requested stop

oyjlMSG_INSUFFICIENT_DATA 

missing or insufficient data

oyjlMSG_ERROR 

usage error

oyjlMSG_PROGRAM_ERROR 

program error

oyjlMSG_SECURITY_ALERT 

chanceld by security policy

◆ oyjlTEXTMARK_e

types of terminal color markers

Enumerator
oyjlNO_MARK 

plain

oyjlRED 

red color

oyjlGREEN 

green color

oyjlBLUE 

blue color

oyjlBOLD 

bold

oyjlITALIC 

italic

oyjlUNDERLINE 

<u>underline</u>

Function Documentation

◆ oyjlBT()

char* oyjlBT ( int stack_limit  OYJL_UNUSED)

backtrace

Create backtrace of execution stack. Honour OYJL_NO_BACKTRACE environment variable.

Parameters
[in]stack_limitset limit of stack depth
Returns
one line string with function names and belonging lines of code
Version
Oyjl: 1.0.0
Date
2021/03/20
Since
2021/03/20 (Oyjl: 1.0.0)

Referenced by oyImage_s::oyImage_WriteCUBE(), oyjlLang(), and oyjlTreeDeSerialise().

◆ oyjlDebugVariableSet()

void oyjlDebugVariableSet ( int *  debug)

set own debug variable

◆ oyjlMessageFunc()

int oyjlMessageFunc ( int  error_code,
const void *context_object  OYJL_UNUSED,
const char *  format,
  ... 
)

the default message handler to stderr

Parameters
error_codeoyjlMSG_e codes
context_objectnot used
formatyour text
Returns
error
Version
OpenICC: 0.1.0
Date
2011/10/21
Since
2008/04/03 (OpenICC: 0.1.0)

◆ oyjlMessageFuncSet()

int oyjlMessageFuncSet ( oyjlMessage_f  message_func)

set a custom message listener

Version
OpenICC: 0.1.0
Date
2011/10/21
Since
2008/04/03 (OpenICC: 0.1.0)

◆ oyjlPrintTime()

const char * oyjlPrintTime ( int  flags,
oyjlTEXTMARK_e  mark 
)

print current date time

Create a static string to contain ISO conforming date/time string.

Parameters
[in]flags0 default so ISO dateTtime+-TimeZoneDiff == OYJL_DATE | OYJL_TIME | OYJL_OYJL_TIME_ZONE_DIFF
  • OYJL_DATE : F
  • OYJL_TIME : H:M:S
  • OYJL_TIME_MILLI : H:M:S.d
  • OYJL_OYJL_TIME_ZONE : Z
  • OYJL_OYJL_TIME_ZONE_DIFF : z
  • OYJL_BRACKETS : [datetime]
[in]markset text marking
Returns
one line string with function names and belonging lines of code
Version
Oyjl: 1.0.0
Date
2021/05/21
Since
2021/05/21 (Oyjl: 1.0.0)

One can use OYJL_BRACKETS alone and has dateTtime+-TimeZoneDiff included.

One can use OYJL_TIME_ZONE or OYJL_TIME_ZONE_DIFF alone and has dateTtime included.

◆ oyjlTermColor()

const char * oyjlTermColor ( oyjlTEXTMARK_e  rgb,
const char *  text 
)

text formating for terminals

Input text can be up to 200 chars wide. The returned text is cached. So copy or flush the text before reusing this function.

Version
Oyjl: 1.0.0
Date
2022/09/15
Since
2019/06/16 (Oyjl: 1.0.0)

Referenced by oyjlTreeToYaml().

◆ oyjlTermColorF()

const char * oyjlTermColorF ( oyjlTEXTMARK_e  rgb,
const char *  format,
  ... 
)

variable text formating for terminals

See also
oyjlTermColor()
Version
Oyjl: 1.0.0
Date
2022/09/15
Since
2022/06/06 (Oyjl: 1.0.0)

References OYJL_CREATE_VA_STRING.

◆ oyjlTermColorFPtr()

const char * oyjlTermColorFPtr ( oyjlTEXTMARK_e  rgb,
char **  color_text,
const char *  format,
  ... 
)

variable text formating for terminals

See also
oyjlTermColorF()
Version
Oyjl: 1.0.0
Date
2023/11/25
Since
2023/11/26 (Oyjl: 1.0.0)

References OYJL_CREATE_VA_STRING.

◆ oyjlTermColorFromHtml()

const char * oyjlTermColorFromHtml ( const char *  text,
int  flags 
)

convert a subset of HTML to terminal colors

The supported codes are "<strong>", "<em>", "<u>" and "&nbsp;".

Version
Oyjl: 1.0.0
Date
2022/05/08
Since
2021/11/20 (Oyjl: 1.0.0)

References oyjlTermColorInit().

◆ oyjlTermColorInit()

int oyjlTermColorInit ( int  flags)

setup formating for terminals

Parameters
[in]flagssupport
Returns
state
  • 1 for simple color term
  • 2 for truecolor term
Version
Oyjl: 1.0.0
Date
2024/01/31
Since
2020/03/09 (Oyjl: 1.0.0)

References OYJL_OBSERVE, and OYJL_RESET_COLORTERM.

Referenced by oyjlTermColorFromHtml().

◆ oyjlTermColorToHtml()

const char * oyjlTermColorToHtml ( const char *  text,
int  flags 
)

convert internal used terminal colors to HTML

Support OYJL_WRAP in flags

Version
Oyjl: 1.0.0
Date
2022/09/14
Since
2022/06/10 (Oyjl: 1.0.0)

References oyjlStr_New(), oyjlStr_Push(), and oyjlStr_Replace().

◆ oyjlTermColorToPlain()

const char* oyjlTermColorToPlain ( const char *  text,
int flags   
)

remove term color marks

The OYJL_REGEXP flag uses: int count = oyjlRegExpReplace( &t, "\033[[0-9;]*m", "" ); .

Parameters
[in]textinput
[in]flagssupport OYJL_REGEXP slower but work as well outside Oyjl
Returns
cleaned text
Version
Oyjl: 1.0.0
Date
2022/06/04
Since
2022/04/03 (Oyjl: 1.0.0)

References OYJL_REGEXP, oyjlRegExpReplace(), and oyjlStringCopy().