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, uint 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, uint k)
 Deactivate chyron key.
Chyrondestroy_chyron (Chyron *chyron)
 Destroy Chyron structure.
void display_chyron (UiSurface *sfc, uint w, Chyron *chyron, uint line, uint col)
 Display chyron on the specified line and column of the surface.
int get_chyron_key (Chyron *chyron, uint x)
 Get keycode from chyron.
bool is_set_chyron_key (Chyron *chyron, uint k)
 Check if function key label is set.
uint mbstr_to_cellstr (UiCell *cmplx_buf, const char *str, const UiCell *cell_base, uint *p, const uint atmost)
 Convert multibyte string to complex character array.
Chyronnew_chyron ()
 Create and initialize Chyron structure.
void set_chyron_key (Chyron *chyron, uint k, char *s, uint kc)
 Set chyron key with default color pair (cp_nt_rev).
void set_chyron_key_cb (Chyron *chyron, uint k, char *s, uint kc, UiCell cell_base)
 Set chyron key with color pair (cp).
void unset_chyron_key (Chyron *chyron, uint 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 1078 of file dwin.c.

1078 {
1079 for (int k = 0; k < CHYRON_KEYS; k++)
1080 chyron->key[k]->active = true;
1081}
#define CHYRON_KEYS
Definition cm.h:375
bool active
Definition cm.h:378
ChyronKey * key[CHYRON_KEYS]
Definition cm.h:387

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

◆ activate_chyron_key()

void activate_chyron_key ( Chyron * chyron,
uint k )

Activate chyron key.

activate_chyron_key

Parameters
chyronstructure
kchyron_key index

Definition at line 1069 of file dwin.c.

1069 {
1070 chyron->key[k]->active = true;
1071}

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 1110 of file dwin.c.

1110 {
1111 uint end_pos = 0;
1112 uint k = 0;
1113 uint pos = 0;
1114 UiCell cell_base = cell_nt_rev;
1115 UiCell *cx;
1116 char tmp_str[MAXLEN];
1117 while (k < CHYRON_KEYS) {
1118 if (chyron->key[k]->text[0] == '\0' || !chyron->key[k]->active) {
1119 k++;
1120 continue;
1121 }
1122 cell_base = chyron->key[k]->cell_base;
1123 if (end_pos == 0) {
1124 cx = chyron->cmplx_buf;
1126 " ",
1127 &cell_base,
1128 &pos,
1129 MAXLEN - 1);
1130 } else {
1132 "|",
1133 &cell_base,
1134 &pos,
1135 MAXLEN - 1);
1136 }
1137 cx = chyron->cmplx_buf;
1138 mbstr_to_cellstr(cx, chyron->key[k]->text, &cell_base, &pos, MAXLEN - 1);
1139 end_pos = pos;
1140 chyron->l = end_pos;
1141 chyron->key[k]->end_pos = end_pos;
1142 ssnprintf(tmp_str, MAXLEN - 1, "k=%d, text=%s, end_pos=%d", k,
1143 chyron->key[k]->text, chyron->key[k]->end_pos);
1144 k++;
1145 }
1146 mbstr_to_cellstr(chyron->cmplx_buf, " ", &cell_base, &pos, MAXLEN - 1);
1147 chyron->l = end_pos;
1148}
#define MAXLEN
Definition curskeys.c:15
UiCell cell_nt_rev
Definition dwin.c:95
uint mbstr_to_cellstr(UiCell *cmplx_buf, const char *str, const UiCell *cell_base, uint *p, const uint atmost)
Convert multibyte string to complex character array.
Definition dwin.c:480
size_t ssnprintf(char *, size_t, const char *,...)
ssnprintf was designed to be a safer alternative to snprintf.
Definition futil.c:413
char text[CHYRON_KEY_MAXLEN]
Definition cm.h:379
UiCell cell_base
Definition cm.h:383
uint end_pos
Definition cm.h:382
UiCell cmplx_buf[MAXLEN]
Definition cm.h:389
uint l
Definition cm.h:391

References ChyronKey::active, ChyronKey::cell_base, cell_nt_rev, Chyron::cmplx_buf, ChyronKey::end_pos, Chyron::key, Chyron::l, mbstr_to_cellstr(), 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(), and picker().

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 1096 of file dwin.c.

1096 {
1097 for (int k = 0; k < CHYRON_KEYS; k++)
1098 chyron->key[k]->active = false;
1099}

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

◆ deactivate_chyron_key()

void deactivate_chyron_key ( Chyron * chyron,
uint k )

Deactivate chyron key.

deactivate_chyron_key

Parameters
chyronstructure
kchyron_key index

Definition at line 1088 of file dwin.c.

1088 {
1089 chyron->key[k]->active = false;
1090}

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 984 of file dwin.c.

984 {
985 uint i;
986
987 if (!chyron)
988 return nullptr;
989 for (i = 0; i < CHYRON_KEYS; i++) {
990 if (chyron->key[i]) {
991 free(chyron->key[i]);
992 chyron->key[i] = nullptr;
993 }
994 }
995 free(chyron);
996 chyron = nullptr;
997 return chyron;
998}

References Chyron::key.

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

Here is the caller graph for this function:

◆ display_chyron()

void display_chyron ( UiSurface * sfc,
uint w,
Chyron * chyron,
uint line,
uint col )

Display chyron on the specified line and column of the surface.

display_chyron

Parameters
sfcPointer to the UiSurface structure
wWindow index (WIN or BOX)
chyronPointer to the Chyron structure
lineLine number where the chyron should be displayed
colColumn number where the chyron should start

This function displays the compiled chyron string on the specified line and column of the given surface. It first moves the cursor to the specified position, clears to the end of the line, and then writes the chyron string. Finally, it moves the cursor back to the specified column for user input.

Definition at line 1163 of file dwin.c.

1163 {
1164 ui_wmove(sfc, w, line, 0);
1165 ui_wclrtoeol(sfc, w);
1166 ui_wmove(sfc, w, line, 0);
1167 ui_mvwadd_wchstr(sfc, w, line, 0, chyron->cmplx_buf);
1168 ui_wmove(sfc, w, line, col);
1169 return;
1170}
int ui_mvwadd_wchstr(UiSurface *s, uint w, uint y, uint x, const UiCell *cell)
int ui_wmove(UiSurface *s, uint w, uint y, uint x)
Definition ui_ncurses.c:732
int ui_wclrtoeol(UiSurface *s, uint w)

References Chyron::cmplx_buf, ui_mvwadd_wchstr(), ui_wclrtoeol(), and ui_wmove().

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

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

◆ get_chyron_key()

int get_chyron_key ( Chyron * chyron,
uint 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 1186 of file dwin.c.

1186 {
1187 uint i = 0;
1188 uint k = -1;
1189 while (i < CHYRON_KEYS - 1) {
1190 if (chyron->key[i]->text[0] != '\0' && chyron->key[i]->active)
1191 if (chyron->key[i]->end_pos >= x) {
1192 k = i;
1193 break;
1194 }
1195 i++;
1196 }
1197 return chyron->key[k]->keycode;
1198}
uint keycode
Definition cm.h:381

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

Referenced by field_editor(), form_post(), form_process(), and picker().

Here is the caller graph for this function:

◆ is_set_chyron_key()

bool is_set_chyron_key ( Chyron * chyron,
uint 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 1005 of file dwin.c.

1005 {
1006 if (chyron->key[k]->text[0] != '\0')
1007 return true;
1008 else
1009 return false;
1010}

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

Referenced by form_post(), and form_process().

Here is the caller graph for this function:

◆ mbstr_to_cellstr()

uint mbstr_to_cellstr ( UiCell * cmplx_buf,
const char * str,
const UiCell * cell_base,
uint * p,
const uint atmost )

Convert multibyte string to complex character array.

mbstr_to_cellstr

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 480 of file dwin.c.

480 {
481 ushort cp;
482 uint p1 = 0;
483 uint *pos = &p1;
484 if (p)
485 pos = p;
486 uint i = 0, len = 0;
487 const char *s;
488 attr_t style;
489 UiCell cc;
490 wchar_t wstr[5];
491 ui_getcchar(cell_base, &wstr[0], &style, &cp, nullptr);
492 mbstate_t mbstate;
493 memset(&mbstate, 0, sizeof(mbstate));
494 if (pos && *pos >= atmost - 1)
495 return 0;
496 while (str[i] != '\0') {
497 s = &str[i];
498 len = mbrtowc(wstr, s, MB_CUR_MAX, &mbstate);
499 if (len <= 0) {
500 wstr[0] = L'?';
501 wstr[1] = L'\0';
502 len = 1;
503 }
504 wstr[1] = L'\0';
505 if (*pos > atmost)
506 break;
507 if (ui_setcchar(&cc, wstr, style, cp, nullptr) != ERR) {
508 if (len > 0 && (*pos + len) < atmost)
509 cmplx_buf[(*pos)++] = cc;
510 }
511 i += len;
512 }
513 wstr[0] = L'\0';
514 wstr[1] = L'\0';
515 ui_setcchar(&cc, wstr, style, cp, nullptr);
516 cmplx_buf[*pos] = cc;
517 return *pos;
518}
uint16_t attr_t
Definition ui_backend.h:256
int ui_getcchar(const UiCell *uc, wchar_t *wstr, attr_t *attrs, ushort *pair, void *opts)
#define ERR
Definition ui_backend.h:249
int ui_setcchar(UiCell *wch, const wchar_t *wc, const attr_t attrs, short pair, const void *opts)

References ui_getcchar(), and ui_setcchar().

Referenced by compile_chyron(), form_display_accept_field(), form_display_field(), and form_display_fields().

Here is the call graph for this function:
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 947 of file dwin.c.

947 {
948 Chyron *chyron = (Chyron *)calloc(1, sizeof(Chyron));
949 if (!chyron) {
950 abend(-1, "calloc chyron failed");
951 return nullptr;
952 }
953 for (int i = 0; i < CHYRON_KEYS; i++) {
954 chyron->key[i] = (ChyronKey *)calloc(1, sizeof(ChyronKey));
955 if (!chyron->key[i]) {
956 abend(-1, "calloc chyron->key[i] failed");
957 return nullptr;
958 }
959 }
960 return chyron;
961}
void abend(int ec, char *s)
Abnormal program termination.
Definition dwin.c:1204
Definition cm.h:386

References abend(), and Chyron::key.

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

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,
uint k,
char * s,
uint 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 1045 of file dwin.c.

1045 {
1046 if (*s != '\0')
1047 ssnprintf(chyron->key[k]->text, CHYRON_KEY_MAXLEN - 1, "%s", s);
1048 else
1049 chyron->key[k]->text[0] = '\0';
1050 chyron->key[k]->keycode = kc;
1051 chyron->key[k]->active = true;
1052 chyron->key[k]->cell_base = cell_nt_rev;
1053}
#define CHYRON_KEY_MAXLEN
Definition cm.h:372

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

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

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

◆ set_chyron_key_cb()

void set_chyron_key_cb ( Chyron * chyron,
uint k,
char * s,
uint kc,
UiCell cell_base )

Set chyron key with color pair (cp).

set_chyron_key

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 1021 of file dwin.c.

1021 {
1022 if (*s != '\0')
1023 ssnprintf(chyron->key[k]->text, CHYRON_KEY_MAXLEN - 1, "%s", s);
1024 else
1025 chyron->key[k]->text[0] = '\0';
1026 chyron->key[k]->keycode = kc;
1027 chyron->key[k]->active = true;
1028 chyron->key[k]->cell_base = cell_base;
1029}

References ChyronKey::active, ChyronKey::cell_base, 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,
uint k )

Unset chyron key.

unset_chyron_key

Parameters
chyronstructure
kchyron_key index

Definition at line 1060 of file dwin.c.

1060 {
1061 chyron->key[k]->text[0] = '\0';
1062}

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