Freeciv-3.1: /fast/freeciv/nightly/S3_1/client/gui-gtk-4.0/chatline.c File Reference

Freeciv-3.1

Loading...
Searching...
No Matches
Data Structures | Macros | Functions | Variables
chatline.c File Reference
`#include <stdio.h>`
`#include <stdlib.h>`
`#include <string.h>`
`#include <time.h>`
`#include <gdk/gdkkeysyms.h>`
`#include "fcintl.h"`
`#include "genlist.h"`
`#include "log.h"`
`#include "mem.h"`
`#include "support.h"`
`#include "chat.h"`
`#include "featured_text.h"`
`#include "game.h"`
`#include "packets.h"`
`#include "client_main.h"`
`#include "climap.h"`
`#include "control.h"`
`#include "mapview_common.h"`
`#include "colors.h"`
`#include "gui_main.h"`
`#include "gui_stuff.h"`
`#include "menu.h"`
`#include "pages.h"`
`#include "chatline.h"`

Go to the source code of this file.

## Data Structures

struct | inputline_toolkit

## Macros

#define | MAX_CHATLINE_HISTORY 20
#define | MAX_MATCHES 10

## Functions

static void | inputline_make_tag (GtkEntry *entry, enum text_tag_type type)
bool | inputline_has_focus (void)
void | inputline_grab_focus (void)
bool | inputline_is_visible (void)
static gboolean | il_lost_focus (GtkEventControllerFocus *controller, gpointer data)
static gboolean | il_gained_focus (GtkEventControllerFocus *controller, gpointer data)
static bool | is_plain_public_message (const char *s)
static void | inputline_return (GtkEntry *w, gpointer data)
static const char * | get_player_or_user_name (int id)
static int | check_player_or_user_name (const char *prefix, const char **matches, const int max_matches)
static size_t | get_common_prefix (const char *const *prefixes, size_t num_prefixes, char *buf, size_t buf_len)
static bool | chatline_autocomplete (GtkEditable *editable)
static gboolean | inputline_handler (GtkEventControllerKey *controller, guint keyval, guint keycode, GdkModifierType state, gpointer data)
void | inputline_make_chat_link (struct tile *ptile, bool unit)
void | scroll_if_necessary (GtkTextView *textview, GtkTextMark *scroll_target)
static gboolean | event_after (GtkGestureClick *gesture, int n_press, double x, double y, gpointer data)
static void | set_cursor_if_appropriate (GtkTextView *text_view, gint x, gint y)
static gboolean | chat_pointer_motion (GtkEventControllerMotion *controller, gdouble e_x, gdouble e_y, gpointer data)
void | set_message_buffer_view_link_handlers (GtkWidget *view)
void | apply_text_tag (const struct text_tag *ptag, GtkTextBuffer *buf, ft_offset_t text_start_offset, const char *text)
void | real_output_window_append (const char *astring, const struct text_tag_list *tags, int conn_id)
void | log_output_window (void)
void | clear_output_window (void)
void | set_output_window_text (const char *text)
bool | chatline_is_scrolled_to_bottom (void)
static gboolean | chatline_scroll_callback (gpointer data)
void | chatline_scroll_to_bottom (bool delayed)
static void | make_tag_callback (GtkButton *button, gpointer data)
static void | color_set (GObject *object, const gchar *color_target, GdkRGBA *color, GtkButton *button)
static void | color_selected (GtkDialog *dialog, gint res, gpointer data)
static void | select_color_callback (GtkButton *button, gpointer data)
static gboolean | move_toolkit (GtkWidget *toolkit_view, gpointer data)
static gboolean | set_toolbar_visibility (GtkWidget *w, gpointer data)
static void | button_toggled (GtkToggleButton *button, gpointer data)
GtkWidget * | inputline_toolkit_view_new (void)
void | inputline_toolkit_view_append_button (GtkWidget *toolkit_view, GtkWidget *button)
void | chatline_init (void)
static gboolean | version_message_main_thread (gpointer user_data)
void | version_message (const char *vertext)

## Variables

static struct genlist * | history_list = NULL
static int | history_pos = -1
static struct inputline_toolkit | toolkit

## Macro Definition Documentation

## ◆ MAX_CHATLINE_HISTORY

#define MAX_CHATLINE_HISTORY 20

Definition at line 53 of file chatline.c.

## ◆ MAX_MATCHES

#define MAX_MATCHES 10

## Function Documentation

## ◆ apply_text_tag()

void apply_text_tag | ( | const struct text_tag * | ptag,
|  | GtkTextBuffer * | buf,
|  | ft_offset_t | text_start_offset,
|  | const char * | text
| ) |  |

Convert a struct text_tag to a GtkTextTag.

Definition at line 794 of file chatline.c.

## ◆ button_toggled()

static void button_toggled | ( | GtkToggleButton * | button,
|  | gpointer | data
| ) |  |

static

Show/Hide the toolbar.

Definition at line 1283 of file chatline.c.

## ◆ chat_pointer_motion()

static gboolean chat_pointer_motion | ( | GtkEventControllerMotion * | controller,
|  | gdouble | e_x,
|  | gdouble | e_y,
|  | gpointer | data
| ) |  |

static

Maybe mouse is moving over a link.

Definition at line 756 of file chatline.c.

Referenced by set_message_buffer_view_link_handlers().

## ◆ chatline_autocomplete()

static bool chatline_autocomplete | ( | GtkEditable * | editable | ) |

static

Autocompletes the input line with a player or user name. Returns FALSE if there is no string to complete.

Definition at line 309 of file chatline.c.

## ◆ chatline_init()

void chatline_init | ( | void |  | ) |

Initializes the chatline stuff.

Definition at line 1336 of file chatline.c.

## ◆ chatline_is_scrolled_to_bottom()

bool chatline_is_scrolled_to_bottom | ( | void |  | ) |

Returns whether the chatline is scrolled to the bottom.

Definition at line 998 of file chatline.c.

## ◆ chatline_scroll_callback()

static gboolean chatline_scroll_callback | ( | gpointer | data | ) |

static

Scrolls the pregame and in-game chat windows all the way to the bottom.

Why do we do it in such a convuluted fasion rather than calling chatline_scroll_to_bottom directly from toplevel_configure? Because the widget is not at its final size yet when the configure event occurs.

Definition at line 1033 of file chatline.c.

## ◆ chatline_scroll_to_bottom()

void chatline_scroll_to_bottom | ( | bool | delayed | ) |

Scrolls the pregame and in-game chat windows all the way to the bottom. If delayed is TRUE, it will be done in a idle_callback.

Definition at line 1045 of file chatline.c.

## ◆ check_player_or_user_name()

static int check_player_or_user_name | ( | const char * | prefix,
|  | const char ** | matches,
|  | const int | max_matches
| ) |  |

static

Find a player or a user by prefix.

Parameters

  prefix | The prefix.
  matches | A string array to set the matches result.
  max_matches | The maximum of matches.

Returns
  the number of the matches names.

Definition at line 227 of file chatline.c.

## ◆ clear_output_window()

void clear_output_window | ( | void |  | ) |

Clear output window. This does not destroy it, or free its resources

Definition at line 982 of file chatline.c.

## ◆ color_selected()

static void color_selected | ( | GtkDialog * | dialog,
|  | gint | res,
|  | gpointer | data
| ) |  |

static

Color selection dialog response.

Definition at line 1135 of file chatline.c.

## ◆ color_set()

static void color_set | ( | GObject * | object,
|  | const gchar * | color_target,
|  | GdkRGBA * | color,
|  | GtkButton * | button
| ) |  |

static

Set the color for an object. Update the button if not NULL.

Definition at line 1082 of file chatline.c.

## ◆ event_after()

static gboolean event_after | ( | GtkGestureClick * | gesture,
|  | int | n_press,
|  | double | x,
|  | double | y,
|  | gpointer | data
| ) |  |

static

Click a link.

Definition at line 620 of file chatline.c.

## ◆ get_common_prefix()

static size_t get_common_prefix | ( | const char *const * | prefixes,
|  | size_t | num_prefixes,
|  | char * | buf,
|  | size_t | buf_len
| ) |  |

static

Find the larger common prefix.

prefixes - A list of prefixes. num_prefixes - The number of prefixes. buf - The buffer to set. buf_len - The maximal size of the buffer.

Returns the length of the common prefix (in characters).

Definition at line 282 of file chatline.c.

## ◆ get_player_or_user_name()

static const char * get_player_or_user_name | ( | int | id | ) |

static

Returns the name of player or user, set in the same list.

Definition at line 200 of file chatline.c.

## ◆ il_gained_focus()

static gboolean il_gained_focus | ( | GtkEventControllerFocus * | controller,
|  | gpointer | data
| ) |  |

static

Inputline has gained focus

Definition at line 107 of file chatline.c.

Referenced by chatline_init().

## ◆ il_lost_focus()

static gboolean il_lost_focus | ( | GtkEventControllerFocus * | controller,
|  | gpointer | data
| ) |  |

static

Inputline has lost focus

Definition at line 96 of file chatline.c.

Referenced by chatline_init().

## ◆ inputline_grab_focus()

void inputline_grab_focus | ( | void |  | ) |

Gives the focus to the intput line.

Definition at line 80 of file chatline.c.

## ◆ inputline_handler()

static gboolean inputline_handler | ( | GtkEventControllerKey * | controller,
|  | guint | keyval,
|  | guint | keycode,
|  | GdkModifierType | state,
|  | gpointer | data
| ) |  |

static

Called when a key is pressed.

Definition at line 370 of file chatline.c.

## ◆ inputline_has_focus()

bool inputline_has_focus | ( | void |  | ) |

Returns TRUE iff the input line has focus.

Definition at line 72 of file chatline.c.

## ◆ inputline_is_visible()

bool inputline_is_visible | ( | void |  | ) |

Returns TRUE iff the input line is currently visible.

Definition at line 88 of file chatline.c.

## ◆ inputline_make_chat_link()

void inputline_make_chat_link | ( | struct tile * | ptile,
|  | bool | unit
| ) |  |

Make a chat link at the current position or make the current selection clickable.

Definition at line 510 of file chatline.c.

## ◆ inputline_make_tag()

void inputline_make_tag | ( | GtkEntry * | entry,
|  | enum text_tag_type | type
| ) |  |

static

Make a text tag for the selected text.

Definition at line 452 of file chatline.c.

## ◆ inputline_return()

static void inputline_return | ( | GtkEntry * | w,
|  | gpointer | data
| ) |  |

static

Called when the return key is pressed.

Definition at line 163 of file chatline.c.

## ◆ inputline_toolkit_view_append_button()

void inputline_toolkit_view_append_button | ( | GtkWidget * | toolkit_view,
|  | GtkWidget * | button
| ) |  |

Appends a button to the inputline toolkit view widget.

Definition at line 1326 of file chatline.c.

## ◆ inputline_toolkit_view_new()

GtkWidget * inputline_toolkit_view_new | ( | void |  | ) |

Returns a new inputline toolkit view widget that can contain the inputline.

This widget has the following datas: "button_box": pointer to the GtkBox where to append buttons.

Definition at line 1307 of file chatline.c.

## ◆ is_plain_public_message()

static bool is_plain_public_message | ( | const char * | s | ) |

static

Helper function to determine if a given client input line is intended as a "plain" public message. Note that messages prefixed with : are a special case (explicit public messages), and will return FALSE.

Definition at line 120 of file chatline.c.

## ◆ log_output_window()

void log_output_window | ( | void |  | ) |

I have no idea what module this belongs in – Syela I've decided to put output_window routines in chatline.c, because the are somewhat related and output_window_* is already here. –dwp

Definition at line 967 of file chatline.c.

## ◆ make_tag_callback()

static void make_tag_callback | ( | GtkButton * | button,
|  | gpointer | data
| ) |  |

static

Tool button clicked.

Definition at line 1072 of file chatline.c.

## ◆ move_toolkit()

static gboolean move_toolkit | ( | GtkWidget * | toolkit_view,
|  | gpointer | data
| ) |  |

static

Moves the tool kit to the toolkit view.

Definition at line 1196 of file chatline.c.

## ◆ real_output_window_append()

void real_output_window_append | ( | const char * | astring,
|  | const struct text_tag_list * | tags,
|  | int | conn_id
| ) |  |

Appends the string to the chat output window. The string should be inserted on its own line, although it will have no newline.

Definition at line 913 of file chatline.c.

## ◆ scroll_if_necessary()

void scroll_if_necessary | ( | GtkTextView * | textview,
|  | GtkTextMark * | scroll_target
| ) |  |

Scroll a textview so that the given mark is visible, but only if the scroll window containing the textview is very close to the bottom. The text mark 'scroll_target' should probably be the first character of the last line in the text buffer.

Definition at line 593 of file chatline.c.

## ◆ select_color_callback()

static void select_color_callback | ( | GtkButton * | button,
|  | gpointer | data
| ) |  |

static

Color selection button clicked.

Definition at line 1160 of file chatline.c.

## ◆ set_cursor_if_appropriate()

static void set_cursor_if_appropriate | ( | GtkTextView * | text_view,
|  | gint | x,
|  | gint | y
| ) |  |

static

Set the "hand" cursor when moving over a link.

Definition at line 708 of file chatline.c.

## ◆ set_message_buffer_view_link_handlers()

void set_message_buffer_view_link_handlers | ( | GtkWidget * | view | ) |

Set the appropriate callbacks for the message buffer.

Definition at line 774 of file chatline.c.

## ◆ set_output_window_text()

void set_output_window_text | ( | const char * | text | ) |

Set given text to output window

Definition at line 990 of file chatline.c.

## ◆ set_toolbar_visibility()

static gboolean set_toolbar_visibility | ( | GtkWidget * | w,
|  | gpointer | data
| ) |  |

static

Show/Hide the toolbar.

Definition at line 1254 of file chatline.c.

## ◆ version_message()

void version_message | ( | const char * | vertext | ) |

Got version message from metaserver thread.

Definition at line 1530 of file chatline.c.

## ◆ version_message_main_thread()

static gboolean version_message_main_thread | ( | gpointer | user_data | ) |

static

Main thread side callback to print version message

Definition at line 1516 of file chatline.c.

## Variable Documentation

## ◆ history_list

struct genlist* history_list = NULL

static

Definition at line 55 of file chatline.c.

## ◆ history_pos

int history_pos = -1

static

Definition at line 56 of file chatline.c.

## ◆ toolkit

struct inputline_toolkit toolkit

static