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)
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 ***********************************************************************/
15 #include <fc_config.h>
22 #include <X11/Intrinsic.h>
23 #include <X11/StringDefs.h>
24 #include <X11/Xaw/AsciiText.h>
41 #include "gui_stuff.h"
45 /**************************************************************************
47 **************************************************************************/
48 void chatline_key_send(Widget w
)
53 XtVaGetValues(w
, XtNstring
, &theinput
, NULL
);
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
,
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
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
--)
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
);
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)
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
);