author | Mikael Berthe <mikael@lilotux.net> |
Sun, 21 Mar 2010 15:14:24 +0100 | |
changeset 1804 | 35a1250c111a |
parent 1802 | b135572fcd26 |
child 1811 | e6d355e50d7a |
permissions | -rw-r--r-- |
307 | 1 |
/* |
2 |
* screen.c -- UI stuff |
|
393 | 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 | 5 |
* Parts of this file come from the Cabber project <cabber@ajmacias.com> |
6 |
* |
|
7 |
* This program is free software; you can redistribute it and/or modify |
|
8 |
* it under the terms of the GNU General Public License as published by |
|
9 |
* the Free Software Foundation; either version 2 of the License, or (at |
|
10 |
* your option) any later version. |
|
11 |
* |
|
12 |
* This program is distributed in the hope that it will be useful, but |
|
13 |
* WITHOUT ANY WARRANTY; without even the implied warranty of |
|
14 |
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
|
15 |
* General Public License for more details. |
|
16 |
* |
|
17 |
* You should have received a copy of the GNU General Public License |
|
18 |
* along with this program; if not, write to the Free Software |
|
19 |
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 |
|
20 |
* USA |
|
21 |
*/ |
|
22 |
||
24 | 23 |
#include <stdio.h> |
24 |
#include <stdlib.h> |
|
25 |
#include <string.h> |
|
26 |
#include <time.h> |
|
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 | 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 | 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> |
8d1bcc83ae32
Add support for spellchecking with Enchant (caolan)
Mikael Berthe <mikael@lilotux.net>
parents:
1579
diff
changeset
|
46 |
#endif |
8d1bcc83ae32
Add support for spellchecking with Enchant (caolan)
Mikael Berthe <mikael@lilotux.net>
parents:
1579
diff
changeset
|
47 |
|
8d1bcc83ae32
Add support for spellchecking with Enchant (caolan)
Mikael Berthe <mikael@lilotux.net>
parents:
1579
diff
changeset
|
48 |
#ifdef WITH_ASPELL |
1179 | 49 |
# include <aspell.h> |
50 |
#endif |
|
51 |
||
24 | 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 | 54 |
#include "hbuf.h" |
47 | 55 |
#include "commands.h" |
95 | 56 |
#include "compl.h" |
81 | 57 |
#include "roster.h" |
180 | 58 |
#include "histolog.h" |
279
f5dd437c057b
Rewrite the settings system
Mikael Berthe <mikael@lilotux.net>
parents:
276
diff
changeset
|
59 |
#include "settings.h" |
81 | 60 |
#include "utils.h" |
1598 | 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 | 63 |
|
739
0d5fb1d9077c
Allow "bright" text colors
Mikael Berthe <mikael@lilotux.net>
parents:
735
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 | 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 | 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; |
515
180f0a6e4ac9
Log window's height can be set by the user
Mikael Berthe <mikael@lilotux.net>
parents:
514
diff
changeset
|
75 |
|
1804
35a1250c111a
Display urgent/attention sign in the roster UI
Mikael Berthe <mikael@lilotux.net>
parents:
1802
diff
changeset
|
76 |
// Default attention sign trigger levels |
35a1250c111a
Display urgent/attention sign in the roster UI
Mikael Berthe <mikael@lilotux.net>
parents:
1802
diff
changeset
|
77 |
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
|
78 |
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
|
79 |
|
336
eb994ee40029
Make some functions static
Mikael Berthe <mikael@lilotux.net>
parents:
332
diff
changeset
|
80 |
static inline void check_offset(int); |
1172
334ae9f498f1
Add some more iline functions (Lego12239)
Mikael Berthe <mikael@lilotux.net>
parents:
1171
diff
changeset
|
81 |
static void scr_cancel_current_completion(void); |
334ae9f498f1
Add some more iline functions (Lego12239)
Mikael Berthe <mikael@lilotux.net>
parents:
1171
diff
changeset
|
82 |
static void scr_end_current_completion(void); |
334ae9f498f1
Add some more iline functions (Lego12239)
Mikael Berthe <mikael@lilotux.net>
parents:
1171
diff
changeset
|
83 |
static void scr_insert_text(const char*); |
334ae9f498f1
Add some more iline functions (Lego12239)
Mikael Berthe <mikael@lilotux.net>
parents:
1171
diff
changeset
|
84 |
static void scr_handle_tab(void); |
151 | 85 |
|
1780
e4378fbab5d7
Major API cleanup - bump API to 4
Mikael Berthe <mikael@lilotux.net>
parents:
1761
diff
changeset
|
86 |
#if defined XEP0022 || defined XEP0085 |
e4378fbab5d7
Major API cleanup - bump API to 4
Mikael Berthe <mikael@lilotux.net>
parents:
1761
diff
changeset
|
87 |
static gboolean scr_chatstates_timeout(); |
e4378fbab5d7
Major API cleanup - bump API to 4
Mikael Berthe <mikael@lilotux.net>
parents:
1761
diff
changeset
|
88 |
#endif |
e4378fbab5d7
Major API cleanup - bump API to 4
Mikael Berthe <mikael@lilotux.net>
parents:
1761
diff
changeset
|
89 |
|
1590
8d1bcc83ae32
Add support for spellchecking with Enchant (caolan)
Mikael Berthe <mikael@lilotux.net>
parents:
1579
diff
changeset
|
90 |
#if defined(WITH_ENCHANT) || defined(WITH_ASPELL) |
1179 | 91 |
static void spellcheck(char *, char *); |
92 |
#endif |
|
93 |
||
1078
7866dbaf67a6
Use a hash for the list of win buffers
Mikael Berthe <mikael@lilotux.net>
parents:
1077
diff
changeset
|
94 |
static GHashTable *winbufhash; |
24 | 95 |
|
822 | 96 |
typedef struct { |
1157
5c857f0f0ab8
Moved all variables related to hbuf to an extra struct, bufdata
Frank Zschockelt
parents:
1156
diff
changeset
|
97 |
GList *hbuf; |
5c857f0f0ab8
Moved all variables related to hbuf to an extra struct, bufdata
Frank Zschockelt
parents:
1156
diff
changeset
|
98 |
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
|
99 |
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
|
100 |
char lock; |
5c857f0f0ab8
Moved all variables related to hbuf to an extra struct, bufdata
Frank Zschockelt
parents:
1156
diff
changeset
|
101 |
} buffdata; |
5c857f0f0ab8
Moved all variables related to hbuf to an extra struct, bufdata
Frank Zschockelt
parents:
1156
diff
changeset
|
102 |
|
5c857f0f0ab8
Moved all variables related to hbuf to an extra struct, bufdata
Frank Zschockelt
parents:
1156
diff
changeset
|
103 |
typedef struct { |
24 | 104 |
WINDOW *win; |
108 | 105 |
PANEL *panel; |
1157
5c857f0f0ab8
Moved all variables related to hbuf to an extra struct, bufdata
Frank Zschockelt
parents:
1156
diff
changeset
|
106 |
buffdata *bd; |
822 | 107 |
} winbuf; |
24 | 108 |
|
1078
7866dbaf67a6
Use a hash for the list of win buffers
Mikael Berthe <mikael@lilotux.net>
parents:
1077
diff
changeset
|
109 |
struct dimensions { |
7866dbaf67a6
Use a hash for the list of win buffers
Mikael Berthe <mikael@lilotux.net>
parents:
1077
diff
changeset
|
110 |
int l; |
7866dbaf67a6
Use a hash for the list of win buffers
Mikael Berthe <mikael@lilotux.net>
parents:
1077
diff
changeset
|
111 |
int c; |
7866dbaf67a6
Use a hash for the list of win buffers
Mikael Berthe <mikael@lilotux.net>
parents:
1077
diff
changeset
|
112 |
}; |
24 | 113 |
|
1133
9dd28a56128f
Do not create one panel per contact
Mikael Berthe <mikael@lilotux.net>
parents:
1131
diff
changeset
|
114 |
static WINDOW *rosterWnd, *chatWnd, *activechatWnd, *inputWnd, *logWnd; |
711 | 115 |
static WINDOW *mainstatusWnd, *chatstatusWnd; |
1133
9dd28a56128f
Do not create one panel per contact
Mikael Berthe <mikael@lilotux.net>
parents:
1131
diff
changeset
|
116 |
static PANEL *rosterPanel, *chatPanel, *activechatPanel, *inputPanel; |
711 | 117 |
static PANEL *mainstatusPanel, *chatstatusPanel; |
118 |
static PANEL *logPanel; |
|
24 | 119 |
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
|
120 |
static int prev_chatwidth; |
849
42c43a88d823
Status buffer management
Mikael Berthe <mikael@lilotux.net>
parents:
848
diff
changeset
|
121 |
static winbuf *statusWindow; |
822 | 122 |
static winbuf *currentWindow; |
851
da03534e46c7
Add startup log messages to the status buffer
Mikael Berthe <mikael@lilotux.net>
parents:
850
diff
changeset
|
123 |
static GList *statushbuf; |
24 | 124 |
|
707
b26a0bde4cdb
Add /roster hide|show|toggle
Mikael Berthe <mikael@lilotux.net>
parents:
701
diff
changeset
|
125 |
static int roster_hidden; |
24 | 126 |
static int chatmode; |
238 | 127 |
static int multimode; |
807
f6cda389db48
Allow messages with a subject (/msay)
Mikael Berthe <mikael@lilotux.net>
parents:
806
diff
changeset
|
128 |
static char *multiline, *multimode_subj; |
1780
e4378fbab5d7
Major API cleanup - bump API to 4
Mikael Berthe <mikael@lilotux.net>
parents:
1761
diff
changeset
|
129 |
|
332
a1901741890e
scr_LogPrint() can be called before ncurses initialization
Mikael Berthe <mikael@lilotux.net>
parents:
330
diff
changeset
|
130 |
static bool Curses; |
972
11b632d824f6
Add option 'log_win_on_top'
Mikael Berthe <mikael@lilotux.net>
parents:
967
diff
changeset
|
131 |
static bool log_win_on_top; |
973
e693cbe33802
Add option 'roster_win_on_right'
Mikael Berthe <mikael@lilotux.net>
parents:
972
diff
changeset
|
132 |
static bool roster_win_on_right; |
1677 | 133 |
static guint autoaway_source = 0; |
24 | 134 |
|
174 | 135 |
static char inputLine[INPUTLINE_LENGTH+1]; |
1590
8d1bcc83ae32
Add support for spellchecking with Enchant (caolan)
Mikael Berthe <mikael@lilotux.net>
parents:
1579
diff
changeset
|
136 |
#if defined(WITH_ENCHANT) || defined(WITH_ASPELL) |
1179 | 137 |
static char maskLine[INPUTLINE_LENGTH+1]; |
138 |
#endif |
|
174 | 139 |
static char *ptr_inputline; |
140 |
static short int inputline_offset; |
|
141 |
static int completion_started; |
|
173 | 142 |
static GList *cmdhisto; |
143 |
static GList *cmdhisto_cur; |
|
1127
fddf2fef7b83
Add option "cmdhistory_lines"
Mikael Berthe <mikael@lilotux.net>
parents:
1122
diff
changeset
|
144 |
static guint cmdhisto_nblines; |
174 | 145 |
static char cmdhisto_backup[INPUTLINE_LENGTH+1]; |
24 | 146 |
|
991
ef10906691bb
Chatstates: add composing timeout
Mikael Berthe <mikael@lilotux.net>
parents:
990
diff
changeset
|
147 |
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
|
148 |
static bool lock_chatstate; |
991
ef10906691bb
Chatstates: add composing timeout
Mikael Berthe <mikael@lilotux.net>
parents:
990
diff
changeset
|
149 |
static time_t chatstate_timestamp; |
1598 | 150 |
static guint chatstate_timeout_id = 0; |
1780
e4378fbab5d7
Major API cleanup - bump API to 4
Mikael Berthe <mikael@lilotux.net>
parents:
1761
diff
changeset
|
151 |
|
e4378fbab5d7
Major API cleanup - bump API to 4
Mikael Berthe <mikael@lilotux.net>
parents:
1761
diff
changeset
|
152 |
int update_roster; |
e4378fbab5d7
Major API cleanup - bump API to 4
Mikael Berthe <mikael@lilotux.net>
parents:
1761
diff
changeset
|
153 |
int utf8_mode; |
e4378fbab5d7
Major API cleanup - bump API to 4
Mikael Berthe <mikael@lilotux.net>
parents:
1761
diff
changeset
|
154 |
gboolean chatstates_disabled; |
e4378fbab5d7
Major API cleanup - bump API to 4
Mikael Berthe <mikael@lilotux.net>
parents:
1761
diff
changeset
|
155 |
gboolean Autoaway; |
990
35e7913affb7
Send events/chatstates notifications (JEP-22/JEP-85)
Mikael Berthe <mikael@lilotux.net>
parents:
987
diff
changeset
|
156 |
|
761
4532a9fe0e8c
Handle some keyboard escape sequences
Mikael Berthe <mikael@lilotux.net>
parents:
760
diff
changeset
|
157 |
#define MAX_KEYSEQ_LENGTH 8 |
4532a9fe0e8c
Handle some keyboard escape sequences
Mikael Berthe <mikael@lilotux.net>
parents:
760
diff
changeset
|
158 |
|
4532a9fe0e8c
Handle some keyboard escape sequences
Mikael Berthe <mikael@lilotux.net>
parents:
760
diff
changeset
|
159 |
typedef struct { |
4532a9fe0e8c
Handle some keyboard escape sequences
Mikael Berthe <mikael@lilotux.net>
parents:
760
diff
changeset
|
160 |
char *seqstr; |
4532a9fe0e8c
Handle some keyboard escape sequences
Mikael Berthe <mikael@lilotux.net>
parents:
760
diff
changeset
|
161 |
guint mkeycode; |
4532a9fe0e8c
Handle some keyboard escape sequences
Mikael Berthe <mikael@lilotux.net>
parents:
760
diff
changeset
|
162 |
gint value; |
4532a9fe0e8c
Handle some keyboard escape sequences
Mikael Berthe <mikael@lilotux.net>
parents:
760
diff
changeset
|
163 |
} keyseq; |
4532a9fe0e8c
Handle some keyboard escape sequences
Mikael Berthe <mikael@lilotux.net>
parents:
760
diff
changeset
|
164 |
|
1521
33f8f795abd2
Check for regex support in glib
Mikael Berthe <mikael@lilotux.net>
parents:
1520
diff
changeset
|
165 |
#ifdef HAVE_GLIB_REGEX |
1520 | 166 |
static GRegex *url_regex; |
1521
33f8f795abd2
Check for regex support in glib
Mikael Berthe <mikael@lilotux.net>
parents:
1520
diff
changeset
|
167 |
#endif |
1520 | 168 |
|
761
4532a9fe0e8c
Handle some keyboard escape sequences
Mikael Berthe <mikael@lilotux.net>
parents:
760
diff
changeset
|
169 |
GSList *keyseqlist; |
4532a9fe0e8c
Handle some keyboard escape sequences
Mikael Berthe <mikael@lilotux.net>
parents:
760
diff
changeset
|
170 |
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
|
171 |
|
1780
e4378fbab5d7
Major API cleanup - bump API to 4
Mikael Berthe <mikael@lilotux.net>
parents:
1761
diff
changeset
|
172 |
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
|
173 |
time_t timestamp, unsigned int prefix_flags, |
e4378fbab5d7
Major API cleanup - bump API to 4
Mikael Berthe <mikael@lilotux.net>
parents:
1761
diff
changeset
|
174 |
int force_show, unsigned mucnicklen, |
e4378fbab5d7
Major API cleanup - bump API to 4
Mikael Berthe <mikael@lilotux.net>
parents:
1761
diff
changeset
|
175 |
gpointer xep184); |
e4378fbab5d7
Major API cleanup - bump API to 4
Mikael Berthe <mikael@lilotux.net>
parents:
1761
diff
changeset
|
176 |
|
e4378fbab5d7
Major API cleanup - bump API to 4
Mikael Berthe <mikael@lilotux.net>
parents:
1761
diff
changeset
|
177 |
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
|
178 |
time_t timestamp, guint prefix_flags, |
e4378fbab5d7
Major API cleanup - bump API to 4
Mikael Berthe <mikael@lilotux.net>
parents:
1761
diff
changeset
|
179 |
unsigned mucnicklen, gpointer xep184); |
e4378fbab5d7
Major API cleanup - bump API to 4
Mikael Berthe <mikael@lilotux.net>
parents:
1761
diff
changeset
|
180 |
|
e4378fbab5d7
Major API cleanup - bump API to 4
Mikael Berthe <mikael@lilotux.net>
parents:
1761
diff
changeset
|
181 |
inline void scr_update_buddy_window(void); |
1413 | 182 |
inline void scr_set_chatmode(int enable); |
183 |
||
1590
8d1bcc83ae32
Add support for spellchecking with Enchant (caolan)
Mikael Berthe <mikael@lilotux.net>
parents:
1579
diff
changeset
|
184 |
#define SPELLBADCHAR 5 |
8d1bcc83ae32
Add support for spellchecking with Enchant (caolan)
Mikael Berthe <mikael@lilotux.net>
parents:
1579
diff
changeset
|
185 |
|
8d1bcc83ae32
Add support for spellchecking with Enchant (caolan)
Mikael Berthe <mikael@lilotux.net>
parents:
1579
diff
changeset
|
186 |
#ifdef WITH_ENCHANT |
8d1bcc83ae32
Add support for spellchecking with Enchant (caolan)
Mikael Berthe <mikael@lilotux.net>
parents:
1579
diff
changeset
|
187 |
EnchantBroker *spell_broker; |
8d1bcc83ae32
Add support for spellchecking with Enchant (caolan)
Mikael Berthe <mikael@lilotux.net>
parents:
1579
diff
changeset
|
188 |
EnchantDict *spell_checker; |
8d1bcc83ae32
Add support for spellchecking with Enchant (caolan)
Mikael Berthe <mikael@lilotux.net>
parents:
1579
diff
changeset
|
189 |
#endif |
8d1bcc83ae32
Add support for spellchecking with Enchant (caolan)
Mikael Berthe <mikael@lilotux.net>
parents:
1579
diff
changeset
|
190 |
|
8d1bcc83ae32
Add support for spellchecking with Enchant (caolan)
Mikael Berthe <mikael@lilotux.net>
parents:
1579
diff
changeset
|
191 |
#ifdef WITH_ASPELL |
1179 | 192 |
AspellConfig *spell_config; |
193 |
AspellSpeller *spell_checker; |
|
194 |
#endif |
|
24 | 195 |
|
1272
033576acac4c
Add configurable roster colors (Michal 'vorner' Vaner)
Mikael Berthe <mikael@lilotux.net>
parents:
1268
diff
changeset
|
196 |
typedef struct { |
1489
e9c71ce96dca
Fixed the colorhandling for mucnicks and /color roster
franky@veqlargh.fs
parents:
1488
diff
changeset
|
197 |
int color_pair; |
e9c71ce96dca
Fixed the colorhandling for mucnicks and /color roster
franky@veqlargh.fs
parents:
1488
diff
changeset
|
198 |
int color_attrib; |
e9c71ce96dca
Fixed the colorhandling for mucnicks and /color roster
franky@veqlargh.fs
parents:
1488
diff
changeset
|
199 |
} ccolor; |
e9c71ce96dca
Fixed the colorhandling for mucnicks and /color roster
franky@veqlargh.fs
parents:
1488
diff
changeset
|
200 |
|
e9c71ce96dca
Fixed the colorhandling for mucnicks and /color roster
franky@veqlargh.fs
parents:
1488
diff
changeset
|
201 |
typedef struct { |
1272
033576acac4c
Add configurable roster colors (Michal 'vorner' Vaner)
Mikael Berthe <mikael@lilotux.net>
parents:
1268
diff
changeset
|
202 |
char *status, *wildcard; |
1598 | 203 |
ccolor *color; |
1272
033576acac4c
Add configurable roster colors (Michal 'vorner' Vaner)
Mikael Berthe <mikael@lilotux.net>
parents:
1268
diff
changeset
|
204 |
GPatternSpec *compiled; |
033576acac4c
Add configurable roster colors (Michal 'vorner' Vaner)
Mikael Berthe <mikael@lilotux.net>
parents:
1268
diff
changeset
|
205 |
} rostercolor; |
033576acac4c
Add configurable roster colors (Michal 'vorner' Vaner)
Mikael Berthe <mikael@lilotux.net>
parents:
1268
diff
changeset
|
206 |
|
1292
382ec54b584e
Muc nick coloring functionality
Michal 'vorner' Vaner <vorner@ucw.cz>
parents:
1291
diff
changeset
|
207 |
static GSList *rostercolrules = 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 |
static GHashTable *muccolors = NULL, *nickcolors = NULL; |
382ec54b584e
Muc nick coloring functionality
Michal 'vorner' Vaner <vorner@ucw.cz>
parents:
1291
diff
changeset
|
210 |
|
382ec54b584e
Muc nick coloring functionality
Michal 'vorner' Vaner <vorner@ucw.cz>
parents:
1291
diff
changeset
|
211 |
typedef struct { |
1413 | 212 |
bool manual; // Manually set? |
1598 | 213 |
ccolor *color; |
1292
382ec54b584e
Muc nick coloring functionality
Michal 'vorner' Vaner <vorner@ucw.cz>
parents:
1291
diff
changeset
|
214 |
} nickcolor; |
382ec54b584e
Muc nick coloring functionality
Michal 'vorner' Vaner <vorner@ucw.cz>
parents:
1291
diff
changeset
|
215 |
|
1489
e9c71ce96dca
Fixed the colorhandling for mucnicks and /color roster
franky@veqlargh.fs
parents:
1488
diff
changeset
|
216 |
static int nickcolcount = 0; |
e9c71ce96dca
Fixed the colorhandling for mucnicks and /color roster
franky@veqlargh.fs
parents:
1488
diff
changeset
|
217 |
static ccolor ** nickcols = NULL; |
1292
382ec54b584e
Muc nick coloring functionality
Michal 'vorner' Vaner <vorner@ucw.cz>
parents:
1291
diff
changeset
|
218 |
static muccoltype glob_muccol = MC_OFF; |
1272
033576acac4c
Add configurable roster colors (Michal 'vorner' Vaner)
Mikael Berthe <mikael@lilotux.net>
parents:
1268
diff
changeset
|
219 |
|
99 | 220 |
/* Functions */ |
24 | 221 |
|
1780
e4378fbab5d7
Major API cleanup - bump API to 4
Mikael Berthe <mikael@lilotux.net>
parents:
1761
diff
changeset
|
222 |
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
|
223 |
{ |
1489
e9c71ce96dca
Fixed the colorhandling for mucnicks and /color roster
franky@veqlargh.fs
parents:
1488
diff
changeset
|
224 |
int result; |
e9c71ce96dca
Fixed the colorhandling for mucnicks and /color roster
franky@veqlargh.fs
parents:
1488
diff
changeset
|
225 |
|
24 | 226 |
if (!strcmp(name, "default")) |
227 |
return -1; |
|
228 |
if (!strcmp(name, "black")) |
|
229 |
return COLOR_BLACK; |
|
230 |
if (!strcmp(name, "red")) |
|
231 |
return COLOR_RED; |
|
232 |
if (!strcmp(name, "green")) |
|
233 |
return COLOR_GREEN; |
|
234 |
if (!strcmp(name, "yellow")) |
|
235 |
return COLOR_YELLOW; |
|
236 |
if (!strcmp(name, "blue")) |
|
237 |
return COLOR_BLUE; |
|
238 |
if (!strcmp(name, "magenta")) |
|
239 |
return COLOR_MAGENTA; |
|
240 |
if (!strcmp(name, "cyan")) |
|
241 |
return COLOR_CYAN; |
|
242 |
if (!strcmp(name, "white")) |
|
243 |
return COLOR_WHITE; |
|
244 |
||
1417
783b47c9d963
Allow more than the 16 default colors (patch from mjs)
Mikael Berthe <mikael@lilotux.net>
parents:
1414
diff
changeset
|
245 |
// 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
|
246 |
result = atoi(name); |
783b47c9d963
Allow more than the 16 default colors (patch from mjs)
Mikael Berthe <mikael@lilotux.net>
parents:
1414
diff
changeset
|
247 |
if (result > 0 && result < COLORS) |
783b47c9d963
Allow more than the 16 default colors (patch from mjs)
Mikael Berthe <mikael@lilotux.net>
parents:
1414
diff
changeset
|
248 |
return result; |
783b47c9d963
Allow more than the 16 default colors (patch from mjs)
Mikael Berthe <mikael@lilotux.net>
parents:
1414
diff
changeset
|
249 |
|
739
0d5fb1d9077c
Allow "bright" text colors
Mikael Berthe <mikael@lilotux.net>
parents:
735
diff
changeset
|
250 |
scr_LogPrint(LPRINT_LOGNORM, "ERROR: Wrong color: %s", name); |
24 | 251 |
return -1; |
252 |
} |
|
253 |
||
1598 | 254 |
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
|
255 |
{ |
1381
40095d413da9
Fix compilation on OpenBSD
Mikael Berthe <mikael@lilotux.net>
parents:
1376
diff
changeset
|
256 |
bool isbright = FALSE; |
1295
33cb828282d5
Fix recognizing of bright colors
Michal 'vorner' Vaner <vorner@ucw.cz>
parents:
1294
diff
changeset
|
257 |
int cl; |
1598 | 258 |
ccolor *ccol; |
1295
33cb828282d5
Fix recognizing of bright colors
Michal 'vorner' Vaner <vorner@ucw.cz>
parents:
1294
diff
changeset
|
259 |
if (!strncmp(color, "bright", 6)) { |
1381
40095d413da9
Fix compilation on OpenBSD
Mikael Berthe <mikael@lilotux.net>
parents:
1376
diff
changeset
|
260 |
isbright = TRUE; |
1295
33cb828282d5
Fix recognizing of bright colors
Michal 'vorner' Vaner <vorner@ucw.cz>
parents:
1294
diff
changeset
|
261 |
color += 6; |
33cb828282d5
Fix recognizing of bright colors
Michal 'vorner' Vaner <vorner@ucw.cz>
parents:
1294
diff
changeset
|
262 |
} |
1780
e4378fbab5d7
Major API cleanup - bump API to 4
Mikael Berthe <mikael@lilotux.net>
parents:
1761
diff
changeset
|
263 |
cl = find_color(color); |
1295
33cb828282d5
Fix recognizing of bright colors
Michal 'vorner' Vaner <vorner@ucw.cz>
parents:
1294
diff
changeset
|
264 |
if (cl < 0) |
1489
e9c71ce96dca
Fixed the colorhandling for mucnicks and /color roster
franky@veqlargh.fs
parents:
1488
diff
changeset
|
265 |
return NULL; |
e9c71ce96dca
Fixed the colorhandling for mucnicks and /color roster
franky@veqlargh.fs
parents:
1488
diff
changeset
|
266 |
ccol = g_new0(ccolor, 1); |
e9c71ce96dca
Fixed the colorhandling for mucnicks and /color roster
franky@veqlargh.fs
parents:
1488
diff
changeset
|
267 |
ccol->color_attrib = isbright ? A_BOLD : A_NORMAL; |
1729
e6e89b1d7831
Minor style and header updates
Mikael Berthe <mikael@lilotux.net>
parents:
1710
diff
changeset
|
268 |
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
|
269 |
return ccol; |
1295
33cb828282d5
Fix recognizing of bright colors
Michal 'vorner' Vaner <vorner@ucw.cz>
parents:
1294
diff
changeset
|
270 |
} |
33cb828282d5
Fix recognizing of bright colors
Michal 'vorner' Vaner <vorner@ucw.cz>
parents:
1294
diff
changeset
|
271 |
|
1292
382ec54b584e
Muc nick coloring functionality
Michal 'vorner' Vaner <vorner@ucw.cz>
parents:
1291
diff
changeset
|
272 |
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
|
273 |
GDestroyNotify value_destroy_func) |
1292
382ec54b584e
Muc nick coloring functionality
Michal 'vorner' Vaner <vorner@ucw.cz>
parents:
1291
diff
changeset
|
274 |
{ |
1729
e6e89b1d7831
Minor style and header updates
Mikael Berthe <mikael@lilotux.net>
parents:
1710
diff
changeset
|
275 |
if (*table) // Have it already |
1292
382ec54b584e
Muc nick coloring functionality
Michal 'vorner' Vaner <vorner@ucw.cz>
parents:
1291
diff
changeset
|
276 |
return; |
382ec54b584e
Muc nick coloring functionality
Michal 'vorner' Vaner <vorner@ucw.cz>
parents:
1291
diff
changeset
|
277 |
*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
|
278 |
g_free, value_destroy_func); |
382ec54b584e
Muc nick coloring functionality
Michal 'vorner' Vaner <vorner@ucw.cz>
parents:
1291
diff
changeset
|
279 |
} |
382ec54b584e
Muc nick coloring functionality
Michal 'vorner' Vaner <vorner@ucw.cz>
parents:
1291
diff
changeset
|
280 |
|
382ec54b584e
Muc nick coloring functionality
Michal 'vorner' Vaner <vorner@ucw.cz>
parents:
1291
diff
changeset
|
281 |
// Sets the coloring mode for given MUC |
382ec54b584e
Muc nick coloring functionality
Michal 'vorner' Vaner <vorner@ucw.cz>
parents:
1291
diff
changeset
|
282 |
// 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
|
283 |
// muc - the JID of room |
382ec54b584e
Muc nick coloring functionality
Michal 'vorner' Vaner <vorner@ucw.cz>
parents:
1291
diff
changeset
|
284 |
// type - the new type |
1780
e4378fbab5d7
Major API cleanup - bump API to 4
Mikael Berthe <mikael@lilotux.net>
parents:
1761
diff
changeset
|
285 |
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
|
286 |
{ |
382ec54b584e
Muc nick coloring functionality
Michal 'vorner' Vaner <vorner@ucw.cz>
parents:
1291
diff
changeset
|
287 |
gchar *muclow = g_utf8_strdown(muc, -1); |
1729
e6e89b1d7831
Minor style and header updates
Mikael Berthe <mikael@lilotux.net>
parents:
1710
diff
changeset
|
288 |
if (type == MC_REMOVE) { // Remove it |
1292
382ec54b584e
Muc nick coloring functionality
Michal 'vorner' Vaner <vorner@ucw.cz>
parents:
1291
diff
changeset
|
289 |
if (strcmp(muc, "*")) { |
382ec54b584e
Muc nick coloring functionality
Michal 'vorner' Vaner <vorner@ucw.cz>
parents:
1291
diff
changeset
|
290 |
if (muccolors && g_hash_table_lookup(muccolors, muclow)) |
382ec54b584e
Muc nick coloring functionality
Michal 'vorner' Vaner <vorner@ucw.cz>
parents:
1291
diff
changeset
|
291 |
g_hash_table_remove(muccolors, muclow); |
382ec54b584e
Muc nick coloring functionality
Michal 'vorner' Vaner <vorner@ucw.cz>
parents:
1291
diff
changeset
|
292 |
} else { |
382ec54b584e
Muc nick coloring functionality
Michal 'vorner' Vaner <vorner@ucw.cz>
parents:
1291
diff
changeset
|
293 |
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
|
294 |
} |
382ec54b584e
Muc nick coloring functionality
Michal 'vorner' Vaner <vorner@ucw.cz>
parents:
1291
diff
changeset
|
295 |
g_free(muclow); |
1729
e6e89b1d7831
Minor style and header updates
Mikael Berthe <mikael@lilotux.net>
parents:
1710
diff
changeset
|
296 |
} else { // Add or overwrite |
1292
382ec54b584e
Muc nick coloring functionality
Michal 'vorner' Vaner <vorner@ucw.cz>
parents:
1291
diff
changeset
|
297 |
if (strcmp(muc, "*")) { |
382ec54b584e
Muc nick coloring functionality
Michal 'vorner' Vaner <vorner@ucw.cz>
parents:
1291
diff
changeset
|
298 |
muccoltype *value = g_new(muccoltype, 1); |
382ec54b584e
Muc nick coloring functionality
Michal 'vorner' Vaner <vorner@ucw.cz>
parents:
1291
diff
changeset
|
299 |
*value = type; |
1476
77afd831f8f7
Avoid mixed declarations and code
Mikael Berthe <mikael@lilotux.net>
parents:
1457
diff
changeset
|
300 |
ensure_string_htable(&muccolors, g_free); |
1292
382ec54b584e
Muc nick coloring functionality
Michal 'vorner' Vaner <vorner@ucw.cz>
parents:
1291
diff
changeset
|
301 |
g_hash_table_replace(muccolors, muclow, value); |
382ec54b584e
Muc nick coloring functionality
Michal 'vorner' Vaner <vorner@ucw.cz>
parents:
1291
diff
changeset
|
302 |
} else { |
382ec54b584e
Muc nick coloring functionality
Michal 'vorner' Vaner <vorner@ucw.cz>
parents:
1291
diff
changeset
|
303 |
glob_muccol = type; |
382ec54b584e
Muc nick coloring functionality
Michal 'vorner' Vaner <vorner@ucw.cz>
parents:
1291
diff
changeset
|
304 |
g_free(muclow); |
382ec54b584e
Muc nick coloring functionality
Michal 'vorner' Vaner <vorner@ucw.cz>
parents:
1291
diff
changeset
|
305 |
} |
382ec54b584e
Muc nick coloring functionality
Michal 'vorner' Vaner <vorner@ucw.cz>
parents:
1291
diff
changeset
|
306 |
} |
1729
e6e89b1d7831
Minor style and header updates
Mikael Berthe <mikael@lilotux.net>
parents:
1710
diff
changeset
|
307 |
// Need to redraw? |
1333
e30a9d907105
Minor coding style adjustments
Mikael Berthe <mikael@lilotux.net>
parents:
1314
diff
changeset
|
308 |
if (chatmode && |
e30a9d907105
Minor coding style adjustments
Mikael Berthe <mikael@lilotux.net>
parents:
1314
diff
changeset
|
309 |
((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
|
310 |
scr_update_buddy_window(); |
1292
382ec54b584e
Muc nick coloring functionality
Michal 'vorner' Vaner <vorner@ucw.cz>
parents:
1291
diff
changeset
|
311 |
} |
382ec54b584e
Muc nick coloring functionality
Michal 'vorner' Vaner <vorner@ucw.cz>
parents:
1291
diff
changeset
|
312 |
|
382ec54b584e
Muc nick coloring functionality
Michal 'vorner' Vaner <vorner@ucw.cz>
parents:
1291
diff
changeset
|
313 |
// Sets the color for nick in MUC |
382ec54b584e
Muc nick coloring functionality
Michal 'vorner' Vaner <vorner@ucw.cz>
parents:
1291
diff
changeset
|
314 |
// 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
|
315 |
// 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
|
316 |
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
|
317 |
{ |
1333
e30a9d907105
Minor coding style adjustments
Mikael Berthe <mikael@lilotux.net>
parents:
1314
diff
changeset
|
318 |
char *snick, *mnick; |
1381
40095d413da9
Fix compilation on OpenBSD
Mikael Berthe <mikael@lilotux.net>
parents:
1376
diff
changeset
|
319 |
bool need_update = FALSE; |
1333
e30a9d907105
Minor coding style adjustments
Mikael Berthe <mikael@lilotux.net>
parents:
1314
diff
changeset
|
320 |
snick = g_strdup_printf("<%s>", nick); |
e30a9d907105
Minor coding style adjustments
Mikael Berthe <mikael@lilotux.net>
parents:
1314
diff
changeset
|
321 |
mnick = g_strdup_printf("*%s ", nick); |
1729
e6e89b1d7831
Minor style and header updates
Mikael Berthe <mikael@lilotux.net>
parents:
1710
diff
changeset
|
322 |
if (!strcmp(color, "-")) { // Remove the color |
1292
382ec54b584e
Muc nick coloring functionality
Michal 'vorner' Vaner <vorner@ucw.cz>
parents:
1291
diff
changeset
|
323 |
if (nickcolors) { |
382ec54b584e
Muc nick coloring functionality
Michal 'vorner' Vaner <vorner@ucw.cz>
parents:
1291
diff
changeset
|
324 |
nickcolor *nc = g_hash_table_lookup(nickcolors, snick); |
1729
e6e89b1d7831
Minor style and header updates
Mikael Berthe <mikael@lilotux.net>
parents:
1710
diff
changeset
|
325 |
if (nc) { // Have this nick already |
1381
40095d413da9
Fix compilation on OpenBSD
Mikael Berthe <mikael@lilotux.net>
parents:
1376
diff
changeset
|
326 |
nc->manual = FALSE; |
1292
382ec54b584e
Muc nick coloring functionality
Michal 'vorner' Vaner <vorner@ucw.cz>
parents:
1291
diff
changeset
|
327 |
nc = g_hash_table_lookup(nickcolors, mnick); |
1729
e6e89b1d7831
Minor style and header updates
Mikael Berthe <mikael@lilotux.net>
parents:
1710
diff
changeset
|
328 |
assert(nc); // Must have both at the same time |
1381
40095d413da9
Fix compilation on OpenBSD
Mikael Berthe <mikael@lilotux.net>
parents:
1376
diff
changeset
|
329 |
nc->manual = FALSE; |
1292
382ec54b584e
Muc nick coloring functionality
Michal 'vorner' Vaner <vorner@ucw.cz>
parents:
1291
diff
changeset
|
330 |
}// Else -> no color saved, nothing to delete |
382ec54b584e
Muc nick coloring functionality
Michal 'vorner' Vaner <vorner@ucw.cz>
parents:
1291
diff
changeset
|
331 |
} |
1729
e6e89b1d7831
Minor style and header updates
Mikael Berthe <mikael@lilotux.net>
parents:
1710
diff
changeset
|
332 |
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
|
333 |
g_free(mnick); |
1381
40095d413da9
Fix compilation on OpenBSD
Mikael Berthe <mikael@lilotux.net>
parents:
1376
diff
changeset
|
334 |
need_update = TRUE; |
1292
382ec54b584e
Muc nick coloring functionality
Michal 'vorner' Vaner <vorner@ucw.cz>
parents:
1291
diff
changeset
|
335 |
} else { |
1598 | 336 |
ccolor *cl = get_user_color(color); |
1489
e9c71ce96dca
Fixed the colorhandling for mucnicks and /color roster
franky@veqlargh.fs
parents:
1488
diff
changeset
|
337 |
if (!cl) { |
1292
382ec54b584e
Muc nick coloring functionality
Michal 'vorner' Vaner <vorner@ucw.cz>
parents:
1291
diff
changeset
|
338 |
scr_LogPrint(LPRINT_NORMAL, "No such color name"); |
382ec54b584e
Muc nick coloring functionality
Michal 'vorner' Vaner <vorner@ucw.cz>
parents:
1291
diff
changeset
|
339 |
g_free(snick); |
382ec54b584e
Muc nick coloring functionality
Michal 'vorner' Vaner <vorner@ucw.cz>
parents:
1291
diff
changeset
|
340 |
g_free(mnick); |
382ec54b584e
Muc nick coloring functionality
Michal 'vorner' Vaner <vorner@ucw.cz>
parents:
1291
diff
changeset
|
341 |
} else { |
382ec54b584e
Muc nick coloring functionality
Michal 'vorner' Vaner <vorner@ucw.cz>
parents:
1291
diff
changeset
|
342 |
nickcolor *nc = g_new(nickcolor, 1); |
382ec54b584e
Muc nick coloring functionality
Michal 'vorner' Vaner <vorner@ucw.cz>
parents:
1291
diff
changeset
|
343 |
ensure_string_htable(&nickcolors, NULL); |
1381
40095d413da9
Fix compilation on OpenBSD
Mikael Berthe <mikael@lilotux.net>
parents:
1376
diff
changeset
|
344 |
nc->manual = TRUE; |
1292
382ec54b584e
Muc nick coloring functionality
Michal 'vorner' Vaner <vorner@ucw.cz>
parents:
1291
diff
changeset
|
345 |
nc->color = cl; |
1729
e6e89b1d7831
Minor style and header updates
Mikael Berthe <mikael@lilotux.net>
parents:
1710
diff
changeset
|
346 |
// Free the struct, if any there already |
1292
382ec54b584e
Muc nick coloring functionality
Michal 'vorner' Vaner <vorner@ucw.cz>
parents:
1291
diff
changeset
|
347 |
g_free(g_hash_table_lookup(nickcolors, mnick)); |
1729
e6e89b1d7831
Minor style and header updates
Mikael Berthe <mikael@lilotux.net>
parents:
1710
diff
changeset
|
348 |
// Save the new ones |
1292
382ec54b584e
Muc nick coloring functionality
Michal 'vorner' Vaner <vorner@ucw.cz>
parents:
1291
diff
changeset
|
349 |
g_hash_table_replace(nickcolors, mnick, nc); |
382ec54b584e
Muc nick coloring functionality
Michal 'vorner' Vaner <vorner@ucw.cz>
parents:
1291
diff
changeset
|
350 |
g_hash_table_replace(nickcolors, snick, nc); |
1381
40095d413da9
Fix compilation on OpenBSD
Mikael Berthe <mikael@lilotux.net>
parents:
1376
diff
changeset
|
351 |
need_update = TRUE; |
1292
382ec54b584e
Muc nick coloring functionality
Michal 'vorner' Vaner <vorner@ucw.cz>
parents:
1291
diff
changeset
|
352 |
} |
382ec54b584e
Muc nick coloring functionality
Michal 'vorner' Vaner <vorner@ucw.cz>
parents:
1291
diff
changeset
|
353 |
} |
382ec54b584e
Muc nick coloring functionality
Michal 'vorner' Vaner <vorner@ucw.cz>
parents:
1291
diff
changeset
|
354 |
if (need_update && chatmode && |
382ec54b584e
Muc nick coloring functionality
Michal 'vorner' Vaner <vorner@ucw.cz>
parents:
1291
diff
changeset
|
355 |
(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
|
356 |
scr_update_buddy_window(); |
1292
382ec54b584e
Muc nick coloring functionality
Michal 'vorner' Vaner <vorner@ucw.cz>
parents:
1291
diff
changeset
|
357 |
} |
382ec54b584e
Muc nick coloring functionality
Michal 'vorner' Vaner <vorner@ucw.cz>
parents:
1291
diff
changeset
|
358 |
|
1272
033576acac4c
Add configurable roster colors (Michal 'vorner' Vaner)
Mikael Berthe <mikael@lilotux.net>
parents:
1268
diff
changeset
|
359 |
static void free_rostercolrule(rostercolor *col) |
033576acac4c
Add configurable roster colors (Michal 'vorner' Vaner)
Mikael Berthe <mikael@lilotux.net>
parents:
1268
diff
changeset
|
360 |
{ |
033576acac4c
Add configurable roster colors (Michal 'vorner' Vaner)
Mikael Berthe <mikael@lilotux.net>
parents:
1268
diff
changeset
|
361 |
g_free(col->status); |
033576acac4c
Add configurable roster colors (Michal 'vorner' Vaner)
Mikael Berthe <mikael@lilotux.net>
parents:
1268
diff
changeset
|
362 |
g_free(col->wildcard); |
1489
e9c71ce96dca
Fixed the colorhandling for mucnicks and /color roster
franky@veqlargh.fs
parents:
1488
diff
changeset
|
363 |
g_free(col->color); |
1272
033576acac4c
Add configurable roster colors (Michal 'vorner' Vaner)
Mikael Berthe <mikael@lilotux.net>
parents:
1268
diff
changeset
|
364 |
g_pattern_spec_free(col->compiled); |
033576acac4c
Add configurable roster colors (Michal 'vorner' Vaner)
Mikael Berthe <mikael@lilotux.net>
parents:
1268
diff
changeset
|
365 |
g_free(col); |
033576acac4c
Add configurable roster colors (Michal 'vorner' Vaner)
Mikael Berthe <mikael@lilotux.net>
parents:
1268
diff
changeset
|
366 |
} |
033576acac4c
Add configurable roster colors (Michal 'vorner' Vaner)
Mikael Berthe <mikael@lilotux.net>
parents:
1268
diff
changeset
|
367 |
|
1284 | 368 |
// Removes all roster coloring rules |
1780
e4378fbab5d7
Major API cleanup - bump API to 4
Mikael Berthe <mikael@lilotux.net>
parents:
1761
diff
changeset
|
369 |
void scr_roster_clear_color(void) |
1272
033576acac4c
Add configurable roster colors (Michal 'vorner' Vaner)
Mikael Berthe <mikael@lilotux.net>
parents:
1268
diff
changeset
|
370 |
{ |
033576acac4c
Add configurable roster colors (Michal 'vorner' Vaner)
Mikael Berthe <mikael@lilotux.net>
parents:
1268
diff
changeset
|
371 |
GSList *head; |
033576acac4c
Add configurable roster colors (Michal 'vorner' Vaner)
Mikael Berthe <mikael@lilotux.net>
parents:
1268
diff
changeset
|
372 |
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
|
373 |
free_rostercolrule(head->data); |
033576acac4c
Add configurable roster colors (Michal 'vorner' Vaner)
Mikael Berthe <mikael@lilotux.net>
parents:
1268
diff
changeset
|
374 |
} |
033576acac4c
Add configurable roster colors (Michal 'vorner' Vaner)
Mikael Berthe <mikael@lilotux.net>
parents:
1268
diff
changeset
|
375 |
g_slist_free(rostercolrules); |
033576acac4c
Add configurable roster colors (Michal 'vorner' Vaner)
Mikael Berthe <mikael@lilotux.net>
parents:
1268
diff
changeset
|
376 |
rostercolrules = NULL; |
033576acac4c
Add configurable roster colors (Michal 'vorner' Vaner)
Mikael Berthe <mikael@lilotux.net>
parents:
1268
diff
changeset
|
377 |
} |
033576acac4c
Add configurable roster colors (Michal 'vorner' Vaner)
Mikael Berthe <mikael@lilotux.net>
parents:
1268
diff
changeset
|
378 |
|
1284 | 379 |
// Adds, modifies or removes roster coloring rule |
380 |
// color set to "-" removes the rule, |
|
381 |
// otherwise it is modified (if exists) or added |
|
382 |
// |
|
383 |
// Returns weather it was successfull (therefore the roster should be |
|
384 |
// redrawed) or not. If it failed, for example because of invalid color |
|
385 |
// name, it also prints the error. |
|
1780
e4378fbab5d7
Major API cleanup - bump API to 4
Mikael Berthe <mikael@lilotux.net>
parents:
1761
diff
changeset
|
386 |
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
|
387 |
const char *color) |
1272
033576acac4c
Add configurable roster colors (Michal 'vorner' Vaner)
Mikael Berthe <mikael@lilotux.net>
parents:
1268
diff
changeset
|
388 |
{ |
033576acac4c
Add configurable roster colors (Michal 'vorner' Vaner)
Mikael Berthe <mikael@lilotux.net>
parents:
1268
diff
changeset
|
389 |
GSList *head; |
033576acac4c
Add configurable roster colors (Michal 'vorner' Vaner)
Mikael Berthe <mikael@lilotux.net>
parents:
1268
diff
changeset
|
390 |
GSList *found = NULL; |
033576acac4c
Add configurable roster colors (Michal 'vorner' Vaner)
Mikael Berthe <mikael@lilotux.net>
parents:
1268
diff
changeset
|
391 |
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
|
392 |
rostercolor *rc = head->data; |
033576acac4c
Add configurable roster colors (Michal 'vorner' Vaner)
Mikael Berthe <mikael@lilotux.net>
parents:
1268
diff
changeset
|
393 |
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
|
394 |
found = head; |
033576acac4c
Add configurable roster colors (Michal 'vorner' Vaner)
Mikael Berthe <mikael@lilotux.net>
parents:
1268
diff
changeset
|
395 |
break; |
033576acac4c
Add configurable roster colors (Michal 'vorner' Vaner)
Mikael Berthe <mikael@lilotux.net>
parents:
1268
diff
changeset
|
396 |
} |
033576acac4c
Add configurable roster colors (Michal 'vorner' Vaner)
Mikael Berthe <mikael@lilotux.net>
parents:
1268
diff
changeset
|
397 |
} |
1729
e6e89b1d7831
Minor style and header updates
Mikael Berthe <mikael@lilotux.net>
parents:
1710
diff
changeset
|
398 |
if (!strcmp(color,"-")) { // Delete the rule |
1272
033576acac4c
Add configurable roster colors (Michal 'vorner' Vaner)
Mikael Berthe <mikael@lilotux.net>
parents:
1268
diff
changeset
|
399 |
if (found) { |
033576acac4c
Add configurable roster colors (Michal 'vorner' Vaner)
Mikael Berthe <mikael@lilotux.net>
parents:
1268
diff
changeset
|
400 |
free_rostercolrule(found->data); |
033576acac4c
Add configurable roster colors (Michal 'vorner' Vaner)
Mikael Berthe <mikael@lilotux.net>
parents:
1268
diff
changeset
|
401 |
rostercolrules = g_slist_delete_link(rostercolrules, found); |
033576acac4c
Add configurable roster colors (Michal 'vorner' Vaner)
Mikael Berthe <mikael@lilotux.net>
parents:
1268
diff
changeset
|
402 |
return TRUE; |
033576acac4c
Add configurable roster colors (Michal 'vorner' Vaner)
Mikael Berthe <mikael@lilotux.net>
parents:
1268
diff
changeset
|
403 |
} else { |
033576acac4c
Add configurable roster colors (Michal 'vorner' Vaner)
Mikael Berthe <mikael@lilotux.net>
parents:
1268
diff
changeset
|
404 |
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
|
405 |
return FALSE; |
033576acac4c
Add configurable roster colors (Michal 'vorner' Vaner)
Mikael Berthe <mikael@lilotux.net>
parents:
1268
diff
changeset
|
406 |
} |
033576acac4c
Add configurable roster colors (Michal 'vorner' Vaner)
Mikael Berthe <mikael@lilotux.net>
parents:
1268
diff
changeset
|
407 |
} else { |
1598 | 408 |
ccolor *cl = get_user_color(color); |
1489
e9c71ce96dca
Fixed the colorhandling for mucnicks and /color roster
franky@veqlargh.fs
parents:
1488
diff
changeset
|
409 |
if (!cl) { |
1272
033576acac4c
Add configurable roster colors (Michal 'vorner' Vaner)
Mikael Berthe <mikael@lilotux.net>
parents:
1268
diff
changeset
|
410 |
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
|
411 |
return FALSE; |
033576acac4c
Add configurable roster colors (Michal 'vorner' Vaner)
Mikael Berthe <mikael@lilotux.net>
parents:
1268
diff
changeset
|
412 |
} |
033576acac4c
Add configurable roster colors (Michal 'vorner' Vaner)
Mikael Berthe <mikael@lilotux.net>
parents:
1268
diff
changeset
|
413 |
if (found) { |
033576acac4c
Add configurable roster colors (Michal 'vorner' Vaner)
Mikael Berthe <mikael@lilotux.net>
parents:
1268
diff
changeset
|
414 |
rostercolor *rc = found->data; |
1489
e9c71ce96dca
Fixed the colorhandling for mucnicks and /color roster
franky@veqlargh.fs
parents:
1488
diff
changeset
|
415 |
g_free(rc->color); |
1272
033576acac4c
Add configurable roster colors (Michal 'vorner' Vaner)
Mikael Berthe <mikael@lilotux.net>
parents:
1268
diff
changeset
|
416 |
rc->color = cl; |
033576acac4c
Add configurable roster colors (Michal 'vorner' Vaner)
Mikael Berthe <mikael@lilotux.net>
parents:
1268
diff
changeset
|
417 |
} else { |
033576acac4c
Add configurable roster colors (Michal 'vorner' Vaner)
Mikael Berthe <mikael@lilotux.net>
parents:
1268
diff
changeset
|
418 |
rostercolor *rc = g_new(rostercolor, 1); |
033576acac4c
Add configurable roster colors (Michal 'vorner' Vaner)
Mikael Berthe <mikael@lilotux.net>
parents:
1268
diff
changeset
|
419 |
rc->status = g_strdup(status); |
033576acac4c
Add configurable roster colors (Michal 'vorner' Vaner)
Mikael Berthe <mikael@lilotux.net>
parents:
1268
diff
changeset
|
420 |
rc->wildcard = g_strdup(wildcard); |
033576acac4c
Add configurable roster colors (Michal 'vorner' Vaner)
Mikael Berthe <mikael@lilotux.net>
parents:
1268
diff
changeset
|
421 |
rc->compiled = g_pattern_spec_new(wildcard); |
033576acac4c
Add configurable roster colors (Michal 'vorner' Vaner)
Mikael Berthe <mikael@lilotux.net>
parents:
1268
diff
changeset
|
422 |
rc->color = cl; |
033576acac4c
Add configurable roster colors (Michal 'vorner' Vaner)
Mikael Berthe <mikael@lilotux.net>
parents:
1268
diff
changeset
|
423 |
rostercolrules = g_slist_prepend(rostercolrules, rc); |
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 |
return TRUE; |
033576acac4c
Add configurable roster colors (Michal 'vorner' Vaner)
Mikael Berthe <mikael@lilotux.net>
parents:
1268
diff
changeset
|
426 |
} |
033576acac4c
Add configurable roster colors (Michal 'vorner' Vaner)
Mikael Berthe <mikael@lilotux.net>
parents:
1268
diff
changeset
|
427 |
} |
033576acac4c
Add configurable roster colors (Michal 'vorner' Vaner)
Mikael Berthe <mikael@lilotux.net>
parents:
1268
diff
changeset
|
428 |
|
1780
e4378fbab5d7
Major API cleanup - bump API to 4
Mikael Berthe <mikael@lilotux.net>
parents:
1761
diff
changeset
|
429 |
static void parse_colors(void) |
24 | 430 |
{ |
739
0d5fb1d9077c
Allow "bright" text colors
Mikael Berthe <mikael@lilotux.net>
parents:
735
diff
changeset
|
431 |
const char *colors[] = { |
24 | 432 |
"", "", |
267 | 433 |
"general", |
785
7e0562e3bc83
Replace color_highlight with color_msgout
Mikael Berthe <mikael@lilotux.net>
parents:
779
diff
changeset
|
434 |
"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
|
435 |
"msghl", |
711 | 436 |
"status", |
712 | 437 |
"roster", |
438 |
"rostersel", |
|
723
23068490d063
Add text color when the selected buddy has an unread message
Mikael Berthe <mikael@lilotux.net>
parents:
721
diff
changeset
|
439 |
"rosterselmsg", |
712 | 440 |
"rosternewmsg", |
1268
dbc907b2d92f
Add configurable colors for info and incoming messages (Michal 'vorner' Vaner)
Mikael Berthe <mikael@lilotux.net>
parents:
1254
diff
changeset
|
441 |
"info", |
dbc907b2d92f
Add configurable colors for info and incoming messages (Michal 'vorner' Vaner)
Mikael Berthe <mikael@lilotux.net>
parents:
1254
diff
changeset
|
442 |
"msgin", |
24 | 443 |
NULL |
444 |
}; |
|
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 | 448 |
const char *backselected = settings_opt_get("color_bgrostersel"); |
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 | 455 |
|
267 | 456 |
// Default values |
711 | 457 |
if (!background) background = "black"; |
267 | 458 |
if (!backselected) backselected = "cyan"; |
711 | 459 |
if (!backstatus) backstatus = "blue"; |
267 | 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 | 472 |
|
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; |
0d5fb1d9077c
Allow "bright" text colors
Mikael Berthe <mikael@lilotux.net>
parents:
735
diff
changeset
|
496 |
case COLOR_ROSTER: |
1780
e4378fbab5d7
Major API cleanup - bump API to 4
Mikael Berthe <mikael@lilotux.net>
parents:
1761
diff
changeset
|
497 |
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
|
498 |
find_color(background)); |
739
0d5fb1d9077c
Allow "bright" text colors
Mikael Berthe <mikael@lilotux.net>
parents:
735
diff
changeset
|
499 |
break; |
0d5fb1d9077c
Allow "bright" text colors
Mikael Berthe <mikael@lilotux.net>
parents:
735
diff
changeset
|
500 |
case COLOR_ROSTERSEL: |
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_BLUE), |
e4378fbab5d7
Major API cleanup - bump API to 4
Mikael Berthe <mikael@lilotux.net>
parents:
1761
diff
changeset
|
502 |
find_color(backselected)); |
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_ROSTERSELNMSG: |
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_RED), |
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_ROSTERNMSG: |
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(background)); |
739
0d5fb1d9077c
Allow "bright" text colors
Mikael Berthe <mikael@lilotux.net>
parents:
735
diff
changeset
|
511 |
break; |
1268
dbc907b2d92f
Add configurable colors for info and incoming messages (Michal 'vorner' Vaner)
Mikael Berthe <mikael@lilotux.net>
parents:
1254
diff
changeset
|
512 |
case COLOR_INFO: |
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_WHITE), |
e4378fbab5d7
Major API cleanup - bump API to 4
Mikael Berthe <mikael@lilotux.net>
parents:
1761
diff
changeset
|
514 |
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
|
515 |
break; |
dbc907b2d92f
Add configurable colors for info and incoming messages (Michal 'vorner' Vaner)
Mikael Berthe <mikael@lilotux.net>
parents:
1254
diff
changeset
|
516 |
case COLOR_MSGIN: |
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; |
24 | 520 |
} |
521 |
} |
|
1489
e9c71ce96dca
Fixed the colorhandling for mucnicks and /color roster
franky@veqlargh.fs
parents:
1488
diff
changeset
|
522 |
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
|
523 |
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
|
524 |
|
1298
af035a304bec
colorable muc nick fix
Michal 'vorner' Vaner <vorner@ucw.cz>
parents:
1296
diff
changeset
|
525 |
if (!nickcols) { |
1314
248e3f69dd9e
Fix a bug in the nick_colors variable parsing
Mikael Berthe <mikael@lilotux.net>
parents:
1311
diff
changeset
|
526 |
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
|
527 |
if (ncolors) { |
1314
248e3f69dd9e
Fix a bug in the nick_colors variable parsing
Mikael Berthe <mikael@lilotux.net>
parents:
1311
diff
changeset
|
528 |
char *ncolor_start, *ncolor_end; |
248e3f69dd9e
Fix a bug in the nick_colors variable parsing
Mikael Berthe <mikael@lilotux.net>
parents:
1311
diff
changeset
|
529 |
ncolor_start = ncolor_end = ncolors; |
248e3f69dd9e
Fix a bug in the nick_colors variable parsing
Mikael Berthe <mikael@lilotux.net>
parents:
1311
diff
changeset
|
530 |
|
248e3f69dd9e
Fix a bug in the nick_colors variable parsing
Mikael Berthe <mikael@lilotux.net>
parents:
1311
diff
changeset
|
531 |
while (*ncolor_end) |
248e3f69dd9e
Fix a bug in the nick_colors variable parsing
Mikael Berthe <mikael@lilotux.net>
parents:
1311
diff
changeset
|
532 |
ncolor_end++; |
248e3f69dd9e
Fix a bug in the nick_colors variable parsing
Mikael Berthe <mikael@lilotux.net>
parents:
1311
diff
changeset
|
533 |
|
248e3f69dd9e
Fix a bug in the nick_colors variable parsing
Mikael Berthe <mikael@lilotux.net>
parents:
1311
diff
changeset
|
534 |
while (ncolors < ncolor_end && *ncolors) { |
1298
af035a304bec
colorable muc nick fix
Michal 'vorner' Vaner <vorner@ucw.cz>
parents:
1296
diff
changeset
|
535 |
if ((*ncolors == ' ') || (*ncolors == '\t')) { |
1314
248e3f69dd9e
Fix a bug in the nick_colors variable parsing
Mikael Berthe <mikael@lilotux.net>
parents:
1311
diff
changeset
|
536 |
ncolors++; |
1292
382ec54b584e
Muc nick coloring functionality
Michal 'vorner' Vaner <vorner@ucw.cz>
parents:
1291
diff
changeset
|
537 |
} else { |
1298
af035a304bec
colorable muc nick fix
Michal 'vorner' Vaner <vorner@ucw.cz>
parents:
1296
diff
changeset
|
538 |
char *end = ncolors; |
1598 | 539 |
ccolor *cl; |
1298
af035a304bec
colorable muc nick fix
Michal 'vorner' Vaner <vorner@ucw.cz>
parents:
1296
diff
changeset
|
540 |
while (*end && (*end != ' ') && (*end != '\t')) |
af035a304bec
colorable muc nick fix
Michal 'vorner' Vaner <vorner@ucw.cz>
parents:
1296
diff
changeset
|
541 |
end++; |
af035a304bec
colorable muc nick fix
Michal 'vorner' Vaner <vorner@ucw.cz>
parents:
1296
diff
changeset
|
542 |
*end = '\0'; |
1314
248e3f69dd9e
Fix a bug in the nick_colors variable parsing
Mikael Berthe <mikael@lilotux.net>
parents:
1311
diff
changeset
|
543 |
cl = get_user_color(ncolors); |
1489
e9c71ce96dca
Fixed the colorhandling for mucnicks and /color roster
franky@veqlargh.fs
parents:
1488
diff
changeset
|
544 |
if (!cl) { |
1298
af035a304bec
colorable muc nick fix
Michal 'vorner' Vaner <vorner@ucw.cz>
parents:
1296
diff
changeset
|
545 |
scr_LogPrint(LPRINT_NORMAL, "Unknown color %s", ncolors); |
af035a304bec
colorable muc nick fix
Michal 'vorner' Vaner <vorner@ucw.cz>
parents:
1296
diff
changeset
|
546 |
} else { |
af035a304bec
colorable muc nick fix
Michal 'vorner' Vaner <vorner@ucw.cz>
parents:
1296
diff
changeset
|
547 |
nickcols = g_realloc(nickcols, (++nickcolcount) * sizeof *nickcols); |
af035a304bec
colorable muc nick fix
Michal 'vorner' Vaner <vorner@ucw.cz>
parents:
1296
diff
changeset
|
548 |
nickcols[nickcolcount-1] = cl; |
af035a304bec
colorable muc nick fix
Michal 'vorner' Vaner <vorner@ucw.cz>
parents:
1296
diff
changeset
|
549 |
} |
1314
248e3f69dd9e
Fix a bug in the nick_colors variable parsing
Mikael Berthe <mikael@lilotux.net>
parents:
1311
diff
changeset
|
550 |
ncolors = end+1; |
1292
382ec54b584e
Muc nick coloring functionality
Michal 'vorner' Vaner <vorner@ucw.cz>
parents:
1291
diff
changeset
|
551 |
} |
382ec54b584e
Muc nick coloring functionality
Michal 'vorner' Vaner <vorner@ucw.cz>
parents:
1291
diff
changeset
|
552 |
} |
1298
af035a304bec
colorable muc nick fix
Michal 'vorner' Vaner <vorner@ucw.cz>
parents:
1296
diff
changeset
|
553 |
g_free(ncolor_start); |
1292
382ec54b584e
Muc nick coloring functionality
Michal 'vorner' Vaner <vorner@ucw.cz>
parents:
1291
diff
changeset
|
554 |
} |
1729
e6e89b1d7831
Minor style and header updates
Mikael Berthe <mikael@lilotux.net>
parents:
1710
diff
changeset
|
555 |
if (!nickcols) { // Fallback to have something |
1298
af035a304bec
colorable muc nick fix
Michal 'vorner' Vaner <vorner@ucw.cz>
parents:
1296
diff
changeset
|
556 |
nickcolcount = 1; |
1489
e9c71ce96dca
Fixed the colorhandling for mucnicks and /color roster
franky@veqlargh.fs
parents:
1488
diff
changeset
|
557 |
nickcols = g_new(ccolor*, 1); |
e9c71ce96dca
Fixed the colorhandling for mucnicks and /color roster
franky@veqlargh.fs
parents:
1488
diff
changeset
|
558 |
*nickcols = g_new(ccolor, 1); |
e9c71ce96dca
Fixed the colorhandling for mucnicks and /color roster
franky@veqlargh.fs
parents:
1488
diff
changeset
|
559 |
(*nickcols)->color_pair = COLOR_GENERAL; |
e9c71ce96dca
Fixed the colorhandling for mucnicks and /color roster
franky@veqlargh.fs
parents:
1488
diff
changeset
|
560 |
(*nickcols)->color_attrib = A_NORMAL; |
1298
af035a304bec
colorable muc nick fix
Michal 'vorner' Vaner <vorner@ucw.cz>
parents:
1296
diff
changeset
|
561 |
} |
1292
382ec54b584e
Muc nick coloring functionality
Michal 'vorner' Vaner <vorner@ucw.cz>
parents:
1291
diff
changeset
|
562 |
} |
24 | 563 |
} |
564 |
||
765
72626e9d60bd
Create init_keycodes(), add 2 screen escape sequences
Mikael Berthe <mikael@lilotux.net>
parents:
764
diff
changeset
|
565 |
static void init_keycodes(void) |
373
af2f8ddf6a1b
Move (reorganize) functions
Mikael Berthe <mikael@lilotux.net>
parents:
370
diff
changeset
|
566 |
{ |
761
4532a9fe0e8c
Handle some keyboard escape sequences
Mikael Berthe <mikael@lilotux.net>
parents:
760
diff
changeset
|
567 |
add_keyseq("O5A", MKEY_EQUIV, 521); // Ctrl-Up |
4532a9fe0e8c
Handle some keyboard escape sequences
Mikael Berthe <mikael@lilotux.net>
parents:
760
diff
changeset
|
568 |
add_keyseq("O5B", MKEY_EQUIV, 514); // Ctrl-Down |
4532a9fe0e8c
Handle some keyboard escape sequences
Mikael Berthe <mikael@lilotux.net>
parents:
760
diff
changeset
|
569 |
add_keyseq("O5C", MKEY_EQUIV, 518); // Ctrl-Right |
4532a9fe0e8c
Handle some keyboard escape sequences
Mikael Berthe <mikael@lilotux.net>
parents:
760
diff
changeset
|
570 |
add_keyseq("O5D", MKEY_EQUIV, 516); // Ctrl-Left |
763 | 571 |
add_keyseq("O6A", MKEY_EQUIV, 520); // Shift-Up |
572 |
add_keyseq("O6B", MKEY_EQUIV, 513); // Shift-Down |
|
573 |
add_keyseq("O6C", MKEY_EQUIV, 402); // Shift-Right |
|
574 |
add_keyseq("O6D", MKEY_EQUIV, 393); // Shift-Left |
|
575 |
add_keyseq("O2A", MKEY_EQUIV, 520); // Shift-Up |
|
576 |
add_keyseq("O2B", MKEY_EQUIV, 513); // Shift-Down |
|
577 |
add_keyseq("O2C", MKEY_EQUIV, 402); // Shift-Right |
|
578 |
add_keyseq("O2D", MKEY_EQUIV, 393); // Shift-Left |
|
579 |
add_keyseq("[5^", MKEY_CTRL_PGUP, 0); // Ctrl-PageUp |
|
580 |
add_keyseq("[6^", MKEY_CTRL_PGDOWN, 0); // Ctrl-PageDown |
|
581 |
add_keyseq("[5@", MKEY_CTRL_SHIFT_PGUP, 0); // Ctrl-Shift-PageUp |
|
582 |
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
|
583 |
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
|
584 |
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
|
585 |
add_keyseq("[8^", MKEY_CTRL_END, 0); // Ctrl-End |
32d5298f9f8d
Add a few keycode sequences
Mikael Berthe <mikael@lilotux.net>
parents:
790
diff
changeset
|
586 |
add_keyseq("[7^", MKEY_CTRL_HOME, 0); // Ctrl-Home |
32d5298f9f8d
Add a few keycode sequences
Mikael Berthe <mikael@lilotux.net>
parents:
790
diff
changeset
|
587 |
add_keyseq("[2^", MKEY_CTRL_INS, 0); // Ctrl-Insert |
32d5298f9f8d
Add a few keycode sequences
Mikael Berthe <mikael@lilotux.net>
parents:
790
diff
changeset
|
588 |
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
|
589 |
|
4532a9fe0e8c
Handle some keyboard escape sequences
Mikael Berthe <mikael@lilotux.net>
parents:
760
diff
changeset
|
590 |
// Xterm |
4532a9fe0e8c
Handle some keyboard escape sequences
Mikael Berthe <mikael@lilotux.net>
parents:
760
diff
changeset
|
591 |
add_keyseq("[1;5A", MKEY_EQUIV, 521); // Ctrl-Up |
4532a9fe0e8c
Handle some keyboard escape sequences
Mikael Berthe <mikael@lilotux.net>
parents:
760
diff
changeset
|
592 |
add_keyseq("[1;5B", MKEY_EQUIV, 514); // Ctrl-Down |
4532a9fe0e8c
Handle some keyboard escape sequences
Mikael Berthe <mikael@lilotux.net>
parents:
760
diff
changeset
|
593 |
add_keyseq("[1;5C", MKEY_EQUIV, 518); // Ctrl-Right |
4532a9fe0e8c
Handle some keyboard escape sequences
Mikael Berthe <mikael@lilotux.net>
parents:
760
diff
changeset
|
594 |
add_keyseq("[1;5D", MKEY_EQUIV, 516); // Ctrl-Left |
4532a9fe0e8c
Handle some keyboard escape sequences
Mikael Berthe <mikael@lilotux.net>
parents:
760
diff
changeset
|
595 |
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
|
596 |
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
|
597 |
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
|
598 |
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
|
599 |
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
|
600 |
add_keyseq("[1;6F", MKEY_CTRL_SHIFT_END, 0); // Ctrl-Shift-End |
763 | 601 |
add_keyseq("[1;2A", MKEY_EQUIV, 521); // Shift-Up |
602 |
add_keyseq("[1;2B", MKEY_EQUIV, 514); // Shift-Down |
|
603 |
add_keyseq("[5;5~", MKEY_CTRL_PGUP, 0); // Ctrl-PageUp |
|
604 |
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
|
605 |
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
|
606 |
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
|
607 |
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
|
608 |
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
|
609 |
|
768
0f6d25a02450
Add PuTTY escape keys for Ctrl-arrows
Mikael Berthe <mikael@lilotux.net>
parents:
766
diff
changeset
|
610 |
// PuTTY |
0f6d25a02450
Add PuTTY escape keys for Ctrl-arrows
Mikael Berthe <mikael@lilotux.net>
parents:
766
diff
changeset
|
611 |
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
|
612 |
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
|
613 |
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
|
614 |
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
|
615 |
|
762
96d46e00524a
Add some key escape sequences for screen
Mikael Berthe <mikael@lilotux.net>
parents:
761
diff
changeset
|
616 |
// screen |
96d46e00524a
Add some key escape sequences for screen
Mikael Berthe <mikael@lilotux.net>
parents:
761
diff
changeset
|
617 |
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
|
618 |
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
|
619 |
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
|
620 |
add_keyseq("Od", MKEY_EQUIV, 516); // Ctrl-Left |
763 | 621 |
add_keyseq("[a", MKEY_EQUIV, 520); // Shift-Up |
622 |
add_keyseq("[b", MKEY_EQUIV, 513); // Shift-Down |
|
623 |
add_keyseq("[c", MKEY_EQUIV, 402); // Shift-Right |
|
624 |
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
|
625 |
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
|
626 |
add_keyseq("[6$", MKEY_SHIFT_PGDOWN, 0); // Shift-PageDown |
1170 | 627 |
|
628 |
// VT100 |
|
629 |
add_keyseq("[H", MKEY_EQUIV, KEY_HOME); // Home |
|
630 |
add_keyseq("[F", MKEY_EQUIV, KEY_END); // End |
|
631 |
||
632 |
// Konsole Linux |
|
633 |
add_keyseq("[1~", MKEY_EQUIV, KEY_HOME); // Home |
|
634 |
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
|
635 |
} |
72626e9d60bd
Create init_keycodes(), add 2 screen escape sequences
Mikael Berthe <mikael@lilotux.net>
parents:
764
diff
changeset
|
636 |
|
1176
547a8ca7c1a8
Move init_bindings() to screen.c, with a few updates
Mikael Berthe <mikael@lilotux.net>
parents:
1173
diff
changeset
|
637 |
// scr_init_bindings() |
547a8ca7c1a8
Move init_bindings() to screen.c, with a few updates
Mikael Berthe <mikael@lilotux.net>
parents:
1173
diff
changeset
|
638 |
// Create default key bindings |
547a8ca7c1a8
Move init_bindings() to screen.c, with a few updates
Mikael Berthe <mikael@lilotux.net>
parents:
1173
diff
changeset
|
639 |
// 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
|
640 |
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
|
641 |
{ |
547a8ca7c1a8
Move init_bindings() to screen.c, with a few updates
Mikael Berthe <mikael@lilotux.net>
parents:
1173
diff
changeset
|
642 |
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
|
643 |
|
547a8ca7c1a8
Move init_bindings() to screen.c, with a few updates
Mikael Berthe <mikael@lilotux.net>
parents:
1173
diff
changeset
|
644 |
// 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
|
645 |
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
|
646 |
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
|
647 |
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
|
648 |
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
|
649 |
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
|
650 |
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
|
651 |
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
|
652 |
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
|
653 |
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
|
654 |
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
|
655 |
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
|
656 |
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
|
657 |
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
|
658 |
"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
|
659 |
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
|
660 |
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
|
661 |
"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
|
662 |
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
|
663 |
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
|
664 |
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
|
665 |
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
|
666 |
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
|
667 |
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
|
668 |
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
|
669 |
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
|
670 |
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
|
671 |
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
|
672 |
// 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
|
673 |
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
|
674 |
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
|
675 |
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
|
676 |
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
|
677 |
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
|
678 |
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
|
679 |
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
|
680 |
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
|
681 |
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
|
682 |
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
|
683 |
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
|
684 |
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
|
685 |
// Ctrl-Left (2 codes): |
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, "515", "iline bword"); |
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, "516", "iline bword"); |
547a8ca7c1a8
Move init_bindings() to screen.c, with a few updates
Mikael Berthe <mikael@lilotux.net>
parents:
1173
diff
changeset
|
688 |
// Ctrl-Right (2 codes): |
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, "517", "iline fword"); |
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, "518", "iline fword"); |
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, "12", "screen_refresh"); // Ctrl-l |
1503
c74cfe7fd848
Add option --show-roster to command chat_disable.
Mikael Berthe <mikael@lilotux.net>
parents:
1502
diff
changeset
|
692 |
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
|
693 |
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
|
694 |
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
|
695 |
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
|
696 |
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
|
697 |
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
|
698 |
|
1208
0dbe51d1e62e
Add default binding for F1 (265) to /help
Mikael Berthe <mikael@lilotux.net>
parents:
1205
diff
changeset
|
699 |
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
|
700 |
|
1176
547a8ca7c1a8
Move init_bindings() to screen.c, with a few updates
Mikael Berthe <mikael@lilotux.net>
parents:
1173
diff
changeset
|
701 |
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
|
702 |
} |
547a8ca7c1a8
Move init_bindings() to screen.c, with a few updates
Mikael Berthe <mikael@lilotux.net>
parents:
1173
diff
changeset
|
703 |
|
1229
e9ea1497ac9d
Fix a key binding issue on FreeBSD
Mikael Berthe <mikael@lilotux.net>
parents:
1228
diff
changeset
|
704 |
// is_speckey(key) |
e9ea1497ac9d
Fix a key binding issue on FreeBSD
Mikael Berthe <mikael@lilotux.net>
parents:
1228
diff
changeset
|
705 |
// 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
|
706 |
// 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
|
707 |
// isprint(KEY_PPAGE) returns TRUE... |
e9ea1497ac9d
Fix a key binding issue on FreeBSD
Mikael Berthe <mikael@lilotux.net>
parents:
1228
diff
changeset
|
708 |
static int is_speckey(int key) |
e9ea1497ac9d
Fix a key binding issue on FreeBSD
Mikael Berthe <mikael@lilotux.net>
parents:
1228
diff
changeset
|
709 |
{ |
e9ea1497ac9d
Fix a key binding issue on FreeBSD
Mikael Berthe <mikael@lilotux.net>
parents:
1228
diff
changeset
|
710 |
switch (key) { |
e9ea1497ac9d
Fix a key binding issue on FreeBSD
Mikael Berthe <mikael@lilotux.net>
parents:
1228
diff
changeset
|
711 |
case 127: |
e9ea1497ac9d
Fix a key binding issue on FreeBSD
Mikael Berthe <mikael@lilotux.net>
parents:
1228
diff
changeset
|
712 |
case 393: |
e9ea1497ac9d
Fix a key binding issue on FreeBSD
Mikael Berthe <mikael@lilotux.net>
parents:
1228
diff
changeset
|
713 |
case 402: |
e9ea1497ac9d
Fix a key binding issue on FreeBSD
Mikael Berthe <mikael@lilotux.net>
parents:
1228
diff
changeset
|
714 |
case KEY_BACKSPACE: |
e9ea1497ac9d
Fix a key binding issue on FreeBSD
Mikael Berthe <mikael@lilotux.net>
parents:
1228
diff
changeset
|
715 |
case KEY_DC: |
e9ea1497ac9d
Fix a key binding issue on FreeBSD
Mikael Berthe <mikael@lilotux.net>
parents:
1228
diff
changeset
|
716 |
case KEY_LEFT: |
e9ea1497ac9d
Fix a key binding issue on FreeBSD
Mikael Berthe <mikael@lilotux.net>
parents:
1228
diff
changeset
|
717 |
case KEY_RIGHT: |
e9ea1497ac9d
Fix a key binding issue on FreeBSD
Mikael Berthe <mikael@lilotux.net>
parents:
1228
diff
changeset
|
718 |
case KEY_UP: |
e9ea1497ac9d
Fix a key binding issue on FreeBSD
Mikael Berthe <mikael@lilotux.net>
parents:
1228
diff
changeset
|
719 |
case KEY_DOWN: |
e9ea1497ac9d
Fix a key binding issue on FreeBSD
Mikael Berthe <mikael@lilotux.net>
parents:
1228
diff
changeset
|
720 |
case KEY_PPAGE: |
e9ea1497ac9d
Fix a key binding issue on FreeBSD
Mikael Berthe <mikael@lilotux.net>
parents:
1228
diff
changeset
|
721 |
case KEY_NPAGE: |
e9ea1497ac9d
Fix a key binding issue on FreeBSD
Mikael Berthe <mikael@lilotux.net>
parents:
1228
diff
changeset
|
722 |
case KEY_HOME: |
e9ea1497ac9d
Fix a key binding issue on FreeBSD
Mikael Berthe <mikael@lilotux.net>
parents:
1228
diff
changeset
|
723 |
case KEY_END: |
e9ea1497ac9d
Fix a key binding issue on FreeBSD
Mikael Berthe <mikael@lilotux.net>
parents:
1228
diff
changeset
|
724 |
case KEY_EOL: |
e9ea1497ac9d
Fix a key binding issue on FreeBSD
Mikael Berthe <mikael@lilotux.net>
parents:
1228
diff
changeset
|
725 |
return TRUE; |
e9ea1497ac9d
Fix a key binding issue on FreeBSD
Mikael Berthe <mikael@lilotux.net>
parents:
1228
diff
changeset
|
726 |
} |
e9ea1497ac9d
Fix a key binding issue on FreeBSD
Mikael Berthe <mikael@lilotux.net>
parents:
1228
diff
changeset
|
727 |
|
e9ea1497ac9d
Fix a key binding issue on FreeBSD
Mikael Berthe <mikael@lilotux.net>
parents:
1228
diff
changeset
|
728 |
// Fn keys |
e9ea1497ac9d
Fix a key binding issue on FreeBSD
Mikael Berthe <mikael@lilotux.net>
parents:
1228
diff
changeset
|
729 |
if (key >= 265 && key < 265+12) |
e9ea1497ac9d
Fix a key binding issue on FreeBSD
Mikael Berthe <mikael@lilotux.net>
parents:
1228
diff
changeset
|
730 |
return TRUE; |
e9ea1497ac9d
Fix a key binding issue on FreeBSD
Mikael Berthe <mikael@lilotux.net>
parents:
1228
diff
changeset
|
731 |
|
e9ea1497ac9d
Fix a key binding issue on FreeBSD
Mikael Berthe <mikael@lilotux.net>
parents:
1228
diff
changeset
|
732 |
// Special key combinations |
e9ea1497ac9d
Fix a key binding issue on FreeBSD
Mikael Berthe <mikael@lilotux.net>
parents:
1228
diff
changeset
|
733 |
if (key >= 513 && key <= 521) |
e9ea1497ac9d
Fix a key binding issue on FreeBSD
Mikael Berthe <mikael@lilotux.net>
parents:
1228
diff
changeset
|
734 |
return TRUE; |
e9ea1497ac9d
Fix a key binding issue on FreeBSD
Mikael Berthe <mikael@lilotux.net>
parents:
1228
diff
changeset
|
735 |
|
e9ea1497ac9d
Fix a key binding issue on FreeBSD
Mikael Berthe <mikael@lilotux.net>
parents:
1228
diff
changeset
|
736 |
return FALSE; |
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 |
|
1780
e4378fbab5d7
Major API cleanup - bump API to 4
Mikael Berthe <mikael@lilotux.net>
parents:
1761
diff
changeset
|
739 |
void scr_init_locale_charset(void) |
779
057ffe7c43dc
Initialize locale charset earlier
Mikael Berthe <mikael@lilotux.net>
parents:
773
diff
changeset
|
740 |
{ |
1651
d0a0d96ed5d5
Set all locale variables
Myhailo Danylenko <isbear@ukrpost.net>
parents:
1602
diff
changeset
|
741 |
setlocale(LC_ALL, ""); |
1382
1447c5296977
Fix locale charset detection on some BSD systems
Mikael Berthe <mikael@lilotux.net>
parents:
1381
diff
changeset
|
742 |
#ifdef HAVE_LOCALCHARSET_H |
1447c5296977
Fix locale charset detection on some BSD systems
Mikael Berthe <mikael@lilotux.net>
parents:
1381
diff
changeset
|
743 |
LocaleCharSet = locale_charset(); |
1447c5296977
Fix locale charset detection on some BSD systems
Mikael Berthe <mikael@lilotux.net>
parents:
1381
diff
changeset
|
744 |
#else |
779
057ffe7c43dc
Initialize locale charset earlier
Mikael Berthe <mikael@lilotux.net>
parents:
773
diff
changeset
|
745 |
LocaleCharSet = nl_langinfo(CODESET); |
1382
1447c5296977
Fix locale charset detection on some BSD systems
Mikael Berthe <mikael@lilotux.net>
parents:
1381
diff
changeset
|
746 |
#endif |
779
057ffe7c43dc
Initialize locale charset earlier
Mikael Berthe <mikael@lilotux.net>
parents:
773
diff
changeset
|
747 |
utf8_mode = (strcmp(LocaleCharSet, "UTF-8") == 0); |
057ffe7c43dc
Initialize locale charset earlier
Mikael Berthe <mikael@lilotux.net>
parents:
773
diff
changeset
|
748 |
} |
057ffe7c43dc
Initialize locale charset earlier
Mikael Berthe <mikael@lilotux.net>
parents:
773
diff
changeset
|
749 |
|
1780
e4378fbab5d7
Major API cleanup - bump API to 4
Mikael Berthe <mikael@lilotux.net>
parents:
1761
diff
changeset
|
750 |
gboolean scr_curses_status(void) |
1733
a9b0364c0cb2
Fix segfault introduced in previous commit
Mikael Berthe <mikael@lilotux.net>
parents:
1729
diff
changeset
|
751 |
{ |
a9b0364c0cb2
Fix segfault introduced in previous commit
Mikael Berthe <mikael@lilotux.net>
parents:
1729
diff
changeset
|
752 |
return Curses; |
a9b0364c0cb2
Fix segfault introduced in previous commit
Mikael Berthe <mikael@lilotux.net>
parents:
1729
diff
changeset
|
753 |
} |
a9b0364c0cb2
Fix segfault introduced in previous commit
Mikael Berthe <mikael@lilotux.net>
parents:
1729
diff
changeset
|
754 |
|
1780
e4378fbab5d7
Major API cleanup - bump API to 4
Mikael Berthe <mikael@lilotux.net>
parents:
1761
diff
changeset
|
755 |
void scr_init_curses(void) |
765
72626e9d60bd
Create init_keycodes(), add 2 screen escape sequences
Mikael Berthe <mikael@lilotux.net>
parents:
764
diff
changeset
|
756 |
{ |
72626e9d60bd
Create init_keycodes(), add 2 screen escape sequences
Mikael Berthe <mikael@lilotux.net>
parents:
764
diff
changeset
|
757 |
/* Key sequences initialization */ |
72626e9d60bd
Create init_keycodes(), add 2 screen escape sequences
Mikael Berthe <mikael@lilotux.net>
parents:
764
diff
changeset
|
758 |
init_keycodes(); |
762
96d46e00524a
Add some key escape sequences for screen
Mikael Berthe <mikael@lilotux.net>
parents:
761
diff
changeset
|
759 |
|
373
af2f8ddf6a1b
Move (reorganize) functions
Mikael Berthe <mikael@lilotux.net>
parents:
370
diff
changeset
|
760 |
initscr(); |
382
4c6e8392e465
Use nodelay() instead of halfdelay()
Mikael Berthe <mikael@lilotux.net>
parents:
374
diff
changeset
|
761 |
raw(); |
373
af2f8ddf6a1b
Move (reorganize) functions
Mikael Berthe <mikael@lilotux.net>
parents:
370
diff
changeset
|
762 |
noecho(); |
389
6e895f397474
Ncurses changes + Ctrl-C does not send a signal anylore
Mikael Berthe <mikael@lilotux.net>
parents:
388
diff
changeset
|
763 |
nonl(); |
6e895f397474
Ncurses changes + Ctrl-C does not send a signal anylore
Mikael Berthe <mikael@lilotux.net>
parents:
388
diff
changeset
|
764 |
intrflush(stdscr, FALSE); |
373
af2f8ddf6a1b
Move (reorganize) functions
Mikael Berthe <mikael@lilotux.net>
parents:
370
diff
changeset
|
765 |
start_color(); |
af2f8ddf6a1b
Move (reorganize) functions
Mikael Berthe <mikael@lilotux.net>
parents:
370
diff
changeset
|
766 |
use_default_colors(); |
1561 | 767 |
#ifdef NCURSES_MOUSE_VERSION |
1563 | 768 |
if (settings_opt_get_int("use_mouse")) |
769 |
mousemask(ALL_MOUSE_EVENTS, NULL); |
|
1561 | 770 |
#endif |
373
af2f8ddf6a1b
Move (reorganize) functions
Mikael Berthe <mikael@lilotux.net>
parents:
370
diff
changeset
|
771 |
|
1386 | 772 |
if (settings_opt_get("escdelay")) { |
773 |
#ifdef HAVE_ESCDELAY |
|
774 |
ESCDELAY = (unsigned) settings_opt_get_int("escdelay"); |
|
775 |
#else |
|
776 |
scr_LogPrint(LPRINT_LOGNORM, "ERROR: no ESCDELAY support."); |
|
777 |
#endif |
|
778 |
} |
|
779 |
||
1780
e4378fbab5d7
Major API cleanup - bump API to 4
Mikael Berthe <mikael@lilotux.net>
parents:
1761
diff
changeset
|
780 |
parse_colors(); |
373
af2f8ddf6a1b
Move (reorganize) functions
Mikael Berthe <mikael@lilotux.net>
parents:
370
diff
changeset
|
781 |
|
af2f8ddf6a1b
Move (reorganize) functions
Mikael Berthe <mikael@lilotux.net>
parents:
370
diff
changeset
|
782 |
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
|
783 |
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
|
784 |
// 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
|
785 |
// 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
|
786 |
|
373
af2f8ddf6a1b
Move (reorganize) functions
Mikael Berthe <mikael@lilotux.net>
parents:
370
diff
changeset
|
787 |
inputLine[0] = 0; |
af2f8ddf6a1b
Move (reorganize) functions
Mikael Berthe <mikael@lilotux.net>
parents:
370
diff
changeset
|
788 |
ptr_inputline = inputLine; |
af2f8ddf6a1b
Move (reorganize) functions
Mikael Berthe <mikael@lilotux.net>
parents:
370
diff
changeset
|
789 |
|
1521
33f8f795abd2
Check for regex support in glib
Mikael Berthe <mikael@lilotux.net>
parents:
1520
diff
changeset
|
790 |
if (settings_opt_get("url_regex")) { |
33f8f795abd2
Check for regex support in glib
Mikael Berthe <mikael@lilotux.net>
parents:
1520
diff
changeset
|
791 |
#ifdef HAVE_GLIB_REGEX |
1520 | 792 |
url_regex = g_regex_new(settings_opt_get("url_regex"), |
793 |
G_REGEX_OPTIMIZE, 0, NULL); |
|
1521
33f8f795abd2
Check for regex support in glib
Mikael Berthe <mikael@lilotux.net>
parents:
1520
diff
changeset
|
794 |
#else |
33f8f795abd2
Check for regex support in glib
Mikael Berthe <mikael@lilotux.net>
parents:
1520
diff
changeset
|
795 |
scr_LogPrint(LPRINT_LOGNORM, "ERROR: Your glib version is too old, " |
33f8f795abd2
Check for regex support in glib
Mikael Berthe <mikael@lilotux.net>
parents:
1520
diff
changeset
|
796 |
"cannot use url_regex."); |
33f8f795abd2
Check for regex support in glib
Mikael Berthe <mikael@lilotux.net>
parents:
1520
diff
changeset
|
797 |
#endif // HAVE_GLIB_REGEX |
33f8f795abd2
Check for regex support in glib
Mikael Berthe <mikael@lilotux.net>
parents:
1520
diff
changeset
|
798 |
} |
1520 | 799 |
|
966
d9acb7f2a3d1
Do not set Curses variable too early
Mikael Berthe <mikael@lilotux.net>
parents:
961
diff
changeset
|
800 |
Curses = TRUE; |
373
af2f8ddf6a1b
Move (reorganize) functions
Mikael Berthe <mikael@lilotux.net>
parents:
370
diff
changeset
|
801 |
return; |
af2f8ddf6a1b
Move (reorganize) functions
Mikael Berthe <mikael@lilotux.net>
parents:
370
diff
changeset
|
802 |
} |
af2f8ddf6a1b
Move (reorganize) functions
Mikael Berthe <mikael@lilotux.net>
parents:
370
diff
changeset
|
803 |
|
1780
e4378fbab5d7
Major API cleanup - bump API to 4
Mikael Berthe <mikael@lilotux.net>
parents:
1761
diff
changeset
|
804 |
void scr_terminate_curses(void) |
373
af2f8ddf6a1b
Move (reorganize) functions
Mikael Berthe <mikael@lilotux.net>
parents:
370
diff
changeset
|
805 |
{ |
af2f8ddf6a1b
Move (reorganize) functions
Mikael Berthe <mikael@lilotux.net>
parents:
370
diff
changeset
|
806 |
if (!Curses) return; |
af2f8ddf6a1b
Move (reorganize) functions
Mikael Berthe <mikael@lilotux.net>
parents:
370
diff
changeset
|
807 |
clear(); |
af2f8ddf6a1b
Move (reorganize) functions
Mikael Berthe <mikael@lilotux.net>
parents:
370
diff
changeset
|
808 |
refresh(); |
af2f8ddf6a1b
Move (reorganize) functions
Mikael Berthe <mikael@lilotux.net>
parents:
370
diff
changeset
|
809 |
endwin(); |
1521
33f8f795abd2
Check for regex support in glib
Mikael Berthe <mikael@lilotux.net>
parents:
1520
diff
changeset
|
810 |
#ifdef HAVE_GLIB_REGEX |
1520 | 811 |
if (url_regex) |
812 |
g_regex_unref(url_regex); |
|
1521
33f8f795abd2
Check for regex support in glib
Mikael Berthe <mikael@lilotux.net>
parents:
1520
diff
changeset
|
813 |
#endif |
373
af2f8ddf6a1b
Move (reorganize) functions
Mikael Berthe <mikael@lilotux.net>
parents:
370
diff
changeset
|
814 |
Curses = FALSE; |
af2f8ddf6a1b
Move (reorganize) functions
Mikael Berthe <mikael@lilotux.net>
parents:
370
diff
changeset
|
815 |
return; |
af2f8ddf6a1b
Move (reorganize) functions
Mikael Berthe <mikael@lilotux.net>
parents:
370
diff
changeset
|
816 |
} |
af2f8ddf6a1b
Move (reorganize) functions
Mikael Berthe <mikael@lilotux.net>
parents:
370
diff
changeset
|
817 |
|
1780
e4378fbab5d7
Major API cleanup - bump API to 4
Mikael Berthe <mikael@lilotux.net>
parents:
1761
diff
changeset
|
818 |
void scr_beep(void) |
675
ae7016aae014
New "beep_on_message" option
Mikael Berthe <mikael@lilotux.net>
parents:
667
diff
changeset
|
819 |
{ |
ae7016aae014
New "beep_on_message" option
Mikael Berthe <mikael@lilotux.net>
parents:
667
diff
changeset
|
820 |
beep(); |
ae7016aae014
New "beep_on_message" option
Mikael Berthe <mikael@lilotux.net>
parents:
667
diff
changeset
|
821 |
} |
ae7016aae014
New "beep_on_message" option
Mikael Berthe <mikael@lilotux.net>
parents:
667
diff
changeset
|
822 |
|
1286
02ad6200df26
Add selectable time prefixes (vorner)
Mikael Berthe <mikael@lilotux.net>
parents:
1284
diff
changeset
|
823 |
// 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
|
824 |
static const char *timeprefixes[] = { |
02ad6200df26
Add selectable time prefixes (vorner)
Mikael Berthe <mikael@lilotux.net>
parents:
1284
diff
changeset
|
825 |
"%m-%d %H:%M ", |
02ad6200df26
Add selectable time prefixes (vorner)
Mikael Berthe <mikael@lilotux.net>
parents:
1284
diff
changeset
|
826 |
"%H:%M ", |
02ad6200df26
Add selectable time prefixes (vorner)
Mikael Berthe <mikael@lilotux.net>
parents:
1284
diff
changeset
|
827 |
" " |
02ad6200df26
Add selectable time prefixes (vorner)
Mikael Berthe <mikael@lilotux.net>
parents:
1284
diff
changeset
|
828 |
}; |
02ad6200df26
Add selectable time prefixes (vorner)
Mikael Berthe <mikael@lilotux.net>
parents:
1284
diff
changeset
|
829 |
|
02ad6200df26
Add selectable time prefixes (vorner)
Mikael Berthe <mikael@lilotux.net>
parents:
1284
diff
changeset
|
830 |
static const char *spectimeprefixes[] = { |
02ad6200df26
Add selectable time prefixes (vorner)
Mikael Berthe <mikael@lilotux.net>
parents:
1284
diff
changeset
|
831 |
"%m-%d %H:%M:%S ", |
02ad6200df26
Add selectable time prefixes (vorner)
Mikael Berthe <mikael@lilotux.net>
parents:
1284
diff
changeset
|
832 |
"%H:%M:%S ", |
02ad6200df26
Add selectable time prefixes (vorner)
Mikael Berthe <mikael@lilotux.net>
parents:
1284
diff
changeset
|
833 |
" " |
02ad6200df26
Add selectable time prefixes (vorner)
Mikael Berthe <mikael@lilotux.net>
parents:
1284
diff
changeset
|
834 |
}; |
02ad6200df26
Add selectable time prefixes (vorner)
Mikael Berthe <mikael@lilotux.net>
parents:
1284
diff
changeset
|
835 |
|
02ad6200df26
Add selectable time prefixes (vorner)
Mikael Berthe <mikael@lilotux.net>
parents:
1284
diff
changeset
|
836 |
static int timepreflengths[] = { |
1376
a0deb5124ebf
Check time_prefix value before using it
Mikael Berthe <mikael@lilotux.net>
parents:
1359
diff
changeset
|
837 |
// (length of the corresponding timeprefix + 5) |
1286
02ad6200df26
Add selectable time prefixes (vorner)
Mikael Berthe <mikael@lilotux.net>
parents:
1284
diff
changeset
|
838 |
17, |
02ad6200df26
Add selectable time prefixes (vorner)
Mikael Berthe <mikael@lilotux.net>
parents:
1284
diff
changeset
|
839 |
11, |
02ad6200df26
Add selectable time prefixes (vorner)
Mikael Berthe <mikael@lilotux.net>
parents:
1284
diff
changeset
|
840 |
6 |
02ad6200df26
Add selectable time prefixes (vorner)
Mikael Berthe <mikael@lilotux.net>
parents:
1284
diff
changeset
|
841 |
}; |
02ad6200df26
Add selectable time prefixes (vorner)
Mikael Berthe <mikael@lilotux.net>
parents:
1284
diff
changeset
|
842 |
|
1486
f83a51eaa5ed
Fix multiline output in /buffer save
Mikael Berthe <mikael@lilotux.net>
parents:
1485
diff
changeset
|
843 |
static const char *gettprefix(void) |
1286
02ad6200df26
Add selectable time prefixes (vorner)
Mikael Berthe <mikael@lilotux.net>
parents:
1284
diff
changeset
|
844 |
{ |
1376
a0deb5124ebf
Check time_prefix value before using it
Mikael Berthe <mikael@lilotux.net>
parents:
1359
diff
changeset
|
845 |
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
|
846 |
return timeprefixes[(n < 3 ? n : 0)]; |
1286
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 |
|
1486
f83a51eaa5ed
Fix multiline output in /buffer save
Mikael Berthe <mikael@lilotux.net>
parents:
1485
diff
changeset
|
849 |
static const char *getspectprefix(void) |
1286
02ad6200df26
Add selectable time prefixes (vorner)
Mikael Berthe <mikael@lilotux.net>
parents:
1284
diff
changeset
|
850 |
{ |
1376
a0deb5124ebf
Check time_prefix value before using it
Mikael Berthe <mikael@lilotux.net>
parents:
1359
diff
changeset
|
851 |
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
|
852 |
return spectimeprefixes[(n < 3 ? n : 0)]; |
1286
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 |
|
1487 | 855 |
guint scr_getprefixwidth(void) |
1286
02ad6200df26
Add selectable time prefixes (vorner)
Mikael Berthe <mikael@lilotux.net>
parents:
1284
diff
changeset
|
856 |
{ |
1376
a0deb5124ebf
Check time_prefix value before using it
Mikael Berthe <mikael@lilotux.net>
parents:
1359
diff
changeset
|
857 |
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
|
858 |
return timepreflengths[(n < 3 ? n : 0)]; |
1286
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 |
|
1761
61f0482d3993
Limit = alignment to 1/3 of screen in option list
Myhailo Danylenko <isbear@ukrpost.net>
parents:
1756
diff
changeset
|
861 |
guint scr_gettextwidth(void) |
61f0482d3993
Limit = alignment to 1/3 of screen in option list
Myhailo Danylenko <isbear@ukrpost.net>
parents:
1756
diff
changeset
|
862 |
{ |
61f0482d3993
Limit = alignment to 1/3 of screen in option list
Myhailo Danylenko <isbear@ukrpost.net>
parents:
1756
diff
changeset
|
863 |
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
|
864 |
} |
61f0482d3993
Limit = alignment to 1/3 of screen in option list
Myhailo Danylenko <isbear@ukrpost.net>
parents:
1756
diff
changeset
|
865 |
|
1791
6e0a8bfb3a01
Add scr_gettextheight()
Myhailo Danylenko <isbear@ukrpost.net>
parents:
1783
diff
changeset
|
866 |
guint scr_gettextheight(void) |
6e0a8bfb3a01
Add scr_gettextheight()
Myhailo Danylenko <isbear@ukrpost.net>
parents:
1783
diff
changeset
|
867 |
{ |
6e0a8bfb3a01
Add scr_gettextheight()
Myhailo Danylenko <isbear@ukrpost.net>
parents:
1783
diff
changeset
|
868 |
// log window, two status bars and one input line |
6e0a8bfb3a01
Add scr_gettextheight()
Myhailo Danylenko <isbear@ukrpost.net>
parents:
1783
diff
changeset
|
869 |
return maxY - Log_Win_Height - 3; |
6e0a8bfb3a01
Add scr_gettextheight()
Myhailo Danylenko <isbear@ukrpost.net>
parents:
1783
diff
changeset
|
870 |
} |
6e0a8bfb3a01
Add scr_gettextheight()
Myhailo Danylenko <isbear@ukrpost.net>
parents:
1783
diff
changeset
|
871 |
|
1518
63dc211a4c1a
New command: /echo (display a message in the log window)
Mikael Berthe <mikael@lilotux.net>
parents:
1515
diff
changeset
|
872 |
// scr_print_logwindow(string) |
63dc211a4c1a
New command: /echo (display a message in the log window)
Mikael Berthe <mikael@lilotux.net>
parents:
1515
diff
changeset
|
873 |
// 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
|
874 |
// 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
|
875 |
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
|
876 |
{ |
63dc211a4c1a
New command: /echo (display a message in the log window)
Mikael Berthe <mikael@lilotux.net>
parents:
1515
diff
changeset
|
877 |
time_t timestamp; |
63dc211a4c1a
New command: /echo (display a message in the log window)
Mikael Berthe <mikael@lilotux.net>
parents:
1515
diff
changeset
|
878 |
char strtimestamp[64]; |
63dc211a4c1a
New command: /echo (display a message in the log window)
Mikael Berthe <mikael@lilotux.net>
parents:
1515
diff
changeset
|
879 |
|
63dc211a4c1a
New command: /echo (display a message in the log window)
Mikael Berthe <mikael@lilotux.net>
parents:
1515
diff
changeset
|
880 |
timestamp = time(NULL); |
63dc211a4c1a
New command: /echo (display a message in the log window)
Mikael Berthe <mikael@lilotux.net>
parents:
1515
diff
changeset
|
881 |
strftime(strtimestamp, 48, "[%H:%M:%S]", localtime(×tamp)); |
63dc211a4c1a
New command: /echo (display a message in the log window)
Mikael Berthe <mikael@lilotux.net>
parents:
1515
diff
changeset
|
882 |
if (Curses) { |
63dc211a4c1a
New command: /echo (display a message in the log window)
Mikael Berthe <mikael@lilotux.net>
parents:
1515
diff
changeset
|
883 |
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
|
884 |
update_panels(); |
63dc211a4c1a
New command: /echo (display a message in the log window)
Mikael Berthe <mikael@lilotux.net>
parents:
1515
diff
changeset
|
885 |
} else { |
63dc211a4c1a
New command: /echo (display a message in the log window)
Mikael Berthe <mikael@lilotux.net>
parents:
1515
diff
changeset
|
886 |
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
|
887 |
} |
63dc211a4c1a
New command: /echo (display a message in the log window)
Mikael Berthe <mikael@lilotux.net>
parents:
1515
diff
changeset
|
888 |
} |
63dc211a4c1a
New command: /echo (display a message in the log window)
Mikael Berthe <mikael@lilotux.net>
parents:
1515
diff
changeset
|
889 |
|
1783
af3de54ef986
Convert scr_LogPrint() to scr_log_print()
Mikael Berthe <mikael@lilotux.net>
parents:
1780
diff
changeset
|
890 |
// scr_log_print(...) |
1518
63dc211a4c1a
New command: /echo (display a message in the log window)
Mikael Berthe <mikael@lilotux.net>
parents:
1515
diff
changeset
|
891 |
// 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
|
892 |
// 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
|
893 |
// 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
|
894 |
void scr_log_print(unsigned int flag, const char *fmt, ...) |
373
af2f8ddf6a1b
Move (reorganize) functions
Mikael Berthe <mikael@lilotux.net>
parents:
370
diff
changeset
|
895 |
{ |
af2f8ddf6a1b
Move (reorganize) functions
Mikael Berthe <mikael@lilotux.net>
parents:
370
diff
changeset
|
896 |
time_t timestamp; |
857
ef35a2bb40d7
scr_LogPrint(): do not use static buffer size
Mikael Berthe <mikael@lilotux.net>
parents:
851
diff
changeset
|
897 |
char strtimestamp[64]; |
858
2683ad5d1003
Improve scr_LogPrint() for log/debug messages
Mikael Berthe <mikael@lilotux.net>
parents:
857
diff
changeset
|
898 |
char *buffer, *btext; |
1075
03bc225ad763
Improve scr_LogPrint() readability
Mikael Berthe <mikael@lilotux.net>
parents:
1072
diff
changeset
|
899 |
char *convbuf1 = NULL, *convbuf2 = NULL; |
373
af2f8ddf6a1b
Move (reorganize) functions
Mikael Berthe <mikael@lilotux.net>
parents:
370
diff
changeset
|
900 |
va_list ap; |
af2f8ddf6a1b
Move (reorganize) functions
Mikael Berthe <mikael@lilotux.net>
parents:
370
diff
changeset
|
901 |
|
771
ce4f8a2129a4
scr_LogPrint() can display UTF-8 strings
Mikael Berthe <mikael@lilotux.net>
parents:
770
diff
changeset
|
902 |
if (!(flag & ~LPRINT_NOTUTF8)) return; // Shouldn't happen |
374
bd5638c21834
Improve logging system (traces)
Mikael Berthe <mikael@lilotux.net>
parents:
373
diff
changeset
|
903 |
|
857
ef35a2bb40d7
scr_LogPrint(): do not use static buffer size
Mikael Berthe <mikael@lilotux.net>
parents:
851
diff
changeset
|
904 |
timestamp = time(NULL); |
ef35a2bb40d7
scr_LogPrint(): do not use static buffer size
Mikael Berthe <mikael@lilotux.net>
parents:
851
diff
changeset
|
905 |
strftime(strtimestamp, 48, "[%H:%M:%S]", localtime(×tamp)); |
ef35a2bb40d7
scr_LogPrint(): do not use static buffer size
Mikael Berthe <mikael@lilotux.net>
parents:
851
diff
changeset
|
906 |
va_start(ap, fmt); |
858
2683ad5d1003
Improve scr_LogPrint() for log/debug messages
Mikael Berthe <mikael@lilotux.net>
parents:
857
diff
changeset
|
907 |
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
|
908 |
va_end(ap); |
373
af2f8ddf6a1b
Move (reorganize) functions
Mikael Berthe <mikael@lilotux.net>
parents:
370
diff
changeset
|
909 |
|
374
bd5638c21834
Improve logging system (traces)
Mikael Berthe <mikael@lilotux.net>
parents:
373
diff
changeset
|
910 |
if (flag & LPRINT_NORMAL) { |
771
ce4f8a2129a4
scr_LogPrint() can display UTF-8 strings
Mikael Berthe <mikael@lilotux.net>
parents:
770
diff
changeset
|
911 |
char *buffer_locale; |
851
da03534e46c7
Add startup log messages to the status buffer
Mikael Berthe <mikael@lilotux.net>
parents:
850
diff
changeset
|
912 |
char *buf_specialwindow; |
da03534e46c7
Add startup log messages to the status buffer
Mikael Berthe <mikael@lilotux.net>
parents:
850
diff
changeset
|
913 |
|
858
2683ad5d1003
Improve scr_LogPrint() for log/debug messages
Mikael Berthe <mikael@lilotux.net>
parents:
857
diff
changeset
|
914 |
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
|
915 |
|
851
da03534e46c7
Add startup log messages to the status buffer
Mikael Berthe <mikael@lilotux.net>
parents:
850
diff
changeset
|
916 |
// 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
|
917 |
if (!(flag & LPRINT_NOTUTF8)) |
1075
03bc225ad763
Improve scr_LogPrint() readability
Mikael Berthe <mikael@lilotux.net>
parents:
1072
diff
changeset
|
918 |
buffer_locale = convbuf1 = from_utf8(buffer); |
771
ce4f8a2129a4
scr_LogPrint() can display UTF-8 strings
Mikael Berthe <mikael@lilotux.net>
parents:
770
diff
changeset
|
919 |
else |
ce4f8a2129a4
scr_LogPrint() can display UTF-8 strings
Mikael Berthe <mikael@lilotux.net>
parents:
770
diff
changeset
|
920 |
buffer_locale = buffer; |
851
da03534e46c7
Add startup log messages to the status buffer
Mikael Berthe <mikael@lilotux.net>
parents:
850
diff
changeset
|
921 |
|
884
9e6d9f0cf9eb
scr_LogPrint(): Add a warning for UTF-8 -> locale conversion failures
Mikael Berthe <mikael@lilotux.net>
parents:
880
diff
changeset
|
922 |
if (!buffer_locale) { |
9e6d9f0cf9eb
scr_LogPrint(): Add a warning for UTF-8 -> locale conversion failures
Mikael Berthe <mikael@lilotux.net>
parents:
880
diff
changeset
|
923 |
wprintw(logWnd, |
9e6d9f0cf9eb
scr_LogPrint(): Add a warning for UTF-8 -> locale conversion failures
Mikael Berthe <mikael@lilotux.net>
parents:
880
diff
changeset
|
924 |
"\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
|
925 |
update_panels(); |
9e6d9f0cf9eb
scr_LogPrint(): Add a warning for UTF-8 -> locale conversion failures
Mikael Berthe <mikael@lilotux.net>
parents:
880
diff
changeset
|
926 |
g_free(buffer); |
897
a05b5a16a06a
Fix memory leak in scr_LogPrint()
Mikael Berthe <mikael@lilotux.net>
parents:
891
diff
changeset
|
927 |
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
|
928 |
return; |
9e6d9f0cf9eb
scr_LogPrint(): Add a warning for UTF-8 -> locale conversion failures
Mikael Berthe <mikael@lilotux.net>
parents:
880
diff
changeset
|
929 |
} |
9e6d9f0cf9eb
scr_LogPrint(): Add a warning for UTF-8 -> locale conversion failures
Mikael Berthe <mikael@lilotux.net>
parents:
880
diff
changeset
|
930 |
|
851
da03534e46c7
Add startup log messages to the status buffer
Mikael Berthe <mikael@lilotux.net>
parents:
850
diff
changeset
|
931 |
// 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
|
932 |
if (flag & LPRINT_NOTUTF8) |
1075
03bc225ad763
Improve scr_LogPrint() readability
Mikael Berthe <mikael@lilotux.net>
parents:
1072
diff
changeset
|
933 |
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
|
934 |
else |
858
2683ad5d1003
Improve scr_LogPrint() for log/debug messages
Mikael Berthe <mikael@lilotux.net>
parents:
857
diff
changeset
|
935 |
buf_specialwindow = btext; |
851
da03534e46c7
Add startup log messages to the status buffer
Mikael Berthe <mikael@lilotux.net>
parents:
850
diff
changeset
|
936 |
|
374
bd5638c21834
Improve logging system (traces)
Mikael Berthe <mikael@lilotux.net>
parents:
373
diff
changeset
|
937 |
if (Curses) { |
771
ce4f8a2129a4
scr_LogPrint() can display UTF-8 strings
Mikael Berthe <mikael@lilotux.net>
parents:
770
diff
changeset
|
938 |
wprintw(logWnd, "\n%s", buffer_locale); |
374
bd5638c21834
Improve logging system (traces)
Mikael Berthe <mikael@lilotux.net>
parents:
373
diff
changeset
|
939 |
update_panels(); |
1780
e4378fbab5d7
Major API cleanup - bump API to 4
Mikael Berthe <mikael@lilotux.net>
parents:
1761
diff
changeset
|
940 |
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
|
941 |
HBB_PREFIX_SPECIAL, FALSE, 0, NULL); |
374
bd5638c21834
Improve logging system (traces)
Mikael Berthe <mikael@lilotux.net>
parents:
373
diff
changeset
|
942 |
} else { |
771
ce4f8a2129a4
scr_LogPrint() can display UTF-8 strings
Mikael Berthe <mikael@lilotux.net>
parents:
770
diff
changeset
|
943 |
printf("%s\n", buffer_locale); |
851
da03534e46c7
Add startup log messages to the status buffer
Mikael Berthe <mikael@lilotux.net>
parents:
850
diff
changeset
|
944 |
// 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
|
945 |
hbuf_add_line(&statushbuf, buf_specialwindow, timestamp, |
1602 | 946 |
HBB_PREFIX_SPECIAL, 0, 0, 0, NULL); |
374
bd5638c21834
Improve logging system (traces)
Mikael Berthe <mikael@lilotux.net>
parents:
373
diff
changeset
|
947 |
} |
851
da03534e46c7
Add startup log messages to the status buffer
Mikael Berthe <mikael@lilotux.net>
parents:
850
diff
changeset
|
948 |
|
1075
03bc225ad763
Improve scr_LogPrint() readability
Mikael Berthe <mikael@lilotux.net>
parents:
1072
diff
changeset
|
949 |
g_free(convbuf1); |
03bc225ad763
Improve scr_LogPrint() readability
Mikael Berthe <mikael@lilotux.net>
parents:
1072
diff
changeset
|
950 |
g_free(convbuf2); |
858
2683ad5d1003
Improve scr_LogPrint() for log/debug messages
Mikael Berthe <mikael@lilotux.net>
parents:
857
diff
changeset
|
951 |
g_free(buffer); |
374
bd5638c21834
Improve logging system (traces)
Mikael Berthe <mikael@lilotux.net>
parents:
373
diff
changeset
|
952 |
} |
412
9c640ee3bae3
Display full date in the log file
Mikael Berthe <mikael@lilotux.net>
parents:
393
diff
changeset
|
953 |
|
857
ef35a2bb40d7
scr_LogPrint(): do not use static buffer size
Mikael Berthe <mikael@lilotux.net>
parents:
851
diff
changeset
|
954 |
if (flag & (LPRINT_LOG|LPRINT_DEBUG)) { |
ef35a2bb40d7
scr_LogPrint(): do not use static buffer size
Mikael Berthe <mikael@lilotux.net>
parents:
851
diff
changeset
|
955 |
strftime(strtimestamp, 23, "[%Y-%m-%d %H:%M:%S]", localtime(×tamp)); |
858
2683ad5d1003
Improve scr_LogPrint() for log/debug messages
Mikael Berthe <mikael@lilotux.net>
parents:
857
diff
changeset
|
956 |
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
|
957 |
ut_write_log(flag, buffer); |
857
ef35a2bb40d7
scr_LogPrint(): do not use static buffer size
Mikael Berthe <mikael@lilotux.net>
parents:
851
diff
changeset
|
958 |
g_free(buffer); |
373
af2f8ddf6a1b
Move (reorganize) functions
Mikael Berthe <mikael@lilotux.net>
parents:
370
diff
changeset
|
959 |
} |
897
a05b5a16a06a
Fix memory leak in scr_LogPrint()
Mikael Berthe <mikael@lilotux.net>
parents:
891
diff
changeset
|
960 |
g_free(btext); |
373
af2f8ddf6a1b
Move (reorganize) functions
Mikael Berthe <mikael@lilotux.net>
parents:
370
diff
changeset
|
961 |
} |
af2f8ddf6a1b
Move (reorganize) functions
Mikael Berthe <mikael@lilotux.net>
parents:
370
diff
changeset
|
962 |
|
1780
e4378fbab5d7
Major API cleanup - bump API to 4
Mikael Berthe <mikael@lilotux.net>
parents:
1761
diff
changeset
|
963 |
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
|
964 |
{ |
cae430fcd385
Mcabber will load symlinked histories only once, now.
Frank Zschockelt
parents:
1154
diff
changeset
|
965 |
char *id; |
cae430fcd385
Mcabber will load symlinked histories only once, now.
Frank Zschockelt
parents:
1154
diff
changeset
|
966 |
winbuf *wbp; |
cae430fcd385
Mcabber will load symlinked histories only once, now.
Frank Zschockelt
parents:
1154
diff
changeset
|
967 |
|
cae430fcd385
Mcabber will load symlinked histories only once, now.
Frank Zschockelt
parents:
1154
diff
changeset
|
968 |
if (special) |
cae430fcd385
Mcabber will load symlinked histories only once, now.
Frank Zschockelt
parents:
1154
diff
changeset
|
969 |
return statusWindow; // Only one special window atm. |
cae430fcd385
Mcabber will load symlinked histories only once, now.
Frank Zschockelt
parents:
1154
diff
changeset
|
970 |
|
cae430fcd385
Mcabber will load symlinked histories only once, now.
Frank Zschockelt
parents:
1154
diff
changeset
|
971 |
if (!winId) |
cae430fcd385
Mcabber will load symlinked histories only once, now.
Frank Zschockelt
parents:
1154
diff
changeset
|
972 |
return NULL; |
cae430fcd385
Mcabber will load symlinked histories only once, now.
Frank Zschockelt
parents:
1154
diff
changeset
|
973 |
|
cae430fcd385
Mcabber will load symlinked histories only once, now.
Frank Zschockelt
parents:
1154
diff
changeset
|
974 |
id = g_strdup(winId); |
cae430fcd385
Mcabber will load symlinked histories only once, now.
Frank Zschockelt
parents:
1154
diff
changeset
|
975 |
mc_strtolower(id); |
cae430fcd385
Mcabber will load symlinked histories only once, now.
Frank Zschockelt
parents:
1154
diff
changeset
|
976 |
wbp = g_hash_table_lookup(winbufhash, id); |
cae430fcd385
Mcabber will load symlinked histories only once, now.
Frank Zschockelt
parents:
1154
diff
changeset
|
977 |
g_free(id); |
cae430fcd385
Mcabber will load symlinked histories only once, now.
Frank Zschockelt
parents:
1154
diff
changeset
|
978 |
return wbp; |
cae430fcd385
Mcabber will load symlinked histories only once, now.
Frank Zschockelt
parents:
1154
diff
changeset
|
979 |
} |
cae430fcd385
Mcabber will load symlinked histories only once, now.
Frank Zschockelt
parents:
1154
diff
changeset
|
980 |
|
1780
e4378fbab5d7
Major API cleanup - bump API to 4
Mikael Berthe <mikael@lilotux.net>
parents:
1761
diff
changeset
|
981 |
int scr_buddy_buffer_exists(const char *bjid) |
1156
cae430fcd385
Mcabber will load symlinked histories only once, now.
Frank Zschockelt
parents:
1154
diff
changeset
|
982 |
{ |
1780
e4378fbab5d7
Major API cleanup - bump API to 4
Mikael Berthe <mikael@lilotux.net>
parents:
1761
diff
changeset
|
983 |
return (scr_search_window(bjid, FALSE) != NULL); |
1156
cae430fcd385
Mcabber will load symlinked histories only once, now.
Frank Zschockelt
parents:
1154
diff
changeset
|
984 |
} |
cae430fcd385
Mcabber will load symlinked histories only once, now.
Frank Zschockelt
parents:
1154
diff
changeset
|
985 |
|
1133
9dd28a56128f
Do not create one panel per contact
Mikael Berthe <mikael@lilotux.net>
parents:
1131
diff
changeset
|
986 |
// scr_new_buddy(title, dontshow) |
1139 | 987 |
// 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
|
988 |
static winbuf *scr_new_buddy(const char *title, int dont_show) |
24 | 989 |
{ |
822 | 990 |
winbuf *tmp; |
393 | 991 |
|
822 | 992 |
tmp = g_new0(winbuf, 1); |
24 | 993 |
|
1133
9dd28a56128f
Do not create one panel per contact
Mikael Berthe <mikael@lilotux.net>
parents:
1131
diff
changeset
|
994 |
tmp->win = activechatWnd; |
9dd28a56128f
Do not create one panel per contact
Mikael Berthe <mikael@lilotux.net>
parents:
1131
diff
changeset
|
995 |
tmp->panel = activechatPanel; |
24 | 996 |
|
143 | 997 |
if (!dont_show) { |
24 | 998 |
currentWindow = tmp; |
999 |
} else { |
|
1000 |
if (currentWindow) |
|
1001 |
top_panel(currentWindow->panel); |
|
1002 |
else |
|
1003 |
top_panel(chatPanel); |
|
1004 |
} |
|
143 | 1005 |
update_panels(); |
24 | 1006 |
|
849
42c43a88d823
Status buffer management
Mikael Berthe <mikael@lilotux.net>
parents:
848
diff
changeset
|
1007 |
// If title is NULL, this is a special buffer |
42c43a88d823
Status buffer management
Mikael Berthe <mikael@lilotux.net>
parents:
848
diff
changeset
|
1008 |
if (title) { |
1078
7866dbaf67a6
Use a hash for the list of win buffers
Mikael Berthe <mikael@lilotux.net>
parents:
1077
diff
changeset
|
1009 |
char *id; |
1156
cae430fcd385
Mcabber will load symlinked histories only once, now.
Frank Zschockelt
parents:
1154
diff
changeset
|
1010 |
id = hlog_get_log_jid(title); |
cae430fcd385
Mcabber will load symlinked histories only once, now.
Frank Zschockelt
parents:
1154
diff
changeset
|
1011 |
if (id) { |
1780
e4378fbab5d7
Major API cleanup - bump API to 4
Mikael Berthe <mikael@lilotux.net>
parents:
1761
diff
changeset
|
1012 |
winbuf *wb = scr_search_window(id, FALSE); |
1160
14f5876b5555
Slight optimization + line wrapping
Mikael Berthe <mikael@lilotux.net>
parents:
1159
diff
changeset
|
1013 |
if (!wb) |
14f5876b5555
Slight optimization + line wrapping
Mikael Berthe <mikael@lilotux.net>
parents:
1159
diff
changeset
|
1014 |
wb = scr_new_buddy(id, TRUE); |
14f5876b5555
Slight optimization + line wrapping
Mikael Berthe <mikael@lilotux.net>
parents:
1159
diff
changeset
|
1015 |
tmp->bd=wb->bd; |
1156
cae430fcd385
Mcabber will load symlinked histories only once, now.
Frank Zschockelt
parents:
1154
diff
changeset
|
1016 |
g_free(id); |
1159
53c0c5be43fa
Small fixes, typos and cleanups
Mikael Berthe <mikael@lilotux.net>
parents:
1157
diff
changeset
|
1017 |
} 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
|
1018 |
tmp->bd = g_new0(buffdata, 1); |
1159
53c0c5be43fa
Small fixes, typos and cleanups
Mikael Berthe <mikael@lilotux.net>
parents:
1157
diff
changeset
|
1019 |
hlog_read_history(title, &tmp->bd->hbuf, |
1487 | 1020 |
maxX - Roster_Width - scr_getprefixwidth()); |
1157
5c857f0f0ab8
Moved all variables related to hbuf to an extra struct, bufdata
Frank Zschockelt
parents:
1156
diff
changeset
|
1021 |
} |
181 | 1022 |
|
1078
7866dbaf67a6
Use a hash for the list of win buffers
Mikael Berthe <mikael@lilotux.net>
parents:
1077
diff
changeset
|
1023 |
id = g_strdup(title); |
7866dbaf67a6
Use a hash for the list of win buffers
Mikael Berthe <mikael@lilotux.net>
parents:
1077
diff
changeset
|
1024 |
mc_strtolower(id); |
7866dbaf67a6
Use a hash for the list of win buffers
Mikael Berthe <mikael@lilotux.net>
parents:
1077
diff
changeset
|
1025 |
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
|
1026 |
} else { |
1159
53c0c5be43fa
Small fixes, typos and cleanups
Mikael Berthe <mikael@lilotux.net>
parents:
1157
diff
changeset
|
1027 |
tmp->bd = g_new0(buffdata, 1); |
849
42c43a88d823
Status buffer management
Mikael Berthe <mikael@lilotux.net>
parents:
848
diff
changeset
|
1028 |
} |
24 | 1029 |
return tmp; |
1030 |
} |
|
1031 |
||
1483
e74cc83e7158
Refactor scr_UpdateWindow()
Mikael Berthe <mikael@lilotux.net>
parents:
1476
diff
changeset
|
1032 |
// scr_line_prefix(line, pref, preflen) |
e74cc83e7158
Refactor scr_UpdateWindow()
Mikael Berthe <mikael@lilotux.net>
parents:
1476
diff
changeset
|
1033 |
// Use data from the hbb_line structure and write the prefix |
e74cc83e7158
Refactor scr_UpdateWindow()
Mikael Berthe <mikael@lilotux.net>
parents:
1476
diff
changeset
|
1034 |
// to pref (not exceeding preflen, trailing null byte included). |
e74cc83e7158
Refactor scr_UpdateWindow()
Mikael Berthe <mikael@lilotux.net>
parents:
1476
diff
changeset
|
1035 |
void scr_line_prefix(hbb_line *line, char *pref, guint preflen) |
e74cc83e7158
Refactor scr_UpdateWindow()
Mikael Berthe <mikael@lilotux.net>
parents:
1476
diff
changeset
|
1036 |
{ |
e74cc83e7158
Refactor scr_UpdateWindow()
Mikael Berthe <mikael@lilotux.net>
parents:
1476
diff
changeset
|
1037 |
char date[64]; |
e74cc83e7158
Refactor scr_UpdateWindow()
Mikael Berthe <mikael@lilotux.net>
parents:
1476
diff
changeset
|
1038 |
|
e74cc83e7158
Refactor scr_UpdateWindow()
Mikael Berthe <mikael@lilotux.net>
parents:
1476
diff
changeset
|
1039 |
if (line->timestamp && |
e74cc83e7158
Refactor scr_UpdateWindow()
Mikael Berthe <mikael@lilotux.net>
parents:
1476
diff
changeset
|
1040 |
!(line->flags & (HBB_PREFIX_SPECIAL|HBB_PREFIX_CONT))) { |
e74cc83e7158
Refactor scr_UpdateWindow()
Mikael Berthe <mikael@lilotux.net>
parents:
1476
diff
changeset
|
1041 |
strftime(date, 30, gettprefix(), localtime(&line->timestamp)); |
e74cc83e7158
Refactor scr_UpdateWindow()
Mikael Berthe <mikael@lilotux.net>
parents:
1476
diff
changeset
|
1042 |
} else |
e74cc83e7158
Refactor scr_UpdateWindow()
Mikael Berthe <mikael@lilotux.net>
parents:
1476
diff
changeset
|
1043 |
strcpy(date, " "); |
e74cc83e7158
Refactor scr_UpdateWindow()
Mikael Berthe <mikael@lilotux.net>
parents:
1476
diff
changeset
|
1044 |
|
e74cc83e7158
Refactor scr_UpdateWindow()
Mikael Berthe <mikael@lilotux.net>
parents:
1476
diff
changeset
|
1045 |
if (!(line->flags & HBB_PREFIX_CONT)) { |
e74cc83e7158
Refactor scr_UpdateWindow()
Mikael Berthe <mikael@lilotux.net>
parents:
1476
diff
changeset
|
1046 |
if (line->flags & HBB_PREFIX_INFO) { |
e74cc83e7158
Refactor scr_UpdateWindow()
Mikael Berthe <mikael@lilotux.net>
parents:
1476
diff
changeset
|
1047 |
char dir = '*'; |
e74cc83e7158
Refactor scr_UpdateWindow()
Mikael Berthe <mikael@lilotux.net>
parents:
1476
diff
changeset
|
1048 |
if (line->flags & HBB_PREFIX_IN) |
e74cc83e7158
Refactor scr_UpdateWindow()
Mikael Berthe <mikael@lilotux.net>
parents:
1476
diff
changeset
|
1049 |
dir = '<'; |
e74cc83e7158
Refactor scr_UpdateWindow()
Mikael Berthe <mikael@lilotux.net>
parents:
1476
diff
changeset
|
1050 |
else if (line->flags & HBB_PREFIX_OUT) |
e74cc83e7158
Refactor scr_UpdateWindow()
Mikael Berthe <mikael@lilotux.net>
parents:
1476
diff
changeset
|
1051 |
dir = '>'; |
e74cc83e7158
Refactor scr_UpdateWindow()
Mikael Berthe <mikael@lilotux.net>
parents:
1476
diff
changeset
|
1052 |
g_snprintf(pref, preflen, "%s*%c* ", date, dir); |
e74cc83e7158
Refactor scr_UpdateWindow()
Mikael Berthe <mikael@lilotux.net>
parents:
1476
diff
changeset
|
1053 |
} else if (line->flags & HBB_PREFIX_ERR) { |
e74cc83e7158
Refactor scr_UpdateWindow()
Mikael Berthe <mikael@lilotux.net>
parents:
1476
diff
changeset
|
1054 |
char dir = '#'; |
e74cc83e7158
Refactor scr_UpdateWindow()
Mikael Berthe <mikael@lilotux.net>
parents:
1476
diff
changeset
|
1055 |
if (line->flags & HBB_PREFIX_IN) |
e74cc83e7158
Refactor scr_UpdateWindow()
Mikael Berthe <mikael@lilotux.net>
parents:
1476
diff
changeset
|
1056 |
dir = '<'; |
e74cc83e7158
Refactor scr_UpdateWindow()
Mikael Berthe <mikael@lilotux.net>
parents:
1476
diff
changeset
|
1057 |
else if (line->flags & HBB_PREFIX_OUT) |
e74cc83e7158
Refactor scr_UpdateWindow()
Mikael Berthe <mikael@lilotux.net>
parents:
1476
diff
changeset
|
1058 |
dir = '>'; |
e74cc83e7158
Refactor scr_UpdateWindow()
Mikael Berthe <mikael@lilotux.net>
parents:
1476
diff
changeset
|
1059 |
g_snprintf(pref, preflen, "%s#%c# ", date, dir); |
e74cc83e7158
Refactor scr_UpdateWindow()
Mikael Berthe <mikael@lilotux.net>
parents:
1476
diff
changeset
|
1060 |
} 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
|
1061 |
char cryptflag; |
7b36b91a4388
New UI message flag (O) when OTR is used
Mikael Berthe <mikael@lilotux.net>
parents:
1483
diff
changeset
|
1062 |
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
|
1063 |
cryptflag = '~'; |
7b36b91a4388
New UI message flag (O) when OTR is used
Mikael Berthe <mikael@lilotux.net>
parents:
1483
diff
changeset
|
1064 |
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
|
1065 |
cryptflag = 'O'; |
7b36b91a4388
New UI message flag (O) when OTR is used
Mikael Berthe <mikael@lilotux.net>
parents:
1483
diff
changeset
|
1066 |
else |
7b36b91a4388
New UI message flag (O) when OTR is used
Mikael Berthe <mikael@lilotux.net>
parents:
1483
diff
changeset
|
1067 |
cryptflag = '='; |
1483
e74cc83e7158
Refactor scr_UpdateWindow()
Mikael Berthe <mikael@lilotux.net>
parents:
1476
diff
changeset
|
1068 |
g_snprintf(pref, preflen, "%s<%c= ", date, cryptflag); |
e74cc83e7158
Refactor scr_UpdateWindow()
Mikael Berthe <mikael@lilotux.net>
parents:
1476
diff
changeset
|
1069 |
} else if (line->flags & HBB_PREFIX_OUT) { |
1602 | 1070 |
char cryptflag, receiptflag; |
1484
7b36b91a4388
New UI message flag (O) when OTR is used
Mikael Berthe <mikael@lilotux.net>
parents:
1483
diff
changeset
|
1071 |
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
|
1072 |
cryptflag = '~'; |
7b36b91a4388
New UI message flag (O) when OTR is used
Mikael Berthe <mikael@lilotux.net>
parents:
1483
diff
changeset
|
1073 |
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
|
1074 |
cryptflag = 'O'; |
7b36b91a4388
New UI message flag (O) when OTR is used
Mikael Berthe <mikael@lilotux.net>
parents:
1483
diff
changeset
|
1075 |
else |
1488
b393b8cee171
Fix small mistake in changeset 7b36b91a4388
Mikael Berthe <mikael@lilotux.net>
parents:
1487
diff
changeset
|
1076 |
cryptflag = '-'; |
1602 | 1077 |
if (line->flags & HBB_PREFIX_RECEIPT) |
1078 |
receiptflag = 'r'; |
|
1079 |
else |
|
1080 |
receiptflag = '-'; |
|
1081 |
g_snprintf(pref, preflen, "%s%c%c> ", date, receiptflag, cryptflag); |
|
1483
e74cc83e7158
Refactor scr_UpdateWindow()
Mikael Berthe <mikael@lilotux.net>
parents:
1476
diff
changeset
|
1082 |
} else if (line->flags & HBB_PREFIX_SPECIAL) { |
e74cc83e7158
Refactor scr_UpdateWindow()
Mikael Berthe <mikael@lilotux.net>
parents:
1476
diff
changeset
|
1083 |
strftime(date, 30, getspectprefix(), localtime(&line->timestamp)); |
e74cc83e7158
Refactor scr_UpdateWindow()
Mikael Berthe <mikael@lilotux.net>
parents:
1476
diff
changeset
|
1084 |
g_snprintf(pref, preflen, "%s ", date); |
e74cc83e7158
Refactor scr_UpdateWindow()
Mikael Berthe <mikael@lilotux.net>
parents:
1476
diff
changeset
|
1085 |
} else { |
e74cc83e7158
Refactor scr_UpdateWindow()
Mikael Berthe <mikael@lilotux.net>
parents:
1476
diff
changeset
|
1086 |
g_snprintf(pref, preflen, "%s ", date); |
e74cc83e7158
Refactor scr_UpdateWindow()
Mikael Berthe <mikael@lilotux.net>
parents:
1476
diff
changeset
|
1087 |
} |
e74cc83e7158
Refactor scr_UpdateWindow()
Mikael Berthe <mikael@lilotux.net>
parents:
1476
diff
changeset
|
1088 |
} else { |
e74cc83e7158
Refactor scr_UpdateWindow()
Mikael Berthe <mikael@lilotux.net>
parents:
1476
diff
changeset
|
1089 |
g_snprintf(pref, preflen, " "); |
e74cc83e7158
Refactor scr_UpdateWindow()
Mikael Berthe <mikael@lilotux.net>
parents:
1476
diff
changeset
|
1090 |
} |
e74cc83e7158
Refactor scr_UpdateWindow()
Mikael Berthe <mikael@lilotux.net>
parents:
1476
diff
changeset
|
1091 |
} |
e74cc83e7158
Refactor scr_UpdateWindow()
Mikael Berthe <mikael@lilotux.net>
parents:
1476
diff
changeset
|
1092 |
|
1780
e4378fbab5d7
Major API cleanup - bump API to 4
Mikael Berthe <mikael@lilotux.net>
parents:
1761
diff
changeset
|
1093 |
// scr_update_window() |
143 | 1094 |
// (Re-)Display the given chat window. |
1780
e4378fbab5d7
Major API cleanup - bump API to 4
Mikael Berthe <mikael@lilotux.net>
parents:
1761
diff
changeset
|
1095 |
static void scr_update_window(winbuf *win_entry) |
74 | 1096 |
{ |
1097 |
int n; |
|
1486
f83a51eaa5ed
Fix multiline output in /buffer save
Mikael Berthe <mikael@lilotux.net>
parents:
1485
diff
changeset
|
1098 |
guint prefixwidth; |
1483
e74cc83e7158
Refactor scr_UpdateWindow()
Mikael Berthe <mikael@lilotux.net>
parents:
1476
diff
changeset
|
1099 |
char pref[96]; |
184 | 1100 |
hbb_line **lines, *line; |
74 | 1101 |
GList *hbuf_head; |
1291
9f64f548ac16
Better way of writing the nick
Michal 'vorner' Vaner <vorner@ucw.cz>
parents:
1290
diff
changeset
|
1102 |
int color; |
74 | 1103 |
|
1487 | 1104 |
prefixwidth = scr_getprefixwidth(); |
1486
f83a51eaa5ed
Fix multiline output in /buffer save
Mikael Berthe <mikael@lilotux.net>
parents:
1485
diff
changeset
|
1105 |
prefixwidth = MIN(prefixwidth, sizeof pref); |
108 | 1106 |
|
1107 |
// Should the window be empty? |
|
1157
5c857f0f0ab8
Moved all variables related to hbuf to an extra struct, bufdata
Frank Zschockelt
parents:
1156
diff
changeset
|
1108 |
if (win_entry->bd->cleared) { |
168 | 1109 |
werase(win_entry->win); |
108 | 1110 |
return; |
1111 |
} |
|
1112 |
||
1160
14f5876b5555
Slight optimization + line wrapping
Mikael Berthe <mikael@lilotux.net>
parents:
1159
diff
changeset
|
1113 |
// win_entry->bd->top is the top message of the screen. If it set to NULL, |
14f5876b5555
Slight optimization + line wrapping
Mikael Berthe <mikael@lilotux.net>
parents:
1159
diff
changeset
|
1114 |
// we are displaying the last messages. |
105 | 1115 |
|
74 | 1116 |
// We will show the last CHAT_WIN_HEIGHT lines. |
1117 |
// Let's find out where it begins. |
|
1160
14f5876b5555
Slight optimization + line wrapping
Mikael Berthe <mikael@lilotux.net>
parents:
1159
diff
changeset
|
1118 |
if (!win_entry->bd->top || (g_list_position(g_list_first(win_entry->bd->hbuf), |
14f5876b5555
Slight optimization + line wrapping
Mikael Berthe <mikael@lilotux.net>
parents:
1159
diff
changeset
|
1119 |
win_entry->bd->top) == -1)) { |
105 | 1120 |
// Move up CHAT_WIN_HEIGHT lines |
1157
5c857f0f0ab8
Moved all variables related to hbuf to an extra struct, bufdata
Frank Zschockelt
parents:
1156
diff
changeset
|
1121 |
win_entry->bd->hbuf = g_list_last(win_entry->bd->hbuf); |
5c857f0f0ab8
Moved all variables related to hbuf to an extra struct, bufdata
Frank Zschockelt
parents:
1156
diff
changeset
|
1122 |
hbuf_head = win_entry->bd->hbuf; |
5c857f0f0ab8
Moved all variables related to hbuf to an extra struct, bufdata
Frank Zschockelt
parents:
1156
diff
changeset
|
1123 |
win_entry->bd->top = NULL; // (Just to make sure) |
105 | 1124 |
n = 0; |
1125 |
while (hbuf_head && (n < CHAT_WIN_HEIGHT-1) && g_list_previous(hbuf_head)) { |
|
1126 |
hbuf_head = g_list_previous(hbuf_head); |
|
1127 |
n++; |
|
1128 |
} |
|
873
ee39f6d94d43
Add /buffer {scroll_lock|scroll_unlock|toggle_scroll}
Mikael Berthe <mikael@lilotux.net>
parents:
866
diff
changeset
|
1129 |
// If the buffer is locked, remember current "top" line for the next time. |
1157
5c857f0f0ab8
Moved all variables related to hbuf to an extra struct, bufdata
Frank Zschockelt
parents:
1156
diff
changeset
|
1130 |
if (win_entry->bd->lock) |
5c857f0f0ab8
Moved all variables related to hbuf to an extra struct, bufdata
Frank Zschockelt
parents:
1156
diff
changeset
|
1131 |
win_entry->bd->top = hbuf_head; |
105 | 1132 |
} else |
1157
5c857f0f0ab8
Moved all variables related to hbuf to an extra struct, bufdata
Frank Zschockelt
parents:
1156
diff
changeset
|
1133 |
hbuf_head = win_entry->bd->top; |
74 | 1134 |
|
1135 |
// Get the last CHAT_WIN_HEIGHT lines. |
|
1136 |
lines = hbuf_get_lines(hbuf_head, CHAT_WIN_HEIGHT); |
|
1137 |
||
1138 |
// Display these lines |
|
1139 |
for (n = 0; n < CHAT_WIN_HEIGHT; n++) { |
|
168 | 1140 |
wmove(win_entry->win, n, 0); |
184 | 1141 |
line = *(lines+n); |
1142 |
if (line) { |
|
1204
e802ec0c02d2
Basic support for nick highlighting in MUC rooms (the whole line is colored)
Mikael Berthe <mikael@lilotux.net>
parents:
1190
diff
changeset
|
1143 |
if (line->flags & HBB_PREFIX_HLIGHT_OUT) |
1291
9f64f548ac16
Better way of writing the nick
Michal 'vorner' Vaner <vorner@ucw.cz>
parents:
1290
diff
changeset
|
1144 |
color = COLOR_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
|
1145 |
else if (line->flags & HBB_PREFIX_HLIGHT) |
1291
9f64f548ac16
Better way of writing the nick
Michal 'vorner' Vaner <vorner@ucw.cz>
parents:
1290
diff
changeset
|
1146 |
color = COLOR_MSGHL; |
1268
dbc907b2d92f
Add configurable colors for info and incoming messages (Michal 'vorner' Vaner)
Mikael Berthe <mikael@lilotux.net>
parents:
1254
diff
changeset
|
1147 |
else if (line->flags & HBB_PREFIX_INFO) |
1291
9f64f548ac16
Better way of writing the nick
Michal 'vorner' Vaner <vorner@ucw.cz>
parents:
1290
diff
changeset
|
1148 |
color = COLOR_INFO; |
1268
dbc907b2d92f
Add configurable colors for info and incoming messages (Michal 'vorner' Vaner)
Mikael Berthe <mikael@lilotux.net>
parents:
1254
diff
changeset
|
1149 |
else if (line->flags & HBB_PREFIX_IN) |
1291
9f64f548ac16
Better way of writing the nick
Michal 'vorner' Vaner <vorner@ucw.cz>
parents:
1290
diff
changeset
|
1150 |
color = COLOR_MSGIN; |
9f64f548ac16
Better way of writing the nick
Michal 'vorner' Vaner <vorner@ucw.cz>
parents:
1290
diff
changeset
|
1151 |
else |
9f64f548ac16
Better way of writing the nick
Michal 'vorner' Vaner <vorner@ucw.cz>
parents:
1290
diff
changeset
|
1152 |
color = COLOR_GENERAL; |
9f64f548ac16
Better way of writing the nick
Michal 'vorner' Vaner <vorner@ucw.cz>
parents:
1290
diff
changeset
|
1153 |
|
9f64f548ac16
Better way of writing the nick
Michal 'vorner' Vaner <vorner@ucw.cz>
parents:
1290
diff
changeset
|
1154 |
if (color != COLOR_GENERAL) |
9f64f548ac16
Better way of writing the nick
Michal 'vorner' Vaner <vorner@ucw.cz>
parents:
1290
diff
changeset
|
1155 |
wattrset(win_entry->win, get_color(color)); |
1268
dbc907b2d92f
Add configurable colors for info and incoming messages (Michal 'vorner' Vaner)
Mikael Berthe <mikael@lilotux.net>
parents:
1254
diff
changeset
|
1156 |
|
1483
e74cc83e7158
Refactor scr_UpdateWindow()
Mikael Berthe <mikael@lilotux.net>
parents:
1476
diff
changeset
|
1157 |
// Generate the prefix area and display it |
1486
f83a51eaa5ed
Fix multiline output in /buffer save
Mikael Berthe <mikael@lilotux.net>
parents:
1485
diff
changeset
|
1158 |
scr_line_prefix(line, pref, prefixwidth); |
1483
e74cc83e7158
Refactor scr_UpdateWindow()
Mikael Berthe <mikael@lilotux.net>
parents:
1476
diff
changeset
|
1159 |
wprintw(win_entry->win, pref); |
729
39f67cade02c
Use bold font for outgoing messages
Mikael Berthe <mikael@lilotux.net>
parents:
728
diff
changeset
|
1160 |
|
1286
02ad6200df26
Add selectable time prefixes (vorner)
Mikael Berthe <mikael@lilotux.net>
parents:
1284
diff
changeset
|
1161 |
// Make sure we are at the right position |
1376
a0deb5124ebf
Check time_prefix value before using it
Mikael Berthe <mikael@lilotux.net>
parents:
1359
diff
changeset
|
1162 |
wmove(win_entry->win, n, prefixwidth-1); |
a0deb5124ebf
Check time_prefix value before using it
Mikael Berthe <mikael@lilotux.net>
parents:
1359
diff
changeset
|
1163 |
|
a0deb5124ebf
Check time_prefix value before using it
Mikael Berthe <mikael@lilotux.net>
parents:
1359
diff
changeset
|
1164 |
// The MUC nick - overwrite with proper color |
1294
86caabe72f3a
Color only incoming messages
Michal 'vorner' Vaner <vorner@ucw.cz>
parents:
1292
diff
changeset
|
1165 |
if (line->mucnicklen) { |
1476
77afd831f8f7
Avoid mixed declarations and code
Mikael Berthe <mikael@lilotux.net>
parents:
1457
diff
changeset
|
1166 |
char *mucjid; |
77afd831f8f7
Avoid mixed declarations and code
Mikael Berthe <mikael@lilotux.net>
parents:
1457
diff
changeset
|
1167 |
char tmp; |
77afd831f8f7
Avoid mixed declarations and code
Mikael Berthe <mikael@lilotux.net>
parents:
1457
diff
changeset
|
1168 |
nickcolor *actual = NULL; |
77afd831f8f7
Avoid mixed declarations and code
Mikael Berthe <mikael@lilotux.net>
parents:
1457
diff
changeset
|
1169 |
muccoltype type, *typetmp; |
77afd831f8f7
Avoid mixed declarations and code
Mikael Berthe <mikael@lilotux.net>
parents:
1457
diff
changeset
|
1170 |
|
1376
a0deb5124ebf
Check time_prefix value before using it
Mikael Berthe <mikael@lilotux.net>
parents:
1359
diff
changeset
|
1171 |
// Store the char after the nick |
1476
77afd831f8f7
Avoid mixed declarations and code
Mikael Berthe <mikael@lilotux.net>
parents:
1457
diff
changeset
|
1172 |
tmp = line->text[line->mucnicklen]; |
77afd831f8f7
Avoid mixed declarations and code
Mikael Berthe <mikael@lilotux.net>
parents:
1457
diff
changeset
|
1173 |
type = glob_muccol; |
1376
a0deb5124ebf
Check time_prefix value before using it
Mikael Berthe <mikael@lilotux.net>
parents:
1359
diff
changeset
|
1174 |
// Terminate the string after the nick |
1290
e42f48103609
Drawing the MUC nicks by a different color
Michal 'vorner' Vaner <vorner@ucw.cz>
parents:
1286
diff
changeset
|
1175 |
line->text[line->mucnicklen] = '\0'; |
1476
77afd831f8f7
Avoid mixed declarations and code
Mikael Berthe <mikael@lilotux.net>
parents:
1457
diff
changeset
|
1176 |
mucjid = g_utf8_strdown(CURRENT_JID, -1); |
1292
382ec54b584e
Muc nick coloring functionality
Michal 'vorner' Vaner <vorner@ucw.cz>
parents:
1291
diff
changeset
|
1177 |
if (muccolors) { |
382ec54b584e
Muc nick coloring functionality
Michal 'vorner' Vaner <vorner@ucw.cz>
parents:
1291
diff
changeset
|
1178 |
typetmp = g_hash_table_lookup(muccolors, mucjid); |
382ec54b584e
Muc nick coloring functionality
Michal 'vorner' Vaner <vorner@ucw.cz>
parents:
1291
diff
changeset
|
1179 |
if (typetmp) |
382ec54b584e
Muc nick coloring functionality
Michal 'vorner' Vaner <vorner@ucw.cz>
parents:
1291
diff
changeset
|
1180 |
type = *typetmp; |
382ec54b584e
Muc nick coloring functionality
Michal 'vorner' Vaner <vorner@ucw.cz>
parents:
1291
diff
changeset
|
1181 |
} |
382ec54b584e
Muc nick coloring functionality
Michal 'vorner' Vaner <vorner@ucw.cz>
parents:
1291
diff
changeset
|
1182 |
g_free(mucjid); |
1510
f6d4e20b9caa
MUC nickname colors depend on nicknames now
Maxim Vuets <maxim.vuets@gmail.com>
parents:
1505
diff
changeset
|
1183 |
// Need to generate a color for the specified nick? |
1292
382ec54b584e
Muc nick coloring functionality
Michal 'vorner' Vaner <vorner@ucw.cz>
parents:
1291
diff
changeset
|
1184 |
if ((type == MC_ALL) && (!nickcolors || |
382ec54b584e
Muc nick coloring functionality
Michal 'vorner' Vaner <vorner@ucw.cz>
parents:
1291
diff
changeset
|
1185 |
!g_hash_table_lookup(nickcolors, line->text))) { |
1476
77afd831f8f7
Avoid mixed declarations and code
Mikael Berthe <mikael@lilotux.net>
parents:
1457
diff
changeset
|
1186 |
char *snick, *mnick; |
77afd831f8f7
Avoid mixed declarations and code
Mikael Berthe <mikael@lilotux.net>
parents:
1457
diff
changeset
|
1187 |
nickcolor *nc; |
1510
f6d4e20b9caa
MUC nickname colors depend on nicknames now
Maxim Vuets <maxim.vuets@gmail.com>
parents:
1505
diff
changeset
|
1188 |
const char *p = line->text; |
f6d4e20b9caa
MUC nickname colors depend on nicknames now
Maxim Vuets <maxim.vuets@gmail.com>
parents:
1505
diff
changeset
|
1189 |
unsigned int nicksum = 0; |
1476
77afd831f8f7
Avoid mixed declarations and code
Mikael Berthe <mikael@lilotux.net>
parents:
1457
diff
changeset
|
1190 |
snick = g_strdup(line->text); |
77afd831f8f7
Avoid mixed declarations and code
Mikael Berthe <mikael@lilotux.net>
parents:
1457
diff
changeset
|
1191 |
mnick = g_strdup(line->text); |
77afd831f8f7
Avoid mixed declarations and code
Mikael Berthe <mikael@lilotux.net>
parents:
1457
diff
changeset
|
1192 |
nc = g_new(nickcolor, 1); |
1292
382ec54b584e
Muc nick coloring functionality
Michal 'vorner' Vaner <vorner@ucw.cz>
parents:
1291
diff
changeset
|
1193 |
ensure_string_htable(&nickcolors, NULL); |
1510
f6d4e20b9caa
MUC nickname colors depend on nicknames now
Maxim Vuets <maxim.vuets@gmail.com>
parents:
1505
diff
changeset
|
1194 |
while (*p) |
f6d4e20b9caa
MUC nickname colors depend on nicknames now
Maxim Vuets <maxim.vuets@gmail.com>
parents:
1505
diff
changeset
|
1195 |
nicksum += *p++; |
f6d4e20b9caa
MUC nickname colors depend on nicknames now
Maxim Vuets <maxim.vuets@gmail.com>
parents:
1505
diff
changeset
|
1196 |
nc->color = nickcols[nicksum % nickcolcount]; |
1381
40095d413da9
Fix compilation on OpenBSD
Mikael Berthe <mikael@lilotux.net>
parents:
1376
diff
changeset
|
1197 |
nc->manual = FALSE; |
1292
382ec54b584e
Muc nick coloring functionality
Michal 'vorner' Vaner <vorner@ucw.cz>
parents:
1291
diff
changeset
|
1198 |
*snick = '<'; |
382ec54b584e
Muc nick coloring functionality
Michal 'vorner' Vaner <vorner@ucw.cz>
parents:
1291
diff
changeset
|
1199 |
snick[strlen(snick)-1] = '>'; |
382ec54b584e
Muc nick coloring functionality
Michal 'vorner' Vaner <vorner@ucw.cz>
parents:
1291
diff
changeset
|
1200 |
*mnick = '*'; |
382ec54b584e
Muc nick coloring functionality
Michal 'vorner' Vaner <vorner@ucw.cz>
parents:
1291
diff
changeset
|
1201 |
mnick[strlen(mnick)-1] = ' '; |
1376
a0deb5124ebf
Check time_prefix value before using it
Mikael Berthe <mikael@lilotux.net>
parents:
1359
diff
changeset
|
1202 |
// Insert them |
1292
382ec54b584e
Muc nick coloring functionality
Michal 'vorner' Vaner <vorner@ucw.cz>
parents:
1291
diff
changeset
|
1203 |
g_hash_table_insert(nickcolors, snick, nc); |
382ec54b584e
Muc nick coloring functionality
Michal 'vorner' Vaner <vorner@ucw.cz>
parents:
1291
diff
changeset
|
1204 |
g_hash_table_insert(nickcolors, mnick, nc); |
382ec54b584e
Muc nick coloring functionality
Michal 'vorner' Vaner <vorner@ucw.cz>
parents:
1291
diff
changeset
|
1205 |
} |
382ec54b584e
Muc nick coloring functionality
Michal 'vorner' Vaner <vorner@ucw.cz>
parents:
1291
diff
changeset
|
1206 |
if (nickcolors) |
382ec54b584e
Muc nick coloring functionality
Michal 'vorner' Vaner <vorner@ucw.cz>
parents:
1291
diff
changeset
|
1207 |
actual = g_hash_table_lookup(nickcolors, line->text); |
1294
86caabe72f3a
Color only incoming messages
Michal 'vorner' Vaner <vorner@ucw.cz>
parents:
1292
diff
changeset
|
1208 |
if (actual && ((type == MC_ALL) || (actual->manual)) |
86caabe72f3a
Color only incoming messages
Michal 'vorner' Vaner <vorner@ucw.cz>
parents:
1292
diff
changeset
|
1209 |
&& (line->flags & HBB_PREFIX_IN) && |
86caabe72f3a
Color only incoming messages
Michal 'vorner' Vaner <vorner@ucw.cz>
parents:
1292
diff
changeset
|
1210 |
(!(line->flags & HBB_PREFIX_HLIGHT_OUT))) |
1489
e9c71ce96dca
Fixed the colorhandling for mucnicks and /color roster
franky@veqlargh.fs
parents:
1488
diff
changeset
|
1211 |
wattrset(win_entry->win, compose_color(actual->color)); |
1290
e42f48103609
Drawing the MUC nicks by a different color
Michal 'vorner' Vaner <vorner@ucw.cz>
parents:
1286
diff
changeset
|
1212 |
wprintw(win_entry->win, "%s", line->text); |
1376
a0deb5124ebf
Check time_prefix value before using it
Mikael Berthe <mikael@lilotux.net>
parents:
1359
diff
changeset
|
1213 |
// Return the char |
1290
e42f48103609
Drawing the MUC nicks by a different color
Michal 'vorner' Vaner <vorner@ucw.cz>
parents:
1286
diff
changeset
|
1214 |
line->text[line->mucnicklen] = tmp; |
1376
a0deb5124ebf
Check time_prefix value before using it
Mikael Berthe <mikael@lilotux.net>
parents:
1359
diff
changeset
|
1215 |
// Return the color back |
1291
9f64f548ac16
Better way of writing the nick
Michal 'vorner' Vaner <vorner@ucw.cz>
parents:
1290
diff
changeset
|
1216 |
wattrset(win_entry->win, get_color(color)); |
1290
e42f48103609
Drawing the MUC nicks by a different color
Michal 'vorner' Vaner <vorner@ucw.cz>
parents:
1286
diff
changeset
|
1217 |
} |
729
39f67cade02c
Use bold font for outgoing messages
Mikael Berthe <mikael@lilotux.net>
parents:
728
diff
changeset
|
1218 |
|
1333
e30a9d907105
Minor coding style adjustments
Mikael Berthe <mikael@lilotux.net>
parents:
1314
diff
changeset
|
1219 |
// Display text line |
e30a9d907105
Minor coding style adjustments
Mikael Berthe <mikael@lilotux.net>
parents:
1314
diff
changeset
|
1220 |
wprintw(win_entry->win, "%s", line->text+line->mucnicklen); |
1291
9f64f548ac16
Better way of writing the nick
Michal 'vorner' Vaner <vorner@ucw.cz>
parents:
1290
diff
changeset
|
1221 |
wclrtoeol(win_entry->win); |
9f64f548ac16
Better way of writing the nick
Michal 'vorner' Vaner <vorner@ucw.cz>
parents:
1290
diff
changeset
|
1222 |
|
1268
dbc907b2d92f
Add configurable colors for info and incoming messages (Michal 'vorner' Vaner)
Mikael Berthe <mikael@lilotux.net>
parents:
1254
diff
changeset
|
1223 |
// Return the color back |
1291
9f64f548ac16
Better way of writing the nick
Michal 'vorner' Vaner <vorner@ucw.cz>
parents:
1290
diff
changeset
|
1224 |
if (color != COLOR_GENERAL) |
739
0d5fb1d9077c
Allow "bright" text colors
Mikael Berthe <mikael@lilotux.net>
parents:
735
diff
changeset
|
1225 |
wattrset(win_entry->win, get_color(COLOR_GENERAL)); |
1483
e74cc83e7158
Refactor scr_UpdateWindow()
Mikael Berthe <mikael@lilotux.net>
parents:
1476
diff
changeset
|
1226 |
|
184 | 1227 |
g_free(line->text); |
898
c65b71dcda94
Fix memory leak in scr_UpdateWindow()
Mikael Berthe <mikael@lilotux.net>
parents:
897
diff
changeset
|
1228 |
g_free(line); |
168 | 1229 |
} else { |
1230 |
wclrtobot(win_entry->win); |
|
1231 |
break; |
|
75 | 1232 |
} |
74 | 1233 |
} |
1234 |
g_free(lines); |
|
1235 |
} |
|
1159
53c0c5be43fa
Small fixes, typos and cleanups
Mikael Berthe <mikael@lilotux.net>
parents:
1157
diff
changeset
|
1236 |
|
1780
e4378fbab5d7
Major API cleanup - bump API to 4
Mikael Berthe <mikael@lilotux.net>
parents:
1761
diff
changeset
|
1237 |
static winbuf *scr_create_window(const char *winId, int special, int dont_show) |
1154 | 1238 |
{ |
1239 |
if (special) { |
|
1240 |
if (!statusWindow) { |
|
1241 |
statusWindow = scr_new_buddy(NULL, dont_show); |
|
1157
5c857f0f0ab8
Moved all variables related to hbuf to an extra struct, bufdata
Frank Zschockelt
parents:
1156
diff
changeset
|
1242 |
statusWindow->bd->hbuf = statushbuf; |
1154 | 1243 |
} |
1244 |
return statusWindow; |
|
1245 |
} else { |
|
1246 |
return scr_new_buddy(winId, dont_show); |
|
1247 |
} |
|
1248 |
} |
|
1249 |
||
1780
e4378fbab5d7
Major API cleanup - bump API to 4
Mikael Berthe <mikael@lilotux.net>
parents:
1761
diff
changeset
|
1250 |
// scr_show_window() |
143 | 1251 |
// Display the chat window with the given identifier. |
849
42c43a88d823
Status buffer management
Mikael Berthe <mikael@lilotux.net>
parents:
848
diff
changeset
|
1252 |
// "special" must be true if this is a special buffer window. |
1780
e4378fbab5d7
Major API cleanup - bump API to 4
Mikael Berthe <mikael@lilotux.net>
parents:
1761
diff
changeset
|
1253 |
static void scr_show_window(const char *winId, int special) |
24 | 1254 |
{ |
849
42c43a88d823
Status buffer management
Mikael Berthe <mikael@lilotux.net>
parents:
848
diff
changeset
|
1255 |
winbuf *win_entry; |
42c43a88d823
Status buffer management
Mikael Berthe <mikael@lilotux.net>
parents:
848
diff
changeset
|
1256 |
|
1780
e4378fbab5d7
Major API cleanup - bump API to 4
Mikael Berthe <mikael@lilotux.net>
parents:
1761
diff
changeset
|
1257 |
win_entry = scr_search_window(winId, special); |
74 | 1258 |
|
849
42c43a88d823
Status buffer management
Mikael Berthe <mikael@lilotux.net>
parents:
848
diff
changeset
|
1259 |
if (!win_entry) { |
1780
e4378fbab5d7
Major API cleanup - bump API to 4
Mikael Berthe <mikael@lilotux.net>
parents:
1761
diff
changeset
|
1260 |
win_entry = scr_create_window(winId, special, FALSE); |
849
42c43a88d823
Status buffer management
Mikael Berthe <mikael@lilotux.net>
parents:
848
diff
changeset
|
1261 |
} |
74 | 1262 |
|
180 | 1263 |
top_panel(win_entry->panel); |
1264 |
currentWindow = win_entry; |
|
1265 |
chatmode = TRUE; |
|
1157
5c857f0f0ab8
Moved all variables related to hbuf to an extra struct, bufdata
Frank Zschockelt
parents:
1156
diff
changeset
|
1266 |
if (!win_entry->bd->lock) |
889
ae93e69aaaaf
Fix up pending message flag for the status special buffer
Mikael Berthe <mikael@lilotux.net>
parents:
888
diff
changeset
|
1267 |
roster_msg_setflag(winId, special, FALSE); |
ae93e69aaaaf
Fix up pending message flag for the status special buffer
Mikael Berthe <mikael@lilotux.net>
parents:
888
diff
changeset
|
1268 |
if (!special) |
849
42c43a88d823
Status buffer management
Mikael Berthe <mikael@lilotux.net>
parents:
848
diff
changeset
|
1269 |
roster_setflags(winId, ROSTER_FLAG_LOCK, TRUE); |
874
293e8955075c
Display a flag in the chat status line when the buffer is locked
Mikael Berthe <mikael@lilotux.net>
parents:
873
diff
changeset
|
1270 |
update_roster = TRUE; |
74 | 1271 |
|
180 | 1272 |
// Refresh the window |
1780
e4378fbab5d7
Major API cleanup - bump API to 4
Mikael Berthe <mikael@lilotux.net>
parents:
1761
diff
changeset
|
1273 |
scr_update_window(win_entry); |
180 | 1274 |
|
1275 |
// Finished :) |
|
1276 |
update_panels(); |
|
142 | 1277 |
|
1278 |
top_panel(inputPanel); |
|
24 | 1279 |
} |
1280 |
||
1780
e4378fbab5d7
Major API cleanup - bump API to 4
Mikael Berthe <mikael@lilotux.net>
parents:
1761
diff
changeset
|
1281 |
// scr_show_buddy_window() |
143 | 1282 |
// Display the chat window buffer for the current buddy. |
1780
e4378fbab5d7
Major API cleanup - bump API to 4
Mikael Berthe <mikael@lilotux.net>
parents:
1761
diff
changeset
|
1283 |
void scr_show_buddy_window(void) |
24 | 1284 |
{ |
1058 | 1285 |
const gchar *bjid; |
140 | 1286 |
|
849
42c43a88d823
Status buffer management
Mikael Berthe <mikael@lilotux.net>
parents:
848
diff
changeset
|
1287 |
if (!current_buddy) { |
1058 | 1288 |
bjid = NULL; |
849
42c43a88d823
Status buffer management
Mikael Berthe <mikael@lilotux.net>
parents:
848
diff
changeset
|
1289 |
} else { |
1058 | 1290 |
bjid = CURRENT_JID; |
849
42c43a88d823
Status buffer management
Mikael Berthe <mikael@lilotux.net>
parents:
848
diff
changeset
|
1291 |
if (buddy_gettype(BUDDATA(current_buddy)) & ROSTER_TYPE_SPECIAL) { |
1780
e4378fbab5d7
Major API cleanup - bump API to 4
Mikael Berthe <mikael@lilotux.net>
parents:
1761
diff
changeset
|
1292 |
scr_show_window(buddy_getname(BUDDATA(current_buddy)), TRUE); |
849
42c43a88d823
Status buffer management
Mikael Berthe <mikael@lilotux.net>
parents:
848
diff
changeset
|
1293 |
return; |
42c43a88d823
Status buffer management
Mikael Berthe <mikael@lilotux.net>
parents:
848
diff
changeset
|
1294 |
} |
42c43a88d823
Status buffer management
Mikael Berthe <mikael@lilotux.net>
parents:
848
diff
changeset
|
1295 |
} |
140 | 1296 |
|
1058 | 1297 |
if (!bjid) { |
140 | 1298 |
top_panel(chatPanel); |
143 | 1299 |
top_panel(inputPanel); |
140 | 1300 |
currentWindow = NULL; |
105 | 1301 |
return; |
140 | 1302 |
} |
1303 |
||
1780
e4378fbab5d7
Major API cleanup - bump API to 4
Mikael Berthe <mikael@lilotux.net>
parents:
1761
diff
changeset
|
1304 |
scr_show_window(bjid, FALSE); |
24 | 1305 |
} |
1306 |
||
1780
e4378fbab5d7
Major API cleanup - bump API to 4
Mikael Berthe <mikael@lilotux.net>
parents:
1761
diff
changeset
|
1307 |
// scr_update_buddy_window() |
865
cee8d6be04e1
Improve changeset a3db3ee8b99e, do not enable chatmode when refreshing
Mikael Berthe <mikael@lilotux.net>
parents:
858
diff
changeset
|
1308 |
// (Re)Display the current window. |
1780
e4378fbab5d7
Major API cleanup - bump API to 4
Mikael Berthe <mikael@lilotux.net>
parents:
1761
diff
changeset
|
1309 |
// If chatmode is enabled, call scr_show_buddy_window(), |
865
cee8d6be04e1
Improve changeset a3db3ee8b99e, do not enable chatmode when refreshing
Mikael Berthe <mikael@lilotux.net>
parents:
858
diff
changeset
|
1310 |
// else display the chat window. |
1780
e4378fbab5d7
Major API cleanup - bump API to 4
Mikael Berthe <mikael@lilotux.net>
parents:
1761
diff
changeset
|
1311 |
inline void scr_update_buddy_window(void) |
865
cee8d6be04e1
Improve changeset a3db3ee8b99e, do not enable chatmode when refreshing
Mikael Berthe <mikael@lilotux.net>
parents:
858
diff
changeset
|
1312 |
{ |
cee8d6be04e1
Improve changeset a3db3ee8b99e, do not enable chatmode when refreshing
Mikael Berthe <mikael@lilotux.net>
parents:
858
diff
changeset
|
1313 |
if (chatmode) { |
1780
e4378fbab5d7
Major API cleanup - bump API to 4
Mikael Berthe <mikael@lilotux.net>
parents:
1761
diff
changeset
|
1314 |
scr_show_buddy_window(); |
865
cee8d6be04e1
Improve changeset a3db3ee8b99e, do not enable chatmode when refreshing
Mikael Berthe <mikael@lilotux.net>
parents:
858
diff
changeset
|
1315 |
return; |
cee8d6be04e1
Improve changeset a3db3ee8b99e, do not enable chatmode when refreshing
Mikael Berthe <mikael@lilotux.net>
parents:
858
diff
changeset
|
1316 |
} |
cee8d6be04e1
Improve changeset a3db3ee8b99e, do not enable chatmode when refreshing
Mikael Berthe <mikael@lilotux.net>
parents:
858
diff
changeset
|
1317 |
|
cee8d6be04e1
Improve changeset a3db3ee8b99e, do not enable chatmode when refreshing
Mikael Berthe <mikael@lilotux.net>
parents:
858
diff
changeset
|
1318 |
top_panel(chatPanel); |
cee8d6be04e1
Improve changeset a3db3ee8b99e, do not enable chatmode when refreshing
Mikael Berthe <mikael@lilotux.net>
parents:
858
diff
changeset
|
1319 |
top_panel(inputPanel); |
cee8d6be04e1
Improve changeset a3db3ee8b99e, do not enable chatmode when refreshing
Mikael Berthe <mikael@lilotux.net>
parents:
858
diff
changeset
|
1320 |
} |
cee8d6be04e1
Improve changeset a3db3ee8b99e, do not enable chatmode when refreshing
Mikael Berthe <mikael@lilotux.net>
parents:
858
diff
changeset
|
1321 |
|
1780
e4378fbab5d7
Major API cleanup - bump API to 4
Mikael Berthe <mikael@lilotux.net>
parents:
1761
diff
changeset
|
1322 |
// scr_write_in_window() |
143 | 1323 |
// Write some text in the winId window (this usually is a jid). |
849
42c43a88d823
Status buffer management
Mikael Berthe <mikael@lilotux.net>
parents:
848
diff
changeset
|
1324 |
// Use winId == NULL for the special status buffer. |
143 | 1325 |
// Lines are splitted when they are too long to fit in the chat window. |
1326 |
// If this window doesn't exist, it is created. |
|
1780
e4378fbab5d7
Major API cleanup - bump API to 4
Mikael Berthe <mikael@lilotux.net>
parents:
1761
diff
changeset
|
1327 |
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
|
1328 |
time_t timestamp, unsigned int prefix_flags, |
e4378fbab5d7
Major API cleanup - bump API to 4
Mikael Berthe <mikael@lilotux.net>
parents:
1761
diff
changeset
|
1329 |
int force_show, unsigned mucnicklen, |
e4378fbab5d7
Major API cleanup - bump API to 4
Mikael Berthe <mikael@lilotux.net>
parents:
1761
diff
changeset
|
1330 |
gpointer xep184) |
24 | 1331 |
{ |
822 | 1332 |
winbuf *win_entry; |
772
464be13343a9
Store most data in UTF-8 internally
Mikael Berthe <mikael@lilotux.net>
parents:
771
diff
changeset
|
1333 |
char *text_locale; |
24 | 1334 |
int dont_show = FALSE; |
849
42c43a88d823
Status buffer management
Mikael Berthe <mikael@lilotux.net>
parents:
848
diff
changeset
|
1335 |
int special; |
1142
0e27177882c7
Small fix for the max_history_blocks option
Mikael Berthe <mikael@lilotux.net>
parents:
1141
diff
changeset
|
1336 |
guint num_history_blocks; |
873
ee39f6d94d43
Add /buffer {scroll_lock|scroll_unlock|toggle_scroll}
Mikael Berthe <mikael@lilotux.net>
parents:
866
diff
changeset
|
1337 |
bool setmsgflg = FALSE; |
1296
7a0eaa53bd53
Further nick colors fixes
Michal 'vorner' Vaner <vorner@ucw.cz>
parents:
1295
diff
changeset
|
1338 |
char *nicktmp, *nicklocaltmp; |
24 | 1339 |
|
74 | 1340 |
// Look for the window entry. |
849
42c43a88d823
Status buffer management
Mikael Berthe <mikael@lilotux.net>
parents:
848
diff
changeset
|
1341 |
special = (winId == NULL); |
1780
e4378fbab5d7
Major API cleanup - bump API to 4
Mikael Berthe <mikael@lilotux.net>
parents:
1761
diff
changeset
|
1342 |
win_entry = scr_search_window(winId, special); |
74 | 1343 |
|
1344 |
// Do we have to really show the window? |
|
24 | 1345 |
if (!chatmode) |
1346 |
dont_show = TRUE; |
|
74 | 1347 |
else if ((!force_show) && ((!currentWindow || (currentWindow != win_entry)))) |
24 | 1348 |
dont_show = TRUE; |
1349 |
||
74 | 1350 |
// If the window entry doesn't exist yet, let's create it. |
849
42c43a88d823
Status buffer management
Mikael Berthe <mikael@lilotux.net>
parents:
848
diff
changeset
|
1351 |
if (!win_entry) { |
1780
e4378fbab5d7
Major API cleanup - bump API to 4
Mikael Berthe <mikael@lilotux.net>
parents:
1761
diff
changeset
|
1352 |
win_entry = scr_create_window(winId, special, dont_show); |
24 | 1353 |
} |
1354 |
||
220 | 1355 |
// The message must be displayed -> update top pointer |
1157
5c857f0f0ab8
Moved all variables related to hbuf to an extra struct, bufdata
Frank Zschockelt
parents:
1156
diff
changeset
|
1356 |
if (win_entry->bd->cleared) |
5c857f0f0ab8
Moved all variables related to hbuf to an extra struct, bufdata
Frank Zschockelt
parents:
1156
diff
changeset
|
1357 |
win_entry->bd->top = g_list_last(win_entry->bd->hbuf); |
220 | 1358 |
|
1142
0e27177882c7
Small fix for the max_history_blocks option
Mikael Berthe <mikael@lilotux.net>
parents:
1141
diff
changeset
|
1359 |
// Make sure we do not free the buffer while it's locked or when |
0e27177882c7
Small fix for the max_history_blocks option
Mikael Berthe <mikael@lilotux.net>
parents:
1141
diff
changeset
|
1360 |
// top is set. |
1157
5c857f0f0ab8
Moved all variables related to hbuf to an extra struct, bufdata
Frank Zschockelt
parents:
1156
diff
changeset
|
1361 |
if (win_entry->bd->lock || win_entry->bd->top) |
1142
0e27177882c7
Small fix for the max_history_blocks option
Mikael Berthe <mikael@lilotux.net>
parents:
1141
diff
changeset
|
1362 |
num_history_blocks = 0U; |
0e27177882c7
Small fix for the max_history_blocks option
Mikael Berthe <mikael@lilotux.net>
parents:
1141
diff
changeset
|
1363 |
else |
0e27177882c7
Small fix for the max_history_blocks option
Mikael Berthe <mikael@lilotux.net>
parents:
1141
diff
changeset
|
1364 |
num_history_blocks = get_max_history_blocks(); |
0e27177882c7
Small fix for the max_history_blocks option
Mikael Berthe <mikael@lilotux.net>
parents:
1141
diff
changeset
|
1365 |
|
772
464be13343a9
Store most data in UTF-8 internally
Mikael Berthe <mikael@lilotux.net>
parents:
771
diff
changeset
|
1366 |
text_locale = from_utf8(text); |
1729
e6e89b1d7831
Minor style and header updates
Mikael Berthe <mikael@lilotux.net>
parents:
1710
diff
changeset
|
1367 |
// Convert the nick alone and compute its length |
1296
7a0eaa53bd53
Further nick colors fixes
Michal 'vorner' Vaner <vorner@ucw.cz>
parents:
1295
diff
changeset
|
1368 |
if (mucnicklen) { |
7a0eaa53bd53
Further nick colors fixes
Michal 'vorner' Vaner <vorner@ucw.cz>
parents:
1295
diff
changeset
|
1369 |
nicktmp = g_strndup(text, mucnicklen); |
7a0eaa53bd53
Further nick colors fixes
Michal 'vorner' Vaner <vorner@ucw.cz>
parents:
1295
diff
changeset
|
1370 |
nicklocaltmp = from_utf8(nicktmp); |
7a0eaa53bd53
Further nick colors fixes
Michal 'vorner' Vaner <vorner@ucw.cz>
parents:
1295
diff
changeset
|
1371 |
mucnicklen = strlen(nicklocaltmp); |
7a0eaa53bd53
Further nick colors fixes
Michal 'vorner' Vaner <vorner@ucw.cz>
parents:
1295
diff
changeset
|
1372 |
g_free(nicklocaltmp); |
7a0eaa53bd53
Further nick colors fixes
Michal 'vorner' Vaner <vorner@ucw.cz>
parents:
1295
diff
changeset
|
1373 |
g_free(nicktmp); |
7a0eaa53bd53
Further nick colors fixes
Michal 'vorner' Vaner <vorner@ucw.cz>
parents:
1295
diff
changeset
|
1374 |
} |
1157
5c857f0f0ab8
Moved all variables related to hbuf to an extra struct, bufdata
Frank Zschockelt
parents:
1156
diff
changeset
|
1375 |
hbuf_add_line(&win_entry->bd->hbuf, text_locale, timestamp, prefix_flags, |
1487 | 1376 |
maxX - Roster_Width - scr_getprefixwidth(), num_history_blocks, |
1602 | 1377 |
mucnicklen, xep184); |
772
464be13343a9
Store most data in UTF-8 internally
Mikael Berthe <mikael@lilotux.net>
parents:
771
diff
changeset
|
1378 |
g_free(text_locale); |
74 | 1379 |
|
1157
5c857f0f0ab8
Moved all variables related to hbuf to an extra struct, bufdata
Frank Zschockelt
parents:
1156
diff
changeset
|
1380 |
if (win_entry->bd->cleared) { |
5c857f0f0ab8
Moved all variables related to hbuf to an extra struct, bufdata
Frank Zschockelt
parents:
1156
diff
changeset
|
1381 |
win_entry->bd->cleared = FALSE; |
5c857f0f0ab8
Moved all variables related to hbuf to an extra struct, bufdata
Frank Zschockelt
parents:
1156
diff
changeset
|
1382 |
if (g_list_next(win_entry->bd->top)) |
5c857f0f0ab8
Moved all variables related to hbuf to an extra struct, bufdata
Frank Zschockelt
parents:
1156
diff
changeset
|
1383 |
win_entry->bd->top = g_list_next(win_entry->bd->top); |
220 | 1384 |
} |
1385 |
||
1386 |
// Make sure the last line appears in the window; update top if necessary |
|
1157
5c857f0f0ab8
Moved all variables related to hbuf to an extra struct, bufdata
Frank Zschockelt
parents:
1156
diff
changeset
|
1387 |
if (!win_entry->bd->lock && win_entry->bd->top) { |
220 | 1388 |
int dist; |
1157
5c857f0f0ab8
Moved all variables related to hbuf to an extra struct, bufdata
Frank Zschockelt
parents:
1156
diff
changeset
|
1389 |
GList *first = g_list_first(win_entry->bd->hbuf); |
5c857f0f0ab8
Moved all variables related to hbuf to an extra struct, bufdata
Frank Zschockelt
parents:
1156
diff
changeset
|
1390 |
dist = g_list_position(first, g_list_last(win_entry->bd->hbuf)) - |
5c857f0f0ab8
Moved all variables related to hbuf to an extra struct, bufdata
Frank Zschockelt
parents:
1156
diff
changeset
|
1391 |
g_list_position(first, win_entry->bd->top); |
220 | 1392 |
if (dist >= CHAT_WIN_HEIGHT) |
1157
5c857f0f0ab8
Moved all variables related to hbuf to an extra struct, bufdata
Frank Zschockelt
parents:
1156
diff
changeset
|
1393 |
win_entry->bd->top = NULL; |
108 | 1394 |
} |
1395 |
||
24 | 1396 |
if (!dont_show) { |
1157
5c857f0f0ab8
Moved all variables related to hbuf to an extra struct, bufdata
Frank Zschockelt
parents:
1156
diff
changeset
|
1397 |
if (win_entry->bd->lock) |
873
ee39f6d94d43
Add /buffer {scroll_lock|scroll_unlock|toggle_scroll}
Mikael Berthe <mikael@lilotux.net>
parents:
866
diff
changeset
|
1398 |
setmsgflg = TRUE; |
74 | 1399 |
// Show and refresh the window |
1400 |
top_panel(win_entry->panel); |
|
1780
e4378fbab5d7
Major API cleanup - bump API to 4
Mikael Berthe <mikael@lilotux.net>
parents:
1761
diff
changeset
|
1401 |
scr_update_window(win_entry); |
142 | 1402 |
top_panel(inputPanel); |
24 | 1403 |
update_panels(); |
873
ee39f6d94d43
Add /buffer {scroll_lock|scroll_unlock|toggle_scroll}
Mikael Berthe <mikael@lilotux.net>
parents:
866
diff
changeset
|
1404 |
} else if (!(prefix_flags & HBB_PREFIX_NOFLAG)) { |
ee39f6d94d43
Add /buffer {scroll_lock|scroll_unlock|toggle_scroll}
Mikael Berthe <mikael@lilotux.net>
parents:
866
diff
changeset
|
1405 |
setmsgflg = TRUE; |
ee39f6d94d43
Add /buffer {scroll_lock|scroll_unlock|toggle_scroll}
Mikael Berthe <mikael@lilotux.net>
parents:
866
diff
changeset
|
1406 |
} |
ee39f6d94d43
Add /buffer {scroll_lock|scroll_unlock|toggle_scroll}
Mikael Berthe <mikael@lilotux.net>
parents:
866
diff
changeset
|
1407 |
if (setmsgflg && !special) { |
889
ae93e69aaaaf
Fix up pending message flag for the status special buffer
Mikael Berthe <mikael@lilotux.net>
parents:
888
diff
changeset
|
1408 |
if (special && !winId) |
ae93e69aaaaf
Fix up pending message flag for the status special buffer
Mikael Berthe <mikael@lilotux.net>
parents:
888
diff
changeset
|
1409 |
winId = SPECIAL_BUFFER_STATUS_ID; |
ae93e69aaaaf
Fix up pending message flag for the status special buffer
Mikael Berthe <mikael@lilotux.net>
parents:
888
diff
changeset
|
1410 |
roster_msg_setflag(winId, special, TRUE); |
30 | 1411 |
update_roster = TRUE; |
24 | 1412 |
} |
1413 |
} |
|
1414 |
||
1780
e4378fbab5d7
Major API cleanup - bump API to 4
Mikael Berthe <mikael@lilotux.net>
parents:
1761
diff
changeset
|
1415 |
// scr_update_main_status(forceupdate) |
713 | 1416 |
// Redraw the main (bottom) status line. |
1780
e4378fbab5d7
Major API cleanup - bump API to 4
Mikael Berthe <mikael@lilotux.net>
parents:
1761
diff
changeset
|
1417 |
// You can set forceupdate to FALSE in order to optimize screen refresh |
e4378fbab5d7
Major API cleanup - bump API to 4
Mikael Berthe <mikael@lilotux.net>
parents:
1761
diff
changeset
|
1418 |
// if you call top_panel()/update_panels() later. |
e4378fbab5d7
Major API cleanup - bump API to 4
Mikael Berthe <mikael@lilotux.net>
parents:
1761
diff
changeset
|
1419 |
void scr_update_main_status(int forceupdate) |
713 | 1420 |
{ |
1598 | 1421 |
char *sm = from_utf8(xmpp_getstatusmsg()); |
1514 | 1422 |
const char *info = settings_opt_get("info"); |
713 | 1423 |
|
1424 |
werase(mainstatusWnd); |
|
1515 | 1425 |
if (info) { |
1519 | 1426 |
char *info_locale = from_utf8(info); |
1743
dcbf31f99fa3
Do not automatically append ":" to the "info" string
Mikael Berthe <mikael@lilotux.net>
parents:
1733
diff
changeset
|
1427 |
mvwprintw(mainstatusWnd, 0, 0, "%c[%c] %s %s", |
1514 | 1428 |
(unread_msg(NULL) ? '#' : ' '), |
1598 | 1429 |
imstatus2char[xmpp_getstatus()], |
1519 | 1430 |
info_locale, (sm ? sm : "")); |
1431 |
g_free(info_locale); |
|
1515 | 1432 |
} else |
1514 | 1433 |
mvwprintw(mainstatusWnd, 0, 0, "%c[%c] %s", |
1434 |
(unread_msg(NULL) ? '#' : ' '), |
|
1598 | 1435 |
imstatus2char[xmpp_getstatus()], (sm ? sm : "")); |
724
264375fe7159
Fix a roster refresh issue
Mikael Berthe <mikael@lilotux.net>
parents:
723
diff
changeset
|
1436 |
if (forceupdate) { |
264375fe7159
Fix a roster refresh issue
Mikael Berthe <mikael@lilotux.net>
parents:
723
diff
changeset
|
1437 |
top_panel(inputPanel); |
264375fe7159
Fix a roster refresh issue
Mikael Berthe <mikael@lilotux.net>
parents:
723
diff
changeset
|
1438 |
update_panels(); |
264375fe7159
Fix a roster refresh issue
Mikael Berthe <mikael@lilotux.net>
parents:
723
diff
changeset
|
1439 |
} |
773
e25b8a348ebd
Screen updating functions use UTF-8
Mikael Berthe <mikael@lilotux.net>
parents:
772
diff
changeset
|
1440 |
g_free(sm); |
713 | 1441 |
} |
1442 |
||
1780
e4378fbab5d7
Major API cleanup - bump API to 4
Mikael Berthe <mikael@lilotux.net>
parents:
1761
diff
changeset
|
1443 |
// scr_draw_main_window() |
157 | 1444 |
// Set fullinit to TRUE to also create panels. Set it to FALSE for a resize. |
151 | 1445 |
// |
1446 |
// I think it could be improved a _lot_ but I'm really not an ncurses |
|
1447 |
// expert... :-\ Mikael. |
|
1448 |
// |
|
1780
e4378fbab5d7
Major API cleanup - bump API to 4
Mikael Berthe <mikael@lilotux.net>
parents:
1761
diff
changeset
|
1449 |
void scr_draw_main_window(unsigned int fullinit) |
24 | 1450 |
{ |
701
6c100adfbfb6
Add setting "roster_width" (variable buddylist width)
Mikael Berthe <mikael@lilotux.net>
parents:
699
diff
changeset
|
1451 |
int requested_size; |
961
95659cf9ea1a
Display mcabber version in the status window
Mikael Berthe <mikael@lilotux.net>
parents:
952
diff
changeset
|
1452 |
gchar *ver, *message; |
972
11b632d824f6
Add option 'log_win_on_top'
Mikael Berthe <mikael@lilotux.net>
parents:
967
diff
changeset
|
1453 |
int chat_y_pos, chatstatus_y_pos, log_y_pos; |
973
e693cbe33802
Add option 'roster_win_on_right'
Mikael Berthe <mikael@lilotux.net>
parents:
972
diff
changeset
|
1454 |
int roster_x_pos, chat_x_pos; |
518
9480a76471b6
Update Log_Win_Height when refreshing the screen
Mikael Berthe <mikael@lilotux.net>
parents:
515
diff
changeset
|
1455 |
|
9480a76471b6
Update Log_Win_Height when refreshing the screen
Mikael Berthe <mikael@lilotux.net>
parents:
515
diff
changeset
|
1456 |
Log_Win_Height = DEFAULT_LOG_WIN_HEIGHT; |
701
6c100adfbfb6
Add setting "roster_width" (variable buddylist width)
Mikael Berthe <mikael@lilotux.net>
parents:
699
diff
changeset
|
1457 |
requested_size = settings_opt_get_int("log_win_height"); |
6c100adfbfb6
Add setting "roster_width" (variable buddylist width)
Mikael Berthe <mikael@lilotux.net>
parents:
699
diff
changeset
|
1458 |
if (requested_size > 0) { |
6c100adfbfb6
Add setting "roster_width" (variable buddylist width)
Mikael Berthe <mikael@lilotux.net>
parents:
699
diff
changeset
|
1459 |
if (maxY > requested_size + 3) |
6c100adfbfb6
Add setting "roster_width" (variable buddylist width)
Mikael Berthe <mikael@lilotux.net>
parents:
699
diff
changeset
|
1460 |
Log_Win_Height = requested_size + 2; |
518
9480a76471b6
Update Log_Win_Height when refreshing the screen
Mikael Berthe <mikael@lilotux.net>
parents:
515
diff
changeset
|
1461 |
else |
9480a76471b6
Update Log_Win_Height when refreshing the screen
Mikael Berthe <mikael@lilotux.net>
parents:
515
diff
changeset
|
1462 |
Log_Win_Height = ((maxY > 5) ? (maxY - 2) : 3); |
701
6c100adfbfb6
Add setting "roster_width" (variable buddylist width)
Mikael Berthe <mikael@lilotux.net>
parents:
699
diff
changeset
|
1463 |
} else if (requested_size < 0) { |
518
9480a76471b6
Update Log_Win_Height when refreshing the screen
Mikael Berthe <mikael@lilotux.net>
parents:
515
diff
changeset
|
1464 |
Log_Win_Height = 3; |
9480a76471b6
Update Log_Win_Height when refreshing the screen
Mikael Berthe <mikael@lilotux.net>
parents:
515
diff
changeset
|
1465 |
} |
9480a76471b6
Update Log_Win_Height when refreshing the screen
Mikael Berthe <mikael@lilotux.net>
parents:
515
diff
changeset
|
1466 |
|
9480a76471b6
Update Log_Win_Height when refreshing the screen
Mikael Berthe <mikael@lilotux.net>
parents:
515
diff
changeset
|
1467 |
if (maxY < Log_Win_Height+2) { |
9480a76471b6
Update Log_Win_Height when refreshing the screen
Mikael Berthe <mikael@lilotux.net>
parents:
515
diff
changeset
|
1468 |
if (maxY < 5) { |
9480a76471b6
Update Log_Win_Height when refreshing the screen
Mikael Berthe <mikael@lilotux.net>
parents:
515
diff
changeset
|
1469 |
Log_Win_Height = 3; |
9480a76471b6
Update Log_Win_Height when refreshing the screen
Mikael Berthe <mikael@lilotux.net>
parents:
515
diff
changeset
|
1470 |
maxY = Log_Win_Height+2; |
9480a76471b6
Update Log_Win_Height when refreshing the screen
Mikael Berthe <mikael@lilotux.net>
parents:
515
diff
changeset
|
1471 |
} else { |
9480a76471b6
Update Log_Win_Height when refreshing the screen
Mikael Berthe <mikael@lilotux.net>
parents:
515
diff
changeset
|
1472 |
Log_Win_Height = maxY - 2; |
9480a76471b6
Update Log_Win_Height when refreshing the screen
Mikael Berthe <mikael@lilotux.net>
parents:
515
diff
changeset
|
1473 |
} |
9480a76471b6
Update Log_Win_Height when refreshing the screen
Mikael Berthe <mikael@lilotux.net>
parents:
515
diff
changeset
|
1474 |
} |
9480a76471b6
Update Log_Win_Height when refreshing the screen
Mikael Berthe <mikael@lilotux.net>
parents:
515
diff
changeset
|
1475 |
|
707
b26a0bde4cdb
Add /roster hide|show|toggle
Mikael Berthe <mikael@lilotux.net>
parents:
701
diff
changeset
|
1476 |
if (roster_hidden) { |
b26a0bde4cdb
Add /roster hide|show|toggle
Mikael Berthe <mikael@lilotux.net>
parents:
701
diff
changeset
|
1477 |
Roster_Width = 0; |
b26a0bde4cdb
Add /roster hide|show|toggle
Mikael Berthe <mikael@lilotux.net>
parents:
701
diff
changeset
|
1478 |
} else { |
b26a0bde4cdb
Add /roster hide|show|toggle
Mikael Berthe <mikael@lilotux.net>
parents:
701
diff
changeset
|
1479 |
requested_size = settings_opt_get_int("roster_width"); |
b26a0bde4cdb
Add /roster hide|show|toggle
Mikael Berthe <mikael@lilotux.net>
parents:
701
diff
changeset
|
1480 |
if (requested_size > 1) |
b26a0bde4cdb
Add /roster hide|show|toggle
Mikael Berthe <mikael@lilotux.net>
parents:
701
diff
changeset
|
1481 |
Roster_Width = requested_size; |
b26a0bde4cdb
Add /roster hide|show|toggle
Mikael Berthe <mikael@lilotux.net>
parents:
701
diff
changeset
|
1482 |
else if (requested_size == 1) |
b26a0bde4cdb
Add /roster hide|show|toggle
Mikael Berthe <mikael@lilotux.net>
parents:
701
diff
changeset
|
1483 |
Roster_Width = 2; |
b26a0bde4cdb
Add /roster hide|show|toggle
Mikael Berthe <mikael@lilotux.net>
parents:
701
diff
changeset
|
1484 |
else |
b26a0bde4cdb
Add /roster hide|show|toggle
Mikael Berthe <mikael@lilotux.net>
parents:
701
diff
changeset
|
1485 |
Roster_Width = DEFAULT_ROSTER_WIDTH; |
b26a0bde4cdb
Add /roster hide|show|toggle
Mikael Berthe <mikael@lilotux.net>
parents:
701
diff
changeset
|
1486 |
} |
701
6c100adfbfb6
Add setting "roster_width" (variable buddylist width)
Mikael Berthe <mikael@lilotux.net>
parents:
699
diff
changeset
|
1487 |
|
972
11b632d824f6
Add option 'log_win_on_top'
Mikael Berthe <mikael@lilotux.net>
parents:
967
diff
changeset
|
1488 |
log_win_on_top = (settings_opt_get_int("log_win_on_top") == 1); |
973
e693cbe33802
Add option 'roster_win_on_right'
Mikael Berthe <mikael@lilotux.net>
parents:
972
diff
changeset
|
1489 |
roster_win_on_right = (settings_opt_get_int("roster_win_on_right") == 1); |
972
11b632d824f6
Add option 'log_win_on_top'
Mikael Berthe <mikael@lilotux.net>
parents:
967
diff
changeset
|
1490 |
|
11b632d824f6
Add option 'log_win_on_top'
Mikael Berthe <mikael@lilotux.net>
parents:
967
diff
changeset
|
1491 |
if (log_win_on_top) { |
11b632d824f6
Add option 'log_win_on_top'
Mikael Berthe <mikael@lilotux.net>
parents:
967
diff
changeset
|
1492 |
chat_y_pos = Log_Win_Height-1; |
11b632d824f6
Add option 'log_win_on_top'
Mikael Berthe <mikael@lilotux.net>
parents:
967
diff
changeset
|
1493 |
log_y_pos = 0; |
11b632d824f6
Add option 'log_win_on_top'
Mikael Berthe <mikael@lilotux.net>
parents:
967
diff
changeset
|
1494 |
chatstatus_y_pos = Log_Win_Height-2; |
11b632d824f6
Add option 'log_win_on_top'
Mikael Berthe <mikael@lilotux.net>
parents:
967
diff
changeset
|
1495 |
} else { |
11b632d824f6
Add option 'log_win_on_top'
Mikael Berthe <mikael@lilotux.net>
parents:
967
diff
changeset
|
1496 |
chat_y_pos = 0; |
11b632d824f6
Add option 'log_win_on_top'
Mikael Berthe <mikael@lilotux.net>
parents:
967
diff
changeset
|
1497 |
log_y_pos = CHAT_WIN_HEIGHT+1; |
11b632d824f6
Add option 'log_win_on_top'
Mikael Berthe <mikael@lilotux.net>
parents:
967
diff
changeset
|
1498 |
chatstatus_y_pos = CHAT_WIN_HEIGHT; |
11b632d824f6
Add option 'log_win_on_top'
Mikael Berthe <mikael@lilotux.net>
parents:
967
diff
changeset
|
1499 |
} |
11b632d824f6
Add option 'log_win_on_top'
Mikael Berthe <mikael@lilotux.net>
parents:
967
diff
changeset
|
1500 |
|
973
e693cbe33802
Add option 'roster_win_on_right'
Mikael Berthe <mikael@lilotux.net>
parents:
972
diff
changeset
|
1501 |
if (roster_win_on_right) { |
e693cbe33802
Add option 'roster_win_on_right'
Mikael Berthe <mikael@lilotux.net>
parents:
972
diff
changeset
|
1502 |
roster_x_pos = maxX - Roster_Width; |
e693cbe33802
Add option 'roster_win_on_right'
Mikael Berthe <mikael@lilotux.net>
parents:
972
diff
changeset
|
1503 |
chat_x_pos = 0; |
e693cbe33802
Add option 'roster_win_on_right'
Mikael Berthe <mikael@lilotux.net>
parents:
972
diff
changeset
|
1504 |
} else { |
e693cbe33802
Add option 'roster_win_on_right'
Mikael Berthe <mikael@lilotux.net>
parents:
972
diff
changeset
|
1505 |
roster_x_pos = 0; |
e693cbe33802
Add option 'roster_win_on_right'
Mikael Berthe <mikael@lilotux.net>
parents:
972
diff
changeset
|
1506 |
chat_x_pos = Roster_Width; |
e693cbe33802
Add option 'roster_win_on_right'
Mikael Berthe <mikael@lilotux.net>
parents:
972
diff
changeset
|
1507 |
} |
e693cbe33802
Add option 'roster_win_on_right'
Mikael Berthe <mikael@lilotux.net>
parents:
972
diff
changeset
|
1508 |
|
157 | 1509 |
if (fullinit) { |
1078
7866dbaf67a6
Use a hash for the list of win buffers
Mikael Berthe <mikael@lilotux.net>
parents:
1077
diff
changeset
|
1510 |
if (!winbufhash) |
7866dbaf67a6
Use a hash for the list of win buffers
Mikael Berthe <mikael@lilotux.net>
parents:
1077
diff
changeset
|
1511 |
winbufhash = g_hash_table_new_full(g_str_hash, g_str_equal, g_free, NULL); |
157 | 1512 |
/* Create windows */ |
973
e693cbe33802
Add option 'roster_win_on_right'
Mikael Berthe <mikael@lilotux.net>
parents:
972
diff
changeset
|
1513 |
rosterWnd = newwin(CHAT_WIN_HEIGHT, Roster_Width, chat_y_pos, roster_x_pos); |
972
11b632d824f6
Add option 'log_win_on_top'
Mikael Berthe <mikael@lilotux.net>
parents:
967
diff
changeset
|
1514 |
chatWnd = newwin(CHAT_WIN_HEIGHT, maxX - Roster_Width, chat_y_pos, |
973
e693cbe33802
Add option 'roster_win_on_right'
Mikael Berthe <mikael@lilotux.net>
parents:
972
diff
changeset
|
1515 |
chat_x_pos); |
1133
9dd28a56128f
Do not create one panel per contact
Mikael Berthe <mikael@lilotux.net>
parents:
1131
diff
changeset
|
1516 |
activechatWnd = newwin(CHAT_WIN_HEIGHT, maxX - Roster_Width, chat_y_pos, |
9dd28a56128f
Do not create one panel per contact
Mikael Berthe <mikael@lilotux.net>
parents:
1131
diff
changeset
|
1517 |
chat_x_pos); |
972
11b632d824f6
Add option 'log_win_on_top'
Mikael Berthe <mikael@lilotux.net>
parents:
967
diff
changeset
|
1518 |
logWnd = newwin(Log_Win_Height-2, maxX, log_y_pos, 0); |
11b632d824f6
Add option 'log_win_on_top'
Mikael Berthe <mikael@lilotux.net>
parents:
967
diff
changeset
|
1519 |
chatstatusWnd = newwin(1, maxX, chatstatus_y_pos, 0); |
711 | 1520 |
mainstatusWnd = newwin(1, maxX, maxY-2, 0); |
157 | 1521 |
inputWnd = newwin(1, maxX, maxY-1, 0); |
358
6e4e667c5571
Fix a segfault when starting mcabber in a really small terminal
Mikael Berthe <mikael@lilotux.net>
parents:
339
diff
changeset
|
1522 |
if (!rosterWnd || !chatWnd || !logWnd || !inputWnd) { |
1780
e4378fbab5d7
Major API cleanup - bump API to 4
Mikael Berthe <mikael@lilotux.net>
parents:
1761
diff
changeset
|
1523 |
scr_terminate_curses(); |
358
6e4e667c5571
Fix a segfault when starting mcabber in a really small terminal
Mikael Berthe <mikael@lilotux.net>
parents:
339
diff
changeset
|
1524 |
fprintf(stderr, "Cannot create windows!\n"); |
6e4e667c5571
Fix a segfault when starting mcabber in a really small terminal
Mikael Berthe <mikael@lilotux.net>
parents:
339
diff
changeset
|
1525 |
exit(EXIT_FAILURE); |
6e4e667c5571
Fix a segfault when starting mcabber in a really small terminal
Mikael Berthe <mikael@lilotux.net>
parents:
339
diff
changeset
|
1526 |
} |
739
0d5fb1d9077c
Allow "bright" text colors
Mikael Berthe <mikael@lilotux.net>
parents:
735
diff
changeset
|
1527 |
wbkgd(rosterWnd, get_color(COLOR_GENERAL)); |
0d5fb1d9077c
Allow "bright" text colors
Mikael Berthe <mikael@lilotux.net>
parents:
735
diff
changeset
|
1528 |
wbkgd(chatWnd, get_color(COLOR_GENERAL)); |
1133
9dd28a56128f
Do not create one panel per contact
Mikael Berthe <mikael@lilotux.net>
parents:
1131
diff
changeset
|
1529 |
wbkgd(activechatWnd, get_color(COLOR_GENERAL)); |
739
0d5fb1d9077c
Allow "bright" text colors
Mikael Berthe <mikael@lilotux.net>
parents:
735
diff
changeset
|
1530 |
wbkgd(logWnd, get_color(COLOR_GENERAL)); |
0d5fb1d9077c
Allow "bright" text colors
Mikael Berthe <mikael@lilotux.net>
parents:
735
diff
changeset
|
1531 |
wbkgd(chatstatusWnd, get_color(COLOR_STATUS)); |
0d5fb1d9077c
Allow "bright" text colors
Mikael Berthe <mikael@lilotux.net>
parents:
735
diff
changeset
|
1532 |
wbkgd(mainstatusWnd, get_color(COLOR_STATUS)); |
157 | 1533 |
} else { |
701
6c100adfbfb6
Add setting "roster_width" (variable buddylist width)
Mikael Berthe <mikael@lilotux.net>
parents:
699
diff
changeset
|
1534 |
/* Resize/move windows */ |
6c100adfbfb6
Add setting "roster_width" (variable buddylist width)
Mikael Berthe <mikael@lilotux.net>
parents:
699
diff
changeset
|
1535 |
wresize(rosterWnd, CHAT_WIN_HEIGHT, Roster_Width); |
6c100adfbfb6
Add setting "roster_width" (variable buddylist width)
Mikael Berthe <mikael@lilotux.net>
parents:
699
diff
changeset
|
1536 |
wresize(chatWnd, CHAT_WIN_HEIGHT, maxX - Roster_Width); |
711 | 1537 |
wresize(logWnd, Log_Win_Height-2, maxX); |
157 | 1538 |
|
973
e693cbe33802
Add option 'roster_win_on_right'
Mikael Berthe <mikael@lilotux.net>
parents:
972
diff
changeset
|
1539 |
mvwin(chatWnd, chat_y_pos, chat_x_pos); |
e693cbe33802
Add option 'roster_win_on_right'
Mikael Berthe <mikael@lilotux.net>
parents:
972
diff
changeset
|
1540 |
mvwin(rosterWnd, chat_y_pos, roster_x_pos); |
972
11b632d824f6
Add option 'log_win_on_top'
Mikael Berthe <mikael@lilotux.net>
parents:
967
diff
changeset
|
1541 |
mvwin(logWnd, log_y_pos, 0); |
157 | 1542 |
|
711 | 1543 |
// Resize & move chat status window |
1544 |
wresize(chatstatusWnd, 1, maxX); |
|
972
11b632d824f6
Add option 'log_win_on_top'
Mikael Berthe <mikael@lilotux.net>
parents:
967
diff
changeset
|
1545 |
mvwin(chatstatusWnd, chatstatus_y_pos, 0); |
711 | 1546 |
// Resize & move main status window |
1547 |
wresize(mainstatusWnd, 1, maxX); |
|
1548 |
mvwin(mainstatusWnd, maxY-2, 0); |
|
1549 |
// Resize & move input line window |
|
157 | 1550 |
wresize(inputWnd, 1, maxX); |
1551 |
mvwin(inputWnd, maxY-1, 0); |
|
168 | 1552 |
|
1553 |
werase(chatWnd); |
|
157 | 1554 |
} |
151 | 1555 |
|
1556 |
/* Draw/init windows */ |
|
1557 |
||
961
95659cf9ea1a
Display mcabber version in the status window
Mikael Berthe <mikael@lilotux.net>
parents:
952
diff
changeset
|
1558 |
ver = mcabber_version(); |
95659cf9ea1a
Display mcabber version in the status window
Mikael Berthe <mikael@lilotux.net>
parents:
952
diff
changeset
|
1559 |
message = g_strdup_printf("MCabber version %s.\n", ver); |
95659cf9ea1a
Display mcabber version in the status window
Mikael Berthe <mikael@lilotux.net>
parents:
952
diff
changeset
|
1560 |
mvwprintw(chatWnd, 0, 0, message); |
1455
bec235cd28a8
Misc. documentation updates
Mikael Berthe <mikael@lilotux.net>
parents:
1454
diff
changeset
|
1561 |
mvwprintw(chatWnd, 1, 0, "http://mcabber.com/"); |
961
95659cf9ea1a
Display mcabber version in the status window
Mikael Berthe <mikael@lilotux.net>
parents:
952
diff
changeset
|
1562 |
g_free(ver); |
95659cf9ea1a
Display mcabber version in the status window
Mikael Berthe <mikael@lilotux.net>
parents:
952
diff
changeset
|
1563 |
g_free(message); |
24 | 1564 |
|
157 | 1565 |
// Auto-scrolling in log window |
74 | 1566 |
scrollok(logWnd, TRUE); |
24 | 1567 |
|
1568 |
||
151 | 1569 |
if (fullinit) { |
157 | 1570 |
// Enable keypad (+ special keys) |
1571 |
keypad(inputWnd, TRUE); |
|
1457
3a537b4d7f8d
Fix UTF-8 on MirBSD (Thorsten Glaser)
Mikael Berthe <mikael@lilotux.net>
parents:
1455
diff
changeset
|
1572 |
#ifdef __MirBSD__ |
3a537b4d7f8d
Fix UTF-8 on MirBSD (Thorsten Glaser)
Mikael Berthe <mikael@lilotux.net>
parents:
1455
diff
changeset
|
1573 |
wtimeout(inputWnd, 50 /* ms */); |
3a537b4d7f8d
Fix UTF-8 on MirBSD (Thorsten Glaser)
Mikael Berthe <mikael@lilotux.net>
parents:
1455
diff
changeset
|
1574 |
#else |
382
4c6e8392e465
Use nodelay() instead of halfdelay()
Mikael Berthe <mikael@lilotux.net>
parents:
374
diff
changeset
|
1575 |
nodelay(inputWnd, TRUE); |
1457
3a537b4d7f8d
Fix UTF-8 on MirBSD (Thorsten Glaser)
Mikael Berthe <mikael@lilotux.net>
parents:
1455
diff
changeset
|
1576 |
#endif |
157 | 1577 |
|
151 | 1578 |
// Create panels |
1579 |
rosterPanel = new_panel(rosterWnd); |
|
1580 |
chatPanel = new_panel(chatWnd); |
|
1133
9dd28a56128f
Do not create one panel per contact
Mikael Berthe <mikael@lilotux.net>
parents:
1131
diff
changeset
|
1581 |
activechatPanel = new_panel(activechatWnd); |
151 | 1582 |
logPanel = new_panel(logWnd); |
711 | 1583 |
chatstatusPanel = new_panel(chatstatusWnd); |
1584 |
mainstatusPanel = new_panel(mainstatusWnd); |
|
151 | 1585 |
inputPanel = new_panel(inputWnd); |
232 | 1586 |
|
849
42c43a88d823
Status buffer management
Mikael Berthe <mikael@lilotux.net>
parents:
848
diff
changeset
|
1587 |
// Build the buddylist at least once, to make sure the special buffer |
42c43a88d823
Status buffer management
Mikael Berthe <mikael@lilotux.net>
parents:
848
diff
changeset
|
1588 |
// is added |
42c43a88d823
Status buffer management
Mikael Berthe <mikael@lilotux.net>
parents:
848
diff
changeset
|
1589 |
buddylist_build(); |
1093
6ca9a65df21f
Do not rewrap buffer lines when the chat window width doesn't change
Mikael Berthe <mikael@lilotux.net>
parents:
1089
diff
changeset
|
1590 |
|
6ca9a65df21f
Do not rewrap buffer lines when the chat window width doesn't change
Mikael Berthe <mikael@lilotux.net>
parents:
1089
diff
changeset
|
1591 |
// Init prev_chatwidth; this variable will be used to prevent us |
6ca9a65df21f
Do not rewrap buffer lines when the chat window width doesn't change
Mikael Berthe <mikael@lilotux.net>
parents:
1089
diff
changeset
|
1592 |
// from rewrapping buffers when the width doesn't change. |
1487 | 1593 |
prev_chatwidth = maxX - Roster_Width - scr_getprefixwidth(); |
851
da03534e46c7
Add startup log messages to the status buffer
Mikael Berthe <mikael@lilotux.net>
parents:
850
diff
changeset
|
1594 |
// Wrap existing status buffer lines |
1093
6ca9a65df21f
Do not rewrap buffer lines when the chat window width doesn't change
Mikael Berthe <mikael@lilotux.net>
parents:
1089
diff
changeset
|
1595 |
hbuf_rebuild(&statushbuf, prev_chatwidth); |
849
42c43a88d823
Status buffer management
Mikael Berthe <mikael@lilotux.net>
parents:
848
diff
changeset
|
1596 |
|
930
a75f7a13df7b
UTF-8 terminal support (Reimar Döffinger)
Mikael Berthe <mikael@lilotux.net>
parents:
929
diff
changeset
|
1597 |
#ifndef UNICODE |
232 | 1598 |
if (utf8_mode) |
930
a75f7a13df7b
UTF-8 terminal support (Reimar Döffinger)
Mikael Berthe <mikael@lilotux.net>
parents:
929
diff
changeset
|
1599 |
scr_LogPrint(LPRINT_NORMAL, |
a75f7a13df7b
UTF-8 terminal support (Reimar Döffinger)
Mikael Berthe <mikael@lilotux.net>
parents:
929
diff
changeset
|
1600 |
"WARNING: Compiled without full UTF-8 support!"); |
a75f7a13df7b
UTF-8 terminal support (Reimar Döffinger)
Mikael Berthe <mikael@lilotux.net>
parents:
929
diff
changeset
|
1601 |
#endif |
157 | 1602 |
} else { |
1603 |
// Update panels |
|
1604 |
replace_panel(rosterPanel, rosterWnd); |
|
1605 |
replace_panel(chatPanel, chatWnd); |
|
1606 |
replace_panel(logPanel, logWnd); |
|
711 | 1607 |
replace_panel(chatstatusPanel, chatstatusWnd); |
1608 |
replace_panel(mainstatusPanel, mainstatusWnd); |
|
157 | 1609 |
replace_panel(inputPanel, inputWnd); |
151 | 1610 |
} |
1611 |
||
1612 |
// We'll need to redraw the roster |
|
149 | 1613 |
update_roster = TRUE; |
24 | 1614 |
return; |
1615 |
} |
|
1616 |
||
1078
7866dbaf67a6
Use a hash for the list of win buffers
Mikael Berthe <mikael@lilotux.net>
parents:
1077
diff
changeset
|
1617 |
static void resize_win_buffer(gpointer key, gpointer value, gpointer data) |
849
42c43a88d823
Status buffer management
Mikael Berthe <mikael@lilotux.net>
parents:
848
diff
changeset
|
1618 |
{ |
1078
7866dbaf67a6
Use a hash for the list of win buffers
Mikael Berthe <mikael@lilotux.net>
parents:
1077
diff
changeset
|
1619 |
winbuf *wbp = value; |
7866dbaf67a6
Use a hash for the list of win buffers
Mikael Berthe <mikael@lilotux.net>
parents:
1077
diff
changeset
|
1620 |
struct dimensions *dim = data; |
973
e693cbe33802
Add option 'roster_win_on_right'
Mikael Berthe <mikael@lilotux.net>
parents:
972
diff
changeset
|
1621 |
int chat_x_pos, chat_y_pos; |
1093
6ca9a65df21f
Do not rewrap buffer lines when the chat window width doesn't change
Mikael Berthe <mikael@lilotux.net>
parents:
1089
diff
changeset
|
1622 |
int new_chatwidth; |
972
11b632d824f6
Add option 'log_win_on_top'
Mikael Berthe <mikael@lilotux.net>
parents:
967
diff
changeset
|
1623 |
|
1078
7866dbaf67a6
Use a hash for the list of win buffers
Mikael Berthe <mikael@lilotux.net>
parents:
1077
diff
changeset
|
1624 |
if (!(wbp && wbp->win)) |
7866dbaf67a6
Use a hash for the list of win buffers
Mikael Berthe <mikael@lilotux.net>
parents:
1077
diff
changeset
|
1625 |
return; |
7866dbaf67a6
Use a hash for the list of win buffers
Mikael Berthe <mikael@lilotux.net>
parents:
1077
diff
changeset
|
1626 |
|
972
11b632d824f6
Add option 'log_win_on_top'
Mikael Berthe <mikael@lilotux.net>
parents:
967
diff
changeset
|
1627 |
if (log_win_on_top) |
11b632d824f6
Add option 'log_win_on_top'
Mikael Berthe <mikael@lilotux.net>
parents:
967
diff
changeset
|
1628 |
chat_y_pos = Log_Win_Height-1; |
11b632d824f6
Add option 'log_win_on_top'
Mikael Berthe <mikael@lilotux.net>
parents:
967
diff
changeset
|
1629 |
else |
11b632d824f6
Add option 'log_win_on_top'
Mikael Berthe <mikael@lilotux.net>
parents:
967
diff
changeset
|
1630 |
chat_y_pos = 0; |
11b632d824f6
Add option 'log_win_on_top'
Mikael Berthe <mikael@lilotux.net>
parents:
967
diff
changeset
|
1631 |
|
973
e693cbe33802
Add option 'roster_win_on_right'
Mikael Berthe <mikael@lilotux.net>
parents:
972
diff
changeset
|
1632 |
if (roster_win_on_right) |
e693cbe33802
Add option 'roster_win_on_right'
Mikael Berthe <mikael@lilotux.net>
parents:
972
diff
changeset
|
1633 |
chat_x_pos = 0; |
e693cbe33802
Add option 'roster_win_on_right'
Mikael Berthe <mikael@lilotux.net>
parents:
972
diff
changeset
|
1634 |
else |
e693cbe33802
Add option 'roster_win_on_right'
Mikael Berthe <mikael@lilotux.net>
parents:
972
diff
changeset
|
1635 |
chat_x_pos = Roster_Width; |
e693cbe33802
Add option 'roster_win_on_right'
Mikael Berthe <mikael@lilotux.net>
parents:
972
diff
changeset
|
1636 |
|
849
42c43a88d823
Status buffer management
Mikael Berthe <mikael@lilotux.net>
parents:
848
diff
changeset
|
1637 |
// Resize/move buddy window |
1078
7866dbaf67a6
Use a hash for the list of win buffers
Mikael Berthe <mikael@lilotux.net>
parents:
1077
diff
changeset
|
1638 |
wresize(wbp->win, dim->l, dim->c); |
973
e693cbe33802
Add option 'roster_win_on_right'
Mikael Berthe <mikael@lilotux.net>
parents:
972
diff
changeset
|
1639 |
mvwin(wbp->win, chat_y_pos, chat_x_pos); |
849
42c43a88d823
Status buffer management
Mikael Berthe <mikael@lilotux.net>
parents:
848
diff
changeset
|
1640 |
werase(wbp->win); |
42c43a88d823
Status buffer management
Mikael Berthe <mikael@lilotux.net>
parents:
848
diff
changeset
|
1641 |
// If a panel exists, replace the old window with the new |
42c43a88d823
Status buffer management
Mikael Berthe <mikael@lilotux.net>
parents:
848
diff
changeset
|
1642 |
if (wbp->panel) |
42c43a88d823
Status buffer management
Mikael Berthe <mikael@lilotux.net>
parents:
848
diff
changeset
|
1643 |
replace_panel(wbp->panel, wbp->win); |
42c43a88d823
Status buffer management
Mikael Berthe <mikael@lilotux.net>
parents:
848
diff
changeset
|
1644 |
// Redo line wrapping |
1157
5c857f0f0ab8
Moved all variables related to hbuf to an extra struct, bufdata
Frank Zschockelt
parents:
1156
diff
changeset
|
1645 |
wbp->bd->top = hbuf_previous_persistent(wbp->bd->top); |
1093
6ca9a65df21f
Do not rewrap buffer lines when the chat window width doesn't change
Mikael Berthe <mikael@lilotux.net>
parents:
1089
diff
changeset
|
1646 |
|
1487 | 1647 |
new_chatwidth = maxX - Roster_Width - scr_getprefixwidth(); |
1093
6ca9a65df21f
Do not rewrap buffer lines when the chat window width doesn't change
Mikael Berthe <mikael@lilotux.net>
parents:
1089
diff
changeset
|
1648 |
if (new_chatwidth != prev_chatwidth) |
1157
5c857f0f0ab8
Moved all variables related to hbuf to an extra struct, bufdata
Frank Zschockelt
parents:
1156
diff
changeset
|
1649 |
hbuf_rebuild(&wbp->bd->hbuf, new_chatwidth); |
849
42c43a88d823
Status buffer management
Mikael Berthe <mikael@lilotux.net>
parents:
848
diff
changeset
|
1650 |
} |
42c43a88d823
Status buffer management
Mikael Berthe <mikael@lilotux.net>
parents:
848
diff
changeset
|
1651 |
|
151 | 1652 |
// scr_Resize() |
1653 |
// Function called when the window is resized. |
|
157 | 1654 |
// - Resize windows |
151 | 1655 |
// - Rewrap lines in each buddy buffer |
1059 | 1656 |
void scr_Resize(void) |
151 | 1657 |
{ |
1078
7866dbaf67a6
Use a hash for the list of win buffers
Mikael Berthe <mikael@lilotux.net>
parents:
1077
diff
changeset
|
1658 |
struct dimensions dim; |
151 | 1659 |
|
1660 |
// First, update the global variables |
|
1661 |
getmaxyx(stdscr, maxY, maxX); |
|
1780
e4378fbab5d7
Major API cleanup - bump API to 4
Mikael Berthe <mikael@lilotux.net>
parents:
1761
diff
changeset
|
1662 |
// scr_draw_main_window() will take care of maxY and Log_Win_Height |
518
9480a76471b6
Update Log_Win_Height when refreshing the screen
Mikael Berthe <mikael@lilotux.net>
parents:
515
diff
changeset
|
1663 |
|
151 | 1664 |
// Make sure the cursor stays inside the window |
1665 |
check_offset(0); |
|
1666 |
||
157 | 1667 |
// Resize windows and update panels |
1780
e4378fbab5d7
Major API cleanup - bump API to 4
Mikael Berthe <mikael@lilotux.net>
parents:
1761
diff
changeset
|
1668 |
scr_draw_main_window(FALSE); |
151 | 1669 |
|
1670 |
// Resize all buddy windows |
|
1078
7866dbaf67a6
Use a hash for the list of win buffers
Mikael Berthe <mikael@lilotux.net>
parents:
1077
diff
changeset
|
1671 |
dim.l = CHAT_WIN_HEIGHT; |
7866dbaf67a6
Use a hash for the list of win buffers
Mikael Berthe <mikael@lilotux.net>
parents:
1077
diff
changeset
|
1672 |
dim.c = maxX - Roster_Width; |
7866dbaf67a6
Use a hash for the list of win buffers
Mikael Berthe <mikael@lilotux.net>
parents:
1077
diff
changeset
|
1673 |
if (dim.c < 1) |
7866dbaf67a6
Use a hash for the list of win buffers
Mikael Berthe <mikael@lilotux.net>
parents:
1077
diff
changeset
|
1674 |
dim.c = 1; |
7866dbaf67a6
Use a hash for the list of win buffers
Mikael Berthe <mikael@lilotux.net>
parents:
1077
diff
changeset
|
1675 |
|
7866dbaf67a6
Use a hash for the list of win buffers
Mikael Berthe <mikael@lilotux.net>
parents:
1077
diff
changeset
|
1676 |
// Resize all buffers |
7866dbaf67a6
Use a hash for the list of win buffers
Mikael Berthe <mikael@lilotux.net>
parents:
1077
diff
changeset
|
1677 |
g_hash_table_foreach(winbufhash, resize_win_buffer, &dim); |
151 | 1678 |
|
849
42c43a88d823
Status buffer management
Mikael Berthe <mikael@lilotux.net>
parents:
848
diff
changeset
|
1679 |
// Resize/move special status buffer |
42c43a88d823
Status buffer management
Mikael Berthe <mikael@lilotux.net>
parents:
848
diff
changeset
|
1680 |
if (statusWindow) |
1078
7866dbaf67a6
Use a hash for the list of win buffers
Mikael Berthe <mikael@lilotux.net>
parents:
1077
diff
changeset
|
1681 |
resize_win_buffer(NULL, statusWindow, &dim); |
849
42c43a88d823
Status buffer management
Mikael Berthe <mikael@lilotux.net>
parents:
848
diff
changeset
|
1682 |
|
1093
6ca9a65df21f
Do not rewrap buffer lines when the chat window width doesn't change
Mikael Berthe <mikael@lilotux.net>
parents:
1089
diff
changeset
|
1683 |
// Update prev_chatwidth, now that all buffers have been resized |
1487 | 1684 |
prev_chatwidth = maxX - Roster_Width - scr_getprefixwidth(); |
1093
6ca9a65df21f
Do not rewrap buffer lines when the chat window width doesn't change
Mikael Berthe <mikael@lilotux.net>
parents:
1089
diff
changeset
|
1685 |
|
151 | 1686 |
// Refresh current buddy window |
157 | 1687 |
if (chatmode) |
1780
e4378fbab5d7
Major API cleanup - bump API to 4
Mikael Berthe <mikael@lilotux.net>
parents:
1761
diff
changeset
|
1688 |
scr_show_buddy_window(); |
151 | 1689 |
} |
1690 |
||
1780
e4378fbab5d7
Major API cleanup - bump API to 4
Mikael Berthe <mikael@lilotux.net>
parents:
1761
diff
changeset
|
1691 |
// scr_update_chat_status(forceupdate) |
713 | 1692 |
// Redraw the buddy status bar. |
939
12fa2ae6445d
Get rid of "busy-waiting" (Christof Meerwald)
Mikael Berthe <mikael@lilotux.net>
parents:
936
diff
changeset
|
1693 |
// Set forceupdate to TRUE if update_panels() must be called. |
1780
e4378fbab5d7
Major API cleanup - bump API to 4
Mikael Berthe <mikael@lilotux.net>
parents:
1761
diff
changeset
|
1694 |
void scr_update_chat_status(int forceupdate) |
713 | 1695 |
{ |
848
a9161d2dc414
Introduce special buffer stuff
Mikael Berthe <mikael@lilotux.net>
parents:
843
diff
changeset
|
1696 |
unsigned short btype, isgrp, ismuc, isspe; |
1502
50dbbca69b55
Small style improvement of buddy status line
Maxim Vuets <maxim.vuets@gmail.com>
parents:
1489
diff
changeset
|
1697 |
const char *btypetext = "Unknown"; |
717
8ce2bfdc4143
Reindent update_chat_status_window()
Mikael Berthe <mikael@lilotux.net>
parents:
716
diff
changeset
|
1698 |
const char *fullname; |
8ce2bfdc4143
Reindent update_chat_status_window()
Mikael Berthe <mikael@lilotux.net>
parents:
716
diff
changeset
|
1699 |
const char *msg = NULL; |
8ce2bfdc4143
Reindent update_chat_status_window()
Mikael Berthe <mikael@lilotux.net>
parents:
716
diff
changeset
|
1700 |
char status; |
773
e25b8a348ebd
Screen updating functions use UTF-8
Mikael Berthe <mikael@lilotux.net>
parents:
772
diff
changeset
|
1701 |
char *buf, *buf_locale; |
713 | 1702 |
|
718
b41799901abd
Add a new_message flag (#) in the main status line
Mikael Berthe <mikael@lilotux.net>
parents:
717
diff
changeset
|
1703 |
// Usually we need to update the bottom status line too, |
b41799901abd
Add a new_message flag (#) in the main status line
Mikael Berthe <mikael@lilotux.net>
parents:
717
diff
changeset
|
1704 |
// at least to refresh the pending message flag. |
1780
e4378fbab5d7
Major API cleanup - bump API to 4
Mikael Berthe <mikael@lilotux.net>
parents:
1761
diff
changeset
|
1705 |
scr_update_main_status(FALSE); |
718
b41799901abd
Add a new_message flag (#) in the main status line
Mikael Berthe <mikael@lilotux.net>
parents:
717
diff
changeset
|
1706 |
|
806
3521e34f722a
Fix a segfault when not connected to a server
Mikael Berthe <mikael@lilotux.net>
parents:
797
diff
changeset
|
1707 |
// Clear the line |
3521e34f722a
Fix a segfault when not connected to a server
Mikael Berthe <mikael@lilotux.net>
parents:
797
diff
changeset
|
1708 |
werase(chatstatusWnd); |
3521e34f722a
Fix a segfault when not connected to a server
Mikael Berthe <mikael@lilotux.net>
parents:
797
diff
changeset
|
1709 |
|
3521e34f722a
Fix a segfault when not connected to a server
Mikael Berthe <mikael@lilotux.net>
parents:
797
diff
changeset
|
1710 |
if (!current_buddy) { |
3521e34f722a
Fix a segfault when not connected to a server
Mikael Berthe <mikael@lilotux.net>
parents:
797
diff
changeset
|
1711 |
if (forceupdate) { |
3521e34f722a
Fix a segfault when not connected to a server
Mikael Berthe <mikael@lilotux.net>
parents:
797
diff
changeset
|
1712 |
update_panels(); |
3521e34f722a
Fix a segfault when not connected to a server
Mikael Berthe <mikael@lilotux.net>
parents:
797
diff
changeset
|
1713 |
} |
3521e34f722a
Fix a segfault when not connected to a server
Mikael Berthe <mikael@lilotux.net>
parents:
797
diff
changeset
|
1714 |
return; |
3521e34f722a
Fix a segfault when not connected to a server
Mikael Berthe <mikael@lilotux.net>
parents:
797
diff
changeset
|
1715 |
} |
3521e34f722a
Fix a segfault when not connected to a server
Mikael Berthe <mikael@lilotux.net>
parents:
797
diff
changeset
|
1716 |
|
717
8ce2bfdc4143
Reindent update_chat_status_window()
Mikael Berthe <mikael@lilotux.net>
parents:
716
diff
changeset
|
1717 |
fullname = buddy_getname(BUDDATA(current_buddy)); |
8ce2bfdc4143
Reindent update_chat_status_window()
Mikael Berthe <mikael@lilotux.net>
parents:
716
diff
changeset
|
1718 |
btype = buddy_gettype(BUDDATA(current_buddy)); |
713 | 1719 |
|
1502
50dbbca69b55
Small style improvement of buddy status line
Maxim Vuets <maxim.vuets@gmail.com>
parents:
1489
diff
changeset
|
1720 |
isgrp = ismuc = isspe = 0; |
50dbbca69b55
Small style improvement of buddy status line
Maxim Vuets <maxim.vuets@gmail.com>
parents:
1489
diff
changeset
|
1721 |
if (btype & ROSTER_TYPE_USER) { |
50dbbca69b55
Small style improvement of buddy status line
Maxim Vuets <maxim.vuets@gmail.com>
parents:
1489
diff
changeset
|
1722 |
btypetext = "Buddy"; |
50dbbca69b55
Small style improvement of buddy status line
Maxim Vuets <maxim.vuets@gmail.com>
parents:
1489
diff
changeset
|
1723 |
} else if (btype & ROSTER_TYPE_GROUP) { |
50dbbca69b55
Small style improvement of buddy status line
Maxim Vuets <maxim.vuets@gmail.com>
parents:
1489
diff
changeset
|
1724 |
btypetext = "Group"; |
50dbbca69b55
Small style improvement of buddy status line
Maxim Vuets <maxim.vuets@gmail.com>
parents:
1489
diff
changeset
|
1725 |
isgrp = 1; |
50dbbca69b55
Small style improvement of buddy status line
Maxim Vuets <maxim.vuets@gmail.com>
parents:
1489
diff
changeset
|
1726 |
} else if (btype & ROSTER_TYPE_AGENT) { |
50dbbca69b55
Small style improvement of buddy status line
Maxim Vuets <maxim.vuets@gmail.com>
parents:
1489
diff
changeset
|
1727 |
btypetext = "Agent"; |
50dbbca69b55
Small style improvement of buddy status line
Maxim Vuets <maxim.vuets@gmail.com>
parents:
1489
diff
changeset
|
1728 |
} else if (btype & ROSTER_TYPE_ROOM) { |
50dbbca69b55
Small style improvement of buddy status line
Maxim Vuets <maxim.vuets@gmail.com>
parents:
1489
diff
changeset
|
1729 |
btypetext = "Room"; |
50dbbca69b55
Small style improvement of buddy status line
Maxim Vuets <maxim.vuets@gmail.com>
parents:
1489
diff
changeset
|
1730 |
ismuc = 1; |
50dbbca69b55
Small style improvement of buddy status line
Maxim Vuets <maxim.vuets@gmail.com>
parents:
1489
diff
changeset
|
1731 |
} else if (btype & ROSTER_TYPE_SPECIAL) { |
50dbbca69b55
Small style improvement of buddy status line
Maxim Vuets <maxim.vuets@gmail.com>
parents:
1489
diff
changeset
|
1732 |
btypetext = "Special buffer"; |
50dbbca69b55
Small style improvement of buddy status line
Maxim Vuets <maxim.vuets@gmail.com>
parents:
1489
diff
changeset
|
1733 |
isspe = 1; |
50dbbca69b55
Small style improvement of buddy status line
Maxim Vuets <maxim.vuets@gmail.com>
parents:
1489
diff
changeset
|
1734 |
} |
713 | 1735 |
|
1513
9d78b571e693
Show '#' for unread message per buddy on the buddy status line
Maxim Vuets <maxim.vuets@gmail.com>
parents:
1511
diff
changeset
|
1736 |
if (chatmode) { |
9d78b571e693
Show '#' for unread message per buddy on the buddy status line
Maxim Vuets <maxim.vuets@gmail.com>
parents:
1511
diff
changeset
|
1737 |
wprintw(chatstatusWnd, "~"); |
9d78b571e693
Show '#' for unread message per buddy on the buddy status line
Maxim Vuets <maxim.vuets@gmail.com>
parents:
1511
diff
changeset
|
1738 |
} else { |
9d78b571e693
Show '#' for unread message per buddy on the buddy status line
Maxim Vuets <maxim.vuets@gmail.com>
parents:
1511
diff
changeset
|
1739 |
unsigned short bflags = buddy_getflags(BUDDATA(current_buddy)); |
9d78b571e693
Show '#' for unread message per buddy on the buddy status line
Maxim Vuets <maxim.vuets@gmail.com>
parents:
1511
diff
changeset
|
1740 |
if (bflags & ROSTER_FLAG_MSG) { |
9d78b571e693
Show '#' for unread message per buddy on the buddy status line
Maxim Vuets <maxim.vuets@gmail.com>
parents:
1511
diff
changeset
|
1741 |
// There is an unread message from the current buddy |
9d78b571e693
Show '#' for unread message per buddy on the buddy status line
Maxim Vuets <maxim.vuets@gmail.com>
parents:
1511
diff
changeset
|
1742 |
wprintw(chatstatusWnd, "#"); |
9d78b571e693
Show '#' for unread message per buddy on the buddy status line
Maxim Vuets <maxim.vuets@gmail.com>
parents:
1511
diff
changeset
|
1743 |
} |
9d78b571e693
Show '#' for unread message per buddy on the buddy status line
Maxim Vuets <maxim.vuets@gmail.com>
parents:
1511
diff
changeset
|
1744 |
} |
9d78b571e693
Show '#' for unread message per buddy on the buddy status line
Maxim Vuets <maxim.vuets@gmail.com>
parents:
1511
diff
changeset
|
1745 |
|
874
293e8955075c
Display a flag in the chat status line when the buffer is locked
Mikael Berthe <mikael@lilotux.net>
parents:
873
diff
changeset
|
1746 |
if (chatmode && !isgrp) { |
293e8955075c
Display a flag in the chat status line when the buffer is locked
Mikael Berthe <mikael@lilotux.net>
parents:
873
diff
changeset
|
1747 |
winbuf *win_entry; |
1780
e4378fbab5d7
Major API cleanup - bump API to 4
Mikael Berthe <mikael@lilotux.net>
parents:
1761
diff
changeset
|
1748 |
win_entry = scr_search_window(buddy_getjid(BUDDATA(current_buddy)), isspe); |
1157
5c857f0f0ab8
Moved all variables related to hbuf to an extra struct, bufdata
Frank Zschockelt
parents:
1156
diff
changeset
|
1749 |
if (win_entry && win_entry->bd->lock) |
874
293e8955075c
Display a flag in the chat status line when the buffer is locked
Mikael Berthe <mikael@lilotux.net>
parents:
873
diff
changeset
|
1750 |
mvwprintw(chatstatusWnd, 0, 0, "*"); |
293e8955075c
Display a flag in the chat status line when the buffer is locked
Mikael Berthe <mikael@lilotux.net>
parents:
873
diff
changeset
|
1751 |
} |
293e8955075c
Display a flag in the chat status line when the buffer is locked
Mikael Berthe <mikael@lilotux.net>
parents:
873
diff
changeset
|
1752 |
|
848
a9161d2dc414
Introduce special buffer stuff
Mikael Berthe <mikael@lilotux.net>
parents:
843
diff
changeset
|
1753 |
if (isgrp || isspe) { |
773
e25b8a348ebd
Screen updating functions use UTF-8
Mikael Berthe <mikael@lilotux.net>
parents:
772
diff
changeset
|
1754 |
buf_locale = from_utf8(fullname); |
1502
50dbbca69b55
Small style improvement of buddy status line
Maxim Vuets <maxim.vuets@gmail.com>
parents:
1489
diff
changeset
|
1755 |
mvwprintw(chatstatusWnd, 0, 5, "%s: %s", btypetext, buf_locale); |
773
e25b8a348ebd
Screen updating functions use UTF-8
Mikael Berthe <mikael@lilotux.net>
parents:
772
diff
changeset
|
1756 |
g_free(buf_locale); |
716
ba1137a01078
Add a chatmode flag (©) in the chat status line
Mikael Berthe <mikael@lilotux.net>
parents:
715
diff
changeset
|
1757 |
if (forceupdate) { |
ba1137a01078
Add a chatmode flag (©) in the chat status line
Mikael Berthe <mikael@lilotux.net>
parents:
715
diff
changeset
|
1758 |
update_panels(); |
ba1137a01078
Add a chatmode flag (©) in the chat status line
Mikael Berthe <mikael@lilotux.net>
parents:
715
diff
changeset
|
1759 |
} |
717
8ce2bfdc4143
Reindent update_chat_status_window()
Mikael Berthe <mikael@lilotux.net>
parents:
716
diff
changeset
|
1760 |
return; |
8ce2bfdc4143
Reindent update_chat_status_window()
Mikael Berthe <mikael@lilotux.net>
parents:
716
diff
changeset
|
1761 |
} |
8ce2bfdc4143
Reindent update_chat_status_window()
Mikael Berthe <mikael@lilotux.net>
parents:
716
diff
changeset
|
1762 |
|
8ce2bfdc4143
Reindent update_chat_status_window()
Mikael Berthe <mikael@lilotux.net>
parents:
716
diff
changeset
|
1763 |
status = '?'; |
8ce2bfdc4143
Reindent update_chat_status_window()
Mikael Berthe <mikael@lilotux.net>
parents:
716
diff
changeset
|
1764 |
|
8ce2bfdc4143
Reindent update_chat_status_window()
Mikael Berthe <mikael@lilotux.net>
parents:
716
diff
changeset
|
1765 |
if (ismuc) { |
8ce2bfdc4143
Reindent update_chat_status_window()
Mikael Berthe <mikael@lilotux.net>
parents:
716
diff
changeset
|
1766 |
if (buddy_getinsideroom(BUDDATA(current_buddy))) |
8ce2bfdc4143
Reindent update_chat_status_window()
Mikael Berthe <mikael@lilotux.net>
parents:
716
diff
changeset
|
1767 |
status = 'C'; |
8ce2bfdc4143
Reindent update_chat_status_window()
Mikael Berthe <mikael@lilotux.net>
parents:
716
diff
changeset
|
1768 |
else |
8ce2bfdc4143
Reindent update_chat_status_window()
Mikael Berthe <mikael@lilotux.net>
parents:
716
diff
changeset
|
1769 |
status = 'x'; |
1598 | 1770 |
} else if (xmpp_getstatus() != offline) { |
717
8ce2bfdc4143
Reindent update_chat_status_window()
Mikael Berthe <mikael@lilotux.net>
parents:
716
diff
changeset
|
1771 |
enum imstatus budstate; |
8ce2bfdc4143
Reindent update_chat_status_window()
Mikael Berthe <mikael@lilotux.net>
parents:
716
diff
changeset
|
1772 |
budstate = buddy_getstatus(BUDDATA(current_buddy), NULL); |
790
5d4ad1d77da4
Kill a few gcc4 warnings
Mikael Berthe <mikael@lilotux.net>
parents:
785
diff
changeset
|
1773 |
if (budstate < imstatus_size) |
717
8ce2bfdc4143
Reindent update_chat_status_window()
Mikael Berthe <mikael@lilotux.net>
parents:
716
diff
changeset
|
1774 |
status = imstatus2char[budstate]; |
8ce2bfdc4143
Reindent update_chat_status_window()
Mikael Berthe <mikael@lilotux.net>
parents:
716
diff
changeset
|
1775 |
} |
8ce2bfdc4143
Reindent update_chat_status_window()
Mikael Berthe <mikael@lilotux.net>
parents:
716
diff
changeset
|
1776 |
|
1502
50dbbca69b55
Small style improvement of buddy status line
Maxim Vuets <maxim.vuets@gmail.com>
parents:
1489
diff
changeset
|
1777 |
// No status message for MUC rooms |
50dbbca69b55
Small style improvement of buddy status line
Maxim Vuets <maxim.vuets@gmail.com>
parents:
1489
diff
changeset
|
1778 |
if (!ismuc) { |
1522
5ef122b2bb75
Use the status string of the most likely resource in the chat status bar
Mikael Berthe <mikael@lilotux.net>
parents:
1521
diff
changeset
|
1779 |
GSList *resources, *p_res, *p_next_res; |
1072
2a3cfb98bd5e
Fix memory leaks after calls to buddy_getresources()
Mikael Berthe <mikael@lilotux.net>
parents:
1059
diff
changeset
|
1780 |
resources = buddy_getresources(BUDDATA(current_buddy)); |
1522
5ef122b2bb75
Use the status string of the most likely resource in the chat status bar
Mikael Berthe <mikael@lilotux.net>
parents:
1521
diff
changeset
|
1781 |
|
5ef122b2bb75
Use the status string of the most likely resource in the chat status bar
Mikael Berthe <mikael@lilotux.net>
parents:
1521
diff
changeset
|
1782 |
for (p_res = resources ; p_res ; p_res = p_next_res) { |
5ef122b2bb75
Use the status string of the most likely resource in the chat status bar
Mikael Berthe <mikael@lilotux.net>
parents:
1521
diff
changeset
|
1783 |
p_next_res = g_slist_next(p_res); |
5ef122b2bb75
Use the status string of the most likely resource in the chat status bar
Mikael Berthe <mikael@lilotux.net>
parents:
1521
diff
changeset
|
1784 |
// Store the status message of the latest resource (highest priority) |
5ef122b2bb75
Use the status string of the most likely resource in the chat status bar
Mikael Berthe <mikael@lilotux.net>
parents:
1521
diff
changeset
|
1785 |
if (!p_next_res) |
5ef122b2bb75
Use the status string of the most likely resource in the chat status bar
Mikael Berthe <mikael@lilotux.net>
parents:
1521
diff
changeset
|
1786 |
msg = buddy_getstatusmsg(BUDDATA(current_buddy), p_res->data); |
1072
2a3cfb98bd5e
Fix memory leaks after calls to buddy_getresources()
Mikael Berthe <mikael@lilotux.net>
parents:
1059
diff
changeset
|
1787 |
g_free(p_res->data); |
1522
5ef122b2bb75
Use the status string of the most likely resource in the chat status bar
Mikael Berthe <mikael@lilotux.net>
parents:
1521
diff
changeset
|
1788 |
} |
1072
2a3cfb98bd5e
Fix memory leaks after calls to buddy_getresources()
Mikael Berthe <mikael@lilotux.net>
parents:
1059
diff
changeset
|
1789 |
g_slist_free(resources); |
1502
50dbbca69b55
Small style improvement of buddy status line
Maxim Vuets <maxim.vuets@gmail.com>
parents:
1489
diff
changeset
|
1790 |
} else { |
721
9cf31c9b1dc4
Use room topic as a description in the chat status line
Mikael Berthe <mikael@lilotux.net>
parents:
720
diff
changeset
|
1791 |
msg = buddy_gettopic(BUDDATA(current_buddy)); |
717
8ce2bfdc4143
Reindent update_chat_status_window()
Mikael Berthe <mikael@lilotux.net>
parents:
716
diff
changeset
|
1792 |
} |
1502
50dbbca69b55
Small style improvement of buddy status line
Maxim Vuets <maxim.vuets@gmail.com>
parents:
1489
diff
changeset
|
1793 |
|
50dbbca69b55
Small style improvement of buddy status line
Maxim Vuets <maxim.vuets@gmail.com>
parents:
1489
diff
changeset
|
1794 |
if (msg) |
50dbbca69b55
Small style improvement of buddy status line
Maxim Vuets <maxim.vuets@gmail.com>
parents:
1489
diff
changeset
|
1795 |
buf = g_strdup_printf("[%c] %s: %s -- %s", status, btypetext, fullname, msg); |
50dbbca69b55
Small style improvement of buddy status line
Maxim Vuets <maxim.vuets@gmail.com>
parents:
1489
diff
changeset
|
1796 |
else |
50dbbca69b55
Small style improvement of buddy status line
Maxim Vuets <maxim.vuets@gmail.com>
parents:
1489
diff
changeset
|
1797 |
buf = g_strdup_printf("[%c] %s: %s", status, btypetext, fullname); |
717
8ce2bfdc4143
Reindent update_chat_status_window()
Mikael Berthe <mikael@lilotux.net>
parents:
716
diff
changeset
|
1798 |
replace_nl_with_dots(buf); |
773
e25b8a348ebd
Screen updating functions use UTF-8
Mikael Berthe <mikael@lilotux.net>
parents:
772
diff
changeset
|
1799 |
buf_locale = from_utf8(buf); |
e25b8a348ebd
Screen updating functions use UTF-8
Mikael Berthe <mikael@lilotux.net>
parents:
772
diff
changeset
|
1800 |
mvwprintw(chatstatusWnd, 0, 1, "%s", buf_locale); |
e25b8a348ebd
Screen updating functions use UTF-8
Mikael Berthe <mikael@lilotux.net>
parents:
772
diff
changeset
|
1801 |
g_free(buf_locale); |
717
8ce2bfdc4143
Reindent update_chat_status_window()
Mikael Berthe <mikael@lilotux.net>
parents:
716
diff
changeset
|
1802 |
g_free(buf); |
8ce2bfdc4143
Reindent update_chat_status_window()
Mikael Berthe <mikael@lilotux.net>
parents:
716
diff
changeset
|
1803 |
|
996
f4d6570e2628
Chatstates: display contact chatstate in the chat status bar
Mikael Berthe <mikael@lilotux.net>
parents:
993
diff
changeset
|
1804 |
// Display chatstates of the contact, if available. |
f4d6570e2628
Chatstates: display contact chatstate in the chat status bar
Mikael Berthe <mikael@lilotux.net>
parents:
993
diff
changeset
|
1805 |
if (btype & ROSTER_TYPE_USER) { |
f4d6570e2628
Chatstates: display contact chatstate in the chat status bar
Mikael Berthe <mikael@lilotux.net>
parents:
993
diff
changeset
|
1806 |
char eventchar = 0; |
f4d6570e2628
Chatstates: display contact chatstate in the chat status bar
Mikael Berthe <mikael@lilotux.net>
parents:
993
diff
changeset
|
1807 |
guint event; |
f4d6570e2628
Chatstates: display contact chatstate in the chat status bar
Mikael Berthe <mikael@lilotux.net>
parents:
993
diff
changeset
|
1808 |
|
f4d6570e2628
Chatstates: display contact chatstate in the chat status bar
Mikael Berthe <mikael@lilotux.net>
parents:
993
diff
changeset
|
1809 |
// We do not specify the resource here, so one of the resources with the |
f4d6570e2628
Chatstates: display contact chatstate in the chat status bar
Mikael Berthe <mikael@lilotux.net>
parents:
993
diff
changeset
|
1810 |
// highest priority will be used. |
f4d6570e2628
Chatstates: display contact chatstate in the chat status bar
Mikael Berthe <mikael@lilotux.net>
parents:
993
diff
changeset
|
1811 |
event = buddy_resource_getevents(BUDDATA(current_buddy), NULL); |
f4d6570e2628
Chatstates: display contact chatstate in the chat status bar
Mikael Berthe <mikael@lilotux.net>
parents:
993
diff
changeset
|
1812 |
|
f4d6570e2628
Chatstates: display contact chatstate in the chat status bar
Mikael Berthe <mikael@lilotux.net>
parents:
993
diff
changeset
|
1813 |
if (event == ROSTER_EVENT_ACTIVE) |
f4d6570e2628
Chatstates: display contact chatstate in the chat status bar
Mikael Berthe <mikael@lilotux.net>
parents:
993
diff
changeset
|
1814 |
eventchar = 'A'; |
f4d6570e2628
Chatstates: display contact chatstate in the chat status bar
Mikael Berthe <mikael@lilotux.net>
parents:
993
diff
changeset
|
1815 |
else if (event == ROSTER_EVENT_COMPOSING) |
f4d6570e2628
Chatstates: display contact chatstate in the chat status bar
Mikael Berthe <mikael@lilotux.net>
parents:
993
diff
changeset
|
1816 |
eventchar = 'C'; |
f4d6570e2628
Chatstates: display contact chatstate in the chat status bar
Mikael Berthe <mikael@lilotux.net>
parents:
993
diff
changeset
|
1817 |
else if (event == ROSTER_EVENT_PAUSED) |
f4d6570e2628
Chatstates: display contact chatstate in the chat status bar
Mikael Berthe <mikael@lilotux.net>
parents:
993
diff
changeset
|
1818 |
eventchar = 'P'; |
f4d6570e2628
Chatstates: display contact chatstate in the chat status bar
Mikael Berthe <mikael@lilotux.net>
parents:
993
diff
changeset
|
1819 |
else if (event == ROSTER_EVENT_INACTIVE) |
f4d6570e2628
Chatstates: display contact chatstate in the chat status bar
Mikael Berthe <mikael@lilotux.net>
parents:
993
diff
changeset
|
1820 |
eventchar = 'I'; |
f4d6570e2628
Chatstates: display contact chatstate in the chat status bar
Mikael Berthe <mikael@lilotux.net>
parents:
993
diff
changeset
|
1821 |
else if (event == ROSTER_EVENT_GONE) |
f4d6570e2628
Chatstates: display contact chatstate in the chat status bar
Mikael Berthe <mikael@lilotux.net>
parents:
993
diff
changeset
|
1822 |
eventchar = 'G'; |
f4d6570e2628
Chatstates: display contact chatstate in the chat status bar
Mikael Berthe <mikael@lilotux.net>
parents:
993
diff
changeset
|
1823 |
|
f4d6570e2628
Chatstates: display contact chatstate in the chat status bar
Mikael Berthe <mikael@lilotux.net>
parents:
993
diff
changeset
|
1824 |
if (eventchar) |
f4d6570e2628
Chatstates: display contact chatstate in the chat status bar
Mikael Berthe <mikael@lilotux.net>
parents:
993
diff
changeset
|
1825 |
mvwprintw(chatstatusWnd, 0, maxX-3, "[%c]", eventchar); |
f4d6570e2628
Chatstates: display contact chatstate in the chat status bar
Mikael Berthe <mikael@lilotux.net>
parents:
993
diff
changeset
|
1826 |
} |
f4d6570e2628
Chatstates: display contact chatstate in the chat status bar
Mikael Berthe <mikael@lilotux.net>
parents:
993
diff
changeset
|
1827 |
|
f4d6570e2628
Chatstates: display contact chatstate in the chat status bar
Mikael Berthe <mikael@lilotux.net>
parents:
993
diff
changeset
|
1828 |
|
717
8ce2bfdc4143
Reindent update_chat_status_window()
Mikael Berthe <mikael@lilotux.net>
parents:
716
diff
changeset
|
1829 |
if (forceupdate) { |
8ce2bfdc4143
Reindent update_chat_status_window()
Mikael Berthe <mikael@lilotux.net>
parents:
716
diff
changeset
|
1830 |
update_panels(); |
8ce2bfdc4143
Reindent update_chat_status_window()
Mikael Berthe <mikael@lilotux.net>
parents:
716
diff
changeset
|
1831 |
} |
713 | 1832 |
} |
1833 |
||
1504
9fafea381eb8
Show the number of unfiltered contacts in folded groups
franky
parents:
1503
diff
changeset
|
1834 |
void increment_if_buddy_not_filtered(gpointer rosterdata, void *param) |
9fafea381eb8
Show the number of unfiltered contacts in folded groups
franky
parents:
1503
diff
changeset
|
1835 |
{ |
9fafea381eb8
Show the number of unfiltered contacts in folded groups
franky
parents:
1503
diff
changeset
|
1836 |
int *p = param; |
9fafea381eb8
Show the number of unfiltered contacts in folded groups
franky
parents:
1503
diff
changeset
|
1837 |
if (buddylist_is_status_filtered(buddy_getstatus(rosterdata, NULL))) |
9fafea381eb8
Show the number of unfiltered contacts in folded groups
franky
parents:
1503
diff
changeset
|
1838 |
*p=*p+1; |
9fafea381eb8
Show the number of unfiltered contacts in folded groups
franky
parents:
1503
diff
changeset
|
1839 |
} |
9fafea381eb8
Show the number of unfiltered contacts in folded groups
franky
parents:
1503
diff
changeset
|
1840 |
|
1780
e4378fbab5d7
Major API cleanup - bump API to 4
Mikael Berthe <mikael@lilotux.net>
parents:
1761
diff
changeset
|
1841 |
// scr_draw_roster() |
328
83d129adde03
Add set_current_buddy() function, to reduce code duplication
Mikael Berthe <mikael@lilotux.net>
parents:
325
diff
changeset
|
1842 |
// Display the buddylist (not really the roster) on the screen |
1780
e4378fbab5d7
Major API cleanup - bump API to 4
Mikael Berthe <mikael@lilotux.net>
parents:
1761
diff
changeset
|
1843 |
void scr_draw_roster(void) |
24 | 1844 |
{ |
735 | 1845 |
static int offset = 0; |
701
6c100adfbfb6
Add setting "roster_width" (variable buddylist width)
Mikael Berthe <mikael@lilotux.net>
parents:
699
diff
changeset
|
1846 |
char *name, *rline; |
81 | 1847 |
int maxx, maxy; |
1848 |
GList *buddy; |
|
1849 |
int i, n; |
|
1850 |
int rOffset; |
|
713 | 1851 |
int cursor_backup; |
1852 |
char status, pending; |
|
1598 | 1853 |
enum imstatus currentstatus = xmpp_getstatus(); |
973
e693cbe33802
Add option 'roster_win_on_right'
Mikael Berthe <mikael@lilotux.net>
parents:
972
diff
changeset
|
1854 |
int x_pos; |
81 | 1855 |
|
123 | 1856 |
// We can reset update_roster |
1857 |
update_roster = FALSE; |
|
1858 |
||
81 | 1859 |
getmaxyx(rosterWnd, maxy, maxx); |
701
6c100adfbfb6
Add setting "roster_width" (variable buddylist width)
Mikael Berthe <mikael@lilotux.net>
parents:
699
diff
changeset
|
1860 |
maxx--; // Last char is for vertical border |
81 | 1861 |
|
713 | 1862 |
cursor_backup = curs_set(0); |
1863 |
||
724
264375fe7159
Fix a roster refresh issue
Mikael Berthe <mikael@lilotux.net>
parents:
723
diff
changeset
|
1864 |
if (!buddylist) |
264375fe7159
Fix a roster refresh issue
Mikael Berthe <mikael@lilotux.net>
parents:
723
diff
changeset
|
1865 |
offset = 0; |
264375fe7159
Fix a roster refresh issue
Mikael Berthe <mikael@lilotux.net>
parents:
723
diff
changeset
|
1866 |
else |
1780
e4378fbab5d7
Major API cleanup - bump API to 4
Mikael Berthe <mikael@lilotux.net>
parents:
1761
diff
changeset
|
1867 |
scr_update_chat_status(FALSE); |
724
264375fe7159
Fix a roster refresh issue
Mikael Berthe <mikael@lilotux.net>
parents:
723
diff
changeset
|
1868 |
|
701
6c100adfbfb6
Add setting "roster_width" (variable buddylist width)
Mikael Berthe <mikael@lilotux.net>
parents:
699
diff
changeset
|
1869 |
// Cleanup of roster window |
168 | 1870 |
werase(rosterWnd); |
81 | 1871 |
|
707
b26a0bde4cdb
Add /roster hide|show|toggle
Mikael Berthe <mikael@lilotux.net>
parents:
701
diff
changeset
|
1872 |
if (Roster_Width) { |
973
e693cbe33802
Add option 'roster_win_on_right'
Mikael Berthe <mikael@lilotux.net>
parents:
972
diff
changeset
|
1873 |
int line_x_pos = roster_win_on_right ? 0 : Roster_Width-1; |
707
b26a0bde4cdb
Add /roster hide|show|toggle
Mikael Berthe <mikael@lilotux.net>
parents:
701
diff
changeset
|
1874 |
// Redraw the vertical line (not very good...) |
739
0d5fb1d9077c
Allow "bright" text colors
Mikael Berthe <mikael@lilotux.net>
parents:
735
diff
changeset
|
1875 |
wattrset(rosterWnd, get_color(COLOR_GENERAL)); |
707
b26a0bde4cdb
Add /roster hide|show|toggle
Mikael Berthe <mikael@lilotux.net>
parents:
701
diff
changeset
|
1876 |
for (i=0 ; i < CHAT_WIN_HEIGHT ; i++) |
973
e693cbe33802
Add option 'roster_win_on_right'
Mikael Berthe <mikael@lilotux.net>
parents:
972
diff
changeset
|
1877 |
mvwaddch(rosterWnd, i, line_x_pos, ACS_VLINE); |
707
b26a0bde4cdb
Add /roster hide|show|toggle
Mikael Berthe <mikael@lilotux.net>
parents:
701
diff
changeset
|
1878 |
} |
b26a0bde4cdb
Add /roster hide|show|toggle
Mikael Berthe <mikael@lilotux.net>
parents:
701
diff
changeset
|
1879 |
|
b26a0bde4cdb
Add /roster hide|show|toggle
Mikael Berthe <mikael@lilotux.net>
parents:
701
diff
changeset
|
1880 |
// Leave now if buddylist is empty or the roster is hidden |
b26a0bde4cdb
Add /roster hide|show|toggle
Mikael Berthe <mikael@lilotux.net>
parents:
701
diff
changeset
|
1881 |
if (!buddylist || !Roster_Width) { |
123 | 1882 |
update_panels(); |
713 | 1883 |
curs_set(cursor_backup); |
81 | 1884 |
return; |
1885 |
} |
|
1886 |
||
84 | 1887 |
// Update offset if necessary |
680
1f8987e0e56c
Try to display as many buddylist items as possible
Mikael Berthe <mikael@lilotux.net>
parents:
679
diff
changeset
|
1888 |
// a) Try to show as many buddylist items as possible |
1f8987e0e56c
Try to display as many buddylist items as possible
Mikael Berthe <mikael@lilotux.net>
parents:
679
diff
changeset
|
1889 |
i = g_list_length(buddylist) - maxy; |
682
f3945593432e
Small fix in scr_DrawRoster()
Mikael Berthe <mikael@lilotux.net>
parents:
680
diff
changeset
|
1890 |
if (i < 0) |
f3945593432e
Small fix in scr_DrawRoster()
Mikael Berthe <mikael@lilotux.net>
parents:
680
diff
changeset
|
1891 |
i = 0; |
f3945593432e
Small fix in scr_DrawRoster()
Mikael Berthe <mikael@lilotux.net>
parents:
680
diff
changeset
|
1892 |
if (i < offset) |
680
1f8987e0e56c
Try to display as many buddylist items as possible
Mikael Berthe <mikael@lilotux.net>
parents:
679
diff
changeset
|
1893 |
offset = i; |
1f8987e0e56c
Try to display as many buddylist items as possible
Mikael Berthe <mikael@lilotux.net>
parents:
679
diff
changeset
|
1894 |
// b) Make sure the current_buddy is visible |
84 | 1895 |
i = g_list_position(buddylist, current_buddy); |
1896 |
if (i == -1) { // This is bad |
|
374
bd5638c21834
Improve logging system (traces)
Mikael Berthe <mikael@lilotux.net>
parents:
373
diff
changeset
|
1897 |
scr_LogPrint(LPRINT_NORMAL, "Doh! Can't find current selected buddy!!"); |
713 | 1898 |
curs_set(cursor_backup); |
84 | 1899 |
return; |
1900 |
} else if (i < offset) { |
|
1901 |
offset = i; |
|
1902 |
} else if (i+1 > offset + maxy) { |
|
1903 |
offset = i + 1 - maxy; |
|
1904 |
} |
|
81 | 1905 |
|
973
e693cbe33802
Add option 'roster_win_on_right'
Mikael Berthe <mikael@lilotux.net>
parents:
972
diff
changeset
|
1906 |
if (roster_win_on_right) |
e693cbe33802
Add option 'roster_win_on_right'
Mikael Berthe <mikael@lilotux.net>
parents:
972
diff
changeset
|
1907 |
x_pos = 1; // 1 char offset (vertical line) |
e693cbe33802
Add option 'roster_win_on_right'
Mikael Berthe <mikael@lilotux.net>
parents:
972
diff
changeset
|
1908 |
else |
e693cbe33802
Add option 'roster_win_on_right'
Mikael Berthe <mikael@lilotux.net>
parents:
972
diff
changeset
|
1909 |
x_pos = 0; |
e693cbe33802
Add option 'roster_win_on_right'
Mikael Berthe <mikael@lilotux.net>
parents:
972
diff
changeset
|
1910 |
|
1026
fc6060707022
[BP] Fixes truncating utf-8 buddy names (Myhailo Danylenko)
Mikael Berthe <mikael@lilotux.net>
parents:
966
diff
changeset
|
1911 |
name = g_new0(char, 4*Roster_Width); |
fc6060707022
[BP] Fixes truncating utf-8 buddy names (Myhailo Danylenko)
Mikael Berthe <mikael@lilotux.net>
parents:
966
diff
changeset
|
1912 |
rline = g_new0(char, 4*Roster_Width+1); |
701
6c100adfbfb6
Add setting "roster_width" (variable buddylist width)
Mikael Berthe <mikael@lilotux.net>
parents:
699
diff
changeset
|
1913 |
|
81 | 1914 |
buddy = buddylist; |
1915 |
rOffset = offset; |
|
1916 |
||
84 | 1917 |
for (i=0; i<maxy && buddy; buddy = g_list_next(buddy)) { |
1804
35a1250c111a
Display urgent/attention sign in the roster UI
Mikael Berthe <mikael@lilotux.net>
parents:
1802
diff
changeset
|
1918 |
unsigned short bflags, btype; |
35a1250c111a
Display urgent/attention sign in the roster UI
Mikael Berthe <mikael@lilotux.net>
parents:
1802
diff
changeset
|
1919 |
unsigned short ismsg, isgrp, ismuc, ishid, isspe; |
35a1250c111a
Display urgent/attention sign in the roster UI
Mikael Berthe <mikael@lilotux.net>
parents:
1802
diff
changeset
|
1920 |
guint isurg; |
773
e25b8a348ebd
Screen updating functions use UTF-8
Mikael Berthe <mikael@lilotux.net>
parents:
772
diff
changeset
|
1921 |
gchar *rline_locale; |
1072
2a3cfb98bd5e
Fix memory leaks after calls to buddy_getresources()
Mikael Berthe <mikael@lilotux.net>
parents:
1059
diff
changeset
|
1922 |
GSList *resources, *p_res; |
713 | 1923 |
|
1924 |
bflags = buddy_getflags(BUDDATA(buddy)); |
|
1925 |
btype = buddy_gettype(BUDDATA(buddy)); |
|
1926 |
||
1927 |
ismsg = bflags & ROSTER_FLAG_MSG; |
|
1928 |
ishid = bflags & ROSTER_FLAG_HIDE; |
|
1929 |
isgrp = btype & ROSTER_TYPE_GROUP; |
|
1930 |
ismuc = btype & ROSTER_TYPE_ROOM; |
|
848
a9161d2dc414
Introduce special buffer stuff
Mikael Berthe <mikael@lilotux.net>
parents:
843
diff
changeset
|
1931 |
isspe = btype & ROSTER_TYPE_SPECIAL; |
1804
35a1250c111a
Display urgent/attention sign in the roster UI
Mikael Berthe <mikael@lilotux.net>
parents:
1802
diff
changeset
|
1932 |
isurg = buddy_getuiprio(BUDDATA(buddy)); |
81 | 1933 |
|
1934 |
if (rOffset > 0) { |
|
1935 |
rOffset--; |
|
1936 |
continue; |
|
1937 |
} |
|
1938 |
||
713 | 1939 |
status = '?'; |
1940 |
pending = ' '; |
|
1941 |
||
986
ed697234bd39
Chat states receival (Alexis Hildebrandt)
Mikael Berthe <mikael@lilotux.net>
parents:
981
diff
changeset
|
1942 |
resources = buddy_getresources(BUDDATA(buddy)); |
1072
2a3cfb98bd5e
Fix memory leaks after calls to buddy_getresources()
Mikael Berthe <mikael@lilotux.net>
parents:
1059
diff
changeset
|
1943 |
for (p_res = resources ; p_res ; p_res = g_slist_next(p_res)) { |
986
ed697234bd39
Chat states receival (Alexis Hildebrandt)
Mikael Berthe <mikael@lilotux.net>
parents:
981
diff
changeset
|
1944 |
guint events = buddy_resource_getevents(BUDDATA(buddy), |
1072
2a3cfb98bd5e
Fix memory leaks after calls to buddy_getresources()
Mikael Berthe <mikael@lilotux.net>
parents:
1059
diff
changeset
|
1945 |
p_res ? p_res->data : ""); |
2a3cfb98bd5e
Fix memory leaks after calls to buddy_getresources()
Mikael Berthe <mikael@lilotux.net>
parents:
1059
diff
changeset
|
1946 |
if ((events & ROSTER_EVENT_PAUSED) && pending != '+') |
992
b37348c2aa79
Chatstates: display "paused" states in the roster
Mikael Berthe <mikael@lilotux.net>
parents:
991
diff
changeset
|
1947 |
pending = '.'; |
1072
2a3cfb98bd5e
Fix memory leaks after calls to buddy_getresources()
Mikael Berthe <mikael@lilotux.net>
parents:
1059
diff
changeset
|
1948 |
if (events & ROSTER_EVENT_COMPOSING) |
987
f47e312560af
Improve JEP22 + JEP85 support
Mikael Berthe <mikael@lilotux.net>
parents:
986
diff
changeset
|
1949 |
pending = '+'; |
1072
2a3cfb98bd5e
Fix memory leaks after calls to buddy_getresources()
Mikael Berthe <mikael@lilotux.net>
parents:
1059
diff
changeset
|
1950 |
g_free(p_res->data); |
986
ed697234bd39
Chat states receival (Alexis Hildebrandt)
Mikael Berthe <mikael@lilotux.net>
parents:
981
diff
changeset
|
1951 |
} |
1072
2a3cfb98bd5e
Fix memory leaks after calls to buddy_getresources()
Mikael Berthe <mikael@lilotux.net>
parents:
1059
diff
changeset
|
1952 |
g_slist_free(resources); |
986
ed697234bd39
Chat states receival (Alexis Hildebrandt)
Mikael Berthe <mikael@lilotux.net>
parents:
981
diff
changeset
|
1953 |
|
149 | 1954 |
// Display message notice if there is a message flag, but not |
1955 |
// for unfolded groups. |
|
1956 |
if (ismsg && (!isgrp || ishid)) { |
|
81 | 1957 |
pending = '#'; |
1958 |
} |
|
1959 |
||
713 | 1960 |
if (ismuc) { |
1961 |
if (buddy_getinsideroom(BUDDATA(buddy))) |
|
1962 |
status = 'C'; |
|
1963 |
else |
|
1964 |
status = 'x'; |
|
1965 |
} else if (currentstatus != offline) { |
|
1966 |
enum imstatus budstate; |
|
1967 |
budstate = buddy_getstatus(BUDDATA(buddy), NULL); |
|
790
5d4ad1d77da4
Kill a few gcc4 warnings
Mikael Berthe <mikael@lilotux.net>
parents:
785
diff
changeset
|
1968 |
if (budstate < imstatus_size) |
713 | 1969 |
status = imstatus2char[budstate]; |
1970 |
} |
|
81 | 1971 |
if (buddy == current_buddy) { |
723
23068490d063
Add text color when the selected buddy has an unread message
Mikael Berthe <mikael@lilotux.net>
parents:
721
diff
changeset
|
1972 |
if (pending == '#') |
739
0d5fb1d9077c
Allow "bright" text colors
Mikael Berthe <mikael@lilotux.net>
parents:
735
diff
changeset
|
1973 |
wattrset(rosterWnd, get_color(COLOR_ROSTERSELNMSG)); |
723
23068490d063
Add text color when the selected buddy has an unread message
Mikael Berthe <mikael@lilotux.net>
parents:
721
diff
changeset
|
1974 |
else |
739
0d5fb1d9077c
Allow "bright" text colors
Mikael Berthe <mikael@lilotux.net>
parents:
735
diff
changeset
|
1975 |
wattrset(rosterWnd, get_color(COLOR_ROSTERSEL)); |
723
23068490d063
Add text color when the selected buddy has an unread message
Mikael Berthe <mikael@lilotux.net>
parents:
721
diff
changeset
|
1976 |
// The 3 following lines aim at coloring the whole line |
973
e693cbe33802
Add option 'roster_win_on_right'
Mikael Berthe <mikael@lilotux.net>
parents:
972
diff
changeset
|
1977 |
wmove(rosterWnd, i, x_pos); |
81 | 1978 |
for (n = 0; n < maxx; n++) |
1979 |
waddch(rosterWnd, ' '); |
|
1980 |
} else { |
|
149 | 1981 |
if (pending == '#') |
739
0d5fb1d9077c
Allow "bright" text colors
Mikael Berthe <mikael@lilotux.net>
parents:
735
diff
changeset
|
1982 |
wattrset(rosterWnd, get_color(COLOR_ROSTERNMSG)); |
1272
033576acac4c
Add configurable roster colors (Michal 'vorner' Vaner)
Mikael Berthe <mikael@lilotux.net>
parents:
1268
diff
changeset
|
1983 |
else { |
033576acac4c
Add configurable roster colors (Michal 'vorner' Vaner)
Mikael Berthe <mikael@lilotux.net>
parents:
1268
diff
changeset
|
1984 |
int color = get_color(COLOR_ROSTER); |
1729
e6e89b1d7831
Minor style and header updates
Mikael Berthe <mikael@lilotux.net>
parents:
1710
diff
changeset
|
1985 |
if ((!isspe) && (!isgrp)) { // Look for color rules |
1272
033576acac4c
Add configurable roster colors (Michal 'vorner' Vaner)
Mikael Berthe <mikael@lilotux.net>
parents:
1268
diff
changeset
|
1986 |
GSList *head; |
1804
35a1250c111a
Display urgent/attention sign in the roster UI
Mikael Berthe <mikael@lilotux.net>
parents:
1802
diff
changeset
|
1987 |
const char *bjid = buddy_getjid(BUDDATA(buddy)); |
1272
033576acac4c
Add configurable roster colors (Michal 'vorner' Vaner)
Mikael Berthe <mikael@lilotux.net>
parents:
1268
diff
changeset
|
1988 |
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
|
1989 |
rostercolor *rc = head->data; |
1804
35a1250c111a
Display urgent/attention sign in the roster UI
Mikael Berthe <mikael@lilotux.net>
parents:
1802
diff
changeset
|
1990 |
if (g_pattern_match_string(rc->compiled, bjid) && |
1272
033576acac4c
Add configurable roster colors (Michal 'vorner' Vaner)
Mikael Berthe <mikael@lilotux.net>
parents:
1268
diff
changeset
|
1991 |
(!strcmp("*", rc->status) || strchr(rc->status, status))) { |
1489
e9c71ce96dca
Fixed the colorhandling for mucnicks and /color roster
franky@veqlargh.fs
parents:
1488
diff
changeset
|
1992 |
color = compose_color(rc->color); |
1272
033576acac4c
Add configurable roster colors (Michal 'vorner' Vaner)
Mikael Berthe <mikael@lilotux.net>
parents:
1268
diff
changeset
|
1993 |
break; |
033576acac4c
Add configurable roster colors (Michal 'vorner' Vaner)
Mikael Berthe <mikael@lilotux.net>
parents:
1268
diff
changeset
|
1994 |
} |
033576acac4c
Add configurable roster colors (Michal 'vorner' Vaner)
Mikael Berthe <mikael@lilotux.net>
parents:
1268
diff
changeset
|
1995 |
} |
033576acac4c
Add configurable roster colors (Michal 'vorner' Vaner)
Mikael Berthe <mikael@lilotux.net>
parents:
1268
diff
changeset
|
1996 |
} |
033576acac4c
Add configurable roster colors (Michal 'vorner' Vaner)
Mikael Berthe <mikael@lilotux.net>
parents:
1268
diff
changeset
|
1997 |
wattrset(rosterWnd, color); |
033576acac4c
Add configurable roster colors (Michal 'vorner' Vaner)
Mikael Berthe <mikael@lilotux.net>
parents:
1268
diff
changeset
|
1998 |
} |
81 | 1999 |
} |
2000 |
||
701
6c100adfbfb6
Add setting "roster_width" (variable buddylist width)
Mikael Berthe <mikael@lilotux.net>
parents:
699
diff
changeset
|
2001 |
if (Roster_Width > 7) |
1026
fc6060707022
[BP] Fixes truncating utf-8 buddy names (Myhailo Danylenko)
Mikael Berthe <mikael@lilotux.net>
parents:
966
diff
changeset
|
2002 |
g_utf8_strncpy(name, buddy_getname(BUDDATA(buddy)), Roster_Width-7); |
701
6c100adfbfb6
Add setting "roster_width" (variable buddylist width)
Mikael Berthe <mikael@lilotux.net>
parents:
699
diff
changeset
|
2003 |
else |
6c100adfbfb6
Add setting "roster_width" (variable buddylist width)
Mikael Berthe <mikael@lilotux.net>
parents:
699
diff
changeset
|
2004 |
name[0] = 0; |
6c100adfbfb6
Add setting "roster_width" (variable buddylist width)
Mikael Berthe <mikael@lilotux.net>
parents:
699
diff
changeset
|
2005 |
|
1804
35a1250c111a
Display urgent/attention sign in the roster UI
Mikael Berthe <mikael@lilotux.net>
parents:
1802
diff
changeset
|
2006 |
if (pending == '#') { |
35a1250c111a
Display urgent/attention sign in the roster UI
Mikael Berthe <mikael@lilotux.net>
parents:
1802
diff
changeset
|
2007 |
// Attention sign? |
35a1250c111a
Display urgent/attention sign in the roster UI
Mikael Berthe <mikael@lilotux.net>
parents:
1802
diff
changeset
|
2008 |
if ((ismuc && isurg >= ui_attn_sign_prio_level_muc) || |
35a1250c111a
Display urgent/attention sign in the roster UI
Mikael Berthe <mikael@lilotux.net>
parents:
1802
diff
changeset
|
2009 |
(!ismuc && isurg >= ui_attn_sign_prio_level)) |
35a1250c111a
Display urgent/attention sign in the roster UI
Mikael Berthe <mikael@lilotux.net>
parents:
1802
diff
changeset
|
2010 |
pending = '!'; |
35a1250c111a
Display urgent/attention sign in the roster UI
Mikael Berthe <mikael@lilotux.net>
parents:
1802
diff
changeset
|
2011 |
} |
35a1250c111a
Display urgent/attention sign in the roster UI
Mikael Berthe <mikael@lilotux.net>
parents:
1802
diff
changeset
|
2012 |
|
149 | 2013 |
if (isgrp) { |
1598 | 2014 |
if (ishid) { |
1504
9fafea381eb8
Show the number of unfiltered contacts in folded groups
franky
parents:
1503
diff
changeset
|
2015 |
int group_count = 0; |
9fafea381eb8
Show the number of unfiltered contacts in folded groups
franky
parents:
1503
diff
changeset
|
2016 |
foreach_group_member(BUDDATA(buddy), increment_if_buddy_not_filtered, |
9fafea381eb8
Show the number of unfiltered contacts in folded groups
franky
parents:
1503
diff
changeset
|
2017 |
&group_count); |
9fafea381eb8
Show the number of unfiltered contacts in folded groups
franky
parents:
1503
diff
changeset
|
2018 |
snprintf(rline, 4*Roster_Width, " %c+++ %s (%i)", pending, name, |
1579
a2dd83167bc9
Fix display error in the roster
Mikael Berthe <mikael@lilotux.net>
parents:
1573
diff
changeset
|
2019 |
group_count); |
a2dd83167bc9
Fix display error in the roster
Mikael Berthe <mikael@lilotux.net>
parents:
1573
diff
changeset
|
2020 |
/* Do not display the item count if there isn't enough space */ |
a2dd83167bc9
Fix display error in the roster
Mikael Berthe <mikael@lilotux.net>
parents:
1573
diff
changeset
|
2021 |
if (g_utf8_strlen(rline, 4*Roster_Width) >= Roster_Width) |
1710
68981c37ed3f
Fix roster issue reported by DavidP
Mikael Berthe <mikael@lilotux.net>
parents:
1700
diff
changeset
|
2022 |
snprintf(rline, 4*Roster_Width, " %c+++ %s", pending, name); |
1504
9fafea381eb8
Show the number of unfiltered contacts in folded groups
franky
parents:
1503
diff
changeset
|
2023 |
} |
133 | 2024 |
else |
1504
9fafea381eb8
Show the number of unfiltered contacts in folded groups
franky
parents:
1503
diff
changeset
|
2025 |
snprintf(rline, 4*Roster_Width, " %c--- %s", pending, name); |
848
a9161d2dc414
Introduce special buffer stuff
Mikael Berthe <mikael@lilotux.net>
parents:
843
diff
changeset
|
2026 |
} else if (isspe) { |
1168
eb05f960613f
Fix UTF-8 group names in the roster (Myhailo Danylenko)
Mikael Berthe <mikael@lilotux.net>
parents:
1160
diff
changeset
|
2027 |
snprintf(rline, 4*Roster_Width, " %c%s", pending, name); |
701
6c100adfbfb6
Add setting "roster_width" (variable buddylist width)
Mikael Berthe <mikael@lilotux.net>
parents:
699
diff
changeset
|
2028 |
} else { |
824
37ef269330f0
Show incomplete subscriptions in the roster
Mikael Berthe <mikael@lilotux.net>
parents:
822
diff
changeset
|
2029 |
char sepleft = '['; |
37ef269330f0
Show incomplete subscriptions in the roster
Mikael Berthe <mikael@lilotux.net>
parents:
822
diff
changeset
|
2030 |
char sepright = ']'; |
37ef269330f0
Show incomplete subscriptions in the roster
Mikael Berthe <mikael@lilotux.net>
parents:
822
diff
changeset
|
2031 |
if (btype & ROSTER_TYPE_USER) { |
37ef269330f0
Show incomplete subscriptions in the roster
Mikael Berthe <mikael@lilotux.net>
parents:
822
diff
changeset
|
2032 |
guint subtype = buddy_getsubscription(BUDDATA(buddy)); |
832
7c210263c661
Small scr_DrawRoster() fix
Mikael Berthe <mikael@lilotux.net>
parents:
828
diff
changeset
|
2033 |
if (status == '_' && !(subtype & sub_to)) |
824
37ef269330f0
Show incomplete subscriptions in the roster
Mikael Berthe <mikael@lilotux.net>
parents:
822
diff
changeset
|
2034 |
status = '?'; |
37ef269330f0
Show incomplete subscriptions in the roster
Mikael Berthe <mikael@lilotux.net>
parents:
822
diff
changeset
|
2035 |
if (!(subtype & sub_from)) { |
37ef269330f0
Show incomplete subscriptions in the roster
Mikael Berthe <mikael@lilotux.net>
parents:
822
diff
changeset
|
2036 |
sepleft = '{'; |
37ef269330f0
Show incomplete subscriptions in the roster
Mikael Berthe <mikael@lilotux.net>
parents:
822
diff
changeset
|
2037 |
sepright = '}'; |
37ef269330f0
Show incomplete subscriptions in the roster
Mikael Berthe <mikael@lilotux.net>
parents:
822
diff
changeset
|
2038 |
} |
37ef269330f0
Show incomplete subscriptions in the roster
Mikael Berthe <mikael@lilotux.net>
parents:
822
diff
changeset
|
2039 |
} |
37ef269330f0
Show incomplete subscriptions in the roster
Mikael Berthe <mikael@lilotux.net>
parents:
822
diff
changeset
|
2040 |
|
1026
fc6060707022
[BP] Fixes truncating utf-8 buddy names (Myhailo Danylenko)
Mikael Berthe <mikael@lilotux.net>
parents:
966
diff
changeset
|
2041 |
snprintf(rline, 4*Roster_Width, |
824
37ef269330f0
Show incomplete subscriptions in the roster
Mikael Berthe <mikael@lilotux.net>
parents:
822
diff
changeset
|
2042 |
" %c%c%c%c %s", pending, sepleft, status, sepright, name); |
133 | 2043 |
} |
84 | 2044 |
|
773
e25b8a348ebd
Screen updating functions use UTF-8
Mikael Berthe <mikael@lilotux.net>
parents:
772
diff
changeset
|
2045 |
rline_locale = from_utf8(rline); |
981
553b8ecf901f
Fixes truncating of utf-8 buddy names (again)
Myhailo Danylenko <isbear@ukrpost.net>
parents:
980
diff
changeset
|
2046 |
mvwprintw(rosterWnd, i, x_pos, "%s", rline_locale); |
773
e25b8a348ebd
Screen updating functions use UTF-8
Mikael Berthe <mikael@lilotux.net>
parents:
772
diff
changeset
|
2047 |
g_free(rline_locale); |
84 | 2048 |
i++; |
81 | 2049 |
} |
2050 |
||
701
6c100adfbfb6
Add setting "roster_width" (variable buddylist width)
Mikael Berthe <mikael@lilotux.net>
parents:
699
diff
changeset
|
2051 |
g_free(rline); |
6c100adfbfb6
Add setting "roster_width" (variable buddylist width)
Mikael Berthe <mikael@lilotux.net>
parents:
699
diff
changeset
|
2052 |
g_free(name); |
142 | 2053 |
top_panel(inputPanel); |
81 | 2054 |
update_panels(); |
713 | 2055 |
curs_set(cursor_backup); |
24 | 2056 |
} |
2057 |
||
1780
e4378fbab5d7
Major API cleanup - bump API to 4
Mikael Berthe <mikael@lilotux.net>
parents:
1761
diff
changeset
|
2058 |
// scr_roster_visibility(status) |
707
b26a0bde4cdb
Add /roster hide|show|toggle
Mikael Berthe <mikael@lilotux.net>
parents:
701
diff
changeset
|
2059 |
// Set the roster visibility: |
b26a0bde4cdb
Add /roster hide|show|toggle
Mikael Berthe <mikael@lilotux.net>
parents:
701
diff
changeset
|
2060 |
// status=1 Show roster |
b26a0bde4cdb
Add /roster hide|show|toggle
Mikael Berthe <mikael@lilotux.net>
parents:
701
diff
changeset
|
2061 |
// status=0 Hide roster |
b26a0bde4cdb
Add /roster hide|show|toggle
Mikael Berthe <mikael@lilotux.net>
parents:
701
diff
changeset
|
2062 |
// status=-1 Toggle roster status |
1780
e4378fbab5d7
Major API cleanup - bump API to 4
Mikael Berthe <mikael@lilotux.net>
parents:
1761
diff
changeset
|
2063 |
void scr_roster_visibility(int status) |
707
b26a0bde4cdb
Add /roster hide|show|toggle
Mikael Berthe <mikael@lilotux.net>
parents:
701
diff
changeset
|
2064 |
{ |
708
ed326697e4ed
scr_RosterVisibility(): do not refresh when it is not needed
Mikael Berthe <mikael@lilotux.net>
parents:
707
diff
changeset
|
2065 |
int old_roster_status = roster_hidden; |
ed326697e4ed
scr_RosterVisibility(): do not refresh when it is not needed
Mikael Berthe <mikael@lilotux.net>
parents:
707
diff
changeset
|
2066 |
|
707
b26a0bde4cdb
Add /roster hide|show|toggle
Mikael Berthe <mikael@lilotux.net>
parents:
701
diff
changeset
|
2067 |
if (status > 0) |
b26a0bde4cdb
Add /roster hide|show|toggle
Mikael Berthe <mikael@lilotux.net>
parents:
701
diff
changeset
|
2068 |
roster_hidden = FALSE; |
b26a0bde4cdb
Add /roster hide|show|toggle
Mikael Berthe <mikael@lilotux.net>
parents:
701
diff
changeset
|
2069 |
else if (status == 0) |
b26a0bde4cdb
Add /roster hide|show|toggle
Mikael Berthe <mikael@lilotux.net>
parents:
701
diff
changeset
|
2070 |
roster_hidden = TRUE; |
b26a0bde4cdb
Add /roster hide|show|toggle
Mikael Berthe <mikael@lilotux.net>
parents:
701
diff
changeset
|
2071 |
else |
b26a0bde4cdb
Add /roster hide|show|toggle
Mikael Berthe <mikael@lilotux.net>
parents:
701
diff
changeset
|
2072 |
roster_hidden = !roster_hidden; |
b26a0bde4cdb
Add /roster hide|show|toggle
Mikael Berthe <mikael@lilotux.net>
parents:
701
diff
changeset
|
2073 |
|
708
ed326697e4ed
scr_RosterVisibility(): do not refresh when it is not needed
Mikael Berthe <mikael@lilotux.net>
parents:
707
diff
changeset
|
2074 |
if (roster_hidden != old_roster_status) { |
ed326697e4ed
scr_RosterVisibility(): do not refresh when it is not needed
Mikael Berthe <mikael@lilotux.net>
parents:
707
diff
changeset
|
2075 |
// Recalculate windows size and redraw |
ed326697e4ed
scr_RosterVisibility(): do not refresh when it is not needed
Mikael Berthe <mikael@lilotux.net>
parents:
707
diff
changeset
|
2076 |
scr_Resize(); |
ed326697e4ed
scr_RosterVisibility(): do not refresh when it is not needed
Mikael Berthe <mikael@lilotux.net>
parents:
707
diff
changeset
|
2077 |
redrawwin(stdscr); |
ed326697e4ed
scr_RosterVisibility(): do not refresh when it is not needed
Mikael Berthe <mikael@lilotux.net>
parents:
707
diff
changeset
|
2078 |
} |
707
b26a0bde4cdb
Add /roster hide|show|toggle
Mikael Berthe <mikael@lilotux.net>
parents:
701
diff
changeset
|
2079 |
} |
b26a0bde4cdb
Add /roster hide|show|toggle
Mikael Berthe <mikael@lilotux.net>
parents:
701
diff
changeset
|
2080 |
|
1521
33f8f795abd2
Check for regex support in glib
Mikael Berthe <mikael@lilotux.net>
parents:
1520
diff
changeset
|
2081 |
#ifdef HAVE_GLIB_REGEX |
1780
e4378fbab5d7
Major API cleanup - bump API to 4
Mikael Berthe <mikael@lilotux.net>
parents:
1761
diff
changeset
|
2082 |
static inline void scr_log_urls(const gchar *string) |
1520 | 2083 |
{ |
2084 |
GMatchInfo *match_info; |
|
1663
dcb0b4522ded
Fix GError handling
Myhailo Danylenko <isbear@ukrpost.net>
parents:
1660
diff
changeset
|
2085 |
|
dcb0b4522ded
Fix GError handling
Myhailo Danylenko <isbear@ukrpost.net>
parents:
1660
diff
changeset
|
2086 |
g_regex_match_full(url_regex, string, -1, 0, 0, &match_info, NULL); |
1520 | 2087 |
while (g_match_info_matches(match_info)) { |
2088 |
gchar *url = g_match_info_fetch(match_info, 0); |
|
2089 |
scr_print_logwindow(url); |
|
2090 |
g_free(url); |
|
1663
dcb0b4522ded
Fix GError handling
Myhailo Danylenko <isbear@ukrpost.net>
parents:
1660
diff
changeset
|
2091 |
g_match_info_next(match_info, NULL); |
1520 | 2092 |
} |
2093 |
g_match_info_free(match_info); |
|
2094 |
} |
|
1521
33f8f795abd2
Check for regex support in glib
Mikael Berthe <mikael@lilotux.net>
parents:
1520
diff
changeset
|
2095 |
#endif |
1520 | 2096 |
|
1780
e4378fbab5d7
Major API cleanup - bump API to 4
Mikael Berthe <mikael@lilotux.net>
parents:
1761
diff
changeset
|
2097 |
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
|
2098 |
time_t timestamp, guint prefix_flags, |
e4378fbab5d7
Major API cleanup - bump API to 4
Mikael Berthe <mikael@lilotux.net>
parents:
1761
diff
changeset
|
2099 |
unsigned mucnicklen, gpointer xep184) |
24 | 2100 |
{ |
727
1c3620668857
Expand tabs when reading history files
Mikael Berthe <mikael@lilotux.net>
parents:
726
diff
changeset
|
2101 |
char *xtext; |
725
1aff92625bdb
Expand tabs when receiving a message
Mikael Berthe <mikael@lilotux.net>
parents:
724
diff
changeset
|
2102 |
|
726 | 2103 |
if (!timestamp) timestamp = time(NULL); |
725
1aff92625bdb
Expand tabs when receiving a message
Mikael Berthe <mikael@lilotux.net>
parents:
724
diff
changeset
|
2104 |
|
1122
648fe6f715a6
Filter out ^M (0x0d) characters in incoming messages
Mikael Berthe <mikael@lilotux.net>
parents:
1115
diff
changeset
|
2105 |
xtext = ut_expand_tabs(text); // Expand tabs and filter out some chars |
726 | 2106 |
|
1780
e4378fbab5d7
Major API cleanup - bump API to 4
Mikael Berthe <mikael@lilotux.net>
parents:
1761
diff
changeset
|
2107 |
scr_write_in_window(bjid, xtext, timestamp, prefix_flags, FALSE, mucnicklen, |
e4378fbab5d7
Major API cleanup - bump API to 4
Mikael Berthe <mikael@lilotux.net>
parents:
1761
diff
changeset
|
2108 |
xep184); |
725
1aff92625bdb
Expand tabs when receiving a message
Mikael Berthe <mikael@lilotux.net>
parents:
724
diff
changeset
|
2109 |
|
1aff92625bdb
Expand tabs when receiving a message
Mikael Berthe <mikael@lilotux.net>
parents:
724
diff
changeset
|
2110 |
if (xtext != (char*)text) |
1aff92625bdb
Expand tabs when receiving a message
Mikael Berthe <mikael@lilotux.net>
parents:
724
diff
changeset
|
2111 |
g_free(xtext); |
24 | 2112 |
} |
2113 |
||
726 | 2114 |
// If prefix is NULL, HBB_PREFIX_IN is supposed. |
1783
af3de54ef986
Convert scr_LogPrint() to scr_log_print()
Mikael Berthe <mikael@lilotux.net>
parents:
1780
diff
changeset
|
2115 |
void scr_write_incoming_message(const char *jidfrom, const char *text, |
af3de54ef986
Convert scr_LogPrint() to scr_log_print()
Mikael Berthe <mikael@lilotux.net>
parents:
1780
diff
changeset
|
2116 |
time_t timestamp, |
af3de54ef986
Convert scr_LogPrint() to scr_log_print()
Mikael Berthe <mikael@lilotux.net>
parents:
1780
diff
changeset
|
2117 |
guint prefix, unsigned mucnicklen) |
726 | 2118 |
{ |
1055
6eb1efea75d0
PGP: Visual encryption flag
Mikael Berthe <mikael@lilotux.net>
parents:
1050
diff
changeset
|
2119 |
if (!(prefix & |
1204
e802ec0c02d2
Basic support for nick highlighting in MUC rooms (the whole line is colored)
Mikael Berthe <mikael@lilotux.net>
parents:
1190
diff
changeset
|
2120 |
~HBB_PREFIX_NOFLAG & ~HBB_PREFIX_HLIGHT & ~HBB_PREFIX_HLIGHT_OUT & |
1484
7b36b91a4388
New UI message flag (O) when OTR is used
Mikael Berthe <mikael@lilotux.net>
parents:
1483
diff
changeset
|
2121 |
~HBB_PREFIX_PGPCRYPT & ~HBB_PREFIX_OTRCRYPT)) |
726 | 2122 |
prefix |= HBB_PREFIX_IN; |
2123 |
||
1521
33f8f795abd2
Check for regex support in glib
Mikael Berthe <mikael@lilotux.net>
parents:
1520
diff
changeset
|
2124 |
#ifdef HAVE_GLIB_REGEX |
1520 | 2125 |
if (url_regex) |
1780
e4378fbab5d7
Major API cleanup - bump API to 4
Mikael Berthe <mikael@lilotux.net>
parents:
1761
diff
changeset
|
2126 |
scr_log_urls(text); |
1521
33f8f795abd2
Check for regex support in glib
Mikael Berthe <mikael@lilotux.net>
parents:
1520
diff
changeset
|
2127 |
#endif |
1780
e4378fbab5d7
Major API cleanup - bump API to 4
Mikael Berthe <mikael@lilotux.net>
parents:
1761
diff
changeset
|
2128 |
scr_write_message(jidfrom, text, timestamp, prefix, mucnicklen, NULL); |
726 | 2129 |
} |
2130 |
||
1783
af3de54ef986
Convert scr_LogPrint() to scr_log_print()
Mikael Berthe <mikael@lilotux.net>
parents:
1780
diff
changeset
|
2131 |
void scr_write_outgoing_message(const char *jidto, const char *text, |
af3de54ef986
Convert scr_LogPrint() to scr_log_print()
Mikael Berthe <mikael@lilotux.net>
parents:
1780
diff
changeset
|
2132 |
guint prefix, gpointer xep184) |
47 | 2133 |
{ |
1115
922a9ae1a17e
Fix /say_to to a member of a folded group
Mikael Berthe <mikael@lilotux.net>
parents:
1093
diff
changeset
|
2134 |
GSList *roster_elt; |
922a9ae1a17e
Fix /say_to to a member of a folded group
Mikael Berthe <mikael@lilotux.net>
parents:
1093
diff
changeset
|
2135 |
roster_elt = roster_find(jidto, jidsearch, |
922a9ae1a17e
Fix /say_to to a member of a folded group
Mikael Berthe <mikael@lilotux.net>
parents:
1093
diff
changeset
|
2136 |
ROSTER_TYPE_USER|ROSTER_TYPE_AGENT|ROSTER_TYPE_ROOM); |
922a9ae1a17e
Fix /say_to to a member of a folded group
Mikael Berthe <mikael@lilotux.net>
parents:
1093
diff
changeset
|
2137 |
|
1780
e4378fbab5d7
Major API cleanup - bump API to 4
Mikael Berthe <mikael@lilotux.net>
parents:
1761
diff
changeset
|
2138 |
scr_write_message(jidto, text, |
e4378fbab5d7
Major API cleanup - bump API to 4
Mikael Berthe <mikael@lilotux.net>
parents:
1761
diff
changeset
|
2139 |
0, prefix|HBB_PREFIX_OUT|HBB_PREFIX_HLIGHT_OUT, 0, xep184); |
1115
922a9ae1a17e
Fix /say_to to a member of a folded group
Mikael Berthe <mikael@lilotux.net>
parents:
1093
diff
changeset
|
2140 |
|
922a9ae1a17e
Fix /say_to to a member of a folded group
Mikael Berthe <mikael@lilotux.net>
parents:
1093
diff
changeset
|
2141 |
// Show jidto's buffer unless the buddy is not in the buddylist |
922a9ae1a17e
Fix /say_to to a member of a folded group
Mikael Berthe <mikael@lilotux.net>
parents:
1093
diff
changeset
|
2142 |
if (roster_elt && g_list_position(buddylist, roster_elt->data) != -1) |
1780
e4378fbab5d7
Major API cleanup - bump API to 4
Mikael Berthe <mikael@lilotux.net>
parents:
1761
diff
changeset
|
2143 |
scr_show_window(jidto, FALSE); |
47 | 2144 |
} |
2145 |
||
1780
e4378fbab5d7
Major API cleanup - bump API to 4
Mikael Berthe <mikael@lilotux.net>
parents:
1761
diff
changeset
|
2146 |
void scr_remove_receipt_flag(const char *bjid, gpointer xep184) |
1602 | 2147 |
{ |
1780
e4378fbab5d7
Major API cleanup - bump API to 4
Mikael Berthe <mikael@lilotux.net>
parents:
1761
diff
changeset
|
2148 |
winbuf *win_entry = scr_search_window(bjid, FALSE); |
1602 | 2149 |
if (win_entry) { |
2150 |
hbuf_remove_receipt(win_entry->bd->hbuf, xep184); |
|
2151 |
if (chatmode && (buddy_search_jid(bjid) == current_buddy)) |
|
1780
e4378fbab5d7
Major API cleanup - bump API to 4
Mikael Berthe <mikael@lilotux.net>
parents:
1761
diff
changeset
|
2152 |
scr_update_buddy_window(); |
1602 | 2153 |
} |
2154 |
} |
|
2155 |
||
935
97e6a6da2b2c
Fix ncurses #include (again)
Mikael Berthe <mikael@lilotux.net>
parents:
933
diff
changeset
|
2156 |
static inline void set_autoaway(bool setaway) |
373
af2f8ddf6a1b
Move (reorganize) functions
Mikael Berthe <mikael@lilotux.net>
parents:
370
diff
changeset
|
2157 |
{ |
af2f8ddf6a1b
Move (reorganize) functions
Mikael Berthe <mikael@lilotux.net>
parents:
370
diff
changeset
|
2158 |
static enum imstatus oldstatus; |
521 | 2159 |
static char *oldmsg; |
373
af2f8ddf6a1b
Move (reorganize) functions
Mikael Berthe <mikael@lilotux.net>
parents:
370
diff
changeset
|
2160 |
Autoaway = setaway; |
af2f8ddf6a1b
Move (reorganize) functions
Mikael Berthe <mikael@lilotux.net>
parents:
370
diff
changeset
|
2161 |
|
af2f8ddf6a1b
Move (reorganize) functions
Mikael Berthe <mikael@lilotux.net>
parents:
370
diff
changeset
|
2162 |
if (setaway) { |
521 | 2163 |
const char *msg, *prevmsg; |
1598 | 2164 |
oldstatus = xmpp_getstatus(); |
521 | 2165 |
if (oldmsg) { |
2166 |
g_free(oldmsg); |
|
2167 |
oldmsg = NULL; |
|
2168 |
} |
|
1598 | 2169 |
prevmsg = xmpp_getstatusmsg(); |
373
af2f8ddf6a1b
Move (reorganize) functions
Mikael Berthe <mikael@lilotux.net>
parents:
370
diff
changeset
|
2170 |
msg = settings_opt_get("message_autoaway"); |
521 | 2171 |
if (!msg) |
2172 |
msg = prevmsg; |
|
2173 |
if (prevmsg) |
|
2174 |
oldmsg = g_strdup(prevmsg); |
|
1598 | 2175 |
xmpp_setstatus(away, NULL, msg, FALSE); |
373
af2f8ddf6a1b
Move (reorganize) functions
Mikael Berthe <mikael@lilotux.net>
parents:
370
diff
changeset
|
2176 |
} else { |
af2f8ddf6a1b
Move (reorganize) functions
Mikael Berthe <mikael@lilotux.net>
parents:
370
diff
changeset
|
2177 |
// Back |
1598 | 2178 |
xmpp_setstatus(oldstatus, NULL, (oldmsg ? oldmsg : ""), FALSE); |
521 | 2179 |
if (oldmsg) { |
2180 |
g_free(oldmsg); |
|
2181 |
oldmsg = NULL; |
|
2182 |
} |
|
373
af2f8ddf6a1b
Move (reorganize) functions
Mikael Berthe <mikael@lilotux.net>
parents:
370
diff
changeset
|
2183 |
} |
af2f8ddf6a1b
Move (reorganize) functions
Mikael Berthe <mikael@lilotux.net>
parents:
370
diff
changeset
|
2184 |
} |
af2f8ddf6a1b
Move (reorganize) functions
Mikael Berthe <mikael@lilotux.net>
parents:
370
diff
changeset
|
2185 |
|
991
ef10906691bb
Chatstates: add composing timeout
Mikael Berthe <mikael@lilotux.net>
parents:
990
diff
changeset
|
2186 |
// set_chatstate(state) |
ef10906691bb
Chatstates: add composing timeout
Mikael Berthe <mikael@lilotux.net>
parents:
990
diff
changeset
|
2187 |
// Set the current chat state (0=active, 1=composing, 2=paused) |
1598 | 2188 |
// If the chat state has changed, call xmpp_send_chatstate() |
1780
e4378fbab5d7
Major API cleanup - bump API to 4
Mikael Berthe <mikael@lilotux.net>
parents:
1761
diff
changeset
|
2189 |
static void set_chatstate(int state) |
991
ef10906691bb
Chatstates: add composing timeout
Mikael Berthe <mikael@lilotux.net>
parents:
990
diff
changeset
|
2190 |
{ |
1691 | 2191 |
#if defined XEP0022 || defined XEP0085 |
993
0759f4c7da68
Add option 'disable_chatstates'
Mikael Berthe <mikael@lilotux.net>
parents:
992
diff
changeset
|
2192 |
if (chatstates_disabled) |
0759f4c7da68
Add option 'disable_chatstates'
Mikael Berthe <mikael@lilotux.net>
parents:
992
diff
changeset
|
2193 |
return; |
991
ef10906691bb
Chatstates: add composing timeout
Mikael Berthe <mikael@lilotux.net>
parents:
990
diff
changeset
|
2194 |
if (!chatmode) |
ef10906691bb
Chatstates: add composing timeout
Mikael Berthe <mikael@lilotux.net>
parents:
990
diff
changeset
|
2195 |
state = 0; |
ef10906691bb
Chatstates: add composing timeout
Mikael Berthe <mikael@lilotux.net>
parents:
990
diff
changeset
|
2196 |
if (state != chatstate) { |
ef10906691bb
Chatstates: add composing timeout
Mikael Berthe <mikael@lilotux.net>
parents:
990
diff
changeset
|
2197 |
chatstate = state; |
ef10906691bb
Chatstates: add composing timeout
Mikael Berthe <mikael@lilotux.net>
parents:
990
diff
changeset
|
2198 |
if (current_buddy && |
ef10906691bb
Chatstates: add composing timeout
Mikael Berthe <mikael@lilotux.net>
parents:
990
diff
changeset
|
2199 |
buddy_gettype(BUDDATA(current_buddy)) == ROSTER_TYPE_USER) { |
ef10906691bb
Chatstates: add composing timeout
Mikael Berthe <mikael@lilotux.net>
parents:
990
diff
changeset
|
2200 |
guint jep_state; |
1598 | 2201 |
if (chatstate == 1) { |
2202 |
if (chatstate_timeout_id == 0) |
|
2203 |
chatstate_timeout_id = g_timeout_add_seconds(1, |
|
1780
e4378fbab5d7
Major API cleanup - bump API to 4
Mikael Berthe <mikael@lilotux.net>
parents:
1761
diff
changeset
|
2204 |
scr_chatstates_timeout, |
1598 | 2205 |
NULL); |
991
ef10906691bb
Chatstates: add composing timeout
Mikael Berthe <mikael@lilotux.net>
parents:
990
diff
changeset
|
2206 |
jep_state = ROSTER_EVENT_COMPOSING; |
1598 | 2207 |
} |
991
ef10906691bb
Chatstates: add composing timeout
Mikael Berthe <mikael@lilotux.net>
parents:
990
diff
changeset
|
2208 |
else if (chatstate == 2) |
ef10906691bb
Chatstates: add composing timeout
Mikael Berthe <mikael@lilotux.net>
parents:
990
diff
changeset
|
2209 |
jep_state = ROSTER_EVENT_PAUSED; |
ef10906691bb
Chatstates: add composing timeout
Mikael Berthe <mikael@lilotux.net>
parents:
990
diff
changeset
|
2210 |
else |
ef10906691bb
Chatstates: add composing timeout
Mikael Berthe <mikael@lilotux.net>
parents:
990
diff
changeset
|
2211 |
jep_state = ROSTER_EVENT_ACTIVE; |
1598 | 2212 |
xmpp_send_chatstate(BUDDATA(current_buddy), jep_state); |
991
ef10906691bb
Chatstates: add composing timeout
Mikael Berthe <mikael@lilotux.net>
parents:
990
diff
changeset
|
2213 |
} |
ef10906691bb
Chatstates: add composing timeout
Mikael Berthe <mikael@lilotux.net>
parents:
990
diff
changeset
|
2214 |
if (!chatstate) |
ef10906691bb
Chatstates: add composing timeout
Mikael Berthe <mikael@lilotux.net>
parents:
990
diff
changeset
|
2215 |
chatstate_timestamp = 0; |
ef10906691bb
Chatstates: add composing timeout
Mikael Berthe <mikael@lilotux.net>
parents:
990
diff
changeset
|
2216 |
} |
ef10906691bb
Chatstates: add composing timeout
Mikael Berthe <mikael@lilotux.net>
parents:
990
diff
changeset
|
2217 |
#endif |
ef10906691bb
Chatstates: add composing timeout
Mikael Berthe <mikael@lilotux.net>
parents:
990
diff
changeset
|
2218 |
} |
ef10906691bb
Chatstates: add composing timeout
Mikael Berthe <mikael@lilotux.net>
parents:
990
diff
changeset
|
2219 |
|
1691 | 2220 |
#if defined XEP0022 || defined XEP0085 |
1780
e4378fbab5d7
Major API cleanup - bump API to 4
Mikael Berthe <mikael@lilotux.net>
parents:
1761
diff
changeset
|
2221 |
static gboolean scr_chatstates_timeout(void) |
991
ef10906691bb
Chatstates: add composing timeout
Mikael Berthe <mikael@lilotux.net>
parents:
990
diff
changeset
|
2222 |
{ |
1598 | 2223 |
time_t now; |
2224 |
time(&now); |
|
991
ef10906691bb
Chatstates: add composing timeout
Mikael Berthe <mikael@lilotux.net>
parents:
990
diff
changeset
|
2225 |
// Check if we're currently composing... |
1598 | 2226 |
if (chatstate != 1 || !chatstate_timestamp) { |
2227 |
chatstate_timeout_id = 0; |
|
2228 |
return FALSE; |
|
2229 |
} |
|
991
ef10906691bb
Chatstates: add composing timeout
Mikael Berthe <mikael@lilotux.net>
parents:
990
diff
changeset
|
2230 |
|
ef10906691bb
Chatstates: add composing timeout
Mikael Berthe <mikael@lilotux.net>
parents:
990
diff
changeset
|
2231 |
// If the timeout is reached, let's change the state right now. |
ef10906691bb
Chatstates: add composing timeout
Mikael Berthe <mikael@lilotux.net>
parents:
990
diff
changeset
|
2232 |
if (now >= chatstate_timestamp + COMPOSING_TIMEOUT) { |
ef10906691bb
Chatstates: add composing timeout
Mikael Berthe <mikael@lilotux.net>
parents:
990
diff
changeset
|
2233 |
chatstate_timestamp = now; |
ef10906691bb
Chatstates: add composing timeout
Mikael Berthe <mikael@lilotux.net>
parents:
990
diff
changeset
|
2234 |
set_chatstate(2); |
1598 | 2235 |
chatstate_timeout_id = 0; |
2236 |
return FALSE; |
|
991
ef10906691bb
Chatstates: add composing timeout
Mikael Berthe <mikael@lilotux.net>
parents:
990
diff
changeset
|
2237 |
} |
1598 | 2238 |
return TRUE; |
991
ef10906691bb
Chatstates: add composing timeout
Mikael Berthe <mikael@lilotux.net>
parents:
990
diff
changeset
|
2239 |
} |
ef10906691bb
Chatstates: add composing timeout
Mikael Berthe <mikael@lilotux.net>
parents:
990
diff
changeset
|
2240 |
#endif |
ef10906691bb
Chatstates: add composing timeout
Mikael Berthe <mikael@lilotux.net>
parents:
990
diff
changeset
|
2241 |
|
1677 | 2242 |
static gboolean scr_autoaway_timeout_callback(gpointer data) |
2243 |
{ |
|
2244 |
enum imstatus cur_st = xmpp_getstatus(); |
|
2245 |
if (cur_st != available && cur_st != freeforchat) |
|
2246 |
// Some non-user-originated status changes, let's wait more. |
|
2247 |
// Maybe the proper fix for that will be set global variable |
|
2248 |
// "autoaway_delayed" and check that variable in postconnect |
|
2249 |
// hook (afaik, only source for such status changes are |
|
2250 |
// error disconnects). |
|
2251 |
return TRUE; |
|
2252 |
set_autoaway(TRUE); |
|
2253 |
// source will be destroyed after return |
|
2254 |
autoaway_source = 0; |
|
2255 |
return FALSE; |
|
2256 |
} |
|
2257 |
||
1780
e4378fbab5d7
Major API cleanup - bump API to 4
Mikael Berthe <mikael@lilotux.net>
parents:
1761
diff
changeset
|
2258 |
static void scr_reinstall_autoaway_timeout(void) |
1677 | 2259 |
{ |
2260 |
unsigned int autoaway_timeout = settings_opt_get_int("autoaway"); |
|
2261 |
enum imstatus cur_st = xmpp_getstatus(); |
|
2262 |
if (autoaway_source) { |
|
2263 |
g_source_remove(autoaway_source); |
|
2264 |
autoaway_source = 0; |
|
2265 |
} |
|
2266 |
if (autoaway_timeout && (cur_st == available || cur_st == freeforchat)) |
|
2267 |
autoaway_source = g_timeout_add_seconds(autoaway_timeout, |
|
2268 |
scr_autoaway_timeout_callback, |
|
2269 |
NULL); |
|
2270 |
} |
|
2271 |
||
2272 |
// Check if we should reset autoaway timeout source |
|
1780
e4378fbab5d7
Major API cleanup - bump API to 4
Mikael Berthe <mikael@lilotux.net>
parents:
1761
diff
changeset
|
2273 |
void scr_check_auto_away(int activity) |
24 | 2274 |
{ |
1677 | 2275 |
if (Autoaway && activity) { |
1780
e4378fbab5d7
Major API cleanup - bump API to 4
Mikael Berthe <mikael@lilotux.net>
parents:
1761
diff
changeset
|
2276 |
scr_reinstall_autoaway_timeout(); |
1677 | 2277 |
set_autoaway(FALSE); |
2278 |
} else if (activity || !autoaway_source) |
|
1780
e4378fbab5d7
Major API cleanup - bump API to 4
Mikael Berthe <mikael@lilotux.net>
parents:
1761
diff
changeset
|
2279 |
scr_reinstall_autoaway_timeout(); |
24 | 2280 |
} |
2281 |
||
328
83d129adde03
Add set_current_buddy() function, to reduce code duplication
Mikael Berthe <mikael@lilotux.net>
parents:
325
diff
changeset
|
2282 |
// set_current_buddy(newbuddy) |
83d129adde03
Add set_current_buddy() function, to reduce code duplication
Mikael Berthe <mikael@lilotux.net>
parents:
325
diff
changeset
|
2283 |
// Set the current_buddy to newbuddy (if not NULL) |
83d129adde03
Add set_current_buddy() function, to reduce code duplication
Mikael Berthe <mikael@lilotux.net>
parents:
325
diff
changeset
|
2284 |
// Lock the newbuddy, and unlock the previous current_buddy |
83d129adde03
Add set_current_buddy() function, to reduce code duplication
Mikael Berthe <mikael@lilotux.net>
parents:
325
diff
changeset
|
2285 |
static void set_current_buddy(GList *newbuddy) |
24 | 2286 |
{ |
328
83d129adde03
Add set_current_buddy() function, to reduce code duplication
Mikael Berthe <mikael@lilotux.net>
parents:
325
diff
changeset
|
2287 |
enum imstatus prev_st = imstatus_size; |
83d129adde03
Add set_current_buddy() function, to reduce code duplication
Mikael Berthe <mikael@lilotux.net>
parents:
325
diff
changeset
|
2288 |
/* prev_st initialized to imstatus_size, which is used as "undef" value. |
83d129adde03
Add set_current_buddy() function, to reduce code duplication
Mikael Berthe <mikael@lilotux.net>
parents:
325
diff
changeset
|
2289 |
* We are sure prev_st will get a different status value after the |
83d129adde03
Add set_current_buddy() function, to reduce code duplication
Mikael Berthe <mikael@lilotux.net>
parents:
325
diff
changeset
|
2290 |
* buddy_getstatus() call. |
83d129adde03
Add set_current_buddy() function, to reduce code duplication
Mikael Berthe <mikael@lilotux.net>
parents:
325
diff
changeset
|
2291 |
*/ |
83d129adde03
Add set_current_buddy() function, to reduce code duplication
Mikael Berthe <mikael@lilotux.net>
parents:
325
diff
changeset
|
2292 |
|
329
7c53bf62a2a2
scr_RosterUnreadMessage() uses set_current_buddy()
Mikael Berthe <mikael@lilotux.net>
parents:
328
diff
changeset
|
2293 |
if (!current_buddy || !newbuddy) return; |
7c53bf62a2a2
scr_RosterUnreadMessage() uses set_current_buddy()
Mikael Berthe <mikael@lilotux.net>
parents:
328
diff
changeset
|
2294 |
if (newbuddy == current_buddy) return; |
24 | 2295 |
|
990
35e7913affb7
Send events/chatstates notifications (JEP-22/JEP-85)
Mikael Berthe <mikael@lilotux.net>
parents:
987
diff
changeset
|
2296 |
// We're moving to another buddy. We're thus inactive wrt current_buddy. |
35e7913affb7
Send events/chatstates notifications (JEP-22/JEP-85)
Mikael Berthe <mikael@lilotux.net>
parents:
987
diff
changeset
|
2297 |
set_chatstate(0); |
35e7913affb7
Send events/chatstates notifications (JEP-22/JEP-85)
Mikael Berthe <mikael@lilotux.net>
parents:
987
diff
changeset
|
2298 |
// We don't want the chatstate to be changed again right now. |
1381
40095d413da9
Fix compilation on OpenBSD
Mikael Berthe <mikael@lilotux.net>
parents:
1376
diff
changeset
|
2299 |
lock_chatstate = TRUE; |
990
35e7913affb7
Send events/chatstates notifications (JEP-22/JEP-85)
Mikael Berthe <mikael@lilotux.net>
parents:
987
diff
changeset
|
2300 |
|
438
b44be19d6229
Handle multiple resources for the same buddy
Mikael Berthe <mikael@lilotux.net>
parents:
419
diff
changeset
|
2301 |
prev_st = buddy_getstatus(BUDDATA(current_buddy), NULL); |
328
83d129adde03
Add set_current_buddy() function, to reduce code duplication
Mikael Berthe <mikael@lilotux.net>
parents:
325
diff
changeset
|
2302 |
buddy_setflags(BUDDATA(current_buddy), ROSTER_FLAG_LOCK, FALSE); |
330 | 2303 |
if (chatmode) |
2304 |
alternate_buddy = current_buddy; |
|
328
83d129adde03
Add set_current_buddy() function, to reduce code duplication
Mikael Berthe <mikael@lilotux.net>
parents:
325
diff
changeset
|
2305 |
current_buddy = newbuddy; |
83d129adde03
Add set_current_buddy() function, to reduce code duplication
Mikael Berthe <mikael@lilotux.net>
parents:
325
diff
changeset
|
2306 |
// Lock the buddy in the buddylist if we're in chat mode |
83d129adde03
Add set_current_buddy() function, to reduce code duplication
Mikael Berthe <mikael@lilotux.net>
parents:
325
diff
changeset
|
2307 |
if (chatmode) |
83d129adde03
Add set_current_buddy() function, to reduce code duplication
Mikael Berthe <mikael@lilotux.net>
parents:
325
diff
changeset
|
2308 |
buddy_setflags(BUDDATA(current_buddy), ROSTER_FLAG_LOCK, TRUE); |
83d129adde03
Add set_current_buddy() function, to reduce code duplication
Mikael Berthe <mikael@lilotux.net>
parents:
325
diff
changeset
|
2309 |
// We should rebuild the buddylist but not everytime |
1311
0dda8238af21
Implement "/roster display"
Mikael Berthe <mikael@lilotux.net>
parents:
1298
diff
changeset
|
2310 |
if (!(buddylist_get_filter() & 1<<prev_st)) |
328
83d129adde03
Add set_current_buddy() function, to reduce code duplication
Mikael Berthe <mikael@lilotux.net>
parents:
325
diff
changeset
|
2311 |
buddylist_build(); |
83d129adde03
Add set_current_buddy() function, to reduce code duplication
Mikael Berthe <mikael@lilotux.net>
parents:
325
diff
changeset
|
2312 |
update_roster = TRUE; |
24 | 2313 |
} |
2314 |
||
1780
e4378fbab5d7
Major API cleanup - bump API to 4
Mikael Berthe <mikael@lilotux.net>
parents:
1761
diff
changeset
|
2315 |
// scr_roster_top() |
143 | 2316 |
// Go to the first buddy in the buddylist |
1780
e4378fbab5d7
Major API cleanup - bump API to 4
Mikael Berthe <mikael@lilotux.net>
parents:
1761
diff
changeset
|
2317 |
void scr_roster_top(void) |
104 | 2318 |
{ |
328
83d129adde03
Add set_current_buddy() function, to reduce code duplication
Mikael Berthe <mikael@lilotux.net>
parents:
325
diff
changeset
|
2319 |
set_current_buddy(buddylist); |
104 | 2320 |
if (chatmode) |
1780
e4378fbab5d7
Major API cleanup - bump API to 4
Mikael Berthe <mikael@lilotux.net>
parents:
1761
diff
changeset
|
2321 |
scr_show_buddy_window(); |
104 | 2322 |
} |
2323 |
||
1780
e4378fbab5d7
Major API cleanup - bump API to 4
Mikael Berthe <mikael@lilotux.net>
parents:
1761
diff
changeset
|
2324 |
// scr_roster_bottom() |
143 | 2325 |
// Go to the last buddy in the buddylist |
1780
e4378fbab5d7
Major API cleanup - bump API to 4
Mikael Berthe <mikael@lilotux.net>
parents:
1761
diff
changeset
|
2326 |
void scr_roster_bottom(void) |
104 | 2327 |
{ |
328
83d129adde03
Add set_current_buddy() function, to reduce code duplication
Mikael Berthe <mikael@lilotux.net>
parents:
325
diff
changeset
|
2328 |
set_current_buddy(g_list_last(buddylist)); |
104 | 2329 |
if (chatmode) |
1780
e4378fbab5d7
Major API cleanup - bump API to 4
Mikael Berthe <mikael@lilotux.net>
parents:
1761
diff
changeset
|
2330 |
scr_show_buddy_window(); |
104 | 2331 |
} |
2332 |
||
1780
e4378fbab5d7
Major API cleanup - bump API to 4
Mikael Berthe <mikael@lilotux.net>
parents:
1761
diff
changeset
|
2333 |
// scr_roster_up_down(updown, n) |
1573
ece4f26bf9ff
Add count parameter to roster up/down command
Mikael Berthe <mikael@lilotux.net>
parents:
1566
diff
changeset
|
2334 |
// Go to the nth next buddy in the buddylist |
ece4f26bf9ff
Add count parameter to roster up/down command
Mikael Berthe <mikael@lilotux.net>
parents:
1566
diff
changeset
|
2335 |
// (up if updown == -1, down if updown == 1) |
1780
e4378fbab5d7
Major API cleanup - bump API to 4
Mikael Berthe <mikael@lilotux.net>
parents:
1761
diff
changeset
|
2336 |
void scr_roster_up_down(int updown, unsigned int n) |
81 | 2337 |
{ |
1573
ece4f26bf9ff
Add count parameter to roster up/down command
Mikael Berthe <mikael@lilotux.net>
parents:
1566
diff
changeset
|
2338 |
unsigned int i; |
ece4f26bf9ff
Add count parameter to roster up/down command
Mikael Berthe <mikael@lilotux.net>
parents:
1566
diff
changeset
|
2339 |
|
ece4f26bf9ff
Add count parameter to roster up/down command
Mikael Berthe <mikael@lilotux.net>
parents:
1566
diff
changeset
|
2340 |
if (updown < 0) { |
ece4f26bf9ff
Add count parameter to roster up/down command
Mikael Berthe <mikael@lilotux.net>
parents:
1566
diff
changeset
|
2341 |
for (i = 0; i < n; i++) |
ece4f26bf9ff
Add count parameter to roster up/down command
Mikael Berthe <mikael@lilotux.net>
parents:
1566
diff
changeset
|
2342 |
set_current_buddy(g_list_previous(current_buddy)); |
ece4f26bf9ff
Add count parameter to roster up/down command
Mikael Berthe <mikael@lilotux.net>
parents:
1566
diff
changeset
|
2343 |
} else { |
ece4f26bf9ff
Add count parameter to roster up/down command
Mikael Berthe <mikael@lilotux.net>
parents:
1566
diff
changeset
|
2344 |
for (i = 0; i < n; i++) |
ece4f26bf9ff
Add count parameter to roster up/down command
Mikael Berthe <mikael@lilotux.net>
parents:
1566
diff
changeset
|
2345 |
set_current_buddy(g_list_next(current_buddy)); |
ece4f26bf9ff
Add count parameter to roster up/down command
Mikael Berthe <mikael@lilotux.net>
parents:
1566
diff
changeset
|
2346 |
} |
104 | 2347 |
if (chatmode) |
1780
e4378fbab5d7
Major API cleanup - bump API to 4
Mikael Berthe <mikael@lilotux.net>
parents:
1761
diff
changeset
|
2348 |
scr_show_buddy_window(); |
81 | 2349 |
} |
2350 |
||
1780
e4378fbab5d7
Major API cleanup - bump API to 4
Mikael Berthe <mikael@lilotux.net>
parents:
1761
diff
changeset
|
2351 |
// scr_roster_prev_group() |
1086
5e2e647e781b
Add command /roster group_prev|group_next and update documentation
Mikael Berthe <mikael@lilotux.net>
parents:
1083
diff
changeset
|
2352 |
// Go to the previous group in the buddylist |
1780
e4378fbab5d7
Major API cleanup - bump API to 4
Mikael Berthe <mikael@lilotux.net>
parents:
1761
diff
changeset
|
2353 |
void scr_roster_prev_group(void) |
1086
5e2e647e781b
Add command /roster group_prev|group_next and update documentation
Mikael Berthe <mikael@lilotux.net>
parents:
1083
diff
changeset
|
2354 |
{ |
5e2e647e781b
Add command /roster group_prev|group_next and update documentation
Mikael Berthe <mikael@lilotux.net>
parents:
1083
diff
changeset
|
2355 |
GList *bud; |
5e2e647e781b
Add command /roster group_prev|group_next and update documentation
Mikael Berthe <mikael@lilotux.net>
parents:
1083
diff
changeset
|
2356 |
|
5e2e647e781b
Add command /roster group_prev|group_next and update documentation
Mikael Berthe <mikael@lilotux.net>
parents:
1083
diff
changeset
|
2357 |
for (bud = current_buddy ; bud ; ) { |
5e2e647e781b
Add command /roster group_prev|group_next and update documentation
Mikael Berthe <mikael@lilotux.net>
parents:
1083
diff
changeset
|
2358 |
bud = g_list_previous(bud); |
5e2e647e781b
Add command /roster group_prev|group_next and update documentation
Mikael Berthe <mikael@lilotux.net>
parents:
1083
diff
changeset
|
2359 |
if (!bud) |
5e2e647e781b
Add command /roster group_prev|group_next and update documentation
Mikael Berthe <mikael@lilotux.net>
parents:
1083
diff
changeset
|
2360 |
break; |
5e2e647e781b
Add command /roster group_prev|group_next and update documentation
Mikael Berthe <mikael@lilotux.net>
parents:
1083
diff
changeset
|
2361 |
if (buddy_gettype(BUDDATA(bud)) & ROSTER_TYPE_GROUP) { |
5e2e647e781b
Add command /roster group_prev|group_next and update documentation
Mikael Berthe <mikael@lilotux.net>
parents:
1083
diff
changeset
|
2362 |
set_current_buddy(bud); |
5e2e647e781b
Add command /roster group_prev|group_next and update documentation
Mikael Berthe <mikael@lilotux.net>
parents:
1083
diff
changeset
|
2363 |
if (chatmode) |
1780
e4378fbab5d7
Major API cleanup - bump API to 4
Mikael Berthe <mikael@lilotux.net>
parents:
1761
diff
changeset
|
2364 |
scr_show_buddy_window(); |
1086
5e2e647e781b
Add command /roster group_prev|group_next and update documentation
Mikael Berthe <mikael@lilotux.net>
parents:
1083
diff
changeset
|
2365 |
break; |
5e2e647e781b
Add command /roster group_prev|group_next and update documentation
Mikael Berthe <mikael@lilotux.net>
parents:
1083
diff
changeset
|
2366 |
} |
5e2e647e781b
Add command /roster group_prev|group_next and update documentation
Mikael Berthe <mikael@lilotux.net>
parents:
1083
diff
changeset
|
2367 |
} |
5e2e647e781b
Add command /roster group_prev|group_next and update documentation
Mikael Berthe <mikael@lilotux.net>
parents:
1083
diff
changeset
|
2368 |
} |
5e2e647e781b
Add command /roster group_prev|group_next and update documentation
Mikael Berthe <mikael@lilotux.net>
parents:
1083
diff
changeset
|
2369 |
|
1780
e4378fbab5d7
Major API cleanup - bump API to 4
Mikael Berthe <mikael@lilotux.net>
parents:
1761
diff
changeset
|
2370 |
// scr_roster_next_group() |
1086
5e2e647e781b
Add command /roster group_prev|group_next and update documentation
Mikael Berthe <mikael@lilotux.net>
parents:
1083
diff
changeset
|
2371 |
// Go to the next group in the buddylist |
1780
e4378fbab5d7
Major API cleanup - bump API to 4
Mikael Berthe <mikael@lilotux.net>
parents:
1761
diff
changeset
|
2372 |
void scr_roster_next_group(void) |
1086
5e2e647e781b
Add command /roster group_prev|group_next and update documentation
Mikael Berthe <mikael@lilotux.net>
parents:
1083
diff
changeset
|
2373 |
{ |
5e2e647e781b
Add command /roster group_prev|group_next and update documentation
Mikael Berthe <mikael@lilotux.net>
parents:
1083
diff
changeset
|
2374 |
GList *bud; |
5e2e647e781b
Add command /roster group_prev|group_next and update documentation
Mikael Berthe <mikael@lilotux.net>
parents:
1083
diff
changeset
|
2375 |
|
5e2e647e781b
Add command /roster group_prev|group_next and update documentation
Mikael Berthe <mikael@lilotux.net>
parents:
1083
diff
changeset
|
2376 |
for (bud = current_buddy ; bud ; ) { |
5e2e647e781b
Add command /roster group_prev|group_next and update documentation
Mikael Berthe <mikael@lilotux.net>
parents:
1083
diff
changeset
|
2377 |
bud = g_list_next(bud); |
5e2e647e781b
Add command /roster group_prev|group_next and update documentation
Mikael Berthe <mikael@lilotux.net>
parents:
1083
diff
changeset
|
2378 |
if (!bud) |
5e2e647e781b
Add command /roster group_prev|group_next and update documentation
Mikael Berthe <mikael@lilotux.net>
parents:
1083
diff
changeset
|
2379 |
break; |
5e2e647e781b
Add command /roster group_prev|group_next and update documentation
Mikael Berthe <mikael@lilotux.net>
parents:
1083
diff
changeset
|
2380 |
if (buddy_gettype(BUDDATA(bud)) & ROSTER_TYPE_GROUP) { |
5e2e647e781b
Add command /roster group_prev|group_next and update documentation
Mikael Berthe <mikael@lilotux.net>
parents:
1083
diff
changeset
|
2381 |
set_current_buddy(bud); |
5e2e647e781b
Add command /roster group_prev|group_next and update documentation
Mikael Berthe <mikael@lilotux.net>
parents:
1083
diff
changeset
|
2382 |
if (chatmode) |
1780
e4378fbab5d7
Major API cleanup - bump API to 4
Mikael Berthe <mikael@lilotux.net>
parents:
1761
diff
changeset
|
2383 |
scr_show_buddy_window(); |
1086
5e2e647e781b
Add command /roster group_prev|group_next and update documentation
Mikael Berthe <mikael@lilotux.net>
parents:
1083
diff
changeset
|
2384 |
break; |
5e2e647e781b
Add command /roster group_prev|group_next and update documentation
Mikael Berthe <mikael@lilotux.net>
parents:
1083
diff
changeset
|
2385 |
} |
5e2e647e781b
Add command /roster group_prev|group_next and update documentation
Mikael Berthe <mikael@lilotux.net>
parents:
1083
diff
changeset
|
2386 |
} |
5e2e647e781b
Add command /roster group_prev|group_next and update documentation
Mikael Berthe <mikael@lilotux.net>
parents:
1083
diff
changeset
|
2387 |
} |
5e2e647e781b
Add command /roster group_prev|group_next and update documentation
Mikael Berthe <mikael@lilotux.net>
parents:
1083
diff
changeset
|
2388 |
|
1780
e4378fbab5d7
Major API cleanup - bump API to 4
Mikael Berthe <mikael@lilotux.net>
parents:
1761
diff
changeset
|
2389 |
// scr_roster_search(str) |
265 | 2390 |
// Look forward for a buddy with jid/name containing str. |
1780
e4378fbab5d7
Major API cleanup - bump API to 4
Mikael Berthe <mikael@lilotux.net>
parents:
1761
diff
changeset
|
2391 |
void scr_roster_search(char *str) |
265 | 2392 |
{ |
328
83d129adde03
Add set_current_buddy() function, to reduce code duplication
Mikael Berthe <mikael@lilotux.net>
parents:
325
diff
changeset
|
2393 |
set_current_buddy(buddy_search(str)); |
265 | 2394 |
if (chatmode) |
1780
e4378fbab5d7
Major API cleanup - bump API to 4
Mikael Berthe <mikael@lilotux.net>
parents:
1761
diff
changeset
|
2395 |
scr_show_buddy_window(); |
265 | 2396 |
} |
2397 |
||
1780
e4378fbab5d7
Major API cleanup - bump API to 4
Mikael Berthe <mikael@lilotux.net>
parents:
1761
diff
changeset
|
2398 |
// scr_roster_jump_jid(bjid) |
1058 | 2399 |
// Jump to buddy bjid. |
480 | 2400 |
// NOTE: With this function, the buddy is added to the roster if doesn't exist. |
1780
e4378fbab5d7
Major API cleanup - bump API to 4
Mikael Berthe <mikael@lilotux.net>
parents:
1761
diff
changeset
|
2401 |
void scr_roster_jump_jid(char *barejid) |
480 | 2402 |
{ |
2403 |
GSList *roster_elt; |
|
2404 |
// Look for an existing buddy |
|
2405 |
roster_elt = roster_find(barejid, jidsearch, |
|
2406 |
ROSTER_TYPE_USER|ROSTER_TYPE_AGENT|ROSTER_TYPE_ROOM); |
|
2407 |
// Create it if necessary |
|
2408 |
if (!roster_elt) |
|
603 | 2409 |
roster_elt = roster_add_user(barejid, NULL, NULL, ROSTER_TYPE_USER, |
1355 | 2410 |
sub_none, -1); |
480 | 2411 |
// Set a lock to see it in the buddylist |
2412 |
buddy_setflags(BUDDATA(roster_elt), ROSTER_FLAG_LOCK, TRUE); |
|
2413 |
buddylist_build(); |
|
2414 |
// Jump to the buddy |
|
2415 |
set_current_buddy(buddy_search_jid(barejid)); |
|
2416 |
if (chatmode) |
|
1780
e4378fbab5d7
Major API cleanup - bump API to 4
Mikael Berthe <mikael@lilotux.net>
parents:
1761
diff
changeset
|
2417 |
scr_show_buddy_window(); |
480 | 2418 |
} |
2419 |
||
1780
e4378fbab5d7
Major API cleanup - bump API to 4
Mikael Berthe <mikael@lilotux.net>
parents:
1761
diff
changeset
|
2420 |
// scr_roster_unread_message(next) |
236 | 2421 |
// Go to a new message. If next is not null, try to go to the next new |
2422 |
// message. If it is not possible or if next is NULL, go to the first new |
|
2423 |
// message from unread_list. |
|
1780
e4378fbab5d7
Major API cleanup - bump API to 4
Mikael Berthe <mikael@lilotux.net>
parents:
1761
diff
changeset
|
2424 |
void scr_roster_unread_message(int next) |
236 | 2425 |
{ |
329
7c53bf62a2a2
scr_RosterUnreadMessage() uses set_current_buddy()
Mikael Berthe <mikael@lilotux.net>
parents:
328
diff
changeset
|
2426 |
gpointer unread_ptr; |
7c53bf62a2a2
scr_RosterUnreadMessage() uses set_current_buddy()
Mikael Berthe <mikael@lilotux.net>
parents:
328
diff
changeset
|
2427 |
gpointer refbuddata; |
7c53bf62a2a2
scr_RosterUnreadMessage() uses set_current_buddy()
Mikael Berthe <mikael@lilotux.net>
parents:
328
diff
changeset
|
2428 |
GList *nbuddy; |
236 | 2429 |
|
329
7c53bf62a2a2
scr_RosterUnreadMessage() uses set_current_buddy()
Mikael Berthe <mikael@lilotux.net>
parents:
328
diff
changeset
|
2430 |
if (!current_buddy) return; |
236 | 2431 |
|
329
7c53bf62a2a2
scr_RosterUnreadMessage() uses set_current_buddy()
Mikael Berthe <mikael@lilotux.net>
parents:
328
diff
changeset
|
2432 |
if (next) refbuddata = BUDDATA(current_buddy); |
7c53bf62a2a2
scr_RosterUnreadMessage() uses set_current_buddy()
Mikael Berthe <mikael@lilotux.net>
parents:
328
diff
changeset
|
2433 |
else refbuddata = NULL; |
236 | 2434 |
|
329
7c53bf62a2a2
scr_RosterUnreadMessage() uses set_current_buddy()
Mikael Berthe <mikael@lilotux.net>
parents:
328
diff
changeset
|
2435 |
unread_ptr = unread_msg(refbuddata); |
7c53bf62a2a2
scr_RosterUnreadMessage() uses set_current_buddy()
Mikael Berthe <mikael@lilotux.net>
parents:
328
diff
changeset
|
2436 |
if (!unread_ptr) return; |
236 | 2437 |
|
889
ae93e69aaaaf
Fix up pending message flag for the status special buffer
Mikael Berthe <mikael@lilotux.net>
parents:
888
diff
changeset
|
2438 |
if (!(buddy_gettype(unread_ptr) & ROSTER_TYPE_SPECIAL)) { |
ae93e69aaaaf
Fix up pending message flag for the status special buffer
Mikael Berthe <mikael@lilotux.net>
parents:
888
diff
changeset
|
2439 |
gpointer ngroup; |
ae93e69aaaaf
Fix up pending message flag for the status special buffer
Mikael Berthe <mikael@lilotux.net>
parents:
888
diff
changeset
|
2440 |
// If buddy is in a folded group, we need to expand it |
ae93e69aaaaf
Fix up pending message flag for the status special buffer
Mikael Berthe <mikael@lilotux.net>
parents:
888
diff
changeset
|
2441 |
ngroup = buddy_getgroup(unread_ptr); |
ae93e69aaaaf
Fix up pending message flag for the status special buffer
Mikael Berthe <mikael@lilotux.net>
parents:
888
diff
changeset
|
2442 |
if (buddy_getflags(ngroup) & ROSTER_FLAG_HIDE) { |
ae93e69aaaaf
Fix up pending message flag for the status special buffer
Mikael Berthe <mikael@lilotux.net>
parents:
888
diff
changeset
|
2443 |
buddy_setflags(ngroup, ROSTER_FLAG_HIDE, FALSE); |
ae93e69aaaaf
Fix up pending message flag for the status special buffer
Mikael Berthe <mikael@lilotux.net>
parents:
888
diff
changeset
|
2444 |
buddylist_build(); |
ae93e69aaaaf
Fix up pending message flag for the status special buffer
Mikael Berthe <mikael@lilotux.net>
parents:
888
diff
changeset
|
2445 |
} |
329
7c53bf62a2a2
scr_RosterUnreadMessage() uses set_current_buddy()
Mikael Berthe <mikael@lilotux.net>
parents:
328
diff
changeset
|
2446 |
} |
236 | 2447 |
|
329
7c53bf62a2a2
scr_RosterUnreadMessage() uses set_current_buddy()
Mikael Berthe <mikael@lilotux.net>
parents:
328
diff
changeset
|
2448 |
nbuddy = g_list_find(buddylist, unread_ptr); |
7c53bf62a2a2
scr_RosterUnreadMessage() uses set_current_buddy()
Mikael Berthe <mikael@lilotux.net>
parents:
328
diff
changeset
|
2449 |
if (nbuddy) { |
7c53bf62a2a2
scr_RosterUnreadMessage() uses set_current_buddy()
Mikael Berthe <mikael@lilotux.net>
parents:
328
diff
changeset
|
2450 |
set_current_buddy(nbuddy); |
1780
e4378fbab5d7
Major API cleanup - bump API to 4
Mikael Berthe <mikael@lilotux.net>
parents:
1761
diff
changeset
|
2451 |
if (chatmode) scr_show_buddy_window(); |
374
bd5638c21834
Improve logging system (traces)
Mikael Berthe <mikael@lilotux.net>
parents:
373
diff
changeset
|
2452 |
} else |
bd5638c21834
Improve logging system (traces)
Mikael Berthe <mikael@lilotux.net>
parents:
373
diff
changeset
|
2453 |
scr_LogPrint(LPRINT_LOGNORM, "Error: nbuddy == NULL"); // should not happen |
236 | 2454 |
} |
2455 |
||
1780
e4378fbab5d7
Major API cleanup - bump API to 4
Mikael Berthe <mikael@lilotux.net>
parents:
1761
diff
changeset
|
2456 |
// scr_roster_jump_alternate() |
330 | 2457 |
// Try to jump to alternate (== previous) buddy |
1780
e4378fbab5d7
Major API cleanup - bump API to 4
Mikael Berthe <mikael@lilotux.net>
parents:
1761
diff
changeset
|
2458 |
void scr_roster_jump_alternate(void) |
105 | 2459 |
{ |
330 | 2460 |
if (!alternate_buddy || g_list_position(buddylist, alternate_buddy) == -1) |
2461 |
return; |
|
2462 |
set_current_buddy(alternate_buddy); |
|
2463 |
if (chatmode) |
|
1780
e4378fbab5d7
Major API cleanup - bump API to 4
Mikael Berthe <mikael@lilotux.net>
parents:
1761
diff
changeset
|
2464 |
scr_show_buddy_window(); |
330 | 2465 |
} |
2466 |
||
1780
e4378fbab5d7
Major API cleanup - bump API to 4
Mikael Berthe <mikael@lilotux.net>
parents:
1761
diff
changeset
|
2467 |
// scr_roster_display(filter) |
1311
0dda8238af21
Implement "/roster display"
Mikael Berthe <mikael@lilotux.net>
parents:
1298
diff
changeset
|
2468 |
// Set the roster filter mask. If filter is null/empty, the current |
0dda8238af21
Implement "/roster display"
Mikael Berthe <mikael@lilotux.net>
parents:
1298
diff
changeset
|
2469 |
// mask is displayed. |
1780
e4378fbab5d7
Major API cleanup - bump API to 4
Mikael Berthe <mikael@lilotux.net>
parents:
1761
diff
changeset
|
2470 |
void scr_roster_display(const char *filter) |
1311
0dda8238af21
Implement "/roster display"
Mikael Berthe <mikael@lilotux.net>
parents:
1298
diff
changeset
|
2471 |
{ |
0dda8238af21
Implement "/roster display"
Mikael Berthe <mikael@lilotux.net>
parents:
1298
diff
changeset
|
2472 |
guchar status; |
0dda8238af21
Implement "/roster display"
Mikael Berthe <mikael@lilotux.net>
parents:
1298
diff
changeset
|
2473 |
enum imstatus budstate; |
0dda8238af21
Implement "/roster display"
Mikael Berthe <mikael@lilotux.net>
parents:
1298
diff
changeset
|
2474 |
char strfilter[imstatus_size+1]; |
0dda8238af21
Implement "/roster display"
Mikael Berthe <mikael@lilotux.net>
parents:
1298
diff
changeset
|
2475 |
char *psfilter; |
0dda8238af21
Implement "/roster display"
Mikael Berthe <mikael@lilotux.net>
parents:
1298
diff
changeset
|
2476 |
|
0dda8238af21
Implement "/roster display"
Mikael Berthe <mikael@lilotux.net>
parents:
1298
diff
changeset
|
2477 |
if (filter && *filter) { |
0dda8238af21
Implement "/roster display"
Mikael Berthe <mikael@lilotux.net>
parents:
1298
diff
changeset
|
2478 |
int show_all = (*filter == '*'); |
0dda8238af21
Implement "/roster display"
Mikael Berthe <mikael@lilotux.net>
parents:
1298
diff
changeset
|
2479 |
status = 0; |
0dda8238af21
Implement "/roster display"
Mikael Berthe <mikael@lilotux.net>
parents:
1298
diff
changeset
|
2480 |
for (budstate = 0; budstate < imstatus_size-1; budstate++) |
0dda8238af21
Implement "/roster display"
Mikael Berthe <mikael@lilotux.net>
parents:
1298
diff
changeset
|
2481 |
if (strchr(filter, imstatus2char[budstate]) || show_all) |
0dda8238af21
Implement "/roster display"
Mikael Berthe <mikael@lilotux.net>
parents:
1298
diff
changeset
|
2482 |
status |= 1<<budstate; |
0dda8238af21
Implement "/roster display"
Mikael Berthe <mikael@lilotux.net>
parents:
1298
diff
changeset
|
2483 |
buddylist_set_filter(status); |
0dda8238af21
Implement "/roster display"
Mikael Berthe <mikael@lilotux.net>
parents:
1298
diff
changeset
|
2484 |
buddylist_build(); |
0dda8238af21
Implement "/roster display"
Mikael Berthe <mikael@lilotux.net>
parents:
1298
diff
changeset
|
2485 |
update_roster = TRUE; |
0dda8238af21
Implement "/roster display"
Mikael Berthe <mikael@lilotux.net>
parents:
1298
diff
changeset
|
2486 |
return; |
0dda8238af21
Implement "/roster display"
Mikael Berthe <mikael@lilotux.net>
parents:
1298
diff
changeset
|
2487 |
} |
0dda8238af21
Implement "/roster display"
Mikael Berthe <mikael@lilotux.net>
parents:
1298
diff
changeset
|
2488 |
|
0dda8238af21
Implement "/roster display"
Mikael Berthe <mikael@lilotux.net>
parents:
1298
diff
changeset
|
2489 |
// Display current filter |
0dda8238af21
Implement "/roster display"
Mikael Berthe <mikael@lilotux.net>
parents:
1298
diff
changeset
|
2490 |
psfilter = strfilter; |
0dda8238af21
Implement "/roster display"
Mikael Berthe <mikael@lilotux.net>
parents:
1298
diff
changeset
|
2491 |
status = buddylist_get_filter(); |
0dda8238af21
Implement "/roster display"
Mikael Berthe <mikael@lilotux.net>
parents:
1298
diff
changeset
|
2492 |
for (budstate = 0; budstate < imstatus_size-1; budstate++) |
0dda8238af21
Implement "/roster display"
Mikael Berthe <mikael@lilotux.net>
parents:
1298
diff
changeset
|
2493 |
if (status & 1<<budstate) |
0dda8238af21
Implement "/roster display"
Mikael Berthe <mikael@lilotux.net>
parents:
1298
diff
changeset
|
2494 |
*psfilter++ = imstatus2char[budstate]; |
0dda8238af21
Implement "/roster display"
Mikael Berthe <mikael@lilotux.net>
parents:
1298
diff
changeset
|
2495 |
*psfilter = '\0'; |
0dda8238af21
Implement "/roster display"
Mikael Berthe <mikael@lilotux.net>
parents:
1298
diff
changeset
|
2496 |
scr_LogPrint(LPRINT_NORMAL, "Roster status filter: %s", strfilter); |
0dda8238af21
Implement "/roster display"
Mikael Berthe <mikael@lilotux.net>
parents:
1298
diff
changeset
|
2497 |
} |
0dda8238af21
Implement "/roster display"
Mikael Berthe <mikael@lilotux.net>
parents:
1298
diff
changeset
|
2498 |
|
1780
e4378fbab5d7
Major API cleanup - bump API to 4
Mikael Berthe <mikael@lilotux.net>
parents:
1761
diff
changeset
|
2499 |
// scr_buffer_scroll_up_down() |
508
5a2132ba2220
Add "/buffer up" and "/buffer down"
Mikael Berthe <mikael@lilotux.net>
parents:
503
diff
changeset
|
2500 |
// Scroll up/down the current buddy window, |
5a2132ba2220
Add "/buffer up" and "/buffer down"
Mikael Berthe <mikael@lilotux.net>
parents:
503
diff
changeset
|
2501 |
// - half a screen if nblines is 0, |
5a2132ba2220
Add "/buffer up" and "/buffer down"
Mikael Berthe <mikael@lilotux.net>
parents:
503
diff
changeset
|
2502 |
// - up if updown == -1, down if updown == 1 |
1780
e4378fbab5d7
Major API cleanup - bump API to 4
Mikael Berthe <mikael@lilotux.net>
parents:
1761
diff
changeset
|
2503 |
void scr_buffer_scroll_up_down(int updown, unsigned int nblines) |
105 | 2504 |
{ |
822 | 2505 |
winbuf *win_entry; |
508
5a2132ba2220
Add "/buffer up" and "/buffer down"
Mikael Berthe <mikael@lilotux.net>
parents:
503
diff
changeset
|
2506 |
int n, nbl; |
105 | 2507 |
GList *hbuf_top; |
849
42c43a88d823
Status buffer management
Mikael Berthe <mikael@lilotux.net>
parents:
848
diff
changeset
|
2508 |
guint isspe; |
105 | 2509 |
|
2510 |
// Get win_entry |
|
361
51ff319947c3
Code cleanup/optimization
Mikael Berthe <mikael@lilotux.net>
parents:
358
diff
changeset
|
2511 |
if (!current_buddy) return; |
849
42c43a88d823
Status buffer management
Mikael Berthe <mikael@lilotux.net>
parents:
848
diff
changeset
|
2512 |
|
42c43a88d823
Status buffer management
Mikael Berthe <mikael@lilotux.net>
parents:
848
diff
changeset
|
2513 |
isspe = buddy_gettype(BUDDATA(current_buddy)) & ROSTER_TYPE_SPECIAL; |
1780
e4378fbab5d7
Major API cleanup - bump API to 4
Mikael Berthe <mikael@lilotux.net>
parents:
1761
diff
changeset
|
2514 |
win_entry = scr_search_window(CURRENT_JID, isspe); |
361
51ff319947c3
Code cleanup/optimization
Mikael Berthe <mikael@lilotux.net>
parents:
358
diff
changeset
|
2515 |
if (!win_entry) return; |
105 | 2516 |
|
508
5a2132ba2220
Add "/buffer up" and "/buffer down"
Mikael Berthe <mikael@lilotux.net>
parents:
503
diff
changeset
|
2517 |
if (!nblines) { |
5a2132ba2220
Add "/buffer up" and "/buffer down"
Mikael Berthe <mikael@lilotux.net>
parents:
503
diff
changeset
|
2518 |
// Scroll half a screen (or less) |
512 | 2519 |
nbl = CHAT_WIN_HEIGHT/2; |
508
5a2132ba2220
Add "/buffer up" and "/buffer down"
Mikael Berthe <mikael@lilotux.net>
parents:
503
diff
changeset
|
2520 |
} else { |
5a2132ba2220
Add "/buffer up" and "/buffer down"
Mikael Berthe <mikael@lilotux.net>
parents:
503
diff
changeset
|
2521 |
nbl = nblines; |
5a2132ba2220
Add "/buffer up" and "/buffer down"
Mikael Berthe <mikael@lilotux.net>
parents:
503
diff
changeset
|
2522 |
} |
1157
5c857f0f0ab8
Moved all variables related to hbuf to an extra struct, bufdata
Frank Zschockelt
parents:
1156
diff
changeset
|
2523 |
hbuf_top = win_entry->bd->top; |
105 | 2524 |
|
361
51ff319947c3
Code cleanup/optimization
Mikael Berthe <mikael@lilotux.net>
parents:
358
diff
changeset
|
2525 |
if (updown == -1) { // UP |
51ff319947c3
Code cleanup/optimization
Mikael Berthe <mikael@lilotux.net>
parents:
358
diff
changeset
|
2526 |
if (!hbuf_top) { |
1157
5c857f0f0ab8
Moved all variables related to hbuf to an extra struct, bufdata
Frank Zschockelt
parents:
1156
diff
changeset
|
2527 |
hbuf_top = g_list_last(win_entry->bd->hbuf); |
5c857f0f0ab8
Moved all variables related to hbuf to an extra struct, bufdata
Frank Zschockelt
parents:
1156
diff
changeset
|
2528 |
if (!win_entry->bd->cleared) { |
512 | 2529 |
if (!nblines) nbl = nbl*3 - 1; |
2530 |
else nbl += CHAT_WIN_HEIGHT - 1; |
|
2531 |
} else { |
|
1157
5c857f0f0ab8
Moved all variables related to hbuf to an extra struct, bufdata
Frank Zschockelt
parents:
1156
diff
changeset
|
2532 |
win_entry->bd->cleared = FALSE; |
512 | 2533 |
} |
361
51ff319947c3
Code cleanup/optimization
Mikael Berthe <mikael@lilotux.net>
parents:
358
diff
changeset
|
2534 |
} |
508
5a2132ba2220
Add "/buffer up" and "/buffer down"
Mikael Berthe <mikael@lilotux.net>
parents:
503
diff
changeset
|
2535 |
for (n=0 ; hbuf_top && n < nbl && g_list_previous(hbuf_top) ; n++) |
361
51ff319947c3
Code cleanup/optimization
Mikael Berthe <mikael@lilotux.net>
parents:
358
diff
changeset
|
2536 |
hbuf_top = g_list_previous(hbuf_top); |
1157
5c857f0f0ab8
Moved all variables related to hbuf to an extra struct, bufdata
Frank Zschockelt
parents:
1156
diff
changeset
|
2537 |
win_entry->bd->top = hbuf_top; |
361
51ff319947c3
Code cleanup/optimization
Mikael Berthe <mikael@lilotux.net>
parents:
358
diff
changeset
|
2538 |
} else { // DOWN |
508
5a2132ba2220
Add "/buffer up" and "/buffer down"
Mikael Berthe <mikael@lilotux.net>
parents:
503
diff
changeset
|
2539 |
for (n=0 ; hbuf_top && n < nbl ; n++) |
361
51ff319947c3
Code cleanup/optimization
Mikael Berthe <mikael@lilotux.net>
parents:
358
diff
changeset
|
2540 |
hbuf_top = g_list_next(hbuf_top); |
1157
5c857f0f0ab8
Moved all variables related to hbuf to an extra struct, bufdata
Frank Zschockelt
parents:
1156
diff
changeset
|
2541 |
win_entry->bd->top = hbuf_top; |
361
51ff319947c3
Code cleanup/optimization
Mikael Berthe <mikael@lilotux.net>
parents:
358
diff
changeset
|
2542 |
// Check if we are at the bottom |
51ff319947c3
Code cleanup/optimization
Mikael Berthe <mikael@lilotux.net>
parents:
358
diff
changeset
|
2543 |
for (n=0 ; hbuf_top && n < CHAT_WIN_HEIGHT-1 ; n++) |
51ff319947c3
Code cleanup/optimization
Mikael Berthe <mikael@lilotux.net>
parents:
358
diff
changeset
|
2544 |
hbuf_top = g_list_next(hbuf_top); |
51ff319947c3
Code cleanup/optimization
Mikael Berthe <mikael@lilotux.net>
parents:
358
diff
changeset
|
2545 |
if (!hbuf_top) |
1157
5c857f0f0ab8
Moved all variables related to hbuf to an extra struct, bufdata
Frank Zschockelt
parents:
1156
diff
changeset
|
2546 |
win_entry->bd->top = NULL; // End reached |
361
51ff319947c3
Code cleanup/optimization
Mikael Berthe <mikael@lilotux.net>
parents:
358
diff
changeset
|
2547 |
} |
105 | 2548 |
|
2549 |
// Refresh the window |
|
1780
e4378fbab5d7
Major API cleanup - bump API to 4
Mikael Berthe <mikael@lilotux.net>
parents:
1761
diff
changeset
|
2550 |
scr_update_window(win_entry); |
105 | 2551 |
|
2552 |
// Finished :) |
|
2553 |
update_panels(); |
|
2554 |
} |
|
2555 |
||
1780
e4378fbab5d7
Major API cleanup - bump API to 4
Mikael Berthe <mikael@lilotux.net>
parents:
1761
diff
changeset
|
2556 |
// scr_buffer_clear() |
143 | 2557 |
// Clear the current buddy window (used for the /clear command) |
1780
e4378fbab5d7
Major API cleanup - bump API to 4
Mikael Berthe <mikael@lilotux.net>
parents:
1761
diff
changeset
|
2558 |
void scr_buffer_clear(void) |
108 | 2559 |
{ |
822 | 2560 |
winbuf *win_entry; |
849
42c43a88d823
Status buffer management
Mikael Berthe <mikael@lilotux.net>
parents:
848
diff
changeset
|
2561 |
guint isspe; |
108 | 2562 |
|
2563 |
// Get win_entry |
|
361
51ff319947c3
Code cleanup/optimization
Mikael Berthe <mikael@lilotux.net>
parents:
358
diff
changeset
|
2564 |
if (!current_buddy) return; |
849
42c43a88d823
Status buffer management
Mikael Berthe <mikael@lilotux.net>
parents:
848
diff
changeset
|
2565 |
isspe = buddy_gettype(BUDDATA(current_buddy)) & ROSTER_TYPE_SPECIAL; |
1780
e4378fbab5d7
Major API cleanup - bump API to 4
Mikael Berthe <mikael@lilotux.net>
parents:
1761
diff
changeset
|
2566 |
win_entry = scr_search_window(CURRENT_JID, isspe); |
361
51ff319947c3
Code cleanup/optimization
Mikael Berthe <mikael@lilotux.net>
parents:
358
diff
changeset
|
2567 |
if (!win_entry) return; |
108 | 2568 |
|
1157
5c857f0f0ab8
Moved all variables related to hbuf to an extra struct, bufdata
Frank Zschockelt
parents:
1156
diff
changeset
|
2569 |
win_entry->bd->cleared = TRUE; |
5c857f0f0ab8
Moved all variables related to hbuf to an extra struct, bufdata
Frank Zschockelt
parents:
1156
diff
changeset
|
2570 |
win_entry->bd->top = NULL; |
108 | 2571 |
|
2572 |
// Refresh the window |
|
1780
e4378fbab5d7
Major API cleanup - bump API to 4
Mikael Berthe <mikael@lilotux.net>
parents:
1761
diff
changeset
|
2573 |
scr_update_window(win_entry); |
108 | 2574 |
|
2575 |
// Finished :) |
|
2576 |
update_panels(); |
|
2577 |
} |
|
2578 |
||
1138
8ba4b1e8b42d
Add command /buffer close_all
Mikael Berthe <mikael@lilotux.net>
parents:
1137
diff
changeset
|
2579 |
// buffer_purge() |
8ba4b1e8b42d
Add command /buffer close_all
Mikael Berthe <mikael@lilotux.net>
parents:
1137
diff
changeset
|
2580 |
// key: winId/jid |
8ba4b1e8b42d
Add command /buffer close_all
Mikael Berthe <mikael@lilotux.net>
parents:
1137
diff
changeset
|
2581 |
// value: winbuf structure |
8ba4b1e8b42d
Add command /buffer close_all
Mikael Berthe <mikael@lilotux.net>
parents:
1137
diff
changeset
|
2582 |
// data: int, set to 1 if the buffer should be closed. |
8ba4b1e8b42d
Add command /buffer close_all
Mikael Berthe <mikael@lilotux.net>
parents:
1137
diff
changeset
|
2583 |
// NOTE: does not work for special buffers. |
8ba4b1e8b42d
Add command /buffer close_all
Mikael Berthe <mikael@lilotux.net>
parents:
1137
diff
changeset
|
2584 |
static void buffer_purge(gpointer key, gpointer value, gpointer data) |
8ba4b1e8b42d
Add command /buffer close_all
Mikael Berthe <mikael@lilotux.net>
parents:
1137
diff
changeset
|
2585 |
{ |
1225
0e9e9724d643
Fix a bad type cast in buffer_purge()
Mikael Berthe <mikael@lilotux.net>
parents:
1209
diff
changeset
|
2586 |
int *p_closebuf = data; |
1138
8ba4b1e8b42d
Add command /buffer close_all
Mikael Berthe <mikael@lilotux.net>
parents:
1137
diff
changeset
|
2587 |
winbuf *win_entry = value; |
8ba4b1e8b42d
Add command /buffer close_all
Mikael Berthe <mikael@lilotux.net>
parents:
1137
diff
changeset
|
2588 |
|
8ba4b1e8b42d
Add command /buffer close_all
Mikael Berthe <mikael@lilotux.net>
parents:
1137
diff
changeset
|
2589 |
// Delete the current hbuf |
1157
5c857f0f0ab8
Moved all variables related to hbuf to an extra struct, bufdata
Frank Zschockelt
parents:
1156
diff
changeset
|
2590 |
hbuf_free(&win_entry->bd->hbuf); |
1138
8ba4b1e8b42d
Add command /buffer close_all
Mikael Berthe <mikael@lilotux.net>
parents:
1137
diff
changeset
|
2591 |
|
1225
0e9e9724d643
Fix a bad type cast in buffer_purge()
Mikael Berthe <mikael@lilotux.net>
parents:
1209
diff
changeset
|
2592 |
if (*p_closebuf) { |
1138
8ba4b1e8b42d
Add command /buffer close_all
Mikael Berthe <mikael@lilotux.net>
parents:
1137
diff
changeset
|
2593 |
g_hash_table_remove(winbufhash, key); |
8ba4b1e8b42d
Add command /buffer close_all
Mikael Berthe <mikael@lilotux.net>
parents:
1137
diff
changeset
|
2594 |
} else { |
1157
5c857f0f0ab8
Moved all variables related to hbuf to an extra struct, bufdata
Frank Zschockelt
parents:
1156
diff
changeset
|
2595 |
win_entry->bd->cleared = FALSE; |
5c857f0f0ab8
Moved all variables related to hbuf to an extra struct, bufdata
Frank Zschockelt
parents:
1156
diff
changeset
|
2596 |
win_entry->bd->top = NULL; |
1138
8ba4b1e8b42d
Add command /buffer close_all
Mikael Berthe <mikael@lilotux.net>
parents:
1137
diff
changeset
|
2597 |
} |
8ba4b1e8b42d
Add command /buffer close_all
Mikael Berthe <mikael@lilotux.net>
parents:
1137
diff
changeset
|
2598 |
} |
8ba4b1e8b42d
Add command /buffer close_all
Mikael Berthe <mikael@lilotux.net>
parents:
1137
diff
changeset
|
2599 |
|
1780
e4378fbab5d7
Major API cleanup - bump API to 4
Mikael Berthe <mikael@lilotux.net>
parents:
1761
diff
changeset
|
2600 |
// scr_buffer_purge(closebuf, jid) |
1279
8bbc764139ef
Implement /buffer close|purge [jid]
Mikael Berthe <mikael@lilotux.net>
parents:
1272
diff
changeset
|
2601 |
// Purge/Drop the current buddy buffer or jid's buffer if jid != NULL. |
1135
5d7c05932b13
Add command /buffer close
Mikael Berthe <mikael@lilotux.net>
parents:
1133
diff
changeset
|
2602 |
// If closebuf is 1, close the buffer. |
1780
e4378fbab5d7
Major API cleanup - bump API to 4
Mikael Berthe <mikael@lilotux.net>
parents:
1761
diff
changeset
|
2603 |
void scr_buffer_purge(int closebuf, const char *jid) |
866 | 2604 |
{ |
2605 |
winbuf *win_entry; |
|
2606 |
guint isspe; |
|
1225
0e9e9724d643
Fix a bad type cast in buffer_purge()
Mikael Berthe <mikael@lilotux.net>
parents:
1209
diff
changeset
|
2607 |
guint *p_closebuf; |
1279
8bbc764139ef
Implement /buffer close|purge [jid]
Mikael Berthe <mikael@lilotux.net>
parents:
1272
diff
changeset
|
2608 |
const char *cjid; |
1345
8e4e741787be
Small change to buffer close
Mikael Berthe <mikael@lilotux.net>
parents:
1333
diff
changeset
|
2609 |
guint hold_chatmode = FALSE; |
1279
8bbc764139ef
Implement /buffer close|purge [jid]
Mikael Berthe <mikael@lilotux.net>
parents:
1272
diff
changeset
|
2610 |
|
8bbc764139ef
Implement /buffer close|purge [jid]
Mikael Berthe <mikael@lilotux.net>
parents:
1272
diff
changeset
|
2611 |
if (jid) { |
8bbc764139ef
Implement /buffer close|purge [jid]
Mikael Berthe <mikael@lilotux.net>
parents:
1272
diff
changeset
|
2612 |
cjid = jid; |
8bbc764139ef
Implement /buffer close|purge [jid]
Mikael Berthe <mikael@lilotux.net>
parents:
1272
diff
changeset
|
2613 |
isspe = FALSE; |
1345
8e4e741787be
Small change to buffer close
Mikael Berthe <mikael@lilotux.net>
parents:
1333
diff
changeset
|
2614 |
// If closebuf is TRUE, it's probably better not to leave chat mode |
8e4e741787be
Small change to buffer close
Mikael Berthe <mikael@lilotux.net>
parents:
1333
diff
changeset
|
2615 |
// if the change isn't related to the current buffer. |
8e4e741787be
Small change to buffer close
Mikael Berthe <mikael@lilotux.net>
parents:
1333
diff
changeset
|
2616 |
if (closebuf && current_buddy) { |
8e4e741787be
Small change to buffer close
Mikael Berthe <mikael@lilotux.net>
parents:
1333
diff
changeset
|
2617 |
if (buddy_gettype(BUDDATA(current_buddy)) & ROSTER_TYPE_SPECIAL || |
8e4e741787be
Small change to buffer close
Mikael Berthe <mikael@lilotux.net>
parents:
1333
diff
changeset
|
2618 |
strcasecmp(jid, CURRENT_JID)) |
8e4e741787be
Small change to buffer close
Mikael Berthe <mikael@lilotux.net>
parents:
1333
diff
changeset
|
2619 |
hold_chatmode = TRUE; |
8e4e741787be
Small change to buffer close
Mikael Berthe <mikael@lilotux.net>
parents:
1333
diff
changeset
|
2620 |
} |
1279
8bbc764139ef
Implement /buffer close|purge [jid]
Mikael Berthe <mikael@lilotux.net>
parents:
1272
diff
changeset
|
2621 |
} else { |
8bbc764139ef
Implement /buffer close|purge [jid]
Mikael Berthe <mikael@lilotux.net>
parents:
1272
diff
changeset
|
2622 |
// Get win_entry |
8bbc764139ef
Implement /buffer close|purge [jid]
Mikael Berthe <mikael@lilotux.net>
parents:
1272
diff
changeset
|
2623 |
if (!current_buddy) return; |
8bbc764139ef
Implement /buffer close|purge [jid]
Mikael Berthe <mikael@lilotux.net>
parents:
1272
diff
changeset
|
2624 |
cjid = CURRENT_JID; |
8bbc764139ef
Implement /buffer close|purge [jid]
Mikael Berthe <mikael@lilotux.net>
parents:
1272
diff
changeset
|
2625 |
isspe = buddy_gettype(BUDDATA(current_buddy)) & ROSTER_TYPE_SPECIAL; |
8bbc764139ef
Implement /buffer close|purge [jid]
Mikael Berthe <mikael@lilotux.net>
parents:
1272
diff
changeset
|
2626 |
} |
1780
e4378fbab5d7
Major API cleanup - bump API to 4
Mikael Berthe <mikael@lilotux.net>
parents:
1761
diff
changeset
|
2627 |
win_entry = scr_search_window(cjid, isspe); |
866 | 2628 |
if (!win_entry) return; |
2629 |
||
1138
8ba4b1e8b42d
Add command /buffer close_all
Mikael Berthe <mikael@lilotux.net>
parents:
1137
diff
changeset
|
2630 |
if (!isspe) { |
1225
0e9e9724d643
Fix a bad type cast in buffer_purge()
Mikael Berthe <mikael@lilotux.net>
parents:
1209
diff
changeset
|
2631 |
p_closebuf = g_new(guint, 1); |
0e9e9724d643
Fix a bad type cast in buffer_purge()
Mikael Berthe <mikael@lilotux.net>
parents:
1209
diff
changeset
|
2632 |
*p_closebuf = closebuf; |
1279
8bbc764139ef
Implement /buffer close|purge [jid]
Mikael Berthe <mikael@lilotux.net>
parents:
1272
diff
changeset
|
2633 |
buffer_purge((gpointer)cjid, win_entry, p_closebuf); |
1700
87dd0a8f1a9c
Remove the "new message" flag when a buffer is purged with /buffer purge
Mikael Berthe <mikael@lilotux.net>
parents:
1694
diff
changeset
|
2634 |
roster_msg_setflag(cjid, FALSE, FALSE); |
1225
0e9e9724d643
Fix a bad type cast in buffer_purge()
Mikael Berthe <mikael@lilotux.net>
parents:
1209
diff
changeset
|
2635 |
g_free(p_closebuf); |
1345
8e4e741787be
Small change to buffer close
Mikael Berthe <mikael@lilotux.net>
parents:
1333
diff
changeset
|
2636 |
if (closebuf && !hold_chatmode) { |
1138
8ba4b1e8b42d
Add command /buffer close_all
Mikael Berthe <mikael@lilotux.net>
parents:
1137
diff
changeset
|
2637 |
scr_set_chatmode(FALSE); |
8ba4b1e8b42d
Add command /buffer close_all
Mikael Berthe <mikael@lilotux.net>
parents:
1137
diff
changeset
|
2638 |
currentWindow = NULL; |
8ba4b1e8b42d
Add command /buffer close_all
Mikael Berthe <mikael@lilotux.net>
parents:
1137
diff
changeset
|
2639 |
} |
8ba4b1e8b42d
Add command /buffer close_all
Mikael Berthe <mikael@lilotux.net>
parents:
1137
diff
changeset
|
2640 |
} else { |
8ba4b1e8b42d
Add command /buffer close_all
Mikael Berthe <mikael@lilotux.net>
parents:
1137
diff
changeset
|
2641 |
// (Special buffer) |
8ba4b1e8b42d
Add command /buffer close_all
Mikael Berthe <mikael@lilotux.net>
parents:
1137
diff
changeset
|
2642 |
// Reset the current hbuf |
1157
5c857f0f0ab8
Moved all variables related to hbuf to an extra struct, bufdata
Frank Zschockelt
parents:
1156
diff
changeset
|
2643 |
hbuf_free(&win_entry->bd->hbuf); |
866 | 2644 |
// Currently it can only be the status buffer |
2645 |
statushbuf = NULL; |
|
1700
87dd0a8f1a9c
Remove the "new message" flag when a buffer is purged with /buffer purge
Mikael Berthe <mikael@lilotux.net>
parents:
1694
diff
changeset
|
2646 |
roster_msg_setflag(SPECIAL_BUFFER_STATUS_ID, TRUE, FALSE); |
1138
8ba4b1e8b42d
Add command /buffer close_all
Mikael Berthe <mikael@lilotux.net>
parents:
1137
diff
changeset
|
2647 |
|
1157
5c857f0f0ab8
Moved all variables related to hbuf to an extra struct, bufdata
Frank Zschockelt
parents:
1156
diff
changeset
|
2648 |
win_entry->bd->cleared = FALSE; |
5c857f0f0ab8
Moved all variables related to hbuf to an extra struct, bufdata
Frank Zschockelt
parents:
1156
diff
changeset
|
2649 |
win_entry->bd->top = NULL; |
866 | 2650 |
} |
2651 |
||
1700
87dd0a8f1a9c
Remove the "new message" flag when a buffer is purged with /buffer purge
Mikael Berthe <mikael@lilotux.net>
parents:
1694
diff
changeset
|
2652 |
update_roster = TRUE; |
87dd0a8f1a9c
Remove the "new message" flag when a buffer is purged with /buffer purge
Mikael Berthe <mikael@lilotux.net>
parents:
1694
diff
changeset
|
2653 |
|
1138
8ba4b1e8b42d
Add command /buffer close_all
Mikael Berthe <mikael@lilotux.net>
parents:
1137
diff
changeset
|
2654 |
// Refresh the window |
1780
e4378fbab5d7
Major API cleanup - bump API to 4
Mikael Berthe <mikael@lilotux.net>
parents:
1761
diff
changeset
|
2655 |
scr_update_buddy_window(); |
1138
8ba4b1e8b42d
Add command /buffer close_all
Mikael Berthe <mikael@lilotux.net>
parents:
1137
diff
changeset
|
2656 |
|
8ba4b1e8b42d
Add command /buffer close_all
Mikael Berthe <mikael@lilotux.net>
parents:
1137
diff
changeset
|
2657 |
// Finished :) |
8ba4b1e8b42d
Add command /buffer close_all
Mikael Berthe <mikael@lilotux.net>
parents:
1137
diff
changeset
|
2658 |
update_panels(); |
8ba4b1e8b42d
Add command /buffer close_all
Mikael Berthe <mikael@lilotux.net>
parents:
1137
diff
changeset
|
2659 |
} |
8ba4b1e8b42d
Add command /buffer close_all
Mikael Berthe <mikael@lilotux.net>
parents:
1137
diff
changeset
|
2660 |
|
1780
e4378fbab5d7
Major API cleanup - bump API to 4
Mikael Berthe <mikael@lilotux.net>
parents:
1761
diff
changeset
|
2661 |
// scr_buffer_purge_all(closebuf) |
e4378fbab5d7
Major API cleanup - bump API to 4
Mikael Berthe <mikael@lilotux.net>
parents:
1761
diff
changeset
|
2662 |
// Purge all existing buffers. |
e4378fbab5d7
Major API cleanup - bump API to 4
Mikael Berthe <mikael@lilotux.net>
parents:
1761
diff
changeset
|
2663 |
// If closebuf is 1, the buffers are closed. |
e4378fbab5d7
Major API cleanup - bump API to 4
Mikael Berthe <mikael@lilotux.net>
parents:
1761
diff
changeset
|
2664 |
void scr_buffer_purge_all(int closebuf) |
1138
8ba4b1e8b42d
Add command /buffer close_all
Mikael Berthe <mikael@lilotux.net>
parents:
1137
diff
changeset
|
2665 |
{ |
1225
0e9e9724d643
Fix a bad type cast in buffer_purge()
Mikael Berthe <mikael@lilotux.net>
parents:
1209
diff
changeset
|
2666 |
guint *p_closebuf; |
0e9e9724d643
Fix a bad type cast in buffer_purge()
Mikael Berthe <mikael@lilotux.net>
parents:
1209
diff
changeset
|
2667 |
p_closebuf = g_new(guint, 1); |
0e9e9724d643
Fix a bad type cast in buffer_purge()
Mikael Berthe <mikael@lilotux.net>
parents:
1209
diff
changeset
|
2668 |
|
0e9e9724d643
Fix a bad type cast in buffer_purge()
Mikael Berthe <mikael@lilotux.net>
parents:
1209
diff
changeset
|
2669 |
*p_closebuf = closebuf; |
0e9e9724d643
Fix a bad type cast in buffer_purge()
Mikael Berthe <mikael@lilotux.net>
parents:
1209
diff
changeset
|
2670 |
g_hash_table_foreach(winbufhash, buffer_purge, p_closebuf); |
0e9e9724d643
Fix a bad type cast in buffer_purge()
Mikael Berthe <mikael@lilotux.net>
parents:
1209
diff
changeset
|
2671 |
g_free(p_closebuf); |
1138
8ba4b1e8b42d
Add command /buffer close_all
Mikael Berthe <mikael@lilotux.net>
parents:
1137
diff
changeset
|
2672 |
|
8ba4b1e8b42d
Add command /buffer close_all
Mikael Berthe <mikael@lilotux.net>
parents:
1137
diff
changeset
|
2673 |
if (closebuf) { |
1135
5d7c05932b13
Add command /buffer close
Mikael Berthe <mikael@lilotux.net>
parents:
1133
diff
changeset
|
2674 |
scr_set_chatmode(FALSE); |
1137
5752017f6e2b
Fix a bug in /buffer close
Mikael Berthe <mikael@lilotux.net>
parents:
1135
diff
changeset
|
2675 |
currentWindow = NULL; |
1135
5d7c05932b13
Add command /buffer close
Mikael Berthe <mikael@lilotux.net>
parents:
1133
diff
changeset
|
2676 |
} |
5d7c05932b13
Add command /buffer close
Mikael Berthe <mikael@lilotux.net>
parents:
1133
diff
changeset
|
2677 |
|
866 | 2678 |
// Refresh the window |
1780
e4378fbab5d7
Major API cleanup - bump API to 4
Mikael Berthe <mikael@lilotux.net>
parents:
1761
diff
changeset
|
2679 |
scr_update_buddy_window(); |
866 | 2680 |
|
2681 |
// Finished :) |
|
2682 |
update_panels(); |
|
2683 |
} |
|
2684 |
||
1780
e4378fbab5d7
Major API cleanup - bump API to 4
Mikael Berthe <mikael@lilotux.net>
parents:
1761
diff
changeset
|
2685 |
// scr_buffer_scroll_lock(lock) |
873
ee39f6d94d43
Add /buffer {scroll_lock|scroll_unlock|toggle_scroll}
Mikael Berthe <mikael@lilotux.net>
parents:
866
diff
changeset
|
2686 |
// Lock/unlock the current buddy buffer |
ee39f6d94d43
Add /buffer {scroll_lock|scroll_unlock|toggle_scroll}
Mikael Berthe <mikael@lilotux.net>
parents:
866
diff
changeset
|
2687 |
// lock = 1 : lock |
ee39f6d94d43
Add /buffer {scroll_lock|scroll_unlock|toggle_scroll}
Mikael Berthe <mikael@lilotux.net>
parents:
866
diff
changeset
|
2688 |
// lock = 0 : unlock |
ee39f6d94d43
Add /buffer {scroll_lock|scroll_unlock|toggle_scroll}
Mikael Berthe <mikael@lilotux.net>
parents:
866
diff
changeset
|
2689 |
// lock = -1: toggle lock status |
1780
e4378fbab5d7
Major API cleanup - bump API to 4
Mikael Berthe <mikael@lilotux.net>
parents:
1761
diff
changeset
|
2690 |
void scr_buffer_scroll_lock(int lock) |
873
ee39f6d94d43
Add /buffer {scroll_lock|scroll_unlock|toggle_scroll}
Mikael Berthe <mikael@lilotux.net>
parents:
866
diff
changeset
|
2691 |
{ |
ee39f6d94d43
Add /buffer {scroll_lock|scroll_unlock|toggle_scroll}
Mikael Berthe <mikael@lilotux.net>
parents:
866
diff
changeset
|
2692 |
winbuf *win_entry; |
ee39f6d94d43
Add /buffer {scroll_lock|scroll_unlock|toggle_scroll}
Mikael Berthe <mikael@lilotux.net>
parents:
866
diff
changeset
|
2693 |
guint isspe; |
ee39f6d94d43
Add /buffer {scroll_lock|scroll_unlock|toggle_scroll}
Mikael Berthe <mikael@lilotux.net>
parents:
866
diff
changeset
|
2694 |
|
ee39f6d94d43
Add /buffer {scroll_lock|scroll_unlock|toggle_scroll}
Mikael Berthe <mikael@lilotux.net>
parents:
866
diff
changeset
|
2695 |
// Get win_entry |
ee39f6d94d43
Add /buffer {scroll_lock|scroll_unlock|toggle_scroll}
Mikael Berthe <mikael@lilotux.net>
parents:
866
diff
changeset
|
2696 |
if (!current_buddy) return; |
ee39f6d94d43
Add /buffer {scroll_lock|scroll_unlock|toggle_scroll}
Mikael Berthe <mikael@lilotux.net>
parents:
866
diff
changeset
|
2697 |
isspe = buddy_gettype(BUDDATA(current_buddy)) & ROSTER_TYPE_SPECIAL; |
1780
e4378fbab5d7
Major API cleanup - bump API to 4
Mikael Berthe <mikael@lilotux.net>
parents:
1761
diff
changeset
|
2698 |
win_entry = scr_search_window(CURRENT_JID, isspe); |
873
ee39f6d94d43
Add /buffer {scroll_lock|scroll_unlock|toggle_scroll}
Mikael Berthe <mikael@lilotux.net>
parents:
866
diff
changeset
|
2699 |
if (!win_entry) return; |
ee39f6d94d43
Add /buffer {scroll_lock|scroll_unlock|toggle_scroll}
Mikael Berthe <mikael@lilotux.net>
parents:
866
diff
changeset
|
2700 |
|
ee39f6d94d43
Add /buffer {scroll_lock|scroll_unlock|toggle_scroll}
Mikael Berthe <mikael@lilotux.net>
parents:
866
diff
changeset
|
2701 |
if (lock == -1) |
1157
5c857f0f0ab8
Moved all variables related to hbuf to an extra struct, bufdata
Frank Zschockelt
parents:
1156
diff
changeset
|
2702 |
lock = !win_entry->bd->lock; |
873
ee39f6d94d43
Add /buffer {scroll_lock|scroll_unlock|toggle_scroll}
Mikael Berthe <mikael@lilotux.net>
parents:
866
diff
changeset
|
2703 |
|
ee39f6d94d43
Add /buffer {scroll_lock|scroll_unlock|toggle_scroll}
Mikael Berthe <mikael@lilotux.net>
parents:
866
diff
changeset
|
2704 |
if (lock) { |
1157
5c857f0f0ab8
Moved all variables related to hbuf to an extra struct, bufdata
Frank Zschockelt
parents:
1156
diff
changeset
|
2705 |
win_entry->bd->lock = TRUE; |
873
ee39f6d94d43
Add /buffer {scroll_lock|scroll_unlock|toggle_scroll}
Mikael Berthe <mikael@lilotux.net>
parents:
866
diff
changeset
|
2706 |
} else { |
1157
5c857f0f0ab8
Moved all variables related to hbuf to an extra struct, bufdata
Frank Zschockelt
parents:
1156
diff
changeset
|
2707 |
win_entry->bd->lock = FALSE; |
880
ea983a945eba
/buffer scroll_unlock: Don't always jump to the end of the buffer
Mikael Berthe <mikael@lilotux.net>
parents:
878
diff
changeset
|
2708 |
if (isspe || (buddy_getflags(BUDDATA(current_buddy)) & ROSTER_FLAG_MSG)) |
1157
5c857f0f0ab8
Moved all variables related to hbuf to an extra struct, bufdata
Frank Zschockelt
parents:
1156
diff
changeset
|
2709 |
win_entry->bd->top = NULL; |
873
ee39f6d94d43
Add /buffer {scroll_lock|scroll_unlock|toggle_scroll}
Mikael Berthe <mikael@lilotux.net>
parents:
866
diff
changeset
|
2710 |
} |
ee39f6d94d43
Add /buffer {scroll_lock|scroll_unlock|toggle_scroll}
Mikael Berthe <mikael@lilotux.net>
parents:
866
diff
changeset
|
2711 |
|
ee39f6d94d43
Add /buffer {scroll_lock|scroll_unlock|toggle_scroll}
Mikael Berthe <mikael@lilotux.net>
parents:
866
diff
changeset
|
2712 |
// If chatmode is disabled and we're at the bottom of the buffer, |
1780
e4378fbab5d7
Major API cleanup - bump API to 4
Mikael Berthe <mikael@lilotux.net>
parents:
1761
diff
changeset
|
2713 |
// we need to set the "top" line, so we need to call scr_show_buddy_window() |
873
ee39f6d94d43
Add /buffer {scroll_lock|scroll_unlock|toggle_scroll}
Mikael Berthe <mikael@lilotux.net>
parents:
866
diff
changeset
|
2714 |
// at least once. (Maybe it will cause a double refresh...) |
1157
5c857f0f0ab8
Moved all variables related to hbuf to an extra struct, bufdata
Frank Zschockelt
parents:
1156
diff
changeset
|
2715 |
if (!chatmode && !win_entry->bd->top) { |
873
ee39f6d94d43
Add /buffer {scroll_lock|scroll_unlock|toggle_scroll}
Mikael Berthe <mikael@lilotux.net>
parents:
866
diff
changeset
|
2716 |
chatmode = TRUE; |
1780
e4378fbab5d7
Major API cleanup - bump API to 4
Mikael Berthe <mikael@lilotux.net>
parents:
1761
diff
changeset
|
2717 |
scr_show_buddy_window(); |
873
ee39f6d94d43
Add /buffer {scroll_lock|scroll_unlock|toggle_scroll}
Mikael Berthe <mikael@lilotux.net>
parents:
866
diff
changeset
|
2718 |
chatmode = FALSE; |
ee39f6d94d43
Add /buffer {scroll_lock|scroll_unlock|toggle_scroll}
Mikael Berthe <mikael@lilotux.net>
parents:
866
diff
changeset
|
2719 |
} |
ee39f6d94d43
Add /buffer {scroll_lock|scroll_unlock|toggle_scroll}
Mikael Berthe <mikael@lilotux.net>
parents:
866
diff
changeset
|
2720 |
|
ee39f6d94d43
Add /buffer {scroll_lock|scroll_unlock|toggle_scroll}
Mikael Berthe <mikael@lilotux.net>
parents:
866
diff
changeset
|
2721 |
// Refresh the window |
1780
e4378fbab5d7
Major API cleanup - bump API to 4
Mikael Berthe <mikael@lilotux.net>
parents:
1761
diff
changeset
|
2722 |
scr_update_buddy_window(); |
873
ee39f6d94d43
Add /buffer {scroll_lock|scroll_unlock|toggle_scroll}
Mikael Berthe <mikael@lilotux.net>
parents:
866
diff
changeset
|
2723 |
|
ee39f6d94d43
Add /buffer {scroll_lock|scroll_unlock|toggle_scroll}
Mikael Berthe <mikael@lilotux.net>
parents:
866
diff
changeset
|
2724 |
// Finished :) |
ee39f6d94d43
Add /buffer {scroll_lock|scroll_unlock|toggle_scroll}
Mikael Berthe <mikael@lilotux.net>
parents:
866
diff
changeset
|
2725 |
update_panels(); |
ee39f6d94d43
Add /buffer {scroll_lock|scroll_unlock|toggle_scroll}
Mikael Berthe <mikael@lilotux.net>
parents:
866
diff
changeset
|
2726 |
} |
ee39f6d94d43
Add /buffer {scroll_lock|scroll_unlock|toggle_scroll}
Mikael Berthe <mikael@lilotux.net>
parents:
866
diff
changeset
|
2727 |
|
1780
e4378fbab5d7
Major API cleanup - bump API to 4
Mikael Berthe <mikael@lilotux.net>
parents:
1761
diff
changeset
|
2728 |
// scr_buffer_top_bottom() |
361
51ff319947c3
Code cleanup/optimization
Mikael Berthe <mikael@lilotux.net>
parents:
358
diff
changeset
|
2729 |
// Jump to the head/tail of the current buddy window |
51ff319947c3
Code cleanup/optimization
Mikael Berthe <mikael@lilotux.net>
parents:
358
diff
changeset
|
2730 |
// (top if topbottom == -1, bottom topbottom == 1) |
1780
e4378fbab5d7
Major API cleanup - bump API to 4
Mikael Berthe <mikael@lilotux.net>
parents:
1761
diff
changeset
|
2731 |
void scr_buffer_top_bottom(int topbottom) |
187 | 2732 |
{ |
822 | 2733 |
winbuf *win_entry; |
849
42c43a88d823
Status buffer management
Mikael Berthe <mikael@lilotux.net>
parents:
848
diff
changeset
|
2734 |
guint isspe; |
187 | 2735 |
|
2736 |
// Get win_entry |
|
2737 |
if (!current_buddy) return; |
|
849
42c43a88d823
Status buffer management
Mikael Berthe <mikael@lilotux.net>
parents:
848
diff
changeset
|
2738 |
isspe = buddy_gettype(BUDDATA(current_buddy)) & ROSTER_TYPE_SPECIAL; |
1780
e4378fbab5d7
Major API cleanup - bump API to 4
Mikael Berthe <mikael@lilotux.net>
parents:
1761
diff
changeset
|
2739 |
win_entry = scr_search_window(CURRENT_JID, isspe); |
187 | 2740 |
if (!win_entry) return; |
2741 |
||
1157
5c857f0f0ab8
Moved all variables related to hbuf to an extra struct, bufdata
Frank Zschockelt
parents:
1156
diff
changeset
|
2742 |
win_entry->bd->cleared = FALSE; |
361
51ff319947c3
Code cleanup/optimization
Mikael Berthe <mikael@lilotux.net>
parents:
358
diff
changeset
|
2743 |
if (topbottom == 1) |
1157
5c857f0f0ab8
Moved all variables related to hbuf to an extra struct, bufdata
Frank Zschockelt
parents:
1156
diff
changeset
|
2744 |
win_entry->bd->top = NULL; |
361
51ff319947c3
Code cleanup/optimization
Mikael Berthe <mikael@lilotux.net>
parents:
358
diff
changeset
|
2745 |
else |
1157
5c857f0f0ab8
Moved all variables related to hbuf to an extra struct, bufdata
Frank Zschockelt
parents:
1156
diff
changeset
|
2746 |
win_entry->bd->top = g_list_first(win_entry->bd->hbuf); |
187 | 2747 |
|
2748 |
// Refresh the window |
|
1780
e4378fbab5d7
Major API cleanup - bump API to 4
Mikael Berthe <mikael@lilotux.net>
parents:
1761
diff
changeset
|
2749 |
scr_update_window(win_entry); |
187 | 2750 |
|
2751 |
// Finished :) |
|
2752 |
update_panels(); |
|
2753 |
} |
|
2754 |
||
1780
e4378fbab5d7
Major API cleanup - bump API to 4
Mikael Berthe <mikael@lilotux.net>
parents:
1761
diff
changeset
|
2755 |
// scr_buffer_search(direction, text) |
370
dd9e2eb52916
Add /buffer search_{backward,forward}
Mikael Berthe <mikael@lilotux.net>
parents:
369
diff
changeset
|
2756 |
// Jump to the next line containing text |
dd9e2eb52916
Add /buffer search_{backward,forward}
Mikael Berthe <mikael@lilotux.net>
parents:
369
diff
changeset
|
2757 |
// (backward search if direction == -1, forward if topbottom == 1) |
1780
e4378fbab5d7
Major API cleanup - bump API to 4
Mikael Berthe <mikael@lilotux.net>
parents:
1761
diff
changeset
|
2758 |
void scr_buffer_search(int direction, const char *text) |
370
dd9e2eb52916
Add /buffer search_{backward,forward}
Mikael Berthe <mikael@lilotux.net>
parents:
369
diff
changeset
|
2759 |
{ |
822 | 2760 |
winbuf *win_entry; |
370
dd9e2eb52916
Add /buffer search_{backward,forward}
Mikael Berthe <mikael@lilotux.net>
parents:
369
diff
changeset
|
2761 |
GList *current_line, *search_res; |
849
42c43a88d823
Status buffer management
Mikael Berthe <mikael@lilotux.net>
parents:
848
diff
changeset
|
2762 |
guint isspe; |
370
dd9e2eb52916
Add /buffer search_{backward,forward}
Mikael Berthe <mikael@lilotux.net>
parents:
369
diff
changeset
|
2763 |
|
dd9e2eb52916
Add /buffer search_{backward,forward}
Mikael Berthe <mikael@lilotux.net>
parents:
369
diff
changeset
|
2764 |
// Get win_entry |
dd9e2eb52916
Add /buffer search_{backward,forward}
Mikael Berthe <mikael@lilotux.net>
parents:
369
diff
changeset
|
2765 |
if (!current_buddy) return; |
849
42c43a88d823
Status buffer management
Mikael Berthe <mikael@lilotux.net>
parents:
848
diff
changeset
|
2766 |
isspe = buddy_gettype(BUDDATA(current_buddy)) & ROSTER_TYPE_SPECIAL; |
1780
e4378fbab5d7
Major API cleanup - bump API to 4
Mikael Berthe <mikael@lilotux.net>
parents:
1761
diff
changeset
|
2767 |
win_entry = scr_search_window(CURRENT_JID, isspe); |
370
dd9e2eb52916
Add /buffer search_{backward,forward}
Mikael Berthe <mikael@lilotux.net>
parents:
369
diff
changeset
|
2768 |
if (!win_entry) return; |
dd9e2eb52916
Add /buffer search_{backward,forward}
Mikael Berthe <mikael@lilotux.net>
parents:
369
diff
changeset
|
2769 |
|
1157
5c857f0f0ab8
Moved all variables related to hbuf to an extra struct, bufdata
Frank Zschockelt
parents:
1156
diff
changeset
|
2770 |
if (win_entry->bd->top) |
5c857f0f0ab8
Moved all variables related to hbuf to an extra struct, bufdata
Frank Zschockelt
parents:
1156
diff
changeset
|
2771 |
current_line = win_entry->bd->top; |
370
dd9e2eb52916
Add /buffer search_{backward,forward}
Mikael Berthe <mikael@lilotux.net>
parents:
369
diff
changeset
|
2772 |
else |
1157
5c857f0f0ab8
Moved all variables related to hbuf to an extra struct, bufdata
Frank Zschockelt
parents:
1156
diff
changeset
|
2773 |
current_line = g_list_last(win_entry->bd->hbuf); |
370
dd9e2eb52916
Add /buffer search_{backward,forward}
Mikael Berthe <mikael@lilotux.net>
parents:
369
diff
changeset
|
2774 |
|
dd9e2eb52916
Add /buffer search_{backward,forward}
Mikael Berthe <mikael@lilotux.net>
parents:
369
diff
changeset
|
2775 |
search_res = hbuf_search(current_line, direction, text); |
dd9e2eb52916
Add /buffer search_{backward,forward}
Mikael Berthe <mikael@lilotux.net>
parents:
369
diff
changeset
|
2776 |
|
dd9e2eb52916
Add /buffer search_{backward,forward}
Mikael Berthe <mikael@lilotux.net>
parents:
369
diff
changeset
|
2777 |
if (search_res) { |
1157
5c857f0f0ab8
Moved all variables related to hbuf to an extra struct, bufdata
Frank Zschockelt
parents:
1156
diff
changeset
|
2778 |
win_entry->bd->cleared = FALSE; |
5c857f0f0ab8
Moved all variables related to hbuf to an extra struct, bufdata
Frank Zschockelt
parents:
1156
diff
changeset
|
2779 |
win_entry->bd->top = search_res; |
370
dd9e2eb52916
Add /buffer search_{backward,forward}
Mikael Berthe <mikael@lilotux.net>
parents:
369
diff
changeset
|
2780 |
|
dd9e2eb52916
Add /buffer search_{backward,forward}
Mikael Berthe <mikael@lilotux.net>
parents:
369
diff
changeset
|
2781 |
// Refresh the window |
1780
e4378fbab5d7
Major API cleanup - bump API to 4
Mikael Berthe <mikael@lilotux.net>
parents:
1761
diff
changeset
|
2782 |
scr_update_window(win_entry); |
370
dd9e2eb52916
Add /buffer search_{backward,forward}
Mikael Berthe <mikael@lilotux.net>
parents:
369
diff
changeset
|
2783 |
|
dd9e2eb52916
Add /buffer search_{backward,forward}
Mikael Berthe <mikael@lilotux.net>
parents:
369
diff
changeset
|
2784 |
// Finished :) |
dd9e2eb52916
Add /buffer search_{backward,forward}
Mikael Berthe <mikael@lilotux.net>
parents:
369
diff
changeset
|
2785 |
update_panels(); |
dd9e2eb52916
Add /buffer search_{backward,forward}
Mikael Berthe <mikael@lilotux.net>
parents:
369
diff
changeset
|
2786 |
} else |
374
bd5638c21834
Improve logging system (traces)
Mikael Berthe <mikael@lilotux.net>
parents:
373
diff
changeset
|
2787 |
scr_LogPrint(LPRINT_NORMAL, "Search string not found"); |
370
dd9e2eb52916
Add /buffer search_{backward,forward}
Mikael Berthe <mikael@lilotux.net>
parents:
369
diff
changeset
|
2788 |
} |
dd9e2eb52916
Add /buffer search_{backward,forward}
Mikael Berthe <mikael@lilotux.net>
parents:
369
diff
changeset
|
2789 |
|
1780
e4378fbab5d7
Major API cleanup - bump API to 4
Mikael Berthe <mikael@lilotux.net>
parents:
1761
diff
changeset
|
2790 |
// scr_buffer_percent(n) |
462 | 2791 |
// Jump to the specified position in the buffer, in % |
1780
e4378fbab5d7
Major API cleanup - bump API to 4
Mikael Berthe <mikael@lilotux.net>
parents:
1761
diff
changeset
|
2792 |
void scr_buffer_percent(int pc) |
462 | 2793 |
{ |
822 | 2794 |
winbuf *win_entry; |
462 | 2795 |
GList *search_res; |
849
42c43a88d823
Status buffer management
Mikael Berthe <mikael@lilotux.net>
parents:
848
diff
changeset
|
2796 |
guint isspe; |
462 | 2797 |
|
2798 |
// Get win_entry |
|
2799 |
if (!current_buddy) return; |
|
849
42c43a88d823
Status buffer management
Mikael Berthe <mikael@lilotux.net>
parents:
848
diff
changeset
|
2800 |
isspe = buddy_gettype(BUDDATA(current_buddy)) & ROSTER_TYPE_SPECIAL; |
1780
e4378fbab5d7
Major API cleanup - bump API to 4
Mikael Berthe <mikael@lilotux.net>
parents:
1761
diff
changeset
|
2801 |
win_entry = scr_search_window(CURRENT_JID, isspe); |
462 | 2802 |
if (!win_entry) return; |
2803 |
||
2804 |
if (pc < 0 || pc > 100) { |
|
1686
393c05fba337
Use G_GNUC_PRINTF to check scr_LogPrint arguments
Myhailo Danylenko <isbear@ukrpost.net>
parents:
1677
diff
changeset
|
2805 |
scr_LogPrint(LPRINT_NORMAL, "Bad %% value"); |
462 | 2806 |
return; |
2807 |
} |
|
2808 |
||
1157
5c857f0f0ab8
Moved all variables related to hbuf to an extra struct, bufdata
Frank Zschockelt
parents:
1156
diff
changeset
|
2809 |
search_res = hbuf_jump_percent(win_entry->bd->hbuf, pc); |
5c857f0f0ab8
Moved all variables related to hbuf to an extra struct, bufdata
Frank Zschockelt
parents:
1156
diff
changeset
|
2810 |
|
5c857f0f0ab8
Moved all variables related to hbuf to an extra struct, bufdata
Frank Zschockelt
parents:
1156
diff
changeset
|
2811 |
win_entry->bd->cleared = FALSE; |
5c857f0f0ab8
Moved all variables related to hbuf to an extra struct, bufdata
Frank Zschockelt
parents:
1156
diff
changeset
|
2812 |
win_entry->bd->top = search_res; |
462 | 2813 |
|
2814 |
// Refresh the window |
|
1780
e4378fbab5d7
Major API cleanup - bump API to 4
Mikael Berthe <mikael@lilotux.net>
parents:
1761
diff
changeset
|
2815 |
scr_update_window(win_entry); |
462 | 2816 |
|
2817 |
// Finished :) |
|
2818 |
update_panels(); |
|
2819 |
} |
|
2820 |
||
1780
e4378fbab5d7
Major API cleanup - bump API to 4
Mikael Berthe <mikael@lilotux.net>
parents:
1761
diff
changeset
|
2821 |
// scr_buffer_date(t) |
464 | 2822 |
// Jump to the first line after date t in the buffer |
2823 |
// t is a date in seconds since `00:00:00 1970-01-01 UTC' |
|
1780
e4378fbab5d7
Major API cleanup - bump API to 4
Mikael Berthe <mikael@lilotux.net>
parents:
1761
diff
changeset
|
2824 |
void scr_buffer_date(time_t t) |
464 | 2825 |
{ |
822 | 2826 |
winbuf *win_entry; |
464 | 2827 |
GList *search_res; |
849
42c43a88d823
Status buffer management
Mikael Berthe <mikael@lilotux.net>
parents:
848
diff
changeset
|
2828 |
guint isspe; |
464 | 2829 |
|
2830 |
// Get win_entry |
|
2831 |
if (!current_buddy) return; |
|
849
42c43a88d823
Status buffer management
Mikael Berthe <mikael@lilotux.net>
parents:
848
diff
changeset
|
2832 |
isspe = buddy_gettype(BUDDATA(current_buddy)) & ROSTER_TYPE_SPECIAL; |
1780
e4378fbab5d7
Major API cleanup - bump API to 4
Mikael Berthe <mikael@lilotux.net>
parents:
1761
diff
changeset
|
2833 |
win_entry = scr_search_window(CURRENT_JID, isspe); |
464 | 2834 |
if (!win_entry) return; |
2835 |
||
1157
5c857f0f0ab8
Moved all variables related to hbuf to an extra struct, bufdata
Frank Zschockelt
parents:
1156
diff
changeset
|
2836 |
search_res = hbuf_jump_date(win_entry->bd->hbuf, t); |
5c857f0f0ab8
Moved all variables related to hbuf to an extra struct, bufdata
Frank Zschockelt
parents:
1156
diff
changeset
|
2837 |
|
5c857f0f0ab8
Moved all variables related to hbuf to an extra struct, bufdata
Frank Zschockelt
parents:
1156
diff
changeset
|
2838 |
win_entry->bd->cleared = FALSE; |
5c857f0f0ab8
Moved all variables related to hbuf to an extra struct, bufdata
Frank Zschockelt
parents:
1156
diff
changeset
|
2839 |
win_entry->bd->top = search_res; |
464 | 2840 |
|
2841 |
// Refresh the window |
|
1780
e4378fbab5d7
Major API cleanup - bump API to 4
Mikael Berthe <mikael@lilotux.net>
parents:
1761
diff
changeset
|
2842 |
scr_update_window(win_entry); |
464 | 2843 |
|
2844 |
// Finished :) |
|
2845 |
update_panels(); |
|
2846 |
} |
|
2847 |
||
1780
e4378fbab5d7
Major API cleanup - bump API to 4
Mikael Berthe <mikael@lilotux.net>
parents:
1761
diff
changeset
|
2848 |
// scr_buffer_dump(filename) |
e4378fbab5d7
Major API cleanup - bump API to 4
Mikael Berthe <mikael@lilotux.net>
parents:
1761
diff
changeset
|
2849 |
// Dump the current buffer content to the specified file. |
e4378fbab5d7
Major API cleanup - bump API to 4
Mikael Berthe <mikael@lilotux.net>
parents:
1761
diff
changeset
|
2850 |
void scr_buffer_dump(const char *file) |
1485
0121b6f3047c
New command: /buffer save
Mikael Berthe <mikael@lilotux.net>
parents:
1484
diff
changeset
|
2851 |
{ |
0121b6f3047c
New command: /buffer save
Mikael Berthe <mikael@lilotux.net>
parents:
1484
diff
changeset
|
2852 |
char *extfname; |
0121b6f3047c
New command: /buffer save
Mikael Berthe <mikael@lilotux.net>
parents:
1484
diff
changeset
|
2853 |
|
0121b6f3047c
New command: /buffer save
Mikael Berthe <mikael@lilotux.net>
parents:
1484
diff
changeset
|
2854 |
if (!currentWindow) { |
0121b6f3047c
New command: /buffer save
Mikael Berthe <mikael@lilotux.net>
parents:
1484
diff
changeset
|
2855 |
scr_LogPrint(LPRINT_NORMAL, "No current buffer!"); |
0121b6f3047c
New command: /buffer save
Mikael Berthe <mikael@lilotux.net>
parents:
1484
diff
changeset
|
2856 |
return; |
0121b6f3047c
New command: /buffer save
Mikael Berthe <mikael@lilotux.net>
parents:
1484
diff
changeset
|
2857 |
} |
0121b6f3047c
New command: /buffer save
Mikael Berthe <mikael@lilotux.net>
parents:
1484
diff
changeset
|
2858 |
|
0121b6f3047c
New command: /buffer save
Mikael Berthe <mikael@lilotux.net>
parents:
1484
diff
changeset
|
2859 |
if (!file || !*file) { |
0121b6f3047c
New command: /buffer save
Mikael Berthe <mikael@lilotux.net>
parents:
1484
diff
changeset
|
2860 |
scr_LogPrint(LPRINT_NORMAL, "Missing parameter (file name)!"); |
0121b6f3047c
New command: /buffer save
Mikael Berthe <mikael@lilotux.net>
parents:
1484
diff
changeset
|
2861 |
return; |
0121b6f3047c
New command: /buffer save
Mikael Berthe <mikael@lilotux.net>
parents:
1484
diff
changeset
|
2862 |
} |
0121b6f3047c
New command: /buffer save
Mikael Berthe <mikael@lilotux.net>
parents:
1484
diff
changeset
|
2863 |
|
0121b6f3047c
New command: /buffer save
Mikael Berthe <mikael@lilotux.net>
parents:
1484
diff
changeset
|
2864 |
extfname = expand_filename(file); |
0121b6f3047c
New command: /buffer save
Mikael Berthe <mikael@lilotux.net>
parents:
1484
diff
changeset
|
2865 |
hbuf_dump_to_file(currentWindow->bd->hbuf, extfname); |
0121b6f3047c
New command: /buffer save
Mikael Berthe <mikael@lilotux.net>
parents:
1484
diff
changeset
|
2866 |
g_free(extfname); |
0121b6f3047c
New command: /buffer save
Mikael Berthe <mikael@lilotux.net>
parents:
1484
diff
changeset
|
2867 |
} |
0121b6f3047c
New command: /buffer save
Mikael Berthe <mikael@lilotux.net>
parents:
1484
diff
changeset
|
2868 |
|
1226
2521efbf3b72
New (debug) subcommand, buffer list
Mikael Berthe <mikael@lilotux.net>
parents:
1225
diff
changeset
|
2869 |
// buffer_list() |
2521efbf3b72
New (debug) subcommand, buffer list
Mikael Berthe <mikael@lilotux.net>
parents:
1225
diff
changeset
|
2870 |
// key: winId/jid |
2521efbf3b72
New (debug) subcommand, buffer list
Mikael Berthe <mikael@lilotux.net>
parents:
1225
diff
changeset
|
2871 |
// value: winbuf structure |
2521efbf3b72
New (debug) subcommand, buffer list
Mikael Berthe <mikael@lilotux.net>
parents:
1225
diff
changeset
|
2872 |
// data: none. |
2521efbf3b72
New (debug) subcommand, buffer list
Mikael Berthe <mikael@lilotux.net>
parents:
1225
diff
changeset
|
2873 |
static void buffer_list(gpointer key, gpointer value, gpointer data) |
2521efbf3b72
New (debug) subcommand, buffer list
Mikael Berthe <mikael@lilotux.net>
parents:
1225
diff
changeset
|
2874 |
{ |
1227
79c396678f1b
Make buffer list display the number of allocated HBB blocks
Mikael Berthe <mikael@lilotux.net>
parents:
1226
diff
changeset
|
2875 |
GList *head; |
1226
2521efbf3b72
New (debug) subcommand, buffer list
Mikael Berthe <mikael@lilotux.net>
parents:
1225
diff
changeset
|
2876 |
winbuf *win_entry = value; |
1227
79c396678f1b
Make buffer list display the number of allocated HBB blocks
Mikael Berthe <mikael@lilotux.net>
parents:
1226
diff
changeset
|
2877 |
|
79c396678f1b
Make buffer list display the number of allocated HBB blocks
Mikael Berthe <mikael@lilotux.net>
parents:
1226
diff
changeset
|
2878 |
head = g_list_first(win_entry->bd->hbuf); |
79c396678f1b
Make buffer list display the number of allocated HBB blocks
Mikael Berthe <mikael@lilotux.net>
parents:
1226
diff
changeset
|
2879 |
|
1686
393c05fba337
Use G_GNUC_PRINTF to check scr_LogPrint arguments
Myhailo Danylenko <isbear@ukrpost.net>
parents:
1677
diff
changeset
|
2880 |
scr_LogPrint(LPRINT_NORMAL, " %s (%u/%u)", (const char *) key, |
1227
79c396678f1b
Make buffer list display the number of allocated HBB blocks
Mikael Berthe <mikael@lilotux.net>
parents:
1226
diff
changeset
|
2881 |
g_list_length(head), hbuf_get_blocks_number(head)); |
1226
2521efbf3b72
New (debug) subcommand, buffer list
Mikael Berthe <mikael@lilotux.net>
parents:
1225
diff
changeset
|
2882 |
} |
2521efbf3b72
New (debug) subcommand, buffer list
Mikael Berthe <mikael@lilotux.net>
parents:
1225
diff
changeset
|
2883 |
|
1780
e4378fbab5d7
Major API cleanup - bump API to 4
Mikael Berthe <mikael@lilotux.net>
parents:
1761
diff
changeset
|
2884 |
void scr_buffer_list(void) |
1226
2521efbf3b72
New (debug) subcommand, buffer list
Mikael Berthe <mikael@lilotux.net>
parents:
1225
diff
changeset
|
2885 |
{ |
2521efbf3b72
New (debug) subcommand, buffer list
Mikael Berthe <mikael@lilotux.net>
parents:
1225
diff
changeset
|
2886 |
scr_LogPrint(LPRINT_NORMAL, "Buffer list:"); |
1227
79c396678f1b
Make buffer list display the number of allocated HBB blocks
Mikael Berthe <mikael@lilotux.net>
parents:
1226
diff
changeset
|
2887 |
buffer_list("[status]", statusWindow, NULL); |
1226
2521efbf3b72
New (debug) subcommand, buffer list
Mikael Berthe <mikael@lilotux.net>
parents:
1225
diff
changeset
|
2888 |
g_hash_table_foreach(winbufhash, buffer_list, NULL); |
2521efbf3b72
New (debug) subcommand, buffer list
Mikael Berthe <mikael@lilotux.net>
parents:
1225
diff
changeset
|
2889 |
scr_LogPrint(LPRINT_NORMAL, "End of buffer list."); |
1252
9f7e6c22cd14
"buffer list" sets the new_msg flag
Mikael Berthe <mikael@lilotux.net>
parents:
1245
diff
changeset
|
2890 |
scr_setmsgflag_if_needed(SPECIAL_BUFFER_STATUS_ID, TRUE); |
9f7e6c22cd14
"buffer list" sets the new_msg flag
Mikael Berthe <mikael@lilotux.net>
parents:
1245
diff
changeset
|
2891 |
update_roster = TRUE; |
1226
2521efbf3b72
New (debug) subcommand, buffer list
Mikael Berthe <mikael@lilotux.net>
parents:
1225
diff
changeset
|
2892 |
} |
2521efbf3b72
New (debug) subcommand, buffer list
Mikael Berthe <mikael@lilotux.net>
parents:
1225
diff
changeset
|
2893 |
|
143 | 2894 |
// scr_set_chatmode() |
261 | 2895 |
// Public function to (un)set chatmode... |
129 | 2896 |
inline void scr_set_chatmode(int enable) |
2897 |
{ |
|
2898 |
chatmode = enable; |
|
1780
e4378fbab5d7
Major API cleanup - bump API to 4
Mikael Berthe <mikael@lilotux.net>
parents:
1761
diff
changeset
|
2899 |
scr_update_chat_status(TRUE); |
129 | 2900 |
} |
2901 |
||
1129
1a109ebf3f24
Add option "events_ignore_active_window"
Mikael Berthe <mikael@lilotux.net>
parents:
1127
diff
changeset
|
2902 |
// scr_get_chatmode() |
1a109ebf3f24
Add option "events_ignore_active_window"
Mikael Berthe <mikael@lilotux.net>
parents:
1127
diff
changeset
|
2903 |
// Public function to get chatmode state. |
1a109ebf3f24
Add option "events_ignore_active_window"
Mikael Berthe <mikael@lilotux.net>
parents:
1127
diff
changeset
|
2904 |
inline int scr_get_chatmode(void) |
1a109ebf3f24
Add option "events_ignore_active_window"
Mikael Berthe <mikael@lilotux.net>
parents:
1127
diff
changeset
|
2905 |
{ |
1a109ebf3f24
Add option "events_ignore_active_window"
Mikael Berthe <mikael@lilotux.net>
parents:
1127
diff
changeset
|
2906 |
return chatmode; |
1a109ebf3f24
Add option "events_ignore_active_window"
Mikael Berthe <mikael@lilotux.net>
parents:
1127
diff
changeset
|
2907 |
} |
1a109ebf3f24
Add option "events_ignore_active_window"
Mikael Berthe <mikael@lilotux.net>
parents:
1127
diff
changeset
|
2908 |
|
238 | 2909 |
// scr_get_multimode() |
261 | 2910 |
// Public function to get multimode status... |
1059 | 2911 |
inline int scr_get_multimode(void) |
238 | 2912 |
{ |
2913 |
return multimode; |
|
2914 |
} |
|
2915 |
||
654
d7fe7b88e4fc
MUC: Set the new_message flag when joining a room
Mikael Berthe <mikael@lilotux.net>
parents:
652
diff
changeset
|
2916 |
// scr_setmsgflag_if_needed(jid) |
d7fe7b88e4fc
MUC: Set the new_message flag when joining a room
Mikael Berthe <mikael@lilotux.net>
parents:
652
diff
changeset
|
2917 |
// Set the message flag unless we're already in the jid buffer window |
1058 | 2918 |
void scr_setmsgflag_if_needed(const char *bjid, int special) |
654
d7fe7b88e4fc
MUC: Set the new_message flag when joining a room
Mikael Berthe <mikael@lilotux.net>
parents:
652
diff
changeset
|
2919 |
{ |
891
78f4971578dd
Add a "special" parameter to scr_setmsgflag_if_needed()
Mikael Berthe <mikael@lilotux.net>
parents:
889
diff
changeset
|
2920 |
const char *current_id; |
873
ee39f6d94d43
Add /buffer {scroll_lock|scroll_unlock|toggle_scroll}
Mikael Berthe <mikael@lilotux.net>
parents:
866
diff
changeset
|
2921 |
bool iscurrentlocked = FALSE; |
667
86bc3295a4db
Fix segfault in scr_setmsgflag_if_needed()
Mikael Berthe <mikael@lilotux.net>
parents:
658
diff
changeset
|
2922 |
|
1058 | 2923 |
if (!bjid) |
849
42c43a88d823
Status buffer management
Mikael Berthe <mikael@lilotux.net>
parents:
848
diff
changeset
|
2924 |
return; |
42c43a88d823
Status buffer management
Mikael Berthe <mikael@lilotux.net>
parents:
848
diff
changeset
|
2925 |
|
873
ee39f6d94d43
Add /buffer {scroll_lock|scroll_unlock|toggle_scroll}
Mikael Berthe <mikael@lilotux.net>
parents:
866
diff
changeset
|
2926 |
if (current_buddy) { |
891
78f4971578dd
Add a "special" parameter to scr_setmsgflag_if_needed()
Mikael Berthe <mikael@lilotux.net>
parents:
889
diff
changeset
|
2927 |
if (special) |
78f4971578dd
Add a "special" parameter to scr_setmsgflag_if_needed()
Mikael Berthe <mikael@lilotux.net>
parents:
889
diff
changeset
|
2928 |
current_id = buddy_getname(BUDDATA(current_buddy)); |
78f4971578dd
Add a "special" parameter to scr_setmsgflag_if_needed()
Mikael Berthe <mikael@lilotux.net>
parents:
889
diff
changeset
|
2929 |
else |
78f4971578dd
Add a "special" parameter to scr_setmsgflag_if_needed()
Mikael Berthe <mikael@lilotux.net>
parents:
889
diff
changeset
|
2930 |
current_id = buddy_getjid(BUDDATA(current_buddy)); |
78f4971578dd
Add a "special" parameter to scr_setmsgflag_if_needed()
Mikael Berthe <mikael@lilotux.net>
parents:
889
diff
changeset
|
2931 |
if (current_id) { |
1780
e4378fbab5d7
Major API cleanup - bump API to 4
Mikael Berthe <mikael@lilotux.net>
parents:
1761
diff
changeset
|
2932 |
winbuf *win_entry = scr_search_window(current_id, special); |
888
578d2034e971
scr_setmsgflag_if_needed(): Add a check after scr_SearchWindow()
Mikael Berthe <mikael@lilotux.net>
parents:
884
diff
changeset
|
2933 |
if (!win_entry) return; |
1157
5c857f0f0ab8
Moved all variables related to hbuf to an extra struct, bufdata
Frank Zschockelt
parents:
1156
diff
changeset
|
2934 |
iscurrentlocked = win_entry->bd->lock; |
873
ee39f6d94d43
Add /buffer {scroll_lock|scroll_unlock|toggle_scroll}
Mikael Berthe <mikael@lilotux.net>
parents:
866
diff
changeset
|
2935 |
} |
ee39f6d94d43
Add /buffer {scroll_lock|scroll_unlock|toggle_scroll}
Mikael Berthe <mikael@lilotux.net>
parents:
866
diff
changeset
|
2936 |
} else { |
891
78f4971578dd
Add a "special" parameter to scr_setmsgflag_if_needed()
Mikael Berthe <mikael@lilotux.net>
parents:
889
diff
changeset
|
2937 |
current_id = NULL; |
873
ee39f6d94d43
Add /buffer {scroll_lock|scroll_unlock|toggle_scroll}
Mikael Berthe <mikael@lilotux.net>
parents:
866
diff
changeset
|
2938 |
} |
1058 | 2939 |
if (!chatmode || !current_id || strcmp(bjid, current_id) || iscurrentlocked) |
2940 |
roster_msg_setflag(bjid, special, TRUE); |
|
654
d7fe7b88e4fc
MUC: Set the new_message flag when joining a room
Mikael Berthe <mikael@lilotux.net>
parents:
652
diff
changeset
|
2941 |
} |
d7fe7b88e4fc
MUC: Set the new_message flag when joining a room
Mikael Berthe <mikael@lilotux.net>
parents:
652
diff
changeset
|
2942 |
|
1802
b135572fcd26
Add urgent flag per screen buffer
Mikael Berthe <mikael@lilotux.net>
parents:
1793
diff
changeset
|
2943 |
// scr_setattentionflag_if_needed(bare_jid, special, value, action) |
b135572fcd26
Add urgent flag per screen buffer
Mikael Berthe <mikael@lilotux.net>
parents:
1793
diff
changeset
|
2944 |
// Set the attention flag unless we're already in the jid buffer window |
b135572fcd26
Add urgent flag per screen buffer
Mikael Berthe <mikael@lilotux.net>
parents:
1793
diff
changeset
|
2945 |
// TODO: avoid code duplication with scr_setmsgflag_if_needed() |
b135572fcd26
Add urgent flag per screen buffer
Mikael Berthe <mikael@lilotux.net>
parents:
1793
diff
changeset
|
2946 |
void scr_setattentionflag_if_needed(const char *bjid, int special, |
b135572fcd26
Add urgent flag per screen buffer
Mikael Berthe <mikael@lilotux.net>
parents:
1793
diff
changeset
|
2947 |
guint value, enum setuiprio_ops action) |
b135572fcd26
Add urgent flag per screen buffer
Mikael Berthe <mikael@lilotux.net>
parents:
1793
diff
changeset
|
2948 |
{ |
b135572fcd26
Add urgent flag per screen buffer
Mikael Berthe <mikael@lilotux.net>
parents:
1793
diff
changeset
|
2949 |
const char *current_id; |
b135572fcd26
Add urgent flag per screen buffer
Mikael Berthe <mikael@lilotux.net>
parents:
1793
diff
changeset
|
2950 |
winbuf *wb; |
b135572fcd26
Add urgent flag per screen buffer
Mikael Berthe <mikael@lilotux.net>
parents:
1793
diff
changeset
|
2951 |
bool iscurrentlocked = FALSE; |
b135572fcd26
Add urgent flag per screen buffer
Mikael Berthe <mikael@lilotux.net>
parents:
1793
diff
changeset
|
2952 |
|
b135572fcd26
Add urgent flag per screen buffer
Mikael Berthe <mikael@lilotux.net>
parents:
1793
diff
changeset
|
2953 |
if (!bjid) |
b135572fcd26
Add urgent flag per screen buffer
Mikael Berthe <mikael@lilotux.net>
parents:
1793
diff
changeset
|
2954 |
return; |
b135572fcd26
Add urgent flag per screen buffer
Mikael Berthe <mikael@lilotux.net>
parents:
1793
diff
changeset
|
2955 |
|
b135572fcd26
Add urgent flag per screen buffer
Mikael Berthe <mikael@lilotux.net>
parents:
1793
diff
changeset
|
2956 |
wb = scr_search_window(bjid, special); |
b135572fcd26
Add urgent flag per screen buffer
Mikael Berthe <mikael@lilotux.net>
parents:
1793
diff
changeset
|
2957 |
if (!wb) |
b135572fcd26
Add urgent flag per screen buffer
Mikael Berthe <mikael@lilotux.net>
parents:
1793
diff
changeset
|
2958 |
return; |
b135572fcd26
Add urgent flag per screen buffer
Mikael Berthe <mikael@lilotux.net>
parents:
1793
diff
changeset
|
2959 |
|
b135572fcd26
Add urgent flag per screen buffer
Mikael Berthe <mikael@lilotux.net>
parents:
1793
diff
changeset
|
2960 |
if (current_buddy) { |
b135572fcd26
Add urgent flag per screen buffer
Mikael Berthe <mikael@lilotux.net>
parents:
1793
diff
changeset
|
2961 |
if (special) |
b135572fcd26
Add urgent flag per screen buffer
Mikael Berthe <mikael@lilotux.net>
parents:
1793
diff
changeset
|
2962 |
current_id = buddy_getname(BUDDATA(current_buddy)); |
b135572fcd26
Add urgent flag per screen buffer
Mikael Berthe <mikael@lilotux.net>
parents:
1793
diff
changeset
|
2963 |
else |
b135572fcd26
Add urgent flag per screen buffer
Mikael Berthe <mikael@lilotux.net>
parents:
1793
diff
changeset
|
2964 |
current_id = buddy_getjid(BUDDATA(current_buddy)); |
b135572fcd26
Add urgent flag per screen buffer
Mikael Berthe <mikael@lilotux.net>
parents:
1793
diff
changeset
|
2965 |
if (current_id) { |
b135572fcd26
Add urgent flag per screen buffer
Mikael Berthe <mikael@lilotux.net>
parents:
1793
diff
changeset
|
2966 |
winbuf *win_entry = scr_search_window(current_id, special); |
b135572fcd26
Add urgent flag per screen buffer
Mikael Berthe <mikael@lilotux.net>
parents:
1793
diff
changeset
|
2967 |
if (!win_entry) return; |
b135572fcd26
Add urgent flag per screen buffer
Mikael Berthe <mikael@lilotux.net>
parents:
1793
diff
changeset
|
2968 |
iscurrentlocked = win_entry->bd->lock; |
b135572fcd26
Add urgent flag per screen buffer
Mikael Berthe <mikael@lilotux.net>
parents:
1793
diff
changeset
|
2969 |
} |
b135572fcd26
Add urgent flag per screen buffer
Mikael Berthe <mikael@lilotux.net>
parents:
1793
diff
changeset
|
2970 |
} else { |
b135572fcd26
Add urgent flag per screen buffer
Mikael Berthe <mikael@lilotux.net>
parents:
1793
diff
changeset
|
2971 |
current_id = NULL; |
b135572fcd26
Add urgent flag per screen buffer
Mikael Berthe <mikael@lilotux.net>
parents:
1793
diff
changeset
|
2972 |
} |
b135572fcd26
Add urgent flag per screen buffer
Mikael Berthe <mikael@lilotux.net>
parents:
1793
diff
changeset
|
2973 |
|
b135572fcd26
Add urgent flag per screen buffer
Mikael Berthe <mikael@lilotux.net>
parents:
1793
diff
changeset
|
2974 |
if (!chatmode || !current_id || strcmp(bjid, current_id) || iscurrentlocked) |
b135572fcd26
Add urgent flag per screen buffer
Mikael Berthe <mikael@lilotux.net>
parents:
1793
diff
changeset
|
2975 |
roster_setuiprio(bjid, special, value, action); |
b135572fcd26
Add urgent flag per screen buffer
Mikael Berthe <mikael@lilotux.net>
parents:
1793
diff
changeset
|
2976 |
} |
b135572fcd26
Add urgent flag per screen buffer
Mikael Berthe <mikael@lilotux.net>
parents:
1793
diff
changeset
|
2977 |
|
238 | 2978 |
// scr_set_multimode() |
261 | 2979 |
// Public function to (un)set multimode... |
260
33e1a05864a6
Add "verbatim multi-line" mode, with commands disabled
mikael@frmp8452
parents:
252
diff
changeset
|
2980 |
// Convention: |
33e1a05864a6
Add "verbatim multi-line" mode, with commands disabled
mikael@frmp8452
parents:
252
diff
changeset
|
2981 |
// 0 = disabled / 1 = multimode / 2 = multimode verbatim (commands disabled) |
1413 | 2982 |
void scr_set_multimode(int enable, char *subject) |
238 | 2983 |
{ |
807
f6cda389db48
Allow messages with a subject (/msay)
Mikael Berthe <mikael@lilotux.net>
parents:
806
diff
changeset
|
2984 |
g_free(multiline); |
f6cda389db48
Allow messages with a subject (/msay)
Mikael Berthe <mikael@lilotux.net>
parents:
806
diff
changeset
|
2985 |
multiline = NULL; |
f6cda389db48
Allow messages with a subject (/msay)
Mikael Berthe <mikael@lilotux.net>
parents:
806
diff
changeset
|
2986 |
|
f6cda389db48
Allow messages with a subject (/msay)
Mikael Berthe <mikael@lilotux.net>
parents:
806
diff
changeset
|
2987 |
g_free(multimode_subj); |
f6cda389db48
Allow messages with a subject (/msay)
Mikael Berthe <mikael@lilotux.net>
parents:
806
diff
changeset
|
2988 |
if (enable && subject) |
f6cda389db48
Allow messages with a subject (/msay)
Mikael Berthe <mikael@lilotux.net>
parents:
806
diff
changeset
|
2989 |
multimode_subj = g_strdup(subject); |
f6cda389db48
Allow messages with a subject (/msay)
Mikael Berthe <mikael@lilotux.net>
parents:
806
diff
changeset
|
2990 |
else |
f6cda389db48
Allow messages with a subject (/msay)
Mikael Berthe <mikael@lilotux.net>
parents:
806
diff
changeset
|
2991 |
multimode_subj = NULL; |
f6cda389db48
Allow messages with a subject (/msay)
Mikael Berthe <mikael@lilotux.net>
parents:
806
diff
changeset
|
2992 |
|
260
33e1a05864a6
Add "verbatim multi-line" mode, with commands disabled
mikael@frmp8452
parents:
252
diff
changeset
|
2993 |
multimode = enable; |
238 | 2994 |
} |
2995 |
||
2996 |
// scr_get_multiline() |
|
261 | 2997 |
// Public function to get the current multi-line. |
1413 | 2998 |
const char *scr_get_multiline(void) |
238 | 2999 |
{ |
3000 |
if (multimode && multiline) |
|
3001 |
return multiline; |
|
807
f6cda389db48
Allow messages with a subject (/msay)
Mikael Berthe <mikael@lilotux.net>
parents:
806
diff
changeset
|
3002 |
return NULL; |
f6cda389db48
Allow messages with a subject (/msay)
Mikael Berthe <mikael@lilotux.net>
parents:
806
diff
changeset
|
3003 |
} |
f6cda389db48
Allow messages with a subject (/msay)
Mikael Berthe <mikael@lilotux.net>
parents:
806
diff
changeset
|
3004 |
|
f6cda389db48
Allow messages with a subject (/msay)
Mikael Berthe <mikael@lilotux.net>
parents:
806
diff
changeset
|
3005 |
// scr_get_multimode_subj() |
f6cda389db48
Allow messages with a subject (/msay)
Mikael Berthe <mikael@lilotux.net>
parents:
806
diff
changeset
|
3006 |
// Public function to get the multi-line subject, if any. |
1413 | 3007 |
const char *scr_get_multimode_subj(void) |
807
f6cda389db48
Allow messages with a subject (/msay)
Mikael Berthe <mikael@lilotux.net>
parents:
806
diff
changeset
|
3008 |
{ |
f6cda389db48
Allow messages with a subject (/msay)
Mikael Berthe <mikael@lilotux.net>
parents:
806
diff
changeset
|
3009 |
if (multimode) |
f6cda389db48
Allow messages with a subject (/msay)
Mikael Berthe <mikael@lilotux.net>
parents:
806
diff
changeset
|
3010 |
return multimode_subj; |
f6cda389db48
Allow messages with a subject (/msay)
Mikael Berthe <mikael@lilotux.net>
parents:
806
diff
changeset
|
3011 |
return NULL; |
238 | 3012 |
} |
3013 |
||
3014 |
// scr_append_multiline(line) |
|
3015 |
// Public function to append a line to the current multi-line message. |
|
3016 |
// Skip empty leading lines. |
|
3017 |
void scr_append_multiline(const char *line) |
|
3018 |
{ |
|
3019 |
static int num; |
|
3020 |
||
3021 |
if (!multimode) { |
|
374
bd5638c21834
Improve logging system (traces)
Mikael Berthe <mikael@lilotux.net>
parents:
373
diff
changeset
|
3022 |
scr_LogPrint(LPRINT_NORMAL, "Error: Not in multi-line message mode!"); |
238 | 3023 |
return; |
3024 |
} |
|
3025 |
if (multiline) { |
|
3026 |
int len = strlen(multiline)+strlen(line)+2; |
|
252 | 3027 |
if (len >= HBB_BLOCKSIZE - 1) { |
238 | 3028 |
// We don't handle single messages with size > HBB_BLOCKSIZE |
3029 |
// (see hbuf) |
|
374
bd5638c21834
Improve logging system (traces)
Mikael Berthe <mikael@lilotux.net>
parents:
373
diff
changeset
|
3030 |
scr_LogPrint(LPRINT_NORMAL, "Your multi-line message is too big, " |
bd5638c21834
Improve logging system (traces)
Mikael Berthe <mikael@lilotux.net>
parents:
373
diff
changeset
|
3031 |
"this line has not been added."); |
bd5638c21834
Improve logging system (traces)
Mikael Berthe <mikael@lilotux.net>
parents:
373
diff
changeset
|
3032 |
scr_LogPrint(LPRINT_NORMAL, "Please send this part now..."); |
238 | 3033 |
return; |
3034 |
} |
|
276
627925d885de
Limit the number of lines in multi-line messages
Mikael Berthe <mikael@lilotux.net>
parents:
271
diff
changeset
|
3035 |
if (num >= MULTILINE_MAX_LINE_NUMBER) { |
627925d885de
Limit the number of lines in multi-line messages
Mikael Berthe <mikael@lilotux.net>
parents:
271
diff
changeset
|
3036 |
// We don't allow too many lines; however the maximum is arbitrary |
627925d885de
Limit the number of lines in multi-line messages
Mikael Berthe <mikael@lilotux.net>
parents:
271
diff
changeset
|
3037 |
// (It should be < 1000 yet) |
374
bd5638c21834
Improve logging system (traces)
Mikael Berthe <mikael@lilotux.net>
parents:
373
diff
changeset
|
3038 |
scr_LogPrint(LPRINT_NORMAL, "Your message has too many lines, " |
bd5638c21834
Improve logging system (traces)
Mikael Berthe <mikael@lilotux.net>
parents:
373
diff
changeset
|
3039 |
"this one has not been added."); |
bd5638c21834
Improve logging system (traces)
Mikael Berthe <mikael@lilotux.net>
parents:
373
diff
changeset
|
3040 |
scr_LogPrint(LPRINT_NORMAL, "Please send this part now..."); |
276
627925d885de
Limit the number of lines in multi-line messages
Mikael Berthe <mikael@lilotux.net>
parents:
271
diff
changeset
|
3041 |
return; |
627925d885de
Limit the number of lines in multi-line messages
Mikael Berthe <mikael@lilotux.net>
parents:
271
diff
changeset
|
3042 |
} |
238 | 3043 |
multiline = g_renew(char, multiline, len); |
3044 |
strcat(multiline, "\n"); |
|
3045 |
strcat(multiline, line); |
|
3046 |
num++; |
|
3047 |
} else { |
|
3048 |
// First message line (we skip leading empty lines) |
|
3049 |
num = 0; |
|
3050 |
if (line[0]) { |
|
419 | 3051 |
multiline = g_strdup(line); |
238 | 3052 |
num++; |
3053 |
} else |
|
3054 |
return; |
|
3055 |
} |
|
772
464be13343a9
Store most data in UTF-8 internally
Mikael Berthe <mikael@lilotux.net>
parents:
771
diff
changeset
|
3056 |
scr_LogPrint(LPRINT_NORMAL|LPRINT_NOTUTF8, |
464be13343a9
Store most data in UTF-8 internally
Mikael Berthe <mikael@lilotux.net>
parents:
771
diff
changeset
|
3057 |
"Multi-line mode: line #%d added [%.25s...", num, line); |
238 | 3058 |
} |
3059 |
||
173 | 3060 |
// scr_cmdhisto_addline() |
3061 |
// Add a line to the inputLine history |
|
1558
3df441efb7c2
Fix gcc warnings related to inline/static uses
Mikael Berthe <mikael@lilotux.net>
parents:
1522
diff
changeset
|
3062 |
static inline void scr_cmdhisto_addline(char *line) |
173 | 3063 |
{ |
1127
fddf2fef7b83
Add option "cmdhistory_lines"
Mikael Berthe <mikael@lilotux.net>
parents:
1122
diff
changeset
|
3064 |
int max_histo_lines; |
fddf2fef7b83
Add option "cmdhistory_lines"
Mikael Berthe <mikael@lilotux.net>
parents:
1122
diff
changeset
|
3065 |
|
fddf2fef7b83
Add option "cmdhistory_lines"
Mikael Berthe <mikael@lilotux.net>
parents:
1122
diff
changeset
|
3066 |
if (!line || !*line) |
fddf2fef7b83
Add option "cmdhistory_lines"
Mikael Berthe <mikael@lilotux.net>
parents:
1122
diff
changeset
|
3067 |
return; |
fddf2fef7b83
Add option "cmdhistory_lines"
Mikael Berthe <mikael@lilotux.net>
parents:
1122
diff
changeset
|
3068 |
|
fddf2fef7b83
Add option "cmdhistory_lines"
Mikael Berthe <mikael@lilotux.net>
parents:
1122
diff
changeset
|
3069 |
max_histo_lines = settings_opt_get_int("cmdhistory_lines"); |
fddf2fef7b83
Add option "cmdhistory_lines"
Mikael Berthe <mikael@lilotux.net>
parents:
1122
diff
changeset
|
3070 |
|
fddf2fef7b83
Add option "cmdhistory_lines"
Mikael Berthe <mikael@lilotux.net>
parents:
1122
diff
changeset
|
3071 |
if (max_histo_lines < 0) |
fddf2fef7b83
Add option "cmdhistory_lines"
Mikael Berthe <mikael@lilotux.net>
parents:
1122
diff
changeset
|
3072 |
max_histo_lines = 1; |
fddf2fef7b83
Add option "cmdhistory_lines"
Mikael Berthe <mikael@lilotux.net>
parents:
1122
diff
changeset
|
3073 |
|
fddf2fef7b83
Add option "cmdhistory_lines"
Mikael Berthe <mikael@lilotux.net>
parents:
1122
diff
changeset
|
3074 |
if (max_histo_lines) |
fddf2fef7b83
Add option "cmdhistory_lines"
Mikael Berthe <mikael@lilotux.net>
parents:
1122
diff
changeset
|
3075 |
while (cmdhisto_nblines >= (guint)max_histo_lines) { |
fddf2fef7b83
Add option "cmdhistory_lines"
Mikael Berthe <mikael@lilotux.net>
parents:
1122
diff
changeset
|
3076 |
if (cmdhisto_cur && cmdhisto_cur == cmdhisto) |
fddf2fef7b83
Add option "cmdhistory_lines"
Mikael Berthe <mikael@lilotux.net>
parents:
1122
diff
changeset
|
3077 |
break; |
fddf2fef7b83
Add option "cmdhistory_lines"
Mikael Berthe <mikael@lilotux.net>
parents:
1122
diff
changeset
|
3078 |
g_free(cmdhisto->data); |
fddf2fef7b83
Add option "cmdhistory_lines"
Mikael Berthe <mikael@lilotux.net>
parents:
1122
diff
changeset
|
3079 |
cmdhisto = g_list_delete_link(cmdhisto, cmdhisto); |
fddf2fef7b83
Add option "cmdhistory_lines"
Mikael Berthe <mikael@lilotux.net>
parents:
1122
diff
changeset
|
3080 |
cmdhisto_nblines--; |
fddf2fef7b83
Add option "cmdhistory_lines"
Mikael Berthe <mikael@lilotux.net>
parents:
1122
diff
changeset
|
3081 |
} |
173 | 3082 |
|
3083 |
cmdhisto = g_list_append(cmdhisto, g_strdup(line)); |
|
1127
fddf2fef7b83
Add option "cmdhistory_lines"
Mikael Berthe <mikael@lilotux.net>
parents:
1122
diff
changeset
|
3084 |
cmdhisto_nblines++; |
173 | 3085 |
} |
3086 |
||
3087 |
// scr_cmdhisto_prev() |
|
3088 |
// Look for previous line beginning w/ the given mask in the inputLine history |
|
175 | 3089 |
// Returns NULL if none found |
336
eb994ee40029
Make some functions static
Mikael Berthe <mikael@lilotux.net>
parents:
332
diff
changeset
|
3090 |
static const char *scr_cmdhisto_prev(char *mask, guint len) |
173 | 3091 |
{ |
3092 |
GList *hl; |
|
3093 |
if (!cmdhisto_cur) { |
|
3094 |
hl = g_list_last(cmdhisto); |
|
174 | 3095 |
if (hl) { // backup current line |
3096 |
strncpy(cmdhisto_backup, mask, INPUTLINE_LENGTH); |
|
3097 |
} |
|
173 | 3098 |
} else { |
3099 |
hl = g_list_previous(cmdhisto_cur); |
|
3100 |
} |
|
3101 |
while (hl) { |
|
3102 |
if (!strncmp((char*)hl->data, mask, len)) { |
|
3103 |
// Found a match |
|
3104 |
cmdhisto_cur = hl; |
|
3105 |
return (const char*)hl->data; |
|
3106 |
} |
|
3107 |
hl = g_list_previous(hl); |
|
3108 |
} |
|
3109 |
return NULL; |
|
3110 |
} |
|
3111 |
||
3112 |
// scr_cmdhisto_next() |
|
3113 |
// Look for next line beginning w/ the given mask in the inputLine history |
|
175 | 3114 |
// Returns NULL if none found |
336
eb994ee40029
Make some functions static
Mikael Berthe <mikael@lilotux.net>
parents:
332
diff
changeset
|
3115 |
static const char *scr_cmdhisto_next(char *mask, guint len) |
173 | 3116 |
{ |
3117 |
GList *hl; |
|
3118 |
if (!cmdhisto_cur) return NULL; |
|
3119 |
hl = cmdhisto_cur; |
|
3120 |
while ((hl = g_list_next(hl)) != NULL) |
|
3121 |
if (!strncmp((char*)hl->data, mask, len)) { |
|
3122 |
// Found a match |
|
3123 |
cmdhisto_cur = hl; |
|
3124 |
return (const char*)hl->data; |
|
3125 |
} |
|
175 | 3126 |
// If the "backuped" line matches, we'll use it |
3127 |
if (strncmp(cmdhisto_backup, mask, len)) return NULL; // No match |
|
174 | 3128 |
cmdhisto_cur = NULL; |
3129 |
return cmdhisto_backup; |
|
173 | 3130 |
} |
3131 |
||
195 | 3132 |
// readline_transpose_chars() |
3133 |
// Drag the character before point forward over the character at |
|
3134 |
// point, moving point forward as well. If point is at the end of |
|
3135 |
// the line, then this transposes the two characters before point. |
|
1059 | 3136 |
void readline_transpose_chars(void) |
195 | 3137 |
{ |
930
a75f7a13df7b
UTF-8 terminal support (Reimar Döffinger)
Mikael Berthe <mikael@lilotux.net>
parents:
929
diff
changeset
|
3138 |
char *c1, *c2; |
a75f7a13df7b
UTF-8 terminal support (Reimar Döffinger)
Mikael Berthe <mikael@lilotux.net>
parents:
929
diff
changeset
|
3139 |
unsigned a, b; |
195 | 3140 |
|
3141 |
if (ptr_inputline == inputLine) return; |
|
3142 |
||
3143 |
if (!*ptr_inputline) { // We're at EOL |
|
3144 |
// If line is only 1 char long, nothing to do... |
|
930
a75f7a13df7b
UTF-8 terminal support (Reimar Döffinger)
Mikael Berthe <mikael@lilotux.net>
parents:
929
diff
changeset
|
3145 |
if (ptr_inputline == prev_char(ptr_inputline, inputLine)) return; |
195 | 3146 |
// Transpose the two previous characters |
930
a75f7a13df7b
UTF-8 terminal support (Reimar Döffinger)
Mikael Berthe <mikael@lilotux.net>
parents:
929
diff
changeset
|
3147 |
c2 = prev_char(ptr_inputline, inputLine); |
a75f7a13df7b
UTF-8 terminal support (Reimar Döffinger)
Mikael Berthe <mikael@lilotux.net>
parents:
929
diff
changeset
|
3148 |
c1 = prev_char(c2, inputLine); |
a75f7a13df7b
UTF-8 terminal support (Reimar Döffinger)
Mikael Berthe <mikael@lilotux.net>
parents:
929
diff
changeset
|
3149 |
a = get_char(c1); |
a75f7a13df7b
UTF-8 terminal support (Reimar Döffinger)
Mikael Berthe <mikael@lilotux.net>
parents:
929
diff
changeset
|
3150 |
b = get_char(c2); |
a75f7a13df7b
UTF-8 terminal support (Reimar Döffinger)
Mikael Berthe <mikael@lilotux.net>
parents:
929
diff
changeset
|
3151 |
put_char(put_char(c1, b), a); |
195 | 3152 |
} else { |
196 | 3153 |
// Swap the two characters before the cursor and move right. |
930
a75f7a13df7b
UTF-8 terminal support (Reimar Döffinger)
Mikael Berthe <mikael@lilotux.net>
parents:
929
diff
changeset
|
3154 |
c2 = ptr_inputline; |
a75f7a13df7b
UTF-8 terminal support (Reimar Döffinger)
Mikael Berthe <mikael@lilotux.net>
parents:
929
diff
changeset
|
3155 |
c1 = prev_char(c2, inputLine); |
a75f7a13df7b
UTF-8 terminal support (Reimar Döffinger)
Mikael Berthe <mikael@lilotux.net>
parents:
929
diff
changeset
|
3156 |
a = get_char(c1); |
a75f7a13df7b
UTF-8 terminal support (Reimar Döffinger)
Mikael Berthe <mikael@lilotux.net>
parents:
929
diff
changeset
|
3157 |
b = get_char(c2); |
a75f7a13df7b
UTF-8 terminal support (Reimar Döffinger)
Mikael Berthe <mikael@lilotux.net>
parents:
929
diff
changeset
|
3158 |
put_char(put_char(c1, b), a); |
195 | 3159 |
check_offset(1); |
3160 |
} |
|
3161 |
} |
|
3162 |
||
1171
03a38b7ad2e0
Add a collection of commands for key bindings (Lego12239)
Mikael Berthe <mikael@lilotux.net>
parents:
1170
diff
changeset
|
3163 |
void readline_forward_kill_word(void) |
03a38b7ad2e0
Add a collection of commands for key bindings (Lego12239)
Mikael Berthe <mikael@lilotux.net>
parents:
1170
diff
changeset
|
3164 |
{ |
03a38b7ad2e0
Add a collection of commands for key bindings (Lego12239)
Mikael Berthe <mikael@lilotux.net>
parents:
1170
diff
changeset
|
3165 |
char *c, *old = ptr_inputline; |
03a38b7ad2e0
Add a collection of commands for key bindings (Lego12239)
Mikael Berthe <mikael@lilotux.net>
parents:
1170
diff
changeset
|
3166 |
int spaceallowed = 1; |
03a38b7ad2e0
Add a collection of commands for key bindings (Lego12239)
Mikael Berthe <mikael@lilotux.net>
parents:
1170
diff
changeset
|
3167 |
|
03a38b7ad2e0
Add a collection of commands for key bindings (Lego12239)
Mikael Berthe <mikael@lilotux.net>
parents:
1170
diff
changeset
|
3168 |
if (! *ptr_inputline) return; |
03a38b7ad2e0
Add a collection of commands for key bindings (Lego12239)
Mikael Berthe <mikael@lilotux.net>
parents:
1170
diff
changeset
|
3169 |
|
03a38b7ad2e0
Add a collection of commands for key bindings (Lego12239)
Mikael Berthe <mikael@lilotux.net>
parents:
1170
diff
changeset
|
3170 |
for (c = ptr_inputline ; *c ; c = next_char(c)) { |
03a38b7ad2e0
Add a collection of commands for key bindings (Lego12239)
Mikael Berthe <mikael@lilotux.net>
parents:
1170
diff
changeset
|
3171 |
if (!iswalnum(get_char(c))) { |
03a38b7ad2e0
Add a collection of commands for key bindings (Lego12239)
Mikael Berthe <mikael@lilotux.net>
parents:
1170
diff
changeset
|
3172 |
if (iswblank(get_char(c))) { |
03a38b7ad2e0
Add a collection of commands for key bindings (Lego12239)
Mikael Berthe <mikael@lilotux.net>
parents:
1170
diff
changeset
|
3173 |
if (!spaceallowed) break; |
03a38b7ad2e0
Add a collection of commands for key bindings (Lego12239)
Mikael Berthe <mikael@lilotux.net>
parents:
1170
diff
changeset
|
3174 |
} else spaceallowed = 0; |
03a38b7ad2e0
Add a collection of commands for key bindings (Lego12239)
Mikael Berthe <mikael@lilotux.net>
parents:
1170
diff
changeset
|
3175 |
} else spaceallowed = 0; |
03a38b7ad2e0
Add a collection of commands for key bindings (Lego12239)
Mikael Berthe <mikael@lilotux.net>
parents:
1170
diff
changeset
|
3176 |
} |
03a38b7ad2e0
Add a collection of commands for key bindings (Lego12239)
Mikael Berthe <mikael@lilotux.net>
parents:
1170
diff
changeset
|
3177 |
|
03a38b7ad2e0
Add a collection of commands for key bindings (Lego12239)
Mikael Berthe <mikael@lilotux.net>
parents:
1170
diff
changeset
|
3178 |
// Modify the line |
03a38b7ad2e0
Add a collection of commands for key bindings (Lego12239)
Mikael Berthe <mikael@lilotux.net>
parents:
1170
diff
changeset
|
3179 |
for (;;) { |
03a38b7ad2e0
Add a collection of commands for key bindings (Lego12239)
Mikael Berthe <mikael@lilotux.net>
parents:
1170
diff
changeset
|
3180 |
*old = *c++; |
03a38b7ad2e0
Add a collection of commands for key bindings (Lego12239)
Mikael Berthe <mikael@lilotux.net>
parents:
1170
diff
changeset
|
3181 |
if (!*old++) break; |
03a38b7ad2e0
Add a collection of commands for key bindings (Lego12239)
Mikael Berthe <mikael@lilotux.net>
parents:
1170
diff
changeset
|
3182 |
} |
03a38b7ad2e0
Add a collection of commands for key bindings (Lego12239)
Mikael Berthe <mikael@lilotux.net>
parents:
1170
diff
changeset
|
3183 |
} |
03a38b7ad2e0
Add a collection of commands for key bindings (Lego12239)
Mikael Berthe <mikael@lilotux.net>
parents:
1170
diff
changeset
|
3184 |
|
195 | 3185 |
// readline_backward_kill_word() |
194 | 3186 |
// Kill the word before the cursor, in input line |
1059 | 3187 |
void readline_backward_kill_word(void) |
194 | 3188 |
{ |
3189 |
char *c, *old = ptr_inputline; |
|
3190 |
int spaceallowed = 1; |
|
3191 |
||
3192 |
if (ptr_inputline == inputLine) return; |
|
3193 |
||
930
a75f7a13df7b
UTF-8 terminal support (Reimar Döffinger)
Mikael Berthe <mikael@lilotux.net>
parents:
929
diff
changeset
|
3194 |
c = prev_char(ptr_inputline, inputLine); |
a75f7a13df7b
UTF-8 terminal support (Reimar Döffinger)
Mikael Berthe <mikael@lilotux.net>
parents:
929
diff
changeset
|
3195 |
for ( ; c > inputLine ; c = prev_char(c, inputLine)) { |
a75f7a13df7b
UTF-8 terminal support (Reimar Döffinger)
Mikael Berthe <mikael@lilotux.net>
parents:
929
diff
changeset
|
3196 |
if (!iswalnum(get_char(c))) { |
933
ede9260be93d
Input line: Improve word-related functions
Mikael Berthe <mikael@lilotux.net>
parents:
932
diff
changeset
|
3197 |
if (iswblank(get_char(c))) { |
194 | 3198 |
if (!spaceallowed) break; |
933
ede9260be93d
Input line: Improve word-related functions
Mikael Berthe <mikael@lilotux.net>
parents:
932
diff
changeset
|
3199 |
} else spaceallowed = 0; |
194 | 3200 |
} else spaceallowed = 0; |
759
a681dc477c7f
Add readline_backward_word and readline_forward_word (Ctrl-Left/Ctrl-Right)
Mikael Berthe <mikael@lilotux.net>
parents:
758
diff
changeset
|
3201 |
} |
194 | 3202 |
|
1280
8b621f980321
readline_backward_kill_word() makes a stop at the "command" character
Mikael Berthe <mikael@lilotux.net>
parents:
1279
diff
changeset
|
3203 |
if (c == inputLine && *c == COMMAND_CHAR && old != c+1) { |
8b621f980321
readline_backward_kill_word() makes a stop at the "command" character
Mikael Berthe <mikael@lilotux.net>
parents:
1279
diff
changeset
|
3204 |
c = next_char(c); |
8b621f980321
readline_backward_kill_word() makes a stop at the "command" character
Mikael Berthe <mikael@lilotux.net>
parents:
1279
diff
changeset
|
3205 |
} else if (c != inputLine || iswblank(get_char(c))) { |
930
a75f7a13df7b
UTF-8 terminal support (Reimar Döffinger)
Mikael Berthe <mikael@lilotux.net>
parents:
929
diff
changeset
|
3206 |
if ((c < prev_char(ptr_inputline, inputLine)) && (!iswalnum(get_char(c)))) |
a75f7a13df7b
UTF-8 terminal support (Reimar Döffinger)
Mikael Berthe <mikael@lilotux.net>
parents:
929
diff
changeset
|
3207 |
c = next_char(c); |
1280
8b621f980321
readline_backward_kill_word() makes a stop at the "command" character
Mikael Berthe <mikael@lilotux.net>
parents:
1279
diff
changeset
|
3208 |
} |
194 | 3209 |
|
3210 |
// Modify the line |
|
3211 |
ptr_inputline = c; |
|
3212 |
for (;;) { |
|
3213 |
*c = *old++; |
|
3214 |
if (!*c++) break; |
|
3215 |
} |
|
195 | 3216 |
check_offset(-1); |
194 | 3217 |
} |
3218 |
||
759
a681dc477c7f
Add readline_backward_word and readline_forward_word (Ctrl-Left/Ctrl-Right)
Mikael Berthe <mikael@lilotux.net>
parents:
758
diff
changeset
|
3219 |
// readline_backward_word() |
a681dc477c7f
Add readline_backward_word and readline_forward_word (Ctrl-Left/Ctrl-Right)
Mikael Berthe <mikael@lilotux.net>
parents:
758
diff
changeset
|
3220 |
// Move back to the start of the current or previous word |
1059 | 3221 |
void readline_backward_word(void) |
759
a681dc477c7f
Add readline_backward_word and readline_forward_word (Ctrl-Left/Ctrl-Right)
Mikael Berthe <mikael@lilotux.net>
parents:
758
diff
changeset
|
3222 |
{ |
1172
334ae9f498f1
Add some more iline functions (Lego12239)
Mikael Berthe <mikael@lilotux.net>
parents:
1171
diff
changeset
|
3223 |
int i = 0; |
759
a681dc477c7f
Add readline_backward_word and readline_forward_word (Ctrl-Left/Ctrl-Right)
Mikael Berthe <mikael@lilotux.net>
parents:
758
diff
changeset
|
3224 |
|
a681dc477c7f
Add readline_backward_word and readline_forward_word (Ctrl-Left/Ctrl-Right)
Mikael Berthe <mikael@lilotux.net>
parents:
758
diff
changeset
|
3225 |
if (ptr_inputline == inputLine) return; |
a681dc477c7f
Add readline_backward_word and readline_forward_word (Ctrl-Left/Ctrl-Right)
Mikael Berthe <mikael@lilotux.net>
parents:
758
diff
changeset
|
3226 |
|
1172
334ae9f498f1
Add some more iline functions (Lego12239)
Mikael Berthe <mikael@lilotux.net>
parents:
1171
diff
changeset
|
3227 |
if (iswalnum(get_char(ptr_inputline)) && |
334ae9f498f1
Add some more iline functions (Lego12239)
Mikael Berthe <mikael@lilotux.net>
parents:
1171
diff
changeset
|
3228 |
!iswalnum(get_char(prev_char(ptr_inputline, inputLine)))) |
334ae9f498f1
Add some more iline functions (Lego12239)
Mikael Berthe <mikael@lilotux.net>
parents:
1171
diff
changeset
|
3229 |
i--; |
334ae9f498f1
Add some more iline functions (Lego12239)
Mikael Berthe <mikael@lilotux.net>
parents:
1171
diff
changeset
|
3230 |
|
1333
e30a9d907105
Minor coding style adjustments
Mikael Berthe <mikael@lilotux.net>
parents:
1314
diff
changeset
|
3231 |
for ( ; |
e30a9d907105
Minor coding style adjustments
Mikael Berthe <mikael@lilotux.net>
parents:
1314
diff
changeset
|
3232 |
ptr_inputline > inputLine; |
e30a9d907105
Minor coding style adjustments
Mikael Berthe <mikael@lilotux.net>
parents:
1314
diff
changeset
|
3233 |
ptr_inputline = prev_char(ptr_inputline, inputLine)) { |
930
a75f7a13df7b
UTF-8 terminal support (Reimar Döffinger)
Mikael Berthe <mikael@lilotux.net>
parents:
929
diff
changeset
|
3234 |
if (!iswalnum(get_char(ptr_inputline))) { |
1172
334ae9f498f1
Add some more iline functions (Lego12239)
Mikael Berthe <mikael@lilotux.net>
parents:
1171
diff
changeset
|
3235 |
if (i) { |
334ae9f498f1
Add some more iline functions (Lego12239)
Mikael Berthe <mikael@lilotux.net>
parents:
1171
diff
changeset
|
3236 |
ptr_inputline = next_char(ptr_inputline); |
334ae9f498f1
Add some more iline functions (Lego12239)
Mikael Berthe <mikael@lilotux.net>
parents:
1171
diff
changeset
|
3237 |
break; |
334ae9f498f1
Add some more iline functions (Lego12239)
Mikael Berthe <mikael@lilotux.net>
parents:
1171
diff
changeset
|
3238 |
} |
334ae9f498f1
Add some more iline functions (Lego12239)
Mikael Berthe <mikael@lilotux.net>
parents:
1171
diff
changeset
|
3239 |
} else i++; |
759
a681dc477c7f
Add readline_backward_word and readline_forward_word (Ctrl-Left/Ctrl-Right)
Mikael Berthe <mikael@lilotux.net>
parents:
758
diff
changeset
|
3240 |
} |
a681dc477c7f
Add readline_backward_word and readline_forward_word (Ctrl-Left/Ctrl-Right)
Mikael Berthe <mikael@lilotux.net>
parents:
758
diff
changeset
|
3241 |
|
a681dc477c7f
Add readline_backward_word and readline_forward_word (Ctrl-Left/Ctrl-Right)
Mikael Berthe <mikael@lilotux.net>
parents:
758
diff
changeset
|
3242 |
check_offset(-1); |
a681dc477c7f
Add readline_backward_word and readline_forward_word (Ctrl-Left/Ctrl-Right)
Mikael Berthe <mikael@lilotux.net>
parents:
758
diff
changeset
|
3243 |
} |
a681dc477c7f
Add readline_backward_word and readline_forward_word (Ctrl-Left/Ctrl-Right)
Mikael Berthe <mikael@lilotux.net>
parents:
758
diff
changeset
|
3244 |
|
a681dc477c7f
Add readline_backward_word and readline_forward_word (Ctrl-Left/Ctrl-Right)
Mikael Berthe <mikael@lilotux.net>
parents:
758
diff
changeset
|
3245 |
// readline_forward_word() |
a681dc477c7f
Add readline_backward_word and readline_forward_word (Ctrl-Left/Ctrl-Right)
Mikael Berthe <mikael@lilotux.net>
parents:
758
diff
changeset
|
3246 |
// Move forward to the end of the next word |
1059 | 3247 |
void readline_forward_word(void) |
759
a681dc477c7f
Add readline_backward_word and readline_forward_word (Ctrl-Left/Ctrl-Right)
Mikael Berthe <mikael@lilotux.net>
parents:
758
diff
changeset
|
3248 |
{ |
1172
334ae9f498f1
Add some more iline functions (Lego12239)
Mikael Berthe <mikael@lilotux.net>
parents:
1171
diff
changeset
|
3249 |
int stopsymbol_allowed = 1; |
334ae9f498f1
Add some more iline functions (Lego12239)
Mikael Berthe <mikael@lilotux.net>
parents:
1171
diff
changeset
|
3250 |
|
334ae9f498f1
Add some more iline functions (Lego12239)
Mikael Berthe <mikael@lilotux.net>
parents:
1171
diff
changeset
|
3251 |
while (*ptr_inputline) { |
334ae9f498f1
Add some more iline functions (Lego12239)
Mikael Berthe <mikael@lilotux.net>
parents:
1171
diff
changeset
|
3252 |
if (!iswalnum(get_char(ptr_inputline))) { |
334ae9f498f1
Add some more iline functions (Lego12239)
Mikael Berthe <mikael@lilotux.net>
parents:
1171
diff
changeset
|
3253 |
if (!stopsymbol_allowed) break; |
334ae9f498f1
Add some more iline functions (Lego12239)
Mikael Berthe <mikael@lilotux.net>
parents:
1171
diff
changeset
|
3254 |
} else stopsymbol_allowed = 0; |
334ae9f498f1
Add some more iline functions (Lego12239)
Mikael Berthe <mikael@lilotux.net>
parents:
1171
diff
changeset
|
3255 |
ptr_inputline = next_char(ptr_inputline); |
334ae9f498f1
Add some more iline functions (Lego12239)
Mikael Berthe <mikael@lilotux.net>
parents:
1171
diff
changeset
|
3256 |
} |
334ae9f498f1
Add some more iline functions (Lego12239)
Mikael Berthe <mikael@lilotux.net>
parents:
1171
diff
changeset
|
3257 |
|
334ae9f498f1
Add some more iline functions (Lego12239)
Mikael Berthe <mikael@lilotux.net>
parents:
1171
diff
changeset
|
3258 |
check_offset(1); |
334ae9f498f1
Add some more iline functions (Lego12239)
Mikael Berthe <mikael@lilotux.net>
parents:
1171
diff
changeset
|
3259 |
} |
334ae9f498f1
Add some more iline functions (Lego12239)
Mikael Berthe <mikael@lilotux.net>
parents:
1171
diff
changeset
|
3260 |
|
334ae9f498f1
Add some more iline functions (Lego12239)
Mikael Berthe <mikael@lilotux.net>
parents:
1171
diff
changeset
|
3261 |
void readline_updowncase_word(int upcase) |
334ae9f498f1
Add some more iline functions (Lego12239)
Mikael Berthe <mikael@lilotux.net>
parents:
1171
diff
changeset
|
3262 |
{ |
334ae9f498f1
Add some more iline functions (Lego12239)
Mikael Berthe <mikael@lilotux.net>
parents:
1171
diff
changeset
|
3263 |
int stopsymbol_allowed = 1; |
759
a681dc477c7f
Add readline_backward_word and readline_forward_word (Ctrl-Left/Ctrl-Right)
Mikael Berthe <mikael@lilotux.net>
parents:
758
diff
changeset
|
3264 |
|
a681dc477c7f
Add readline_backward_word and readline_forward_word (Ctrl-Left/Ctrl-Right)
Mikael Berthe <mikael@lilotux.net>
parents:
758
diff
changeset
|
3265 |
while (*ptr_inputline) { |
930
a75f7a13df7b
UTF-8 terminal support (Reimar Döffinger)
Mikael Berthe <mikael@lilotux.net>
parents:
929
diff
changeset
|
3266 |
if (!iswalnum(get_char(ptr_inputline))) { |
1172
334ae9f498f1
Add some more iline functions (Lego12239)
Mikael Berthe <mikael@lilotux.net>
parents:
1171
diff
changeset
|
3267 |
if (!stopsymbol_allowed) break; |
334ae9f498f1
Add some more iline functions (Lego12239)
Mikael Berthe <mikael@lilotux.net>
parents:
1171
diff
changeset
|
3268 |
} else { |
334ae9f498f1
Add some more iline functions (Lego12239)
Mikael Berthe <mikael@lilotux.net>
parents:
1171
diff
changeset
|
3269 |
stopsymbol_allowed = 0; |
334ae9f498f1
Add some more iline functions (Lego12239)
Mikael Berthe <mikael@lilotux.net>
parents:
1171
diff
changeset
|
3270 |
if (upcase) |
1748
51a23403cc80
Fix readline_updowncase_word() and readline_capitalize_word() wrt UTF-8
Mikael Berthe <mikael@lilotux.net>
parents:
1743
diff
changeset
|
3271 |
put_char(ptr_inputline, towupper(get_char(ptr_inputline))); |
1172
334ae9f498f1
Add some more iline functions (Lego12239)
Mikael Berthe <mikael@lilotux.net>
parents:
1171
diff
changeset
|
3272 |
else |
1748
51a23403cc80
Fix readline_updowncase_word() and readline_capitalize_word() wrt UTF-8
Mikael Berthe <mikael@lilotux.net>
parents:
1743
diff
changeset
|
3273 |
put_char(ptr_inputline, towlower(get_char(ptr_inputline))); |
1172
334ae9f498f1
Add some more iline functions (Lego12239)
Mikael Berthe <mikael@lilotux.net>
parents:
1171
diff
changeset
|
3274 |
} |
334ae9f498f1
Add some more iline functions (Lego12239)
Mikael Berthe <mikael@lilotux.net>
parents:
1171
diff
changeset
|
3275 |
ptr_inputline = next_char(ptr_inputline); |
334ae9f498f1
Add some more iline functions (Lego12239)
Mikael Berthe <mikael@lilotux.net>
parents:
1171
diff
changeset
|
3276 |
} |
334ae9f498f1
Add some more iline functions (Lego12239)
Mikael Berthe <mikael@lilotux.net>
parents:
1171
diff
changeset
|
3277 |
|
334ae9f498f1
Add some more iline functions (Lego12239)
Mikael Berthe <mikael@lilotux.net>
parents:
1171
diff
changeset
|
3278 |
check_offset(1); |
334ae9f498f1
Add some more iline functions (Lego12239)
Mikael Berthe <mikael@lilotux.net>
parents:
1171
diff
changeset
|
3279 |
} |
334ae9f498f1
Add some more iline functions (Lego12239)
Mikael Berthe <mikael@lilotux.net>
parents:
1171
diff
changeset
|
3280 |
|
334ae9f498f1
Add some more iline functions (Lego12239)
Mikael Berthe <mikael@lilotux.net>
parents:
1171
diff
changeset
|
3281 |
void readline_capitalize_word(void) |
334ae9f498f1
Add some more iline functions (Lego12239)
Mikael Berthe <mikael@lilotux.net>
parents:
1171
diff
changeset
|
3282 |
{ |
334ae9f498f1
Add some more iline functions (Lego12239)
Mikael Berthe <mikael@lilotux.net>
parents:
1171
diff
changeset
|
3283 |
int stopsymbol_allowed = 1; |
334ae9f498f1
Add some more iline functions (Lego12239)
Mikael Berthe <mikael@lilotux.net>
parents:
1171
diff
changeset
|
3284 |
int upcased = 0; |
334ae9f498f1
Add some more iline functions (Lego12239)
Mikael Berthe <mikael@lilotux.net>
parents:
1171
diff
changeset
|
3285 |
|
334ae9f498f1
Add some more iline functions (Lego12239)
Mikael Berthe <mikael@lilotux.net>
parents:
1171
diff
changeset
|
3286 |
while (*ptr_inputline) { |
334ae9f498f1
Add some more iline functions (Lego12239)
Mikael Berthe <mikael@lilotux.net>
parents:
1171
diff
changeset
|
3287 |
if (!iswalnum(get_char(ptr_inputline))) { |
334ae9f498f1
Add some more iline functions (Lego12239)
Mikael Berthe <mikael@lilotux.net>
parents:
1171
diff
changeset
|
3288 |
if (!stopsymbol_allowed) break; |
334ae9f498f1
Add some more iline functions (Lego12239)
Mikael Berthe <mikael@lilotux.net>
parents:
1171
diff
changeset
|
3289 |
} else { |
334ae9f498f1
Add some more iline functions (Lego12239)
Mikael Berthe <mikael@lilotux.net>
parents:
1171
diff
changeset
|
3290 |
stopsymbol_allowed = 0; |
334ae9f498f1
Add some more iline functions (Lego12239)
Mikael Berthe <mikael@lilotux.net>
parents:
1171
diff
changeset
|
3291 |
if (!upcased) { |
1748
51a23403cc80
Fix readline_updowncase_word() and readline_capitalize_word() wrt UTF-8
Mikael Berthe <mikael@lilotux.net>
parents:
1743
diff
changeset
|
3292 |
put_char(ptr_inputline, towupper(get_char(ptr_inputline))); |
1172
334ae9f498f1
Add some more iline functions (Lego12239)
Mikael Berthe <mikael@lilotux.net>
parents:
1171
diff
changeset
|
3293 |
upcased = 1; |
1748
51a23403cc80
Fix readline_updowncase_word() and readline_capitalize_word() wrt UTF-8
Mikael Berthe <mikael@lilotux.net>
parents:
1743
diff
changeset
|
3294 |
} else |
51a23403cc80
Fix readline_updowncase_word() and readline_capitalize_word() wrt UTF-8
Mikael Berthe <mikael@lilotux.net>
parents:
1743
diff
changeset
|
3295 |
put_char(ptr_inputline, towlower(get_char(ptr_inputline))); |
1172
334ae9f498f1
Add some more iline functions (Lego12239)
Mikael Berthe <mikael@lilotux.net>
parents:
1171
diff
changeset
|
3296 |
} |
334ae9f498f1
Add some more iline functions (Lego12239)
Mikael Berthe <mikael@lilotux.net>
parents:
1171
diff
changeset
|
3297 |
ptr_inputline = next_char(ptr_inputline); |
759
a681dc477c7f
Add readline_backward_word and readline_forward_word (Ctrl-Left/Ctrl-Right)
Mikael Berthe <mikael@lilotux.net>
parents:
758
diff
changeset
|
3298 |
} |
a681dc477c7f
Add readline_backward_word and readline_forward_word (Ctrl-Left/Ctrl-Right)
Mikael Berthe <mikael@lilotux.net>
parents:
758
diff
changeset
|
3299 |
|
a681dc477c7f
Add readline_backward_word and readline_forward_word (Ctrl-Left/Ctrl-Right)
Mikael Berthe <mikael@lilotux.net>
parents:
758
diff
changeset
|
3300 |
check_offset(1); |
a681dc477c7f
Add readline_backward_word and readline_forward_word (Ctrl-Left/Ctrl-Right)
Mikael Berthe <mikael@lilotux.net>
parents:
758
diff
changeset
|
3301 |
} |
a681dc477c7f
Add readline_backward_word and readline_forward_word (Ctrl-Left/Ctrl-Right)
Mikael Berthe <mikael@lilotux.net>
parents:
758
diff
changeset
|
3302 |
|
1171
03a38b7ad2e0
Add a collection of commands for key bindings (Lego12239)
Mikael Berthe <mikael@lilotux.net>
parents:
1170
diff
changeset
|
3303 |
void readline_backward_char(void) |
03a38b7ad2e0
Add a collection of commands for key bindings (Lego12239)
Mikael Berthe <mikael@lilotux.net>
parents:
1170
diff
changeset
|
3304 |
{ |
03a38b7ad2e0
Add a collection of commands for key bindings (Lego12239)
Mikael Berthe <mikael@lilotux.net>
parents:
1170
diff
changeset
|
3305 |
if (ptr_inputline == (char*)&inputLine) return; |
03a38b7ad2e0
Add a collection of commands for key bindings (Lego12239)
Mikael Berthe <mikael@lilotux.net>
parents:
1170
diff
changeset
|
3306 |
|
03a38b7ad2e0
Add a collection of commands for key bindings (Lego12239)
Mikael Berthe <mikael@lilotux.net>
parents:
1170
diff
changeset
|
3307 |
ptr_inputline = prev_char(ptr_inputline, inputLine); |
03a38b7ad2e0
Add a collection of commands for key bindings (Lego12239)
Mikael Berthe <mikael@lilotux.net>
parents:
1170
diff
changeset
|
3308 |
check_offset(-1); |
03a38b7ad2e0
Add a collection of commands for key bindings (Lego12239)
Mikael Berthe <mikael@lilotux.net>
parents:
1170
diff
changeset
|
3309 |
} |
03a38b7ad2e0
Add a collection of commands for key bindings (Lego12239)
Mikael Berthe <mikael@lilotux.net>
parents:
1170
diff
changeset
|
3310 |
|
03a38b7ad2e0
Add a collection of commands for key bindings (Lego12239)
Mikael Berthe <mikael@lilotux.net>
parents:
1170
diff
changeset
|
3311 |
void readline_forward_char(void) |
03a38b7ad2e0
Add a collection of commands for key bindings (Lego12239)
Mikael Berthe <mikael@lilotux.net>
parents:
1170
diff
changeset
|
3312 |
{ |
03a38b7ad2e0
Add a collection of commands for key bindings (Lego12239)
Mikael Berthe <mikael@lilotux.net>
parents:
1170
diff
changeset
|
3313 |
if (!*ptr_inputline) return; |
03a38b7ad2e0
Add a collection of commands for key bindings (Lego12239)
Mikael Berthe <mikael@lilotux.net>
parents:
1170
diff
changeset
|
3314 |
|
03a38b7ad2e0
Add a collection of commands for key bindings (Lego12239)
Mikael Berthe <mikael@lilotux.net>
parents:
1170
diff
changeset
|
3315 |
ptr_inputline = next_char(ptr_inputline); |
03a38b7ad2e0
Add a collection of commands for key bindings (Lego12239)
Mikael Berthe <mikael@lilotux.net>
parents:
1170
diff
changeset
|
3316 |
check_offset(1); |
03a38b7ad2e0
Add a collection of commands for key bindings (Lego12239)
Mikael Berthe <mikael@lilotux.net>
parents:
1170
diff
changeset
|
3317 |
} |
03a38b7ad2e0
Add a collection of commands for key bindings (Lego12239)
Mikael Berthe <mikael@lilotux.net>
parents:
1170
diff
changeset
|
3318 |
|
1177
10733d7de004
Refactor readline_accept_line() and readline_accept_line_down_hist()
Mikael Berthe <mikael@lilotux.net>
parents:
1176
diff
changeset
|
3319 |
// readline_accept_line(down_history) |
10733d7de004
Refactor readline_accept_line() and readline_accept_line_down_hist()
Mikael Berthe <mikael@lilotux.net>
parents:
1176
diff
changeset
|
3320 |
// Validate current command line. |
10733d7de004
Refactor readline_accept_line() and readline_accept_line_down_hist()
Mikael Berthe <mikael@lilotux.net>
parents:
1176
diff
changeset
|
3321 |
// If down_history is true, load the next history line. |
10733d7de004
Refactor readline_accept_line() and readline_accept_line_down_hist()
Mikael Berthe <mikael@lilotux.net>
parents:
1176
diff
changeset
|
3322 |
int readline_accept_line(int down_history) |
1172
334ae9f498f1
Add some more iline functions (Lego12239)
Mikael Berthe <mikael@lilotux.net>
parents:
1171
diff
changeset
|
3323 |
{ |
1780
e4378fbab5d7
Major API cleanup - bump API to 4
Mikael Berthe <mikael@lilotux.net>
parents:
1761
diff
changeset
|
3324 |
scr_check_auto_away(TRUE); |
1172
334ae9f498f1
Add some more iline functions (Lego12239)
Mikael Berthe <mikael@lilotux.net>
parents:
1171
diff
changeset
|
3325 |
if (process_line(inputLine)) |
334ae9f498f1
Add some more iline functions (Lego12239)
Mikael Berthe <mikael@lilotux.net>
parents:
1171
diff
changeset
|
3326 |
return 255; |
334ae9f498f1
Add some more iline functions (Lego12239)
Mikael Berthe <mikael@lilotux.net>
parents:
1171
diff
changeset
|
3327 |
// Add line to history |
334ae9f498f1
Add some more iline functions (Lego12239)
Mikael Berthe <mikael@lilotux.net>
parents:
1171
diff
changeset
|
3328 |
scr_cmdhisto_addline(inputLine); |
334ae9f498f1
Add some more iline functions (Lego12239)
Mikael Berthe <mikael@lilotux.net>
parents:
1171
diff
changeset
|
3329 |
// Reset the line |
334ae9f498f1
Add some more iline functions (Lego12239)
Mikael Berthe <mikael@lilotux.net>
parents:
1171
diff
changeset
|
3330 |
ptr_inputline = inputLine; |
334ae9f498f1
Add some more iline functions (Lego12239)
Mikael Berthe <mikael@lilotux.net>
parents:
1171
diff
changeset
|
3331 |
*ptr_inputline = 0; |
334ae9f498f1
Add some more iline functions (Lego12239)
Mikael Berthe <mikael@lilotux.net>
parents:
1171
diff
changeset
|
3332 |
inputline_offset = 0; |
334ae9f498f1
Add some more iline functions (Lego12239)
Mikael Berthe <mikael@lilotux.net>
parents:
1171
diff
changeset
|
3333 |
|
1177
10733d7de004
Refactor readline_accept_line() and readline_accept_line_down_hist()
Mikael Berthe <mikael@lilotux.net>
parents:
1176
diff
changeset
|
3334 |
if (down_history) { |
10733d7de004
Refactor readline_accept_line() and readline_accept_line_down_hist()
Mikael Berthe <mikael@lilotux.net>
parents:
1176
diff
changeset
|
3335 |
// Use next history line instead of a blank line |
10733d7de004
Refactor readline_accept_line() and readline_accept_line_down_hist()
Mikael Berthe <mikael@lilotux.net>
parents:
1176
diff
changeset
|
3336 |
const char *l = scr_cmdhisto_next("", 0); |
10733d7de004
Refactor readline_accept_line() and readline_accept_line_down_hist()
Mikael Berthe <mikael@lilotux.net>
parents:
1176
diff
changeset
|
3337 |
if (l) strcpy(inputLine, l); |
10733d7de004
Refactor readline_accept_line() and readline_accept_line_down_hist()
Mikael Berthe <mikael@lilotux.net>
parents:
1176
diff
changeset
|
3338 |
// Reset backup history line |
10733d7de004
Refactor readline_accept_line() and readline_accept_line_down_hist()
Mikael Berthe <mikael@lilotux.net>
parents:
1176
diff
changeset
|
3339 |
cmdhisto_backup[0] = 0; |
10733d7de004
Refactor readline_accept_line() and readline_accept_line_down_hist()
Mikael Berthe <mikael@lilotux.net>
parents:
1176
diff
changeset
|
3340 |
} else { |
10733d7de004
Refactor readline_accept_line() and readline_accept_line_down_hist()
Mikael Berthe <mikael@lilotux.net>
parents:
1176
diff
changeset
|
3341 |
// Reset history line pointer |
10733d7de004
Refactor readline_accept_line() and readline_accept_line_down_hist()
Mikael Berthe <mikael@lilotux.net>
parents:
1176
diff
changeset
|
3342 |
cmdhisto_cur = NULL; |
10733d7de004
Refactor readline_accept_line() and readline_accept_line_down_hist()
Mikael Berthe <mikael@lilotux.net>
parents:
1176
diff
changeset
|
3343 |
} |
1172
334ae9f498f1
Add some more iline functions (Lego12239)
Mikael Berthe <mikael@lilotux.net>
parents:
1171
diff
changeset
|
3344 |
return 0; |
334ae9f498f1
Add some more iline functions (Lego12239)
Mikael Berthe <mikael@lilotux.net>
parents:
1171
diff
changeset
|
3345 |
} |
334ae9f498f1
Add some more iline functions (Lego12239)
Mikael Berthe <mikael@lilotux.net>
parents:
1171
diff
changeset
|
3346 |
|
334ae9f498f1
Add some more iline functions (Lego12239)
Mikael Berthe <mikael@lilotux.net>
parents:
1171
diff
changeset
|
3347 |
void readline_cancel_completion(void) |
334ae9f498f1
Add some more iline functions (Lego12239)
Mikael Berthe <mikael@lilotux.net>
parents:
1171
diff
changeset
|
3348 |
{ |
334ae9f498f1
Add some more iline functions (Lego12239)
Mikael Berthe <mikael@lilotux.net>
parents:
1171
diff
changeset
|
3349 |
scr_cancel_current_completion(); |
334ae9f498f1
Add some more iline functions (Lego12239)
Mikael Berthe <mikael@lilotux.net>
parents:
1171
diff
changeset
|
3350 |
scr_end_current_completion(); |
334ae9f498f1
Add some more iline functions (Lego12239)
Mikael Berthe <mikael@lilotux.net>
parents:
1171
diff
changeset
|
3351 |
check_offset(-1); |
334ae9f498f1
Add some more iline functions (Lego12239)
Mikael Berthe <mikael@lilotux.net>
parents:
1171
diff
changeset
|
3352 |
} |
334ae9f498f1
Add some more iline functions (Lego12239)
Mikael Berthe <mikael@lilotux.net>
parents:
1171
diff
changeset
|
3353 |
|
334ae9f498f1
Add some more iline functions (Lego12239)
Mikael Berthe <mikael@lilotux.net>
parents:
1171
diff
changeset
|
3354 |
void readline_do_completion(void) |
334ae9f498f1
Add some more iline functions (Lego12239)
Mikael Berthe <mikael@lilotux.net>
parents:
1171
diff
changeset
|
3355 |
{ |
334ae9f498f1
Add some more iline functions (Lego12239)
Mikael Berthe <mikael@lilotux.net>
parents:
1171
diff
changeset
|
3356 |
int i, n; |
334ae9f498f1
Add some more iline functions (Lego12239)
Mikael Berthe <mikael@lilotux.net>
parents:
1171
diff
changeset
|
3357 |
|
1413 | 3358 |
if (multimode != 2) { |
1172
334ae9f498f1
Add some more iline functions (Lego12239)
Mikael Berthe <mikael@lilotux.net>
parents:
1171
diff
changeset
|
3359 |
// Not in verbatim multi-line mode |
334ae9f498f1
Add some more iline functions (Lego12239)
Mikael Berthe <mikael@lilotux.net>
parents:
1171
diff
changeset
|
3360 |
scr_handle_tab(); |
334ae9f498f1
Add some more iline functions (Lego12239)
Mikael Berthe <mikael@lilotux.net>
parents:
1171
diff
changeset
|
3361 |
} else { |
334ae9f498f1
Add some more iline functions (Lego12239)
Mikael Berthe <mikael@lilotux.net>
parents:
1171
diff
changeset
|
3362 |
// Verbatim multi-line mode: expand tab |
334ae9f498f1
Add some more iline functions (Lego12239)
Mikael Berthe <mikael@lilotux.net>
parents:
1171
diff
changeset
|
3363 |
char tabstr[9]; |
334ae9f498f1
Add some more iline functions (Lego12239)
Mikael Berthe <mikael@lilotux.net>
parents:
1171
diff
changeset
|
3364 |
n = 8 - (ptr_inputline - inputLine) % 8; |
334ae9f498f1
Add some more iline functions (Lego12239)
Mikael Berthe <mikael@lilotux.net>
parents:
1171
diff
changeset
|
3365 |
for (i = 0; i < n; i++) |
334ae9f498f1
Add some more iline functions (Lego12239)
Mikael Berthe <mikael@lilotux.net>
parents:
1171
diff
changeset
|
3366 |
tabstr[i] = ' '; |
334ae9f498f1
Add some more iline functions (Lego12239)
Mikael Berthe <mikael@lilotux.net>
parents:
1171
diff
changeset
|
3367 |
tabstr[i] = '\0'; |
334ae9f498f1
Add some more iline functions (Lego12239)
Mikael Berthe <mikael@lilotux.net>
parents:
1171
diff
changeset
|
3368 |
scr_insert_text(tabstr); |
334ae9f498f1
Add some more iline functions (Lego12239)
Mikael Berthe <mikael@lilotux.net>
parents:
1171
diff
changeset
|
3369 |
} |
334ae9f498f1
Add some more iline functions (Lego12239)
Mikael Berthe <mikael@lilotux.net>
parents:
1171
diff
changeset
|
3370 |
check_offset(0); |
334ae9f498f1
Add some more iline functions (Lego12239)
Mikael Berthe <mikael@lilotux.net>
parents:
1171
diff
changeset
|
3371 |
} |
334ae9f498f1
Add some more iline functions (Lego12239)
Mikael Berthe <mikael@lilotux.net>
parents:
1171
diff
changeset
|
3372 |
|
334ae9f498f1
Add some more iline functions (Lego12239)
Mikael Berthe <mikael@lilotux.net>
parents:
1171
diff
changeset
|
3373 |
void readline_refresh_screen(void) |
334ae9f498f1
Add some more iline functions (Lego12239)
Mikael Berthe <mikael@lilotux.net>
parents:
1171
diff
changeset
|
3374 |
{ |
1780
e4378fbab5d7
Major API cleanup - bump API to 4
Mikael Berthe <mikael@lilotux.net>
parents:
1761
diff
changeset
|
3375 |
scr_check_auto_away(TRUE); |
e4378fbab5d7
Major API cleanup - bump API to 4
Mikael Berthe <mikael@lilotux.net>
parents:
1761
diff
changeset
|
3376 |
parse_colors(); |
1172
334ae9f498f1
Add some more iline functions (Lego12239)
Mikael Berthe <mikael@lilotux.net>
parents:
1171
diff
changeset
|
3377 |
scr_Resize(); |
334ae9f498f1
Add some more iline functions (Lego12239)
Mikael Berthe <mikael@lilotux.net>
parents:
1171
diff
changeset
|
3378 |
redrawwin(stdscr); |
334ae9f498f1
Add some more iline functions (Lego12239)
Mikael Berthe <mikael@lilotux.net>
parents:
1171
diff
changeset
|
3379 |
} |
334ae9f498f1
Add some more iline functions (Lego12239)
Mikael Berthe <mikael@lilotux.net>
parents:
1171
diff
changeset
|
3380 |
|
1503
c74cfe7fd848
Add option --show-roster to command chat_disable.
Mikael Berthe <mikael@lilotux.net>
parents:
1502
diff
changeset
|
3381 |
void readline_disable_chat_mode(guint show_roster) |
1172
334ae9f498f1
Add some more iline functions (Lego12239)
Mikael Berthe <mikael@lilotux.net>
parents:
1171
diff
changeset
|
3382 |
{ |
1780
e4378fbab5d7
Major API cleanup - bump API to 4
Mikael Berthe <mikael@lilotux.net>
parents:
1761
diff
changeset
|
3383 |
scr_check_auto_away(TRUE); |
1172
334ae9f498f1
Add some more iline functions (Lego12239)
Mikael Berthe <mikael@lilotux.net>
parents:
1171
diff
changeset
|
3384 |
currentWindow = NULL; |
334ae9f498f1
Add some more iline functions (Lego12239)
Mikael Berthe <mikael@lilotux.net>
parents:
1171
diff
changeset
|
3385 |
chatmode = FALSE; |
334ae9f498f1
Add some more iline functions (Lego12239)
Mikael Berthe <mikael@lilotux.net>
parents:
1171
diff
changeset
|
3386 |
if (current_buddy) |
334ae9f498f1
Add some more iline functions (Lego12239)
Mikael Berthe <mikael@lilotux.net>
parents:
1171
diff
changeset
|
3387 |
buddy_setflags(BUDDATA(current_buddy), ROSTER_FLAG_LOCK, FALSE); |
1503
c74cfe7fd848
Add option --show-roster to command chat_disable.
Mikael Berthe <mikael@lilotux.net>
parents:
1502
diff
changeset
|
3388 |
if (show_roster) |
1780
e4378fbab5d7
Major API cleanup - bump API to 4
Mikael Berthe <mikael@lilotux.net>
parents:
1761
diff
changeset
|
3389 |
scr_roster_visibility(1); |
e4378fbab5d7
Major API cleanup - bump API to 4
Mikael Berthe <mikael@lilotux.net>
parents:
1761
diff
changeset
|
3390 |
scr_update_chat_status(FALSE); |
1172
334ae9f498f1
Add some more iline functions (Lego12239)
Mikael Berthe <mikael@lilotux.net>
parents:
1171
diff
changeset
|
3391 |
top_panel(chatPanel); |
334ae9f498f1
Add some more iline functions (Lego12239)
Mikael Berthe <mikael@lilotux.net>
parents:
1171
diff
changeset
|
3392 |
top_panel(inputPanel); |
334ae9f498f1
Add some more iline functions (Lego12239)
Mikael Berthe <mikael@lilotux.net>
parents:
1171
diff
changeset
|
3393 |
update_panels(); |
334ae9f498f1
Add some more iline functions (Lego12239)
Mikael Berthe <mikael@lilotux.net>
parents:
1171
diff
changeset
|
3394 |
} |
334ae9f498f1
Add some more iline functions (Lego12239)
Mikael Berthe <mikael@lilotux.net>
parents:
1171
diff
changeset
|
3395 |
|
1190
be06bbe7e449
Add readline_hist_beginning_search_bwd/fwd functions
Mikael Berthe <mikael@lilotux.net>
parents:
1187
diff
changeset
|
3396 |
void readline_hist_beginning_search_bwd(void) |
1171
03a38b7ad2e0
Add a collection of commands for key bindings (Lego12239)
Mikael Berthe <mikael@lilotux.net>
parents:
1170
diff
changeset
|
3397 |
{ |
03a38b7ad2e0
Add a collection of commands for key bindings (Lego12239)
Mikael Berthe <mikael@lilotux.net>
parents:
1170
diff
changeset
|
3398 |
const char *l = scr_cmdhisto_prev(inputLine, ptr_inputline-inputLine); |
03a38b7ad2e0
Add a collection of commands for key bindings (Lego12239)
Mikael Berthe <mikael@lilotux.net>
parents:
1170
diff
changeset
|
3399 |
if (l) strcpy(inputLine, l); |
03a38b7ad2e0
Add a collection of commands for key bindings (Lego12239)
Mikael Berthe <mikael@lilotux.net>
parents:
1170
diff
changeset
|
3400 |
} |
03a38b7ad2e0
Add a collection of commands for key bindings (Lego12239)
Mikael Berthe <mikael@lilotux.net>
parents:
1170
diff
changeset
|
3401 |
|
1190
be06bbe7e449
Add readline_hist_beginning_search_bwd/fwd functions
Mikael Berthe <mikael@lilotux.net>
parents:
1187
diff
changeset
|
3402 |
void readline_hist_beginning_search_fwd(void) |
1171
03a38b7ad2e0
Add a collection of commands for key bindings (Lego12239)
Mikael Berthe <mikael@lilotux.net>
parents:
1170
diff
changeset
|
3403 |
{ |
03a38b7ad2e0
Add a collection of commands for key bindings (Lego12239)
Mikael Berthe <mikael@lilotux.net>
parents:
1170
diff
changeset
|
3404 |
const char *l = scr_cmdhisto_next(inputLine, ptr_inputline-inputLine); |
03a38b7ad2e0
Add a collection of commands for key bindings (Lego12239)
Mikael Berthe <mikael@lilotux.net>
parents:
1170
diff
changeset
|
3405 |
if (l) strcpy(inputLine, l); |
03a38b7ad2e0
Add a collection of commands for key bindings (Lego12239)
Mikael Berthe <mikael@lilotux.net>
parents:
1170
diff
changeset
|
3406 |
} |
03a38b7ad2e0
Add a collection of commands for key bindings (Lego12239)
Mikael Berthe <mikael@lilotux.net>
parents:
1170
diff
changeset
|
3407 |
|
1190
be06bbe7e449
Add readline_hist_beginning_search_bwd/fwd functions
Mikael Berthe <mikael@lilotux.net>
parents:
1187
diff
changeset
|
3408 |
void readline_hist_prev(void) |
be06bbe7e449
Add readline_hist_beginning_search_bwd/fwd functions
Mikael Berthe <mikael@lilotux.net>
parents:
1187
diff
changeset
|
3409 |
{ |
be06bbe7e449
Add readline_hist_beginning_search_bwd/fwd functions
Mikael Berthe <mikael@lilotux.net>
parents:
1187
diff
changeset
|
3410 |
const char *l = scr_cmdhisto_prev(inputLine, 0); |
be06bbe7e449
Add readline_hist_beginning_search_bwd/fwd functions
Mikael Berthe <mikael@lilotux.net>
parents:
1187
diff
changeset
|
3411 |
if (l) { |
be06bbe7e449
Add readline_hist_beginning_search_bwd/fwd functions
Mikael Berthe <mikael@lilotux.net>
parents:
1187
diff
changeset
|
3412 |
strcpy(inputLine, l); |
be06bbe7e449
Add readline_hist_beginning_search_bwd/fwd functions
Mikael Berthe <mikael@lilotux.net>
parents:
1187
diff
changeset
|
3413 |
// Set the pointer at the EOL. |
be06bbe7e449
Add readline_hist_beginning_search_bwd/fwd functions
Mikael Berthe <mikael@lilotux.net>
parents:
1187
diff
changeset
|
3414 |
// We have to move it to BOL first, because we could be too far already. |
be06bbe7e449
Add readline_hist_beginning_search_bwd/fwd functions
Mikael Berthe <mikael@lilotux.net>
parents:
1187
diff
changeset
|
3415 |
readline_iline_start(); |
be06bbe7e449
Add readline_hist_beginning_search_bwd/fwd functions
Mikael Berthe <mikael@lilotux.net>
parents:
1187
diff
changeset
|
3416 |
readline_iline_end(); |
be06bbe7e449
Add readline_hist_beginning_search_bwd/fwd functions
Mikael Berthe <mikael@lilotux.net>
parents:
1187
diff
changeset
|
3417 |
} |
be06bbe7e449
Add readline_hist_beginning_search_bwd/fwd functions
Mikael Berthe <mikael@lilotux.net>
parents:
1187
diff
changeset
|
3418 |
} |
be06bbe7e449
Add readline_hist_beginning_search_bwd/fwd functions
Mikael Berthe <mikael@lilotux.net>
parents:
1187
diff
changeset
|
3419 |
|
be06bbe7e449
Add readline_hist_beginning_search_bwd/fwd functions
Mikael Berthe <mikael@lilotux.net>
parents:
1187
diff
changeset
|
3420 |
void readline_hist_next(void) |
be06bbe7e449
Add readline_hist_beginning_search_bwd/fwd functions
Mikael Berthe <mikael@lilotux.net>
parents:
1187
diff
changeset
|
3421 |
{ |
be06bbe7e449
Add readline_hist_beginning_search_bwd/fwd functions
Mikael Berthe <mikael@lilotux.net>
parents:
1187
diff
changeset
|
3422 |
const char *l = scr_cmdhisto_next(inputLine, 0); |
be06bbe7e449
Add readline_hist_beginning_search_bwd/fwd functions
Mikael Berthe <mikael@lilotux.net>
parents:
1187
diff
changeset
|
3423 |
if (l) { |
be06bbe7e449
Add readline_hist_beginning_search_bwd/fwd functions
Mikael Berthe <mikael@lilotux.net>
parents:
1187
diff
changeset
|
3424 |
strcpy(inputLine, l); |
be06bbe7e449
Add readline_hist_beginning_search_bwd/fwd functions
Mikael Berthe <mikael@lilotux.net>
parents:
1187
diff
changeset
|
3425 |
// Set the pointer at the EOL. |
be06bbe7e449
Add readline_hist_beginning_search_bwd/fwd functions
Mikael Berthe <mikael@lilotux.net>
parents:
1187
diff
changeset
|
3426 |
// We have to move it to BOL first, because we could be too far already. |
be06bbe7e449
Add readline_hist_beginning_search_bwd/fwd functions
Mikael Berthe <mikael@lilotux.net>
parents:
1187
diff
changeset
|
3427 |
readline_iline_start(); |
be06bbe7e449
Add readline_hist_beginning_search_bwd/fwd functions
Mikael Berthe <mikael@lilotux.net>
parents:
1187
diff
changeset
|
3428 |
readline_iline_end(); |
be06bbe7e449
Add readline_hist_beginning_search_bwd/fwd functions
Mikael Berthe <mikael@lilotux.net>
parents:
1187
diff
changeset
|
3429 |
} |
be06bbe7e449
Add readline_hist_beginning_search_bwd/fwd functions
Mikael Berthe <mikael@lilotux.net>
parents:
1187
diff
changeset
|
3430 |
} |
be06bbe7e449
Add readline_hist_beginning_search_bwd/fwd functions
Mikael Berthe <mikael@lilotux.net>
parents:
1187
diff
changeset
|
3431 |
|
1171
03a38b7ad2e0
Add a collection of commands for key bindings (Lego12239)
Mikael Berthe <mikael@lilotux.net>
parents:
1170
diff
changeset
|
3432 |
void readline_backward_kill_char(void) |
03a38b7ad2e0
Add a collection of commands for key bindings (Lego12239)
Mikael Berthe <mikael@lilotux.net>
parents:
1170
diff
changeset
|
3433 |
{ |
03a38b7ad2e0
Add a collection of commands for key bindings (Lego12239)
Mikael Berthe <mikael@lilotux.net>
parents:
1170
diff
changeset
|
3434 |
char *src, *c; |
03a38b7ad2e0
Add a collection of commands for key bindings (Lego12239)
Mikael Berthe <mikael@lilotux.net>
parents:
1170
diff
changeset
|
3435 |
|
03a38b7ad2e0
Add a collection of commands for key bindings (Lego12239)
Mikael Berthe <mikael@lilotux.net>
parents:
1170
diff
changeset
|
3436 |
if (ptr_inputline == (char*)&inputLine) |
03a38b7ad2e0
Add a collection of commands for key bindings (Lego12239)
Mikael Berthe <mikael@lilotux.net>
parents:
1170
diff
changeset
|
3437 |
return; |
03a38b7ad2e0
Add a collection of commands for key bindings (Lego12239)
Mikael Berthe <mikael@lilotux.net>
parents:
1170
diff
changeset
|
3438 |
|
03a38b7ad2e0
Add a collection of commands for key bindings (Lego12239)
Mikael Berthe <mikael@lilotux.net>
parents:
1170
diff
changeset
|
3439 |
src = ptr_inputline; |
03a38b7ad2e0
Add a collection of commands for key bindings (Lego12239)
Mikael Berthe <mikael@lilotux.net>
parents:
1170
diff
changeset
|
3440 |
c = prev_char(ptr_inputline, inputLine); |
03a38b7ad2e0
Add a collection of commands for key bindings (Lego12239)
Mikael Berthe <mikael@lilotux.net>
parents:
1170
diff
changeset
|
3441 |
ptr_inputline = c; |
03a38b7ad2e0
Add a collection of commands for key bindings (Lego12239)
Mikael Berthe <mikael@lilotux.net>
parents:
1170
diff
changeset
|
3442 |
for ( ; *src ; ) |
03a38b7ad2e0
Add a collection of commands for key bindings (Lego12239)
Mikael Berthe <mikael@lilotux.net>
parents:
1170
diff
changeset
|
3443 |
*c++ = *src++; |
03a38b7ad2e0
Add a collection of commands for key bindings (Lego12239)
Mikael Berthe <mikael@lilotux.net>
parents:
1170
diff
changeset
|
3444 |
*c = 0; |
03a38b7ad2e0
Add a collection of commands for key bindings (Lego12239)
Mikael Berthe <mikael@lilotux.net>
parents:
1170
diff
changeset
|
3445 |
check_offset(-1); |
03a38b7ad2e0
Add a collection of commands for key bindings (Lego12239)
Mikael Berthe <mikael@lilotux.net>
parents:
1170
diff
changeset
|
3446 |
} |
03a38b7ad2e0
Add a collection of commands for key bindings (Lego12239)
Mikael Berthe <mikael@lilotux.net>
parents:
1170
diff
changeset
|
3447 |
|
03a38b7ad2e0
Add a collection of commands for key bindings (Lego12239)
Mikael Berthe <mikael@lilotux.net>
parents:
1170
diff
changeset
|
3448 |
void readline_forward_kill_char(void) |
03a38b7ad2e0
Add a collection of commands for key bindings (Lego12239)
Mikael Berthe <mikael@lilotux.net>
parents:
1170
diff
changeset
|
3449 |
{ |
03a38b7ad2e0
Add a collection of commands for key bindings (Lego12239)
Mikael Berthe <mikael@lilotux.net>
parents:
1170
diff
changeset
|
3450 |
if (!*ptr_inputline) |
03a38b7ad2e0
Add a collection of commands for key bindings (Lego12239)
Mikael Berthe <mikael@lilotux.net>
parents:
1170
diff
changeset
|
3451 |
return; |
03a38b7ad2e0
Add a collection of commands for key bindings (Lego12239)
Mikael Berthe <mikael@lilotux.net>
parents:
1170
diff
changeset
|
3452 |
|
03a38b7ad2e0
Add a collection of commands for key bindings (Lego12239)
Mikael Berthe <mikael@lilotux.net>
parents:
1170
diff
changeset
|
3453 |
strcpy(ptr_inputline, next_char(ptr_inputline)); |
03a38b7ad2e0
Add a collection of commands for key bindings (Lego12239)
Mikael Berthe <mikael@lilotux.net>
parents:
1170
diff
changeset
|
3454 |
} |
03a38b7ad2e0
Add a collection of commands for key bindings (Lego12239)
Mikael Berthe <mikael@lilotux.net>
parents:
1170
diff
changeset
|
3455 |
|
03a38b7ad2e0
Add a collection of commands for key bindings (Lego12239)
Mikael Berthe <mikael@lilotux.net>
parents:
1170
diff
changeset
|
3456 |
void readline_iline_start(void) |
03a38b7ad2e0
Add a collection of commands for key bindings (Lego12239)
Mikael Berthe <mikael@lilotux.net>
parents:
1170
diff
changeset
|
3457 |
{ |
03a38b7ad2e0
Add a collection of commands for key bindings (Lego12239)
Mikael Berthe <mikael@lilotux.net>
parents:
1170
diff
changeset
|
3458 |
ptr_inputline = inputLine; |
03a38b7ad2e0
Add a collection of commands for key bindings (Lego12239)
Mikael Berthe <mikael@lilotux.net>
parents:
1170
diff
changeset
|
3459 |
inputline_offset = 0; |
03a38b7ad2e0
Add a collection of commands for key bindings (Lego12239)
Mikael Berthe <mikael@lilotux.net>
parents:
1170
diff
changeset
|
3460 |
} |
03a38b7ad2e0
Add a collection of commands for key bindings (Lego12239)
Mikael Berthe <mikael@lilotux.net>
parents:
1170
diff
changeset
|
3461 |
|
03a38b7ad2e0
Add a collection of commands for key bindings (Lego12239)
Mikael Berthe <mikael@lilotux.net>
parents:
1170
diff
changeset
|
3462 |
void readline_iline_end(void) |
03a38b7ad2e0
Add a collection of commands for key bindings (Lego12239)
Mikael Berthe <mikael@lilotux.net>
parents:
1170
diff
changeset
|
3463 |
{ |
03a38b7ad2e0
Add a collection of commands for key bindings (Lego12239)
Mikael Berthe <mikael@lilotux.net>
parents:
1170
diff
changeset
|
3464 |
for (; *ptr_inputline; ptr_inputline++) ; |
03a38b7ad2e0
Add a collection of commands for key bindings (Lego12239)
Mikael Berthe <mikael@lilotux.net>
parents:
1170
diff
changeset
|
3465 |
check_offset(1); |
03a38b7ad2e0
Add a collection of commands for key bindings (Lego12239)
Mikael Berthe <mikael@lilotux.net>
parents:
1170
diff
changeset
|
3466 |
} |
03a38b7ad2e0
Add a collection of commands for key bindings (Lego12239)
Mikael Berthe <mikael@lilotux.net>
parents:
1170
diff
changeset
|
3467 |
|
03a38b7ad2e0
Add a collection of commands for key bindings (Lego12239)
Mikael Berthe <mikael@lilotux.net>
parents:
1170
diff
changeset
|
3468 |
void readline_backward_kill_iline(void) |
03a38b7ad2e0
Add a collection of commands for key bindings (Lego12239)
Mikael Berthe <mikael@lilotux.net>
parents:
1170
diff
changeset
|
3469 |
{ |
03a38b7ad2e0
Add a collection of commands for key bindings (Lego12239)
Mikael Berthe <mikael@lilotux.net>
parents:
1170
diff
changeset
|
3470 |
strcpy(inputLine, ptr_inputline); |
03a38b7ad2e0
Add a collection of commands for key bindings (Lego12239)
Mikael Berthe <mikael@lilotux.net>
parents:
1170
diff
changeset
|
3471 |
ptr_inputline = inputLine; |
03a38b7ad2e0
Add a collection of commands for key bindings (Lego12239)
Mikael Berthe <mikael@lilotux.net>
parents:
1170
diff
changeset
|
3472 |
inputline_offset = 0; |
03a38b7ad2e0
Add a collection of commands for key bindings (Lego12239)
Mikael Berthe <mikael@lilotux.net>
parents:
1170
diff
changeset
|
3473 |
} |
03a38b7ad2e0
Add a collection of commands for key bindings (Lego12239)
Mikael Berthe <mikael@lilotux.net>
parents:
1170
diff
changeset
|
3474 |
|
03a38b7ad2e0
Add a collection of commands for key bindings (Lego12239)
Mikael Berthe <mikael@lilotux.net>
parents:
1170
diff
changeset
|
3475 |
void readline_forward_kill_iline(void) |
03a38b7ad2e0
Add a collection of commands for key bindings (Lego12239)
Mikael Berthe <mikael@lilotux.net>
parents:
1170
diff
changeset
|
3476 |
{ |
03a38b7ad2e0
Add a collection of commands for key bindings (Lego12239)
Mikael Berthe <mikael@lilotux.net>
parents:
1170
diff
changeset
|
3477 |
*ptr_inputline = 0; |
03a38b7ad2e0
Add a collection of commands for key bindings (Lego12239)
Mikael Berthe <mikael@lilotux.net>
parents:
1170
diff
changeset
|
3478 |
} |
03a38b7ad2e0
Add a collection of commands for key bindings (Lego12239)
Mikael Berthe <mikael@lilotux.net>
parents:
1170
diff
changeset
|
3479 |
|
03a38b7ad2e0
Add a collection of commands for key bindings (Lego12239)
Mikael Berthe <mikael@lilotux.net>
parents:
1170
diff
changeset
|
3480 |
void readline_send_multiline(void) |
03a38b7ad2e0
Add a collection of commands for key bindings (Lego12239)
Mikael Berthe <mikael@lilotux.net>
parents:
1170
diff
changeset
|
3481 |
{ |
03a38b7ad2e0
Add a collection of commands for key bindings (Lego12239)
Mikael Berthe <mikael@lilotux.net>
parents:
1170
diff
changeset
|
3482 |
// Validate current multi-line |
1413 | 3483 |
if (multimode) |
1187
16abe7ec3056
Fix a conflict between verbatim multiline mode and the key binding system
Mikael Berthe <mikael@lilotux.net>
parents:
1186
diff
changeset
|
3484 |
process_command(mkcmdstr("msay send"), TRUE); |
1171
03a38b7ad2e0
Add a collection of commands for key bindings (Lego12239)
Mikael Berthe <mikael@lilotux.net>
parents:
1170
diff
changeset
|
3485 |
} |
03a38b7ad2e0
Add a collection of commands for key bindings (Lego12239)
Mikael Berthe <mikael@lilotux.net>
parents:
1170
diff
changeset
|
3486 |
|
98 | 3487 |
// which_row() |
3488 |
// Tells which row our cursor is in, in the command line. |
|
503
ddec224c2318
MUC: nickname completion
Mikael Berthe <mikael@lilotux.net>
parents:
499
diff
changeset
|
3489 |
// -2 -> normal text |
ddec224c2318
MUC: nickname completion
Mikael Berthe <mikael@lilotux.net>
parents:
499
diff
changeset
|
3490 |
// -1 -> room: nickname completion |
98 | 3491 |
// 0 -> command |
3492 |
// 1 -> parameter 1 (etc.) |
|
102 | 3493 |
// If > 0, then *p_row is set to the beginning of the row |
503
ddec224c2318
MUC: nickname completion
Mikael Berthe <mikael@lilotux.net>
parents:
499
diff
changeset
|
3494 |
static int which_row(const char **p_row) |
98 | 3495 |
{ |
3496 |
int row = -1; |
|
3497 |
char *p; |
|
3498 |
int quote = FALSE; |
|
3499 |
||
3500 |
// Not a command? |
|
967 | 3501 |
if ((ptr_inputline == inputLine) || (inputLine[0] != COMMAND_CHAR)) { |
503
ddec224c2318
MUC: nickname completion
Mikael Berthe <mikael@lilotux.net>
parents:
499
diff
changeset
|
3502 |
if (!current_buddy) return -2; |
ddec224c2318
MUC: nickname completion
Mikael Berthe <mikael@lilotux.net>
parents:
499
diff
changeset
|
3503 |
if (buddy_gettype(BUDDATA(current_buddy)) == ROSTER_TYPE_ROOM) { |
ddec224c2318
MUC: nickname completion
Mikael Berthe <mikael@lilotux.net>
parents:
499
diff
changeset
|
3504 |
*p_row = inputLine; |
ddec224c2318
MUC: nickname completion
Mikael Berthe <mikael@lilotux.net>
parents:
499
diff
changeset
|
3505 |
return -1; |
ddec224c2318
MUC: nickname completion
Mikael Berthe <mikael@lilotux.net>
parents:
499
diff
changeset
|
3506 |
} |
ddec224c2318
MUC: nickname completion
Mikael Berthe <mikael@lilotux.net>
parents:
499
diff
changeset
|
3507 |
return -2; |
ddec224c2318
MUC: nickname completion
Mikael Berthe <mikael@lilotux.net>
parents:
499
diff
changeset
|
3508 |
} |
98 | 3509 |
|
3510 |
// This is a command |
|
3511 |
row = 0; |
|
930
a75f7a13df7b
UTF-8 terminal support (Reimar Döffinger)
Mikael Berthe <mikael@lilotux.net>
parents:
929
diff
changeset
|
3512 |
for (p = inputLine ; p < ptr_inputline ; p = next_char(p)) { |
98 | 3513 |
if (quote) { |
3514 |
if (*p == '"' && *(p-1) != '\\') |
|
3515 |
quote = FALSE; |
|
3516 |
continue; |
|
3517 |
} |
|
3518 |
if (*p == '"' && *(p-1) != '\\') { |
|
3519 |
quote = TRUE; |
|
121 | 3520 |
} else if (*p == ' ') { |
3521 |
if (*(p-1) != ' ') |
|
3522 |
row++; |
|
102 | 3523 |
*p_row = p+1; |
3524 |
} |
|
98 | 3525 |
} |
3526 |
return row; |
|
3527 |
} |
|
3528 |
||
143 | 3529 |
// scr_insert_text() |
3530 |
// Insert the given text at the current cursor position. |
|
3531 |
// The cursor is moved. We don't check if the cursor still is in the screen |
|
3532 |
// after, the caller should do that. |
|
336
eb994ee40029
Make some functions static
Mikael Berthe <mikael@lilotux.net>
parents:
332
diff
changeset
|
3533 |
static void scr_insert_text(const char *text) |
98 | 3534 |
{ |
3535 |
char tmpLine[INPUTLINE_LENGTH+1]; |
|
3536 |
int len = strlen(text); |
|
3537 |
// Check the line isn't too long |
|
3538 |
if (strlen(inputLine) + len >= INPUTLINE_LENGTH) { |
|
374
bd5638c21834
Improve logging system (traces)
Mikael Berthe <mikael@lilotux.net>
parents:
373
diff
changeset
|
3539 |
scr_LogPrint(LPRINT_LOGNORM, "Cannot insert text, line too long."); |
98 | 3540 |
return; |
3541 |
} |
|
3542 |
||
3543 |
strcpy(tmpLine, ptr_inputline); |
|
419 | 3544 |
strcpy(ptr_inputline, text); |
3545 |
ptr_inputline += len; |
|
98 | 3546 |
strcpy(ptr_inputline, tmpLine); |
3547 |
} |
|
3548 |
||
930
a75f7a13df7b
UTF-8 terminal support (Reimar Döffinger)
Mikael Berthe <mikael@lilotux.net>
parents:
929
diff
changeset
|
3549 |
static void scr_cancel_current_completion(void); |
a75f7a13df7b
UTF-8 terminal support (Reimar Döffinger)
Mikael Berthe <mikael@lilotux.net>
parents:
929
diff
changeset
|
3550 |
|
143 | 3551 |
// scr_handle_tab() |
3552 |
// Function called when tab is pressed. |
|
3553 |
// Initiate or continue a completion... |
|
336
eb994ee40029
Make some functions static
Mikael Berthe <mikael@lilotux.net>
parents:
332
diff
changeset
|
3554 |
static void scr_handle_tab(void) |
98 | 3555 |
{ |
102 | 3556 |
int nrow; |
503
ddec224c2318
MUC: nickname completion
Mikael Berthe <mikael@lilotux.net>
parents:
499
diff
changeset
|
3557 |
const char *row; |
102 | 3558 |
const char *cchar; |
103 | 3559 |
guint compl_categ; |
98 | 3560 |
|
740 | 3561 |
row = inputLine; // (Kills a GCC warning) |
102 | 3562 |
nrow = which_row(&row); |
98 | 3563 |
|
503
ddec224c2318
MUC: nickname completion
Mikael Berthe <mikael@lilotux.net>
parents:
499
diff
changeset
|
3564 |
// a) No completion if no leading slash ('cause not a command), |
ddec224c2318
MUC: nickname completion
Mikael Berthe <mikael@lilotux.net>
parents:
499
diff
changeset
|
3565 |
// unless this is a room (then, it is a nickname completion) |
103 | 3566 |
// b) We can't have more than 2 parameters (we use 2 flags) |
503
ddec224c2318
MUC: nickname completion
Mikael Berthe <mikael@lilotux.net>
parents:
499
diff
changeset
|
3567 |
if ((nrow == -2) || (nrow == 3 && !completion_started) || nrow > 3) |
ddec224c2318
MUC: nickname completion
Mikael Berthe <mikael@lilotux.net>
parents:
499
diff
changeset
|
3568 |
return; |
102 | 3569 |
|
503
ddec224c2318
MUC: nickname completion
Mikael Berthe <mikael@lilotux.net>
parents:
499
diff
changeset
|
3570 |
if (nrow == 0) { // Command completion |
930
a75f7a13df7b
UTF-8 terminal support (Reimar Döffinger)
Mikael Berthe <mikael@lilotux.net>
parents:
929
diff
changeset
|
3571 |
row = next_char(inputLine); |
103 | 3572 |
compl_categ = COMPL_CMD; |
503
ddec224c2318
MUC: nickname completion
Mikael Berthe <mikael@lilotux.net>
parents:
499
diff
changeset
|
3573 |
} else if (nrow == -1) { // Nickname completion |
ddec224c2318
MUC: nickname completion
Mikael Berthe <mikael@lilotux.net>
parents:
499
diff
changeset
|
3574 |
compl_categ = COMPL_RESOURCE; |
ddec224c2318
MUC: nickname completion
Mikael Berthe <mikael@lilotux.net>
parents:
499
diff
changeset
|
3575 |
} else { // Other completion, depending on the command |
285 | 3576 |
int alias = FALSE; |
3577 |
cmd *com; |
|
3578 |
char *xpline = expandalias(inputLine); |
|
3579 |
com = cmd_get(xpline); |
|
3580 |
if (xpline != inputLine) { |
|
3581 |
// This is an alias, so we can't complete rows > 0 |
|
3582 |
alias = TRUE; |
|
3583 |
g_free(xpline); |
|
3584 |
} |
|
3585 |
if ((!com && (!alias || !completion_started)) || !row) { |
|
374
bd5638c21834
Improve logging system (traces)
Mikael Berthe <mikael@lilotux.net>
parents:
373
diff
changeset
|
3586 |
scr_LogPrint(LPRINT_NORMAL, "I cannot complete that..."); |
103 | 3587 |
return; |
3588 |
} |
|
285 | 3589 |
if (!alias) |
3590 |
compl_categ = com->completion_flags[nrow-1]; |
|
3591 |
else |
|
3592 |
compl_categ = 0; |
|
103 | 3593 |
} |
3594 |
||
3595 |
if (!completion_started) { |
|
1076
b9698c89f46d
Fix memory leak in scr_handle_tab()
Mikael Berthe <mikael@lilotux.net>
parents:
1075
diff
changeset
|
3596 |
guint dynlist; |
b9698c89f46d
Fix memory leak in scr_handle_tab()
Mikael Berthe <mikael@lilotux.net>
parents:
1075
diff
changeset
|
3597 |
GSList *list = compl_get_category_list(compl_categ, &dynlist); |
103 | 3598 |
if (list) { |
1228
9a68fe4515dc
Improve MUC nickname completion
Mikael Berthe <mikael@lilotux.net>
parents:
1227
diff
changeset
|
3599 |
guint n; |
103 | 3600 |
char *prefix = g_strndup(row, ptr_inputline-row); |
3601 |
// Init completion |
|
1756
e2c084204583
Add (optional) suffix after nick completion in Multi-User Chats
Mikael Berthe <mikael@lilotux.net>
parents:
1748
diff
changeset
|
3602 |
n = new_completion(prefix, list, |
e2c084204583
Add (optional) suffix after nick completion in Multi-User Chats
Mikael Berthe <mikael@lilotux.net>
parents:
1748
diff
changeset
|
3603 |
(compl_categ == COMPL_RESOURCE ? |
1793
c3ddb52f1055
Rename completion_muc_suffix to muc_completion_suffix
Myhailo Danylenko <isbear@ukrpost.net>
parents:
1791
diff
changeset
|
3604 |
settings_opt_get("muc_completion_suffix") : NULL)); |
103 | 3605 |
g_free(prefix); |
1228
9a68fe4515dc
Improve MUC nickname completion
Mikael Berthe <mikael@lilotux.net>
parents:
1227
diff
changeset
|
3606 |
if (n == 0 && nrow == -1) { |
9a68fe4515dc
Improve MUC nickname completion
Mikael Berthe <mikael@lilotux.net>
parents:
1227
diff
changeset
|
3607 |
// This is a MUC room and we can't complete from the beginning of the |
9a68fe4515dc
Improve MUC nickname completion
Mikael Berthe <mikael@lilotux.net>
parents:
1227
diff
changeset
|
3608 |
// line. Let's try a bit harder and complete the current word. |
9a68fe4515dc
Improve MUC nickname completion
Mikael Berthe <mikael@lilotux.net>
parents:
1227
diff
changeset
|
3609 |
row = prev_char(ptr_inputline, inputLine); |
9a68fe4515dc
Improve MUC nickname completion
Mikael Berthe <mikael@lilotux.net>
parents:
1227
diff
changeset
|
3610 |
while (row >= inputLine) { |
1239
eb9fc5d6d085
MUC: Nickname completion starts from any non-space character
Mikael Berthe <mikael@lilotux.net>
parents:
1229
diff
changeset
|
3611 |
if (iswspace(get_char(row)) || get_char(row) == '(') { |
1228
9a68fe4515dc
Improve MUC nickname completion
Mikael Berthe <mikael@lilotux.net>
parents:
1227
diff
changeset
|
3612 |
row = next_char((char*)row); |
9a68fe4515dc
Improve MUC nickname completion
Mikael Berthe <mikael@lilotux.net>
parents:
1227
diff
changeset
|
3613 |
break; |
9a68fe4515dc
Improve MUC nickname completion
Mikael Berthe <mikael@lilotux.net>
parents:
1227
diff
changeset
|
3614 |
} |
9a68fe4515dc
Improve MUC nickname completion
Mikael Berthe <mikael@lilotux.net>
parents:
1227
diff
changeset
|
3615 |
if (row == inputLine) |
9a68fe4515dc
Improve MUC nickname completion
Mikael Berthe <mikael@lilotux.net>
parents:
1227
diff
changeset
|
3616 |
break; |
9a68fe4515dc
Improve MUC nickname completion
Mikael Berthe <mikael@lilotux.net>
parents:
1227
diff
changeset
|
3617 |
row = prev_char((char*)row, inputLine); |
9a68fe4515dc
Improve MUC nickname completion
Mikael Berthe <mikael@lilotux.net>
parents:
1227
diff
changeset
|
3618 |
} |
9a68fe4515dc
Improve MUC nickname completion
Mikael Berthe <mikael@lilotux.net>
parents:
1227
diff
changeset
|
3619 |
// There's no need to try again if row == inputLine |
9a68fe4515dc
Improve MUC nickname completion
Mikael Berthe <mikael@lilotux.net>
parents:
1227
diff
changeset
|
3620 |
if (row > inputLine) { |
9a68fe4515dc
Improve MUC nickname completion
Mikael Berthe <mikael@lilotux.net>
parents:
1227
diff
changeset
|
3621 |
prefix = g_strndup(row, ptr_inputline-row); |
1756
e2c084204583
Add (optional) suffix after nick completion in Multi-User Chats
Mikael Berthe <mikael@lilotux.net>
parents:
1748
diff
changeset
|
3622 |
new_completion(prefix, list, NULL); |
1228
9a68fe4515dc
Improve MUC nickname completion
Mikael Berthe <mikael@lilotux.net>
parents:
1227
diff
changeset
|
3623 |
g_free(prefix); |
9a68fe4515dc
Improve MUC nickname completion
Mikael Berthe <mikael@lilotux.net>
parents:
1227
diff
changeset
|
3624 |
} |
9a68fe4515dc
Improve MUC nickname completion
Mikael Berthe <mikael@lilotux.net>
parents:
1227
diff
changeset
|
3625 |
} |
1076
b9698c89f46d
Fix memory leak in scr_handle_tab()
Mikael Berthe <mikael@lilotux.net>
parents:
1075
diff
changeset
|
3626 |
// Free the list if it's a dynamic one |
b9698c89f46d
Fix memory leak in scr_handle_tab()
Mikael Berthe <mikael@lilotux.net>
parents:
1075
diff
changeset
|
3627 |
if (dynlist) { |
b9698c89f46d
Fix memory leak in scr_handle_tab()
Mikael Berthe <mikael@lilotux.net>
parents:
1075
diff
changeset
|
3628 |
GSList *slp; |
b9698c89f46d
Fix memory leak in scr_handle_tab()
Mikael Berthe <mikael@lilotux.net>
parents:
1075
diff
changeset
|
3629 |
for (slp = list; slp; slp = g_slist_next(slp)) |
b9698c89f46d
Fix memory leak in scr_handle_tab()
Mikael Berthe <mikael@lilotux.net>
parents:
1075
diff
changeset
|
3630 |
g_free(slp->data); |
b9698c89f46d
Fix memory leak in scr_handle_tab()
Mikael Berthe <mikael@lilotux.net>
parents:
1075
diff
changeset
|
3631 |
g_slist_free(list); |
b9698c89f46d
Fix memory leak in scr_handle_tab()
Mikael Berthe <mikael@lilotux.net>
parents:
1075
diff
changeset
|
3632 |
} |
103 | 3633 |
// Now complete |
98 | 3634 |
cchar = complete(); |
3635 |
if (cchar) |
|
3636 |
scr_insert_text(cchar); |
|
103 | 3637 |
completion_started = TRUE; |
98 | 3638 |
} |
103 | 3639 |
} else { // Completion already initialized |
930
a75f7a13df7b
UTF-8 terminal support (Reimar Döffinger)
Mikael Berthe <mikael@lilotux.net>
parents:
929
diff
changeset
|
3640 |
scr_cancel_current_completion(); |
103 | 3641 |
// Now complete again |
3642 |
cchar = complete(); |
|
3643 |
if (cchar) |
|
3644 |
scr_insert_text(cchar); |
|
102 | 3645 |
} |
98 | 3646 |
} |
3647 |
||
336
eb994ee40029
Make some functions static
Mikael Berthe <mikael@lilotux.net>
parents:
332
diff
changeset
|
3648 |
static void scr_cancel_current_completion(void) |
98 | 3649 |
{ |
3650 |
char *c; |
|
930
a75f7a13df7b
UTF-8 terminal support (Reimar Döffinger)
Mikael Berthe <mikael@lilotux.net>
parents:
929
diff
changeset
|
3651 |
char *src = ptr_inputline; |
98 | 3652 |
guint back = cancel_completion(); |
930
a75f7a13df7b
UTF-8 terminal support (Reimar Döffinger)
Mikael Berthe <mikael@lilotux.net>
parents:
929
diff
changeset
|
3653 |
guint i; |
98 | 3654 |
// Remove $back chars |
930
a75f7a13df7b
UTF-8 terminal support (Reimar Döffinger)
Mikael Berthe <mikael@lilotux.net>
parents:
929
diff
changeset
|
3655 |
for (i = 0; i < back; i++) |
a75f7a13df7b
UTF-8 terminal support (Reimar Döffinger)
Mikael Berthe <mikael@lilotux.net>
parents:
929
diff
changeset
|
3656 |
ptr_inputline = prev_char(ptr_inputline, inputLine); |
98 | 3657 |
c = ptr_inputline; |
930
a75f7a13df7b
UTF-8 terminal support (Reimar Döffinger)
Mikael Berthe <mikael@lilotux.net>
parents:
929
diff
changeset
|
3658 |
for ( ; *src ; ) |
a75f7a13df7b
UTF-8 terminal support (Reimar Döffinger)
Mikael Berthe <mikael@lilotux.net>
parents:
929
diff
changeset
|
3659 |
*c++ = *src++; |
a75f7a13df7b
UTF-8 terminal support (Reimar Döffinger)
Mikael Berthe <mikael@lilotux.net>
parents:
929
diff
changeset
|
3660 |
*c = 0; |
98 | 3661 |
} |
3662 |
||
336
eb994ee40029
Make some functions static
Mikael Berthe <mikael@lilotux.net>
parents:
332
diff
changeset
|
3663 |
static void scr_end_current_completion(void) |
98 | 3664 |
{ |
3665 |
done_completion(); |
|
3666 |
completion_started = FALSE; |
|
3667 |
} |
|
3668 |
||
24 | 3669 |
// check_offset(int direction) |
3670 |
// Check inputline_offset value, and make sure the cursor is inside the |
|
3671 |
// screen. |
|
336
eb994ee40029
Make some functions static
Mikael Berthe <mikael@lilotux.net>
parents:
332
diff
changeset
|
3672 |
static inline void check_offset(int direction) |
24 | 3673 |
{ |
930
a75f7a13df7b
UTF-8 terminal support (Reimar Döffinger)
Mikael Berthe <mikael@lilotux.net>
parents:
929
diff
changeset
|
3674 |
int i; |
a75f7a13df7b
UTF-8 terminal support (Reimar Döffinger)
Mikael Berthe <mikael@lilotux.net>
parents:
929
diff
changeset
|
3675 |
char *c = &inputLine[inputline_offset]; |
24 | 3676 |
// Left side |
3677 |
if (inputline_offset && direction <= 0) { |
|
930
a75f7a13df7b
UTF-8 terminal support (Reimar Döffinger)
Mikael Berthe <mikael@lilotux.net>
parents:
929
diff
changeset
|
3678 |
while (ptr_inputline <= c) { |
a75f7a13df7b
UTF-8 terminal support (Reimar Döffinger)
Mikael Berthe <mikael@lilotux.net>
parents:
929
diff
changeset
|
3679 |
for (i = 0; i < 5; i++) |
a75f7a13df7b
UTF-8 terminal support (Reimar Döffinger)
Mikael Berthe <mikael@lilotux.net>
parents:
929
diff
changeset
|
3680 |
c = prev_char(c, inputLine); |
a75f7a13df7b
UTF-8 terminal support (Reimar Döffinger)
Mikael Berthe <mikael@lilotux.net>
parents:
929
diff
changeset
|
3681 |
if (c == inputLine) |
828
319fc55b9a2b
Fix a bug in check_offset()
Mikael Berthe <mikael@lilotux.net>
parents:
827
diff
changeset
|
3682 |
break; |
24 | 3683 |
} |
3684 |
} |
|
3685 |
// Right side |
|
3686 |
if (direction >= 0) { |
|
932
fc6aaa223650
Fix a few problems with non-UTF-8 locales
Mikael Berthe <mikael@lilotux.net>
parents:
931
diff
changeset
|
3687 |
int delta = get_char_width(c); |
930
a75f7a13df7b
UTF-8 terminal support (Reimar Döffinger)
Mikael Berthe <mikael@lilotux.net>
parents:
929
diff
changeset
|
3688 |
while (ptr_inputline > c) { |
a75f7a13df7b
UTF-8 terminal support (Reimar Döffinger)
Mikael Berthe <mikael@lilotux.net>
parents:
929
diff
changeset
|
3689 |
c = next_char(c); |
932
fc6aaa223650
Fix a few problems with non-UTF-8 locales
Mikael Berthe <mikael@lilotux.net>
parents:
931
diff
changeset
|
3690 |
delta += get_char_width(c); |
930
a75f7a13df7b
UTF-8 terminal support (Reimar Döffinger)
Mikael Berthe <mikael@lilotux.net>
parents:
929
diff
changeset
|
3691 |
} |
a75f7a13df7b
UTF-8 terminal support (Reimar Döffinger)
Mikael Berthe <mikael@lilotux.net>
parents:
929
diff
changeset
|
3692 |
c = &inputLine[inputline_offset]; |
a75f7a13df7b
UTF-8 terminal support (Reimar Döffinger)
Mikael Berthe <mikael@lilotux.net>
parents:
929
diff
changeset
|
3693 |
while (delta >= maxX) { |
a75f7a13df7b
UTF-8 terminal support (Reimar Döffinger)
Mikael Berthe <mikael@lilotux.net>
parents:
929
diff
changeset
|
3694 |
for (i = 0; i < 5; i++) { |
932
fc6aaa223650
Fix a few problems with non-UTF-8 locales
Mikael Berthe <mikael@lilotux.net>
parents:
931
diff
changeset
|
3695 |
delta -= get_char_width(c); |
930
a75f7a13df7b
UTF-8 terminal support (Reimar Döffinger)
Mikael Berthe <mikael@lilotux.net>
parents:
929
diff
changeset
|
3696 |
c = next_char(c); |
a75f7a13df7b
UTF-8 terminal support (Reimar Döffinger)
Mikael Berthe <mikael@lilotux.net>
parents:
929
diff
changeset
|
3697 |
} |
a75f7a13df7b
UTF-8 terminal support (Reimar Döffinger)
Mikael Berthe <mikael@lilotux.net>
parents:
929
diff
changeset
|
3698 |
} |
24 | 3699 |
} |
930
a75f7a13df7b
UTF-8 terminal support (Reimar Döffinger)
Mikael Berthe <mikael@lilotux.net>
parents:
929
diff
changeset
|
3700 |
inputline_offset = c - inputLine; |
24 | 3701 |
} |
3702 |
||
1590
8d1bcc83ae32
Add support for spellchecking with Enchant (caolan)
Mikael Berthe <mikael@lilotux.net>
parents:
1579
diff
changeset
|
3703 |
#if defined(WITH_ENCHANT) || defined(WITH_ASPELL) |
1179 | 3704 |
// prints inputLine with underlined words when misspelled |
3705 |
static inline void print_checked_line(void) |
|
3706 |
{ |
|
3707 |
char *wprint_char_fmt = "%c"; |
|
3708 |
int point; |
|
1566
d64e0b2855fc
Fix display of last character in the input line when Aspell support is enabled
Mikael Berthe <mikael@lilotux.net>
parents:
1563
diff
changeset
|
3709 |
int nrchar = maxX; |
1179 | 3710 |
char *ptrCur = inputLine + inputline_offset; |
3711 |
||
3712 |
#ifdef UNICODE |
|
3713 |
// We need this to display a single UTF-8 char... Any better solution? |
|
3714 |
if (utf8_mode) |
|
3715 |
wprint_char_fmt = "%lc"; |
|
3716 |
#endif |
|
3717 |
||
3718 |
wmove(inputWnd, 0, 0); // problem with backspace |
|
3719 |
||
1566
d64e0b2855fc
Fix display of last character in the input line when Aspell support is enabled
Mikael Berthe <mikael@lilotux.net>
parents:
1563
diff
changeset
|
3720 |
while (*ptrCur && nrchar-- > 0) { |
1179 | 3721 |
point = ptrCur - inputLine; |
3722 |
if (maskLine[point]) |
|
3723 |
wattrset(inputWnd, A_UNDERLINE); |
|
3724 |
wprintw(inputWnd, wprint_char_fmt, get_char(ptrCur)); |
|
3725 |
wattrset(inputWnd, A_NORMAL); |
|
3726 |
ptrCur = next_char(ptrCur); |
|
3727 |
} |
|
3728 |
} |
|
3729 |
#endif |
|
3730 |
||
336
eb994ee40029
Make some functions static
Mikael Berthe <mikael@lilotux.net>
parents:
332
diff
changeset
|
3731 |
static inline void refresh_inputline(void) |
312
f0b7ff2df7e8
Ctrl-C does not terminate mcabber
Mikael Berthe <mikael@lilotux.net>
parents:
307
diff
changeset
|
3732 |
{ |
1590
8d1bcc83ae32
Add support for spellchecking with Enchant (caolan)
Mikael Berthe <mikael@lilotux.net>
parents:
1579
diff
changeset
|
3733 |
#if defined(WITH_ENCHANT) || defined(WITH_ASPELL) |
8d1bcc83ae32
Add support for spellchecking with Enchant (caolan)
Mikael Berthe <mikael@lilotux.net>
parents:
1579
diff
changeset
|
3734 |
if (settings_opt_get_int("spell_enable")) { |
1179 | 3735 |
memset(maskLine, 0, INPUTLINE_LENGTH+1); |
3736 |
spellcheck(inputLine, maskLine); |
|
3737 |
} |
|
3738 |
print_checked_line(); |
|
312
f0b7ff2df7e8
Ctrl-C does not terminate mcabber
Mikael Berthe <mikael@lilotux.net>
parents:
307
diff
changeset
|
3739 |
wclrtoeol(inputWnd); |
930
a75f7a13df7b
UTF-8 terminal support (Reimar Döffinger)
Mikael Berthe <mikael@lilotux.net>
parents:
929
diff
changeset
|
3740 |
if (*ptr_inputline) { |
a75f7a13df7b
UTF-8 terminal support (Reimar Döffinger)
Mikael Berthe <mikael@lilotux.net>
parents:
929
diff
changeset
|
3741 |
// hack to set cursor pos. Characters can have different width, |
a75f7a13df7b
UTF-8 terminal support (Reimar Döffinger)
Mikael Berthe <mikael@lilotux.net>
parents:
929
diff
changeset
|
3742 |
// so I know of no better way. |
a75f7a13df7b
UTF-8 terminal support (Reimar Döffinger)
Mikael Berthe <mikael@lilotux.net>
parents:
929
diff
changeset
|
3743 |
char c = *ptr_inputline; |
a75f7a13df7b
UTF-8 terminal support (Reimar Döffinger)
Mikael Berthe <mikael@lilotux.net>
parents:
929
diff
changeset
|
3744 |
*ptr_inputline = 0; |
1179 | 3745 |
print_checked_line(); |
930
a75f7a13df7b
UTF-8 terminal support (Reimar Döffinger)
Mikael Berthe <mikael@lilotux.net>
parents:
929
diff
changeset
|
3746 |
*ptr_inputline = c; |
a75f7a13df7b
UTF-8 terminal support (Reimar Döffinger)
Mikael Berthe <mikael@lilotux.net>
parents:
929
diff
changeset
|
3747 |
} |
1179 | 3748 |
#else |
3749 |
mvwprintw(inputWnd, 0, 0, "%s", inputLine + inputline_offset); |
|
3750 |
wclrtoeol(inputWnd); |
|
3751 |
if (*ptr_inputline) { |
|
3752 |
// hack to set cursor pos. Characters can have different width, |
|
3753 |
// so I know of no better way. |
|
3754 |
char c = *ptr_inputline; |
|
3755 |
*ptr_inputline = 0; |
|
3756 |
mvwprintw(inputWnd, 0, 0, "%s", inputLine + inputline_offset); |
|
3757 |
*ptr_inputline = c; |
|
3758 |
} |
|
3759 |
#endif |
|
312
f0b7ff2df7e8
Ctrl-C does not terminate mcabber
Mikael Berthe <mikael@lilotux.net>
parents:
307
diff
changeset
|
3760 |
} |
f0b7ff2df7e8
Ctrl-C does not terminate mcabber
Mikael Berthe <mikael@lilotux.net>
parents:
307
diff
changeset
|
3761 |
|
389
6e895f397474
Ncurses changes + Ctrl-C does not send a signal anylore
Mikael Berthe <mikael@lilotux.net>
parents:
388
diff
changeset
|
3762 |
void scr_handle_CtrlC(void) |
312
f0b7ff2df7e8
Ctrl-C does not terminate mcabber
Mikael Berthe <mikael@lilotux.net>
parents:
307
diff
changeset
|
3763 |
{ |
365
ddb6593bedc9
Fix segfault when mcabber receives an INT signal (Ctrl-C) early
Mikael Berthe <mikael@lilotux.net>
parents:
364
diff
changeset
|
3764 |
if (!Curses) return; |
315
65aa05520556
First Ctrl-C now also leaves multi-line message mode
Mikael Berthe <mikael@lilotux.net>
parents:
314
diff
changeset
|
3765 |
// Leave multi-line mode |
1187
16abe7ec3056
Fix a conflict between verbatim multiline mode and the key binding system
Mikael Berthe <mikael@lilotux.net>
parents:
1186
diff
changeset
|
3766 |
process_command(mkcmdstr("msay abort"), TRUE); |
312
f0b7ff2df7e8
Ctrl-C does not terminate mcabber
Mikael Berthe <mikael@lilotux.net>
parents:
307
diff
changeset
|
3767 |
// Same as Ctrl-g, now |
f0b7ff2df7e8
Ctrl-C does not terminate mcabber
Mikael Berthe <mikael@lilotux.net>
parents:
307
diff
changeset
|
3768 |
scr_cancel_current_completion(); |
f0b7ff2df7e8
Ctrl-C does not terminate mcabber
Mikael Berthe <mikael@lilotux.net>
parents:
307
diff
changeset
|
3769 |
scr_end_current_completion(); |
f0b7ff2df7e8
Ctrl-C does not terminate mcabber
Mikael Berthe <mikael@lilotux.net>
parents:
307
diff
changeset
|
3770 |
check_offset(-1); |
f0b7ff2df7e8
Ctrl-C does not terminate mcabber
Mikael Berthe <mikael@lilotux.net>
parents:
307
diff
changeset
|
3771 |
refresh_inputline(); |
f0b7ff2df7e8
Ctrl-C does not terminate mcabber
Mikael Berthe <mikael@lilotux.net>
parents:
307
diff
changeset
|
3772 |
} |
f0b7ff2df7e8
Ctrl-C does not terminate mcabber
Mikael Berthe <mikael@lilotux.net>
parents:
307
diff
changeset
|
3773 |
|
761
4532a9fe0e8c
Handle some keyboard escape sequences
Mikael Berthe <mikael@lilotux.net>
parents:
760
diff
changeset
|
3774 |
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
|
3775 |
{ |
4532a9fe0e8c
Handle some keyboard escape sequences
Mikael Berthe <mikael@lilotux.net>
parents:
760
diff
changeset
|
3776 |
keyseq *ks; |
4532a9fe0e8c
Handle some keyboard escape sequences
Mikael Berthe <mikael@lilotux.net>
parents:
760
diff
changeset
|
3777 |
|
4532a9fe0e8c
Handle some keyboard escape sequences
Mikael Berthe <mikael@lilotux.net>
parents:
760
diff
changeset
|
3778 |
// Let's make sure the length is correct |
4532a9fe0e8c
Handle some keyboard escape sequences
Mikael Berthe <mikael@lilotux.net>
parents:
760
diff
changeset
|
3779 |
if (strlen(seqstr) > MAX_KEYSEQ_LENGTH) { |
4532a9fe0e8c
Handle some keyboard escape sequences
Mikael Berthe <mikael@lilotux.net>
parents:
760
diff
changeset
|
3780 |
scr_LogPrint(LPRINT_LOGNORM, "add_keyseq(): key sequence is too long!"); |
4532a9fe0e8c
Handle some keyboard escape sequences
Mikael Berthe <mikael@lilotux.net>
parents:
760
diff
changeset
|
3781 |
return; |
4532a9fe0e8c
Handle some keyboard escape sequences
Mikael Berthe <mikael@lilotux.net>
parents:
760
diff
changeset
|
3782 |
} |
4532a9fe0e8c
Handle some keyboard escape sequences
Mikael Berthe <mikael@lilotux.net>
parents:
760
diff
changeset
|
3783 |
|
4532a9fe0e8c
Handle some keyboard escape sequences
Mikael Berthe <mikael@lilotux.net>
parents:
760
diff
changeset
|
3784 |
ks = g_new0(keyseq, 1); |
4532a9fe0e8c
Handle some keyboard escape sequences
Mikael Berthe <mikael@lilotux.net>
parents:
760
diff
changeset
|
3785 |
ks->seqstr = g_strdup(seqstr); |
4532a9fe0e8c
Handle some keyboard escape sequences
Mikael Berthe <mikael@lilotux.net>
parents:
760
diff
changeset
|
3786 |
ks->mkeycode = mkeycode; |
4532a9fe0e8c
Handle some keyboard escape sequences
Mikael Berthe <mikael@lilotux.net>
parents:
760
diff
changeset
|
3787 |
ks->value = value; |
4532a9fe0e8c
Handle some keyboard escape sequences
Mikael Berthe <mikael@lilotux.net>
parents:
760
diff
changeset
|
3788 |
keyseqlist = g_slist_append(keyseqlist, ks); |
4532a9fe0e8c
Handle some keyboard escape sequences
Mikael Berthe <mikael@lilotux.net>
parents:
760
diff
changeset
|
3789 |
} |
4532a9fe0e8c
Handle some keyboard escape sequences
Mikael Berthe <mikael@lilotux.net>
parents:
760
diff
changeset
|
3790 |
|
4532a9fe0e8c
Handle some keyboard escape sequences
Mikael Berthe <mikael@lilotux.net>
parents:
760
diff
changeset
|
3791 |
// match_keyseq(iseq, &ret) |
4532a9fe0e8c
Handle some keyboard escape sequences
Mikael Berthe <mikael@lilotux.net>
parents:
760
diff
changeset
|
3792 |
// Check if "iseq" is a known key escape sequence. |
4532a9fe0e8c
Handle some keyboard escape sequences
Mikael Berthe <mikael@lilotux.net>
parents:
760
diff
changeset
|
3793 |
// Return value: |
4532a9fe0e8c
Handle some keyboard escape sequences
Mikael Berthe <mikael@lilotux.net>
parents:
760
diff
changeset
|
3794 |
// -1 if "seq" matches no known sequence |
4532a9fe0e8c
Handle some keyboard escape sequences
Mikael Berthe <mikael@lilotux.net>
parents:
760
diff
changeset
|
3795 |
// 0 if "seq" could match 1 or more known sequences |
4532a9fe0e8c
Handle some keyboard escape sequences
Mikael Berthe <mikael@lilotux.net>
parents:
760
diff
changeset
|
3796 |
// >0 if "seq" matches a key sequence; the mkey code is returned |
4532a9fe0e8c
Handle some keyboard escape sequences
Mikael Berthe <mikael@lilotux.net>
parents:
760
diff
changeset
|
3797 |
// and *ret is set to the matching keyseq structure. |
952 | 3798 |
static inline gint match_keyseq(int *iseq, keyseq **ret) |
373
af2f8ddf6a1b
Move (reorganize) functions
Mikael Berthe <mikael@lilotux.net>
parents:
370
diff
changeset
|
3799 |
{ |
761
4532a9fe0e8c
Handle some keyboard escape sequences
Mikael Berthe <mikael@lilotux.net>
parents:
760
diff
changeset
|
3800 |
GSList *ksl; |
4532a9fe0e8c
Handle some keyboard escape sequences
Mikael Berthe <mikael@lilotux.net>
parents:
760
diff
changeset
|
3801 |
keyseq *ksp; |
4532a9fe0e8c
Handle some keyboard escape sequences
Mikael Berthe <mikael@lilotux.net>
parents:
760
diff
changeset
|
3802 |
char *p, c; |
4532a9fe0e8c
Handle some keyboard escape sequences
Mikael Berthe <mikael@lilotux.net>
parents:
760
diff
changeset
|
3803 |
int *i; |
4532a9fe0e8c
Handle some keyboard escape sequences
Mikael Berthe <mikael@lilotux.net>
parents:
760
diff
changeset
|
3804 |
int needmore = FALSE; |
4532a9fe0e8c
Handle some keyboard escape sequences
Mikael Berthe <mikael@lilotux.net>
parents:
760
diff
changeset
|
3805 |
|
4532a9fe0e8c
Handle some keyboard escape sequences
Mikael Berthe <mikael@lilotux.net>
parents:
760
diff
changeset
|
3806 |
for (ksl = keyseqlist; ksl; ksl = g_slist_next(ksl)) { |
4532a9fe0e8c
Handle some keyboard escape sequences
Mikael Berthe <mikael@lilotux.net>
parents:
760
diff
changeset
|
3807 |
ksp = ksl->data; |
4532a9fe0e8c
Handle some keyboard escape sequences
Mikael Berthe <mikael@lilotux.net>
parents:
760
diff
changeset
|
3808 |
p = ksp->seqstr; |
4532a9fe0e8c
Handle some keyboard escape sequences
Mikael Berthe <mikael@lilotux.net>
parents:
760
diff
changeset
|
3809 |
i = iseq; |
4532a9fe0e8c
Handle some keyboard escape sequences
Mikael Berthe <mikael@lilotux.net>
parents:
760
diff
changeset
|
3810 |
while (1) { |
4532a9fe0e8c
Handle some keyboard escape sequences
Mikael Berthe <mikael@lilotux.net>
parents:
760
diff
changeset
|
3811 |
c = (unsigned char)*i; |
4532a9fe0e8c
Handle some keyboard escape sequences
Mikael Berthe <mikael@lilotux.net>
parents:
760
diff
changeset
|
3812 |
if (!*p && !c) { // Match |
4532a9fe0e8c
Handle some keyboard escape sequences
Mikael Berthe <mikael@lilotux.net>
parents:
760
diff
changeset
|
3813 |
(*ret) = ksp; |
4532a9fe0e8c
Handle some keyboard escape sequences
Mikael Berthe <mikael@lilotux.net>
parents:
760
diff
changeset
|
3814 |
return ksp->mkeycode; |
4532a9fe0e8c
Handle some keyboard escape sequences
Mikael Berthe <mikael@lilotux.net>
parents:
760
diff
changeset
|
3815 |
} |
4532a9fe0e8c
Handle some keyboard escape sequences
Mikael Berthe <mikael@lilotux.net>
parents:
760
diff
changeset
|
3816 |
if (!c) { |
4532a9fe0e8c
Handle some keyboard escape sequences
Mikael Berthe <mikael@lilotux.net>
parents:
760
diff
changeset
|
3817 |
// iseq is too short |
4532a9fe0e8c
Handle some keyboard escape sequences
Mikael Berthe <mikael@lilotux.net>
parents:
760
diff
changeset
|
3818 |
needmore = TRUE; |
4532a9fe0e8c
Handle some keyboard escape sequences
Mikael Berthe <mikael@lilotux.net>
parents:
760
diff
changeset
|
3819 |
break; |
4532a9fe0e8c
Handle some keyboard escape sequences
Mikael Berthe <mikael@lilotux.net>
parents:
760
diff
changeset
|
3820 |
} else if (!*p || c != *p) { |
4532a9fe0e8c
Handle some keyboard escape sequences
Mikael Berthe <mikael@lilotux.net>
parents:
760
diff
changeset
|
3821 |
// This isn't a match |
4532a9fe0e8c
Handle some keyboard escape sequences
Mikael Berthe <mikael@lilotux.net>
parents:
760
diff
changeset
|
3822 |
break; |
4532a9fe0e8c
Handle some keyboard escape sequences
Mikael Berthe <mikael@lilotux.net>
parents:
760
diff
changeset
|
3823 |
} |
4532a9fe0e8c
Handle some keyboard escape sequences
Mikael Berthe <mikael@lilotux.net>
parents:
760
diff
changeset
|
3824 |
p++; i++; |
4532a9fe0e8c
Handle some keyboard escape sequences
Mikael Berthe <mikael@lilotux.net>
parents:
760
diff
changeset
|
3825 |
} |
4532a9fe0e8c
Handle some keyboard escape sequences
Mikael Berthe <mikael@lilotux.net>
parents:
760
diff
changeset
|
3826 |
} |
4532a9fe0e8c
Handle some keyboard escape sequences
Mikael Berthe <mikael@lilotux.net>
parents:
760
diff
changeset
|
3827 |
|
4532a9fe0e8c
Handle some keyboard escape sequences
Mikael Berthe <mikael@lilotux.net>
parents:
760
diff
changeset
|
3828 |
if (needmore) |
4532a9fe0e8c
Handle some keyboard escape sequences
Mikael Berthe <mikael@lilotux.net>
parents:
760
diff
changeset
|
3829 |
return 0; |
4532a9fe0e8c
Handle some keyboard escape sequences
Mikael Berthe <mikael@lilotux.net>
parents:
760
diff
changeset
|
3830 |
return -1; |
4532a9fe0e8c
Handle some keyboard escape sequences
Mikael Berthe <mikael@lilotux.net>
parents:
760
diff
changeset
|
3831 |
} |
4532a9fe0e8c
Handle some keyboard escape sequences
Mikael Berthe <mikael@lilotux.net>
parents:
760
diff
changeset
|
3832 |
|
930
a75f7a13df7b
UTF-8 terminal support (Reimar Döffinger)
Mikael Berthe <mikael@lilotux.net>
parents:
929
diff
changeset
|
3833 |
static inline int match_utf8_keyseq(int *iseq) |
a75f7a13df7b
UTF-8 terminal support (Reimar Döffinger)
Mikael Berthe <mikael@lilotux.net>
parents:
929
diff
changeset
|
3834 |
{ |
a75f7a13df7b
UTF-8 terminal support (Reimar Döffinger)
Mikael Berthe <mikael@lilotux.net>
parents:
929
diff
changeset
|
3835 |
int *strp = iseq; |
a75f7a13df7b
UTF-8 terminal support (Reimar Döffinger)
Mikael Berthe <mikael@lilotux.net>
parents:
929
diff
changeset
|
3836 |
unsigned c = *strp++; |
a75f7a13df7b
UTF-8 terminal support (Reimar Döffinger)
Mikael Berthe <mikael@lilotux.net>
parents:
929
diff
changeset
|
3837 |
unsigned mask = 0x80; |
a75f7a13df7b
UTF-8 terminal support (Reimar Döffinger)
Mikael Berthe <mikael@lilotux.net>
parents:
929
diff
changeset
|
3838 |
int len = -1; |
a75f7a13df7b
UTF-8 terminal support (Reimar Döffinger)
Mikael Berthe <mikael@lilotux.net>
parents:
929
diff
changeset
|
3839 |
while (c & mask) { |
a75f7a13df7b
UTF-8 terminal support (Reimar Döffinger)
Mikael Berthe <mikael@lilotux.net>
parents:
929
diff
changeset
|
3840 |
mask >>= 1; |
a75f7a13df7b
UTF-8 terminal support (Reimar Döffinger)
Mikael Berthe <mikael@lilotux.net>
parents:
929
diff
changeset
|
3841 |
len++; |
a75f7a13df7b
UTF-8 terminal support (Reimar Döffinger)
Mikael Berthe <mikael@lilotux.net>
parents:
929
diff
changeset
|
3842 |
} |
a75f7a13df7b
UTF-8 terminal support (Reimar Döffinger)
Mikael Berthe <mikael@lilotux.net>
parents:
929
diff
changeset
|
3843 |
if (len <= 0 || len > 4) |
a75f7a13df7b
UTF-8 terminal support (Reimar Döffinger)
Mikael Berthe <mikael@lilotux.net>
parents:
929
diff
changeset
|
3844 |
return -1; |
a75f7a13df7b
UTF-8 terminal support (Reimar Döffinger)
Mikael Berthe <mikael@lilotux.net>
parents:
929
diff
changeset
|
3845 |
c &= mask - 1; |
a75f7a13df7b
UTF-8 terminal support (Reimar Döffinger)
Mikael Berthe <mikael@lilotux.net>
parents:
929
diff
changeset
|
3846 |
while ((*strp & 0xc0) == 0x80) { |
a75f7a13df7b
UTF-8 terminal support (Reimar Döffinger)
Mikael Berthe <mikael@lilotux.net>
parents:
929
diff
changeset
|
3847 |
if (len-- <= 0) // can't happen |
a75f7a13df7b
UTF-8 terminal support (Reimar Döffinger)
Mikael Berthe <mikael@lilotux.net>
parents:
929
diff
changeset
|
3848 |
return -1; |
a75f7a13df7b
UTF-8 terminal support (Reimar Döffinger)
Mikael Berthe <mikael@lilotux.net>
parents:
929
diff
changeset
|
3849 |
c = (c << 6) | (*strp++ & 0x3f); |
a75f7a13df7b
UTF-8 terminal support (Reimar Döffinger)
Mikael Berthe <mikael@lilotux.net>
parents:
929
diff
changeset
|
3850 |
} |
a75f7a13df7b
UTF-8 terminal support (Reimar Döffinger)
Mikael Berthe <mikael@lilotux.net>
parents:
929
diff
changeset
|
3851 |
if (len) |
a75f7a13df7b
UTF-8 terminal support (Reimar Döffinger)
Mikael Berthe <mikael@lilotux.net>
parents:
929
diff
changeset
|
3852 |
return 0; |
a75f7a13df7b
UTF-8 terminal support (Reimar Döffinger)
Mikael Berthe <mikael@lilotux.net>
parents:
929
diff
changeset
|
3853 |
return c; |
a75f7a13df7b
UTF-8 terminal support (Reimar Döffinger)
Mikael Berthe <mikael@lilotux.net>
parents:
929
diff
changeset
|
3854 |
} |
a75f7a13df7b
UTF-8 terminal support (Reimar Döffinger)
Mikael Berthe <mikael@lilotux.net>
parents:
929
diff
changeset
|
3855 |
|
1780
e4378fbab5d7
Major API cleanup - bump API to 4
Mikael Berthe <mikael@lilotux.net>
parents:
1761
diff
changeset
|
3856 |
void scr_getch(keycode *kcode) |
761
4532a9fe0e8c
Handle some keyboard escape sequences
Mikael Berthe <mikael@lilotux.net>
parents:
760
diff
changeset
|
3857 |
{ |
769 | 3858 |
keyseq *mks = NULL; |
761
4532a9fe0e8c
Handle some keyboard escape sequences
Mikael Berthe <mikael@lilotux.net>
parents:
760
diff
changeset
|
3859 |
int ks[MAX_KEYSEQ_LENGTH+1]; |
4532a9fe0e8c
Handle some keyboard escape sequences
Mikael Berthe <mikael@lilotux.net>
parents:
760
diff
changeset
|
3860 |
int i; |
4532a9fe0e8c
Handle some keyboard escape sequences
Mikael Berthe <mikael@lilotux.net>
parents:
760
diff
changeset
|
3861 |
|
4532a9fe0e8c
Handle some keyboard escape sequences
Mikael Berthe <mikael@lilotux.net>
parents:
760
diff
changeset
|
3862 |
memset(kcode, 0, sizeof(keycode)); |
4532a9fe0e8c
Handle some keyboard escape sequences
Mikael Berthe <mikael@lilotux.net>
parents:
760
diff
changeset
|
3863 |
memset(ks, 0, sizeof(ks)); |
4532a9fe0e8c
Handle some keyboard escape sequences
Mikael Berthe <mikael@lilotux.net>
parents:
760
diff
changeset
|
3864 |
|
4532a9fe0e8c
Handle some keyboard escape sequences
Mikael Berthe <mikael@lilotux.net>
parents:
760
diff
changeset
|
3865 |
kcode->value = wgetch(inputWnd); |
930
a75f7a13df7b
UTF-8 terminal support (Reimar Döffinger)
Mikael Berthe <mikael@lilotux.net>
parents:
929
diff
changeset
|
3866 |
if (utf8_mode) { |
1058 | 3867 |
bool ismeta = (kcode->value == 27); |
1561 | 3868 |
#ifdef NCURSES_MOUSE_VERSION |
3869 |
bool ismouse = (kcode->value == KEY_MOUSE); |
|
3870 |
||
3871 |
if (ismouse) { |
|
3872 |
MEVENT mouse; |
|
3873 |
getmouse(&mouse); |
|
3874 |
kcode->value = mouse.bstate; |
|
3875 |
kcode->mcode = MKEY_MOUSE; |
|
3876 |
return; |
|
3877 |
} else if (ismeta) |
|
3878 |
#else |
|
1058 | 3879 |
if (ismeta) |
1561 | 3880 |
#endif |
944
aec71ebf98fa
Fix Meta + UTF-8 character
Mikael Berthe <mikael@lilotux.net>
parents:
940
diff
changeset
|
3881 |
ks[0] = wgetch(inputWnd); |
aec71ebf98fa
Fix Meta + UTF-8 character
Mikael Berthe <mikael@lilotux.net>
parents:
940
diff
changeset
|
3882 |
else |
aec71ebf98fa
Fix Meta + UTF-8 character
Mikael Berthe <mikael@lilotux.net>
parents:
940
diff
changeset
|
3883 |
ks[0] = kcode->value; |
aec71ebf98fa
Fix Meta + UTF-8 character
Mikael Berthe <mikael@lilotux.net>
parents:
940
diff
changeset
|
3884 |
|
930
a75f7a13df7b
UTF-8 terminal support (Reimar Döffinger)
Mikael Berthe <mikael@lilotux.net>
parents:
929
diff
changeset
|
3885 |
for (i = 0; i < MAX_KEYSEQ_LENGTH - 1; i++) { |
a75f7a13df7b
UTF-8 terminal support (Reimar Döffinger)
Mikael Berthe <mikael@lilotux.net>
parents:
929
diff
changeset
|
3886 |
int match = match_utf8_keyseq(ks); |
a75f7a13df7b
UTF-8 terminal support (Reimar Döffinger)
Mikael Berthe <mikael@lilotux.net>
parents:
929
diff
changeset
|
3887 |
if (match == -1) |
a75f7a13df7b
UTF-8 terminal support (Reimar Döffinger)
Mikael Berthe <mikael@lilotux.net>
parents:
929
diff
changeset
|
3888 |
break; |
a75f7a13df7b
UTF-8 terminal support (Reimar Döffinger)
Mikael Berthe <mikael@lilotux.net>
parents:
929
diff
changeset
|
3889 |
if (match > 0) { |
a75f7a13df7b
UTF-8 terminal support (Reimar Döffinger)
Mikael Berthe <mikael@lilotux.net>
parents:
929
diff
changeset
|
3890 |
kcode->value = match; |
a75f7a13df7b
UTF-8 terminal support (Reimar Döffinger)
Mikael Berthe <mikael@lilotux.net>
parents:
929
diff
changeset
|
3891 |
kcode->utf8 = 1; |
1058 | 3892 |
if (ismeta) |
944
aec71ebf98fa
Fix Meta + UTF-8 character
Mikael Berthe <mikael@lilotux.net>
parents:
940
diff
changeset
|
3893 |
kcode->mcode = MKEY_META; |
930
a75f7a13df7b
UTF-8 terminal support (Reimar Döffinger)
Mikael Berthe <mikael@lilotux.net>
parents:
929
diff
changeset
|
3894 |
return; |
a75f7a13df7b
UTF-8 terminal support (Reimar Döffinger)
Mikael Berthe <mikael@lilotux.net>
parents:
929
diff
changeset
|
3895 |
} |
a75f7a13df7b
UTF-8 terminal support (Reimar Döffinger)
Mikael Berthe <mikael@lilotux.net>
parents:
929
diff
changeset
|
3896 |
ks[i + 1] = wgetch(inputWnd); |
a75f7a13df7b
UTF-8 terminal support (Reimar Döffinger)
Mikael Berthe <mikael@lilotux.net>
parents:
929
diff
changeset
|
3897 |
if (ks[i + 1] == ERR) |
a75f7a13df7b
UTF-8 terminal support (Reimar Döffinger)
Mikael Berthe <mikael@lilotux.net>
parents:
929
diff
changeset
|
3898 |
break; |
a75f7a13df7b
UTF-8 terminal support (Reimar Döffinger)
Mikael Berthe <mikael@lilotux.net>
parents:
929
diff
changeset
|
3899 |
} |
a75f7a13df7b
UTF-8 terminal support (Reimar Döffinger)
Mikael Berthe <mikael@lilotux.net>
parents:
929
diff
changeset
|
3900 |
while (i > 0) |
a75f7a13df7b
UTF-8 terminal support (Reimar Döffinger)
Mikael Berthe <mikael@lilotux.net>
parents:
929
diff
changeset
|
3901 |
ungetch(ks[i--]); |
1058 | 3902 |
if (ismeta) |
944
aec71ebf98fa
Fix Meta + UTF-8 character
Mikael Berthe <mikael@lilotux.net>
parents:
940
diff
changeset
|
3903 |
ungetch(ks[0]); |
930
a75f7a13df7b
UTF-8 terminal support (Reimar Döffinger)
Mikael Berthe <mikael@lilotux.net>
parents:
929
diff
changeset
|
3904 |
memset(ks, 0, sizeof(ks)); |
a75f7a13df7b
UTF-8 terminal support (Reimar Döffinger)
Mikael Berthe <mikael@lilotux.net>
parents:
929
diff
changeset
|
3905 |
} |
761
4532a9fe0e8c
Handle some keyboard escape sequences
Mikael Berthe <mikael@lilotux.net>
parents:
760
diff
changeset
|
3906 |
if (kcode->value != 27) |
4532a9fe0e8c
Handle some keyboard escape sequences
Mikael Berthe <mikael@lilotux.net>
parents:
760
diff
changeset
|
3907 |
return; |
4532a9fe0e8c
Handle some keyboard escape sequences
Mikael Berthe <mikael@lilotux.net>
parents:
760
diff
changeset
|
3908 |
|
4532a9fe0e8c
Handle some keyboard escape sequences
Mikael Berthe <mikael@lilotux.net>
parents:
760
diff
changeset
|
3909 |
// Check for escape key sequence |
4532a9fe0e8c
Handle some keyboard escape sequences
Mikael Berthe <mikael@lilotux.net>
parents:
760
diff
changeset
|
3910 |
for (i=0; i < MAX_KEYSEQ_LENGTH; i++) { |
4532a9fe0e8c
Handle some keyboard escape sequences
Mikael Berthe <mikael@lilotux.net>
parents:
760
diff
changeset
|
3911 |
int match; |
4532a9fe0e8c
Handle some keyboard escape sequences
Mikael Berthe <mikael@lilotux.net>
parents:
760
diff
changeset
|
3912 |
ks[i] = wgetch(inputWnd); |
4532a9fe0e8c
Handle some keyboard escape sequences
Mikael Berthe <mikael@lilotux.net>
parents:
760
diff
changeset
|
3913 |
if (ks[i] == ERR) break; |
4532a9fe0e8c
Handle some keyboard escape sequences
Mikael Berthe <mikael@lilotux.net>
parents:
760
diff
changeset
|
3914 |
match = match_keyseq(ks, &mks); |
4532a9fe0e8c
Handle some keyboard escape sequences
Mikael Berthe <mikael@lilotux.net>
parents:
760
diff
changeset
|
3915 |
if (match == -1) { |
4532a9fe0e8c
Handle some keyboard escape sequences
Mikael Berthe <mikael@lilotux.net>
parents:
760
diff
changeset
|
3916 |
// No such key sequence. Let's increment i as it is a valid key. |
4532a9fe0e8c
Handle some keyboard escape sequences
Mikael Berthe <mikael@lilotux.net>
parents:
760
diff
changeset
|
3917 |
i++; |
4532a9fe0e8c
Handle some keyboard escape sequences
Mikael Berthe <mikael@lilotux.net>
parents:
760
diff
changeset
|
3918 |
break; |
4532a9fe0e8c
Handle some keyboard escape sequences
Mikael Berthe <mikael@lilotux.net>
parents:
760
diff
changeset
|
3919 |
} |
4532a9fe0e8c
Handle some keyboard escape sequences
Mikael Berthe <mikael@lilotux.net>
parents:
760
diff
changeset
|
3920 |
if (match > 0) { |
4532a9fe0e8c
Handle some keyboard escape sequences
Mikael Berthe <mikael@lilotux.net>
parents:
760
diff
changeset
|
3921 |
// We have a matching sequence |
4532a9fe0e8c
Handle some keyboard escape sequences
Mikael Berthe <mikael@lilotux.net>
parents:
760
diff
changeset
|
3922 |
kcode->mcode = mks->mkeycode; |
4532a9fe0e8c
Handle some keyboard escape sequences
Mikael Berthe <mikael@lilotux.net>
parents:
760
diff
changeset
|
3923 |
kcode->value = mks->value; |
4532a9fe0e8c
Handle some keyboard escape sequences
Mikael Berthe <mikael@lilotux.net>
parents:
760
diff
changeset
|
3924 |
return; |
4532a9fe0e8c
Handle some keyboard escape sequences
Mikael Berthe <mikael@lilotux.net>
parents:
760
diff
changeset
|
3925 |
} |
4532a9fe0e8c
Handle some keyboard escape sequences
Mikael Berthe <mikael@lilotux.net>
parents:
760
diff
changeset
|
3926 |
} |
4532a9fe0e8c
Handle some keyboard escape sequences
Mikael Berthe <mikael@lilotux.net>
parents:
760
diff
changeset
|
3927 |
|
4532a9fe0e8c
Handle some keyboard escape sequences
Mikael Berthe <mikael@lilotux.net>
parents:
760
diff
changeset
|
3928 |
// No match. Let's return a meta-key. |
4532a9fe0e8c
Handle some keyboard escape sequences
Mikael Berthe <mikael@lilotux.net>
parents:
760
diff
changeset
|
3929 |
if (i > 0) { |
4532a9fe0e8c
Handle some keyboard escape sequences
Mikael Berthe <mikael@lilotux.net>
parents:
760
diff
changeset
|
3930 |
kcode->mcode = MKEY_META; |
4532a9fe0e8c
Handle some keyboard escape sequences
Mikael Berthe <mikael@lilotux.net>
parents:
760
diff
changeset
|
3931 |
kcode->value = ks[0]; |
4532a9fe0e8c
Handle some keyboard escape sequences
Mikael Berthe <mikael@lilotux.net>
parents:
760
diff
changeset
|
3932 |
} |
4532a9fe0e8c
Handle some keyboard escape sequences
Mikael Berthe <mikael@lilotux.net>
parents:
760
diff
changeset
|
3933 |
if (i > 1) { |
4532a9fe0e8c
Handle some keyboard escape sequences
Mikael Berthe <mikael@lilotux.net>
parents:
760
diff
changeset
|
3934 |
// We need to push some keys back to the keyboard buffer |
4532a9fe0e8c
Handle some keyboard escape sequences
Mikael Berthe <mikael@lilotux.net>
parents:
760
diff
changeset
|
3935 |
while (i-- > 1) |
4532a9fe0e8c
Handle some keyboard escape sequences
Mikael Berthe <mikael@lilotux.net>
parents:
760
diff
changeset
|
3936 |
ungetch(ks[i]); |
4532a9fe0e8c
Handle some keyboard escape sequences
Mikael Berthe <mikael@lilotux.net>
parents:
760
diff
changeset
|
3937 |
} |
4532a9fe0e8c
Handle some keyboard escape sequences
Mikael Berthe <mikael@lilotux.net>
parents:
760
diff
changeset
|
3938 |
return; |
373
af2f8ddf6a1b
Move (reorganize) functions
Mikael Berthe <mikael@lilotux.net>
parents:
370
diff
changeset
|
3939 |
} |
af2f8ddf6a1b
Move (reorganize) functions
Mikael Berthe <mikael@lilotux.net>
parents:
370
diff
changeset
|
3940 |
|
1780
e4378fbab5d7
Major API cleanup - bump API to 4
Mikael Berthe <mikael@lilotux.net>
parents:
1761
diff
changeset
|
3941 |
void scr_do_update(void) |
939
12fa2ae6445d
Get rid of "busy-waiting" (Christof Meerwald)
Mikael Berthe <mikael@lilotux.net>
parents:
936
diff
changeset
|
3942 |
{ |
12fa2ae6445d
Get rid of "busy-waiting" (Christof Meerwald)
Mikael Berthe <mikael@lilotux.net>
parents:
936
diff
changeset
|
3943 |
doupdate(); |
12fa2ae6445d
Get rid of "busy-waiting" (Christof Meerwald)
Mikael Berthe <mikael@lilotux.net>
parents:
936
diff
changeset
|
3944 |
} |
12fa2ae6445d
Get rid of "busy-waiting" (Christof Meerwald)
Mikael Berthe <mikael@lilotux.net>
parents:
936
diff
changeset
|
3945 |
|
930
a75f7a13df7b
UTF-8 terminal support (Reimar Döffinger)
Mikael Berthe <mikael@lilotux.net>
parents:
929
diff
changeset
|
3946 |
static int bindcommand(keycode kcode) |
a75f7a13df7b
UTF-8 terminal support (Reimar Döffinger)
Mikael Berthe <mikael@lilotux.net>
parents:
929
diff
changeset
|
3947 |
{ |
945
17ef145f3326
Display and use UTF-8 key codes
Mikael Berthe <mikael@lilotux.net>
parents:
944
diff
changeset
|
3948 |
gchar asciikey[16], asciicode[16]; |
764
4e15322d315e
Allow binding of meta keys
Mikael Berthe <mikael@lilotux.net>
parents:
763
diff
changeset
|
3949 |
const gchar *boundcmd; |
4e15322d315e
Allow binding of meta keys
Mikael Berthe <mikael@lilotux.net>
parents:
763
diff
changeset
|
3950 |
|
945
17ef145f3326
Display and use UTF-8 key codes
Mikael Berthe <mikael@lilotux.net>
parents:
944
diff
changeset
|
3951 |
if (kcode.utf8) |
17ef145f3326
Display and use UTF-8 key codes
Mikael Berthe <mikael@lilotux.net>
parents:
944
diff
changeset
|
3952 |
g_snprintf(asciicode, 15, "U%d", kcode.value); |
17ef145f3326
Display and use UTF-8 key codes
Mikael Berthe <mikael@lilotux.net>
parents:
944
diff
changeset
|
3953 |
else |
17ef145f3326
Display and use UTF-8 key codes
Mikael Berthe <mikael@lilotux.net>
parents:
944
diff
changeset
|
3954 |
g_snprintf(asciicode, 15, "%d", kcode.value); |
17ef145f3326
Display and use UTF-8 key codes
Mikael Berthe <mikael@lilotux.net>
parents:
944
diff
changeset
|
3955 |
|
764
4e15322d315e
Allow binding of meta keys
Mikael Berthe <mikael@lilotux.net>
parents:
763
diff
changeset
|
3956 |
if (!kcode.mcode || kcode.mcode == MKEY_EQUIV) |
945
17ef145f3326
Display and use UTF-8 key codes
Mikael Berthe <mikael@lilotux.net>
parents:
944
diff
changeset
|
3957 |
g_snprintf(asciikey, 15, "%s", asciicode); |
764
4e15322d315e
Allow binding of meta keys
Mikael Berthe <mikael@lilotux.net>
parents:
763
diff
changeset
|
3958 |
else if (kcode.mcode == MKEY_META) |
945
17ef145f3326
Display and use UTF-8 key codes
Mikael Berthe <mikael@lilotux.net>
parents:
944
diff
changeset
|
3959 |
g_snprintf(asciikey, 15, "M%s", asciicode); |
1561 | 3960 |
else if (kcode.mcode == MKEY_MOUSE) |
3961 |
g_snprintf(asciikey, 15, "p%s", asciicode); |
|
764
4e15322d315e
Allow binding of meta keys
Mikael Berthe <mikael@lilotux.net>
parents:
763
diff
changeset
|
3962 |
else |
949
e3c49b2f8143
Fix bindings of special keys (MK*)
Mikael Berthe <mikael@lilotux.net>
parents:
945
diff
changeset
|
3963 |
g_snprintf(asciikey, 15, "MK%d", kcode.mcode); |
764
4e15322d315e
Allow binding of meta keys
Mikael Berthe <mikael@lilotux.net>
parents:
763
diff
changeset
|
3964 |
|
4e15322d315e
Allow binding of meta keys
Mikael Berthe <mikael@lilotux.net>
parents:
763
diff
changeset
|
3965 |
boundcmd = settings_get(SETTINGS_TYPE_BINDING, asciikey); |
4e15322d315e
Allow binding of meta keys
Mikael Berthe <mikael@lilotux.net>
parents:
763
diff
changeset
|
3966 |
|
4e15322d315e
Allow binding of meta keys
Mikael Berthe <mikael@lilotux.net>
parents:
763
diff
changeset
|
3967 |
if (boundcmd) { |
1357
7bbfb0073f88
Fix an UTF-8 problem in new hook_execute_internal() function
Mikael Berthe <mikael@lilotux.net>
parents:
1355
diff
changeset
|
3968 |
gchar *cmdline = from_utf8(boundcmd); |
1780
e4378fbab5d7
Major API cleanup - bump API to 4
Mikael Berthe <mikael@lilotux.net>
parents:
1761
diff
changeset
|
3969 |
scr_check_auto_away(TRUE); |
1187
16abe7ec3056
Fix a conflict between verbatim multiline mode and the key binding system
Mikael Berthe <mikael@lilotux.net>
parents:
1186
diff
changeset
|
3970 |
if (process_command(cmdline, TRUE)) |
764
4e15322d315e
Allow binding of meta keys
Mikael Berthe <mikael@lilotux.net>
parents:
763
diff
changeset
|
3971 |
return 255; // Quit |
1058 | 3972 |
g_free(cmdline); |
764
4e15322d315e
Allow binding of meta keys
Mikael Berthe <mikael@lilotux.net>
parents:
763
diff
changeset
|
3973 |
return 0; |
4e15322d315e
Allow binding of meta keys
Mikael Berthe <mikael@lilotux.net>
parents:
763
diff
changeset
|
3974 |
} |
4e15322d315e
Allow binding of meta keys
Mikael Berthe <mikael@lilotux.net>
parents:
763
diff
changeset
|
3975 |
|
4e15322d315e
Allow binding of meta keys
Mikael Berthe <mikael@lilotux.net>
parents:
763
diff
changeset
|
3976 |
scr_LogPrint(LPRINT_NORMAL, "Unknown key=%s", asciikey); |
930
a75f7a13df7b
UTF-8 terminal support (Reimar Döffinger)
Mikael Berthe <mikael@lilotux.net>
parents:
929
diff
changeset
|
3977 |
#ifndef UNICODE |
764
4e15322d315e
Allow binding of meta keys
Mikael Berthe <mikael@lilotux.net>
parents:
763
diff
changeset
|
3978 |
if (utf8_mode) |
930
a75f7a13df7b
UTF-8 terminal support (Reimar Döffinger)
Mikael Berthe <mikael@lilotux.net>
parents:
929
diff
changeset
|
3979 |
scr_LogPrint(LPRINT_NORMAL, |
a75f7a13df7b
UTF-8 terminal support (Reimar Döffinger)
Mikael Berthe <mikael@lilotux.net>
parents:
929
diff
changeset
|
3980 |
"WARNING: Compiled without full UTF-8 support!"); |
a75f7a13df7b
UTF-8 terminal support (Reimar Döffinger)
Mikael Berthe <mikael@lilotux.net>
parents:
929
diff
changeset
|
3981 |
#endif |
764
4e15322d315e
Allow binding of meta keys
Mikael Berthe <mikael@lilotux.net>
parents:
763
diff
changeset
|
3982 |
return -1; |
4e15322d315e
Allow binding of meta keys
Mikael Berthe <mikael@lilotux.net>
parents:
763
diff
changeset
|
3983 |
} |
4e15322d315e
Allow binding of meta keys
Mikael Berthe <mikael@lilotux.net>
parents:
763
diff
changeset
|
3984 |
|
1780
e4378fbab5d7
Major API cleanup - bump API to 4
Mikael Berthe <mikael@lilotux.net>
parents:
1761
diff
changeset
|
3985 |
// scr_process_key(key) |
44 | 3986 |
// Handle the pressed key, in the command line (bottom). |
1780
e4378fbab5d7
Major API cleanup - bump API to 4
Mikael Berthe <mikael@lilotux.net>
parents:
1761
diff
changeset
|
3987 |
void scr_process_key(keycode kcode) |
24 | 3988 |
{ |
761
4532a9fe0e8c
Handle some keyboard escape sequences
Mikael Berthe <mikael@lilotux.net>
parents:
760
diff
changeset
|
3989 |
int key = kcode.value; |
931
1cd6d694ac3c
Fix display of some UTF-8 chars
Mikael Berthe <mikael@lilotux.net>
parents:
930
diff
changeset
|
3990 |
int display_char = FALSE; |
761
4532a9fe0e8c
Handle some keyboard escape sequences
Mikael Berthe <mikael@lilotux.net>
parents:
760
diff
changeset
|
3991 |
|
1381
40095d413da9
Fix compilation on OpenBSD
Mikael Berthe <mikael@lilotux.net>
parents:
1376
diff
changeset
|
3992 |
lock_chatstate = FALSE; |
990
35e7913affb7
Send events/chatstates notifications (JEP-22/JEP-85)
Mikael Berthe <mikael@lilotux.net>
parents:
987
diff
changeset
|
3993 |
|
761
4532a9fe0e8c
Handle some keyboard escape sequences
Mikael Berthe <mikael@lilotux.net>
parents:
760
diff
changeset
|
3994 |
switch (kcode.mcode) { |
4532a9fe0e8c
Handle some keyboard escape sequences
Mikael Berthe <mikael@lilotux.net>
parents:
760
diff
changeset
|
3995 |
case 0: |
4532a9fe0e8c
Handle some keyboard escape sequences
Mikael Berthe <mikael@lilotux.net>
parents:
760
diff
changeset
|
3996 |
break; |
4532a9fe0e8c
Handle some keyboard escape sequences
Mikael Berthe <mikael@lilotux.net>
parents:
760
diff
changeset
|
3997 |
case MKEY_EQUIV: |
4532a9fe0e8c
Handle some keyboard escape sequences
Mikael Berthe <mikael@lilotux.net>
parents:
760
diff
changeset
|
3998 |
key = kcode.value; |
4532a9fe0e8c
Handle some keyboard escape sequences
Mikael Berthe <mikael@lilotux.net>
parents:
760
diff
changeset
|
3999 |
break; |
4532a9fe0e8c
Handle some keyboard escape sequences
Mikael Berthe <mikael@lilotux.net>
parents:
760
diff
changeset
|
4000 |
case MKEY_META: |
4532a9fe0e8c
Handle some keyboard escape sequences
Mikael Berthe <mikael@lilotux.net>
parents:
760
diff
changeset
|
4001 |
default: |
1359
7daf906fbcdc
The command /quit can be used in bindings, hooks and sourced files
Mikael Berthe <mikael@lilotux.net>
parents:
1357
diff
changeset
|
4002 |
if (bindcommand(kcode) == 255) { |
7daf906fbcdc
The command /quit can be used in bindings, hooks and sourced files
Mikael Berthe <mikael@lilotux.net>
parents:
1357
diff
changeset
|
4003 |
mcabber_set_terminate_ui(); |
7daf906fbcdc
The command /quit can be used in bindings, hooks and sourced files
Mikael Berthe <mikael@lilotux.net>
parents:
1357
diff
changeset
|
4004 |
return; |
7daf906fbcdc
The command /quit can be used in bindings, hooks and sourced files
Mikael Berthe <mikael@lilotux.net>
parents:
1357
diff
changeset
|
4005 |
} |
764
4e15322d315e
Allow binding of meta keys
Mikael Berthe <mikael@lilotux.net>
parents:
763
diff
changeset
|
4006 |
key = ERR; // Do not process any further |
758 | 4007 |
} |
761
4532a9fe0e8c
Handle some keyboard escape sequences
Mikael Berthe <mikael@lilotux.net>
parents:
760
diff
changeset
|
4008 |
|
931
1cd6d694ac3c
Fix display of some UTF-8 chars
Mikael Berthe <mikael@lilotux.net>
parents:
930
diff
changeset
|
4009 |
if (kcode.utf8) { |
1cd6d694ac3c
Fix display of some UTF-8 chars
Mikael Berthe <mikael@lilotux.net>
parents:
930
diff
changeset
|
4010 |
if (key != ERR && !kcode.mcode) |
1cd6d694ac3c
Fix display of some UTF-8 chars
Mikael Berthe <mikael@lilotux.net>
parents:
930
diff
changeset
|
4011 |
display_char = TRUE; |
1cd6d694ac3c
Fix display of some UTF-8 chars
Mikael Berthe <mikael@lilotux.net>
parents:
930
diff
changeset
|
4012 |
goto display; |
1cd6d694ac3c
Fix display of some UTF-8 chars
Mikael Berthe <mikael@lilotux.net>
parents:
930
diff
changeset
|
4013 |
} |
1cd6d694ac3c
Fix display of some UTF-8 chars
Mikael Berthe <mikael@lilotux.net>
parents:
930
diff
changeset
|
4014 |
|
758 | 4015 |
switch (key) { |
761
4532a9fe0e8c
Handle some keyboard escape sequences
Mikael Berthe <mikael@lilotux.net>
parents:
760
diff
changeset
|
4016 |
case 0: |
4532a9fe0e8c
Handle some keyboard escape sequences
Mikael Berthe <mikael@lilotux.net>
parents:
760
diff
changeset
|
4017 |
case ERR: |
758 | 4018 |
break; |
1173
960f34ec22a2
Add init_bindings() for default key bindings (Lego12239)
Mikael Berthe <mikael@lilotux.net>
parents:
1172
diff
changeset
|
4019 |
case 9: // Tab |
960f34ec22a2
Add init_bindings() for default key bindings (Lego12239)
Mikael Berthe <mikael@lilotux.net>
parents:
1172
diff
changeset
|
4020 |
readline_do_completion(); |
960f34ec22a2
Add init_bindings() for default key bindings (Lego12239)
Mikael Berthe <mikael@lilotux.net>
parents:
1172
diff
changeset
|
4021 |
break; |
960f34ec22a2
Add init_bindings() for default key bindings (Lego12239)
Mikael Berthe <mikael@lilotux.net>
parents:
1172
diff
changeset
|
4022 |
case 13: // Enter |
1359
7daf906fbcdc
The command /quit can be used in bindings, hooks and sourced files
Mikael Berthe <mikael@lilotux.net>
parents:
1357
diff
changeset
|
4023 |
if (readline_accept_line(FALSE) == 255) { |
7daf906fbcdc
The command /quit can be used in bindings, hooks and sourced files
Mikael Berthe <mikael@lilotux.net>
parents:
1357
diff
changeset
|
4024 |
mcabber_set_terminate_ui(); |
7daf906fbcdc
The command /quit can be used in bindings, hooks and sourced files
Mikael Berthe <mikael@lilotux.net>
parents:
1357
diff
changeset
|
4025 |
return; |
7daf906fbcdc
The command /quit can be used in bindings, hooks and sourced files
Mikael Berthe <mikael@lilotux.net>
parents:
1357
diff
changeset
|
4026 |
} |
1173
960f34ec22a2
Add init_bindings() for default key bindings (Lego12239)
Mikael Berthe <mikael@lilotux.net>
parents:
1172
diff
changeset
|
4027 |
break; |
960f34ec22a2
Add init_bindings() for default key bindings (Lego12239)
Mikael Berthe <mikael@lilotux.net>
parents:
1172
diff
changeset
|
4028 |
case 3: // Ctrl-C |
960f34ec22a2
Add init_bindings() for default key bindings (Lego12239)
Mikael Berthe <mikael@lilotux.net>
parents:
1172
diff
changeset
|
4029 |
scr_handle_CtrlC(); |
960f34ec22a2
Add init_bindings() for default key bindings (Lego12239)
Mikael Berthe <mikael@lilotux.net>
parents:
1172
diff
changeset
|
4030 |
break; |
960f34ec22a2
Add init_bindings() for default key bindings (Lego12239)
Mikael Berthe <mikael@lilotux.net>
parents:
1172
diff
changeset
|
4031 |
case KEY_RESIZE: |
1454
6b98dc22946d
Add optional SIGWINCH handler (Markus Hennecke)
Mikael Berthe <mikael@lilotux.net>
parents:
1424
diff
changeset
|
4032 |
#ifdef USE_SIGWINCH |
6b98dc22946d
Add optional SIGWINCH handler (Markus Hennecke)
Mikael Berthe <mikael@lilotux.net>
parents:
1424
diff
changeset
|
4033 |
{ |
1660
dc03a24198a9
Do not call do_screen_refresh() on SIGWINCH
Mikael Berthe <mikael@lilotux.net>
parents:
1653
diff
changeset
|
4034 |
struct winsize size; |
dc03a24198a9
Do not call do_screen_refresh() on SIGWINCH
Mikael Berthe <mikael@lilotux.net>
parents:
1653
diff
changeset
|
4035 |
if (ioctl(STDIN_FILENO, TIOCGWINSZ, &size) != -1) |
dc03a24198a9
Do not call do_screen_refresh() on SIGWINCH
Mikael Berthe <mikael@lilotux.net>
parents:
1653
diff
changeset
|
4036 |
resizeterm(size.ws_row, size.ws_col); |
1454
6b98dc22946d
Add optional SIGWINCH handler (Markus Hennecke)
Mikael Berthe <mikael@lilotux.net>
parents:
1424
diff
changeset
|
4037 |
} |
1660
dc03a24198a9
Do not call do_screen_refresh() on SIGWINCH
Mikael Berthe <mikael@lilotux.net>
parents:
1653
diff
changeset
|
4038 |
#endif |
1173
960f34ec22a2
Add init_bindings() for default key bindings (Lego12239)
Mikael Berthe <mikael@lilotux.net>
parents:
1172
diff
changeset
|
4039 |
scr_Resize(); |
960f34ec22a2
Add init_bindings() for default key bindings (Lego12239)
Mikael Berthe <mikael@lilotux.net>
parents:
1172
diff
changeset
|
4040 |
break; |
499
baa812f04f24
Reorganise process_key()
Mikael Berthe <mikael@lilotux.net>
parents:
480
diff
changeset
|
4041 |
default: |
931
1cd6d694ac3c
Fix display of some UTF-8 chars
Mikael Berthe <mikael@lilotux.net>
parents:
930
diff
changeset
|
4042 |
display_char = TRUE; |
1cd6d694ac3c
Fix display of some UTF-8 chars
Mikael Berthe <mikael@lilotux.net>
parents:
930
diff
changeset
|
4043 |
} // switch |
263 | 4044 |
|
931
1cd6d694ac3c
Fix display of some UTF-8 chars
Mikael Berthe <mikael@lilotux.net>
parents:
930
diff
changeset
|
4045 |
display: |
1cd6d694ac3c
Fix display of some UTF-8 chars
Mikael Berthe <mikael@lilotux.net>
parents:
930
diff
changeset
|
4046 |
if (display_char) { |
1394 | 4047 |
guint printable; |
4048 |
||
4049 |
if (kcode.utf8) { |
|
4050 |
printable = iswprint(key); |
|
4051 |
} else { |
|
4052 |
#ifdef __CYGWIN__ |
|
4053 |
printable = (isprint(key) || (key >= 161 && key <= 255)) |
|
4054 |
&& !is_speckey(key); |
|
4055 |
#else |
|
4056 |
printable = isprint(key) && !is_speckey(key); |
|
4057 |
#endif |
|
4058 |
} |
|
4059 |
if (printable) { |
|
931
1cd6d694ac3c
Fix display of some UTF-8 chars
Mikael Berthe <mikael@lilotux.net>
parents:
930
diff
changeset
|
4060 |
char tmpLine[INPUTLINE_LENGTH+1]; |
499
baa812f04f24
Reorganise process_key()
Mikael Berthe <mikael@lilotux.net>
parents:
480
diff
changeset
|
4061 |
|
931
1cd6d694ac3c
Fix display of some UTF-8 chars
Mikael Berthe <mikael@lilotux.net>
parents:
930
diff
changeset
|
4062 |
// Check the line isn't too long |
1cd6d694ac3c
Fix display of some UTF-8 chars
Mikael Berthe <mikael@lilotux.net>
parents:
930
diff
changeset
|
4063 |
if (strlen(inputLine) + 4 > INPUTLINE_LENGTH) |
1359
7daf906fbcdc
The command /quit can be used in bindings, hooks and sourced files
Mikael Berthe <mikael@lilotux.net>
parents:
1357
diff
changeset
|
4064 |
return; |
931
1cd6d694ac3c
Fix display of some UTF-8 chars
Mikael Berthe <mikael@lilotux.net>
parents:
930
diff
changeset
|
4065 |
|
1cd6d694ac3c
Fix display of some UTF-8 chars
Mikael Berthe <mikael@lilotux.net>
parents:
930
diff
changeset
|
4066 |
// Insert char |
1cd6d694ac3c
Fix display of some UTF-8 chars
Mikael Berthe <mikael@lilotux.net>
parents:
930
diff
changeset
|
4067 |
strcpy(tmpLine, ptr_inputline); |
1cd6d694ac3c
Fix display of some UTF-8 chars
Mikael Berthe <mikael@lilotux.net>
parents:
930
diff
changeset
|
4068 |
ptr_inputline = put_char(ptr_inputline, key); |
1cd6d694ac3c
Fix display of some UTF-8 chars
Mikael Berthe <mikael@lilotux.net>
parents:
930
diff
changeset
|
4069 |
strcpy(ptr_inputline, tmpLine); |
1cd6d694ac3c
Fix display of some UTF-8 chars
Mikael Berthe <mikael@lilotux.net>
parents:
930
diff
changeset
|
4070 |
check_offset(1); |
1cd6d694ac3c
Fix display of some UTF-8 chars
Mikael Berthe <mikael@lilotux.net>
parents:
930
diff
changeset
|
4071 |
} else { |
1cd6d694ac3c
Fix display of some UTF-8 chars
Mikael Berthe <mikael@lilotux.net>
parents:
930
diff
changeset
|
4072 |
// Look for a key binding. |
1359
7daf906fbcdc
The command /quit can be used in bindings, hooks and sourced files
Mikael Berthe <mikael@lilotux.net>
parents:
1357
diff
changeset
|
4073 |
if (!kcode.utf8 && (bindcommand(kcode) == 255)) { |
7daf906fbcdc
The command /quit can be used in bindings, hooks and sourced files
Mikael Berthe <mikael@lilotux.net>
parents:
1357
diff
changeset
|
4074 |
mcabber_set_terminate_ui(); |
7daf906fbcdc
The command /quit can be used in bindings, hooks and sourced files
Mikael Berthe <mikael@lilotux.net>
parents:
1357
diff
changeset
|
4075 |
return; |
7daf906fbcdc
The command /quit can be used in bindings, hooks and sourced files
Mikael Berthe <mikael@lilotux.net>
parents:
1357
diff
changeset
|
4076 |
} |
931
1cd6d694ac3c
Fix display of some UTF-8 chars
Mikael Berthe <mikael@lilotux.net>
parents:
930
diff
changeset
|
4077 |
} |
24 | 4078 |
} |
499
baa812f04f24
Reorganise process_key()
Mikael Berthe <mikael@lilotux.net>
parents:
480
diff
changeset
|
4079 |
|
157 | 4080 |
if (completion_started && key != 9 && key != KEY_RESIZE) |
98 | 4081 |
scr_end_current_completion(); |
312
f0b7ff2df7e8
Ctrl-C does not terminate mcabber
Mikael Berthe <mikael@lilotux.net>
parents:
307
diff
changeset
|
4082 |
refresh_inputline(); |
990
35e7913affb7
Send events/chatstates notifications (JEP-22/JEP-85)
Mikael Berthe <mikael@lilotux.net>
parents:
987
diff
changeset
|
4083 |
|
35e7913affb7
Send events/chatstates notifications (JEP-22/JEP-85)
Mikael Berthe <mikael@lilotux.net>
parents:
987
diff
changeset
|
4084 |
if (!lock_chatstate) { |
997 | 4085 |
// Set chat state to composing (1) if the user is currently composing, |
4086 |
// i.e. not an empty line and not a command line. |
|
990
35e7913affb7
Send events/chatstates notifications (JEP-22/JEP-85)
Mikael Berthe <mikael@lilotux.net>
parents:
987
diff
changeset
|
4087 |
if (inputLine[0] == 0 || inputLine[0] == COMMAND_CHAR) |
35e7913affb7
Send events/chatstates notifications (JEP-22/JEP-85)
Mikael Berthe <mikael@lilotux.net>
parents:
987
diff
changeset
|
4088 |
set_chatstate(0); |
35e7913affb7
Send events/chatstates notifications (JEP-22/JEP-85)
Mikael Berthe <mikael@lilotux.net>
parents:
987
diff
changeset
|
4089 |
else |
35e7913affb7
Send events/chatstates notifications (JEP-22/JEP-85)
Mikael Berthe <mikael@lilotux.net>
parents:
987
diff
changeset
|
4090 |
set_chatstate(1); |
991
ef10906691bb
Chatstates: add composing timeout
Mikael Berthe <mikael@lilotux.net>
parents:
990
diff
changeset
|
4091 |
if (chatstate) |
ef10906691bb
Chatstates: add composing timeout
Mikael Berthe <mikael@lilotux.net>
parents:
990
diff
changeset
|
4092 |
time(&chatstate_timestamp); |
990
35e7913affb7
Send events/chatstates notifications (JEP-22/JEP-85)
Mikael Berthe <mikael@lilotux.net>
parents:
987
diff
changeset
|
4093 |
} |
1359
7daf906fbcdc
The command /quit can be used in bindings, hooks and sourced files
Mikael Berthe <mikael@lilotux.net>
parents:
1357
diff
changeset
|
4094 |
return; |
24 | 4095 |
} |
576 | 4096 |
|
1590
8d1bcc83ae32
Add support for spellchecking with Enchant (caolan)
Mikael Berthe <mikael@lilotux.net>
parents:
1579
diff
changeset
|
4097 |
#if defined(WITH_ENCHANT) || defined(WITH_ASPELL) |
8d1bcc83ae32
Add support for spellchecking with Enchant (caolan)
Mikael Berthe <mikael@lilotux.net>
parents:
1579
diff
changeset
|
4098 |
// initialization |
1179 | 4099 |
void spellcheck_init(void) |
4100 |
{ |
|
1590
8d1bcc83ae32
Add support for spellchecking with Enchant (caolan)
Mikael Berthe <mikael@lilotux.net>
parents:
1579
diff
changeset
|
4101 |
int spell_enable = settings_opt_get_int("spell_enable"); |
8d1bcc83ae32
Add support for spellchecking with Enchant (caolan)
Mikael Berthe <mikael@lilotux.net>
parents:
1579
diff
changeset
|
4102 |
const char *spell_lang = settings_opt_get("spell_lang"); |
8d1bcc83ae32
Add support for spellchecking with Enchant (caolan)
Mikael Berthe <mikael@lilotux.net>
parents:
1579
diff
changeset
|
4103 |
#ifdef WITH_ASPELL |
8d1bcc83ae32
Add support for spellchecking with Enchant (caolan)
Mikael Berthe <mikael@lilotux.net>
parents:
1579
diff
changeset
|
4104 |
const char *spell_encoding = settings_opt_get("spell_encoding"); |
1179 | 4105 |
AspellCanHaveError *possible_err; |
1590
8d1bcc83ae32
Add support for spellchecking with Enchant (caolan)
Mikael Berthe <mikael@lilotux.net>
parents:
1579
diff
changeset
|
4106 |
#endif |
8d1bcc83ae32
Add support for spellchecking with Enchant (caolan)
Mikael Berthe <mikael@lilotux.net>
parents:
1579
diff
changeset
|
4107 |
|
8d1bcc83ae32
Add support for spellchecking with Enchant (caolan)
Mikael Berthe <mikael@lilotux.net>
parents:
1579
diff
changeset
|
4108 |
if (!spell_enable) |
1179 | 4109 |
return; |
4110 |
||
1590
8d1bcc83ae32
Add support for spellchecking with Enchant (caolan)
Mikael Berthe <mikael@lilotux.net>
parents:
1579
diff
changeset
|
4111 |
#ifdef WITH_ENCHANT |
8d1bcc83ae32
Add support for spellchecking with Enchant (caolan)
Mikael Berthe <mikael@lilotux.net>
parents:
1579
diff
changeset
|
4112 |
if (spell_checker) { |
8d1bcc83ae32
Add support for spellchecking with Enchant (caolan)
Mikael Berthe <mikael@lilotux.net>
parents:
1579
diff
changeset
|
4113 |
enchant_broker_free_dict(spell_broker, spell_checker); |
8d1bcc83ae32
Add support for spellchecking with Enchant (caolan)
Mikael Berthe <mikael@lilotux.net>
parents:
1579
diff
changeset
|
4114 |
enchant_broker_free(spell_broker); |
8d1bcc83ae32
Add support for spellchecking with Enchant (caolan)
Mikael Berthe <mikael@lilotux.net>
parents:
1579
diff
changeset
|
4115 |
spell_checker = NULL; |
8d1bcc83ae32
Add support for spellchecking with Enchant (caolan)
Mikael Berthe <mikael@lilotux.net>
parents:
1579
diff
changeset
|
4116 |
spell_broker = NULL; |
8d1bcc83ae32
Add support for spellchecking with Enchant (caolan)
Mikael Berthe <mikael@lilotux.net>
parents:
1579
diff
changeset
|
4117 |
} |
8d1bcc83ae32
Add support for spellchecking with Enchant (caolan)
Mikael Berthe <mikael@lilotux.net>
parents:
1579
diff
changeset
|
4118 |
|
8d1bcc83ae32
Add support for spellchecking with Enchant (caolan)
Mikael Berthe <mikael@lilotux.net>
parents:
1579
diff
changeset
|
4119 |
spell_broker = enchant_broker_init(); |
8d1bcc83ae32
Add support for spellchecking with Enchant (caolan)
Mikael Berthe <mikael@lilotux.net>
parents:
1579
diff
changeset
|
4120 |
spell_checker = enchant_broker_request_dict(spell_broker, spell_lang); |
8d1bcc83ae32
Add support for spellchecking with Enchant (caolan)
Mikael Berthe <mikael@lilotux.net>
parents:
1579
diff
changeset
|
4121 |
#endif |
8d1bcc83ae32
Add support for spellchecking with Enchant (caolan)
Mikael Berthe <mikael@lilotux.net>
parents:
1579
diff
changeset
|
4122 |
#ifdef WITH_ASPELL |
1179 | 4123 |
if (spell_checker) { |
4124 |
delete_aspell_speller(spell_checker); |
|
4125 |
delete_aspell_config(spell_config); |
|
4126 |
spell_checker = NULL; |
|
4127 |
spell_config = NULL; |
|
4128 |
} |
|
4129 |
||
4130 |
spell_config = new_aspell_config(); |
|
1590
8d1bcc83ae32
Add support for spellchecking with Enchant (caolan)
Mikael Berthe <mikael@lilotux.net>
parents:
1579
diff
changeset
|
4131 |
aspell_config_replace(spell_config, "encoding", spell_encoding); |
8d1bcc83ae32
Add support for spellchecking with Enchant (caolan)
Mikael Berthe <mikael@lilotux.net>
parents:
1579
diff
changeset
|
4132 |
aspell_config_replace(spell_config, "lang", spell_lang); |
1179 | 4133 |
possible_err = new_aspell_speller(spell_config); |
4134 |
||
4135 |
if (aspell_error_number(possible_err) != 0) { |
|
4136 |
spell_checker = NULL; |
|
4137 |
delete_aspell_config(spell_config); |
|
4138 |
spell_config = NULL; |
|
4139 |
} else { |
|
4140 |
spell_checker = to_aspell_speller(possible_err); |
|
4141 |
} |
|
1590
8d1bcc83ae32
Add support for spellchecking with Enchant (caolan)
Mikael Berthe <mikael@lilotux.net>
parents:
1579
diff
changeset
|
4142 |
#endif |
1179 | 4143 |
} |
4144 |
||
1590
8d1bcc83ae32
Add support for spellchecking with Enchant (caolan)
Mikael Berthe <mikael@lilotux.net>
parents:
1579
diff
changeset
|
4145 |
// Deinitialization of spellchecker |
1179 | 4146 |
void spellcheck_deinit(void) |
4147 |
{ |
|
4148 |
if (spell_checker) { |
|
1590
8d1bcc83ae32
Add support for spellchecking with Enchant (caolan)
Mikael Berthe <mikael@lilotux.net>
parents:
1579
diff
changeset
|
4149 |
#ifdef WITH_ENCHANT |
8d1bcc83ae32
Add support for spellchecking with Enchant (caolan)
Mikael Berthe <mikael@lilotux.net>
parents:
1579
diff
changeset
|
4150 |
enchant_broker_free_dict(spell_broker, spell_checker); |
8d1bcc83ae32
Add support for spellchecking with Enchant (caolan)
Mikael Berthe <mikael@lilotux.net>
parents:
1579
diff
changeset
|
4151 |
#endif |
8d1bcc83ae32
Add support for spellchecking with Enchant (caolan)
Mikael Berthe <mikael@lilotux.net>
parents:
1579
diff
changeset
|
4152 |
#ifdef WITH_ASPELL |
1179 | 4153 |
delete_aspell_speller(spell_checker); |
1590
8d1bcc83ae32
Add support for spellchecking with Enchant (caolan)
Mikael Berthe <mikael@lilotux.net>
parents:
1579
diff
changeset
|
4154 |
#endif |
1179 | 4155 |
spell_checker = NULL; |
4156 |
} |
|
4157 |
||
1590
8d1bcc83ae32
Add support for spellchecking with Enchant (caolan)
Mikael Berthe <mikael@lilotux.net>
parents:
1579
diff
changeset
|
4158 |
#ifdef WITH_ENCHANT |
8d1bcc83ae32
Add support for spellchecking with Enchant (caolan)
Mikael Berthe <mikael@lilotux.net>
parents:
1579
diff
changeset
|
4159 |
if (spell_broker) { |
8d1bcc83ae32
Add support for spellchecking with Enchant (caolan)
Mikael Berthe <mikael@lilotux.net>
parents:
1579
diff
changeset
|
4160 |
enchant_broker_free(spell_broker); |
8d1bcc83ae32
Add support for spellchecking with Enchant (caolan)
Mikael Berthe <mikael@lilotux.net>
parents:
1579
diff
changeset
|
4161 |
spell_broker = NULL; |
8d1bcc83ae32
Add support for spellchecking with Enchant (caolan)
Mikael Berthe <mikael@lilotux.net>
parents:
1579
diff
changeset
|
4162 |
} |
8d1bcc83ae32
Add support for spellchecking with Enchant (caolan)
Mikael Berthe <mikael@lilotux.net>
parents:
1579
diff
changeset
|
4163 |
#endif |
8d1bcc83ae32
Add support for spellchecking with Enchant (caolan)
Mikael Berthe <mikael@lilotux.net>
parents:
1579
diff
changeset
|
4164 |
#ifdef WITH_ASPELL |
1179 | 4165 |
if (spell_config) { |
4166 |
delete_aspell_config(spell_config); |
|
4167 |
spell_config = NULL; |
|
4168 |
} |
|
1590
8d1bcc83ae32
Add support for spellchecking with Enchant (caolan)
Mikael Berthe <mikael@lilotux.net>
parents:
1579
diff
changeset
|
4169 |
#endif |
1179 | 4170 |
} |
4171 |
||
1590
8d1bcc83ae32
Add support for spellchecking with Enchant (caolan)
Mikael Berthe <mikael@lilotux.net>
parents:
1579
diff
changeset
|
4172 |
#define spell_isalpha(c) (utf8_mode ? iswalpha(get_char(c)) : isalpha(*c)) |
1245
e6ddd19956eb
Fix Aspell support on some systems
Mikael Berthe <mikael@lilotux.net>
parents:
1239
diff
changeset
|
4173 |
|
1179 | 4174 |
// Spell checking function |
4175 |
static void spellcheck(char *line, char *checked) |
|
4176 |
{ |
|
4177 |
const char *start, *line_start; |
|
4178 |
||
4179 |
if (inputLine[0] == 0 || inputLine[0] == COMMAND_CHAR) |
|
4180 |
return; |
|
4181 |
||
4182 |
line_start = line; |
|
4183 |
||
4184 |
while (*line) { |
|
4185 |
||
1590
8d1bcc83ae32
Add support for spellchecking with Enchant (caolan)
Mikael Berthe <mikael@lilotux.net>
parents:
1579
diff
changeset
|
4186 |
if (!spell_isalpha(line)) { |
1179 | 4187 |
line = next_char(line); |
4188 |
continue; |
|
4189 |
} |
|
4190 |
||
4191 |
if (!strncmp(line, "http://", 7)) { |
|
4192 |
line += 7; // : and / characters are 1 byte long in utf8, right? |
|
4193 |
||
4194 |
while (!strchr(" \t\r\n", *line)) |
|
4195 |
line = next_char(line); // i think line++ would be fine here? |
|
4196 |
||
4197 |
continue; |
|
4198 |
} |
|
4199 |
||
4200 |
if (!strncmp(line, "ftp://", 6)) { |
|
4201 |
line += 6; |
|
4202 |
||
4203 |
while (!strchr(" \t\r\n", *line)) |
|
4204 |
line = next_char(line); |
|
4205 |
||
4206 |
continue; |
|
4207 |
} |
|
4208 |
||
4209 |
start = line; |
|
4210 |
||
1590
8d1bcc83ae32
Add support for spellchecking with Enchant (caolan)
Mikael Berthe <mikael@lilotux.net>
parents:
1579
diff
changeset
|
4211 |
while (spell_isalpha(line)) |
1179 | 4212 |
line = next_char(line); |
4213 |
||
4214 |
if (spell_checker && |
|
1590
8d1bcc83ae32
Add support for spellchecking with Enchant (caolan)
Mikael Berthe <mikael@lilotux.net>
parents:
1579
diff
changeset
|
4215 |
#ifdef WITH_ENCHANT |
8d1bcc83ae32
Add support for spellchecking with Enchant (caolan)
Mikael Berthe <mikael@lilotux.net>
parents:
1579
diff
changeset
|
4216 |
enchant_dict_check(spell_checker, start, line - start) != 0 |
8d1bcc83ae32
Add support for spellchecking with Enchant (caolan)
Mikael Berthe <mikael@lilotux.net>
parents:
1579
diff
changeset
|
4217 |
#endif |
8d1bcc83ae32
Add support for spellchecking with Enchant (caolan)
Mikael Berthe <mikael@lilotux.net>
parents:
1579
diff
changeset
|
4218 |
#ifdef WITH_ASPELL |
8d1bcc83ae32
Add support for spellchecking with Enchant (caolan)
Mikael Berthe <mikael@lilotux.net>
parents:
1579
diff
changeset
|
4219 |
aspell_speller_check(spell_checker, start, line - start) == 0 |
8d1bcc83ae32
Add support for spellchecking with Enchant (caolan)
Mikael Berthe <mikael@lilotux.net>
parents:
1579
diff
changeset
|
4220 |
#endif |
8d1bcc83ae32
Add support for spellchecking with Enchant (caolan)
Mikael Berthe <mikael@lilotux.net>
parents:
1579
diff
changeset
|
4221 |
) |
8d1bcc83ae32
Add support for spellchecking with Enchant (caolan)
Mikael Berthe <mikael@lilotux.net>
parents:
1579
diff
changeset
|
4222 |
memset(&checked[start - line_start], SPELLBADCHAR, line - start); |
1179 | 4223 |
} |
4224 |
} |
|
4225 |
#endif |
|
4226 |
||
580 | 4227 |
/* vim: set expandtab cindent cinoptions=>2\:2(0: For Vim users... */ |