annotate mcabber/src/screen.c @ 880:ea983a945eba

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