annotate mcabber/mcabber/screen.c @ 2074:e04b6dfbb054

Some whitespace cleanup
author Mikael Berthe <mikael@lilotux.net>
date Sun, 29 Sep 2013 11:07:06 +0200
parents 0722fe4b7580
children 16b04d64ec88
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 *
1729
e6e89b1d7831 Minor style and header updates
Mikael Berthe <mikael@lilotux.net>
parents: 1710
diff changeset
4 * Copyright (C) 2005-2010 Mikael Berthe <mikael@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 <time.h>
e88b15cbf2de [/trunk] Changeset 40 by mikael
mikael
parents:
diff changeset
27 #include <ctype.h>
1382
1447c5296977 Fix locale charset detection on some BSD systems
Mikael Berthe <mikael@lilotux.net>
parents: 1381
diff changeset
28
1447c5296977 Fix locale charset detection on some BSD systems
Mikael Berthe <mikael@lilotux.net>
parents: 1381
diff changeset
29 #include <config.h>
24
e88b15cbf2de [/trunk] Changeset 40 by mikael
mikael
parents:
diff changeset
30 #include <locale.h>
1292
382ec54b584e Muc nick coloring functionality
Michal 'vorner' Vaner <vorner@ucw.cz>
parents: 1291
diff changeset
31 #include <assert.h>
1454
6b98dc22946d Add optional SIGWINCH handler (Markus Hennecke)
Mikael Berthe <mikael@lilotux.net>
parents: 1424
diff changeset
32 #ifdef USE_SIGWINCH
6b98dc22946d Add optional SIGWINCH handler (Markus Hennecke)
Mikael Berthe <mikael@lilotux.net>
parents: 1424
diff changeset
33 # include <sys/ioctl.h>
6b98dc22946d Add optional SIGWINCH handler (Markus Hennecke)
Mikael Berthe <mikael@lilotux.net>
parents: 1424
diff changeset
34 # include <termios.h>
6b98dc22946d Add optional SIGWINCH handler (Markus Hennecke)
Mikael Berthe <mikael@lilotux.net>
parents: 1424
diff changeset
35 # include <unistd.h>
6b98dc22946d Add optional SIGWINCH handler (Markus Hennecke)
Mikael Berthe <mikael@lilotux.net>
parents: 1424
diff changeset
36 #endif
929
f4bf564893b5 Fix ncurses #include
Mikael Berthe <mikael@lilotux.net>
parents: 898
diff changeset
37
1382
1447c5296977 Fix locale charset detection on some BSD systems
Mikael Berthe <mikael@lilotux.net>
parents: 1381
diff changeset
38 #ifdef HAVE_LOCALCHARSET_H
1447c5296977 Fix locale charset detection on some BSD systems
Mikael Berthe <mikael@lilotux.net>
parents: 1381
diff changeset
39 # include <localcharset.h>
1447c5296977 Fix locale charset detection on some BSD systems
Mikael Berthe <mikael@lilotux.net>
parents: 1381
diff changeset
40 #else
1447c5296977 Fix locale charset detection on some BSD systems
Mikael Berthe <mikael@lilotux.net>
parents: 1381
diff changeset
41 # include <langinfo.h>
1447c5296977 Fix locale charset detection on some BSD systems
Mikael Berthe <mikael@lilotux.net>
parents: 1381
diff changeset
42 #endif
1447c5296977 Fix locale charset detection on some BSD systems
Mikael Berthe <mikael@lilotux.net>
parents: 1381
diff changeset
43
1590
8d1bcc83ae32 Add support for spellchecking with Enchant (caolan)
Mikael Berthe <mikael@lilotux.net>
parents: 1579
diff changeset
44 #ifdef WITH_ENCHANT
8d1bcc83ae32 Add support for spellchecking with Enchant (caolan)
Mikael Berthe <mikael@lilotux.net>
parents: 1579
diff changeset
45 # include <enchant.h>
2015
db8ec238cd2c Fix segfault when spell checking is enabled and spell_lang is not set.
Mikael Berthe <mikael@lilotux.net>
parents: 2013
diff changeset
46 #else
db8ec238cd2c Fix segfault when spell checking is enabled and spell_lang is not set.
Mikael Berthe <mikael@lilotux.net>
parents: 2013
diff changeset
47 # ifdef WITH_ASPELL
db8ec238cd2c Fix segfault when spell checking is enabled and spell_lang is not set.
Mikael Berthe <mikael@lilotux.net>
parents: 2013
diff changeset
48 # include <aspell.h>
db8ec238cd2c Fix segfault when spell checking is enabled and spell_lang is not set.
Mikael Berthe <mikael@lilotux.net>
parents: 2013
diff changeset
49 # endif
1179
0f7e0346d9cb Add aspell support
entragian <entragian@o2.pl>
parents: 1178
diff changeset
50 #endif
0f7e0346d9cb Add aspell support
entragian <entragian@o2.pl>
parents: 1178
diff changeset
51
24
e88b15cbf2de [/trunk] Changeset 40 by mikael
mikael
parents:
diff changeset
52 #include "screen.h"
930
a75f7a13df7b UTF-8 terminal support (Reimar Döffinger)
Mikael Berthe <mikael@lilotux.net>
parents: 929
diff changeset
53 #include "utf8.h"
81
0bd578421ce9 [/trunk] Changeset 95 by mikael
mikael
parents: 76
diff changeset
54 #include "hbuf.h"
47
7259a61e1a4b [/trunk] Changeset 63 by mikael
mikael
parents: 44
diff changeset
55 #include "commands.h"
95
9e6b7897ec37 [/trunk] Changeset 109 by mikael
mikael
parents: 84
diff changeset
56 #include "compl.h"
81
0bd578421ce9 [/trunk] Changeset 95 by mikael
mikael
parents: 76
diff changeset
57 #include "roster.h"
180
42a33611233b [/trunk] Changeset 192 by mikael
mikael
parents: 178
diff changeset
58 #include "histolog.h"
279
f5dd437c057b Rewrite the settings system
Mikael Berthe <mikael@lilotux.net>
parents: 276
diff changeset
59 #include "settings.h"
81
0bd578421ce9 [/trunk] Changeset 95 by mikael
mikael
parents: 76
diff changeset
60 #include "utils.h"
1598
a087125d8fc8 Replace libjabber with loudmouth
franky
parents: 1590
diff changeset
61 #include "xmpp.h"
1653
fca9a4c17432 Improve UI latency and CPU usage
Myhailo Danylenko <isbear@ukrpost.net>
parents: 1651
diff changeset
62 #include "main.h"
24
e88b15cbf2de [/trunk] Changeset 40 by mikael
mikael
parents:
diff changeset
63
2028
7b5bd6ad83b4 Add 'color_log' (text color in the log window)
Mikael Berthe <mikael@lilotux.net>
parents: 2015
diff changeset
64 #define get_color(col) (COLOR_PAIR(col)|COLOR_ATTRIB[col])
1489
e9c71ce96dca Fixed the colorhandling for mucnicks and /color roster
franky@veqlargh.fs
parents: 1488
diff changeset
65 #define compose_color(col) (COLOR_PAIR(col->color_pair)|col->color_attrib)
24
e88b15cbf2de [/trunk] Changeset 40 by mikael
mikael
parents:
diff changeset
66
515
180f0a6e4ac9 Log window's height can be set by the user
Mikael Berthe <mikael@lilotux.net>
parents: 514
diff changeset
67 #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
68 #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
69 #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
70
1390
753a348c65c1 LocaleCharSet is const
Mikael Berthe <mikael@lilotux.net>
parents: 1386
diff changeset
71 const char *LocaleCharSet = "C";
592
67a332121aea Try UTF8 -> locale conversion with fallback
Mikael Berthe <mikael@lilotux.net>
parents: 580
diff changeset
72
515
180f0a6e4ac9 Log window's height can be set by the user
Mikael Berthe <mikael@lilotux.net>
parents: 514
diff changeset
73 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
74 static unsigned short int Roster_Width;
1942
3e39a336a992 Use guards for colors (Myhailo Danylenko)
Mikael Berthe <mikael@lilotux.net>
parents: 1935
diff changeset
75 static gboolean colors_stalled = FALSE;
515
180f0a6e4ac9 Log window's height can be set by the user
Mikael Berthe <mikael@lilotux.net>
parents: 514
diff changeset
76
1804
35a1250c111a Display urgent/attention sign in the roster UI
Mikael Berthe <mikael@lilotux.net>
parents: 1802
diff changeset
77 // Default attention sign trigger levels
35a1250c111a Display urgent/attention sign in the roster UI
Mikael Berthe <mikael@lilotux.net>
parents: 1802
diff changeset
78 static guint ui_attn_sign_prio_level_muc = ROSTER_UI_PRIO_MUC_HL_MESSAGE;
35a1250c111a Display urgent/attention sign in the roster UI
Mikael Berthe <mikael@lilotux.net>
parents: 1802
diff changeset
79 static guint ui_attn_sign_prio_level = ROSTER_UI_PRIO_ATTENTION_MESSAGE;
35a1250c111a Display urgent/attention sign in the roster UI
Mikael Berthe <mikael@lilotux.net>
parents: 1802
diff changeset
80
336
eb994ee40029 Make some functions static
Mikael Berthe <mikael@lilotux.net>
parents: 332
diff changeset
81 static inline void check_offset(int);
1172
334ae9f498f1 Add some more iline functions (Lego12239)
Mikael Berthe <mikael@lilotux.net>
parents: 1171
diff changeset
82 static void scr_cancel_current_completion(void);
334ae9f498f1 Add some more iline functions (Lego12239)
Mikael Berthe <mikael@lilotux.net>
parents: 1171
diff changeset
83 static void scr_end_current_completion(void);
334ae9f498f1 Add some more iline functions (Lego12239)
Mikael Berthe <mikael@lilotux.net>
parents: 1171
diff changeset
84 static void scr_insert_text(const char*);
334ae9f498f1 Add some more iline functions (Lego12239)
Mikael Berthe <mikael@lilotux.net>
parents: 1171
diff changeset
85 static void scr_handle_tab(void);
151
b69c0b7a23e3 [/trunk] Changeset 163 by mikael
mikael
parents: 149
diff changeset
86
1780
e4378fbab5d7 Major API cleanup - bump API to 4
Mikael Berthe <mikael@lilotux.net>
parents: 1761
diff changeset
87 #if defined XEP0022 || defined XEP0085
e4378fbab5d7 Major API cleanup - bump API to 4
Mikael Berthe <mikael@lilotux.net>
parents: 1761
diff changeset
88 static gboolean scr_chatstates_timeout();
e4378fbab5d7 Major API cleanup - bump API to 4
Mikael Berthe <mikael@lilotux.net>
parents: 1761
diff changeset
89 #endif
e4378fbab5d7 Major API cleanup - bump API to 4
Mikael Berthe <mikael@lilotux.net>
parents: 1761
diff changeset
90
1590
8d1bcc83ae32 Add support for spellchecking with Enchant (caolan)
Mikael Berthe <mikael@lilotux.net>
parents: 1579
diff changeset
91 #if defined(WITH_ENCHANT) || defined(WITH_ASPELL)
1179
0f7e0346d9cb Add aspell support
entragian <entragian@o2.pl>
parents: 1178
diff changeset
92 static void spellcheck(char *, char *);
0f7e0346d9cb Add aspell support
entragian <entragian@o2.pl>
parents: 1178
diff changeset
93 #endif
0f7e0346d9cb Add aspell support
entragian <entragian@o2.pl>
parents: 1178
diff changeset
94
1078
7866dbaf67a6 Use a hash for the list of win buffers
Mikael Berthe <mikael@lilotux.net>
parents: 1077
diff changeset
95 static GHashTable *winbufhash;
24
e88b15cbf2de [/trunk] Changeset 40 by mikael
mikael
parents:
diff changeset
96
822
0dbb2be10975 Get rid of list.h
Mikael Berthe <mikael@lilotux.net>
parents: 807
diff changeset
97 typedef struct {
1157
5c857f0f0ab8 Moved all variables related to hbuf to an extra struct, bufdata
Frank Zschockelt
parents: 1156
diff changeset
98 GList *hbuf;
5c857f0f0ab8 Moved all variables related to hbuf to an extra struct, bufdata
Frank Zschockelt
parents: 1156
diff changeset
99 GList *top; // If top is NULL, we'll display the last lines
5c857f0f0ab8 Moved all variables related to hbuf to an extra struct, bufdata
Frank Zschockelt
parents: 1156
diff changeset
100 char cleared; // For ex, user has issued a /clear command...
5c857f0f0ab8 Moved all variables related to hbuf to an extra struct, bufdata
Frank Zschockelt
parents: 1156
diff changeset
101 char lock;
5c857f0f0ab8 Moved all variables related to hbuf to an extra struct, bufdata
Frank Zschockelt
parents: 1156
diff changeset
102 } buffdata;
5c857f0f0ab8 Moved all variables related to hbuf to an extra struct, bufdata
Frank Zschockelt
parents: 1156
diff changeset
103
5c857f0f0ab8 Moved all variables related to hbuf to an extra struct, bufdata
Frank Zschockelt
parents: 1156
diff changeset
104 typedef struct {
24
e88b15cbf2de [/trunk] Changeset 40 by mikael
mikael
parents:
diff changeset
105 WINDOW *win;
108
7fb72bc13732 [/trunk] Changeset 122 by mikael
mikael
parents: 105
diff changeset
106 PANEL *panel;
1157
5c857f0f0ab8 Moved all variables related to hbuf to an extra struct, bufdata
Frank Zschockelt
parents: 1156
diff changeset
107 buffdata *bd;
822
0dbb2be10975 Get rid of list.h
Mikael Berthe <mikael@lilotux.net>
parents: 807
diff changeset
108 } winbuf;
24
e88b15cbf2de [/trunk] Changeset 40 by mikael
mikael
parents:
diff changeset
109
1078
7866dbaf67a6 Use a hash for the list of win buffers
Mikael Berthe <mikael@lilotux.net>
parents: 1077
diff changeset
110 struct dimensions {
7866dbaf67a6 Use a hash for the list of win buffers
Mikael Berthe <mikael@lilotux.net>
parents: 1077
diff changeset
111 int l;
7866dbaf67a6 Use a hash for the list of win buffers
Mikael Berthe <mikael@lilotux.net>
parents: 1077
diff changeset
112 int c;
7866dbaf67a6 Use a hash for the list of win buffers
Mikael Berthe <mikael@lilotux.net>
parents: 1077
diff changeset
113 };
24
e88b15cbf2de [/trunk] Changeset 40 by mikael
mikael
parents:
diff changeset
114
1133
9dd28a56128f Do not create one panel per contact
Mikael Berthe <mikael@lilotux.net>
parents: 1131
diff changeset
115 static WINDOW *rosterWnd, *chatWnd, *activechatWnd, *inputWnd, *logWnd;
711
75dde88f1884 Introduce status lines
Mikael Berthe <mikael@lilotux.net>
parents: 709
diff changeset
116 static WINDOW *mainstatusWnd, *chatstatusWnd;
1133
9dd28a56128f Do not create one panel per contact
Mikael Berthe <mikael@lilotux.net>
parents: 1131
diff changeset
117 static PANEL *rosterPanel, *chatPanel, *activechatPanel, *inputPanel;
711
75dde88f1884 Introduce status lines
Mikael Berthe <mikael@lilotux.net>
parents: 709
diff changeset
118 static PANEL *mainstatusPanel, *chatstatusPanel;
75dde88f1884 Introduce status lines
Mikael Berthe <mikael@lilotux.net>
parents: 709
diff changeset
119 static PANEL *logPanel;
24
e88b15cbf2de [/trunk] Changeset 40 by mikael
mikael
parents:
diff changeset
120 static int maxY, maxX;
1093
6ca9a65df21f Do not rewrap buffer lines when the chat window width doesn't change
Mikael Berthe <mikael@lilotux.net>
parents: 1089
diff changeset
121 static int prev_chatwidth;
849
42c43a88d823 Status buffer management
Mikael Berthe <mikael@lilotux.net>
parents: 848
diff changeset
122 static winbuf *statusWindow;
822
0dbb2be10975 Get rid of list.h
Mikael Berthe <mikael@lilotux.net>
parents: 807
diff changeset
123 static winbuf *currentWindow;
851
da03534e46c7 Add startup log messages to the status buffer
Mikael Berthe <mikael@lilotux.net>
parents: 850
diff changeset
124 static GList *statushbuf;
24
e88b15cbf2de [/trunk] Changeset 40 by mikael
mikael
parents:
diff changeset
125
707
b26a0bde4cdb Add /roster hide|show|toggle
Mikael Berthe <mikael@lilotux.net>
parents: 701
diff changeset
126 static int roster_hidden;
24
e88b15cbf2de [/trunk] Changeset 40 by mikael
mikael
parents:
diff changeset
127 static int chatmode;
238
8e30b2bb380e [/trunk] Changeset 251 by mikael
mikael
parents: 236
diff changeset
128 static int multimode;
807
f6cda389db48 Allow messages with a subject (/msay)
Mikael Berthe <mikael@lilotux.net>
parents: 806
diff changeset
129 static char *multiline, *multimode_subj;
2009
a859ed648638 Replace the option « no_space_before_items » with « roster_no_leading_space ».
Simon Jacquin <simon@jacquin.me>
parents: 2008
diff changeset
130 static int roster_no_leading_space;
1780
e4378fbab5d7 Major API cleanup - bump API to 4
Mikael Berthe <mikael@lilotux.net>
parents: 1761
diff changeset
131
332
a1901741890e scr_LogPrint() can be called before ncurses initialization
Mikael Berthe <mikael@lilotux.net>
parents: 330
diff changeset
132 static bool Curses;
972
11b632d824f6 Add option 'log_win_on_top'
Mikael Berthe <mikael@lilotux.net>
parents: 967
diff changeset
133 static bool log_win_on_top;
973
e693cbe33802 Add option 'roster_win_on_right'
Mikael Berthe <mikael@lilotux.net>
parents: 972
diff changeset
134 static bool roster_win_on_right;
1677
9a0ed33fb91b Fix autoaway
Myhailo Danylenko <isbear@ukrpost.net>
parents: 1668
diff changeset
135 static guint autoaway_source = 0;
24
e88b15cbf2de [/trunk] Changeset 40 by mikael
mikael
parents:
diff changeset
136
174
6354625e8fb2 [/trunk] Changeset 186 by mikael
mikael
parents: 173
diff changeset
137 static char inputLine[INPUTLINE_LENGTH+1];
1590
8d1bcc83ae32 Add support for spellchecking with Enchant (caolan)
Mikael Berthe <mikael@lilotux.net>
parents: 1579
diff changeset
138 #if defined(WITH_ENCHANT) || defined(WITH_ASPELL)
1179
0f7e0346d9cb Add aspell support
entragian <entragian@o2.pl>
parents: 1178
diff changeset
139 static char maskLine[INPUTLINE_LENGTH+1];
0f7e0346d9cb Add aspell support
entragian <entragian@o2.pl>
parents: 1178
diff changeset
140 #endif
174
6354625e8fb2 [/trunk] Changeset 186 by mikael
mikael
parents: 173
diff changeset
141 static char *ptr_inputline;
6354625e8fb2 [/trunk] Changeset 186 by mikael
mikael
parents: 173
diff changeset
142 static short int inputline_offset;
6354625e8fb2 [/trunk] Changeset 186 by mikael
mikael
parents: 173
diff changeset
143 static int completion_started;
173
09e24917059d [/trunk] Changeset 185 by mikael
mikael
parents: 168
diff changeset
144 static GList *cmdhisto;
09e24917059d [/trunk] Changeset 185 by mikael
mikael
parents: 168
diff changeset
145 static GList *cmdhisto_cur;
1127
fddf2fef7b83 Add option "cmdhistory_lines"
Mikael Berthe <mikael@lilotux.net>
parents: 1122
diff changeset
146 static guint cmdhisto_nblines;
174
6354625e8fb2 [/trunk] Changeset 186 by mikael
mikael
parents: 173
diff changeset
147 static char cmdhisto_backup[INPUTLINE_LENGTH+1];
24
e88b15cbf2de [/trunk] Changeset 40 by mikael
mikael
parents:
diff changeset
148
991
ef10906691bb Chatstates: add composing timeout
Mikael Berthe <mikael@lilotux.net>
parents: 990
diff changeset
149 static int chatstate; /* (0=active, 1=composing, 2=paused) */
990
35e7913affb7 Send events/chatstates notifications (JEP-22/JEP-85)
Mikael Berthe <mikael@lilotux.net>
parents: 987
diff changeset
150 static bool lock_chatstate;
991
ef10906691bb Chatstates: add composing timeout
Mikael Berthe <mikael@lilotux.net>
parents: 990
diff changeset
151 static time_t chatstate_timestamp;
1598
a087125d8fc8 Replace libjabber with loudmouth
franky
parents: 1590
diff changeset
152 static guint chatstate_timeout_id = 0;
1780
e4378fbab5d7 Major API cleanup - bump API to 4
Mikael Berthe <mikael@lilotux.net>
parents: 1761
diff changeset
153
e4378fbab5d7 Major API cleanup - bump API to 4
Mikael Berthe <mikael@lilotux.net>
parents: 1761
diff changeset
154 int update_roster;
e4378fbab5d7 Major API cleanup - bump API to 4
Mikael Berthe <mikael@lilotux.net>
parents: 1761
diff changeset
155 int utf8_mode;
e4378fbab5d7 Major API cleanup - bump API to 4
Mikael Berthe <mikael@lilotux.net>
parents: 1761
diff changeset
156 gboolean chatstates_disabled;
e4378fbab5d7 Major API cleanup - bump API to 4
Mikael Berthe <mikael@lilotux.net>
parents: 1761
diff changeset
157 gboolean Autoaway;
990
35e7913affb7 Send events/chatstates notifications (JEP-22/JEP-85)
Mikael Berthe <mikael@lilotux.net>
parents: 987
diff changeset
158
761
4532a9fe0e8c Handle some keyboard escape sequences
Mikael Berthe <mikael@lilotux.net>
parents: 760
diff changeset
159 #define MAX_KEYSEQ_LENGTH 8
4532a9fe0e8c Handle some keyboard escape sequences
Mikael Berthe <mikael@lilotux.net>
parents: 760
diff changeset
160
4532a9fe0e8c Handle some keyboard escape sequences
Mikael Berthe <mikael@lilotux.net>
parents: 760
diff changeset
161 typedef struct {
4532a9fe0e8c Handle some keyboard escape sequences
Mikael Berthe <mikael@lilotux.net>
parents: 760
diff changeset
162 char *seqstr;
4532a9fe0e8c Handle some keyboard escape sequences
Mikael Berthe <mikael@lilotux.net>
parents: 760
diff changeset
163 guint mkeycode;
4532a9fe0e8c Handle some keyboard escape sequences
Mikael Berthe <mikael@lilotux.net>
parents: 760
diff changeset
164 gint value;
4532a9fe0e8c Handle some keyboard escape sequences
Mikael Berthe <mikael@lilotux.net>
parents: 760
diff changeset
165 } keyseq;
4532a9fe0e8c Handle some keyboard escape sequences
Mikael Berthe <mikael@lilotux.net>
parents: 760
diff changeset
166
4532a9fe0e8c Handle some keyboard escape sequences
Mikael Berthe <mikael@lilotux.net>
parents: 760
diff changeset
167 GSList *keyseqlist;
4532a9fe0e8c Handle some keyboard escape sequences
Mikael Berthe <mikael@lilotux.net>
parents: 760
diff changeset
168 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
169
1780
e4378fbab5d7 Major API cleanup - bump API to 4
Mikael Berthe <mikael@lilotux.net>
parents: 1761
diff changeset
170 static void scr_write_in_window(const char *winId, const char *text,
e4378fbab5d7 Major API cleanup - bump API to 4
Mikael Berthe <mikael@lilotux.net>
parents: 1761
diff changeset
171 time_t timestamp, unsigned int prefix_flags,
e4378fbab5d7 Major API cleanup - bump API to 4
Mikael Berthe <mikael@lilotux.net>
parents: 1761
diff changeset
172 int force_show, unsigned mucnicklen,
e4378fbab5d7 Major API cleanup - bump API to 4
Mikael Berthe <mikael@lilotux.net>
parents: 1761
diff changeset
173 gpointer xep184);
e4378fbab5d7 Major API cleanup - bump API to 4
Mikael Berthe <mikael@lilotux.net>
parents: 1761
diff changeset
174
e4378fbab5d7 Major API cleanup - bump API to 4
Mikael Berthe <mikael@lilotux.net>
parents: 1761
diff changeset
175 static void scr_write_message(const char *bjid, const char *text,
e4378fbab5d7 Major API cleanup - bump API to 4
Mikael Berthe <mikael@lilotux.net>
parents: 1761
diff changeset
176 time_t timestamp, guint prefix_flags,
e4378fbab5d7 Major API cleanup - bump API to 4
Mikael Berthe <mikael@lilotux.net>
parents: 1761
diff changeset
177 unsigned mucnicklen, gpointer xep184);
e4378fbab5d7 Major API cleanup - bump API to 4
Mikael Berthe <mikael@lilotux.net>
parents: 1761
diff changeset
178
e4378fbab5d7 Major API cleanup - bump API to 4
Mikael Berthe <mikael@lilotux.net>
parents: 1761
diff changeset
179 inline void scr_update_buddy_window(void);
1413
f89844a0448a Remove useless inlines
Mikael Berthe <mikael@lilotux.net>
parents: 1394
diff changeset
180 inline void scr_set_chatmode(int enable);
f89844a0448a Remove useless inlines
Mikael Berthe <mikael@lilotux.net>
parents: 1394
diff changeset
181
1590
8d1bcc83ae32 Add support for spellchecking with Enchant (caolan)
Mikael Berthe <mikael@lilotux.net>
parents: 1579
diff changeset
182 #define SPELLBADCHAR 5
8d1bcc83ae32 Add support for spellchecking with Enchant (caolan)
Mikael Berthe <mikael@lilotux.net>
parents: 1579
diff changeset
183
8d1bcc83ae32 Add support for spellchecking with Enchant (caolan)
Mikael Berthe <mikael@lilotux.net>
parents: 1579
diff changeset
184 #ifdef WITH_ENCHANT
8d1bcc83ae32 Add support for spellchecking with Enchant (caolan)
Mikael Berthe <mikael@lilotux.net>
parents: 1579
diff changeset
185 EnchantBroker *spell_broker;
8d1bcc83ae32 Add support for spellchecking with Enchant (caolan)
Mikael Berthe <mikael@lilotux.net>
parents: 1579
diff changeset
186 EnchantDict *spell_checker;
8d1bcc83ae32 Add support for spellchecking with Enchant (caolan)
Mikael Berthe <mikael@lilotux.net>
parents: 1579
diff changeset
187 #endif
8d1bcc83ae32 Add support for spellchecking with Enchant (caolan)
Mikael Berthe <mikael@lilotux.net>
parents: 1579
diff changeset
188
8d1bcc83ae32 Add support for spellchecking with Enchant (caolan)
Mikael Berthe <mikael@lilotux.net>
parents: 1579
diff changeset
189 #ifdef WITH_ASPELL
1179
0f7e0346d9cb Add aspell support
entragian <entragian@o2.pl>
parents: 1178
diff changeset
190 AspellConfig *spell_config;
0f7e0346d9cb Add aspell support
entragian <entragian@o2.pl>
parents: 1178
diff changeset
191 AspellSpeller *spell_checker;
0f7e0346d9cb Add aspell support
entragian <entragian@o2.pl>
parents: 1178
diff changeset
192 #endif
24
e88b15cbf2de [/trunk] Changeset 40 by mikael
mikael
parents:
diff changeset
193
1272
033576acac4c Add configurable roster colors (Michal 'vorner' Vaner)
Mikael Berthe <mikael@lilotux.net>
parents: 1268
diff changeset
194 typedef struct {
1489
e9c71ce96dca Fixed the colorhandling for mucnicks and /color roster
franky@veqlargh.fs
parents: 1488
diff changeset
195 int color_pair;
e9c71ce96dca Fixed the colorhandling for mucnicks and /color roster
franky@veqlargh.fs
parents: 1488
diff changeset
196 int color_attrib;
e9c71ce96dca Fixed the colorhandling for mucnicks and /color roster
franky@veqlargh.fs
parents: 1488
diff changeset
197 } ccolor;
e9c71ce96dca Fixed the colorhandling for mucnicks and /color roster
franky@veqlargh.fs
parents: 1488
diff changeset
198
e9c71ce96dca Fixed the colorhandling for mucnicks and /color roster
franky@veqlargh.fs
parents: 1488
diff changeset
199 typedef struct {
1272
033576acac4c Add configurable roster colors (Michal 'vorner' Vaner)
Mikael Berthe <mikael@lilotux.net>
parents: 1268
diff changeset
200 char *status, *wildcard;
1598
a087125d8fc8 Replace libjabber with loudmouth
franky
parents: 1590
diff changeset
201 ccolor *color;
1272
033576acac4c Add configurable roster colors (Michal 'vorner' Vaner)
Mikael Berthe <mikael@lilotux.net>
parents: 1268
diff changeset
202 GPatternSpec *compiled;
033576acac4c Add configurable roster colors (Michal 'vorner' Vaner)
Mikael Berthe <mikael@lilotux.net>
parents: 1268
diff changeset
203 } rostercolor;
033576acac4c Add configurable roster colors (Michal 'vorner' Vaner)
Mikael Berthe <mikael@lilotux.net>
parents: 1268
diff changeset
204
1292
382ec54b584e Muc nick coloring functionality
Michal 'vorner' Vaner <vorner@ucw.cz>
parents: 1291
diff changeset
205 static GSList *rostercolrules = NULL;
382ec54b584e Muc nick coloring functionality
Michal 'vorner' Vaner <vorner@ucw.cz>
parents: 1291
diff changeset
206
382ec54b584e Muc nick coloring functionality
Michal 'vorner' Vaner <vorner@ucw.cz>
parents: 1291
diff changeset
207 static GHashTable *muccolors = NULL, *nickcolors = NULL;
382ec54b584e Muc nick coloring functionality
Michal 'vorner' Vaner <vorner@ucw.cz>
parents: 1291
diff changeset
208
382ec54b584e Muc nick coloring functionality
Michal 'vorner' Vaner <vorner@ucw.cz>
parents: 1291
diff changeset
209 typedef struct {
1413
f89844a0448a Remove useless inlines
Mikael Berthe <mikael@lilotux.net>
parents: 1394
diff changeset
210 bool manual; // Manually set?
1598
a087125d8fc8 Replace libjabber with loudmouth
franky
parents: 1590
diff changeset
211 ccolor *color;
1292
382ec54b584e Muc nick coloring functionality
Michal 'vorner' Vaner <vorner@ucw.cz>
parents: 1291
diff changeset
212 } nickcolor;
382ec54b584e Muc nick coloring functionality
Michal 'vorner' Vaner <vorner@ucw.cz>
parents: 1291
diff changeset
213
1489
e9c71ce96dca Fixed the colorhandling for mucnicks and /color roster
franky@veqlargh.fs
parents: 1488
diff changeset
214 static int nickcolcount = 0;
e9c71ce96dca Fixed the colorhandling for mucnicks and /color roster
franky@veqlargh.fs
parents: 1488
diff changeset
215 static ccolor ** nickcols = NULL;
1292
382ec54b584e Muc nick coloring functionality
Michal 'vorner' Vaner <vorner@ucw.cz>
parents: 1291
diff changeset
216 static muccoltype glob_muccol = MC_OFF;
1272
033576acac4c Add configurable roster colors (Michal 'vorner' Vaner)
Mikael Berthe <mikael@lilotux.net>
parents: 1268
diff changeset
217
99
7fffb8a6b229 [/trunk] Changeset 113 by mikael
mikael
parents: 98
diff changeset
218 /* Functions */
24
e88b15cbf2de [/trunk] Changeset 40 by mikael
mikael
parents:
diff changeset
219
1780
e4378fbab5d7 Major API cleanup - bump API to 4
Mikael Berthe <mikael@lilotux.net>
parents: 1761
diff changeset
220 static int find_color(const char *name)
1272
033576acac4c Add configurable roster colors (Michal 'vorner' Vaner)
Mikael Berthe <mikael@lilotux.net>
parents: 1268
diff changeset
221 {
1489
e9c71ce96dca Fixed the colorhandling for mucnicks and /color roster
franky@veqlargh.fs
parents: 1488
diff changeset
222 int result;
e9c71ce96dca Fixed the colorhandling for mucnicks and /color roster
franky@veqlargh.fs
parents: 1488
diff changeset
223
24
e88b15cbf2de [/trunk] Changeset 40 by mikael
mikael
parents:
diff changeset
224 if (!strcmp(name, "default"))
e88b15cbf2de [/trunk] Changeset 40 by mikael
mikael
parents:
diff changeset
225 return -1;
e88b15cbf2de [/trunk] Changeset 40 by mikael
mikael
parents:
diff changeset
226 if (!strcmp(name, "black"))
e88b15cbf2de [/trunk] Changeset 40 by mikael
mikael
parents:
diff changeset
227 return COLOR_BLACK;
e88b15cbf2de [/trunk] Changeset 40 by mikael
mikael
parents:
diff changeset
228 if (!strcmp(name, "red"))
e88b15cbf2de [/trunk] Changeset 40 by mikael
mikael
parents:
diff changeset
229 return COLOR_RED;
e88b15cbf2de [/trunk] Changeset 40 by mikael
mikael
parents:
diff changeset
230 if (!strcmp(name, "green"))
e88b15cbf2de [/trunk] Changeset 40 by mikael
mikael
parents:
diff changeset
231 return COLOR_GREEN;
e88b15cbf2de [/trunk] Changeset 40 by mikael
mikael
parents:
diff changeset
232 if (!strcmp(name, "yellow"))
e88b15cbf2de [/trunk] Changeset 40 by mikael
mikael
parents:
diff changeset
233 return COLOR_YELLOW;
e88b15cbf2de [/trunk] Changeset 40 by mikael
mikael
parents:
diff changeset
234 if (!strcmp(name, "blue"))
e88b15cbf2de [/trunk] Changeset 40 by mikael
mikael
parents:
diff changeset
235 return COLOR_BLUE;
e88b15cbf2de [/trunk] Changeset 40 by mikael
mikael
parents:
diff changeset
236 if (!strcmp(name, "magenta"))
e88b15cbf2de [/trunk] Changeset 40 by mikael
mikael
parents:
diff changeset
237 return COLOR_MAGENTA;
e88b15cbf2de [/trunk] Changeset 40 by mikael
mikael
parents:
diff changeset
238 if (!strcmp(name, "cyan"))
e88b15cbf2de [/trunk] Changeset 40 by mikael
mikael
parents:
diff changeset
239 return COLOR_CYAN;
e88b15cbf2de [/trunk] Changeset 40 by mikael
mikael
parents:
diff changeset
240 if (!strcmp(name, "white"))
e88b15cbf2de [/trunk] Changeset 40 by mikael
mikael
parents:
diff changeset
241 return COLOR_WHITE;
e88b15cbf2de [/trunk] Changeset 40 by mikael
mikael
parents:
diff changeset
242
1417
783b47c9d963 Allow more than the 16 default colors (patch from mjs)
Mikael Berthe <mikael@lilotux.net>
parents: 1414
diff changeset
243 // Directly support 256-color values
783b47c9d963 Allow more than the 16 default colors (patch from mjs)
Mikael Berthe <mikael@lilotux.net>
parents: 1414
diff changeset
244 result = atoi(name);
2029
ca40744c03be Do not warn when the configuration file contains 256-color values
Mikael Berthe <mikael@lilotux.net>
parents: 2028
diff changeset
245 if (result > 0 && (result < COLORS || !Curses))
1417
783b47c9d963 Allow more than the 16 default colors (patch from mjs)
Mikael Berthe <mikael@lilotux.net>
parents: 1414
diff changeset
246 return result;
783b47c9d963 Allow more than the 16 default colors (patch from mjs)
Mikael Berthe <mikael@lilotux.net>
parents: 1414
diff changeset
247
739
0d5fb1d9077c Allow "bright" text colors
Mikael Berthe <mikael@lilotux.net>
parents: 735
diff changeset
248 scr_LogPrint(LPRINT_LOGNORM, "ERROR: Wrong color: %s", name);
24
e88b15cbf2de [/trunk] Changeset 40 by mikael
mikael
parents:
diff changeset
249 return -1;
e88b15cbf2de [/trunk] Changeset 40 by mikael
mikael
parents:
diff changeset
250 }
e88b15cbf2de [/trunk] Changeset 40 by mikael
mikael
parents:
diff changeset
251
1598
a087125d8fc8 Replace libjabber with loudmouth
franky
parents: 1590
diff changeset
252 static ccolor *get_user_color(const char *color)
1295
33cb828282d5 Fix recognizing of bright colors
Michal 'vorner' Vaner <vorner@ucw.cz>
parents: 1294
diff changeset
253 {
1381
40095d413da9 Fix compilation on OpenBSD
Mikael Berthe <mikael@lilotux.net>
parents: 1376
diff changeset
254 bool isbright = FALSE;
1295
33cb828282d5 Fix recognizing of bright colors
Michal 'vorner' Vaner <vorner@ucw.cz>
parents: 1294
diff changeset
255 int cl;
1598
a087125d8fc8 Replace libjabber with loudmouth
franky
parents: 1590
diff changeset
256 ccolor *ccol;
1295
33cb828282d5 Fix recognizing of bright colors
Michal 'vorner' Vaner <vorner@ucw.cz>
parents: 1294
diff changeset
257 if (!strncmp(color, "bright", 6)) {
1381
40095d413da9 Fix compilation on OpenBSD
Mikael Berthe <mikael@lilotux.net>
parents: 1376
diff changeset
258 isbright = TRUE;
1295
33cb828282d5 Fix recognizing of bright colors
Michal 'vorner' Vaner <vorner@ucw.cz>
parents: 1294
diff changeset
259 color += 6;
33cb828282d5 Fix recognizing of bright colors
Michal 'vorner' Vaner <vorner@ucw.cz>
parents: 1294
diff changeset
260 }
1780
e4378fbab5d7 Major API cleanup - bump API to 4
Mikael Berthe <mikael@lilotux.net>
parents: 1761
diff changeset
261 cl = find_color(color);
1295
33cb828282d5 Fix recognizing of bright colors
Michal 'vorner' Vaner <vorner@ucw.cz>
parents: 1294
diff changeset
262 if (cl < 0)
1489
e9c71ce96dca Fixed the colorhandling for mucnicks and /color roster
franky@veqlargh.fs
parents: 1488
diff changeset
263 return NULL;
e9c71ce96dca Fixed the colorhandling for mucnicks and /color roster
franky@veqlargh.fs
parents: 1488
diff changeset
264 ccol = g_new0(ccolor, 1);
e9c71ce96dca Fixed the colorhandling for mucnicks and /color roster
franky@veqlargh.fs
parents: 1488
diff changeset
265 ccol->color_attrib = isbright ? A_BOLD : A_NORMAL;
1729
e6e89b1d7831 Minor style and header updates
Mikael Berthe <mikael@lilotux.net>
parents: 1710
diff changeset
266 ccol->color_pair = cl + COLOR_max; // User colors come after the internal ones
1489
e9c71ce96dca Fixed the colorhandling for mucnicks and /color roster
franky@veqlargh.fs
parents: 1488
diff changeset
267 return ccol;
1295
33cb828282d5 Fix recognizing of bright colors
Michal 'vorner' Vaner <vorner@ucw.cz>
parents: 1294
diff changeset
268 }
33cb828282d5 Fix recognizing of bright colors
Michal 'vorner' Vaner <vorner@ucw.cz>
parents: 1294
diff changeset
269
1292
382ec54b584e Muc nick coloring functionality
Michal 'vorner' Vaner <vorner@ucw.cz>
parents: 1291
diff changeset
270 static void ensure_string_htable(GHashTable **table,
1780
e4378fbab5d7 Major API cleanup - bump API to 4
Mikael Berthe <mikael@lilotux.net>
parents: 1761
diff changeset
271 GDestroyNotify value_destroy_func)
1292
382ec54b584e Muc nick coloring functionality
Michal 'vorner' Vaner <vorner@ucw.cz>
parents: 1291
diff changeset
272 {
1729
e6e89b1d7831 Minor style and header updates
Mikael Berthe <mikael@lilotux.net>
parents: 1710
diff changeset
273 if (*table) // Have it already
1292
382ec54b584e Muc nick coloring functionality
Michal 'vorner' Vaner <vorner@ucw.cz>
parents: 1291
diff changeset
274 return;
382ec54b584e Muc nick coloring functionality
Michal 'vorner' Vaner <vorner@ucw.cz>
parents: 1291
diff changeset
275 *table = g_hash_table_new_full(g_str_hash, g_str_equal,
382ec54b584e Muc nick coloring functionality
Michal 'vorner' Vaner <vorner@ucw.cz>
parents: 1291
diff changeset
276 g_free, value_destroy_func);
382ec54b584e Muc nick coloring functionality
Michal 'vorner' Vaner <vorner@ucw.cz>
parents: 1291
diff changeset
277 }
382ec54b584e Muc nick coloring functionality
Michal 'vorner' Vaner <vorner@ucw.cz>
parents: 1291
diff changeset
278
382ec54b584e Muc nick coloring functionality
Michal 'vorner' Vaner <vorner@ucw.cz>
parents: 1291
diff changeset
279 // Sets the coloring mode for given MUC
382ec54b584e Muc nick coloring functionality
Michal 'vorner' Vaner <vorner@ucw.cz>
parents: 1291
diff changeset
280 // The MUC room does not need to be in the roster at that time
382ec54b584e Muc nick coloring functionality
Michal 'vorner' Vaner <vorner@ucw.cz>
parents: 1291
diff changeset
281 // muc - the JID of room
382ec54b584e Muc nick coloring functionality
Michal 'vorner' Vaner <vorner@ucw.cz>
parents: 1291
diff changeset
282 // type - the new type
1780
e4378fbab5d7 Major API cleanup - bump API to 4
Mikael Berthe <mikael@lilotux.net>
parents: 1761
diff changeset
283 void scr_muc_color(const char *muc, muccoltype type)
1292
382ec54b584e Muc nick coloring functionality
Michal 'vorner' Vaner <vorner@ucw.cz>
parents: 1291
diff changeset
284 {
382ec54b584e Muc nick coloring functionality
Michal 'vorner' Vaner <vorner@ucw.cz>
parents: 1291
diff changeset
285 gchar *muclow = g_utf8_strdown(muc, -1);
1729
e6e89b1d7831 Minor style and header updates
Mikael Berthe <mikael@lilotux.net>
parents: 1710
diff changeset
286 if (type == MC_REMOVE) { // Remove it
1292
382ec54b584e Muc nick coloring functionality
Michal 'vorner' Vaner <vorner@ucw.cz>
parents: 1291
diff changeset
287 if (strcmp(muc, "*")) {
382ec54b584e Muc nick coloring functionality
Michal 'vorner' Vaner <vorner@ucw.cz>
parents: 1291
diff changeset
288 if (muccolors && g_hash_table_lookup(muccolors, muclow))
382ec54b584e Muc nick coloring functionality
Michal 'vorner' Vaner <vorner@ucw.cz>
parents: 1291
diff changeset
289 g_hash_table_remove(muccolors, muclow);
382ec54b584e Muc nick coloring functionality
Michal 'vorner' Vaner <vorner@ucw.cz>
parents: 1291
diff changeset
290 } else {
382ec54b584e Muc nick coloring functionality
Michal 'vorner' Vaner <vorner@ucw.cz>
parents: 1291
diff changeset
291 scr_LogPrint(LPRINT_NORMAL, "Can not remove global coloring mode");
382ec54b584e Muc nick coloring functionality
Michal 'vorner' Vaner <vorner@ucw.cz>
parents: 1291
diff changeset
292 }
382ec54b584e Muc nick coloring functionality
Michal 'vorner' Vaner <vorner@ucw.cz>
parents: 1291
diff changeset
293 g_free(muclow);
1729
e6e89b1d7831 Minor style and header updates
Mikael Berthe <mikael@lilotux.net>
parents: 1710
diff changeset
294 } else { // Add or overwrite
1292
382ec54b584e Muc nick coloring functionality
Michal 'vorner' Vaner <vorner@ucw.cz>
parents: 1291
diff changeset
295 if (strcmp(muc, "*")) {
382ec54b584e Muc nick coloring functionality
Michal 'vorner' Vaner <vorner@ucw.cz>
parents: 1291
diff changeset
296 muccoltype *value = g_new(muccoltype, 1);
382ec54b584e Muc nick coloring functionality
Michal 'vorner' Vaner <vorner@ucw.cz>
parents: 1291
diff changeset
297 *value = type;
1476
77afd831f8f7 Avoid mixed declarations and code
Mikael Berthe <mikael@lilotux.net>
parents: 1457
diff changeset
298 ensure_string_htable(&muccolors, g_free);
1292
382ec54b584e Muc nick coloring functionality
Michal 'vorner' Vaner <vorner@ucw.cz>
parents: 1291
diff changeset
299 g_hash_table_replace(muccolors, muclow, value);
382ec54b584e Muc nick coloring functionality
Michal 'vorner' Vaner <vorner@ucw.cz>
parents: 1291
diff changeset
300 } else {
382ec54b584e Muc nick coloring functionality
Michal 'vorner' Vaner <vorner@ucw.cz>
parents: 1291
diff changeset
301 glob_muccol = type;
382ec54b584e Muc nick coloring functionality
Michal 'vorner' Vaner <vorner@ucw.cz>
parents: 1291
diff changeset
302 g_free(muclow);
382ec54b584e Muc nick coloring functionality
Michal 'vorner' Vaner <vorner@ucw.cz>
parents: 1291
diff changeset
303 }
382ec54b584e Muc nick coloring functionality
Michal 'vorner' Vaner <vorner@ucw.cz>
parents: 1291
diff changeset
304 }
1729
e6e89b1d7831 Minor style and header updates
Mikael Berthe <mikael@lilotux.net>
parents: 1710
diff changeset
305 // Need to redraw?
1333
e30a9d907105 Minor coding style adjustments
Mikael Berthe <mikael@lilotux.net>
parents: 1314
diff changeset
306 if (chatmode &&
e30a9d907105 Minor coding style adjustments
Mikael Berthe <mikael@lilotux.net>
parents: 1314
diff changeset
307 ((buddy_search_jid(muc) == current_buddy) || !strcmp(muc, "*")))
1780
e4378fbab5d7 Major API cleanup - bump API to 4
Mikael Berthe <mikael@lilotux.net>
parents: 1761
diff changeset
308 scr_update_buddy_window();
1292
382ec54b584e Muc nick coloring functionality
Michal 'vorner' Vaner <vorner@ucw.cz>
parents: 1291
diff changeset
309 }
382ec54b584e Muc nick coloring functionality
Michal 'vorner' Vaner <vorner@ucw.cz>
parents: 1291
diff changeset
310
382ec54b584e Muc nick coloring functionality
Michal 'vorner' Vaner <vorner@ucw.cz>
parents: 1291
diff changeset
311 // Sets the color for nick in MUC
382ec54b584e Muc nick coloring functionality
Michal 'vorner' Vaner <vorner@ucw.cz>
parents: 1291
diff changeset
312 // If color is "-", the color is marked as automaticly assigned and is
382ec54b584e Muc nick coloring functionality
Michal 'vorner' Vaner <vorner@ucw.cz>
parents: 1291
diff changeset
313 // not used if the room is in the "preset" mode
1780
e4378fbab5d7 Major API cleanup - bump API to 4
Mikael Berthe <mikael@lilotux.net>
parents: 1761
diff changeset
314 void scr_muc_nick_color(const char *nick, const char *color)
1292
382ec54b584e Muc nick coloring functionality
Michal 'vorner' Vaner <vorner@ucw.cz>
parents: 1291
diff changeset
315 {
1333
e30a9d907105 Minor coding style adjustments
Mikael Berthe <mikael@lilotux.net>
parents: 1314
diff changeset
316 char *snick, *mnick;
1381
40095d413da9 Fix compilation on OpenBSD
Mikael Berthe <mikael@lilotux.net>
parents: 1376
diff changeset
317 bool need_update = FALSE;
1333
e30a9d907105 Minor coding style adjustments
Mikael Berthe <mikael@lilotux.net>
parents: 1314
diff changeset
318 snick = g_strdup_printf("<%s>", nick);
e30a9d907105 Minor coding style adjustments
Mikael Berthe <mikael@lilotux.net>
parents: 1314
diff changeset
319 mnick = g_strdup_printf("*%s ", nick);
1729
e6e89b1d7831 Minor style and header updates
Mikael Berthe <mikael@lilotux.net>
parents: 1710
diff changeset
320 if (!strcmp(color, "-")) { // Remove the color
1292
382ec54b584e Muc nick coloring functionality
Michal 'vorner' Vaner <vorner@ucw.cz>
parents: 1291
diff changeset
321 if (nickcolors) {
382ec54b584e Muc nick coloring functionality
Michal 'vorner' Vaner <vorner@ucw.cz>
parents: 1291
diff changeset
322 nickcolor *nc = g_hash_table_lookup(nickcolors, snick);
1729
e6e89b1d7831 Minor style and header updates
Mikael Berthe <mikael@lilotux.net>
parents: 1710
diff changeset
323 if (nc) { // Have this nick already
1381
40095d413da9 Fix compilation on OpenBSD
Mikael Berthe <mikael@lilotux.net>
parents: 1376
diff changeset
324 nc->manual = FALSE;
1292
382ec54b584e Muc nick coloring functionality
Michal 'vorner' Vaner <vorner@ucw.cz>
parents: 1291
diff changeset
325 nc = g_hash_table_lookup(nickcolors, mnick);
1729
e6e89b1d7831 Minor style and header updates
Mikael Berthe <mikael@lilotux.net>
parents: 1710
diff changeset
326 assert(nc); // Must have both at the same time
1381
40095d413da9 Fix compilation on OpenBSD
Mikael Berthe <mikael@lilotux.net>
parents: 1376
diff changeset
327 nc->manual = FALSE;
1292
382ec54b584e Muc nick coloring functionality
Michal 'vorner' Vaner <vorner@ucw.cz>
parents: 1291
diff changeset
328 }// Else -> no color saved, nothing to delete
382ec54b584e Muc nick coloring functionality
Michal 'vorner' Vaner <vorner@ucw.cz>
parents: 1291
diff changeset
329 }
1729
e6e89b1d7831 Minor style and header updates
Mikael Berthe <mikael@lilotux.net>
parents: 1710
diff changeset
330 g_free(snick); // They are not saved in the hash
1292
382ec54b584e Muc nick coloring functionality
Michal 'vorner' Vaner <vorner@ucw.cz>
parents: 1291
diff changeset
331 g_free(mnick);
1381
40095d413da9 Fix compilation on OpenBSD
Mikael Berthe <mikael@lilotux.net>
parents: 1376
diff changeset
332 need_update = TRUE;
1292
382ec54b584e Muc nick coloring functionality
Michal 'vorner' Vaner <vorner@ucw.cz>
parents: 1291
diff changeset
333 } else {
1598
a087125d8fc8 Replace libjabber with loudmouth
franky
parents: 1590
diff changeset
334 ccolor *cl = get_user_color(color);
1489
e9c71ce96dca Fixed the colorhandling for mucnicks and /color roster
franky@veqlargh.fs
parents: 1488
diff changeset
335 if (!cl) {
1292
382ec54b584e Muc nick coloring functionality
Michal 'vorner' Vaner <vorner@ucw.cz>
parents: 1291
diff changeset
336 scr_LogPrint(LPRINT_NORMAL, "No such color name");
382ec54b584e Muc nick coloring functionality
Michal 'vorner' Vaner <vorner@ucw.cz>
parents: 1291
diff changeset
337 g_free(snick);
382ec54b584e Muc nick coloring functionality
Michal 'vorner' Vaner <vorner@ucw.cz>
parents: 1291
diff changeset
338 g_free(mnick);
382ec54b584e Muc nick coloring functionality
Michal 'vorner' Vaner <vorner@ucw.cz>
parents: 1291
diff changeset
339 } else {
382ec54b584e Muc nick coloring functionality
Michal 'vorner' Vaner <vorner@ucw.cz>
parents: 1291
diff changeset
340 nickcolor *nc = g_new(nickcolor, 1);
382ec54b584e Muc nick coloring functionality
Michal 'vorner' Vaner <vorner@ucw.cz>
parents: 1291
diff changeset
341 ensure_string_htable(&nickcolors, NULL);
1381
40095d413da9 Fix compilation on OpenBSD
Mikael Berthe <mikael@lilotux.net>
parents: 1376
diff changeset
342 nc->manual = TRUE;
1292
382ec54b584e Muc nick coloring functionality
Michal 'vorner' Vaner <vorner@ucw.cz>
parents: 1291
diff changeset
343 nc->color = cl;
1729
e6e89b1d7831 Minor style and header updates
Mikael Berthe <mikael@lilotux.net>
parents: 1710
diff changeset
344 // Free the struct, if any there already
1292
382ec54b584e Muc nick coloring functionality
Michal 'vorner' Vaner <vorner@ucw.cz>
parents: 1291
diff changeset
345 g_free(g_hash_table_lookup(nickcolors, mnick));
1729
e6e89b1d7831 Minor style and header updates
Mikael Berthe <mikael@lilotux.net>
parents: 1710
diff changeset
346 // Save the new ones
1292
382ec54b584e Muc nick coloring functionality
Michal 'vorner' Vaner <vorner@ucw.cz>
parents: 1291
diff changeset
347 g_hash_table_replace(nickcolors, mnick, nc);
382ec54b584e Muc nick coloring functionality
Michal 'vorner' Vaner <vorner@ucw.cz>
parents: 1291
diff changeset
348 g_hash_table_replace(nickcolors, snick, nc);
1381
40095d413da9 Fix compilation on OpenBSD
Mikael Berthe <mikael@lilotux.net>
parents: 1376
diff changeset
349 need_update = TRUE;
1292
382ec54b584e Muc nick coloring functionality
Michal 'vorner' Vaner <vorner@ucw.cz>
parents: 1291
diff changeset
350 }
382ec54b584e Muc nick coloring functionality
Michal 'vorner' Vaner <vorner@ucw.cz>
parents: 1291
diff changeset
351 }
382ec54b584e Muc nick coloring functionality
Michal 'vorner' Vaner <vorner@ucw.cz>
parents: 1291
diff changeset
352 if (need_update && chatmode &&
382ec54b584e Muc nick coloring functionality
Michal 'vorner' Vaner <vorner@ucw.cz>
parents: 1291
diff changeset
353 (buddy_gettype(BUDDATA(current_buddy)) & ROSTER_TYPE_ROOM))
1780
e4378fbab5d7 Major API cleanup - bump API to 4
Mikael Berthe <mikael@lilotux.net>
parents: 1761
diff changeset
354 scr_update_buddy_window();
1292
382ec54b584e Muc nick coloring functionality
Michal 'vorner' Vaner <vorner@ucw.cz>
parents: 1291
diff changeset
355 }
382ec54b584e Muc nick coloring functionality
Michal 'vorner' Vaner <vorner@ucw.cz>
parents: 1291
diff changeset
356
1272
033576acac4c Add configurable roster colors (Michal 'vorner' Vaner)
Mikael Berthe <mikael@lilotux.net>
parents: 1268
diff changeset
357 static void free_rostercolrule(rostercolor *col)
033576acac4c Add configurable roster colors (Michal 'vorner' Vaner)
Mikael Berthe <mikael@lilotux.net>
parents: 1268
diff changeset
358 {
033576acac4c Add configurable roster colors (Michal 'vorner' Vaner)
Mikael Berthe <mikael@lilotux.net>
parents: 1268
diff changeset
359 g_free(col->status);
033576acac4c Add configurable roster colors (Michal 'vorner' Vaner)
Mikael Berthe <mikael@lilotux.net>
parents: 1268
diff changeset
360 g_free(col->wildcard);
1489
e9c71ce96dca Fixed the colorhandling for mucnicks and /color roster
franky@veqlargh.fs
parents: 1488
diff changeset
361 g_free(col->color);
1272
033576acac4c Add configurable roster colors (Michal 'vorner' Vaner)
Mikael Berthe <mikael@lilotux.net>
parents: 1268
diff changeset
362 g_pattern_spec_free(col->compiled);
033576acac4c Add configurable roster colors (Michal 'vorner' Vaner)
Mikael Berthe <mikael@lilotux.net>
parents: 1268
diff changeset
363 g_free(col);
033576acac4c Add configurable roster colors (Michal 'vorner' Vaner)
Mikael Berthe <mikael@lilotux.net>
parents: 1268
diff changeset
364 }
033576acac4c Add configurable roster colors (Michal 'vorner' Vaner)
Mikael Berthe <mikael@lilotux.net>
parents: 1268
diff changeset
365
1284
2c96720c4f5b Add comments (vorner)
Mikael Berthe <mikael@lilotux.net>
parents: 1280
diff changeset
366 // Removes all roster coloring rules
1780
e4378fbab5d7 Major API cleanup - bump API to 4
Mikael Berthe <mikael@lilotux.net>
parents: 1761
diff changeset
367 void scr_roster_clear_color(void)
1272
033576acac4c Add configurable roster colors (Michal 'vorner' Vaner)
Mikael Berthe <mikael@lilotux.net>
parents: 1268
diff changeset
368 {
033576acac4c Add configurable roster colors (Michal 'vorner' Vaner)
Mikael Berthe <mikael@lilotux.net>
parents: 1268
diff changeset
369 GSList *head;
033576acac4c Add configurable roster colors (Michal 'vorner' Vaner)
Mikael Berthe <mikael@lilotux.net>
parents: 1268
diff changeset
370 for (head = rostercolrules; head; head = g_slist_next(head)) {
033576acac4c Add configurable roster colors (Michal 'vorner' Vaner)
Mikael Berthe <mikael@lilotux.net>
parents: 1268
diff changeset
371 free_rostercolrule(head->data);
033576acac4c Add configurable roster colors (Michal 'vorner' Vaner)
Mikael Berthe <mikael@lilotux.net>
parents: 1268
diff changeset
372 }
033576acac4c Add configurable roster colors (Michal 'vorner' Vaner)
Mikael Berthe <mikael@lilotux.net>
parents: 1268
diff changeset
373 g_slist_free(rostercolrules);
033576acac4c Add configurable roster colors (Michal 'vorner' Vaner)
Mikael Berthe <mikael@lilotux.net>
parents: 1268
diff changeset
374 rostercolrules = NULL;
033576acac4c Add configurable roster colors (Michal 'vorner' Vaner)
Mikael Berthe <mikael@lilotux.net>
parents: 1268
diff changeset
375 }
033576acac4c Add configurable roster colors (Michal 'vorner' Vaner)
Mikael Berthe <mikael@lilotux.net>
parents: 1268
diff changeset
376
1284
2c96720c4f5b Add comments (vorner)
Mikael Berthe <mikael@lilotux.net>
parents: 1280
diff changeset
377 // Adds, modifies or removes roster coloring rule
2c96720c4f5b Add comments (vorner)
Mikael Berthe <mikael@lilotux.net>
parents: 1280
diff changeset
378 // color set to "-" removes the rule,
2c96720c4f5b Add comments (vorner)
Mikael Berthe <mikael@lilotux.net>
parents: 1280
diff changeset
379 // otherwise it is modified (if exists) or added
2c96720c4f5b Add comments (vorner)
Mikael Berthe <mikael@lilotux.net>
parents: 1280
diff changeset
380 //
2c96720c4f5b Add comments (vorner)
Mikael Berthe <mikael@lilotux.net>
parents: 1280
diff changeset
381 // Returns weather it was successfull (therefore the roster should be
2c96720c4f5b Add comments (vorner)
Mikael Berthe <mikael@lilotux.net>
parents: 1280
diff changeset
382 // redrawed) or not. If it failed, for example because of invalid color
2c96720c4f5b Add comments (vorner)
Mikael Berthe <mikael@lilotux.net>
parents: 1280
diff changeset
383 // name, it also prints the error.
1780
e4378fbab5d7 Major API cleanup - bump API to 4
Mikael Berthe <mikael@lilotux.net>
parents: 1761
diff changeset
384 bool scr_roster_color(const char *status, const char *wildcard,
e4378fbab5d7 Major API cleanup - bump API to 4
Mikael Berthe <mikael@lilotux.net>
parents: 1761
diff changeset
385 const char *color)
1272
033576acac4c Add configurable roster colors (Michal 'vorner' Vaner)
Mikael Berthe <mikael@lilotux.net>
parents: 1268
diff changeset
386 {
033576acac4c Add configurable roster colors (Michal 'vorner' Vaner)
Mikael Berthe <mikael@lilotux.net>
parents: 1268
diff changeset
387 GSList *head;
033576acac4c Add configurable roster colors (Michal 'vorner' Vaner)
Mikael Berthe <mikael@lilotux.net>
parents: 1268
diff changeset
388 GSList *found = NULL;
033576acac4c Add configurable roster colors (Michal 'vorner' Vaner)
Mikael Berthe <mikael@lilotux.net>
parents: 1268
diff changeset
389 for (head = rostercolrules; head; head = g_slist_next(head)) {
033576acac4c Add configurable roster colors (Michal 'vorner' Vaner)
Mikael Berthe <mikael@lilotux.net>
parents: 1268
diff changeset
390 rostercolor *rc = head->data;
033576acac4c Add configurable roster colors (Michal 'vorner' Vaner)
Mikael Berthe <mikael@lilotux.net>
parents: 1268
diff changeset
391 if ((!strcmp(status, rc->status)) && (!strcmp(wildcard, rc->wildcard))) {
033576acac4c Add configurable roster colors (Michal 'vorner' Vaner)
Mikael Berthe <mikael@lilotux.net>
parents: 1268
diff changeset
392 found = head;
033576acac4c Add configurable roster colors (Michal 'vorner' Vaner)
Mikael Berthe <mikael@lilotux.net>
parents: 1268
diff changeset
393 break;
033576acac4c Add configurable roster colors (Michal 'vorner' Vaner)
Mikael Berthe <mikael@lilotux.net>
parents: 1268
diff changeset
394 }
033576acac4c Add configurable roster colors (Michal 'vorner' Vaner)
Mikael Berthe <mikael@lilotux.net>
parents: 1268
diff changeset
395 }
1729
e6e89b1d7831 Minor style and header updates
Mikael Berthe <mikael@lilotux.net>
parents: 1710
diff changeset
396 if (!strcmp(color,"-")) { // Delete the rule
1272
033576acac4c Add configurable roster colors (Michal 'vorner' Vaner)
Mikael Berthe <mikael@lilotux.net>
parents: 1268
diff changeset
397 if (found) {
033576acac4c Add configurable roster colors (Michal 'vorner' Vaner)
Mikael Berthe <mikael@lilotux.net>
parents: 1268
diff changeset
398 free_rostercolrule(found->data);
033576acac4c Add configurable roster colors (Michal 'vorner' Vaner)
Mikael Berthe <mikael@lilotux.net>
parents: 1268
diff changeset
399 rostercolrules = g_slist_delete_link(rostercolrules, found);
033576acac4c Add configurable roster colors (Michal 'vorner' Vaner)
Mikael Berthe <mikael@lilotux.net>
parents: 1268
diff changeset
400 return TRUE;
033576acac4c Add configurable roster colors (Michal 'vorner' Vaner)
Mikael Berthe <mikael@lilotux.net>
parents: 1268
diff changeset
401 } else {
033576acac4c Add configurable roster colors (Michal 'vorner' Vaner)
Mikael Berthe <mikael@lilotux.net>
parents: 1268
diff changeset
402 scr_LogPrint(LPRINT_NORMAL, "No such color rule, nothing removed");
033576acac4c Add configurable roster colors (Michal 'vorner' Vaner)
Mikael Berthe <mikael@lilotux.net>
parents: 1268
diff changeset
403 return FALSE;
033576acac4c Add configurable roster colors (Michal 'vorner' Vaner)
Mikael Berthe <mikael@lilotux.net>
parents: 1268
diff changeset
404 }
033576acac4c Add configurable roster colors (Michal 'vorner' Vaner)
Mikael Berthe <mikael@lilotux.net>
parents: 1268
diff changeset
405 } else {
1598
a087125d8fc8 Replace libjabber with loudmouth
franky
parents: 1590
diff changeset
406 ccolor *cl = get_user_color(color);
1489
e9c71ce96dca Fixed the colorhandling for mucnicks and /color roster
franky@veqlargh.fs
parents: 1488
diff changeset
407 if (!cl) {
1272
033576acac4c Add configurable roster colors (Michal 'vorner' Vaner)
Mikael Berthe <mikael@lilotux.net>
parents: 1268
diff changeset
408 scr_LogPrint(LPRINT_NORMAL, "No such color name");
033576acac4c Add configurable roster colors (Michal 'vorner' Vaner)
Mikael Berthe <mikael@lilotux.net>
parents: 1268
diff changeset
409 return FALSE;
033576acac4c Add configurable roster colors (Michal 'vorner' Vaner)
Mikael Berthe <mikael@lilotux.net>
parents: 1268
diff changeset
410 }
033576acac4c Add configurable roster colors (Michal 'vorner' Vaner)
Mikael Berthe <mikael@lilotux.net>
parents: 1268
diff changeset
411 if (found) {
033576acac4c Add configurable roster colors (Michal 'vorner' Vaner)
Mikael Berthe <mikael@lilotux.net>
parents: 1268
diff changeset
412 rostercolor *rc = found->data;
1489
e9c71ce96dca Fixed the colorhandling for mucnicks and /color roster
franky@veqlargh.fs
parents: 1488
diff changeset
413 g_free(rc->color);
1272
033576acac4c Add configurable roster colors (Michal 'vorner' Vaner)
Mikael Berthe <mikael@lilotux.net>
parents: 1268
diff changeset
414 rc->color = cl;
033576acac4c Add configurable roster colors (Michal 'vorner' Vaner)
Mikael Berthe <mikael@lilotux.net>
parents: 1268
diff changeset
415 } else {
033576acac4c Add configurable roster colors (Michal 'vorner' Vaner)
Mikael Berthe <mikael@lilotux.net>
parents: 1268
diff changeset
416 rostercolor *rc = g_new(rostercolor, 1);
033576acac4c Add configurable roster colors (Michal 'vorner' Vaner)
Mikael Berthe <mikael@lilotux.net>
parents: 1268
diff changeset
417 rc->status = g_strdup(status);
033576acac4c Add configurable roster colors (Michal 'vorner' Vaner)
Mikael Berthe <mikael@lilotux.net>
parents: 1268
diff changeset
418 rc->wildcard = g_strdup(wildcard);
033576acac4c Add configurable roster colors (Michal 'vorner' Vaner)
Mikael Berthe <mikael@lilotux.net>
parents: 1268
diff changeset
419 rc->compiled = g_pattern_spec_new(wildcard);
033576acac4c Add configurable roster colors (Michal 'vorner' Vaner)
Mikael Berthe <mikael@lilotux.net>
parents: 1268
diff changeset
420 rc->color = cl;
033576acac4c Add configurable roster colors (Michal 'vorner' Vaner)
Mikael Berthe <mikael@lilotux.net>
parents: 1268
diff changeset
421 rostercolrules = g_slist_prepend(rostercolrules, rc);
033576acac4c Add configurable roster colors (Michal 'vorner' Vaner)
Mikael Berthe <mikael@lilotux.net>
parents: 1268
diff changeset
422 }
033576acac4c Add configurable roster colors (Michal 'vorner' Vaner)
Mikael Berthe <mikael@lilotux.net>
parents: 1268
diff changeset
423 return TRUE;
033576acac4c Add configurable roster colors (Michal 'vorner' Vaner)
Mikael Berthe <mikael@lilotux.net>
parents: 1268
diff changeset
424 }
033576acac4c Add configurable roster colors (Michal 'vorner' Vaner)
Mikael Berthe <mikael@lilotux.net>
parents: 1268
diff changeset
425 }
033576acac4c Add configurable roster colors (Michal 'vorner' Vaner)
Mikael Berthe <mikael@lilotux.net>
parents: 1268
diff changeset
426
1780
e4378fbab5d7 Major API cleanup - bump API to 4
Mikael Berthe <mikael@lilotux.net>
parents: 1761
diff changeset
427 static void parse_colors(void)
24
e88b15cbf2de [/trunk] Changeset 40 by mikael
mikael
parents:
diff changeset
428 {
739
0d5fb1d9077c Allow "bright" text colors
Mikael Berthe <mikael@lilotux.net>
parents: 735
diff changeset
429 const char *colors[] = {
24
e88b15cbf2de [/trunk] Changeset 40 by mikael
mikael
parents:
diff changeset
430 "", "",
267
8d3d5bd52da3 Improve color configuration
mikael@frmp8452
parents: 265
diff changeset
431 "general",
785
7e0562e3bc83 Replace color_highlight with color_msgout
Mikael Berthe <mikael@lilotux.net>
parents: 779
diff changeset
432 "msgout",
1204
e802ec0c02d2 Basic support for nick highlighting in MUC rooms (the whole line is colored)
Mikael Berthe <mikael@lilotux.net>
parents: 1190
diff changeset
433 "msghl",
711
75dde88f1884 Introduce status lines
Mikael Berthe <mikael@lilotux.net>
parents: 709
diff changeset
434 "status",
2028
7b5bd6ad83b4 Add 'color_log' (text color in the log window)
Mikael Berthe <mikael@lilotux.net>
parents: 2015
diff changeset
435 "log",
712
e1639629c87b Rename color options
Mikael Berthe <mikael@lilotux.net>
parents: 711
diff changeset
436 "roster",
e1639629c87b Rename color options
Mikael Berthe <mikael@lilotux.net>
parents: 711
diff changeset
437 "rostersel",
723
23068490d063 Add text color when the selected buddy has an unread message
Mikael Berthe <mikael@lilotux.net>
parents: 721
diff changeset
438 "rosterselmsg",
712
e1639629c87b Rename color options
Mikael Berthe <mikael@lilotux.net>
parents: 711
diff changeset
439 "rosternewmsg",
1268
dbc907b2d92f Add configurable colors for info and incoming messages (Michal 'vorner' Vaner)
Mikael Berthe <mikael@lilotux.net>
parents: 1254
diff changeset
440 "info",
dbc907b2d92f Add configurable colors for info and incoming messages (Michal 'vorner' Vaner)
Mikael Berthe <mikael@lilotux.net>
parents: 1254
diff changeset
441 "msgin",
1960
b596bcff758e Add 'color_readmark'
Mikael Berthe <mikael@lilotux.net>
parents: 1957
diff changeset
442 "readmark",
24
e88b15cbf2de [/trunk] Changeset 40 by mikael
mikael
parents:
diff changeset
443 NULL
e88b15cbf2de [/trunk] Changeset 40 by mikael
mikael
parents:
diff changeset
444 };
e88b15cbf2de [/trunk] Changeset 40 by mikael
mikael
parents:
diff changeset
445
281
f562b9af2de7 Add "const" specifier in prototypes
Mikael Berthe <mikael@lilotux.net>
parents: 279
diff changeset
446 const char *color;
f562b9af2de7 Add "const" specifier in prototypes
Mikael Berthe <mikael@lilotux.net>
parents: 279
diff changeset
447 const char *background = settings_opt_get("color_background");
712
e1639629c87b Rename color options
Mikael Berthe <mikael@lilotux.net>
parents: 711
diff changeset
448 const char *backselected = settings_opt_get("color_bgrostersel");
e1639629c87b Rename color options
Mikael Berthe <mikael@lilotux.net>
parents: 711
diff changeset
449 const char *backstatus = settings_opt_get("color_bgstatus");
739
0d5fb1d9077c Allow "bright" text colors
Mikael Berthe <mikael@lilotux.net>
parents: 735
diff changeset
450 char *tmp;
0d5fb1d9077c Allow "bright" text colors
Mikael Berthe <mikael@lilotux.net>
parents: 735
diff changeset
451 int i;
0d5fb1d9077c Allow "bright" text colors
Mikael Berthe <mikael@lilotux.net>
parents: 735
diff changeset
452
0d5fb1d9077c Allow "bright" text colors
Mikael Berthe <mikael@lilotux.net>
parents: 735
diff changeset
453 // Initialize color attributes
0d5fb1d9077c Allow "bright" text colors
Mikael Berthe <mikael@lilotux.net>
parents: 735
diff changeset
454 memset(COLOR_ATTRIB, 0, sizeof(COLOR_ATTRIB));
24
e88b15cbf2de [/trunk] Changeset 40 by mikael
mikael
parents:
diff changeset
455
267
8d3d5bd52da3 Improve color configuration
mikael@frmp8452
parents: 265
diff changeset
456 // Default values
711
75dde88f1884 Introduce status lines
Mikael Berthe <mikael@lilotux.net>
parents: 709
diff changeset
457 if (!background) background = "black";
267
8d3d5bd52da3 Improve color configuration
mikael@frmp8452
parents: 265
diff changeset
458 if (!backselected) backselected = "cyan";
711
75dde88f1884 Introduce status lines
Mikael Berthe <mikael@lilotux.net>
parents: 709
diff changeset
459 if (!backstatus) backstatus = "blue";
267
8d3d5bd52da3 Improve color configuration
mikael@frmp8452
parents: 265
diff changeset
460
739
0d5fb1d9077c Allow "bright" text colors
Mikael Berthe <mikael@lilotux.net>
parents: 735
diff changeset
461 for (i=0; colors[i]; i++) {
0d5fb1d9077c Allow "bright" text colors
Mikael Berthe <mikael@lilotux.net>
parents: 735
diff changeset
462 tmp = g_strdup_printf("color_%s", colors[i]);
279
f5dd437c057b Rewrite the settings system
Mikael Berthe <mikael@lilotux.net>
parents: 276
diff changeset
463 color = settings_opt_get(tmp);
739
0d5fb1d9077c Allow "bright" text colors
Mikael Berthe <mikael@lilotux.net>
parents: 735
diff changeset
464 g_free(tmp);
0d5fb1d9077c Allow "bright" text colors
Mikael Berthe <mikael@lilotux.net>
parents: 735
diff changeset
465
0d5fb1d9077c Allow "bright" text colors
Mikael Berthe <mikael@lilotux.net>
parents: 735
diff changeset
466 if (color) {
0d5fb1d9077c Allow "bright" text colors
Mikael Berthe <mikael@lilotux.net>
parents: 735
diff changeset
467 if (!strncmp(color, "bright", 6)) {
0d5fb1d9077c Allow "bright" text colors
Mikael Berthe <mikael@lilotux.net>
parents: 735
diff changeset
468 COLOR_ATTRIB[i+1] = A_BOLD;
0d5fb1d9077c Allow "bright" text colors
Mikael Berthe <mikael@lilotux.net>
parents: 735
diff changeset
469 color += 6;
0d5fb1d9077c Allow "bright" text colors
Mikael Berthe <mikael@lilotux.net>
parents: 735
diff changeset
470 }
0d5fb1d9077c Allow "bright" text colors
Mikael Berthe <mikael@lilotux.net>
parents: 735
diff changeset
471 }
24
e88b15cbf2de [/trunk] Changeset 40 by mikael
mikael
parents:
diff changeset
472
e88b15cbf2de [/trunk] Changeset 40 by mikael
mikael
parents:
diff changeset
473 switch (i + 1) {
739
0d5fb1d9077c Allow "bright" text colors
Mikael Berthe <mikael@lilotux.net>
parents: 735
diff changeset
474 case 1:
0d5fb1d9077c Allow "bright" text colors
Mikael Berthe <mikael@lilotux.net>
parents: 735
diff changeset
475 init_pair(1, COLOR_BLACK, COLOR_WHITE);
0d5fb1d9077c Allow "bright" text colors
Mikael Berthe <mikael@lilotux.net>
parents: 735
diff changeset
476 break;
0d5fb1d9077c Allow "bright" text colors
Mikael Berthe <mikael@lilotux.net>
parents: 735
diff changeset
477 case 2:
0d5fb1d9077c Allow "bright" text colors
Mikael Berthe <mikael@lilotux.net>
parents: 735
diff changeset
478 init_pair(2, COLOR_WHITE, COLOR_BLACK);
0d5fb1d9077c Allow "bright" text colors
Mikael Berthe <mikael@lilotux.net>
parents: 735
diff changeset
479 break;
0d5fb1d9077c Allow "bright" text colors
Mikael Berthe <mikael@lilotux.net>
parents: 735
diff changeset
480 case COLOR_GENERAL:
1780
e4378fbab5d7 Major API cleanup - bump API to 4
Mikael Berthe <mikael@lilotux.net>
parents: 1761
diff changeset
481 init_pair(i+1, ((color) ? find_color(color) : COLOR_WHITE),
e4378fbab5d7 Major API cleanup - bump API to 4
Mikael Berthe <mikael@lilotux.net>
parents: 1761
diff changeset
482 find_color(background));
739
0d5fb1d9077c Allow "bright" text colors
Mikael Berthe <mikael@lilotux.net>
parents: 735
diff changeset
483 break;
785
7e0562e3bc83 Replace color_highlight with color_msgout
Mikael Berthe <mikael@lilotux.net>
parents: 779
diff changeset
484 case COLOR_MSGOUT:
1780
e4378fbab5d7 Major API cleanup - bump API to 4
Mikael Berthe <mikael@lilotux.net>
parents: 1761
diff changeset
485 init_pair(i+1, ((color) ? find_color(color) : COLOR_CYAN),
e4378fbab5d7 Major API cleanup - bump API to 4
Mikael Berthe <mikael@lilotux.net>
parents: 1761
diff changeset
486 find_color(background));
739
0d5fb1d9077c Allow "bright" text colors
Mikael Berthe <mikael@lilotux.net>
parents: 735
diff changeset
487 break;
1204
e802ec0c02d2 Basic support for nick highlighting in MUC rooms (the whole line is colored)
Mikael Berthe <mikael@lilotux.net>
parents: 1190
diff changeset
488 case COLOR_MSGHL:
1780
e4378fbab5d7 Major API cleanup - bump API to 4
Mikael Berthe <mikael@lilotux.net>
parents: 1761
diff changeset
489 init_pair(i+1, ((color) ? find_color(color) : COLOR_YELLOW),
e4378fbab5d7 Major API cleanup - bump API to 4
Mikael Berthe <mikael@lilotux.net>
parents: 1761
diff changeset
490 find_color(background));
1204
e802ec0c02d2 Basic support for nick highlighting in MUC rooms (the whole line is colored)
Mikael Berthe <mikael@lilotux.net>
parents: 1190
diff changeset
491 break;
739
0d5fb1d9077c Allow "bright" text colors
Mikael Berthe <mikael@lilotux.net>
parents: 735
diff changeset
492 case COLOR_STATUS:
1780
e4378fbab5d7 Major API cleanup - bump API to 4
Mikael Berthe <mikael@lilotux.net>
parents: 1761
diff changeset
493 init_pair(i+1, ((color) ? find_color(color) : COLOR_WHITE),
e4378fbab5d7 Major API cleanup - bump API to 4
Mikael Berthe <mikael@lilotux.net>
parents: 1761
diff changeset
494 find_color(backstatus));
739
0d5fb1d9077c Allow "bright" text colors
Mikael Berthe <mikael@lilotux.net>
parents: 735
diff changeset
495 break;
2028
7b5bd6ad83b4 Add 'color_log' (text color in the log window)
Mikael Berthe <mikael@lilotux.net>
parents: 2015
diff changeset
496 case COLOR_LOG:
7b5bd6ad83b4 Add 'color_log' (text color in the log window)
Mikael Berthe <mikael@lilotux.net>
parents: 2015
diff changeset
497 init_pair(i+1, ((color) ? find_color(color) : COLOR_WHITE),
7b5bd6ad83b4 Add 'color_log' (text color in the log window)
Mikael Berthe <mikael@lilotux.net>
parents: 2015
diff changeset
498 find_color(background));
7b5bd6ad83b4 Add 'color_log' (text color in the log window)
Mikael Berthe <mikael@lilotux.net>
parents: 2015
diff changeset
499 break;
739
0d5fb1d9077c Allow "bright" text colors
Mikael Berthe <mikael@lilotux.net>
parents: 735
diff changeset
500 case COLOR_ROSTER:
1780
e4378fbab5d7 Major API cleanup - bump API to 4
Mikael Berthe <mikael@lilotux.net>
parents: 1761
diff changeset
501 init_pair(i+1, ((color) ? find_color(color) : COLOR_GREEN),
e4378fbab5d7 Major API cleanup - bump API to 4
Mikael Berthe <mikael@lilotux.net>
parents: 1761
diff changeset
502 find_color(background));
739
0d5fb1d9077c Allow "bright" text colors
Mikael Berthe <mikael@lilotux.net>
parents: 735
diff changeset
503 break;
0d5fb1d9077c Allow "bright" text colors
Mikael Berthe <mikael@lilotux.net>
parents: 735
diff changeset
504 case COLOR_ROSTERSEL:
1780
e4378fbab5d7 Major API cleanup - bump API to 4
Mikael Berthe <mikael@lilotux.net>
parents: 1761
diff changeset
505 init_pair(i+1, ((color) ? find_color(color) : COLOR_BLUE),
e4378fbab5d7 Major API cleanup - bump API to 4
Mikael Berthe <mikael@lilotux.net>
parents: 1761
diff changeset
506 find_color(backselected));
739
0d5fb1d9077c Allow "bright" text colors
Mikael Berthe <mikael@lilotux.net>
parents: 735
diff changeset
507 break;
0d5fb1d9077c Allow "bright" text colors
Mikael Berthe <mikael@lilotux.net>
parents: 735
diff changeset
508 case COLOR_ROSTERSELNMSG:
1780
e4378fbab5d7 Major API cleanup - bump API to 4
Mikael Berthe <mikael@lilotux.net>
parents: 1761
diff changeset
509 init_pair(i+1, ((color) ? find_color(color) : COLOR_RED),
e4378fbab5d7 Major API cleanup - bump API to 4
Mikael Berthe <mikael@lilotux.net>
parents: 1761
diff changeset
510 find_color(backselected));
739
0d5fb1d9077c Allow "bright" text colors
Mikael Berthe <mikael@lilotux.net>
parents: 735
diff changeset
511 break;
0d5fb1d9077c Allow "bright" text colors
Mikael Berthe <mikael@lilotux.net>
parents: 735
diff changeset
512 case COLOR_ROSTERNMSG:
1780
e4378fbab5d7 Major API cleanup - bump API to 4
Mikael Berthe <mikael@lilotux.net>
parents: 1761
diff changeset
513 init_pair(i+1, ((color) ? find_color(color) : COLOR_RED),
e4378fbab5d7 Major API cleanup - bump API to 4
Mikael Berthe <mikael@lilotux.net>
parents: 1761
diff changeset
514 find_color(background));
739
0d5fb1d9077c Allow "bright" text colors
Mikael Berthe <mikael@lilotux.net>
parents: 735
diff changeset
515 break;
1268
dbc907b2d92f Add configurable colors for info and incoming messages (Michal 'vorner' Vaner)
Mikael Berthe <mikael@lilotux.net>
parents: 1254
diff changeset
516 case COLOR_INFO:
1780
e4378fbab5d7 Major API cleanup - bump API to 4
Mikael Berthe <mikael@lilotux.net>
parents: 1761
diff changeset
517 init_pair(i+1, ((color) ? find_color(color) : COLOR_WHITE),
e4378fbab5d7 Major API cleanup - bump API to 4
Mikael Berthe <mikael@lilotux.net>
parents: 1761
diff changeset
518 find_color(background));
1268
dbc907b2d92f Add configurable colors for info and incoming messages (Michal 'vorner' Vaner)
Mikael Berthe <mikael@lilotux.net>
parents: 1254
diff changeset
519 break;
dbc907b2d92f Add configurable colors for info and incoming messages (Michal 'vorner' Vaner)
Mikael Berthe <mikael@lilotux.net>
parents: 1254
diff changeset
520 case COLOR_MSGIN:
1780
e4378fbab5d7 Major API cleanup - bump API to 4
Mikael Berthe <mikael@lilotux.net>
parents: 1761
diff changeset
521 init_pair(i+1, ((color) ? find_color(color) : COLOR_WHITE),
e4378fbab5d7 Major API cleanup - bump API to 4
Mikael Berthe <mikael@lilotux.net>
parents: 1761
diff changeset
522 find_color(background));
1268
dbc907b2d92f Add configurable colors for info and incoming messages (Michal 'vorner' Vaner)
Mikael Berthe <mikael@lilotux.net>
parents: 1254
diff changeset
523 break;
1960
b596bcff758e Add 'color_readmark'
Mikael Berthe <mikael@lilotux.net>
parents: 1957
diff changeset
524 case COLOR_READMARK:
b596bcff758e Add 'color_readmark'
Mikael Berthe <mikael@lilotux.net>
parents: 1957
diff changeset
525 init_pair(i+1, ((color) ? find_color(color) : COLOR_RED),
b596bcff758e Add 'color_readmark'
Mikael Berthe <mikael@lilotux.net>
parents: 1957
diff changeset
526 find_color(background));
b596bcff758e Add 'color_readmark'
Mikael Berthe <mikael@lilotux.net>
parents: 1957
diff changeset
527 break;
24
e88b15cbf2de [/trunk] Changeset 40 by mikael
mikael
parents:
diff changeset
528 }
e88b15cbf2de [/trunk] Changeset 40 by mikael
mikael
parents:
diff changeset
529 }
1489
e9c71ce96dca Fixed the colorhandling for mucnicks and /color roster
franky@veqlargh.fs
parents: 1488
diff changeset
530 for (i = COLOR_max; i < (COLOR_max + COLORS); i++)
1780
e4378fbab5d7 Major API cleanup - bump API to 4
Mikael Berthe <mikael@lilotux.net>
parents: 1761
diff changeset
531 init_pair(i, i-COLOR_max, find_color(background));
1489
e9c71ce96dca Fixed the colorhandling for mucnicks and /color roster
franky@veqlargh.fs
parents: 1488
diff changeset
532
1298
af035a304bec colorable muc nick fix
Michal 'vorner' Vaner <vorner@ucw.cz>
parents: 1296
diff changeset
533 if (!nickcols) {
1314
248e3f69dd9e Fix a bug in the nick_colors variable parsing
Mikael Berthe <mikael@lilotux.net>
parents: 1311
diff changeset
534 char *ncolors = g_strdup(settings_opt_get("nick_colors"));
1298
af035a304bec colorable muc nick fix
Michal 'vorner' Vaner <vorner@ucw.cz>
parents: 1296
diff changeset
535 if (ncolors) {
1314
248e3f69dd9e Fix a bug in the nick_colors variable parsing
Mikael Berthe <mikael@lilotux.net>
parents: 1311
diff changeset
536 char *ncolor_start, *ncolor_end;
248e3f69dd9e Fix a bug in the nick_colors variable parsing
Mikael Berthe <mikael@lilotux.net>
parents: 1311
diff changeset
537 ncolor_start = ncolor_end = ncolors;
248e3f69dd9e Fix a bug in the nick_colors variable parsing
Mikael Berthe <mikael@lilotux.net>
parents: 1311
diff changeset
538
248e3f69dd9e Fix a bug in the nick_colors variable parsing
Mikael Berthe <mikael@lilotux.net>
parents: 1311
diff changeset
539 while (*ncolor_end)
248e3f69dd9e Fix a bug in the nick_colors variable parsing
Mikael Berthe <mikael@lilotux.net>
parents: 1311
diff changeset
540 ncolor_end++;
248e3f69dd9e Fix a bug in the nick_colors variable parsing
Mikael Berthe <mikael@lilotux.net>
parents: 1311
diff changeset
541
248e3f69dd9e Fix a bug in the nick_colors variable parsing
Mikael Berthe <mikael@lilotux.net>
parents: 1311
diff changeset
542 while (ncolors < ncolor_end && *ncolors) {
1298
af035a304bec colorable muc nick fix
Michal 'vorner' Vaner <vorner@ucw.cz>
parents: 1296
diff changeset
543 if ((*ncolors == ' ') || (*ncolors == '\t')) {
1314
248e3f69dd9e Fix a bug in the nick_colors variable parsing
Mikael Berthe <mikael@lilotux.net>
parents: 1311
diff changeset
544 ncolors++;
1292
382ec54b584e Muc nick coloring functionality
Michal 'vorner' Vaner <vorner@ucw.cz>
parents: 1291
diff changeset
545 } else {
1298
af035a304bec colorable muc nick fix
Michal 'vorner' Vaner <vorner@ucw.cz>
parents: 1296
diff changeset
546 char *end = ncolors;
1598
a087125d8fc8 Replace libjabber with loudmouth
franky
parents: 1590
diff changeset
547 ccolor *cl;
1298
af035a304bec colorable muc nick fix
Michal 'vorner' Vaner <vorner@ucw.cz>
parents: 1296
diff changeset
548 while (*end && (*end != ' ') && (*end != '\t'))
af035a304bec colorable muc nick fix
Michal 'vorner' Vaner <vorner@ucw.cz>
parents: 1296
diff changeset
549 end++;
af035a304bec colorable muc nick fix
Michal 'vorner' Vaner <vorner@ucw.cz>
parents: 1296
diff changeset
550 *end = '\0';
1314
248e3f69dd9e Fix a bug in the nick_colors variable parsing
Mikael Berthe <mikael@lilotux.net>
parents: 1311
diff changeset
551 cl = get_user_color(ncolors);
1489
e9c71ce96dca Fixed the colorhandling for mucnicks and /color roster
franky@veqlargh.fs
parents: 1488
diff changeset
552 if (!cl) {
1298
af035a304bec colorable muc nick fix
Michal 'vorner' Vaner <vorner@ucw.cz>
parents: 1296
diff changeset
553 scr_LogPrint(LPRINT_NORMAL, "Unknown color %s", ncolors);
af035a304bec colorable muc nick fix
Michal 'vorner' Vaner <vorner@ucw.cz>
parents: 1296
diff changeset
554 } else {
af035a304bec colorable muc nick fix
Michal 'vorner' Vaner <vorner@ucw.cz>
parents: 1296
diff changeset
555 nickcols = g_realloc(nickcols, (++nickcolcount) * sizeof *nickcols);
af035a304bec colorable muc nick fix
Michal 'vorner' Vaner <vorner@ucw.cz>
parents: 1296
diff changeset
556 nickcols[nickcolcount-1] = cl;
af035a304bec colorable muc nick fix
Michal 'vorner' Vaner <vorner@ucw.cz>
parents: 1296
diff changeset
557 }
1314
248e3f69dd9e Fix a bug in the nick_colors variable parsing
Mikael Berthe <mikael@lilotux.net>
parents: 1311
diff changeset
558 ncolors = end+1;
1292
382ec54b584e Muc nick coloring functionality
Michal 'vorner' Vaner <vorner@ucw.cz>
parents: 1291
diff changeset
559 }
382ec54b584e Muc nick coloring functionality
Michal 'vorner' Vaner <vorner@ucw.cz>
parents: 1291
diff changeset
560 }
1298
af035a304bec colorable muc nick fix
Michal 'vorner' Vaner <vorner@ucw.cz>
parents: 1296
diff changeset
561 g_free(ncolor_start);
1292
382ec54b584e Muc nick coloring functionality
Michal 'vorner' Vaner <vorner@ucw.cz>
parents: 1291
diff changeset
562 }
1729
e6e89b1d7831 Minor style and header updates
Mikael Berthe <mikael@lilotux.net>
parents: 1710
diff changeset
563 if (!nickcols) { // Fallback to have something
1298
af035a304bec colorable muc nick fix
Michal 'vorner' Vaner <vorner@ucw.cz>
parents: 1296
diff changeset
564 nickcolcount = 1;
1489
e9c71ce96dca Fixed the colorhandling for mucnicks and /color roster
franky@veqlargh.fs
parents: 1488
diff changeset
565 nickcols = g_new(ccolor*, 1);
e9c71ce96dca Fixed the colorhandling for mucnicks and /color roster
franky@veqlargh.fs
parents: 1488
diff changeset
566 *nickcols = g_new(ccolor, 1);
e9c71ce96dca Fixed the colorhandling for mucnicks and /color roster
franky@veqlargh.fs
parents: 1488
diff changeset
567 (*nickcols)->color_pair = COLOR_GENERAL;
e9c71ce96dca Fixed the colorhandling for mucnicks and /color roster
franky@veqlargh.fs
parents: 1488
diff changeset
568 (*nickcols)->color_attrib = A_NORMAL;
1298
af035a304bec colorable muc nick fix
Michal 'vorner' Vaner <vorner@ucw.cz>
parents: 1296
diff changeset
569 }
1292
382ec54b584e Muc nick coloring functionality
Michal 'vorner' Vaner <vorner@ucw.cz>
parents: 1291
diff changeset
570 }
1942
3e39a336a992 Use guards for colors (Myhailo Danylenko)
Mikael Berthe <mikael@lilotux.net>
parents: 1935
diff changeset
571
3e39a336a992 Use guards for colors (Myhailo Danylenko)
Mikael Berthe <mikael@lilotux.net>
parents: 1935
diff changeset
572 colors_stalled = FALSE;
24
e88b15cbf2de [/trunk] Changeset 40 by mikael
mikael
parents:
diff changeset
573 }
e88b15cbf2de [/trunk] Changeset 40 by mikael
mikael
parents:
diff changeset
574
765
72626e9d60bd Create init_keycodes(), add 2 screen escape sequences
Mikael Berthe <mikael@lilotux.net>
parents: 764
diff changeset
575 static void init_keycodes(void)
373
af2f8ddf6a1b Move (reorganize) functions
Mikael Berthe <mikael@lilotux.net>
parents: 370
diff changeset
576 {
761
4532a9fe0e8c Handle some keyboard escape sequences
Mikael Berthe <mikael@lilotux.net>
parents: 760
diff changeset
577 add_keyseq("O5A", MKEY_EQUIV, 521); // Ctrl-Up
4532a9fe0e8c Handle some keyboard escape sequences
Mikael Berthe <mikael@lilotux.net>
parents: 760
diff changeset
578 add_keyseq("O5B", MKEY_EQUIV, 514); // Ctrl-Down
4532a9fe0e8c Handle some keyboard escape sequences
Mikael Berthe <mikael@lilotux.net>
parents: 760
diff changeset
579 add_keyseq("O5C", MKEY_EQUIV, 518); // Ctrl-Right
4532a9fe0e8c Handle some keyboard escape sequences
Mikael Berthe <mikael@lilotux.net>
parents: 760
diff changeset
580 add_keyseq("O5D", MKEY_EQUIV, 516); // Ctrl-Left
763
6866ee749225 More keycodes
Mikael Berthe <mikael@lilotux.net>
parents: 762
diff changeset
581 add_keyseq("O6A", MKEY_EQUIV, 520); // Shift-Up
6866ee749225 More keycodes
Mikael Berthe <mikael@lilotux.net>
parents: 762
diff changeset
582 add_keyseq("O6B", MKEY_EQUIV, 513); // Shift-Down
6866ee749225 More keycodes
Mikael Berthe <mikael@lilotux.net>
parents: 762
diff changeset
583 add_keyseq("O6C", MKEY_EQUIV, 402); // Shift-Right
6866ee749225 More keycodes
Mikael Berthe <mikael@lilotux.net>
parents: 762
diff changeset
584 add_keyseq("O6D", MKEY_EQUIV, 393); // Shift-Left
6866ee749225 More keycodes
Mikael Berthe <mikael@lilotux.net>
parents: 762
diff changeset
585 add_keyseq("O2A", MKEY_EQUIV, 520); // Shift-Up
6866ee749225 More keycodes
Mikael Berthe <mikael@lilotux.net>
parents: 762
diff changeset
586 add_keyseq("O2B", MKEY_EQUIV, 513); // Shift-Down
6866ee749225 More keycodes
Mikael Berthe <mikael@lilotux.net>
parents: 762
diff changeset
587 add_keyseq("O2C", MKEY_EQUIV, 402); // Shift-Right
6866ee749225 More keycodes
Mikael Berthe <mikael@lilotux.net>
parents: 762
diff changeset
588 add_keyseq("O2D", MKEY_EQUIV, 393); // Shift-Left
6866ee749225 More keycodes
Mikael Berthe <mikael@lilotux.net>
parents: 762
diff changeset
589 add_keyseq("[5^", MKEY_CTRL_PGUP, 0); // Ctrl-PageUp
6866ee749225 More keycodes
Mikael Berthe <mikael@lilotux.net>
parents: 762
diff changeset
590 add_keyseq("[6^", MKEY_CTRL_PGDOWN, 0); // Ctrl-PageDown
6866ee749225 More keycodes
Mikael Berthe <mikael@lilotux.net>
parents: 762
diff changeset
591 add_keyseq("[5@", MKEY_CTRL_SHIFT_PGUP, 0); // Ctrl-Shift-PageUp
6866ee749225 More keycodes
Mikael Berthe <mikael@lilotux.net>
parents: 762
diff changeset
592 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
593 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
594 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
595 add_keyseq("[8^", MKEY_CTRL_END, 0); // Ctrl-End
32d5298f9f8d Add a few keycode sequences
Mikael Berthe <mikael@lilotux.net>
parents: 790
diff changeset
596 add_keyseq("[7^", MKEY_CTRL_HOME, 0); // Ctrl-Home
32d5298f9f8d Add a few keycode sequences
Mikael Berthe <mikael@lilotux.net>
parents: 790
diff changeset
597 add_keyseq("[2^", MKEY_CTRL_INS, 0); // Ctrl-Insert
32d5298f9f8d Add a few keycode sequences
Mikael Berthe <mikael@lilotux.net>
parents: 790
diff changeset
598 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
599
4532a9fe0e8c Handle some keyboard escape sequences
Mikael Berthe <mikael@lilotux.net>
parents: 760
diff changeset
600 // Xterm
4532a9fe0e8c Handle some keyboard escape sequences
Mikael Berthe <mikael@lilotux.net>
parents: 760
diff changeset
601 add_keyseq("[1;5A", MKEY_EQUIV, 521); // Ctrl-Up
4532a9fe0e8c Handle some keyboard escape sequences
Mikael Berthe <mikael@lilotux.net>
parents: 760
diff changeset
602 add_keyseq("[1;5B", MKEY_EQUIV, 514); // Ctrl-Down
4532a9fe0e8c Handle some keyboard escape sequences
Mikael Berthe <mikael@lilotux.net>
parents: 760
diff changeset
603 add_keyseq("[1;5C", MKEY_EQUIV, 518); // Ctrl-Right
4532a9fe0e8c Handle some keyboard escape sequences
Mikael Berthe <mikael@lilotux.net>
parents: 760
diff changeset
604 add_keyseq("[1;5D", MKEY_EQUIV, 516); // Ctrl-Left
4532a9fe0e8c Handle some keyboard escape sequences
Mikael Berthe <mikael@lilotux.net>
parents: 760
diff changeset
605 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
606 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
607 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
608 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
609 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
610 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
611 add_keyseq("[1;2A", MKEY_EQUIV, 521); // Shift-Up
6866ee749225 More keycodes
Mikael Berthe <mikael@lilotux.net>
parents: 762
diff changeset
612 add_keyseq("[1;2B", MKEY_EQUIV, 514); // Shift-Down
6866ee749225 More keycodes
Mikael Berthe <mikael@lilotux.net>
parents: 762
diff changeset
613 add_keyseq("[5;5~", MKEY_CTRL_PGUP, 0); // Ctrl-PageUp
6866ee749225 More keycodes
Mikael Berthe <mikael@lilotux.net>
parents: 762
diff changeset
614 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
615 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
616 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
617 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
618 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
619
768
0f6d25a02450 Add PuTTY escape keys for Ctrl-arrows
Mikael Berthe <mikael@lilotux.net>
parents: 766
diff changeset
620 // PuTTY
0f6d25a02450 Add PuTTY escape keys for Ctrl-arrows
Mikael Berthe <mikael@lilotux.net>
parents: 766
diff changeset
621 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
622 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
623 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
624 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
625
762
96d46e00524a Add some key escape sequences for screen
Mikael Berthe <mikael@lilotux.net>
parents: 761
diff changeset
626 // screen
96d46e00524a Add some key escape sequences for screen
Mikael Berthe <mikael@lilotux.net>
parents: 761
diff changeset
627 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
628 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
629 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
630 add_keyseq("Od", MKEY_EQUIV, 516); // Ctrl-Left
763
6866ee749225 More keycodes
Mikael Berthe <mikael@lilotux.net>
parents: 762
diff changeset
631 add_keyseq("[a", MKEY_EQUIV, 520); // Shift-Up
6866ee749225 More keycodes
Mikael Berthe <mikael@lilotux.net>
parents: 762
diff changeset
632 add_keyseq("[b", MKEY_EQUIV, 513); // Shift-Down
6866ee749225 More keycodes
Mikael Berthe <mikael@lilotux.net>
parents: 762
diff changeset
633 add_keyseq("[c", MKEY_EQUIV, 402); // Shift-Right
6866ee749225 More keycodes
Mikael Berthe <mikael@lilotux.net>
parents: 762
diff changeset
634 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
635 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
636 add_keyseq("[6$", MKEY_SHIFT_PGDOWN, 0); // Shift-PageDown
1170
29f805d8412f Add some keycodes
Mikael Berthe <mikael@lilotux.net>
parents: 1168
diff changeset
637
29f805d8412f Add some keycodes
Mikael Berthe <mikael@lilotux.net>
parents: 1168
diff changeset
638 // VT100
29f805d8412f Add some keycodes
Mikael Berthe <mikael@lilotux.net>
parents: 1168
diff changeset
639 add_keyseq("[H", MKEY_EQUIV, KEY_HOME); // Home
29f805d8412f Add some keycodes
Mikael Berthe <mikael@lilotux.net>
parents: 1168
diff changeset
640 add_keyseq("[F", MKEY_EQUIV, KEY_END); // End
29f805d8412f Add some keycodes
Mikael Berthe <mikael@lilotux.net>
parents: 1168
diff changeset
641
29f805d8412f Add some keycodes
Mikael Berthe <mikael@lilotux.net>
parents: 1168
diff changeset
642 // Konsole Linux
29f805d8412f Add some keycodes
Mikael Berthe <mikael@lilotux.net>
parents: 1168
diff changeset
643 add_keyseq("[1~", MKEY_EQUIV, KEY_HOME); // Home
29f805d8412f Add some keycodes
Mikael Berthe <mikael@lilotux.net>
parents: 1168
diff changeset
644 add_keyseq("[4~", MKEY_EQUIV, KEY_END); // End
765
72626e9d60bd Create init_keycodes(), add 2 screen escape sequences
Mikael Berthe <mikael@lilotux.net>
parents: 764
diff changeset
645 }
72626e9d60bd Create init_keycodes(), add 2 screen escape sequences
Mikael Berthe <mikael@lilotux.net>
parents: 764
diff changeset
646
1176
547a8ca7c1a8 Move init_bindings() to screen.c, with a few updates
Mikael Berthe <mikael@lilotux.net>
parents: 1173
diff changeset
647 // scr_init_bindings()
547a8ca7c1a8 Move init_bindings() to screen.c, with a few updates
Mikael Berthe <mikael@lilotux.net>
parents: 1173
diff changeset
648 // Create default key bindings
547a8ca7c1a8 Move init_bindings() to screen.c, with a few updates
Mikael Berthe <mikael@lilotux.net>
parents: 1173
diff changeset
649 // Return 0 if error and 1 if none
547a8ca7c1a8 Move init_bindings() to screen.c, with a few updates
Mikael Berthe <mikael@lilotux.net>
parents: 1173
diff changeset
650 void scr_init_bindings(void)
547a8ca7c1a8 Move init_bindings() to screen.c, with a few updates
Mikael Berthe <mikael@lilotux.net>
parents: 1173
diff changeset
651 {
547a8ca7c1a8 Move init_bindings() to screen.c, with a few updates
Mikael Berthe <mikael@lilotux.net>
parents: 1173
diff changeset
652 GString *sbuf = g_string_new("");
547a8ca7c1a8 Move init_bindings() to screen.c, with a few updates
Mikael Berthe <mikael@lilotux.net>
parents: 1173
diff changeset
653
547a8ca7c1a8 Move init_bindings() to screen.c, with a few updates
Mikael Berthe <mikael@lilotux.net>
parents: 1173
diff changeset
654 // Common backspace key codes: 8, 127
547a8ca7c1a8 Move init_bindings() to screen.c, with a few updates
Mikael Berthe <mikael@lilotux.net>
parents: 1173
diff changeset
655 settings_set(SETTINGS_TYPE_BINDING, "8", "iline char_bdel"); // Ctrl-h
547a8ca7c1a8 Move init_bindings() to screen.c, with a few updates
Mikael Berthe <mikael@lilotux.net>
parents: 1173
diff changeset
656 settings_set(SETTINGS_TYPE_BINDING, "127", "iline char_bdel");
547a8ca7c1a8 Move init_bindings() to screen.c, with a few updates
Mikael Berthe <mikael@lilotux.net>
parents: 1173
diff changeset
657 g_string_printf(sbuf, "%d", KEY_BACKSPACE);
547a8ca7c1a8 Move init_bindings() to screen.c, with a few updates
Mikael Berthe <mikael@lilotux.net>
parents: 1173
diff changeset
658 settings_set(SETTINGS_TYPE_BINDING, sbuf->str, "iline char_bdel");
547a8ca7c1a8 Move init_bindings() to screen.c, with a few updates
Mikael Berthe <mikael@lilotux.net>
parents: 1173
diff changeset
659 g_string_printf(sbuf, "%d", KEY_DC);
547a8ca7c1a8 Move init_bindings() to screen.c, with a few updates
Mikael Berthe <mikael@lilotux.net>
parents: 1173
diff changeset
660 settings_set(SETTINGS_TYPE_BINDING, sbuf->str, "iline char_fdel");
547a8ca7c1a8 Move init_bindings() to screen.c, with a few updates
Mikael Berthe <mikael@lilotux.net>
parents: 1173
diff changeset
661 g_string_printf(sbuf, "%d", KEY_LEFT);
547a8ca7c1a8 Move init_bindings() to screen.c, with a few updates
Mikael Berthe <mikael@lilotux.net>
parents: 1173
diff changeset
662 settings_set(SETTINGS_TYPE_BINDING, sbuf->str, "iline bchar");
547a8ca7c1a8 Move init_bindings() to screen.c, with a few updates
Mikael Berthe <mikael@lilotux.net>
parents: 1173
diff changeset
663 g_string_printf(sbuf, "%d", KEY_RIGHT);
547a8ca7c1a8 Move init_bindings() to screen.c, with a few updates
Mikael Berthe <mikael@lilotux.net>
parents: 1173
diff changeset
664 settings_set(SETTINGS_TYPE_BINDING, sbuf->str, "iline fchar");
547a8ca7c1a8 Move init_bindings() to screen.c, with a few updates
Mikael Berthe <mikael@lilotux.net>
parents: 1173
diff changeset
665 settings_set(SETTINGS_TYPE_BINDING, "7", "iline compl_cancel"); // Ctrl-g
547a8ca7c1a8 Move init_bindings() to screen.c, with a few updates
Mikael Berthe <mikael@lilotux.net>
parents: 1173
diff changeset
666 g_string_printf(sbuf, "%d", KEY_UP);
1190
be06bbe7e449 Add readline_hist_beginning_search_bwd/fwd functions
Mikael Berthe <mikael@lilotux.net>
parents: 1187
diff changeset
667 settings_set(SETTINGS_TYPE_BINDING, sbuf->str,
be06bbe7e449 Add readline_hist_beginning_search_bwd/fwd functions
Mikael Berthe <mikael@lilotux.net>
parents: 1187
diff changeset
668 "iline hist_beginning_search_bwd");
1176
547a8ca7c1a8 Move init_bindings() to screen.c, with a few updates
Mikael Berthe <mikael@lilotux.net>
parents: 1173
diff changeset
669 g_string_printf(sbuf, "%d", KEY_DOWN);
1190
be06bbe7e449 Add readline_hist_beginning_search_bwd/fwd functions
Mikael Berthe <mikael@lilotux.net>
parents: 1187
diff changeset
670 settings_set(SETTINGS_TYPE_BINDING, sbuf->str,
be06bbe7e449 Add readline_hist_beginning_search_bwd/fwd functions
Mikael Berthe <mikael@lilotux.net>
parents: 1187
diff changeset
671 "iline hist_beginning_search_fwd");
1176
547a8ca7c1a8 Move init_bindings() to screen.c, with a few updates
Mikael Berthe <mikael@lilotux.net>
parents: 1173
diff changeset
672 g_string_printf(sbuf, "%d", KEY_PPAGE);
547a8ca7c1a8 Move init_bindings() to screen.c, with a few updates
Mikael Berthe <mikael@lilotux.net>
parents: 1173
diff changeset
673 settings_set(SETTINGS_TYPE_BINDING, sbuf->str, "roster up");
547a8ca7c1a8 Move init_bindings() to screen.c, with a few updates
Mikael Berthe <mikael@lilotux.net>
parents: 1173
diff changeset
674 g_string_printf(sbuf, "%d", KEY_NPAGE);
547a8ca7c1a8 Move init_bindings() to screen.c, with a few updates
Mikael Berthe <mikael@lilotux.net>
parents: 1173
diff changeset
675 settings_set(SETTINGS_TYPE_BINDING, sbuf->str, "roster down");
547a8ca7c1a8 Move init_bindings() to screen.c, with a few updates
Mikael Berthe <mikael@lilotux.net>
parents: 1173
diff changeset
676 g_string_printf(sbuf, "%d", KEY_HOME);
547a8ca7c1a8 Move init_bindings() to screen.c, with a few updates
Mikael Berthe <mikael@lilotux.net>
parents: 1173
diff changeset
677 settings_set(SETTINGS_TYPE_BINDING, sbuf->str, "iline iline_start");
547a8ca7c1a8 Move init_bindings() to screen.c, with a few updates
Mikael Berthe <mikael@lilotux.net>
parents: 1173
diff changeset
678 settings_set(SETTINGS_TYPE_BINDING, "1", "iline iline_start"); // Ctrl-a
547a8ca7c1a8 Move init_bindings() to screen.c, with a few updates
Mikael Berthe <mikael@lilotux.net>
parents: 1173
diff changeset
679 g_string_printf(sbuf, "%d", KEY_END);
547a8ca7c1a8 Move init_bindings() to screen.c, with a few updates
Mikael Berthe <mikael@lilotux.net>
parents: 1173
diff changeset
680 settings_set(SETTINGS_TYPE_BINDING, sbuf->str, "iline iline_end");
547a8ca7c1a8 Move init_bindings() to screen.c, with a few updates
Mikael Berthe <mikael@lilotux.net>
parents: 1173
diff changeset
681 settings_set(SETTINGS_TYPE_BINDING, "5", "iline iline_end"); // Ctrl-e
547a8ca7c1a8 Move init_bindings() to screen.c, with a few updates
Mikael Berthe <mikael@lilotux.net>
parents: 1173
diff changeset
682 // Ctrl-o (accept-line-and-down-history):
547a8ca7c1a8 Move init_bindings() to screen.c, with a few updates
Mikael Berthe <mikael@lilotux.net>
parents: 1173
diff changeset
683 settings_set(SETTINGS_TYPE_BINDING, "15", "iline iline_accept_down_hist");
547a8ca7c1a8 Move init_bindings() to screen.c, with a few updates
Mikael Berthe <mikael@lilotux.net>
parents: 1173
diff changeset
684 settings_set(SETTINGS_TYPE_BINDING, "21", "iline iline_bdel"); // Ctrl-u
547a8ca7c1a8 Move init_bindings() to screen.c, with a few updates
Mikael Berthe <mikael@lilotux.net>
parents: 1173
diff changeset
685 g_string_printf(sbuf, "%d", KEY_EOL);
547a8ca7c1a8 Move init_bindings() to screen.c, with a few updates
Mikael Berthe <mikael@lilotux.net>
parents: 1173
diff changeset
686 settings_set(SETTINGS_TYPE_BINDING, sbuf->str, "iline iline_fdel");
547a8ca7c1a8 Move init_bindings() to screen.c, with a few updates
Mikael Berthe <mikael@lilotux.net>
parents: 1173
diff changeset
687 settings_set(SETTINGS_TYPE_BINDING, "11", "iline iline_fdel"); // Ctrl-k
547a8ca7c1a8 Move init_bindings() to screen.c, with a few updates
Mikael Berthe <mikael@lilotux.net>
parents: 1173
diff changeset
688 settings_set(SETTINGS_TYPE_BINDING, "16", "buffer up"); // Ctrl-p
547a8ca7c1a8 Move init_bindings() to screen.c, with a few updates
Mikael Berthe <mikael@lilotux.net>
parents: 1173
diff changeset
689 settings_set(SETTINGS_TYPE_BINDING, "14", "buffer down"); // Ctrl-n
547a8ca7c1a8 Move init_bindings() to screen.c, with a few updates
Mikael Berthe <mikael@lilotux.net>
parents: 1173
diff changeset
690 settings_set(SETTINGS_TYPE_BINDING, "20", "iline char_swap"); // Ctrl-t
547a8ca7c1a8 Move init_bindings() to screen.c, with a few updates
Mikael Berthe <mikael@lilotux.net>
parents: 1173
diff changeset
691 settings_set(SETTINGS_TYPE_BINDING, "23", "iline word_bdel"); // Ctrl-w
547a8ca7c1a8 Move init_bindings() to screen.c, with a few updates
Mikael Berthe <mikael@lilotux.net>
parents: 1173
diff changeset
692 settings_set(SETTINGS_TYPE_BINDING, "M98", "iline bword"); // Meta-b
547a8ca7c1a8 Move init_bindings() to screen.c, with a few updates
Mikael Berthe <mikael@lilotux.net>
parents: 1173
diff changeset
693 settings_set(SETTINGS_TYPE_BINDING, "M102", "iline fword"); // Meta-f
1186
0158bd8ca9d6 Add a default binding to Meta-d (iline word_fdel)
Mikael Berthe <mikael@lilotux.net>
parents: 1185
diff changeset
694 settings_set(SETTINGS_TYPE_BINDING, "M100", "iline word_fdel"); // Meta-d
1176
547a8ca7c1a8 Move init_bindings() to screen.c, with a few updates
Mikael Berthe <mikael@lilotux.net>
parents: 1173
diff changeset
695 // Ctrl-Left (2 codes):
547a8ca7c1a8 Move init_bindings() to screen.c, with a few updates
Mikael Berthe <mikael@lilotux.net>
parents: 1173
diff changeset
696 settings_set(SETTINGS_TYPE_BINDING, "515", "iline bword");
547a8ca7c1a8 Move init_bindings() to screen.c, with a few updates
Mikael Berthe <mikael@lilotux.net>
parents: 1173
diff changeset
697 settings_set(SETTINGS_TYPE_BINDING, "516", "iline bword");
547a8ca7c1a8 Move init_bindings() to screen.c, with a few updates
Mikael Berthe <mikael@lilotux.net>
parents: 1173
diff changeset
698 // Ctrl-Right (2 codes):
547a8ca7c1a8 Move init_bindings() to screen.c, with a few updates
Mikael Berthe <mikael@lilotux.net>
parents: 1173
diff changeset
699 settings_set(SETTINGS_TYPE_BINDING, "517", "iline fword");
547a8ca7c1a8 Move init_bindings() to screen.c, with a few updates
Mikael Berthe <mikael@lilotux.net>
parents: 1173
diff changeset
700 settings_set(SETTINGS_TYPE_BINDING, "518", "iline fword");
547a8ca7c1a8 Move init_bindings() to screen.c, with a few updates
Mikael Berthe <mikael@lilotux.net>
parents: 1173
diff changeset
701 settings_set(SETTINGS_TYPE_BINDING, "12", "screen_refresh"); // Ctrl-l
1503
c74cfe7fd848 Add option --show-roster to command chat_disable.
Mikael Berthe <mikael@lilotux.net>
parents: 1502
diff changeset
702 settings_set(SETTINGS_TYPE_BINDING, "27", "chat_disable --show-roster");// Esc
1185
5c34af370b67 Bind Meta-Esc (Esc-Esc) to chat_disable by default
Mikael Berthe <mikael@lilotux.net>
parents: 1179
diff changeset
703 settings_set(SETTINGS_TYPE_BINDING, "M27", "chat_disable"); // Esc-Esc
1176
547a8ca7c1a8 Move init_bindings() to screen.c, with a few updates
Mikael Berthe <mikael@lilotux.net>
parents: 1173
diff changeset
704 settings_set(SETTINGS_TYPE_BINDING, "4", "iline send_multiline"); // Ctrl-d
547a8ca7c1a8 Move init_bindings() to screen.c, with a few updates
Mikael Berthe <mikael@lilotux.net>
parents: 1173
diff changeset
705 settings_set(SETTINGS_TYPE_BINDING, "M117", "iline word_upcase"); // Meta-u
547a8ca7c1a8 Move init_bindings() to screen.c, with a few updates
Mikael Berthe <mikael@lilotux.net>
parents: 1173
diff changeset
706 settings_set(SETTINGS_TYPE_BINDING, "M108", "iline word_downcase"); // Meta-l
547a8ca7c1a8 Move init_bindings() to screen.c, with a few updates
Mikael Berthe <mikael@lilotux.net>
parents: 1173
diff changeset
707 settings_set(SETTINGS_TYPE_BINDING, "M99", "iline word_capit"); // Meta-c
547a8ca7c1a8 Move init_bindings() to screen.c, with a few updates
Mikael Berthe <mikael@lilotux.net>
parents: 1173
diff changeset
708
1208
0dbe51d1e62e Add default binding for F1 (265) to /help
Mikael Berthe <mikael@lilotux.net>
parents: 1205
diff changeset
709 settings_set(SETTINGS_TYPE_BINDING, "265", "help"); // Bind F1 to help...
0dbe51d1e62e Add default binding for F1 (265) to /help
Mikael Berthe <mikael@lilotux.net>
parents: 1205
diff changeset
710
1176
547a8ca7c1a8 Move init_bindings() to screen.c, with a few updates
Mikael Berthe <mikael@lilotux.net>
parents: 1173
diff changeset
711 g_string_free(sbuf, TRUE);
547a8ca7c1a8 Move init_bindings() to screen.c, with a few updates
Mikael Berthe <mikael@lilotux.net>
parents: 1173
diff changeset
712 }
547a8ca7c1a8 Move init_bindings() to screen.c, with a few updates
Mikael Berthe <mikael@lilotux.net>
parents: 1173
diff changeset
713
1229
e9ea1497ac9d Fix a key binding issue on FreeBSD
Mikael Berthe <mikael@lilotux.net>
parents: 1228
diff changeset
714 // is_speckey(key)
e9ea1497ac9d Fix a key binding issue on FreeBSD
Mikael Berthe <mikael@lilotux.net>
parents: 1228
diff changeset
715 // Return TRUE if key is a special code, i.e. no char should be displayed on
e9ea1497ac9d Fix a key binding issue on FreeBSD
Mikael Berthe <mikael@lilotux.net>
parents: 1228
diff changeset
716 // the screen. It's not very nice, it's a workaround for the systems where
e9ea1497ac9d Fix a key binding issue on FreeBSD
Mikael Berthe <mikael@lilotux.net>
parents: 1228
diff changeset
717 // isprint(KEY_PPAGE) returns TRUE...
e9ea1497ac9d Fix a key binding issue on FreeBSD
Mikael Berthe <mikael@lilotux.net>
parents: 1228
diff changeset
718 static int is_speckey(int key)
e9ea1497ac9d Fix a key binding issue on FreeBSD
Mikael Berthe <mikael@lilotux.net>
parents: 1228
diff changeset
719 {
e9ea1497ac9d Fix a key binding issue on FreeBSD
Mikael Berthe <mikael@lilotux.net>
parents: 1228
diff changeset
720 switch (key) {
e9ea1497ac9d Fix a key binding issue on FreeBSD
Mikael Berthe <mikael@lilotux.net>
parents: 1228
diff changeset
721 case 127:
e9ea1497ac9d Fix a key binding issue on FreeBSD
Mikael Berthe <mikael@lilotux.net>
parents: 1228
diff changeset
722 case 393:
e9ea1497ac9d Fix a key binding issue on FreeBSD
Mikael Berthe <mikael@lilotux.net>
parents: 1228
diff changeset
723 case 402:
e9ea1497ac9d Fix a key binding issue on FreeBSD
Mikael Berthe <mikael@lilotux.net>
parents: 1228
diff changeset
724 case KEY_BACKSPACE:
e9ea1497ac9d Fix a key binding issue on FreeBSD
Mikael Berthe <mikael@lilotux.net>
parents: 1228
diff changeset
725 case KEY_DC:
e9ea1497ac9d Fix a key binding issue on FreeBSD
Mikael Berthe <mikael@lilotux.net>
parents: 1228
diff changeset
726 case KEY_LEFT:
e9ea1497ac9d Fix a key binding issue on FreeBSD
Mikael Berthe <mikael@lilotux.net>
parents: 1228
diff changeset
727 case KEY_RIGHT:
e9ea1497ac9d Fix a key binding issue on FreeBSD
Mikael Berthe <mikael@lilotux.net>
parents: 1228
diff changeset
728 case KEY_UP:
e9ea1497ac9d Fix a key binding issue on FreeBSD
Mikael Berthe <mikael@lilotux.net>
parents: 1228
diff changeset
729 case KEY_DOWN:
e9ea1497ac9d Fix a key binding issue on FreeBSD
Mikael Berthe <mikael@lilotux.net>
parents: 1228
diff changeset
730 case KEY_PPAGE:
e9ea1497ac9d Fix a key binding issue on FreeBSD
Mikael Berthe <mikael@lilotux.net>
parents: 1228
diff changeset
731 case KEY_NPAGE:
e9ea1497ac9d Fix a key binding issue on FreeBSD
Mikael Berthe <mikael@lilotux.net>
parents: 1228
diff changeset
732 case KEY_HOME:
e9ea1497ac9d Fix a key binding issue on FreeBSD
Mikael Berthe <mikael@lilotux.net>
parents: 1228
diff changeset
733 case KEY_END:
e9ea1497ac9d Fix a key binding issue on FreeBSD
Mikael Berthe <mikael@lilotux.net>
parents: 1228
diff changeset
734 case KEY_EOL:
e9ea1497ac9d Fix a key binding issue on FreeBSD
Mikael Berthe <mikael@lilotux.net>
parents: 1228
diff changeset
735 return TRUE;
e9ea1497ac9d Fix a key binding issue on FreeBSD
Mikael Berthe <mikael@lilotux.net>
parents: 1228
diff changeset
736 }
e9ea1497ac9d Fix a key binding issue on FreeBSD
Mikael Berthe <mikael@lilotux.net>
parents: 1228
diff changeset
737
e9ea1497ac9d Fix a key binding issue on FreeBSD
Mikael Berthe <mikael@lilotux.net>
parents: 1228
diff changeset
738 // Fn keys
e9ea1497ac9d Fix a key binding issue on FreeBSD
Mikael Berthe <mikael@lilotux.net>
parents: 1228
diff changeset
739 if (key >= 265 && key < 265+12)
e9ea1497ac9d Fix a key binding issue on FreeBSD
Mikael Berthe <mikael@lilotux.net>
parents: 1228
diff changeset
740 return TRUE;
e9ea1497ac9d Fix a key binding issue on FreeBSD
Mikael Berthe <mikael@lilotux.net>
parents: 1228
diff changeset
741
e9ea1497ac9d Fix a key binding issue on FreeBSD
Mikael Berthe <mikael@lilotux.net>
parents: 1228
diff changeset
742 // Special key combinations
e9ea1497ac9d Fix a key binding issue on FreeBSD
Mikael Berthe <mikael@lilotux.net>
parents: 1228
diff changeset
743 if (key >= 513 && key <= 521)
e9ea1497ac9d Fix a key binding issue on FreeBSD
Mikael Berthe <mikael@lilotux.net>
parents: 1228
diff changeset
744 return TRUE;
e9ea1497ac9d Fix a key binding issue on FreeBSD
Mikael Berthe <mikael@lilotux.net>
parents: 1228
diff changeset
745
e9ea1497ac9d Fix a key binding issue on FreeBSD
Mikael Berthe <mikael@lilotux.net>
parents: 1228
diff changeset
746 return FALSE;
e9ea1497ac9d Fix a key binding issue on FreeBSD
Mikael Berthe <mikael@lilotux.net>
parents: 1228
diff changeset
747 }
e9ea1497ac9d Fix a key binding issue on FreeBSD
Mikael Berthe <mikael@lilotux.net>
parents: 1228
diff changeset
748
1780
e4378fbab5d7 Major API cleanup - bump API to 4
Mikael Berthe <mikael@lilotux.net>
parents: 1761
diff changeset
749 void scr_init_locale_charset(void)
779
057ffe7c43dc Initialize locale charset earlier
Mikael Berthe <mikael@lilotux.net>
parents: 773
diff changeset
750 {
1651
d0a0d96ed5d5 Set all locale variables
Myhailo Danylenko <isbear@ukrpost.net>
parents: 1602
diff changeset
751 setlocale(LC_ALL, "");
1382
1447c5296977 Fix locale charset detection on some BSD systems
Mikael Berthe <mikael@lilotux.net>
parents: 1381
diff changeset
752 #ifdef HAVE_LOCALCHARSET_H
1447c5296977 Fix locale charset detection on some BSD systems
Mikael Berthe <mikael@lilotux.net>
parents: 1381
diff changeset
753 LocaleCharSet = locale_charset();
1447c5296977 Fix locale charset detection on some BSD systems
Mikael Berthe <mikael@lilotux.net>
parents: 1381
diff changeset
754 #else
779
057ffe7c43dc Initialize locale charset earlier
Mikael Berthe <mikael@lilotux.net>
parents: 773
diff changeset
755 LocaleCharSet = nl_langinfo(CODESET);
1382
1447c5296977 Fix locale charset detection on some BSD systems
Mikael Berthe <mikael@lilotux.net>
parents: 1381
diff changeset
756 #endif
779
057ffe7c43dc Initialize locale charset earlier
Mikael Berthe <mikael@lilotux.net>
parents: 773
diff changeset
757 utf8_mode = (strcmp(LocaleCharSet, "UTF-8") == 0);
057ffe7c43dc Initialize locale charset earlier
Mikael Berthe <mikael@lilotux.net>
parents: 773
diff changeset
758 }
057ffe7c43dc Initialize locale charset earlier
Mikael Berthe <mikael@lilotux.net>
parents: 773
diff changeset
759
1780
e4378fbab5d7 Major API cleanup - bump API to 4
Mikael Berthe <mikael@lilotux.net>
parents: 1761
diff changeset
760 gboolean scr_curses_status(void)
1733
a9b0364c0cb2 Fix segfault introduced in previous commit
Mikael Berthe <mikael@lilotux.net>
parents: 1729
diff changeset
761 {
a9b0364c0cb2 Fix segfault introduced in previous commit
Mikael Berthe <mikael@lilotux.net>
parents: 1729
diff changeset
762 return Curses;
a9b0364c0cb2 Fix segfault introduced in previous commit
Mikael Berthe <mikael@lilotux.net>
parents: 1729
diff changeset
763 }
a9b0364c0cb2 Fix segfault introduced in previous commit
Mikael Berthe <mikael@lilotux.net>
parents: 1729
diff changeset
764
1942
3e39a336a992 Use guards for colors (Myhailo Danylenko)
Mikael Berthe <mikael@lilotux.net>
parents: 1935
diff changeset
765 static gchar *scr_color_guard(const gchar *key, const gchar *new_value)
3e39a336a992 Use guards for colors (Myhailo Danylenko)
Mikael Berthe <mikael@lilotux.net>
parents: 1935
diff changeset
766 {
3e39a336a992 Use guards for colors (Myhailo Danylenko)
Mikael Berthe <mikael@lilotux.net>
parents: 1935
diff changeset
767 if (g_strcmp0(settings_opt_get(key), new_value))
3e39a336a992 Use guards for colors (Myhailo Danylenko)
Mikael Berthe <mikael@lilotux.net>
parents: 1935
diff changeset
768 colors_stalled = TRUE;
3e39a336a992 Use guards for colors (Myhailo Danylenko)
Mikael Berthe <mikael@lilotux.net>
parents: 1935
diff changeset
769 return g_strdup(new_value);
3e39a336a992 Use guards for colors (Myhailo Danylenko)
Mikael Berthe <mikael@lilotux.net>
parents: 1935
diff changeset
770 }
3e39a336a992 Use guards for colors (Myhailo Danylenko)
Mikael Berthe <mikael@lilotux.net>
parents: 1935
diff changeset
771
1780
e4378fbab5d7 Major API cleanup - bump API to 4
Mikael Berthe <mikael@lilotux.net>
parents: 1761
diff changeset
772 void scr_init_curses(void)
765
72626e9d60bd Create init_keycodes(), add 2 screen escape sequences
Mikael Berthe <mikael@lilotux.net>
parents: 764
diff changeset
773 {
72626e9d60bd Create init_keycodes(), add 2 screen escape sequences
Mikael Berthe <mikael@lilotux.net>
parents: 764
diff changeset
774 /* Key sequences initialization */
72626e9d60bd Create init_keycodes(), add 2 screen escape sequences
Mikael Berthe <mikael@lilotux.net>
parents: 764
diff changeset
775 init_keycodes();
762
96d46e00524a Add some key escape sequences for screen
Mikael Berthe <mikael@lilotux.net>
parents: 761
diff changeset
776
373
af2f8ddf6a1b Move (reorganize) functions
Mikael Berthe <mikael@lilotux.net>
parents: 370
diff changeset
777 initscr();
382
4c6e8392e465 Use nodelay() instead of halfdelay()
Mikael Berthe <mikael@lilotux.net>
parents: 374
diff changeset
778 raw();
373
af2f8ddf6a1b Move (reorganize) functions
Mikael Berthe <mikael@lilotux.net>
parents: 370
diff changeset
779 noecho();
389
6e895f397474 Ncurses changes + Ctrl-C does not send a signal anylore
Mikael Berthe <mikael@lilotux.net>
parents: 388
diff changeset
780 nonl();
6e895f397474 Ncurses changes + Ctrl-C does not send a signal anylore
Mikael Berthe <mikael@lilotux.net>
parents: 388
diff changeset
781 intrflush(stdscr, FALSE);
373
af2f8ddf6a1b Move (reorganize) functions
Mikael Berthe <mikael@lilotux.net>
parents: 370
diff changeset
782 start_color();
af2f8ddf6a1b Move (reorganize) functions
Mikael Berthe <mikael@lilotux.net>
parents: 370
diff changeset
783 use_default_colors();
1561
2e86c1cc4eb1 Map mouse events to p* keycodes
franky
parents: 1558
diff changeset
784 #ifdef NCURSES_MOUSE_VERSION
1563
c1d0f906d379 Add option "use_mouse"
franky
parents: 1561
diff changeset
785 if (settings_opt_get_int("use_mouse"))
c1d0f906d379 Add option "use_mouse"
franky
parents: 1561
diff changeset
786 mousemask(ALL_MOUSE_EVENTS, NULL);
1561
2e86c1cc4eb1 Map mouse events to p* keycodes
franky
parents: 1558
diff changeset
787 #endif
373
af2f8ddf6a1b Move (reorganize) functions
Mikael Berthe <mikael@lilotux.net>
parents: 370
diff changeset
788
1386
8e763c2c331f Add option 'escdelay'
Mikael Berthe <mikael@lilotux.net>
parents: 1382
diff changeset
789 if (settings_opt_get("escdelay")) {
8e763c2c331f Add option 'escdelay'
Mikael Berthe <mikael@lilotux.net>
parents: 1382
diff changeset
790 #ifdef HAVE_ESCDELAY
8e763c2c331f Add option 'escdelay'
Mikael Berthe <mikael@lilotux.net>
parents: 1382
diff changeset
791 ESCDELAY = (unsigned) settings_opt_get_int("escdelay");
8e763c2c331f Add option 'escdelay'
Mikael Berthe <mikael@lilotux.net>
parents: 1382
diff changeset
792 #else
8e763c2c331f Add option 'escdelay'
Mikael Berthe <mikael@lilotux.net>
parents: 1382
diff changeset
793 scr_LogPrint(LPRINT_LOGNORM, "ERROR: no ESCDELAY support.");
8e763c2c331f Add option 'escdelay'
Mikael Berthe <mikael@lilotux.net>
parents: 1382
diff changeset
794 #endif
8e763c2c331f Add option 'escdelay'
Mikael Berthe <mikael@lilotux.net>
parents: 1382
diff changeset
795 }
8e763c2c331f Add option 'escdelay'
Mikael Berthe <mikael@lilotux.net>
parents: 1382
diff changeset
796
1780
e4378fbab5d7 Major API cleanup - bump API to 4
Mikael Berthe <mikael@lilotux.net>
parents: 1761
diff changeset
797 parse_colors();
373
af2f8ddf6a1b Move (reorganize) functions
Mikael Berthe <mikael@lilotux.net>
parents: 370
diff changeset
798
1942
3e39a336a992 Use guards for colors (Myhailo Danylenko)
Mikael Berthe <mikael@lilotux.net>
parents: 1935
diff changeset
799 settings_set_guard("color_background", scr_color_guard);
3e39a336a992 Use guards for colors (Myhailo Danylenko)
Mikael Berthe <mikael@lilotux.net>
parents: 1935
diff changeset
800 settings_set_guard("color_general", scr_color_guard);
3e39a336a992 Use guards for colors (Myhailo Danylenko)
Mikael Berthe <mikael@lilotux.net>
parents: 1935
diff changeset
801 settings_set_guard("color_info", scr_color_guard);
3e39a336a992 Use guards for colors (Myhailo Danylenko)
Mikael Berthe <mikael@lilotux.net>
parents: 1935
diff changeset
802 settings_set_guard("color_msgin", scr_color_guard);
3e39a336a992 Use guards for colors (Myhailo Danylenko)
Mikael Berthe <mikael@lilotux.net>
parents: 1935
diff changeset
803 settings_set_guard("color_msgout", scr_color_guard);
3e39a336a992 Use guards for colors (Myhailo Danylenko)
Mikael Berthe <mikael@lilotux.net>
parents: 1935
diff changeset
804 settings_set_guard("color_msghl", scr_color_guard);
3e39a336a992 Use guards for colors (Myhailo Danylenko)
Mikael Berthe <mikael@lilotux.net>
parents: 1935
diff changeset
805 settings_set_guard("color_bgstatus", scr_color_guard);
3e39a336a992 Use guards for colors (Myhailo Danylenko)
Mikael Berthe <mikael@lilotux.net>
parents: 1935
diff changeset
806 settings_set_guard("color_status", scr_color_guard);
2028
7b5bd6ad83b4 Add 'color_log' (text color in the log window)
Mikael Berthe <mikael@lilotux.net>
parents: 2015
diff changeset
807 settings_set_guard("color_log", scr_color_guard);
1942
3e39a336a992 Use guards for colors (Myhailo Danylenko)
Mikael Berthe <mikael@lilotux.net>
parents: 1935
diff changeset
808 settings_set_guard("color_roster", scr_color_guard);
3e39a336a992 Use guards for colors (Myhailo Danylenko)
Mikael Berthe <mikael@lilotux.net>
parents: 1935
diff changeset
809 settings_set_guard("color_bgrostersel", scr_color_guard);
3e39a336a992 Use guards for colors (Myhailo Danylenko)
Mikael Berthe <mikael@lilotux.net>
parents: 1935
diff changeset
810 settings_set_guard("color_rostersel", scr_color_guard);
3e39a336a992 Use guards for colors (Myhailo Danylenko)
Mikael Berthe <mikael@lilotux.net>
parents: 1935
diff changeset
811 settings_set_guard("color_rosterselmsg", scr_color_guard);
3e39a336a992 Use guards for colors (Myhailo Danylenko)
Mikael Berthe <mikael@lilotux.net>
parents: 1935
diff changeset
812 settings_set_guard("color_rosternewmsg", scr_color_guard);
3e39a336a992 Use guards for colors (Myhailo Danylenko)
Mikael Berthe <mikael@lilotux.net>
parents: 1935
diff changeset
813
373
af2f8ddf6a1b Move (reorganize) functions
Mikael Berthe <mikael@lilotux.net>
parents: 370
diff changeset
814 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
815 Log_Win_Height = DEFAULT_LOG_WIN_HEIGHT;
1780
e4378fbab5d7 Major API cleanup - bump API to 4
Mikael Berthe <mikael@lilotux.net>
parents: 1761
diff changeset
816 // Note scr_draw_main_window() should be called early after scr_init_curses()
518
9480a76471b6 Update Log_Win_Height when refreshing the screen
Mikael Berthe <mikael@lilotux.net>
parents: 515
diff changeset
817 // 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
818
373
af2f8ddf6a1b Move (reorganize) functions
Mikael Berthe <mikael@lilotux.net>
parents: 370
diff changeset
819 inputLine[0] = 0;
af2f8ddf6a1b Move (reorganize) functions
Mikael Berthe <mikael@lilotux.net>
parents: 370
diff changeset
820 ptr_inputline = inputLine;
af2f8ddf6a1b Move (reorganize) functions
Mikael Berthe <mikael@lilotux.net>
parents: 370
diff changeset
821
966
d9acb7f2a3d1 Do not set Curses variable too early
Mikael Berthe <mikael@lilotux.net>
parents: 961
diff changeset
822 Curses = TRUE;
373
af2f8ddf6a1b Move (reorganize) functions
Mikael Berthe <mikael@lilotux.net>
parents: 370
diff changeset
823 return;
af2f8ddf6a1b Move (reorganize) functions
Mikael Berthe <mikael@lilotux.net>
parents: 370
diff changeset
824 }
af2f8ddf6a1b Move (reorganize) functions
Mikael Berthe <mikael@lilotux.net>
parents: 370
diff changeset
825
1780
e4378fbab5d7 Major API cleanup - bump API to 4
Mikael Berthe <mikael@lilotux.net>
parents: 1761
diff changeset
826 void scr_terminate_curses(void)
373
af2f8ddf6a1b Move (reorganize) functions
Mikael Berthe <mikael@lilotux.net>
parents: 370
diff changeset
827 {
af2f8ddf6a1b Move (reorganize) functions
Mikael Berthe <mikael@lilotux.net>
parents: 370
diff changeset
828 if (!Curses) return;
af2f8ddf6a1b Move (reorganize) functions
Mikael Berthe <mikael@lilotux.net>
parents: 370
diff changeset
829 clear();
af2f8ddf6a1b Move (reorganize) functions
Mikael Berthe <mikael@lilotux.net>
parents: 370
diff changeset
830 refresh();
af2f8ddf6a1b Move (reorganize) functions
Mikael Berthe <mikael@lilotux.net>
parents: 370
diff changeset
831 endwin();
af2f8ddf6a1b Move (reorganize) functions
Mikael Berthe <mikael@lilotux.net>
parents: 370
diff changeset
832 Curses = FALSE;
af2f8ddf6a1b Move (reorganize) functions
Mikael Berthe <mikael@lilotux.net>
parents: 370
diff changeset
833 return;
af2f8ddf6a1b Move (reorganize) functions
Mikael Berthe <mikael@lilotux.net>
parents: 370
diff changeset
834 }
af2f8ddf6a1b Move (reorganize) functions
Mikael Berthe <mikael@lilotux.net>
parents: 370
diff changeset
835
1780
e4378fbab5d7 Major API cleanup - bump API to 4
Mikael Berthe <mikael@lilotux.net>
parents: 1761
diff changeset
836 void scr_beep(void)
675
ae7016aae014 New "beep_on_message" option
Mikael Berthe <mikael@lilotux.net>
parents: 667
diff changeset
837 {
ae7016aae014 New "beep_on_message" option
Mikael Berthe <mikael@lilotux.net>
parents: 667
diff changeset
838 beep();
ae7016aae014 New "beep_on_message" option
Mikael Berthe <mikael@lilotux.net>
parents: 667
diff changeset
839 }
ae7016aae014 New "beep_on_message" option
Mikael Berthe <mikael@lilotux.net>
parents: 667
diff changeset
840
1286
02ad6200df26 Add selectable time prefixes (vorner)
Mikael Berthe <mikael@lilotux.net>
parents: 1284
diff changeset
841 // This and following belongs to dynamic setting of time prefix
02ad6200df26 Add selectable time prefixes (vorner)
Mikael Berthe <mikael@lilotux.net>
parents: 1284
diff changeset
842 static const char *timeprefixes[] = {
02ad6200df26 Add selectable time prefixes (vorner)
Mikael Berthe <mikael@lilotux.net>
parents: 1284
diff changeset
843 "%m-%d %H:%M ",
02ad6200df26 Add selectable time prefixes (vorner)
Mikael Berthe <mikael@lilotux.net>
parents: 1284
diff changeset
844 "%H:%M ",
02ad6200df26 Add selectable time prefixes (vorner)
Mikael Berthe <mikael@lilotux.net>
parents: 1284
diff changeset
845 " "
02ad6200df26 Add selectable time prefixes (vorner)
Mikael Berthe <mikael@lilotux.net>
parents: 1284
diff changeset
846 };
02ad6200df26 Add selectable time prefixes (vorner)
Mikael Berthe <mikael@lilotux.net>
parents: 1284
diff changeset
847
02ad6200df26 Add selectable time prefixes (vorner)
Mikael Berthe <mikael@lilotux.net>
parents: 1284
diff changeset
848 static const char *spectimeprefixes[] = {
02ad6200df26 Add selectable time prefixes (vorner)
Mikael Berthe <mikael@lilotux.net>
parents: 1284
diff changeset
849 "%m-%d %H:%M:%S ",
02ad6200df26 Add selectable time prefixes (vorner)
Mikael Berthe <mikael@lilotux.net>
parents: 1284
diff changeset
850 "%H:%M:%S ",
02ad6200df26 Add selectable time prefixes (vorner)
Mikael Berthe <mikael@lilotux.net>
parents: 1284
diff changeset
851 " "
02ad6200df26 Add selectable time prefixes (vorner)
Mikael Berthe <mikael@lilotux.net>
parents: 1284
diff changeset
852 };
02ad6200df26 Add selectable time prefixes (vorner)
Mikael Berthe <mikael@lilotux.net>
parents: 1284
diff changeset
853
02ad6200df26 Add selectable time prefixes (vorner)
Mikael Berthe <mikael@lilotux.net>
parents: 1284
diff changeset
854 static int timepreflengths[] = {
1376
a0deb5124ebf Check time_prefix value before using it
Mikael Berthe <mikael@lilotux.net>
parents: 1359
diff changeset
855 // (length of the corresponding timeprefix + 5)
1286
02ad6200df26 Add selectable time prefixes (vorner)
Mikael Berthe <mikael@lilotux.net>
parents: 1284
diff changeset
856 17,
02ad6200df26 Add selectable time prefixes (vorner)
Mikael Berthe <mikael@lilotux.net>
parents: 1284
diff changeset
857 11,
02ad6200df26 Add selectable time prefixes (vorner)
Mikael Berthe <mikael@lilotux.net>
parents: 1284
diff changeset
858 6
02ad6200df26 Add selectable time prefixes (vorner)
Mikael Berthe <mikael@lilotux.net>
parents: 1284
diff changeset
859 };
02ad6200df26 Add selectable time prefixes (vorner)
Mikael Berthe <mikael@lilotux.net>
parents: 1284
diff changeset
860
1486
f83a51eaa5ed Fix multiline output in /buffer save
Mikael Berthe <mikael@lilotux.net>
parents: 1485
diff changeset
861 static const char *gettprefix(void)
1286
02ad6200df26 Add selectable time prefixes (vorner)
Mikael Berthe <mikael@lilotux.net>
parents: 1284
diff changeset
862 {
1376
a0deb5124ebf Check time_prefix value before using it
Mikael Berthe <mikael@lilotux.net>
parents: 1359
diff changeset
863 guint n = settings_opt_get_int("time_prefix");
a0deb5124ebf Check time_prefix value before using it
Mikael Berthe <mikael@lilotux.net>
parents: 1359
diff changeset
864 return timeprefixes[(n < 3 ? n : 0)];
1286
02ad6200df26 Add selectable time prefixes (vorner)
Mikael Berthe <mikael@lilotux.net>
parents: 1284
diff changeset
865 }
02ad6200df26 Add selectable time prefixes (vorner)
Mikael Berthe <mikael@lilotux.net>
parents: 1284
diff changeset
866
1486
f83a51eaa5ed Fix multiline output in /buffer save
Mikael Berthe <mikael@lilotux.net>
parents: 1485
diff changeset
867 static const char *getspectprefix(void)
1286
02ad6200df26 Add selectable time prefixes (vorner)
Mikael Berthe <mikael@lilotux.net>
parents: 1284
diff changeset
868 {
1376
a0deb5124ebf Check time_prefix value before using it
Mikael Berthe <mikael@lilotux.net>
parents: 1359
diff changeset
869 guint n = settings_opt_get_int("time_prefix");
a0deb5124ebf Check time_prefix value before using it
Mikael Berthe <mikael@lilotux.net>
parents: 1359
diff changeset
870 return spectimeprefixes[(n < 3 ? n : 0)];
1286
02ad6200df26 Add selectable time prefixes (vorner)
Mikael Berthe <mikael@lilotux.net>
parents: 1284
diff changeset
871 }
02ad6200df26 Add selectable time prefixes (vorner)
Mikael Berthe <mikael@lilotux.net>
parents: 1284
diff changeset
872
1487
f61ed2466f7c Minor style upgrade
Mikael Berthe <mikael@lilotux.net>
parents: 1486
diff changeset
873 guint scr_getprefixwidth(void)
1286
02ad6200df26 Add selectable time prefixes (vorner)
Mikael Berthe <mikael@lilotux.net>
parents: 1284
diff changeset
874 {
1376
a0deb5124ebf Check time_prefix value before using it
Mikael Berthe <mikael@lilotux.net>
parents: 1359
diff changeset
875 guint n = settings_opt_get_int("time_prefix");
a0deb5124ebf Check time_prefix value before using it
Mikael Berthe <mikael@lilotux.net>
parents: 1359
diff changeset
876 return timepreflengths[(n < 3 ? n : 0)];
1286
02ad6200df26 Add selectable time prefixes (vorner)
Mikael Berthe <mikael@lilotux.net>
parents: 1284
diff changeset
877 }
02ad6200df26 Add selectable time prefixes (vorner)
Mikael Berthe <mikael@lilotux.net>
parents: 1284
diff changeset
878
1761
61f0482d3993 Limit = alignment to 1/3 of screen in option list
Myhailo Danylenko <isbear@ukrpost.net>
parents: 1756
diff changeset
879 guint scr_gettextwidth(void)
61f0482d3993 Limit = alignment to 1/3 of screen in option list
Myhailo Danylenko <isbear@ukrpost.net>
parents: 1756
diff changeset
880 {
61f0482d3993 Limit = alignment to 1/3 of screen in option list
Myhailo Danylenko <isbear@ukrpost.net>
parents: 1756
diff changeset
881 return maxX - Roster_Width - scr_getprefixwidth();
61f0482d3993 Limit = alignment to 1/3 of screen in option list
Myhailo Danylenko <isbear@ukrpost.net>
parents: 1756
diff changeset
882 }
61f0482d3993 Limit = alignment to 1/3 of screen in option list
Myhailo Danylenko <isbear@ukrpost.net>
parents: 1756
diff changeset
883
1791
6e0a8bfb3a01 Add scr_gettextheight()
Myhailo Danylenko <isbear@ukrpost.net>
parents: 1783
diff changeset
884 guint scr_gettextheight(void)
6e0a8bfb3a01 Add scr_gettextheight()
Myhailo Danylenko <isbear@ukrpost.net>
parents: 1783
diff changeset
885 {
6e0a8bfb3a01 Add scr_gettextheight()
Myhailo Danylenko <isbear@ukrpost.net>
parents: 1783
diff changeset
886 // log window, two status bars and one input line
6e0a8bfb3a01 Add scr_gettextheight()
Myhailo Danylenko <isbear@ukrpost.net>
parents: 1783
diff changeset
887 return maxY - Log_Win_Height - 3;
6e0a8bfb3a01 Add scr_gettextheight()
Myhailo Danylenko <isbear@ukrpost.net>
parents: 1783
diff changeset
888 }
6e0a8bfb3a01 Add scr_gettextheight()
Myhailo Danylenko <isbear@ukrpost.net>
parents: 1783
diff changeset
889
1819
d13315366ba5 Add scr_getlogwinheight()
Mikael Berthe <mikael@lilotux.net>
parents: 1815
diff changeset
890 guint scr_getlogwinheight(void)
d13315366ba5 Add scr_getlogwinheight()
Mikael Berthe <mikael@lilotux.net>
parents: 1815
diff changeset
891 {
d13315366ba5 Add scr_getlogwinheight()
Mikael Berthe <mikael@lilotux.net>
parents: 1815
diff changeset
892 if (Log_Win_Height >= 2)
d13315366ba5 Add scr_getlogwinheight()
Mikael Berthe <mikael@lilotux.net>
parents: 1815
diff changeset
893 return Log_Win_Height - 2;
d13315366ba5 Add scr_getlogwinheight()
Mikael Berthe <mikael@lilotux.net>
parents: 1815
diff changeset
894 return 0;
d13315366ba5 Add scr_getlogwinheight()
Mikael Berthe <mikael@lilotux.net>
parents: 1815
diff changeset
895 }
d13315366ba5 Add scr_getlogwinheight()
Mikael Berthe <mikael@lilotux.net>
parents: 1815
diff changeset
896
1518
63dc211a4c1a New command: /echo (display a message in the log window)
Mikael Berthe <mikael@lilotux.net>
parents: 1515
diff changeset
897 // scr_print_logwindow(string)
63dc211a4c1a New command: /echo (display a message in the log window)
Mikael Berthe <mikael@lilotux.net>
parents: 1515
diff changeset
898 // Display the string in the log window.
63dc211a4c1a New command: /echo (display a message in the log window)
Mikael Berthe <mikael@lilotux.net>
parents: 1515
diff changeset
899 // Note: The string must be in the user's locale!
63dc211a4c1a New command: /echo (display a message in the log window)
Mikael Berthe <mikael@lilotux.net>
parents: 1515
diff changeset
900 void scr_print_logwindow(const char *string)
63dc211a4c1a New command: /echo (display a message in the log window)
Mikael Berthe <mikael@lilotux.net>
parents: 1515
diff changeset
901 {
63dc211a4c1a New command: /echo (display a message in the log window)
Mikael Berthe <mikael@lilotux.net>
parents: 1515
diff changeset
902 time_t timestamp;
63dc211a4c1a New command: /echo (display a message in the log window)
Mikael Berthe <mikael@lilotux.net>
parents: 1515
diff changeset
903 char strtimestamp[64];
63dc211a4c1a New command: /echo (display a message in the log window)
Mikael Berthe <mikael@lilotux.net>
parents: 1515
diff changeset
904
63dc211a4c1a New command: /echo (display a message in the log window)
Mikael Berthe <mikael@lilotux.net>
parents: 1515
diff changeset
905 timestamp = time(NULL);
63dc211a4c1a New command: /echo (display a message in the log window)
Mikael Berthe <mikael@lilotux.net>
parents: 1515
diff changeset
906 strftime(strtimestamp, 48, "[%H:%M:%S]", localtime(&timestamp));
63dc211a4c1a New command: /echo (display a message in the log window)
Mikael Berthe <mikael@lilotux.net>
parents: 1515
diff changeset
907 if (Curses) {
63dc211a4c1a New command: /echo (display a message in the log window)
Mikael Berthe <mikael@lilotux.net>
parents: 1515
diff changeset
908 wprintw(logWnd, "\n%s %s", strtimestamp, string);
63dc211a4c1a New command: /echo (display a message in the log window)
Mikael Berthe <mikael@lilotux.net>
parents: 1515
diff changeset
909 update_panels();
63dc211a4c1a New command: /echo (display a message in the log window)
Mikael Berthe <mikael@lilotux.net>
parents: 1515
diff changeset
910 } else {
63dc211a4c1a New command: /echo (display a message in the log window)
Mikael Berthe <mikael@lilotux.net>
parents: 1515
diff changeset
911 printf("%s %s\n", strtimestamp, string);
63dc211a4c1a New command: /echo (display a message in the log window)
Mikael Berthe <mikael@lilotux.net>
parents: 1515
diff changeset
912 }
63dc211a4c1a New command: /echo (display a message in the log window)
Mikael Berthe <mikael@lilotux.net>
parents: 1515
diff changeset
913 }
63dc211a4c1a New command: /echo (display a message in the log window)
Mikael Berthe <mikael@lilotux.net>
parents: 1515
diff changeset
914
1783
af3de54ef986 Convert scr_LogPrint() to scr_log_print()
Mikael Berthe <mikael@lilotux.net>
parents: 1780
diff changeset
915 // scr_log_print(...)
1518
63dc211a4c1a New command: /echo (display a message in the log window)
Mikael Berthe <mikael@lilotux.net>
parents: 1515
diff changeset
916 // Display a message in the log window and in the status buffer.
63dc211a4c1a New command: /echo (display a message in the log window)
Mikael Berthe <mikael@lilotux.net>
parents: 1515
diff changeset
917 // Add the message to the tracelog file if the log flag is set.
771
ce4f8a2129a4 scr_LogPrint() can display UTF-8 strings
Mikael Berthe <mikael@lilotux.net>
parents: 770
diff changeset
918 // This function will convert from UTF-8 unless the LPRINT_NOTUTF8 flag is set.
1783
af3de54ef986 Convert scr_LogPrint() to scr_log_print()
Mikael Berthe <mikael@lilotux.net>
parents: 1780
diff changeset
919 void scr_log_print(unsigned int flag, const char *fmt, ...)
373
af2f8ddf6a1b Move (reorganize) functions
Mikael Berthe <mikael@lilotux.net>
parents: 370
diff changeset
920 {
af2f8ddf6a1b Move (reorganize) functions
Mikael Berthe <mikael@lilotux.net>
parents: 370
diff changeset
921 time_t timestamp;
857
ef35a2bb40d7 scr_LogPrint(): do not use static buffer size
Mikael Berthe <mikael@lilotux.net>
parents: 851
diff changeset
922 char strtimestamp[64];
858
2683ad5d1003 Improve scr_LogPrint() for log/debug messages
Mikael Berthe <mikael@lilotux.net>
parents: 857
diff changeset
923 char *buffer, *btext;
1075
03bc225ad763 Improve scr_LogPrint() readability
Mikael Berthe <mikael@lilotux.net>
parents: 1072
diff changeset
924 char *convbuf1 = NULL, *convbuf2 = NULL;
373
af2f8ddf6a1b Move (reorganize) functions
Mikael Berthe <mikael@lilotux.net>
parents: 370
diff changeset
925 va_list ap;
af2f8ddf6a1b Move (reorganize) functions
Mikael Berthe <mikael@lilotux.net>
parents: 370
diff changeset
926
771
ce4f8a2129a4 scr_LogPrint() can display UTF-8 strings
Mikael Berthe <mikael@lilotux.net>
parents: 770
diff changeset
927 if (!(flag & ~LPRINT_NOTUTF8)) return; // Shouldn't happen
374
bd5638c21834 Improve logging system (traces)
Mikael Berthe <mikael@lilotux.net>
parents: 373
diff changeset
928
857
ef35a2bb40d7 scr_LogPrint(): do not use static buffer size
Mikael Berthe <mikael@lilotux.net>
parents: 851
diff changeset
929 timestamp = time(NULL);
ef35a2bb40d7 scr_LogPrint(): do not use static buffer size
Mikael Berthe <mikael@lilotux.net>
parents: 851
diff changeset
930 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
931 va_start(ap, fmt);
858
2683ad5d1003 Improve scr_LogPrint() for log/debug messages
Mikael Berthe <mikael@lilotux.net>
parents: 857
diff changeset
932 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
933 va_end(ap);
373
af2f8ddf6a1b Move (reorganize) functions
Mikael Berthe <mikael@lilotux.net>
parents: 370
diff changeset
934
374
bd5638c21834 Improve logging system (traces)
Mikael Berthe <mikael@lilotux.net>
parents: 373
diff changeset
935 if (flag & LPRINT_NORMAL) {
771
ce4f8a2129a4 scr_LogPrint() can display UTF-8 strings
Mikael Berthe <mikael@lilotux.net>
parents: 770
diff changeset
936 char *buffer_locale;
851
da03534e46c7 Add startup log messages to the status buffer
Mikael Berthe <mikael@lilotux.net>
parents: 850
diff changeset
937 char *buf_specialwindow;
da03534e46c7 Add startup log messages to the status buffer
Mikael Berthe <mikael@lilotux.net>
parents: 850
diff changeset
938
858
2683ad5d1003 Improve scr_LogPrint() for log/debug messages
Mikael Berthe <mikael@lilotux.net>
parents: 857
diff changeset
939 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
940
851
da03534e46c7 Add startup log messages to the status buffer
Mikael Berthe <mikael@lilotux.net>
parents: 850
diff changeset
941 // 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
942 if (!(flag & LPRINT_NOTUTF8))
1075
03bc225ad763 Improve scr_LogPrint() readability
Mikael Berthe <mikael@lilotux.net>
parents: 1072
diff changeset
943 buffer_locale = convbuf1 = from_utf8(buffer);
771
ce4f8a2129a4 scr_LogPrint() can display UTF-8 strings
Mikael Berthe <mikael@lilotux.net>
parents: 770
diff changeset
944 else
ce4f8a2129a4 scr_LogPrint() can display UTF-8 strings
Mikael Berthe <mikael@lilotux.net>
parents: 770
diff changeset
945 buffer_locale = buffer;
851
da03534e46c7 Add startup log messages to the status buffer
Mikael Berthe <mikael@lilotux.net>
parents: 850
diff changeset
946
884
9e6d9f0cf9eb scr_LogPrint(): Add a warning for UTF-8 -> locale conversion failures
Mikael Berthe <mikael@lilotux.net>
parents: 880
diff changeset
947 if (!buffer_locale) {
9e6d9f0cf9eb scr_LogPrint(): Add a warning for UTF-8 -> locale conversion failures
Mikael Berthe <mikael@lilotux.net>
parents: 880
diff changeset
948 wprintw(logWnd,
9e6d9f0cf9eb scr_LogPrint(): Add a warning for UTF-8 -> locale conversion failures
Mikael Berthe <mikael@lilotux.net>
parents: 880
diff changeset
949 "\n%s*Error: cannot convert string to locale.", strtimestamp);
9e6d9f0cf9eb scr_LogPrint(): Add a warning for UTF-8 -> locale conversion failures
Mikael Berthe <mikael@lilotux.net>
parents: 880
diff changeset
950 update_panels();
9e6d9f0cf9eb scr_LogPrint(): Add a warning for UTF-8 -> locale conversion failures
Mikael Berthe <mikael@lilotux.net>
parents: 880
diff changeset
951 g_free(buffer);
897
a05b5a16a06a Fix memory leak in scr_LogPrint()
Mikael Berthe <mikael@lilotux.net>
parents: 891
diff changeset
952 g_free(btext);
884
9e6d9f0cf9eb scr_LogPrint(): Add a warning for UTF-8 -> locale conversion failures
Mikael Berthe <mikael@lilotux.net>
parents: 880
diff changeset
953 return;
9e6d9f0cf9eb scr_LogPrint(): Add a warning for UTF-8 -> locale conversion failures
Mikael Berthe <mikael@lilotux.net>
parents: 880
diff changeset
954 }
9e6d9f0cf9eb scr_LogPrint(): Add a warning for UTF-8 -> locale conversion failures
Mikael Berthe <mikael@lilotux.net>
parents: 880
diff changeset
955
851
da03534e46c7 Add startup log messages to the status buffer
Mikael Berthe <mikael@lilotux.net>
parents: 850
diff changeset
956 // 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
957 if (flag & LPRINT_NOTUTF8)
1075
03bc225ad763 Improve scr_LogPrint() readability
Mikael Berthe <mikael@lilotux.net>
parents: 1072
diff changeset
958 buf_specialwindow = convbuf2 = to_utf8(btext);
851
da03534e46c7 Add startup log messages to the status buffer
Mikael Berthe <mikael@lilotux.net>
parents: 850
diff changeset
959 else
858
2683ad5d1003 Improve scr_LogPrint() for log/debug messages
Mikael Berthe <mikael@lilotux.net>
parents: 857
diff changeset
960 buf_specialwindow = btext;
851
da03534e46c7 Add startup log messages to the status buffer
Mikael Berthe <mikael@lilotux.net>
parents: 850
diff changeset
961
374
bd5638c21834 Improve logging system (traces)
Mikael Berthe <mikael@lilotux.net>
parents: 373
diff changeset
962 if (Curses) {
771
ce4f8a2129a4 scr_LogPrint() can display UTF-8 strings
Mikael Berthe <mikael@lilotux.net>
parents: 770
diff changeset
963 wprintw(logWnd, "\n%s", buffer_locale);
374
bd5638c21834 Improve logging system (traces)
Mikael Berthe <mikael@lilotux.net>
parents: 373
diff changeset
964 update_panels();
1780
e4378fbab5d7 Major API cleanup - bump API to 4
Mikael Berthe <mikael@lilotux.net>
parents: 1761
diff changeset
965 scr_write_in_window(NULL, buf_specialwindow, timestamp,
e4378fbab5d7 Major API cleanup - bump API to 4
Mikael Berthe <mikael@lilotux.net>
parents: 1761
diff changeset
966 HBB_PREFIX_SPECIAL, FALSE, 0, NULL);
374
bd5638c21834 Improve logging system (traces)
Mikael Berthe <mikael@lilotux.net>
parents: 373
diff changeset
967 } else {
771
ce4f8a2129a4 scr_LogPrint() can display UTF-8 strings
Mikael Berthe <mikael@lilotux.net>
parents: 770
diff changeset
968 printf("%s\n", buffer_locale);
851
da03534e46c7 Add startup log messages to the status buffer
Mikael Berthe <mikael@lilotux.net>
parents: 850
diff changeset
969 // 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
970 hbuf_add_line(&statushbuf, buf_specialwindow, timestamp,
1602
f4a2c6f767d1 Message Receipts support (XEP-0184)
franky
parents: 1599
diff changeset
971 HBB_PREFIX_SPECIAL, 0, 0, 0, NULL);
374
bd5638c21834 Improve logging system (traces)
Mikael Berthe <mikael@lilotux.net>
parents: 373
diff changeset
972 }
851
da03534e46c7 Add startup log messages to the status buffer
Mikael Berthe <mikael@lilotux.net>
parents: 850
diff changeset
973
1075
03bc225ad763 Improve scr_LogPrint() readability
Mikael Berthe <mikael@lilotux.net>
parents: 1072
diff changeset
974 g_free(convbuf1);
03bc225ad763 Improve scr_LogPrint() readability
Mikael Berthe <mikael@lilotux.net>
parents: 1072
diff changeset
975 g_free(convbuf2);
858
2683ad5d1003 Improve scr_LogPrint() for log/debug messages
Mikael Berthe <mikael@lilotux.net>
parents: 857
diff changeset
976 g_free(buffer);
374
bd5638c21834 Improve logging system (traces)
Mikael Berthe <mikael@lilotux.net>
parents: 373
diff changeset
977 }
412
9c640ee3bae3 Display full date in the log file
Mikael Berthe <mikael@lilotux.net>
parents: 393
diff changeset
978
857
ef35a2bb40d7 scr_LogPrint(): do not use static buffer size
Mikael Berthe <mikael@lilotux.net>
parents: 851
diff changeset
979 if (flag & (LPRINT_LOG|LPRINT_DEBUG)) {
ef35a2bb40d7 scr_LogPrint(): do not use static buffer size
Mikael Berthe <mikael@lilotux.net>
parents: 851
diff changeset
980 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
981 buffer = g_strdup_printf("%s %s\n", strtimestamp, btext);
1780
e4378fbab5d7 Major API cleanup - bump API to 4
Mikael Berthe <mikael@lilotux.net>
parents: 1761
diff changeset
982 ut_write_log(flag, buffer);
857
ef35a2bb40d7 scr_LogPrint(): do not use static buffer size
Mikael Berthe <mikael@lilotux.net>
parents: 851
diff changeset
983 g_free(buffer);
373
af2f8ddf6a1b Move (reorganize) functions
Mikael Berthe <mikael@lilotux.net>
parents: 370
diff changeset
984 }
897
a05b5a16a06a Fix memory leak in scr_LogPrint()
Mikael Berthe <mikael@lilotux.net>
parents: 891
diff changeset
985 g_free(btext);
373
af2f8ddf6a1b Move (reorganize) functions
Mikael Berthe <mikael@lilotux.net>
parents: 370
diff changeset
986 }
af2f8ddf6a1b Move (reorganize) functions
Mikael Berthe <mikael@lilotux.net>
parents: 370
diff changeset
987
1780
e4378fbab5d7 Major API cleanup - bump API to 4
Mikael Berthe <mikael@lilotux.net>
parents: 1761
diff changeset
988 static winbuf *scr_search_window(const char *winId, int special)
1156
cae430fcd385 Mcabber will load symlinked histories only once, now.
Frank Zschockelt
parents: 1154
diff changeset
989 {
cae430fcd385 Mcabber will load symlinked histories only once, now.
Frank Zschockelt
parents: 1154
diff changeset
990 char *id;
cae430fcd385 Mcabber will load symlinked histories only once, now.
Frank Zschockelt
parents: 1154
diff changeset
991 winbuf *wbp;
cae430fcd385 Mcabber will load symlinked histories only once, now.
Frank Zschockelt
parents: 1154
diff changeset
992
cae430fcd385 Mcabber will load symlinked histories only once, now.
Frank Zschockelt
parents: 1154
diff changeset
993 if (special)
cae430fcd385 Mcabber will load symlinked histories only once, now.
Frank Zschockelt
parents: 1154
diff changeset
994 return statusWindow; // Only one special window atm.
cae430fcd385 Mcabber will load symlinked histories only once, now.
Frank Zschockelt
parents: 1154
diff changeset
995
cae430fcd385 Mcabber will load symlinked histories only once, now.
Frank Zschockelt
parents: 1154
diff changeset
996 if (!winId)
cae430fcd385 Mcabber will load symlinked histories only once, now.
Frank Zschockelt
parents: 1154
diff changeset
997 return NULL;
cae430fcd385 Mcabber will load symlinked histories only once, now.
Frank Zschockelt
parents: 1154
diff changeset
998
cae430fcd385 Mcabber will load symlinked histories only once, now.
Frank Zschockelt
parents: 1154
diff changeset
999 id = g_strdup(winId);
cae430fcd385 Mcabber will load symlinked histories only once, now.
Frank Zschockelt
parents: 1154
diff changeset
1000 mc_strtolower(id);
cae430fcd385 Mcabber will load symlinked histories only once, now.
Frank Zschockelt
parents: 1154
diff changeset
1001 wbp = g_hash_table_lookup(winbufhash, id);
cae430fcd385 Mcabber will load symlinked histories only once, now.
Frank Zschockelt
parents: 1154
diff changeset
1002 g_free(id);
cae430fcd385 Mcabber will load symlinked histories only once, now.
Frank Zschockelt
parents: 1154
diff changeset
1003 return wbp;
cae430fcd385 Mcabber will load symlinked histories only once, now.
Frank Zschockelt
parents: 1154
diff changeset
1004 }
cae430fcd385 Mcabber will load symlinked histories only once, now.
Frank Zschockelt
parents: 1154
diff changeset
1005
1780
e4378fbab5d7 Major API cleanup - bump API to 4
Mikael Berthe <mikael@lilotux.net>
parents: 1761
diff changeset
1006 int scr_buddy_buffer_exists(const char *bjid)
1156
cae430fcd385 Mcabber will load symlinked histories only once, now.
Frank Zschockelt
parents: 1154
diff changeset
1007 {
1780
e4378fbab5d7 Major API cleanup - bump API to 4
Mikael Berthe <mikael@lilotux.net>
parents: 1761
diff changeset
1008 return (scr_search_window(bjid, FALSE) != NULL);
1156
cae430fcd385 Mcabber will load symlinked histories only once, now.
Frank Zschockelt
parents: 1154
diff changeset
1009 }
cae430fcd385 Mcabber will load symlinked histories only once, now.
Frank Zschockelt
parents: 1154
diff changeset
1010
1133
9dd28a56128f Do not create one panel per contact
Mikael Berthe <mikael@lilotux.net>
parents: 1131
diff changeset
1011 // scr_new_buddy(title, dontshow)
1139
104676e3389b Update documentation
Mikael Berthe <mikael@lilotux.net>
parents: 1138
diff changeset
1012 // Note: title (aka winId/jid) can be NULL for special buffers
1133
9dd28a56128f Do not create one panel per contact
Mikael Berthe <mikael@lilotux.net>
parents: 1131
diff changeset
1013 static winbuf *scr_new_buddy(const char *title, int dont_show)
24
e88b15cbf2de [/trunk] Changeset 40 by mikael
mikael
parents:
diff changeset
1014 {
822
0dbb2be10975 Get rid of list.h
Mikael Berthe <mikael@lilotux.net>
parents: 807
diff changeset
1015 winbuf *tmp;
393
f8f3c7493457 Whitespace cleanup
Mikael Berthe <mikael@lilotux.net>
parents: 389
diff changeset
1016
822
0dbb2be10975 Get rid of list.h
Mikael Berthe <mikael@lilotux.net>
parents: 807
diff changeset
1017 tmp = g_new0(winbuf, 1);
24
e88b15cbf2de [/trunk] Changeset 40 by mikael
mikael
parents:
diff changeset
1018
1133
9dd28a56128f Do not create one panel per contact
Mikael Berthe <mikael@lilotux.net>
parents: 1131
diff changeset
1019 tmp->win = activechatWnd;
9dd28a56128f Do not create one panel per contact
Mikael Berthe <mikael@lilotux.net>
parents: 1131
diff changeset
1020 tmp->panel = activechatPanel;
24
e88b15cbf2de [/trunk] Changeset 40 by mikael
mikael
parents:
diff changeset
1021
143
300bb88f631f [/trunk] Changeset 155 by mikael
mikael
parents: 142
diff changeset
1022 if (!dont_show) {
24
e88b15cbf2de [/trunk] Changeset 40 by mikael
mikael
parents:
diff changeset
1023 currentWindow = tmp;
e88b15cbf2de [/trunk] Changeset 40 by mikael
mikael
parents:
diff changeset
1024 } else {
e88b15cbf2de [/trunk] Changeset 40 by mikael
mikael
parents:
diff changeset
1025 if (currentWindow)
e88b15cbf2de [/trunk] Changeset 40 by mikael
mikael
parents:
diff changeset
1026 top_panel(currentWindow->panel);
e88b15cbf2de [/trunk] Changeset 40 by mikael
mikael
parents:
diff changeset
1027 else
e88b15cbf2de [/trunk] Changeset 40 by mikael
mikael
parents:
diff changeset
1028 top_panel(chatPanel);
e88b15cbf2de [/trunk] Changeset 40 by mikael
mikael
parents:
diff changeset
1029 }
143
300bb88f631f [/trunk] Changeset 155 by mikael
mikael
parents: 142
diff changeset
1030 update_panels();
24
e88b15cbf2de [/trunk] Changeset 40 by mikael
mikael
parents:
diff changeset
1031
849
42c43a88d823 Status buffer management
Mikael Berthe <mikael@lilotux.net>
parents: 848
diff changeset
1032 // If title is NULL, this is a special buffer
42c43a88d823 Status buffer management
Mikael Berthe <mikael@lilotux.net>
parents: 848
diff changeset
1033 if (title) {
1078
7866dbaf67a6 Use a hash for the list of win buffers
Mikael Berthe <mikael@lilotux.net>
parents: 1077
diff changeset
1034 char *id;
1156
cae430fcd385 Mcabber will load symlinked histories only once, now.
Frank Zschockelt
parents: 1154
diff changeset
1035 id = hlog_get_log_jid(title);
cae430fcd385 Mcabber will load symlinked histories only once, now.
Frank Zschockelt
parents: 1154
diff changeset
1036 if (id) {
1780
e4378fbab5d7 Major API cleanup - bump API to 4
Mikael Berthe <mikael@lilotux.net>
parents: 1761
diff changeset
1037 winbuf *wb = scr_search_window(id, FALSE);
1160
14f5876b5555 Slight optimization + line wrapping
Mikael Berthe <mikael@lilotux.net>
parents: 1159
diff changeset
1038 if (!wb)
14f5876b5555 Slight optimization + line wrapping
Mikael Berthe <mikael@lilotux.net>
parents: 1159
diff changeset
1039 wb = scr_new_buddy(id, TRUE);
14f5876b5555 Slight optimization + line wrapping
Mikael Berthe <mikael@lilotux.net>
parents: 1159
diff changeset
1040 tmp->bd=wb->bd;
1156
cae430fcd385 Mcabber will load symlinked histories only once, now.
Frank Zschockelt
parents: 1154
diff changeset
1041 g_free(id);
1159
53c0c5be43fa Small fixes, typos and cleanups
Mikael Berthe <mikael@lilotux.net>
parents: 1157
diff changeset
1042 } else { // Load buddy history from file (if enabled)
1157
5c857f0f0ab8 Moved all variables related to hbuf to an extra struct, bufdata
Frank Zschockelt
parents: 1156
diff changeset
1043 tmp->bd = g_new0(buffdata, 1);
1159
53c0c5be43fa Small fixes, typos and cleanups
Mikael Berthe <mikael@lilotux.net>
parents: 1157
diff changeset
1044 hlog_read_history(title, &tmp->bd->hbuf,
1487
f61ed2466f7c Minor style upgrade
Mikael Berthe <mikael@lilotux.net>
parents: 1486
diff changeset
1045 maxX - Roster_Width - scr_getprefixwidth());
1965
ec737f5f1d6f Couple of readmark-related bugfixes
Mikael Berthe <mikael@lilotux.net>
parents: 1961
diff changeset
1046
ec737f5f1d6f Couple of readmark-related bugfixes
Mikael Berthe <mikael@lilotux.net>
parents: 1961
diff changeset
1047 // Set a readmark to separate new content
ec737f5f1d6f Couple of readmark-related bugfixes
Mikael Berthe <mikael@lilotux.net>
parents: 1961
diff changeset
1048 hbuf_set_readmark(tmp->bd->hbuf, TRUE);
1157
5c857f0f0ab8 Moved all variables related to hbuf to an extra struct, bufdata
Frank Zschockelt
parents: 1156
diff changeset
1049 }
181
4a0bde661562 [/trunk] Changeset 193 by mikael
mikael
parents: 180
diff changeset
1050
1078
7866dbaf67a6 Use a hash for the list of win buffers
Mikael Berthe <mikael@lilotux.net>
parents: 1077
diff changeset
1051 id = g_strdup(title);
7866dbaf67a6 Use a hash for the list of win buffers
Mikael Berthe <mikael@lilotux.net>
parents: 1077
diff changeset
1052 mc_strtolower(id);
7866dbaf67a6 Use a hash for the list of win buffers
Mikael Berthe <mikael@lilotux.net>
parents: 1077
diff changeset
1053 g_hash_table_insert(winbufhash, id, tmp);
1157
5c857f0f0ab8 Moved all variables related to hbuf to an extra struct, bufdata
Frank Zschockelt
parents: 1156
diff changeset
1054 } else {
1159
53c0c5be43fa Small fixes, typos and cleanups
Mikael Berthe <mikael@lilotux.net>
parents: 1157
diff changeset
1055 tmp->bd = g_new0(buffdata, 1);
849
42c43a88d823 Status buffer management
Mikael Berthe <mikael@lilotux.net>
parents: 848
diff changeset
1056 }
24
e88b15cbf2de [/trunk] Changeset 40 by mikael
mikael
parents:
diff changeset
1057 return tmp;
e88b15cbf2de [/trunk] Changeset 40 by mikael
mikael
parents:
diff changeset
1058 }
e88b15cbf2de [/trunk] Changeset 40 by mikael
mikael
parents:
diff changeset
1059
1483
e74cc83e7158 Refactor scr_UpdateWindow()
Mikael Berthe <mikael@lilotux.net>
parents: 1476
diff changeset
1060 // scr_line_prefix(line, pref, preflen)
e74cc83e7158 Refactor scr_UpdateWindow()
Mikael Berthe <mikael@lilotux.net>
parents: 1476
diff changeset
1061 // Use data from the hbb_line structure and write the prefix
e74cc83e7158 Refactor scr_UpdateWindow()
Mikael Berthe <mikael@lilotux.net>
parents: 1476
diff changeset
1062 // to pref (not exceeding preflen, trailing null byte included).
e74cc83e7158 Refactor scr_UpdateWindow()
Mikael Berthe <mikael@lilotux.net>
parents: 1476
diff changeset
1063 void scr_line_prefix(hbb_line *line, char *pref, guint preflen)
e74cc83e7158 Refactor scr_UpdateWindow()
Mikael Berthe <mikael@lilotux.net>
parents: 1476
diff changeset
1064 {
e74cc83e7158 Refactor scr_UpdateWindow()
Mikael Berthe <mikael@lilotux.net>
parents: 1476
diff changeset
1065 char date[64];
e74cc83e7158 Refactor scr_UpdateWindow()
Mikael Berthe <mikael@lilotux.net>
parents: 1476
diff changeset
1066
e74cc83e7158 Refactor scr_UpdateWindow()
Mikael Berthe <mikael@lilotux.net>
parents: 1476
diff changeset
1067 if (line->timestamp &&
e74cc83e7158 Refactor scr_UpdateWindow()
Mikael Berthe <mikael@lilotux.net>
parents: 1476
diff changeset
1068 !(line->flags & (HBB_PREFIX_SPECIAL|HBB_PREFIX_CONT))) {
e74cc83e7158 Refactor scr_UpdateWindow()
Mikael Berthe <mikael@lilotux.net>
parents: 1476
diff changeset
1069 strftime(date, 30, gettprefix(), localtime(&line->timestamp));
e74cc83e7158 Refactor scr_UpdateWindow()
Mikael Berthe <mikael@lilotux.net>
parents: 1476
diff changeset
1070 } else
e74cc83e7158 Refactor scr_UpdateWindow()
Mikael Berthe <mikael@lilotux.net>
parents: 1476
diff changeset
1071 strcpy(date, " ");
e74cc83e7158 Refactor scr_UpdateWindow()
Mikael Berthe <mikael@lilotux.net>
parents: 1476
diff changeset
1072
e74cc83e7158 Refactor scr_UpdateWindow()
Mikael Berthe <mikael@lilotux.net>
parents: 1476
diff changeset
1073 if (!(line->flags & HBB_PREFIX_CONT)) {
e74cc83e7158 Refactor scr_UpdateWindow()
Mikael Berthe <mikael@lilotux.net>
parents: 1476
diff changeset
1074 if (line->flags & HBB_PREFIX_INFO) {
e74cc83e7158 Refactor scr_UpdateWindow()
Mikael Berthe <mikael@lilotux.net>
parents: 1476
diff changeset
1075 char dir = '*';
e74cc83e7158 Refactor scr_UpdateWindow()
Mikael Berthe <mikael@lilotux.net>
parents: 1476
diff changeset
1076 if (line->flags & HBB_PREFIX_IN)
e74cc83e7158 Refactor scr_UpdateWindow()
Mikael Berthe <mikael@lilotux.net>
parents: 1476
diff changeset
1077 dir = '<';
e74cc83e7158 Refactor scr_UpdateWindow()
Mikael Berthe <mikael@lilotux.net>
parents: 1476
diff changeset
1078 else if (line->flags & HBB_PREFIX_OUT)
e74cc83e7158 Refactor scr_UpdateWindow()
Mikael Berthe <mikael@lilotux.net>
parents: 1476
diff changeset
1079 dir = '>';
e74cc83e7158 Refactor scr_UpdateWindow()
Mikael Berthe <mikael@lilotux.net>
parents: 1476
diff changeset
1080 g_snprintf(pref, preflen, "%s*%c* ", date, dir);
e74cc83e7158 Refactor scr_UpdateWindow()
Mikael Berthe <mikael@lilotux.net>
parents: 1476
diff changeset
1081 } else if (line->flags & HBB_PREFIX_ERR) {
e74cc83e7158 Refactor scr_UpdateWindow()
Mikael Berthe <mikael@lilotux.net>
parents: 1476
diff changeset
1082 char dir = '#';
e74cc83e7158 Refactor scr_UpdateWindow()
Mikael Berthe <mikael@lilotux.net>
parents: 1476
diff changeset
1083 if (line->flags & HBB_PREFIX_IN)
e74cc83e7158 Refactor scr_UpdateWindow()
Mikael Berthe <mikael@lilotux.net>
parents: 1476
diff changeset
1084 dir = '<';
e74cc83e7158 Refactor scr_UpdateWindow()
Mikael Berthe <mikael@lilotux.net>
parents: 1476
diff changeset
1085 else if (line->flags & HBB_PREFIX_OUT)
e74cc83e7158 Refactor scr_UpdateWindow()
Mikael Berthe <mikael@lilotux.net>
parents: 1476
diff changeset
1086 dir = '>';
e74cc83e7158 Refactor scr_UpdateWindow()
Mikael Berthe <mikael@lilotux.net>
parents: 1476
diff changeset
1087 g_snprintf(pref, preflen, "%s#%c# ", date, dir);
e74cc83e7158 Refactor scr_UpdateWindow()
Mikael Berthe <mikael@lilotux.net>
parents: 1476
diff changeset
1088 } else if (line->flags & HBB_PREFIX_IN) {
1484
7b36b91a4388 New UI message flag (O) when OTR is used
Mikael Berthe <mikael@lilotux.net>
parents: 1483
diff changeset
1089 char cryptflag;
7b36b91a4388 New UI message flag (O) when OTR is used
Mikael Berthe <mikael@lilotux.net>
parents: 1483
diff changeset
1090 if (line->flags & HBB_PREFIX_PGPCRYPT)
7b36b91a4388 New UI message flag (O) when OTR is used
Mikael Berthe <mikael@lilotux.net>
parents: 1483
diff changeset
1091 cryptflag = '~';
7b36b91a4388 New UI message flag (O) when OTR is used
Mikael Berthe <mikael@lilotux.net>
parents: 1483
diff changeset
1092 else if (line->flags & HBB_PREFIX_OTRCRYPT)
7b36b91a4388 New UI message flag (O) when OTR is used
Mikael Berthe <mikael@lilotux.net>
parents: 1483
diff changeset
1093 cryptflag = 'O';
7b36b91a4388 New UI message flag (O) when OTR is used
Mikael Berthe <mikael@lilotux.net>
parents: 1483
diff changeset
1094 else
7b36b91a4388 New UI message flag (O) when OTR is used
Mikael Berthe <mikael@lilotux.net>
parents: 1483
diff changeset
1095 cryptflag = '=';
1483
e74cc83e7158 Refactor scr_UpdateWindow()
Mikael Berthe <mikael@lilotux.net>
parents: 1476
diff changeset
1096 g_snprintf(pref, preflen, "%s<%c= ", date, cryptflag);
e74cc83e7158 Refactor scr_UpdateWindow()
Mikael Berthe <mikael@lilotux.net>
parents: 1476
diff changeset
1097 } else if (line->flags & HBB_PREFIX_OUT) {
1602
f4a2c6f767d1 Message Receipts support (XEP-0184)
franky
parents: 1599
diff changeset
1098 char cryptflag, receiptflag;
1484
7b36b91a4388 New UI message flag (O) when OTR is used
Mikael Berthe <mikael@lilotux.net>
parents: 1483
diff changeset
1099 if (line->flags & HBB_PREFIX_PGPCRYPT)
7b36b91a4388 New UI message flag (O) when OTR is used
Mikael Berthe <mikael@lilotux.net>
parents: 1483
diff changeset
1100 cryptflag = '~';
7b36b91a4388 New UI message flag (O) when OTR is used
Mikael Berthe <mikael@lilotux.net>
parents: 1483
diff changeset
1101 else if (line->flags & HBB_PREFIX_OTRCRYPT)
7b36b91a4388 New UI message flag (O) when OTR is used
Mikael Berthe <mikael@lilotux.net>
parents: 1483
diff changeset
1102 cryptflag = 'O';
7b36b91a4388 New UI message flag (O) when OTR is used
Mikael Berthe <mikael@lilotux.net>
parents: 1483
diff changeset
1103 else
1488
b393b8cee171 Fix small mistake in changeset 7b36b91a4388
Mikael Berthe <mikael@lilotux.net>
parents: 1487
diff changeset
1104 cryptflag = '-';
1602
f4a2c6f767d1 Message Receipts support (XEP-0184)
franky
parents: 1599
diff changeset
1105 if (line->flags & HBB_PREFIX_RECEIPT)
f4a2c6f767d1 Message Receipts support (XEP-0184)
franky
parents: 1599
diff changeset
1106 receiptflag = 'r';
f4a2c6f767d1 Message Receipts support (XEP-0184)
franky
parents: 1599
diff changeset
1107 else
f4a2c6f767d1 Message Receipts support (XEP-0184)
franky
parents: 1599
diff changeset
1108 receiptflag = '-';
f4a2c6f767d1 Message Receipts support (XEP-0184)
franky
parents: 1599
diff changeset
1109 g_snprintf(pref, preflen, "%s%c%c> ", date, receiptflag, cryptflag);
1483
e74cc83e7158 Refactor scr_UpdateWindow()
Mikael Berthe <mikael@lilotux.net>
parents: 1476
diff changeset
1110 } else if (line->flags & HBB_PREFIX_SPECIAL) {
e74cc83e7158 Refactor scr_UpdateWindow()
Mikael Berthe <mikael@lilotux.net>
parents: 1476
diff changeset
1111 strftime(date, 30, getspectprefix(), localtime(&line->timestamp));
e74cc83e7158 Refactor scr_UpdateWindow()
Mikael Berthe <mikael@lilotux.net>
parents: 1476
diff changeset
1112 g_snprintf(pref, preflen, "%s ", date);
e74cc83e7158 Refactor scr_UpdateWindow()
Mikael Berthe <mikael@lilotux.net>
parents: 1476
diff changeset
1113 } else {
e74cc83e7158 Refactor scr_UpdateWindow()
Mikael Berthe <mikael@lilotux.net>
parents: 1476
diff changeset
1114 g_snprintf(pref, preflen, "%s ", date);
e74cc83e7158 Refactor scr_UpdateWindow()
Mikael Berthe <mikael@lilotux.net>
parents: 1476
diff changeset
1115 }
e74cc83e7158 Refactor scr_UpdateWindow()
Mikael Berthe <mikael@lilotux.net>
parents: 1476
diff changeset
1116 } else {
e74cc83e7158 Refactor scr_UpdateWindow()
Mikael Berthe <mikael@lilotux.net>
parents: 1476
diff changeset
1117 g_snprintf(pref, preflen, " ");
e74cc83e7158 Refactor scr_UpdateWindow()
Mikael Berthe <mikael@lilotux.net>
parents: 1476
diff changeset
1118 }
e74cc83e7158 Refactor scr_UpdateWindow()
Mikael Berthe <mikael@lilotux.net>
parents: 1476
diff changeset
1119 }
e74cc83e7158 Refactor scr_UpdateWindow()
Mikael Berthe <mikael@lilotux.net>
parents: 1476
diff changeset
1120
1780
e4378fbab5d7 Major API cleanup - bump API to 4
Mikael Berthe <mikael@lilotux.net>
parents: 1761
diff changeset
1121 // scr_update_window()
143
300bb88f631f [/trunk] Changeset 155 by mikael
mikael
parents: 142
diff changeset
1122 // (Re-)Display the given chat window.
1780