<commit_before>/*
 * Yabar - A modern and lightweight status bar for X window managers.
 *
 * Copyright (c) 2016, <NAME>
 * See LICENSE for more information.
 *
 */

#ifndef YABAR_H
#define YABAR_H

#include <stdio.h>
#include <errno.h>
#define __USE_XOPEN2K //for setenv implicit function decleration warning
#include <stdlib.h>
#include <string.h>
#include <stdbool.h>
#include <unistd.h>
#include <sys/types.h>
#include <sys/stat.h>
#include <sys/wait.h>
#include <ctype.h>
#include <xcb/xcb.h>
#include <pango/pango.h>
#include <pango/pangocairo.h>
#include <cairo/cairo-xcb.h>
#include <cairo/cairo.h>
#include <signal.h>
#include <getopt.h>
#include <libconfig.h>

#include <xcb/randr.h>
#include <xcb/xcb_ewmh.h>
#include <xcb/xcb_icccm.h>

#include <gdk-pixbuf/gdk-pixbuf.h>

//just to suppress gcc syntastic warnings in vim
//VERSION is obtained from Makefile
#ifndef VERSION
#define VERSION ""
#endif


extern char *strdup(const char *s); //to suppress implicit decleration warning for strdup

#define BUFSIZE_EXT 512 //buffer size for external blocks
#define BUFSIZE_EXT_PANGO 1024 //buffer size for extern blocks with pango markup
#define BUFSIZE_INT 256 //initial value of buffer size for internal blocks, can be overridden in runtime if needed

#define CFILELEN 256
#define YA_DEF_FONT "sans bold 9"

#define PT1 printf("%d:%s:%s\n", __LINE__, __FUNCTION__, __FILE__)

#define GET_ALPHA(c)	((double)(((c)>>24) & 0xff)/255.0)
#define GET_RED(c)		((double)(((c)>>16) & 0xff)/255.0)
#define GET_GREEN(c)	((double)(((c))     & 0xff)/255.0)
#define GET_BLUE(c)		((double)(((c)>>8)  & 0xff)/255.0)


#define GET_MIN(A, B) ((A) < (B) ? (A) : (B))
#define GET_MAX(A, B) ((A) > (B) ? (A) : (B))


#define DRAW_TEXT(blk) if((blk->attr & BLKA_VAR_WIDTH)) \
							ya_draw_text_var_width(blk);\
						else							\
							ya_draw_pango_text(blk);


enum {
	A_LEFT =0,
	A_CENTER=1,
	A_RIGHT=2
};

enum {
	YA_TOP = 0,
	YA_BOTTOM,
	YA_LEFT,
	YA_RIGHT
};

//Flags of block attributes; stored in blk->attr
enum {
	BLKA_PERIODIC		= 1<<0,
	BLKA_PERSIST		= 1<<1,
	BLKA_ONCE			= 1<<2,
	BLKA_INTERNAL		= 1<<3,
	BLKA_EXTERNAL		= 1<<4,
	BLKA_MARKUP_PANGO 	= 1<<5,
	BLKA_FIXED_WIDTH 	= 1<<6,
	BLKA_ALIGN_LEFT 	= 1<<7,
	BLKA_ALIGN_CENTER 	= 1<<8,
	BLKA_ALIGN_RIGHT 	= 1<<9,
	BLKA_BGCOLOR 		= 1<<10,
	BLKA_FGCOLOR		= 1<<11,
	BLKA_UNDERLINE 		= 1<<12,
	BLKA_OVERLINE 		= 1<<13,
	BLKA_INHERIT		= 1<<14,
	BLKA_INTERN_X_EV	= 1<<15,
	BLKA_ICON			= 1<<16,
	BLKA_DIRTY_COL		= 1<<17,
	BLKA_VAR_WIDTH		= 1<<18
};


// Flags of bar attributes; stored in bar->attr
enum {
	BARA_INHERIT = 1<<0,
	BARA_INHERIT_ALL = 1<<1,
	BARA_DYN_COL = 1<<2,
	BARA_REDRAW = 1<<3
};

//for variable-width blocks, check for whether the bar should be redrawn.
#define SHOULD_REDRAW(blk) (((blk)->attr & BLKA_VAR_WIDTH) && (!((blk)->bar->attr & BARA_REDRAW)) && ((blk)->curwidth != (blk)->width))


#ifdef YA_INTERNAL_EWMH
#define YA_INTERNAL_LEN 15
#else
#define YA_INTERNAL_LEN 13
#endif
enum {
	YA_INT_DATE = 0,
	YA_INT_UPTIME,
	YA_INT_THERMAL,
	YA_INT_BRIGHTNESS,
	YA_INT_BANDWIDTH,
	YA_INT_MEMORY,
	YA_INT_CPU,
	YA_INT_LOADAVG,
	YA_INT_DISKIO,
	YA_INT_NETWORK,
	YA_INT_BATTERY,
	YA_INT_VOLUME,
    YA_INT_WIFI,
	YA_INT_TITLE,
	YA_INT_WORKSPACE
};

#define NOT_INHERIT_BAR(bar) (((bar)->attr & BARA_INHERIT)==0)
#define NOT_INHERIT_BLK(blk) (((blk)->attr & BLKA_INHERIT)==0)

#define CMONLEN 16

typedef struct ya_monitor ya_monitor_t;<commit_msg>Minor indentation fix (tab instead of space)<commit_after>/*
 * Yabar - A modern and lightweight status bar for X window managers.
 *
 * Copyright (c) 2016, <NAME>
 * See LICENSE for more information.
 *
 */

#ifndef YABAR_H
#define YABAR_H

#include <stdio.h>
#include <errno.h>
#define __USE_XOPEN2K //for setenv implicit function decleration warning
#include <stdlib.h>
#include <string.h>
#include <stdbool.h>
#include <unistd.h>
#include <sys/types.h>
#include <sys/stat.h>
#include <sys/wait.h>
#include <ctype.h>
#include <xcb/xcb.h>
#include <pango/pango.h>
#include <pango/pangocairo.h>
#include <cairo/cairo-xcb.h>
#include <cairo/cairo.h>
#include <signal.h>
#include <getopt.h>
#include <libconfig.h>

#include <xcb/randr.h>
#include <xcb/xcb_ewmh.h>
#include <xcb/xcb_icccm.h>

#include <gdk-pixbuf/gdk-pixbuf.h>

//just to suppress gcc syntastic warnings in vim
//VERSION is obtained from Makefile
#ifndef VERSION
#define VERSION ""
#endif


extern char *strdup(const char *s); //to suppress implicit decleration warning for strdup

#define BUFSIZE_EXT 512 //buffer size for external blocks
#define BUFSIZE_EXT_PANGO 1024 //buffer size for extern blocks with pango markup
#define BUFSIZE_INT 256 //initial value of buffer size for internal blocks, can be overridden in runtime if needed

#define CFILELEN 256
#define YA_DEF_FONT "sans bold 9"

#define PT1 printf("%d:%s:%s\n", __LINE__, __FUNCTION__, __FILE__)

#define GET_ALPHA(c)	((double)(((c)>>24) & 0xff)/255.0)
#define GET_RED(c)		((double)(((c)>>16) & 0xff)/255.0)
#define GET_GREEN(c)	((double)(((c))     & 0xff)/255.0)
#define GET_BLUE(c)		((double)(((c)>>8)  & 0xff)/255.0)


#define GET_MIN(A, B) ((A) < (B) ? (A) : (B))
#define GET_MAX(A, B) ((A) > (B) ? (A) : (B))


#define DRAW_TEXT(blk) if((blk->attr & BLKA_VAR_WIDTH)) \
							ya_draw_text_var_width(blk);\
						else							\
							ya_draw_pango_text(blk);


enum {
	A_LEFT =0,
	A_CENTER=1,
	A_RIGHT=2
};

enum {
	YA_TOP = 0,
	YA_BOTTOM,
	YA_LEFT,
	YA_RIGHT
};

//Flags of block attributes; stored in blk->attr
enum {
	BLKA_PERIODIC		= 1<<0,
	BLKA_PERSIST		= 1<<1,
	BLKA_ONCE			= 1<<2,
	BLKA_INTERNAL		= 1<<3,
	BLKA_EXTERNAL		= 1<<4,
	BLKA_MARKUP_PANGO 	= 1<<5,
	BLKA_FIXED_WIDTH 	= 1<<6,
	BLKA_ALIGN_LEFT 	= 1<<7,
	BLKA_ALIGN_CENTER 	= 1<<8,
	BLKA_ALIGN_RIGHT 	= 1<<9,
	BLKA_BGCOLOR 		= 1<<10,
	BLKA_FGCOLOR		= 1<<11,
	BLKA_UNDERLINE 		= 1<<12,
	BLKA_OVERLINE 		= 1<<13,
	BLKA_INHERIT		= 1<<14,
	BLKA_INTERN_X_EV	= 1<<15,
	BLKA_ICON			= 1<<16,
	BLKA_DIRTY_COL		= 1<<17,
	BLKA_VAR_WIDTH		= 1<<18
};


// Flags of bar attributes; stored in bar->attr
enum {
	BARA_INHERIT = 1<<0,
	BARA_INHERIT_ALL = 1<<1,
	BARA_DYN_COL = 1<<2,
	BARA_REDRAW = 1<<3
};

//for variable-width blocks, check for whether the bar should be redrawn.
#define SHOULD_REDRAW(blk) (((blk)->attr & BLKA_VAR_WIDTH) && (!((blk)->bar->attr & BARA_REDRAW)) && ((blk)->curwidth != (blk)->width))


#ifdef YA_INTERNAL_EWMH
#define YA_INTERNAL_LEN 15
#else
#define YA_INTERNAL_LEN 13
#endif
enum {
	YA_INT_DATE = 0,
	YA_INT_UPTIME,
	YA_INT_THERMAL,
	YA_INT_BRIGHTNESS,
	YA_INT_BANDWIDTH,
	YA_INT_MEMORY,
	YA_INT_CPU,
	YA_INT_LOADAVG,
	YA_INT_DISKIO,
	YA_INT_NETWORK,
	YA_INT_BATTERY,
	YA_INT_VOLUME,
	YA_INT_WIFI,
	YA_INT_TITLE,
	YA_INT_WORKSPACE
};

#define NOT_INHERIT_BAR(bar) (((bar)->attr & BARA_INHERIT)==0)
#define NOT_INHERIT_BLK(blk) (((blk)->attr & BLKA_INHERIT)==0)

#define CMONLEN 16

typedef struct ya_monitor ya_monitor_t;
{'fraction_non_alphanumeric': 0.1506288388417666, 'fraction_numerical': 0.03305059959052355, 'mean_word_length': 4.542139384116694, 'pattern_counts': {'":': 0, '<': 143, '<?xml version=': 0, '>': 83, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '6910381', 'n_tokens_mistral': 3375, 'n_tokens_neox': 3038, 'n_words': 663}