C-Menu 0.2.9
A User Interface Toolkit
Loading...
Searching...
No Matches
Chyron Management

Create and manage the Chyron. More...

Functions

void activate_all_chyron_keys (Chyron *chyron)
 Deactivate chyron key.
void activate_chyron_key (Chyron *chyron, int k)
 Activate chyron key.
void compile_chyron (Chyron *chyron)
 construct the chyron string from the chyron structure
void deactivate_all_chyron_keys (Chyron *chyron)
 Deactivate all chyron keys.
void deactivate_chyron_key (Chyron *chyron, int k)
 Deactivate chyron key.
Chyrondestroy_chyron (Chyron *chyron)
 Destroy Chyron structure.
void display_chyron (WINDOW *win, Chyron *chyron, int line, int col)
 Display chyron on window.
int get_chyron_key (Chyron *chyron, int x)
 Get keycode from chyron.
bool is_set_chyron_key (Chyron *chyron, int k)
 Check if function key label is set.
int mb_to_cc (cchar_t *cmplx_buf, char *str, attr_t attr, int cpx, int *pos, int maxlen)
 Convert multibyte string to complex character array.
Chyronnew_chyron ()
 Create and initialize Chyron structure.
void set_chyron_key (Chyron *chyron, int k, char *s, int kc)
 Set chyron key with default color pair (cp_nt_rev).
void set_chyron_key_cp (Chyron *chyron, int k, char *s, int kc, int cp)
 Set chyron key with color pair (cp).
void unset_chyron_key (Chyron *chyron, int k)
 Unset chyron key.

Detailed Description

Create and manage the Chyron.

Function Documentation

◆ activate_all_chyron_keys()

void activate_all_chyron_keys ( Chyron * chyron)

Deactivate chyron key.

deactivate_chyron_key

Parameters
chyronstructure
kchyron_key index

Definition at line 1816 of file dwin.c.

1816 {
1817 for (int k = 0; k < CHYRON_KEYS; k++)
1818 chyron->key[k]->active = true;
1819}
#define CHYRON_KEYS
Definition cm.h:333
bool active
Definition cm.h:336
ChyronKey * key[CHYRON_KEYS]
Definition cm.h:345

References ChyronKey::active, and Chyron::key.

◆ activate_chyron_key()

void activate_chyron_key ( Chyron * chyron,
int k )

Activate chyron key.

activate_chyron_key

Parameters
chyronstructure
kchyron_key index

Definition at line 1807 of file dwin.c.

1807 {
1808 chyron->key[k]->active = true;
1809}

References ChyronKey::active, and Chyron::key.

◆ compile_chyron()

void compile_chyron ( Chyron * chyron)

construct the chyron string from the chyron structure

compile_chyron

Parameters
chyron

The chyron string is constructed by concatenating the labels of the set keys, separated by " | ". The end_pos values for each key are set to determine the zones for mouse clicks. When a mouse click occurs, the get_chyron_key function uses the end_pos values to determine which key was clicked based on the X position of the click.

Definition at line 1848 of file dwin.c.

1848 {
1849 int end_pos = 0;
1850 int k = 0;
1851 int pos = 0;
1852 int cp = cp_nt_rev;
1853 cchar_t *cx;
1854 char tmp_str[MAXLEN];
1855 while (k < CHYRON_KEYS) {
1856 if (chyron->key[k]->text[0] == '\0' || !chyron->key[k]->active) {
1857 k++;
1858 continue;
1859 }
1860 if (end_pos == 0) {
1861 cx = chyron->cmplx_buf;
1862 mb_to_cc(cx, " ", WA_NORMAL, cp_nt_rev, &pos, MAXLEN - 1);
1863 } else {
1864 mb_to_cc(chyron->cmplx_buf, "|", WA_NORMAL, cp_nt_rev, &pos,
1865 MAXLEN - 1);
1866 }
1867 cx = chyron->cmplx_buf;
1868 if (chyron->key[k]->cp)
1869 cp = chyron->key[k]->cp;
1870 mb_to_cc(cx, chyron->key[k]->text, WA_NORMAL, cp, &pos, MAXLEN - 1);
1871 end_pos = pos;
1872 chyron->l = end_pos;
1873 chyron->key[k]->end_pos = end_pos;
1874 ssnprintf(tmp_str, MAXLEN - 1, "k=%d, text=%s, end_pos=%d", k,
1875 chyron->key[k]->text, chyron->key[k]->end_pos);
1876 k++;
1877 }
1878 mb_to_cc(chyron->cmplx_buf, " ", WA_NORMAL, cp, &pos, MAXLEN - 1);
1879 chyron->l = end_pos;
1880}
int cp_nt_rev
Definition dwin.c:184
#define MAXLEN
Definition curskeys.c:15
int mb_to_cc(cchar_t *, char *, attr_t, int, int *, int)
Convert multibyte string to complex character array.
Definition dwin.c:705
size_t ssnprintf(char *, size_t, const char *,...)
ssnprintf was designed to be a safer alternative to snprintf.
Definition futil.c:420
char text[CHYRON_KEY_MAXLEN]
Definition cm.h:337
int end_pos
Definition cm.h:340
int cp
Definition cm.h:341
int l
Definition cm.h:348
cchar_t cmplx_buf[MAXLEN]
Definition cm.h:347

References ChyronKey::active, Chyron::cmplx_buf, ChyronKey::cp, cp_nt_rev, ChyronKey::end_pos, Chyron::key, Chyron::l, mb_to_cc(), ssnprintf(), and ChyronKey::text.

Referenced by action_disposition(), answer_yn(), display_error(), field_editor(), form_engine(), form_post(), form_process(), init_pick(), Perror(), pick_engine(), picker(), and wait_mk_chyron().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ deactivate_all_chyron_keys()

void deactivate_all_chyron_keys ( Chyron * chyron)

Deactivate all chyron keys.

deactivate_all_chyron_keys

Parameters
chyronstructure

Definition at line 1834 of file dwin.c.

1834 {
1835 for (int k = 0; k < CHYRON_KEYS; k++)
1836 chyron->key[k]->active = false;
1837}

References ChyronKey::active, and Chyron::key.

◆ deactivate_chyron_key()

void deactivate_chyron_key ( Chyron * chyron,
int k )

Deactivate chyron key.

deactivate_chyron_key

Parameters
chyronstructure
kchyron_key index

Definition at line 1826 of file dwin.c.

1826 {
1827 chyron->key[k]->active = false;
1828}

References ChyronKey::active, and Chyron::key.

◆ destroy_chyron()

Chyron * destroy_chyron ( Chyron * chyron)

Destroy Chyron structure.

destroy_chyron

Parameters
chyronpointer to Chyron structure
Returns
nullptr

Definition at line 1722 of file dwin.c.

1722 {
1723 int i;
1724
1725 if (!chyron)
1726 return nullptr;
1727 for (i = 0; i < CHYRON_KEYS; i++) {
1728 if (chyron->key[i]) {
1729 free(chyron->key[i]);
1730 chyron->key[i] = nullptr;
1731 }
1732 }
1733 free(chyron);
1734 chyron = nullptr;
1735 return chyron;
1736}

References Chyron::key.

Referenced by action_disposition(), answer_yn(), display_error(), init_form(), Perror(), pick_engine(), wait_destroy(), and waitpid_with_timeout().

Here is the caller graph for this function:

◆ display_chyron()

void display_chyron ( WINDOW * win,
Chyron * chyron,
int line,
int col )

Display chyron on window.

display_chyron

Parameters
winNCurses window to display chyron on
chyronChyron structure containing the compiled chyron string
lineLine number to display the chyron on
colColumn number to start displaying the chyron from

This function clears the line where the chyron will be displayed, then uses wadd_wchstr to add the compiled chyron string (cmplx_buf) to the window. Finally, it moves the cursor to the specified column position.

Definition at line 1892 of file dwin.c.

1892 {
1893 wmove(win, line, 0);
1894 wclrtoeol(win);
1895 wmove(win, line, 0);
1896 wadd_wchstr(win, chyron->cmplx_buf);
1897 wmove(win, line, col);
1898 update_panels();
1899 doupdate();
1900 return;
1901}

References Chyron::cmplx_buf.

Referenced by action_disposition(), answer_yn(), display_error(), field_editor(), form_engine(), form_post(), form_process(), Perror(), picker(), wait_continue(), and wait_mk_win().

Here is the caller graph for this function:

◆ get_chyron_key()

int get_chyron_key ( Chyron * chyron,
int x )

Get keycode from chyron.

get_chyron_key

Parameters
chyronstructure
xMouse X position
Returns
Keycode

This function uses the end_pos values set in compile_chyron to determine which key was clicked. The chyron functions provide xwgetch() with a mechanism to translate mouse click positions into key codes based on the labels set in the chyron structure. When a mouse click occurs, xwgetch() can call get_chyron_key() with the X position of the click to determine which function key was clicked, allowing for dynamic and customizable function key behavior in the chyron area of the interface.

Definition at line 1917 of file dwin.c.

1917 {
1918 int i = 0;
1919 int k = -1;
1920 while (i < CHYRON_KEYS - 1) {
1921 if (chyron->key[i]->text[0] != '\0' && chyron->key[i]->active)
1922 if (chyron->key[i]->end_pos >= x) {
1923 k = i;
1924 break;
1925 }
1926 i++;
1927 }
1928 if (k == -1)
1929 return 0;
1930 return chyron->key[k]->keycode;
1931}
int keycode
Definition cm.h:339

References ChyronKey::active, ChyronKey::end_pos, Chyron::key, ChyronKey::keycode, and ChyronKey::text.

Referenced by dxwgetch(), and xwgetch().

Here is the caller graph for this function:

◆ is_set_chyron_key()

bool is_set_chyron_key ( Chyron * chyron,
int k )

Check if function key label is set.

is_set_chyron_key

Parameters
chyronstructure
kFunction key index (0-19)
Returns
true if set, false if not set

Definition at line 1743 of file dwin.c.

1743 {
1744 if (chyron->key[k]->text[0] != '\0')
1745 return true;
1746 else
1747 return false;
1748}

References Chyron::key, and ChyronKey::text.

Referenced by form_post(), and form_process().

Here is the caller graph for this function:

◆ mb_to_cc()

int mb_to_cc ( cchar_t * cmplx_buf,
char * str,
attr_t attr,
int cpx,
int * pos,
int maxlen )

Convert multibyte string to complex character array.

mb_to_cc

Parameters
cmplx_bufOutput buffer for complex characters
strInput multibyte string
attrAttributes to apply to the complex characters
cpxColor pair index for the complex characters
posPointer to current position in the output buffer, updated as characters are added
maxlenMaximum length of the output buffer
Returns
Number of bytes processed from the input string

This function converts a multibyte string to an array of complex characters (cchar_t) that can be used with NCurses functions. It handles multibyte characters and applies the specified color pair to each character. The pos parameter is updated to reflect the current position in the output buffer, and the function ensures that it does not exceed the maximum length.

Definition at line 705 of file dwin.c.

706 {
707 int i = 0, len = 0;
708 const char *s;
709 cchar_t cc = {0};
710 wchar_t wstr[2] = {L'\0', L'\0'};
711 mbstate_t mbstate;
712 memset(&mbstate, 0, sizeof(mbstate));
713 attr = WA_NORMAL;
714 if (*pos >= maxlen - 1)
715 return 0;
716 while (str[i] != '\0') {
717 s = &str[i];
718 len = mbrtowc(wstr, s, MB_CUR_MAX, &mbstate);
719 if (len <= 0) {
720 wstr[0] = L'?';
721 wstr[1] = L'\0';
722 len = 1;
723 }
724 wstr[1] = L'\0';
725 if (*pos >= maxlen - 1)
726 break;
727 if (setcchar(&cc, wstr, attr, cpx, nullptr) != ERR) {
728 if (len > 0 && (*pos + len) < MAXLEN - 1)
729 cmplx_buf[(*pos)++] = cc;
730 }
731 i += len;
732 }
733 wstr[0] = L'\0';
734 wstr[1] = L'\0';
735 setcchar(&cc, wstr, attr, cpx, nullptr);
736 cmplx_buf[*pos] = cc;
737 return *pos;
738}

Referenced by border_hsplit_text(), border_title(), and compile_chyron().

Here is the caller graph for this function:

◆ new_chyron()

Chyron * new_chyron ( )

Create and initialize Chyron structure.

new_chyron

Returns
pointer to new Chyron structure

This function allocates memory for a new Chyron structure and initializes the key pointers. Each key pointer is allocated memory for a ChyronKey structure. The Chyron structure is used to manage function key labels and their associated keycodes for mouse click handling in the chyron area of the interface. The use of calloc ensures that the allocated memory is initialized to zero, which means that the text for each key will be initialized to an empty string and the keycodes will be initialized to zero. This allows the is_set_chyron_key function to check if a key is set by checking if the first character of the text is not '\0'. If any memory allocation fails, the function will call abend to handle the error and return nullptr.

Definition at line 1701 of file dwin.c.

1701 {
1702 Chyron *chyron = (Chyron *)calloc(1, sizeof(Chyron));
1703 if (!chyron) {
1704 abend(-1, "calloc chyron failed");
1705 return nullptr;
1706 }
1707 for (int i = 0; i < CHYRON_KEYS; i++) {
1708 chyron->key[i] = (ChyronKey *)calloc(1, sizeof(ChyronKey));
1709 if (!chyron->key[i]) {
1710 abend(-1, "calloc chyron->key[i] failed");
1711 return nullptr;
1712 }
1713 }
1714 return chyron;
1715}
void abend(int, char *)
Abnormal program termination.
Definition dwin.c:2018
Definition cm.h:344

References abend(), and Chyron::key.

Referenced by action_disposition(), answer_yn(), display_error(), form_engine(), init_pick(), Perror(), and wait_mk_chyron().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ set_chyron_key()

void set_chyron_key ( Chyron * chyron,
int k,
char * s,
int kc )

Set chyron key with default color pair (cp_nt_rev).

set_chyron_key

Parameters
chyronstructure
kchyron key index (0-19)
schyron key label
kcchyron key code

This function sets the label and keycode for a function key in the chyron structure. It uses the default color pair cp_nt_rev for the key label. If the input string s is not empty, it copies the string into the chyron key's text field. If the input string is empty, it sets the first character of the text field to '\0' to indicate that the key is not set. The keycode is stored in the chyron key's keycode field, and the color pair index is set to cp_nt_rev.

Definition at line 1783 of file dwin.c.

1783 {
1784 if (*s != '\0')
1785 ssnprintf(chyron->key[k]->text, CHYRON_KEY_MAXLEN - 1, "%s", s);
1786 else
1787 chyron->key[k]->text[0] = '\0';
1788 chyron->key[k]->keycode = kc;
1789 chyron->key[k]->active = true;
1790 chyron->key[k]->cp = cp_nt_rev;
1791}
#define CHYRON_KEY_MAXLEN
Definition cm.h:330

References ChyronKey::active, ChyronKey::cp, cp_nt_rev, Chyron::key, ChyronKey::keycode, ssnprintf(), and ChyronKey::text.

Referenced by action_disposition(), answer_yn(), display_error(), form_engine(), init_pick(), Perror(), and wait_mk_chyron().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ set_chyron_key_cp()

void set_chyron_key_cp ( Chyron * chyron,
int k,
char * s,
int kc,
int cp )

Set chyron key with color pair (cp).

set_chyron_key_cp

Parameters
chyronstructure
kchyron key index (0-19)
schyron key label
kcchyron key code
cpcolor pair index for the key label

This function is like set_chyron_key, except it includes a color pair numbers

Definition at line 1759 of file dwin.c.

1759 {
1760 if (*s != '\0')
1761 ssnprintf(chyron->key[k]->text, CHYRON_KEY_MAXLEN - 1, "%s", s);
1762 else
1763 chyron->key[k]->text[0] = '\0';
1764 chyron->key[k]->keycode = kc;
1765 chyron->key[k]->active = true;
1766 chyron->key[k]->cp = cp;
1767}

References ChyronKey::active, ChyronKey::cp, Chyron::key, ChyronKey::keycode, ssnprintf(), and ChyronKey::text.

Referenced by field_editor(), form_engine(), and picker().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ unset_chyron_key()

void unset_chyron_key ( Chyron * chyron,
int k )

Unset chyron key.

unset_chyron_key

Parameters
chyronstructure
kchyron_key index

Definition at line 1798 of file dwin.c.

1798 {
1799 chyron->key[k]->text[0] = '\0';
1800}

References Chyron::key, and ChyronKey::text.