Xmipp  v3.23.11-Nereus
Enumerations | Functions
xmipp_color.h File Reference
#include <stdio.h>
#include "xmipp_strings.h"
Include dependency graph for xmipp_color.h:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Enumerations

enum  colorAttribute {
  RESET = 0, BRIGHT = 1, DIM = 2, UNDERLINE = 3,
  BLINK = 4, REVERSE = 7, HIDDEN = 8
}
 
enum  colorCode {
  BLACK = 0, RED = 1, GREEN = 2, YELLOW = 3,
  BLUE = 4, MAGENTA = 5, CYAN = 6, WHITE = 7
}
 

Functions

String colorString (const char *msg, int color, int attribute=BRIGHT, int bgcolor=BLACK)
 

Enumeration Type Documentation

◆ colorAttribute

Enumerator
RESET 
BRIGHT 
DIM 
UNDERLINE 
BLINK 
REVERSE 
HIDDEN 

Definition at line 31 of file xmipp_color.h.

32 {
33  RESET = 0,
34  BRIGHT = 1,
35  DIM = 2,
36  UNDERLINE = 3,
37  BLINK = 4,
38  REVERSE = 7,
39  HIDDEN = 8
40 };

◆ colorCode

enum colorCode
Enumerator
BLACK 
RED 
GREEN 
YELLOW 
BLUE 
MAGENTA 
CYAN 
WHITE 

Definition at line 42 of file xmipp_color.h.

43 {
44  BLACK = 0,
45  RED = 1,
46  GREEN = 2,
47  YELLOW = 3,
48  BLUE = 4,
49  MAGENTA = 5,
50  CYAN = 6,
51  WHITE = 7
52 };

Function Documentation

◆ colorString()

String colorString ( const char *  msg,
int  color,
int  attribute = BRIGHT,
int  bgcolor = BLACK 
)

Definition at line 28 of file xmipp_color.cpp.

29 {
30  size_t n = strlen(msg);
31  char *formatBuffer = new char[n+20]; // Extra space for color characters
32  sprintf(formatBuffer, "%c[%d;%dm%s%c[0m", 0x1B, attribute, color + 30, msg, 0x1B);
33  String s = formatBuffer;
34  delete[] formatBuffer;
35  return s;
36 }
std::string String
Definition: xmipp_strings.h:34
int * n