Freeciv-3.2
Loading...
Searching...
No Matches
chatline_common.c
Go to the documentation of this file.
1/***********************************************************************
2 Freeciv - Copyright (C) 1996 - A Kjeldberg, L Gregersen, P Unold
3 This program is free software; you can redistribute it and/or modify
4 it under the terms of the GNU General Public License as published by
5 the Free Software Foundation; either version 2, or (at your option)
6 any later version.
7
8 This program is distributed in the hope that it will be useful,
9 but WITHOUT ANY WARRANTY; without even the implied warranty of
10 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 GNU General Public License for more details.
12***********************************************************************/
13
14#ifdef HAVE_CONFIG_H
15#include <fc_config.h>
16#endif
17
18#include <stdarg.h>
19#include <string.h>
20
21/* utility */
22#include "astring.h"
23#include "fcintl.h"
24#include "fcthread.h"
25#include "fc_utf8.h"
26#include "log.h"
27
28/* common */
29#include "featured_text.h"
30#include "packets.h"
31
32/* include */
33#include "chatline_g.h"
34
35/* client */
36#include "client_main.h"
37#include "options.h"
38
39#include "chatline_common.h"
40
42
43/**********************************************************************/
46int send_chat(const char *message)
47{
49}
50
51/**********************************************************************/
55int send_chat_printf(const char *format, ...)
56{
57 struct packet_chat_msg_req packet;
58 va_list args;
59
60 va_start(args, format);
61 fc_utf8_vsnprintf_trunc(packet.message, sizeof(packet.message),
62 format, args);
63 va_end(args);
64
65 return send_packet_chat_msg_req(&client.conn, &packet);
66}
67
68/**********************************************************************/
75
76/**********************************************************************/
83
84/**********************************************************************/
88{
90}
91
92/**********************************************************************/
99
100/**********************************************************************/
105 const char *featured_text)
106{
108 struct text_tag_list *tags;
109
110 /* Separate the text and the tags. */
112 sizeof(plain_text), &tags, FALSE);
113
115 /* A color is requested. */
117 color);
118
119 if (ptag) {
120 /* Prepends to the list, to avoid to overwrite inside colors. */
122 } else {
123 log_error("Failed to create a color text tag (fg = %s, bg = %s).",
124 (NULL != color.foreground ? color.foreground : "NULL"),
125 (NULL != color.background ? color.background : "NULL"));
126 }
127 }
128
133}
134
135/**********************************************************************/
140 const char *format, va_list args)
141{
143
144 fc_vsnprintf(featured_text, sizeof(featured_text), format, args);
146}
147
148
149/**********************************************************************/
154 const char *format, ...)
155{
156 va_list args;
157
158 va_start(args, format);
159 output_window_vprintf(color, format, args);
160 va_end(args);
161}
162
163/**********************************************************************/
167 const struct text_tag_list *tags, int conn_id)
168{
172}
173
174/**********************************************************************/
178{
179 output_window_append(ftc_any, _("Freeciv is free software and you are "
180 "welcome to distribute copies of it "
181 "under certain conditions;"));
183 output_window_append(ftc_any, _("See the \"Copying\" item on the "
184 "Help menu."));
185 } else {
186 output_window_append(ftc_any, _("See COPYING file distributed with "
187 "this program."));
188 }
189 output_window_append(ftc_any, _("Now ... Go give 'em hell!"));
190}
191
192/**********************************************************************/
197{
199 char buf[512];
200
201 fc_snprintf(buf, sizeof(buf), _("Exporting output window to '%s' ..."),
204
205 if (fp) {
206 fputs(txt, fp);
207 fclose(fp);
208 output_window_append(ftc_client, _("Export complete."));
209 } else {
211 _("Export failed, couldn't write to file."));
212 }
213}
int send_chat_printf(const char *format,...)
int send_chat(const char *message)
static fc_mutex ow_mutex
void output_window_append(const struct ft_color color, const char *featured_text)
void output_window_event(const char *plain_text, const struct text_tag_list *tags, int conn_id)
void write_chatline_content(const char *txt)
void fc_allocate_ow_mutex(void)
void fc_release_ow_mutex(void)
void output_window_vprintf(const struct ft_color color, const char *format, va_list args)
void output_window_printf(const struct ft_color color, const char *format,...)
void chat_welcome_message(bool gui_has_copying_mitem)
void fc_destroy_ow_mutex(void)
void fc_init_ow_mutex(void)
struct civclient client
char * incite_cost
Definition comments.c:75
#define MAX_LEN_MSG
Definition conn_types.h:37
int fc_utf8_vsnprintf_trunc(char *str, size_t n, const char *format, va_list args)
Definition fc_utf8.c:552
#define _(String)
Definition fcintl.h:67
void fc_mutex_allocate(fc_mutex *mutex)
void fc_mutex_init(fc_mutex *mutex)
void fc_mutex_release(fc_mutex *mutex)
void fc_mutex_destroy(fc_mutex *mutex)
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_client
const struct ft_color ftc_any
struct text_tag * text_tag_new(enum text_tag_type tag_type, ft_offset_t start_offset, ft_offset_t stop_offset,...)
#define FT_OFFSET_UNSET
static bool ft_color_requested(const struct ft_color color)
@ TTT_COLOR
void real_output_window_append(const char *astring, const struct text_tag_list *tags, int conn_id)
Definition chatline.c:874
#define log_error(message,...)
Definition log.h:103
struct client_options gui_options
Definition options.c:71
int dsend_packet_chat_msg_req(struct connection *pc, const char *message)
int send_packet_chat_msg_req(struct connection *pc, const struct packet_chat_msg_req *packet)
struct connection conn
Definition client_main.h:96
char default_chat_logfile[512]
Definition options.h:122
Definition colors.h:21
char message[MAX_LEN_MSG]
int fc_snprintf(char *str, size_t n, const char *format,...)
Definition support.c:974
int fc_vsnprintf(char *str, size_t n, const char *format, va_list ap)
Definition support.c:900
FILE * fc_fopen(const char *filename, const char *opentype)
Definition support.c:507
#define FALSE
Definition support.h:47