Removed silencing of gtk warning logs from gtk3.22-client.
[freeciv.git] / client / gui-xaw / chatline.c
blob36fe33a1255ee54c113f0f0b835dcecb6de426e9
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.
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 ***********************************************************************/
14 #ifdef HAVE_CONFIG_H
15 #include <fc_config.h>
16 #endif
18 #include <stdio.h>
19 #include <stdlib.h>
20 #include <string.h>
22 #include <X11/Intrinsic.h>
23 #include <X11/StringDefs.h>
24 #include <X11/Xaw/AsciiText.h>
26 /* utility */
27 #include "fcintl.h"
28 #include "log.h"
29 #include "mem.h"
30 #include "shared.h"
31 #include "support.h"
33 /* common */
34 #include "packets.h"
36 /* client */
37 #include "climisc.h"
39 /* client/gui-xaw */
40 #include "gui_main.h"
41 #include "gui_stuff.h"
43 #include "chatline.h"
45 /**************************************************************************
46 ...
47 **************************************************************************/
48 void chatline_key_send(Widget w)
50 String theinput;
51 String empty="";
53 XtVaGetValues(w, XtNstring, &theinput, NULL);
55 if(*theinput) {
56 send_chat(theinput);
59 XtVaSetValues(w, XtNstring, empty, NULL);
62 /**************************************************************************
63 Appends the string to the chat output window. The string should be
64 inserted on its own line, although it will have no newline.
65 **************************************************************************/
66 void real_output_window_append(const char *astring,
67 const struct text_tag_list *tags,
68 int conn_id)
70 /* this is properly a bad way to append to a text widget. Using the
71 * "useStringInPlace" resource and doubling mem alloc'ing would be better.
72 * Nope - tried it and many other variations and it wasn't any better.
73 * I'll replace this widget with a widget supportting hyperlinks later, so
74 * leth's forget the problem.
76 * There seems to be an Xaw problem with doing both wrap and scroll:
77 * its supposed to automatically scroll to end when we change the insertion
78 * point, but if a line is wrapped the scroll lags behind a line, and
79 * stays behind on subsequent additions, until the too-long line scrolls
80 * off the top. (I tried setting the insert position to the last char,
81 * instead of the start of line as below, but that didn't help.) So we
82 * split the line ourselves. I'm just using a fixed length split; should
83 * perhaps check and use width of output window (but font size?) -dwp
85 * Now uses window's font size and width. Assumes fixed-width font. --jjm
87 String theoutput;
88 char *newout, *rmcr, *astring2 = fc_strdup(astring);
90 XtVaGetValues(outputwindow_text, XtNstring, &theoutput, NULL);
91 newout=fc_malloc(strlen(astring2)+strlen(theoutput)+2);
92 sprintf(newout, "%s\n%s", theoutput, astring2);
94 /* calc carret position - last line, first pos */
95 for(rmcr=newout+strlen(newout); rmcr>newout; rmcr--)
96 if(*rmcr=='\n')
97 break;
99 /* shit happens when setting both values at the same time */
100 XawTextDisableRedisplay(outputwindow_text);
101 XtVaSetValues(outputwindow_text, XtNstring, newout, NULL);
102 XtVaSetValues(outputwindow_text, XtNinsertPosition, rmcr-newout+1, NULL);
103 XawTextEnableRedisplay(outputwindow_text);
105 free(newout);
106 free(astring2);
109 /**************************************************************************
110 I have no idea what module this belongs in -- Syela
111 I've decided to put output_window routines in chatline.c, because
112 the are somewhat related and append_output_window is already here. --dwp
113 **************************************************************************/
114 void log_output_window(void)
116 String theoutput;
118 XtVaGetValues(outputwindow_text, XtNstring, &theoutput, NULL);
119 write_chatline_content(theoutput);
122 /**************************************************************************
124 **************************************************************************/
125 void clear_output_window(void)
127 XtVaSetValues(outputwindow_text, XtNstring, _("Cleared output window."), NULL);
130 /**************************************************************************
131 Got version message from metaserver thread.
132 **************************************************************************/
133 void version_message(const char *vertext)
135 output_window_append(ftc_client, vertext);