void _rl_set_normal_color (void) { if (is_colored (C_NORM)) { _rl_put_indicator (&_rl_color_indicator[C_LEFT]); _rl_put_indicator (&_rl_color_indicator[C_NORM]); _rl_put_indicator (&_rl_color_indicator[C_RIGHT]); } }
void TilingPatternImpl::on_write(ObjFmt& fmt) { fmt .dict_key("Type").output("Pattern") .dict_key("PatternType").space().output(1) .dict_key("PaintType").space().output(is_colored() ? 1 : 2) .dict_key("TilingType").space().output(m_tiling_type) .dict_key("XStep").space().output(m_step[0]) .dict_key("YStep").space().output(m_step[1]) ; output_array("BBox", fmt, m_bbox, m_bbox+4); output_array("Matrix", fmt, m_matrix.begin(), m_matrix.end()); output_resource_dictionary_ref(m_res_dict, fmt); }
bool _rl_print_prefix_color (void) { struct bin_str *s; /* What do we want to use for the prefix? Let's try cyan first, see colors.h */ s = &_rl_color_indicator[C_PREFIX]; if (s->string != NULL) { if (is_colored (C_NORM)) restore_default_color (); _rl_put_indicator (&_rl_color_indicator[C_LEFT]); _rl_put_indicator (s); _rl_put_indicator (&_rl_color_indicator[C_RIGHT]); return 0; } else return 1; }
/* Returns whether any color sequence was printed. */ bool _rl_print_color_indicator (const char *f) { enum indicator_no colored_filetype; COLOR_EXT_TYPE *ext; /* Color extension */ size_t len; /* Length of name */ const char* name; char *filename; struct stat astat, linkstat; mode_t mode; int linkok; /* 1 == ok, 0 == dangling symlink, -1 == missing */ int stat_ok; name = f; /* This should already have undergone tilde expansion */ filename = 0; if (rl_filename_stat_hook) { filename = savestring (f); (*rl_filename_stat_hook) (&filename); name = filename; } #if defined (HAVE_LSTAT) stat_ok = lstat(name, &astat); #else stat_ok = stat(name, &astat); #endif if (stat_ok == 0) { mode = astat.st_mode; #if defined (HAVE_LSTAT) if (S_ISLNK (mode)) { linkok = stat (name, &linkstat) == 0; if (linkok && strncmp (_rl_color_indicator[C_LINK].string, "target", 6) == 0) mode = linkstat.st_mode; } else #endif linkok = 1; } else linkok = -1; /* Is this a nonexistent file? If so, linkok == -1. */ if (linkok == -1 && _rl_color_indicator[C_MISSING].string != NULL) colored_filetype = C_MISSING; else if (linkok == 0 && S_ISLNK(mode) && _rl_color_indicator[C_ORPHAN].string != NULL) colored_filetype = C_ORPHAN; /* dangling symlink */ else if(stat_ok != 0) { static enum indicator_no filetype_indicator[] = FILETYPE_INDICATORS; colored_filetype = filetype_indicator[normal]; //f->filetype]; } else { if (S_ISREG (mode)) { colored_filetype = C_FILE; if ((mode & S_ISUID) != 0 && is_colored (C_SETUID)) colored_filetype = C_SETUID; else if ((mode & S_ISGID) != 0 && is_colored (C_SETGID)) colored_filetype = C_SETGID; else if (is_colored (C_CAP) && 0) //f->has_capability) colored_filetype = C_CAP; else if ((mode & S_IXUGO) != 0 && is_colored (C_EXEC)) colored_filetype = C_EXEC; else if ((1 < astat.st_nlink) && is_colored (C_MULTIHARDLINK)) colored_filetype = C_MULTIHARDLINK; } else if (S_ISDIR (mode)) { colored_filetype = C_DIR; #if defined (S_ISVTX) if ((mode & S_ISVTX) && (mode & S_IWOTH) && is_colored (C_STICKY_OTHER_WRITABLE)) colored_filetype = C_STICKY_OTHER_WRITABLE; else #endif if ((mode & S_IWOTH) != 0 && is_colored (C_OTHER_WRITABLE)) colored_filetype = C_OTHER_WRITABLE; #if defined (S_ISVTX) else if ((mode & S_ISVTX) != 0 && is_colored (C_STICKY)) colored_filetype = C_STICKY; #endif } else if (S_ISLNK (mode)) colored_filetype = C_LINK; else if (S_ISFIFO (mode)) colored_filetype = C_FIFO; else if (S_ISSOCK (mode)) colored_filetype = C_SOCK; else if (S_ISBLK (mode)) colored_filetype = C_BLK; else if (S_ISCHR (mode)) colored_filetype = C_CHR; else { /* Classify a file of some other type as C_ORPHAN. */ colored_filetype = C_ORPHAN; } } /* Check the file's suffix only if still classified as C_FILE. */ ext = NULL; if (colored_filetype == C_FILE) { /* Test if NAME has a recognized suffix. */ len = strlen (name); name += len; /* Pointer to final \0. */ for (ext = _rl_color_ext_list; ext != NULL; ext = ext->next) { if (ext->ext.len <= len && strncmp (name - ext->ext.len, ext->ext.string, ext->ext.len) == 0) break; } } free (filename); /* NULL or savestring return value */ { const struct bin_str *const s = ext ? &(ext->seq) : &_rl_color_indicator[colored_filetype]; if (s->string != NULL) { /* Need to reset so not dealing with attribute combinations */ if (is_colored (C_NORM)) restore_default_color (); _rl_put_indicator (&_rl_color_indicator[C_LEFT]); _rl_put_indicator (s); _rl_put_indicator (&_rl_color_indicator[C_RIGHT]); return 0; } else return 1; } }