annotate mcabber/src/screen.c @ 807:f6cda389db48

Allow messages with a subject (/msay)
author Mikael Berthe <mikael@lilotux.net>
date Fri, 14 Apr 2006 20:43:11 +0200
parents 3521e34f722a
children 0dbb2be10975
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
307
566818afee1c Add headers to C files
Mikael Berthe <mikael@lilotux.net>
parents: 288
diff changeset
1 /*
566818afee1c Add headers to C files
Mikael Berthe <mikael@lilotux.net>
parents: 288
diff changeset
2 * screen.c -- UI stuff
393
f8f3c7493457 Whitespace cleanup
Mikael Berthe <mikael@lilotux.net>
parents: 389
diff changeset
3 *
699
ee03b56b93ee Update Copyright (2006)
Mikael Berthe <mikael@lilotux.net>
parents: 682
diff changeset
4 * Copyright (C) 2005, 2006 Mikael Berthe <bmikael@lists.lilotux.net>
307
566818afee1c Add headers to C files
Mikael Berthe <mikael@lilotux.net>
parents: 288
diff changeset
5 * Parts of this file come from the Cabber project <cabber@ajmacias.com>
566818afee1c Add headers to C files
Mikael Berthe <mikael@lilotux.net>
parents: 288
diff changeset
6 *
566818afee1c Add headers to C files
Mikael Berthe <mikael@lilotux.net>
parents: 288
diff changeset
7 * This program is free software; you can redistribute it and/or modify
566818afee1c Add headers to C files
Mikael Berthe <mikael@lilotux.net>
parents: 288
diff changeset
8 * it under the terms of the GNU General Public License as published by
566818afee1c Add headers to C files
Mikael Berthe <mikael@lilotux.net>
parents: 288
diff changeset
9 * the Free Software Foundation; either version 2 of the License, or (at
566818afee1c Add headers to C files
Mikael Berthe <mikael@lilotux.net>
parents: 288
diff changeset
10 * your option) any later version.
566818afee1c Add headers to C files
Mikael Berthe <mikael@lilotux.net>
parents: 288
diff changeset
11 *
566818afee1c Add headers to C files
Mikael Berthe <mikael@lilotux.net>
parents: 288
diff changeset
12 * This program is distributed in the hope that it will be useful, but
566818afee1c Add headers to C files
Mikael Berthe <mikael@lilotux.net>
parents: 288
diff changeset
13 * WITHOUT ANY WARRANTY; without even the implied warranty of
566818afee1c Add headers to C files
Mikael Berthe <mikael@lilotux.net>
parents: 288
diff changeset
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
566818afee1c Add headers to C files
Mikael Berthe <mikael@lilotux.net>
parents: 288
diff changeset
15 * General Public License for more details.
566818afee1c Add headers to C files
Mikael Berthe <mikael@lilotux.net>
parents: 288
diff changeset
16 *
566818afee1c Add headers to C files
Mikael Berthe <mikael@lilotux.net>
parents: 288
diff changeset
17 * You should have received a copy of the GNU General Public License
566818afee1c Add headers to C files
Mikael Berthe <mikael@lilotux.net>
parents: 288
diff changeset
18 * along with this program; if not, write to the Free Software
566818afee1c Add headers to C files
Mikael Berthe <mikael@lilotux.net>
parents: 288
diff changeset
19 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
566818afee1c Add headers to C files
Mikael Berthe <mikael@lilotux.net>
parents: 288
diff changeset
20 * USA
566818afee1c Add headers to C files
Mikael Berthe <mikael@lilotux.net>
parents: 288
diff changeset
21 */
566818afee1c Add headers to C files
Mikael Berthe <mikael@lilotux.net>
parents: 288
diff changeset
22
24
e88b15cbf2de [/trunk] Changeset 40 by mikael
mikael
parents:
diff changeset
23 #include <stdio.h>
e88b15cbf2de [/trunk] Changeset 40 by mikael
mikael
parents:
diff changeset
24 #include <stdlib.h>
e88b15cbf2de [/trunk] Changeset 40 by mikael
mikael
parents:
diff changeset
25 #include <string.h>
e88b15cbf2de [/trunk] Changeset 40 by mikael
mikael
parents:
diff changeset
26 #include <ncurses.h>
e88b15cbf2de [/trunk] Changeset 40 by mikael
mikael
parents:
diff changeset
27 #include <panel.h>
e88b15cbf2de [/trunk] Changeset 40 by mikael
mikael
parents:
diff changeset
28 #include <time.h>
e88b15cbf2de [/trunk] Changeset 40 by mikael
mikael
parents:
diff changeset
29 #include <ctype.h>
e88b15cbf2de [/trunk] Changeset 40 by mikael
mikael
parents:
diff changeset
30 #include <locale.h>
232
9a6ba4b38e63 [/trunk] Changeset 245 by mikael
mikael
parents: 220
diff changeset
31 #include <langinfo.h>
24
e88b15cbf2de [/trunk] Changeset 40 by mikael
mikael
parents:
diff changeset
32
e88b15cbf2de [/trunk] Changeset 40 by mikael
mikael
parents:
diff changeset
33 #include "screen.h"
81
0bd578421ce9 [/trunk] Changeset 95 by mikael
mikael
parents: 76
diff changeset
34 #include "hbuf.h"
47
7259a61e1a4b [/trunk] Changeset 63 by mikael
mikael
parents: 44
diff changeset
35 #include "commands.h"
95
9e6b7897ec37 [/trunk] Changeset 109 by mikael
mikael
parents: 84
diff changeset
36 #include "compl.h"
81
0bd578421ce9 [/trunk] Changeset 95 by mikael
mikael
parents: 76
diff changeset
37 #include "roster.h"
180
42a33611233b [/trunk] Changeset 192 by mikael
mikael
parents: 178
diff changeset
38 #include "histolog.h"
279
f5dd437c057b Rewrite the settings system
Mikael Berthe <mikael@lilotux.net>
parents: 276
diff changeset
39 #include "settings.h"
81
0bd578421ce9 [/trunk] Changeset 95 by mikael
mikael
parents: 76
diff changeset
40 #include "utils.h"
24
e88b15cbf2de [/trunk] Changeset 40 by mikael
mikael
parents:
diff changeset
41 #include "list.h"
e88b15cbf2de [/trunk] Changeset 40 by mikael
mikael
parents:
diff changeset
42
e88b15cbf2de [/trunk] Changeset 40 by mikael
mikael
parents:
diff changeset
43 #define window_entry(n) list_entry(n, window_entry_t, list)
739
0d5fb1d9077c Allow "bright" text colors
Mikael Berthe <mikael@lilotux.net>
parents: 735
diff changeset
44 #define get_color(col) (COLOR_PAIR(col)|COLOR_ATTRIB[col])
24
e88b15cbf2de [/trunk] Changeset 40 by mikael
mikael
parents:
diff changeset
45
515
180f0a6e4ac9 Log window's height can be set by the user
Mikael Berthe <mikael@lilotux.net>
parents: 514
diff changeset
46 #define DEFAULT_LOG_WIN_HEIGHT (5+2)
701
6c100adfbfb6 Add setting "roster_width" (variable buddylist width)
Mikael Berthe <mikael@lilotux.net>
parents: 699
diff changeset
47 #define DEFAULT_ROSTER_WIDTH 24
515
180f0a6e4ac9 Log window's height can be set by the user
Mikael Berthe <mikael@lilotux.net>
parents: 514
diff changeset
48 #define CHAT_WIN_HEIGHT (maxY-1-Log_Win_Height)
180f0a6e4ac9 Log window's height can be set by the user
Mikael Berthe <mikael@lilotux.net>
parents: 514
diff changeset
49
592
67a332121aea Try UTF8 -> locale conversion with fallback
Mikael Berthe <mikael@lilotux.net>
parents: 580
diff changeset
50 char *LocaleCharSet = "C";
67a332121aea Try UTF8 -> locale conversion with fallback
Mikael Berthe <mikael@lilotux.net>
parents: 580
diff changeset
51
515
180f0a6e4ac9 Log window's height can be set by the user
Mikael Berthe <mikael@lilotux.net>
parents: 514
diff changeset
52 static unsigned short int Log_Win_Height;
701
6c100adfbfb6 Add setting "roster_width" (variable buddylist width)
Mikael Berthe <mikael@lilotux.net>
parents: 699
diff changeset
53 static unsigned short int Roster_Width;
515
180f0a6e4ac9 Log window's height can be set by the user
Mikael Berthe <mikael@lilotux.net>
parents: 514
diff changeset
54
336
eb994ee40029 Make some functions static
Mikael Berthe <mikael@lilotux.net>
parents: 332
diff changeset
55 static inline void check_offset(int);
151
b69c0b7a23e3 [/trunk] Changeset 163 by mikael
mikael
parents: 149
diff changeset
56
24
e88b15cbf2de [/trunk] Changeset 40 by mikael
mikael
parents:
diff changeset
57 LIST_HEAD(window_list);
e88b15cbf2de [/trunk] Changeset 40 by mikael
mikael
parents:
diff changeset
58
e88b15cbf2de [/trunk] Changeset 40 by mikael
mikael
parents:
diff changeset
59 typedef struct _window_entry_t {
e88b15cbf2de [/trunk] Changeset 40 by mikael
mikael
parents:
diff changeset
60 WINDOW *win;
108
7fb72bc13732 [/trunk] Changeset 122 by mikael
mikael
parents: 105
diff changeset
61 PANEL *panel;
7fb72bc13732 [/trunk] Changeset 122 by mikael
mikael
parents: 105
diff changeset
62 char *name;
7fb72bc13732 [/trunk] Changeset 122 by mikael
mikael
parents: 105
diff changeset
63 GList *hbuf;
181
4a0bde661562 [/trunk] Changeset 193 by mikael
mikael
parents: 180
diff changeset
64 GList *top; // If top is NULL, we'll display the last lines
4a0bde661562 [/trunk] Changeset 193 by mikael
mikael
parents: 180
diff changeset
65 char cleared; // For ex, user has issued a /clear command...
24
e88b15cbf2de [/trunk] Changeset 40 by mikael
mikael
parents:
diff changeset
66 struct list_head list;
e88b15cbf2de [/trunk] Changeset 40 by mikael
mikael
parents:
diff changeset
67 } window_entry_t;
e88b15cbf2de [/trunk] Changeset 40 by mikael
mikael
parents:
diff changeset
68
e88b15cbf2de [/trunk] Changeset 40 by mikael
mikael
parents:
diff changeset
69
711
75dde88f1884 Introduce status lines
Mikael Berthe <mikael@lilotux.net>
parents: 709
diff changeset
70 static WINDOW *rosterWnd, *chatWnd, *inputWnd, *logWnd;
75dde88f1884 Introduce status lines
Mikael Berthe <mikael@lilotux.net>
parents: 709
diff changeset
71 static WINDOW *mainstatusWnd, *chatstatusWnd;
24
e88b15cbf2de [/trunk] Changeset 40 by mikael
mikael
parents:
diff changeset
72 static PANEL *rosterPanel, *chatPanel, *inputPanel;
711
75dde88f1884 Introduce status lines
Mikael Berthe <mikael@lilotux.net>
parents: 709
diff changeset
73 static PANEL *mainstatusPanel, *chatstatusPanel;
75dde88f1884 Introduce status lines
Mikael Berthe <mikael@lilotux.net>
parents: 709
diff changeset
74 static PANEL *logPanel;
24
e88b15cbf2de [/trunk] Changeset 40 by mikael
mikael
parents:
diff changeset
75 static int maxY, maxX;
e88b15cbf2de [/trunk] Changeset 40 by mikael
mikael
parents:
diff changeset
76 static window_entry_t *currentWindow;
e88b15cbf2de [/trunk] Changeset 40 by mikael
mikael
parents:
diff changeset
77
707
b26a0bde4cdb Add /roster hide|show|toggle
Mikael Berthe <mikael@lilotux.net>
parents: 701
diff changeset
78 static int roster_hidden;
24
e88b15cbf2de [/trunk] Changeset 40 by mikael
mikael
parents:
diff changeset
79 static int chatmode;
238
8e30b2bb380e [/trunk] Changeset 251 by mikael
mikael
parents: 236
diff changeset
80 static int multimode;
807
f6cda389db48 Allow messages with a subject (/msay)
Mikael Berthe <mikael@lilotux.net>
parents: 806
diff changeset
81 static char *multiline, *multimode_subj;
30
4ea2df449381 [/trunk] Changeset 46 by mikael
mikael
parents: 29
diff changeset
82 int update_roster;
232
9a6ba4b38e63 [/trunk] Changeset 245 by mikael
mikael
parents: 220
diff changeset
83 int utf8_mode = 0;
322
da138cdebf04 Implement auto-away mode
Mikael Berthe <mikael@lilotux.net>
parents: 314
diff changeset
84 static bool Autoaway;
332
a1901741890e scr_LogPrint() can be called before ncurses initialization
Mikael Berthe <mikael@lilotux.net>
parents: 330
diff changeset
85 static bool Curses;
24
e88b15cbf2de [/trunk] Changeset 40 by mikael
mikael
parents:
diff changeset
86
174
6354625e8fb2 [/trunk] Changeset 186 by mikael
mikael
parents: 173
diff changeset
87 static char inputLine[INPUTLINE_LENGTH+1];
6354625e8fb2 [/trunk] Changeset 186 by mikael
mikael
parents: 173
diff changeset
88 static char *ptr_inputline;
6354625e8fb2 [/trunk] Changeset 186 by mikael
mikael
parents: 173
diff changeset
89 static short int inputline_offset;
6354625e8fb2 [/trunk] Changeset 186 by mikael
mikael
parents: 173
diff changeset
90 static int completion_started;
173
09e24917059d [/trunk] Changeset 185 by mikael
mikael
parents: 168
diff changeset
91 static GList *cmdhisto;
09e24917059d [/trunk] Changeset 185 by mikael
mikael
parents: 168
diff changeset
92 static GList *cmdhisto_cur;
174
6354625e8fb2 [/trunk] Changeset 186 by mikael
mikael
parents: 173
diff changeset
93 static char cmdhisto_backup[INPUTLINE_LENGTH+1];
24
e88b15cbf2de [/trunk] Changeset 40 by mikael
mikael
parents:
diff changeset
94
761
4532a9fe0e8c Handle some keyboard escape sequences
Mikael Berthe <mikael@lilotux.net>
parents: 760
diff changeset
95 #define MAX_KEYSEQ_LENGTH 8
4532a9fe0e8c Handle some keyboard escape sequences
Mikael Berthe <mikael@lilotux.net>
parents: 760
diff changeset
96
4532a9fe0e8c Handle some keyboard escape sequences
Mikael Berthe <mikael@lilotux.net>
parents: 760
diff changeset
97 typedef struct {
4532a9fe0e8c Handle some keyboard escape sequences
Mikael Berthe <mikael@lilotux.net>
parents: 760
diff changeset
98 char *seqstr;
4532a9fe0e8c Handle some keyboard escape sequences
Mikael Berthe <mikael@lilotux.net>
parents: 760
diff changeset
99 guint mkeycode;
4532a9fe0e8c Handle some keyboard escape sequences
Mikael Berthe <mikael@lilotux.net>
parents: 760
diff changeset
100 gint value;
4532a9fe0e8c Handle some keyboard escape sequences
Mikael Berthe <mikael@lilotux.net>
parents: 760
diff changeset
101 } keyseq;
4532a9fe0e8c Handle some keyboard escape sequences
Mikael Berthe <mikael@lilotux.net>
parents: 760
diff changeset
102
4532a9fe0e8c Handle some keyboard escape sequences
Mikael Berthe <mikael@lilotux.net>
parents: 760
diff changeset
103 GSList *keyseqlist;
4532a9fe0e8c Handle some keyboard escape sequences
Mikael Berthe <mikael@lilotux.net>
parents: 760
diff changeset
104 static void add_keyseq(char *seqstr, guint mkeycode, gint value);
4532a9fe0e8c Handle some keyboard escape sequences
Mikael Berthe <mikael@lilotux.net>
parents: 760
diff changeset
105
24
e88b15cbf2de [/trunk] Changeset 40 by mikael
mikael
parents:
diff changeset
106
99
7fffb8a6b229 [/trunk] Changeset 113 by mikael
mikael
parents: 98
diff changeset
107 /* Functions */
24
e88b15cbf2de [/trunk] Changeset 40 by mikael
mikael
parents:
diff changeset
108
336
eb994ee40029 Make some functions static
Mikael Berthe <mikael@lilotux.net>
parents: 332
diff changeset
109 static int scr_WindowWidth(WINDOW * win)
24
e88b15cbf2de [/trunk] Changeset 40 by mikael
mikael
parents:
diff changeset
110 {
e88b15cbf2de [/trunk] Changeset 40 by mikael
mikael
parents:
diff changeset
111 int x, y;
e88b15cbf2de [/trunk] Changeset 40 by mikael
mikael
parents:
diff changeset
112 getmaxyx(win, y, x);
e88b15cbf2de [/trunk] Changeset 40 by mikael
mikael
parents:
diff changeset
113 return x;
e88b15cbf2de [/trunk] Changeset 40 by mikael
mikael
parents:
diff changeset
114 }
e88b15cbf2de [/trunk] Changeset 40 by mikael
mikael
parents:
diff changeset
115
336
eb994ee40029 Make some functions static
Mikael Berthe <mikael@lilotux.net>
parents: 332
diff changeset
116 static int FindColor(const char *name)
24
e88b15cbf2de [/trunk] Changeset 40 by mikael
mikael
parents:
diff changeset
117 {
e88b15cbf2de [/trunk] Changeset 40 by mikael
mikael
parents:
diff changeset
118 if (!strcmp(name, "default"))
e88b15cbf2de [/trunk] Changeset 40 by mikael
mikael
parents:
diff changeset
119 return -1;
e88b15cbf2de [/trunk] Changeset 40 by mikael
mikael
parents:
diff changeset
120 if (!strcmp(name, "black"))
e88b15cbf2de [/trunk] Changeset 40 by mikael
mikael
parents:
diff changeset
121 return COLOR_BLACK;
e88b15cbf2de [/trunk] Changeset 40 by mikael
mikael
parents:
diff changeset
122 if (!strcmp(name, "red"))
e88b15cbf2de [/trunk] Changeset 40 by mikael
mikael
parents:
diff changeset
123 return COLOR_RED;
e88b15cbf2de [/trunk] Changeset 40 by mikael
mikael
parents:
diff changeset
124 if (!strcmp(name, "green"))
e88b15cbf2de [/trunk] Changeset 40 by mikael
mikael
parents:
diff changeset
125 return COLOR_GREEN;
e88b15cbf2de [/trunk] Changeset 40 by mikael
mikael
parents:
diff changeset
126 if (!strcmp(name, "yellow"))
e88b15cbf2de [/trunk] Changeset 40 by mikael
mikael
parents:
diff changeset
127 return COLOR_YELLOW;
e88b15cbf2de [/trunk] Changeset 40 by mikael
mikael
parents:
diff changeset
128 if (!strcmp(name, "blue"))
e88b15cbf2de [/trunk] Changeset 40 by mikael
mikael
parents:
diff changeset
129 return COLOR_BLUE;
e88b15cbf2de [/trunk] Changeset 40 by mikael
mikael
parents:
diff changeset
130 if (!strcmp(name, "magenta"))
e88b15cbf2de [/trunk] Changeset 40 by mikael
mikael
parents:
diff changeset
131 return COLOR_MAGENTA;
e88b15cbf2de [/trunk] Changeset 40 by mikael
mikael
parents:
diff changeset
132 if (!strcmp(name, "cyan"))
e88b15cbf2de [/trunk] Changeset 40 by mikael
mikael
parents:
diff changeset
133 return COLOR_CYAN;
e88b15cbf2de [/trunk] Changeset 40 by mikael
mikael
parents:
diff changeset
134 if (!strcmp(name, "white"))
e88b15cbf2de [/trunk] Changeset 40 by mikael
mikael
parents:
diff changeset
135 return COLOR_WHITE;
e88b15cbf2de [/trunk] Changeset 40 by mikael
mikael
parents:
diff changeset
136
739
0d5fb1d9077c Allow "bright" text colors
Mikael Berthe <mikael@lilotux.net>
parents: 735
diff changeset
137 scr_LogPrint(LPRINT_LOGNORM, "ERROR: Wrong color: %s", name);
24
e88b15cbf2de [/trunk] Changeset 40 by mikael
mikael
parents:
diff changeset
138 return -1;
e88b15cbf2de [/trunk] Changeset 40 by mikael
mikael
parents:
diff changeset
139 }
e88b15cbf2de [/trunk] Changeset 40 by mikael
mikael
parents:
diff changeset
140
336
eb994ee40029 Make some functions static
Mikael Berthe <mikael@lilotux.net>
parents: 332
diff changeset
141 static void ParseColors(void)
24
e88b15cbf2de [/trunk] Changeset 40 by mikael
mikael
parents:
diff changeset
142 {
739
0d5fb1d9077c Allow "bright" text colors
Mikael Berthe <mikael@lilotux.net>
parents: 735
diff changeset
143 const char *colors[] = {
24
e88b15cbf2de [/trunk] Changeset 40 by mikael
mikael
parents:
diff changeset
144 "", "",
267
8d3d5bd52da3 Improve color configuration
mikael@frmp8452
parents: 265
diff changeset
145 "general",
785
7e0562e3bc83 Replace color_highlight with color_msgout
Mikael Berthe <mikael@lilotux.net>
parents: 779
diff changeset
146 "msgout",
711
75dde88f1884 Introduce status lines
Mikael Berthe <mikael@lilotux.net>
parents: 709
diff changeset
147 "status",
712
e1639629c87b Rename color options
Mikael Berthe <mikael@lilotux.net>
parents: 711
diff changeset
148 "roster",
e1639629c87b Rename color options
Mikael Berthe <mikael@lilotux.net>
parents: 711
diff changeset
149 "rostersel",
723
23068490d063 Add text color when the selected buddy has an unread message
Mikael Berthe <mikael@lilotux.net>
parents: 721
diff changeset
150 "rosterselmsg",
712
e1639629c87b Rename color options
Mikael Berthe <mikael@lilotux.net>
parents: 711
diff changeset
151 "rosternewmsg",
24
e88b15cbf2de [/trunk] Changeset 40 by mikael
mikael
parents:
diff changeset
152 NULL
e88b15cbf2de [/trunk] Changeset 40 by mikael
mikael
parents:
diff changeset
153 };
e88b15cbf2de [/trunk] Changeset 40 by mikael
mikael
parents:
diff changeset
154
281
f562b9af2de7 Add "const" specifier in prototypes
Mikael Berthe <mikael@lilotux.net>
parents: 279
diff changeset
155 const char *color;
f562b9af2de7 Add "const" specifier in prototypes
Mikael Berthe <mikael@lilotux.net>
parents: 279
diff changeset
156 const char *background = settings_opt_get("color_background");
712
e1639629c87b Rename color options
Mikael Berthe <mikael@lilotux.net>
parents: 711
diff changeset
157 const char *backselected = settings_opt_get("color_bgrostersel");
e1639629c87b Rename color options
Mikael Berthe <mikael@lilotux.net>
parents: 711
diff changeset
158 const char *backstatus = settings_opt_get("color_bgstatus");
739
0d5fb1d9077c Allow "bright" text colors
Mikael Berthe <mikael@lilotux.net>
parents: 735
diff changeset
159 char *tmp;
0d5fb1d9077c Allow "bright" text colors
Mikael Berthe <mikael@lilotux.net>
parents: 735
diff changeset
160 int i;
0d5fb1d9077c Allow "bright" text colors
Mikael Berthe <mikael@lilotux.net>
parents: 735
diff changeset
161
0d5fb1d9077c Allow "bright" text colors
Mikael Berthe <mikael@lilotux.net>
parents: 735
diff changeset
162 // Initialize color attributes
0d5fb1d9077c Allow "bright" text colors
Mikael Berthe <mikael@lilotux.net>
parents: 735
diff changeset
163 memset(COLOR_ATTRIB, 0, sizeof(COLOR_ATTRIB));
24
e88b15cbf2de [/trunk] Changeset 40 by mikael
mikael
parents:
diff changeset
164
267
8d3d5bd52da3 Improve color configuration
mikael@frmp8452
parents: 265
diff changeset
165 // Default values
711
75dde88f1884 Introduce status lines
Mikael Berthe <mikael@lilotux.net>
parents: 709
diff changeset
166 if (!background) background = "black";
267
8d3d5bd52da3 Improve color configuration
mikael@frmp8452
parents: 265
diff changeset
167 if (!backselected) backselected = "cyan";
711
75dde88f1884 Introduce status lines
Mikael Berthe <mikael@lilotux.net>
parents: 709
diff changeset
168 if (!backstatus) backstatus = "blue";
267
8d3d5bd52da3 Improve color configuration
mikael@frmp8452
parents: 265
diff changeset
169
739
0d5fb1d9077c Allow "bright" text colors
Mikael Berthe <mikael@lilotux.net>
parents: 735
diff changeset
170 for (i=0; colors[i]; i++) {
0d5fb1d9077c Allow "bright" text colors
Mikael Berthe <mikael@lilotux.net>
parents: 735
diff changeset
171 tmp = g_strdup_printf("color_%s", colors[i]);
279
f5dd437c057b Rewrite the settings system
Mikael Berthe <mikael@lilotux.net>
parents: 276
diff changeset
172 color = settings_opt_get(tmp);
739
0d5fb1d9077c Allow "bright" text colors
Mikael Berthe <mikael@lilotux.net>
parents: 735
diff changeset
173 g_free(tmp);
0d5fb1d9077c Allow "bright" text colors
Mikael Berthe <mikael@lilotux.net>
parents: 735
diff changeset
174
0d5fb1d9077c Allow "bright" text colors
Mikael Berthe <mikael@lilotux.net>
parents: 735
diff changeset
175 if (color) {
0d5fb1d9077c Allow "bright" text colors
Mikael Berthe <mikael@lilotux.net>
parents: 735
diff changeset
176 if (!strncmp(color, "bright", 6)) {
0d5fb1d9077c Allow "bright" text colors
Mikael Berthe <mikael@lilotux.net>
parents: 735
diff changeset
177 COLOR_ATTRIB[i+1] = A_BOLD;
0d5fb1d9077c Allow "bright" text colors
Mikael Berthe <mikael@lilotux.net>
parents: 735
diff changeset
178 color += 6;
0d5fb1d9077c Allow "bright" text colors
Mikael Berthe <mikael@lilotux.net>
parents: 735
diff changeset
179 }
0d5fb1d9077c Allow "bright" text colors
Mikael Berthe <mikael@lilotux.net>
parents: 735
diff changeset
180 }
24
e88b15cbf2de [/trunk] Changeset 40 by mikael
mikael
parents:
diff changeset
181
e88b15cbf2de [/trunk] Changeset 40 by mikael
mikael
parents:
diff changeset
182 switch (i + 1) {
739
0d5fb1d9077c Allow "bright" text colors
Mikael Berthe <mikael@lilotux.net>
parents: 735
diff changeset
183 case 1:
0d5fb1d9077c Allow "bright" text colors
Mikael Berthe <mikael@lilotux.net>
parents: 735
diff changeset
184 init_pair(1, COLOR_BLACK, COLOR_WHITE);
0d5fb1d9077c Allow "bright" text colors
Mikael Berthe <mikael@lilotux.net>
parents: 735
diff changeset
185 break;
0d5fb1d9077c Allow "bright" text colors
Mikael Berthe <mikael@lilotux.net>
parents: 735
diff changeset
186 case 2:
0d5fb1d9077c Allow "bright" text colors
Mikael Berthe <mikael@lilotux.net>
parents: 735
diff changeset
187 init_pair(2, COLOR_WHITE, COLOR_BLACK);
0d5fb1d9077c Allow "bright" text colors
Mikael Berthe <mikael@lilotux.net>
parents: 735
diff changeset
188 break;
0d5fb1d9077c Allow "bright" text colors
Mikael Berthe <mikael@lilotux.net>
parents: 735
diff changeset
189 case COLOR_GENERAL:
0d5fb1d9077c Allow "bright" text colors
Mikael Berthe <mikael@lilotux.net>
parents: 735
diff changeset
190 init_pair(i+1, ((color) ? FindColor(color) : COLOR_WHITE),
0d5fb1d9077c Allow "bright" text colors
Mikael Berthe <mikael@lilotux.net>
parents: 735
diff changeset
191 FindColor(background));
0d5fb1d9077c Allow "bright" text colors
Mikael Berthe <mikael@lilotux.net>
parents: 735
diff changeset
192 break;
785
7e0562e3bc83 Replace color_highlight with color_msgout
Mikael Berthe <mikael@lilotux.net>
parents: 779
diff changeset
193 case COLOR_MSGOUT:
739
0d5fb1d9077c Allow "bright" text colors
Mikael Berthe <mikael@lilotux.net>
parents: 735
diff changeset
194 init_pair(i+1, ((color) ? FindColor(color) : COLOR_CYAN),
0d5fb1d9077c Allow "bright" text colors
Mikael Berthe <mikael@lilotux.net>
parents: 735
diff changeset
195 FindColor(background));
0d5fb1d9077c Allow "bright" text colors
Mikael Berthe <mikael@lilotux.net>
parents: 735
diff changeset
196 break;
0d5fb1d9077c Allow "bright" text colors
Mikael Berthe <mikael@lilotux.net>
parents: 735
diff changeset
197 case COLOR_STATUS:
0d5fb1d9077c Allow "bright" text colors
Mikael Berthe <mikael@lilotux.net>
parents: 735
diff changeset
198 init_pair(i+1, ((color) ? FindColor(color) : COLOR_WHITE),
0d5fb1d9077c Allow "bright" text colors
Mikael Berthe <mikael@lilotux.net>
parents: 735
diff changeset
199 FindColor(backstatus));
0d5fb1d9077c Allow "bright" text colors
Mikael Berthe <mikael@lilotux.net>
parents: 735
diff changeset
200 break;
0d5fb1d9077c Allow "bright" text colors
Mikael Berthe <mikael@lilotux.net>
parents: 735
diff changeset
201 case COLOR_ROSTER:
0d5fb1d9077c Allow "bright" text colors
Mikael Berthe <mikael@lilotux.net>
parents: 735
diff changeset
202 init_pair(i+1, ((color) ? FindColor(color) : COLOR_GREEN),
0d5fb1d9077c Allow "bright" text colors
Mikael Berthe <mikael@lilotux.net>
parents: 735
diff changeset
203 FindColor(background));
0d5fb1d9077c Allow "bright" text colors
Mikael Berthe <mikael@lilotux.net>
parents: 735
diff changeset
204 break;
0d5fb1d9077c Allow "bright" text colors
Mikael Berthe <mikael@lilotux.net>
parents: 735
diff changeset
205 case COLOR_ROSTERSEL:
0d5fb1d9077c Allow "bright" text colors
Mikael Berthe <mikael@lilotux.net>
parents: 735
diff changeset
206 init_pair(i+1, ((color) ? FindColor(color) : COLOR_BLUE),
0d5fb1d9077c Allow "bright" text colors
Mikael Berthe <mikael@lilotux.net>
parents: 735
diff changeset
207 FindColor(backselected));
0d5fb1d9077c Allow "bright" text colors
Mikael Berthe <mikael@lilotux.net>
parents: 735
diff changeset
208 break;
0d5fb1d9077c Allow "bright" text colors
Mikael Berthe <mikael@lilotux.net>
parents: 735
diff changeset
209 case COLOR_ROSTERSELNMSG:
0d5fb1d9077c Allow "bright" text colors
Mikael Berthe <mikael@lilotux.net>
parents: 735
diff changeset
210 init_pair(i+1, ((color) ? FindColor(color) : COLOR_RED),
0d5fb1d9077c Allow "bright" text colors
Mikael Berthe <mikael@lilotux.net>
parents: 735
diff changeset
211 FindColor(backselected));
0d5fb1d9077c Allow "bright" text colors
Mikael Berthe <mikael@lilotux.net>
parents: 735
diff changeset
212 break;
0d5fb1d9077c Allow "bright" text colors
Mikael Berthe <mikael@lilotux.net>
parents: 735
diff changeset
213 case COLOR_ROSTERNMSG:
0d5fb1d9077c Allow "bright" text colors
Mikael Berthe <mikael@lilotux.net>
parents: 735
diff changeset
214 init_pair(i+1, ((color) ? FindColor(color) : COLOR_RED),
0d5fb1d9077c Allow "bright" text colors
Mikael Berthe <mikael@lilotux.net>
parents: 735
diff changeset
215 FindColor(background));
0d5fb1d9077c Allow "bright" text colors
Mikael Berthe <mikael@lilotux.net>
parents: 735
diff changeset
216 break;
24
e88b15cbf2de [/trunk] Changeset 40 by mikael
mikael
parents:
diff changeset
217 }
e88b15cbf2de [/trunk] Changeset 40 by mikael
mikael
parents:
diff changeset
218 }
e88b15cbf2de [/trunk] Changeset 40 by mikael
mikael
parents:
diff changeset
219 }
e88b15cbf2de [/trunk] Changeset 40 by mikael
mikael
parents:
diff changeset
220
765
72626e9d60bd Create init_keycodes(), add 2 screen escape sequences
Mikael Berthe <mikael@lilotux.net>
parents: 764
diff changeset
221 static void init_keycodes(void)
373
af2f8ddf6a1b Move (reorganize) functions
Mikael Berthe <mikael@lilotux.net>
parents: 370
diff changeset
222 {
761
4532a9fe0e8c Handle some keyboard escape sequences
Mikael Berthe <mikael@lilotux.net>
parents: 760
diff changeset
223 add_keyseq("O5A", MKEY_EQUIV, 521); // Ctrl-Up
4532a9fe0e8c Handle some keyboard escape sequences
Mikael Berthe <mikael@lilotux.net>
parents: 760
diff changeset
224 add_keyseq("O5B", MKEY_EQUIV, 514); // Ctrl-Down
4532a9fe0e8c Handle some keyboard escape sequences
Mikael Berthe <mikael@lilotux.net>
parents: 760
diff changeset
225 add_keyseq("O5C", MKEY_EQUIV, 518); // Ctrl-Right
4532a9fe0e8c Handle some keyboard escape sequences
Mikael Berthe <mikael@lilotux.net>
parents: 760
diff changeset
226 add_keyseq("O5D", MKEY_EQUIV, 516); // Ctrl-Left
763
6866ee749225 More keycodes
Mikael Berthe <mikael@lilotux.net>
parents: 762
diff changeset
227 add_keyseq("O6A", MKEY_EQUIV, 520); // Shift-Up
6866ee749225 More keycodes
Mikael Berthe <mikael@lilotux.net>
parents: 762
diff changeset
228 add_keyseq("O6B", MKEY_EQUIV, 513); // Shift-Down
6866ee749225 More keycodes
Mikael Berthe <mikael@lilotux.net>
parents: 762
diff changeset
229 add_keyseq("O6C", MKEY_EQUIV, 402); // Shift-Right
6866ee749225 More keycodes
Mikael Berthe <mikael@lilotux.net>
parents: 762
diff changeset
230 add_keyseq("O6D", MKEY_EQUIV, 393); // Shift-Left
6866ee749225 More keycodes
Mikael Berthe <mikael@lilotux.net>
parents: 762
diff changeset
231 add_keyseq("O2A", MKEY_EQUIV, 520); // Shift-Up
6866ee749225 More keycodes
Mikael Berthe <mikael@lilotux.net>
parents: 762
diff changeset
232 add_keyseq("O2B", MKEY_EQUIV, 513); // Shift-Down
6866ee749225 More keycodes
Mikael Berthe <mikael@lilotux.net>
parents: 762
diff changeset
233 add_keyseq("O2C", MKEY_EQUIV, 402); // Shift-Right
6866ee749225 More keycodes
Mikael Berthe <mikael@lilotux.net>
parents: 762
diff changeset
234 add_keyseq("O2D", MKEY_EQUIV, 393); // Shift-Left
6866ee749225 More keycodes
Mikael Berthe <mikael@lilotux.net>
parents: 762
diff changeset
235 add_keyseq("[5^", MKEY_CTRL_PGUP, 0); // Ctrl-PageUp
6866ee749225 More keycodes
Mikael Berthe <mikael@lilotux.net>
parents: 762
diff changeset
236 add_keyseq("[6^", MKEY_CTRL_PGDOWN, 0); // Ctrl-PageDown
6866ee749225 More keycodes
Mikael Berthe <mikael@lilotux.net>
parents: 762
diff changeset
237 add_keyseq("[5@", MKEY_CTRL_SHIFT_PGUP, 0); // Ctrl-Shift-PageUp
6866ee749225 More keycodes
Mikael Berthe <mikael@lilotux.net>
parents: 762
diff changeset
238 add_keyseq("[6@", MKEY_CTRL_SHIFT_PGDOWN, 0); // Ctrl-Shift-PageDown
794
32d5298f9f8d Add a few keycode sequences
Mikael Berthe <mikael@lilotux.net>
parents: 790
diff changeset
239 add_keyseq("[8^", MKEY_CTRL_END, 0); // Ctrl-End
32d5298f9f8d Add a few keycode sequences
Mikael Berthe <mikael@lilotux.net>
parents: 790
diff changeset
240 add_keyseq("[7^", MKEY_CTRL_HOME, 0); // Ctrl-Home
32d5298f9f8d Add a few keycode sequences
Mikael Berthe <mikael@lilotux.net>
parents: 790
diff changeset
241 add_keyseq("[2^", MKEY_CTRL_INS, 0); // Ctrl-Insert
32d5298f9f8d Add a few keycode sequences
Mikael Berthe <mikael@lilotux.net>
parents: 790
diff changeset
242 add_keyseq("[3^", MKEY_CTRL_DEL, 0); // Ctrl-Delete
761
4532a9fe0e8c Handle some keyboard escape sequences
Mikael Berthe <mikael@lilotux.net>
parents: 760
diff changeset
243
4532a9fe0e8c Handle some keyboard escape sequences
Mikael Berthe <mikael@lilotux.net>
parents: 760
diff changeset
244 // Xterm
4532a9fe0e8c Handle some keyboard escape sequences
Mikael Berthe <mikael@lilotux.net>
parents: 760
diff changeset
245 add_keyseq("[1;5A", MKEY_EQUIV, 521); // Ctrl-Up
4532a9fe0e8c Handle some keyboard escape sequences
Mikael Berthe <mikael@lilotux.net>
parents: 760
diff changeset
246 add_keyseq("[1;5B", MKEY_EQUIV, 514); // Ctrl-Down
4532a9fe0e8c Handle some keyboard escape sequences
Mikael Berthe <mikael@lilotux.net>
parents: 760
diff changeset
247 add_keyseq("[1;5C", MKEY_EQUIV, 518); // Ctrl-Right
4532a9fe0e8c Handle some keyboard escape sequences
Mikael Berthe <mikael@lilotux.net>
parents: 760
diff changeset
248 add_keyseq("[1;5D", MKEY_EQUIV, 516); // Ctrl-Left
4532a9fe0e8c Handle some keyboard escape sequences
Mikael Berthe <mikael@lilotux.net>
parents: 760
diff changeset
249 add_keyseq("[1;6A", MKEY_EQUIV, 520); // Ctrl-Shift-Up
4532a9fe0e8c Handle some keyboard escape sequences
Mikael Berthe <mikael@lilotux.net>
parents: 760
diff changeset
250 add_keyseq("[1;6B", MKEY_EQUIV, 513); // Ctrl-Shift-Down
4532a9fe0e8c Handle some keyboard escape sequences
Mikael Berthe <mikael@lilotux.net>
parents: 760
diff changeset
251 add_keyseq("[1;6C", MKEY_EQUIV, 402); // Ctrl-Shift-Right
4532a9fe0e8c Handle some keyboard escape sequences
Mikael Berthe <mikael@lilotux.net>
parents: 760
diff changeset
252 add_keyseq("[1;6D", MKEY_EQUIV, 393); // Ctrl-Shift-Left
763
6866ee749225 More keycodes
Mikael Berthe <mikael@lilotux.net>
parents: 762
diff changeset
253 add_keyseq("[1;2A", MKEY_EQUIV, 521); // Shift-Up
6866ee749225 More keycodes
Mikael Berthe <mikael@lilotux.net>
parents: 762
diff changeset
254 add_keyseq("[1;2B", MKEY_EQUIV, 514); // Shift-Down
6866ee749225 More keycodes
Mikael Berthe <mikael@lilotux.net>
parents: 762
diff changeset
255 add_keyseq("[5;5~", MKEY_CTRL_PGUP, 0); // Ctrl-PageUp
6866ee749225 More keycodes
Mikael Berthe <mikael@lilotux.net>
parents: 762
diff changeset
256 add_keyseq("[6;5~", MKEY_CTRL_PGDOWN, 0); // Ctrl-PageDown
794
32d5298f9f8d Add a few keycode sequences
Mikael Berthe <mikael@lilotux.net>
parents: 790
diff changeset
257 add_keyseq("[1;5F", MKEY_CTRL_END, 0); // Ctrl-End
32d5298f9f8d Add a few keycode sequences
Mikael Berthe <mikael@lilotux.net>
parents: 790
diff changeset
258 add_keyseq("[1;5H", MKEY_CTRL_HOME, 0); // Ctrl-Home
32d5298f9f8d Add a few keycode sequences
Mikael Berthe <mikael@lilotux.net>
parents: 790
diff changeset
259 add_keyseq("[2;5~", MKEY_CTRL_INS, 0); // Ctrl-Insert
32d5298f9f8d Add a few keycode sequences
Mikael Berthe <mikael@lilotux.net>
parents: 790
diff changeset
260 add_keyseq("[3;5~", MKEY_CTRL_DEL, 0); // Ctrl-Delete
761
4532a9fe0e8c Handle some keyboard escape sequences
Mikael Berthe <mikael@lilotux.net>
parents: 760
diff changeset
261
768
0f6d25a02450 Add PuTTY escape keys for Ctrl-arrows
Mikael Berthe <mikael@lilotux.net>
parents: 766
diff changeset
262 // PuTTY
0f6d25a02450 Add PuTTY escape keys for Ctrl-arrows
Mikael Berthe <mikael@lilotux.net>
parents: 766
diff changeset
263 add_keyseq("[A", MKEY_EQUIV, 521); // Ctrl-Up
0f6d25a02450 Add PuTTY escape keys for Ctrl-arrows
Mikael Berthe <mikael@lilotux.net>
parents: 766
diff changeset
264 add_keyseq("[B", MKEY_EQUIV, 514); // Ctrl-Down
0f6d25a02450 Add PuTTY escape keys for Ctrl-arrows
Mikael Berthe <mikael@lilotux.net>
parents: 766
diff changeset
265 add_keyseq("[C", MKEY_EQUIV, 518); // Ctrl-Right
0f6d25a02450 Add PuTTY escape keys for Ctrl-arrows
Mikael Berthe <mikael@lilotux.net>
parents: 766
diff changeset
266 add_keyseq("[D", MKEY_EQUIV, 516); // Ctrl-Left
0f6d25a02450 Add PuTTY escape keys for Ctrl-arrows
Mikael Berthe <mikael@lilotux.net>
parents: 766
diff changeset
267
762
96d46e00524a Add some key escape sequences for screen
Mikael Berthe <mikael@lilotux.net>
parents: 761
diff changeset
268 // screen
96d46e00524a Add some key escape sequences for screen
Mikael Berthe <mikael@lilotux.net>
parents: 761
diff changeset
269 add_keyseq("Oa", MKEY_EQUIV, 521); // Ctrl-Up
96d46e00524a Add some key escape sequences for screen
Mikael Berthe <mikael@lilotux.net>
parents: 761
diff changeset
270 add_keyseq("Ob", MKEY_EQUIV, 514); // Ctrl-Down
96d46e00524a Add some key escape sequences for screen
Mikael Berthe <mikael@lilotux.net>
parents: 761
diff changeset
271 add_keyseq("Oc", MKEY_EQUIV, 518); // Ctrl-Right
96d46e00524a Add some key escape sequences for screen
Mikael Berthe <mikael@lilotux.net>
parents: 761
diff changeset
272 add_keyseq("Od", MKEY_EQUIV, 516); // Ctrl-Left
763
6866ee749225 More keycodes
Mikael Berthe <mikael@lilotux.net>
parents: 762
diff changeset
273 add_keyseq("[a", MKEY_EQUIV, 520); // Shift-Up
6866ee749225 More keycodes
Mikael Berthe <mikael@lilotux.net>
parents: 762
diff changeset
274 add_keyseq("[b", MKEY_EQUIV, 513); // Shift-Down
6866ee749225 More keycodes
Mikael Berthe <mikael@lilotux.net>
parents: 762
diff changeset
275 add_keyseq("[c", MKEY_EQUIV, 402); // Shift-Right
6866ee749225 More keycodes
Mikael Berthe <mikael@lilotux.net>
parents: 762
diff changeset
276 add_keyseq("[d", MKEY_EQUIV, 393); // Shift-Left
765
72626e9d60bd Create init_keycodes(), add 2 screen escape sequences
Mikael Berthe <mikael@lilotux.net>
parents: 764
diff changeset
277 add_keyseq("[5$", MKEY_SHIFT_PGUP, 0); // Shift-PageUp
72626e9d60bd Create init_keycodes(), add 2 screen escape sequences
Mikael Berthe <mikael@lilotux.net>
parents: 764
diff changeset
278 add_keyseq("[6$", MKEY_SHIFT_PGDOWN, 0); // Shift-PageDown
72626e9d60bd Create init_keycodes(), add 2 screen escape sequences
Mikael Berthe <mikael@lilotux.net>
parents: 764
diff changeset
279 }
72626e9d60bd Create init_keycodes(), add 2 screen escape sequences
Mikael Berthe <mikael@lilotux.net>
parents: 764
diff changeset
280
779
057ffe7c43dc Initialize locale charset earlier
Mikael Berthe <mikael@lilotux.net>
parents: 773
diff changeset
281 void scr_InitLocaleCharSet(void)
057ffe7c43dc Initialize locale charset earlier
Mikael Berthe <mikael@lilotux.net>
parents: 773
diff changeset
282 {
057ffe7c43dc Initialize locale charset earlier
Mikael Berthe <mikael@lilotux.net>
parents: 773
diff changeset
283 setlocale(LC_CTYPE, "");
057ffe7c43dc Initialize locale charset earlier
Mikael Berthe <mikael@lilotux.net>
parents: 773
diff changeset
284 LocaleCharSet = nl_langinfo(CODESET);
057ffe7c43dc Initialize locale charset earlier
Mikael Berthe <mikael@lilotux.net>
parents: 773
diff changeset
285 utf8_mode = (strcmp(LocaleCharSet, "UTF-8") == 0);
057ffe7c43dc Initialize locale charset earlier
Mikael Berthe <mikael@lilotux.net>
parents: 773
diff changeset
286 }
057ffe7c43dc Initialize locale charset earlier
Mikael Berthe <mikael@lilotux.net>
parents: 773
diff changeset
287
765
72626e9d60bd Create init_keycodes(), add 2 screen escape sequences
Mikael Berthe <mikael@lilotux.net>
parents: 764
diff changeset
288 void scr_InitCurses(void)
72626e9d60bd Create init_keycodes(), add 2 screen escape sequences
Mikael Berthe <mikael@lilotux.net>
parents: 764
diff changeset
289 {
72626e9d60bd Create init_keycodes(), add 2 screen escape sequences
Mikael Berthe <mikael@lilotux.net>
parents: 764
diff changeset
290 /* Key sequences initialization */
72626e9d60bd Create init_keycodes(), add 2 screen escape sequences
Mikael Berthe <mikael@lilotux.net>
parents: 764
diff changeset
291 init_keycodes();
762
96d46e00524a Add some key escape sequences for screen
Mikael Berthe <mikael@lilotux.net>
parents: 761
diff changeset
292
373
af2f8ddf6a1b Move (reorganize) functions
Mikael Berthe <mikael@lilotux.net>
parents: 370
diff changeset
293 initscr();
382
4c6e8392e465 Use nodelay() instead of halfdelay()
Mikael Berthe <mikael@lilotux.net>
parents: 374
diff changeset
294 raw();
373
af2f8ddf6a1b Move (reorganize) functions
Mikael Berthe <mikael@lilotux.net>
parents: 370
diff changeset
295 noecho();
389
6e895f397474 Ncurses changes + Ctrl-C does not send a signal anylore
Mikael Berthe <mikael@lilotux.net>
parents: 388
diff changeset
296 nonl();
6e895f397474 Ncurses changes + Ctrl-C does not send a signal anylore
Mikael Berthe <mikael@lilotux.net>
parents: 388
diff changeset
297 intrflush(stdscr, FALSE);
373
af2f8ddf6a1b Move (reorganize) functions
Mikael Berthe <mikael@lilotux.net>
parents: 370
diff changeset
298 start_color();
af2f8ddf6a1b Move (reorganize) functions
Mikael Berthe <mikael@lilotux.net>
parents: 370
diff changeset
299 use_default_colors();
af2f8ddf6a1b Move (reorganize) functions
Mikael Berthe <mikael@lilotux.net>
parents: 370
diff changeset
300 Curses = TRUE;
af2f8ddf6a1b Move (reorganize) functions
Mikael Berthe <mikael@lilotux.net>
parents: 370
diff changeset
301
af2f8ddf6a1b Move (reorganize) functions
Mikael Berthe <mikael@lilotux.net>
parents: 370
diff changeset
302 ParseColors();
af2f8ddf6a1b Move (reorganize) functions
Mikael Berthe <mikael@lilotux.net>
parents: 370
diff changeset
303
af2f8ddf6a1b Move (reorganize) functions
Mikael Berthe <mikael@lilotux.net>
parents: 370
diff changeset
304 getmaxyx(stdscr, maxY, maxX);
515
180f0a6e4ac9 Log window's height can be set by the user
Mikael Berthe <mikael@lilotux.net>
parents: 514
diff changeset
305 Log_Win_Height = DEFAULT_LOG_WIN_HEIGHT;
518
9480a76471b6 Update Log_Win_Height when refreshing the screen
Mikael Berthe <mikael@lilotux.net>
parents: 515
diff changeset
306 // Note scr_DrawMainWindow() should be called early after scr_InitCurses()
9480a76471b6 Update Log_Win_Height when refreshing the screen
Mikael Berthe <mikael@lilotux.net>
parents: 515
diff changeset
307 // to update Log_Win_Height and set max{X,Y}
515
180f0a6e4ac9 Log window's height can be set by the user
Mikael Berthe <mikael@lilotux.net>
parents: 514
diff changeset
308
373
af2f8ddf6a1b Move (reorganize) functions
Mikael Berthe <mikael@lilotux.net>
parents: 370
diff changeset
309 inputLine[0] = 0;
af2f8ddf6a1b Move (reorganize) functions
Mikael Berthe <mikael@lilotux.net>
parents: 370
diff changeset
310 ptr_inputline = inputLine;
af2f8ddf6a1b Move (reorganize) functions
Mikael Berthe <mikael@lilotux.net>
parents: 370
diff changeset
311
af2f8ddf6a1b Move (reorganize) functions
Mikael Berthe <mikael@lilotux.net>
parents: 370
diff changeset
312 return;
af2f8ddf6a1b Move (reorganize) functions
Mikael Berthe <mikael@lilotux.net>
parents: 370
diff changeset
313 }
af2f8ddf6a1b Move (reorganize) functions
Mikael Berthe <mikael@lilotux.net>
parents: 370
diff changeset
314
af2f8ddf6a1b Move (reorganize) functions
Mikael Berthe <mikael@lilotux.net>
parents: 370
diff changeset
315 void scr_TerminateCurses(void)
af2f8ddf6a1b Move (reorganize) functions
Mikael Berthe <mikael@lilotux.net>
parents: 370
diff changeset
316 {
af2f8ddf6a1b Move (reorganize) functions
Mikael Berthe <mikael@lilotux.net>
parents: 370
diff changeset
317 if (!Curses) return;
af2f8ddf6a1b Move (reorganize) functions
Mikael Berthe <mikael@lilotux.net>
parents: 370
diff changeset
318 clear();
af2f8ddf6a1b Move (reorganize) functions
Mikael Berthe <mikael@lilotux.net>
parents: 370
diff changeset
319 refresh();
af2f8ddf6a1b Move (reorganize) functions
Mikael Berthe <mikael@lilotux.net>
parents: 370
diff changeset
320 endwin();
af2f8ddf6a1b Move (reorganize) functions
Mikael Berthe <mikael@lilotux.net>
parents: 370
diff changeset
321 Curses = FALSE;
af2f8ddf6a1b Move (reorganize) functions
Mikael Berthe <mikael@lilotux.net>
parents: 370
diff changeset
322 return;
af2f8ddf6a1b Move (reorganize) functions
Mikael Berthe <mikael@lilotux.net>
parents: 370
diff changeset
323 }
af2f8ddf6a1b Move (reorganize) functions
Mikael Berthe <mikael@lilotux.net>
parents: 370
diff changeset
324
675
ae7016aae014 New "beep_on_message" option
Mikael Berthe <mikael@lilotux.net>
parents: 667
diff changeset
325 inline void scr_Beep(void)
ae7016aae014 New "beep_on_message" option
Mikael Berthe <mikael@lilotux.net>
parents: 667
diff changeset
326 {
ae7016aae014 New "beep_on_message" option
Mikael Berthe <mikael@lilotux.net>
parents: 667
diff changeset
327 beep();
ae7016aae014 New "beep_on_message" option
Mikael Berthe <mikael@lilotux.net>
parents: 667
diff changeset
328 }
ae7016aae014 New "beep_on_message" option
Mikael Berthe <mikael@lilotux.net>
parents: 667
diff changeset
329
373
af2f8ddf6a1b Move (reorganize) functions
Mikael Berthe <mikael@lilotux.net>
parents: 370
diff changeset
330 // scr_LogPrint(...)
af2f8ddf6a1b Move (reorganize) functions
Mikael Berthe <mikael@lilotux.net>
parents: 370
diff changeset
331 // Display a message in the log window.
771
ce4f8a2129a4 scr_LogPrint() can display UTF-8 strings
Mikael Berthe <mikael@lilotux.net>
parents: 770
diff changeset
332 // This function will convert from UTF-8 unless the LPRINT_NOTUTF8 flag is set.
374
bd5638c21834 Improve logging system (traces)
Mikael Berthe <mikael@lilotux.net>
parents: 373
diff changeset
333 void scr_LogPrint(unsigned int flag, const char *fmt, ...)
373
af2f8ddf6a1b Move (reorganize) functions
Mikael Berthe <mikael@lilotux.net>
parents: 370
diff changeset
334 {
af2f8ddf6a1b Move (reorganize) functions
Mikael Berthe <mikael@lilotux.net>
parents: 370
diff changeset
335 time_t timestamp;
374
bd5638c21834 Improve logging system (traces)
Mikael Berthe <mikael@lilotux.net>
parents: 373
diff changeset
336 char *buffer, *b2;
373
af2f8ddf6a1b Move (reorganize) functions
Mikael Berthe <mikael@lilotux.net>
parents: 370
diff changeset
337 va_list ap;
af2f8ddf6a1b Move (reorganize) functions
Mikael Berthe <mikael@lilotux.net>
parents: 370
diff changeset
338
771
ce4f8a2129a4 scr_LogPrint() can display UTF-8 strings
Mikael Berthe <mikael@lilotux.net>
parents: 770
diff changeset
339 if (!(flag & ~LPRINT_NOTUTF8)) return; // Shouldn't happen
374
bd5638c21834 Improve logging system (traces)
Mikael Berthe <mikael@lilotux.net>
parents: 373
diff changeset
340
602
7b20c27cae48 Increase scr_LogPrint() buffer size
Mikael Berthe <mikael@lilotux.net>
parents: 592
diff changeset
341 buffer = g_new(char, 5184);
373
af2f8ddf6a1b Move (reorganize) functions
Mikael Berthe <mikael@lilotux.net>
parents: 370
diff changeset
342
af2f8ddf6a1b Move (reorganize) functions
Mikael Berthe <mikael@lilotux.net>
parents: 370
diff changeset
343 timestamp = time(NULL);
602
7b20c27cae48 Increase scr_LogPrint() buffer size
Mikael Berthe <mikael@lilotux.net>
parents: 592
diff changeset
344 strftime(buffer, 48, "[%H:%M:%S] ", localtime(&timestamp));
374
bd5638c21834 Improve logging system (traces)
Mikael Berthe <mikael@lilotux.net>
parents: 373
diff changeset
345 for (b2 = buffer ; *b2 ; b2++)
bd5638c21834 Improve logging system (traces)
Mikael Berthe <mikael@lilotux.net>
parents: 373
diff changeset
346 ;
373
af2f8ddf6a1b Move (reorganize) functions
Mikael Berthe <mikael@lilotux.net>
parents: 370
diff changeset
347 va_start(ap, fmt);
602
7b20c27cae48 Increase scr_LogPrint() buffer size
Mikael Berthe <mikael@lilotux.net>
parents: 592
diff changeset
348 vsnprintf(b2, 5120, fmt, ap);
373
af2f8ddf6a1b Move (reorganize) functions
Mikael Berthe <mikael@lilotux.net>
parents: 370
diff changeset
349 va_end(ap);
af2f8ddf6a1b Move (reorganize) functions
Mikael Berthe <mikael@lilotux.net>
parents: 370
diff changeset
350
374
bd5638c21834 Improve logging system (traces)
Mikael Berthe <mikael@lilotux.net>
parents: 373
diff changeset
351 if (flag & LPRINT_NORMAL) {
771
ce4f8a2129a4 scr_LogPrint() can display UTF-8 strings
Mikael Berthe <mikael@lilotux.net>
parents: 770
diff changeset
352 char *buffer_locale;
ce4f8a2129a4 scr_LogPrint() can display UTF-8 strings
Mikael Berthe <mikael@lilotux.net>
parents: 770
diff changeset
353 if (!(flag & LPRINT_NOTUTF8))
ce4f8a2129a4 scr_LogPrint() can display UTF-8 strings
Mikael Berthe <mikael@lilotux.net>
parents: 770
diff changeset
354 buffer_locale = from_utf8(buffer);
ce4f8a2129a4 scr_LogPrint() can display UTF-8 strings
Mikael Berthe <mikael@lilotux.net>
parents: 770
diff changeset
355 else
ce4f8a2129a4 scr_LogPrint() can display UTF-8 strings
Mikael Berthe <mikael@lilotux.net>
parents: 770
diff changeset
356 buffer_locale = buffer;
374
bd5638c21834 Improve logging system (traces)
Mikael Berthe <mikael@lilotux.net>
parents: 373
diff changeset
357 if (Curses) {
771
ce4f8a2129a4 scr_LogPrint() can display UTF-8 strings
Mikael Berthe <mikael@lilotux.net>
parents: 770
diff changeset
358 wprintw(logWnd, "\n%s", buffer_locale);
374
bd5638c21834 Improve logging system (traces)
Mikael Berthe <mikael@lilotux.net>
parents: 373
diff changeset
359 update_panels();
bd5638c21834 Improve logging system (traces)
Mikael Berthe <mikael@lilotux.net>
parents: 373
diff changeset
360 doupdate();
bd5638c21834 Improve logging system (traces)
Mikael Berthe <mikael@lilotux.net>
parents: 373
diff changeset
361 } else {
771
ce4f8a2129a4 scr_LogPrint() can display UTF-8 strings
Mikael Berthe <mikael@lilotux.net>
parents: 770
diff changeset
362 printf("%s\n", buffer_locale);
374
bd5638c21834 Improve logging system (traces)
Mikael Berthe <mikael@lilotux.net>
parents: 373
diff changeset
363 }
771
ce4f8a2129a4 scr_LogPrint() can display UTF-8 strings
Mikael Berthe <mikael@lilotux.net>
parents: 770
diff changeset
364 if (!(flag & LPRINT_NOTUTF8))
ce4f8a2129a4 scr_LogPrint() can display UTF-8 strings
Mikael Berthe <mikael@lilotux.net>
parents: 770
diff changeset
365 g_free(buffer_locale);
374
bd5638c21834 Improve logging system (traces)
Mikael Berthe <mikael@lilotux.net>
parents: 373
diff changeset
366 }
bd5638c21834 Improve logging system (traces)
Mikael Berthe <mikael@lilotux.net>
parents: 373
diff changeset
367 if (flag & (LPRINT_LOG|LPRINT_DEBUG)) {
658
5d71d1f8887e Avoid g_try_new()
Mikael Berthe <mikael@lilotux.net>
parents: 657
diff changeset
368 char *buffer2 = g_new(char, 5184);
412
9c640ee3bae3 Display full date in the log file
Mikael Berthe <mikael@lilotux.net>
parents: 393
diff changeset
369
658
5d71d1f8887e Avoid g_try_new()
Mikael Berthe <mikael@lilotux.net>
parents: 657
diff changeset
370 strftime(buffer2, 23, "[%Y-%m-%d %H:%M:%S] ", localtime(&timestamp));
5d71d1f8887e Avoid g_try_new()
Mikael Berthe <mikael@lilotux.net>
parents: 657
diff changeset
371 strcat(buffer2, b2);
412
9c640ee3bae3 Display full date in the log file
Mikael Berthe <mikael@lilotux.net>
parents: 393
diff changeset
372 strcat(buffer2, "\n");
9c640ee3bae3 Display full date in the log file
Mikael Berthe <mikael@lilotux.net>
parents: 393
diff changeset
373 ut_WriteLog(flag, buffer2);
658
5d71d1f8887e Avoid g_try_new()
Mikael Berthe <mikael@lilotux.net>
parents: 657
diff changeset
374 g_free(buffer2);
373
af2f8ddf6a1b Move (reorganize) functions
Mikael Berthe <mikael@lilotux.net>
parents: 370
diff changeset
375 }
602
7b20c27cae48 Increase scr_LogPrint() buffer size
Mikael Berthe <mikael@lilotux.net>
parents: 592
diff changeset
376 g_free(buffer);
373
af2f8ddf6a1b Move (reorganize) functions
Mikael Berthe <mikael@lilotux.net>
parents: 370
diff changeset
377 }
af2f8ddf6a1b Move (reorganize) functions
Mikael Berthe <mikael@lilotux.net>
parents: 370
diff changeset
378
336
eb994ee40029 Make some functions static
Mikael Berthe <mikael@lilotux.net>
parents: 332
diff changeset
379 static window_entry_t *scr_CreateBuddyPanel(const char *title, int dont_show)
24
e88b15cbf2de [/trunk] Changeset 40 by mikael
mikael
parents:
diff changeset
380 {
151
b69c0b7a23e3 [/trunk] Changeset 163 by mikael
mikael
parents: 149
diff changeset
381 int x;
b69c0b7a23e3 [/trunk] Changeset 163 by mikael
mikael
parents: 149
diff changeset
382 int y;
b69c0b7a23e3 [/trunk] Changeset 163 by mikael
mikael
parents: 149
diff changeset
383 int lines;
b69c0b7a23e3 [/trunk] Changeset 163 by mikael
mikael
parents: 149
diff changeset
384 int cols;
153
ae0844311710 [/trunk] Changeset 165 by mikael
mikael
parents: 151
diff changeset
385 window_entry_t *tmp;
393
f8f3c7493457 Whitespace cleanup
Mikael Berthe <mikael@lilotux.net>
parents: 389
diff changeset
386
657
056dc9e65c25 Some memory allocation code cleaning
Mikael Berthe <mikael@lilotux.net>
parents: 654
diff changeset
387 tmp = g_new0(window_entry_t, 1);
24
e88b15cbf2de [/trunk] Changeset 40 by mikael
mikael
parents:
diff changeset
388
151
b69c0b7a23e3 [/trunk] Changeset 163 by mikael
mikael
parents: 149
diff changeset
389 // Dimensions
701
6c100adfbfb6 Add setting "roster_width" (variable buddylist width)
Mikael Berthe <mikael@lilotux.net>
parents: 699
diff changeset
390 x = Roster_Width;
151
b69c0b7a23e3 [/trunk] Changeset 163 by mikael
mikael
parents: 149
diff changeset
391 y = 0;
b69c0b7a23e3 [/trunk] Changeset 163 by mikael
mikael
parents: 149
diff changeset
392 lines = CHAT_WIN_HEIGHT;
701
6c100adfbfb6 Add setting "roster_width" (variable buddylist width)
Mikael Berthe <mikael@lilotux.net>
parents: 699
diff changeset
393 cols = maxX - Roster_Width;
6c100adfbfb6 Add setting "roster_width" (variable buddylist width)
Mikael Berthe <mikael@lilotux.net>
parents: 699
diff changeset
394 if (cols < 1) cols = 1;
151
b69c0b7a23e3 [/trunk] Changeset 163 by mikael
mikael
parents: 149
diff changeset
395
24
e88b15cbf2de [/trunk] Changeset 40 by mikael
mikael
parents:
diff changeset
396 tmp->win = newwin(lines, cols, y, x);
154
8630b7cae87b [/trunk] Changeset 166 by mikael
mikael
parents: 153
diff changeset
397 while (!tmp->win) {
419
2f9852610cf4 Small code review
Mikael Berthe <mikael@lilotux.net>
parents: 412
diff changeset
398 safe_usleep(250);
154
8630b7cae87b [/trunk] Changeset 166 by mikael
mikael
parents: 153
diff changeset
399 tmp->win = newwin(lines, cols, y, x);
8630b7cae87b [/trunk] Changeset 166 by mikael
mikael
parents: 153
diff changeset
400 }
739
0d5fb1d9077c Allow "bright" text colors
Mikael Berthe <mikael@lilotux.net>
parents: 735
diff changeset
401 wbkgd(tmp->win, get_color(COLOR_GENERAL));
24
e88b15cbf2de [/trunk] Changeset 40 by mikael
mikael
parents:
diff changeset
402 tmp->panel = new_panel(tmp->win);
657
056dc9e65c25 Some memory allocation code cleaning
Mikael Berthe <mikael@lilotux.net>
parents: 654
diff changeset
403 tmp->name = g_strdup(title);
24
e88b15cbf2de [/trunk] Changeset 40 by mikael
mikael
parents:
diff changeset
404
143
300bb88f631f [/trunk] Changeset 155 by mikael
mikael
parents: 142
diff changeset
405 if (!dont_show) {
24
e88b15cbf2de [/trunk] Changeset 40 by mikael
mikael
parents:
diff changeset
406 currentWindow = tmp;
e88b15cbf2de [/trunk] Changeset 40 by mikael
mikael
parents:
diff changeset
407 } else {
e88b15cbf2de [/trunk] Changeset 40 by mikael
mikael
parents:
diff changeset
408 if (currentWindow)
e88b15cbf2de [/trunk] Changeset 40 by mikael
mikael
parents:
diff changeset
409 top_panel(currentWindow->panel);
e88b15cbf2de [/trunk] Changeset 40 by mikael
mikael
parents:
diff changeset
410 else
e88b15cbf2de [/trunk] Changeset 40 by mikael
mikael
parents:
diff changeset
411 top_panel(chatPanel);
e88b15cbf2de [/trunk] Changeset 40 by mikael
mikael
parents:
diff changeset
412 }
143
300bb88f631f [/trunk] Changeset 155 by mikael
mikael
parents: 142
diff changeset
413 update_panels();
24
e88b15cbf2de [/trunk] Changeset 40 by mikael
mikael
parents:
diff changeset
414
181
4a0bde661562 [/trunk] Changeset 193 by mikael
mikael
parents: 180
diff changeset
415 // Load buddy history from file (if enabled)
701
6c100adfbfb6 Add setting "roster_width" (variable buddylist width)
Mikael Berthe <mikael@lilotux.net>
parents: 699
diff changeset
416 hlog_read_history(title, &tmp->hbuf, maxX - Roster_Width - PREFIX_WIDTH);
181
4a0bde661562 [/trunk] Changeset 193 by mikael
mikael
parents: 180
diff changeset
417
24
e88b15cbf2de [/trunk] Changeset 40 by mikael
mikael
parents:
diff changeset
418 list_add_tail(&tmp->list, &window_list);
e88b15cbf2de [/trunk] Changeset 40 by mikael
mikael
parents:
diff changeset
419
e88b15cbf2de [/trunk] Changeset 40 by mikael
mikael
parents:
diff changeset
420 return tmp;
e88b15cbf2de [/trunk] Changeset 40 by mikael
mikael
parents:
diff changeset
421 }
e88b15cbf2de [/trunk] Changeset 40 by mikael
mikael
parents:
diff changeset
422
336
eb994ee40029 Make some functions static
Mikael Berthe <mikael@lilotux.net>
parents: 332
diff changeset
423 static window_entry_t *scr_SearchWindow(const char *winId)
24
e88b15cbf2de [/trunk] Changeset 40 by mikael
mikael
parents:
diff changeset
424 {
e88b15cbf2de [/trunk] Changeset 40 by mikael
mikael
parents:
diff changeset
425 struct list_head *pos, *n;
e88b15cbf2de [/trunk] Changeset 40 by mikael
mikael
parents:
diff changeset
426 window_entry_t *search_entry = NULL;
e88b15cbf2de [/trunk] Changeset 40 by mikael
mikael
parents:
diff changeset
427
361
51ff319947c3 Code cleanup/optimization
Mikael Berthe <mikael@lilotux.net>
parents: 358
diff changeset
428 if (!winId) return NULL;
51ff319947c3 Code cleanup/optimization
Mikael Berthe <mikael@lilotux.net>
parents: 358
diff changeset
429
24
e88b15cbf2de [/trunk] Changeset 40 by mikael
mikael
parents:
diff changeset
430 list_for_each_safe(pos, n, &window_list) {
e88b15cbf2de [/trunk] Changeset 40 by mikael
mikael
parents:
diff changeset
431 search_entry = window_entry(pos);
e88b15cbf2de [/trunk] Changeset 40 by mikael
mikael
parents:
diff changeset
432 if (search_entry->name) {
e88b15cbf2de [/trunk] Changeset 40 by mikael
mikael
parents:
diff changeset
433 if (!strcasecmp(search_entry->name, winId)) {
e88b15cbf2de [/trunk] Changeset 40 by mikael
mikael
parents:
diff changeset
434 return search_entry;
e88b15cbf2de [/trunk] Changeset 40 by mikael
mikael
parents:
diff changeset
435 }
e88b15cbf2de [/trunk] Changeset 40 by mikael
mikael
parents:
diff changeset
436 }
e88b15cbf2de [/trunk] Changeset 40 by mikael
mikael
parents:
diff changeset
437 }
e88b15cbf2de [/trunk] Changeset 40 by mikael
mikael
parents:
diff changeset
438 return NULL;
e88b15cbf2de [/trunk] Changeset 40 by mikael
mikael
parents:
diff changeset
439 }
e88b15cbf2de [/trunk] Changeset 40 by mikael
mikael
parents:
diff changeset
440
514
979eb0fe2969 Show status changes in buddy window, if it is open
Mikael Berthe <mikael@lilotux.net>
parents: 513
diff changeset
441 bool scr_BuddyBufferExists(const char *jid)
979eb0fe2969 Show status changes in buddy window, if it is open
Mikael Berthe <mikael@lilotux.net>
parents: 513
diff changeset
442 {
979eb0fe2969 Show status changes in buddy window, if it is open
Mikael Berthe <mikael@lilotux.net>
parents: 513
diff changeset
443 return (scr_SearchWindow(jid) != NULL);
979eb0fe2969 Show status changes in buddy window, if it is open
Mikael Berthe <mikael@lilotux.net>
parents: 513
diff changeset
444 }
979eb0fe2969 Show status changes in buddy window, if it is open
Mikael Berthe <mikael@lilotux.net>
parents: 513
diff changeset
445
143
300bb88f631f [/trunk] Changeset 155 by mikael
mikael
parents: 142
diff changeset
446 // scr_UpdateWindow()
300bb88f631f [/trunk] Changeset 155 by mikael
mikael
parents: 142
diff changeset
447 // (Re-)Display the given chat window.
336
eb994ee40029 Make some functions static
Mikael Berthe <mikael@lilotux.net>
parents: 332
diff changeset
448 static void scr_UpdateWindow(window_entry_t *win_entry)
74
b392112ab995 [/trunk] Changeset 88 by mikael
mikael
parents: 65
diff changeset
449 {
b392112ab995 [/trunk] Changeset 88 by mikael
mikael
parents: 65
diff changeset
450 int n;
b392112ab995 [/trunk] Changeset 88 by mikael
mikael
parents: 65
diff changeset
451 int width;
184
b5aa2b9c425a [/trunk] Changeset 196 by mikael
mikael
parents: 181
diff changeset
452 hbb_line **lines, *line;
74
b392112ab995 [/trunk] Changeset 88 by mikael
mikael
parents: 65
diff changeset
453 GList *hbuf_head;
184
b5aa2b9c425a [/trunk] Changeset 196 by mikael
mikael
parents: 181
diff changeset
454 char date[32];
74
b392112ab995 [/trunk] Changeset 88 by mikael
mikael
parents: 65
diff changeset
455
108
7fb72bc13732 [/trunk] Changeset 122 by mikael
mikael
parents: 105
diff changeset
456 width = scr_WindowWidth(win_entry->win);
7fb72bc13732 [/trunk] Changeset 122 by mikael
mikael
parents: 105
diff changeset
457
7fb72bc13732 [/trunk] Changeset 122 by mikael
mikael
parents: 105
diff changeset
458 // Should the window be empty?
7fb72bc13732 [/trunk] Changeset 122 by mikael
mikael
parents: 105
diff changeset
459 if (win_entry->cleared) {
168
6ad156673b19 [/trunk] Changeset 180 by mikael
mikael
parents: 167
diff changeset
460 werase(win_entry->win);
108
7fb72bc13732 [/trunk] Changeset 122 by mikael
mikael
parents: 105
diff changeset
461 return;
7fb72bc13732 [/trunk] Changeset 122 by mikael
mikael
parents: 105
diff changeset
462 }
7fb72bc13732 [/trunk] Changeset 122 by mikael
mikael
parents: 105
diff changeset
463
105
91d3ec21c24e [/trunk] Changeset 119 by mikael
mikael
parents: 104
diff changeset
464 // win_entry->top is the top message of the screen. If it set to NULL, we
91d3ec21c24e [/trunk] Changeset 119 by mikael
mikael
parents: 104
diff changeset
465 // are displaying the last messages.
91d3ec21c24e [/trunk] Changeset 119 by mikael
mikael
parents: 104
diff changeset
466
74
b392112ab995 [/trunk] Changeset 88 by mikael
mikael
parents: 65
diff changeset
467 // We will show the last CHAT_WIN_HEIGHT lines.
b392112ab995 [/trunk] Changeset 88 by mikael
mikael
parents: 65
diff changeset
468 // Let's find out where it begins.
105
91d3ec21c24e [/trunk] Changeset 119 by mikael
mikael
parents: 104
diff changeset
469 if (!win_entry->top ||
91d3ec21c24e [/trunk] Changeset 119 by mikael
mikael
parents: 104
diff changeset
470 (g_list_position(g_list_first(win_entry->hbuf), win_entry->top) == -1)) {
91d3ec21c24e [/trunk] Changeset 119 by mikael
mikael
parents: 104
diff changeset
471 // Move up CHAT_WIN_HEIGHT lines
91d3ec21c24e [/trunk] Changeset 119 by mikael
mikael
parents: 104
diff changeset
472 win_entry->hbuf = g_list_last(win_entry->hbuf);
91d3ec21c24e [/trunk] Changeset 119 by mikael
mikael
parents: 104
diff changeset
473 hbuf_head = win_entry->hbuf;
91d3ec21c24e [/trunk] Changeset 119 by mikael
mikael
parents: 104
diff changeset
474 win_entry->top = NULL; // (Just to make sure)
91d3ec21c24e [/trunk] Changeset 119 by mikael
mikael
parents: 104
diff changeset
475 n = 0;
91d3ec21c24e [/trunk] Changeset 119 by mikael
mikael
parents: 104
diff changeset
476 while (hbuf_head && (n < CHAT_WIN_HEIGHT-1) && g_list_previous(hbuf_head)) {
91d3ec21c24e [/trunk] Changeset 119 by mikael
mikael
parents: 104
diff changeset
477 hbuf_head = g_list_previous(hbuf_head);
91d3ec21c24e [/trunk] Changeset 119 by mikael
mikael
parents: 104
diff changeset
478 n++;
91d3ec21c24e [/trunk] Changeset 119 by mikael
mikael
parents: 104
diff changeset
479 }
91d3ec21c24e [/trunk] Changeset 119 by mikael
mikael
parents: 104
diff changeset
480 } else
91d3ec21c24e [/trunk] Changeset 119 by mikael
mikael
parents: 104
diff changeset
481 hbuf_head = win_entry->top;
74
b392112ab995 [/trunk] Changeset 88 by mikael
mikael
parents: 65
diff changeset
482
b392112ab995 [/trunk] Changeset 88 by mikael
mikael
parents: 65
diff changeset
483 // Get the last CHAT_WIN_HEIGHT lines.
b392112ab995 [/trunk] Changeset 88 by mikael
mikael
parents: 65
diff changeset
484 lines = hbuf_get_lines(hbuf_head, CHAT_WIN_HEIGHT);
b392112ab995 [/trunk] Changeset 88 by mikael
mikael
parents: 65
diff changeset
485
b392112ab995 [/trunk] Changeset 88 by mikael
mikael
parents: 65
diff changeset
486 // Display these lines
b392112ab995 [/trunk] Changeset 88 by mikael
mikael
parents: 65
diff changeset
487 for (n = 0; n < CHAT_WIN_HEIGHT; n++) {
168
6ad156673b19 [/trunk] Changeset 180 by mikael
mikael
parents: 167
diff changeset
488 wmove(win_entry->win, n, 0);
184
b5aa2b9c425a [/trunk] Changeset 196 by mikael
mikael
parents: 181
diff changeset
489 line = *(lines+n);
185
e8e447a07641 [/trunk] Changeset 197 by mikael
mikael
parents: 184
diff changeset
490 // NOTE: update PREFIX_WIDTH if you change the date format!!
e8e447a07641 [/trunk] Changeset 197 by mikael
mikael
parents: 184
diff changeset
491 // You need to set it to the whole prefix length + 1
184
b5aa2b9c425a [/trunk] Changeset 196 by mikael
mikael
parents: 181
diff changeset
492 if (line) {
730
e46c680bdd3d New color: color_highlight (for outgoing messages)
Mikael Berthe <mikael@lilotux.net>
parents: 729
diff changeset
493 if (line->flags & HBB_PREFIX_HLIGHT)
785
7e0562e3bc83 Replace color_highlight with color_msgout
Mikael Berthe <mikael@lilotux.net>
parents: 779
diff changeset
494 wattrset(win_entry->win, get_color(COLOR_MSGOUT));
730
e46c680bdd3d New color: color_highlight (for outgoing messages)
Mikael Berthe <mikael@lilotux.net>
parents: 729
diff changeset
495
184
b5aa2b9c425a [/trunk] Changeset 196 by mikael
mikael
parents: 181
diff changeset
496 if (line->timestamp) {
419
2f9852610cf4 Small code review
Mikael Berthe <mikael@lilotux.net>
parents: 412
diff changeset
497 strftime(date, 30, "%m-%d %H:%M", localtime(&line->timestamp));
184
b5aa2b9c425a [/trunk] Changeset 196 by mikael
mikael
parents: 181
diff changeset
498 } else
185
e8e447a07641 [/trunk] Changeset 197 by mikael
mikael
parents: 184
diff changeset
499 strcpy(date, " ");
197
c289e3c39c48 [/trunk] Changeset 209 by mikael
mikael
parents: 196
diff changeset
500 if (line->flags & HBB_PREFIX_INFO) {
c289e3c39c48 [/trunk] Changeset 209 by mikael
mikael
parents: 196
diff changeset
501 char dir = '*';
c289e3c39c48 [/trunk] Changeset 209 by mikael
mikael
parents: 196
diff changeset
502 if (line->flags & HBB_PREFIX_IN)
c289e3c39c48 [/trunk] Changeset 209 by mikael
mikael
parents: 196
diff changeset
503 dir = '<';
c289e3c39c48 [/trunk] Changeset 209 by mikael
mikael
parents: 196
diff changeset
504 else if (line->flags & HBB_PREFIX_OUT)
c289e3c39c48 [/trunk] Changeset 209 by mikael
mikael
parents: 196
diff changeset
505 dir = '>';
c289e3c39c48 [/trunk] Changeset 209 by mikael
mikael
parents: 196
diff changeset
506 wprintw(win_entry->win, "%.11s *%c* ", date, dir);
325
ff6fb51bfd78 Handle "error" message type
Mikael Berthe <mikael@lilotux.net>
parents: 322
diff changeset
507 } else if (line->flags & HBB_PREFIX_ERR) {
ff6fb51bfd78 Handle "error" message type
Mikael Berthe <mikael@lilotux.net>
parents: 322
diff changeset
508 char dir = '#';
ff6fb51bfd78 Handle "error" message type
Mikael Berthe <mikael@lilotux.net>
parents: 322
diff changeset
509 if (line->flags & HBB_PREFIX_IN)
ff6fb51bfd78 Handle "error" message type
Mikael Berthe <mikael@lilotux.net>
parents: 322
diff changeset
510 dir = '<';
ff6fb51bfd78 Handle "error" message type
Mikael Berthe <mikael@lilotux.net>
parents: 322
diff changeset
511 else if (line->flags & HBB_PREFIX_OUT)
ff6fb51bfd78 Handle "error" message type
Mikael Berthe <mikael@lilotux.net>
parents: 322
diff changeset
512 dir = '>';
ff6fb51bfd78 Handle "error" message type
Mikael Berthe <mikael@lilotux.net>
parents: 322
diff changeset
513 wprintw(win_entry->win, "%.11s #%c# ", date, dir);
728
421b337dc6d2 Chat window: Highlight the flag in our messages
Mikael Berthe <mikael@lilotux.net>
parents: 727
diff changeset
514 } else if (line->flags & HBB_PREFIX_IN) {
729
39f67cade02c Use bold font for outgoing messages
Mikael Berthe <mikael@lilotux.net>
parents: 728
diff changeset
515 wprintw(win_entry->win, "%.11s <== ", date);
728
421b337dc6d2 Chat window: Highlight the flag in our messages
Mikael Berthe <mikael@lilotux.net>
parents: 727
diff changeset
516 } else if (line->flags & HBB_PREFIX_OUT) {
729
39f67cade02c Use bold font for outgoing messages
Mikael Berthe <mikael@lilotux.net>
parents: 728
diff changeset
517 wprintw(win_entry->win, "%.11s --> ", date);
728
421b337dc6d2 Chat window: Highlight the flag in our messages
Mikael Berthe <mikael@lilotux.net>
parents: 727
diff changeset
518 } else {
185
e8e447a07641 [/trunk] Changeset 197 by mikael
mikael
parents: 184
diff changeset
519 wprintw(win_entry->win, "%.11s ", date);
75
ff119bb11563 [/trunk] Changeset 89 by mikael
mikael
parents: 74
diff changeset
520 }
729
39f67cade02c Use bold font for outgoing messages
Mikael Berthe <mikael@lilotux.net>
parents: 728
diff changeset
521
730
e46c680bdd3d New color: color_highlight (for outgoing messages)
Mikael Berthe <mikael@lilotux.net>
parents: 729
diff changeset
522 wprintw(win_entry->win, "%s", line->text); // Display text line
729
39f67cade02c Use bold font for outgoing messages
Mikael Berthe <mikael@lilotux.net>
parents: 728
diff changeset
523
730
e46c680bdd3d New color: color_highlight (for outgoing messages)
Mikael Berthe <mikael@lilotux.net>
parents: 729
diff changeset
524 if (line->flags & HBB_PREFIX_HLIGHT)
739
0d5fb1d9077c Allow "bright" text colors
Mikael Berthe <mikael@lilotux.net>
parents: 735
diff changeset
525 wattrset(win_entry->win, get_color(COLOR_GENERAL));
168
6ad156673b19 [/trunk] Changeset 180 by mikael
mikael
parents: 167
diff changeset
526 wclrtoeol(win_entry->win);
184
b5aa2b9c425a [/trunk] Changeset 196 by mikael
mikael
parents: 181
diff changeset
527 g_free(line->text);
168
6ad156673b19 [/trunk] Changeset 180 by mikael
mikael
parents: 167
diff changeset
528 } else {
6ad156673b19 [/trunk] Changeset 180 by mikael
mikael
parents: 167
diff changeset
529 wclrtobot(win_entry->win);
6ad156673b19 [/trunk] Changeset 180 by mikael
mikael
parents: 167
diff changeset
530 break;
75
ff119bb11563 [/trunk] Changeset 89 by mikael
mikael
parents: 74
diff changeset
531 }
74
b392112ab995 [/trunk] Changeset 88 by mikael
mikael
parents: 65
diff changeset
532 }
b392112ab995 [/trunk] Changeset 88 by mikael
mikael
parents: 65
diff changeset
533 g_free(lines);
b392112ab995 [/trunk] Changeset 88 by mikael
mikael
parents: 65
diff changeset
534 }
b392112ab995 [/trunk] Changeset 88 by mikael
mikael
parents: 65
diff changeset
535
143
300bb88f631f [/trunk] Changeset 155 by mikael
mikael
parents: 142
diff changeset
536 // scr_ShowWindow()
300bb88f631f [/trunk] Changeset 155 by mikael
mikael
parents: 142
diff changeset
537 // Display the chat window with the given identifier.
336
eb994ee40029 Make some functions static
Mikael Berthe <mikael@lilotux.net>
parents: 332
diff changeset
538 static void scr_ShowWindow(const char *winId)
24
e88b15cbf2de [/trunk] Changeset 40 by mikael
mikael
parents:
diff changeset
539 {
74
b392112ab995 [/trunk] Changeset 88 by mikael
mikael
parents: 65
diff changeset
540 window_entry_t *win_entry = scr_SearchWindow(winId);
b392112ab995 [/trunk] Changeset 88 by mikael
mikael
parents: 65
diff changeset
541
181
4a0bde661562 [/trunk] Changeset 193 by mikael
mikael
parents: 180
diff changeset
542 if (!win_entry)
180
42a33611233b [/trunk] Changeset 192 by mikael
mikael
parents: 178
diff changeset
543 win_entry = scr_CreateBuddyPanel(winId, FALSE);
74
b392112ab995 [/trunk] Changeset 88 by mikael
mikael
parents: 65
diff changeset
544
180
42a33611233b [/trunk] Changeset 192 by mikael
mikael
parents: 178
diff changeset
545 top_panel(win_entry->panel);
42a33611233b [/trunk] Changeset 192 by mikael
mikael
parents: 178
diff changeset
546 currentWindow = win_entry;
42a33611233b [/trunk] Changeset 192 by mikael
mikael
parents: 178
diff changeset
547 chatmode = TRUE;
42a33611233b [/trunk] Changeset 192 by mikael
mikael
parents: 178
diff changeset
548 roster_msg_setflag(winId, FALSE);
42a33611233b [/trunk] Changeset 192 by mikael
mikael
parents: 178
diff changeset
549 roster_setflags(winId, ROSTER_FLAG_LOCK, TRUE);
42a33611233b [/trunk] Changeset 192 by mikael
mikael
parents: 178
diff changeset
550 update_roster = TRUE;
74
b392112ab995 [/trunk] Changeset 88 by mikael
mikael
parents: 65
diff changeset
551
180
42a33611233b [/trunk] Changeset 192 by mikael
mikael
parents: 178
diff changeset
552 // Refresh the window
42a33611233b [/trunk] Changeset 192 by mikael
mikael
parents: 178
diff changeset
553 scr_UpdateWindow(win_entry);
42a33611233b [/trunk] Changeset 192 by mikael
mikael
parents: 178
diff changeset
554
42a33611233b [/trunk] Changeset 192 by mikael
mikael
parents: 178
diff changeset
555 // Finished :)
42a33611233b [/trunk] Changeset 192 by mikael
mikael
parents: 178
diff changeset
556 update_panels();
142
bb6fe91589b9 [/trunk] Changeset 154 by mikael
mikael
parents: 140
diff changeset
557
bb6fe91589b9 [/trunk] Changeset 154 by mikael
mikael
parents: 140
diff changeset
558 top_panel(inputPanel);
24
e88b15cbf2de [/trunk] Changeset 40 by mikael
mikael
parents:
diff changeset
559 }
e88b15cbf2de [/trunk] Changeset 40 by mikael
mikael
parents:
diff changeset
560
143
300bb88f631f [/trunk] Changeset 155 by mikael
mikael
parents: 142
diff changeset
561 // scr_ShowBuddyWindow()
300bb88f631f [/trunk] Changeset 155 by mikael
mikael
parents: 142
diff changeset
562 // Display the chat window buffer for the current buddy.
24
e88b15cbf2de [/trunk] Changeset 40 by mikael
mikael
parents:
diff changeset
563 void scr_ShowBuddyWindow(void)
e88b15cbf2de [/trunk] Changeset 40 by mikael
mikael
parents:
diff changeset
564 {
105
91d3ec21c24e [/trunk] Changeset 119 by mikael
mikael
parents: 104
diff changeset
565 const gchar *jid;
140
3b480b73df19 [/trunk] Changeset 152 by mikael
mikael
parents: 139
diff changeset
566
105
91d3ec21c24e [/trunk] Changeset 119 by mikael
mikael
parents: 104
diff changeset
567 if (!current_buddy)
140
3b480b73df19 [/trunk] Changeset 152 by mikael
mikael
parents: 139
diff changeset
568 jid = NULL;
3b480b73df19 [/trunk] Changeset 152 by mikael
mikael
parents: 139
diff changeset
569 else
3b480b73df19 [/trunk] Changeset 152 by mikael
mikael
parents: 139
diff changeset
570 jid = CURRENT_JID;
3b480b73df19 [/trunk] Changeset 152 by mikael
mikael
parents: 139
diff changeset
571
3b480b73df19 [/trunk] Changeset 152 by mikael
mikael
parents: 139
diff changeset
572 if (!jid) {
3b480b73df19 [/trunk] Changeset 152 by mikael
mikael
parents: 139
diff changeset
573 top_panel(chatPanel);
143
300bb88f631f [/trunk] Changeset 155 by mikael
mikael
parents: 142
diff changeset
574 top_panel(inputPanel);
140
3b480b73df19 [/trunk] Changeset 152 by mikael
mikael
parents: 139
diff changeset
575 currentWindow = NULL;
105
91d3ec21c24e [/trunk] Changeset 119 by mikael
mikael
parents: 104
diff changeset
576 return;
140
3b480b73df19 [/trunk] Changeset 152 by mikael
mikael
parents: 139
diff changeset
577 }
3b480b73df19 [/trunk] Changeset 152 by mikael
mikael
parents: 139
diff changeset
578
105
91d3ec21c24e [/trunk] Changeset 119 by mikael
mikael
parents: 104
diff changeset
579 scr_ShowWindow(jid);
24
e88b15cbf2de [/trunk] Changeset 40 by mikael
mikael
parents:
diff changeset
580 }
e88b15cbf2de [/trunk] Changeset 40 by mikael
mikael
parents:
diff changeset
581
143
300bb88f631f [/trunk] Changeset 155 by mikael
mikael
parents: 142
diff changeset
582 // scr_WriteInWindow()
300bb88f631f [/trunk] Changeset 155 by mikael
mikael
parents: 142
diff changeset
583 // Write some text in the winId window (this usually is a jid).
300bb88f631f [/trunk] Changeset 155 by mikael
mikael
parents: 142
diff changeset
584 // Lines are splitted when they are too long to fit in the chat window.
300bb88f631f [/trunk] Changeset 155 by mikael
mikael
parents: 142
diff changeset
585 // If this window doesn't exist, it is created.
184
b5aa2b9c425a [/trunk] Changeset 196 by mikael
mikael
parents: 181
diff changeset
586 void scr_WriteInWindow(const char *winId, const char *text, time_t timestamp,
b5aa2b9c425a [/trunk] Changeset 196 by mikael
mikael
parents: 181
diff changeset
587 unsigned int prefix_flags, int force_show)
24
e88b15cbf2de [/trunk] Changeset 40 by mikael
mikael
parents:
diff changeset
588 {
74
b392112ab995 [/trunk] Changeset 88 by mikael
mikael
parents: 65
diff changeset
589 window_entry_t *win_entry;
772
464be13343a9 Store most data in UTF-8 internally
Mikael Berthe <mikael@lilotux.net>
parents: 771
diff changeset
590 char *text_locale;
24
e88b15cbf2de [/trunk] Changeset 40 by mikael
mikael
parents:
diff changeset
591 int dont_show = FALSE;
e88b15cbf2de [/trunk] Changeset 40 by mikael
mikael
parents:
diff changeset
592
74
b392112ab995 [/trunk] Changeset 88 by mikael
mikael
parents: 65
diff changeset
593 // Look for the window entry.
b392112ab995 [/trunk] Changeset 88 by mikael
mikael
parents: 65
diff changeset
594 win_entry = scr_SearchWindow(winId);
b392112ab995 [/trunk] Changeset 88 by mikael
mikael
parents: 65
diff changeset
595
b392112ab995 [/trunk] Changeset 88 by mikael
mikael
parents: 65
diff changeset
596 // Do we have to really show the window?
24
e88b15cbf2de [/trunk] Changeset 40 by mikael
mikael
parents:
diff changeset
597 if (!chatmode)
e88b15cbf2de [/trunk] Changeset 40 by mikael
mikael
parents:
diff changeset
598 dont_show = TRUE;
74
b392112ab995 [/trunk] Changeset 88 by mikael
mikael
parents: 65
diff changeset
599 else if ((!force_show) && ((!currentWindow || (currentWindow != win_entry))))
24
e88b15cbf2de [/trunk] Changeset 40 by mikael
mikael
parents:
diff changeset
600 dont_show = TRUE;
e88b15cbf2de [/trunk] Changeset 40 by mikael
mikael
parents:
diff changeset
601
74
b392112ab995 [/trunk] Changeset 88 by mikael
mikael
parents: 65
diff changeset
602 // If the window entry doesn't exist yet, let's create it.
b392112ab995 [/trunk] Changeset 88 by mikael
mikael
parents: 65
diff changeset
603 if (win_entry == NULL) {
151
b69c0b7a23e3 [/trunk] Changeset 163 by mikael
mikael
parents: 149
diff changeset
604 win_entry = scr_CreateBuddyPanel(winId, dont_show);
24
e88b15cbf2de [/trunk] Changeset 40 by mikael
mikael
parents:
diff changeset
605 }
e88b15cbf2de [/trunk] Changeset 40 by mikael
mikael
parents:
diff changeset
606
220
8dfdc6f1778e [/trunk] Changeset 232 by mikael
mikael
parents: 197
diff changeset
607 // The message must be displayed -> update top pointer
8dfdc6f1778e [/trunk] Changeset 232 by mikael
mikael
parents: 197
diff changeset
608 if (win_entry->cleared)
8dfdc6f1778e [/trunk] Changeset 232 by mikael
mikael
parents: 197
diff changeset
609 win_entry->top = g_list_last(win_entry->hbuf);
8dfdc6f1778e [/trunk] Changeset 232 by mikael
mikael
parents: 197
diff changeset
610
772
464be13343a9 Store most data in UTF-8 internally
Mikael Berthe <mikael@lilotux.net>
parents: 771
diff changeset
611 text_locale = from_utf8(text);
464be13343a9 Store most data in UTF-8 internally
Mikael Berthe <mikael@lilotux.net>
parents: 771
diff changeset
612 hbuf_add_line(&win_entry->hbuf, text_locale, timestamp, prefix_flags,
701
6c100adfbfb6 Add setting "roster_width" (variable buddylist width)
Mikael Berthe <mikael@lilotux.net>
parents: 699
diff changeset
613 maxX - Roster_Width - PREFIX_WIDTH);
772
464be13343a9 Store most data in UTF-8 internally
Mikael Berthe <mikael@lilotux.net>
parents: 771
diff changeset
614 g_free(text_locale);
74
b392112ab995 [/trunk] Changeset 88 by mikael
mikael
parents: 65
diff changeset
615
108
7fb72bc13732 [/trunk] Changeset 122 by mikael
mikael
parents: 105
diff changeset
616 if (win_entry->cleared) {
220
8dfdc6f1778e [/trunk] Changeset 232 by mikael
mikael
parents: 197
diff changeset
617 win_entry->cleared = FALSE;
8dfdc6f1778e [/trunk] Changeset 232 by mikael
mikael
parents: 197
diff changeset
618 if (g_list_next(win_entry->top))
8dfdc6f1778e [/trunk] Changeset 232 by mikael
mikael
parents: 197
diff changeset
619 win_entry->top = g_list_next(win_entry->top);
8dfdc6f1778e [/trunk] Changeset 232 by mikael
mikael
parents: 197
diff changeset
620 }
8dfdc6f1778e [/trunk] Changeset 232 by mikael
mikael
parents: 197
diff changeset
621
8dfdc6f1778e [/trunk] Changeset 232 by mikael
mikael
parents: 197
diff changeset
622 // Make sure the last line appears in the window; update top if necessary
8dfdc6f1778e [/trunk] Changeset 232 by mikael
mikael
parents: 197
diff changeset
623 if (win_entry->top) {
8dfdc6f1778e [/trunk] Changeset 232 by mikael
mikael
parents: 197
diff changeset
624 int dist;
8dfdc6f1778e [/trunk] Changeset 232 by mikael
mikael
parents: 197
diff changeset
625 GList *first = g_list_first(win_entry->hbuf);
8dfdc6f1778e [/trunk] Changeset 232 by mikael
mikael
parents: 197
diff changeset
626 dist = g_list_position(first, g_list_last(win_entry->hbuf)) -
8dfdc6f1778e [/trunk] Changeset 232 by mikael
mikael
parents: 197
diff changeset
627 g_list_position(first, win_entry->top);
8dfdc6f1778e [/trunk] Changeset 232 by mikael
mikael
parents: 197
diff changeset
628 if (dist >= CHAT_WIN_HEIGHT)
8dfdc6f1778e [/trunk] Changeset 232 by mikael
mikael
parents: 197
diff changeset
629 win_entry->top = NULL;
108
7fb72bc13732 [/trunk] Changeset 122 by mikael
mikael
parents: 105
diff changeset
630 }
7fb72bc13732 [/trunk] Changeset 122 by mikael
mikael
parents: 105
diff changeset
631
24
e88b15cbf2de [/trunk] Changeset 40 by mikael
mikael
parents:
diff changeset
632 if (!dont_show) {
74
b392112ab995 [/trunk] Changeset 88 by mikael
mikael
parents: 65
diff changeset
633 // Show and refresh the window
b392112ab995 [/trunk] Changeset 88 by mikael
mikael
parents: 65
diff changeset
634 top_panel(win_entry->panel);
b392112ab995 [/trunk] Changeset 88 by mikael
mikael
parents: 65
diff changeset
635 scr_UpdateWindow(win_entry);
142
bb6fe91589b9 [/trunk] Changeset 154 by mikael
mikael
parents: 140
diff changeset
636 top_panel(inputPanel);
24
e88b15cbf2de [/trunk] Changeset 40 by mikael
mikael
parents:
diff changeset
637 update_panels();
e88b15cbf2de [/trunk] Changeset 40 by mikael
mikael
parents:
diff changeset
638 doupdate();
513
d40c434fff46 Add HBB_PREFIX_NOFLAG
Mikael Berthe <mikael@lilotux.net>
parents: 512
diff changeset
639 } else if (!(prefix_flags & HBB_PREFIX_NOFLAG)) {
148
c3624b2a7059 [/trunk] Changeset 160 by mikael
mikael
parents: 143
diff changeset
640 roster_msg_setflag(winId, TRUE);
30
4ea2df449381 [/trunk] Changeset 46 by mikael
mikael
parents: 29
diff changeset
641 update_roster = TRUE;
24
e88b15cbf2de [/trunk] Changeset 40 by mikael
mikael
parents:
diff changeset
642 }
e88b15cbf2de [/trunk] Changeset 40 by mikael
mikael
parents:
diff changeset
643 }
e88b15cbf2de [/trunk] Changeset 40 by mikael
mikael
parents:
diff changeset
644
713
b5aa7b7afee8 Update status lines
Mikael Berthe <mikael@lilotux.net>
parents: 712
diff changeset
645 // scr_UpdateMainStatus()
b5aa7b7afee8 Update status lines
Mikael Berthe <mikael@lilotux.net>
parents: 712
diff changeset
646 // Redraw the main (bottom) status line.
724
264375fe7159 Fix a roster refresh issue
Mikael Berthe <mikael@lilotux.net>
parents: 723
diff changeset
647 void scr_UpdateMainStatus(int forceupdate)
713
b5aa7b7afee8 Update status lines
Mikael Berthe <mikael@lilotux.net>
parents: 712
diff changeset
648 {
773
e25b8a348ebd Screen updating functions use UTF-8
Mikael Berthe <mikael@lilotux.net>
parents: 772
diff changeset
649 char *sm = from_utf8(jb_getstatusmsg());
713
b5aa7b7afee8 Update status lines
Mikael Berthe <mikael@lilotux.net>
parents: 712
diff changeset
650
b5aa7b7afee8 Update status lines
Mikael Berthe <mikael@lilotux.net>
parents: 712
diff changeset
651 werase(mainstatusWnd);
724
264375fe7159 Fix a roster refresh issue
Mikael Berthe <mikael@lilotux.net>
parents: 723
diff changeset
652 mvwprintw(mainstatusWnd, 0, 0, "%c[%c] %s",
718
b41799901abd Add a new_message flag (#) in the main status line
Mikael Berthe <mikael@lilotux.net>
parents: 717
diff changeset
653 (unread_msg(NULL) ? '#' : ' '),
b41799901abd Add a new_message flag (#) in the main status line
Mikael Berthe <mikael@lilotux.net>
parents: 717
diff changeset
654 imstatus2char[jb_getstatus()], (sm ? sm : ""));
724
264375fe7159 Fix a roster refresh issue
Mikael Berthe <mikael@lilotux.net>
parents: 723
diff changeset
655 if (forceupdate) {
264375fe7159 Fix a roster refresh issue
Mikael Berthe <mikael@lilotux.net>
parents: 723
diff changeset
656 top_panel(inputPanel);
264375fe7159 Fix a roster refresh issue
Mikael Berthe <mikael@lilotux.net>
parents: 723
diff changeset
657 update_panels();
264375fe7159 Fix a roster refresh issue
Mikael Berthe <mikael@lilotux.net>
parents: 723
diff changeset
658 doupdate();
264375fe7159 Fix a roster refresh issue
Mikael Berthe <mikael@lilotux.net>
parents: 723
diff changeset
659 }
773
e25b8a348ebd Screen updating functions use UTF-8
Mikael Berthe <mikael@lilotux.net>
parents: 772
diff changeset
660 g_free(sm);
713
b5aa7b7afee8 Update status lines
Mikael Berthe <mikael@lilotux.net>
parents: 712
diff changeset
661 }
b5aa7b7afee8 Update status lines
Mikael Berthe <mikael@lilotux.net>
parents: 712
diff changeset
662
151
b69c0b7a23e3 [/trunk] Changeset 163 by mikael
mikael
parents: 149
diff changeset
663 // scr_DrawMainWindow()
157
409ff07d9fe2 [/trunk] Changeset 169 by mikael
mikael
parents: 154
diff changeset
664 // Set fullinit to TRUE to also create panels. Set it to FALSE for a resize.
151
b69c0b7a23e3 [/trunk] Changeset 163 by mikael
mikael
parents: 149
diff changeset
665 //
b69c0b7a23e3 [/trunk] Changeset 163 by mikael
mikael
parents: 149
diff changeset
666 // I think it could be improved a _lot_ but I'm really not an ncurses
b69c0b7a23e3 [/trunk] Changeset 163 by mikael
mikael
parents: 149
diff changeset
667 // expert... :-\ Mikael.
b69c0b7a23e3 [/trunk] Changeset 163 by mikael
mikael
parents: 149
diff changeset
668 //
b69c0b7a23e3 [/trunk] Changeset 163 by mikael
mikael
parents: 149
diff changeset
669 void scr_DrawMainWindow(unsigned int fullinit)
24
e88b15cbf2de [/trunk] Changeset 40 by mikael
mikael
parents:
diff changeset
670 {
701
6c100adfbfb6 Add setting "roster_width" (variable buddylist width)
Mikael Berthe <mikael@lilotux.net>
parents: 699
diff changeset
671 int requested_size;
518
9480a76471b6 Update Log_Win_Height when refreshing the screen
Mikael Berthe <mikael@lilotux.net>
parents: 515
diff changeset
672
9480a76471b6 Update Log_Win_Height when refreshing the screen
Mikael Berthe <mikael@lilotux.net>
parents: 515
diff changeset
673 Log_Win_Height = DEFAULT_LOG_WIN_HEIGHT;
701
6c100adfbfb6 Add setting "roster_width" (variable buddylist width)
Mikael Berthe <mikael@lilotux.net>
parents: 699
diff changeset
674 requested_size = settings_opt_get_int("log_win_height");
6c100adfbfb6 Add setting "roster_width" (variable buddylist width)
Mikael Berthe <mikael@lilotux.net>
parents: 699
diff changeset
675 if (requested_size > 0) {
6c100adfbfb6 Add setting "roster_width" (variable buddylist width)
Mikael Berthe <mikael@lilotux.net>
parents: 699
diff changeset
676 if (maxY > requested_size + 3)
6c100adfbfb6 Add setting "roster_width" (variable buddylist width)
Mikael Berthe <mikael@lilotux.net>
parents: 699
diff changeset
677 Log_Win_Height = requested_size + 2;
518
9480a76471b6 Update Log_Win_Height when refreshing the screen
Mikael Berthe <mikael@lilotux.net>
parents: 515
diff changeset
678 else
9480a76471b6 Update Log_Win_Height when refreshing the screen
Mikael Berthe <mikael@lilotux.net>
parents: 515
diff changeset
679 Log_Win_Height = ((maxY > 5) ? (maxY - 2) : 3);
701
6c100adfbfb6 Add setting "roster_width" (variable buddylist width)
Mikael Berthe <mikael@lilotux.net>
parents: 699
diff changeset
680 } else if (requested_size < 0) {
518
9480a76471b6 Update Log_Win_Height when refreshing the screen
Mikael Berthe <mikael@lilotux.net>
parents: 515
diff changeset
681 Log_Win_Height = 3;
9480a76471b6 Update Log_Win_Height when refreshing the screen
Mikael Berthe <mikael@lilotux.net>
parents: 515
diff changeset
682 }
9480a76471b6 Update Log_Win_Height when refreshing the screen
Mikael Berthe <mikael@lilotux.net>
parents: 515
diff changeset
683
9480a76471b6 Update Log_Win_Height when refreshing the screen
Mikael Berthe <mikael@lilotux.net>
parents: 515
diff changeset
684 if (maxY < Log_Win_Height+2) {
9480a76471b6 Update Log_Win_Height when refreshing the screen
Mikael Berthe <mikael@lilotux.net>
parents: 515
diff changeset
685 if (maxY < 5) {
9480a76471b6 Update Log_Win_Height when refreshing the screen
Mikael Berthe <mikael@lilotux.net>
parents: 515
diff changeset
686 Log_Win_Height = 3;
9480a76471b6 Update Log_Win_Height when refreshing the screen
Mikael Berthe <mikael@lilotux.net>
parents: 515
diff changeset
687 maxY = Log_Win_Height+2;
9480a76471b6 Update Log_Win_Height when refreshing the screen
Mikael Berthe <mikael@lilotux.net>
parents: 515
diff changeset
688 } else {
9480a76471b6 Update Log_Win_Height when refreshing the screen
Mikael Berthe <mikael@lilotux.net>
parents: 515
diff changeset
689 Log_Win_Height = maxY - 2;
9480a76471b6 Update Log_Win_Height when refreshing the screen
Mikael Berthe <mikael@lilotux.net>
parents: 515
diff changeset
690 }
9480a76471b6 Update Log_Win_Height when refreshing the screen
Mikael Berthe <mikael@lilotux.net>
parents: 515
diff changeset
691 }
9480a76471b6 Update Log_Win_Height when refreshing the screen
Mikael Berthe <mikael@lilotux.net>
parents: 515
diff changeset
692
707
b26a0bde4cdb Add /roster hide|show|toggle
Mikael Berthe <mikael@lilotux.net>
parents: 701
diff changeset
693 if (roster_hidden) {
b26a0bde4cdb Add /roster hide|show|toggle
Mikael Berthe <mikael@lilotux.net>
parents: 701
diff changeset
694 Roster_Width = 0;
b26a0bde4cdb Add /roster hide|show|toggle
Mikael Berthe <mikael@lilotux.net>
parents: 701
diff changeset
695 } else {
b26a0bde4cdb Add /roster hide|show|toggle
Mikael Berthe <mikael@lilotux.net>
parents: 701
diff changeset
696 requested_size = settings_opt_get_int("roster_width");
b26a0bde4cdb Add /roster hide|show|toggle
Mikael Berthe <mikael@lilotux.net>
parents: 701
diff changeset
697 if (requested_size > 1)
b26a0bde4cdb Add /roster hide|show|toggle
Mikael Berthe <mikael@lilotux.net>
parents: 701
diff changeset
698 Roster_Width = requested_size;
b26a0bde4cdb Add /roster hide|show|toggle
Mikael Berthe <mikael@lilotux.net>
parents: 701
diff changeset
699 else if (requested_size == 1)
b26a0bde4cdb Add /roster hide|show|toggle
Mikael Berthe <mikael@lilotux.net>
parents: 701
diff changeset
700 Roster_Width = 2;
b26a0bde4cdb Add /roster hide|show|toggle
Mikael Berthe <mikael@lilotux.net>
parents: 701
diff changeset
701 else
b26a0bde4cdb Add /roster hide|show|toggle
Mikael Berthe <mikael@lilotux.net>
parents: 701
diff changeset
702 Roster_Width = DEFAULT_ROSTER_WIDTH;
b26a0bde4cdb Add /roster hide|show|toggle
Mikael Berthe <mikael@lilotux.net>
parents: 701
diff changeset
703 }
701
6c100adfbfb6 Add setting "roster_width" (variable buddylist width)
Mikael Berthe <mikael@lilotux.net>
parents: 699
diff changeset
704
157
409ff07d9fe2 [/trunk] Changeset 169 by mikael
mikael
parents: 154
diff changeset
705 if (fullinit) {
409ff07d9fe2 [/trunk] Changeset 169 by mikael
mikael
parents: 154
diff changeset
706 /* Create windows */
701
6c100adfbfb6 Add setting "roster_width" (variable buddylist width)
Mikael Berthe <mikael@lilotux.net>
parents: 699
diff changeset
707 rosterWnd = newwin(CHAT_WIN_HEIGHT, Roster_Width, 0, 0);
6c100adfbfb6 Add setting "roster_width" (variable buddylist width)
Mikael Berthe <mikael@lilotux.net>
parents: 699
diff changeset
708 chatWnd = newwin(CHAT_WIN_HEIGHT, maxX - Roster_Width, 0, Roster_Width);
711
75dde88f1884 Introduce status lines
Mikael Berthe <mikael@lilotux.net>
parents: 709
diff changeset
709 logWnd = newwin(Log_Win_Height-2, maxX, CHAT_WIN_HEIGHT+1, 0);
75dde88f1884 Introduce status lines
Mikael Berthe <mikael@lilotux.net>
parents: 709
diff changeset
710 chatstatusWnd = newwin(1, maxX, CHAT_WIN_HEIGHT, 0);
75dde88f1884 Introduce status lines
Mikael Berthe <mikael@lilotux.net>
parents: 709
diff changeset
711 mainstatusWnd = newwin(1, maxX, maxY-2, 0);
157
409ff07d9fe2 [/trunk] Changeset 169 by mikael
mikael
parents: 154
diff changeset
712 inputWnd = newwin(1, maxX, maxY-1, 0);
358
6e4e667c5571 Fix a segfault when starting mcabber in a really small terminal
Mikael Berthe <mikael@lilotux.net>
parents: 339
diff changeset
713 if (!rosterWnd || !chatWnd || !logWnd || !inputWnd) {
6e4e667c5571 Fix a segfault when starting mcabber in a really small terminal
Mikael Berthe <mikael@lilotux.net>
parents: 339
diff changeset
714 scr_TerminateCurses();
6e4e667c5571 Fix a segfault when starting mcabber in a really small terminal
Mikael Berthe <mikael@lilotux.net>
parents: 339
diff changeset
715 fprintf(stderr, "Cannot create windows!\n");
6e4e667c5571 Fix a segfault when starting mcabber in a really small terminal
Mikael Berthe <mikael@lilotux.net>
parents: 339
diff changeset
716 exit(EXIT_FAILURE);
6e4e667c5571 Fix a segfault when starting mcabber in a really small terminal
Mikael Berthe <mikael@lilotux.net>
parents: 339
diff changeset
717 }
739
0d5fb1d9077c Allow "bright" text colors
Mikael Berthe <mikael@lilotux.net>
parents: 735
diff changeset
718 wbkgd(rosterWnd, get_color(COLOR_GENERAL));
0d5fb1d9077c Allow "bright" text colors
Mikael Berthe <mikael@lilotux.net>
parents: 735
diff changeset
719 wbkgd(chatWnd, get_color(COLOR_GENERAL));
0d5fb1d9077c Allow "bright" text colors
Mikael Berthe <mikael@lilotux.net>
parents: 735
diff changeset
720 wbkgd(logWnd, get_color(COLOR_GENERAL));
0d5fb1d9077c Allow "bright" text colors
Mikael Berthe <mikael@lilotux.net>
parents: 735
diff changeset
721 wbkgd(chatstatusWnd, get_color(COLOR_STATUS));
0d5fb1d9077c Allow "bright" text colors
Mikael Berthe <mikael@lilotux.net>
parents: 735
diff changeset
722 wbkgd(mainstatusWnd, get_color(COLOR_STATUS));
157
409ff07d9fe2 [/trunk] Changeset 169 by mikael
mikael
parents: 154
diff changeset
723 } else {
701
6c100adfbfb6 Add setting "roster_width" (variable buddylist width)
Mikael Berthe <mikael@lilotux.net>
parents: 699
diff changeset
724 /* Resize/move windows */
6c100adfbfb6 Add setting "roster_width" (variable buddylist width)
Mikael Berthe <mikael@lilotux.net>
parents: 699
diff changeset
725 wresize(rosterWnd, CHAT_WIN_HEIGHT, Roster_Width);
6c100adfbfb6 Add setting "roster_width" (variable buddylist width)
Mikael Berthe <mikael@lilotux.net>
parents: 699
diff changeset
726 wresize(chatWnd, CHAT_WIN_HEIGHT, maxX - Roster_Width);
6c100adfbfb6 Add setting "roster_width" (variable buddylist width)
Mikael Berthe <mikael@lilotux.net>
parents: 699
diff changeset
727 mvwin(chatWnd, 0, Roster_Width);
157
409ff07d9fe2 [/trunk] Changeset 169 by mikael
mikael
parents: 154
diff changeset
728
711
75dde88f1884 Introduce status lines
Mikael Berthe <mikael@lilotux.net>
parents: 709
diff changeset
729 wresize(logWnd, Log_Win_Height-2, maxX);
75dde88f1884 Introduce status lines
Mikael Berthe <mikael@lilotux.net>
parents: 709
diff changeset
730 mvwin(logWnd, CHAT_WIN_HEIGHT+1, 0);
157
409ff07d9fe2 [/trunk] Changeset 169 by mikael
mikael
parents: 154
diff changeset
731
711
75dde88f1884 Introduce status lines
Mikael Berthe <mikael@lilotux.net>
parents: 709
diff changeset
732 // Resize & move chat status window
75dde88f1884 Introduce status lines
Mikael Berthe <mikael@lilotux.net>
parents: 709
diff changeset
733 wresize(chatstatusWnd, 1, maxX);
75dde88f1884 Introduce status lines
Mikael Berthe <mikael@lilotux.net>
parents: 709
diff changeset
734 mvwin(chatstatusWnd, CHAT_WIN_HEIGHT, 0);
75dde88f1884 Introduce status lines
Mikael Berthe <mikael@lilotux.net>
parents: 709
diff changeset
735 // Resize & move main status window
75dde88f1884 Introduce status lines
Mikael Berthe <mikael@lilotux.net>
parents: 709
diff changeset
736 wresize(mainstatusWnd, 1, maxX);
75dde88f1884 Introduce status lines
Mikael Berthe <mikael@lilotux.net>
parents: 709
diff changeset
737 mvwin(mainstatusWnd, maxY-2, 0);
75dde88f1884 Introduce status lines
Mikael Berthe <mikael@lilotux.net>
parents: 709
diff changeset
738 // Resize & move input line window
157
409ff07d9fe2 [/trunk] Changeset 169 by mikael
mikael
parents: 154
diff changeset
739 wresize(inputWnd, 1, maxX);
409ff07d9fe2 [/trunk] Changeset 169 by mikael
mikael
parents: 154
diff changeset
740 mvwin(inputWnd, maxY-1, 0);
168
6ad156673b19 [/trunk] Changeset 180 by mikael
mikael
parents: 167
diff changeset
741
6ad156673b19 [/trunk] Changeset 180 by mikael
mikael
parents: 167
diff changeset
742 werase(chatWnd);
157
409ff07d9fe2 [/trunk] Changeset 169 by mikael
mikael
parents: 154
diff changeset
743 }
151
b69c0b7a23e3 [/trunk] Changeset 163 by mikael
mikael
parents: 149
diff changeset
744
b69c0b7a23e3 [/trunk] Changeset 163 by mikael
mikael
parents: 149
diff changeset
745 /* Draw/init windows */
b69c0b7a23e3 [/trunk] Changeset 163 by mikael
mikael
parents: 149
diff changeset
746
679
5933a8036672 Remove "This is the status window" message
Mikael Berthe <mikael@lilotux.net>
parents: 675
diff changeset
747 mvwprintw(chatWnd, 0, 0, "Thanks for using mcabber.\n");
5933a8036672 Remove "This is the status window" message
Mikael Berthe <mikael@lilotux.net>
parents: 675
diff changeset
748 mvwprintw(chatWnd, 1, 0, "http://www.lilotux.net/~mikael/mcabber/");
24
e88b15cbf2de [/trunk] Changeset 40 by mikael
mikael
parents:
diff changeset
749
157
409ff07d9fe2 [/trunk] Changeset 169 by mikael
mikael
parents: 154
diff changeset
750 // Auto-scrolling in log window
74
b392112ab995 [/trunk] Changeset 88 by mikael
mikael
parents: 65
diff changeset
751 scrollok(logWnd, TRUE);
24
e88b15cbf2de [/trunk] Changeset 40 by mikael
mikael
parents:
diff changeset
752
e88b15cbf2de [/trunk] Changeset 40 by mikael
mikael
parents:
diff changeset
753
151
b69c0b7a23e3 [/trunk] Changeset 163 by mikael
mikael
parents: 149
diff changeset
754 if (fullinit) {
157
409ff07d9fe2 [/trunk] Changeset 169 by mikael
mikael
parents: 154
diff changeset
755 // Enable keypad (+ special keys)
409ff07d9fe2 [/trunk] Changeset 169 by mikael
mikael
parents: 154
diff changeset
756 keypad(inputWnd, TRUE);
382
4c6e8392e465 Use nodelay() instead of halfdelay()
Mikael Berthe <mikael@lilotux.net>
parents: 374
diff changeset
757 nodelay(inputWnd, TRUE);
157
409ff07d9fe2 [/trunk] Changeset 169 by mikael
mikael
parents: 154
diff changeset
758
151
b69c0b7a23e3 [/trunk] Changeset 163 by mikael
mikael
parents: 149
diff changeset
759 // Create panels
b69c0b7a23e3 [/trunk] Changeset 163 by mikael
mikael
parents: 149
diff changeset
760 rosterPanel = new_panel(rosterWnd);
b69c0b7a23e3 [/trunk] Changeset 163 by mikael
mikael
parents: 149
diff changeset
761 chatPanel = new_panel(chatWnd);
b69c0b7a23e3 [/trunk] Changeset 163 by mikael
mikael
parents: 149
diff changeset
762 logPanel = new_panel(logWnd);
711
75dde88f1884 Introduce status lines
Mikael Berthe <mikael@lilotux.net>
parents: 709
diff changeset
763 chatstatusPanel = new_panel(chatstatusWnd);
75dde88f1884 Introduce status lines
Mikael Berthe <mikael@lilotux.net>
parents: 709
diff changeset
764 mainstatusPanel = new_panel(mainstatusWnd);
151
b69c0b7a23e3 [/trunk] Changeset 163 by mikael
mikael
parents: 149
diff changeset
765 inputPanel = new_panel(inputWnd);
232
9a6ba4b38e63 [/trunk] Changeset 245 by mikael
mikael
parents: 220
diff changeset
766
9a6ba4b38e63 [/trunk] Changeset 245 by mikael
mikael
parents: 220
diff changeset
767 if (utf8_mode)
374
bd5638c21834 Improve logging system (traces)
Mikael Berthe <mikael@lilotux.net>
parents: 373
diff changeset
768 scr_LogPrint(LPRINT_NORMAL, "WARNING: UTF-8 not yet supported!");
157
409ff07d9fe2 [/trunk] Changeset 169 by mikael
mikael
parents: 154
diff changeset
769 } else {
409ff07d9fe2 [/trunk] Changeset 169 by mikael
mikael
parents: 154
diff changeset
770 // Update panels
409ff07d9fe2 [/trunk] Changeset 169 by mikael
mikael
parents: 154
diff changeset
771 replace_panel(rosterPanel, rosterWnd);
409ff07d9fe2 [/trunk] Changeset 169 by mikael
mikael
parents: 154
diff changeset
772 replace_panel(chatPanel, chatWnd);
409ff07d9fe2 [/trunk] Changeset 169 by mikael
mikael
parents: 154
diff changeset
773 replace_panel(logPanel, logWnd);
711
75dde88f1884 Introduce status lines
Mikael Berthe <mikael@lilotux.net>
parents: 709
diff changeset
774 replace_panel(chatstatusPanel, chatstatusWnd);
75dde88f1884 Introduce status lines
Mikael Berthe <mikael@lilotux.net>
parents: 709
diff changeset
775 replace_panel(mainstatusPanel, mainstatusWnd);
157
409ff07d9fe2 [/trunk] Changeset 169 by mikael
mikael
parents: 154
diff changeset
776 replace_panel(inputPanel, inputWnd);
151
b69c0b7a23e3 [/trunk] Changeset 163 by mikael
mikael
parents: 149
diff changeset
777 }
b69c0b7a23e3 [/trunk] Changeset 163 by mikael
mikael
parents: 149
diff changeset
778
b69c0b7a23e3 [/trunk] Changeset 163 by mikael
mikael
parents: 149
diff changeset
779 // We'll need to redraw the roster
149
9f74832eb4f8 [/trunk] Changeset 161 by mikael
mikael
parents: 148
diff changeset
780 update_roster = TRUE;
24
e88b15cbf2de [/trunk] Changeset 40 by mikael
mikael
parents:
diff changeset
781 return;
e88b15cbf2de [/trunk] Changeset 40 by mikael
mikael
parents:
diff changeset
782 }
e88b15cbf2de [/trunk] Changeset 40 by mikael
mikael
parents:
diff changeset
783
151
b69c0b7a23e3 [/trunk] Changeset 163 by mikael
mikael
parents: 149
diff changeset
784 // scr_Resize()
b69c0b7a23e3 [/trunk] Changeset 163 by mikael
mikael
parents: 149
diff changeset
785 // Function called when the window is resized.
157
409ff07d9fe2 [/trunk] Changeset 169 by mikael
mikael
parents: 154
diff changeset
786 // - Resize windows
151
b69c0b7a23e3 [/trunk] Changeset 163 by mikael
mikael
parents: 149
diff changeset
787 // - Rewrap lines in each buddy buffer
b69c0b7a23e3 [/trunk] Changeset 163 by mikael
mikael
parents: 149
diff changeset
788 void scr_Resize()
b69c0b7a23e3 [/trunk] Changeset 163 by mikael
mikael
parents: 149
diff changeset
789 {
b69c0b7a23e3 [/trunk] Changeset 163 by mikael
mikael
parents: 149
diff changeset
790 struct list_head *pos, *n;
b69c0b7a23e3 [/trunk] Changeset 163 by mikael
mikael
parents: 149
diff changeset
791 window_entry_t *search_entry;
b69c0b7a23e3 [/trunk] Changeset 163 by mikael
mikael
parents: 149
diff changeset
792 int x, y, lines, cols;
b69c0b7a23e3 [/trunk] Changeset 163 by mikael
mikael
parents: 149
diff changeset
793
b69c0b7a23e3 [/trunk] Changeset 163 by mikael
mikael
parents: 149
diff changeset
794 // First, update the global variables
b69c0b7a23e3 [/trunk] Changeset 163 by mikael
mikael
parents: 149
diff changeset
795 getmaxyx(stdscr, maxY, maxX);
518
9480a76471b6 Update Log_Win_Height when refreshing the screen
Mikael Berthe <mikael@lilotux.net>
parents: 515
diff changeset
796 // scr_DrawMainWindow() will take care of maxY and Log_Win_Height
9480a76471b6 Update Log_Win_Height when refreshing the screen
Mikael Berthe <mikael@lilotux.net>
parents: 515
diff changeset
797
151
b69c0b7a23e3 [/trunk] Changeset 163 by mikael
mikael
parents: 149
diff changeset
798 // Make sure the cursor stays inside the window
b69c0b7a23e3 [/trunk] Changeset 163 by mikael
mikael
parents: 149
diff changeset
799 check_offset(0);
b69c0b7a23e3 [/trunk] Changeset 163 by mikael
mikael
parents: 149
diff changeset
800
157
409ff07d9fe2 [/trunk] Changeset 169 by mikael
mikael
parents: 154
diff changeset
801 // Resize windows and update panels
151
b69c0b7a23e3 [/trunk] Changeset 163 by mikael
mikael
parents: 149
diff changeset
802 scr_DrawMainWindow(FALSE);
b69c0b7a23e3 [/trunk] Changeset 163 by mikael
mikael
parents: 149
diff changeset
803
b69c0b7a23e3 [/trunk] Changeset 163 by mikael
mikael
parents: 149
diff changeset
804 // Resize all buddy windows
701
6c100adfbfb6 Add setting "roster_width" (variable buddylist width)
Mikael Berthe <mikael@lilotux.net>
parents: 699
diff changeset
805 x = Roster_Width;
151
b69c0b7a23e3 [/trunk] Changeset 163 by mikael
mikael
parents: 149
diff changeset
806 y = 0;
b69c0b7a23e3 [/trunk] Changeset 163 by mikael
mikael
parents: 149
diff changeset
807 lines = CHAT_WIN_HEIGHT;
701
6c100adfbfb6 Add setting "roster_width" (variable buddylist width)
Mikael Berthe <mikael@lilotux.net>
parents: 699
diff changeset
808 cols = maxX - Roster_Width;
6c100adfbfb6 Add setting "roster_width" (variable buddylist width)
Mikael Berthe <mikael@lilotux.net>
parents: 699
diff changeset
809 if (cols < 1) cols = 1;
151
b69c0b7a23e3 [/trunk] Changeset 163 by mikael
mikael
parents: 149
diff changeset
810
b69c0b7a23e3 [/trunk] Changeset 163 by mikael
mikael
parents: 149
diff changeset
811 list_for_each_safe(pos, n, &window_list) {
b69c0b7a23e3 [/trunk] Changeset 163 by mikael
mikael
parents: 149
diff changeset
812 search_entry = window_entry(pos);
b69c0b7a23e3 [/trunk] Changeset 163 by mikael
mikael
parents: 149
diff changeset
813 if (search_entry->win) {
189
4f3975f1b852 [/trunk] Changeset 201 by mikael
mikael
parents: 187
diff changeset
814 GList *rescue_top;
701
6c100adfbfb6 Add setting "roster_width" (variable buddylist width)
Mikael Berthe <mikael@lilotux.net>
parents: 699
diff changeset
815 // Resize/move buddy window
157
409ff07d9fe2 [/trunk] Changeset 169 by mikael
mikael
parents: 154
diff changeset
816 wresize(search_entry->win, lines, cols);
701
6c100adfbfb6 Add setting "roster_width" (variable buddylist width)
Mikael Berthe <mikael@lilotux.net>
parents: 699
diff changeset
817 mvwin(search_entry->win, 0, Roster_Width);
168
6ad156673b19 [/trunk] Changeset 180 by mikael
mikael
parents: 167
diff changeset
818 werase(search_entry->win);
151
b69c0b7a23e3 [/trunk] Changeset 163 by mikael
mikael
parents: 149
diff changeset
819 // If a panel exists, replace the old window with the new
b69c0b7a23e3 [/trunk] Changeset 163 by mikael
mikael
parents: 149
diff changeset
820 if (search_entry->panel) {
b69c0b7a23e3 [/trunk] Changeset 163 by mikael
mikael
parents: 149
diff changeset
821 replace_panel(search_entry->panel, search_entry->win);
b69c0b7a23e3 [/trunk] Changeset 163 by mikael
mikael
parents: 149
diff changeset
822 }
b69c0b7a23e3 [/trunk] Changeset 163 by mikael
mikael
parents: 149
diff changeset
823 // Redo line wrapping
189
4f3975f1b852 [/trunk] Changeset 201 by mikael
mikael
parents: 187
diff changeset
824 rescue_top = hbuf_previous_persistent(search_entry->top);
151
b69c0b7a23e3 [/trunk] Changeset 163 by mikael
mikael
parents: 149
diff changeset
825 hbuf_rebuild(&search_entry->hbuf,
701
6c100adfbfb6 Add setting "roster_width" (variable buddylist width)
Mikael Berthe <mikael@lilotux.net>
parents: 699
diff changeset
826 maxX - Roster_Width - PREFIX_WIDTH);
388
f211238d5812 Ctrl-l does a full refresh
Mikael Berthe <mikael@lilotux.net>
parents: 384
diff changeset
827 if (g_list_position(g_list_first(search_entry->hbuf),
f211238d5812 Ctrl-l does a full refresh
Mikael Berthe <mikael@lilotux.net>
parents: 384
diff changeset
828 search_entry->top) == -1) {
189
4f3975f1b852 [/trunk] Changeset 201 by mikael
mikael
parents: 187
diff changeset
829 search_entry->top = rescue_top;
388
f211238d5812 Ctrl-l does a full refresh
Mikael Berthe <mikael@lilotux.net>
parents: 384
diff changeset
830 }
151
b69c0b7a23e3 [/trunk] Changeset 163 by mikael
mikael
parents: 149
diff changeset
831 }
b69c0b7a23e3 [/trunk] Changeset 163 by mikael
mikael
parents: 149
diff changeset
832 }
b69c0b7a23e3 [/trunk] Changeset 163 by mikael
mikael
parents: 149
diff changeset
833
b69c0b7a23e3 [/trunk] Changeset 163 by mikael
mikael
parents: 149
diff changeset
834 // Refresh current buddy window
157
409ff07d9fe2 [/trunk] Changeset 169 by mikael
mikael
parents: 154
diff changeset
835 if (chatmode)
151
b69c0b7a23e3 [/trunk] Changeset 163 by mikael
mikael
parents: 149
diff changeset
836 scr_ShowBuddyWindow();
b69c0b7a23e3 [/trunk] Changeset 163 by mikael
mikael
parents: 149
diff changeset
837 }
b69c0b7a23e3 [/trunk] Changeset 163 by mikael
mikael
parents: 149
diff changeset
838
721
9cf31c9b1dc4 Use room topic as a description in the chat status line
Mikael Berthe <mikael@lilotux.net>
parents: 720
diff changeset
839 // scr_UpdateChatStatus(forceupdate)
713
b5aa7b7afee8 Update status lines
Mikael Berthe <mikael@lilotux.net>
parents: 712
diff changeset
840 // Redraw the buddy status bar.
716
ba1137a01078 Add a chatmode flag (©) in the chat status line
Mikael Berthe <mikael@lilotux.net>
parents: 715
diff changeset
841 // Set forceupdate to TRUE if doupdate() must be called.
721
9cf31c9b1dc4 Use room topic as a description in the chat status line
Mikael Berthe <mikael@lilotux.net>
parents: 720
diff changeset
842 void scr_UpdateChatStatus(int forceupdate)
713
b5aa7b7afee8 Update status lines
Mikael Berthe <mikael@lilotux.net>
parents: 712
diff changeset
843 {
717
8ce2bfdc4143 Reindent update_chat_status_window()
Mikael Berthe <mikael@lilotux.net>
parents: 716
diff changeset
844 unsigned short btype, isgrp, ismuc;
8ce2bfdc4143 Reindent update_chat_status_window()
Mikael Berthe <mikael@lilotux.net>
parents: 716
diff changeset
845 const char *fullname;
8ce2bfdc4143 Reindent update_chat_status_window()
Mikael Berthe <mikael@lilotux.net>
parents: 716
diff changeset
846 const char *msg = NULL;
8ce2bfdc4143 Reindent update_chat_status_window()
Mikael Berthe <mikael@lilotux.net>
parents: 716
diff changeset
847 char status;
773
e25b8a348ebd Screen updating functions use UTF-8
Mikael Berthe <mikael@lilotux.net>
parents: 772
diff changeset
848 char *buf, *buf_locale;
713
b5aa7b7afee8 Update status lines
Mikael Berthe <mikael@lilotux.net>
parents: 712
diff changeset
849
718
b41799901abd Add a new_message flag (#) in the main status line
Mikael Berthe <mikael@lilotux.net>
parents: 717
diff changeset
850 // Usually we need to update the bottom status line too,
b41799901abd Add a new_message flag (#) in the main status line
Mikael Berthe <mikael@lilotux.net>
parents: 717
diff changeset
851 // at least to refresh the pending message flag.
724
264375fe7159 Fix a roster refresh issue
Mikael Berthe <mikael@lilotux.net>
parents: 723
diff changeset
852 scr_UpdateMainStatus(FALSE);
718
b41799901abd Add a new_message flag (#) in the main status line
Mikael Berthe <mikael@lilotux.net>
parents: 717
diff changeset
853
806
3521e34f722a Fix a segfault when not connected to a server
Mikael Berthe <mikael@lilotux.net>
parents: 797
diff changeset
854 // Clear the line
3521e34f722a Fix a segfault when not connected to a server
Mikael Berthe <mikael@lilotux.net>
parents: 797
diff changeset
855 werase(chatstatusWnd);
3521e34f722a Fix a segfault when not connected to a server
Mikael Berthe <mikael@lilotux.net>
parents: 797
diff changeset
856
3521e34f722a Fix a segfault when not connected to a server
Mikael Berthe <mikael@lilotux.net>
parents: 797
diff changeset
857 if (chatmode)
3521e34f722a Fix a segfault when not connected to a server
Mikael Berthe <mikael@lilotux.net>
parents: 797
diff changeset
858 wprintw(chatstatusWnd, "~");
3521e34f722a Fix a segfault when not connected to a server
Mikael Berthe <mikael@lilotux.net>
parents: 797
diff changeset
859
3521e34f722a Fix a segfault when not connected to a server
Mikael Berthe <mikael@lilotux.net>
parents: 797
diff changeset
860 if (!current_buddy) {
3521e34f722a Fix a segfault when not connected to a server
Mikael Berthe <mikael@lilotux.net>
parents: 797
diff changeset
861 if (forceupdate) {
3521e34f722a Fix a segfault when not connected to a server
Mikael Berthe <mikael@lilotux.net>
parents: 797
diff changeset
862 update_panels();
3521e34f722a Fix a segfault when not connected to a server
Mikael Berthe <mikael@lilotux.net>
parents: 797
diff changeset
863 doupdate();
3521e34f722a Fix a segfault when not connected to a server
Mikael Berthe <mikael@lilotux.net>
parents: 797
diff changeset
864 }
3521e34f722a Fix a segfault when not connected to a server
Mikael Berthe <mikael@lilotux.net>
parents: 797
diff changeset
865 return;
3521e34f722a Fix a segfault when not connected to a server
Mikael Berthe <mikael@lilotux.net>
parents: 797
diff changeset
866 }
3521e34f722a Fix a segfault when not connected to a server
Mikael Berthe <mikael@lilotux.net>
parents: 797
diff changeset
867
717
8ce2bfdc4143 Reindent update_chat_status_window()
Mikael Berthe <mikael@lilotux.net>
parents: 716
diff changeset
868 fullname = buddy_getname(BUDDATA(current_buddy));
8ce2bfdc4143 Reindent update_chat_status_window()
Mikael Berthe <mikael@lilotux.net>
parents: 716
diff changeset
869 btype = buddy_gettype(BUDDATA(current_buddy));
713
b5aa7b7afee8 Update status lines
Mikael Berthe <mikael@lilotux.net>
parents: 712
diff changeset
870
717
8ce2bfdc4143 Reindent update_chat_status_window()
Mikael Berthe <mikael@lilotux.net>
parents: 716
diff changeset
871 isgrp = btype & ROSTER_TYPE_GROUP;
8ce2bfdc4143 Reindent update_chat_status_window()
Mikael Berthe <mikael@lilotux.net>
parents: 716
diff changeset
872 ismuc = btype & ROSTER_TYPE_ROOM;
713
b5aa7b7afee8 Update status lines
Mikael Berthe <mikael@lilotux.net>
parents: 712
diff changeset
873
717
8ce2bfdc4143 Reindent update_chat_status_window()
Mikael Berthe <mikael@lilotux.net>
parents: 716
diff changeset
874 if (isgrp) {
773
e25b8a348ebd Screen updating functions use UTF-8
Mikael Berthe <mikael@lilotux.net>
parents: 772
diff changeset
875 buf_locale = from_utf8(fullname);
e25b8a348ebd Screen updating functions use UTF-8
Mikael Berthe <mikael@lilotux.net>
parents: 772
diff changeset
876 mvwprintw(chatstatusWnd, 0, 5, "Group: %s", buf_locale);
e25b8a348ebd Screen updating functions use UTF-8
Mikael Berthe <mikael@lilotux.net>
parents: 772
diff changeset
877 g_free(buf_locale);
716
ba1137a01078 Add a chatmode flag (©) in the chat status line
Mikael Berthe <mikael@lilotux.net>
parents: 715
diff changeset
878 if (forceupdate) {
ba1137a01078 Add a chatmode flag (©) in the chat status line
Mikael Berthe <mikael@lilotux.net>
parents: 715
diff changeset
879 update_panels();
ba1137a01078 Add a chatmode flag (©) in the chat status line
Mikael Berthe <mikael@lilotux.net>
parents: 715
diff changeset
880 doupdate();
ba1137a01078 Add a chatmode flag (©) in the chat status line
Mikael Berthe <mikael@lilotux.net>
parents: 715
diff changeset
881 }
717
8ce2bfdc4143 Reindent update_chat_status_window()
Mikael Berthe <mikael@lilotux.net>
parents: 716
diff changeset
882 return;
8ce2bfdc4143 Reindent update_chat_status_window()
Mikael Berthe <mikael@lilotux.net>
parents: 716
diff changeset
883 }
8ce2bfdc4143 Reindent update_chat_status_window()
Mikael Berthe <mikael@lilotux.net>
parents: 716
diff changeset
884
8ce2bfdc4143 Reindent update_chat_status_window()
Mikael Berthe <mikael@lilotux.net>
parents: 716
diff changeset
885 status = '?';
8ce2bfdc4143 Reindent update_chat_status_window()
Mikael Berthe <mikael@lilotux.net>
parents: 716
diff changeset
886
8ce2bfdc4143 Reindent update_chat_status_window()
Mikael Berthe <mikael@lilotux.net>
parents: 716
diff changeset
887 if (ismuc) {
8ce2bfdc4143 Reindent update_chat_status_window()
Mikael Berthe <mikael@lilotux.net>
parents: 716
diff changeset
888 if (buddy_getinsideroom(BUDDATA(current_buddy)))
8ce2bfdc4143 Reindent update_chat_status_window()
Mikael Berthe <mikael@lilotux.net>
parents: 716
diff changeset
889 status = 'C';
8ce2bfdc4143 Reindent update_chat_status_window()
Mikael Berthe <mikael@lilotux.net>
parents: 716
diff changeset
890 else
8ce2bfdc4143 Reindent update_chat_status_window()
Mikael Berthe <mikael@lilotux.net>
parents: 716
diff changeset
891 status = 'x';
8ce2bfdc4143 Reindent update_chat_status_window()
Mikael Berthe <mikael@lilotux.net>
parents: 716
diff changeset
892 } else if (jb_getstatus() != offline) {
8ce2bfdc4143 Reindent update_chat_status_window()
Mikael Berthe <mikael@lilotux.net>
parents: 716
diff changeset
893 enum imstatus budstate;
8ce2bfdc4143 Reindent update_chat_status_window()
Mikael Berthe <mikael@lilotux.net>
parents: 716
diff changeset
894 budstate = buddy_getstatus(BUDDATA(current_buddy), NULL);
790
5d4ad1d77da4 Kill a few gcc4 warnings
Mikael Berthe <mikael@lilotux.net>
parents: 785
diff changeset
895 if (budstate < imstatus_size)
717
8ce2bfdc4143 Reindent update_chat_status_window()
Mikael Berthe <mikael@lilotux.net>
parents: 716
diff changeset
896 status = imstatus2char[budstate];
8ce2bfdc4143 Reindent update_chat_status_window()
Mikael Berthe <mikael@lilotux.net>
parents: 716
diff changeset
897 }
8ce2bfdc4143 Reindent update_chat_status_window()
Mikael Berthe <mikael@lilotux.net>
parents: 716
diff changeset
898
8ce2bfdc4143 Reindent update_chat_status_window()
Mikael Berthe <mikael@lilotux.net>
parents: 716
diff changeset
899 // No status message for groups & MUC rooms
8ce2bfdc4143 Reindent update_chat_status_window()
Mikael Berthe <mikael@lilotux.net>
parents: 716
diff changeset
900 if (!isgrp && !ismuc) {
8ce2bfdc4143 Reindent update_chat_status_window()
Mikael Berthe <mikael@lilotux.net>
parents: 716
diff changeset
901 GSList *resources = buddy_getresources(BUDDATA(current_buddy));
8ce2bfdc4143 Reindent update_chat_status_window()
Mikael Berthe <mikael@lilotux.net>
parents: 716
diff changeset
902 if (resources)
8ce2bfdc4143 Reindent update_chat_status_window()
Mikael Berthe <mikael@lilotux.net>
parents: 716
diff changeset
903 msg = buddy_getstatusmsg(BUDDATA(current_buddy), resources->data);
721
9cf31c9b1dc4 Use room topic as a description in the chat status line
Mikael Berthe <mikael@lilotux.net>
parents: 720
diff changeset
904 } else if (ismuc) {
9cf31c9b1dc4 Use room topic as a description in the chat status line
Mikael Berthe <mikael@lilotux.net>
parents: 720
diff changeset
905 msg = buddy_gettopic(BUDDATA(current_buddy));
717
8ce2bfdc4143 Reindent update_chat_status_window()
Mikael Berthe <mikael@lilotux.net>
parents: 716
diff changeset
906 }
8ce2bfdc4143 Reindent update_chat_status_window()
Mikael Berthe <mikael@lilotux.net>
parents: 716
diff changeset
907 if (!msg)
8ce2bfdc4143 Reindent update_chat_status_window()
Mikael Berthe <mikael@lilotux.net>
parents: 716
diff changeset
908 msg = "";
8ce2bfdc4143 Reindent update_chat_status_window()
Mikael Berthe <mikael@lilotux.net>
parents: 716
diff changeset
909
8ce2bfdc4143 Reindent update_chat_status_window()
Mikael Berthe <mikael@lilotux.net>
parents: 716
diff changeset
910 buf = g_strdup_printf("[%c] Buddy: %s -- %s", status, fullname, msg);
8ce2bfdc4143 Reindent update_chat_status_window()
Mikael Berthe <mikael@lilotux.net>
parents: 716
diff changeset
911 replace_nl_with_dots(buf);
773
e25b8a348ebd Screen updating functions use UTF-8
Mikael Berthe <mikael@lilotux.net>
parents: 772
diff changeset
912 buf_locale = from_utf8(buf);
e25b8a348ebd Screen updating functions use UTF-8
Mikael Berthe <mikael@lilotux.net>
parents: 772
diff changeset
913 mvwprintw(chatstatusWnd, 0, 1, "%s", buf_locale);
e25b8a348ebd Screen updating functions use UTF-8
Mikael Berthe <mikael@lilotux.net>
parents: 772
diff changeset
914 g_free(buf_locale);
717
8ce2bfdc4143 Reindent update_chat_status_window()
Mikael Berthe <mikael@lilotux.net>
parents: 716
diff changeset
915 g_free(buf);
8ce2bfdc4143 Reindent update_chat_status_window()
Mikael Berthe <mikael@lilotux.net>
parents: 716
diff changeset
916
8ce2bfdc4143 Reindent update_chat_status_window()
Mikael Berthe <mikael@lilotux.net>
parents: 716
diff changeset
917 if (forceupdate) {
8ce2bfdc4143 Reindent update_chat_status_window()
Mikael Berthe <mikael@lilotux.net>
parents: 716
diff changeset
918 update_panels();
8ce2bfdc4143 Reindent update_chat_status_window()
Mikael Berthe <mikael@lilotux.net>
parents: 716
diff changeset
919 doupdate();
8ce2bfdc4143 Reindent update_chat_status_window()
Mikael Berthe <mikael@lilotux.net>
parents: 716
diff changeset
920 }
713
b5aa7b7afee8 Update status lines
Mikael Berthe <mikael@lilotux.net>
parents: 712
diff changeset
921 }
b5aa7b7afee8 Update status lines
Mikael Berthe <mikael@lilotux.net>
parents: 712
diff changeset
922
143
300bb88f631f [/trunk] Changeset 155 by mikael
mikael
parents: 142
diff changeset
923 // scr_DrawRoster()
328
83d129adde03 Add set_current_buddy() function, to reduce code duplication
Mikael Berthe <mikael@lilotux.net>
parents: 325
diff changeset
924 // Display the buddylist (not really the roster) on the screen
81
0bd578421ce9 [/trunk] Changeset 95 by mikael
mikael
parents: 76
diff changeset
925 void scr_DrawRoster(void)
24
e88b15cbf2de [/trunk] Changeset 40 by mikael
mikael
parents:
diff changeset
926 {
735
2f027806cd48 Some code cleanup
Mikael Berthe <mikael@lilotux.net>
parents: 731
diff changeset
927 static int offset = 0;
701
6c100adfbfb6 Add setting "roster_width" (variable buddylist width)
Mikael Berthe <mikael@lilotux.net>
parents: 699
diff changeset
928 char *name, *rline;
81
0bd578421ce9 [/trunk] Changeset 95 by mikael
mikael
parents: 76
diff changeset
929 int maxx, maxy;
0bd578421ce9 [/trunk] Changeset 95 by mikael
mikael
parents: 76
diff changeset
930 GList *buddy;
0bd578421ce9 [/trunk] Changeset 95 by mikael
mikael
parents: 76
diff changeset
931 int i, n;
0bd578421ce9 [/trunk] Changeset 95 by mikael
mikael
parents: 76
diff changeset
932 int rOffset;
713
b5aa7b7afee8 Update status lines
Mikael Berthe <mikael@lilotux.net>
parents: 712
diff changeset
933 int cursor_backup;
b5aa7b7afee8 Update status lines
Mikael Berthe <mikael@lilotux.net>
parents: 712
diff changeset
934 char status, pending;
164
faf534be8ff0 [/trunk] Changeset 176 by mikael
mikael
parents: 159
diff changeset
935 enum imstatus currentstatus = jb_getstatus();
81
0bd578421ce9 [/trunk] Changeset 95 by mikael
mikael
parents: 76
diff changeset
936
123
1bdf882bed98 [/trunk] Changeset 136 by mikael
mikael
parents: 121
diff changeset
937 // We can reset update_roster
1bdf882bed98 [/trunk] Changeset 136 by mikael
mikael
parents: 121
diff changeset
938 update_roster = FALSE;
1bdf882bed98 [/trunk] Changeset 136 by mikael
mikael
parents: 121
diff changeset
939
81
0bd578421ce9 [/trunk] Changeset 95 by mikael
mikael
parents: 76
diff changeset
940 getmaxyx(rosterWnd, maxy, maxx);
701
6c100adfbfb6 Add setting "roster_width" (variable buddylist width)
Mikael Berthe <mikael@lilotux.net>
parents: 699
diff changeset
941 maxx--; // Last char is for vertical border
81
0bd578421ce9 [/trunk] Changeset 95 by mikael
mikael
parents: 76
diff changeset
942
713
b5aa7b7afee8 Update status lines
Mikael Berthe <mikael@lilotux.net>
parents: 712
diff changeset
943 cursor_backup = curs_set(0);
b5aa7b7afee8 Update status lines
Mikael Berthe <mikael@lilotux.net>
parents: 712
diff changeset
944
724
264375fe7159 Fix a roster refresh issue
Mikael Berthe <mikael@lilotux.net>
parents: 723
diff changeset
945 if (!buddylist)
264375fe7159 Fix a roster refresh issue
Mikael Berthe <mikael@lilotux.net>
parents: 723
diff changeset
946 offset = 0;
264375fe7159 Fix a roster refresh issue
Mikael Berthe <mikael@lilotux.net>
parents: 723
diff changeset
947 else
264375fe7159 Fix a roster refresh issue
Mikael Berthe <mikael@lilotux.net>
parents: 723
diff changeset
948 scr_UpdateChatStatus(FALSE);
264375fe7159 Fix a roster refresh issue
Mikael Berthe <mikael@lilotux.net>
parents: 723
diff changeset
949
701
6c100adfbfb6 Add setting "roster_width" (variable buddylist width)
Mikael Berthe <mikael@lilotux.net>
parents: 699
diff changeset
950 // Cleanup of roster window
168
6ad156673b19 [/trunk] Changeset 180 by mikael
mikael
parents: 167
diff changeset
951 werase(rosterWnd);
81
0bd578421ce9 [/trunk] Changeset 95 by mikael
mikael
parents: 76
diff changeset
952
707
b26a0bde4cdb Add /roster hide|show|toggle
Mikael Berthe <mikael@lilotux.net>
parents: 701
diff changeset
953 if (Roster_Width) {
b26a0bde4cdb Add /roster hide|show|toggle
Mikael Berthe <mikael@lilotux.net>
parents: 701
diff changeset
954 // Redraw the vertical line (not very good...)
739
0d5fb1d9077c Allow "bright" text colors
Mikael Berthe <mikael@lilotux.net>
parents: 735
diff changeset
955 wattrset(rosterWnd, get_color(COLOR_GENERAL));
707
b26a0bde4cdb Add /roster hide|show|toggle
Mikael Berthe <mikael@lilotux.net>
parents: 701
diff changeset
956 for (i=0 ; i < CHAT_WIN_HEIGHT ; i++)
b26a0bde4cdb Add /roster hide|show|toggle
Mikael Berthe <mikael@lilotux.net>
parents: 701
diff changeset
957 mvwaddch(rosterWnd, i, Roster_Width-1, ACS_VLINE);
b26a0bde4cdb Add /roster hide|show|toggle
Mikael Berthe <mikael@lilotux.net>
parents: 701
diff changeset
958 }
b26a0bde4cdb Add /roster hide|show|toggle
Mikael Berthe <mikael@lilotux.net>
parents: 701
diff changeset
959
b26a0bde4cdb Add /roster hide|show|toggle
Mikael Berthe <mikael@lilotux.net>
parents: 701
diff changeset
960 // Leave now if buddylist is empty or the roster is hidden
b26a0bde4cdb Add /roster hide|show|toggle
Mikael Berthe <mikael@lilotux.net>
parents: 701
diff changeset
961 if (!buddylist || !Roster_Width) {
123
1bdf882bed98 [/trunk] Changeset 136 by mikael
mikael
parents: 121
diff changeset
962 update_panels();
1bdf882bed98 [/trunk] Changeset 136 by mikael
mikael
parents: 121
diff changeset
963 doupdate();
713
b5aa7b7afee8 Update status lines
Mikael Berthe <mikael@lilotux.net>
parents: 712
diff changeset
964 curs_set(cursor_backup);
81
0bd578421ce9 [/trunk] Changeset 95 by mikael
mikael
parents: 76
diff changeset
965 return;
0bd578421ce9 [/trunk] Changeset 95 by mikael
mikael
parents: 76
diff changeset
966 }
0bd578421ce9 [/trunk] Changeset 95 by mikael
mikael
parents: 76
diff changeset
967
701
6c100adfbfb6 Add setting "roster_width" (variable buddylist width)
Mikael Berthe <mikael@lilotux.net>
parents: 699
diff changeset
968 name = g_new0(char, Roster_Width);
6c100adfbfb6 Add setting "roster_width" (variable buddylist width)
Mikael Berthe <mikael@lilotux.net>
parents: 699
diff changeset
969
84
134fe2567f07 [/trunk] Changeset 98 by mikael
mikael
parents: 81
diff changeset
970 // Update offset if necessary
680
1f8987e0e56c Try to display as many buddylist items as possible
Mikael Berthe <mikael@lilotux.net>
parents: 679
diff changeset
971 // a) Try to show as many buddylist items as possible
1f8987e0e56c Try to display as many buddylist items as possible
Mikael Berthe <mikael@lilotux.net>
parents: 679
diff changeset
972 i = g_list_length(buddylist) - maxy;
682
f3945593432e Small fix in scr_DrawRoster()
Mikael Berthe <mikael@lilotux.net>
parents: 680
diff changeset
973 if (i < 0)
f3945593432e Small fix in scr_DrawRoster()
Mikael Berthe <mikael@lilotux.net>
parents: 680
diff changeset
974 i = 0;
f3945593432e Small fix in scr_DrawRoster()
Mikael Berthe <mikael@lilotux.net>
parents: 680
diff changeset
975 if (i < offset)
680
1f8987e0e56c Try to display as many buddylist items as possible
Mikael Berthe <mikael@lilotux.net>
parents: 679
diff changeset
976 offset = i;
1f8987e0e56c Try to display as many buddylist items as possible
Mikael Berthe <mikael@lilotux.net>
parents: 679
diff changeset
977 // b) Make sure the current_buddy is visible
84
134fe2567f07 [/trunk] Changeset 98 by mikael
mikael
parents: 81
diff changeset
978 i = g_list_position(buddylist, current_buddy);
134fe2567f07 [/trunk] Changeset 98 by mikael
mikael
parents: 81
diff changeset
979 if (i == -1) { // This is bad
374
bd5638c21834 Improve logging system (traces)
Mikael Berthe <mikael@lilotux.net>
parents: 373
diff changeset
980 scr_LogPrint(LPRINT_NORMAL, "Doh! Can't find current selected buddy!!");
701
6c100adfbfb6 Add setting "roster_width" (variable buddylist width)
Mikael Berthe <mikael@lilotux.net>
parents: 699
diff changeset
981 g_free(name);
713
b5aa7b7afee8 Update status lines
Mikael Berthe <mikael@lilotux.net>
parents: 712
diff changeset
982 curs_set(cursor_backup);
84
134fe2567f07 [/trunk] Changeset 98 by mikael
mikael
parents: 81
diff changeset
983 return;
134fe2567f07 [/trunk] Changeset 98 by mikael
mikael
parents: 81
diff changeset
984 } else if (i < offset) {
134fe2567f07 [/trunk] Changeset 98 by mikael
mikael
parents: 81
diff changeset
985 offset = i;
134fe2567f07 [/trunk] Changeset 98 by mikael
mikael
parents: 81
diff changeset
986 } else if (i+1 > offset + maxy) {
134fe2567f07 [/trunk] Changeset 98 by mikael
mikael
parents: 81
diff changeset
987 offset = i + 1 - maxy;
134fe2567f07 [/trunk] Changeset 98 by mikael
mikael
parents: 81
diff changeset
988 }
81
0bd578421ce9 [/trunk] Changeset 95 by mikael
mikael
parents: 76
diff changeset
989
701
6c100adfbfb6 Add setting "roster_width" (variable buddylist width)
Mikael Berthe <mikael@lilotux.net>
parents: 699
diff changeset
990 rline = g_new0(char, Roster_Width+1);
6c100adfbfb6 Add setting "roster_width" (variable buddylist width)
Mikael Berthe <mikael@lilotux.net>
parents: 699
diff changeset
991
81
0bd578421ce9 [/trunk] Changeset 95 by mikael
mikael
parents: 76
diff changeset
992 buddy = buddylist;
0bd578421ce9 [/trunk] Changeset 95 by mikael
mikael
parents: 76
diff changeset
993 rOffset = offset;
0bd578421ce9 [/trunk] Changeset 95 by mikael
mikael
parents: 76
diff changeset
994
84
134fe2567f07 [/trunk] Changeset 98 by mikael
mikael
parents: 81
diff changeset
995 for (i=0; i<maxy && buddy; buddy = g_list_next(buddy)) {
713
b5aa7b7afee8 Update status lines
Mikael Berthe <mikael@lilotux.net>
parents: 712
diff changeset
996 unsigned short bflags, btype, ismsg, isgrp, ismuc, ishid;
773
e25b8a348ebd Screen updating functions use UTF-8
Mikael Berthe <mikael@lilotux.net>
parents: 772
diff changeset
997 gchar *rline_locale;
713
b5aa7b7afee8 Update status lines
Mikael Berthe <mikael@lilotux.net>
parents: 712
diff changeset
998
b5aa7b7afee8 Update status lines
Mikael Berthe <mikael@lilotux.net>
parents: 712
diff changeset
999 bflags = buddy_getflags(BUDDATA(buddy));
b5aa7b7afee8 Update status lines
Mikael Berthe <mikael@lilotux.net>
parents: 712
diff changeset
1000 btype = buddy_gettype(BUDDATA(buddy));
b5aa7b7afee8 Update status lines
Mikael Berthe <mikael@lilotux.net>
parents: 712
diff changeset
1001
b5aa7b7afee8 Update status lines
Mikael Berthe <mikael@lilotux.net>
parents: 712
diff changeset
1002 ismsg = bflags & ROSTER_FLAG_MSG;
b5aa7b7afee8 Update status lines
Mikael Berthe <mikael@lilotux.net>
parents: 712
diff changeset
1003 ishid = bflags & ROSTER_FLAG_HIDE;
b5aa7b7afee8 Update status lines
Mikael Berthe <mikael@lilotux.net>
parents: 712
diff changeset
1004 isgrp = btype & ROSTER_TYPE_GROUP;
b5aa7b7afee8 Update status lines
Mikael Berthe <mikael@lilotux.net>
parents: 712
diff changeset
1005 ismuc = btype & ROSTER_TYPE_ROOM;
81
0bd578421ce9 [/trunk] Changeset 95 by mikael
mikael
parents: 76
diff changeset
1006
0bd578421ce9 [/trunk] Changeset 95 by mikael
mikael
parents: 76
diff changeset
1007 if (rOffset > 0) {
0bd578421ce9 [/trunk] Changeset 95 by mikael
mikael
parents: 76
diff changeset
1008 rOffset--;
0bd578421ce9 [/trunk] Changeset 95 by mikael
mikael
parents: 76
diff changeset
1009 continue;
0bd578421ce9 [/trunk] Changeset 95 by mikael
mikael
parents: 76
diff changeset
1010 }
0bd578421ce9 [/trunk] Changeset 95 by mikael
mikael
parents: 76
diff changeset
1011
713
b5aa7b7afee8 Update status lines
Mikael Berthe <mikael@lilotux.net>
parents: 712
diff changeset
1012 status = '?';
b5aa7b7afee8 Update status lines
Mikael Berthe <mikael@lilotux.net>
parents: 712
diff changeset
1013 pending = ' ';
b5aa7b7afee8 Update status lines
Mikael Berthe <mikael@lilotux.net>
parents: 712
diff changeset
1014
149
9f74832eb4f8 [/trunk] Changeset 161 by mikael
mikael
parents: 148
diff changeset
1015 // Display message notice if there is a message flag, but not
9f74832eb4f8 [/trunk] Changeset 161 by mikael
mikael
parents: 148
diff changeset
1016 // for unfolded groups.
9f74832eb4f8 [/trunk] Changeset 161 by mikael
mikael
parents: 148
diff changeset
1017 if (ismsg && (!isgrp || ishid)) {
81
0bd578421ce9 [/trunk] Changeset 95 by mikael
mikael
parents: 76
diff changeset
1018 pending = '#';
0bd578421ce9 [/trunk] Changeset 95 by mikael
mikael
parents: 76
diff changeset
1019 }
0bd578421ce9 [/trunk] Changeset 95 by mikael
mikael
parents: 76
diff changeset
1020
713
b5aa7b7afee8 Update status lines
Mikael Berthe <mikael@lilotux.net>
parents: 712
diff changeset
1021 if (ismuc) {
b5aa7b7afee8 Update status lines
Mikael Berthe <mikael@lilotux.net>
parents: 712
diff changeset
1022 if (buddy_getinsideroom(BUDDATA(buddy)))
b5aa7b7afee8 Update status lines
Mikael Berthe <mikael@lilotux.net>
parents: 712
diff changeset
1023 status = 'C';
b5aa7b7afee8 Update status lines
Mikael Berthe <mikael@lilotux.net>
parents: 712
diff changeset
1024 else
b5aa7b7afee8 Update status lines
Mikael Berthe <mikael@lilotux.net>
parents: 712
diff changeset
1025 status = 'x';
b5aa7b7afee8 Update status lines
Mikael Berthe <mikael@lilotux.net>
parents: 712
diff changeset
1026 } else if (currentstatus != offline) {
b5aa7b7afee8 Update status lines
Mikael Berthe <mikael@lilotux.net>
parents: 712
diff changeset
1027 enum imstatus budstate;
b5aa7b7afee8 Update status lines
Mikael Berthe <mikael@lilotux.net>
parents: 712
diff changeset
1028 budstate = buddy_getstatus(BUDDATA(buddy), NULL);
790
5d4ad1d77da4 Kill a few gcc4 warnings
Mikael Berthe <mikael@lilotux.net>
parents: 785
diff changeset
1029 if (budstate < imstatus_size)
713
b5aa7b7afee8 Update status lines
Mikael Berthe <mikael@lilotux.net>
parents: 712
diff changeset
1030 status = imstatus2char[budstate];
b5aa7b7afee8 Update status lines
Mikael Berthe <mikael@lilotux.net>
parents: 712
diff changeset
1031 }
81
0bd578421ce9 [/trunk] Changeset 95 by mikael
mikael
parents: 76
diff changeset
1032 if (buddy == current_buddy) {
723
23068490d063 Add text color when the selected buddy has an unread message
Mikael Berthe <mikael@lilotux.net>
parents: 721
diff changeset
1033 if (pending == '#')
739
0d5fb1d9077c Allow "bright" text colors
Mikael Berthe <mikael@lilotux.net>
parents: 735
diff changeset
1034 wattrset(rosterWnd, get_color(COLOR_ROSTERSELNMSG));
723
23068490d063 Add text color when the selected buddy has an unread message
Mikael Berthe <mikael@lilotux.net>
parents: 721
diff changeset
1035 else
739
0d5fb1d9077c Allow "bright" text colors
Mikael Berthe <mikael@lilotux.net>
parents: 735
diff changeset
1036 wattrset(rosterWnd, get_color(COLOR_ROSTERSEL));
723
23068490d063 Add text color when the selected buddy has an unread message
Mikael Berthe <mikael@lilotux.net>
parents: 721
diff changeset
1037 // The 3 following lines aim at coloring the whole line
81
0bd578421ce9 [/trunk] Changeset 95 by mikael
mikael
parents: 76
diff changeset
1038 wmove(rosterWnd, i, 0);
0bd578421ce9 [/trunk] Changeset 95 by mikael
mikael
parents: 76
diff changeset
1039 for (n = 0; n < maxx; n++)
0bd578421ce9 [/trunk] Changeset 95 by mikael
mikael
parents: 76
diff changeset
1040 waddch(rosterWnd, ' ');
0bd578421ce9 [/trunk] Changeset 95 by mikael
mikael
parents: 76
diff changeset
1041 } else {
149
9f74832eb4f8 [/trunk] Changeset 161 by mikael
mikael
parents: 148
diff changeset
1042 if (pending == '#')
739
0d5fb1d9077c Allow "bright" text colors
Mikael Berthe <mikael@lilotux.net>
parents: 735
diff changeset
1043 wattrset(rosterWnd, get_color(COLOR_ROSTERNMSG));
139
8d7e31d37bec [/trunk] Changeset 151 by mikael
mikael
parents: 135
diff changeset
1044 else
739
0d5fb1d9077c Allow "bright" text colors
Mikael Berthe <mikael@lilotux.net>
parents: 735
diff changeset
1045 wattrset(rosterWnd, get_color(COLOR_ROSTER));
81
0bd578421ce9 [/trunk] Changeset 95 by mikael
mikael
parents: 76
diff changeset
1046 }
0bd578421ce9 [/trunk] Changeset 95 by mikael
mikael
parents: 76
diff changeset
1047
701
6c100adfbfb6 Add setting "roster_width" (variable buddylist width)
Mikael Berthe <mikael@lilotux.net>
parents: 699
diff changeset
1048 if (Roster_Width > 7)
6c100adfbfb6 Add setting "roster_width" (variable buddylist width)
Mikael Berthe <mikael@lilotux.net>
parents: 699
diff changeset
1049 strncpy(name, buddy_getname(BUDDATA(buddy)), Roster_Width-7);
6c100adfbfb6 Add setting "roster_width" (variable buddylist width)
Mikael Berthe <mikael@lilotux.net>
parents: 699
diff changeset
1050 else
6c100adfbfb6 Add setting "roster_width" (variable buddylist width)
Mikael Berthe <mikael@lilotux.net>
parents: 699
diff changeset
1051 name[0] = 0;
6c100adfbfb6 Add setting "roster_width" (variable buddylist width)
Mikael Berthe <mikael@lilotux.net>
parents: 699
diff changeset
1052
149
9f74832eb4f8 [/trunk] Changeset 161 by mikael
mikael
parents: 148
diff changeset
1053 if (isgrp) {
133
a27b22e3b3a1 [/trunk] Changeset 146 by mikael
mikael
parents: 129
diff changeset
1054 char *sep;
149
9f74832eb4f8 [/trunk] Changeset 161 by mikael
mikael
parents: 148
diff changeset
1055 if (ishid)
133
a27b22e3b3a1 [/trunk] Changeset 146 by mikael
mikael
parents: 129
diff changeset
1056 sep = "+++";
a27b22e3b3a1 [/trunk] Changeset 146 by mikael
mikael
parents: 129
diff changeset
1057 else
a27b22e3b3a1 [/trunk] Changeset 146 by mikael
mikael
parents: 129
diff changeset
1058 sep = "---";
701
6c100adfbfb6 Add setting "roster_width" (variable buddylist width)
Mikael Berthe <mikael@lilotux.net>
parents: 699
diff changeset
1059 snprintf(rline, Roster_Width, " %c%s %s", pending, sep, name);
6c100adfbfb6 Add setting "roster_width" (variable buddylist width)
Mikael Berthe <mikael@lilotux.net>
parents: 699
diff changeset
1060 } else {
6c100adfbfb6 Add setting "roster_width" (variable buddylist width)
Mikael Berthe <mikael@lilotux.net>
parents: 699
diff changeset
1061 snprintf(rline, Roster_Width, " %c[%c] %s", pending, status, name);
133
a27b22e3b3a1 [/trunk] Changeset 146 by mikael
mikael
parents: 129
diff changeset
1062 }
84
134fe2567f07 [/trunk] Changeset 98 by mikael
mikael
parents: 81
diff changeset
1063
773
e25b8a348ebd Screen updating functions use UTF-8
Mikael Berthe <mikael@lilotux.net>
parents: 772
diff changeset
1064 rline_locale = from_utf8(rline);
e25b8a348ebd Screen updating functions use UTF-8
Mikael Berthe <mikael@lilotux.net>
parents: 772
diff changeset
1065 mvwprintw(rosterWnd, i, 0, "%s", rline_locale);
e25b8a348ebd Screen updating functions use UTF-8
Mikael Berthe <mikael@lilotux.net>
parents: 772
diff changeset
1066 g_free(rline_locale);
84
134fe2567f07 [/trunk] Changeset 98 by mikael
mikael
parents: 81
diff changeset
1067 i++;
81
0bd578421ce9 [/trunk] Changeset 95 by mikael
mikael
parents: 76
diff changeset
1068 }
0bd578421ce9 [/trunk] Changeset 95 by mikael
mikael
parents: 76
diff changeset
1069
701
6c100adfbfb6 Add setting "roster_width" (variable buddylist width)
Mikael Berthe <mikael@lilotux.net>
parents: 699
diff changeset
1070 g_free(rline);
6c100adfbfb6 Add setting "roster_width" (variable buddylist width)
Mikael Berthe <mikael@lilotux.net>
parents: 699
diff changeset
1071 g_free(name);
142
bb6fe91589b9 [/trunk] Changeset 154 by mikael
mikael
parents: 140
diff changeset
1072 top_panel(inputPanel);
81
0bd578421ce9 [/trunk] Changeset 95 by mikael
mikael
parents: 76
diff changeset
1073 update_panels();
0bd578421ce9 [/trunk] Changeset 95 by mikael
mikael
parents: 76
diff changeset
1074 doupdate();
713
b5aa7b7afee8 Update status lines
Mikael Berthe <mikael@lilotux.net>
parents: 712
diff changeset
1075 curs_set(cursor_backup);
24
e88b15cbf2de [/trunk] Changeset 40 by mikael
mikael
parents:
diff changeset
1076 }
e88b15cbf2de [/trunk] Changeset 40 by mikael
mikael
parents:
diff changeset
1077
707
b26a0bde4cdb Add /roster hide|show|toggle
Mikael Berthe <mikael@lilotux.net>
parents: 701
diff changeset
1078 // scr_RosterVisibility(status)
b26a0bde4cdb Add /roster hide|show|toggle
Mikael Berthe <mikael@lilotux.net>
parents: 701
diff changeset
1079 // Set the roster visibility:
b26a0bde4cdb Add /roster hide|show|toggle
Mikael Berthe <mikael@lilotux.net>
parents: 701
diff changeset
1080 // status=1 Show roster
b26a0bde4cdb Add /roster hide|show|toggle
Mikael Berthe <mikael@lilotux.net>
parents: 701
diff changeset
1081 // status=0 Hide roster
b26a0bde4cdb Add /roster hide|show|toggle
Mikael Berthe <mikael@lilotux.net>
parents: 701
diff changeset
1082 // status=-1 Toggle roster status
b26a0bde4cdb Add /roster hide|show|toggle
Mikael Berthe <mikael@lilotux.net>
parents: 701
diff changeset
1083 void scr_RosterVisibility(int status)
b26a0bde4cdb Add /roster hide|show|toggle
Mikael Berthe <mikael@lilotux.net>
parents: 701
diff changeset
1084 {
708
ed326697e4ed scr_RosterVisibility(): do not refresh when it is not needed
Mikael Berthe <mikael@lilotux.net>
parents: 707
diff changeset
1085 int old_roster_status = roster_hidden;
ed326697e4ed scr_RosterVisibility(): do not refresh when it is not needed
Mikael Berthe <mikael@lilotux.net>
parents: 707
diff changeset
1086
707
b26a0bde4cdb Add /roster hide|show|toggle
Mikael Berthe <mikael@lilotux.net>
parents: 701
diff changeset
1087 if (status > 0)
b26a0bde4cdb Add /roster hide|show|toggle
Mikael Berthe <mikael@lilotux.net>
parents: 701
diff changeset
1088 roster_hidden = FALSE;
b26a0bde4cdb Add /roster hide|show|toggle
Mikael Berthe <mikael@lilotux.net>
parents: 701
diff changeset
1089 else if (status == 0)
b26a0bde4cdb Add /roster hide|show|toggle
Mikael Berthe <mikael@lilotux.net>
parents: 701
diff changeset
1090 roster_hidden = TRUE;
b26a0bde4cdb Add /roster hide|show|toggle
Mikael Berthe <mikael@lilotux.net>
parents: 701
diff changeset
1091 else
b26a0bde4cdb Add /roster hide|show|toggle
Mikael Berthe <mikael@lilotux.net>
parents: 701
diff changeset
1092 roster_hidden = !roster_hidden;
b26a0bde4cdb Add /roster hide|show|toggle
Mikael Berthe <mikael@lilotux.net>
parents: 701
diff changeset
1093
708
ed326697e4ed scr_RosterVisibility(): do not refresh when it is not needed
Mikael Berthe <mikael@lilotux.net>
parents: 707
diff changeset
1094 if (roster_hidden != old_roster_status) {
709
5aa66101807b Leave full-width mode automatically under some conditions
Mikael Berthe <mikael@lilotux.net>
parents: 708
diff changeset
1095 if (roster_hidden) {
5aa66101807b Leave full-width mode automatically under some conditions
Mikael Berthe <mikael@lilotux.net>
parents: 708
diff changeset
1096 // Enter chat mode
5aa66101807b Leave full-width mode automatically under some conditions
Mikael Berthe <mikael@lilotux.net>
parents: 708
diff changeset
1097 scr_set_chatmode(TRUE);
5aa66101807b Leave full-width mode automatically under some conditions
Mikael Berthe <mikael@lilotux.net>
parents: 708
diff changeset
1098 scr_ShowBuddyWindow();
5aa66101807b Leave full-width mode automatically under some conditions
Mikael Berthe <mikael@lilotux.net>
parents: 708
diff changeset
1099 }
708
ed326697e4ed scr_RosterVisibility(): do not refresh when it is not needed
Mikael Berthe <mikael@lilotux.net>
parents: 707
diff changeset
1100 // Recalculate windows size and redraw
ed326697e4ed scr_RosterVisibility(): do not refresh when it is not needed
Mikael Berthe <mikael@lilotux.net>
parents: 707
diff changeset
1101 scr_Resize();
ed326697e4ed scr_RosterVisibility(): do not refresh when it is not needed
Mikael Berthe <mikael@lilotux.net>
parents: 707
diff changeset
1102 redrawwin(stdscr);
ed326697e4ed scr_RosterVisibility(): do not refresh when it is not needed
Mikael Berthe <mikael@lilotux.net>
parents: 707
diff changeset
1103 }
707
b26a0bde4cdb Add /roster hide|show|toggle
Mikael Berthe <mikael@lilotux.net>
parents: 701
diff changeset
1104 }
b26a0bde4cdb Add /roster hide|show|toggle
Mikael Berthe <mikael@lilotux.net>
parents: 701
diff changeset
1105
480
882e1acae422 Add /say_to command
Mikael Berthe <mikael@lilotux.net>
parents: 464
diff changeset
1106 inline void scr_WriteMessage(const char *jid, const char *text,
882e1acae422 Add /say_to command
Mikael Berthe <mikael@lilotux.net>
parents: 464
diff changeset
1107 time_t timestamp, guint prefix_flags)
24
e88b15cbf2de [/trunk] Changeset 40 by mikael
mikael
parents:
diff changeset
1108 {
727
1c3620668857 Expand tabs when reading history files
Mikael Berthe <mikael@lilotux.net>
parents: 726
diff changeset
1109 char *xtext;
725
1aff92625bdb Expand tabs when receiving a message
Mikael Berthe <mikael@lilotux.net>
parents: 724
diff changeset
1110
726
51be2bc1a820 Better tab expansion
Mikael Berthe <mikael@lilotux.net>
parents: 725
diff changeset
1111 if (!timestamp) timestamp = time(NULL);
725
1aff92625bdb Expand tabs when receiving a message
Mikael Berthe <mikael@lilotux.net>
parents: 724
diff changeset
1112
727
1c3620668857 Expand tabs when reading history files
Mikael Berthe <mikael@lilotux.net>
parents: 726
diff changeset
1113 xtext = ut_expand_tabs(text); // Expand tabs
725
1aff92625bdb Expand tabs when receiving a message
Mikael Berthe <mikael@lilotux.net>
parents: 724
diff changeset
1114
726
51be2bc1a820 Better tab expansion
Mikael Berthe <mikael@lilotux.net>
parents: 725
diff changeset
1115 // XXX Are there other special chars we should filter out?
51be2bc1a820 Better tab expansion
Mikael Berthe <mikael@lilotux.net>
parents: 725
diff changeset
1116
51be2bc1a820 Better tab expansion
Mikael Berthe <mikael@lilotux.net>
parents: 725
diff changeset
1117 scr_WriteInWindow(jid, xtext, timestamp, prefix_flags, FALSE);
725
1aff92625bdb Expand tabs when receiving a message
Mikael Berthe <mikael@lilotux.net>
parents: 724
diff changeset
1118
1aff92625bdb Expand tabs when receiving a message
Mikael Berthe <mikael@lilotux.net>
parents: 724
diff changeset
1119 if (xtext != (char*)text)
1aff92625bdb Expand tabs when receiving a message
Mikael Berthe <mikael@lilotux.net>
parents: 724
diff changeset
1120 g_free(xtext);
24
e88b15cbf2de [/trunk] Changeset 40 by mikael
mikael
parents:
diff changeset
1121 }
e88b15cbf2de [/trunk] Changeset 40 by mikael
mikael
parents:
diff changeset
1122
726
51be2bc1a820 Better tab expansion
Mikael Berthe <mikael@lilotux.net>
parents: 725
diff changeset
1123 // If prefix is NULL, HBB_PREFIX_IN is supposed.
51be2bc1a820 Better tab expansion
Mikael Berthe <mikael@lilotux.net>
parents: 725
diff changeset
1124 void scr_WriteIncomingMessage(const char *jidfrom, const char *text,
51be2bc1a820 Better tab expansion
Mikael Berthe <mikael@lilotux.net>
parents: 725
diff changeset
1125 time_t timestamp, guint prefix)
51be2bc1a820 Better tab expansion
Mikael Berthe <mikael@lilotux.net>
parents: 725
diff changeset
1126 {
728
421b337dc6d2 Chat window: Highlight the flag in our messages
Mikael Berthe <mikael@lilotux.net>
parents: 727
diff changeset
1127 if (!(prefix & ~HBB_PREFIX_NOFLAG & ~HBB_PREFIX_HLIGHT))
726
51be2bc1a820 Better tab expansion
Mikael Berthe <mikael@lilotux.net>
parents: 725
diff changeset
1128 prefix |= HBB_PREFIX_IN;
51be2bc1a820 Better tab expansion
Mikael Berthe <mikael@lilotux.net>
parents: 725
diff changeset
1129
51be2bc1a820 Better tab expansion
Mikael Berthe <mikael@lilotux.net>
parents: 725
diff changeset
1130 scr_WriteMessage(jidfrom, text, timestamp, prefix);
51be2bc1a820 Better tab expansion
Mikael Berthe <mikael@lilotux.net>
parents: 725
diff changeset
1131 update_panels();
51be2bc1a820 Better tab expansion
Mikael Berthe <mikael@lilotux.net>
parents: 725
diff changeset
1132 doupdate();
51be2bc1a820 Better tab expansion
Mikael Berthe <mikael@lilotux.net>
parents: 725
diff changeset
1133 }
51be2bc1a820 Better tab expansion
Mikael Berthe <mikael@lilotux.net>
parents: 725
diff changeset
1134
50
5425ee13dce6 [/trunk] Changeset 66 by mikael
mikael
parents: 47
diff changeset
1135 void scr_WriteOutgoingMessage(const char *jidto, const char *text)
47
7259a61e1a4b [/trunk] Changeset 63 by mikael
mikael
parents: 44
diff changeset
1136 {
729
39f67cade02c Use bold font for outgoing messages
Mikael Berthe <mikael@lilotux.net>
parents: 728
diff changeset
1137 scr_WriteMessage(jidto, text, 0, HBB_PREFIX_OUT|HBB_PREFIX_HLIGHT);
47
7259a61e1a4b [/trunk] Changeset 63 by mikael
mikael
parents: 44
diff changeset
1138 scr_ShowWindow(jidto);
7259a61e1a4b [/trunk] Changeset 63 by mikael
mikael
parents: 44
diff changeset
1139 }
7259a61e1a4b [/trunk] Changeset 63 by mikael
mikael
parents: 44
diff changeset
1140
735
2f027806cd48 Some code cleanup
Mikael Berthe <mikael@lilotux.net>
parents: 731
diff changeset
1141 inline void set_autoaway(bool setaway)
373
af2f8ddf6a1b Move (reorganize) functions
Mikael Berthe <mikael@lilotux.net>
parents: 370
diff changeset
1142 {
af2f8ddf6a1b Move (reorganize) functions
Mikael Berthe <mikael@lilotux.net>
parents: 370
diff changeset
1143 static enum imstatus oldstatus;
521
cc8c969ab6e5 "/status" changes
Mikael Berthe <mikael@lilotux.net>
parents: 518
diff changeset
1144 static char *oldmsg;
373
af2f8ddf6a1b Move (reorganize) functions
Mikael Berthe <mikael@lilotux.net>
parents: 370
diff changeset
1145 Autoaway = setaway;
af2f8ddf6a1b Move (reorganize) functions
Mikael Berthe <mikael@lilotux.net>
parents: 370
diff changeset
1146
af2f8ddf6a1b Move (reorganize) functions
Mikael Berthe <mikael@lilotux.net>
parents: 370
diff changeset
1147 if (setaway) {
521
cc8c969ab6e5 "/status" changes
Mikael Berthe <mikael@lilotux.net>
parents: 518
diff changeset
1148 const char *msg, *prevmsg;
373
af2f8ddf6a1b Move (reorganize) functions
Mikael Berthe <mikael@lilotux.net>
parents: 370
diff changeset
1149 oldstatus = jb_getstatus();
521
cc8c969ab6e5 "/status" changes
Mikael Berthe <mikael@lilotux.net>
parents: 518
diff changeset
1150 if (oldmsg) {
cc8c969ab6e5 "/status" changes
Mikael Berthe <mikael@lilotux.net>
parents: 518
diff changeset
1151 g_free(oldmsg);
cc8c969ab6e5 "/status" changes
Mikael Berthe <mikael@lilotux.net>
parents: 518
diff changeset
1152 oldmsg = NULL;
cc8c969ab6e5 "/status" changes
Mikael Berthe <mikael@lilotux.net>
parents: 518
diff changeset
1153 }
cc8c969ab6e5 "/status" changes
Mikael Berthe <mikael@lilotux.net>
parents: 518
diff changeset
1154 prevmsg = jb_getstatusmsg();
373
af2f8ddf6a1b Move (reorganize) functions
Mikael Berthe <mikael@lilotux.net>
parents: 370
diff changeset
1155 msg = settings_opt_get("message_autoaway");
521
cc8c969ab6e5 "/status" changes
Mikael Berthe <mikael@lilotux.net>
parents: 518
diff changeset
1156 if (!msg)
cc8c969ab6e5 "/status" changes
Mikael Berthe <mikael@lilotux.net>
parents: 518
diff changeset
1157 msg = prevmsg;
cc8c969ab6e5 "/status" changes
Mikael Berthe <mikael@lilotux.net>
parents: 518
diff changeset
1158 if (prevmsg)
cc8c969ab6e5 "/status" changes
Mikael Berthe <mikael@lilotux.net>
parents: 518
diff changeset
1159 oldmsg = g_strdup(prevmsg);
444
5927c3bfba13 Add /status_to command
Mikael Berthe <mikael@lilotux.net>
parents: 438
diff changeset
1160 jb_setstatus(away, NULL, msg);
373
af2f8ddf6a1b Move (reorganize) functions
Mikael Berthe <mikael@lilotux.net>
parents: 370
diff changeset
1161 } else {
af2f8ddf6a1b Move (reorganize) functions
Mikael Berthe <mikael@lilotux.net>
parents: 370
diff changeset
1162 // Back
521
cc8c969ab6e5 "/status" changes
Mikael Berthe <mikael@lilotux.net>
parents: 518
diff changeset
1163 jb_setstatus(oldstatus, NULL, (oldmsg ? oldmsg : ""));
cc8c969ab6e5 "/status" changes
Mikael Berthe <mikael@lilotux.net>
parents: 518
diff changeset
1164 if (oldmsg) {
cc8c969ab6e5 "/status" changes
Mikael Berthe <mikael@lilotux.net>
parents: 518
diff changeset
1165 g_free(oldmsg);
cc8c969ab6e5 "/status" changes
Mikael Berthe <mikael@lilotux.net>
parents: 518
diff changeset
1166 oldmsg = NULL;
cc8c969ab6e5 "/status" changes
Mikael Berthe <mikael@lilotux.net>
parents: 518
diff changeset
1167 }
373
af2f8ddf6a1b Move (reorganize) functions
Mikael Berthe <mikael@lilotux.net>
parents: 370
diff changeset
1168 }
af2f8ddf6a1b Move (reorganize) functions
Mikael Berthe <mikael@lilotux.net>
parents: 370
diff changeset
1169 }
af2f8ddf6a1b Move (reorganize) functions
Mikael Berthe <mikael@lilotux.net>
parents: 370
diff changeset
1170
af2f8ddf6a1b Move (reorganize) functions
Mikael Berthe <mikael@lilotux.net>
parents: 370
diff changeset
1171 // Check if we should enter/leave automatic away status
af2f8ddf6a1b Move (reorganize) functions
Mikael Berthe <mikael@lilotux.net>
parents: 370
diff changeset
1172 void scr_CheckAutoAway(bool activity)
24
e88b15cbf2de [/trunk] Changeset 40 by mikael
mikael
parents:
diff changeset
1173 {
373
af2f8ddf6a1b Move (reorganize) functions
Mikael Berthe <mikael@lilotux.net>
parents: 370
diff changeset
1174 static time_t LastActivity;
af2f8ddf6a1b Move (reorganize) functions
Mikael Berthe <mikael@lilotux.net>
parents: 370
diff changeset
1175 enum imstatus cur_st;
af2f8ddf6a1b Move (reorganize) functions
Mikael Berthe <mikael@lilotux.net>
parents: 370
diff changeset
1176 unsigned int autoaway_timeout = settings_opt_get_int("autoaway");
af2f8ddf6a1b Move (reorganize) functions
Mikael Berthe <mikael@lilotux.net>
parents: 370
diff changeset
1177
af2f8ddf6a1b Move (reorganize) functions
Mikael Berthe <mikael@lilotux.net>
parents: 370
diff changeset
1178 if (Autoaway && activity) set_autoaway(FALSE);
af2f8ddf6a1b Move (reorganize) functions
Mikael Berthe <mikael@lilotux.net>
parents: 370
diff changeset
1179 if (!autoaway_timeout) return;
af2f8ddf6a1b Move (reorganize) functions
Mikael Berthe <mikael@lilotux.net>
parents: 370
diff changeset
1180 if (!LastActivity || activity) time(&LastActivity);
af2f8ddf6a1b Move (reorganize) functions
Mikael Berthe <mikael@lilotux.net>
parents: 370
diff changeset
1181
af2f8ddf6a1b Move (reorganize) functions
Mikael Berthe <mikael@lilotux.net>
parents: 370
diff changeset
1182 cur_st = jb_getstatus();
af2f8ddf6a1b Move (reorganize) functions
Mikael Berthe <mikael@lilotux.net>
parents: 370
diff changeset
1183 // Auto-away is disabled for the following states
af2f8ddf6a1b Move (reorganize) functions
Mikael Berthe <mikael@lilotux.net>
parents: 370
diff changeset
1184 if ((cur_st != available) && (cur_st != freeforchat))
af2f8ddf6a1b Move (reorganize) functions
Mikael Berthe <mikael@lilotux.net>
parents: 370
diff changeset
1185 return;
af2f8ddf6a1b Move (reorganize) functions
Mikael Berthe <mikael@lilotux.net>
parents: 370
diff changeset
1186
af2f8ddf6a1b Move (reorganize) functions
Mikael Berthe <mikael@lilotux.net>
parents: 370
diff changeset
1187 if (!activity) {
af2f8ddf6a1b Move (reorganize) functions
Mikael Berthe <mikael@lilotux.net>
parents: 370
diff changeset
1188 time_t now;
af2f8ddf6a1b Move (reorganize) functions
Mikael Berthe <mikael@lilotux.net>
parents: 370
diff changeset
1189 time(&now);
735
2f027806cd48 Some code cleanup
Mikael Berthe <mikael@lilotux.net>
parents: 731
diff changeset
1190 if (!Autoaway && (now > LastActivity + (time_t)autoaway_timeout))
373
af2f8ddf6a1b Move (reorganize) functions
Mikael Berthe <mikael@lilotux.net>
parents: 370
diff changeset
1191 set_autoaway(TRUE);
af2f8ddf6a1b Move (reorganize) functions
Mikael Berthe <mikael@lilotux.net>
parents: 370
diff changeset
1192 }
24
e88b15cbf2de [/trunk] Changeset 40 by mikael
mikael
parents:
diff changeset
1193 }
e88b15cbf2de [/trunk] Changeset 40 by mikael
mikael
parents:
diff changeset
1194
328
83d129adde03 Add set_current_buddy() function, to reduce code duplication
Mikael Berthe <mikael@lilotux.net>
parents: 325
diff changeset
1195 // set_current_buddy(newbuddy)
83d129adde03 Add set_current_buddy() function, to reduce code duplication
Mikael Berthe <mikael@lilotux.net>
parents: 325
diff changeset
1196 // Set the current_buddy to newbuddy (if not NULL)
83d129adde03 Add set_current_buddy() function, to reduce code duplication
Mikael Berthe <mikael@lilotux.net>
parents: 325
diff changeset
1197 // Lock the newbuddy, and unlock the previous current_buddy
83d129adde03 Add set_current_buddy() function, to reduce code duplication
Mikael Berthe <mikael@lilotux.net>
parents: 325
diff changeset
1198 static void set_current_buddy(GList *newbuddy)
24
e88b15cbf2de [/trunk] Changeset 40 by mikael
mikael
parents:
diff changeset
1199 {
328
83d129adde03 Add set_current_buddy() function, to reduce code duplication
Mikael Berthe <mikael@lilotux.net>
parents: 325
diff changeset
1200 enum imstatus prev_st = imstatus_size;
83d129adde03 Add set_current_buddy() function, to reduce code duplication
Mikael Berthe <mikael@lilotux.net>
parents: 325
diff changeset
1201 /* prev_st initialized to imstatus_size, which is used as "undef" value.
83d129adde03 Add set_current_buddy() function, to reduce code duplication
Mikael Berthe <mikael@lilotux.net>
parents: 325
diff changeset
1202 * We are sure prev_st will get a different status value after the
83d129adde03 Add set_current_buddy() function, to reduce code duplication
Mikael Berthe <mikael@lilotux.net>
parents: 325
diff changeset
1203 * buddy_getstatus() call.
83d129adde03 Add set_current_buddy() function, to reduce code duplication
Mikael Berthe <mikael@lilotux.net>
parents: 325
diff changeset
1204 */
83d129adde03 Add set_current_buddy() function, to reduce code duplication
Mikael Berthe <mikael@lilotux.net>
parents: 325
diff changeset
1205
329
7c53bf62a2a2 scr_RosterUnreadMessage() uses set_current_buddy()
Mikael Berthe <mikael@lilotux.net>
parents: 328
diff changeset
1206 if (!current_buddy || !newbuddy) return;
7c53bf62a2a2 scr_RosterUnreadMessage() uses set_current_buddy()
Mikael Berthe <mikael@lilotux.net>
parents: 328
diff changeset
1207 if (newbuddy == current_buddy) return;
24
e88b15cbf2de [/trunk] Changeset 40 by mikael
mikael
parents:
<