"Fossies" - the Fresh Open Source Software Archive  

Source code changes of the file "src/terminal/Color.c" between
monit-5.27.2.tar.gz and monit-5.28.0.tar.gz

About: Monit is a utility for managing and monitoring processes, files, directories and filesystems (with automatic error recovery).

Color.c  (monit-5.27.2):Color.c  (monit-5.28.0)
skipping to change at line 36 skipping to change at line 36
#ifdef HAVE_STDLIB_H #ifdef HAVE_STDLIB_H
#include <stdlib.h> #include <stdlib.h>
#endif #endif
#ifdef HAVE_UNISTD_H #ifdef HAVE_UNISTD_H
#include <unistd.h> #include <unistd.h>
#endif #endif
#include "monit.h" #include "monit.h"
#include "Color.h" #include "TextColor.h"
// libmonit // libmonit
#include "util/Str.h" #include "util/Str.h"
/** /**
* Implementation of the Terminal color interface * Implementation of the Terminal color interface
* *
* @author http://www.tildeslash.com/ * @author http://www.tildeslash.com/
* @see http://www.mmonit.com/ * @see http://www.mmonit.com/
* @file * @file
*/ */
/* -------------------------------------------------------- Public Methods */ /* -------------------------------------------------------- Public Methods */
bool Color_support() { bool TextColor_support() {
if (! (Run.flags & Run_Batch) && isatty(STDOUT_FILENO)) { if (! (Run.flags & Run_Batch) && isatty(STDOUT_FILENO)) {
if (getenv("COLORTERM")) { if (getenv("COLORTERM")) {
return true; return true;
} else { } else {
char *term = getenv("TERM"); char *term = getenv("TERM");
if (term && (Str_startsWith(term, "screen") || Str_start sWith(term, "xterm") || Str_startsWith(term, "vt100") || Str_startsWith(term, "a nsi") || Str_startsWith(term, "linux") || Str_startsWith(term, "rxvt") || Str_su b(term, "color"))) if (term && (Str_startsWith(term, "screen") || Str_start sWith(term, "xterm") || Str_startsWith(term, "vt100") || Str_startsWith(term, "a nsi") || Str_startsWith(term, "linux") || Str_startsWith(term, "rxvt") || Str_su b(term, "color")))
return true; return true;
} }
} }
return false; return false;
} }
int Color_length(char *s) { int TextColor_length(char *s) {
if (STR_DEF(s)) { if (STR_DEF(s)) {
int length = 0; int length = 0;
bool ansi = false; bool ansi = false;
for (int i = 0; s[i]; i++) { for (int i = 0; s[i]; i++) {
if (s[i] == '\033' && s[i + 1] == '[') { if (s[i] == '\033' && s[i + 1] == '[') {
// Escape sequence start // Escape sequence start
ansi = true; ansi = true;
length += 2; length += 2;
i++; i++;
} else if (ansi) { } else if (ansi) {
skipping to change at line 86 skipping to change at line 86
// Escape sequence stop // Escape sequence stop
if (s[i] >= 64 && s[i] <= 126) if (s[i] >= 64 && s[i] <= 126)
ansi = false; ansi = false;
} }
} }
return length; return length;
} }
return 0; return 0;
} }
char *Color_strip(char *s) { char *TextColor_strip(char *s) {
if (STR_DEF(s)) { if (STR_DEF(s)) {
int x, y; int x, y;
bool ansi = false; bool ansi = false;
for (x = 0, y = 0; s[y]; y++) { for (x = 0, y = 0; s[y]; y++) {
if (s[y] == '\033' && s[y + 1] == '[') { if (s[y] == '\033' && s[y + 1] == '[') {
// Escape sequence start // Escape sequence start
ansi = true; ansi = true;
y++; // ++ to skip 'ESC[' y++; // ++ to skip 'ESC['
} else if (ansi) { } else if (ansi) {
// Escape sequence stop // Escape sequence stop
 End of changes. 4 change blocks. 
4 lines changed or deleted 4 lines changed or added

Home  |  About  |  Features  |  All  |  Newest  |  Dox  |  Diffs  |  RSS Feeds  |  Screenshots  |  Comments  |  Imprint  |  Privacy  |  HTTP(S)