ekg2  GIT master
Struktury danych | Definicje | Funkcje | Zmienne
Dokumentacja pliku themes.c
#include "ekg2.h"
#include <limits.h>
#include <stdarg.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <unistd.h>
#include <errno.h>
Wykres zależności załączania dla themes.c:

Struktury danych

struct  format
 

Definicje

#define ROL(x)   (((x>>25)&0x7f)|((x<<7)&0xffffff80))
 
#define NPAR   16 /* ECMA-48 CSI have got max 16 params (NPAR) defined in <linux/console_struct.h> */
 
#define FORMAT_ADD(format, value, replace)   sprintf(tmp, format, status); format_add(tmp, value, replace)
 
#define FORMAT_ADDF(format, fvalue, replace)   FORMAT_ADD(format, theme_init_contact_helper(fvalue, color), replace);
 

Funkcje

static void list_format_free (struct format *data)
 
static void formats_add (struct format **lista, struct format *new_)
 
static struct formatformats_removei (struct format **lista, struct format *elem)
 
static void formats_destroy (struct format **lista)
 
static int gim_hash (const char *name)
 
const char * format_find (const char *name)
 
static const char * format_ansi (char ch)
 
void fstring_iter (const fstring_t *s, gchar **text, fstr_attr_t **attr, gssize *len)
 
gboolean fstring_next (gchar **text, fstr_attr_t **attr, gssize *len, fstr_attr_t *change)
 
static char * fstring2str (fstring_t *f)
 
static char * va_format_string (const char *format, va_list ap)
 
fstring_tfstring_dup (const fstring_t *str)
 
fstring_tfstring_new (const char *str)
 
fstring_tfstring_new_format (const char *format,...)
 
void fstring_free (fstring_t *str)
 
char * format_string (const char *format,...)
 
static void print_window_c (window_t *w, int activity, const char *theme, va_list ap)
 
static window_tprint_window_find (const char *target, session_t *session, int separate)
 
void print_window (const char *target, session_t *session, int activity, int separate, const char *theme,...)
 
void print_info (const char *target, session_t *session, const char *theme,...)
 
void print_warning (const char *target, session_t *session, const char *theme,...)
 
void print_window_w (window_t *w, int activity, const char *theme,...)
 
void theme_cache_reset ()
 
void format_add (const char *name, const char *value, int replace)
 
static int format_remove (const char *name)
 
static FILE * theme_open (const char *prefix, const char *filename)
 
int theme_read (const char *filename, int replace)
 
int theme_write (const char *filename)
 
void theme_enumerate (int(*enumerator)(const char *theme, const char *value))
 
void theme_free ()
 
void theme_plugins_init ()
 
static const char * theme_init_contact_helper (const char *theme, char color)
 
static void theme_init_contact_status (const char *status, char color, int want_quick_list)
 
void theme_init ()
 

Zmienne

static char * prompt_cache = NULL
 
static char * prompt2_cache = NULL
 
static char * error_cache = NULL
 
static const char * timestamp_cache = NULL
 
static int no_prompt_cache = 0
 
static int no_prompt_cache_hash = 0x139dcbd6
 
static struct formatformats [0x100]
 

Dokumentacja definicji

◆ FORMAT_ADD

#define FORMAT_ADD (   format,
  value,
  replace 
)    sprintf(tmp, format, status); format_add(tmp, value, replace)

◆ FORMAT_ADDF

#define FORMAT_ADDF (   format,
  fvalue,
  replace 
)    FORMAT_ADD(format, theme_init_contact_helper(fvalue, color), replace);

◆ NPAR

#define NPAR   16 /* ECMA-48 CSI have got max 16 params (NPAR) defined in <linux/console_struct.h> */

◆ ROL

#define ROL (   x)    (((x>>25)&0x7f)|((x<<7)&0xffffff80))

Dokumentacja funkcji

◆ format_add()

void format_add ( const char *  name,
const char *  value,
int  replace 
)

format_add()

Add format with name and value.
If replace set to 1, than if format with the same name exists. than format value will be replaced.

Do zrobienia:
What about creating global variable: formats_unique_here.. and if set to 1, don't search if this format already exists? It should speedup theme_init() a little.
Parametry
name- name of format
value- value of format
replace- if this format exists and is set to 1 than format value will be replaced with new one. else do nothing.

◆ format_ansi()

static const char* format_ansi ( char  ch)
static

◆ format_find()

const char* format_find ( const char *  name)

◆ format_remove()

static int format_remove ( const char *  name)
static

format_remove()

Remove format with given name.

Do zrobienia:
We can speedup it a little, by passing to list_remove() ptr to previous item.. senseless?
Parametry
name
Zwraca
0 if format was founded and removed from list
-1 else

◆ format_string()

char* format_string ( const char *  format,
  ... 
)

◆ formats_add()

static void formats_add ( struct format **  lista,
struct format new_ 
)
static

◆ formats_destroy()

static void formats_destroy ( struct format **  lista)
static

◆ formats_removei()

static struct format* formats_removei ( struct format **  lista,
struct format elem 
)
static

◆ fstring2str()

static char* fstring2str ( fstring_t f)
static

◆ fstring_dup()

fstring_t* fstring_dup ( const fstring_t str)

fstring_dup()

Return a duplicated copy of a fstring_t with all internal data duplicated.

Parametry
str- string
Zwraca
A newly-allocated fstring_t.
Nota
Please note that private data is not duplicated.

◆ fstring_free()

void fstring_free ( fstring_t str)

fstring_free()

Free memory allocated by str

Do zrobienia:
XXX Think about freeing str->priv_data
Parametry
str- fstring_t * to free.

◆ fstring_iter()

void fstring_iter ( const fstring_t s,
gchar **  text,
fstr_attr_t **  attr,
gssize *  len 
)

fstring_iter()

Initiate iteration over fstring_t. Set pointers to the initial values.

Parametry
s- the iterated fstring_t.
text- location to store the current text segment pointer.
attr- location to store the current attr segment pointer.
len- location to store the length of the current segment.
Nota
This function just initializes the vars, use fstring_next() to get the first segment.

◆ fstring_new()

fstring_t* fstring_new ( const char *  str)

fstring_new()

Change formatted ansi string (str) to Nowy-i-Lepszy (tm) [New-and-Better].

Parametry
str- string
Zobacz również
format_string() - Function to format strings.
fstring_free() - Function to free fstring_t.
Zwraca
Allocated fstring_t.

◆ fstring_new_format()

fstring_t* fstring_new_format ( const char *  format,
  ... 
)

fstring_new_format()

char *tmp = format_string("format", .....); fstr = fstring_new(tmp); xfree(tmp);

◆ fstring_next()

gboolean fstring_next ( gchar **  text,
fstr_attr_t **  attr,
gssize *  len,
fstr_attr_t change 
)

fstring_next()

Iterate over fragments of fstring_t with unchanged attributes.

Parametry
text- location to store the current text segment pointer.
attr- location to store the current attr segment pointer.
len- location to store the length of the current segment.
change- location to store changed attribute map or NULL.
Zwraca
TRUE if next segment was found, FALSE on end of string.
Nota
This function relies on the values stored by previous calls, please do not modify them. The variables need to be initialized by fstring_iter().
gchar *s;
gssize len;
fstr_attr_t change;
fstring_iter(fstr, &s, &a, &len);
while (fstring_next(&s, &a, &len, NULL)) {
my_setattr(*a);
my_printn(s, len);
}

◆ gim_hash()

static int gim_hash ( const char *  name)
static

◆ list_format_free()

static void list_format_free ( struct format data)
static

◆ print_info()

void print_info ( const char *  target,
session_t session,
const char *  theme,
  ... 
)

◆ print_warning()

void print_warning ( const char *  target,
session_t session,
const char *  theme,
  ... 
)

◆ print_window()

void print_window ( const char *  target,
session_t session,
int  activity,
int  separate,
const char *  theme,
  ... 
)

print_window()

Print given text in given window [target+ session]

Do zrobienia:
We have no policy for displaying messages by e.g. jabber resources.
For now we do: [only jabber]
  • If target has '/' inside. We put there NUL char.
  • After it we search for window with stripped '/'
  • If founded, than done.
    If not, we look for user in userlist.. And if not found, than we'll create new window with stripped '/' [only jabber]
Parametry
target- target to look for.
session- session to look for.
activity- how important is text?
separate- if essence of text is important to create new window
theme- Name of format to format_string() with ... Text will be be built.
...

◆ print_window_c()

static void print_window_c ( window_t w,
int  activity,
const char *  theme,
va_list  ap 
)
static

print_window_c()

Mind abbreviation ;) print_window_c() -> print_window_common()
Common stuff for: print_window() and print_window_w()
Change w->act if needed, format theme, make fstring() and send everything to window_print()

Nota
We only check if w == NULL, if you send here wrong window_t ptr, everything can happen. don't do it. Yeah, we can do here window_find_ptr() but it'll slow down code a lot.

◆ print_window_find()

static window_t* print_window_find ( const char *  target,
session_t session,
int  separate 
)
static

print_window_find()

Find given window [based on target and session] if not found, and separate set, create new one.

Print given text in given window [target+ session]

Do zrobienia:
We have no policy for displaying messages by e.g. jabber resources.
For now we do: [only jabber]
  • If target has '/' inside. We put there NUL char.
  • After it we search for window with stripped '/'
  • If founded, than done.
    If not, we look for user in userlist.. And if not found, than we'll create new window with stripped '/' [only jabber]
Parametry
target- target to look for.
session- session to look for.
separate- if essence of text is important to create new window

◆ print_window_w()

void print_window_w ( window_t w,
int  activity,
const char *  theme,
  ... 
)

print_window_w()

Like print_window() but it takes window_t struct instead of target+session.

Nota
The same as in print_window_c(): we don't check if w is valid window ptr. Just be careful. If you are not sure call:
print_window_c(window_find_ptr(w), separate, theme, ...) And in worst case text will be displayed in (__status / or __current) window instead of a usual one.. But ekg2 won't crash.
Parametry
w- window to display,
if NULL than __status or __current will be used. it depends on: config_default_status_window and config_display_crap variables.

◆ theme_cache_reset()

static void theme_cache_reset ( )

theme_cache_reset()

Remove cached: prompt_cache, prompt2_cache, error_cache and timestamp_cache
These values are used by va_format_string() to don't call format_find() on:
["prompt" "%>", "prompt2" "%)", "errror" "%!", "timestamp" "%#"]

◆ theme_enumerate()

void theme_enumerate ( int(*)(const char *theme, const char *value)  enumerator)

◆ theme_free()

void theme_free ( )

◆ theme_init()

void theme_init ( )

◆ theme_init_contact_helper()

static const char* theme_init_contact_helper ( const char *  theme,
char  color 
)
static

◆ theme_init_contact_status()

static void theme_init_contact_status ( const char *  status,
char  color,
int  want_quick_list 
)
static

◆ theme_open()

static FILE* theme_open ( const char *  prefix,
const char *  filename 
)
static

◆ theme_plugins_init()

void theme_plugins_init ( )

◆ theme_read()

int theme_read ( const char *  filename,
int  replace 
)

◆ theme_write()

int theme_write ( const char *  filename)

◆ va_format_string()

static char* va_format_string ( const char *  format,
va_list  ap 
)
static

Dokumentacja zmiennych

◆ error_cache

char * error_cache = NULL
static

◆ formats

struct format* formats[0x100]
static

◆ no_prompt_cache

int no_prompt_cache = 0
static

◆ no_prompt_cache_hash

int no_prompt_cache_hash = 0x139dcbd6
static

◆ prompt2_cache

char * prompt2_cache = NULL
static

◆ prompt_cache

char* prompt_cache = NULL
static

◆ timestamp_cache

const char* timestamp_cache = NULL
static