42#define log_featured_text log_verbose
44#define text_tag_list_rev_iterate(tags, ptag) \
45 TYPED_LIST_ITERATE_REV(struct text_tag, tags, ptag)
46#define text_tag_list_rev_iterate_end LIST_ITERATE_REV_END
176 char *buf_out,
size_t write_len)
178 size_t option_len = strlen(
option);
180 while (*buf_in !=
'\0') {
181 while (
fc_isspace(*buf_in) && *buf_in !=
'\0') {
185 if (0 == strncasecmp(buf_in,
option, option_len)) {
187 buf_in += option_len;
189 while ((
fc_isspace(*buf_in) || *buf_in ==
'=') && *buf_in !=
'\0') {
192 if (*buf_in ==
'"') {
194 const char *end = strchr(++buf_in,
'"');
199 if (end - buf_in + 1 > 0) {
200 fc_strlcpy(buf_out, buf_in,
MIN(end - buf_in + 1, write_len));
206 while (
fc_isalnum(*buf_in) && write_len > 1) {
207 *buf_out++ = *buf_in++;
227 const char *sequence)
261 if (!
find_option(sequence,
"target", buf,
sizeof(buf))
262 && !
find_option(sequence,
"tgt", buf,
sizeof(buf))) {
264 "target link type not set.");
277 "target link type not supported (\"%s\").", buf);
284 if (!
find_option(sequence,
"id", buf,
sizeof(buf))) {
286 "city link without id.");
291 "city link without valid id (\"%s\").", buf);
299 "CITY_ID%d", ptag->
link.
id);
308 if (!
find_option(sequence,
"x", buf,
sizeof(buf))) {
310 "tile link without x coordinate.");
315 "tile link without valid x coordinate "
320 if (!
find_option(sequence,
"y", buf,
sizeof(buf))) {
322 "tile link without y coordinate.");
327 "tile link without valid y coordinate "
335 "(%d, %d) are not valid coordinates "
336 "in this game.", x, y);
346 if (!
find_option(sequence,
"id", buf,
sizeof(buf))) {
348 "unit link without id.");
353 "unit link without valid id (\"%s\").", buf);
361 "UNIT_ID%d", ptag->
link.
id);
406 if ((NULL ==
color.foreground ||
'\0' ==
color.foreground[0])
407 && (NULL ==
color.background ||
'\0' ==
color.background[0])) {
411 if (NULL !=
color.foreground &&
'\0' !=
color.foreground[0]) {
417 if (NULL !=
color.background &&
'\0' !=
color.background[0]) {
430 struct city *pcity = va_arg(args,
struct city *);
441 struct tile *ptile = va_arg(args,
struct tile *);
472 char *buf,
size_t len)
474 switch (ptag->
type) {
509 " id=%d name=\"%s\"",
536 " id=%d name=\"%s\"",
561 char *buf,
size_t len)
576 char *buf,
size_t len,
577 bool replace_link_text)
583 if (replace_link_text) {
594 if (NULL != pcity && NULL !=
city_tile(pcity)) {
716 log_error(
"text_tag_color_foreground(): incompatible tag type.");
730 log_error(
"text_tag_color_background(): incompatible tag type.");
744 log_error(
"text_tag_link_type(): incompatible tag type.");
759 log_error(
"text_tag_link_id(): incompatible tag type.");
771 char *buf,
size_t len,
775 const char *buf_in = featured_text;
776 const char *stop = strchr(buf_in,
SEQ_STOP);
777 const char *end = stop;
788 for (buf_in++;
fc_isspace(*buf_in); buf_in++);
815 type_len =
name - buf_in;
819 name_len = strlen(
name);
829 name_len = strlen(
name);
830 if (name_len == type_len
846 if (end - buf_in + 2 > 0) {
851 return stop - featured_text + 1;
865 char *plain_text,
size_t plain_text_len,
866 struct text_tag_list **tags,
867 bool replace_link_text)
869 const char *text_in = featured_text;
870 char *text_out = plain_text;
871 size_t text_out_len = plain_text_len;
877 while (*text_in !=
'\0' && text_out_len > 1) {
880 char buf[text_out_len];
896 text_out - plain_text, buf)) {
897 text_tag_list_append(*tags, ptag);
912 if (piter->type ==
type
933 text_out - plain_text, buf)) {
947 text_tag_list_append(*tags, ptag);
954 *text_out++ = *text_in++;
958 *text_out++ = *text_in++;
966 ptag->stop_offset = text_out - plain_text;
972 return plain_text_len - text_out_len;
994 char *featured_text,
size_t featured_text_len,
1001 size_t len, total_len = 0;
1023 && *text_source !=
'\0'
1024 && featured_text_len > 1) {
1025 *featured_text++ = *text_source++;
1026 featured_text_len--;
1035 featured_text +=
len;
1036 featured_text_len -=
len;
1041 && *text_source !=
'\0'
1042 && featured_text_len > 1) {
1043 *featured_text++ = *text_source++;
1044 featured_text_len--;
1052 featured_text +=
len;
1053 featured_text_len -=
len;
1056 while (*text_source !=
'\0'
1057 && featured_text_len > 1) {
1058 *featured_text++ = *text_source++;
1059 featured_text_len--;
1062 *featured_text =
'\0';
1076 fc_snprintf(buf,
sizeof(buf),
"%c%s tgt=\"%s\" id=%d name=\"%s\" %c%c",
1094 fc_snprintf(buf,
sizeof(buf),
"%c%s tgt=\"%s\" x=%d y=%d%c%s%c%c%s%c",
1110 fc_snprintf(buf,
sizeof(buf),
"%c%s tgt=\"%s\" x=%d y=%d %c%c",
1149 _(
" and achieved the rank of %s"),
1184 if (firepower == 1) {
1204 fc_snprintf(buf,
sizeof(buf),
"%c%s tgt=\"%s\" id=%d name=\"%s\" %c%c",
1222 fc_snprintf(buf,
sizeof(buf),
"%c%s tgt=\"%s\" x=%d y=%d%c%s%c%c%s%c",
const char * city_name_get(const struct city *pcity)
#define city_tile(_pcity_)
bool is_tired_attack(int moves_left)
struct unit struct city struct unit struct tile struct extra_type const struct act_prob *act_probs int actor_unit_id struct unit struct unit * punit
static bool text_tag_init_from_sequence(struct text_tag *ptag, enum text_tag_type type, ft_offset_t start_offset, const char *sequence)
const struct ft_color ftc_chat_private
size_t featured_text_apply_tag(const char *text_source, char *featured_text, size_t featured_text_len, enum text_tag_type tag_type, ft_offset_t start_offset, ft_offset_t stop_offset,...)
const struct ft_color ftc_luaconsole_debug
static bool find_option(const char *buf_in, const char *option, char *buf_out, size_t write_len)
const struct ft_color ftc_vote_abstain
const char * unit_tired_attack_string(const struct unit *punit)
const char * unit_veteran_level_string(const struct unit *punit)
enum text_link_type text_tag_link_type(const struct text_tag *ptag)
const struct ft_color ftc_log
const struct ft_color ftc_player_lost
const char * city_tile_link(const struct city *pcity)
size_t featured_text_to_plain_text(const char *featured_text, char *plain_text, size_t plain_text_len, struct text_tag_list **tags, bool replace_link_text)
const struct ft_color ftc_luaconsole_verbose
struct text_tag * text_tag_copy(const struct text_tag *ptag)
#define text_tag_list_rev_iterate(tags, ptag)
const char * tile_link(const struct tile *ptile)
const struct ft_color ftc_command
ft_offset_t text_tag_stop_offset(const struct text_tag *ptag)
static bool text_tag_initv(struct text_tag *ptag, enum text_tag_type type, ft_offset_t start_offset, ft_offset_t stop_offset, va_list args)
const char * unit_firepower_if_not_one(int firepower)
const struct ft_color ftc_server
const struct ft_color ftc_vote_failed
void text_tag_destroy(struct text_tag *ptag)
const struct ft_color ftc_vote_yes
static size_t text_tag_start_sequence(const struct text_tag *ptag, char *buf, size_t len)
const struct ft_color ftc_luaconsole_error
const struct ft_color ftc_warning
const char * text_tag_color_foreground(const struct text_tag *ptag)
#define text_tag_list_rev_iterate_end
static const char * text_link_type_name(enum text_link_type type)
const struct ft_color ftc_client
const struct ft_color ftc_luaconsole_normal
const struct ft_color ftc_editor
static const char * text_tag_type_name(enum text_tag_type type)
static size_t text_tag_replace_text(const struct text_tag *ptag, char *buf, size_t len, bool replace_link_text)
const char * city_link(const struct city *pcity)
const struct ft_color ftc_any
const struct ft_color ftc_vote_no
const struct ft_color ftc_vote_passed
VAR_ARG_CONST struct ft_color ftc_changed
#define log_featured_text
static size_t text_tag_stop_sequence(const struct text_tag *ptag, char *buf, size_t len)
const struct ft_color ftc_luaconsole_warn
static size_t extract_sequence_text(const char *featured_text, char *buf, size_t len, enum sequence_type *seq_type, enum text_tag_type *type)
int text_tag_link_id(const struct text_tag *ptag)
const struct ft_color ftc_chat_luaconsole
static const char * text_tag_type_short_name(enum text_tag_type type)
ft_offset_t text_tag_start_offset(const struct text_tag *ptag)
struct text_tag * text_tag_new(enum text_tag_type tag_type, ft_offset_t start_offset, ft_offset_t stop_offset,...)
const struct ft_color ftc_vote_team
const struct ft_color ftc_game_start
const char * unit_link(const struct unit *punit)
const struct ft_color ftc_server_prompt
const struct ft_color ftc_vote_public
const char * unit_tile_link(const struct unit *punit)
const char * text_tag_color_background(const struct text_tag *ptag)
const struct ft_color ftc_luaconsole_input
const struct ft_color ftc_chat_public
const char * unit_achieved_rank_string(const struct unit *punit)
const struct ft_color ftc_chat_ally
#define text_tag_list_iterate_end
#define text_tag_list_iterate(tags, ptag)
#define text_tag_list_new()
struct unit * game_unit_by_number(int id)
struct city * game_city_by_number(int id)
#define log_error(message,...)
struct tile * index_to_tile(const struct civ_map *imap, int mindex)
struct tile * map_pos_to_tile(const struct civ_map *nmap, int map_x, int map_y)
static const char * name_translation_get(const struct name_translation *ptrans)
bool str_to_int(const char *str, int *pint)
char background[MAX_LEN_STR]
struct text_tag::@25::@28 link
char foreground[MAX_LEN_STR]
struct text_tag::@25::@27 color
struct name_translation name
int fc_snprintf(char *str, size_t n, const char *format,...)
size_t fc_strlcpy(char *dest, const char *src, size_t n)
int fc_strncasecmp(const char *str0, const char *str1, size_t n)
#define sz_strlcpy(dest, src)
const struct unit_type * unit_type_get(const struct unit *punit)
const char * unit_name_translation(const struct unit *punit)
const struct veteran_level * utype_veteran_level(const struct unit_type *punittype, int level)