claude-statusline-powerline
Version:
Beautiful powerline-style statusline for Claude Code with git integration, session tracking, and cost monitoring
52 lines • 1.61 kB
JavaScript
;
Object.defineProperty(exports, "__esModule", { value: true });
exports.hex_to_ansi_bg = hex_to_ansi_bg;
exports.hex_to_ansi_fg = hex_to_ansi_fg;
exports.hex_to_ansi = hex_to_ansi;
exports.create_segment_theme = create_segment_theme;
/**
* Convert hex color to ANSI background code
*/
function hex_to_ansi_bg(hex) {
const r = parseInt(hex.slice(1, 3), 16);
const g = parseInt(hex.slice(3, 5), 16);
const b = parseInt(hex.slice(5, 7), 16);
return `\x1b[48;2;${r};${g};${b}m`;
}
/**
* Convert hex color to ANSI foreground code
*/
function hex_to_ansi_fg(hex) {
const r = parseInt(hex.slice(1, 3), 16);
const g = parseInt(hex.slice(3, 5), 16);
const b = parseInt(hex.slice(5, 7), 16);
return `\x1b[38;2;${r};${g};${b}m`;
}
/**
* Convert hex color to ANSI escape code (legacy support)
*/
function hex_to_ansi(hex_color, is_background = false) {
// If it's already an ANSI code, return as-is
if (hex_color.startsWith('\x1b[')) {
return hex_color;
}
// If it's not a hex color, return as-is
if (!hex_color.startsWith('#') || hex_color.length !== 7) {
return hex_color;
}
// Use the dedicated functions for consistency
return is_background
? hex_to_ansi_bg(hex_color)
: hex_to_ansi_fg(hex_color);
}
/**
* Create segment theme from palette colors
*/
function create_segment_theme(bg_color, fg_color) {
return {
background: hex_to_ansi_bg(bg_color),
foreground: hex_to_ansi_fg(fg_color),
separator_color: hex_to_ansi_fg(bg_color),
};
}
//# sourceMappingURL=colors.js.map