author | Holger Weiß <holger@zedat.fu-berlin.de> |
Fri, 24 Jul 2015 02:37:07 +0200 | |
changeset 2305 | 5b1a63dc2b1a |
parent 2304 | fa8365fb6ac2 |
child 2306 | 7afb9a0c6409 |
permissions | -rw-r--r-- |
307 | 1 |
/* |
2 |
* screen.c -- UI stuff |
|
393 | 3 |
* |
2136
54548cf8f646
screen.c: Remove one memory allocation in scr_draw_roster()
Mikael Berthe <mikael@lilotux.net>
parents:
2101
diff
changeset
|
4 |
* Copyright (C) 2005-2014 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 |
|
2268
f5402d705f67
Fix FSF addresses in all files
Mikael Berthe <mikael@lilotux.net>
parents:
2264
diff
changeset
|
18 |
* along with this program; if not, see <http://www.gnu.org/licenses/>. |
307 | 19 |
*/ |
20 |
||
24 | 21 |
#include <stdio.h> |
22 |
#include <stdlib.h> |
|
23 |
#include <string.h> |
|
24 |
#include <time.h> |
|
25 |
#include <ctype.h> |
|
1382
1447c5296977
Fix locale charset detection on some BSD systems
Mikael Berthe <mikael@lilotux.net>
parents:
1381
diff
changeset
|
26 |
|
1447c5296977
Fix locale charset detection on some BSD systems
Mikael Berthe <mikael@lilotux.net>
parents:
1381
diff
changeset
|
27 |
#include <config.h> |
24 | 28 |
#include <locale.h> |
1292
382ec54b584e
Muc nick coloring functionality
Michal 'vorner' Vaner <vorner@ucw.cz>
parents:
1291
diff
changeset
|
29 |
#include <assert.h> |
1454
6b98dc22946d
Add optional SIGWINCH handler (Markus Hennecke)
Mikael Berthe <mikael@lilotux.net>
parents:
1424
diff
changeset
|
30 |
#ifdef USE_SIGWINCH |
6b98dc22946d
Add optional SIGWINCH handler (Markus Hennecke)
Mikael Berthe <mikael@lilotux.net>
parents:
1424
diff
changeset
|
31 |
# include <sys/ioctl.h> |
6b98dc22946d
Add optional SIGWINCH handler (Markus Hennecke)
Mikael Berthe <mikael@lilotux.net>
parents:
1424
diff
changeset
|
32 |
# include <termios.h> |
6b98dc22946d
Add optional SIGWINCH handler (Markus Hennecke)
Mikael Berthe <mikael@lilotux.net>
parents:
1424
diff
changeset
|
33 |
# include <unistd.h> |
6b98dc22946d
Add optional SIGWINCH handler (Markus Hennecke)
Mikael Berthe <mikael@lilotux.net>
parents:
1424
diff
changeset
|
34 |
#endif |
929 | 35 |
|
1382
1447c5296977
Fix locale charset detection on some BSD systems
Mikael Berthe <mikael@lilotux.net>
parents:
1381
diff
changeset
|
36 |
#ifdef HAVE_LOCALCHARSET_H |
1447c5296977
Fix locale charset detection on some BSD systems
Mikael Berthe <mikael@lilotux.net>
parents:
1381
diff
changeset
|
37 |
# include <localcharset.h> |
1447c5296977
Fix locale charset detection on some BSD systems
Mikael Berthe <mikael@lilotux.net>
parents:
1381
diff
changeset
|
38 |
#else |
1447c5296977
Fix locale charset detection on some BSD systems
Mikael Berthe <mikael@lilotux.net>
parents:
1381
diff
changeset
|
39 |
# include <langinfo.h> |
1447c5296977
Fix locale charset detection on some BSD systems
Mikael Berthe <mikael@lilotux.net>
parents:
1381
diff
changeset
|
40 |
#endif |
1447c5296977
Fix locale charset detection on some BSD systems
Mikael Berthe <mikael@lilotux.net>
parents:
1381
diff
changeset
|
41 |
|
1590
8d1bcc83ae32
Add support for spellchecking with Enchant (caolan)
Mikael Berthe <mikael@lilotux.net>
parents:
1579
diff
changeset
|
42 |
#ifdef WITH_ENCHANT |
8d1bcc83ae32
Add support for spellchecking with Enchant (caolan)
Mikael Berthe <mikael@lilotux.net>
parents:
1579
diff
changeset
|
43 |
# include <enchant.h> |
2015
db8ec238cd2c
Fix segfault when spell checking is enabled and spell_lang is not set.
Mikael Berthe <mikael@lilotux.net>
parents:
2013
diff
changeset
|
44 |
#else |
db8ec238cd2c
Fix segfault when spell checking is enabled and spell_lang is not set.
Mikael Berthe <mikael@lilotux.net>
parents:
2013
diff
changeset
|
45 |
# ifdef WITH_ASPELL |
db8ec238cd2c
Fix segfault when spell checking is enabled and spell_lang is not set.
Mikael Berthe <mikael@lilotux.net>
parents:
2013
diff
changeset
|
46 |
# include <aspell.h> |
db8ec238cd2c
Fix segfault when spell checking is enabled and spell_lang is not set.
Mikael Berthe <mikael@lilotux.net>
parents:
2013
diff
changeset
|
47 |
# endif |
1179 | 48 |
#endif |
49 |
||
24 | 50 |
#include "screen.h" |
930
a75f7a13df7b
UTF-8 terminal support (Reimar Döffinger)
Mikael Berthe <mikael@lilotux.net>
parents:
929
diff
changeset
|
51 |
#include "utf8.h" |
81 | 52 |
#include "hbuf.h" |
47 | 53 |
#include "commands.h" |
95 | 54 |
#include "compl.h" |
81 | 55 |
#include "roster.h" |
180 | 56 |
#include "histolog.h" |
279
f5dd437c057b
Rewrite the settings system
Mikael Berthe <mikael@lilotux.net>
parents:
276
diff
changeset
|
57 |
#include "settings.h" |
81 | 58 |
#include "utils.h" |
1598 | 59 |
#include "xmpp.h" |
1653
fca9a4c17432
Improve UI latency and CPU usage
Myhailo Danylenko <isbear@ukrpost.net>
parents:
1651
diff
changeset
|
60 |
#include "main.h" |
24 | 61 |
|
2028
7b5bd6ad83b4
Add 'color_log' (text color in the log window)
Mikael Berthe <mikael@lilotux.net>
parents:
2015
diff
changeset
|
62 |
#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
|
63 |
#define compose_color(col) (COLOR_PAIR(col->color_pair)|col->color_attrib) |
24 | 64 |
|
515
180f0a6e4ac9
Log window's height can be set by the user
Mikael Berthe <mikael@lilotux.net>
parents:
514
diff
changeset
|
65 |
#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
|
66 |
#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
|
67 |
#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
|
68 |
|
2100
113d3b96ae3e
Add option 'attention_char'
Mikael Berthe <mikael@lilotux.net>
parents:
2098
diff
changeset
|
69 |
#define DEFAULT_ATTENTION_CHAR '!' |
113d3b96ae3e
Add option 'attention_char'
Mikael Berthe <mikael@lilotux.net>
parents:
2098
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; |
1942
3e39a336a992
Use guards for colors (Myhailo Danylenko)
Mikael Berthe <mikael@lilotux.net>
parents:
1935
diff
changeset
|
75 |
static gboolean colors_stalled = FALSE; |
515
180f0a6e4ac9
Log window's height can be set by the user
Mikael Berthe <mikael@lilotux.net>
parents:
514
diff
changeset
|
76 |
|
1804
35a1250c111a
Display urgent/attention sign in the roster UI
Mikael Berthe <mikael@lilotux.net>
parents:
1802
diff
changeset
|
77 |
// Default attention sign trigger levels |
35a1250c111a
Display urgent/attention sign in the roster UI
Mikael Berthe <mikael@lilotux.net>
parents:
1802
diff
changeset
|
78 |
static guint ui_attn_sign_prio_level_muc = ROSTER_UI_PRIO_MUC_HL_MESSAGE; |
35a1250c111a
Display urgent/attention sign in the roster UI
Mikael Berthe <mikael@lilotux.net>
parents:
1802
diff
changeset
|
79 |
static guint ui_attn_sign_prio_level = ROSTER_UI_PRIO_ATTENTION_MESSAGE; |
35a1250c111a
Display urgent/attention sign in the roster UI
Mikael Berthe <mikael@lilotux.net>
parents:
1802
diff
changeset
|
80 |
|
336
eb994ee40029
Make some functions static
Mikael Berthe <mikael@lilotux.net>
parents:
332
diff
changeset
|
81 |
static inline void check_offset(int); |
1172
334ae9f498f1
Add some more iline functions (Lego12239)
Mikael Berthe <mikael@lilotux.net>
parents:
1171
diff
changeset
|
82 |
static void scr_cancel_current_completion(void); |
334ae9f498f1
Add some more iline functions (Lego12239)
Mikael Berthe <mikael@lilotux.net>
parents:
1171
diff
changeset
|
83 |
static void scr_end_current_completion(void); |
334ae9f498f1
Add some more iline functions (Lego12239)
Mikael Berthe <mikael@lilotux.net>
parents:
1171
diff
changeset
|
84 |
static void scr_insert_text(const char*); |
2143
2f294c2b6778
Add a backward completion (Oleg)
Mikael Berthe <mikael@lilotux.net>
parents:
2136
diff
changeset
|
85 |
static void scr_handle_tab(gboolean fwd); |
151 | 86 |
|
2149
1b3add57c912
Try to display the GLib warnings in the log window
Mikael Berthe <mikael@lilotux.net>
parents:
2143
diff
changeset
|
87 |
static void scr_glog_print(const gchar *log_domain, GLogLevelFlags log_level, |
1b3add57c912
Try to display the GLib warnings in the log window
Mikael Berthe <mikael@lilotux.net>
parents:
2143
diff
changeset
|
88 |
const gchar *message, gpointer user_data); |
1b3add57c912
Try to display the GLib warnings in the log window
Mikael Berthe <mikael@lilotux.net>
parents:
2143
diff
changeset
|
89 |
|
2165 | 90 |
#ifdef XEP0085 |
1780
e4378fbab5d7
Major API cleanup - bump API to 4
Mikael Berthe <mikael@lilotux.net>
parents:
1761
diff
changeset
|
91 |
static gboolean scr_chatstates_timeout(); |
e4378fbab5d7
Major API cleanup - bump API to 4
Mikael Berthe <mikael@lilotux.net>
parents:
1761
diff
changeset
|
92 |
#endif |
e4378fbab5d7
Major API cleanup - bump API to 4
Mikael Berthe <mikael@lilotux.net>
parents:
1761
diff
changeset
|
93 |
|
1590
8d1bcc83ae32
Add support for spellchecking with Enchant (caolan)
Mikael Berthe <mikael@lilotux.net>
parents:
1579
diff
changeset
|
94 |
#if defined(WITH_ENCHANT) || defined(WITH_ASPELL) |
1179 | 95 |
static void spellcheck(char *, char *); |
96 |
#endif |
|
97 |
||
2304
fa8365fb6ac2
[PATCH 1/3] New option: vi_mode
Holger Weiß <holger@zedat.fu-berlin.de>
parents:
2292
diff
changeset
|
98 |
static void open_chat_window(void); |
fa8365fb6ac2
[PATCH 1/3] New option: vi_mode
Holger Weiß <holger@zedat.fu-berlin.de>
parents:
2292
diff
changeset
|
99 |
static void clear_inputline(void); |
fa8365fb6ac2
[PATCH 1/3] New option: vi_mode
Holger Weiß <holger@zedat.fu-berlin.de>
parents:
2292
diff
changeset
|
100 |
|
1078
7866dbaf67a6
Use a hash for the list of win buffers
Mikael Berthe <mikael@lilotux.net>
parents:
1077
diff
changeset
|
101 |
static GHashTable *winbufhash; |
24 | 102 |
|
822 | 103 |
typedef struct { |
2225
dc3b3ac1ba76
Free the buffdata structures when buffers are closed
Mikael Berthe <mikael@lilotux.net>
parents:
2222
diff
changeset
|
104 |
GList *hbuf; |
dc3b3ac1ba76
Free the buffdata structures when buffers are closed
Mikael Berthe <mikael@lilotux.net>
parents:
2222
diff
changeset
|
105 |
GList *top; // If top is NULL, we'll display the last lines |
dc3b3ac1ba76
Free the buffdata structures when buffers are closed
Mikael Berthe <mikael@lilotux.net>
parents:
2222
diff
changeset
|
106 |
char cleared; // For ex, user has issued a /clear command... |
dc3b3ac1ba76
Free the buffdata structures when buffers are closed
Mikael Berthe <mikael@lilotux.net>
parents:
2222
diff
changeset
|
107 |
char lock; |
dc3b3ac1ba76
Free the buffdata structures when buffers are closed
Mikael Berthe <mikael@lilotux.net>
parents:
2222
diff
changeset
|
108 |
char refcount; // refcount > 0 if there are other users of this struct |
dc3b3ac1ba76
Free the buffdata structures when buffers are closed
Mikael Berthe <mikael@lilotux.net>
parents:
2222
diff
changeset
|
109 |
// e.g. with symlinked history |
1157
5c857f0f0ab8
Moved all variables related to hbuf to an extra struct, bufdata
Frank Zschockelt
parents:
1156
diff
changeset
|
110 |
} buffdata; |
5c857f0f0ab8
Moved all variables related to hbuf to an extra struct, bufdata
Frank Zschockelt
parents:
1156
diff
changeset
|
111 |
|
5c857f0f0ab8
Moved all variables related to hbuf to an extra struct, bufdata
Frank Zschockelt
parents:
1156
diff
changeset
|
112 |
typedef struct { |
24 | 113 |
WINDOW *win; |
108 | 114 |
PANEL *panel; |
1157
5c857f0f0ab8
Moved all variables related to hbuf to an extra struct, bufdata
Frank Zschockelt
parents:
1156
diff
changeset
|
115 |
buffdata *bd; |
822 | 116 |
} winbuf; |
24 | 117 |
|
1078
7866dbaf67a6
Use a hash for the list of win buffers
Mikael Berthe <mikael@lilotux.net>
parents:
1077
diff
changeset
|
118 |
struct dimensions { |
7866dbaf67a6
Use a hash for the list of win buffers
Mikael Berthe <mikael@lilotux.net>
parents:
1077
diff
changeset
|
119 |
int l; |
7866dbaf67a6
Use a hash for the list of win buffers
Mikael Berthe <mikael@lilotux.net>
parents:
1077
diff
changeset
|
120 |
int c; |
7866dbaf67a6
Use a hash for the list of win buffers
Mikael Berthe <mikael@lilotux.net>
parents:
1077
diff
changeset
|
121 |
}; |
24 | 122 |
|
1133
9dd28a56128f
Do not create one panel per contact
Mikael Berthe <mikael@lilotux.net>
parents:
1131
diff
changeset
|
123 |
static WINDOW *rosterWnd, *chatWnd, *activechatWnd, *inputWnd, *logWnd; |
711 | 124 |
static WINDOW *mainstatusWnd, *chatstatusWnd; |
1133
9dd28a56128f
Do not create one panel per contact
Mikael Berthe <mikael@lilotux.net>
parents:
1131
diff
changeset
|
125 |
static PANEL *rosterPanel, *chatPanel, *activechatPanel, *inputPanel; |
711 | 126 |
static PANEL *mainstatusPanel, *chatstatusPanel; |
127 |
static PANEL *logPanel; |
|
24 | 128 |
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
|
129 |
static int prev_chatwidth; |
849
42c43a88d823
Status buffer management
Mikael Berthe <mikael@lilotux.net>
parents:
848
diff
changeset
|
130 |
static winbuf *statusWindow; |
822 | 131 |
static winbuf *currentWindow; |
851
da03534e46c7
Add startup log messages to the status buffer
Mikael Berthe <mikael@lilotux.net>
parents:
850
diff
changeset
|
132 |
static GList *statushbuf; |
24 | 133 |
|
707
b26a0bde4cdb
Add /roster hide|show|toggle
Mikael Berthe <mikael@lilotux.net>
parents:
701
diff
changeset
|
134 |
static int roster_hidden; |
24 | 135 |
static int chatmode; |
238 | 136 |
static int multimode; |
807
f6cda389db48
Allow messages with a subject (/msay)
Mikael Berthe <mikael@lilotux.net>
parents:
806
diff
changeset
|
137 |
static char *multiline, *multimode_subj; |
2009
a859ed648638
Replace the option « no_space_before_items » with « roster_no_leading_space ».
Simon Jacquin <simon@jacquin.me>
parents:
2008
diff
changeset
|
138 |
static int roster_no_leading_space; |
1780
e4378fbab5d7
Major API cleanup - bump API to 4
Mikael Berthe <mikael@lilotux.net>
parents:
1761
diff
changeset
|
139 |
|
332
a1901741890e
scr_LogPrint() can be called before ncurses initialization
Mikael Berthe <mikael@lilotux.net>
parents:
330
diff
changeset
|
140 |
static bool Curses; |
972
11b632d824f6
Add option 'log_win_on_top'
Mikael Berthe <mikael@lilotux.net>
parents:
967
diff
changeset
|
141 |
static bool log_win_on_top; |
973
e693cbe33802
Add option 'roster_win_on_right'
Mikael Berthe <mikael@lilotux.net>
parents:
972
diff
changeset
|
142 |
static bool roster_win_on_right; |
1677 | 143 |
static guint autoaway_source = 0; |
24 | 144 |
|
174 | 145 |
static char inputLine[INPUTLINE_LENGTH+1]; |
1590
8d1bcc83ae32
Add support for spellchecking with Enchant (caolan)
Mikael Berthe <mikael@lilotux.net>
parents:
1579
diff
changeset
|
146 |
#if defined(WITH_ENCHANT) || defined(WITH_ASPELL) |
1179 | 147 |
static char maskLine[INPUTLINE_LENGTH+1]; |
148 |
#endif |
|
174 | 149 |
static char *ptr_inputline; |
150 |
static short int inputline_offset; |
|
151 |
static int completion_started; |
|
173 | 152 |
static GList *cmdhisto; |
153 |
static GList *cmdhisto_cur; |
|
1127
fddf2fef7b83
Add option "cmdhistory_lines"
Mikael Berthe <mikael@lilotux.net>
parents:
1122
diff
changeset
|
154 |
static guint cmdhisto_nblines; |
174 | 155 |
static char cmdhisto_backup[INPUTLINE_LENGTH+1]; |
24 | 156 |
|
991
ef10906691bb
Chatstates: add composing timeout
Mikael Berthe <mikael@lilotux.net>
parents:
990
diff
changeset
|
157 |
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
|
158 |
static bool lock_chatstate; |
991
ef10906691bb
Chatstates: add composing timeout
Mikael Berthe <mikael@lilotux.net>
parents:
990
diff
changeset
|
159 |
static time_t chatstate_timestamp; |
1598 | 160 |
static guint chatstate_timeout_id = 0; |
1780
e4378fbab5d7
Major API cleanup - bump API to 4
Mikael Berthe <mikael@lilotux.net>
parents:
1761
diff
changeset
|
161 |
|
2292
f181418db215
Replace global variable update_roster with scr_update_roster()
franky
parents:
2291
diff
changeset
|
162 |
int _update_roster; |
1780
e4378fbab5d7
Major API cleanup - bump API to 4
Mikael Berthe <mikael@lilotux.net>
parents:
1761
diff
changeset
|
163 |
int utf8_mode; |
e4378fbab5d7
Major API cleanup - bump API to 4
Mikael Berthe <mikael@lilotux.net>
parents:
1761
diff
changeset
|
164 |
gboolean chatstates_disabled; |
e4378fbab5d7
Major API cleanup - bump API to 4
Mikael Berthe <mikael@lilotux.net>
parents:
1761
diff
changeset
|
165 |
gboolean Autoaway; |
990
35e7913affb7
Send events/chatstates notifications (JEP-22/JEP-85)
Mikael Berthe <mikael@lilotux.net>
parents:
987
diff
changeset
|
166 |
|
761
4532a9fe0e8c
Handle some keyboard escape sequences
Mikael Berthe <mikael@lilotux.net>
parents:
760
diff
changeset
|
167 |
#define MAX_KEYSEQ_LENGTH 8 |
4532a9fe0e8c
Handle some keyboard escape sequences
Mikael Berthe <mikael@lilotux.net>
parents:
760
diff
changeset
|
168 |
|
4532a9fe0e8c
Handle some keyboard escape sequences
Mikael Berthe <mikael@lilotux.net>
parents:
760
diff
changeset
|
169 |
typedef struct { |
4532a9fe0e8c
Handle some keyboard escape sequences
Mikael Berthe <mikael@lilotux.net>
parents:
760
diff
changeset
|
170 |
char *seqstr; |
4532a9fe0e8c
Handle some keyboard escape sequences
Mikael Berthe <mikael@lilotux.net>
parents:
760
diff
changeset
|
171 |
guint mkeycode; |
4532a9fe0e8c
Handle some keyboard escape sequences
Mikael Berthe <mikael@lilotux.net>
parents:
760
diff
changeset
|
172 |
gint value; |
4532a9fe0e8c
Handle some keyboard escape sequences
Mikael Berthe <mikael@lilotux.net>
parents:
760
diff
changeset
|
173 |
} keyseq; |
4532a9fe0e8c
Handle some keyboard escape sequences
Mikael Berthe <mikael@lilotux.net>
parents:
760
diff
changeset
|
174 |
|
4532a9fe0e8c
Handle some keyboard escape sequences
Mikael Berthe <mikael@lilotux.net>
parents:
760
diff
changeset
|
175 |
GSList *keyseqlist; |
4532a9fe0e8c
Handle some keyboard escape sequences
Mikael Berthe <mikael@lilotux.net>
parents:
760
diff
changeset
|
176 |
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
|
177 |
|
1780
e4378fbab5d7
Major API cleanup - bump API to 4
Mikael Berthe <mikael@lilotux.net>
parents:
1761
diff
changeset
|
178 |
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
|
179 |
time_t timestamp, unsigned int prefix_flags, |
e4378fbab5d7
Major API cleanup - bump API to 4
Mikael Berthe <mikael@lilotux.net>
parents:
1761
diff
changeset
|
180 |
int force_show, unsigned mucnicklen, |
e4378fbab5d7
Major API cleanup - bump API to 4
Mikael Berthe <mikael@lilotux.net>
parents:
1761
diff
changeset
|
181 |
gpointer xep184); |
e4378fbab5d7
Major API cleanup - bump API to 4
Mikael Berthe <mikael@lilotux.net>
parents:
1761
diff
changeset
|
182 |
|
e4378fbab5d7
Major API cleanup - bump API to 4
Mikael Berthe <mikael@lilotux.net>
parents:
1761
diff
changeset
|
183 |
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
|
184 |
time_t timestamp, guint prefix_flags, |
e4378fbab5d7
Major API cleanup - bump API to 4
Mikael Berthe <mikael@lilotux.net>
parents:
1761
diff
changeset
|
185 |
unsigned mucnicklen, gpointer xep184); |
e4378fbab5d7
Major API cleanup - bump API to 4
Mikael Berthe <mikael@lilotux.net>
parents:
1761
diff
changeset
|
186 |
|
e4378fbab5d7
Major API cleanup - bump API to 4
Mikael Berthe <mikael@lilotux.net>
parents:
1761
diff
changeset
|
187 |
inline void scr_update_buddy_window(void); |
1413 | 188 |
inline void scr_set_chatmode(int enable); |
189 |
||
1590
8d1bcc83ae32
Add support for spellchecking with Enchant (caolan)
Mikael Berthe <mikael@lilotux.net>
parents:
1579
diff
changeset
|
190 |
#define SPELLBADCHAR 5 |
8d1bcc83ae32
Add support for spellchecking with Enchant (caolan)
Mikael Berthe <mikael@lilotux.net>
parents:
1579
diff
changeset
|
191 |
|
2170
282531385f34
Multilanguage spell checking
Dmitry Potapov <potapov.d@gmail.com>
parents:
2165
diff
changeset
|
192 |
#if defined(WITH_ENCHANT) || defined(WITH_ASPELL) |
282531385f34
Multilanguage spell checking
Dmitry Potapov <potapov.d@gmail.com>
parents:
2165
diff
changeset
|
193 |
typedef struct { |
1590
8d1bcc83ae32
Add support for spellchecking with Enchant (caolan)
Mikael Berthe <mikael@lilotux.net>
parents:
1579
diff
changeset
|
194 |
#ifdef WITH_ENCHANT |
2170
282531385f34
Multilanguage spell checking
Dmitry Potapov <potapov.d@gmail.com>
parents:
2165
diff
changeset
|
195 |
EnchantBroker *broker; |
282531385f34
Multilanguage spell checking
Dmitry Potapov <potapov.d@gmail.com>
parents:
2165
diff
changeset
|
196 |
EnchantDict *checker; |
1590
8d1bcc83ae32
Add support for spellchecking with Enchant (caolan)
Mikael Berthe <mikael@lilotux.net>
parents:
1579
diff
changeset
|
197 |
#endif |
8d1bcc83ae32
Add support for spellchecking with Enchant (caolan)
Mikael Berthe <mikael@lilotux.net>
parents:
1579
diff
changeset
|
198 |
#ifdef WITH_ASPELL |
2170
282531385f34
Multilanguage spell checking
Dmitry Potapov <potapov.d@gmail.com>
parents:
2165
diff
changeset
|
199 |
AspellConfig *config; |
282531385f34
Multilanguage spell checking
Dmitry Potapov <potapov.d@gmail.com>
parents:
2165
diff
changeset
|
200 |
AspellSpeller *checker; |
282531385f34
Multilanguage spell checking
Dmitry Potapov <potapov.d@gmail.com>
parents:
2165
diff
changeset
|
201 |
#endif |
282531385f34
Multilanguage spell checking
Dmitry Potapov <potapov.d@gmail.com>
parents:
2165
diff
changeset
|
202 |
} spell_checker; |
282531385f34
Multilanguage spell checking
Dmitry Potapov <potapov.d@gmail.com>
parents:
2165
diff
changeset
|
203 |
|
282531385f34
Multilanguage spell checking
Dmitry Potapov <potapov.d@gmail.com>
parents:
2165
diff
changeset
|
204 |
GSList* spell_checkers = NULL; |
1179 | 205 |
#endif |
24 | 206 |
|
1272
033576acac4c
Add configurable roster colors (Michal 'vorner' Vaner)
Mikael Berthe <mikael@lilotux.net>
parents:
1268
diff
changeset
|
207 |
typedef struct { |
2264
44bb9a033407
Revert patch c1eb68306520
Mikael Berthe <mikael@lilotux.net>
parents:
2231
diff
changeset
|
208 |
int color_pair; |
44bb9a033407
Revert patch c1eb68306520
Mikael Berthe <mikael@lilotux.net>
parents:
2231
diff
changeset
|
209 |
int color_attrib; |
1489
e9c71ce96dca
Fixed the colorhandling for mucnicks and /color roster
franky@veqlargh.fs
parents:
1488
diff
changeset
|
210 |
} ccolor; |
e9c71ce96dca
Fixed the colorhandling for mucnicks and /color roster
franky@veqlargh.fs
parents:
1488
diff
changeset
|
211 |
|
e9c71ce96dca
Fixed the colorhandling for mucnicks and /color roster
franky@veqlargh.fs
parents:
1488
diff
changeset
|
212 |
typedef struct { |
1272
033576acac4c
Add configurable roster colors (Michal 'vorner' Vaner)
Mikael Berthe <mikael@lilotux.net>
parents:
1268
diff
changeset
|
213 |
char *status, *wildcard; |
1598 | 214 |
ccolor *color; |
1272
033576acac4c
Add configurable roster colors (Michal 'vorner' Vaner)
Mikael Berthe <mikael@lilotux.net>
parents:
1268
diff
changeset
|
215 |
GPatternSpec *compiled; |
033576acac4c
Add configurable roster colors (Michal 'vorner' Vaner)
Mikael Berthe <mikael@lilotux.net>
parents:
1268
diff
changeset
|
216 |
} rostercolor; |
033576acac4c
Add configurable roster colors (Michal 'vorner' Vaner)
Mikael Berthe <mikael@lilotux.net>
parents:
1268
diff
changeset
|
217 |
|
1292
382ec54b584e
Muc nick coloring functionality
Michal 'vorner' Vaner <vorner@ucw.cz>
parents:
1291
diff
changeset
|
218 |
static GSList *rostercolrules = NULL; |
382ec54b584e
Muc nick coloring functionality
Michal 'vorner' Vaner <vorner@ucw.cz>
parents:
1291
diff
changeset
|
219 |
|
382ec54b584e
Muc nick coloring functionality
Michal 'vorner' Vaner <vorner@ucw.cz>
parents:
1291
diff
changeset
|
220 |
static GHashTable *muccolors = NULL, *nickcolors = NULL; |
382ec54b584e
Muc nick coloring functionality
Michal 'vorner' Vaner <vorner@ucw.cz>
parents:
1291
diff
changeset
|
221 |
|
382ec54b584e
Muc nick coloring functionality
Michal 'vorner' Vaner <vorner@ucw.cz>
parents:
1291
diff
changeset
|
222 |
typedef struct { |
1413 | 223 |
bool manual; // Manually set? |
1598 | 224 |
ccolor *color; |
1292
382ec54b584e
Muc nick coloring functionality
Michal 'vorner' Vaner <vorner@ucw.cz>
parents:
1291
diff
changeset
|
225 |
} nickcolor; |
382ec54b584e
Muc nick coloring functionality
Michal 'vorner' Vaner <vorner@ucw.cz>
parents:
1291
diff
changeset
|
226 |
|
1489
e9c71ce96dca
Fixed the colorhandling for mucnicks and /color roster
franky@veqlargh.fs
parents:
1488
diff
changeset
|
227 |
static int nickcolcount = 0; |
e9c71ce96dca
Fixed the colorhandling for mucnicks and /color roster
franky@veqlargh.fs
parents:
1488
diff
changeset
|
228 |
static ccolor ** nickcols = NULL; |
1292
382ec54b584e
Muc nick coloring functionality
Michal 'vorner' Vaner <vorner@ucw.cz>
parents:
1291
diff
changeset
|
229 |
static muccoltype glob_muccol = MC_OFF; |
1272
033576acac4c
Add configurable roster colors (Michal 'vorner' Vaner)
Mikael Berthe <mikael@lilotux.net>
parents:
1268
diff
changeset
|
230 |
|
99 | 231 |
/* Functions */ |
24 | 232 |
|
1780
e4378fbab5d7
Major API cleanup - bump API to 4
Mikael Berthe <mikael@lilotux.net>
parents:
1761
diff
changeset
|
233 |
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
|
234 |
{ |
1489
e9c71ce96dca
Fixed the colorhandling for mucnicks and /color roster
franky@veqlargh.fs
parents:
1488
diff
changeset
|
235 |
int result; |
e9c71ce96dca
Fixed the colorhandling for mucnicks and /color roster
franky@veqlargh.fs
parents:
1488
diff
changeset
|
236 |
|
24 | 237 |
if (!strcmp(name, "default")) |
238 |
return -1; |
|
239 |
if (!strcmp(name, "black")) |
|
240 |
return COLOR_BLACK; |
|
241 |
if (!strcmp(name, "red")) |
|
242 |
return COLOR_RED; |
|
243 |
if (!strcmp(name, "green")) |
|
244 |
return COLOR_GREEN; |
|
245 |
if (!strcmp(name, "yellow")) |
|
246 |
return COLOR_YELLOW; |
|
247 |
if (!strcmp(name, "blue")) |
|
248 |
return COLOR_BLUE; |
|
249 |
if (!strcmp(name, "magenta")) |
|
250 |
return COLOR_MAGENTA; |
|
251 |
if (!strcmp(name, "cyan")) |
|
252 |
return COLOR_CYAN; |
|
253 |
if (!strcmp(name, "white")) |
|
254 |
return COLOR_WHITE; |
|
255 |
||
1417
783b47c9d963
Allow more than the 16 default colors (patch from mjs)
Mikael Berthe <mikael@lilotux.net>
parents:
1414
diff
changeset
|
256 |
// 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
|
257 |
result = atoi(name); |
2029
ca40744c03be
Do not warn when the configuration file contains 256-color values
Mikael Berthe <mikael@lilotux.net>
parents:
2028
diff
changeset
|
258 |
if (result > 0 && (result < COLORS || !Curses)) |
1417
783b47c9d963
Allow more than the 16 default colors (patch from mjs)
Mikael Berthe <mikael@lilotux.net>
parents:
1414
diff
changeset
|
259 |
return result; |
783b47c9d963
Allow more than the 16 default colors (patch from mjs)
Mikael Berthe <mikael@lilotux.net>
parents:
1414
diff
changeset
|
260 |
|
739
0d5fb1d9077c
Allow "bright" text colors
Mikael Berthe <mikael@lilotux.net>
parents:
735
diff
changeset
|
261 |
scr_LogPrint(LPRINT_LOGNORM, "ERROR: Wrong color: %s", name); |
24 | 262 |
return -1; |
263 |
} |
|
264 |
||
1598 | 265 |
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
|
266 |
{ |
1381
40095d413da9
Fix compilation on OpenBSD
Mikael Berthe <mikael@lilotux.net>
parents:
1376
diff
changeset
|
267 |
bool isbright = FALSE; |
1295
33cb828282d5
Fix recognizing of bright colors
Michal 'vorner' Vaner <vorner@ucw.cz>
parents:
1294
diff
changeset
|
268 |
int cl; |
1598 | 269 |
ccolor *ccol; |
1295
33cb828282d5
Fix recognizing of bright colors
Michal 'vorner' Vaner <vorner@ucw.cz>
parents:
1294
diff
changeset
|
270 |
if (!strncmp(color, "bright", 6)) { |
1381
40095d413da9
Fix compilation on OpenBSD
Mikael Berthe <mikael@lilotux.net>
parents:
1376
diff
changeset
|
271 |
isbright = TRUE; |
1295
33cb828282d5
Fix recognizing of bright colors
Michal 'vorner' Vaner <vorner@ucw.cz>
parents:
1294
diff
changeset
|
272 |
color += 6; |
33cb828282d5
Fix recognizing of bright colors
Michal 'vorner' Vaner <vorner@ucw.cz>
parents:
1294
diff
changeset
|
273 |
} |
1780
e4378fbab5d7
Major API cleanup - bump API to 4
Mikael Berthe <mikael@lilotux.net>
parents:
1761
diff
changeset
|
274 |
cl = find_color(color); |
1295
33cb828282d5
Fix recognizing of bright colors
Michal 'vorner' Vaner <vorner@ucw.cz>
parents:
1294
diff
changeset
|
275 |
if (cl < 0) |
1489
e9c71ce96dca
Fixed the colorhandling for mucnicks and /color roster
franky@veqlargh.fs
parents:
1488
diff
changeset
|
276 |
return NULL; |
e9c71ce96dca
Fixed the colorhandling for mucnicks and /color roster
franky@veqlargh.fs
parents:
1488
diff
changeset
|
277 |
ccol = g_new0(ccolor, 1); |
e9c71ce96dca
Fixed the colorhandling for mucnicks and /color roster
franky@veqlargh.fs
parents:
1488
diff
changeset
|
278 |
ccol->color_attrib = isbright ? A_BOLD : A_NORMAL; |
1729
e6e89b1d7831
Minor style and header updates
Mikael Berthe <mikael@lilotux.net>
parents:
1710
diff
changeset
|
279 |
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
|
280 |
return ccol; |
1295
33cb828282d5
Fix recognizing of bright colors
Michal 'vorner' Vaner <vorner@ucw.cz>
parents:
1294
diff
changeset
|
281 |
} |
33cb828282d5
Fix recognizing of bright colors
Michal 'vorner' Vaner <vorner@ucw.cz>
parents:
1294
diff
changeset
|
282 |
|
1292
382ec54b584e
Muc nick coloring functionality
Michal 'vorner' Vaner <vorner@ucw.cz>
parents:
1291
diff
changeset
|
283 |
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
|
284 |
GDestroyNotify value_destroy_func) |
1292
382ec54b584e
Muc nick coloring functionality
Michal 'vorner' Vaner <vorner@ucw.cz>
parents:
1291
diff
changeset
|
285 |
{ |
1729
e6e89b1d7831
Minor style and header updates
Mikael Berthe <mikael@lilotux.net>
parents:
1710
diff
changeset
|
286 |
if (*table) // Have it already |
1292
382ec54b584e
Muc nick coloring functionality
Michal 'vorner' Vaner <vorner@ucw.cz>
parents:
1291
diff
changeset
|
287 |
return; |
382ec54b584e
Muc nick coloring functionality
Michal 'vorner' Vaner <vorner@ucw.cz>
parents:
1291
diff
changeset
|
288 |
*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
|
289 |
g_free, value_destroy_func); |
382ec54b584e
Muc nick coloring functionality
Michal 'vorner' Vaner <vorner@ucw.cz>
parents:
1291
diff
changeset
|
290 |
} |
382ec54b584e
Muc nick coloring functionality
Michal 'vorner' Vaner <vorner@ucw.cz>
parents:
1291
diff
changeset
|
291 |
|
382ec54b584e
Muc nick coloring functionality
Michal 'vorner' Vaner <vorner@ucw.cz>
parents:
1291
diff
changeset
|
292 |
// Sets the coloring mode for given MUC |
382ec54b584e
Muc nick coloring functionality
Michal 'vorner' Vaner <vorner@ucw.cz>
parents:
1291
diff
changeset
|
293 |
// 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
|
294 |
// muc - the JID of room |
382ec54b584e
Muc nick coloring functionality
Michal 'vorner' Vaner <vorner@ucw.cz>
parents:
1291
diff
changeset
|
295 |
// type - the new type |
1780
e4378fbab5d7
Major API cleanup - bump API to 4
Mikael Berthe <mikael@lilotux.net>
parents:
1761
diff
changeset
|
296 |
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
|
297 |
{ |
382ec54b584e
Muc nick coloring functionality
Michal 'vorner' Vaner <vorner@ucw.cz>
parents:
1291
diff
changeset
|
298 |
gchar *muclow = g_utf8_strdown(muc, -1); |
1729
e6e89b1d7831
Minor style and header updates
Mikael Berthe <mikael@lilotux.net>
parents:
1710
diff
changeset
|
299 |
if (type == MC_REMOVE) { // Remove it |
1292
382ec54b584e
Muc nick coloring functionality
Michal 'vorner' Vaner <vorner@ucw.cz>
parents:
1291
diff
changeset
|
300 |
if (strcmp(muc, "*")) { |
382ec54b584e
Muc nick coloring functionality
Michal 'vorner' Vaner <vorner@ucw.cz>
parents:
1291
diff
changeset
|
301 |
if (muccolors && g_hash_table_lookup(muccolors, muclow)) |
382ec54b584e
Muc nick coloring functionality
Michal 'vorner' Vaner <vorner@ucw.cz>
parents:
1291
diff
changeset
|
302 |
g_hash_table_remove(muccolors, muclow); |
382ec54b584e
Muc nick coloring functionality
Michal 'vorner' Vaner <vorner@ucw.cz>
parents:
1291
diff
changeset
|
303 |
} else { |
382ec54b584e
Muc nick coloring functionality
Michal 'vorner' Vaner <vorner@ucw.cz>
parents:
1291
diff
changeset
|
304 |
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
|
305 |
} |
382ec54b584e
Muc nick coloring functionality
Michal 'vorner' Vaner <vorner@ucw.cz>
parents:
1291
diff
changeset
|
306 |
g_free(muclow); |
1729
e6e89b1d7831
Minor style and header updates
Mikael Berthe <mikael@lilotux.net>
parents:
1710
diff
changeset
|
307 |
} else { // Add or overwrite |
1292
382ec54b584e
Muc nick coloring functionality
Michal 'vorner' Vaner <vorner@ucw.cz>
parents:
1291
diff
changeset
|
308 |
if (strcmp(muc, "*")) { |
382ec54b584e
Muc nick coloring functionality
Michal 'vorner' Vaner <vorner@ucw.cz>
parents:
1291
diff
changeset
|
309 |
muccoltype *value = g_new(muccoltype, 1); |
382ec54b584e
Muc nick coloring functionality
Michal 'vorner' Vaner <vorner@ucw.cz>
parents:
1291
diff
changeset
|
310 |
*value = type; |
1476
77afd831f8f7
Avoid mixed declarations and code
Mikael Berthe <mikael@lilotux.net>
parents:
1457
diff
changeset
|
311 |
ensure_string_htable(&muccolors, g_free); |
1292
382ec54b584e
Muc nick coloring functionality
Michal 'vorner' Vaner <vorner@ucw.cz>
parents:
1291
diff
changeset
|
312 |
g_hash_table_replace(muccolors, muclow, value); |
382ec54b584e
Muc nick coloring functionality
Michal 'vorner' Vaner <vorner@ucw.cz>
parents:
1291
diff
changeset
|
313 |
} else { |
382ec54b584e
Muc nick coloring functionality
Michal 'vorner' Vaner <vorner@ucw.cz>
parents:
1291
diff
changeset
|
314 |
glob_muccol = type; |
382ec54b584e
Muc nick coloring functionality
Michal 'vorner' Vaner <vorner@ucw.cz>
parents:
1291
diff
changeset
|
315 |
g_free(muclow); |
382ec54b584e
Muc nick coloring functionality
Michal 'vorner' Vaner <vorner@ucw.cz>
parents:
1291
diff
changeset
|
316 |
} |
382ec54b584e
Muc nick coloring functionality
Michal 'vorner' Vaner <vorner@ucw.cz>
parents:
1291
diff
changeset
|
317 |
} |
1729
e6e89b1d7831
Minor style and header updates
Mikael Berthe <mikael@lilotux.net>
parents:
1710
diff
changeset
|
318 |
// Need to redraw? |
1333
e30a9d907105
Minor coding style adjustments
Mikael Berthe <mikael@lilotux.net>
parents:
1314
diff
changeset
|
319 |
if (chatmode && |
e30a9d907105
Minor coding style adjustments
Mikael Berthe <mikael@lilotux.net>
parents:
1314
diff
changeset
|
320 |
((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
|
321 |
scr_update_buddy_window(); |
1292
382ec54b584e
Muc nick coloring functionality
Michal 'vorner' Vaner <vorner@ucw.cz>
parents:
1291
diff
changeset
|
322 |
} |
382ec54b584e
Muc nick coloring functionality
Michal 'vorner' Vaner <vorner@ucw.cz>
parents:
1291
diff
changeset
|
323 |
|
382ec54b584e
Muc nick coloring functionality
Michal 'vorner' Vaner <vorner@ucw.cz>
parents:
1291
diff
changeset
|
324 |
// Sets the color for nick in MUC |
382ec54b584e
Muc nick coloring functionality
Michal 'vorner' Vaner <vorner@ucw.cz>
parents:
1291
diff
changeset
|
325 |
// 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
|
326 |
// 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
|
327 |
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
|
328 |
{ |
1333
e30a9d907105
Minor coding style adjustments
Mikael Berthe <mikael@lilotux.net>
parents:
1314
diff
changeset
|
329 |
char *snick, *mnick; |
1381
40095d413da9
Fix compilation on OpenBSD
Mikael Berthe <mikael@lilotux.net>
parents:
1376
diff
changeset
|
330 |
bool need_update = FALSE; |
1333
e30a9d907105
Minor coding style adjustments
Mikael Berthe <mikael@lilotux.net>
parents:
1314
diff
changeset
|
331 |
snick = g_strdup_printf("<%s>", nick); |
e30a9d907105
Minor coding style adjustments
Mikael Berthe <mikael@lilotux.net>
parents:
1314
diff
changeset
|
332 |
mnick = g_strdup_printf("*%s ", nick); |
1729
e6e89b1d7831
Minor style and header updates
Mikael Berthe <mikael@lilotux.net>
parents:
1710
diff
changeset
|
333 |
if (!strcmp(color, "-")) { // Remove the color |
1292
382ec54b584e
Muc nick coloring functionality
Michal 'vorner' Vaner <vorner@ucw.cz>
parents:
1291
diff
changeset
|
334 |
if (nickcolors) { |
382ec54b584e
Muc nick coloring functionality
Michal 'vorner' Vaner <vorner@ucw.cz>
parents:
1291
diff
changeset
|
335 |
nickcolor *nc = g_hash_table_lookup(nickcolors, snick); |
1729
e6e89b1d7831
Minor style and header updates
Mikael Berthe <mikael@lilotux.net>
parents:
1710
diff
changeset
|
336 |
if (nc) { // Have this nick already |
1381
40095d413da9
Fix compilation on OpenBSD
Mikael Berthe <mikael@lilotux.net>
parents:
1376
diff
changeset
|
337 |
nc->manual = FALSE; |
1292
382ec54b584e
Muc nick coloring functionality
Michal 'vorner' Vaner <vorner@ucw.cz>
parents:
1291
diff
changeset
|
338 |
nc = g_hash_table_lookup(nickcolors, mnick); |
1729
e6e89b1d7831
Minor style and header updates
Mikael Berthe <mikael@lilotux.net>
parents:
1710
diff
changeset
|
339 |
assert(nc); // Must have both at the same time |
1381
40095d413da9
Fix compilation on OpenBSD
Mikael Berthe <mikael@lilotux.net>
parents:
1376
diff
changeset
|
340 |
nc->manual = FALSE; |
1292
382ec54b584e
Muc nick coloring functionality
Michal 'vorner' Vaner <vorner@ucw.cz>
parents:
1291
diff
changeset
|
341 |
}// Else -> no color saved, nothing to delete |
382ec54b584e
Muc nick coloring functionality
Michal 'vorner' Vaner <vorner@ucw.cz>
parents:
1291
diff
changeset
|
342 |
} |
1729
e6e89b1d7831
Minor style and header updates
Mikael Berthe <mikael@lilotux.net>
parents:
1710
diff
changeset
|
343 |
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
|
344 |
g_free(mnick); |
1381
40095d413da9
Fix compilation on OpenBSD
Mikael Berthe <mikael@lilotux.net>
parents:
1376
diff
changeset
|
345 |
need_update = TRUE; |
1292
382ec54b584e
Muc nick coloring functionality
Michal 'vorner' Vaner <vorner@ucw.cz>
parents:
1291
diff
changeset
|
346 |
} else { |
1598 | 347 |
ccolor *cl = get_user_color(color); |
1489
e9c71ce96dca
Fixed the colorhandling for mucnicks and /color roster
franky@veqlargh.fs
parents:
1488
diff
changeset
|
348 |
if (!cl) { |
1292
382ec54b584e
Muc nick coloring functionality
Michal 'vorner' Vaner <vorner@ucw.cz>
parents:
1291
diff
changeset
|
349 |
scr_LogPrint(LPRINT_NORMAL, "No such color name"); |
382ec54b584e
Muc nick coloring functionality
Michal 'vorner' Vaner <vorner@ucw.cz>
parents:
1291
diff
changeset
|
350 |
g_free(snick); |
382ec54b584e
Muc nick coloring functionality
Michal 'vorner' Vaner <vorner@ucw.cz>
parents:
1291
diff
changeset
|
351 |
g_free(mnick); |
382ec54b584e
Muc nick coloring functionality
Michal 'vorner' Vaner <vorner@ucw.cz>
parents:
1291
diff
changeset
|
352 |
} else { |
382ec54b584e
Muc nick coloring functionality
Michal 'vorner' Vaner <vorner@ucw.cz>
parents:
1291
diff
changeset
|
353 |
nickcolor *nc = g_new(nickcolor, 1); |
382ec54b584e
Muc nick coloring functionality
Michal 'vorner' Vaner <vorner@ucw.cz>
parents:
1291
diff
changeset
|
354 |
ensure_string_htable(&nickcolors, NULL); |
1381
40095d413da9
Fix compilation on OpenBSD
Mikael Berthe <mikael@lilotux.net>
parents:
1376
diff
changeset
|
355 |
nc->manual = TRUE; |
1292
382ec54b584e
Muc nick coloring functionality
Michal 'vorner' Vaner <vorner@ucw.cz>
parents:
1291
diff
changeset
|
356 |
nc->color = cl; |
1729
e6e89b1d7831
Minor style and header updates
Mikael Berthe <mikael@lilotux.net>
parents:
1710
diff
changeset
|
357 |
// Free the struct, if any there already |
2264
44bb9a033407
Revert patch c1eb68306520
Mikael Berthe <mikael@lilotux.net>
parents:
2231
diff
changeset
|
358 |
g_free(g_hash_table_lookup(nickcolors, mnick)); |
1729
e6e89b1d7831
Minor style and header updates
Mikael Berthe <mikael@lilotux.net>
parents:
1710
diff
changeset
|
359 |
// Save the new ones |
1292
382ec54b584e
Muc nick coloring functionality
Michal 'vorner' Vaner <vorner@ucw.cz>
parents:
1291
diff
changeset
|
360 |
g_hash_table_replace(nickcolors, mnick, nc); |
382ec54b584e
Muc nick coloring functionality
Michal 'vorner' Vaner <vorner@ucw.cz>
parents:
1291
diff
changeset
|
361 |
g_hash_table_replace(nickcolors, snick, nc); |
1381
40095d413da9
Fix compilation on OpenBSD
Mikael Berthe <mikael@lilotux.net>
parents:
1376
diff
changeset
|
362 |
need_update = TRUE; |
1292
382ec54b584e
Muc nick coloring functionality
Michal 'vorner' Vaner <vorner@ucw.cz>
parents:
1291
diff
changeset
|
363 |
} |
382ec54b584e
Muc nick coloring functionality
Michal 'vorner' Vaner <vorner@ucw.cz>
parents:
1291
diff
changeset
|
364 |
} |
382ec54b584e
Muc nick coloring functionality
Michal 'vorner' Vaner <vorner@ucw.cz>
parents:
1291
diff
changeset
|
365 |
if (need_update && chatmode && |
382ec54b584e
Muc nick coloring functionality
Michal 'vorner' Vaner <vorner@ucw.cz>
parents:
1291
diff
changeset
|
366 |
(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
|
367 |
scr_update_buddy_window(); |
1292
382ec54b584e
Muc nick coloring functionality
Michal 'vorner' Vaner <vorner@ucw.cz>
parents:
1291
diff
changeset
|
368 |
} |
382ec54b584e
Muc nick coloring functionality
Michal 'vorner' Vaner <vorner@ucw.cz>
parents:
1291
diff
changeset
|
369 |
|
1272
033576acac4c
Add configurable roster colors (Michal 'vorner' Vaner)
Mikael Berthe <mikael@lilotux.net>
parents:
1268
diff
changeset
|
370 |
static void free_rostercolrule(rostercolor *col) |
033576acac4c
Add configurable roster colors (Michal 'vorner' Vaner)
Mikael Berthe <mikael@lilotux.net>
parents:
1268
diff
changeset
|
371 |
{ |
033576acac4c
Add configurable roster colors (Michal 'vorner' Vaner)
Mikael Berthe <mikael@lilotux.net>
parents:
1268
diff
changeset
|
372 |
g_free(col->status); |
033576acac4c
Add configurable roster colors (Michal 'vorner' Vaner)
Mikael Berthe <mikael@lilotux.net>
parents:
1268
diff
changeset
|
373 |
g_free(col->wildcard); |
1489
e9c71ce96dca
Fixed the colorhandling for mucnicks and /color roster
franky@veqlargh.fs
parents:
1488
diff
changeset
|
374 |
g_free(col->color); |
1272
033576acac4c
Add configurable roster colors (Michal 'vorner' Vaner)
Mikael Berthe <mikael@lilotux.net>
parents:
1268
diff
changeset
|
375 |
g_pattern_spec_free(col->compiled); |
033576acac4c
Add configurable roster colors (Michal 'vorner' Vaner)
Mikael Berthe <mikael@lilotux.net>
parents:
1268
diff
changeset
|
376 |
g_free(col); |
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 |
// Removes all roster coloring rules |
1780
e4378fbab5d7
Major API cleanup - bump API to 4
Mikael Berthe <mikael@lilotux.net>
parents:
1761
diff
changeset
|
380 |
void scr_roster_clear_color(void) |
1272
033576acac4c
Add configurable roster colors (Michal 'vorner' Vaner)
Mikael Berthe <mikael@lilotux.net>
parents:
1268
diff
changeset
|
381 |
{ |
033576acac4c
Add configurable roster colors (Michal 'vorner' Vaner)
Mikael Berthe <mikael@lilotux.net>
parents:
1268
diff
changeset
|
382 |
GSList *head; |
033576acac4c
Add configurable roster colors (Michal 'vorner' Vaner)
Mikael Berthe <mikael@lilotux.net>
parents:
1268
diff
changeset
|
383 |
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
|
384 |
free_rostercolrule(head->data); |
033576acac4c
Add configurable roster colors (Michal 'vorner' Vaner)
Mikael Berthe <mikael@lilotux.net>
parents:
1268
diff
changeset
|
385 |
} |
033576acac4c
Add configurable roster colors (Michal 'vorner' Vaner)
Mikael Berthe <mikael@lilotux.net>
parents:
1268
diff
changeset
|
386 |
g_slist_free(rostercolrules); |
033576acac4c
Add configurable roster colors (Michal 'vorner' Vaner)
Mikael Berthe <mikael@lilotux.net>
parents:
1268
diff
changeset
|
387 |
rostercolrules = NULL; |
2292
f181418db215
Replace global variable update_roster with scr_update_roster()
franky
parents:
2291
diff
changeset
|
388 |
scr_update_roster(); |
1272
033576acac4c
Add configurable roster colors (Michal 'vorner' Vaner)
Mikael Berthe <mikael@lilotux.net>
parents:
1268
diff
changeset
|
389 |
} |
033576acac4c
Add configurable roster colors (Michal 'vorner' Vaner)
Mikael Berthe <mikael@lilotux.net>
parents:
1268
diff
changeset
|
390 |
|
1284 | 391 |
// Adds, modifies or removes roster coloring rule |
392 |
// color set to "-" removes the rule, |
|
393 |
// otherwise it is modified (if exists) or added |
|
394 |
// |
|
395 |
// Returns weather it was successfull (therefore the roster should be |
|
396 |
// redrawed) or not. If it failed, for example because of invalid color |
|
397 |
// name, it also prints the error. |
|
1780
e4378fbab5d7
Major API cleanup - bump API to 4
Mikael Berthe <mikael@lilotux.net>
parents:
1761
diff
changeset
|
398 |
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
|
399 |
const char *color) |
1272
033576acac4c
Add configurable roster colors (Michal 'vorner' Vaner)
Mikael Berthe <mikael@lilotux.net>
parents:
1268
diff
changeset
|
400 |
{ |
033576acac4c
Add configurable roster colors (Michal 'vorner' Vaner)
Mikael Berthe <mikael@lilotux.net>
parents:
1268
diff
changeset
|
401 |
GSList *head; |
033576acac4c
Add configurable roster colors (Michal 'vorner' Vaner)
Mikael Berthe <mikael@lilotux.net>
parents:
1268
diff
changeset
|
402 |
GSList *found = NULL; |
033576acac4c
Add configurable roster colors (Michal 'vorner' Vaner)
Mikael Berthe <mikael@lilotux.net>
parents:
1268
diff
changeset
|
403 |
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
|
404 |
rostercolor *rc = head->data; |
033576acac4c
Add configurable roster colors (Michal 'vorner' Vaner)
Mikael Berthe <mikael@lilotux.net>
parents:
1268
diff
changeset
|
405 |
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
|
406 |
found = head; |
033576acac4c
Add configurable roster colors (Michal 'vorner' Vaner)
Mikael Berthe <mikael@lilotux.net>
parents:
1268
diff
changeset
|
407 |
break; |
033576acac4c
Add configurable roster colors (Michal 'vorner' Vaner)
Mikael Berthe <mikael@lilotux.net>
parents:
1268
diff
changeset
|
408 |
} |
033576acac4c
Add configurable roster colors (Michal 'vorner' Vaner)
Mikael Berthe <mikael@lilotux.net>
parents:
1268
diff
changeset
|
409 |
} |
1729
e6e89b1d7831
Minor style and header updates
Mikael Berthe <mikael@lilotux.net>
parents:
1710
diff
changeset
|
410 |
if (!strcmp(color,"-")) { // Delete the rule |
1272
033576acac4c
Add configurable roster colors (Michal 'vorner' Vaner)
Mikael Berthe <mikael@lilotux.net>
parents:
1268
diff
changeset
|
411 |
if (found) { |
033576acac4c
Add configurable roster colors (Michal 'vorner' Vaner)
Mikael Berthe <mikael@lilotux.net>
parents:
1268
diff
changeset
|
412 |
free_rostercolrule(found->data); |
033576acac4c
Add configurable roster colors (Michal 'vorner' Vaner)
Mikael Berthe <mikael@lilotux.net>
parents:
1268
diff
changeset
|
413 |
rostercolrules = g_slist_delete_link(rostercolrules, found); |
2292
f181418db215
Replace global variable update_roster with scr_update_roster()
franky
parents:
2291
diff
changeset
|
414 |
scr_update_roster(); |
1272
033576acac4c
Add configurable roster colors (Michal 'vorner' Vaner)
Mikael Berthe <mikael@lilotux.net>
parents:
1268
diff
changeset
|
415 |
return TRUE; |
033576acac4c
Add configurable roster colors (Michal 'vorner' Vaner)
Mikael Berthe <mikael@lilotux.net>
parents:
1268
diff
changeset
|
416 |
} else { |
033576acac4c
Add configurable roster colors (Michal 'vorner' Vaner)
Mikael Berthe <mikael@lilotux.net>
parents:
1268
diff
changeset
|
417 |
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
|
418 |
return FALSE; |
033576acac4c
Add configurable roster colors (Michal 'vorner' Vaner)
Mikael Berthe <mikael@lilotux.net>
parents:
1268
diff
changeset
|
419 |
} |
033576acac4c
Add configurable roster colors (Michal 'vorner' Vaner)
Mikael Berthe <mikael@lilotux.net>
parents:
1268
diff
changeset
|
420 |
} else { |
1598 | 421 |
ccolor *cl = get_user_color(color); |
1489
e9c71ce96dca
Fixed the colorhandling for mucnicks and /color roster
franky@veqlargh.fs
parents:
1488
diff
changeset
|
422 |
if (!cl) { |
1272
033576acac4c
Add configurable roster colors (Michal 'vorner' Vaner)
Mikael Berthe <mikael@lilotux.net>
parents:
1268
diff
changeset
|
423 |
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
|
424 |
return FALSE; |
033576acac4c
Add configurable roster colors (Michal 'vorner' Vaner)
Mikael Berthe <mikael@lilotux.net>
parents:
1268
diff
changeset
|
425 |
} |
033576acac4c
Add configurable roster colors (Michal 'vorner' Vaner)
Mikael Berthe <mikael@lilotux.net>
parents:
1268
diff
changeset
|
426 |
if (found) { |
033576acac4c
Add configurable roster colors (Michal 'vorner' Vaner)
Mikael Berthe <mikael@lilotux.net>
parents:
1268
diff
changeset
|
427 |
rostercolor *rc = found->data; |
2264
44bb9a033407
Revert patch c1eb68306520
Mikael Berthe <mikael@lilotux.net>
parents:
2231
diff
changeset
|
428 |
g_free(rc->color); |
1272
033576acac4c
Add configurable roster colors (Michal 'vorner' Vaner)
Mikael Berthe <mikael@lilotux.net>
parents:
1268
diff
changeset
|
429 |
rc->color = cl; |
033576acac4c
Add configurable roster colors (Michal 'vorner' Vaner)
Mikael Berthe <mikael@lilotux.net>
parents:
1268
diff
changeset
|
430 |
} else { |
033576acac4c
Add configurable roster colors (Michal 'vorner' Vaner)
Mikael Berthe <mikael@lilotux.net>
parents:
1268
diff
changeset
|
431 |
rostercolor *rc = g_new(rostercolor, 1); |
033576acac4c
Add configurable roster colors (Michal 'vorner' Vaner)
Mikael Berthe <mikael@lilotux.net>
parents:
1268
diff
changeset
|
432 |
rc->status = g_strdup(status); |
033576acac4c
Add configurable roster colors (Michal 'vorner' Vaner)
Mikael Berthe <mikael@lilotux.net>
parents:
1268
diff
changeset
|
433 |
rc->wildcard = g_strdup(wildcard); |
033576acac4c
Add configurable roster colors (Michal 'vorner' Vaner)
Mikael Berthe <mikael@lilotux.net>
parents:
1268
diff
changeset
|
434 |
rc->compiled = g_pattern_spec_new(wildcard); |
033576acac4c
Add configurable roster colors (Michal 'vorner' Vaner)
Mikael Berthe <mikael@lilotux.net>
parents:
1268
diff
changeset
|
435 |
rc->color = cl; |
033576acac4c
Add configurable roster colors (Michal 'vorner' Vaner)
Mikael Berthe <mikael@lilotux.net>
parents:
1268
diff
changeset
|
436 |
rostercolrules = g_slist_prepend(rostercolrules, rc); |
033576acac4c
Add configurable roster colors (Michal 'vorner' Vaner)
Mikael Berthe <mikael@lilotux.net>
parents:
1268
diff
changeset
|
437 |
} |
2292
f181418db215
Replace global variable update_roster with scr_update_roster()
franky
parents:
2291
diff
changeset
|
438 |
scr_update_roster(); |
1272
033576acac4c
Add configurable roster colors (Michal 'vorner' Vaner)
Mikael Berthe <mikael@lilotux.net>
parents:
1268
diff
changeset
|
439 |
return TRUE; |
033576acac4c
Add configurable roster colors (Michal 'vorner' Vaner)
Mikael Berthe <mikael@lilotux.net>
parents:
1268
diff
changeset
|
440 |
} |
033576acac4c
Add configurable roster colors (Michal 'vorner' Vaner)
Mikael Berthe <mikael@lilotux.net>
parents:
1268
diff
changeset
|
441 |
} |
033576acac4c
Add configurable roster colors (Michal 'vorner' Vaner)
Mikael Berthe <mikael@lilotux.net>
parents:
1268
diff
changeset
|
442 |
|
1780
e4378fbab5d7
Major API cleanup - bump API to 4
Mikael Berthe <mikael@lilotux.net>
parents:
1761
diff
changeset
|
443 |
static void parse_colors(void) |
24 | 444 |
{ |
739
0d5fb1d9077c
Allow "bright" text colors
Mikael Berthe <mikael@lilotux.net>
parents:
735
diff
changeset
|
445 |
const char *colors[] = { |
24 | 446 |
"", "", |
267 | 447 |
"general", |
785
7e0562e3bc83
Replace color_highlight with color_msgout
Mikael Berthe <mikael@lilotux.net>
parents:
779
diff
changeset
|
448 |
"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
|
449 |
"msghl", |
711 | 450 |
"status", |
2028
7b5bd6ad83b4
Add 'color_log' (text color in the log window)
Mikael Berthe <mikael@lilotux.net>
parents:
2015
diff
changeset
|
451 |
"log", |
712 | 452 |
"roster", |
453 |
"rostersel", |
|
723
23068490d063
Add text color when the selected buddy has an unread message
Mikael Berthe <mikael@lilotux.net>
parents:
721
diff
changeset
|
454 |
"rosterselmsg", |
712 | 455 |
"rosternewmsg", |
1268
dbc907b2d92f
Add configurable colors for info and incoming messages (Michal 'vorner' Vaner)
Mikael Berthe <mikael@lilotux.net>
parents:
1254
diff
changeset
|
456 |
"info", |
dbc907b2d92f
Add configurable colors for info and incoming messages (Michal 'vorner' Vaner)
Mikael Berthe <mikael@lilotux.net>
parents:
1254
diff
changeset
|
457 |
"msgin", |
1960 | 458 |
"readmark", |
2090
16b04d64ec88
Add option to highlight timestamp added by server.
Hermitifier
parents:
2074
diff
changeset
|
459 |
"timestamp", |
24 | 460 |
NULL |
461 |
}; |
|
462 |
||
281
f562b9af2de7
Add "const" specifier in prototypes
Mikael Berthe <mikael@lilotux.net>
parents:
279
diff
changeset
|
463 |
const char *color; |
f562b9af2de7
Add "const" specifier in prototypes
Mikael Berthe <mikael@lilotux.net>
parents:
279
diff
changeset
|
464 |
const char *background = settings_opt_get("color_background"); |
712 | 465 |
const char *backselected = settings_opt_get("color_bgrostersel"); |
466 |
const char *backstatus = settings_opt_get("color_bgstatus"); |
|
739
0d5fb1d9077c
Allow "bright" text colors
Mikael Berthe <mikael@lilotux.net>
parents:
735
diff
changeset
|
467 |
char *tmp; |
0d5fb1d9077c
Allow "bright" text colors
Mikael Berthe <mikael@lilotux.net>
parents:
735
diff
changeset
|
468 |
int i; |
0d5fb1d9077c
Allow "bright" text colors
Mikael Berthe <mikael@lilotux.net>
parents:
735
diff
changeset
|
469 |
|
0d5fb1d9077c
Allow "bright" text colors
Mikael Berthe <mikael@lilotux.net>
parents:
735
diff
changeset
|
470 |
// Initialize color attributes |
0d5fb1d9077c
Allow "bright" text colors
Mikael Berthe <mikael@lilotux.net>
parents:
735
diff
changeset
|
471 |
memset(COLOR_ATTRIB, 0, sizeof(COLOR_ATTRIB)); |
24 | 472 |
|
267 | 473 |
// Default values |
711 | 474 |
if (!background) background = "black"; |
267 | 475 |
if (!backselected) backselected = "cyan"; |
711 | 476 |
if (!backstatus) backstatus = "blue"; |
267 | 477 |
|
739
0d5fb1d9077c
Allow "bright" text colors
Mikael Berthe <mikael@lilotux.net>
parents:
735
diff
changeset
|
478 |
for (i=0; colors[i]; i++) { |
0d5fb1d9077c
Allow "bright" text colors
Mikael Berthe <mikael@lilotux.net>
parents:
735
diff
changeset
|
479 |
tmp = g_strdup_printf("color_%s", colors[i]); |
279
f5dd437c057b
Rewrite the settings system
Mikael Berthe <mikael@lilotux.net>
parents:
276
diff
changeset
|
480 |
color = settings_opt_get(tmp); |
739
0d5fb1d9077c
Allow "bright" text colors
Mikael Berthe <mikael@lilotux.net>
parents:
735
diff
changeset
|
481 |
g_free(tmp); |
0d5fb1d9077c
Allow "bright" text colors
Mikael Berthe <mikael@lilotux.net>
parents:
735
diff
changeset
|
482 |
|
0d5fb1d9077c
Allow "bright" text colors
Mikael Berthe <mikael@lilotux.net>
parents:
735
diff
changeset
|
483 |
if (color) { |
0d5fb1d9077c
Allow "bright" text colors
Mikael Berthe <mikael@lilotux.net>
parents:
735
diff
changeset
|
484 |
if (!strncmp(color, "bright", 6)) { |
0d5fb1d9077c
Allow "bright" text colors
Mikael Berthe <mikael@lilotux.net>
parents:
735
diff
changeset
|
485 |
COLOR_ATTRIB[i+1] = A_BOLD; |
0d5fb1d9077c
Allow "bright" text colors
Mikael Berthe <mikael@lilotux.net>
parents:
735
diff
changeset
|
486 |
color += 6; |
0d5fb1d9077c
Allow "bright" text colors
Mikael Berthe <mikael@lilotux.net>
parents:
735
diff
changeset
|
487 |
} |
0d5fb1d9077c
Allow "bright" text colors
Mikael Berthe <mikael@lilotux.net>
parents:
735
diff
changeset
|
488 |
} |
24 | 489 |
|
490 |
switch (i + 1) { |
|
739
0d5fb1d9077c
Allow "bright" text colors
Mikael Berthe <mikael@lilotux.net>
parents:
735
diff
changeset
|
491 |
case 1: |
0d5fb1d9077c
Allow "bright" text colors
Mikael Berthe <mikael@lilotux.net>
parents:
735
diff
changeset
|
492 |
init_pair(1, COLOR_BLACK, COLOR_WHITE); |
0d5fb1d9077c
Allow "bright" text colors
Mikael Berthe <mikael@lilotux.net>
parents:
735
diff
changeset
|
493 |
break; |
0d5fb1d9077c
Allow "bright" text colors
Mikael Berthe <mikael@lilotux.net>
parents:
735
diff
changeset
|
494 |
case 2: |
0d5fb1d9077c
Allow "bright" text colors
Mikael Berthe <mikael@lilotux.net>
parents:
735
diff
changeset
|
495 |
init_pair(2, COLOR_WHITE, COLOR_BLACK); |
0d5fb1d9077c
Allow "bright" text colors
Mikael Berthe <mikael@lilotux.net>
parents:
735
diff
changeset
|
496 |
break; |
0d5fb1d9077c
Allow "bright" text colors
Mikael Berthe <mikael@lilotux.net>
parents:
735
diff
changeset
|
497 |
case COLOR_GENERAL: |
1780
e4378fbab5d7
Major API cleanup - bump API to 4
Mikael Berthe <mikael@lilotux.net>
parents:
1761
diff
changeset
|
498 |
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
|
499 |
find_color(background)); |
739
0d5fb1d9077c
Allow "bright" text colors
Mikael Berthe <mikael@lilotux.net>
parents:
735
diff
changeset
|
500 |
break; |
785
7e0562e3bc83
Replace color_highlight with color_msgout
Mikael Berthe <mikael@lilotux.net>
parents:
779
diff
changeset
|
501 |
case COLOR_MSGOUT: |
1780
e4378fbab5d7
Major API cleanup - bump API to 4
Mikael Berthe <mikael@lilotux.net>
parents:
1761
diff
changeset
|
502 |
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
|
503 |
find_color(background)); |
739
0d5fb1d9077c
Allow "bright" text colors
Mikael Berthe <mikael@lilotux.net>
parents:
735
diff
changeset
|
504 |
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
|
505 |
case COLOR_MSGHL: |
1780
e4378fbab5d7
Major API cleanup - bump API to 4
Mikael Berthe <mikael@lilotux.net>
parents:
1761
diff
changeset
|
506 |
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
|
507 |
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
|
508 |
break; |
739
0d5fb1d9077c
Allow "bright" text colors
Mikael Berthe <mikael@lilotux.net>
parents:
735
diff
changeset
|
509 |
case COLOR_STATUS: |
1780
e4378fbab5d7
Major API cleanup - bump API to 4
Mikael Berthe <mikael@lilotux.net>
parents:
1761
diff
changeset
|
510 |
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
|
511 |
find_color(backstatus)); |
739
0d5fb1d9077c
Allow "bright" text colors
Mikael Berthe <mikael@lilotux.net>
parents:
735
diff
changeset
|
512 |
break; |
2028
7b5bd6ad83b4
Add 'color_log' (text color in the log window)
Mikael Berthe <mikael@lilotux.net>
parents:
2015
diff
changeset
|
513 |
case COLOR_LOG: |
7b5bd6ad83b4
Add 'color_log' (text color in the log window)
Mikael Berthe <mikael@lilotux.net>
parents:
2015
diff
changeset
|
514 |
init_pair(i+1, ((color) ? find_color(color) : COLOR_WHITE), |
7b5bd6ad83b4
Add 'color_log' (text color in the log window)
Mikael Berthe <mikael@lilotux.net>
parents:
2015
diff
changeset
|
515 |
find_color(background)); |
7b5bd6ad83b4
Add 'color_log' (text color in the log window)
Mikael Berthe <mikael@lilotux.net>
parents:
2015
diff
changeset
|
516 |
break; |
739
0d5fb1d9077c
Allow "bright" text colors
Mikael Berthe <mikael@lilotux.net>
parents:
735
diff
changeset
|
517 |
case COLOR_ROSTER: |
1780
e4378fbab5d7
Major API cleanup - bump API to 4
Mikael Berthe <mikael@lilotux.net>
parents:
1761
diff
changeset
|
518 |
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
|
519 |
find_color(background)); |
739
0d5fb1d9077c
Allow "bright" text colors
Mikael Berthe <mikael@lilotux.net>
parents:
735
diff
changeset
|
520 |
break; |
0d5fb1d9077c
Allow "bright" text colors
Mikael Berthe <mikael@lilotux.net>
parents:
735
diff
changeset
|
521 |
case COLOR_ROSTERSEL: |
1780
e4378fbab5d7
Major API cleanup - bump API to 4
Mikael Berthe <mikael@lilotux.net>
parents:
1761
diff
changeset
|
522 |
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
|
523 |
find_color(backselected)); |
739
0d5fb1d9077c
Allow "bright" text colors
Mikael Berthe <mikael@lilotux.net>
parents:
735
diff
changeset
|
524 |
break; |
0d5fb1d9077c
Allow "bright" text colors
Mikael Berthe <mikael@lilotux.net>
parents:
735
diff
changeset
|
525 |
case COLOR_ROSTERSELNMSG: |
1780
e4378fbab5d7
Major API cleanup - bump API to 4
Mikael Berthe <mikael@lilotux.net>
parents:
1761
diff
changeset
|
526 |
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
|
527 |
find_color(backselected)); |
739
0d5fb1d9077c
Allow "bright" text colors
Mikael Berthe <mikael@lilotux.net>
parents:
735
diff
changeset
|
528 |
break; |
0d5fb1d9077c
Allow "bright" text colors
Mikael Berthe <mikael@lilotux.net>
parents:
735
diff
changeset
|
529 |
case COLOR_ROSTERNMSG: |
1780
e4378fbab5d7
Major API cleanup - bump API to 4
Mikael Berthe <mikael@lilotux.net>
parents:
1761
diff
changeset
|
530 |
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
|
531 |
find_color(background)); |
739
0d5fb1d9077c
Allow "bright" text colors
Mikael Berthe <mikael@lilotux.net>
parents:
735
diff
changeset
|
532 |
break; |
1268
dbc907b2d92f
Add configurable colors for info and incoming messages (Michal 'vorner' Vaner)
Mikael Berthe <mikael@lilotux.net>
parents:
1254
diff
changeset
|
533 |
case COLOR_INFO: |
1780
e4378fbab5d7
Major API cleanup - bump API to 4
Mikael Berthe <mikael@lilotux.net>
parents:
1761
diff
changeset
|
534 |
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
|
535 |
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
|
536 |
break; |
dbc907b2d92f
Add configurable colors for info and incoming messages (Michal 'vorner' Vaner)
Mikael Berthe <mikael@lilotux.net>
parents:
1254
diff
changeset
|
537 |
case COLOR_MSGIN: |
1780
e4378fbab5d7
Major API cleanup - bump API to 4
Mikael Berthe <mikael@lilotux.net>
parents:
1761
diff
changeset
|
538 |
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
|
539 |
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
|
540 |
break; |
1960 | 541 |
case COLOR_READMARK: |
542 |
init_pair(i+1, ((color) ? find_color(color) : COLOR_RED), |
|
543 |
find_color(background)); |
|
544 |
break; |
|
2090
16b04d64ec88
Add option to highlight timestamp added by server.
Hermitifier
parents:
2074
diff
changeset
|
545 |
case COLOR_TIMESTAMP: |
16b04d64ec88
Add option to highlight timestamp added by server.
Hermitifier
parents:
2074
diff
changeset
|
546 |
init_pair(i+1, ((color) ? find_color(color) : COLOR_WHITE), |
16b04d64ec88
Add option to highlight timestamp added by server.
Hermitifier
parents:
2074
diff
changeset
|
547 |
find_color(background)); |
16b04d64ec88
Add option to highlight timestamp added by server.
Hermitifier
parents:
2074
diff
changeset
|
548 |
break; |
24 | 549 |
} |
550 |
} |
|
1489
e9c71ce96dca
Fixed the colorhandling for mucnicks and /color roster
franky@veqlargh.fs
parents:
1488
diff
changeset
|
551 |
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
|
552 |
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
|
553 |
|
1298
af035a304bec
colorable muc nick fix
Michal 'vorner' Vaner <vorner@ucw.cz>
parents:
1296
diff
changeset
|
554 |
if (!nickcols) { |
1314
248e3f69dd9e
Fix a bug in the nick_colors variable parsing
Mikael Berthe <mikael@lilotux.net>
parents:
1311
diff
changeset
|
555 |
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
|
556 |
if (ncolors) { |
1314
248e3f69dd9e
Fix a bug in the nick_colors variable parsing
Mikael Berthe <mikael@lilotux.net>
parents:
1311
diff
changeset
|
557 |
char *ncolor_start, *ncolor_end; |
248e3f69dd9e
Fix a bug in the nick_colors variable parsing
Mikael Berthe <mikael@lilotux.net>
parents:
1311
diff
changeset
|
558 |
ncolor_start = ncolor_end = ncolors; |
248e3f69dd9e
Fix a bug in the nick_colors variable parsing
Mikael Berthe <mikael@lilotux.net>
parents:
1311
diff
changeset
|
559 |
|
248e3f69dd9e
Fix a bug in the nick_colors variable parsing
Mikael Berthe <mikael@lilotux.net>
parents:
1311
diff
changeset
|
560 |
while (*ncolor_end) |
248e3f69dd9e
Fix a bug in the nick_colors variable parsing
Mikael Berthe <mikael@lilotux.net>
parents:
1311
diff
changeset
|
561 |
ncolor_end++; |
248e3f69dd9e
Fix a bug in the nick_colors variable parsing
Mikael Berthe <mikael@lilotux.net>
parents:
1311
diff
changeset
|
562 |
|
248e3f69dd9e
Fix a bug in the nick_colors variable parsing
Mikael Berthe <mikael@lilotux.net>
parents:
1311
diff
changeset
|
563 |
while (ncolors < ncolor_end && *ncolors) { |
1298
af035a304bec
colorable muc nick fix
Michal 'vorner' Vaner <vorner@ucw.cz>
parents:
1296
diff
changeset
|
564 |
if ((*ncolors == ' ') || (*ncolors == '\t')) { |
1314
248e3f69dd9e
Fix a bug in the nick_colors variable parsing
Mikael Berthe <mikael@lilotux.net>
parents:
1311
diff
changeset
|
565 |
ncolors++; |
1292
382ec54b584e
Muc nick coloring functionality
Michal 'vorner' Vaner <vorner@ucw.cz>
parents:
1291
diff
changeset
|
566 |
} else { |
1298
af035a304bec
colorable muc nick fix
Michal 'vorner' Vaner <vorner@ucw.cz>
parents:
1296
diff
changeset
|
567 |
char *end = ncolors; |
1598 | 568 |
ccolor *cl; |
1298
af035a304bec
colorable muc nick fix
Michal 'vorner' Vaner <vorner@ucw.cz>
parents:
1296
diff
changeset
|
569 |
while (*end && (*end != ' ') && (*end != '\t')) |
af035a304bec
colorable muc nick fix
Michal 'vorner' Vaner <vorner@ucw.cz>
parents:
1296
diff
changeset
|
570 |
end++; |
af035a304bec
colorable muc nick fix
Michal 'vorner' Vaner <vorner@ucw.cz>
parents:
1296
diff
changeset
|
571 |
*end = '\0'; |
1314
248e3f69dd9e
Fix a bug in the nick_colors variable parsing
Mikael Berthe <mikael@lilotux.net>
parents:
1311
diff
changeset
|
572 |
cl = get_user_color(ncolors); |
1489
e9c71ce96dca
Fixed the colorhandling for mucnicks and /color roster
franky@veqlargh.fs
parents:
1488
diff
changeset
|
573 |
if (!cl) { |
1298
af035a304bec
colorable muc nick fix
Michal 'vorner' Vaner <vorner@ucw.cz>
parents:
1296
diff
changeset
|
574 |
scr_LogPrint(LPRINT_NORMAL, "Unknown color %s", ncolors); |
af035a304bec
colorable muc nick fix
Michal 'vorner' Vaner <vorner@ucw.cz>
parents:
1296
diff
changeset
|
575 |
} else { |
af035a304bec
colorable muc nick fix
Michal 'vorner' Vaner <vorner@ucw.cz>
parents:
1296
diff
changeset
|
576 |
nickcols = g_realloc(nickcols, (++nickcolcount) * sizeof *nickcols); |
af035a304bec
colorable muc nick fix
Michal 'vorner' Vaner <vorner@ucw.cz>
parents:
1296
diff
changeset
|
577 |
nickcols[nickcolcount-1] = cl; |
af035a304bec
colorable muc nick fix
Michal 'vorner' Vaner <vorner@ucw.cz>
parents:
1296
diff
changeset
|
578 |
} |
1314
248e3f69dd9e
Fix a bug in the nick_colors variable parsing
Mikael Berthe <mikael@lilotux.net>
parents:
1311
diff
changeset
|
579 |
ncolors = end+1; |
1292
382ec54b584e
Muc nick coloring functionality
Michal 'vorner' Vaner <vorner@ucw.cz>
parents:
1291
diff
changeset
|
580 |
} |
382ec54b584e
Muc nick coloring functionality
Michal 'vorner' Vaner <vorner@ucw.cz>
parents:
1291
diff
changeset
|
581 |
} |
1298
af035a304bec
colorable muc nick fix
Michal 'vorner' Vaner <vorner@ucw.cz>
parents:
1296
diff
changeset
|
582 |
g_free(ncolor_start); |
1292
382ec54b584e
Muc nick coloring functionality
Michal 'vorner' Vaner <vorner@ucw.cz>
parents:
1291
diff
changeset
|
583 |
} |
1729
e6e89b1d7831
Minor style and header updates
Mikael Berthe <mikael@lilotux.net>
parents:
1710
diff
changeset
|
584 |
if (!nickcols) { // Fallback to have something |
1298
af035a304bec
colorable muc nick fix
Michal 'vorner' Vaner <vorner@ucw.cz>
parents:
1296
diff
changeset
|
585 |
nickcolcount = 1; |
2264
44bb9a033407
Revert patch c1eb68306520
Mikael Berthe <mikael@lilotux.net>
parents:
2231
diff
changeset
|
586 |
nickcols = g_new(ccolor*, 1); |
44bb9a033407
Revert patch c1eb68306520
Mikael Berthe <mikael@lilotux.net>
parents:
2231
diff
changeset
|
587 |
*nickcols = g_new(ccolor, 1); |
1489
e9c71ce96dca
Fixed the colorhandling for mucnicks and /color roster
franky@veqlargh.fs
parents:
1488
diff
changeset
|
588 |
(*nickcols)->color_pair = COLOR_GENERAL; |
e9c71ce96dca
Fixed the colorhandling for mucnicks and /color roster
franky@veqlargh.fs
parents:
1488
diff
changeset
|
589 |
(*nickcols)->color_attrib = A_NORMAL; |
1298
af035a304bec
colorable muc nick fix
Michal 'vorner' Vaner <vorner@ucw.cz>
parents:
1296
diff
changeset
|
590 |
} |
1292
382ec54b584e
Muc nick coloring functionality
Michal 'vorner' Vaner <vorner@ucw.cz>
parents:
1291
diff
changeset
|
591 |
} |
1942
3e39a336a992
Use guards for colors (Myhailo Danylenko)
Mikael Berthe <mikael@lilotux.net>
parents:
1935
diff
changeset
|
592 |
|
3e39a336a992
Use guards for colors (Myhailo Danylenko)
Mikael Berthe <mikael@lilotux.net>
parents:
1935
diff
changeset
|
593 |
colors_stalled = FALSE; |
24 | 594 |
} |
595 |
||
765
72626e9d60bd
Create init_keycodes(), add 2 screen escape sequences
Mikael Berthe <mikael@lilotux.net>
parents:
764
diff
changeset
|
596 |
static void init_keycodes(void) |
373
af2f8ddf6a1b
Move (reorganize) functions
Mikael Berthe <mikael@lilotux.net>
parents:
370
diff
changeset
|
597 |
{ |
761
4532a9fe0e8c
Handle some keyboard escape sequences
Mikael Berthe <mikael@lilotux.net>
parents:
760
diff
changeset
|
598 |
add_keyseq("O5A", MKEY_EQUIV, 521); // Ctrl-Up |
4532a9fe0e8c
Handle some keyboard escape sequences
Mikael Berthe <mikael@lilotux.net>
parents:
760
diff
changeset
|
599 |
add_keyseq("O5B", MKEY_EQUIV, 514); // Ctrl-Down |
4532a9fe0e8c
Handle some keyboard escape sequences
Mikael Berthe <mikael@lilotux.net>
parents:
760
diff
changeset
|
600 |
add_keyseq("O5C", MKEY_EQUIV, 518); // Ctrl-Right |
4532a9fe0e8c
Handle some keyboard escape sequences
Mikael Berthe <mikael@lilotux.net>
parents:
760
diff
changeset
|
601 |
add_keyseq("O5D", MKEY_EQUIV, 516); // Ctrl-Left |
763 | 602 |
add_keyseq("O6A", MKEY_EQUIV, 520); // Shift-Up |
603 |
add_keyseq("O6B", MKEY_EQUIV, 513); // Shift-Down |
|
604 |
add_keyseq("O6C", MKEY_EQUIV, 402); // Shift-Right |
|
605 |
add_keyseq("O6D", MKEY_EQUIV, 393); // Shift-Left |
|
606 |
add_keyseq("O2A", MKEY_EQUIV, 520); // Shift-Up |
|
607 |
add_keyseq("O2B", MKEY_EQUIV, 513); // Shift-Down |
|
608 |
add_keyseq("O2C", MKEY_EQUIV, 402); // Shift-Right |
|
609 |
add_keyseq("O2D", MKEY_EQUIV, 393); // Shift-Left |
|
610 |
add_keyseq("[5^", MKEY_CTRL_PGUP, 0); // Ctrl-PageUp |
|
611 |
add_keyseq("[6^", MKEY_CTRL_PGDOWN, 0); // Ctrl-PageDown |
|
612 |
add_keyseq("[5@", MKEY_CTRL_SHIFT_PGUP, 0); // Ctrl-Shift-PageUp |
|
613 |
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
|
614 |
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
|
615 |
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
|
616 |
add_keyseq("[8^", MKEY_CTRL_END, 0); // Ctrl-End |
32d5298f9f8d
Add a few keycode sequences
Mikael Berthe <mikael@lilotux.net>
parents:
790
diff
changeset
|
617 |
add_keyseq("[7^", MKEY_CTRL_HOME, 0); // Ctrl-Home |
32d5298f9f8d
Add a few keycode sequences
Mikael Berthe <mikael@lilotux.net>
parents:
790
diff
changeset
|
618 |
add_keyseq("[2^", MKEY_CTRL_INS, 0); // Ctrl-Insert |
32d5298f9f8d
Add a few keycode sequences
Mikael Berthe <mikael@lilotux.net>
parents:
790
diff
changeset
|
619 |
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
|
620 |
|
4532a9fe0e8c
Handle some keyboard escape sequences
Mikael Berthe <mikael@lilotux.net>
parents:
760
diff
changeset
|
621 |
// Xterm |
4532a9fe0e8c
Handle some keyboard escape sequences
Mikael Berthe <mikael@lilotux.net>
parents:
760
diff
changeset
|
622 |
add_keyseq("[1;5A", MKEY_EQUIV, 521); // Ctrl-Up |
4532a9fe0e8c
Handle some keyboard escape sequences
Mikael Berthe <mikael@lilotux.net>
parents:
760
diff
changeset
|
623 |
add_keyseq("[1;5B", MKEY_EQUIV, 514); // Ctrl-Down |
4532a9fe0e8c
Handle some keyboard escape sequences
Mikael Berthe <mikael@lilotux.net>
parents:
760
diff
changeset
|
624 |
add_keyseq("[1;5C", MKEY_EQUIV, 518); // Ctrl-Right |
4532a9fe0e8c
Handle some keyboard escape sequences
Mikael Berthe <mikael@lilotux.net>
parents:
760
diff
changeset
|
625 |
add_keyseq("[1;5D", MKEY_EQUIV, 516); // Ctrl-Left |
4532a9fe0e8c
Handle some keyboard escape sequences
Mikael Berthe <mikael@lilotux.net>
parents:
760
diff
changeset
|
626 |
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
|
627 |
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
|
628 |
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
|
629 |
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
|
630 |
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
|
631 |
add_keyseq("[1;6F", MKEY_CTRL_SHIFT_END, 0); // Ctrl-Shift-End |
763 | 632 |
add_keyseq("[1;2A", MKEY_EQUIV, 521); // Shift-Up |
633 |
add_keyseq("[1;2B", MKEY_EQUIV, 514); // Shift-Down |
|
634 |
add_keyseq("[5;5~", MKEY_CTRL_PGUP, 0); // Ctrl-PageUp |
|
635 |
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
|
636 |
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
|
637 |
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
|
638 |
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
|
639 |
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
|
640 |
|
768
0f6d25a02450
Add PuTTY escape keys for Ctrl-arrows
Mikael Berthe <mikael@lilotux.net>
parents:
766
diff
changeset
|
641 |
// PuTTY |
0f6d25a02450
Add PuTTY escape keys for Ctrl-arrows
Mikael Berthe <mikael@lilotux.net>
parents:
766
diff
changeset
|
642 |
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
|
643 |
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
|
644 |
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
|
645 |
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
|
646 |
|
762
96d46e00524a
Add some key escape sequences for screen
Mikael Berthe <mikael@lilotux.net>
parents:
761
diff
changeset
|
647 |
// screen |
96d46e00524a
Add some key escape sequences for screen
Mikael Berthe <mikael@lilotux.net>
parents:
761
diff
changeset
|
648 |
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
|
649 |
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
|
650 |
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
|
651 |
add_keyseq("Od", MKEY_EQUIV, 516); // Ctrl-Left |
763 | 652 |
add_keyseq("[a", MKEY_EQUIV, 520); // Shift-Up |
653 |
add_keyseq("[b", MKEY_EQUIV, 513); // Shift-Down |
|
654 |
add_keyseq("[c", MKEY_EQUIV, 402); // Shift-Right |
|
655 |
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
|
656 |
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
|
657 |
add_keyseq("[6$", MKEY_SHIFT_PGDOWN, 0); // Shift-PageDown |
1170 | 658 |
|
659 |
// VT100 |
|
660 |
add_keyseq("[H", MKEY_EQUIV, KEY_HOME); // Home |
|
661 |
add_keyseq("[F", MKEY_EQUIV, KEY_END); // End |
|
662 |
||
663 |
// Konsole Linux |
|
664 |
add_keyseq("[1~", MKEY_EQUIV, KEY_HOME); // Home |
|
665 |
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
|
666 |
} |
72626e9d60bd
Create init_keycodes(), add 2 screen escape sequences
Mikael Berthe <mikael@lilotux.net>
parents:
764
diff
changeset
|
667 |
|
1176
547a8ca7c1a8
Move init_bindings() to screen.c, with a few updates
Mikael Berthe <mikael@lilotux.net>
parents:
1173
diff
changeset
|
668 |
// scr_init_bindings() |
547a8ca7c1a8
Move init_bindings() to screen.c, with a few updates
Mikael Berthe <mikael@lilotux.net>
parents:
1173
diff
changeset
|
669 |
// Create default key bindings |
547a8ca7c1a8
Move init_bindings() to screen.c, with a few updates
Mikael Berthe <mikael@lilotux.net>
parents:
1173
diff
changeset
|
670 |
// 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
|
671 |
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
|
672 |
{ |
547a8ca7c1a8
Move init_bindings() to screen.c, with a few updates
Mikael Berthe <mikael@lilotux.net>
parents:
1173
diff
changeset
|
673 |
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
|
674 |
|
547a8ca7c1a8
Move init_bindings() to screen.c, with a few updates
Mikael Berthe <mikael@lilotux.net>
parents:
1173
diff
changeset
|
675 |
// 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
|
676 |
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
|
677 |
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
|
678 |
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
|
679 |
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
|
680 |
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
|
681 |
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
|
682 |
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
|
683 |
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
|
684 |
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
|
685 |
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
|
686 |
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
|
687 |
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
|
688 |
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
|
689 |
"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
|
690 |
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
|
691 |
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
|
692 |
"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
|
693 |
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
|
694 |
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
|
695 |
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
|
696 |
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
|
697 |
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
|
698 |
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
|
699 |
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
|
700 |
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
|
701 |
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
|
702 |
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
|
703 |
// 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
|
704 |
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
|
705 |
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
|
706 |
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
|
707 |
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
|
708 |
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
|
709 |
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
|
710 |
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
|
711 |
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
|
712 |
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
|
713 |
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
|
714 |
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
|
715 |
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
|
716 |
// Ctrl-Left (2 codes): |
547a8ca7c1a8
Move init_bindings() to screen.c, with a few updates
Mikael Berthe <mikael@lilotux.net>
parents:
1173
diff
changeset
|
717 |
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
|
718 |
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
|
719 |
// Ctrl-Right (2 codes): |
547a8ca7c1a8
Move init_bindings() to screen.c, with a few updates
Mikael Berthe <mikael@lilotux.net>
parents:
1173
diff
changeset
|
720 |
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
|
721 |
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
|
722 |
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
|
723 |
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
|
724 |
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
|
725 |
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
|
726 |
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
|
727 |
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
|
728 |
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
|
729 |
|
1208
0dbe51d1e62e
Add default binding for F1 (265) to /help
Mikael Berthe <mikael@lilotux.net>
parents:
1205
diff
changeset
|
730 |
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
|
731 |
|
1176
547a8ca7c1a8
Move init_bindings() to screen.c, with a few updates
Mikael Berthe <mikael@lilotux.net>
parents:
1173
diff
changeset
|
732 |
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
|
733 |
} |
547a8ca7c1a8
Move init_bindings() to screen.c, with a few updates
Mikael Berthe <mikael@lilotux.net>
parents:
1173
diff
changeset
|
734 |
|
1229
e9ea1497ac9d
Fix a key binding issue on FreeBSD
Mikael Berthe <mikael@lilotux.net>
parents:
1228
diff
changeset
|
735 |
// is_speckey(key) |
e9ea1497ac9d
Fix a key binding issue on FreeBSD
Mikael Berthe <mikael@lilotux.net>
parents:
1228
diff
changeset
|
736 |
// 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
|
737 |
// 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
|
738 |
// isprint(KEY_PPAGE) returns TRUE... |
e9ea1497ac9d
Fix a key binding issue on FreeBSD
Mikael Berthe <mikael@lilotux.net>
parents:
1228
diff
changeset
|
739 |
static int is_speckey(int key) |
e9ea1497ac9d
Fix a key binding issue on FreeBSD
Mikael Berthe <mikael@lilotux.net>
parents:
1228
diff
changeset
|
740 |
{ |
e9ea1497ac9d
Fix a key binding issue on FreeBSD
Mikael Berthe <mikael@lilotux.net>
parents:
1228
diff
changeset
|
741 |
switch (key) { |
e9ea1497ac9d
Fix a key binding issue on FreeBSD
Mikael Berthe <mikael@lilotux.net>
parents:
1228
diff
changeset
|
742 |
case 127: |
e9ea1497ac9d
Fix a key binding issue on FreeBSD
Mikael Berthe <mikael@lilotux.net>
parents:
1228
diff
changeset
|
743 |
case 393: |
e9ea1497ac9d
Fix a key binding issue on FreeBSD
Mikael Berthe <mikael@lilotux.net>
parents:
1228
diff
changeset
|
744 |
case 402: |
e9ea1497ac9d
Fix a key binding issue on FreeBSD
Mikael Berthe <mikael@lilotux.net>
parents:
1228
diff
changeset
|
745 |
case KEY_BACKSPACE: |
e9ea1497ac9d
Fix a key binding issue on FreeBSD
Mikael Berthe <mikael@lilotux.net>
parents:
1228
diff
changeset
|
746 |
case KEY_DC: |
e9ea1497ac9d
Fix a key binding issue on FreeBSD
Mikael Berthe <mikael@lilotux.net>
parents:
1228
diff
changeset
|
747 |
case KEY_LEFT: |
e9ea1497ac9d
Fix a key binding issue on FreeBSD
Mikael Berthe <mikael@lilotux.net>
parents:
1228
diff
changeset
|
748 |
case KEY_RIGHT: |
e9ea1497ac9d
Fix a key binding issue on FreeBSD
Mikael Berthe <mikael@lilotux.net>
parents:
1228
diff
changeset
|
749 |
case KEY_UP: |
e9ea1497ac9d
Fix a key binding issue on FreeBSD
Mikael Berthe <mikael@lilotux.net>
parents:
1228
diff
changeset
|
750 |
case KEY_DOWN: |
e9ea1497ac9d
Fix a key binding issue on FreeBSD
Mikael Berthe <mikael@lilotux.net>
parents:
1228
diff
changeset
|
751 |
case KEY_PPAGE: |
e9ea1497ac9d
Fix a key binding issue on FreeBSD
Mikael Berthe <mikael@lilotux.net>
parents:
1228
diff
changeset
|
752 |
case KEY_NPAGE: |
e9ea1497ac9d
Fix a key binding issue on FreeBSD
Mikael Berthe <mikael@lilotux.net>
parents:
1228
diff
changeset
|
753 |
case KEY_HOME: |
e9ea1497ac9d
Fix a key binding issue on FreeBSD
Mikael Berthe <mikael@lilotux.net>
parents:
1228
diff
changeset
|
754 |
case KEY_END: |
e9ea1497ac9d
Fix a key binding issue on FreeBSD
Mikael Berthe <mikael@lilotux.net>
parents:
1228
diff
changeset
|
755 |
case KEY_EOL: |
e9ea1497ac9d
Fix a key binding issue on FreeBSD
Mikael Berthe <mikael@lilotux.net>
parents:
1228
diff
changeset
|
756 |
return TRUE; |
e9ea1497ac9d
Fix a key binding issue on FreeBSD
Mikael Berthe <mikael@lilotux.net>
parents:
1228
diff
changeset
|
757 |
} |
e9ea1497ac9d
Fix a key binding issue on FreeBSD
Mikael Berthe <mikael@lilotux.net>
parents:
1228
diff
changeset
|
758 |
|
e9ea1497ac9d
Fix a key binding issue on FreeBSD
Mikael Berthe <mikael@lilotux.net>
parents:
1228
diff
changeset
|
759 |
// Fn keys |
e9ea1497ac9d
Fix a key binding issue on FreeBSD
Mikael Berthe <mikael@lilotux.net>
parents:
1228
diff
changeset
|
760 |
if (key >= 265 && key < 265+12) |
e9ea1497ac9d
Fix a key binding issue on FreeBSD
Mikael Berthe <mikael@lilotux.net>
parents:
1228
diff
changeset
|
761 |
return TRUE; |
e9ea1497ac9d
Fix a key binding issue on FreeBSD
Mikael Berthe <mikael@lilotux.net>
parents:
1228
diff
changeset
|
762 |
|
e9ea1497ac9d
Fix a key binding issue on FreeBSD
Mikael Berthe <mikael@lilotux.net>
parents:
1228
diff
changeset
|
763 |
// Special key combinations |
e9ea1497ac9d
Fix a key binding issue on FreeBSD
Mikael Berthe <mikael@lilotux.net>
parents:
1228
diff
changeset
|
764 |
if (key >= 513 && key <= 521) |
e9ea1497ac9d
Fix a key binding issue on FreeBSD
Mikael Berthe <mikael@lilotux.net>
parents:
1228
diff
changeset
|
765 |
return TRUE; |
e9ea1497ac9d
Fix a key binding issue on FreeBSD
Mikael Berthe <mikael@lilotux.net>
parents:
1228
diff
changeset
|
766 |
|
e9ea1497ac9d
Fix a key binding issue on FreeBSD
Mikael Berthe <mikael@lilotux.net>
parents:
1228
diff
changeset
|
767 |
return FALSE; |
e9ea1497ac9d
Fix a key binding issue on FreeBSD
Mikael Berthe <mikael@lilotux.net>
parents:
1228
diff
changeset
|
768 |
} |
e9ea1497ac9d
Fix a key binding issue on FreeBSD
Mikael Berthe <mikael@lilotux.net>
parents:
1228
diff
changeset
|
769 |
|
1780
e4378fbab5d7
Major API cleanup - bump API to 4
Mikael Berthe <mikael@lilotux.net>
parents:
1761
diff
changeset
|
770 |
void scr_init_locale_charset(void) |
779
057ffe7c43dc
Initialize locale charset earlier
Mikael Berthe <mikael@lilotux.net>
parents:
773
diff
changeset
|
771 |
{ |
1651
d0a0d96ed5d5
Set all locale variables
Myhailo Danylenko <isbear@ukrpost.net>
parents:
1602
diff
changeset
|
772 |
setlocale(LC_ALL, ""); |
1382
1447c5296977
Fix locale charset detection on some BSD systems
Mikael Berthe <mikael@lilotux.net>
parents:
1381
diff
changeset
|
773 |
#ifdef HAVE_LOCALCHARSET_H |
1447c5296977
Fix locale charset detection on some BSD systems
Mikael Berthe <mikael@lilotux.net>
parents:
1381
diff
changeset
|
774 |
LocaleCharSet = locale_charset(); |
1447c5296977
Fix locale charset detection on some BSD systems
Mikael Berthe <mikael@lilotux.net>
parents:
1381
diff
changeset
|
775 |
#else |
779
057ffe7c43dc
Initialize locale charset earlier
Mikael Berthe <mikael@lilotux.net>
parents:
773
diff
changeset
|
776 |
LocaleCharSet = nl_langinfo(CODESET); |
1382
1447c5296977
Fix locale charset detection on some BSD systems
Mikael Berthe <mikael@lilotux.net>
parents:
1381
diff
changeset
|
777 |
#endif |
779
057ffe7c43dc
Initialize locale charset earlier
Mikael Berthe <mikael@lilotux.net>
parents:
773
diff
changeset
|
778 |
utf8_mode = (strcmp(LocaleCharSet, "UTF-8") == 0); |
057ffe7c43dc
Initialize locale charset earlier
Mikael Berthe <mikael@lilotux.net>
parents:
773
diff
changeset
|
779 |
} |
057ffe7c43dc
Initialize locale charset earlier
Mikael Berthe <mikael@lilotux.net>
parents:
773
diff
changeset
|
780 |
|
1780
e4378fbab5d7
Major API cleanup - bump API to 4
Mikael Berthe <mikael@lilotux.net>
parents:
1761
diff
changeset
|
781 |
gboolean scr_curses_status(void) |
1733
a9b0364c0cb2
Fix segfault introduced in previous commit
Mikael Berthe <mikael@lilotux.net>
parents:
1729
diff
changeset
|
782 |
{ |
a9b0364c0cb2
Fix segfault introduced in previous commit
Mikael Berthe <mikael@lilotux.net>
parents:
1729
diff
changeset
|
783 |
return Curses; |
a9b0364c0cb2
Fix segfault introduced in previous commit
Mikael Berthe <mikael@lilotux.net>
parents:
1729
diff
changeset
|
784 |
} |
a9b0364c0cb2
Fix segfault introduced in previous commit
Mikael Berthe <mikael@lilotux.net>
parents:
1729
diff
changeset
|
785 |
|
1942
3e39a336a992
Use guards for colors (Myhailo Danylenko)
Mikael Berthe <mikael@lilotux.net>
parents:
1935
diff
changeset
|
786 |
static gchar *scr_color_guard(const gchar *key, const gchar *new_value) |
3e39a336a992
Use guards for colors (Myhailo Danylenko)
Mikael Berthe <mikael@lilotux.net>
parents:
1935
diff
changeset
|
787 |
{ |
3e39a336a992
Use guards for colors (Myhailo Danylenko)
Mikael Berthe <mikael@lilotux.net>
parents:
1935
diff
changeset
|
788 |
if (g_strcmp0(settings_opt_get(key), new_value)) |
3e39a336a992
Use guards for colors (Myhailo Danylenko)
Mikael Berthe <mikael@lilotux.net>
parents:
1935
diff
changeset
|
789 |
colors_stalled = TRUE; |
3e39a336a992
Use guards for colors (Myhailo Danylenko)
Mikael Berthe <mikael@lilotux.net>
parents:
1935
diff
changeset
|
790 |
return g_strdup(new_value); |
3e39a336a992
Use guards for colors (Myhailo Danylenko)
Mikael Berthe <mikael@lilotux.net>
parents:
1935
diff
changeset
|
791 |
} |
3e39a336a992
Use guards for colors (Myhailo Danylenko)
Mikael Berthe <mikael@lilotux.net>
parents:
1935
diff
changeset
|
792 |
|
1780
e4378fbab5d7
Major API cleanup - bump API to 4
Mikael Berthe <mikael@lilotux.net>
parents:
1761
diff
changeset
|
793 |
void scr_init_curses(void) |
765
72626e9d60bd
Create init_keycodes(), add 2 screen escape sequences
Mikael Berthe <mikael@lilotux.net>
parents:
764
diff
changeset
|
794 |
{ |
72626e9d60bd
Create init_keycodes(), add 2 screen escape sequences
Mikael Berthe <mikael@lilotux.net>
parents:
764
diff
changeset
|
795 |
/* Key sequences initialization */ |
72626e9d60bd
Create init_keycodes(), add 2 screen escape sequences
Mikael Berthe <mikael@lilotux.net>
parents:
764
diff
changeset
|
796 |
init_keycodes(); |
762
96d46e00524a
Add some key escape sequences for screen
Mikael Berthe <mikael@lilotux.net>
parents:
761
diff
changeset
|
797 |
|
373
af2f8ddf6a1b
Move (reorganize) functions
Mikael Berthe <mikael@lilotux.net>
parents:
370
diff
changeset
|
798 |
initscr(); |
382
4c6e8392e465
Use nodelay() instead of halfdelay()
Mikael Berthe <mikael@lilotux.net>
parents:
374
diff
changeset
|
799 |
raw(); |
373
af2f8ddf6a1b
Move (reorganize) functions
Mikael Berthe <mikael@lilotux.net>
parents:
370
diff
changeset
|
800 |
noecho(); |
389
6e895f397474
Ncurses changes + Ctrl-C does not send a signal anylore
Mikael Berthe <mikael@lilotux.net>
parents:
388
diff
changeset
|
801 |
nonl(); |
6e895f397474
Ncurses changes + Ctrl-C does not send a signal anylore
Mikael Berthe <mikael@lilotux.net>
parents:
388
diff
changeset
|
802 |
intrflush(stdscr, FALSE); |
373
af2f8ddf6a1b
Move (reorganize) functions
Mikael Berthe <mikael@lilotux.net>
parents:
370
diff
changeset
|
803 |
start_color(); |
af2f8ddf6a1b
Move (reorganize) functions
Mikael Berthe <mikael@lilotux.net>
parents:
370
diff
changeset
|
804 |
use_default_colors(); |
1561 | 805 |
#ifdef NCURSES_MOUSE_VERSION |
1563 | 806 |
if (settings_opt_get_int("use_mouse")) |
807 |
mousemask(ALL_MOUSE_EVENTS, NULL); |
|
1561 | 808 |
#endif |
373
af2f8ddf6a1b
Move (reorganize) functions
Mikael Berthe <mikael@lilotux.net>
parents:
370
diff
changeset
|
809 |
|
1386 | 810 |
if (settings_opt_get("escdelay")) { |
811 |
#ifdef HAVE_ESCDELAY |
|
812 |
ESCDELAY = (unsigned) settings_opt_get_int("escdelay"); |
|
813 |
#else |
|
814 |
scr_LogPrint(LPRINT_LOGNORM, "ERROR: no ESCDELAY support."); |
|
815 |
#endif |
|
816 |
} |
|
817 |
||
1780
e4378fbab5d7
Major API cleanup - bump API to 4
Mikael Berthe <mikael@lilotux.net>
parents:
1761
diff
changeset
|
818 |
parse_colors(); |
373
af2f8ddf6a1b
Move (reorganize) functions
Mikael Berthe <mikael@lilotux.net>
parents:
370
diff
changeset
|
819 |
|
1942
3e39a336a992
Use guards for colors (Myhailo Danylenko)
Mikael Berthe <mikael@lilotux.net>
parents:
1935
diff
changeset
|
820 |
settings_set_guard("color_background", scr_color_guard); |
3e39a336a992
Use guards for colors (Myhailo Danylenko)
Mikael Berthe <mikael@lilotux.net>
parents:
1935
diff
changeset
|
821 |
settings_set_guard("color_general", scr_color_guard); |
3e39a336a992
Use guards for colors (Myhailo Danylenko)
Mikael Berthe <mikael@lilotux.net>
parents:
1935
diff
changeset
|
822 |
settings_set_guard("color_info", scr_color_guard); |
3e39a336a992
Use guards for colors (Myhailo Danylenko)
Mikael Berthe <mikael@lilotux.net>
parents:
1935
diff
changeset
|
823 |
settings_set_guard("color_msgin", scr_color_guard); |
3e39a336a992
Use guards for colors (Myhailo Danylenko)
Mikael Berthe <mikael@lilotux.net>
parents:
1935
diff
changeset
|
824 |
settings_set_guard("color_msgout", scr_color_guard); |
3e39a336a992
Use guards for colors (Myhailo Danylenko)
Mikael Berthe <mikael@lilotux.net>
parents:
1935
diff
changeset
|
825 |
settings_set_guard("color_msghl", scr_color_guard); |
3e39a336a992
Use guards for colors (Myhailo Danylenko)
Mikael Berthe <mikael@lilotux.net>
parents:
1935
diff
changeset
|
826 |
settings_set_guard("color_bgstatus", scr_color_guard); |
3e39a336a992
Use guards for colors (Myhailo Danylenko)
Mikael Berthe <mikael@lilotux.net>
parents:
1935
diff
changeset
|
827 |
settings_set_guard("color_status", scr_color_guard); |
2028
7b5bd6ad83b4
Add 'color_log' (text color in the log window)
Mikael Berthe <mikael@lilotux.net>
parents:
2015
diff
changeset
|
828 |
settings_set_guard("color_log", scr_color_guard); |
1942
3e39a336a992
Use guards for colors (Myhailo Danylenko)
Mikael Berthe <mikael@lilotux.net>
parents:
1935
diff
changeset
|
829 |
settings_set_guard("color_roster", scr_color_guard); |
3e39a336a992
Use guards for colors (Myhailo Danylenko)
Mikael Berthe <mikael@lilotux.net>
parents:
1935
diff
changeset
|
830 |
settings_set_guard("color_bgrostersel", scr_color_guard); |
3e39a336a992
Use guards for colors (Myhailo Danylenko)
Mikael Berthe <mikael@lilotux.net>
parents:
1935
diff
changeset
|
831 |
settings_set_guard("color_rostersel", scr_color_guard); |
3e39a336a992
Use guards for colors (Myhailo Danylenko)
Mikael Berthe <mikael@lilotux.net>
parents:
1935
diff
changeset
|
832 |
settings_set_guard("color_rosterselmsg", scr_color_guard); |
3e39a336a992
Use guards for colors (Myhailo Danylenko)
Mikael Berthe <mikael@lilotux.net>
parents:
1935
diff
changeset
|
833 |
settings_set_guard("color_rosternewmsg", scr_color_guard); |
2090
16b04d64ec88
Add option to highlight timestamp added by server.
Hermitifier
parents:
2074
diff
changeset
|
834 |
settings_set_guard("color_timestamp", scr_color_guard); |
1942
3e39a336a992
Use guards for colors (Myhailo Danylenko)
Mikael Berthe <mikael@lilotux.net>
parents:
1935
diff
changeset
|
835 |
|
373
af2f8ddf6a1b
Move (reorganize) functions
Mikael Berthe <mikael@lilotux.net>
parents:
370
diff
changeset
|
836 |
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
|
837 |
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
|
838 |
// 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
|
839 |
// 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
|
840 |
|
373
af2f8ddf6a1b
Move (reorganize) functions
Mikael Berthe <mikael@lilotux.net>
parents:
370
diff
changeset
|
841 |
inputLine[0] = 0; |
af2f8ddf6a1b
Move (reorganize) functions
Mikael Berthe <mikael@lilotux.net>
parents:
370
diff
changeset
|
842 |
ptr_inputline = inputLine; |
af2f8ddf6a1b
Move (reorganize) functions
Mikael Berthe <mikael@lilotux.net>
parents:
370
diff
changeset
|
843 |
|
966
d9acb7f2a3d1
Do not set Curses variable too early
Mikael Berthe <mikael@lilotux.net>
parents:
961
diff
changeset
|
844 |
Curses = TRUE; |
2149
1b3add57c912
Try to display the GLib warnings in the log window
Mikael Berthe <mikael@lilotux.net>
parents:
2143
diff
changeset
|
845 |
|
1b3add57c912
Try to display the GLib warnings in the log window
Mikael Berthe <mikael@lilotux.net>
parents:
2143
diff
changeset
|
846 |
g_log_set_handler("GLib", G_LOG_LEVEL_MASK, scr_glog_print, NULL); |
373
af2f8ddf6a1b
Move (reorganize) functions
Mikael Berthe <mikael@lilotux.net>
parents:
370
diff
changeset
|
847 |
return; |
af2f8ddf6a1b
Move (reorganize) functions
Mikael Berthe <mikael@lilotux.net>
parents:
370
diff
changeset
|
848 |
} |
af2f8ddf6a1b
Move (reorganize) functions
Mikael Berthe <mikael@lilotux.net>
parents:
370
diff
changeset
|
849 |
|
1780
e4378fbab5d7
Major API cleanup - bump API to 4
Mikael Berthe <mikael@lilotux.net>
parents:
1761
diff
changeset
|
850 |
void scr_terminate_curses(void) |
373
af2f8ddf6a1b
Move (reorganize) functions
Mikael Berthe <mikael@lilotux.net>
parents:
370
diff
changeset
|
851 |
{ |
af2f8ddf6a1b
Move (reorganize) functions
Mikael Berthe <mikael@lilotux.net>
parents:
370
diff
changeset
|
852 |
if (!Curses) return; |
af2f8ddf6a1b
Move (reorganize) functions
Mikael Berthe <mikael@lilotux.net>
parents:
370
diff
changeset
|
853 |
clear(); |
af2f8ddf6a1b
Move (reorganize) functions
Mikael Berthe <mikael@lilotux.net>
parents:
370
diff
changeset
|
854 |
refresh(); |
af2f8ddf6a1b
Move (reorganize) functions
Mikael Berthe <mikael@lilotux.net>
parents:
370
diff
changeset
|
855 |
endwin(); |
af2f8ddf6a1b
Move (reorganize) functions
Mikael Berthe <mikael@lilotux.net>
parents:
370
diff
changeset
|
856 |
Curses = FALSE; |
af2f8ddf6a1b
Move (reorganize) functions
Mikael Berthe <mikael@lilotux.net>
parents:
370
diff
changeset
|
857 |
return; |
af2f8ddf6a1b
Move (reorganize) functions
Mikael Berthe <mikael@lilotux.net>
parents:
370
diff
changeset
|
858 |
} |
af2f8ddf6a1b
Move (reorganize) functions
Mikael Berthe <mikael@lilotux.net>
parents:
370
diff
changeset
|
859 |
|
1780
e4378fbab5d7
Major API cleanup - bump API to 4
Mikael Berthe <mikael@lilotux.net>
parents:
1761
diff
changeset
|
860 |
void scr_beep(void) |
675
ae7016aae014
New "beep_on_message" option
Mikael Berthe <mikael@lilotux.net>
parents:
667
diff
changeset
|
861 |
{ |
ae7016aae014
New "beep_on_message" option
Mikael Berthe <mikael@lilotux.net>
parents:
667
diff
changeset
|
862 |
beep(); |
ae7016aae014
New "beep_on_message" option
Mikael Berthe <mikael@lilotux.net>
parents:
667
diff
changeset
|
863 |
} |
ae7016aae014
New "beep_on_message" option
Mikael Berthe <mikael@lilotux.net>
parents:
667
diff
changeset
|
864 |
|
1286
02ad6200df26
Add selectable time prefixes (vorner)
Mikael Berthe <mikael@lilotux.net>
parents:
1284
diff
changeset
|
865 |
// 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
|
866 |
static const char *timeprefixes[] = { |
02ad6200df26
Add selectable time prefixes (vorner)
Mikael Berthe <mikael@lilotux.net>
parents:
1284
diff
changeset
|
867 |
"%m-%d %H:%M ", |
02ad6200df26
Add selectable time prefixes (vorner)
Mikael Berthe <mikael@lilotux.net>
parents:
1284
diff
changeset
|
868 |
"%H:%M ", |
02ad6200df26
Add selectable time prefixes (vorner)
Mikael Berthe <mikael@lilotux.net>
parents:
1284
diff
changeset
|
869 |
" " |
02ad6200df26
Add selectable time prefixes (vorner)
Mikael Berthe <mikael@lilotux.net>
parents:
1284
diff
changeset
|
870 |
}; |
02ad6200df26
Add selectable time prefixes (vorner)
Mikael Berthe <mikael@lilotux.net>
parents:
1284
diff
changeset
|
871 |
|
02ad6200df26
Add selectable time prefixes (vorner)
Mikael Berthe <mikael@lilotux.net>
parents:
1284
diff
changeset
|
872 |
static const char *spectimeprefixes[] = { |
02ad6200df26
Add selectable time prefixes (vorner)
Mikael Berthe <mikael@lilotux.net>
parents:
1284
diff
changeset
|
873 |
"%m-%d %H:%M:%S ", |
02ad6200df26
Add selectable time prefixes (vorner)
Mikael Berthe <mikael@lilotux.net>
parents:
1284
diff
changeset
|
874 |
"%H:%M:%S ", |
02ad6200df26
Add selectable time prefixes (vorner)
Mikael Berthe <mikael@lilotux.net>
parents:
1284
diff
changeset
|
875 |
" " |
02ad6200df26
Add selectable time prefixes (vorner)
Mikael Berthe <mikael@lilotux.net>
parents:
1284
diff
changeset
|
876 |
}; |
02ad6200df26
Add selectable time prefixes (vorner)
Mikael Berthe <mikael@lilotux.net>
parents:
1284
diff
changeset
|
877 |
|
02ad6200df26
Add selectable time prefixes (vorner)
Mikael Berthe <mikael@lilotux.net>
parents:
1284
diff
changeset
|
878 |
static int timepreflengths[] = { |
1376
a0deb5124ebf
Check time_prefix value before using it
Mikael Berthe <mikael@lilotux.net>
parents:
1359
diff
changeset
|
879 |
// (length of the corresponding timeprefix + 5) |
1286
02ad6200df26
Add selectable time prefixes (vorner)
Mikael Berthe <mikael@lilotux.net>
parents:
1284
diff
changeset
|
880 |
17, |
02ad6200df26
Add selectable time prefixes (vorner)
Mikael Berthe <mikael@lilotux.net>
parents:
1284
diff
changeset
|
881 |
11, |
02ad6200df26
Add selectable time prefixes (vorner)
Mikael Berthe <mikael@lilotux.net>
parents:
1284
diff
changeset
|
882 |
6 |
02ad6200df26
Add selectable time prefixes (vorner)
Mikael Berthe <mikael@lilotux.net>
parents:
1284
diff
changeset
|
883 |
}; |
02ad6200df26
Add selectable time prefixes (vorner)
Mikael Berthe <mikael@lilotux.net>
parents:
1284
diff
changeset
|
884 |
|
1486
f83a51eaa5ed
Fix multiline output in /buffer save
Mikael Berthe <mikael@lilotux.net>
parents:
1485
diff
changeset
|
885 |
static const char *gettprefix(void) |
1286
02ad6200df26
Add selectable time prefixes (vorner)
Mikael Berthe <mikael@lilotux.net>
parents:
1284
diff
changeset
|
886 |
{ |
1376
a0deb5124ebf
Check time_prefix value before using it
Mikael Berthe <mikael@lilotux.net>
parents:
1359
diff
changeset
|
887 |
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
|
888 |
return timeprefixes[(n < 3 ? n : 0)]; |
1286
02ad6200df26
Add selectable time prefixes (vorner)
Mikael Berthe <mikael@lilotux.net>
parents:
1284
diff
changeset
|
889 |
} |
02ad6200df26
Add selectable time prefixes (vorner)
Mikael Berthe <mikael@lilotux.net>
parents:
1284
diff
changeset
|
890 |
|
1486
f83a51eaa5ed
Fix multiline output in /buffer save
Mikael Berthe <mikael@lilotux.net>
parents:
1485
diff
changeset
|
891 |
static const char *getspectprefix(void) |
1286
02ad6200df26
Add selectable time prefixes (vorner)
Mikael Berthe <mikael@lilotux.net>
parents:
1284
diff
changeset
|
892 |
{ |
1376
a0deb5124ebf
Check time_prefix value before using it
Mikael Berthe <mikael@lilotux.net>
parents:
1359
diff
changeset
|
893 |
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
|
894 |
return spectimeprefixes[(n < 3 ? n : 0)]; |
1286
02ad6200df26
Add selectable time prefixes (vorner)
Mikael Berthe <mikael@lilotux.net>
parents:
1284
diff
changeset
|
895 |
} |
02ad6200df26
Add selectable time prefixes (vorner)
Mikael Berthe <mikael@lilotux.net>
parents:
1284
diff
changeset
|
896 |
|
1487 | 897 |
guint scr_getprefixwidth(void) |
1286
02ad6200df26
Add selectable time prefixes (vorner)
Mikael Berthe <mikael@lilotux.net>
parents:
1284
diff
changeset
|
898 |
{ |
1376
a0deb5124ebf
Check time_prefix value before using it
Mikael Berthe <mikael@lilotux.net>
parents:
1359
diff
changeset
|
899 |
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
|
900 |
return timepreflengths[(n < 3 ? n : 0)]; |
1286
02ad6200df26
Add selectable time prefixes (vorner)
Mikael Berthe <mikael@lilotux.net>
parents:
1284
diff
changeset
|
901 |
} |
02ad6200df26
Add selectable time prefixes (vorner)
Mikael Berthe <mikael@lilotux.net>
parents:
1284
diff
changeset
|
902 |
|
1761
61f0482d3993
Limit = alignment to 1/3 of screen in option list
Myhailo Danylenko <isbear@ukrpost.net>
parents:
1756
diff
changeset
|
903 |
guint scr_gettextwidth(void) |
61f0482d3993
Limit = alignment to 1/3 of screen in option list
Myhailo Danylenko <isbear@ukrpost.net>
parents:
1756
diff
changeset
|
904 |
{ |
61f0482d3993
Limit = alignment to 1/3 of screen in option list
Myhailo Danylenko <isbear@ukrpost.net>
parents:
1756
diff
changeset
|
905 |
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
|
906 |
} |
61f0482d3993
Limit = alignment to 1/3 of screen in option list
Myhailo Danylenko <isbear@ukrpost.net>
parents:
1756
diff
changeset
|
907 |
|
1791
6e0a8bfb3a01
Add scr_gettextheight()
Myhailo Danylenko <isbear@ukrpost.net>
parents:
1783
diff
changeset
|
908 |
guint scr_gettextheight(void) |
6e0a8bfb3a01
Add scr_gettextheight()
Myhailo Danylenko <isbear@ukrpost.net>
parents:
1783
diff
changeset
|
909 |
{ |
6e0a8bfb3a01
Add scr_gettextheight()
Myhailo Danylenko <isbear@ukrpost.net>
parents:
1783
diff
changeset
|
910 |
// log window, two status bars and one input line |
6e0a8bfb3a01
Add scr_gettextheight()
Myhailo Danylenko <isbear@ukrpost.net>
parents:
1783
diff
changeset
|
911 |
return maxY - Log_Win_Height - 3; |
6e0a8bfb3a01
Add scr_gettextheight()
Myhailo Danylenko <isbear@ukrpost.net>
parents:
1783
diff
changeset
|
912 |
} |
6e0a8bfb3a01
Add scr_gettextheight()
Myhailo Danylenko <isbear@ukrpost.net>
parents:
1783
diff
changeset
|
913 |
|
1819
d13315366ba5
Add scr_getlogwinheight()
Mikael Berthe <mikael@lilotux.net>
parents:
1815
diff
changeset
|
914 |
guint scr_getlogwinheight(void) |
d13315366ba5
Add scr_getlogwinheight()
Mikael Berthe <mikael@lilotux.net>
parents:
1815
diff
changeset
|
915 |
{ |
d13315366ba5
Add scr_getlogwinheight()
Mikael Berthe <mikael@lilotux.net>
parents:
1815
diff
changeset
|
916 |
if (Log_Win_Height >= 2) |
d13315366ba5
Add scr_getlogwinheight()
Mikael Berthe <mikael@lilotux.net>
parents:
1815
diff
changeset
|
917 |
return Log_Win_Height - 2; |
d13315366ba5
Add scr_getlogwinheight()
Mikael Berthe <mikael@lilotux.net>
parents:
1815
diff
changeset
|
918 |
return 0; |
d13315366ba5
Add scr_getlogwinheight()
Mikael Berthe <mikael@lilotux.net>
parents:
1815
diff
changeset
|
919 |
} |
d13315366ba5
Add scr_getlogwinheight()
Mikael Berthe <mikael@lilotux.net>
parents:
1815
diff
changeset
|
920 |
|
1518
63dc211a4c1a
New command: /echo (display a message in the log window)
Mikael Berthe <mikael@lilotux.net>
parents:
1515
diff
changeset
|
921 |
// scr_print_logwindow(string) |
63dc211a4c1a
New command: /echo (display a message in the log window)
Mikael Berthe <mikael@lilotux.net>
parents:
1515
diff
changeset
|
922 |
// 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
|
923 |
// 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
|
924 |
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
|
925 |
{ |
63dc211a4c1a
New command: /echo (display a message in the log window)
Mikael Berthe <mikael@lilotux.net>
parents:
1515
diff
changeset
|
926 |
time_t timestamp; |
63dc211a4c1a
New command: /echo (display a message in the log window)
Mikael Berthe <mikael@lilotux.net>
parents:
1515
diff
changeset
|
927 |
char strtimestamp[64]; |
63dc211a4c1a
New command: /echo (display a message in the log window)
Mikael Berthe <mikael@lilotux.net>
parents:
1515
diff
changeset
|
928 |
|
63dc211a4c1a
New command: /echo (display a message in the log window)
Mikael Berthe <mikael@lilotux.net>
parents:
1515
diff
changeset
|
929 |
timestamp = time(NULL); |
63dc211a4c1a
New command: /echo (display a message in the log window)
Mikael Berthe <mikael@lilotux.net>
parents:
1515
diff
changeset
|
930 |
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
|
931 |
if (Curses) { |
63dc211a4c1a
New command: /echo (display a message in the log window)
Mikael Berthe <mikael@lilotux.net>
parents:
1515
diff
changeset
|
932 |
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
|
933 |
update_panels(); |
63dc211a4c1a
New command: /echo (display a message in the log window)
Mikael Berthe <mikael@lilotux.net>
parents:
1515
diff
changeset
|
934 |
} else { |
63dc211a4c1a
New command: /echo (display a message in the log window)
Mikael Berthe <mikael@lilotux.net>
parents:
1515
diff
changeset
|
935 |
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
|
936 |
} |
63dc211a4c1a
New command: /echo (display a message in the log window)
Mikael Berthe <mikael@lilotux.net>
parents:
1515
diff
changeset
|
937 |
} |
63dc211a4c1a
New command: /echo (display a message in the log window)
Mikael Berthe <mikael@lilotux.net>
parents:
1515
diff
changeset
|
938 |
|
1783
af3de54ef986
Convert scr_LogPrint() to scr_log_print()
Mikael Berthe <mikael@lilotux.net>
parents:
1780
diff
changeset
|
939 |
// scr_log_print(...) |
1518
63dc211a4c1a
New command: /echo (display a message in the log window)
Mikael Berthe <mikael@lilotux.net>
parents:
1515
diff
changeset
|
940 |
// 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
|
941 |
// 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
|
942 |
// 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
|
943 |
void scr_log_print(unsigned int flag, const char *fmt, ...) |
373
af2f8ddf6a1b
Move (reorganize) functions
Mikael Berthe <mikael@lilotux.net>
parents:
370
diff
changeset
|
944 |
{ |
af2f8ddf6a1b
Move (reorganize) functions
Mikael Berthe <mikael@lilotux.net>
parents:
370
diff
changeset
|
945 |
time_t timestamp; |
857
ef35a2bb40d7
scr_LogPrint(): do not use static buffer size
Mikael Berthe <mikael@lilotux.net>
parents:
851
diff
changeset
|
946 |
char strtimestamp[64]; |
858
2683ad5d1003
Improve scr_LogPrint() for log/debug messages
Mikael Berthe <mikael@lilotux.net>
parents:
857
diff
changeset
|
947 |
char *buffer, *btext; |
1075
03bc225ad763
Improve scr_LogPrint() readability
Mikael Berthe <mikael@lilotux.net>
parents:
1072
diff
changeset
|
948 |
char *convbuf1 = NULL, *convbuf2 = NULL; |
373
af2f8ddf6a1b
Move (reorganize) functions
Mikael Berthe <mikael@lilotux.net>
parents:
370
diff
changeset
|
949 |
va_list ap; |
af2f8ddf6a1b
Move (reorganize) functions
Mikael Berthe <mikael@lilotux.net>
parents:
370
diff
changeset
|
950 |
|
771
ce4f8a2129a4
scr_LogPrint() can display UTF-8 strings
Mikael Berthe <mikael@lilotux.net>
parents:
770
diff
changeset
|
951 |
if (!(flag & ~LPRINT_NOTUTF8)) return; // Shouldn't happen |
374
bd5638c21834
Improve logging system (traces)
Mikael Berthe <mikael@lilotux.net>
parents:
373
diff
changeset
|
952 |
|
857
ef35a2bb40d7
scr_LogPrint(): do not use static buffer size
Mikael Berthe <mikael@lilotux.net>
parents:
851
diff
changeset
|
953 |
timestamp = time(NULL); |
ef35a2bb40d7
scr_LogPrint(): do not use static buffer size
Mikael Berthe <mikael@lilotux.net>
parents:
851
diff
changeset
|
954 |
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
|
955 |
va_start(ap, fmt); |
858
2683ad5d1003
Improve scr_LogPrint() for log/debug messages
Mikael Berthe <mikael@lilotux.net>
parents:
857
diff
changeset
|
956 |
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
|
957 |
va_end(ap); |
373
af2f8ddf6a1b
Move (reorganize) functions
Mikael Berthe <mikael@lilotux.net>
parents:
370
diff
changeset
|
958 |
|
374
bd5638c21834
Improve logging system (traces)
Mikael Berthe <mikael@lilotux.net>
parents:
373
diff
changeset
|
959 |
if (flag & LPRINT_NORMAL) { |
771
ce4f8a2129a4
scr_LogPrint() can display UTF-8 strings
Mikael Berthe <mikael@lilotux.net>
parents:
770
diff
changeset
|
960 |
char *buffer_locale; |
851
da03534e46c7
Add startup log messages to the status buffer
Mikael Berthe <mikael@lilotux.net>
parents:
850
diff
changeset
|
961 |
char *buf_specialwindow; |
da03534e46c7
Add startup log messages to the status buffer
Mikael Berthe <mikael@lilotux.net>
parents:
850
diff
changeset
|
962 |
|
858
2683ad5d1003
Improve scr_LogPrint() for log/debug messages
Mikael Berthe <mikael@lilotux.net>
parents:
857
diff
changeset
|
963 |
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
|
964 |
|
851
da03534e46c7
Add startup log messages to the status buffer
Mikael Berthe <mikael@lilotux.net>
parents:
850
diff
changeset
|
965 |
// 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
|
966 |
if (!(flag & LPRINT_NOTUTF8)) |
1075
03bc225ad763
Improve scr_LogPrint() readability
Mikael Berthe <mikael@lilotux.net>
parents:
1072
diff
changeset
|
967 |
buffer_locale = convbuf1 = from_utf8(buffer); |
771
ce4f8a2129a4
scr_LogPrint() can display UTF-8 strings
Mikael Berthe <mikael@lilotux.net>
parents:
770
diff
changeset
|
968 |
else |
ce4f8a2129a4
scr_LogPrint() can display UTF-8 strings
Mikael Berthe <mikael@lilotux.net>
parents:
770
diff
changeset
|
969 |
buffer_locale = buffer; |
851
da03534e46c7
Add startup log messages to the status buffer
Mikael Berthe <mikael@lilotux.net>
parents:
850
diff
changeset
|
970 |
|
884
9e6d9f0cf9eb
scr_LogPrint(): Add a warning for UTF-8 -> locale conversion failures
Mikael Berthe <mikael@lilotux.net>
parents:
880
diff
changeset
|
971 |
if (!buffer_locale) { |
9e6d9f0cf9eb
scr_LogPrint(): Add a warning for UTF-8 -> locale conversion failures
Mikael Berthe <mikael@lilotux.net>
parents:
880
diff
changeset
|
972 |
wprintw(logWnd, |
9e6d9f0cf9eb
scr_LogPrint(): Add a warning for UTF-8 -> locale conversion failures
Mikael Berthe <mikael@lilotux.net>
parents:
880
diff
changeset
|
973 |
"\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
|
974 |
update_panels(); |
9e6d9f0cf9eb
scr_LogPrint(): Add a warning for UTF-8 -> locale conversion failures
Mikael Berthe <mikael@lilotux.net>
parents:
880
diff
changeset
|
975 |
g_free(buffer); |
897
a05b5a16a06a
Fix memory leak in scr_LogPrint()
Mikael Berthe <mikael@lilotux.net>
parents:
891
diff
changeset
|
976 |
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
|
977 |
return; |
9e6d9f0cf9eb
scr_LogPrint(): Add a warning for UTF-8 -> locale conversion failures
Mikael Berthe <mikael@lilotux.net>
parents:
880
diff
changeset
|
978 |
} |
9e6d9f0cf9eb
scr_LogPrint(): Add a warning for UTF-8 -> locale conversion failures
Mikael Berthe <mikael@lilotux.net>
parents:
880
diff
changeset
|
979 |
|
851
da03534e46c7
Add startup log messages to the status buffer
Mikael Berthe <mikael@lilotux.net>
parents:
850
diff
changeset
|
980 |
// 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
|
981 |
if (flag & LPRINT_NOTUTF8) |
1075
03bc225ad763
Improve scr_LogPrint() readability
Mikael Berthe <mikael@lilotux.net>
parents:
1072
diff
changeset
|
982 |
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
|
983 |
else |
858
2683ad5d1003
Improve scr_LogPrint() for log/debug messages
Mikael Berthe <mikael@lilotux.net>
parents:
857
diff
changeset
|
984 |
buf_specialwindow = btext; |
851
da03534e46c7
Add startup log messages to the status buffer
Mikael Berthe <mikael@lilotux.net>
parents:
850
diff
changeset
|
985 |
|
374
bd5638c21834
Improve logging system (traces)
Mikael Berthe <mikael@lilotux.net>
parents:
373
diff
changeset
|
986 |
if (Curses) { |
771
ce4f8a2129a4
scr_LogPrint() can display UTF-8 strings
Mikael Berthe <mikael@lilotux.net>
parents:
770
diff
changeset
|
987 |
wprintw(logWnd, "\n%s", buffer_locale); |
374
bd5638c21834
Improve logging system (traces)
Mikael Berthe <mikael@lilotux.net>
parents:
373
diff
changeset
|
988 |
update_panels(); |
1780
e4378fbab5d7
Major API cleanup - bump API to 4
Mikael Berthe <mikael@lilotux.net>
parents:
1761
diff
changeset
|
989 |
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
|
990 |
HBB_PREFIX_SPECIAL, FALSE, 0, NULL); |
374
bd5638c21834
Improve logging system (traces)
Mikael Berthe <mikael@lilotux.net>
parents:
373
diff
changeset
|
991 |
} else { |
771
ce4f8a2129a4
scr_LogPrint() can display UTF-8 strings
Mikael Berthe <mikael@lilotux.net>
parents:
770
diff
changeset
|
992 |
printf("%s\n", buffer_locale); |
851
da03534e46c7
Add startup log messages to the status buffer
Mikael Berthe <mikael@lilotux.net>
parents:
850
diff
changeset
|
993 |
// 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
|
994 |
hbuf_add_line(&statushbuf, buf_specialwindow, timestamp, |
1602 | 995 |
HBB_PREFIX_SPECIAL, 0, 0, 0, NULL); |
374
bd5638c21834
Improve logging system (traces)
Mikael Berthe <mikael@lilotux.net>
parents:
373
diff
changeset
|
996 |
} |
851
da03534e46c7
Add startup log messages to the status buffer
Mikael Berthe <mikael@lilotux.net>
parents:
850
diff
changeset
|
997 |
|
1075
03bc225ad763
Improve scr_LogPrint() readability
Mikael Berthe <mikael@lilotux.net>
parents:
1072
diff
changeset
|
998 |
g_free(convbuf1); |
03bc225ad763
Improve scr_LogPrint() readability
Mikael Berthe <mikael@lilotux.net>
parents:
1072
diff
changeset
|
999 |
g_free(convbuf2); |
858
2683ad5d1003
Improve scr_LogPrint() for log/debug messages
Mikael Berthe <mikael@lilotux.net>
parents:
857
diff
changeset
|
1000 |
g_free(buffer); |
374
bd5638c21834
Improve logging system (traces)
Mikael Berthe <mikael@lilotux.net>
parents:
373
diff
changeset
|
1001 |
} |
412
9c640ee3bae3
Display full date in the log file
Mikael Berthe <mikael@lilotux.net>
parents:
393
diff
changeset
|
1002 |
|
857
ef35a2bb40d7
scr_LogPrint(): do not use static buffer size
Mikael Berthe <mikael@lilotux.net>
parents:
851
diff
changeset
|
1003 |
if (flag & (LPRINT_LOG|LPRINT_DEBUG)) { |
ef35a2bb40d7
scr_LogPrint(): do not use static buffer size
Mikael Berthe <mikael@lilotux.net>
parents:
851
diff
changeset
|
1004 |
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
|
1005 |
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
|
1006 |
ut_write_log(flag, buffer); |
857
ef35a2bb40d7
scr_LogPrint(): do not use static buffer size
Mikael Berthe <mikael@lilotux.net>
parents:
851
diff
changeset
|
1007 |
g_free(buffer); |
373
af2f8ddf6a1b
Move (reorganize) functions
Mikael Berthe <mikael@lilotux.net>
parents:
370
diff
changeset
|
1008 |
} |
897
a05b5a16a06a
Fix memory leak in scr_LogPrint()
Mikael Berthe <mikael@lilotux.net>
parents:
891
diff
changeset
|
1009 |
g_free(btext); |
373
af2f8ddf6a1b
Move (reorganize) functions
Mikael Berthe <mikael@lilotux.net>
parents:
370
diff
changeset
|
1010 |
} |
af2f8ddf6a1b
Move (reorganize) functions
Mikael Berthe <mikael@lilotux.net>
parents:
370
diff
changeset
|
1011 |
|
2149
1b3add57c912
Try to display the GLib warnings in the log window
Mikael Berthe <mikael@lilotux.net>
parents:
2143
diff
changeset
|
1012 |
// This is a GLogFunc for Glib log messages |
1b3add57c912
Try to display the GLib warnings in the log window
Mikael Berthe <mikael@lilotux.net>
parents:
2143
diff
changeset
|
1013 |
static void scr_glog_print(const gchar *log_domain, GLogLevelFlags log_level, |
1b3add57c912
Try to display the GLib warnings in the log window
Mikael Berthe <mikael@lilotux.net>
parents:
2143
diff
changeset
|
1014 |
const gchar *message, gpointer user_data) |
1b3add57c912
Try to display the GLib warnings in the log window
Mikael Berthe <mikael@lilotux.net>
parents:
2143
diff
changeset
|
1015 |
{ |
1b3add57c912
Try to display the GLib warnings in the log window
Mikael Berthe <mikael@lilotux.net>
parents:
2143
diff
changeset
|
1016 |
scr_log_print(LPRINT_NORMAL, "[%s] %s", log_domain, message); |
1b3add57c912
Try to display the GLib warnings in the log window
Mikael Berthe <mikael@lilotux.net>
parents:
2143
diff
changeset
|
1017 |
} |
1b3add57c912
Try to display the GLib warnings in the log window
Mikael Berthe <mikael@lilotux.net>
parents:
2143
diff
changeset
|
1018 |
|
1780
e4378fbab5d7
Major API cleanup - bump API to 4
Mikael Berthe <mikael@lilotux.net>
parents:
1761
diff
changeset
|
1019 |
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
|
1020 |
{ |
cae430fcd385
Mcabber will load symlinked histories only once, now.
Frank Zschockelt
parents:
1154
diff
changeset
|
1021 |
char *id; |
cae430fcd385
Mcabber will load symlinked histories only once, now.
Frank Zschockelt
parents:
1154
diff
changeset
|
1022 |
winbuf *wbp; |
cae430fcd385
Mcabber will load symlinked histories only once, now.
Frank Zschockelt
parents:
1154
diff
changeset
|
1023 |
|
cae430fcd385
Mcabber will load symlinked histories only once, now.
Frank Zschockelt
parents:
1154
diff
changeset
|
1024 |
if (special) |
cae430fcd385
Mcabber will load symlinked histories only once, now.
Frank Zschockelt
parents:
1154
diff
changeset
|
1025 |
return statusWindow; // Only one special window atm. |
cae430fcd385
Mcabber will load symlinked histories only once, now.
Frank Zschockelt
parents:
1154
diff
changeset
|
1026 |
|
cae430fcd385
Mcabber will load symlinked histories only once, now.
Frank Zschockelt
parents:
1154
diff
changeset
|
1027 |
if (!winId) |
cae430fcd385
Mcabber will load symlinked histories only once, now.
Frank Zschockelt
parents:
1154
diff
changeset
|
1028 |
return NULL; |
cae430fcd385
Mcabber will load symlinked histories only once, now.
Frank Zschockelt
parents:
1154
diff
changeset
|
1029 |
|
cae430fcd385
Mcabber will load symlinked histories only once, now.
Frank Zschockelt
parents:
1154
diff
changeset
|
1030 |
id = g_strdup(winId); |
cae430fcd385
Mcabber will load symlinked histories only once, now.
Frank Zschockelt
parents:
1154
diff
changeset
|
1031 |
mc_strtolower(id); |
cae430fcd385
Mcabber will load symlinked histories only once, now.
Frank Zschockelt
parents:
1154
diff
changeset
|
1032 |
wbp = g_hash_table_lookup(winbufhash, id); |
cae430fcd385
Mcabber will load symlinked histories only once, now.
Frank Zschockelt
parents:
1154
diff
changeset
|
1033 |
g_free(id); |
cae430fcd385
Mcabber will load symlinked histories only once, now.
Frank Zschockelt
parents:
1154
diff
changeset
|
1034 |
return wbp; |
cae430fcd385
Mcabber will load symlinked histories only once, now.
Frank Zschockelt
parents:
1154
diff
changeset
|
1035 |
} |
cae430fcd385
Mcabber will load symlinked histories only once, now.
Frank Zschockelt
parents:
1154
diff
changeset
|
1036 |
|
1780
e4378fbab5d7
Major API cleanup - bump API to 4
Mikael Berthe <mikael@lilotux.net>
parents:
1761
diff
changeset
|
1037 |
int scr_buddy_buffer_exists(const char *bjid) |
1156
cae430fcd385
Mcabber will load symlinked histories only once, now.
Frank Zschockelt
parents:
1154
diff
changeset
|
1038 |
{ |
1780
e4378fbab5d7
Major API cleanup - bump API to 4
Mikael Berthe <mikael@lilotux.net>
parents:
1761
diff
changeset
|
1039 |
return (scr_search_window(bjid, FALSE) != NULL); |
1156
cae430fcd385
Mcabber will load symlinked histories only once, now.
Frank Zschockelt
parents:
1154
diff
changeset
|
1040 |
} |
cae430fcd385
Mcabber will load symlinked histories only once, now.
Frank Zschockelt
parents:
1154
diff
changeset
|
1041 |
|
1133
9dd28a56128f
Do not create one panel per contact
Mikael Berthe <mikael@lilotux.net>
parents:
1131
diff
changeset
|
1042 |
// scr_new_buddy(title, dontshow) |
1139 | 1043 |
// 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
|
1044 |
static winbuf *scr_new_buddy(const char *title, int dont_show) |
24 | 1045 |
{ |
822 | 1046 |
winbuf *tmp; |
2225
dc3b3ac1ba76
Free the buffdata structures when buffers are closed
Mikael Berthe <mikael@lilotux.net>
parents:
2222
diff
changeset
|
1047 |
char *id; |
393 | 1048 |
|
822 | 1049 |
tmp = g_new0(winbuf, 1); |
24 | 1050 |
|
1133
9dd28a56128f
Do not create one panel per contact
Mikael Berthe <mikael@lilotux.net>
parents:
1131
diff
changeset
|
1051 |
tmp->win = activechatWnd; |
9dd28a56128f
Do not create one panel per contact
Mikael Berthe <mikael@lilotux.net>
parents:
1131
diff
changeset
|
1052 |
tmp->panel = activechatPanel; |
24 | 1053 |
|
143 | 1054 |
if (!dont_show) { |
24 | 1055 |
currentWindow = tmp; |
1056 |
} else { |
|
1057 |
if (currentWindow) |
|
1058 |
top_panel(currentWindow->panel); |
|
1059 |
else |
|
1060 |
top_panel(chatPanel); |
|
1061 |
} |
|
143 | 1062 |
update_panels(); |
24 | 1063 |
|
849
42c43a88d823
Status buffer management
Mikael Berthe <mikael@lilotux.net>
parents:
848
diff
changeset
|
1064 |
// If title is NULL, this is a special buffer |
2225
dc3b3ac1ba76
Free the buffdata structures when buffers are closed
Mikael Berthe <mikael@lilotux.net>
parents:
2222
diff
changeset
|
1065 |
if (!title) { |
1159
53c0c5be43fa
Small fixes, typos and cleanups
Mikael Berthe <mikael@lilotux.net>
parents:
1157
diff
changeset
|
1066 |
tmp->bd = g_new0(buffdata, 1); |
2225
dc3b3ac1ba76
Free the buffdata structures when buffers are closed
Mikael Berthe <mikael@lilotux.net>
parents:
2222
diff
changeset
|
1067 |
return tmp; |
849
42c43a88d823
Status buffer management
Mikael Berthe <mikael@lilotux.net>
parents:
848
diff
changeset
|
1068 |
} |
2225
dc3b3ac1ba76
Free the buffdata structures when buffers are closed
Mikael Berthe <mikael@lilotux.net>
parents:
2222
diff
changeset
|
1069 |
|
dc3b3ac1ba76
Free the buffdata structures when buffers are closed
Mikael Berthe <mikael@lilotux.net>
parents:
2222
diff
changeset
|
1070 |
id = hlog_get_log_jid(title); |
dc3b3ac1ba76
Free the buffdata structures when buffers are closed
Mikael Berthe <mikael@lilotux.net>
parents:
2222
diff
changeset
|
1071 |
if (id) { |
dc3b3ac1ba76
Free the buffdata structures when buffers are closed
Mikael Berthe <mikael@lilotux.net>
parents:
2222
diff
changeset
|
1072 |
// This is a symlinked history log file. |
dc3b3ac1ba76
Free the buffdata structures when buffers are closed
Mikael Berthe <mikael@lilotux.net>
parents:
2222
diff
changeset
|
1073 |
// Let's check if the target JID buffer has already been created. |
dc3b3ac1ba76
Free the buffdata structures when buffers are closed
Mikael Berthe <mikael@lilotux.net>
parents:
2222
diff
changeset
|
1074 |
winbuf *wb = scr_search_window(id, FALSE); |
dc3b3ac1ba76
Free the buffdata structures when buffers are closed
Mikael Berthe <mikael@lilotux.net>
parents:
2222
diff
changeset
|
1075 |
if (!wb) |
dc3b3ac1ba76
Free the buffdata structures when buffers are closed
Mikael Berthe <mikael@lilotux.net>
parents:
2222
diff
changeset
|
1076 |
wb = scr_new_buddy(id, TRUE); |
dc3b3ac1ba76
Free the buffdata structures when buffers are closed
Mikael Berthe <mikael@lilotux.net>
parents:
2222
diff
changeset
|
1077 |
tmp->bd = wb->bd; |
dc3b3ac1ba76
Free the buffdata structures when buffers are closed
Mikael Berthe <mikael@lilotux.net>
parents:
2222
diff
changeset
|
1078 |
tmp->bd->refcount++; |
dc3b3ac1ba76
Free the buffdata structures when buffers are closed
Mikael Berthe <mikael@lilotux.net>
parents:
2222
diff
changeset
|
1079 |
g_free(id); |
dc3b3ac1ba76
Free the buffdata structures when buffers are closed
Mikael Berthe <mikael@lilotux.net>
parents:
2222
diff
changeset
|
1080 |
} else { // Load buddy history from file (if enabled) |
dc3b3ac1ba76
Free the buffdata structures when buffers are closed
Mikael Berthe <mikael@lilotux.net>
parents:
2222
diff
changeset
|
1081 |
tmp->bd = g_new0(buffdata, 1); |
dc3b3ac1ba76
Free the buffdata structures when buffers are closed
Mikael Berthe <mikael@lilotux.net>
parents:
2222
diff
changeset
|
1082 |
hlog_read_history(title, &tmp->bd->hbuf, |
dc3b3ac1ba76
Free the buffdata structures when buffers are closed
Mikael Berthe <mikael@lilotux.net>
parents:
2222
diff
changeset
|
1083 |
maxX - Roster_Width - scr_getprefixwidth()); |
dc3b3ac1ba76
Free the buffdata structures when buffers are closed
Mikael Berthe <mikael@lilotux.net>
parents:
2222
diff
changeset
|
1084 |
|
dc3b3ac1ba76
Free the buffdata structures when buffers are closed
Mikael Berthe <mikael@lilotux.net>
parents:
2222
diff
changeset
|
1085 |
// Set a readmark to separate new content |
dc3b3ac1ba76
Free the buffdata structures when buffers are closed
Mikael Berthe <mikael@lilotux.net>
parents:
2222
diff
changeset
|
1086 |
hbuf_set_readmark(tmp->bd->hbuf, TRUE); |
dc3b3ac1ba76
Free the buffdata structures when buffers are closed
Mikael Berthe <mikael@lilotux.net>
parents:
2222
diff
changeset
|
1087 |
} |
dc3b3ac1ba76
Free the buffdata structures when buffers are closed
Mikael Berthe <mikael@lilotux.net>
parents:
2222
diff
changeset
|
1088 |
|
dc3b3ac1ba76
Free the buffdata structures when buffers are closed
Mikael Berthe <mikael@lilotux.net>
parents:
2222
diff
changeset
|
1089 |
id = g_strdup(title); |
dc3b3ac1ba76
Free the buffdata structures when buffers are closed
Mikael Berthe <mikael@lilotux.net>
parents:
2222
diff
changeset
|
1090 |
mc_strtolower(id); |
dc3b3ac1ba76
Free the buffdata structures when buffers are closed
Mikael Berthe <mikael@lilotux.net>
parents:
2222
diff
changeset
|
1091 |
g_hash_table_insert(winbufhash, id, tmp); |
dc3b3ac1ba76
Free the buffdata structures when buffers are closed
Mikael Berthe <mikael@lilotux.net>
parents:
2222
diff
changeset
|
1092 |
|
24 | 1093 |
return tmp; |
1094 |
} |
|
1095 |
||
1483
e74cc83e7158
Refactor scr_UpdateWindow()
Mikael Berthe <mikael@lilotux.net>
parents:
1476
diff
changeset
|
1096 |
// scr_line_prefix(line, pref, preflen) |
e74cc83e7158
Refactor scr_UpdateWindow()
Mikael Berthe <mikael@lilotux.net>
parents:
1476
diff
changeset
|
1097 |
// Use data from the hbb_line structure and write the prefix |
e74cc83e7158
Refactor scr_UpdateWindow()
Mikael Berthe <mikael@lilotux.net>
parents:
1476
diff
changeset
|
1098 |
// to pref (not exceeding preflen, trailing null byte included). |
2090
16b04d64ec88
Add option to highlight timestamp added by server.
Hermitifier
parents:
2074
diff
changeset
|
1099 |
size_t scr_line_prefix(hbb_line *line, char *pref, guint preflen) |
1483
e74cc83e7158
Refactor scr_UpdateWindow()
Mikael Berthe <mikael@lilotux.net>
parents:
1476
diff
changeset
|
1100 |
{ |
e74cc83e7158
Refactor scr_UpdateWindow()
Mikael Berthe <mikael@lilotux.net>
parents:
1476
diff
changeset
|
1101 |
char date[64]; |
2090
16b04d64ec88
Add option to highlight timestamp added by server.
Hermitifier
parents:
2074
diff
changeset
|
1102 |
size_t timepreflen = 0; |
1483
e74cc83e7158
Refactor scr_UpdateWindow()
Mikael Berthe <mikael@lilotux.net>
parents:
1476
diff
changeset
|
1103 |
|
e74cc83e7158
Refactor scr_UpdateWindow()
Mikael Berthe <mikael@lilotux.net>
parents:
1476
diff
changeset
|
1104 |
if (line->timestamp && |
e74cc83e7158
Refactor scr_UpdateWindow()
Mikael Berthe <mikael@lilotux.net>
parents:
1476
diff
changeset
|
1105 |
!(line->flags & (HBB_PREFIX_SPECIAL|HBB_PREFIX_CONT))) { |
2090
16b04d64ec88
Add option to highlight timestamp added by server.
Hermitifier
parents:
2074
diff
changeset
|
1106 |
timepreflen = strftime(date, 30, gettprefix(), localtime(&line->timestamp)); |
1483
e74cc83e7158
Refactor scr_UpdateWindow()
Mikael Berthe <mikael@lilotux.net>
parents:
1476
diff
changeset
|
1107 |
} else |
e74cc83e7158
Refactor scr_UpdateWindow()
Mikael Berthe <mikael@lilotux.net>
parents:
1476
diff
changeset
|
1108 |
strcpy(date, " "); |
e74cc83e7158
Refactor scr_UpdateWindow()
Mikael Berthe <mikael@lilotux.net>
parents:
1476
diff
changeset
|
1109 |
|
e74cc83e7158
Refactor scr_UpdateWindow()
Mikael Berthe <mikael@lilotux.net>
parents:
1476
diff
changeset
|
1110 |
if (!(line->flags & HBB_PREFIX_CONT)) { |
e74cc83e7158
Refactor scr_UpdateWindow()
Mikael Berthe <mikael@lilotux.net>
parents:
1476
diff
changeset
|
1111 |
if (line->flags & HBB_PREFIX_INFO) { |
e74cc83e7158
Refactor scr_UpdateWindow()
Mikael Berthe <mikael@lilotux.net>
parents:
1476
diff
changeset
|
1112 |
char dir = '*'; |
e74cc83e7158
Refactor scr_UpdateWindow()
Mikael Berthe <mikael@lilotux.net>
parents:
1476
diff
changeset
|
1113 |
if (line->flags & HBB_PREFIX_IN) |
e74cc83e7158
Refactor scr_UpdateWindow()
Mikael Berthe <mikael@lilotux.net>
parents:
1476
diff
changeset
|
1114 |
dir = '<'; |
e74cc83e7158
Refactor scr_UpdateWindow()
Mikael Berthe <mikael@lilotux.net>
parents:
1476
diff
changeset
|
1115 |
else if (line->flags & HBB_PREFIX_OUT) |
e74cc83e7158
Refactor scr_UpdateWindow()
Mikael Berthe <mikael@lilotux.net>
parents:
1476
diff
changeset
|
1116 |
dir = '>'; |
e74cc83e7158
Refactor scr_UpdateWindow()
Mikael Berthe <mikael@lilotux.net>
parents:
1476
diff
changeset
|
1117 |
g_snprintf(pref, preflen, "%s*%c* ", date, dir); |
e74cc83e7158
Refactor scr_UpdateWindow()
Mikael Berthe <mikael@lilotux.net>
parents:
1476
diff
changeset
|
1118 |
} else if (line->flags & HBB_PREFIX_ERR) { |
e74cc83e7158
Refactor scr_UpdateWindow()
Mikael Berthe <mikael@lilotux.net>
parents:
1476
diff
changeset
|
1119 |
char dir = '#'; |
e74cc83e7158
Refactor scr_UpdateWindow()
Mikael Berthe <mikael@lilotux.net>
parents:
1476
diff
changeset
|
1120 |
if (line->flags & HBB_PREFIX_IN) |
e74cc83e7158
Refactor scr_UpdateWindow()
Mikael Berthe <mikael@lilotux.net>
parents:
1476
diff
changeset
|
1121 |
dir = '<'; |
e74cc83e7158
Refactor scr_UpdateWindow()
Mikael Berthe <mikael@lilotux.net>
parents:
1476
diff
changeset
|
1122 |
else if (line->flags & HBB_PREFIX_OUT) |
e74cc83e7158
Refactor scr_UpdateWindow()
Mikael Berthe <mikael@lilotux.net>
parents:
1476
diff
changeset
|
1123 |
dir = '>'; |
e74cc83e7158
Refactor scr_UpdateWindow()
Mikael Berthe <mikael@lilotux.net>
parents:
1476
diff
changeset
|
1124 |
g_snprintf(pref, preflen, "%s#%c# ", date, dir); |
e74cc83e7158
Refactor scr_UpdateWindow()
Mikael Berthe <mikael@lilotux.net>
parents:
1476
diff
changeset
|
1125 |
} 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
|
1126 |
char cryptflag; |
7b36b91a4388
New UI message flag (O) when OTR is used
Mikael Berthe <mikael@lilotux.net>
parents:
1483
diff
changeset
|
1127 |
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
|
1128 |
cryptflag = '~'; |
7b36b91a4388
New UI message flag (O) when OTR is used
Mikael Berthe <mikael@lilotux.net>
parents:
1483
diff
changeset
|
1129 |
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
|
1130 |
cryptflag = 'O'; |
7b36b91a4388
New UI message flag (O) when OTR is used
Mikael Berthe <mikael@lilotux.net>
parents:
1483
diff
changeset
|
1131 |
else |
7b36b91a4388
New UI message flag (O) when OTR is used
Mikael Berthe <mikael@lilotux.net>
parents:
1483
diff
changeset
|
1132 |
cryptflag = '='; |
1483
e74cc83e7158
Refactor scr_UpdateWindow()
Mikael Berthe <mikael@lilotux.net>
parents:
1476
diff
changeset
|
1133 |
g_snprintf(pref, preflen, "%s<%c= ", date, cryptflag); |
e74cc83e7158
Refactor scr_UpdateWindow()
Mikael Berthe <mikael@lilotux.net>
parents:
1476
diff
changeset
|
1134 |
} else if (line->flags & HBB_PREFIX_OUT) { |
1602 | 1135 |
char cryptflag, receiptflag; |
1484
7b36b91a4388
New UI message flag (O) when OTR is used
Mikael Berthe <mikael@lilotux.net>
parents:
1483
diff
changeset
|
1136 |
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
|
1137 |
cryptflag = '~'; |
7b36b91a4388
New UI message flag (O) when OTR is used
Mikael Berthe <mikael@lilotux.net>
parents:
1483
diff
changeset
|
1138 |
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
|
1139 |
cryptflag = 'O'; |
7b36b91a4388
New UI message flag (O) when OTR is used
Mikael Berthe <mikael@lilotux.net>
parents:
1483
diff
changeset
|
1140 |
else |
1488
b393b8cee171
Fix small mistake in changeset 7b36b91a4388
Mikael Berthe <mikael@lilotux.net>
parents:
1487
diff
changeset
|
1141 |
cryptflag = '-'; |
1602 | 1142 |
if (line->flags & HBB_PREFIX_RECEIPT) |
1143 |
receiptflag = 'r'; |
|
1144 |
else |
|
1145 |
receiptflag = '-'; |
|
1146 |
g_snprintf(pref, preflen, "%s%c%c> ", date, receiptflag, cryptflag); |
|
1483
e74cc83e7158
Refactor scr_UpdateWindow()
Mikael Berthe <mikael@lilotux.net>
parents:
1476
diff
changeset
|
1147 |
} else if (line->flags & HBB_PREFIX_SPECIAL) { |
2090
16b04d64ec88
Add option to highlight timestamp added by server.
Hermitifier
parents:
2074
diff
changeset
|
1148 |
timepreflen = strftime(date, 30, getspectprefix(), localtime(&line->timestamp)); |
1483
e74cc83e7158
Refactor scr_UpdateWindow()
Mikael Berthe <mikael@lilotux.net>
parents:
1476
diff
changeset
|
1149 |
g_snprintf(pref, preflen, "%s ", date); |
e74cc83e7158
Refactor scr_UpdateWindow()
Mikael Berthe <mikael@lilotux.net>
parents:
1476
diff
changeset
|
1150 |
} else { |
e74cc83e7158
Refactor scr_UpdateWindow()
Mikael Berthe <mikael@lilotux.net>
parents:
1476
diff
changeset
|
1151 |
g_snprintf(pref, preflen, "%s ", date); |
e74cc83e7158
Refactor scr_UpdateWindow()
Mikael Berthe <mikael@lilotux.net>
parents:
1476
diff
changeset
|
1152 |
} |
e74cc83e7158
Refactor scr_UpdateWindow()
Mikael Berthe <mikael@lilotux.net>
parents:
1476
diff
changeset
|
1153 |
} else { |
e74cc83e7158
Refactor scr_UpdateWindow()
Mikael Berthe <mikael@lilotux.net>
parents:
1476
diff
changeset
|
1154 |
g_snprintf(pref, preflen, " "); |
e74cc83e7158
Refactor scr_UpdateWindow()
Mikael Berthe <mikael@lilotux.net>
parents:
1476
diff
changeset
|
1155 |
} |
2090
16b04d64ec88
Add option to highlight timestamp added by server.
Hermitifier
parents:
2074
diff
changeset
|
1156 |
return timepreflen; |
1483
e74cc83e7158
Refactor scr_UpdateWindow()
Mikael Berthe <mikael@lilotux.net>
parents:
1476
diff
changeset
|
1157 |
} |
e74cc83e7158
Refactor scr_UpdateWindow()
Mikael Berthe <mikael@lilotux.net>
parents:
1476
diff
changeset
|
1158 |
|
1780
e4378fbab5d7
Major API cleanup - bump API to 4
Mikael Berthe <mikael@lilotux.net>
parents:
1761
diff
changeset
|
1159 |
// scr_update_window() |
143 | 1160 |
// (Re-)Display the given chat window. |
1780
e4378fbab5d7
Major API cleanup - bump API to 4
Mikael Berthe <mikael@lilotux.net>
parents:
1761
diff
changeset
|
1161 |
static void scr_update_window(winbuf *win_entry) |
74 | 1162 |
{ |
1948 | 1163 |
int n, mark_offset = 0; |
1486
f83a51eaa5ed
Fix multiline output in /buffer save
Mikael Berthe <mikael@lilotux.net>
parents:
1485
diff
changeset
|
1164 |
guint prefixwidth; |
1483
e74cc83e7158
Refactor scr_UpdateWindow()
Mikael Berthe <mikael@lilotux.net>
parents:
1476
diff
changeset
|
1165 |
char pref[96]; |
184 | 1166 |
hbb_line **lines, *line; |
74 | 1167 |
GList *hbuf_head; |
1965
ec737f5f1d6f
Couple of readmark-related bugfixes
Mikael Berthe <mikael@lilotux.net>
parents:
1961
diff
changeset
|
1168 |
int color = COLOR_GENERAL; |
1948 | 1169 |
bool readmark = FALSE; |
1170 |
bool skipline = FALSE; |
|
2098
c4a68361883f
Lock buffer automatically when scrolled up, unlock when at bottom ("buffer_smart_scrolling" setting)
Hermitifier
parents:
2090
diff
changeset
|
1171 |
int autolock; |
c4a68361883f
Lock buffer automatically when scrolled up, unlock when at bottom ("buffer_smart_scrolling" setting)
Hermitifier
parents:
2090
diff
changeset
|
1172 |
|
c4a68361883f
Lock buffer automatically when scrolled up, unlock when at bottom ("buffer_smart_scrolling" setting)
Hermitifier
parents:
2090
diff
changeset
|
1173 |
autolock = settings_opt_get_int("buffer_smart_scrolling"); |
74 | 1174 |
|
1487 | 1175 |
prefixwidth = scr_getprefixwidth(); |
1486
f83a51eaa5ed
Fix multiline output in /buffer save
Mikael Berthe <mikael@lilotux.net>
parents:
1485
diff
changeset
|
1176 |
prefixwidth = MIN(prefixwidth, sizeof pref); |
108 | 1177 |
|
1178 |
// Should the window be empty? |
|
1157
5c857f0f0ab8
Moved all variables related to hbuf to an extra struct, bufdata
Frank Zschockelt
parents:
1156
diff
changeset
|
1179 |
if (win_entry->bd->cleared) { |
168 | 1180 |
werase(win_entry->win); |
2098
c4a68361883f
Lock buffer automatically when scrolled up, unlock when at bottom ("buffer_smart_scrolling" setting)
Hermitifier
parents:
2090
diff
changeset
|
1181 |
if (autolock && win_entry->bd->lock) |
c4a68361883f
Lock buffer automatically when scrolled up, unlock when at bottom ("buffer_smart_scrolling" setting)
Hermitifier
parents:
2090
diff
changeset
|
1182 |
scr_buffer_scroll_lock(0); |
108 | 1183 |
return; |
1184 |
} |
|
1185 |
||
1160
14f5876b5555
Slight optimization + line wrapping
Mikael Berthe <mikael@lilotux.net>
parents:
1159
diff
changeset
|
1186 |
// 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
|
1187 |
// we are displaying the last messages. |
105 | 1188 |
|
74 | 1189 |
// We will show the last CHAT_WIN_HEIGHT lines. |
1190 |
// Let's find out where it begins. |
|
1160
14f5876b5555
Slight optimization + line wrapping
Mikael Berthe <mikael@lilotux.net>
parents:
1159
diff
changeset
|
1191 |
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
|
1192 |
win_entry->bd->top) == -1)) { |
105 | 1193 |
// 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
|
1194 |
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
|
1195 |
hbuf_head = win_entry->bd->hbuf; |
5c857f0f0ab8
Moved all variables related to hbuf to an extra struct, bufdata
Frank Zschockelt
parents:
1156
diff
changeset
|
1196 |
win_entry->bd->top = NULL; // (Just to make sure) |
105 | 1197 |
n = 0; |
1198 |
while (hbuf_head && (n < CHAT_WIN_HEIGHT-1) && g_list_previous(hbuf_head)) { |
|
1199 |
hbuf_head = g_list_previous(hbuf_head); |
|
1200 |
n++; |
|
1201 |
} |
|
873
ee39f6d94d43
Add /buffer {scroll_lock|scroll_unlock|toggle_scroll}
Mikael Berthe <mikael@lilotux.net>
parents:
866
diff
changeset
|
1202 |
// 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
|
1203 |
if (win_entry->bd->lock) |
5c857f0f0ab8
Moved all variables related to hbuf to an extra struct, bufdata
Frank Zschockelt
parents:
1156
diff
changeset
|
1204 |
win_entry->bd->top = hbuf_head; |
105 | 1205 |
} else |
1157
5c857f0f0ab8
Moved all variables related to hbuf to an extra struct, bufdata
Frank Zschockelt
parents:
1156
diff
changeset
|
1206 |
hbuf_head = win_entry->bd->top; |
74 | 1207 |
|
2098
c4a68361883f
Lock buffer automatically when scrolled up, unlock when at bottom ("buffer_smart_scrolling" setting)
Hermitifier
parents:
2090
diff
changeset
|
1208 |
// Get the last CHAT_WIN_HEIGHT lines, and one more to detect scroll. |
c4a68361883f
Lock buffer automatically when scrolled up, unlock when at bottom ("buffer_smart_scrolling" setting)
Hermitifier
parents:
2090
diff
changeset
|
1209 |
lines = hbuf_get_lines(hbuf_head, CHAT_WIN_HEIGHT+1); |
74 | 1210 |
|
1948 | 1211 |
if (CHAT_WIN_HEIGHT > 1) { |
1212 |
// Do we have a read mark? |
|
1213 |
for (n = 0; n < CHAT_WIN_HEIGHT; n++) { |
|
1214 |
line = *(lines+n); |
|
1954
256cfc706ae5
Update readmark support
Mikael Berthe <mikael@lilotux.net>
parents:
1950
diff
changeset
|
1215 |
if (line) { |
256cfc706ae5
Update readmark support
Mikael Berthe <mikael@lilotux.net>
parents:
1950
diff
changeset
|
1216 |
if (line->flags & HBB_PREFIX_READMARK) { |
256cfc706ae5
Update readmark support
Mikael Berthe <mikael@lilotux.net>
parents:
1950
diff
changeset
|
1217 |
// If this is not the last line, we'll display a mark |
256cfc706ae5
Update readmark support
Mikael Berthe <mikael@lilotux.net>
parents:
1950
diff
changeset
|
1218 |
if (n+1 < CHAT_WIN_HEIGHT && *(lines+n+1)) { |
256cfc706ae5
Update readmark support
Mikael Berthe <mikael@lilotux.net>
parents:
1950
diff
changeset
|
1219 |
readmark = TRUE; |
256cfc706ae5
Update readmark support
Mikael Berthe <mikael@lilotux.net>
parents:
1950
diff
changeset
|
1220 |
skipline = TRUE; |
256cfc706ae5
Update readmark support
Mikael Berthe <mikael@lilotux.net>
parents:
1950
diff
changeset
|
1221 |
mark_offset = -1; |
256cfc706ae5
Update readmark support
Mikael Berthe <mikael@lilotux.net>
parents:
1950
diff
changeset
|
1222 |
} |
256cfc706ae5
Update readmark support
Mikael Berthe <mikael@lilotux.net>
parents:
1950
diff
changeset
|
1223 |
} |
256cfc706ae5
Update readmark support
Mikael Berthe <mikael@lilotux.net>
parents:
1950
diff
changeset
|
1224 |
} else if (readmark) { |
256cfc706ae5
Update readmark support
Mikael Berthe <mikael@lilotux.net>
parents:
1950
diff
changeset
|
1225 |
// There will be empty lines, so we don't need to skip the first line |
256cfc706ae5
Update readmark support
Mikael Berthe <mikael@lilotux.net>
parents:
1950
diff
changeset
|
1226 |
skipline = FALSE; |
256cfc706ae5
Update readmark support
Mikael Berthe <mikael@lilotux.net>
parents:
1950
diff
changeset
|
1227 |
mark_offset = 0; |
1948 | 1228 |
} |
1229 |
} |
|
1230 |
} |
|
1231 |
||
1232 |
// Display the lines |
|
1233 |
for (n = 0 ; n < CHAT_WIN_HEIGHT; n++) { |
|
2090
16b04d64ec88
Add option to highlight timestamp added by server.
Hermitifier
parents:
2074
diff
changeset
|
1234 |
int timelen; |
1948 | 1235 |
int winy = n + mark_offset; |
1236 |
wmove(win_entry->win, winy, 0); |
|
184 | 1237 |
line = *(lines+n); |
1238 |
if (line) { |
|
1948 | 1239 |
if (skipline) |
1240 |
goto scr_update_window_skipline; |
|
1241 |
||
1204
e802ec0c02d2
Basic support for nick highlighting in MUC rooms (the whole line is colored)
Mikael Berthe <mikael@lilotux.net>
parents:
1190
diff
changeset
|
1242 |
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
|
1243 |
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
|
1244 |
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
|
1245 |
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
|
1246 |
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
|
1247 |
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
|
1248 |
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
|
1249 |
color = COLOR_MSGIN; |
9f64f548ac16
Better way of writing the nick
Michal 'vorner' Vaner <vorner@ucw.cz>
parents:
1290
diff
changeset
|
1250 |
else |
9f64f548ac16
Better way of writing the nick
Michal 'vorner' Vaner <vorner@ucw.cz>
parents:
1290
diff
changeset
|
1251 |
color = COLOR_GENERAL; |
9f64f548ac16
Better way of writing the nick
Michal 'vorner' Vaner <vorner@ucw.cz>
parents:
1290
diff
changeset
|
1252 |
|
9f64f548ac16
Better way of writing the nick
Michal 'vorner' Vaner <vorner@ucw.cz>
parents:
1290
diff
changeset
|
1253 |
if (color != COLOR_GENERAL) |
9f64f548ac16
Better way of writing the nick
Michal 'vorner' Vaner <vorner@ucw.cz>
parents:
1290
diff
changeset
|
1254 |
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
|
1255 |
|
1483
e74cc83e7158
Refactor scr_UpdateWindow()
Mikael Berthe <mikael@lilotux.net>
parents:
1476
diff
changeset
|
1256 |
// Generate the prefix area and display it |
2090
16b04d64ec88
Add option to highlight timestamp added by server.
Hermitifier
parents:
2074
diff
changeset
|
1257 |
|
16b04d64ec88
Add option to highlight timestamp added by server.
Hermitifier
parents:
2074
diff
changeset
|
1258 |
timelen = scr_line_prefix(line, pref, prefixwidth); |
16b04d64ec88
Add option to highlight timestamp added by server.
Hermitifier
parents:
2074
diff
changeset
|
1259 |
if (timelen && line->flags & HBB_PREFIX_DELAYED) { |
16b04d64ec88
Add option to highlight timestamp added by server.
Hermitifier
parents:
2074
diff
changeset
|
1260 |
char tmp; |
16b04d64ec88
Add option to highlight timestamp added by server.
Hermitifier
parents:
2074
diff
changeset
|
1261 |
|
16b04d64ec88
Add option to highlight timestamp added by server.
Hermitifier
parents:
2074
diff
changeset
|
1262 |
tmp = pref[timelen]; |
16b04d64ec88
Add option to highlight timestamp added by server.
Hermitifier
parents:
2074
diff
changeset
|
1263 |
pref[timelen] = '\0'; |
16b04d64ec88
Add option to highlight timestamp added by server.
Hermitifier
parents:
2074
diff
changeset
|
1264 |
wattrset(win_entry->win, get_color(COLOR_TIMESTAMP)); |
16b04d64ec88
Add option to highlight timestamp added by server.
Hermitifier
parents:
2074
diff
changeset
|
1265 |
wprintw(win_entry->win, pref); |
16b04d64ec88
Add option to highlight timestamp added by server.
Hermitifier
parents:
2074
diff
changeset
|
1266 |
pref[timelen] = tmp; |
16b04d64ec88
Add option to highlight timestamp added by server.
Hermitifier
parents:
2074
diff
changeset
|
1267 |
wattrset(win_entry->win, get_color(color)); |
16b04d64ec88
Add option to highlight timestamp added by server.
Hermitifier
parents:
2074
diff
changeset
|
1268 |
wprintw(win_entry->win, pref+timelen); |
16b04d64ec88
Add option to highlight timestamp added by server.
Hermitifier
parents:
2074
diff
changeset
|
1269 |
} else |
16b04d64ec88
Add option to highlight timestamp added by server.
Hermitifier
parents:
2074
diff
changeset
|
1270 |
wprintw(win_entry->win, pref); |
729
39f67cade02c
Use bold font for outgoing messages
Mikael Berthe <mikael@lilotux.net>
parents:
728
diff
changeset
|
1271 |
|
1286
02ad6200df26
Add selectable time prefixes (vorner)
Mikael Berthe <mikael@lilotux.net>
parents:
1284
diff
changeset
|
1272 |
// Make sure we are at the right position |
1948 | 1273 |
wmove(win_entry->win, winy, prefixwidth-1); |
1376
a0deb5124ebf
Check time_prefix value before using it
Mikael Berthe <mikael@lilotux.net>
parents:
1359
diff
changeset
|
1274 |
|
a0deb5124ebf
Check time_prefix value before using it
Mikael Berthe <mikael@lilotux.net>
parents:
1359
diff
changeset
|
1275 |
// The MUC nick - overwrite with proper color |
1294
86caabe72f3a
Color only incoming messages
Michal 'vorner' Vaner <vorner@ucw.cz>
parents:
1292
diff
changeset
|
1276 |
if (line->mucnicklen) { |
1476
77afd831f8f7
Avoid mixed declarations and code
Mikael Berthe <mikael@lilotux.net>
parents:
1457
diff
changeset
|
1277 |
char *mucjid; |
77afd831f8f7
Avoid mixed declarations and code
Mikael Berthe <mikael@lilotux.net>
parents:
1457
diff
changeset
|
1278 |
char tmp; |
77afd831f8f7
Avoid mixed declarations and code
Mikael Berthe <mikael@lilotux.net>
parents:
1457
diff
changeset
|
1279 |
nickcolor *actual = NULL; |
77afd831f8f7
Avoid mixed declarations and code
Mikael Berthe <mikael@lilotux.net>
parents:
1457
diff
changeset
|
1280 |
muccoltype type, *typetmp; |
77afd831f8f7
Avoid mixed declarations and code
Mikael Berthe <mikael@lilotux.net>
parents:
1457
diff
changeset
|
1281 |
|
1376
a0deb5124ebf
Check time_prefix value before using it
Mikael Berthe <mikael@lilotux.net>
parents:
1359
diff
changeset
|
1282 |
// Store the char after the nick |
1476
77afd831f8f7
Avoid mixed declarations and code
Mikael Berthe <mikael@lilotux.net>
parents:
1457
diff
changeset
|
1283 |
tmp = line->text[line->mucnicklen]; |
77afd831f8f7
Avoid mixed declarations and code
Mikael Berthe <mikael@lilotux.net>
parents:
1457
diff
changeset
|
1284 |
type = glob_muccol; |
1376
a0deb5124ebf
Check time_prefix value before using it
Mikael Berthe <mikael@lilotux.net>
parents:
1359
diff
changeset
|
1285 |
// 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
|
1286 |
line->text[line->mucnicklen] = '\0'; |
1476
77afd831f8f7
Avoid mixed declarations and code
Mikael Berthe <mikael@lilotux.net>
parents:
1457
diff
changeset
|
1287 |
mucjid = g_utf8_strdown(CURRENT_JID, -1); |
1292
382ec54b584e
Muc nick coloring functionality
Michal 'vorner' Vaner <vorner@ucw.cz>
parents:
1291
diff
changeset
|
1288 |
if (muccolors) { |
382ec54b584e
Muc nick coloring functionality
Michal 'vorner' Vaner <vorner@ucw.cz>
parents:
1291
diff
changeset
|
1289 |
typetmp = g_hash_table_lookup(muccolors, mucjid); |
382ec54b584e
Muc nick coloring functionality
Michal 'vorner' Vaner <vorner@ucw.cz>
parents:
1291
diff
changeset
|
1290 |
if (typetmp) |
382ec54b584e
Muc nick coloring functionality
Michal 'vorner' Vaner <vorner@ucw.cz>
parents:
1291
diff
changeset
|
1291 |
type = *typetmp; |
382ec54b584e
Muc nick coloring functionality
Michal 'vorner' Vaner <vorner@ucw.cz>
parents:
1291
diff
changeset
|
1292 |
} |
382ec54b584e
Muc nick coloring functionality
Michal 'vorner' Vaner <vorner@ucw.cz>
parents:
1291
diff
changeset
|
1293 |
g_free(mucjid); |
1510
f6d4e20b9caa
MUC nickname colors depend on nicknames now
Maxim Vuets <maxim.vuets@gmail.com>
parents:
1505
diff
changeset
|
1294 |
// 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
|
1295 |
if ((type == MC_ALL) && (!nickcolors || |
382ec54b584e
Muc nick coloring functionality
Michal 'vorner' Vaner <vorner@ucw.cz>
parents:
1291
diff
changeset
|
1296 |
!g_hash_table_lookup(nickcolors, line->text))) { |
1476
77afd831f8f7
Avoid mixed declarations and code
Mikael Berthe <mikael@lilotux.net>
parents:
1457
diff
changeset
|
1297 |
char *snick, *mnick; |
77afd831f8f7
Avoid mixed declarations and code
Mikael Berthe <mikael@lilotux.net>
parents:
1457
diff
changeset
|
1298 |
nickcolor *nc; |
1510
f6d4e20b9caa
MUC nickname colors depend on nicknames now
Maxim Vuets <maxim.vuets@gmail.com>
parents:
1505
diff
changeset
|
1299 |
const char *p = line->text; |
f6d4e20b9caa
MUC nickname colors depend on nicknames now
Maxim Vuets <maxim.vuets@gmail.com>
parents:
1505
diff
changeset
|
1300 |
unsigned int nicksum = 0; |
1476
77afd831f8f7
Avoid mixed declarations and code
Mikael Berthe <mikael@lilotux.net>
parents:
1457
diff
changeset
|
1301 |
snick = g_strdup(line->text); |
77afd831f8f7
Avoid mixed declarations and code
Mikael Berthe <mikael@lilotux.net>
parents:
1457
diff
changeset
|
1302 |
mnick = g_strdup(line->text); |
77afd831f8f7
Avoid mixed declarations and code
Mikael Berthe <mikael@lilotux.net>
parents:
1457
diff
changeset
|
1303 |
nc = g_new(nickcolor, 1); |
1292
382ec54b584e
Muc nick coloring functionality
Michal 'vorner' Vaner <vorner@ucw.cz>
parents:
1291
diff
changeset
|
1304 |
ensure_string_htable(&nickcolors, NULL); |
1510
f6d4e20b9caa
MUC nickname colors depend on nicknames now
Maxim Vuets <maxim.vuets@gmail.com>
parents:
1505
diff
changeset
|
1305 |
while (*p) |
f6d4e20b9caa
MUC nickname colors depend on nicknames now
Maxim Vuets <maxim.vuets@gmail.com>
parents:
1505
diff
changeset
|
1306 |
nicksum += *p++; |
f6d4e20b9caa
MUC nickname colors depend on nicknames now
Maxim Vuets <maxim.vuets@gmail.com>
parents:
1505
diff
changeset
|
1307 |
nc->color = nickcols[nicksum % nickcolcount]; |
1381
40095d413da9
Fix compilation on OpenBSD
Mikael Berthe <mikael@lilotux.net>
parents:
1376
diff
changeset
|
1308 |
nc->manual = FALSE; |
1292
382ec54b584e
Muc nick coloring functionality
Michal 'vorner' Vaner <vorner@ucw.cz>
parents:
1291
diff
changeset
|
1309 |
*snick = '<'; |
382ec54b584e
Muc nick coloring functionality
Michal 'vorner' Vaner <vorner@ucw.cz>
parents:
1291
diff
changeset
|
1310 |
snick[strlen(snick)-1] = '>'; |
382ec54b584e
Muc nick coloring functionality
Michal 'vorner' Vaner <vorner@ucw.cz>
parents:
1291
diff
changeset
|
1311 |
*mnick = '*'; |
382ec54b584e
Muc nick coloring functionality
Michal 'vorner' Vaner <vorner@ucw.cz>
parents:
1291
diff
changeset
|
1312 |
mnick[strlen(mnick)-1] = ' '; |
1376
a0deb5124ebf
Check time_prefix value before using it
Mikael Berthe <mikael@lilotux.net>
parents:
1359
diff
changeset
|
1313 |
// Insert them |
1292
382ec54b584e
Muc nick coloring functionality
Michal 'vorner' Vaner <vorner@ucw.cz>
parents:
1291
diff
changeset
|
1314 |
g_hash_table_insert(nickcolors, snick, nc); |
382ec54b584e
Muc nick coloring functionality
Michal 'vorner' Vaner <vorner@ucw.cz>
parents:
1291
diff
changeset
|
1315 |
g_hash_table_insert(nickcolors, mnick, nc); |
382ec54b584e
Muc nick coloring functionality
Michal 'vorner' Vaner <vorner@ucw.cz>
parents:
1291
diff
changeset
|
1316 |
} |
382ec54b584e
Muc nick coloring functionality
Michal 'vorner' Vaner <vorner@ucw.cz>
parents:
1291
diff
changeset
|
1317 |
if (nickcolors) |
382ec54b584e
Muc nick coloring functionality
Michal 'vorner' Vaner <vorner@ucw.cz>
parents:
1291
diff
changeset
|
1318 |
actual = g_hash_table_lookup(nickcolors, line->text); |
1294
86caabe72f3a
Color only incoming messages
Michal 'vorner' Vaner <vorner@ucw.cz>
parents:
1292
diff
changeset
|
1319 |
if (actual && ((type == MC_ALL) || (actual->manual)) |
86caabe72f3a
Color only incoming messages
Michal 'vorner' Vaner <vorner@ucw.cz>
parents:
1292
diff
changeset
|
1320 |
&& (line->flags & HBB_PREFIX_IN) && |
86caabe72f3a
Color only incoming messages
Michal 'vorner' Vaner <vorner@ucw.cz>
parents:
1292
diff
changeset
|
1321 |
(!(line->flags & HBB_PREFIX_HLIGHT_OUT))) |
1489
e9c71ce96dca
Fixed the colorhandling for mucnicks and /color roster
franky@veqlargh.fs
parents:
1488
diff
changeset
|
1322 |
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
|
1323 |
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
|
1324 |
// Return the char |
1290
e42f48103609
Drawing the MUC nicks by a different color
Michal 'vorner' Vaner <vorner@ucw.cz>
parents:
1286
diff
changeset
|
1325 |
line->text[line->mucnicklen] = tmp; |
1376
a0deb5124ebf
Check time_prefix value before using it
Mikael Berthe <mikael@lilotux.net>
parents:
1359
diff
changeset
|
1326 |
// Return the color back |
1291
9f64f548ac16
Better way of writing the nick
Michal 'vorner' Vaner <vorner@ucw.cz>
parents:
1290
diff
changeset
|
1327 |
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
|
1328 |
} |
729
39f67cade02c
Use bold font for outgoing messages
Mikael Berthe <mikael@lilotux.net>
parents:
728
diff
changeset
|
1329 |
|
1333
e30a9d907105
Minor coding style adjustments
Mikael Berthe <mikael@lilotux.net>
parents:
1314
diff
changeset
|
1330 |
// Display text line |
e30a9d907105
Minor coding style adjustments
Mikael Berthe <mikael@lilotux.net>
parents:
1314
diff
changeset
|
1331 |
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
|
1332 |
wclrtoeol(win_entry->win); |
9f64f548ac16
Better way of writing the nick
Michal 'vorner' Vaner <vorner@ucw.cz>
parents:
1290
diff
changeset
|
1333 |
|
1948 | 1334 |
scr_update_window_skipline: |
1335 |
skipline = FALSE; |
|
1336 |
if (readmark && line->flags & HBB_PREFIX_READMARK) { |
|
1337 |
int i, w; |
|
1338 |
mark_offset++; |
|
1339 |
||
1340 |
// Display the mark |
|
1341 |
winy = n + mark_offset; |
|
1342 |
wmove(win_entry->win, winy, 0); |
|
1965
ec737f5f1d6f
Couple of readmark-related bugfixes
Mikael Berthe <mikael@lilotux.net>
parents:
1961
diff
changeset
|
1343 |
color = COLOR_READMARK; |
ec737f5f1d6f
Couple of readmark-related bugfixes
Mikael Berthe <mikael@lilotux.net>
parents:
1961
diff
changeset
|
1344 |
wattrset(win_entry->win, get_color(color)); |
1948 | 1345 |
g_snprintf(pref, prefixwidth, " == "); |
1346 |
wprintw(win_entry->win, pref); |
|
1347 |
w = scr_gettextwidth() / 3; |
|
1348 |
for (i=0; i<w; i++) |
|
1349 |
wprintw(win_entry->win, "== "); |
|
1350 |
wclrtoeol(win_entry->win); |
|
1960 | 1351 |
wattrset(win_entry->win, get_color(COLOR_GENERAL)); |
1948 | 1352 |
} |
1353 |
||
1965
ec737f5f1d6f
Couple of readmark-related bugfixes
Mikael Berthe <mikael@lilotux.net>
parents:
1961
diff
changeset
|
1354 |
// Restore default ("general") color |
ec737f5f1d6f
Couple of readmark-related bugfixes
Mikael Berthe <mikael@lilotux.net>
parents:
1961
diff
changeset
|
1355 |
if (color != COLOR_GENERAL) |
ec737f5f1d6f
Couple of readmark-related bugfixes
Mikael Berthe <mikael@lilotux.net>
parents:
1961
diff
changeset
|
1356 |
wattrset(win_entry->win, get_color(COLOR_GENERAL)); |
ec737f5f1d6f
Couple of readmark-related bugfixes
Mikael Berthe <mikael@lilotux.net>
parents:
1961
diff
changeset
|
1357 |
|
184 | 1358 |
g_free(line->text); |
898
c65b71dcda94
Fix memory leak in scr_UpdateWindow()
Mikael Berthe <mikael@lilotux.net>
parents:
897
diff
changeset
|
1359 |
g_free(line); |
168 | 1360 |
} else { |
1361 |
wclrtobot(win_entry->win); |
|
1362 |
break; |
|
75 | 1363 |
} |
74 | 1364 |
} |
2098
c4a68361883f
Lock buffer automatically when scrolled up, unlock when at bottom ("buffer_smart_scrolling" setting)
Hermitifier
parents:
2090
diff
changeset
|
1365 |
line = *(lines+CHAT_WIN_HEIGHT); //line is scrolled out and never written |
c4a68361883f
Lock buffer automatically when scrolled up, unlock when at bottom ("buffer_smart_scrolling" setting)
Hermitifier
parents:
2090
diff
changeset
|
1366 |
if (line) { |
c4a68361883f
Lock buffer automatically when scrolled up, unlock when at bottom ("buffer_smart_scrolling" setting)
Hermitifier
parents:
2090
diff
changeset
|
1367 |
if (autolock && !win_entry->bd->lock) { |
c4a68361883f
Lock buffer automatically when scrolled up, unlock when at bottom ("buffer_smart_scrolling" setting)
Hermitifier
parents:
2090
diff
changeset
|
1368 |
if (!hbuf_jump_readmark(hbuf_head)) |
c4a68361883f
Lock buffer automatically when scrolled up, unlock when at bottom ("buffer_smart_scrolling" setting)
Hermitifier
parents:
2090
diff
changeset
|
1369 |
scr_buffer_readmark(TRUE); |
c4a68361883f
Lock buffer automatically when scrolled up, unlock when at bottom ("buffer_smart_scrolling" setting)
Hermitifier
parents:
2090
diff
changeset
|
1370 |
scr_buffer_scroll_lock(1); |
c4a68361883f
Lock buffer automatically when scrolled up, unlock when at bottom ("buffer_smart_scrolling" setting)
Hermitifier
parents:
2090
diff
changeset
|
1371 |
} |
c4a68361883f
Lock buffer automatically when scrolled up, unlock when at bottom ("buffer_smart_scrolling" setting)
Hermitifier
parents:
2090
diff
changeset
|
1372 |
g_free(line->text); |
c4a68361883f
Lock buffer automatically when scrolled up, unlock when at bottom ("buffer_smart_scrolling" setting)
Hermitifier
parents:
2090
diff
changeset
|
1373 |
g_free(line); |
c4a68361883f
Lock buffer automatically when scrolled up, unlock when at bottom ("buffer_smart_scrolling" setting)
Hermitifier
parents:
2090
diff
changeset
|
1374 |
} else if (autolock && win_entry->bd->lock) { |
c4a68361883f
Lock buffer automatically when scrolled up, unlock when at bottom ("buffer_smart_scrolling" setting)
Hermitifier
parents:
2090
diff
changeset
|
1375 |
scr_buffer_scroll_lock(0); |
c4a68361883f
Lock buffer automatically when scrolled up, unlock when at bottom ("buffer_smart_scrolling" setting)
Hermitifier
parents:
2090
diff
changeset
|
1376 |
} |
c4a68361883f
Lock buffer automatically when scrolled up, unlock when at bottom ("buffer_smart_scrolling" setting)
Hermitifier
parents:
2090
diff
changeset
|
1377 |
|
74 | 1378 |
g_free(lines); |
1379 |
} |
|
1159
53c0c5be43fa
Small fixes, typos and cleanups
Mikael Berthe <mikael@lilotux.net>
parents:
1157
diff
changeset
|
1380 |
|
1780
e4378fbab5d7
Major API cleanup - bump API to 4
Mikael Berthe <mikael@lilotux.net>
parents:
1761
diff
changeset
|
1381 |
static winbuf *scr_create_window(const char *winId, int special, int dont_show) |
1154 | 1382 |
{ |
1383 |
if (special) { |
|
1384 |
if (!statusWindow) { |
|
1385 |
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
|
1386 |
statusWindow->bd->hbuf = statushbuf; |
1154 | 1387 |
} |
1388 |
return statusWindow; |
|
1389 |
} else { |
|
1390 |
return scr_new_buddy(winId, dont_show); |
|
1391 |
} |
|
1392 |
} |
|
1393 |
||
1780
e4378fbab5d7
Major API cleanup - bump API to 4
Mikael Berthe <mikael@lilotux.net>
parents:
1761
diff
changeset
|
1394 |
// scr_show_window() |
143 | 1395 |
// Display the chat window with the given identifier. |
849
42c43a88d823
Status buffer management
Mikael Berthe <mikael@lilotux.net>
parents:
848
diff
changeset
|
1396 |
// "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
|
1397 |
static void scr_show_window(const char *winId, int special) |
24 | 1398 |
{ |
849
42c43a88d823
Status buffer management
Mikael Berthe <mikael@lilotux.net>
parents:
848
diff
changeset
|
1399 |
winbuf *win_entry; |
42c43a88d823
Status buffer management
Mikael Berthe <mikael@lilotux.net>
parents:
848
diff
changeset
|
1400 |
|
1780
e4378fbab5d7
Major API cleanup - bump API to 4
Mikael Berthe <mikael@lilotux.net>
parents:
1761
diff
changeset
|
1401 |
win_entry = scr_search_window(winId, special); |
74 | 1402 |
|
849
42c43a88d823
Status buffer management
Mikael Berthe <mikael@lilotux.net>
parents:
848
diff
changeset
|
1403 |
if (!win_entry) { |
1780
e4378fbab5d7
Major API cleanup - bump API to 4
Mikael Berthe <mikael@lilotux.net>
parents:
1761
diff
changeset
|
1404 |
win_entry = scr_create_window(winId, special, FALSE); |
849
42c43a88d823
Status buffer management
Mikael Berthe <mikael@lilotux.net>
parents:
848
diff
changeset
|
1405 |
} |
74 | 1406 |
|
180 | 1407 |
top_panel(win_entry->panel); |
1408 |
currentWindow = win_entry; |
|
1409 |
chatmode = TRUE; |
|
1157
5c857f0f0ab8
Moved all variables related to hbuf to an extra struct, bufdata
Frank Zschockelt
parents:
1156
diff
changeset
|
1410 |
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
|
1411 |
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
|
1412 |
if (!special) |
849
42c43a88d823
Status buffer management
Mikael Berthe <mikael@lilotux.net>
parents:
848
diff
changeset
|
1413 |
roster_setflags(winId, ROSTER_FLAG_LOCK, TRUE); |
2292
f181418db215
Replace global variable update_roster with scr_update_roster()
franky
parents:
2291
diff
changeset
|
1414 |
scr_update_roster(); |
74 | 1415 |
|
180 | 1416 |
// Refresh the window |
1780
e4378fbab5d7
Major API cleanup - bump API to 4
Mikael Berthe <mikael@lilotux.net>
parents:
1761
diff
changeset
|
1417 |
scr_update_window(win_entry); |
180 | 1418 |
|
1419 |
// Finished :) |
|
1420 |
update_panels(); |
|
142 | 1421 |
|
1422 |
top_panel(inputPanel); |
|
24 | 1423 |
} |
1424 |
||
1780
e4378fbab5d7
Major API cleanup - bump API to 4
Mikael Berthe <mikael@lilotux.net>
parents:
1761
diff
changeset
|
1425 |
// scr_show_buddy_window() |
143 | 1426 |
// 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
|
1427 |
void scr_show_buddy_window(void) |
24 | 1428 |
{ |
1058 | 1429 |
const gchar *bjid; |
140 | 1430 |
|
849
42c43a88d823
Status buffer management
Mikael Berthe <mikael@lilotux.net>
parents:
848
diff
changeset
|
1431 |
if (!current_buddy) { |
1058 | 1432 |
bjid = NULL; |
849
42c43a88d823
Status buffer management
Mikael Berthe <mikael@lilotux.net>
parents:
848
diff
changeset
|
1433 |
} else { |
1058 | 1434 |
bjid = CURRENT_JID; |
849
42c43a88d823
Status buffer management
Mikael Berthe <mikael@lilotux.net>
parents:
848
diff
changeset
|
1435 |
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
|
1436 |
scr_show_window(buddy_getname(BUDDATA(current_buddy)), TRUE); |
849
42c43a88d823
Status buffer management
Mikael Berthe <mikael@lilotux.net>
parents:
848
diff
changeset
|
1437 |
return; |
42c43a88d823
Status buffer management
Mikael Berthe <mikael@lilotux.net>
parents:
848
diff
changeset
|
1438 |
} |
42c43a88d823
Status buffer management
Mikael Berthe <mikael@lilotux.net>
parents:
848
diff
changeset
|
1439 |
} |
140 | 1440 |
|
1058 | 1441 |
if (!bjid) { |
140 | 1442 |
top_panel(chatPanel); |
143 | 1443 |
top_panel(inputPanel); |
140 | 1444 |
currentWindow = NULL; |
105 | 1445 |
return; |
140 | 1446 |
} |
1447 |
||
1780
e4378fbab5d7
Major API cleanup - bump API to 4
Mikael Berthe <mikael@lilotux.net>
parents:
1761
diff
changeset
|
1448 |
scr_show_window(bjid, FALSE); |
24 | 1449 |
} |
1450 |
||
1780
e4378fbab5d7
Major API cleanup - bump API to 4
Mikael Berthe <mikael@lilotux.net>
parents:
1761
diff
changeset
|
1451 |
// scr_update_buddy_window() |
865
cee8d6be04e1
Improve changeset a3db3ee8b99e, do not enable chatmode when refreshing
Mikael Berthe <mikael@lilotux.net>
parents:
858
diff
changeset
|
1452 |
// (Re)Display the current window. |
1780
e4378fbab5d7
Major API cleanup - bump API to 4
Mikael Berthe <mikael@lilotux.net>
parents:
1761
diff
changeset
|
1453 |
// 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
|
1454 |
// else display the chat window. |
1780
e4378fbab5d7
Major API cleanup - bump API to 4
Mikael Berthe <mikael@lilotux.net>
parents:
1761
diff
changeset
|
1455 |
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
|
1456 |
{ |
cee8d6be04e1
Improve changeset a3db3ee8b99e, do not enable chatmode when refreshing
Mikael Berthe <mikael@lilotux.net>
parents:
858
diff
changeset
|
1457 |
if (chatmode) { |
1780
e4378fbab5d7
Major API cleanup - bump API to 4
Mikael Berthe <mikael@lilotux.net>
parents:
1761
diff
changeset
|
1458 |
scr_show_buddy_window(); |
865
cee8d6be04e1
Improve changeset a3db3ee8b99e, do not enable chatmode when refreshing
Mikael Berthe <mikael@lilotux.net>
parents:
858
diff
changeset
|
1459 |
return; |
cee8d6be04e1
Improve changeset a3db3ee8b99e, do not enable chatmode when refreshing
Mikael Berthe <mikael@lilotux.net>
parents:
858
diff
changeset
|
1460 |
} |
cee8d6be04e1
Improve changeset a3db3ee8b99e, do not enable chatmode when refreshing
Mikael Berthe <mikael@lilotux.net>
parents:
858
diff
changeset
|
1461 |
|
cee8d6be04e1
Improve changeset a3db3ee8b99e, do not enable chatmode when refreshing
Mikael Berthe <mikael@lilotux.net>
parents:
858
diff
changeset
|
1462 |
top_panel(chatPanel); |
cee8d6be04e1
Improve changeset a3db3ee8b99e, do not enable chatmode when refreshing
Mikael Berthe <mikael@lilotux.net>
parents:
858
diff
changeset
|
1463 |
top_panel(inputPanel); |
cee8d6be04e1
Improve changeset a3db3ee8b99e, do not enable chatmode when refreshing
Mikael Berthe <mikael@lilotux.net>
parents:
858
diff
changeset
|
1464 |
} |
cee8d6be04e1
Improve changeset a3db3ee8b99e, do not enable chatmode when refreshing
Mikael Berthe <mikael@lilotux.net>
parents:
858
diff
changeset
|
1465 |
|
1780
e4378fbab5d7
Major API cleanup - bump API to 4
Mikael Berthe <mikael@lilotux.net>
parents:
1761
diff
changeset
|
1466 |
// scr_write_in_window() |
143 | 1467 |
// 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
|
1468 |
// Use winId == NULL for the special status buffer. |
143 | 1469 |
// Lines are splitted when they are too long to fit in the chat window. |
1470 |
// 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
|
1471 |
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
|
1472 |
time_t timestamp, unsigned int prefix_flags, |
e4378fbab5d7
Major API cleanup - bump API to 4
Mikael Berthe <mikael@lilotux.net>
parents:
1761
diff
changeset
|
1473 |
int force_show, unsigned mucnicklen, |
e4378fbab5d7
Major API cleanup - bump API to 4
Mikael Berthe <mikael@lilotux.net>
parents:
1761
diff
changeset
|
1474 |
gpointer xep184) |
24 | 1475 |
{ |
822 | 1476 |
winbuf *win_entry; |
772
464be13343a9
Store most data in UTF-8 internally
Mikael Berthe <mikael@lilotux.net>
parents:
771
diff
changeset
|
1477 |
char *text_locale; |
24 | 1478 |
int dont_show = FALSE; |
849
42c43a88d823
Status buffer management
Mikael Berthe <mikael@lilotux.net>
parents:
848
diff
changeset
|
1479 |
int special; |
1142
0e27177882c7
Small fix for the max_history_blocks option
Mikael Berthe <mikael@lilotux.net>
parents:
1141
diff
changeset
|
1480 |
guint num_history_blocks; |
873
ee39f6d94d43
Add /buffer {scroll_lock|scroll_unlock|toggle_scroll}
Mikael Berthe <mikael@lilotux.net>
parents:
866
diff
changeset
|
1481 |
bool setmsgflg = FALSE; |
2190
ee3a40ffcd8b
New option: 'clear_unread_on_carbon'
Holger Weiß <holger@zedat.fu-berlin.de>
parents:
2181
diff
changeset
|
1482 |
bool clearmsgflg = FALSE; |
1296
7a0eaa53bd53
Further nick colors fixes
Michal 'vorner' Vaner <vorner@ucw.cz>
parents:
1295
diff
changeset
|
1483 |
char *nicktmp, *nicklocaltmp; |
24 | 1484 |
|
74 | 1485 |
// Look for the window entry. |
849
42c43a88d823
Status buffer management
Mikael Berthe <mikael@lilotux.net>
parents:
848
diff
changeset
|
1486 |
special = (winId == NULL); |
1780
e4378fbab5d7
Major API cleanup - bump API to 4
Mikael Berthe <mikael@lilotux.net>
parents:
1761
diff
changeset
|
1487 |
win_entry = scr_search_window(winId, special); |
74 | 1488 |
|
1489 |
// Do we have to really show the window? |
|
24 | 1490 |
if (!chatmode) |
1491 |
dont_show = TRUE; |
|
74 | 1492 |
else if ((!force_show) && ((!currentWindow || (currentWindow != win_entry)))) |
24 | 1493 |
dont_show = TRUE; |
1494 |
||
74 | 1495 |
// 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
|
1496 |
if (!win_entry) { |
1780
e4378fbab5d7
Major API cleanup - bump API to 4
Mikael Berthe <mikael@lilotux.net>
parents:
1761
diff
changeset
|
1497 |
win_entry = scr_create_window(winId, special, dont_show); |
24 | 1498 |
} |
1499 |
||
220 | 1500 |
// 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
|
1501 |
if (win_entry->bd->cleared) |
5c857f0f0ab8
Moved all variables related to hbuf to an extra struct, bufdata
Frank Zschockelt
parents:
1156
diff
changeset
|
1502 |
win_entry->bd->top = g_list_last(win_entry->bd->hbuf); |
220 | 1503 |
|
1142
0e27177882c7
Small fix for the max_history_blocks option
Mikael Berthe <mikael@lilotux.net>
parents:
1141
diff
changeset
|
1504 |
// 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
|
1505 |
// top is set. |
1157
5c857f0f0ab8
Moved all variables related to hbuf to an extra struct, bufdata
Frank Zschockelt
parents:
1156
diff
changeset
|
1506 |
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
|
1507 |
num_history_blocks = 0U; |
0e27177882c7
Small fix for the max_history_blocks option
Mikael Berthe <mikael@lilotux.net>
parents:
1141
diff
changeset
|
1508 |
else |
0e27177882c7
Small fix for the max_history_blocks option
Mikael Berthe <mikael@lilotux.net>
parents:
1141
diff
changeset
|
1509 |
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
|
1510 |
|
772
464be13343a9
Store most data in UTF-8 internally
Mikael Berthe <mikael@lilotux.net>
parents:
771
diff
changeset
|
1511 |
text_locale = from_utf8(text); |
1729
e6e89b1d7831
Minor style and header updates
Mikael Berthe <mikael@lilotux.net>
parents:
1710
diff
changeset
|
1512 |
// Convert the nick alone and compute its length |
1296
7a0eaa53bd53
Further nick colors fixes
Michal 'vorner' Vaner <vorner@ucw.cz>
parents:
1295
diff
changeset
|
1513 |
if (mucnicklen) { |
7a0eaa53bd53
Further nick colors fixes
Michal 'vorner' Vaner <vorner@ucw.cz>
parents:
1295
diff
changeset
|
1514 |
nicktmp = g_strndup(text, mucnicklen); |
7a0eaa53bd53
Further nick colors fixes
Michal 'vorner' Vaner <vorner@ucw.cz>
parents:
1295
diff
changeset
|
1515 |
nicklocaltmp = from_utf8(nicktmp); |
1918
0fa6df17bc5c
Fix potential issue pointed out by franky's clang report
Mikael Berthe <mikael@lilotux.net>
parents:
1915
diff
changeset
|
1516 |
if (nicklocaltmp) |
0fa6df17bc5c
Fix potential issue pointed out by franky's clang report
Mikael Berthe <mikael@lilotux.net>
parents:
1915
diff
changeset
|
1517 |
mucnicklen = strlen(nicklocaltmp); |
1296
7a0eaa53bd53
Further nick colors fixes
Michal 'vorner' Vaner <vorner@ucw.cz>
parents:
1295
diff
changeset
|
1518 |
g_free(nicklocaltmp); |
7a0eaa53bd53
Further nick colors fixes
Michal 'vorner' Vaner <vorner@ucw.cz>
parents:
1295
diff
changeset
|
1519 |
g_free(nicktmp); |
7a0eaa53bd53
Further nick colors fixes
Michal 'vorner' Vaner <vorner@ucw.cz>
parents:
1295
diff
changeset
|
1520 |
} |
1157
5c857f0f0ab8
Moved all variables related to hbuf to an extra struct, bufdata
Frank Zschockelt
parents:
1156
diff
changeset
|
1521 |
hbuf_add_line(&win_entry->bd->hbuf, text_locale, timestamp, prefix_flags, |
1487 | 1522 |
maxX - Roster_Width - scr_getprefixwidth(), num_history_blocks, |
1602 | 1523 |
mucnicklen, xep184); |
772
464be13343a9
Store most data in UTF-8 internally
Mikael Berthe <mikael@lilotux.net>
parents:
771
diff
changeset
|
1524 |
g_free(text_locale); |
74 | 1525 |
|
1157
5c857f0f0ab8
Moved all variables related to hbuf to an extra struct, bufdata
Frank Zschockelt
parents:
1156
diff
changeset
|
1526 |
if (win_entry->bd->cleared) { |
5c857f0f0ab8
Moved all variables related to hbuf to an extra struct, bufdata
Frank Zschockelt
parents:
1156
diff
changeset
|
1527 |
win_entry->bd->cleared = FALSE; |
5c857f0f0ab8
Moved all variables related to hbuf to an extra struct, bufdata
Frank Zschockelt
parents:
1156
diff
changeset
|
1528 |
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
|
1529 |
win_entry->bd->top = g_list_next(win_entry->bd->top); |
220 | 1530 |
} |
1531 |
||
1532 |
// 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
|
1533 |
if (!win_entry->bd->lock && win_entry->bd->top) { |
220 | 1534 |
int dist; |
1157
5c857f0f0ab8
Moved all variables related to hbuf to an extra struct, bufdata
Frank Zschockelt
parents:
1156
diff
changeset
|
1535 |
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
|
1536 |
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
|
1537 |
g_list_position(first, win_entry->bd->top); |
220 | 1538 |
if (dist >= CHAT_WIN_HEIGHT) |
1157
5c857f0f0ab8
Moved all variables related to hbuf to an extra struct, bufdata
Frank Zschockelt
parents:
1156
diff
changeset
|
1539 |
win_entry->bd->top = NULL; |
108 | 1540 |
} |
1541 |
||
24 | 1542 |
if (!dont_show) { |
1157
5c857f0f0ab8
Moved all variables related to hbuf to an extra struct, bufdata
Frank Zschockelt
parents:
1156
diff
changeset
|
1543 |
if (win_entry->bd->lock) |
873
ee39f6d94d43
Add /buffer {scroll_lock|scroll_unlock|toggle_scroll}
Mikael Berthe <mikael@lilotux.net>
parents:
866
diff
changeset
|
1544 |
setmsgflg = TRUE; |
1955
fad27c72a229
Don't update readmark when buffer scroll_lock is set
Mikael Berthe <mikael@lilotux.net>
parents:
1954
diff
changeset
|
1545 |
else |
1961
39021fd6b0e1
Try to improve readmarks in some cases
Mikael Berthe <mikael@lilotux.net>
parents:
1960
diff
changeset
|
1546 |
// If this is an outgoing message, remove the readmark |
1955
fad27c72a229
Don't update readmark when buffer scroll_lock is set
Mikael Berthe <mikael@lilotux.net>
parents:
1954
diff
changeset
|
1547 |
if (!special && (prefix_flags & (HBB_PREFIX_OUT|HBB_PREFIX_HLIGHT_OUT))) |
fad27c72a229
Don't update readmark when buffer scroll_lock is set
Mikael Berthe <mikael@lilotux.net>
parents:
1954
diff
changeset
|
1548 |
hbuf_set_readmark(win_entry->bd->hbuf, FALSE); |
74 | 1549 |
// Show and refresh the window |
1550 |
top_panel(win_entry->panel); |
|
1780
e4378fbab5d7
Major API cleanup - bump API to 4
Mikael Berthe <mikael@lilotux.net>
parents:
1761
diff
changeset
|
1551 |
scr_update_window(win_entry); |
142 | 1552 |
top_panel(inputPanel); |
24 | 1553 |
update_panels(); |
2190
ee3a40ffcd8b
New option: 'clear_unread_on_carbon'
Holger Weiß <holger@zedat.fu-berlin.de>
parents:
2181
diff
changeset
|
1554 |
} else if (settings_opt_get_int("clear_unread_on_carbon") && |
ee3a40ffcd8b
New option: 'clear_unread_on_carbon'
Holger Weiß <holger@zedat.fu-berlin.de>
parents:
2181
diff
changeset
|
1555 |
prefix_flags & HBB_PREFIX_OUT && |
ee3a40ffcd8b
New option: 'clear_unread_on_carbon'
Holger Weiß <holger@zedat.fu-berlin.de>
parents:
2181
diff
changeset
|
1556 |
prefix_flags & HBB_PREFIX_CARBON) { |
ee3a40ffcd8b
New option: 'clear_unread_on_carbon'
Holger Weiß <holger@zedat.fu-berlin.de>
parents:
2181
diff
changeset
|
1557 |
clearmsgflg = TRUE; |
873
ee39f6d94d43
Add /buffer {scroll_lock|scroll_unlock|toggle_scroll}
Mikael Berthe <mikael@lilotux.net>
parents:
866
diff
changeset
|
1558 |
} 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
|
1559 |
setmsgflg = TRUE; |
ee39f6d94d43
Add /buffer {scroll_lock|scroll_unlock|toggle_scroll}
Mikael Berthe <mikael@lilotux.net>
parents:
866
diff
changeset
|
1560 |
} |
2190
ee3a40ffcd8b
New option: 'clear_unread_on_carbon'
Holger Weiß <holger@zedat.fu-berlin.de>
parents:
2181
diff
changeset
|
1561 |
if (!special) { |
ee3a40ffcd8b
New option: 'clear_unread_on_carbon'
Holger Weiß <holger@zedat.fu-berlin.de>
parents:
2181
diff
changeset
|
1562 |
if (clearmsgflg) { |
ee3a40ffcd8b
New option: 'clear_unread_on_carbon'
Holger Weiß <holger@zedat.fu-berlin.de>
parents:
2181
diff
changeset
|
1563 |
roster_msg_setflag(winId, FALSE, FALSE); |
2292
f181418db215
Replace global variable update_roster with scr_update_roster()
franky
parents:
2291
diff
changeset
|
1564 |
scr_update_roster(); |
2190
ee3a40ffcd8b
New option: 'clear_unread_on_carbon'
Holger Weiß <holger@zedat.fu-berlin.de>
parents:
2181
diff
changeset
|
1565 |
} else if (setmsgflg) { |
ee3a40ffcd8b
New option: 'clear_unread_on_carbon'
Holger Weiß <holger@zedat.fu-berlin.de>
parents:
2181
diff
changeset
|
1566 |
roster_msg_setflag(winId, FALSE, TRUE); |
2292
f181418db215
Replace global variable update_roster with scr_update_roster()
franky
parents:
2291
diff
changeset
|
1567 |
scr_update_roster(); |
2190
ee3a40ffcd8b
New option: 'clear_unread_on_carbon'
Holger Weiß <holger@zedat.fu-berlin.de>
parents:
2181
diff
changeset
|
1568 |
} |
24 | 1569 |
} |
1570 |
} |
|
1571 |
||
2101
f56c214a19dc
Add a guard for 'attention_char'
Mikael Berthe <mikael@lilotux.net>
parents:
2100
diff
changeset
|
1572 |
static char *attention_sign_guard(const gchar *key, const gchar *new_value) |
f56c214a19dc
Add a guard for 'attention_char'
Mikael Berthe <mikael@lilotux.net>
parents:
2100
diff
changeset
|
1573 |
{ |
2292
f181418db215
Replace global variable update_roster with scr_update_roster()
franky
parents:
2291
diff
changeset
|
1574 |
scr_update_roster(); |
2101
f56c214a19dc
Add a guard for 'attention_char'
Mikael Berthe <mikael@lilotux.net>
parents:
2100
diff
changeset
|
1575 |
if (g_strcmp0(settings_opt_get(key), new_value)) { |
f56c214a19dc
Add a guard for 'attention_char'
Mikael Berthe <mikael@lilotux.net>
parents:
2100
diff
changeset
|
1576 |
guint sign; |
f56c214a19dc
Add a guard for 'attention_char'
Mikael Berthe <mikael@lilotux.net>
parents:
2100
diff
changeset
|
1577 |
char *c; |
f56c214a19dc
Add a guard for 'attention_char'
Mikael Berthe <mikael@lilotux.net>
parents:
2100
diff
changeset
|
1578 |
if (!new_value || !*new_value) |
f56c214a19dc
Add a guard for 'attention_char'
Mikael Berthe <mikael@lilotux.net>
parents:
2100
diff
changeset
|
1579 |
return NULL; |
f56c214a19dc
Add a guard for 'attention_char'
Mikael Berthe <mikael@lilotux.net>
parents:
2100
diff
changeset
|
1580 |
sign = get_char(new_value); |
f56c214a19dc
Add a guard for 'attention_char'
Mikael Berthe <mikael@lilotux.net>
parents:
2100
diff
changeset
|
1581 |
c = next_char((char*)new_value); |
f56c214a19dc
Add a guard for 'attention_char'
Mikael Berthe <mikael@lilotux.net>
parents:
2100
diff
changeset
|
1582 |
if (get_char_width(new_value) != 1 || !iswprint(sign) || *c) { |
f56c214a19dc
Add a guard for 'attention_char'
Mikael Berthe <mikael@lilotux.net>
parents:
2100
diff
changeset
|
1583 |
scr_log_print(LPRINT_NORMAL, "attention_char value is invalid."); |
f56c214a19dc
Add a guard for 'attention_char'
Mikael Berthe <mikael@lilotux.net>
parents:
2100
diff
changeset
|
1584 |
return NULL; |
f56c214a19dc
Add a guard for 'attention_char'
Mikael Berthe <mikael@lilotux.net>
parents:
2100
diff
changeset
|
1585 |
} |
f56c214a19dc
Add a guard for 'attention_char'
Mikael Berthe <mikael@lilotux.net>
parents:
2100
diff
changeset
|
1586 |
// The new value looks good (1-char wide and printable) |
f56c214a19dc
Add a guard for 'attention_char'
Mikael Berthe <mikael@lilotux.net>
parents:
2100
diff
changeset
|
1587 |
return g_strdup(new_value); |
f56c214a19dc
Add a guard for 'attention_char'
Mikael Berthe <mikael@lilotux.net>
parents:
2100
diff
changeset
|
1588 |
} |
f56c214a19dc
Add a guard for 'attention_char'
Mikael Berthe <mikael@lilotux.net>
parents:
2100
diff
changeset
|
1589 |
return g_strdup(new_value); |
f56c214a19dc
Add a guard for 'attention_char'
Mikael Berthe <mikael@lilotux.net>
parents:
2100
diff
changeset
|
1590 |
} |
f56c214a19dc
Add a guard for 'attention_char'
Mikael Berthe <mikael@lilotux.net>
parents:
2100
diff
changeset
|
1591 |
|
f56c214a19dc
Add a guard for 'attention_char'
Mikael Berthe <mikael@lilotux.net>
parents:
2100
diff
changeset
|
1592 |
// scr_init_settings() |
f56c214a19dc
Add a guard for 'attention_char'
Mikael Berthe <mikael@lilotux.net>
parents:
2100
diff
changeset
|
1593 |
// Create guards for UI settings |
f56c214a19dc
Add a guard for 'attention_char'
Mikael Berthe <mikael@lilotux.net>
parents:
2100
diff
changeset
|
1594 |
void scr_init_settings(void) |
f56c214a19dc
Add a guard for 'attention_char'
Mikael Berthe <mikael@lilotux.net>
parents:
2100
diff
changeset
|
1595 |
{ |
f56c214a19dc
Add a guard for 'attention_char'
Mikael Berthe <mikael@lilotux.net>
parents:
2100
diff
changeset
|
1596 |
settings_set_guard("attention_char", attention_sign_guard); |
f56c214a19dc
Add a guard for 'attention_char'
Mikael Berthe <mikael@lilotux.net>
parents:
2100
diff
changeset
|
1597 |
} |
f56c214a19dc
Add a guard for 'attention_char'
Mikael Berthe <mikael@lilotux.net>
parents:
2100
diff
changeset
|
1598 |
|
2100
113d3b96ae3e
Add option 'attention_char'
Mikael Berthe <mikael@lilotux.net>
parents:
2098
diff
changeset
|
1599 |
static unsigned int attention_sign(void) |
113d3b96ae3e
Add option 'attention_char'
Mikael Berthe <mikael@lilotux.net>
parents:
2098
diff
changeset
|
1600 |
{ |
113d3b96ae3e
Add option 'attention_char'
Mikael Berthe <mikael@lilotux.net>
parents:
2098
diff
changeset
|
1601 |
const char *as = settings_opt_get("attention_char"); |
113d3b96ae3e
Add option 'attention_char'
Mikael Berthe <mikael@lilotux.net>
parents:
2098
diff
changeset
|
1602 |
if (!as) |
113d3b96ae3e
Add option 'attention_char'
Mikael Berthe <mikael@lilotux.net>
parents:
2098
diff
changeset
|
1603 |
return DEFAULT_ATTENTION_CHAR; |
2101
f56c214a19dc
Add a guard for 'attention_char'
Mikael Berthe <mikael@lilotux.net>
parents:
2100
diff
changeset
|
1604 |
return get_char(as); |
2100
113d3b96ae3e
Add option 'attention_char'
Mikael Berthe <mikael@lilotux.net>
parents:
2098
diff
changeset
|
1605 |
} |
113d3b96ae3e
Add option 'attention_char'
Mikael Berthe <mikael@lilotux.net>
parents:
2098
diff
changeset
|
1606 |
|
1780
e4378fbab5d7
Major API cleanup - bump API to 4
Mikael Berthe <mikael@lilotux.net>
parents:
1761
diff
changeset
|
1607 |
// scr_update_main_status(forceupdate) |
713 | 1608 |
// Redraw the main (bottom) status line. |
1780
e4378fbab5d7
Major API cleanup - bump API to 4
Mikael Berthe <mikael@lilotux.net>
parents:
1761
diff
changeset
|
1609 |
// 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
|
1610 |
// 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
|
1611 |
void scr_update_main_status(int forceupdate) |
713 | 1612 |
{ |
1598 | 1613 |
char *sm = from_utf8(xmpp_getstatusmsg()); |
1514 | 1614 |
const char *info = settings_opt_get("info"); |
1977
1d8f9135e000
Use smarter message flag in the main status line
Mikael Berthe <mikael@lilotux.net>
parents:
1974
diff
changeset
|
1615 |
guint prio = 0; |
1d8f9135e000
Use smarter message flag in the main status line
Mikael Berthe <mikael@lilotux.net>
parents:
1974
diff
changeset
|
1616 |
gpointer unread_ptr; |
2100
113d3b96ae3e
Add option 'attention_char'
Mikael Berthe <mikael@lilotux.net>
parents:
2098
diff
changeset
|
1617 |
guint unreadchar; |
1977
1d8f9135e000
Use smarter message flag in the main status line
Mikael Berthe <mikael@lilotux.net>
parents:
1974
diff
changeset
|
1618 |
|
1d8f9135e000
Use smarter message flag in the main status line
Mikael Berthe <mikael@lilotux.net>
parents:
1974
diff
changeset
|
1619 |
unread_ptr = unread_msg(NULL); |
1d8f9135e000
Use smarter message flag in the main status line
Mikael Berthe <mikael@lilotux.net>
parents:
1974
diff
changeset
|
1620 |
if (unread_ptr) { |
1d8f9135e000
Use smarter message flag in the main status line
Mikael Berthe <mikael@lilotux.net>
parents:
1974
diff
changeset
|
1621 |
prio = buddy_getuiprio(unread_ptr); |
1d8f9135e000
Use smarter message flag in the main status line
Mikael Berthe <mikael@lilotux.net>
parents:
1974
diff
changeset
|
1622 |
// If there's an unerad buffer but no priority set, let's consider the |
1d8f9135e000
Use smarter message flag in the main status line
Mikael Berthe <mikael@lilotux.net>
parents:
1974
diff
changeset
|
1623 |
// priority is 1. |
1d8f9135e000
Use smarter message flag in the main status line
Mikael Berthe <mikael@lilotux.net>
parents:
1974
diff
changeset
|
1624 |
if (!prio && buddy_getflags(unread_ptr) & ROSTER_FLAG_MSG) |
1d8f9135e000
Use smarter message flag in the main status line
Mikael Berthe <mikael@lilotux.net>
parents:
1974
diff
changeset
|
1625 |
prio = 1; |
1d8f9135e000
Use smarter message flag in the main status line
Mikael Berthe <mikael@lilotux.net>
parents:
1974
diff
changeset
|
1626 |
} |
1d8f9135e000
Use smarter message flag in the main status line
Mikael Berthe <mikael@lilotux.net>
parents:
1974
diff
changeset
|
1627 |
|
1d8f9135e000
Use smarter message flag in the main status line
Mikael Berthe <mikael@lilotux.net>
parents:
1974
diff
changeset
|
1628 |
// Status bar unread message flag |
1d8f9135e000
Use smarter message flag in the main status line
Mikael Berthe <mikael@lilotux.net>
parents:
1974
diff
changeset
|
1629 |
if (prio >= ROSTER_UI_PRIO_MUC_HL_MESSAGE) |
2100
113d3b96ae3e
Add option 'attention_char'
Mikael Berthe <mikael@lilotux.net>
parents:
2098
diff
changeset
|
1630 |
unreadchar = attention_sign(); |
1977
1d8f9135e000
Use smarter message flag in the main status line
Mikael Berthe <mikael@lilotux.net>
parents:
1974
diff
changeset
|
1631 |
else if (prio > 0) |
1d8f9135e000
Use smarter message flag in the main status line
Mikael Berthe <mikael@lilotux.net>
parents:
1974
diff
changeset
|
1632 |
unreadchar = '#'; |
1d8f9135e000
Use smarter message flag in the main status line
Mikael Berthe <mikael@lilotux.net>
parents:
1974
diff
changeset
|
1633 |
else |
1d8f9135e000
Use smarter message flag in the main status line
Mikael Berthe <mikael@lilotux.net>
parents:
1974
diff
changeset
|
1634 |
unreadchar = ' '; |
713 | 1635 |
|
1636 |
werase(mainstatusWnd); |
|
1515 | 1637 |
if (info) { |
1519 | 1638 |
char *info_locale = from_utf8(info); |
2100
113d3b96ae3e
Add option 'attention_char'
Mikael Berthe <mikael@lilotux.net>
parents:
2098
diff
changeset
|
1639 |
mvwprintw(mainstatusWnd, 0, 0, "%lc[%c] %s %s", unreadchar, |
1598 | 1640 |
imstatus2char[xmpp_getstatus()], |
1519 | 1641 |
info_locale, (sm ? sm : "")); |
1642 |
g_free(info_locale); |
|
1515 | 1643 |
} else |
2100
113d3b96ae3e
Add option 'attention_char'
Mikael Berthe <mikael@lilotux.net>
parents:
2098
diff
changeset
|
1644 |
mvwprintw(mainstatusWnd, 0, 0, "%lc[%c] %s", unreadchar, |
1598 | 1645 |
imstatus2char[xmpp_getstatus()], (sm ? sm : "")); |
724
264375fe7159
Fix a roster refresh issue
Mikael Berthe <mikael@lilotux.net>
parents:
723
diff
changeset
|
1646 |
if (forceupdate) { |
264375fe7159
Fix a roster refresh issue
Mikael Berthe <mikael@lilotux.net>
parents:
723
diff
changeset
|
1647 |
top_panel(inputPanel); |
264375fe7159
Fix a roster refresh issue
Mikael Berthe <mikael@lilotux.net>
parents:
723
diff
changeset
|
1648 |
update_panels(); |
264375fe7159
Fix a roster refresh issue
Mikael Berthe <mikael@lilotux.net>
parents:
723
diff
changeset
|
1649 |
} |
773
e25b8a348ebd
Screen updating functions use UTF-8
Mikael Berthe <mikael@lilotux.net>
parents:
772
diff
changeset
|
1650 |
g_free(sm); |
713 | 1651 |
} |
1652 |
||
1780
e4378fbab5d7
Major API cleanup - bump API to 4
Mikael Berthe <mikael@lilotux.net>
parents:
1761
diff
changeset
|
1653 |
// scr_draw_main_window() |
157 | 1654 |
// Set fullinit to TRUE to also create panels. Set it to FALSE for a resize. |
151 | 1655 |
// |
1656 |
// I think it could be improved a _lot_ but I'm really not an ncurses |
|
1657 |
// expert... :-\ Mikael. |
|
1658 |
// |
|
1780
e4378fbab5d7
Major API cleanup - bump API to 4
Mikael Berthe <mikael@lilotux.net>
parents:
1761
diff
changeset
|
1659 |
void scr_draw_main_window(unsigned int fullinit) |
24 | 1660 |
{ |
701
6c100adfbfb6
Add setting "roster_width" (variable buddylist width)
Mikael Berthe <mikael@lilotux.net>
parents:
699
diff
changeset
|
1661 |
int requested_size; |
961
95659cf9ea1a
Display mcabber version in the status window
Mikael Berthe <mikael@lilotux.net>
parents:
952
diff
changeset
|
1662 |
gchar *ver, *message; |
972
11b632d824f6
Add option 'log_win_on_top'
Mikael Berthe <mikael@lilotux.net>
parents:
967
diff
changeset
|
1663 |
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
|
1664 |
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
|
1665 |
|
2009
a859ed648638
Replace the option « no_space_before_items » with « roster_no_leading_space ».
Simon Jacquin <simon@jacquin.me>
parents:
2008
diff
changeset
|
1666 |
roster_no_leading_space = settings_opt_get_int("roster_no_leading_space"); |
2007
6c02ccb14c1c
Added an option to remove the extra space before items in the roster.
Simon Jacquin <simon@jacquin.me>
parents:
1997
diff
changeset
|
1667 |
|
518
9480a76471b6
Update Log_Win_Height when refreshing the screen
Mikael Berthe <mikael@lilotux.net>
parents:
515
diff
changeset
|
1668 |
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
|
1669 |
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
|
1670 |
if (requested_size > 0) { |
6c100adfbfb6
Add setting "roster_width" (variable buddylist width)
Mikael Berthe <mikael@lilotux.net>
parents:
699
diff
changeset
|
1671 |
if (maxY > requested_size + 3) |
6c100adfbfb6
Add setting "roster_width" (variable buddylist width)
Mikael Berthe <mikael@lilotux.net>
parents:
699
diff
changeset
|
1672 |
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
|
1673 |
else |
9480a76471b6
Update Log_Win_Height when refreshing the screen
Mikael Berthe <mikael@lilotux.net>
parents:
515
diff
changeset
|
1674 |
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
|
1675 |
} else if (requested_size < 0) { |
518
9480a76471b6
Update Log_Win_Height when refreshing the screen
Mikael Berthe <mikael@lilotux.net>
parents:
515
diff
changeset
|
1676 |
Log_Win_Height = 3; |
9480a76471b6
Update Log_Win_Height when refreshing the screen
Mikael Berthe <mikael@lilotux.net>
parents:
515
diff
changeset
|
1677 |
} |
9480a76471b6
Update Log_Win_Height when refreshing the screen
Mikael Berthe <mikael@lilotux.net>
parents:
515
diff
changeset
|
1678 |
|
9480a76471b6
Update Log_Win_Height when refreshing the screen
Mikael Berthe <mikael@lilotux.net>
parents:
515
diff
changeset
|
1679 |
if (maxY < Log_Win_Height+2) { |
9480a76471b6
Update Log_Win_Height when refreshing the screen
Mikael Berthe <mikael@lilotux.net>
parents:
515
diff
changeset
|
1680 |
if (maxY < 5) { |
9480a76471b6
Update Log_Win_Height when refreshing the screen
Mikael Berthe <mikael@lilotux.net>
parents:
515
diff
changeset
|
1681 |
Log_Win_Height = 3; |
9480a76471b6
Update Log_Win_Height when refreshing the screen
Mikael Berthe <mikael@lilotux.net>
parents:
515
diff
changeset
|
1682 |
maxY = Log_Win_Height+2; |
9480a76471b6
Update Log_Win_Height when refreshing the screen
Mikael Berthe <mikael@lilotux.net>
parents:
515
diff
changeset
|
1683 |
} else { |
9480a76471b6
Update Log_Win_Height when refreshing the screen
Mikael Berthe <mikael@lilotux.net>
parents:
515
diff
changeset
|
1684 |
Log_Win_Height = maxY - 2; |
9480a76471b6
Update Log_Win_Height when refreshing the screen
Mikael Berthe <mikael@lilotux.net>
parents:
515
diff
changeset
|
1685 |
} |
9480a76471b6
Update Log_Win_Height when refreshing the screen
Mikael Berthe <mikael@lilotux.net>
parents:
515
diff
changeset
|
1686 |
} |
9480a76471b6
Update Log_Win_Height when refreshing the screen
Mikael Berthe <mikael@lilotux.net>
parents:
515
diff
changeset
|
1687 |
|
707
b26a0bde4cdb
Add /roster hide|show|toggle
Mikael Berthe <mikael@lilotux.net>
parents:
701
diff
changeset
|
1688 |
if (roster_hidden) { |
b26a0bde4cdb
Add /roster hide|show|toggle
Mikael Berthe <mikael@lilotux.net>
parents:
701
diff
changeset
|
1689 |
Roster_Width = 0; |
b26a0bde4cdb
Add /roster hide|show|toggle
Mikael Berthe <mikael@lilotux.net>
parents:
701
diff
changeset
|
1690 |
} else { |
b26a0bde4cdb
Add /roster hide|show|toggle
Mikael Berthe <mikael@lilotux.net>
parents:
701
diff
changeset
|
1691 |
requested_size = settings_opt_get_int("roster_width"); |
b26a0bde4cdb
Add /roster hide|show|toggle
Mikael Berthe <mikael@lilotux.net>
parents:
701
diff
changeset
|
1692 |
if (requested_size > 1) |
b26a0bde4cdb
Add /roster hide|show|toggle
Mikael Berthe <mikael@lilotux.net>
parents:
701
diff
changeset
|
1693 |
Roster_Width = requested_size; |
b26a0bde4cdb
Add /roster hide|show|toggle
Mikael Berthe <mikael@lilotux.net>
parents:
701
diff
changeset
|
1694 |
else if (requested_size == 1) |
b26a0bde4cdb
Add /roster hide|show|toggle
Mikael Berthe <mikael@lilotux.net>
parents:
701
diff
changeset
|
1695 |
Roster_Width = 2; |
b26a0bde4cdb
Add /roster hide|show|toggle
Mikael Berthe <mikael@lilotux.net>
parents:
701
diff
changeset
|
1696 |
else |
b26a0bde4cdb
Add /roster hide|show|toggle
Mikael Berthe <mikael@lilotux.net>
parents:
701
diff
changeset
|
1697 |
Roster_Width = DEFAULT_ROSTER_WIDTH; |
b26a0bde4cdb
Add /roster hide|show|toggle
Mikael Berthe <mikael@lilotux.net>
parents:
701
diff
changeset
|
1698 |
} |
701
6c100adfbfb6
Add setting "roster_width" (variable buddylist width)
Mikael Berthe <mikael@lilotux.net>
parents:
699
diff
changeset
|
1699 |
|
972
11b632d824f6
Add option 'log_win_on_top'
Mikael Berthe <mikael@lilotux.net>
parents:
967
diff
changeset
|
1700 |
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
|
1701 |
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
|
1702 |
|
11b632d824f6
Add option 'log_win_on_top'
Mikael Berthe <mikael@lilotux.net>
parents:
967
diff
changeset
|
1703 |
if (log_win_on_top) { |
11b632d824f6
Add option 'log_win_on_top'
Mikael Berthe <mikael@lilotux.net>
parents:
967
diff
changeset
|
1704 |
chat_y_pos = Log_Win_Height-1; |
11b632d824f6
Add option 'log_win_on_top'
Mikael Berthe <mikael@lilotux.net>
parents:
967
diff
changeset
|
1705 |
log_y_pos = 0; |
11b632d824f6
Add option 'log_win_on_top'
Mikael Berthe <mikael@lilotux.net>
parents:
967
diff
changeset
|
1706 |
chatstatus_y_pos = Log_Win_Height-2; |
11b632d824f6
Add option 'log_win_on_top'
Mikael Berthe <mikael@lilotux.net>
parents:
967
diff
changeset
|
1707 |
} else { |
11b632d824f6
Add option 'log_win_on_top'
Mikael Berthe <mikael@lilotux.net>
parents:
967
diff
changeset
|
1708 |
chat_y_pos = 0; |
11b632d824f6
Add option 'log_win_on_top'
Mikael Berthe <mikael@lilotux.net>
parents:
967
diff
changeset
|
1709 |
log_y_pos = CHAT_WIN_HEIGHT+1; |
11b632d824f6
Add option 'log_win_on_top'
Mikael Berthe <mikael@lilotux.net>
parents:
967
diff
changeset
|
1710 |
chatstatus_y_pos = CHAT_WIN_HEIGHT; |
11b632d824f6
Add option 'log_win_on_top'
Mikael Berthe <mikael@lilotux.net>
parents:
967
diff
changeset
|
1711 |
} |
11b632d824f6
Add option 'log_win_on_top'
Mikael Berthe <mikael@lilotux.net>
parents:
967
diff
changeset
|
1712 |
|
973
e693cbe33802
Add option 'roster_win_on_right'
Mikael Berthe <mikael@lilotux.net>
parents:
972
diff
changeset
|
1713 |
if (roster_win_on_right) { |
e693cbe33802
Add option 'roster_win_on_right'
Mikael Berthe <mikael@lilotux.net>
parents:
972
diff
changeset
|
1714 |
roster_x_pos = maxX - Roster_Width; |
e693cbe33802
Add option 'roster_win_on_right'
Mikael Berthe <mikael@lilotux.net>
parents:
972
diff
changeset
|
1715 |
chat_x_pos = 0; |
e693cbe33802
Add option 'roster_win_on_right'
Mikael Berthe <mikael@lilotux.net>
parents:
972
diff
changeset
|
1716 |
} else { |
e693cbe33802
Add option 'roster_win_on_right'
Mikael Berthe <mikael@lilotux.net>
parents:
972
diff
changeset
|
1717 |
roster_x_pos = 0; |
e693cbe33802
Add option 'roster_win_on_right'
Mikael Berthe <mikael@lilotux.net>
parents:
972
diff
changeset
|
1718 |
chat_x_pos = Roster_Width; |
e693cbe33802
Add option 'roster_win_on_right'
Mikael Berthe <mikael@lilotux.net>
parents:
972
diff
changeset
|
1719 |
} |
e693cbe33802
Add option 'roster_win_on_right'
Mikael Berthe <mikael@lilotux.net>
parents:
972
diff
changeset
|
1720 |
|
157 | 1721 |
if (fullinit) { |
1078
7866dbaf67a6
Use a hash for the list of win buffers
Mikael Berthe <mikael@lilotux.net>
parents:
1077
diff
changeset
|
1722 |
if (!winbufhash) |
2222
ce1043326bbc
Fix a small leak when a window is closed
Mikael Berthe <mikael@lilotux.net>
parents:
2211
diff
changeset
|
1723 |
winbufhash = g_hash_table_new_full(g_str_hash, g_str_equal, |
ce1043326bbc
Fix a small leak when a window is closed
Mikael Berthe <mikael@lilotux.net>
parents:
2211
diff
changeset
|
1724 |
g_free, g_free); |
157 | 1725 |
/* Create windows */ |
973
e693cbe33802
Add option 'roster_win_on_right'
Mikael Berthe <mikael@lilotux.net>
parents:
972
diff
changeset
|
1726 |
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
|
1727 |
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
|
1728 |
chat_x_pos); |
1133
9dd28a56128f
Do not create one panel per contact
Mikael Berthe <mikael@lilotux.net>
parents:
1131
diff
changeset
|
1729 |
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
|
1730 |
chat_x_pos); |
972
11b632d824f6
Add option 'log_win_on_top'
Mikael Berthe <mikael@lilotux.net>
parents:
967
diff
changeset
|
1731 |
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
|
1732 |
chatstatusWnd = newwin(1, maxX, chatstatus_y_pos, 0); |
711 | 1733 |
mainstatusWnd = newwin(1, maxX, maxY-2, 0); |
157 | 1734 |
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
|
1735 |
if (!rosterWnd || !chatWnd || !logWnd || !inputWnd) { |
1780
e4378fbab5d7
Major API cleanup - bump API to 4
Mikael Berthe <mikael@lilotux.net>
parents:
1761
diff
changeset
|
1736 |
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
|
1737 |
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
|
1738 |
exit(EXIT_FAILURE); |
6e4e667c5571
Fix a segfault when starting mcabber in a really small terminal
Mikael Berthe <mikael@lilotux.net>
parents:
339
diff
changeset
|
1739 |
} |
739
0d5fb1d9077c
Allow "bright" text colors
Mikael Berthe <mikael@lilotux.net>
parents:
735
diff
changeset
|
1740 |
wbkgd(rosterWnd, get_color(COLOR_GENERAL)); |
0d5fb1d9077c
Allow "bright" text colors
Mikael Berthe <mikael@lilotux.net>
parents:
735
diff
changeset
|
1741 |
wbkgd(chatWnd, get_color(COLOR_GENERAL)); |
1133
9dd28a56128f
Do not create one panel per contact
Mikael Berthe <mikael@lilotux.net>
parents:
1131
diff
changeset
|
1742 |
wbkgd(activechatWnd, get_color(COLOR_GENERAL)); |
739
0d5fb1d9077c
Allow "bright" text colors
Mikael Berthe <mikael@lilotux.net>
parents:
735
diff
changeset
|
1743 |
wbkgd(logWnd, get_color(COLOR_GENERAL)); |
0d5fb1d9077c
Allow "bright" text colors
Mikael Berthe <mikael@lilotux.net>
parents:
735
diff
changeset
|
1744 |
wbkgd(chatstatusWnd, get_color(COLOR_STATUS)); |
0d5fb1d9077c
Allow "bright" text colors
Mikael Berthe <mikael@lilotux.net>
parents:
735
diff
changeset
|
1745 |
wbkgd(mainstatusWnd, get_color(COLOR_STATUS)); |
2028
7b5bd6ad83b4
Add 'color_log' (text color in the log window)
Mikael Berthe <mikael@lilotux.net>
parents:
2015
diff
changeset
|
1746 |
|
7b5bd6ad83b4
Add 'color_log' (text color in the log window)
Mikael Berthe <mikael@lilotux.net>
parents:
2015
diff
changeset
|
1747 |
wattrset(logWnd, get_color(COLOR_LOG)); |
157 | 1748 |
} else { |
701
6c100adfbfb6
Add setting "roster_width" (variable buddylist width)
Mikael Berthe <mikael@lilotux.net>
parents:
699
diff
changeset
|
1749 |
/* Resize/move windows */ |
6c100adfbfb6
Add setting "roster_width" (variable buddylist width)
Mikael Berthe <mikael@lilotux.net>
parents:
699
diff
changeset
|
1750 |
wresize(rosterWnd, CHAT_WIN_HEIGHT, Roster_Width); |
6c100adfbfb6
Add setting "roster_width" (variable buddylist width)
Mikael Berthe <mikael@lilotux.net>
parents:
699
diff
changeset
|
1751 |
wresize(chatWnd, CHAT_WIN_HEIGHT, maxX - Roster_Width); |
711 | 1752 |
wresize(logWnd, Log_Win_Height-2, maxX); |
157 | 1753 |
|
973
e693cbe33802
Add option 'roster_win_on_right'
Mikael Berthe <mikael@lilotux.net>
parents:
972
diff
changeset
|
1754 |
mvwin(chatWnd, chat_y_pos, chat_x_pos); |
e693cbe33802
Add option 'roster_win_on_right'
Mikael Berthe <mikael@lilotux.net>
parents:
972
diff
changeset
|
1755 |
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
|
1756 |
mvwin(logWnd, log_y_pos, 0); |
157 | 1757 |
|
711 | 1758 |
// Resize & move chat status window |
1759 |
wresize(chatstatusWnd, 1, maxX); |
|
972
11b632d824f6
Add option 'log_win_on_top'
Mikael Berthe <mikael@lilotux.net>
parents:
967
diff
changeset
|
1760 |
mvwin(chatstatusWnd, chatstatus_y_pos, 0); |
711 | 1761 |
// Resize & move main status window |
1762 |
wresize(mainstatusWnd, 1, maxX); |
|
1763 |
mvwin(mainstatusWnd, maxY-2, 0); |
|
1764 |
// Resize & move input line window |
|
157 | 1765 |
wresize(inputWnd, 1, maxX); |
1766 |
mvwin(inputWnd, maxY-1, 0); |
|
168 | 1767 |
|
1768 |
werase(chatWnd); |
|
157 | 1769 |
} |
151 | 1770 |
|
1771 |
/* Draw/init windows */ |
|
1772 |
||
961
95659cf9ea1a
Display mcabber version in the status window
Mikael Berthe <mikael@lilotux.net>
parents:
952
diff
changeset
|
1773 |
ver = mcabber_version(); |
95659cf9ea1a
Display mcabber version in the status window
Mikael Berthe <mikael@lilotux.net>
parents:
952
diff
changeset
|
1774 |
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
|
1775 |
mvwprintw(chatWnd, 0, 0, message); |
1455
bec235cd28a8
Misc. documentation updates
Mikael Berthe <mikael@lilotux.net>
parents:
1454
diff
changeset
|
1776 |
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
|
1777 |
g_free(ver); |
95659cf9ea1a
Display mcabber version in the status window
Mikael Berthe <mikael@lilotux.net>
parents:
952
diff
changeset
|
1778 |
g_free(message); |
24 | 1779 |
|
157 | 1780 |
// Auto-scrolling in log window |
74 | 1781 |
scrollok(logWnd, TRUE); |
24 | 1782 |
|
1783 |
||
151 | 1784 |
if (fullinit) { |
157 | 1785 |
// Enable keypad (+ special keys) |
1786 |
keypad(inputWnd, TRUE); |
|
1457
3a537b4d7f8d
Fix UTF-8 on MirBSD (Thorsten Glaser)
Mikael Berthe <mikael@lilotux.net>
parents:
1455
diff
changeset
|
1787 |
#ifdef __MirBSD__ |
3a537b4d7f8d
Fix UTF-8 on MirBSD (Thorsten Glaser)
Mikael Berthe <mikael@lilotux.net>
parents:
1455
diff
changeset
|
1788 |
wtimeout(inputWnd, 50 /* ms */); |
3a537b4d7f8d
Fix UTF-8 on MirBSD (Thorsten Glaser)
Mikael Berthe <mikael@lilotux.net>
parents:
1455
diff
changeset
|
1789 |
#else |
382
4c6e8392e465
Use nodelay() instead of halfdelay()
Mikael Berthe <mikael@lilotux.net>
parents:
374
diff
changeset
|
1790 |
nodelay(inputWnd, TRUE); |
1457
3a537b4d7f8d
Fix UTF-8 on MirBSD (Thorsten Glaser)
Mikael Berthe <mikael@lilotux.net>
parents:
1455
diff
changeset
|
1791 |
#endif |
157 | 1792 |
|
151 | 1793 |
// Create panels |
1794 |
rosterPanel = new_panel(rosterWnd); |
|
1795 |
chatPanel = new_panel(chatWnd); |
|
1133
9dd28a56128f
Do not create one panel per contact
Mikael Berthe <mikael@lilotux.net>
parents:
1131
diff
changeset
|
1796 |
activechatPanel = new_panel(activechatWnd); |
151 | 1797 |
logPanel = new_panel(logWnd); |
711 | 1798 |
chatstatusPanel = new_panel(chatstatusWnd); |
1799 |
mainstatusPanel = new_panel(mainstatusWnd); |
|
151 | 1800 |
inputPanel = new_panel(inputWnd); |
232 | 1801 |
|
849
42c43a88d823
Status buffer management
Mikael Berthe <mikael@lilotux.net>
parents:
848
diff
changeset
|
1802 |
// 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
|
1803 |
// is added |
2291
0d350e979bde
Don't rebuild the buddylist multiple times before a screen refresh
franky
parents:
2288
diff
changeset
|
1804 |
buddylist_defer_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
|
1805 |
|
6ca9a65df21f
Do not rewrap buffer lines when the chat window width doesn't change
Mikael Berthe <mikael@lilotux.net>
parents:
1089
diff
changeset
|
1806 |
// 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
|
1807 |
// from rewrapping buffers when the width doesn't change. |
1487 | 1808 |
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
|
1809 |
// 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
|
1810 |
hbuf_rebuild(&statushbuf, prev_chatwidth); |
849
42c43a88d823
Status buffer management
Mikael Berthe <mikael@lilotux.net>
parents:
848
diff
changeset
|
1811 |
|
930
a75f7a13df7b
UTF-8 terminal support (Reimar Döffinger)
Mikael Berthe <mikael@lilotux.net>
parents:
929
diff
changeset
|
1812 |
#ifndef UNICODE |
232 | 1813 |
if (utf8_mode) |
930
a75f7a13df7b
UTF-8 terminal support (Reimar Döffinger)
Mikael Berthe <mikael@lilotux.net>
parents:
929
diff
changeset
|
1814 |
scr_LogPrint(LPRINT_NORMAL, |
a75f7a13df7b
UTF-8 terminal support (Reimar Döffinger)
Mikael Berthe <mikael@lilotux.net>
parents:
929
diff
changeset
|
1815 |
"WARNING: Compiled without full UTF-8 support!"); |
a75f7a13df7b
UTF-8 terminal support (Reimar Döffinger)
Mikael Berthe <mikael@lilotux.net>
parents:
929
diff
changeset
|
1816 |
#endif |
157 | 1817 |
} else { |
1818 |
// Update panels |
|
1819 |
replace_panel(rosterPanel, rosterWnd); |
|
1820 |
replace_panel(chatPanel, chatWnd); |
|
1821 |
replace_panel(logPanel, logWnd); |
|
711 | 1822 |
replace_panel(chatstatusPanel, chatstatusWnd); |
1823 |
replace_panel(mainstatusPanel, mainstatusWnd); |
|
157 | 1824 |
replace_panel(inputPanel, inputWnd); |
151 | 1825 |
} |
1826 |
||
1827 |
// We'll need to redraw the roster |
|
2292
f181418db215
Replace global variable update_roster with scr_update_roster()
franky
parents:
2291
diff
changeset
|
1828 |
scr_update_roster(); |
24 | 1829 |
return; |
1830 |
} |
|
1831 |
||
1078
7866dbaf67a6
Use a hash for the list of win buffers
Mikael Berthe <mikael@lilotux.net>
parents:
1077
diff
changeset
|
1832 |
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
|
1833 |
{ |
1078
7866dbaf67a6
Use a hash for the list of win buffers
Mikael Berthe <mikael@lilotux.net>
parents:
1077
diff
changeset
|
1834 |
winbuf *wbp = value; |
7866dbaf67a6
Use a hash for the list of win buffers
Mikael Berthe <mikael@lilotux.net>
parents:
1077
diff
changeset
|
1835 |
struct dimensions *dim = data; |
973
e693cbe33802
Add option 'roster_win_on_right'
Mikael Berthe <mikael@lilotux.net>
parents:
972
diff
changeset
|
1836 |
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
|
1837 |
int new_chatwidth; |
972
11b632d824f6
Add option 'log_win_on_top'
Mikael Berthe <mikael@lilotux.net>
parents:
967
diff
changeset
|
1838 |
|
1078
7866dbaf67a6
Use a hash for the list of win buffers
Mikael Berthe <mikael@lilotux.net>
parents:
1077
diff
changeset
|
1839 |
if (!(wbp && wbp->win)) |
7866dbaf67a6
Use a hash for the list of win buffers
Mikael Berthe <mikael@lilotux.net>
parents:
1077
diff
changeset
|
1840 |
return; |
7866dbaf67a6
Use a hash for the list of win buffers
Mikael Berthe <mikael@lilotux.net>
parents:
1077
diff
changeset
|
1841 |
|
972
11b632d824f6
Add option 'log_win_on_top'
Mikael Berthe <mikael@lilotux.net>
parents:
967
diff
changeset
|
1842 |
if (log_win_on_top) |
11b632d824f6
Add option 'log_win_on_top'
Mikael Berthe <mikael@lilotux.net>
parents:
967
diff
changeset
|
1843 |
chat_y_pos = Log_Win_Height-1; |
11b632d824f6
Add option 'log_win_on_top'
Mikael Berthe <mikael@lilotux.net>
parents:
967
diff
changeset
|
1844 |
else |
11b632d824f6
Add option 'log_win_on_top'
Mikael Berthe <mikael@lilotux.net>
parents:
967
diff
changeset
|
1845 |
chat_y_pos = 0; |
11b632d824f6
Add option 'log_win_on_top'
Mikael Berthe <mikael@lilotux.net>
parents:
967
diff
changeset
|
1846 |
|
973
e693cbe33802
Add option 'roster_win_on_right'
Mikael Berthe <mikael@lilotux.net>
parents:
972
diff
changeset
|
1847 |
if (roster_win_on_right) |
e693cbe33802
Add option 'roster_win_on_right'
Mikael Berthe <mikael@lilotux.net>
parents:
972
diff
changeset
|
1848 |
chat_x_pos = 0; |
e693cbe33802
Add option 'roster_win_on_right'
Mikael Berthe <mikael@lilotux.net>
parents:
972
diff
changeset
|
1849 |
else |
e693cbe33802
Add option 'roster_win_on_right'
Mikael Berthe <mikael@lilotux.net>
parents:
972
diff
changeset
|
1850 |
chat_x_pos = Roster_Width; |
e693cbe33802
Add option 'roster_win_on_right'
Mikael Berthe <mikael@lilotux.net>
parents:
972
diff
changeset
|
1851 |
|
849
42c43a88d823
Status buffer management
Mikael Berthe <mikael@lilotux.net>
parents:
848
diff
changeset
|
1852 |
// Resize/move buddy window |
1078
7866dbaf67a6
Use a hash for the list of win buffers
Mikael Berthe <mikael@lilotux.net>
parents:
1077
diff
changeset
|
1853 |
wresize(wbp->win, dim->l, dim->c); |
973
e693cbe33802
Add option 'roster_win_on_right'
Mikael Berthe <mikael@lilotux.net>
parents:
972
diff
changeset
|
1854 |
mvwin(wbp->win, chat_y_pos, chat_x_pos); |
849
42c43a88d823
Status buffer management
Mikael Berthe <mikael@lilotux.net>
parents:
848
diff
changeset
|
1855 |
werase(wbp->win); |
42c43a88d823
Status buffer management
Mikael Berthe <mikael@lilotux.net>
parents:
848
diff
changeset
|
1856 |
// If a panel exists, replace the old window with the new |
42c43a88d823
Status buffer management
Mikael Berthe <mikael@lilotux.net>
parents:
848
diff
changeset
|
1857 |
if (wbp->panel) |
42c43a88d823
Status buffer management
Mikael Berthe <mikael@lilotux.net>
parents:
848
diff
changeset
|
1858 |
replace_panel(wbp->panel, wbp->win); |
42c43a88d823
Status buffer management
Mikael Berthe <mikael@lilotux.net>
parents:
848
diff
changeset
|
1859 |
// Redo line wrapping |
1157
5c857f0f0ab8
Moved all variables related to hbuf to an extra struct, bufdata
Frank Zschockelt
parents:
1156
diff
changeset
|
1860 |
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
|
1861 |
|
1487 | 1862 |
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
|
1863 |
if (new_chatwidth != prev_chatwidth) |
1157
5c857f0f0ab8
Moved all variables related to hbuf to an extra struct, bufdata
Frank Zschockelt
parents:
1156
diff
changeset
|
1864 |
hbuf_rebuild(&wbp->bd->hbuf, new_chatwidth); |
849
42c43a88d823
Status buffer management
Mikael Berthe <mikael@lilotux.net>
parents:
848
diff
changeset
|
1865 |
} |
42c43a88d823
Status buffer management
Mikael Berthe <mikael@lilotux.net>
parents:
848
diff
changeset
|
1866 |
|
2231
387cea2a1a81
Fix resizing with --enable-sigwinch
Mikael Berthe <mikael@lilotux.net>
parents:
2226
diff
changeset
|
1867 |
// scr_resize() |
151 | 1868 |
// Function called when the window is resized. |
157 | 1869 |
// - Resize windows |
151 | 1870 |
// - Rewrap lines in each buddy buffer |
2231
387cea2a1a81
Fix resizing with --enable-sigwinch
Mikael Berthe <mikael@lilotux.net>
parents:
2226
diff
changeset
|
1871 |
void scr_resize(void) |
151 | 1872 |
{ |
1078
7866dbaf67a6
Use a hash for the list of win buffers
Mikael Berthe <mikael@lilotux.net>
parents:
1077
diff
changeset
|
1873 |
struct dimensions dim; |
151 | 1874 |
|
1875 |
// First, update the global variables |
|
1876 |
getmaxyx(stdscr, maxY, maxX); |
|
1780
e4378fbab5d7
Major API cleanup - bump API to 4
Mikael Berthe <mikael@lilotux.net>
parents:
1761
diff
changeset
|
1877 |
// 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
|
1878 |
|
151 | 1879 |
// Make sure the cursor stays inside the window |
1880 |
check_offset(0); |
|
1881 |
||
157 | 1882 |
// Resize windows and update panels |
1780
e4378fbab5d7
Major API cleanup - bump API to 4
Mikael Berthe <mikael@lilotux.net>
parents:
1761
diff
changeset
|
1883 |
scr_draw_main_window(FALSE); |
151 | 1884 |
|
1885 |
// Resize all buddy windows |
|
1078
7866dbaf67a6
Use a hash for the list of win buffers
Mikael Berthe <mikael@lilotux.net>
parents:
1077
diff
changeset
|
1886 |
dim.l = CHAT_WIN_HEIGHT; |
7866dbaf67a6
Use a hash for the list of win buffers
Mikael Berthe <mikael@lilotux.net>
parents:
1077
diff
changeset
|
1887 |
dim.c = maxX - Roster_Width; |
7866dbaf67a6
Use a hash for the list of win buffers
Mikael Berthe <mikael@lilotux.net>
parents:
1077
diff
changeset
|
1888 |
if (dim.c < 1) |
7866dbaf67a6
Use a hash for the list of win buffers
Mikael Berthe <mikael@lilotux.net>
parents:
1077
diff
changeset
|
1889 |
dim.c = 1; |
7866dbaf67a6
Use a hash for the list of win buffers
Mikael Berthe <mikael@lilotux.net>
parents:
1077
diff
changeset
|
1890 |
|
7866dbaf67a6
Use a hash for the list of win buffers
Mikael Berthe <mikael@lilotux.net>
parents:
1077
diff
changeset
|
1891 |
// Resize all buffers |
7866dbaf67a6
Use a hash for the list of win buffers
Mikael Berthe <mikael@lilotux.net>
parents:
1077
diff
changeset
|
1892 |
g_hash_table_foreach(winbufhash, resize_win_buffer, &dim); |
151 | 1893 |
|
849
42c43a88d823
Status buffer management
Mikael Berthe <mikael@lilotux.net>
parents:
848
diff
changeset
|
1894 |
// Resize/move special status buffer |
42c43a88d823
Status buffer management
Mikael Berthe <mikael@lilotux.net>
parents:
848
diff
changeset
|
1895 |
if (statusWindow) |
1078
7866dbaf67a6
Use a hash for the list of win buffers
Mikael Berthe <mikael@lilotux.net>
parents:
1077
diff
changeset
|
1896 |
resize_win_buffer(NULL, statusWindow, &dim); |
849
42c43a88d823
Status buffer management
Mikael Berthe <mikael@lilotux.net>
parents:
848
diff
changeset
|
1897 |
|
1093
6ca9a65df21f
Do not rewrap buffer lines when the chat window width doesn't change
Mikael Berthe <mikael@lilotux.net>
parents:
1089
diff
changeset
|
1898 |
// Update prev_chatwidth, now that all buffers have been resized |
1487 | 1899 |
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
|
1900 |
|
151 | 1901 |
// Refresh current buddy window |
157 | 1902 |
if (chatmode) |
1780
e4378fbab5d7
Major API cleanup - bump API to 4
Mikael Berthe <mikael@lilotux.net>
parents:
1761
diff
changeset
|
1903 |
scr_show_buddy_window(); |
151 | 1904 |
} |
1905 |
||
2231
387cea2a1a81
Fix resizing with --enable-sigwinch
Mikael Berthe <mikael@lilotux.net>
parents:
2226
diff
changeset
|
1906 |
#ifdef USE_SIGWINCH |
387cea2a1a81
Fix resizing with --enable-sigwinch
Mikael Berthe <mikael@lilotux.net>
parents:
2226
diff
changeset
|
1907 |
void sigwinch_resize(void) |
387cea2a1a81
Fix resizing with --enable-sigwinch
Mikael Berthe <mikael@lilotux.net>
parents:
2226
diff
changeset
|
1908 |
{ |
387cea2a1a81
Fix resizing with --enable-sigwinch
Mikael Berthe <mikael@lilotux.net>
parents:
2226
diff
changeset
|
1909 |
struct winsize size; |
387cea2a1a81
Fix resizing with --enable-sigwinch
Mikael Berthe <mikael@lilotux.net>
parents:
2226
diff
changeset
|
1910 |
if (ioctl(STDIN_FILENO, TIOCGWINSZ, &size) != -1) |
387cea2a1a81
Fix resizing with --enable-sigwinch
Mikael Berthe <mikael@lilotux.net>
parents:
2226
diff
changeset
|
1911 |
resizeterm(size.ws_row, size.ws_col); |
387cea2a1a81
Fix resizing with --enable-sigwinch
Mikael Berthe <mikael@lilotux.net>
parents:
2226
diff
changeset
|
1912 |
scr_resize(); |
387cea2a1a81
Fix resizing with --enable-sigwinch
Mikael Berthe <mikael@lilotux.net>
parents:
2226
diff
changeset
|
1913 |
} |
387cea2a1a81
Fix resizing with --enable-sigwinch
Mikael Berthe <mikael@lilotux.net>
parents:
2226
diff
changeset
|
1914 |
#endif |
387cea2a1a81
Fix resizing with --enable-sigwinch
Mikael Berthe <mikael@lilotux.net>
parents:
2226
diff
changeset
|
1915 |
|
1780
e4378fbab5d7
Major API cleanup - bump API to 4
Mikael Berthe <mikael@lilotux.net>
parents:
1761
diff
changeset
|
1916 |
// scr_update_chat_status(forceupdate) |
713 | 1917 |
// Redraw the buddy status bar. |
939
12fa2ae6445d
Get rid of "busy-waiting" (Christof Meerwald)
Mikael Berthe <mikael@lilotux.net>
parents:
936
diff
changeset
|
1918 |
// 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
|
1919 |
void scr_update_chat_status(int forceupdate) |
713 | 1920 |
{ |
848
a9161d2dc414
Introduce special buffer stuff
Mikael Berthe <mikael@lilotux.net>
parents:
843
diff
changeset
|
1921 |
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
|
1922 |
const char *btypetext = "Unknown"; |
717
8ce2bfdc4143
Reindent update_chat_status_window()
Mikael Berthe <mikael@lilotux.net>
parents:
716
diff
changeset
|
1923 |
const char *fullname; |
2013
8dc418af3e72
Allow to select to which buddy resource messages go. Closes issue #55
Hermitifier
parents:
2012
diff
changeset
|
1924 |
char *fullnameres = NULL; |
8dc418af3e72
Allow to select to which buddy resource messages go. Closes issue #55
Hermitifier
parents:
2012
diff
changeset
|
1925 |
const char *activeres; |
717
8ce2bfdc4143
Reindent update_chat_status_window()
Mikael Berthe <mikael@lilotux.net>
parents:
716
diff
changeset
|
1926 |
const char *msg = NULL; |
8ce2bfdc4143
Reindent update_chat_status_window()
Mikael Berthe <mikael@lilotux.net>
parents:
716
diff
changeset
|
1927 |
char status; |
773
e25b8a348ebd
Screen updating functions use UTF-8
Mikael Berthe <mikael@lilotux.net>
parents:
772
diff
changeset
|
1928 |
char *buf, *buf_locale; |
713 | 1929 |
|
718
b41799901abd
Add a new_message flag (#) in the main status line
Mikael Berthe <mikael@lilotux.net>
parents:
717
diff
changeset
|
1930 |
// 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
|
1931 |
// 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
|
1932 |
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
|
1933 |
|
806
3521e34f722a
Fix a segfault when not connected to a server
Mikael Berthe <mikael@lilotux.net>
parents:
797
diff
changeset
|
1934 |
// Clear the line |
3521e34f722a
Fix a segfault when not connected to a server
Mikael Berthe <mikael@lilotux.net>
parents:
797
diff
changeset
|
1935 |
werase(chatstatusWnd); |
3521e34f722a
Fix a segfault when not connected to a server
Mikael Berthe <mikael@lilotux.net>
parents:
797
diff
changeset
|
1936 |
|
3521e34f722a
Fix a segfault when not connected to a server
Mikael Berthe <mikael@lilotux.net>
parents:
797
diff
changeset
|
1937 |
if (!current_buddy) { |
3521e34f722a
Fix a segfault when not connected to a server
Mikael Berthe <mikael@lilotux.net>
parents:
797
diff
changeset
|
1938 |
if (forceupdate) { |
3521e34f722a
Fix a segfault when not connected to a server
Mikael Berthe <mikael@lilotux.net>
parents:
797
diff
changeset
|
1939 |
update_panels(); |
3521e34f722a
Fix a segfault when not connected to a server
Mikael Berthe <mikael@lilotux.net>
parents:
797
diff
changeset
|
1940 |
} |
3521e34f722a
Fix a segfault when not connected to a server
Mikael Berthe <mikael@lilotux.net>
parents:
797
diff
changeset
|
1941 |
return; |
3521e34f722a
Fix a segfault when not connected to a server
Mikael Berthe <mikael@lilotux.net>
parents:
797
diff
changeset
|
1942 |
} |
3521e34f722a
Fix a segfault when not connected to a server
Mikael Berthe <mikael@lilotux.net>
parents:
797
diff
changeset
|
1943 |
|
717
8ce2bfdc4143
Reindent update_chat_status_window()
Mikael Berthe <mikael@lilotux.net>
parents:
716
diff
changeset
|
1944 |
fullname = buddy_getname(BUDDATA(current_buddy)); |
8ce2bfdc4143
Reindent update_chat_status_window()
Mikael Berthe <mikael@lilotux.net>
parents:
716
diff
changeset
|
1945 |
btype = buddy_gettype(BUDDATA(current_buddy)); |
713 | 1946 |
|
1502
50dbbca69b55
Small style improvement of buddy status line
Maxim Vuets <maxim.vuets@gmail.com>
parents:
1489
diff
changeset
|
1947 |
isgrp = ismuc = isspe = 0; |
50dbbca69b55
Small style improvement of buddy status line
Maxim Vuets <maxim.vuets@gmail.com>
parents:
1489
diff
changeset
|
1948 |
if (btype & ROSTER_TYPE_USER) { |
50dbbca69b55
Small style improvement of buddy status line
Maxim Vuets <maxim.vuets@gmail.com>
parents:
1489
diff
changeset
|
1949 |
btypetext = "Buddy"; |
50dbbca69b55
Small style improvement of buddy status line
Maxim Vuets <maxim.vuets@gmail.com>
parents:
1489
diff
changeset
|
1950 |
} else if (btype & ROSTER_TYPE_GROUP) { |
50dbbca69b55
Small style improvement of buddy status line
Maxim Vuets <maxim.vuets@gmail.com>
parents:
1489
diff
changeset
|
1951 |
btypetext = "Group"; |
50dbbca69b55
Small style improvement of buddy status line
Maxim Vuets <maxim.vuets@gmail.com>
parents:
1489
diff
changeset
|
1952 |
isgrp = 1; |
50dbbca69b55
Small style improvement of buddy status line
Maxim Vuets <maxim.vuets@gmail.com>
parents:
1489
diff
changeset
|
1953 |
} else if (btype & ROSTER_TYPE_AGENT) { |
50dbbca69b55
Small style improvement of buddy status line
Maxim Vuets <maxim.vuets@gmail.com>
parents:
1489
diff
changeset
|
1954 |
btypetext = "Agent"; |
50dbbca69b55
Small style improvement of buddy status line
Maxim Vuets <maxim.vuets@gmail.com>
parents:
1489
diff
changeset
|
1955 |
} else if (btype & ROSTER_TYPE_ROOM) { |
50dbbca69b55
Small style improvement of buddy status line
Maxim Vuets <maxim.vuets@gmail.com>
parents:
1489
diff
changeset
|
1956 |
btypetext = "Room"; |
50dbbca69b55
Small style improvement of buddy status line
Maxim Vuets <maxim.vuets@gmail.com>
parents:
1489
diff
changeset
|
1957 |
ismuc = 1; |
50dbbca69b55
Small style improvement of buddy status line
Maxim Vuets <maxim.vuets@gmail.com>
parents:
1489
diff
changeset
|
1958 |
} else if (btype & ROSTER_TYPE_SPECIAL) { |
50dbbca69b55
Small style improvement of buddy status line
Maxim Vuets <maxim.vuets@gmail.com>
parents:
1489
diff
changeset
|
1959 |
btypetext = "Special buffer"; |
50dbbca69b55
Small style improvement of buddy status line
Maxim Vuets <maxim.vuets@gmail.com>
parents:
1489
diff
changeset
|
1960 |
isspe = 1; |
50dbbca69b55
Small style improvement of buddy status line
Maxim Vuets <maxim.vuets@gmail.com>
parents:
1489
diff
changeset
|
1961 |
} |
713 | 1962 |
|
1513
9d78b571e693
Show '#' for unread message per buddy on the buddy status line
Maxim Vuets <maxim.vuets@gmail.com>
parents:
1511
diff
changeset
|
1963 |
if (chatmode) { |
9d78b571e693
Show '#' for unread message per buddy on the buddy status line
Maxim Vuets <maxim.vuets@gmail.com>
parents:
1511
diff
changeset
|
1964 |
wprintw(chatstatusWnd, "~"); |
9d78b571e693
Show '#' for unread message per buddy on the buddy status line
Maxim Vuets <maxim.vuets@gmail.com>
parents:
1511
diff
changeset
|
1965 |
} else { |
9d78b571e693
Show '#' for unread message per buddy on the buddy status line
Maxim Vuets <maxim.vuets@gmail.com>
parents:
1511
diff
changeset
|
1966 |
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
|
1967 |
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
|
1968 |
// 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
|
1969 |
wprintw(chatstatusWnd, "#"); |
9d78b571e693
Show '#' for unread message per buddy on the buddy status line
Maxim Vuets <maxim.vuets@gmail.com>
parents:
1511
diff
changeset
|
1970 |
} |
9d78b571e693
Show '#' for unread message per buddy on the buddy status line
Maxim Vuets <maxim.vuets@gmail.com>
parents:
1511
diff
changeset
|
1971 |
} |
9d78b571e693
Show '#' for unread message per buddy on the buddy status line
Maxim Vuets <maxim.vuets@gmail.com>
parents:
1511
diff
changeset
|
1972 |
|
874
293e8955075c
Display a flag in the chat status line when the buffer is locked
Mikael Berthe <mikael@lilotux.net>
parents:
873
diff
changeset
|
1973 |
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
|
1974 |
winbuf *win_entry; |
1780
e4378fbab5d7
Major API cleanup - bump API to 4
Mikael Berthe <mikael@lilotux.net>
parents:
1761
diff
changeset
|
1975 |
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
|
1976 |
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
|
1977 |
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
|
1978 |
} |
293e8955075c
Display a flag in the chat status line when the buffer is locked
Mikael Berthe <mikael@lilotux.net>
parents:
873
diff
changeset
|
1979 |
|
848
a9161d2dc414
Introduce special buffer stuff
Mikael Berthe <mikael@lilotux.net>
parents:
843
diff
changeset
|
1980 |
if (isgrp || isspe) { |
773
e25b8a348ebd
Screen updating functions use UTF-8
Mikael Berthe <mikael@lilotux.net>
parents:
772
diff
changeset
|
1981 |
buf_locale = from_utf8(fullname); |
1502
50dbbca69b55
Small style improvement of buddy status line
Maxim Vuets <maxim.vuets@gmail.com>
parents:
1489
diff
changeset
|
1982 |
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
|
1983 |
g_free(buf_locale); |
716
ba1137a01078
Add a chatmode flag (©) in the chat status line
Mikael Berthe <mikael@lilotux.net>
parents:
715
diff
changeset
|
1984 |
if (forceupdate) { |
ba1137a01078
Add a chatmode flag (©) in the chat status line
Mikael Berthe <mikael@lilotux.net>
parents:
715
diff
changeset
|
1985 |
update_panels(); |
ba1137a01078
Add a chatmode flag (©) in the chat status line
Mikael Berthe <mikael@lilotux.net>
parents:
715
diff
changeset
|
1986 |
} |
717
8ce2bfdc4143
Reindent update_chat_status_window()
Mikael Berthe <mikael@lilotux.net>
parents:
716
diff
changeset
|
1987 |
return; |
8ce2bfdc4143
Reindent update_chat_status_window()
Mikael Berthe <mikael@lilotux.net>
parents:
716
diff
changeset
|
1988 |
} |
8ce2bfdc4143
Reindent update_chat_status_window()
Mikael Berthe <mikael@lilotux.net>
parents:
716
diff
changeset
|
1989 |
|
8ce2bfdc4143
Reindent update_chat_status_window()
Mikael Berthe <mikael@lilotux.net>
parents:
716
diff
changeset
|
1990 |
status = '?'; |
8ce2bfdc4143
Reindent update_chat_status_window()
Mikael Berthe <mikael@lilotux.net>
parents:
716
diff
changeset
|
1991 |
|
2013
8dc418af3e72
Allow to select to which buddy resource messages go. Closes issue #55
Hermitifier
parents:
2012
diff
changeset
|
1992 |
activeres = buddy_getactiveresource(BUDDATA(current_buddy)); |
8dc418af3e72
Allow to select to which buddy resource messages go. Closes issue #55
Hermitifier
parents:
2012
diff
changeset
|
1993 |
|
717
8ce2bfdc4143
Reindent update_chat_status_window()
Mikael Berthe <mikael@lilotux.net>
parents:
716
diff
changeset
|
1994 |
if (ismuc) { |
8ce2bfdc4143
Reindent update_chat_status_window()
Mikael Berthe <mikael@lilotux.net>
parents:
716
diff
changeset
|
1995 |
if (buddy_getinsideroom(BUDDATA(current_buddy))) |
8ce2bfdc4143
Reindent update_chat_status_window()
Mikael Berthe <mikael@lilotux.net>
parents:
716
diff
changeset
|
1996 |
status = 'C'; |
8ce2bfdc4143
Reindent update_chat_status_window()
Mikael Berthe <mikael@lilotux.net>
parents:
716
diff
changeset
|
1997 |
else |
8ce2bfdc4143
Reindent update_chat_status_window()
Mikael Berthe <mikael@lilotux.net>
parents:
716
diff
changeset
|
1998 |
status = 'x'; |
1598 | 1999 |
} else if (xmpp_getstatus() != offline) { |
717
8ce2bfdc4143
Reindent update_chat_status_window()
Mikael Berthe <mikael@lilotux.net>
parents:
716
diff
changeset
|
2000 |
enum imstatus budstate; |
2013
8dc418af3e72
Allow to select to which buddy resource messages go. Closes issue #55
Hermitifier
parents:
2012
diff
changeset
|
2001 |
budstate = buddy_getstatus(BUDDATA(current_buddy), activeres); |
790
5d4ad1d77da4
Kill a few gcc4 warnings
Mikael Berthe <mikael@lilotux.net>
parents:
785
diff
changeset
|
2002 |
if (budstate < imstatus_size) |
717
8ce2bfdc4143
Reindent update_chat_status_window()
Mikael Berthe <mikael@lilotux.net>
parents:
716
diff
changeset
|
2003 |
status = imstatus2char[budstate]; |
8ce2bfdc4143
Reindent update_chat_status_window()
Mikael Berthe <mikael@lilotux.net>
parents:
716
diff
changeset
|
2004 |
} |
8ce2bfdc4143
Reindent update_chat_status_window()
Mikael Berthe <mikael@lilotux.net>
parents:
716
diff
changeset
|
2005 |
|
1502
50dbbca69b55
Small style improvement of buddy status line
Maxim Vuets <maxim.vuets@gmail.com>
parents:
1489
diff
changeset
|
2006 |
// No status message for MUC rooms |
50dbbca69b55
Small style improvement of buddy status line
Maxim Vuets <maxim.vuets@gmail.com>
parents:
1489
diff
changeset
|
2007 |
if (!ismuc) { |
2013
8dc418af3e72
Allow to select to which buddy resource messages go. Closes issue #55
Hermitifier
parents:
2012
diff
changeset
|
2008 |
if (activeres) { |
8dc418af3e72
Allow to select to which buddy resource messages go. Closes issue #55
Hermitifier
parents:
2012
diff
changeset
|
2009 |
fullnameres = g_strdup_printf("%s/%s", fullname, activeres); |
8dc418af3e72
Allow to select to which buddy resource messages go. Closes issue #55
Hermitifier
parents:
2012
diff
changeset
|
2010 |
fullname = fullnameres; |
8dc418af3e72
Allow to select to which buddy resource messages go. Closes issue #55
Hermitifier
parents:
2012
diff
changeset
|
2011 |
msg = buddy_getstatusmsg(BUDDATA(current_buddy), activeres); |
8dc418af3e72
Allow to select to which buddy resource messages go. Closes issue #55
Hermitifier
parents:
2012
diff
changeset
|
2012 |
} else { |
8dc418af3e72
Allow to select to which buddy resource messages go. Closes issue #55
Hermitifier
parents:
2012
diff
changeset
|
2013 |
GSList *resources, *p_res, *p_next_res; |
8dc418af3e72
Allow to select to which buddy resource messages go. Closes issue #55
Hermitifier
parents:
2012
diff
changeset
|
2014 |
resources = buddy_getresources(BUDDATA(current_buddy)); |
8dc418af3e72
Allow to select to which buddy resource messages go. Closes issue #55
Hermitifier
parents:
2012
diff
changeset
|
2015 |
|
8dc418af3e72
Allow to select to which buddy resource messages go. Closes issue #55
Hermitifier
parents:
2012
diff
changeset
|
2016 |
for (p_res = resources ; p_res ; p_res = p_next_res) { |
8dc418af3e72
Allow to select to which buddy resource messages go. Closes issue #55
Hermitifier
parents:
2012
diff
changeset
|
2017 |
p_next_res = g_slist_next(p_res); |
8dc418af3e72
Allow to select to which buddy resource messages go. Closes issue #55
Hermitifier
parents:
2012
diff
changeset
|
2018 |
// Store the status message of the latest resource (highest priority) |
8dc418af3e72
Allow to select to which buddy resource messages go. Closes issue #55
Hermitifier
parents:
2012
diff
changeset
|
2019 |
if (!p_next_res) |
8dc418af3e72
Allow to select to which buddy resource messages go. Closes issue #55
Hermitifier
parents:
2012
diff
changeset
|
2020 |
msg = buddy_getstatusmsg(BUDDATA(current_buddy), p_res->data); |
8dc418af3e72
Allow to select to which buddy resource messages go. Closes issue #55
Hermitifier
parents:
2012
diff
changeset
|
2021 |
g_free(p_res->data); |
8dc418af3e72
Allow to select to which buddy resource messages go. Closes issue #55
Hermitifier
parents:
2012
diff
changeset
|
2022 |
} |
8dc418af3e72
Allow to select to which buddy resource messages go. Closes issue #55
Hermitifier
parents:
2012
diff
changeset
|
2023 |
g_slist_free(resources); |
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
|
2024 |
} |
1502
50dbbca69b55
Small style improvement of buddy status line
Maxim Vuets <maxim.vuets@gmail.com>
parents:
1489
diff
changeset
|
2025 |
} else { |
721
9cf31c9b1dc4
Use room topic as a description in the chat status line
Mikael Berthe <mikael@lilotux.net>
parents:
720
diff
changeset
|
2026 |
msg = buddy_gettopic(BUDDATA(current_buddy)); |
717
8ce2bfdc4143
Reindent update_chat_status_window()
Mikael Berthe <mikael@lilotux.net>
parents:
716
diff
changeset
|
2027 |
} |
1502
50dbbca69b55
Small style improvement of buddy status line
Maxim Vuets <maxim.vuets@gmail.com>
parents:
1489
diff
changeset
|
2028 |
|
50dbbca69b55
Small style improvement of buddy status line
Maxim Vuets <maxim.vuets@gmail.com>
parents:
1489
diff
changeset
|
2029 |
if (msg) |
50dbbca69b55
Small style improvement of buddy status line
Maxim Vuets <maxim.vuets@gmail.com>
parents:
1489
diff
changeset
|
2030 |
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
|
2031 |
else |
50dbbca69b55
Small style improvement of buddy status line
Maxim Vuets <maxim.vuets@gmail.com>
parents:
1489
diff
changeset
|
2032 |
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
|
2033 |
replace_nl_with_dots(buf); |
773
e25b8a348ebd
Screen updating functions use UTF-8
Mikael Berthe <mikael@lilotux.net>
parents:
772
diff
changeset
|
2034 |
buf_locale = from_utf8(buf); |
e25b8a348ebd
Screen updating functions use UTF-8
Mikael Berthe <mikael@lilotux.net>
parents:
772
diff
changeset
|
2035 |
mvwprintw(chatstatusWnd, 0, 1, "%s", buf_locale); |
2013
8dc418af3e72
Allow to select to which buddy resource messages go. Closes issue #55
Hermitifier
parents:
2012
diff
changeset
|
2036 |
g_free(fullnameres); |
773
e25b8a348ebd
Screen updating functions use UTF-8
Mikael Berthe <mikael@lilotux.net>
parents:
772
diff
changeset
|
2037 |
g_free(buf_locale); |
717
8ce2bfdc4143
Reindent update_chat_status_window()
Mikael Berthe <mikael@lilotux.net>
parents:
716
diff
changeset
|
2038 |
g_free(buf); |
8ce2bfdc4143
Reindent update_chat_status_window()
Mikael Berthe <mikael@lilotux.net>
parents:
716
diff
changeset
|
2039 |
|
996
f4d6570e2628
Chatstates: display contact chatstate in the chat status bar
Mikael Berthe <mikael@lilotux.net>
parents:
993
diff
changeset
|
2040 |
// 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
|
2041 |
if (btype & ROSTER_TYPE_USER) { |
f4d6570e2628
Chatstates: display contact chatstate in the chat status bar
Mikael Berthe <mikael@lilotux.net>
parents:
993
diff
changeset
|
2042 |
char eventchar = 0; |
f4d6570e2628
Chatstates: display contact chatstate in the chat status bar
Mikael Berthe <mikael@lilotux.net>
parents:
993
diff
changeset
|
2043 |
guint event; |
f4d6570e2628
Chatstates: display contact chatstate in the chat status bar
Mikael Berthe <mikael@lilotux.net>
parents:
993
diff
changeset
|
2044 |
|
2013
8dc418af3e72
Allow to select to which buddy resource messages go. Closes issue #55
Hermitifier
parents:
2012
diff
changeset
|
2045 |
// We specify active resource here, so when there is none then the resource |
8dc418af3e72
Allow to select to which buddy resource messages go. Closes issue #55
Hermitifier
parents:
2012
diff
changeset
|
2046 |
// with the highest priority will be used. |
8dc418af3e72
Allow to select to which buddy resource messages go. Closes issue #55
Hermitifier
parents:
2012
diff
changeset
|
2047 |
event = buddy_resource_getevents(BUDDATA(current_buddy), activeres); |
996
f4d6570e2628
Chatstates: display contact chatstate in the chat status bar
Mikael Berthe <mikael@lilotux.net>
parents:
993
diff
changeset
|
2048 |
|
f4d6570e2628
Chatstates: display contact chatstate in the chat status bar
Mikael Berthe <mikael@lilotux.net>
parents:
993
diff
changeset
|
2049 |
if (event == ROSTER_EVENT_ACTIVE) |
f4d6570e2628
Chatstates: display contact chatstate in the chat status bar
Mikael Berthe <mikael@lilotux.net>
parents:
993
diff
changeset
|
2050 |
eventchar = 'A'; |
f4d6570e2628
Chatstates: display contact chatstate in the chat status bar
Mikael Berthe <mikael@lilotux.net>
parents:
993
diff
changeset
|
2051 |
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
|
2052 |
eventchar = 'C'; |
f4d6570e2628
Chatstates: display contact chatstate in the chat status bar
Mikael Berthe <mikael@lilotux.net>
parents:
993
diff
changeset
|
2053 |
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
|
2054 |
eventchar = 'P'; |
f4d6570e2628
Chatstates: display contact chatstate in the chat status bar
Mikael Berthe <mikael@lilotux.net>
parents:
993
diff
changeset
|
2055 |
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
|
2056 |
eventchar = 'I'; |
f4d6570e2628
Chatstates: display contact chatstate in the chat status bar
Mikael Berthe <mikael@lilotux.net>
parents:
993
diff
changeset
|
2057 |
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
|
2058 |
eventchar = 'G'; |
f4d6570e2628
Chatstates: display contact chatstate in the chat status bar
Mikael Berthe <mikael@lilotux.net>
parents:
993
diff
changeset
|
2059 |
|
f4d6570e2628
Chatstates: display contact chatstate in the chat status bar
Mikael Berthe <mikael@lilotux.net>
parents:
993
diff
changeset
|
2060 |
if (eventchar) |
f4d6570e2628
Chatstates: display contact chatstate in the chat status bar
Mikael Berthe <mikael@lilotux.net>
parents:
993
diff
changeset
|
2061 |
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
|
2062 |
} |
f4d6570e2628
Chatstates: display contact chatstate in the chat status bar
Mikael Berthe <mikael@lilotux.net>
parents:
993
diff
changeset
|
2063 |
|
f4d6570e2628
Chatstates: display contact chatstate in the chat status bar
Mikael Berthe <mikael@lilotux.net>
parents:
993
diff
changeset
|
2064 |
|
717
8ce2bfdc4143
Reindent update_chat_status_window()
Mikael Berthe <mikael@lilotux.net>
parents:
716
diff
changeset
|
2065 |
if (forceupdate) { |
8ce2bfdc4143
Reindent update_chat_status_window()
Mikael Berthe <mikael@lilotux.net>
parents:
716
diff
changeset
|
2066 |
update_panels(); |
8ce2bfdc4143
Reindent update_chat_status_window()
Mikael Berthe <mikael@lilotux.net>
parents:
716
diff
changeset
|
2067 |
} |
713 | 2068 |
} |
2069 |
||
1504
9fafea381eb8
Show the number of unfiltered contacts in folded groups
franky
parents:
1503
diff
changeset
|
2070 |
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
|
2071 |
{ |
9fafea381eb8
Show the number of unfiltered contacts in folded groups
franky
parents:
1503
diff
changeset
|
2072 |
int *p = param; |
9fafea381eb8
Show the number of unfiltered contacts in folded groups
franky
parents:
1503
diff
changeset
|
2073 |
if (buddylist_is_status_filtered(buddy_getstatus(rosterdata, NULL))) |
9fafea381eb8
Show the number of unfiltered contacts in folded groups
franky
parents:
1503
diff
changeset
|
2074 |
*p=*p+1; |
9fafea381eb8
Show the number of unfiltered contacts in folded groups
franky
parents:
1503
diff
changeset
|
2075 |
} |
9fafea381eb8
Show the number of unfiltered contacts in folded groups
franky
parents:
1503
diff
changeset
|
2076 |
|
1780
e4378fbab5d7
Major API cleanup - bump API to 4
Mikael Berthe <mikael@lilotux.net>
parents:
1761
diff
changeset
|
2077 |
// scr_draw_roster() |
328
83d129adde03
Add set_current_buddy() function, to reduce code duplication
Mikael Berthe <mikael@lilotux.net>
parents:
325
diff
changeset
|
2078 |
// 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
|
2079 |
void scr_draw_roster(void) |
24 | 2080 |
{ |
735 | 2081 |
static int offset = 0; |
701
6c100adfbfb6
Add setting "roster_width" (variable buddylist width)
Mikael Berthe <mikael@lilotux.net>
parents:
699
diff
changeset
|
2082 |
char *name, *rline; |
81 | 2083 |
int maxx, maxy; |
2084 |
GList *buddy; |
|
2085 |
int i, n; |
|
2086 |
int rOffset; |
|
713 | 2087 |
int cursor_backup; |
2100
113d3b96ae3e
Add option 'attention_char'
Mikael Berthe <mikael@lilotux.net>
parents:
2098
diff
changeset
|
2088 |
guint status, pending; |
1598 | 2089 |
enum imstatus currentstatus = xmpp_getstatus(); |
973
e693cbe33802
Add option 'roster_win_on_right'
Mikael Berthe <mikael@lilotux.net>
parents:
972
diff
changeset
|
2090 |
int x_pos; |
2007
6c02ccb14c1c
Added an option to remove the extra space before items in the roster.
Simon Jacquin <simon@jacquin.me>
parents:
1997
diff
changeset
|
2091 |
int prefix_length; |
2136
54548cf8f646
screen.c: Remove one memory allocation in scr_draw_roster()
Mikael Berthe <mikael@lilotux.net>
parents:
2101
diff
changeset
|
2092 |
char space[2] = " "; |
81 | 2093 |
|
123 | 2094 |
// We can reset update_roster |
2292
f181418db215
Replace global variable update_roster with scr_update_roster()
franky
parents:
2291
diff
changeset
|
2095 |
if (_update_roster == FALSE) |
f181418db215
Replace global variable update_roster with scr_update_roster()
franky
parents:
2291
diff
changeset
|
2096 |
return; |
f181418db215
Replace global variable update_roster with scr_update_roster()
franky
parents:
2291
diff
changeset
|
2097 |
_update_roster = FALSE; |
123 | 2098 |
|
2291
0d350e979bde
Don't rebuild the buddylist multiple times before a screen refresh
franky
parents:
2288
diff
changeset
|
2099 |
buddylist_build(); |
0d350e979bde
Don't rebuild the buddylist multiple times before a screen refresh
franky
parents:
2288
diff
changeset
|
2100 |
|
81 | 2101 |
getmaxyx(rosterWnd, maxy, maxx); |
701
6c100adfbfb6
Add setting "roster_width" (variable buddylist width)
Mikael Berthe <mikael@lilotux.net>
parents:
699
diff
changeset
|
2102 |
maxx--; // Last char is for vertical border |
81 | 2103 |
|
713 | 2104 |
cursor_backup = curs_set(0); |
2105 |
||
724
264375fe7159
Fix a roster refresh issue
Mikael Berthe <mikael@lilotux.net>
parents:
723
diff
changeset
|
2106 |
if (!buddylist) |
264375fe7159
Fix a roster refresh issue
Mikael Berthe <mikael@lilotux.net>
parents:
723
diff
changeset
|
2107 |
offset = 0; |
264375fe7159
Fix a roster refresh issue
Mikael Berthe <mikael@lilotux.net>
parents:
723
diff
changeset
|
2108 |
else |
1780
e4378fbab5d7
Major API cleanup - bump API to 4
Mikael Berthe <mikael@lilotux.net>
parents:
1761
diff
changeset
|
2109 |
scr_update_chat_status(FALSE); |
724
264375fe7159
Fix a roster refresh issue
Mikael Berthe <mikael@lilotux.net>
parents:
723
diff
changeset
|
2110 |
|
701
6c100adfbfb6
Add setting "roster_width" (variable buddylist width)
Mikael Berthe <mikael@lilotux.net>
parents:
699
diff
changeset
|
2111 |
// Cleanup of roster window |
168 | 2112 |
werase(rosterWnd); |
81 | 2113 |
|
707
b26a0bde4cdb
Add /roster hide|show|toggle
Mikael Berthe <mikael@lilotux.net>
parents:
701
diff
changeset
|
2114 |
if (Roster_Width) { |
973
e693cbe33802
Add option 'roster_win_on_right'
Mikael Berthe <mikael@lilotux.net>
parents:
972
diff
changeset
|
2115 |
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
|
2116 |
// Redraw the vertical line (not very good...) |
739
0d5fb1d9077c
Allow "bright" text colors
Mikael Berthe <mikael@lilotux.net>
parents:
735
diff
changeset
|
2117 |
wattrset(rosterWnd, get_color(COLOR_GENERAL)); |
707
b26a0bde4cdb
Add /roster hide|show|toggle
Mikael Berthe <mikael@lilotux.net>
parents:
701
diff
changeset
|
2118 |
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
|
2119 |
mvwaddch(rosterWnd, i, line_x_pos, ACS_VLINE); |
707
b26a0bde4cdb
Add /roster hide|show|toggle
Mikael Berthe <mikael@lilotux.net>
parents:
701
diff
changeset
|
2120 |
} |
b26a0bde4cdb
Add /roster hide|show|toggle
Mikael Berthe <mikael@lilotux.net>
parents:
701
diff
changeset
|
2121 |
|
b26a0bde4cdb
Add /roster hide|show|toggle
Mikael Berthe <mikael@lilotux.net>
parents:
701
diff
changeset
|
2122 |
// 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
|
2123 |
if (!buddylist || !Roster_Width) { |
123 | 2124 |
update_panels(); |
713 | 2125 |
curs_set(cursor_backup); |
81 | 2126 |
return; |
2127 |
} |
|
2128 |
||
84 | 2129 |
// Update offset if necessary |
680
1f8987e0e56c
Try to display as many buddylist items as possible
Mikael Berthe <mikael@lilotux.net>
parents:
679
diff
changeset
|
2130 |
// 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
|
2131 |
i = g_list_length(buddylist) - maxy; |
682
f3945593432e
Small fix in scr_DrawRoster()
Mikael Berthe <mikael@lilotux.net>
parents:
680
diff
changeset
|
2132 |
if (i < 0) |
f3945593432e
Small fix in scr_DrawRoster()
Mikael Berthe <mikael@lilotux.net>
parents:
680
diff
changeset
|
2133 |
i = 0; |
f3945593432e
Small fix in scr_DrawRoster()
Mikael Berthe <mikael@lilotux.net>
parents:
680
diff
changeset
|
2134 |
if (i < offset) |
680
1f8987e0e56c
Try to display as many buddylist items as possible
Mikael Berthe <mikael@lilotux.net>
parents:
679
diff
changeset
|
2135 |
offset = i; |
1f8987e0e56c
Try to display as many buddylist items as possible
Mikael Berthe <mikael@lilotux.net>
parents:
679
diff
changeset
|
2136 |
// b) Make sure the current_buddy is visible |
84 | 2137 |
i = g_list_position(buddylist, current_buddy); |
2138 |
if (i == -1) { // This is bad |
|
374
bd5638c21834
Improve logging system (traces)
Mikael Berthe <mikael@lilotux.net>
parents:
373
diff
changeset
|
2139 |
scr_LogPrint(LPRINT_NORMAL, "Doh! Can't find current selected buddy!!"); |
713 | 2140 |
curs_set(cursor_backup); |
84 | 2141 |
return; |
2142 |
} else if (i < offset) { |
|
2143 |
offset = i; |
|
2144 |
} else if (i+1 > offset + maxy) { |
|
2145 |
offset = i + 1 - maxy; |
|
2146 |
} |
|
81 | 2147 |
|
973
e693cbe33802
Add option 'roster_win_on_right'
Mikael Berthe <mikael@lilotux.net>
parents:
972
diff
changeset
|
2148 |
if (roster_win_on_right) |
e693cbe33802
Add option 'roster_win_on_right'
Mikael Berthe <mikael@lilotux.net>
parents:
972
diff
changeset
|
2149 |
x_pos = 1; // 1 char offset (vertical line) |
e693cbe33802
Add option 'roster_win_on_right'
Mikael Berthe <mikael@lilotux.net>
parents:
972
diff
changeset
|
2150 |
else |
e693cbe33802
Add option 'roster_win_on_right'
Mikael Berthe <mikael@lilotux.net>
parents:
972
diff
changeset
|
2151 |
x_pos = 0; |
e693cbe33802
Add option 'roster_win_on_right'
Mikael Berthe <mikael@lilotux.net>
parents:
972
diff
changeset
|
2152 |
|
2009
a859ed648638
Replace the option « no_space_before_items » with « roster_no_leading_space ».
Simon Jacquin <simon@jacquin.me>
parents:
2008
diff
changeset
|
2153 |
if (roster_no_leading_space) { |
2007
6c02ccb14c1c
Added an option to remove the extra space before items in the roster.
Simon Jacquin <simon@jacquin.me>
parents:
1997
diff
changeset
|
2154 |
space[0] = '\0'; |
6c02ccb14c1c
Added an option to remove the extra space before items in the roster.
Simon Jacquin <simon@jacquin.me>
parents:
1997
diff
changeset
|
2155 |
prefix_length = 6; |
6c02ccb14c1c
Added an option to remove the extra space before items in the roster.
Simon Jacquin <simon@jacquin.me>
parents:
1997
diff
changeset
|
2156 |
} else { |
6c02ccb14c1c
Added an option to remove the extra space before items in the roster.
Simon Jacquin <simon@jacquin.me>
parents:
1997
diff
changeset
|
2157 |
prefix_length = 7; |
6c02ccb14c1c
Added an option to remove the extra space before items in the roster.
Simon Jacquin <simon@jacquin.me>
parents:
1997
diff
changeset
|
2158 |
} |
6c02ccb14c1c
Added an option to remove the extra space before items in the roster.
Simon Jacquin <simon@jacquin.me>
parents:
1997
diff
changeset
|
2159 |
|
1026
fc6060707022
[BP] Fixes truncating utf-8 buddy names (Myhailo Danylenko)
Mikael Berthe <mikael@lilotux.net>
parents:
966
diff
changeset
|
2160 |
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
|
2161 |
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
|
2162 |
|
81 | 2163 |
buddy = buddylist; |
2164 |
rOffset = offset; |
|
2165 |
||
84 | 2166 |
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
|
2167 |
unsigned short bflags, btype; |
35a1250c111a
Display urgent/attention sign in the roster UI
Mikael Berthe <mikael@lilotux.net>
parents:
1802
diff
changeset
|
2168 |
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
|
2169 |
guint isurg; |
773
e25b8a348ebd
Screen updating functions use UTF-8
Mikael Berthe <mikael@lilotux.net>
parents:
772
diff
changeset
|
2170 |
gchar *rline_locale; |
713 | 2171 |
|
2172 |
bflags = buddy_getflags(BUDDATA(buddy)); |
|
2173 |
btype = buddy_gettype(BUDDATA(buddy)); |
|
2174 |
||
2175 |
ismsg = bflags & ROSTER_FLAG_MSG; |
|
2176 |
ishid = bflags & ROSTER_FLAG_HIDE; |
|
2177 |
isgrp = btype & ROSTER_TYPE_GROUP; |
|
2178 |
ismuc = btype & ROSTER_TYPE_ROOM; |
|
848
a9161d2dc414
Introduce special buffer stuff
Mikael Berthe <mikael@lilotux.net>
parents:
843
diff
changeset
|
2179 |
isspe = btype & ROSTER_TYPE_SPECIAL; |
1804
35a1250c111a
Display urgent/attention sign in the roster UI
Mikael Berthe <mikael@lilotux.net>
parents:
1802
diff
changeset
|
2180 |
isurg = buddy_getuiprio(BUDDATA(buddy)); |
81 | 2181 |
|
2182 |
if (rOffset > 0) { |
|
2183 |
rOffset--; |
|
2184 |
continue; |
|
2185 |
} |
|
2186 |
||
713 | 2187 |
status = '?'; |
2188 |
pending = ' '; |
|
2189 |
||
2280
f1eebfdd6db7
Improve efficiency with high number of MUC resources
Mikael Berthe <mikael@lilotux.net>
parents:
2268
diff
changeset
|
2190 |
if (!ismuc) { |
f1eebfdd6db7
Improve efficiency with high number of MUC resources
Mikael Berthe <mikael@lilotux.net>
parents:
2268
diff
changeset
|
2191 |
// There is currently no chat state support for MUC |
f1eebfdd6db7
Improve efficiency with high number of MUC resources
Mikael Berthe <mikael@lilotux.net>
parents:
2268
diff
changeset
|
2192 |
GSList *resources = buddy_getresources(BUDDATA(buddy)); |
f1eebfdd6db7
Improve efficiency with high number of MUC resources
Mikael Berthe <mikael@lilotux.net>
parents:
2268
diff
changeset
|
2193 |
GSList *p_res; |
f1eebfdd6db7
Improve efficiency with high number of MUC resources
Mikael Berthe <mikael@lilotux.net>
parents:
2268
diff
changeset
|
2194 |
|
f1eebfdd6db7
Improve efficiency with high number of MUC resources
Mikael Berthe <mikael@lilotux.net>
parents:
2268
diff
changeset
|
2195 |
for (p_res = resources ; p_res ; p_res = g_slist_next(p_res)) { |
f1eebfdd6db7
Improve efficiency with high number of MUC resources
Mikael Berthe <mikael@lilotux.net>
parents:
2268
diff
changeset
|
2196 |
guint events = buddy_resource_getevents(BUDDATA(buddy), |
f1eebfdd6db7
Improve efficiency with high number of MUC resources
Mikael Berthe <mikael@lilotux.net>
parents:
2268
diff
changeset
|
2197 |
p_res ? p_res->data : ""); |
f1eebfdd6db7
Improve efficiency with high number of MUC resources
Mikael Berthe <mikael@lilotux.net>
parents:
2268
diff
changeset
|
2198 |
if ((events & ROSTER_EVENT_PAUSED) && pending != '+') |
f1eebfdd6db7
Improve efficiency with high number of MUC resources
Mikael Berthe <mikael@lilotux.net>
parents:
2268
diff
changeset
|
2199 |
pending = '.'; |
f1eebfdd6db7
Improve efficiency with high number of MUC resources
Mikael Berthe <mikael@lilotux.net>
parents:
2268
diff
changeset
|
2200 |
if (events & ROSTER_EVENT_COMPOSING) |
f1eebfdd6db7
Improve efficiency with high number of MUC resources
Mikael Berthe <mikael@lilotux.net>
parents:
2268
diff
changeset
|
2201 |
pending = '+'; |
f1eebfdd6db7
Improve efficiency with high number of MUC resources
Mikael Berthe <mikael@lilotux.net>
parents:
2268
diff
changeset
|
2202 |
g_free(p_res->data); |
f1eebfdd6db7
Improve efficiency with high number of MUC resources
Mikael Berthe <mikael@lilotux.net>
parents:
2268
diff
changeset
|
2203 |
} |
f1eebfdd6db7
Improve efficiency with high number of MUC resources
Mikael Berthe <mikael@lilotux.net>
parents:
2268
diff
changeset
|
2204 |
g_slist_free(resources); |
986
ed697234bd39
Chat states receival (Alexis Hildebrandt)
Mikael Berthe <mikael@lilotux.net>
parents:
981
diff
changeset
|
2205 |
} |
ed697234bd39
Chat states receival (Alexis Hildebrandt)
Mikael Berthe <mikael@lilotux.net>
parents:
981
diff
changeset
|
2206 |
|
149 | 2207 |
// Display message notice if there is a message flag, but not |
2208 |
// for unfolded groups. |
|
2209 |
if (ismsg && (!isgrp || ishid)) { |
|
81 | 2210 |
pending = '#'; |
2211 |
} |
|
2212 |
||
713 | 2213 |
if (ismuc) { |
2214 |
if (buddy_getinsideroom(BUDDATA(buddy))) |
|
2215 |
status = 'C'; |
|
2216 |
else |
|
2217 |
status = 'x'; |
|
2218 |
} else if (currentstatus != offline) { |
|
2219 |
enum imstatus budstate; |
|
2220 |
budstate = buddy_getstatus(BUDDATA(buddy), NULL); |
|
790
5d4ad1d77da4
Kill a few gcc4 warnings
Mikael Berthe <mikael@lilotux.net>
parents:
785
diff
changeset
|
2221 |
if (budstate < imstatus_size) |
713 | 2222 |
status = imstatus2char[budstate]; |
2223 |
} |
|
81 | 2224 |
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
|
2225 |
if (pending == '#') |
739
0d5fb1d9077c
Allow "bright" text colors
Mikael Berthe <mikael@lilotux.net>
parents:
735
diff
changeset
|
2226 |
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
|
2227 |
else |
739
0d5fb1d9077c
Allow "bright" text colors
Mikael Berthe <mikael@lilotux.net>
parents:
735
diff
changeset
|
2228 |
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
|
2229 |
// 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
|
2230 |
wmove(rosterWnd, i, x_pos); |
81 | 2231 |
for (n = 0; n < maxx; n++) |
2232 |
waddch(rosterWnd, ' '); |
|
2233 |
} else { |
|
149 | 2234 |
if (pending == '#') |
739
0d5fb1d9077c
Allow "bright" text colors
Mikael Berthe <mikael@lilotux.net>
parents:
735
diff
changeset
|
2235 |
wattrset(rosterWnd, get_color(COLOR_ROSTERNMSG)); |
1272
033576acac4c
Add configurable roster colors (Michal 'vorner' Vaner)
Mikael Berthe <mikael@lilotux.net>
parents:
1268
diff
changeset
|
2236 |
else { |
033576acac4c
Add configurable roster colors (Michal 'vorner' Vaner)
Mikael Berthe <mikael@lilotux.net>
parents:
1268
diff
changeset
|
2237 |
int color = get_color(COLOR_ROSTER); |
1729
e6e89b1d7831
Minor style and header updates
Mikael Berthe <mikael@lilotux.net>
parents:
1710
diff
changeset
|
2238 |
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
|
2239 |
GSList *head; |
1804
35a1250c111a
Display urgent/attention sign in the roster UI
Mikael Berthe <mikael@lilotux.net>
parents:
1802
diff
changeset
|
2240 |
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
|
2241 |
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
|
2242 |
rostercolor *rc = head->data; |
1804
35a1250c111a
Display urgent/attention sign in the roster UI
Mikael Berthe <mikael@lilotux.net>
parents:
1802
diff
changeset
|
2243 |
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
|
2244 |
(!strcmp("*", rc->status) || strchr(rc->status, status))) { |
1489
e9c71ce96dca
Fixed the colorhandling for mucnicks and /color roster
franky@veqlargh.fs
parents:
1488
diff
changeset
|
2245 |
color = compose_color(rc->color); |
1272
033576acac4c
Add configurable roster colors (Michal 'vorner' Vaner)
Mikael Berthe <mikael@lilotux.net>
parents:
1268
diff
changeset
|
2246 |
break; |
033576acac4c
Add configurable roster colors (Michal 'vorner' Vaner)
Mikael Berthe <mikael@lilotux.net>
parents:
1268
diff
changeset
|
2247 |
} |
033576acac4c
Add configurable roster colors (Michal 'vorner' Vaner)
Mikael Berthe <mikael@lilotux.net>
parents:
1268
diff
changeset
|
2248 |
} |
033576acac4c
Add configurable roster colors (Michal 'vorner' Vaner)
Mikael Berthe <mikael@lilotux.net>
parents:
1268
diff
changeset
|
2249 |
} |
033576acac4c
Add configurable roster colors (Michal 'vorner' Vaner)
Mikael Berthe <mikael@lilotux.net>
parents:
1268
diff
changeset
|
2250 |
wattrset(rosterWnd, color); |
033576acac4c
Add configurable roster colors (Michal 'vorner' Vaner)
Mikael Berthe <mikael@lilotux.net>
parents:
1268
diff
changeset
|
2251 |
} |
81 | 2252 |
} |
2253 |
||
2007
6c02ccb14c1c
Added an option to remove the extra space before items in the roster.
Simon Jacquin <simon@jacquin.me>
parents:
1997
diff
changeset
|
2254 |
if (Roster_Width > prefix_length) |
6c02ccb14c1c
Added an option to remove the extra space before items in the roster.
Simon Jacquin <simon@jacquin.me>
parents:
1997
diff
changeset
|
2255 |
g_utf8_strncpy(name, buddy_getname(BUDDATA(buddy)), Roster_Width-prefix_length); |
701
6c100adfbfb6
Add setting "roster_width" (variable buddylist width)
Mikael Berthe <mikael@lilotux.net>
parents:
699
diff
changeset
|
2256 |
else |
6c100adfbfb6
Add setting "roster_width" (variable buddylist width)
Mikael Berthe <mikael@lilotux.net>
parents:
699
diff
changeset
|
2257 |
name[0] = 0; |
6c100adfbfb6
Add setting "roster_width" (variable buddylist width)
Mikael Berthe <mikael@lilotux.net>
parents:
699
diff
changeset
|
2258 |
|
1804
35a1250c111a
Display urgent/attention sign in the roster UI
Mikael Berthe <mikael@lilotux.net>
parents:
1802
diff
changeset
|
2259 |
if (pending == '#') { |
35a1250c111a
Display urgent/attention sign in the roster UI
Mikael Berthe <mikael@lilotux.net>
parents:
1802
diff
changeset
|
2260 |
// Attention sign? |
35a1250c111a
Display urgent/attention sign in the roster UI
Mikael Berthe <mikael@lilotux.net>
parents:
1802
diff
changeset
|
2261 |
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
|
2262 |
(!ismuc && isurg >= ui_attn_sign_prio_level)) |
2100
113d3b96ae3e
Add option 'attention_char'
Mikael Berthe <mikael@lilotux.net>
parents:
2098
diff
changeset
|
2263 |
pending = attention_sign(); |
1804
35a1250c111a
Display urgent/attention sign in the roster UI
Mikael Berthe <mikael@lilotux.net>
parents:
1802
diff
changeset
|
2264 |
} |
35a1250c111a
Display urgent/attention sign in the roster UI
Mikael Berthe <mikael@lilotux.net>
parents:
1802
diff
changeset
|
2265 |
|
149 | 2266 |
if (isgrp) { |
1598 | 2267 |
if (ishid) { |
1504
9fafea381eb8
Show the number of unfiltered contacts in folded groups
franky
parents:
1503
diff
changeset
|
2268 |
int group_count = 0; |
9fafea381eb8
Show the number of unfiltered contacts in folded groups
franky
parents:
1503
diff
changeset
|
2269 |
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
|
2270 |
&group_count); |
2100
113d3b96ae3e
Add option 'attention_char'
Mikael Berthe <mikael@lilotux.net>
parents:
2098
diff
changeset
|
2271 |
snprintf(rline, 4*Roster_Width, "%s%lc+++ %s (%i)", space, pending, |
113d3b96ae3e
Add option 'attention_char'
Mikael Berthe <mikael@lilotux.net>
parents:
2098
diff
changeset
|
2272 |
name, group_count); |
1579
a2dd83167bc9
Fix display error in the roster
Mikael Berthe <mikael@lilotux.net>
parents:
1573
diff
changeset
|
2273 |
/* 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
|
2274 |
if (g_utf8_strlen(rline, 4*Roster_Width) >= Roster_Width) |
2100
113d3b96ae3e
Add option 'attention_char'
Mikael Berthe <mikael@lilotux.net>
parents:
2098
diff
changeset
|
2275 |
snprintf(rline, 4*Roster_Width, "%s%lc+++ %s", space, pending, name); |
1504
9fafea381eb8
Show the number of unfiltered contacts in folded groups
franky
parents:
1503
diff
changeset
|
2276 |
} |
133 | 2277 |
else |
2100
113d3b96ae3e
Add option 'attention_char'
Mikael Berthe <mikael@lilotux.net>
parents:
2098
diff
changeset
|
2278 |
snprintf(rline, 4*Roster_Width, "%s%lc--- %s", space, pending, name); |
848
a9161d2dc414
Introduce special buffer stuff
Mikael Berthe <mikael@lilotux.net>
parents:
843
diff
changeset
|
2279 |
} else if (isspe) { |
2100
113d3b96ae3e
Add option 'attention_char'
Mikael Berthe <mikael@lilotux.net>
parents:
2098
diff
changeset
|
2280 |
snprintf(rline, 4*Roster_Width, "%s%lc%s", space, pending, name); |
701
6c100adfbfb6
Add setting "roster_width" (variable buddylist width)
Mikael Berthe <mikael@lilotux.net>
parents:
699
diff
changeset
|
2281 |
} else { |
824
37ef269330f0
Show incomplete subscriptions in the roster
Mikael Berthe <mikael@lilotux.net>
parents:
822
diff
changeset
|
2282 |
char sepleft = '['; |
37ef269330f0
Show incomplete subscriptions in the roster
Mikael Berthe <mikael@lilotux.net>
parents:
822
diff
changeset
|
2283 |
char sepright = ']'; |
37ef269330f0
Show incomplete subscriptions in the roster
Mikael Berthe <mikael@lilotux.net>
parents:
822
diff
changeset
|
2284 |
if (btype & ROSTER_TYPE_USER) { |
37ef269330f0
Show incomplete subscriptions in the roster
Mikael Berthe <mikael@lilotux.net>
parents:
822
diff
changeset
|
2285 |
guint subtype = buddy_getsubscription(BUDDATA(buddy)); |
832
7c210263c661
Small scr_DrawRoster() fix
Mikael Berthe <mikael@lilotux.net>
parents:
828
diff
changeset
|
2286 |
if (status == '_' && !(subtype & sub_to)) |
824
37ef269330f0
Show incomplete subscriptions in the roster
Mikael Berthe <mikael@lilotux.net>
parents:
822
diff
changeset
|
2287 |
status = '?'; |
37ef269330f0
Show incomplete subscriptions in the roster
Mikael Berthe <mikael@lilotux.net>
parents:
822
diff
changeset
|
2288 |
if (!(subtype & sub_from)) { |
37ef269330f0
Show incomplete subscriptions in the roster
Mikael Berthe <mikael@lilotux.net>
parents:
822
diff
changeset
|
2289 |
sepleft = '{'; |
37ef269330f0
Show incomplete subscriptions in the roster
Mikael Berthe <mikael@lilotux.net>
parents:
822
diff
changeset
|
2290 |
sepright = '}'; |
37ef269330f0
Show incomplete subscriptions in the roster
Mikael Berthe <mikael@lilotux.net>
parents:
822
diff
changeset
|
2291 |
} |
37ef269330f0
Show incomplete subscriptions in the roster
Mikael Berthe <mikael@lilotux.net>
parents:
822
diff
changeset
|
2292 |
} |
2100
113d3b96ae3e
Add option 'attention_char'
Mikael Berthe <mikael@lilotux.net>
parents:
2098
diff
changeset
|
2293 |
snprintf(rline, 4*Roster_Width, "%s%lc%c%c%c %s", |
113d3b96ae3e
Add option 'attention_char'
Mikael Berthe <mikael@lilotux.net>
parents:
2098
diff
changeset
|
2294 |
space, pending, sepleft, status, sepright, name); |
133 | 2295 |
} |
84 | 2296 |
|
773
e25b8a348ebd
Screen updating functions use UTF-8
Mikael Berthe <mikael@lilotux.net>
parents:
772
diff
changeset
|
2297 |
rline_locale = from_utf8(rline); |
981
553b8ecf901f
Fixes truncating of utf-8 buddy names (again)
Myhailo Danylenko <isbear@ukrpost.net>
parents:
980
diff
changeset
|
2298 |
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
|
2299 |
g_free(rline_locale); |
84 | 2300 |
i++; |
81 | 2301 |
} |
2302 |
||
701
6c100adfbfb6
Add setting "roster_width" (variable buddylist width)
Mikael Berthe <mikael@lilotux.net>
parents:
699
diff
changeset
|
2303 |
g_free(rline); |
6c100adfbfb6
Add setting "roster_width" (variable buddylist width)
Mikael Berthe <mikael@lilotux.net>
parents:
699
diff
changeset
|
2304 |
g_free(name); |
142 | 2305 |
top_panel(inputPanel); |
81 | 2306 |
update_panels(); |
713 | 2307 |
curs_set(cursor_backup); |
24 | 2308 |
} |
2309 |
||
2292
f181418db215
Replace global variable update_roster with scr_update_roster()
franky
parents:
2291
diff
changeset
|
2310 |
void scr_update_roster(void) |
f181418db215
Replace global variable update_roster with scr_update_roster()
franky
parents:
2291
diff
changeset
|
2311 |
{ |
f181418db215
Replace global variable update_roster with scr_update_roster()
franky
parents:
2291
diff
changeset
|
2312 |
_update_roster = TRUE; |
f181418db215
Replace global variable update_roster with scr_update_roster()
franky
parents:
2291
diff
changeset
|
2313 |
} |
f181418db215
Replace global variable update_roster with scr_update_roster()
franky
parents:
2291
diff
changeset
|
2314 |
|
f181418db215
Replace global variable update_roster with scr_update_roster()
franky
parents:
2291
diff
changeset
|
2315 |
|
1780
e4378fbab5d7
Major API cleanup - bump API to 4
Mikael Berthe <mikael@lilotux.net>
parents:
1761
diff
changeset
|
2316 |
// scr_roster_visibility(status) |
707
b26a0bde4cdb
Add /roster hide|show|toggle
Mikael Berthe <mikael@lilotux.net>
parents:
701
diff
changeset
|
2317 |
// Set the roster visibility: |
b26a0bde4cdb
Add /roster hide|show|toggle
Mikael Berthe <mikael@lilotux.net>
parents:
701
diff
changeset
|
2318 |
// status=1 Show roster |
b26a0bde4cdb
Add /roster hide|show|toggle
Mikael Berthe <mikael@lilotux.net>
parents:
701
diff
changeset
|
2319 |
// status=0 Hide roster |
b26a0bde4cdb
Add /roster hide|show|toggle
Mikael Berthe <mikael@lilotux.net>
parents:
701
diff
changeset
|
2320 |
// status=-1 Toggle roster status |
1780
e4378fbab5d7
Major API cleanup - bump API to 4
Mikael Berthe <mikael@lilotux.net>
parents:
1761
diff
changeset
|
2321 |
void scr_roster_visibility(int status) |
707
b26a0bde4cdb
Add /roster hide|show|toggle
Mikael Berthe <mikael@lilotux.net>
parents:
701
diff
changeset
|
2322 |
{ |
708
ed326697e4ed
scr_RosterVisibility(): do not refresh when it is not needed
Mikael Berthe <mikael@lilotux.net>
parents:
707
diff
changeset
|
2323 |
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
|
2324 |
|
707
b26a0bde4cdb
Add /roster hide|show|toggle
Mikael Berthe <mikael@lilotux.net>
parents:
701
diff
changeset
|
2325 |
if (status > 0) |
b26a0bde4cdb
Add /roster hide|show|toggle
Mikael Berthe <mikael@lilotux.net>
parents:
701
diff
changeset
|
2326 |
roster_hidden = FALSE; |
b26a0bde4cdb
Add /roster hide|show|toggle
Mikael Berthe <mikael@lilotux.net>
parents:
701
diff
changeset
|
2327 |
else if (status == 0) |
b26a0bde4cdb
Add /roster hide|show|toggle
Mikael Berthe <mikael@lilotux.net>
parents:
701
diff
changeset
|
2328 |
roster_hidden = TRUE; |
b26a0bde4cdb
Add /roster hide|show|toggle
Mikael Berthe <mikael@lilotux.net>
parents:
701
diff
changeset
|
2329 |
else |
b26a0bde4cdb
Add /roster hide|show|toggle
Mikael Berthe <mikael@lilotux.net>
parents:
701
diff
changeset
|
2330 |
roster_hidden = !roster_hidden; |
b26a0bde4cdb
Add /roster hide|show|toggle
Mikael Berthe <mikael@lilotux.net>
parents:
701
diff
changeset
|
2331 |
|
708
ed326697e4ed
scr_RosterVisibility(): do not refresh when it is not needed
Mikael Berthe <mikael@lilotux.net>
parents:
707
diff
changeset
|
2332 |
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
|
2333 |
// Recalculate windows size and redraw |
2231
387cea2a1a81
Fix resizing with --enable-sigwinch
Mikael Berthe <mikael@lilotux.net>
parents:
2226
diff
changeset
|
2334 |
scr_resize(); |
708
ed326697e4ed
scr_RosterVisibility(): do not refresh when it is not needed
Mikael Berthe <mikael@lilotux.net>
parents:
707
diff
changeset
|
2335 |
redrawwin(stdscr); |
ed326697e4ed
scr_RosterVisibility(): do not refresh when it is not needed
Mikael Berthe <mikael@lilotux.net>
parents:
707
diff
changeset
|
2336 |
} |
707
b26a0bde4cdb
Add /roster hide|show|toggle
Mikael Berthe <mikael@lilotux.net>
parents:
701
diff
changeset
|
2337 |
} |
b26a0bde4cdb
Add /roster hide|show|toggle
Mikael Berthe <mikael@lilotux.net>
parents:
701
diff
changeset
|
2338 |
|
1780
e4378fbab5d7
Major API cleanup - bump API to 4
Mikael Berthe <mikael@lilotux.net>
parents:
1761
diff
changeset
|
2339 |
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
|
2340 |
time_t timestamp, guint prefix_flags, |
e4378fbab5d7
Major API cleanup - bump API to 4
Mikael Berthe <mikael@lilotux.net>
parents:
1761
diff
changeset
|
2341 |
unsigned mucnicklen, gpointer xep184) |
24 | 2342 |
{ |
727
1c3620668857
Expand tabs when reading history files
Mikael Berthe <mikael@lilotux.net>
parents:
726
diff
changeset
|
2343 |
char *xtext; |
725
1aff92625bdb
Expand tabs when receiving a message
Mikael Berthe <mikael@lilotux.net>
parents:
724
diff
changeset
|
2344 |
|
2090
16b04d64ec88
Add option to highlight timestamp added by server.
Hermitifier
parents:
2074
diff
changeset
|
2345 |
if (!timestamp) |
16b04d64ec88
Add option to highlight timestamp added by server.
Hermitifier
parents:
2074
diff
changeset
|
2346 |
timestamp = time(NULL); |
16b04d64ec88
Add option to highlight timestamp added by server.
Hermitifier
parents:
2074
diff
changeset
|
2347 |
else |
16b04d64ec88
Add option to highlight timestamp added by server.
Hermitifier
parents:
2074
diff
changeset
|
2348 |
prefix_flags |= HBB_PREFIX_DELAYED; |
725
1aff92625bdb
Expand tabs when receiving a message
Mikael Berthe <mikael@lilotux.net>
parents:
724
diff
changeset
|
2349 |
|
1122
648fe6f715a6
Filter out ^M (0x0d) characters in incoming messages
Mikael Berthe <mikael@lilotux.net>
parents:
1115
diff
changeset
|
2350 |
xtext = ut_expand_tabs(text); // Expand tabs and filter out some chars |
726 | 2351 |
|
1780
e4378fbab5d7
Major API cleanup - bump API to 4
Mikael Berthe <mikael@lilotux.net>
parents:
1761
diff
changeset
|
2352 |
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
|
2353 |
xep184); |
725
1aff92625bdb
Expand tabs when receiving a message
Mikael Berthe <mikael@lilotux.net>
parents:
724
diff
changeset
|
2354 |
|
1aff92625bdb
Expand tabs when receiving a message
Mikael Berthe <mikael@lilotux.net>
parents:
724
diff
changeset
|
2355 |
if (xtext != (char*)text) |
1aff92625bdb
Expand tabs when receiving a message
Mikael Berthe <mikael@lilotux.net>
parents:
724
diff
changeset
|
2356 |
g_free(xtext); |
24 | 2357 |
} |
2358 |
||
726 | 2359 |
// 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
|
2360 |
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
|
2361 |
time_t timestamp, |
af3de54ef986
Convert scr_LogPrint() to scr_log_print()
Mikael Berthe <mikael@lilotux.net>
parents:
1780
diff
changeset
|
2362 |
guint prefix, unsigned mucnicklen) |
726 | 2363 |
{ |
1055
6eb1efea75d0
PGP: Visual encryption flag
Mikael Berthe <mikael@lilotux.net>
parents:
1050
diff
changeset
|
2364 |
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
|
2365 |
~HBB_PREFIX_NOFLAG & ~HBB_PREFIX_HLIGHT & ~HBB_PREFIX_HLIGHT_OUT & |
2190
ee3a40ffcd8b
New option: 'clear_unread_on_carbon'
Holger Weiß <holger@zedat.fu-berlin.de>
parents:
2181
diff
changeset
|
2366 |
~HBB_PREFIX_PGPCRYPT & ~HBB_PREFIX_OTRCRYPT & ~HBB_PREFIX_CARBON)) |
726 | 2367 |
prefix |= HBB_PREFIX_IN; |
2368 |
||
1780
e4378fbab5d7
Major API cleanup - bump API to 4
Mikael Berthe <mikael@lilotux.net>
parents:
1761
diff
changeset
|
2369 |
scr_write_message(jidfrom, text, timestamp, prefix, mucnicklen, NULL); |
726 | 2370 |
} |
2371 |
||
1783
af3de54ef986
Convert scr_LogPrint() to scr_log_print()
Mikael Berthe <mikael@lilotux.net>
parents:
1780
diff
changeset
|
2372 |
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
|
2373 |
guint prefix, gpointer xep184) |
47 | 2374 |
{ |
1115
922a9ae1a17e
Fix /say_to to a member of a folded group
Mikael Berthe <mikael@lilotux.net>
parents:
1093
diff
changeset
|
2375 |
GSList *roster_elt; |
922a9ae1a17e
Fix /say_to to a member of a folded group
Mikael Berthe <mikael@lilotux.net>
parents:
1093
diff
changeset
|
2376 |
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
|
2377 |
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
|
2378 |
|
1780
e4378fbab5d7
Major API cleanup - bump API to 4
Mikael Berthe <mikael@lilotux.net>
parents:
1761
diff
changeset
|
2379 |
scr_write_message(jidto, text, |
e4378fbab5d7
Major API cleanup - bump API to 4
Mikael Berthe <mikael@lilotux.net>
parents:
1761
diff
changeset
|
2380 |
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
|
2381 |
|
922a9ae1a17e
Fix /say_to to a member of a folded group
Mikael Berthe <mikael@lilotux.net>
parents:
1093
diff
changeset
|
2382 |
// 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
|
2383 |
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
|
2384 |
scr_show_window(jidto, FALSE); |
47 | 2385 |
} |
2386 |
||
2032
f740c4128f76
Fix receipts handling according to recent XEP updates
Myhailo Danylenko <isbear@ukrpost.net>
parents:
2029
diff
changeset
|
2387 |
void scr_remove_receipt_flag(const char *bjid, gconstpointer xep184) |
1602 | 2388 |
{ |
1780
e4378fbab5d7
Major API cleanup - bump API to 4
Mikael Berthe <mikael@lilotux.net>
parents:
1761
diff
changeset
|
2389 |
winbuf *win_entry = scr_search_window(bjid, FALSE); |
2036
f8958ab545ac
Make message delivery receipts more backward-compatible
Mikael Berthe <mikael@lilotux.net>
parents:
2032
diff
changeset
|
2390 |
if (win_entry && xep184) { |
1602 | 2391 |
hbuf_remove_receipt(win_entry->bd->hbuf, xep184); |
2392 |
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
|
2393 |
scr_update_buddy_window(); |
1602 | 2394 |
} |
2395 |
} |
|
2396 |
||
935
97e6a6da2b2c
Fix ncurses #include (again)
Mikael Berthe <mikael@lilotux.net>
parents:
933
diff
changeset
|
2397 |
static inline void set_autoaway(bool setaway) |
373
af2f8ddf6a1b
Move (reorganize) functions
Mikael Berthe <mikael@lilotux.net>
parents:
370
diff
changeset
|
2398 |
{ |
af2f8ddf6a1b
Move (reorganize) functions
Mikael Berthe <mikael@lilotux.net>
parents:
370
diff
changeset
|
2399 |
static enum imstatus oldstatus; |
521 | 2400 |
static char *oldmsg; |
373
af2f8ddf6a1b
Move (reorganize) functions
Mikael Berthe <mikael@lilotux.net>
parents:
370
diff
changeset
|
2401 |
Autoaway = setaway; |
af2f8ddf6a1b
Move (reorganize) functions
Mikael Berthe <mikael@lilotux.net>
parents:
370
diff
changeset
|
2402 |
|
af2f8ddf6a1b
Move (reorganize) functions
Mikael Berthe <mikael@lilotux.net>
parents:
370
diff
changeset
|
2403 |
if (setaway) { |
521 | 2404 |
const char *msg, *prevmsg; |
1598 | 2405 |
oldstatus = xmpp_getstatus(); |
521 | 2406 |
if (oldmsg) { |
2407 |
g_free(oldmsg); |
|
2408 |
oldmsg = NULL; |
|
2409 |
} |
|
1598 | 2410 |
prevmsg = xmpp_getstatusmsg(); |
373
af2f8ddf6a1b
Move (reorganize) functions
Mikael Berthe <mikael@lilotux.net>
parents:
370
diff
changeset
|
2411 |
msg = settings_opt_get("message_autoaway"); |
521 | 2412 |
if (!msg) |
2413 |
msg = prevmsg; |
|
2414 |
if (prevmsg) |
|
2415 |
oldmsg = g_strdup(prevmsg); |
|
1598 | 2416 |
xmpp_setstatus(away, NULL, msg, FALSE); |
373
af2f8ddf6a1b
Move (reorganize) functions
Mikael Berthe <mikael@lilotux.net>
parents:
370
diff
changeset
|
2417 |
} else { |
af2f8ddf6a1b
Move (reorganize) functions
Mikael Berthe <mikael@lilotux.net>
parents:
370
diff
changeset
|
2418 |
// Back |
1598 | 2419 |
xmpp_setstatus(oldstatus, NULL, (oldmsg ? oldmsg : ""), FALSE); |
521 | 2420 |
if (oldmsg) { |
2421 |
g_free(oldmsg); |
|
2422 |
oldmsg = NULL; |
|
2423 |
} |
|
373
af2f8ddf6a1b
Move (reorganize) functions
Mikael Berthe <mikael@lilotux.net>
parents:
370
diff
changeset
|
2424 |
} |
af2f8ddf6a1b
Move (reorganize) functions
Mikael Berthe <mikael@lilotux.net>
parents:
370
diff
changeset
|
2425 |
} |
af2f8ddf6a1b
Move (reorganize) functions
Mikael Berthe <mikael@lilotux.net>
parents:
370
diff
changeset
|
2426 |
|
991
ef10906691bb
Chatstates: add composing timeout
Mikael Berthe <mikael@lilotux.net>
parents:
990
diff
changeset
|
2427 |
// set_chatstate(state) |
ef10906691bb
Chatstates: add composing timeout
Mikael Berthe <mikael@lilotux.net>
parents:
990
diff
changeset
|
2428 |
// Set the current chat state (0=active, 1=composing, 2=paused) |
1598 | 2429 |
// 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
|
2430 |
static void set_chatstate(int state) |
991
ef10906691bb
Chatstates: add composing timeout
Mikael Berthe <mikael@lilotux.net>
parents:
990
diff
changeset
|
2431 |
{ |
2165 | 2432 |
#ifdef XEP0085 |
993
0759f4c7da68
Add option 'disable_chatstates'
Mikael Berthe <mikael@lilotux.net>
parents:
992
diff
changeset
|
2433 |
if (chatstates_disabled) |
0759f4c7da68
Add option 'disable_chatstates'
Mikael Berthe <mikael@lilotux.net>
parents:
992
diff
changeset
|
2434 |
return; |
991
ef10906691bb
Chatstates: add composing timeout
Mikael Berthe <mikael@lilotux.net>
parents:
990
diff
changeset
|
2435 |
if (!chatmode) |
ef10906691bb
Chatstates: add composing timeout
Mikael Berthe <mikael@lilotux.net>
parents:
990
diff
changeset
|
2436 |
state = 0; |
ef10906691bb
Chatstates: add composing timeout
Mikael Berthe <mikael@lilotux.net>
parents:
990
diff
changeset
|
2437 |
if (state != chatstate) { |
ef10906691bb
Chatstates: add composing timeout
Mikael Berthe <mikael@lilotux.net>
parents:
990
diff
changeset
|
2438 |
chatstate = state; |
ef10906691bb
Chatstates: add composing timeout
Mikael Berthe <mikael@lilotux.net>
parents:
990
diff
changeset
|
2439 |
if (current_buddy && |
ef10906691bb
Chatstates: add composing timeout
Mikael Berthe <mikael@lilotux.net>
parents:
990
diff
changeset
|
2440 |
buddy_gettype(BUDDATA(current_buddy)) == ROSTER_TYPE_USER) { |
ef10906691bb
Chatstates: add composing timeout
Mikael Berthe <mikael@lilotux.net>
parents:
990
diff
changeset
|
2441 |
guint jep_state; |
1598 | 2442 |
if (chatstate == 1) { |
2443 |
if (chatstate_timeout_id == 0) |
|
2444 |
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
|
2445 |
scr_chatstates_timeout, |
1598 | 2446 |
NULL); |
991
ef10906691bb
Chatstates: add composing timeout
Mikael Berthe <mikael@lilotux.net>
parents:
990
diff
changeset
|
2447 |
jep_state = ROSTER_EVENT_COMPOSING; |
1598 | 2448 |
} |
991
ef10906691bb
Chatstates: add composing timeout
Mikael Berthe <mikael@lilotux.net>
parents:
990
diff
changeset
|
2449 |
else if (chatstate == 2) |
ef10906691bb
Chatstates: add composing timeout
Mikael Berthe <mikael@lilotux.net>
parents:
990
diff
changeset
|
2450 |
jep_state = ROSTER_EVENT_PAUSED; |
ef10906691bb
Chatstates: add composing timeout
Mikael Berthe <mikael@lilotux.net>
parents:
990
diff
changeset
|
2451 |
else |
ef10906691bb
Chatstates: add composing timeout
Mikael Berthe <mikael@lilotux.net>
parents:
990
diff
changeset
|
2452 |
jep_state = ROSTER_EVENT_ACTIVE; |
1598 | 2453 |
xmpp_send_chatstate(BUDDATA(current_buddy), jep_state); |
991
ef10906691bb
Chatstates: add composing timeout
Mikael Berthe <mikael@lilotux.net>
parents:
990
diff
changeset
|
2454 |
} |
ef10906691bb
Chatstates: add composing timeout
Mikael Berthe <mikael@lilotux.net>
parents:
990
diff
changeset
|
2455 |
if (!chatstate) |
ef10906691bb
Chatstates: add composing timeout
Mikael Berthe <mikael@lilotux.net>
parents:
990
diff
changeset
|
2456 |
chatstate_timestamp = 0; |
ef10906691bb
Chatstates: add composing timeout
Mikael Berthe <mikael@lilotux.net>
parents:
990
diff
changeset
|
2457 |
} |
ef10906691bb
Chatstates: add composing timeout
Mikael Berthe <mikael@lilotux.net>
parents:
990
diff
changeset
|
2458 |
#endif |
ef10906691bb
Chatstates: add composing timeout
Mikael Berthe <mikael@lilotux.net>
parents:
990
diff
changeset
|
2459 |
} |
ef10906691bb
Chatstates: add composing timeout
Mikael Berthe <mikael@lilotux.net>
parents:
990
diff
changeset
|
2460 |
|
2165 | 2461 |
#ifdef XEP0085 |
1780
e4378fbab5d7
Major API cleanup - bump API to 4
Mikael Berthe <mikael@lilotux.net>
parents:
1761
diff
changeset
|
2462 |
static gboolean scr_chatstates_timeout(void) |
991
ef10906691bb
Chatstates: add composing timeout
Mikael Berthe <mikael@lilotux.net>
parents:
990
diff
changeset
|
2463 |
{ |
1598 | 2464 |
time_t now; |
2465 |
time(&now); |
|
991
ef10906691bb
Chatstates: add composing timeout
Mikael Berthe <mikael@lilotux.net>
parents:
990
diff
changeset
|
2466 |
// Check if we're currently composing... |
1598 | 2467 |
if (chatstate != 1 || !chatstate_timestamp) { |
2468 |
chatstate_timeout_id = 0; |
|
2469 |
return FALSE; |
|
2470 |
} |
|
991
ef10906691bb
Chatstates: add composing timeout
Mikael Berthe <mikael@lilotux.net>
parents:
990
diff
changeset
|
2471 |
|
ef10906691bb
Chatstates: add composing timeout
Mikael Berthe <mikael@lilotux.net>
parents:
990
diff
changeset
|
2472 |
// 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
|
2473 |
if (now >= chatstate_timestamp + COMPOSING_TIMEOUT) { |
ef10906691bb
Chatstates: add composing timeout
Mikael Berthe <mikael@lilotux.net>
parents:
990
diff
changeset
|
2474 |
chatstate_timestamp = now; |
ef10906691bb
Chatstates: add composing timeout
Mikael Berthe <mikael@lilotux.net>
parents:
990
diff
changeset
|
2475 |
set_chatstate(2); |
1598 | 2476 |
chatstate_timeout_id = 0; |
2477 |
return FALSE; |
|
991
ef10906691bb
Chatstates: add composing timeout
Mikael Berthe <mikael@lilotux.net>
parents:
990
diff
changeset
|
2478 |
} |
1598 | 2479 |
return TRUE; |
991
ef10906691bb
Chatstates: add composing timeout
Mikael Berthe <mikael@lilotux.net>
parents:
990
diff
changeset
|
2480 |
} |
ef10906691bb
Chatstates: add composing timeout
Mikael Berthe <mikael@lilotux.net>
parents:
990
diff
changeset
|
2481 |
#endif |
ef10906691bb
Chatstates: add composing timeout
Mikael Berthe <mikael@lilotux.net>
parents:
990
diff
changeset
|
2482 |
|
1677 | 2483 |
static gboolean scr_autoaway_timeout_callback(gpointer data) |
2484 |
{ |
|
2485 |
enum imstatus cur_st = xmpp_getstatus(); |
|
2486 |
if (cur_st != available && cur_st != freeforchat) |
|
2487 |
// Some non-user-originated status changes, let's wait more. |
|
2488 |
// Maybe the proper fix for that will be set global variable |
|
2489 |
// "autoaway_delayed" and check that variable in postconnect |
|
2490 |
// hook (afaik, only source for such status changes are |
|
2491 |
// error disconnects). |
|
2492 |
return TRUE; |
|
2493 |
set_autoaway(TRUE); |
|
2494 |
// source will be destroyed after return |
|
2495 |
autoaway_source = 0; |
|
2496 |
return FALSE; |
|
2497 |
} |
|
2498 |
||
1780
e4378fbab5d7
Major API cleanup - bump API to 4
Mikael Berthe <mikael@lilotux.net>
parents:
1761
diff
changeset
|
2499 |
static void scr_reinstall_autoaway_timeout(void) |
1677 | 2500 |
{ |
2501 |
unsigned int autoaway_timeout = settings_opt_get_int("autoaway"); |
|
2502 |
enum imstatus cur_st = xmpp_getstatus(); |
|
2503 |
if (autoaway_source) { |
|
2504 |
g_source_remove(autoaway_source); |
|
2505 |
autoaway_source = 0; |
|
2506 |
} |
|
2507 |
if (autoaway_timeout && (cur_st == available || cur_st == freeforchat)) |
|
2508 |
autoaway_source = g_timeout_add_seconds(autoaway_timeout, |
|
2509 |
scr_autoaway_timeout_callback, |
|
2510 |
NULL); |
|
2511 |
} |
|
2512 |
||
2513 |
// 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
|
2514 |
void scr_check_auto_away(int activity) |
24 | 2515 |
{ |
1677 | 2516 |
if (Autoaway && activity) { |
1780
e4378fbab5d7
Major API cleanup - bump API to 4
Mikael Berthe <mikael@lilotux.net>
parents:
1761
diff
changeset
|
2517 |
scr_reinstall_autoaway_timeout(); |
1677 | 2518 |
set_autoaway(FALSE); |
2519 |
} else if (activity || !autoaway_source) |
|
1780
e4378fbab5d7
Major API cleanup - bump API to 4
Mikael Berthe <mikael@lilotux.net>
parents:
1761
diff
changeset
|
2520 |
scr_reinstall_autoaway_timeout(); |
24 | 2521 |
} |
2522 |
||
328
83d129adde03
Add set_current_buddy() function, to reduce code duplication
Mikael Berthe <mikael@lilotux.net>
parents:
325
diff
changeset
|
2523 |
// set_current_buddy(newbuddy) |
83d129adde03
Add set_current_buddy() function, to reduce code duplication
Mikael Berthe <mikael@lilotux.net>
parents:
325
diff
changeset
|
2524 |
// 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
|
2525 |
// 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
|
2526 |
static void set_current_buddy(GList *newbuddy) |
24 | 2527 |
{ |
328
83d129adde03
Add set_current_buddy() function, to reduce code duplication
Mikael Berthe <mikael@lilotux.net>
parents:
325
diff
changeset
|
2528 |
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
|
2529 |
/* 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
|
2530 |
* 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
|
2531 |
* buddy_getstatus() call. |
83d129adde03
Add set_current_buddy() function, to reduce code duplication
Mikael Berthe <mikael@lilotux.net>
parents:
325
diff
changeset
|
2532 |
*/ |
83d129adde03
Add set_current_buddy() function, to reduce code duplication
Mikael Berthe <mikael@lilotux.net>
parents:
325
diff
changeset
|
2533 |
|
329
7c53bf62a2a2
scr_RosterUnreadMessage() uses set_current_buddy()
Mikael Berthe <mikael@lilotux.net>
parents:
328
diff
changeset
|
2534 |
if (!current_buddy || !newbuddy) return; |
7c53bf62a2a2
scr_RosterUnreadMessage() uses set_current_buddy()
Mikael Berthe <mikael@lilotux.net>
parents:
328
diff
changeset
|
2535 |
if (newbuddy == current_buddy) return; |
24 | 2536 |
|
990
35e7913affb7
Send events/chatstates notifications (JEP-22/JEP-85)
Mikael Berthe <mikael@lilotux.net>
parents:
987
diff
changeset
|
2537 |
// 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
|
2538 |
set_chatstate(0); |
35e7913affb7
Send events/chatstates notifications (JEP-22/JEP-85)
Mikael Berthe <mikael@lilotux.net>
parents:
987
diff
changeset
|
2539 |
// 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
|
2540 |
lock_chatstate = TRUE; |
990
35e7913affb7
Send events/chatstates notifications (JEP-22/JEP-85)
Mikael Berthe <mikael@lilotux.net>
parents:
987
diff
changeset
|
2541 |
|
438
b44be19d6229
Handle multiple resources for the same buddy
Mikael Berthe <mikael@lilotux.net>
parents:
419
diff
changeset
|
2542 |
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
|
2543 |
buddy_setflags(BUDDATA(current_buddy), ROSTER_FLAG_LOCK, FALSE); |
1950
aec86670047b
Automatically set readmark flag
Mikael Berthe <mikael@lilotux.net>
parents:
1949
diff
changeset
|
2544 |
if (chatmode) { |
aec86670047b
Automatically set readmark flag
Mikael Berthe <mikael@lilotux.net>
parents:
1949
diff
changeset
|
2545 |
scr_buffer_readmark(TRUE); |
330 | 2546 |
alternate_buddy = current_buddy; |
1950
aec86670047b
Automatically set readmark flag
Mikael Berthe <mikael@lilotux.net>
parents:
1949
diff
changeset
|
2547 |
} |
328
83d129adde03
Add set_current_buddy() function, to reduce code duplication
Mikael Berthe <mikael@lilotux.net>
parents:
325
diff
changeset
|
2548 |
current_buddy = newbuddy; |
83d129adde03
Add set_current_buddy() function, to reduce code duplication
Mikael Berthe <mikael@lilotux.net>
parents:
325
diff
changeset
|
2549 |
// Lock the buddy in the buddylist if we're in chat mode |
1961
39021fd6b0e1
Try to improve readmarks in some cases
Mikael Berthe <mikael@lilotux.net>
parents:
1960
diff
changeset
|
2550 |
if (chatmode) { |
328
83d129adde03
Add set_current_buddy() function, to reduce code duplication
Mikael Berthe <mikael@lilotux.net>
parents:
325
diff
changeset
|
2551 |
buddy_setflags(BUDDATA(current_buddy), ROSTER_FLAG_LOCK, TRUE); |
1961
39021fd6b0e1
Try to improve readmarks in some cases
Mikael Berthe <mikael@lilotux.net>
parents:
1960
diff
changeset
|
2552 |
// Remove the readmark if it is at the end of the buffer |
39021fd6b0e1
Try to improve readmarks in some cases
Mikael Berthe <mikael@lilotux.net>
parents:
1960
diff
changeset
|
2553 |
scr_buffer_readmark(-1); |
39021fd6b0e1
Try to improve readmarks in some cases
Mikael Berthe <mikael@lilotux.net>
parents:
1960
diff
changeset
|
2554 |
} |
2292
f181418db215
Replace global variable update_roster with scr_update_roster()
franky
parents:
2291
diff
changeset
|
2555 |
// We should rebuild the buddylist when the last selected buddy isn't |
f181418db215
Replace global variable update_roster with scr_update_roster()
franky
parents:
2291
diff
changeset
|
2556 |
// displayed anymore |
1311
0dda8238af21
Implement "/roster display"
Mikael Berthe <mikael@lilotux.net>
parents:
1298
diff
changeset
|
2557 |
if (!(buddylist_get_filter() & 1<<prev_st)) |
2291
0d350e979bde
Don't rebuild the buddylist multiple times before a screen refresh
franky
parents:
2288
diff
changeset
|
2558 |
buddylist_defer_build(); |
2292
f181418db215
Replace global variable update_roster with scr_update_roster()
franky
parents:
2291
diff
changeset
|
2559 |
scr_update_roster(); |
24 | 2560 |
} |
2561 |
||
1780
e4378fbab5d7
Major API cleanup - bump API to 4
Mikael Berthe <mikael@lilotux.net>
parents:
1761
diff
changeset
|
2562 |
// scr_roster_top() |
143 | 2563 |
// 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
|
2564 |
void scr_roster_top(void) |
104 | 2565 |
{ |
328
83d129adde03
Add set_current_buddy() function, to reduce code duplication
Mikael Berthe <mikael@lilotux.net>
parents:
325
diff
changeset
|
2566 |
set_current_buddy(buddylist); |
1996
7837d5a3f509
Going back to the first buddy with /roster next_unread when there is no more unread messages.
Simon Jacquin
parents:
1985
diff
changeset
|
2567 |
if (chatmode) { |
7837d5a3f509
Going back to the first buddy with /roster next_unread when there is no more unread messages.
Simon Jacquin
parents:
1985
diff
changeset
|
2568 |
last_activity_buddy = current_buddy; |
1780
e4378fbab5d7
Major API cleanup - bump API to 4
Mikael Berthe <mikael@lilotux.net>
parents:
1761
diff
changeset
|
2569 |
scr_show_buddy_window(); |
1996
7837d5a3f509
Going back to the first buddy with /roster next_unread when there is no more unread messages.
Simon Jacquin
parents:
1985
diff
changeset
|
2570 |
} |
104 | 2571 |
} |
2572 |
||
1780
e4378fbab5d7
Major API cleanup - bump API to 4
Mikael Berthe <mikael@lilotux.net>
parents:
1761
diff
changeset
|
2573 |
// scr_roster_bottom() |
143 | 2574 |
// 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
|
2575 |
void scr_roster_bottom(void) |
104 | 2576 |
{ |
328
83d129adde03
Add set_current_buddy() function, to reduce code duplication
Mikael Berthe <mikael@lilotux.net>
parents:
325
diff
changeset
|
2577 |
set_current_buddy(g_list_last(buddylist)); |
1996
7837d5a3f509
Going back to the first buddy with /roster next_unread when there is no more unread messages.
Simon Jacquin
parents:
1985
diff
changeset
|
2578 |
if (chatmode) { |
7837d5a3f509
Going back to the first buddy with /roster next_unread when there is no more unread messages.
Simon Jacquin
parents:
1985
diff
changeset
|
2579 |
last_activity_buddy = current_buddy; |
1780
e4378fbab5d7
Major API cleanup - bump API to 4
Mikael Berthe <mikael@lilotux.net>
parents:
1761
diff
changeset
|
2580 |
scr_show_buddy_window(); |
1996
7837d5a3f509
Going back to the first buddy with /roster next_unread when there is no more unread messages.
Simon Jacquin
parents:
1985
diff
changeset
|
2581 |
} |
104 | 2582 |
} |
2583 |
||
1780
e4378fbab5d7
Major API cleanup - bump API to 4
Mikael Berthe <mikael@lilotux.net>
parents:
1761
diff
changeset
|
2584 |
// 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
|
2585 |
// 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
|
2586 |
// (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
|
2587 |
void scr_roster_up_down(int updown, unsigned int n) |
81 | 2588 |
{ |
1573
ece4f26bf9ff
Add count parameter to roster up/down command
Mikael Berthe <mikael@lilotux.net>
parents:
1566
diff
changeset
|
2589 |
unsigned int i; |
2045
7f06eb956734
Correctly set the alternate buffer after roster up|down N with N > 1
Mikael Berthe <mikael@lilotux.net>
parents:
2036
diff
changeset
|
2590 |
GList *new_buddy = current_buddy; |
7f06eb956734
Correctly set the alternate buffer after roster up|down N with N > 1
Mikael Berthe <mikael@lilotux.net>
parents:
2036
diff
changeset
|
2591 |
GList *tmp_buddy; |
7f06eb956734
Correctly set the alternate buffer after roster up|down N with N > 1
Mikael Berthe <mikael@lilotux.net>
parents:
2036
diff
changeset
|
2592 |
|
7f06eb956734
Correctly set the alternate buffer after roster up|down N with N > 1
Mikael Berthe <mikael@lilotux.net>
parents:
2036
diff
changeset
|
2593 |
if (!current_buddy) |
7f06eb956734
Correctly set the alternate buffer after roster up|down N with N > 1
Mikael Berthe <mikael@lilotux.net>
parents:
2036
diff
changeset
|
2594 |
return; |
1573
ece4f26bf9ff
Add count parameter to roster up/down command
Mikael Berthe <mikael@lilotux.net>
parents:
1566
diff
changeset
|
2595 |
|
2047
a60b933d04cc
Refactor scr_roster_up_down()
Mikael Berthe <mikael@lilotux.net>
parents:
2045
diff
changeset
|
2596 |
for (i = 0; i < n; i++) { |
a60b933d04cc
Refactor scr_roster_up_down()
Mikael Berthe <mikael@lilotux.net>
parents:
2045
diff
changeset
|
2597 |
if (updown < 0) |
2045
7f06eb956734
Correctly set the alternate buffer after roster up|down N with N > 1
Mikael Berthe <mikael@lilotux.net>
parents:
2036
diff
changeset
|
2598 |
tmp_buddy = g_list_previous(new_buddy); |
2047
a60b933d04cc
Refactor scr_roster_up_down()
Mikael Berthe <mikael@lilotux.net>
parents:
2045
diff
changeset
|
2599 |
else |
2045
7f06eb956734
Correctly set the alternate buffer after roster up|down N with N > 1
Mikael Berthe <mikael@lilotux.net>
parents:
2036
diff
changeset
|
2600 |
tmp_buddy = g_list_next(new_buddy); |
2047
a60b933d04cc
Refactor scr_roster_up_down()
Mikael Berthe <mikael@lilotux.net>
parents:
2045
diff
changeset
|
2601 |
if (tmp_buddy) |
a60b933d04cc
Refactor scr_roster_up_down()
Mikael Berthe <mikael@lilotux.net>
parents:
2045
diff
changeset
|
2602 |
new_buddy = tmp_buddy; |
1573
ece4f26bf9ff
Add count parameter to roster up/down command
Mikael Berthe <mikael@lilotux.net>
parents:
1566
diff
changeset
|
2603 |
} |
2045
7f06eb956734
Correctly set the alternate buffer after roster up|down N with N > 1
Mikael Berthe <mikael@lilotux.net>
parents:
2036
diff
changeset
|
2604 |
if (new_buddy == current_buddy) |
7f06eb956734
Correctly set the alternate buffer after roster up|down N with N > 1
Mikael Berthe <mikael@lilotux.net>
parents:
2036
diff
changeset
|
2605 |
return; |
7f06eb956734
Correctly set the alternate buffer after roster up|down N with N > 1
Mikael Berthe <mikael@lilotux.net>
parents:
2036
diff
changeset
|
2606 |
|
7f06eb956734
Correctly set the alternate buffer after roster up|down N with N > 1
Mikael Berthe <mikael@lilotux.net>
parents:
2036
diff
changeset
|
2607 |
set_current_buddy(new_buddy); |
1996
7837d5a3f509
Going back to the first buddy with /roster next_unread when there is no more unread messages.
Simon Jacquin
parents:
1985
diff
changeset
|
2608 |
if (chatmode) { |
7837d5a3f509
Going back to the first buddy with /roster next_unread when there is no more unread messages.
Simon Jacquin
parents:
1985
diff
changeset
|
2609 |
last_activity_buddy = current_buddy; |
1780
e4378fbab5d7
Major API cleanup - bump API to 4
Mikael Berthe <mikael@lilotux.net>
parents:
1761
diff
changeset
|
2610 |
scr_show_buddy_window(); |
1996
7837d5a3f509
Going back to the first buddy with /roster next_unread when there is no more unread messages.
Simon Jacquin
parents:
1985
diff
changeset
|
2611 |
} |
81 | 2612 |
} |
2613 |
||
1780
e4378fbab5d7
Major API cleanup - bump API to 4
Mikael Berthe <mikael@lilotux.net>
parents:
1761
diff
changeset
|
2614 |
// 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
|
2615 |
// 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
|
2616 |
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
|
2617 |
{ |
5e2e647e781b
Add command /roster group_prev|group_next and update documentation
Mikael Berthe <mikael@lilotux.net>
parents:
1083
diff
changeset
|
2618 |
GList *bud; |
5e2e647e781b
Add command /roster group_prev|group_next and update documentation
Mikael Berthe <mikael@lilotux.net>
parents:
1083
diff
changeset
|
2619 |
|
5e2e647e781b
Add command /roster group_prev|group_next and update documentation
Mikael Berthe <mikael@lilotux.net>
parents:
1083
diff
changeset
|
2620 |
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
|
2621 |
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
|
2622 |
if (!bud) |
5e2e647e781b
Add command /roster group_prev|group_next and update documentation
Mikael Berthe <mikael@lilotux.net>
parents:
1083
diff
changeset
|
2623 |
break; |
5e2e647e781b
Add command /roster group_prev|group_next and update documentation
Mikael Berthe <mikael@lilotux.net>
parents:
1083
diff
changeset
|
2624 |
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
|
2625 |
set_current_buddy(bud); |
1996
7837d5a3f509
Going back to the first buddy with /roster next_unread when there is no more unread messages.
Simon Jacquin
parents:
1985
diff
changeset
|
2626 |
if (chatmode) { |
7837d5a3f509
Going back to the first buddy with /roster next_unread when there is no more unread messages.
Simon Jacquin
parents:
1985
diff
changeset
|
2627 |
last_activity_buddy = current_buddy; |
1780
e4378fbab5d7
Major API cleanup - bump API to 4
Mikael Berthe <mikael@lilotux.net>
parents:
1761
diff
changeset
|
2628 |
scr_show_buddy_window(); |
1996
7837d5a3f509
Going back to the first buddy with /roster next_unread when there is no more unread messages.
Simon Jacquin
parents:
1985
diff
changeset
|
2629 |
} |
1086
5e2e647e781b
Add command /roster group_prev|group_next and update documentation
Mikael Berthe <mikael@lilotux.net>
parents:
1083
diff
changeset
|
2630 |
break; |
5e2e647e781b
Add command /roster group_prev|group_next and update documentation
Mikael Berthe <mikael@lilotux.net>
parents:
1083
diff
changeset
|
2631 |
} |
5e2e647e781b
Add command /roster group_prev|group_next and update documentation
Mikael Berthe <mikael@lilotux.net>
parents:
1083
diff
changeset
|
2632 |
} |
5e2e647e781b
Add command /roster group_prev|group_next and update documentation
Mikael Berthe <mikael@lilotux.net>
parents:
1083
diff
changeset
|
2633 |
} |
5e2e647e781b
Add command /roster group_prev|group_next and update documentation
Mikael Berthe <mikael@lilotux.net>
parents:
1083
diff
changeset
|
2634 |
|
1780
e4378fbab5d7
Major API cleanup - bump API to 4
Mikael Berthe <mikael@lilotux.net>
parents:
1761
diff
changeset
|
2635 |
// 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
|
2636 |
// 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
|
2637 |
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
|
2638 |
{ |
5e2e647e781b
Add command /roster group_prev|group_next and update documentation
Mikael Berthe <mikael@lilotux.net>
parents:
1083
diff
changeset
|
2639 |
GList *bud; |
5e2e647e781b
Add command /roster group_prev|group_next and update documentation
Mikael Berthe <mikael@lilotux.net>
parents:
1083
diff
changeset
|
2640 |
|
5e2e647e781b
Add command /roster group_prev|group_next and update documentation
Mikael Berthe <mikael@lilotux.net>
parents:
1083
diff
changeset
|
2641 |
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
|
2642 |
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
|
2643 |
if (!bud) |
5e2e647e781b
Add command /roster group_prev|group_next and update documentation
Mikael Berthe <mikael@lilotux.net>
parents:
1083
diff
changeset
|
2644 |
break; |
5e2e647e781b
Add command /roster group_prev|group_next and update documentation
Mikael Berthe <mikael@lilotux.net>
parents:
1083
diff
changeset
|
2645 |
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
|
2646 |
set_current_buddy(bud); |
1996
7837d5a3f509
Going back to the first buddy with /roster next_unread when there is no more unread messages.
Simon Jacquin
parents:
1985
diff
changeset
|
2647 |
if (chatmode) { |
7837d5a3f509
Going back to the first buddy with /roster next_unread when there is no more unread messages.
Simon Jacquin
parents:
1985
diff
changeset
|
2648 |
last_activity_buddy = current_buddy; |
1780
e4378fbab5d7
Major API cleanup - bump API to 4
Mikael Berthe <mikael@lilotux.net>
parents:
1761
diff
changeset
|
2649 |
scr_show_buddy_window(); |
1996
7837d5a3f509
Going back to the first buddy with /roster next_unread when there is no more unread messages.
Simon Jacquin
parents:
1985
diff
changeset
|
2650 |
} |
1086
5e2e647e781b
Add command /roster group_prev|group_next and update documentation
Mikael Berthe <mikael@lilotux.net>
parents:
1083
diff
changeset
|
2651 |
break; |
5e2e647e781b
Add command /roster group_prev|group_next and update documentation
Mikael Berthe <mikael@lilotux.net>
parents:
1083
diff
changeset
|
2652 |
} |
5e2e647e781b
Add command /roster group_prev|group_next and update documentation
Mikael Berthe <mikael@lilotux.net>
parents:
1083
diff
changeset
|
2653 |
} |
5e2e647e781b
Add command /roster group_prev|group_next and update documentation
Mikael Berthe <mikael@lilotux.net>
parents:
1083
diff
changeset
|
2654 |
} |
5e2e647e781b
Add command /roster group_prev|group_next and update documentation
Mikael Berthe <mikael@lilotux.net>
parents:
1083
diff
changeset
|
2655 |
|
1780
e4378fbab5d7
Major API cleanup - bump API to 4
Mikael Berthe <mikael@lilotux.net>
parents:
1761
diff
changeset
|
2656 |
// scr_roster_search(str) |
265 | 2657 |
// 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
|
2658 |
void scr_roster_search(char *str) |
265 | 2659 |
{ |
328
83d129adde03
Add set_current_buddy() function, to reduce code duplication
Mikael Berthe <mikael@lilotux.net>
parents:
325
diff
changeset
|
2660 |
set_current_buddy(buddy_search(str)); |
1996
7837d5a3f509
Going back to the first buddy with /roster next_unread when there is no more unread messages.
Simon Jacquin
parents:
1985
diff
changeset
|
2661 |
if (chatmode) { |
7837d5a3f509
Going back to the first buddy with /roster next_unread when there is no more unread messages.
Simon Jacquin
parents:
1985
diff
changeset
|
2662 |
last_activity_buddy = current_buddy; |
1780
e4378fbab5d7
Major API cleanup - bump API to 4
Mikael Berthe <mikael@lilotux.net>
parents:
1761
diff
changeset
|
2663 |
scr_show_buddy_window(); |
1996
7837d5a3f509
Going back to the first buddy with /roster next_unread when there is no more unread messages.
Simon Jacquin
parents:
1985
diff
changeset
|
2664 |
} |
265 | 2665 |
} |
2666 |
||
1780
e4378fbab5d7
Major API cleanup - bump API to 4
Mikael Berthe <mikael@lilotux.net>
parents:
1761
diff
changeset
|
2667 |
// scr_roster_jump_jid(bjid) |
1058 | 2668 |
// Jump to buddy bjid. |
480 | 2669 |
// 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
|
2670 |
void scr_roster_jump_jid(char *barejid) |
480 | 2671 |
{ |
2672 |
GSList *roster_elt; |
|
2673 |
// Look for an existing buddy |
|
2674 |
roster_elt = roster_find(barejid, jidsearch, |
|
2675 |
ROSTER_TYPE_USER|ROSTER_TYPE_AGENT|ROSTER_TYPE_ROOM); |
|
2676 |
// Create it if necessary |
|
2677 |
if (!roster_elt) |
|
603 | 2678 |
roster_elt = roster_add_user(barejid, NULL, NULL, ROSTER_TYPE_USER, |
1355 | 2679 |
sub_none, -1); |
480 | 2680 |
// Set a lock to see it in the buddylist |
2681 |
buddy_setflags(BUDDATA(roster_elt), ROSTER_FLAG_LOCK, TRUE); |
|
2291
0d350e979bde
Don't rebuild the buddylist multiple times before a screen refresh
franky
parents:
2288
diff
changeset
|
2682 |
buddylist_defer_build(); |
480 | 2683 |
// Jump to the buddy |
2684 |
set_current_buddy(buddy_search_jid(barejid)); |
|
1996
7837d5a3f509
Going back to the first buddy with /roster next_unread when there is no more unread messages.
Simon Jacquin
parents:
1985
diff
changeset
|
2685 |
if (chatmode) { |
7837d5a3f509
Going back to the first buddy with /roster next_unread when there is no more unread messages.
Simon Jacquin
parents:
1985
diff
changeset
|
2686 |
last_activity_buddy = current_buddy; |
1780
e4378fbab5d7
Major API cleanup - bump API to 4
Mikael Berthe <mikael@lilotux.net>
parents:
1761
diff
changeset
|
2687 |
scr_show_buddy_window(); |
1996
7837d5a3f509
Going back to the first buddy with /roster next_unread when there is no more unread messages.
Simon Jacquin
parents:
1985
diff
changeset
|
2688 |
} |
480 | 2689 |
} |
2690 |
||
1780
e4378fbab5d7
Major API cleanup - bump API to 4
Mikael Berthe <mikael@lilotux.net>
parents:
1761
diff
changeset
|
2691 |
// scr_roster_unread_message(next) |
236 | 2692 |
// Go to a new message. If next is not null, try to go to the next new |
2693 |
// message. If it is not possible or if next is NULL, go to the first new |
|
2694 |
// message from unread_list. |
|
1780
e4378fbab5d7
Major API cleanup - bump API to 4
Mikael Berthe <mikael@lilotux.net>
parents:
1761
diff
changeset
|
2695 |
void scr_roster_unread_message(int next) |
236 | 2696 |
{ |
329
7c53bf62a2a2
scr_RosterUnreadMessage() uses set_current_buddy()
Mikael Berthe <mikael@lilotux.net>
parents:
328
diff
changeset
|
2697 |
gpointer unread_ptr; |
7c53bf62a2a2
scr_RosterUnreadMessage() uses set_current_buddy()
Mikael Berthe <mikael@lilotux.net>
parents:
328
diff
changeset
|
2698 |
gpointer refbuddata; |
7c53bf62a2a2
scr_RosterUnreadMessage() uses set_current_buddy()
Mikael Berthe <mikael@lilotux.net>
parents:
328
diff
changeset
|
2699 |
GList *nbuddy; |
236 | 2700 |
|
329
7c53bf62a2a2
scr_RosterUnreadMessage() uses set_current_buddy()
Mikael Berthe <mikael@lilotux.net>
parents:
328
diff
changeset
|
2701 |
if (!current_buddy) return; |
236 | 2702 |
|
329
7c53bf62a2a2
scr_RosterUnreadMessage() uses set_current_buddy()
Mikael Berthe <mikael@lilotux.net>
parents:
328
diff
changeset
|
2703 |
if (next) refbuddata = BUDDATA(current_buddy); |
7c53bf62a2a2
scr_RosterUnreadMessage() uses set_current_buddy()
Mikael Berthe <mikael@lilotux.net>
parents:
328
diff
changeset
|
2704 |
else refbuddata = NULL; |
236 | 2705 |
|
329
7c53bf62a2a2
scr_RosterUnreadMessage() uses set_current_buddy()
Mikael Berthe <mikael@lilotux.net>
parents:
328
diff
changeset
|
2706 |
unread_ptr = unread_msg(refbuddata); |
1996
7837d5a3f509
Going back to the first buddy with /roster next_unread when there is no more unread messages.
Simon Jacquin
parents:
1985
diff
changeset
|
2707 |
if (!unread_ptr) { |
7837d5a3f509
Going back to the first buddy with /roster next_unread when there is no more unread messages.
Simon Jacquin
parents:
1985
diff
changeset
|
2708 |
if (!last_activity_buddy || g_list_position(buddylist, last_activity_buddy) == -1) |
7837d5a3f509
Going back to the first buddy with /roster next_unread when there is no more unread messages.
Simon Jacquin
parents:
1985
diff
changeset
|
2709 |
return; |
7837d5a3f509
Going back to the first buddy with /roster next_unread when there is no more unread messages.
Simon Jacquin
parents:
1985
diff
changeset
|
2710 |
unread_ptr = BUDDATA(last_activity_buddy); |
7837d5a3f509
Going back to the first buddy with /roster next_unread when there is no more unread messages.
Simon Jacquin
parents:
1985
diff
changeset
|
2711 |
} |
236 | 2712 |
|
889
ae93e69aaaaf
Fix up pending message flag for the status special buffer
Mikael Berthe <mikael@lilotux.net>
parents:
888
diff
changeset
|
2713 |
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
|
2714 |
gpointer ngroup; |
ae93e69aaaaf
Fix up pending message flag for the status special buffer
Mikael Berthe <mikael@lilotux.net>
parents:
888
diff
changeset
|
2715 |
// 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
|
2716 |
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
|
2717 |
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
|
2718 |
buddy_setflags(ngroup, ROSTER_FLAG_HIDE, FALSE); |
2291
0d350e979bde
Don't rebuild the buddylist multiple times before a screen refresh
franky
parents:
2288
diff
changeset
|
2719 |
buddylist_defer_build(); |
889
ae93e69aaaaf
Fix up pending message flag for the status special buffer
Mikael Berthe <mikael@lilotux.net>
parents:
888
diff
changeset
|
2720 |
} |
329
7c53bf62a2a2
scr_RosterUnreadMessage() uses set_current_buddy()
Mikael Berthe <mikael@lilotux.net>
parents:
328
diff
changeset
|
2721 |
} |
236 | 2722 |
|
329
7c53bf62a2a2
scr_RosterUnreadMessage() uses set_current_buddy()
Mikael Berthe <mikael@lilotux.net>
parents:
328
diff
changeset
|
2723 |
nbuddy = g_list_find(buddylist, unread_ptr); |
7c53bf62a2a2
scr_RosterUnreadMessage() uses set_current_buddy()
Mikael Berthe <mikael@lilotux.net>
parents:
328
diff
changeset
|
2724 |
if (nbuddy) { |
7c53bf62a2a2
scr_RosterUnreadMessage() uses set_current_buddy()
Mikael Berthe <mikael@lilotux.net>
parents:
328
diff
changeset
|
2725 |
set_current_buddy(nbuddy); |
1780
e4378fbab5d7
Major API cleanup - bump API to 4
Mikael Berthe <mikael@lilotux.net>
parents:
1761
diff
changeset
|
2726 |
if (chatmode) scr_show_buddy_window(); |
374
bd5638c21834
Improve logging system (traces)
Mikael Berthe <mikael@lilotux.net>
parents:
373
diff
changeset
|
2727 |
} else |
bd5638c21834
Improve logging system (traces)
Mikael Berthe <mikael@lilotux.net>
parents:
373
diff
changeset
|
2728 |
scr_LogPrint(LPRINT_LOGNORM, "Error: nbuddy == NULL"); // should not happen |
236 | 2729 |
} |
2730 |
||
2160
798baf5db4eb
Add /roster next_open_buffer
Mikael Berthe <mikael@lilotux.net>
parents:
2149
diff
changeset
|
2731 |
// scr_roster_next_open_buffer() |
798baf5db4eb
Add /roster next_open_buffer
Mikael Berthe <mikael@lilotux.net>
parents:
2149
diff
changeset
|
2732 |
// Jump to the next open buffer (experimental XXX) |
798baf5db4eb
Add /roster next_open_buffer
Mikael Berthe <mikael@lilotux.net>
parents:
2149
diff
changeset
|
2733 |
// This implementation ignores the hidden entries (folded groups). |
798baf5db4eb
Add /roster next_open_buffer
Mikael Berthe <mikael@lilotux.net>
parents:
2149
diff
changeset
|
2734 |
void scr_roster_next_open_buffer(void) |
798baf5db4eb
Add /roster next_open_buffer
Mikael Berthe <mikael@lilotux.net>
parents:
2149
diff
changeset
|
2735 |
{ |
798baf5db4eb
Add /roster next_open_buffer
Mikael Berthe <mikael@lilotux.net>
parents:
2149
diff
changeset
|
2736 |
GList *bud = current_buddy; |
798baf5db4eb
Add /roster next_open_buffer
Mikael Berthe <mikael@lilotux.net>
parents:
2149
diff
changeset
|
2737 |
|
798baf5db4eb
Add /roster next_open_buffer
Mikael Berthe <mikael@lilotux.net>
parents:
2149
diff
changeset
|
2738 |
if (!current_buddy) return; |
798baf5db4eb
Add /roster next_open_buffer
Mikael Berthe <mikael@lilotux.net>
parents:
2149
diff
changeset
|
2739 |
|
798baf5db4eb
Add /roster next_open_buffer
Mikael Berthe <mikael@lilotux.net>
parents:
2149
diff
changeset
|
2740 |
for (;;) { |
798baf5db4eb
Add /roster next_open_buffer
Mikael Berthe <mikael@lilotux.net>
parents:
2149
diff
changeset
|
2741 |
guint budtype; |
798baf5db4eb
Add /roster next_open_buffer
Mikael Berthe <mikael@lilotux.net>
parents:
2149
diff
changeset
|
2742 |
bud = g_list_next(bud); |
798baf5db4eb
Add /roster next_open_buffer
Mikael Berthe <mikael@lilotux.net>
parents:
2149
diff
changeset
|
2743 |
// End of list: jump to the first entry |
798baf5db4eb
Add /roster next_open_buffer
Mikael Berthe <mikael@lilotux.net>
parents:
2149
diff
changeset
|
2744 |
if (!bud) |
798baf5db4eb
Add /roster next_open_buffer
Mikael Berthe <mikael@lilotux.net>
parents:
2149
diff
changeset
|
2745 |
bud = buddylist; |
798baf5db4eb
Add /roster next_open_buffer
Mikael Berthe <mikael@lilotux.net>
parents:
2149
diff
changeset
|
2746 |
// Check if we're back to the initial position |
798baf5db4eb
Add /roster next_open_buffer
Mikael Berthe <mikael@lilotux.net>
parents:
2149
diff
changeset
|
2747 |
if (bud == current_buddy) |
798baf5db4eb
Add /roster next_open_buffer
Mikael Berthe <mikael@lilotux.net>
parents:
2149
diff
changeset
|
2748 |
break; |
798baf5db4eb
Add /roster next_open_buffer
Mikael Berthe <mikael@lilotux.net>
parents:
2149
diff
changeset
|
2749 |
// Ignore the special buffer(s), groups |
798baf5db4eb
Add /roster next_open_buffer
Mikael Berthe <mikael@lilotux.net>
parents:
2149
diff
changeset
|
2750 |
budtype = buddy_gettype(BUDDATA(bud)); |
798baf5db4eb
Add /roster next_open_buffer
Mikael Berthe <mikael@lilotux.net>
parents:
2149
diff
changeset
|
2751 |
if (budtype & (ROSTER_TYPE_GROUP | ROSTER_TYPE_SPECIAL)) |
798baf5db4eb
Add /roster next_open_buffer
Mikael Berthe <mikael@lilotux.net>
parents:
2149
diff
changeset
|
2752 |
continue; |
798baf5db4eb
Add /roster next_open_buffer
Mikael Berthe <mikael@lilotux.net>
parents:
2149
diff
changeset
|
2753 |
|
798baf5db4eb
Add /roster next_open_buffer
Mikael Berthe <mikael@lilotux.net>
parents:
2149
diff
changeset
|
2754 |
// Check if a buffer/window exists |
798baf5db4eb
Add /roster next_open_buffer
Mikael Berthe <mikael@lilotux.net>
parents:
2149
diff
changeset
|
2755 |
if (scr_search_window(buddy_getjid(BUDDATA(bud)), 0)) { |
798baf5db4eb
Add /roster next_open_buffer
Mikael Berthe <mikael@lilotux.net>
parents:
2149
diff
changeset
|
2756 |
set_current_buddy(bud); |
798baf5db4eb
Add /roster next_open_buffer
Mikael Berthe <mikael@lilotux.net>
parents:
2149
diff
changeset
|
2757 |
if (chatmode) { |
798baf5db4eb
Add /roster next_open_buffer
Mikael Berthe <mikael@lilotux.net>
parents:
2149
diff
changeset
|
2758 |
last_activity_buddy = current_buddy; |
798baf5db4eb
Add /roster next_open_buffer
Mikael Berthe <mikael@lilotux.net>
parents:
2149
diff
changeset
|
2759 |
scr_show_buddy_window(); |
798baf5db4eb
Add /roster next_open_buffer
Mikael Berthe <mikael@lilotux.net>
parents:
2149
diff
changeset
|
2760 |
} |
798baf5db4eb
Add /roster next_open_buffer
Mikael Berthe <mikael@lilotux.net>
parents:
2149
diff
changeset
|
2761 |
break; |
798baf5db4eb
Add /roster next_open_buffer
Mikael Berthe <mikael@lilotux.net>
parents:
2149
diff
changeset
|
2762 |
} |
798baf5db4eb
Add /roster next_open_buffer
Mikael Berthe <mikael@lilotux.net>
parents:
2149
diff
changeset
|
2763 |
} |
798baf5db4eb
Add /roster next_open_buffer
Mikael Berthe <mikael@lilotux.net>
parents:
2149
diff
changeset
|
2764 |
} |
798baf5db4eb
Add /roster next_open_buffer
Mikael Berthe <mikael@lilotux.net>
parents:
2149
diff
changeset
|
2765 |
|
1780
e4378fbab5d7
Major API cleanup - bump API to 4
Mikael Berthe <mikael@lilotux.net>
parents:
1761
diff
changeset
|
2766 |
// scr_roster_jump_alternate() |
330 | 2767 |
// 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
|
2768 |
void scr_roster_jump_alternate(void) |
105 | 2769 |
{ |
330 | 2770 |
if (!alternate_buddy || g_list_position(buddylist, alternate_buddy) == -1) |
2771 |
return; |
|
2772 |
set_current_buddy(alternate_buddy); |
|
1997
555e342556e7
/roster alternate also changes last_activity_buddy.
Simon Jacquin
parents:
1996
diff
changeset
|
2773 |
if (chatmode) { |
555e342556e7
/roster alternate also changes last_activity_buddy.
Simon Jacquin
parents:
1996
diff
changeset
|
2774 |
last_activity_buddy = current_buddy; |
1780
e4378fbab5d7
Major API cleanup - bump API to 4
Mikael Berthe <mikael@lilotux.net>
parents:
1761
diff
changeset
|
2775 |
scr_show_buddy_window(); |
1997
555e342556e7
/roster alternate also changes last_activity_buddy.
Simon Jacquin
parents:
1996
diff
changeset
|
2776 |
} |
330 | 2777 |
} |
2778 |
||
1780
e4378fbab5d7
Major API cleanup - bump API to 4
Mikael Berthe <mikael@lilotux.net>
parents:
1761
diff
changeset
|
2779 |
// scr_roster_display(filter) |
1311
0dda8238af21
Implement "/roster display"
Mikael Berthe <mikael@lilotux.net>
parents:
1298
diff
changeset
|
2780 |
// 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
|
2781 |
// mask is displayed. |
1780
e4378fbab5d7
Major API cleanup - bump API to 4
Mikael Berthe <mikael@lilotux.net>
parents:
1761
diff
changeset
|
2782 |
void scr_roster_display(const char *filter) |
1311
0dda8238af21
Implement "/roster display"
Mikael Berthe <mikael@lilotux.net>
parents:
1298
diff
changeset
|
2783 |
{ |
0dda8238af21
Implement "/roster display"
Mikael Berthe <mikael@lilotux.net>
parents:
1298
diff
changeset
|
2784 |
guchar status; |
0dda8238af21
Implement "/roster display"
Mikael Berthe <mikael@lilotux.net>
parents:
1298
diff
changeset
|
2785 |
enum imstatus budstate; |
0dda8238af21
Implement "/roster display"
Mikael Berthe <mikael@lilotux.net>
parents:
1298
diff
changeset
|
2786 |
char strfilter[imstatus_size+1]; |
0dda8238af21
Implement "/roster display"
Mikael Berthe <mikael@lilotux.net>
parents:
1298
diff
changeset
|
2787 |
char *psfilter; |
0dda8238af21
Implement "/roster display"
Mikael Berthe <mikael@lilotux.net>
parents:
1298
diff
changeset
|
2788 |
|
0dda8238af21
Implement "/roster display"
Mikael Berthe <mikael@lilotux.net>
parents:
1298
diff
changeset
|
2789 |
if (filter && *filter) { |
0dda8238af21
Implement "/roster display"
Mikael Berthe <mikael@lilotux.net>
parents:
1298
diff
changeset
|
2790 |
int show_all = (*filter == '*'); |
0dda8238af21
Implement "/roster display"
Mikael Berthe <mikael@lilotux.net>
parents:
1298
diff
changeset
|
2791 |
status = 0; |
0dda8238af21
Implement "/roster display"
Mikael Berthe <mikael@lilotux.net>
parents:
1298
diff
changeset
|
2792 |
for (budstate = 0; budstate < imstatus_size-1; budstate++) |
0dda8238af21
Implement "/roster display"
Mikael Berthe <mikael@lilotux.net>
parents:
1298
diff
changeset
|
2793 |
if (strchr(filter, imstatus2char[budstate]) || show_all) |
0dda8238af21
Implement "/roster display"
Mikael Berthe <mikael@lilotux.net>
parents:
1298
diff
changeset
|
2794 |
status |= 1<<budstate; |
0dda8238af21
Implement "/roster display"
Mikael Berthe <mikael@lilotux.net>
parents:
1298
diff
changeset
|
2795 |
buddylist_set_filter(status); |
2291
0d350e979bde
Don't rebuild the buddylist multiple times before a screen refresh
franky
parents:
2288
diff
changeset
|
2796 |
buddylist_defer_build(); |
2292
f181418db215
Replace global variable update_roster with scr_update_roster()
franky
parents:
2291
diff
changeset
|
2797 |
scr_update_roster(); |
1311
0dda8238af21
Implement "/roster display"
Mikael Berthe <mikael@lilotux.net>
parents:
1298
diff
changeset
|
2798 |
return; |
0dda8238af21
Implement "/roster display"
Mikael Berthe <mikael@lilotux.net>
parents:
1298
diff
changeset
|
2799 |
} |
0dda8238af21
Implement "/roster display"
Mikael Berthe <mikael@lilotux.net>
parents:
1298
diff
changeset
|
2800 |
|
0dda8238af21
Implement "/roster display"
Mikael Berthe <mikael@lilotux.net>
parents:
1298
diff
changeset
|
2801 |
// Display current filter |
0dda8238af21
Implement "/roster display"
Mikael Berthe <mikael@lilotux.net>
parents:
1298
diff
changeset
|
2802 |
psfilter = strfilter; |
0dda8238af21
Implement "/roster display"
Mikael Berthe <mikael@lilotux.net>
parents:
1298
diff
changeset
|
2803 |
status = buddylist_get_filter(); |
0dda8238af21
Implement "/roster display"
Mikael Berthe <mikael@lilotux.net>
parents:
1298
diff
changeset
|
2804 |
for (budstate = 0; budstate < imstatus_size-1; budstate++) |
0dda8238af21
Implement "/roster display"
Mikael Berthe <mikael@lilotux.net>
parents:
1298
diff
changeset
|
2805 |
if (status & 1<<budstate) |
0dda8238af21
Implement "/roster display"
Mikael Berthe <mikael@lilotux.net>
parents:
1298
diff
changeset
|
2806 |
*psfilter++ = imstatus2char[budstate]; |
0dda8238af21
Implement "/roster display"
Mikael Berthe <mikael@lilotux.net>
parents:
1298
diff
changeset
|
2807 |
*psfilter = '\0'; |
0dda8238af21
Implement "/roster display"
Mikael Berthe <mikael@lilotux.net>
parents:
1298
diff
changeset
|
2808 |
scr_LogPrint(LPRINT_NORMAL, "Roster status filter: %s", strfilter); |
0dda8238af21
Implement "/roster display"
Mikael Berthe <mikael@lilotux.net>
parents:
1298
diff
changeset
|
2809 |
} |
0dda8238af21
Implement "/roster display"
Mikael Berthe <mikael@lilotux.net>
parents:
1298
diff
changeset
|
2810 |
|
1780
e4378fbab5d7
Major API cleanup - bump API to 4
Mikael Berthe <mikael@lilotux.net>
parents:
1761
diff
changeset
|
2811 |
// scr_buffer_scroll_up_down() |
508
5a2132ba2220
Add "/buffer up" and "/buffer down"
Mikael Berthe <mikael@lilotux.net>
parents:
503
diff
changeset
|
2812 |
// Scroll up/down the current buddy window, |
5a2132ba2220
Add "/buffer up" and "/buffer down"
Mikael Berthe <mikael@lilotux.net>
parents:
503
diff
changeset
|
2813 |
// - half a screen if nblines is 0, |
5a2132ba2220
Add "/buffer up" and "/buffer down"
Mikael Berthe <mikael@lilotux.net>
parents:
503
diff
changeset
|
2814 |
// - 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
|
2815 |
void scr_buffer_scroll_up_down(int updown, unsigned int nblines) |
105 | 2816 |
{ |
822 | 2817 |
winbuf *win_entry; |
508
5a2132ba2220
Add "/buffer up" and "/buffer down"
Mikael Berthe <mikael@lilotux.net>
parents:
503
diff
changeset
|
2818 |
int n, nbl; |
105 | 2819 |
GList *hbuf_top; |
849
42c43a88d823
Status buffer management
Mikael Berthe <mikael@lilotux.net>
parents:
848
diff
changeset
|
2820 |
guint isspe; |
105 | 2821 |
|
2822 |
// Get win_entry |
|
361
51ff319947c3
Code cleanup/optimization
Mikael Berthe <mikael@lilotux.net>
parents:
358
diff
changeset
|
2823 |
if (!current_buddy) return; |
849
42c43a88d823
Status buffer management
Mikael Berthe <mikael@lilotux.net>
parents:
848
diff
changeset
|
2824 |
|
42c43a88d823
Status buffer management
Mikael Berthe <mikael@lilotux.net>
parents:
848
diff
changeset
|
2825 |
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
|
2826 |
win_entry = scr_search_window(CURRENT_JID, isspe); |
361
51ff319947c3
Code cleanup/optimization
Mikael Berthe <mikael@lilotux.net>
parents:
358
diff
changeset
|
2827 |
if (!win_entry) return; |
105 | 2828 |
|
508
5a2132ba2220
Add "/buffer up" and "/buffer down"
Mikael Berthe <mikael@lilotux.net>
parents:
503
diff
changeset
|
2829 |
if (!nblines) { |
5a2132ba2220
Add "/buffer up" and "/buffer down"
Mikael Berthe <mikael@lilotux.net>
parents:
503
diff
changeset
|
2830 |
// Scroll half a screen (or less) |
512 | 2831 |
nbl = CHAT_WIN_HEIGHT/2; |
508
5a2132ba2220
Add "/buffer up" and "/buffer down"
Mikael Berthe <mikael@lilotux.net>
parents:
503
diff
changeset
|
2832 |
} else { |
5a2132ba2220
Add "/buffer up" and "/buffer down"
Mikael Berthe <mikael@lilotux.net>
parents:
503
diff
changeset
|
2833 |
nbl = nblines; |
5a2132ba2220
Add "/buffer up" and "/buffer down"
Mikael Berthe <mikael@lilotux.net>
parents:
503
diff
changeset
|
2834 |
} |
1157
5c857f0f0ab8
Moved all variables related to hbuf to an extra struct, bufdata
Frank Zschockelt
parents:
1156
diff
changeset
|
2835 |
hbuf_top = win_entry->bd->top; |
105 | 2836 |
|
361
51ff319947c3
Code cleanup/optimization
Mikael Berthe <mikael@lilotux.net>
parents:
358
diff
changeset
|
2837 |
if (updown == -1) { // UP |
1969
d9255c408027
Improve (fix) buffer up 1 when the screen is cleared
Mikael Berthe <mikael@lilotux.net>
parents:
1968
diff
changeset
|
2838 |
n = 0; |
361
51ff319947c3
Code cleanup/optimization
Mikael Berthe <mikael@lilotux.net>
parents:
358
diff
changeset
|
2839 |
if (!hbuf_top) { |
1157
5c857f0f0ab8
Moved all variables related to hbuf to an extra struct, bufdata
Frank Zschockelt
parents:
1156
diff
changeset
|
2840 |
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
|
2841 |
if (!win_entry->bd->cleared) { |
512 | 2842 |
if (!nblines) nbl = nbl*3 - 1; |
2843 |
else nbl += CHAT_WIN_HEIGHT - 1; |
|
2844 |
} else { |
|
1157
5c857f0f0ab8
Moved all variables related to hbuf to an extra struct, bufdata
Frank Zschockelt
parents:
1156
diff
changeset
|
2845 |
win_entry->bd->cleared = FALSE; |
1969
d9255c408027
Improve (fix) buffer up 1 when the screen is cleared
Mikael Berthe <mikael@lilotux.net>
parents:
1968
diff
changeset
|
2846 |
n++; // We'll scroll one line less |
512 | 2847 |
} |
361
51ff319947c3
Code cleanup/optimization
Mikael Berthe <mikael@lilotux.net>
parents:
358
diff
changeset
|
2848 |
} |
1969
d9255c408027
Improve (fix) buffer up 1 when the screen is cleared
Mikael Berthe <mikael@lilotux.net>
parents:
1968
diff
changeset
|
2849 |
for ( ; hbuf_top && n < nbl && g_list_previous(hbuf_top) ; n++) |
361
51ff319947c3
Code cleanup/optimization
Mikael Berthe <mikael@lilotux.net>
parents:
358
diff
changeset
|
2850 |
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
|
2851 |
win_entry->bd->top = hbuf_top; |
361
51ff319947c3
Code cleanup/optimization
Mikael Berthe <mikael@lilotux.net>
parents:
358
diff
changeset
|
2852 |
} else { // DOWN |
508
5a2132ba2220
Add "/buffer up" and "/buffer down"
Mikael Berthe <mikael@lilotux.net>
parents:
503
diff
changeset
|
2853 |
for (n=0 ; hbuf_top && n < nbl ; n++) |
361
51ff319947c3
Code cleanup/optimization
Mikael Berthe <mikael@lilotux.net>
parents:
358
diff
changeset
|
2854 |
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
|
2855 |
win_entry->bd->top = hbuf_top; |
361
51ff319947c3
Code cleanup/optimization
Mikael Berthe <mikael@lilotux.net>
parents:
358
diff
changeset
|
2856 |
// Check if we are at the bottom |
51ff319947c3
Code cleanup/optimization
Mikael Berthe <mikael@lilotux.net>
parents:
358
diff
changeset
|
2857 |
for (n=0 ; hbuf_top && n < CHAT_WIN_HEIGHT-1 ; n++) |
51ff319947c3
Code cleanup/optimization
Mikael Berthe <mikael@lilotux.net>
parents:
358
diff
changeset
|
2858 |
hbuf_top = g_list_next(hbuf_top); |
51ff319947c3
Code cleanup/optimization
Mikael Berthe <mikael@lilotux.net>
parents:
358
diff
changeset
|
2859 |
if (!hbuf_top) |
1157
5c857f0f0ab8
Moved all variables related to hbuf to an extra struct, bufdata
Frank Zschockelt
parents:
1156
diff
changeset
|
2860 |
win_entry->bd->top = NULL; // End reached |
361
51ff319947c3
Code cleanup/optimization
Mikael Berthe <mikael@lilotux.net>
parents:
358
diff
changeset
|
2861 |
} |
105 | 2862 |
|
2863 |
// Refresh the window |
|
1780
e4378fbab5d7
Major API cleanup - bump API to 4
Mikael Berthe <mikael@lilotux.net>
parents:
1761
diff
changeset
|
2864 |
scr_update_window(win_entry); |
105 | 2865 |
|
2866 |
// Finished :) |
|
2867 |
update_panels(); |
|
2868 |
} |
|
2869 |
||
1780
e4378fbab5d7
Major API cleanup - bump API to 4
Mikael Berthe <mikael@lilotux.net>
parents:
1761
diff
changeset
|
2870 |
// scr_buffer_clear() |
143 | 2871 |
// 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
|
2872 |
void scr_buffer_clear(void) |
108 | 2873 |
{ |
822 | 2874 |
winbuf *win_entry; |
849
42c43a88d823
Status buffer management
Mikael Berthe <mikael@lilotux.net>
parents:
848
diff
changeset
|
2875 |
guint isspe; |
108 | 2876 |
|
2877 |
// Get win_entry |
|
361
51ff319947c3
Code cleanup/optimization
Mikael Berthe <mikael@lilotux.net>
parents:
358
diff
changeset
|
2878 |
if (!current_buddy) return; |
849
42c43a88d823
Status buffer management
Mikael Berthe <mikael@lilotux.net>
parents:
848
diff
changeset
|
2879 |
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
|
2880 |
win_entry = scr_search_window(CURRENT_JID, isspe); |
361
51ff319947c3
Code cleanup/optimization
Mikael Berthe <mikael@lilotux.net>
parents:
358
diff
changeset
|
2881 |
if (!win_entry) return; |
108 | 2882 |
|
1157
5c857f0f0ab8
Moved all variables related to hbuf to an extra struct, bufdata
Frank Zschockelt
parents:
1156
diff
changeset
|
2883 |
win_entry->bd->cleared = TRUE; |
5c857f0f0ab8
Moved all variables related to hbuf to an extra struct, bufdata
Frank Zschockelt
parents:
1156
diff
changeset
|
2884 |
win_entry->bd->top = NULL; |
108 | 2885 |
|
2886 |
// Refresh the window |
|
1780
e4378fbab5d7
Major API cleanup - bump API to 4
Mikael Berthe <mikael@lilotux.net>
parents:
1761
diff
changeset
|
2887 |
scr_update_window(win_entry); |
108 | 2888 |
|
2889 |
// Finished :) |
|
2890 |
update_panels(); |
|
2891 |
} |
|
2892 |
||
1138
8ba4b1e8b42d
Add command /buffer close_all
Mikael Berthe <mikael@lilotux.net>
parents:
1137
diff
changeset
|
2893 |
// buffer_purge() |
8ba4b1e8b42d
Add command /buffer close_all
Mikael Berthe <mikael@lilotux.net>
parents:
1137
diff
changeset
|
2894 |
// key: winId/jid |
8ba4b1e8b42d
Add command /buffer close_all
Mikael Berthe <mikael@lilotux.net>
parents:
1137
diff
changeset
|
2895 |
// value: winbuf structure |
8ba4b1e8b42d
Add command /buffer close_all
Mikael Berthe <mikael@lilotux.net>
parents:
1137
diff
changeset
|
2896 |
// 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
|
2897 |
// NOTE: does not work for special buffers. |
2222
ce1043326bbc
Fix a small leak when a window is closed
Mikael Berthe <mikael@lilotux.net>
parents:
2211
diff
changeset
|
2898 |
// Returns TRUE IFF the win_entry can be closed and freed. |
2012 | 2899 |
static gboolean buffer_purge(gpointer key, gpointer value, gpointer data) |
1138
8ba4b1e8b42d
Add command /buffer close_all
Mikael Berthe <mikael@lilotux.net>
parents:
1137
diff
changeset
|
2900 |
{ |
1225
0e9e9724d643
Fix a bad type cast in buffer_purge()
Mikael Berthe <mikael@lilotux.net>
parents:
1209
diff
changeset
|
2901 |
int *p_closebuf = data; |
1138
8ba4b1e8b42d
Add command /buffer close_all
Mikael Berthe <mikael@lilotux.net>
parents:
1137
diff
changeset
|
2902 |
winbuf *win_entry = value; |
2012 | 2903 |
gboolean retval = FALSE; |
1138
8ba4b1e8b42d
Add command /buffer close_all
Mikael Berthe <mikael@lilotux.net>
parents:
1137
diff
changeset
|
2904 |
|
8ba4b1e8b42d
Add command /buffer close_all
Mikael Berthe <mikael@lilotux.net>
parents:
1137
diff
changeset
|
2905 |
// Delete the current hbuf |
2225
dc3b3ac1ba76
Free the buffdata structures when buffers are closed
Mikael Berthe <mikael@lilotux.net>
parents:
2222
diff
changeset
|
2906 |
// unless we close the buffer *and* this is a shared bd structure |
dc3b3ac1ba76
Free the buffdata structures when buffers are closed
Mikael Berthe <mikael@lilotux.net>
parents:
2222
diff
changeset
|
2907 |
if (!(*p_closebuf && win_entry->bd->refcount)) |
dc3b3ac1ba76
Free the buffdata structures when buffers are closed
Mikael Berthe <mikael@lilotux.net>
parents:
2222
diff
changeset
|
2908 |
hbuf_free(&win_entry->bd->hbuf); |
1138
8ba4b1e8b42d
Add command /buffer close_all
Mikael Berthe <mikael@lilotux.net>
parents:
1137
diff
changeset
|
2909 |
|
1225
0e9e9724d643
Fix a bad type cast in buffer_purge()
Mikael Berthe <mikael@lilotux.net>
parents:
1209
diff
changeset
|
2910 |
if (*p_closebuf) { |
2013
8dc418af3e72
Allow to select to which buddy resource messages go. Closes issue #55
Hermitifier
parents:
2012
diff
changeset
|
2911 |
GSList *roster_elt; |
2012 | 2912 |
retval = TRUE; |
2013
8dc418af3e72
Allow to select to which buddy resource messages go. Closes issue #55
Hermitifier
parents:
2012
diff
changeset
|
2913 |
roster_elt = roster_find(key, jidsearch, |
8dc418af3e72
Allow to select to which buddy resource messages go. Closes issue #55
Hermitifier
parents:
2012
diff
changeset
|
2914 |
ROSTER_TYPE_USER|ROSTER_TYPE_AGENT); |
8dc418af3e72
Allow to select to which buddy resource messages go. Closes issue #55
Hermitifier
parents:
2012
diff
changeset
|
2915 |
if (roster_elt) |
8dc418af3e72
Allow to select to which buddy resource messages go. Closes issue #55
Hermitifier
parents:
2012
diff
changeset
|
2916 |
buddy_setactiveresource(roster_elt->data, NULL); |
2225
dc3b3ac1ba76
Free the buffdata structures when buffers are closed
Mikael Berthe <mikael@lilotux.net>
parents:
2222
diff
changeset
|
2917 |
if (win_entry->bd->refcount) { |
dc3b3ac1ba76
Free the buffdata structures when buffers are closed
Mikael Berthe <mikael@lilotux.net>
parents:
2222
diff
changeset
|
2918 |
win_entry->bd->refcount--; |
dc3b3ac1ba76
Free the buffdata structures when buffers are closed
Mikael Berthe <mikael@lilotux.net>
parents:
2222
diff
changeset
|
2919 |
} else { |
dc3b3ac1ba76
Free the buffdata structures when buffers are closed
Mikael Berthe <mikael@lilotux.net>
parents:
2222
diff
changeset
|
2920 |
g_free(win_entry->bd); |
dc3b3ac1ba76
Free the buffdata structures when buffers are closed
Mikael Berthe <mikael@lilotux.net>
parents:
2222
diff
changeset
|
2921 |
win_entry->bd = NULL; |
dc3b3ac1ba76
Free the buffdata structures when buffers are closed
Mikael Berthe <mikael@lilotux.net>
parents:
2222
diff
changeset
|
2922 |
} |
1138
8ba4b1e8b42d
Add command /buffer close_all
Mikael Berthe <mikael@lilotux.net>
parents:
1137
diff
changeset
|
2923 |
} else { |
1157
5c857f0f0ab8
Moved all variables related to hbuf to an extra struct, bufdata
Frank Zschockelt
parents:
1156
diff
changeset
|
2924 |
win_entry->bd->cleared = FALSE; |
5c857f0f0ab8
Moved all variables related to hbuf to an extra struct, bufdata
Frank Zschockelt
parents:
1156
diff
changeset
|
2925 |
win_entry->bd->top = NULL; |
1138
8ba4b1e8b42d
Add command /buffer close_all
Mikael Berthe <mikael@lilotux.net>
parents:
1137
diff
changeset
|
2926 |
} |
2012 | 2927 |
return retval; |
1138
8ba4b1e8b42d
Add command /buffer close_all
Mikael Berthe <mikael@lilotux.net>
parents:
1137
diff
changeset
|
2928 |
} |
8ba4b1e8b42d
Add command /buffer close_all
Mikael Berthe <mikael@lilotux.net>
parents:
1137
diff
changeset
|
2929 |
|
1780
e4378fbab5d7
Major API cleanup - bump API to 4
Mikael Berthe <mikael@lilotux.net>
parents:
1761
diff
changeset
|
2930 |
// scr_buffer_purge(closebuf, jid) |
1279
8bbc764139ef
Implement /buffer close|purge [jid]
Mikael Berthe <mikael@lilotux.net>
parents:
1272
diff
changeset
|
2931 |
// 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
|
2932 |
// 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
|
2933 |
void scr_buffer_purge(int closebuf, const char *jid) |
866 | 2934 |
{ |
2935 |
winbuf *win_entry; |
|
2936 |
guint isspe; |
|
1279
8bbc764139ef
Implement /buffer close|purge [jid]
Mikael Berthe <mikael@lilotux.net>
parents:
1272
diff
changeset
|
2937 |
const char *cjid; |
2222
ce1043326bbc
Fix a small leak when a window is closed
Mikael Berthe <mikael@lilotux.net>
parents:
2211
diff
changeset
|
2938 |
char *ljid = NULL; |
1345
8e4e741787be
Small change to buffer close
Mikael Berthe <mikael@lilotux.net>
parents:
1333
diff
changeset
|
2939 |
guint hold_chatmode = FALSE; |
1279
8bbc764139ef
Implement /buffer close|purge [jid]
Mikael Berthe <mikael@lilotux.net>
parents:
1272
diff
changeset
|
2940 |
|
8bbc764139ef
Implement /buffer close|purge [jid]
Mikael Berthe <mikael@lilotux.net>
parents:
1272
diff
changeset
|
2941 |
if (jid) { |
8bbc764139ef
Implement /buffer close|purge [jid]
Mikael Berthe <mikael@lilotux.net>
parents:
1272
diff
changeset
|
2942 |
isspe = FALSE; |
2222
ce1043326bbc
Fix a small leak when a window is closed
Mikael Berthe <mikael@lilotux.net>
parents:
2211
diff
changeset
|
2943 |
ljid = g_strdup(jid); |
ce1043326bbc
Fix a small leak when a window is closed
Mikael Berthe <mikael@lilotux.net>
parents:
2211
diff
changeset
|
2944 |
mc_strtolower(ljid); |
ce1043326bbc
Fix a small leak when a window is closed
Mikael Berthe <mikael@lilotux.net>
parents:
2211
diff
changeset
|
2945 |
cjid = ljid; |
1345
8e4e741787be
Small change to buffer close
Mikael Berthe <mikael@lilotux.net>
parents:
1333
diff
changeset
|
2946 |
// 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
|
2947 |
// 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
|
2948 |
if (closebuf && current_buddy) { |
8e4e741787be
Small change to buffer close
Mikael Berthe <mikael@lilotux.net>
parents:
1333
diff
changeset
|
2949 |
if (buddy_gettype(BUDDATA(current_buddy)) & ROSTER_TYPE_SPECIAL || |
8e4e741787be
Small change to buffer close
Mikael Berthe <mikael@lilotux.net>
parents:
1333
diff
changeset
|
2950 |
strcasecmp(jid, CURRENT_JID)) |
8e4e741787be
Small change to buffer close
Mikael Berthe <mikael@lilotux.net>
parents:
1333
diff
changeset
|
2951 |
hold_chatmode = TRUE; |
8e4e741787be
Small change to buffer close
Mikael Berthe <mikael@lilotux.net>
parents:
1333
diff
changeset
|
2952 |
} |
1279
8bbc764139ef
Implement /buffer close|purge [jid]
Mikael Berthe <mikael@lilotux.net>
parents:
1272
diff
changeset
|
2953 |
} else { |
8bbc764139ef
Implement /buffer close|purge [jid]
Mikael Berthe <mikael@lilotux.net>
parents:
1272
diff
changeset
|
2954 |
// Get win_entry |
8bbc764139ef
Implement /buffer close|purge [jid]
Mikael Berthe <mikael@lilotux.net>
parents:
1272
diff
changeset
|
2955 |
if (!current_buddy) return; |
8bbc764139ef
Implement /buffer close|purge [jid]
Mikael Berthe <mikael@lilotux.net>
parents:
1272
diff
changeset
|
2956 |
cjid = CURRENT_JID; |
8bbc764139ef
Implement /buffer close|purge [jid]
Mikael Berthe <mikael@lilotux.net>
parents:
1272
diff
changeset
|
2957 |
isspe = buddy_gettype(BUDDATA(current_buddy)) & ROSTER_TYPE_SPECIAL; |
8bbc764139ef
Implement /buffer close|purge [jid]
Mikael Berthe <mikael@lilotux.net>
parents:
1272
diff
changeset
|
2958 |
} |
1780
e4378fbab5d7
Major API cleanup - bump API to 4
Mikael Berthe <mikael@lilotux.net>
parents:
1761
diff
changeset
|
2959 |
win_entry = scr_search_window(cjid, isspe); |
2222
ce1043326bbc
Fix a small leak when a window is closed
Mikael Berthe <mikael@lilotux.net>
parents:
2211
diff
changeset
|
2960 |
if (!win_entry) { |
ce1043326bbc
Fix a small leak when a window is closed
Mikael Berthe <mikael@lilotux.net>
parents:
2211
diff
changeset
|
2961 |
g_free(ljid); |
ce1043326bbc
Fix a small leak when a window is closed
Mikael Berthe <mikael@lilotux.net>
parents:
2211
diff
changeset
|
2962 |
return; |
ce1043326bbc
Fix a small leak when a window is closed
Mikael Berthe <mikael@lilotux.net>
parents:
2211
diff
changeset
|
2963 |
} |
866 | 2964 |
|
1138
8ba4b1e8b42d
Add command /buffer close_all
Mikael Berthe <mikael@lilotux.net>
parents:
1137
diff
changeset
|
2965 |
if (!isspe) { |
2222
ce1043326bbc
Fix a small leak when a window is closed
Mikael Berthe <mikael@lilotux.net>
parents:
2211
diff
changeset
|
2966 |
if (buffer_purge((gpointer)cjid, win_entry, &closebuf)) |
2012 | 2967 |
g_hash_table_remove(winbufhash, cjid); |
1700
87dd0a8f1a9c
Remove the "new message" flag when a buffer is purged with /buffer purge
Mikael Berthe <mikael@lilotux.net>
parents:
1694
diff
changeset
|
2968 |
roster_msg_setflag(cjid, FALSE, FALSE); |
1345
8e4e741787be
Small change to buffer close
Mikael Berthe <mikael@lilotux.net>
parents:
1333
diff
changeset
|
2969 |
if (closebuf && !hold_chatmode) { |
1138
8ba4b1e8b42d
Add command /buffer close_all
Mikael Berthe <mikael@lilotux.net>
parents:
1137
diff
changeset
|
2970 |
scr_set_chatmode(FALSE); |
8ba4b1e8b42d
Add command /buffer close_all
Mikael Berthe <mikael@lilotux.net>
parents:
1137
diff
changeset
|
2971 |
currentWindow = NULL; |
8ba4b1e8b42d
Add command /buffer close_all
Mikael Berthe <mikael@lilotux.net>
parents:
1137
diff
changeset
|
2972 |
} |
8ba4b1e8b42d
Add command /buffer close_all
Mikael Berthe <mikael@lilotux.net>
parents:
1137
diff
changeset
|
2973 |
} else { |
8ba4b1e8b42d
Add command /buffer close_all
Mikael Berthe <mikael@lilotux.net>
parents:
1137
diff
changeset
|
2974 |
// (Special buffer) |
8ba4b1e8b42d
Add command /buffer close_all
Mikael Berthe <mikael@lilotux.net>
parents:
1137
diff
changeset
|
2975 |
// Reset the current hbuf |
1157
5c857f0f0ab8
Moved all variables related to hbuf to an extra struct, bufdata
Frank Zschockelt
parents:
1156
diff
changeset
|
2976 |
hbuf_free(&win_entry->bd->hbuf); |
866 | 2977 |
// Currently it can only be the status buffer |
2978 |
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
|
2979 |
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
|
2980 |
|
1157
5c857f0f0ab8
Moved all variables related to hbuf to an extra struct, bufdata
Frank Zschockelt
parents:
1156
diff
changeset
|
2981 |
win_entry->bd->cleared = FALSE; |
5c857f0f0ab8
Moved all variables related to hbuf to an extra struct, bufdata
Frank Zschockelt
parents:
1156
diff
changeset
|
2982 |
win_entry->bd->top = NULL; |
866 | 2983 |
} |
2984 |
||
2292
f181418db215
Replace global variable update_roster with scr_update_roster()
franky
parents:
2291
diff
changeset
|
2985 |
scr_update_roster(); |
1700
87dd0a8f1a9c
Remove the "new message" flag when a buffer is purged with /buffer purge
Mikael Berthe <mikael@lilotux.net>
parents:
1694
diff
changeset
|
2986 |
|
1138
8ba4b1e8b42d
Add command /buffer close_all
Mikael Berthe <mikael@lilotux.net>
parents:
1137
diff
changeset
|
2987 |
// Refresh the window |
1780
e4378fbab5d7
Major API cleanup - bump API to 4
Mikael Berthe <mikael@lilotux.net>
parents:
1761
diff
changeset
|
2988 |
scr_update_buddy_window(); |
1138
8ba4b1e8b42d
Add command /buffer close_all
Mikael Berthe <mikael@lilotux.net>
parents:
1137
diff
changeset
|
2989 |
|
8ba4b1e8b42d
Add command /buffer close_all
Mikael Berthe <mikael@lilotux.net>
parents:
1137
diff
changeset
|
2990 |
// Finished :) |
8ba4b1e8b42d
Add command /buffer close_all
Mikael Berthe <mikael@lilotux.net>
parents:
1137
diff
changeset
|
2991 |
update_panels(); |
2222
ce1043326bbc
Fix a small leak when a window is closed
Mikael Berthe <mikael@lilotux.net>
parents:
2211
diff
changeset
|
2992 |
|
ce1043326bbc
Fix a small leak when a window is closed
Mikael Berthe <mikael@lilotux.net>
parents:
2211
diff
changeset
|
2993 |
g_free(ljid); |
1138
8ba4b1e8b42d
Add command /buffer close_all
Mikael Berthe <mikael@lilotux.net>
parents:
1137
diff
changeset
|
2994 |
} |
8ba4b1e8b42d
Add command /buffer close_all
Mikael Berthe <mikael@lilotux.net>
parents:
1137
diff
changeset
|
2995 |
|
1780
e4378fbab5d7
Major API cleanup - bump API to 4
Mikael Berthe <mikael@lilotux.net>
parents:
1761
diff
changeset
|
2996 |
// scr_buffer_purge_all(closebuf) |
e4378fbab5d7
Major API cleanup - bump API to 4
Mikael Berthe <mikael@lilotux.net>
parents:
1761
diff
changeset
|
2997 |
// Purge all existing buffers. |
e4378fbab5d7
Major API cleanup - bump API to 4
Mikael Berthe <mikael@lilotux.net>
parents:
1761
diff
changeset
|
2998 |
// 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
|
2999 |
void scr_buffer_purge_all(int closebuf) |
1138
8ba4b1e8b42d
Add command /buffer close_all
Mikael Berthe <mikael@lilotux.net>
parents:
1137
diff
changeset
|
3000 |
{ |
2222
ce1043326bbc
Fix a small leak when a window is closed
Mikael Berthe <mikael@lilotux.net>
parents:
2211
diff
changeset
|
3001 |
g_hash_table_foreach_remove(winbufhash, buffer_purge, &closebuf); |
1138
8ba4b1e8b42d
Add command /buffer close_all
Mikael Berthe <mikael@lilotux.net>
parents:
1137
diff
changeset
|
3002 |
|
8ba4b1e8b42d
Add command /buffer close_all
Mikael Berthe <mikael@lilotux.net>
parents:
1137
diff
changeset
|
3003 |
if (closebuf) { |
1135
5d7c05932b13
Add command /buffer close
Mikael Berthe <mikael@lilotux.net>
parents:
1133
diff
changeset
|
3004 |
scr_set_chatmode(FALSE); |
1137
5752017f6e2b
Fix a bug in /buffer close
Mikael Berthe <mikael@lilotux.net>
parents:
1135
diff
changeset
|
3005 |
currentWindow = NULL; |
1135
5d7c05932b13
Add command /buffer close
Mikael Berthe <mikael@lilotux.net>
parents:
1133
diff
changeset
|
3006 |
} |
5d7c05932b13
Add command /buffer close
Mikael Berthe <mikael@lilotux.net>
parents:
1133
diff
changeset
|
3007 |
|
866 | 3008 |
// Refresh the window |
1780
e4378fbab5d7
Major API cleanup - bump API to 4
Mikael Berthe <mikael@lilotux.net>
parents:
1761
diff
changeset
|
3009 |
scr_update_buddy_window(); |
866 | 3010 |
|
3011 |
// Finished :) |
|
3012 |
update_panels(); |
|
3013 |
} |
|
3014 |
||
1780
e4378fbab5d7
Major API cleanup - bump API to 4
Mikael Berthe <mikael@lilotux.net>
parents:
1761
diff
changeset
|
3015 |
// scr_buffer_scroll_lock(lock) |
873
ee39f6d94d43
Add /buffer {scroll_lock|scroll_unlock|toggle_scroll}
Mikael Berthe <mikael@lilotux.net>
parents:
866
diff
changeset
|
3016 |
// Lock/unlock the current buddy buffer |
ee39f6d94d43
Add /buffer {scroll_lock|scroll_unlock|toggle_scroll}
Mikael Berthe <mikael@lilotux.net>
parents:
866
diff
changeset
|
3017 |
// lock = 1 : lock |
ee39f6d94d43
Add /buffer {scroll_lock|scroll_unlock|toggle_scroll}
Mikael Berthe <mikael@lilotux.net>
parents:
866
diff
changeset
|
3018 |
// lock = 0 : unlock |
ee39f6d94d43
Add /buffer {scroll_lock|scroll_unlock|toggle_scroll}
Mikael Berthe <mikael@lilotux.net>
parents:
866
diff
changeset
|
3019 |
// lock = -1: toggle lock status |
1780
e4378fbab5d7
Major API cleanup - bump API to 4
Mikael Berthe <mikael@lilotux.net>
parents:
1761
diff
changeset
|
3020 |
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
|
3021 |
{ |
ee39f6d94d43
Add /buffer {scroll_lock|scroll_unlock|toggle_scroll}
Mikael Berthe <mikael@lilotux.net>
parents:
866
diff
changeset
|
3022 |
winbuf *win_entry; |
ee39f6d94d43
Add /buffer {scroll_lock|scroll_unlock|toggle_scroll}
Mikael Berthe <mikael@lilotux.net>
parents:
866
diff
changeset
|
3023 |
guint isspe; |
ee39f6d94d43
Add /buffer {scroll_lock|scroll_unlock|toggle_scroll}
Mikael Berthe <mikael@lilotux.net>
parents:
866
diff
changeset
|
3024 |
|
ee39f6d94d43
Add /buffer {scroll_lock|scroll_unlock|toggle_scroll}
Mikael Berthe <mikael@lilotux.net>
parents:
866
diff
changeset
|
3025 |
// Get win_entry |
ee39f6d94d43
Add /buffer {scroll_lock|scroll_unlock|toggle_scroll}
Mikael Berthe <mikael@lilotux.net>
parents:
866
diff
changeset
|
3026 |
if (!current_buddy) return; |
ee39f6d94d43
Add /buffer {scroll_lock|scroll_unlock|toggle_scroll}
Mikael Berthe <mikael@lilotux.net>
parents:
866
diff
changeset
|
3027 |
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
|
3028 |
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
|
3029 |
if (!win_entry) return; |
ee39f6d94d43
Add /buffer {scroll_lock|scroll_unlock|toggle_scroll}
Mikael Berthe <mikael@lilotux.net>
parents:
866
diff
changeset
|
3030 |
|
ee39f6d94d43
Add /buffer {scroll_lock|scroll_unlock|toggle_scroll}
Mikael Berthe <mikael@lilotux.net>
parents:
866
diff
changeset
|
3031 |
if (lock == -1) |
1157
5c857f0f0ab8
Moved all variables related to hbuf to an extra struct, bufdata
Frank Zschockelt
parents:
1156
diff
changeset
|
3032 |
lock = !win_entry->bd->lock; |
873
ee39f6d94d43
Add /buffer {scroll_lock|scroll_unlock|toggle_scroll}
Mikael Berthe <mikael@lilotux.net>
parents:
866
diff
changeset
|
3033 |
|
ee39f6d94d43
Add /buffer {scroll_lock|scroll_unlock|toggle_scroll}
Mikael Berthe <mikael@lilotux.net>
parents:
866
diff
changeset
|
3034 |
if (lock) { |
1157
5c857f0f0ab8
Moved all variables related to hbuf to an extra struct, bufdata
Frank Zschockelt
parents:
1156
diff
changeset
|
3035 |
win_entry->bd->lock = TRUE; |
873
ee39f6d94d43
Add /buffer {scroll_lock|scroll_unlock|toggle_scroll}
Mikael Berthe <mikael@lilotux.net>
parents:
866
diff
changeset
|
3036 |
} else { |
1157
5c857f0f0ab8
Moved all variables related to hbuf to an extra struct, bufdata
Frank Zschockelt
parents:
1156
diff
changeset
|
3037 |
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
|
3038 |
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
|
3039 |
win_entry->bd->top = NULL; |
873
ee39f6d94d43
Add /buffer {scroll_lock|scroll_unlock|toggle_scroll}
Mikael Berthe <mikael@lilotux.net>
parents:
866
diff
changeset
|
3040 |
} |
ee39f6d94d43
Add /buffer {scroll_lock|scroll_unlock|toggle_scroll}
Mikael Berthe <mikael@lilotux.net>
parents:
866
diff
changeset
|
3041 |
|
ee39f6d94d43
Add /buffer {scroll_lock|scroll_unlock|toggle_scroll}
Mikael Berthe <mikael@lilotux.net>
parents:
866
diff
changeset
|
3042 |
// 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
|
3043 |
// 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
|
3044 |
// 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
|
3045 |
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
|
3046 |
chatmode = TRUE; |
1780
e4378fbab5d7
Major API cleanup - bump API to 4
Mikael Berthe <mikael@lilotux.net>
parents:
1761
diff
changeset
|
3047 |
scr_show_buddy_window(); |
873
ee39f6d94d43
Add /buffer {scroll_lock|scroll_unlock|toggle_scroll}
Mikael Berthe <mikael@lilotux.net>
parents:
866
diff
changeset
|
3048 |
chatmode = FALSE; |
ee39f6d94d43
Add /buffer {scroll_lock|scroll_unlock|toggle_scroll}
Mikael Berthe <mikael@lilotux.net>
parents:
866
diff
changeset
|
3049 |
} |
ee39f6d94d43
Add /buffer {scroll_lock|scroll_unlock|toggle_scroll}
Mikael Berthe <mikael@lilotux.net>
parents:
866
diff
changeset
|
3050 |
|
ee39f6d94d43
Add /buffer {scroll_lock|scroll_unlock|toggle_scroll}
Mikael Berthe <mikael@lilotux.net>
parents:
866
diff
changeset
|
3051 |
// Refresh the window |
1780
e4378fbab5d7
Major API cleanup - bump API to 4
Mikael Berthe <mikael@lilotux.net>
parents:
1761
diff
changeset
|
3052 |
scr_update_buddy_window(); |
873
ee39f6d94d43
Add /buffer {scroll_lock|scroll_unlock|toggle_scroll}
Mikael Berthe <mikael@lilotux.net>
parents:
866
diff
changeset
|
3053 |
|
ee39f6d94d43
Add /buffer {scroll_lock|scroll_unlock|toggle_scroll}
Mikael Berthe <mikael@lilotux.net>
parents:
866
diff
changeset
|
3054 |
// Finished :) |
ee39f6d94d43
Add /buffer {scroll_lock|scroll_unlock|toggle_scroll}
Mikael Berthe <mikael@lilotux.net>
parents:
866
diff
changeset
|
3055 |
update_panels(); |
ee39f6d94d43
Add /buffer {scroll_lock|scroll_unlock|toggle_scroll}
Mikael Berthe <mikael@lilotux.net>
parents:
866
diff
changeset
|
3056 |
} |
ee39f6d94d43
Add /buffer {scroll_lock|scroll_unlock|toggle_scroll}
Mikael Berthe <mikael@lilotux.net>
parents:
866
diff
changeset
|
3057 |
|
1961
39021fd6b0e1
Try to improve readmarks in some cases
Mikael Berthe <mikael@lilotux.net>
parents:
1960
diff
changeset
|
3058 |
// scr_buffer_readmark(action) |
39021fd6b0e1
Try to improve readmarks in some cases
Mikael Berthe <mikael@lilotux.net>
parents:
1960
diff
changeset
|
3059 |
// Update the readmark flag for the current buffer |
39021fd6b0e1
Try to improve readmarks in some cases
Mikael Berthe <mikael@lilotux.net>
parents:
1960
diff
changeset
|
3060 |
// If action = 1, set the readmark flag on the last message |
39021fd6b0e1
Try to improve readmarks in some cases
Mikael Berthe <mikael@lilotux.net>
parents:
1960
diff
changeset
|
3061 |
// If action = 0, reset the readmark flag |
39021fd6b0e1
Try to improve readmarks in some cases
Mikael Berthe <mikael@lilotux.net>
parents:
1960
diff
changeset
|
3062 |
// If action = -1, remove the readmark flag iff it is on the last line |
39021fd6b0e1
Try to improve readmarks in some cases
Mikael Berthe <mikael@lilotux.net>
parents:
1960
diff
changeset
|
3063 |
void scr_buffer_readmark(gchar action) |
1949
13d18777a629
Add scr_buffer_readmark()
Mikael Berthe <mikael@lilotux.net>
parents:
1948
diff
changeset
|
3064 |
{ |
13d18777a629
Add scr_buffer_readmark()
Mikael Berthe <mikael@lilotux.net>
parents:
1948
diff
changeset
|
3065 |
winbuf *win_entry; |
13d18777a629
Add scr_buffer_readmark()
Mikael Berthe <mikael@lilotux.net>
parents:
1948
diff
changeset
|
3066 |
guint isspe; |
2098
c4a68361883f
Lock buffer automatically when scrolled up, unlock when at bottom ("buffer_smart_scrolling" setting)
Hermitifier
parents:
2090
diff
changeset
|
3067 |
int autolock; |
1949
13d18777a629
Add scr_buffer_readmark()
Mikael Berthe <mikael@lilotux.net>
parents:
1948
diff
changeset
|
3068 |
|
13d18777a629
Add scr_buffer_readmark()
Mikael Berthe <mikael@lilotux.net>
parents:
1948
diff
changeset
|
3069 |
// Get win_entry |
13d18777a629
Add scr_buffer_readmark()
Mikael Berthe <mikael@lilotux.net>
parents:
1948
diff
changeset
|
3070 |
if (!current_buddy) return; |
13d18777a629
Add scr_buffer_readmark()
Mikael Berthe <mikael@lilotux.net>
parents:
1948
diff
changeset
|
3071 |
isspe = buddy_gettype(BUDDATA(current_buddy)) & ROSTER_TYPE_SPECIAL; |
13d18777a629
Add scr_buffer_readmark()
Mikael Berthe <mikael@lilotux.net>
parents:
1948
diff
changeset
|
3072 |
if (isspe) return; // Maybe not necessary |
13d18777a629
Add scr_buffer_readmark()
Mikael Berthe <mikael@lilotux.net>
parents:
1948
diff
changeset
|
3073 |
win_entry = scr_search_window(CURRENT_JID, isspe); |
13d18777a629
Add scr_buffer_readmark()
Mikael Berthe <mikael@lilotux.net>
parents:
1948
diff
changeset
|
3074 |
if (!win_entry) return; |
13d18777a629
Add scr_buffer_readmark()
Mikael Berthe <mikael@lilotux.net>
parents:
1948
diff
changeset
|
3075 |
|
2098
c4a68361883f
Lock buffer automatically when scrolled up, unlock when at bottom ("buffer_smart_scrolling" setting)
Hermitifier
parents:
2090
diff
changeset
|
3076 |
autolock = settings_opt_get_int("buffer_smart_scrolling"); |
c4a68361883f
Lock buffer automatically when scrolled up, unlock when at bottom ("buffer_smart_scrolling" setting)
Hermitifier
parents:
2090
diff
changeset
|
3077 |
if (!win_entry->bd->lock || autolock) { |
1961
39021fd6b0e1
Try to improve readmarks in some cases
Mikael Berthe <mikael@lilotux.net>
parents:
1960
diff
changeset
|
3078 |
if (action >= 0) |
39021fd6b0e1
Try to improve readmarks in some cases
Mikael Berthe <mikael@lilotux.net>
parents:
1960
diff
changeset
|
3079 |
hbuf_set_readmark(win_entry->bd->hbuf, action); |
39021fd6b0e1
Try to improve readmarks in some cases
Mikael Berthe <mikael@lilotux.net>
parents:
1960
diff
changeset
|
3080 |
else |
39021fd6b0e1
Try to improve readmarks in some cases
Mikael Berthe <mikael@lilotux.net>
parents:
1960
diff
changeset
|
3081 |
hbuf_remove_trailing_readmark(win_entry->bd->hbuf); |
39021fd6b0e1
Try to improve readmarks in some cases
Mikael Berthe <mikael@lilotux.net>
parents:
1960
diff
changeset
|
3082 |
} |
1949
13d18777a629
Add scr_buffer_readmark()
Mikael Berthe <mikael@lilotux.net>
parents:
1948
diff
changeset
|
3083 |
} |
13d18777a629
Add scr_buffer_readmark()
Mikael Berthe <mikael@lilotux.net>
parents:
1948
diff
changeset
|
3084 |
|
13d18777a629
Add scr_buffer_readmark()
Mikael Berthe <mikael@lilotux.net>
parents:
1948
diff
changeset
|
3085 |
|
1780
e4378fbab5d7
Major API cleanup - bump API to 4
Mikael Berthe <mikael@lilotux.net>
parents:
1761
diff
changeset
|
3086 |
// scr_buffer_top_bottom() |
361
51ff319947c3
Code cleanup/optimization
Mikael Berthe <mikael@lilotux.net>
parents:
358
diff
changeset
|
3087 |
// Jump to the head/tail of the current buddy window |
51ff319947c3
Code cleanup/optimization
Mikael Berthe <mikael@lilotux.net>
parents:
358
diff
changeset
|
3088 |
// (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
|
3089 |
void scr_buffer_top_bottom(int topbottom) |
187 | 3090 |
{ |
822 | 3091 |
winbuf *win_entry; |
849
42c43a88d823
Status buffer management
Mikael Berthe <mikael@lilotux.net>
parents:
848
diff
changeset
|
3092 |
guint isspe; |
187 | 3093 |
|
3094 |
// Get win_entry |
|
3095 |
if (!current_buddy) return; |
|
849
42c43a88d823
Status buffer management
Mikael Berthe <mikael@lilotux.net>
parents:
848
diff
changeset
|
3096 |
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
|
3097 |
win_entry = scr_search_window(CURRENT_JID, isspe); |
187 | 3098 |
if (!win_entry) return; |
3099 |
||
1157
5c857f0f0ab8
Moved all variables related to hbuf to an extra struct, bufdata
Frank Zschockelt
parents:
1156
diff
changeset
|
3100 |
win_entry->bd->cleared = FALSE; |
361
51ff319947c3
Code cleanup/optimization
Mikael Berthe <mikael@lilotux.net>
parents:
358
diff
changeset
|
3101 |
if (topbottom == 1) |
1157
5c857f0f0ab8
Moved all variables related to hbuf to an extra struct, bufdata
Frank Zschockelt
parents:
1156
diff
changeset
|
3102 |
win_entry->bd->top = NULL; |
361
51ff319947c3
Code cleanup/optimization
Mikael Berthe <mikael@lilotux.net>
parents:
358
diff
changeset
|
3103 |
else |
1157
5c857f0f0ab8
Moved all variables related to hbuf to an extra struct, bufdata
Frank Zschockelt
parents:
1156
diff
changeset
|
3104 |
win_entry->bd->top = g_list_first(win_entry->bd->hbuf); |
187 | 3105 |
|
3106 |
// Refresh the window |
|
1780
e4378fbab5d7
Major API cleanup - bump API to 4
Mikael Berthe <mikael@lilotux.net>
parents:
1761
diff
changeset
|
3107 |
scr_update_window(win_entry); |
187 | 3108 |
|
3109 |
// Finished :) |
|
3110 |
update_panels(); |
|
3111 |
} |
|
3112 |
||
1780
e4378fbab5d7
Major API cleanup - bump API to 4
Mikael Berthe <mikael@lilotux.net>
parents:
1761
diff
changeset
|
3113 |
// scr_buffer_search(direction, text) |
370
dd9e2eb52916
Add /buffer search_{backward,forward}
Mikael Berthe <mikael@lilotux.net>
parents:
369
diff
changeset
|
3114 |
// Jump to the next line containing text |
dd9e2eb52916
Add /buffer search_{backward,forward}
Mikael Berthe <mikael@lilotux.net>
parents:
369
diff
changeset
|
3115 |
// (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
|
3116 |
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
|
3117 |
{ |
822 | 3118 |
winbuf *win_entry; |
370
dd9e2eb52916
Add /buffer search_{backward,forward}
Mikael Berthe <mikael@lilotux.net>
parents:
369
diff
changeset
|
3119 |
GList *current_line, *search_res; |
849
42c43a88d823
Status buffer management
Mikael Berthe <mikael@lilotux.net>
parents:
848
diff
changeset
|
3120 |
guint isspe; |
370
dd9e2eb52916
Add /buffer search_{backward,forward}
Mikael Berthe <mikael@lilotux.net>
parents:
369
diff
changeset
|
3121 |
|
dd9e2eb52916
Add /buffer search_{backward,forward}
Mikael Berthe <mikael@lilotux.net>
parents:
369
diff
changeset
|
3122 |
// Get win_entry |
dd9e2eb52916
Add /buffer search_{backward,forward}
Mikael Berthe <mikael@lilotux.net>
parents:
369
diff
changeset
|
3123 |
if (!current_buddy) return; |
849
42c43a88d823
Status buffer management
Mikael Berthe <mikael@lilotux.net>
parents:
848
diff
changeset
|
3124 |
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
|
3125 |
win_entry = scr_search_window(CURRENT_JID, isspe); |
370
dd9e2eb52916
Add /buffer search_{backward,forward}
Mikael Berthe <mikael@lilotux.net>
parents:
369
diff
changeset
|
3126 |
if (!win_entry) return; |
dd9e2eb52916
Add /buffer search_{backward,forward}
Mikael Berthe <mikael@lilotux.net>
parents:
369
diff
changeset
|
3127 |
|
1157
5c857f0f0ab8
Moved all variables related to hbuf to an extra struct, bufdata
Frank Zschockelt
parents:
1156
diff
changeset
|
3128 |
if (win_entry->bd->top) |
5c857f0f0ab8
Moved all variables related to hbuf to an extra struct, bufdata
Frank Zschockelt
parents:
1156
diff
changeset
|
3129 |
current_line = win_entry->bd->top; |
370
dd9e2eb52916
Add /buffer search_{backward,forward}
Mikael Berthe <mikael@lilotux.net>
parents:
369
diff
changeset
|
3130 |
else |
1157
5c857f0f0ab8
Moved all variables related to hbuf to an extra struct, bufdata
Frank Zschockelt
parents:
1156
diff
changeset
|
3131 |
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
|
3132 |
|
dd9e2eb52916
Add /buffer search_{backward,forward}
Mikael Berthe <mikael@lilotux.net>
parents:
369
diff
changeset
|
3133 |
search_res = hbuf_search(current_line, direction, text); |
dd9e2eb52916
Add /buffer search_{backward,forward}
Mikael Berthe <mikael@lilotux.net>
parents:
369
diff
changeset
|
3134 |
|
dd9e2eb52916
Add /buffer search_{backward,forward}
Mikael Berthe <mikael@lilotux.net>
parents:
369
diff
changeset
|
3135 |
if (search_res) { |
1157
5c857f0f0ab8
Moved all variables related to hbuf to an extra struct, bufdata
Frank Zschockelt
parents:
1156
diff
changeset
|
3136 |
win_entry->bd->cleared = FALSE; |
5c857f0f0ab8
Moved all variables related to hbuf to an extra struct, bufdata
Frank Zschockelt
parents:
1156
diff
changeset
|
3137 |
win_entry->bd->top = search_res; |
370
dd9e2eb52916
Add /buffer search_{backward,forward}
Mikael Berthe <mikael@lilotux.net>
parents:
369
diff
changeset
|
3138 |
|
dd9e2eb52916
Add /buffer search_{backward,forward}
Mikael Berthe <mikael@lilotux.net>
parents:
369
diff
changeset
|
3139 |
// Refresh the window |
1780
e4378fbab5d7
Major API cleanup - bump API to 4
Mikael Berthe <mikael@lilotux.net>
parents:
1761
diff
changeset
|
3140 |
scr_update_window(win_entry); |
370
dd9e2eb52916
Add /buffer search_{backward,forward}
Mikael Berthe <mikael@lilotux.net>
parents:
369
diff
changeset
|
3141 |
|
dd9e2eb52916
Add /buffer search_{backward,forward}
Mikael Berthe <mikael@lilotux.net>
parents:
369
diff
changeset
|
3142 |
// Finished :) |
dd9e2eb52916
Add /buffer search_{backward,forward}
Mikael Berthe <mikael@lilotux.net>
parents:
369
diff
changeset
|
3143 |
update_panels(); |
dd9e2eb52916
Add /buffer search_{backward,forward}
Mikael Berthe <mikael@lilotux.net>
parents:
369
diff
changeset
|
3144 |
} else |
1957
e3e8fb918d56
Be more verbose when the buffer search commands are not successful
Mikael Berthe <mikael@lilotux.net>
parents:
1956
diff
changeset
|
3145 |
scr_LogPrint(LPRINT_NORMAL, "Search string not found."); |
370
dd9e2eb52916
Add /buffer search_{backward,forward}
Mikael Berthe <mikael@lilotux.net>
parents:
369
diff
changeset
|
3146 |
} |
dd9e2eb52916
Add /buffer search_{backward,forward}
Mikael Berthe <mikael@lilotux.net>
parents:
369
diff
changeset
|
3147 |
|
1780
e4378fbab5d7
Major API cleanup - bump API to 4
Mikael Berthe <mikael@lilotux.net>
parents:
1761
diff
changeset
|
3148 |
// scr_buffer_percent(n) |
462 | 3149 |
// 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
|
3150 |
void scr_buffer_percent(int pc) |
462 | 3151 |
{ |
822 | 3152 |
winbuf *win_entry; |
462 | 3153 |
GList *search_res; |
849
42c43a88d823
Status buffer management
Mikael Berthe <mikael@lilotux.net>
parents:
848
diff
changeset
|
3154 |
guint isspe; |
462 | 3155 |
|
3156 |
// Get win_entry |
|
3157 |
if (!current_buddy) return; |
|
849
42c43a88d823
Status buffer management
Mikael Berthe <mikael@lilotux.net>
parents:
848
diff
changeset
|
3158 |
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
|
3159 |
win_entry = scr_search_window(CURRENT_JID, isspe); |
462 | 3160 |
if (!win_entry) return; |
3161 |
||
3162 |
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
|
3163 |
scr_LogPrint(LPRINT_NORMAL, "Bad %% value"); |
462 | 3164 |
return; |
3165 |
} |
|
3166 |
||
1157
5c857f0f0ab8
Moved all variables related to hbuf to an extra struct, bufdata
Frank Zschockelt
parents:
1156
diff
changeset
|
3167 |
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
|
3168 |
|
5c857f0f0ab8
Moved all variables related to hbuf to an extra struct, bufdata
Frank Zschockelt
parents:
1156
diff
changeset
|
3169 |
win_entry->bd->cleared = FALSE; |
5c857f0f0ab8
Moved all variables related to hbuf to an extra struct, bufdata
Frank Zschockelt
parents:
1156
diff
changeset
|
3170 |
win_entry->bd->top = search_res; |
462 | 3171 |
|
3172 |
// Refresh the window |
|
1780
e4378fbab5d7
Major API cleanup - bump API to 4
Mikael Berthe <mikael@lilotux.net>
parents:
1761
diff
changeset
|
3173 |
scr_update_window(win_entry); |
462 | 3174 |
|
3175 |
// Finished :) |
|
3176 |
update_panels(); |
|
3177 |
} |
|
3178 |
||
1780
e4378fbab5d7
Major API cleanup - bump API to 4
Mikael Berthe <mikael@lilotux.net>
parents:
1761
diff
changeset
|
3179 |
// scr_buffer_date(t) |
464 | 3180 |
// Jump to the first line after date t in the buffer |
3181 |
// 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
|
3182 |
void scr_buffer_date(time_t t) |
464 | 3183 |
{ |
822 | 3184 |
winbuf *win_entry; |
464 | 3185 |
GList *search_res; |
849
42c43a88d823
Status buffer management
Mikael Berthe <mikael@lilotux.net>
parents:
848
diff
changeset
|
3186 |
guint isspe; |
464 | 3187 |
|
3188 |
// Get win_entry |
|
3189 |
if (!current_buddy) return; |
|
849
42c43a88d823
Status buffer management
Mikael Berthe <mikael@lilotux.net>
parents:
848
diff
changeset
|
3190 |
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
|
3191 |
win_entry = scr_search_window(CURRENT_JID, isspe); |
464 | 3192 |
if (!win_entry) return; |
3193 |
||
1157
5c857f0f0ab8
Moved all variables related to hbuf to an extra struct, bufdata
Frank Zschockelt
parents:
1156
diff
changeset
|
3194 |
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
|
3195 |
|
5c857f0f0ab8
Moved all variables related to hbuf to an extra struct, bufdata
Frank Zschockelt
parents:
1156
diff
changeset
|
3196 |
win_entry->bd->cleared = FALSE; |
5c857f0f0ab8
Moved all variables related to hbuf to an extra struct, bufdata
Frank Zschockelt
parents:
1156
diff
changeset
|
3197 |
win_entry->bd->top = search_res; |
464 | 3198 |
|
1957
e3e8fb918d56
Be more verbose when the buffer search commands are not successful
Mikael Berthe <mikael@lilotux.net>
parents:
1956
diff
changeset
|
3199 |
if (!search_res) |
e3e8fb918d56
Be more verbose when the buffer search commands are not successful
Mikael Berthe <mikael@lilotux.net>
parents:
1956
diff
changeset
|
3200 |
scr_log_print(LPRINT_NORMAL, "Date not found."); |
e3e8fb918d56
Be more verbose when the buffer search commands are not successful
Mikael Berthe <mikael@lilotux.net>
parents:
1956
diff
changeset
|
3201 |
|
464 | 3202 |
// Refresh the window |
1780
e4378fbab5d7
Major API cleanup - bump API to 4
Mikael Berthe <mikael@lilotux.net>
parents:
1761
diff
changeset
|
3203 |
scr_update_window(win_entry); |
464 | 3204 |
|
3205 |
// Finished :) |
|
3206 |
update_panels(); |
|
3207 |
} |
|
3208 |
||
1956
f309f343070c
Add command /buffer readmark
Mikael Berthe <mikael@lilotux.net>
parents:
1955
diff
changeset
|
3209 |
// scr_buffer_jump_readmark() |
f309f343070c
Add command /buffer readmark
Mikael Berthe <mikael@lilotux.net>
parents:
1955
diff
changeset
|
3210 |
// Jump to the buffer readmark, if there's one |
f309f343070c
Add command /buffer readmark
Mikael Berthe <mikael@lilotux.net>
parents:
1955
diff
changeset
|
3211 |
void scr_buffer_jump_readmark(void) |
f309f343070c
Add command /buffer readmark
Mikael Berthe <mikael@lilotux.net>
parents:
1955
diff
changeset
|
3212 |
{ |
f309f343070c
Add command /buffer readmark
Mikael Berthe <mikael@lilotux.net>
parents:
1955
diff
changeset
|
3213 |
winbuf *win_entry; |
f309f343070c
Add command /buffer readmark
Mikael Berthe <mikael@lilotux.net>
parents:
1955
diff
changeset
|
3214 |
GList *search_res; |
f309f343070c
Add command /buffer readmark
Mikael Berthe <mikael@lilotux.net>
parents:
1955
diff
changeset
|
3215 |
guint isspe; |
f309f343070c
Add command /buffer readmark
Mikael Berthe <mikael@lilotux.net>
parents:
1955
diff
changeset
|
3216 |
|
f309f343070c
Add command /buffer readmark
Mikael Berthe <mikael@lilotux.net>
parents:
1955
diff
changeset
|
3217 |
// Get win_entry |
f309f343070c
Add command /buffer readmark
Mikael Berthe <mikael@lilotux.net>
parents:
1955
diff
changeset
|
3218 |
if (!current_buddy) return; |
f309f343070c
Add command /buffer readmark
Mikael Berthe <mikael@lilotux.net>
parents:
1955
diff
changeset
|
3219 |
isspe = buddy_gettype(BUDDATA(current_buddy)) & ROSTER_TYPE_SPECIAL; |
f309f343070c
Add command /buffer readmark
Mikael Berthe <mikael@lilotux.net>
parents:
1955
diff
changeset
|
3220 |
if (isspe) return; |
f309f343070c
Add command /buffer readmark
Mikael Berthe <mikael@lilotux.net>
parents:
1955
diff
changeset
|
3221 |
win_entry = scr_search_window(CURRENT_JID, isspe); |
f309f343070c
Add command /buffer readmark
Mikael Berthe <mikael@lilotux.net>
parents:
1955
diff
changeset
|
3222 |
if (!win_entry) return; |
f309f343070c
Add command /buffer readmark
Mikael Berthe <mikael@lilotux.net>
parents:
1955
diff
changeset
|
3223 |
|
f309f343070c
Add command /buffer readmark
Mikael Berthe <mikael@lilotux.net>
parents:
1955
diff
changeset
|
3224 |
search_res = hbuf_jump_readmark(win_entry->bd->hbuf); |
f309f343070c
Add command /buffer readmark
Mikael Berthe <mikael@lilotux.net>
parents:
1955
diff
changeset
|
3225 |
|
1968
83d7c7daea6a
buffer readmark: don't update the screen when there is no mark
Mikael Berthe <mikael@lilotux.net>
parents:
1965
diff
changeset
|
3226 |
if (!search_res) { |
83d7c7daea6a
buffer readmark: don't update the screen when there is no mark
Mikael Berthe <mikael@lilotux.net>
parents:
1965
diff
changeset
|
3227 |
scr_log_print(LPRINT_NORMAL, "Readmark not found."); |
83d7c7daea6a
buffer readmark: don't update the screen when there is no mark
Mikael Berthe <mikael@lilotux.net>
parents:
1965
diff
changeset
|
3228 |
return; |
83d7c7daea6a
buffer readmark: don't update the screen when there is no mark
Mikael Berthe <mikael@lilotux.net>
parents:
1965
diff
changeset
|
3229 |
} |
83d7c7daea6a
buffer readmark: don't update the screen when there is no mark
Mikael Berthe <mikael@lilotux.net>
parents:
1965
diff
changeset
|
3230 |
|
1956
f309f343070c
Add command /buffer readmark
Mikael Berthe <mikael@lilotux.net>
parents:
1955
diff
changeset
|
3231 |
win_entry->bd->cleared = FALSE; |
f309f343070c
Add command /buffer readmark
Mikael Berthe <mikael@lilotux.net>
parents:
1955
diff
changeset
|
3232 |
win_entry->bd->top = search_res; |
f309f343070c
Add command /buffer readmark
Mikael Berthe <mikael@lilotux.net>
parents:
1955
diff
changeset
|
3233 |
|
f309f343070c
Add command /buffer readmark
Mikael Berthe <mikael@lilotux.net>
parents:
1955
diff
changeset
|
3234 |
// Refresh the window |
f309f343070c
Add command /buffer readmark
Mikael Berthe <mikael@lilotux.net>
parents:
1955
diff
changeset
|
3235 |
scr_update_window(win_entry); |
f309f343070c
Add command /buffer readmark
Mikael Berthe <mikael@lilotux.net>
parents:
1955
diff
changeset
|
3236 |
|
f309f343070c
Add command /buffer readmark
Mikael Berthe <mikael@lilotux.net>
parents:
1955
diff
changeset
|
3237 |
// Finished :) |
f309f343070c
Add command /buffer readmark
Mikael Berthe <mikael@lilotux.net>
parents:
1955
diff
changeset
|
3238 |
update_panels(); |
f309f343070c
Add command /buffer readmark
Mikael Berthe <mikael@lilotux.net>
parents:
1955
diff
changeset
|
3239 |
} |
f309f343070c
Add command /buffer readmark
Mikael Berthe <mikael@lilotux.net>
parents:
1955
diff
changeset
|
3240 |
|
1780
e4378fbab5d7
Major API cleanup - bump API to 4
Mikael Berthe <mikael@lilotux.net>
parents:
1761
diff
changeset
|
3241 |
// scr_buffer_dump(filename) |
e4378fbab5d7
Major API cleanup - bump API to 4
Mikael Berthe <mikael@lilotux.net>
parents:
1761
diff
changeset
|
3242 |
// 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
|
3243 |
void scr_buffer_dump(const char *file) |
1485
0121b6f3047c
New command: /buffer save
Mikael Berthe <mikael@lilotux.net>
parents:
1484
diff
changeset
|
3244 |
{ |
0121b6f3047c
New command: /buffer save
Mikael Berthe <mikael@lilotux.net>
parents:
1484
diff
changeset
|
3245 |
char *extfname; |
0121b6f3047c
New command: /buffer save
Mikael Berthe <mikael@lilotux.net>
parents:
1484
diff
changeset
|
3246 |
|
0121b6f3047c
New command: /buffer save
Mikael Berthe <mikael@lilotux.net>
parents:
1484
diff
changeset
|
3247 |
if (!currentWindow) { |
0121b6f3047c
New command: /buffer save
Mikael Berthe <mikael@lilotux.net>
parents:
1484
diff
changeset
|
3248 |
scr_LogPrint(LPRINT_NORMAL, "No current buffer!"); |
0121b6f3047c
New command: /buffer save
Mikael Berthe <mikael@lilotux.net>
parents:
1484
diff
changeset
|
3249 |
return; |
0121b6f3047c
New command: /buffer save
Mikael Berthe <mikael@lilotux.net>
parents:
1484
diff
changeset
|
3250 |
} |
0121b6f3047c
New command: /buffer save
Mikael Berthe <mikael@lilotux.net>
parents:
1484
diff
changeset
|
3251 |
|
0121b6f3047c
New command: /buffer save
Mikael Berthe <mikael@lilotux.net>
parents:
1484
diff
changeset
|
3252 |
if (!file || !*file) { |
0121b6f3047c
New command: /buffer save
Mikael Berthe <mikael@lilotux.net>
parents:
1484
diff
changeset
|
3253 |
scr_LogPrint(LPRINT_NORMAL, "Missing parameter (file name)!"); |
0121b6f3047c
New command: /buffer save
Mikael Berthe <mikael@lilotux.net>
parents:
1484
diff
changeset
|
3254 |
return; |
0121b6f3047c
New command: /buffer save
Mikael Berthe <mikael@lilotux.net>
parents:
1484
diff
changeset
|
3255 |
} |
0121b6f3047c
New command: /buffer save
Mikael Berthe <mikael@lilotux.net>
parents:
1484
diff
changeset
|
3256 |
|
0121b6f3047c
New command: /buffer save
Mikael Berthe <mikael@lilotux.net>
parents:
1484
diff
changeset
|
3257 |
extfname = expand_filename(file); |
0121b6f3047c
New command: /buffer save
Mikael Berthe <mikael@lilotux.net>
parents:
1484
diff
changeset
|
3258 |
hbuf_dump_to_file(currentWindow->bd->hbuf, extfname); |
0121b6f3047c
New command: /buffer save
Mikael Berthe <mikael@lilotux.net>
parents:
1484
diff
changeset
|
3259 |
g_free(extfname); |
0121b6f3047c
New command: /buffer save
Mikael Berthe <mikael@lilotux.net>
parents:
1484
diff
changeset
|
3260 |
} |
0121b6f3047c
New command: /buffer save
Mikael Berthe <mikael@lilotux.net>
parents:
1484
diff
changeset
|
3261 |
|
1226
2521efbf3b72
New (debug) subcommand, buffer list
Mikael Berthe <mikael@lilotux.net>
parents:
1225
diff
changeset
|
3262 |
// buffer_list() |
2521efbf3b72
New (debug) subcommand, buffer list
Mikael Berthe <mikael@lilotux.net>
parents:
1225
diff
changeset
|
3263 |
// key: winId/jid |
2521efbf3b72
New (debug) subcommand, buffer list
Mikael Berthe <mikael@lilotux.net>
parents:
1225
diff
changeset
|
3264 |
// value: winbuf structure |
2521efbf3b72
New (debug) subcommand, buffer list
Mikael Berthe <mikael@lilotux.net>
parents:
1225
diff
changeset
|
3265 |
// data: none. |
2521efbf3b72
New (debug) subcommand, buffer list
Mikael Berthe <mikael@lilotux.net>
parents:
1225
diff
changeset
|
3266 |
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
|
3267 |
{ |
1227
79c396678f1b
Make buffer list display the number of allocated HBB blocks
Mikael Berthe <mikael@lilotux.net>
parents:
1226
diff
changeset
|
3268 |
GList *head; |
1226
2521efbf3b72
New (debug) subcommand, buffer list
Mikael Berthe <mikael@lilotux.net>
parents:
1225
diff
changeset
|
3269 |
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
|
3270 |
|
79c396678f1b
Make buffer list display the number of allocated HBB blocks
Mikael Berthe <mikael@lilotux.net>
parents:
1226
diff
changeset
|
3271 |
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
|
3272 |
|
1686
393c05fba337
Use G_GNUC_PRINTF to check scr_LogPrint arguments
Myhailo Danylenko <isbear@ukrpost.net>
parents:
1677
diff
changeset
|
3273 |
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
|
3274 |
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
|
3275 |
} |
2521efbf3b72
New (debug) subcommand, buffer list
Mikael Berthe <mikael@lilotux.net>
parents:
1225
diff
changeset
|
3276 |
|
1780
e4378fbab5d7
Major API cleanup - bump API to 4
Mikael Berthe <mikael@lilotux.net>
parents:
1761
diff
changeset
|
3277 |
void scr_buffer_list(void) |
1226
2521efbf3b72
New (debug) subcommand, buffer list
Mikael Berthe <mikael@lilotux.net>
parents:
1225
diff
changeset
|
3278 |
{ |
2521efbf3b72
New (debug) subcommand, buffer list
Mikael Berthe <mikael@lilotux.net>
parents:
1225
diff
changeset
|
3279 |
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
|
3280 |
buffer_list("[status]", statusWindow, NULL); |
1226
2521efbf3b72
New (debug) subcommand, buffer list
Mikael Berthe <mikael@lilotux.net>
parents:
1225
diff
changeset
|
3281 |
g_hash_table_foreach(winbufhash, buffer_list, NULL); |
2521efbf3b72
New (debug) subcommand, buffer list
Mikael Berthe <mikael@lilotux.net>
parents:
1225
diff
changeset
|
3282 |
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
|
3283 |
scr_setmsgflag_if_needed(SPECIAL_BUFFER_STATUS_ID, TRUE); |
1815
6abca6000762
Make use of ROSTER_UI_PRIO_STATUS_WIN_MESSAGE
Mikael Berthe <mikael@lilotux.net>
parents:
1811
diff
changeset
|
3284 |
scr_setattentionflag_if_needed(SPECIAL_BUFFER_STATUS_ID, TRUE, |
6abca6000762
Make use of ROSTER_UI_PRIO_STATUS_WIN_MESSAGE
Mikael Berthe <mikael@lilotux.net>
parents:
1811
diff
changeset
|
3285 |
ROSTER_UI_PRIO_STATUS_WIN_MESSAGE, prio_max); |
1226
2521efbf3b72
New (debug) subcommand, buffer list
Mikael Berthe <mikael@lilotux.net>
parents:
1225
diff
changeset
|
3286 |
} |
2521efbf3b72
New (debug) subcommand, buffer list
Mikael Berthe <mikael@lilotux.net>
parents:
1225
diff
changeset
|
3287 |
|
143 | 3288 |
// scr_set_chatmode() |
261 | 3289 |
// Public function to (un)set chatmode... |
129 | 3290 |
inline void scr_set_chatmode(int enable) |
3291 |
{ |
|
1961
39021fd6b0e1
Try to improve readmarks in some cases
Mikael Berthe <mikael@lilotux.net>
parents:
1960
diff
changeset
|
3292 |
gboolean enter_chatmode = enable && chatmode == FALSE; |
129 | 3293 |
chatmode = enable; |
1780
e4378fbab5d7
Major API cleanup - bump API to 4
Mikael Berthe <mikael@lilotux.net>
parents:
1761
diff
changeset
|
3294 |
scr_update_chat_status(TRUE); |
1961
39021fd6b0e1
Try to improve readmarks in some cases
Mikael Berthe <mikael@lilotux.net>
parents:
1960
diff
changeset
|
3295 |
if (enter_chatmode) |
39021fd6b0e1
Try to improve readmarks in some cases
Mikael Berthe <mikael@lilotux.net>
parents:
1960
diff
changeset
|
3296 |
scr_buffer_readmark(-1); |
129 | 3297 |
} |
3298 |
||
1129
1a109ebf3f24
Add option "events_ignore_active_window"
Mikael Berthe <mikael@lilotux.net>
parents:
1127
diff
changeset
|
3299 |
// scr_get_chatmode() |
1a109ebf3f24
Add option "events_ignore_active_window"
Mikael Berthe <mikael@lilotux.net>
parents:
1127
diff
changeset
|
3300 |
// Public function to get chatmode state. |
1a109ebf3f24
Add option "events_ignore_active_window"
Mikael Berthe <mikael@lilotux.net>
parents:
1127
diff
changeset
|
3301 |
inline int scr_get_chatmode(void) |
1a109ebf3f24
Add option "events_ignore_active_window"
Mikael Berthe <mikael@lilotux.net>
parents:
1127
diff
changeset
|
3302 |
{ |
1a109ebf3f24
Add option "events_ignore_active_window"
Mikael Berthe <mikael@lilotux.net>
parents:
1127
diff
changeset
|
3303 |
return chatmode; |
1a109ebf3f24
Add option "events_ignore_active_window"
Mikael Berthe <mikael@lilotux.net>
parents:
1127
diff
changeset
|
3304 |
} |
1a109ebf3f24
Add option "events_ignore_active_window"
Mikael Berthe <mikael@lilotux.net>
parents:
1127
diff
changeset
|
3305 |
|
238 | 3306 |
// scr_get_multimode() |
261 | 3307 |
// Public function to get multimode status... |
1059 | 3308 |
inline int scr_get_multimode(void) |
238 | 3309 |
{ |
3310 |
return multimode; |
|
3311 |
} |
|
3312 |
||
654
d7fe7b88e4fc
MUC: Set the new_message flag when joining a room
Mikael Berthe <mikael@lilotux.net>
parents:
652
diff
changeset
|
3313 |
// 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
|
3314 |
// Set the message flag unless we're already in the jid buffer window |
1058 | 3315 |
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
|
3316 |
{ |
891
78f4971578dd
Add a "special" parameter to scr_setmsgflag_if_needed()
Mikael Berthe <mikael@lilotux.net>
parents:
889
diff
changeset
|
3317 |
const char *current_id; |
873
ee39f6d94d43
Add /buffer {scroll_lock|scroll_unlock|toggle_scroll}
Mikael Berthe <mikael@lilotux.net>
parents:
866
diff
changeset
|
3318 |
bool iscurrentlocked = FALSE; |
667
86bc3295a4db
Fix segfault in scr_setmsgflag_if_needed()
Mikael Berthe <mikael@lilotux.net>
parents:
658
diff
changeset
|
3319 |
|
1058 | 3320 |
if (!bjid) |
849
42c43a88d823
Status buffer management
Mikael Berthe <mikael@lilotux.net>
parents:
848
diff
changeset
|
3321 |
return; |
42c43a88d823
Status buffer management
Mikael Berthe <mikael@lilotux.net>
parents:
848
diff
changeset
|
3322 |
|
873
ee39f6d94d43
Add /buffer {scroll_lock|scroll_unlock|toggle_scroll}
Mikael Berthe <mikael@lilotux.net>
parents:
866
diff
changeset
|
3323 |
if (current_buddy) { |
891
78f4971578dd
Add a "special" parameter to scr_setmsgflag_if_needed()
Mikael Berthe <mikael@lilotux.net>
parents:
889
diff
changeset
|
3324 |
if (special) |
78f4971578dd
Add a "special" parameter to scr_setmsgflag_if_needed()
Mikael Berthe <mikael@lilotux.net>
parents:
889
diff
changeset
|
3325 |
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
|
3326 |
else |
78f4971578dd
Add a "special" parameter to scr_setmsgflag_if_needed()
Mikael Berthe <mikael@lilotux.net>
parents:
889
diff
changeset
|
3327 |
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
|
3328 |
if (current_id) { |
1780
e4378fbab5d7
Major API cleanup - bump API to 4
Mikael Berthe <mikael@lilotux.net>
parents:
1761
diff
changeset
|
3329 |
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
|
3330 |
if (!win_entry) return; |
1157
5c857f0f0ab8
Moved all variables related to hbuf to an extra struct, bufdata
Frank Zschockelt
parents:
1156
diff
changeset
|
3331 |
iscurrentlocked = win_entry->bd->lock; |
873
ee39f6d94d43
Add /buffer {scroll_lock|scroll_unlock|toggle_scroll}
Mikael Berthe <mikael@lilotux.net>
parents:
866
diff
changeset
|
3332 |
} |
ee39f6d94d43
Add /buffer {scroll_lock|scroll_unlock|toggle_scroll}
Mikael Berthe <mikael@lilotux.net>
parents:
866
diff
changeset
|
3333 |
} else { |
891
78f4971578dd
Add a "special" parameter to scr_setmsgflag_if_needed()
Mikael Berthe <mikael@lilotux.net>
parents:
889
diff
changeset
|
3334 |
current_id = NULL; |
873
ee39f6d94d43
Add /buffer {scroll_lock|scroll_unlock|toggle_scroll}
Mikael Berthe <mikael@lilotux.net>
parents:
866
diff
changeset
|
3335 |
} |
1821
60db836ad98a
Move some "update_roster" updates to a better place
Mikael Berthe <mikael@lilotux.net>
parents:
1819
diff
changeset
|
3336 |
if (!chatmode || !current_id || strcmp(bjid, current_id) || iscurrentlocked) { |
1058 | 3337 |
roster_msg_setflag(bjid, special, TRUE); |
2292
f181418db215
Replace global variable update_roster with scr_update_roster()
franky
parents:
2291
diff
changeset
|
3338 |
scr_update_roster(); |
1821
60db836ad98a
Move some "update_roster" updates to a better place
Mikael Berthe <mikael@lilotux.net>
parents:
1819
diff
changeset
|
3339 |
} |
654
d7fe7b88e4fc
MUC: Set the new_message flag when joining a room
Mikael Berthe <mikael@lilotux.net>
parents:
652
diff
changeset
|
3340 |
} |
d7fe7b88e4fc
MUC: Set the new_message flag when joining a room
Mikael Berthe <mikael@lilotux.net>
parents:
652
diff
changeset
|
3341 |
|
1802
b135572fcd26
Add urgent flag per screen buffer
Mikael Berthe <mikael@lilotux.net>
parents:
1793
diff
changeset
|
3342 |
// 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
|
3343 |
// 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
|
3344 |
// 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
|
3345 |
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
|
3346 |
guint value, enum setuiprio_ops action) |
b135572fcd26
Add urgent flag per screen buffer
Mikael Berthe <mikael@lilotux.net>
parents:
1793
diff
changeset
|
3347 |
{ |
b135572fcd26
Add urgent flag per screen buffer
Mikael Berthe <mikael@lilotux.net>
parents:
1793
diff
changeset
|
3348 |
const char *current_id; |
b135572fcd26
Add urgent flag per screen buffer
Mikael Berthe <mikael@lilotux.net>
parents:
1793
diff
changeset
|
3349 |
winbuf *wb; |
b135572fcd26
Add urgent flag per screen buffer
Mikael Berthe <mikael@lilotux.net>
parents:
1793
diff
changeset
|
3350 |
bool iscurrentlocked = FALSE; |
b135572fcd26
Add urgent flag per screen buffer
Mikael Berthe <mikael@lilotux.net>
parents:
1793
diff
changeset
|
3351 |
|
b135572fcd26
Add urgent flag per screen buffer
Mikael Berthe <mikael@lilotux.net>
parents:
1793
diff
changeset
|
3352 |
if (!bjid) |
b135572fcd26
Add urgent flag per screen buffer
Mikael Berthe <mikael@lilotux.net>
parents:
1793
diff
changeset
|
3353 |
return; |
b135572fcd26
Add urgent flag per screen buffer
Mikael Berthe <mikael@lilotux.net>
parents:
1793
diff
changeset
|
3354 |
|
b135572fcd26
Add urgent flag per screen buffer
Mikael Berthe <mikael@lilotux.net>
parents:
1793
diff
changeset
|
3355 |
wb = scr_search_window(bjid, special); |
b135572fcd26
Add urgent flag per screen buffer
Mikael Berthe <mikael@lilotux.net>
parents:
1793
diff
changeset
|
3356 |
if (!wb) |
b135572fcd26
Add urgent flag per screen buffer
Mikael Berthe <mikael@lilotux.net>
parents:
1793
diff
changeset
|
3357 |
return; |
b135572fcd26
Add urgent flag per screen buffer
Mikael Berthe <mikael@lilotux.net>
parents:
1793
diff
changeset
|
3358 |
|
b135572fcd26
Add urgent flag per screen buffer
Mikael Berthe <mikael@lilotux.net>
parents:
1793
diff
changeset
|
3359 |
if (current_buddy) { |
b135572fcd26
Add urgent flag per screen buffer
Mikael Berthe <mikael@lilotux.net>
parents:
1793
diff
changeset
|
3360 |
if (special) |
b135572fcd26
Add urgent flag per screen buffer
Mikael Berthe <mikael@lilotux.net>
parents:
1793
diff
changeset
|
3361 |
current_id = buddy_getname(BUDDATA(current_buddy)); |
b135572fcd26
Add urgent flag per screen buffer
Mikael Berthe <mikael@lilotux.net>
parents:
1793
diff
changeset
|
3362 |
else |
b135572fcd26
Add urgent flag per screen buffer
Mikael Berthe <mikael@lilotux.net>
parents:
1793
diff
changeset
|
3363 |
current_id = buddy_getjid(BUDDATA(current_buddy)); |
b135572fcd26
Add urgent flag per screen buffer
Mikael Berthe <mikael@lilotux.net>
parents:
1793
diff
changeset
|
3364 |
if (current_id) { |
b135572fcd26
Add urgent flag per screen buffer
Mikael Berthe <mikael@lilotux.net>
parents:
1793
diff
changeset
|
3365 |
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
|
3366 |
if (!win_entry) return; |
b135572fcd26
Add urgent flag per screen buffer
Mikael Berthe <mikael@lilotux.net>
parents:
1793
diff
changeset
|
3367 |
iscurrentlocked = win_entry->bd->lock; |
b135572fcd26
Add urgent flag per screen buffer
Mikael Berthe <mikael@lilotux.net>
parents:
1793
diff
changeset
|
3368 |
} |
b135572fcd26
Add urgent flag per screen buffer
Mikael Berthe <mikael@lilotux.net>
parents:
1793
diff
changeset
|
3369 |
} else { |
b135572fcd26
Add urgent flag per screen buffer
Mikael Berthe <mikael@lilotux.net>
parents:
1793
diff
changeset
|
3370 |
current_id = NULL; |
b135572fcd26
Add urgent flag per screen buffer
Mikael Berthe <mikael@lilotux.net>
parents:
1793
diff
changeset
|
3371 |
} |
b135572fcd26
Add urgent flag per screen buffer
Mikael Berthe <mikael@lilotux.net>
parents:
1793
diff
changeset
|
3372 |
|
1821
60db836ad98a
Move some "update_roster" updates to a better place
Mikael Berthe <mikael@lilotux.net>
parents:
1819
diff
changeset
|
3373 |
if (!chatmode || !current_id || strcmp(bjid, current_id) || iscurrentlocked) { |
1802
b135572fcd26
Add urgent flag per screen buffer
Mikael Berthe <mikael@lilotux.net>
parents:
1793
diff
changeset
|
3374 |
roster_setuiprio(bjid, special, value, action); |
2292
f181418db215
Replace global variable update_roster with scr_update_roster()
franky
parents:
2291
diff
changeset
|
3375 |
scr_update_roster(); |
1821
60db836ad98a
Move some "update_roster" updates to a better place
Mikael Berthe <mikael@lilotux.net>
parents:
1819
diff
changeset
|
3376 |
} |
1802
b135572fcd26
Add urgent flag per screen buffer
Mikael Berthe <mikael@lilotux.net>
parents:
1793
diff
changeset
|
3377 |
} |
b135572fcd26
Add urgent flag per screen buffer
Mikael Berthe <mikael@lilotux.net>
parents:
1793
diff
changeset
|
3378 |
|
238 | 3379 |
// scr_set_multimode() |
261 | 3380 |
// Public function to (un)set multimode... |
260
33e1a05864a6
Add "verbatim multi-line" mode, with commands disabled
mikael@frmp8452
parents:
252
diff
changeset
|
3381 |
// Convention: |
33e1a05864a6
Add "verbatim multi-line" mode, with commands disabled
mikael@frmp8452
parents:
252
diff
changeset
|
3382 |
// 0 = disabled / 1 = multimode / 2 = multimode verbatim (commands disabled) |
1413 | 3383 |
void scr_set_multimode(int enable, char *subject) |
238 | 3384 |
{ |
807
f6cda389db48
Allow messages with a subject (/msay)
Mikael Berthe <mikael@lilotux.net>
parents:
806
diff
changeset
|
3385 |
g_free(multiline); |
f6cda389db48
Allow messages with a subject (/msay)
Mikael Berthe <mikael@lilotux.net>
parents:
806
diff
changeset
|
3386 |
multiline = NULL; |
f6cda389db48
Allow messages with a subject (/msay)
Mikael Berthe <mikael@lilotux.net>
parents:
806
diff
changeset
|
3387 |
|
f6cda389db48
Allow messages with a subject (/msay)
Mikael Berthe <mikael@lilotux.net>
parents:
806
diff
changeset
|
3388 |
g_free(multimode_subj); |
f6cda389db48
Allow messages with a subject (/msay)
Mikael Berthe <mikael@lilotux.net>
parents:
806
diff
changeset
|
3389 |
if (enable && subject) |
f6cda389db48
Allow messages with a subject (/msay)
Mikael Berthe <mikael@lilotux.net>
parents:
806
diff
changeset
|
3390 |
multimode_subj = g_strdup(subject); |
f6cda389db48
Allow messages with a subject (/msay)
Mikael Berthe <mikael@lilotux.net>
parents:
806
diff
changeset
|
3391 |
else |
f6cda389db48
Allow messages with a subject (/msay)
Mikael Berthe <mikael@lilotux.net>
parents:
806
diff
changeset
|
3392 |
multimode_subj = NULL; |
f6cda389db48
Allow messages with a subject (/msay)
Mikael Berthe <mikael@lilotux.net>
parents:
806
diff
changeset
|
3393 |
|
260
33e1a05864a6
Add "verbatim multi-line" mode, with commands disabled
mikael@frmp8452
parents:
252
diff
changeset
|
3394 |
multimode = enable; |
238 | 3395 |
} |
3396 |
||
3397 |
// scr_get_multiline() |
|
261 | 3398 |
// Public function to get the current multi-line. |
1413 | 3399 |
const char *scr_get_multiline(void) |
238 | 3400 |
{ |
3401 |
if (multimode && multiline) |
|
3402 |
return multiline; |
|
807
f6cda389db48
Allow messages with a subject (/msay)
Mikael Berthe <mikael@lilotux.net>
parents:
806
diff
changeset
|
3403 |
return NULL; |
f6cda389db48
Allow messages with a subject (/msay)
Mikael Berthe <mikael@lilotux.net>
parents:
806
diff
changeset
|
3404 |
} |
f6cda389db48
Allow messages with a subject (/msay)
Mikael Berthe <mikael@lilotux.net>
parents:
806
diff
changeset
|
3405 |
|
f6cda389db48
Allow messages with a subject (/msay)
Mikael Berthe <mikael@lilotux.net>
parents:
806
diff
changeset
|
3406 |
// scr_get_multimode_subj() |
f6cda389db48
Allow messages with a subject (/msay)
Mikael Berthe <mikael@lilotux.net>
parents:
806
diff
changeset
|
3407 |
// Public function to get the multi-line subject, if any. |
1413 | 3408 |
const char *scr_get_multimode_subj(void) |
807
f6cda389db48
Allow messages with a subject (/msay)
Mikael Berthe <mikael@lilotux.net>
parents:
806
diff
changeset
|
3409 |
{ |
f6cda389db48
Allow messages with a subject (/msay)
Mikael Berthe <mikael@lilotux.net>
parents:
806
diff
changeset
|
3410 |
if (multimode) |
f6cda389db48
Allow messages with a subject (/msay)
Mikael Berthe <mikael@lilotux.net>
parents:
806
diff
changeset
|
3411 |
return multimode_subj; |
f6cda389db48
Allow messages with a subject (/msay)
Mikael Berthe <mikael@lilotux.net>
parents:
806
diff
changeset
|
3412 |
return NULL; |
238 | 3413 |
} |
3414 |
||
3415 |
// scr_append_multiline(line) |
|
3416 |
// Public function to append a line to the current multi-line message. |
|
3417 |
// Skip empty leading lines. |
|
3418 |
void scr_append_multiline(const char *line) |
|
3419 |
{ |
|
3420 |
static int num; |
|
3421 |
||
3422 |
if (!multimode) { |
|
374
bd5638c21834
Improve logging system (traces)
Mikael Berthe <mikael@lilotux.net>
parents:
373
diff
changeset
|
3423 |
scr_LogPrint(LPRINT_NORMAL, "Error: Not in multi-line message mode!"); |
238 | 3424 |
return; |
3425 |
} |
|
3426 |
if (multiline) { |
|
3427 |
int len = strlen(multiline)+strlen(line)+2; |
|
252 | 3428 |
if (len >= HBB_BLOCKSIZE - 1) { |
238 | 3429 |
// We don't handle single messages with size > HBB_BLOCKSIZE |
3430 |
// (see hbuf) |
|
374
bd5638c21834
Improve logging system (traces)
Mikael Berthe <mikael@lilotux.net>
parents:
373
diff
changeset
|
3431 |
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
|
3432 |
"this line has not been added."); |
bd5638c21834
Improve logging system (traces)
Mikael Berthe <mikael@lilotux.net>
parents:
373
diff
changeset
|
3433 |
scr_LogPrint(LPRINT_NORMAL, "Please send this part now..."); |
238 | 3434 |
return; |
3435 |
} |
|
276
627925d885de
Limit the number of lines in multi-line messages
Mikael Berthe <mikael@lilotux.net>
parents:
271
diff
changeset
|
3436 |
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
|
3437 |
// 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
|
3438 |
// (It should be < 1000 yet) |
374
bd5638c21834
Improve logging system (traces)
Mikael Berthe <mikael@lilotux.net>
parents:
373
diff
changeset
|
3439 |
scr_LogPrint(LPRINT_NORMAL, "Your message has too many lines, " |
bd5638c21834
Improve logging system (traces)
Mikael Berthe <mikael@lilotux.net>
parents:
373
diff
changeset
|
3440 |
"this one has not been added."); |
bd5638c21834
Improve logging system (traces)
Mikael Berthe <mikael@lilotux.net>
parents:
373
diff
changeset
|
3441 |
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
|
3442 |
return; |
627925d885de
Limit the number of lines in multi-line messages
Mikael Berthe <mikael@lilotux.net>
parents:
271
diff
changeset
|
3443 |
} |
238 | 3444 |
multiline = g_renew(char, multiline, len); |
3445 |
strcat(multiline, "\n"); |
|
3446 |
strcat(multiline, line); |
|
3447 |
num++; |
|
3448 |
} else { |
|
3449 |
// First message line (we skip leading empty lines) |
|
3450 |
num = 0; |
|
3451 |
if (line[0]) { |
|
419 | 3452 |
multiline = g_strdup(line); |
238 | 3453 |
num++; |
3454 |
} else |
|
3455 |
return; |
|
3456 |
} |
|
772
464be13343a9
Store most data in UTF-8 internally
Mikael Berthe <mikael@lilotux.net>
parents:
771
diff
changeset
|
3457 |
scr_LogPrint(LPRINT_NORMAL|LPRINT_NOTUTF8, |
464be13343a9
Store most data in UTF-8 internally
Mikael Berthe <mikael@lilotux.net>
parents:
771
diff
changeset
|
3458 |
"Multi-line mode: line #%d added [%.25s...", num, line); |
238 | 3459 |
} |
3460 |
||
173 | 3461 |
// scr_cmdhisto_addline() |
3462 |
// Add a line to the inputLine history |
|
1985
0870005f7efc
Add command /iline clear_history
Mikael Berthe <mikael@lilotux.net>
parents:
1977
diff
changeset
|
3463 |
static void scr_cmdhisto_addline(char *line) |
173 | 3464 |
{ |
1127
fddf2fef7b83
Add option "cmdhistory_lines"
Mikael Berthe <mikael@lilotux.net>
parents:
1122
diff
changeset
|
3465 |
int max_histo_lines; |
fddf2fef7b83
Add option "cmdhistory_lines"
Mikael Berthe <mikael@lilotux.net>
parents:
1122
diff
changeset
|
3466 |
|
fddf2fef7b83
Add option "cmdhistory_lines"
Mikael Berthe <mikael@lilotux.net>
parents:
1122
diff
changeset
|
3467 |
if (!line || !*line) |
fddf2fef7b83
Add option "cmdhistory_lines"
Mikael Berthe <mikael@lilotux.net>
parents:
1122
diff
changeset
|
3468 |
return; |
fddf2fef7b83
Add option "cmdhistory_lines"
Mikael Berthe <mikael@lilotux.net>
parents:
1122
diff
changeset
|
3469 |
|
fddf2fef7b83
Add option "cmdhistory_lines"
Mikael Berthe <mikael@lilotux.net>
parents:
1122
diff
changeset
|
3470 |
max_histo_lines = settings_opt_get_int("cmdhistory_lines"); |
fddf2fef7b83
Add option "cmdhistory_lines"
Mikael Berthe <mikael@lilotux.net>
parents:
1122
diff
changeset
|
3471 |
|
fddf2fef7b83
Add option "cmdhistory_lines"
Mikael Berthe <mikael@lilotux.net>
parents:
1122
diff
changeset
|
3472 |
if (max_histo_lines < 0) |
fddf2fef7b83
Add option "cmdhistory_lines"
Mikael Berthe <mikael@lilotux.net>
parents:
1122
diff
changeset
|
3473 |
max_histo_lines = 1; |
fddf2fef7b83
Add option "cmdhistory_lines"
Mikael Berthe <mikael@lilotux.net>
parents:
1122
diff
changeset
|
3474 |
|
fddf2fef7b83
Add option "cmdhistory_lines"
Mikael Berthe <mikael@lilotux.net>
parents:
1122
diff
changeset
|
3475 |
if (max_histo_lines) |
fddf2fef7b83
Add option "cmdhistory_lines"
Mikael Berthe <mikael@lilotux.net>
parents:
1122
diff
changeset
|
3476 |
while (cmdhisto_nblines >= (guint)max_histo_lines) { |
fddf2fef7b83
Add option "cmdhistory_lines"
Mikael Berthe <mikael@lilotux.net>
parents:
1122
diff
changeset
|
3477 |
if (cmdhisto_cur && cmdhisto_cur == cmdhisto) |
fddf2fef7b83
Add option "cmdhistory_lines"
Mikael Berthe <mikael@lilotux.net>
parents:
1122
diff
changeset
|
3478 |
break; |
fddf2fef7b83
Add option "cmdhistory_lines"
Mikael Berthe <mikael@lilotux.net>
parents:
1122
diff
changeset
|
3479 |
g_free(cmdhisto->data); |
fddf2fef7b83
Add option "cmdhistory_lines"
Mikael Berthe <mikael@lilotux.net>
parents:
1122
diff
changeset
|
3480 |
cmdhisto = g_list_delete_link(cmdhisto, cmdhisto); |
fddf2fef7b83
Add option "cmdhistory_lines"
Mikael Berthe <mikael@lilotux.net>
parents:
1122
diff
changeset
|
3481 |
cmdhisto_nblines--; |
fddf2fef7b83
Add option "cmdhistory_lines"
Mikael Berthe <mikael@lilotux.net>
parents:
1122
diff
changeset
|
3482 |
} |
173 | 3483 |
|
3484 |
cmdhisto = g_list_append(cmdhisto, g_strdup(line)); |
|
1127
fddf2fef7b83
Add option "cmdhistory_lines"
Mikael Berthe <mikael@lilotux.net>
parents:
1122
diff
changeset
|
3485 |
cmdhisto_nblines++; |
173 | 3486 |
} |
3487 |
||
1985
0870005f7efc
Add command /iline clear_history
Mikael Berthe <mikael@lilotux.net>
parents:
1977
diff
changeset
|
3488 |
// scr_cmdhisto_reset() |
0870005f7efc
Add command /iline clear_history
Mikael Berthe <mikael@lilotux.net>
parents:
1977
diff
changeset
|
3489 |
// Reset the inputLine history |
0870005f7efc
Add command /iline clear_history
Mikael Berthe <mikael@lilotux.net>
parents:
1977
diff
changeset
|
3490 |
static void scr_cmdhisto_reset(void) |
0870005f7efc
Add command /iline clear_history
Mikael Berthe <mikael@lilotux.net>
parents:
1977
diff
changeset
|
3491 |
{ |
0870005f7efc
Add command /iline clear_history
Mikael Berthe <mikael@lilotux.net>
parents:
1977
diff
changeset
|
3492 |
while (cmdhisto_nblines) { |
0870005f7efc
Add command /iline clear_history
Mikael Berthe <mikael@lilotux.net>
parents:
1977
diff
changeset
|
3493 |
g_free(cmdhisto->data); |
0870005f7efc
Add command /iline clear_history
Mikael Berthe <mikael@lilotux.net>
parents:
1977
diff
changeset
|
3494 |
cmdhisto = g_list_delete_link(cmdhisto, cmdhisto); |
0870005f7efc
Add command /iline clear_history
Mikael Berthe <mikael@lilotux.net>
parents:
1977
diff
changeset
|
3495 |
cmdhisto_nblines--; |
0870005f7efc
Add command /iline clear_history
Mikael Berthe <mikael@lilotux.net>
parents:
1977
diff
changeset
|
3496 |
} |
0870005f7efc
Add command /iline clear_history
Mikael Berthe <mikael@lilotux.net>
parents:
1977
diff
changeset
|
3497 |
cmdhisto_backup[0] = 0; |
0870005f7efc
Add command /iline clear_history
Mikael Berthe <mikael@lilotux.net>
parents:
1977
diff
changeset
|
3498 |
cmdhisto_cur = NULL; |
0870005f7efc
Add command /iline clear_history
Mikael Berthe <mikael@lilotux.net>
parents:
1977
diff
changeset
|
3499 |
} |
0870005f7efc
Add command /iline clear_history
Mikael Berthe <mikael@lilotux.net>
parents:
1977
diff
changeset
|
3500 |
|
173 | 3501 |
// scr_cmdhisto_prev() |
3502 |
// Look for previous line beginning w/ the given mask in the inputLine history |
|
175 | 3503 |
// Returns NULL if none found |
336
eb994ee40029
Make some functions static
Mikael Berthe <mikael@lilotux.net>
parents:
332
diff
changeset
|
3504 |
static const char *scr_cmdhisto_prev(char *mask, guint len) |
173 | 3505 |
{ |
3506 |
GList *hl; |
|
3507 |
if (!cmdhisto_cur) { |
|
3508 |
hl = g_list_last(cmdhisto); |
|
174 | 3509 |
if (hl) { // backup current line |
3510 |
strncpy(cmdhisto_backup, mask, INPUTLINE_LENGTH); |
|
3511 |
} |
|
173 | 3512 |
} else { |
3513 |
hl = g_list_previous(cmdhisto_cur); |
|
3514 |
} |
|
3515 |
while (hl) { |
|
3516 |
if (!strncmp((char*)hl->data, mask, len)) { |
|
3517 |
// Found a match |
|
3518 |
cmdhisto_cur = hl; |
|
3519 |
return (const char*)hl->data; |
|
3520 |
} |
|
3521 |
hl = g_list_previous(hl); |
|
3522 |
} |
|
3523 |
return NULL; |
|
3524 |
} |
|
3525 |
||
3526 |
// scr_cmdhisto_next() |
|
3527 |
// Look for next line beginning w/ the given mask in the inputLine history |
|
175 | 3528 |
// Returns NULL if none found |
336
eb994ee40029
Make some functions static
Mikael Berthe <mikael@lilotux.net>
parents:
332
diff
changeset
|
3529 |
static const char *scr_cmdhisto_next(char *mask, guint len) |
173 | 3530 |
{ |
3531 |
GList *hl; |
|
3532 |
if (!cmdhisto_cur) return NULL; |
|
3533 |
hl = cmdhisto_cur; |
|
3534 |
while ((hl = g_list_next(hl)) != NULL) |
|
3535 |
if (!strncmp((char*)hl->data, mask, len)) { |
|
3536 |
// Found a match |
|
3537 |
cmdhisto_cur = hl; |
|
3538 |
return (const char*)hl->data; |
|
3539 |
} |
|
175 | 3540 |
// If the "backuped" line matches, we'll use it |
3541 |
if (strncmp(cmdhisto_backup, mask, len)) return NULL; // No match |
|
174 | 3542 |
cmdhisto_cur = NULL; |
3543 |
return cmdhisto_backup; |
|
173 | 3544 |
} |
3545 |
||
1903
75a0a22bbf78
Fix issue #54 -- command line corruption
Mikael Berthe <mikael@lilotux.net>
parents:
1863
diff
changeset
|
3546 |
static char *_strmove(char *dst, const char *src) |
75a0a22bbf78
Fix issue #54 -- command line corruption
Mikael Berthe <mikael@lilotux.net>
parents:
1863
diff
changeset
|
3547 |
{ |
75a0a22bbf78
Fix issue #54 -- command line corruption
Mikael Berthe <mikael@lilotux.net>
parents:
1863
diff
changeset
|
3548 |
char *dest = dst; |
75a0a22bbf78
Fix issue #54 -- command line corruption
Mikael Berthe <mikael@lilotux.net>
parents:
1863
diff
changeset
|
3549 |
while ((*dest++ = *src++) != '\0') |
75a0a22bbf78
Fix issue #54 -- command line corruption
Mikael Berthe <mikael@lilotux.net>
parents:
1863
diff
changeset
|
3550 |
; |
75a0a22bbf78
Fix issue #54 -- command line corruption
Mikael Berthe <mikael@lilotux.net>
parents:
1863
diff
changeset
|
3551 |
return dest; |
75a0a22bbf78
Fix issue #54 -- command line corruption
Mikael Berthe <mikael@lilotux.net>
parents:
1863
diff
changeset
|
3552 |
} |
75a0a22bbf78
Fix issue #54 -- command line corruption
Mikael Berthe <mikael@lilotux.net>
parents:
1863
diff
changeset
|
3553 |
|
195 | 3554 |
// readline_transpose_chars() |
3555 |
// Drag the character before point forward over the character at |
|
3556 |
// point, moving point forward as well. If point is at the end of |
|
3557 |
// the line, then this transposes the two characters before point. |
|
1059 | 3558 |
void readline_transpose_chars(void) |
195 | 3559 |
{ |
930
a75f7a13df7b
UTF-8 terminal support (Reimar Döffinger)
Mikael Berthe <mikael@lilotux.net>
parents:
929
diff
changeset
|
3560 |
char *c1, *c2; |
a75f7a13df7b
UTF-8 terminal support (Reimar Döffinger)
Mikael Berthe <mikael@lilotux.net>
parents:
929
diff
changeset
|
3561 |
unsigned a, b; |
195 | 3562 |
|
3563 |
if (ptr_inputline == inputLine) return; |
|
3564 |
||
3565 |
if (!*ptr_inputline) { // We're at EOL |
|
3566 |
// 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
|
3567 |
if (ptr_inputline == prev_char(ptr_inputline, inputLine)) return; |
195 | 3568 |
// Transpose the two previous characters |
930
a75f7a13df7b
UTF-8 terminal support (Reimar Döffinger)
Mikael Berthe <mikael@lilotux.net>
parents:
929
diff
changeset
|
3569 |
c2 = prev_char(ptr_inputline, inputLine); |
a75f7a13df7b
UTF-8 terminal support (Reimar Döffinger)
Mikael Berthe <mikael@lilotux.net>
parents:
929
diff
changeset
|
3570 |
c1 = prev_char(c2, inputLine); |
a75f7a13df7b
UTF-8 terminal support (Reimar Döffinger)
Mikael Berthe <mikael@lilotux.net>
parents:
929
diff
changeset
|
3571 |
a = get_char(c1); |
a75f7a13df7b
UTF-8 terminal support (Reimar Döffinger)
Mikael Berthe <mikael@lilotux.net>
parents:
929
diff
changeset
|
3572 |
b = get_char(c2); |
a75f7a13df7b
UTF-8 terminal support (Reimar Döffinger)
Mikael Berthe <mikael@lilotux.net>
parents:
929
diff
changeset
|
3573 |
put_char(put_char(c1, b), a); |
195 | 3574 |
} else { |
196 | 3575 |
// 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
|
3576 |
c2 = ptr_inputline; |
a75f7a13df7b
UTF-8 terminal support (Reimar Döffinger)
Mikael Berthe <mikael@lilotux.net>
parents:
929
diff
changeset
|
3577 |
c1 = prev_char(c2, inputLine); |
a75f7a13df7b
UTF-8 terminal support (Reimar Döffinger)
Mikael Berthe <mikael@lilotux.net>
parents:
929
diff
changeset
|
3578 |
a = get_char(c1); |
a75f7a13df7b
UTF-8 terminal support (Reimar Döffinger)
Mikael Berthe <mikael@lilotux.net>
parents:
929
diff
changeset
|
3579 |
b = get_char(c2); |
a75f7a13df7b
UTF-8 terminal support (Reimar Döffinger)
Mikael Berthe <mikael@lilotux.net>
parents:
929
diff
changeset
|
3580 |
put_char(put_char(c1, b), a); |
195 | 3581 |
check_offset(1); |
3582 |
} |
|
3583 |
} |
|
3584 |
||
1171
03a38b7ad2e0
Add a collection of commands for key bindings (Lego12239)
Mikael Berthe <mikael@lilotux.net>
parents:
1170
diff
changeset
|
3585 |
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
|
3586 |
{ |
03a38b7ad2e0
Add a collection of commands for key bindings (Lego12239)
Mikael Berthe <mikael@lilotux.net>
parents:
1170
diff
changeset
|
3587 |
char *c, *old = ptr_inputline; |
03a38b7ad2e0
Add a collection of commands for key bindings (Lego12239)
Mikael Berthe <mikael@lilotux.net>
parents:
1170
diff
changeset
|
3588 |
int spaceallowed = 1; |
03a38b7ad2e0
Add a collection of commands for key bindings (Lego12239)
Mikael Berthe <mikael@lilotux.net>
parents:
1170
diff
changeset
|
3589 |
|
03a38b7ad2e0
Add a collection of commands for key bindings (Lego12239)
Mikael Berthe <mikael@lilotux.net>
parents:
1170
diff
changeset
|
3590 |
if (! *ptr_inputline) return; |
03a38b7ad2e0
Add a collection of commands for key bindings (Lego12239)
Mikael Berthe <mikael@lilotux.net>
parents:
1170
diff
changeset
|
3591 |
|
03a38b7ad2e0
Add a collection of commands for key bindings (Lego12239)
Mikael Berthe <mikael@lilotux.net>
parents:
1170
diff
changeset
|
3592 |
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
|
3593 |
if (!iswalnum(get_char(c))) { |
03a38b7ad2e0
Add a collection of commands for key bindings (Lego12239)
Mikael Berthe <mikael@lilotux.net>
parents:
1170
diff
changeset
|
3594 |
if (iswblank(get_char(c))) { |
03a38b7ad2e0
Add a collection of commands for key bindings (Lego12239)
Mikael Berthe <mikael@lilotux.net>
parents:
1170
diff
changeset
|
3595 |
if (!spaceallowed) break; |
03a38b7ad2e0
Add a collection of commands for key bindings (Lego12239)
Mikael Berthe <mikael@lilotux.net>
parents:
1170
diff
changeset
|
3596 |
} else spaceallowed = 0; |
03a38b7ad2e0
Add a collection of commands for key bindings (Lego12239)
Mikael Berthe <mikael@lilotux.net>
parents:
1170
diff
changeset
|
3597 |
} else spaceallowed = 0; |
03a38b7ad2e0
Add a collection of commands for key bindings (Lego12239)
Mikael Berthe <mikael@lilotux.net>
parents:
1170
diff
changeset
|
3598 |
} |
03a38b7ad2e0
Add a collection of commands for key bindings (Lego12239)
Mikael Berthe <mikael@lilotux.net>
parents:
1170
diff
changeset
|
3599 |
|
03a38b7ad2e0
Add a collection of commands for key bindings (Lego12239)
Mikael Berthe <mikael@lilotux.net>
parents:
1170
diff
changeset
|
3600 |
// Modify the line |
03a38b7ad2e0
Add a collection of commands for key bindings (Lego12239)
Mikael Berthe <mikael@lilotux.net>
parents:
1170
diff
changeset
|
3601 |
for (;;) { |
03a38b7ad2e0
Add a collection of commands for key bindings (Lego12239)
Mikael Berthe <mikael@lilotux.net>
parents:
1170
diff
changeset
|
3602 |
*old = *c++; |
03a38b7ad2e0
Add a collection of commands for key bindings (Lego12239)
Mikael Berthe <mikael@lilotux.net>
parents:
1170
diff
changeset
|
3603 |
if (!*old++) break; |
03a38b7ad2e0
Add a collection of commands for key bindings (Lego12239)
Mikael Berthe <mikael@lilotux.net>
parents:
1170
diff
changeset
|
3604 |
} |
03a38b7ad2e0
Add a collection of commands for key bindings (Lego12239)
Mikael Berthe <mikael@lilotux.net>
parents:
1170
diff
changeset
|
3605 |
} |
03a38b7ad2e0
Add a collection of commands for key bindings (Lego12239)
Mikael Berthe <mikael@lilotux.net>
parents:
1170
diff
changeset
|
3606 |
|
195 | 3607 |
// readline_backward_kill_word() |
194 | 3608 |
// Kill the word before the cursor, in input line |
1059 | 3609 |
void readline_backward_kill_word(void) |
194 | 3610 |
{ |
3611 |
char *c, *old = ptr_inputline; |
|
3612 |
int spaceallowed = 1; |
|
3613 |
||
3614 |
if (ptr_inputline == inputLine) return; |
|
3615 |
||
930
a75f7a13df7b
UTF-8 terminal support (Reimar Döffinger)
Mikael Berthe <mikael@lilotux.net>
parents:
929
diff
changeset
|
3616 |
c = prev_char(ptr_inputline, inputLine); |
a75f7a13df7b
UTF-8 terminal support (Reimar Döffinger)
Mikael Berthe <mikael@lilotux.net>
parents:
929
diff
changeset
|
3617 |
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
|
3618 |
if (!iswalnum(get_char(c))) { |
933
ede9260be93d
Input line: Improve word-related functions
Mikael Berthe <mikael@lilotux.net>
parents:
932
diff
changeset
|
3619 |
if (iswblank(get_char(c))) { |
194 | 3620 |
if (!spaceallowed) break; |
933
ede9260be93d
Input line: Improve word-related functions
Mikael Berthe <mikael@lilotux.net>
parents:
932
diff
changeset
|
3621 |
} else spaceallowed = 0; |
194 | 3622 |
} 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
|
3623 |
} |
194 | 3624 |
|
1280
8b621f980321
readline_backward_kill_word() makes a stop at the "command" character
Mikael Berthe <mikael@lilotux.net>
parents:
1279
diff
changeset
|
3625 |
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
|
3626 |
c = next_char(c); |
2072
0722fe4b7580
Small fix for readline_backward_kill_word()
Mikael Berthe <mikael@lilotux.net>
parents:
2047
diff
changeset
|
3627 |
} else if (c != inputLine || (iswblank(get_char(c)) && !spaceallowed)) { |
930
a75f7a13df7b
UTF-8 terminal support (Reimar Döffinger)
Mikael Berthe <mikael@lilotux.net>
parents:
929
diff
changeset
|
3628 |
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
|
3629 |
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
|
3630 |
} |
194 | 3631 |
|
3632 |
// Modify the line |
|
3633 |
ptr_inputline = c; |
|
1903
75a0a22bbf78
Fix issue #54 -- command line corruption
Mikael Berthe <mikael@lilotux.net>
parents:
1863
diff
changeset
|
3634 |
_strmove(ptr_inputline, old); |
195 | 3635 |
check_offset(-1); |
194 | 3636 |
} |
3637 |
||
759
a681dc477c7f
Add readline_backward_word and readline_forward_word (Ctrl-Left/Ctrl-Right)
Mikael Berthe <mikael@lilotux.net>
parents:
758
diff
changeset
|
3638 |
// readline_backward_word() |
2074
e04b6dfbb054
Some whitespace cleanup
Mikael Berthe <mikael@lilotux.net>
parents:
2072
diff
changeset
|
3639 |
// Move back to the start of the current or previous word |
1059 | 3640 |
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
|
3641 |
{ |
1172
334ae9f498f1
Add some more iline functions (Lego12239)
Mikael Berthe <mikael@lilotux.net>
parents:
1171
diff
changeset
|
3642 |
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
|
3643 |
|
a681dc477c7f
Add readline_backward_word and readline_forward_word (Ctrl-Left/Ctrl-Right)
Mikael Berthe <mikael@lilotux.net>
parents:
758
diff
changeset
|
3644 |
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
|
3645 |
|
1172
334ae9f498f1
Add some more iline functions (Lego12239)
Mikael Berthe <mikael@lilotux.net>
parents:
1171
diff
changeset
|
3646 |
if (iswalnum(get_char(ptr_inputline)) && |
334ae9f498f1
Add some more iline functions (Lego12239)
Mikael Berthe <mikael@lilotux.net>
parents:
1171
diff
changeset
|
3647 |
!iswalnum(get_char(prev_char(ptr_inputline, inputLine)))) |
334ae9f498f1
Add some more iline functions (Lego12239)
Mikael Berthe <mikael@lilotux.net>
parents:
1171
diff
changeset
|
3648 |
i--; |
334ae9f498f1
Add some more iline functions (Lego12239)
Mikael Berthe <mikael@lilotux.net>
parents:
1171
diff
changeset
|
3649 |
|
1333
e30a9d907105
Minor coding style adjustments
Mikael Berthe <mikael@lilotux.net>
parents:
1314
diff
changeset
|
3650 |
for ( ; |
e30a9d907105
Minor coding style adjustments
Mikael Berthe <mikael@lilotux.net>
parents:
1314
diff
changeset
|
3651 |
ptr_inputline > inputLine; |
e30a9d907105
Minor coding style adjustments
Mikael Berthe <mikael@lilotux.net>
parents:
1314
diff
changeset
|
3652 |
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
|
3653 |
if (!iswalnum(get_char(ptr_inputline))) { |
1172
334ae9f498f1
Add some more iline functions (Lego12239)
Mikael Berthe <mikael@lilotux.net>
parents:
1171
diff
changeset
|
3654 |
if (i) { |
334ae9f498f1
Add some more iline functions (Lego12239)
Mikael Berthe <mikael@lilotux.net>
parents:
1171
diff
changeset
|
3655 |
ptr_inputline = next_char(ptr_inputline); |
334ae9f498f1
Add some more iline functions (Lego12239)
Mikael Berthe <mikael@lilotux.net>
parents:
1171
diff
changeset
|
3656 |
break; |
334ae9f498f1
Add some more iline functions (Lego12239)
Mikael Berthe <mikael@lilotux.net>
parents:
1171
diff
changeset
|
3657 |
} |
334ae9f498f1
Add some more iline functions (Lego12239)
Mikael Berthe <mikael@lilotux.net>
parents:
1171
diff
changeset
|
3658 |
} 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
|
3659 |
} |
a681dc477c7f
Add readline_backward_word and readline_forward_word (Ctrl-Left/Ctrl-Right)
Mikael Berthe <mikael@lilotux.net>
parents:
758
diff
changeset
|
3660 |
|
a681dc477c7f
Add readline_backward_word and readline_forward_word (Ctrl-Left/Ctrl-Right)
Mikael Berthe <mikael@lilotux.net>
parents:
758
diff
changeset
|
3661 |
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
|
3662 |
} |
a681dc477c7f
Add readline_backward_word and readline_forward_word (Ctrl-Left/Ctrl-Right)
Mikael Berthe <mikael@lilotux.net>
parents:
758
diff
changeset
|
3663 |
|
a681dc477c7f
Add readline_backward_word and readline_forward_word (Ctrl-Left/Ctrl-Right)
Mikael Berthe <mikael@lilotux.net>
parents:
758
diff
changeset
|
3664 |
// 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
|
3665 |
// Move forward to the end of the next word |
1059 | 3666 |
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
|
3667 |
{ |
1172
334ae9f498f1
Add some more iline functions (Lego12239)
Mikael Berthe <mikael@lilotux.net>
parents:
1171
diff
changeset
|
3668 |
int stopsymbol_allowed = 1; |
334ae9f498f1
Add some more iline functions (Lego12239)
Mikael Berthe <mikael@lilotux.net>
parents:
1171
diff
changeset
|
3669 |
|
334ae9f498f1
Add some more iline functions (Lego12239)
Mikael Berthe <mikael@lilotux.net>
parents:
1171
diff
changeset
|
3670 |
while (*ptr_inputline) { |
334ae9f498f1
Add some more iline functions (Lego12239)
Mikael Berthe <mikael@lilotux.net>
parents:
1171
diff
changeset
|
3671 |
if (!iswalnum(get_char(ptr_inputline))) { |
334ae9f498f1
Add some more iline functions (Lego12239)
Mikael Berthe <mikael@lilotux.net>
parents:
1171
diff
changeset
|
3672 |
if (!stopsymbol_allowed) break; |
334ae9f498f1
Add some more iline functions (Lego12239)
Mikael Berthe <mikael@lilotux.net>
parents:
1171
diff
changeset
|
3673 |
} else stopsymbol_allowed = 0; |
334ae9f498f1
Add some more iline functions (Lego12239)
Mikael Berthe <mikael@lilotux.net>
parents:
1171
diff
changeset
|
3674 |
ptr_inputline = next_char(ptr_inputline); |
334ae9f498f1
Add some more iline functions (Lego12239)
Mikael Berthe <mikael@lilotux.net>
parents:
1171
diff
changeset
|
3675 |
} |
334ae9f498f1
Add some more iline functions (Lego12239)
Mikael Berthe <mikael@lilotux.net>
parents:
1171
diff
changeset
|
3676 |
|
334ae9f498f1
Add some more iline functions (Lego12239)
Mikael Berthe <mikael@lilotux.net>
parents:
1171
diff
changeset
|
3677 |
check_offset(1); |
334ae9f498f1
Add some more iline functions (Lego12239)
Mikael Berthe <mikael@lilotux.net>
parents:
1171
diff
changeset
|
3678 |
} |
334ae9f498f1
Add some more iline functions (Lego12239)
Mikael Berthe <mikael@lilotux.net>
parents:
1171
diff
changeset
|
3679 |
|
334ae9f498f1
Add some more iline functions (Lego12239)
Mikael Berthe <mikael@lilotux.net>
parents:
1171
diff
changeset
|
3680 |
void readline_updowncase_word(int upcase) |
334ae9f498f1
Add some more iline functions (Lego12239)
Mikael Berthe <mikael@lilotux.net>
parents:
1171
diff
changeset
|
3681 |
{ |
334ae9f498f1
Add some more iline functions (Lego12239)
Mikael Berthe <mikael@lilotux.net>
parents:
1171
diff
changeset
|
3682 |
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
|
3683 |
|
a681dc477c7f
Add readline_backward_word and readline_forward_word (Ctrl-Left/Ctrl-Right)
Mikael Berthe <mikael@lilotux.net>
parents:
758
diff
changeset
|
3684 |
while (*ptr_inputline) { |
930
a75f7a13df7b
UTF-8 terminal support (Reimar Döffinger)
Mikael Berthe <mikael@lilotux.net>
parents:
929
diff
changeset
|
3685 |
if (!iswalnum(get_char(ptr_inputline))) { |
1172
334ae9f498f1
Add some more iline functions (Lego12239)
Mikael Berthe <mikael@lilotux.net>
parents:
1171
diff
changeset
|
3686 |
if (!stopsymbol_allowed) break; |
334ae9f498f1
Add some more iline functions (Lego12239)
Mikael Berthe <mikael@lilotux.net>
parents:
1171
diff
changeset
|
3687 |
} else { |
334ae9f498f1
Add some more iline functions (Lego12239)
Mikael Berthe <mikael@lilotux.net>
parents:
1171
diff
changeset
|
3688 |
stopsymbol_allowed = 0; |
334ae9f498f1
Add some more iline functions (Lego12239)
Mikael Berthe <mikael@lilotux.net>
parents:
1171
diff
changeset
|
3689 |
if (upcase) |
1748
51a23403cc80
Fix readline_updowncase_word() and readline_capitalize_word() wrt UTF-8
Mikael Berthe <mikael@lilotux.net>
parents:
1743
diff
changeset
|
3690 |
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
|
3691 |
else |
1748
51a23403cc80
Fix readline_updowncase_word() and readline_capitalize_word() wrt UTF-8
Mikael Berthe <mikael@lilotux.net>
parents:
1743
diff
changeset
|
3692 |
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
|
3693 |
} |
334ae9f498f1
Add some more iline functions (Lego12239)
Mikael Berthe <mikael@lilotux.net>
parents:
1171
diff
changeset
|
3694 |
ptr_inputline = next_char(ptr_inputline); |
334ae9f498f1
Add some more iline functions (Lego12239)
Mikael Berthe <mikael@lilotux.net>
parents:
1171
diff
changeset
|
3695 |
} |
334ae9f498f1
Add some more iline functions (Lego12239)
Mikael Berthe <mikael@lilotux.net>
parents:
1171
diff
changeset
|
3696 |
|
334ae9f498f1
Add some more iline functions (Lego12239)
Mikael Berthe <mikael@lilotux.net>
parents:
1171
diff
changeset
|
3697 |
check_offset(1); |
334ae9f498f1
Add some more iline functions (Lego12239)
Mikael Berthe <mikael@lilotux.net>
parents:
1171
diff
changeset
|
3698 |
} |
334ae9f498f1
Add some more iline functions (Lego12239)
Mikael Berthe <mikael@lilotux.net>
parents:
1171
diff
changeset
|
3699 |
|
334ae9f498f1
Add some more iline functions (Lego12239)
Mikael Berthe <mikael@lilotux.net>
parents:
1171
diff
changeset
|
3700 |
void readline_capitalize_word(void) |
334ae9f498f1
Add some more iline functions (Lego12239)
Mikael Berthe <mikael@lilotux.net>
parents:
1171
diff
changeset
|
3701 |
{ |
334ae9f498f1
Add some more iline functions (Lego12239)
Mikael Berthe <mikael@lilotux.net>
parents:
1171
diff
changeset
|
3702 |
int stopsymbol_allowed = 1; |
334ae9f498f1
Add some more iline functions (Lego12239)
Mikael Berthe <mikael@lilotux.net>
parents:
1171
diff
changeset
|
3703 |
int upcased = 0; |
334ae9f498f1
Add some more iline functions (Lego12239)
Mikael Berthe <mikael@lilotux.net>
parents:
1171
diff
changeset
|
3704 |
|
334ae9f498f1
Add some more iline functions (Lego12239)
Mikael Berthe <mikael@lilotux.net>
parents:
1171
diff
changeset
|
3705 |
while (*ptr_inputline) { |
334ae9f498f1
Add some more iline functions (Lego12239)
Mikael Berthe <mikael@lilotux.net>
parents:
1171
diff
changeset
|
3706 |
if (!iswalnum(get_char(ptr_inputline))) { |
334ae9f498f1
Add some more iline functions (Lego12239)
Mikael Berthe <mikael@lilotux.net>
parents:
1171
diff
changeset
|
3707 |
if (!stopsymbol_allowed) break; |
334ae9f498f1
Add some more iline functions (Lego12239)
Mikael Berthe <mikael@lilotux.net>
parents:
1171
diff
changeset
|
3708 |
} else { |
334ae9f498f1
Add some more iline functions (Lego12239)
Mikael Berthe <mikael@lilotux.net>
parents:
1171
diff
changeset
|
3709 |
stopsymbol_allowed = 0; |
334ae9f498f1
Add some more iline functions (Lego12239)
Mikael Berthe <mikael@lilotux.net>
parents:
1171
diff
changeset
|
3710 |
if (!upcased) { |
1748
51a23403cc80
Fix readline_updowncase_word() and readline_capitalize_word() wrt UTF-8
Mikael Berthe <mikael@lilotux.net>
parents:
1743
diff
changeset
|
3711 |
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
|
3712 |
upcased = 1; |
1748
51a23403cc80
Fix readline_updowncase_word() and readline_capitalize_word() wrt UTF-8
Mikael Berthe <mikael@lilotux.net>
parents:
1743
diff
changeset
|
3713 |
} else |
51a23403cc80
Fix readline_updowncase_word() and readline_capitalize_word() wrt UTF-8
Mikael Berthe <mikael@lilotux.net>
parents:
1743
diff
changeset
|
3714 |
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
|
3715 |
} |
334ae9f498f1
Add some more iline functions (Lego12239)
Mikael Berthe <mikael@lilotux.net>
parents:
1171
diff
changeset
|
3716 |
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
|
3717 |
} |
a681dc477c7f
Add readline_backward_word and readline_forward_word (Ctrl-Left/Ctrl-Right)
Mikael Berthe <mikael@lilotux.net>
parents:
758
diff
changeset
|
3718 |
|
a681dc477c7f
Add readline_backward_word and readline_forward_word (Ctrl-Left/Ctrl-Right)
Mikael Berthe <mikael@lilotux.net>
parents:
758
diff
changeset
|
3719 |
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
|
3720 |
} |
a681dc477c7f
Add readline_backward_word and readline_forward_word (Ctrl-Left/Ctrl-Right)
Mikael Berthe <mikael@lilotux.net>
parents:
758
diff
changeset
|
3721 |
|
1171
03a38b7ad2e0
Add a collection of commands for key bindings (Lego12239)
Mikael Berthe <mikael@lilotux.net>
parents:
1170
diff
changeset
|
3722 |
void readline_backward_char(void) |
03a38b7ad2e0
Add a collection of commands for key bindings (Lego12239)
Mikael Berthe <mikael@lilotux.net>
parents:
1170
diff
changeset
|
3723 |
{ |
03a38b7ad2e0
Add a collection of commands for key bindings (Lego12239)
Mikael Berthe <mikael@lilotux.net>
parents:
1170
diff
changeset
|
3724 |
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
|
3725 |
|
03a38b7ad2e0
Add a collection of commands for key bindings (Lego12239)
Mikael Berthe <mikael@lilotux.net>
parents:
1170
diff
changeset
|
3726 |
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
|
3727 |
check_offset(-1); |
03a38b7ad2e0
Add a collection of commands for key bindings (Lego12239)
Mikael Berthe <mikael@lilotux.net>
parents:
1170
diff
changeset
|
3728 |
} |
03a38b7ad2e0
Add a collection of commands for key bindings (Lego12239)
Mikael Berthe <mikael@lilotux.net>
parents:
1170
diff
changeset
|
3729 |
|
03a38b7ad2e0
Add a collection of commands for key bindings (Lego12239)
Mikael Berthe <mikael@lilotux.net>
parents:
1170
diff
changeset
|
3730 |
void readline_forward_char(void) |
03a38b7ad2e0
Add a collection of commands for key bindings (Lego12239)
Mikael Berthe <mikael@lilotux.net>
parents:
1170
diff
changeset
|
3731 |
{ |
03a38b7ad2e0
Add a collection of commands for key bindings (Lego12239)
Mikael Berthe <mikael@lilotux.net>
parents:
1170
diff
changeset
|
3732 |
if (!*ptr_inputline) return; |
03a38b7ad2e0
Add a collection of commands for key bindings (Lego12239)
Mikael Berthe <mikael@lilotux.net>
parents:
1170
diff
changeset
|
3733 |
|
03a38b7ad2e0
Add a collection of commands for key bindings (Lego12239)
Mikael Berthe <mikael@lilotux.net>
parents:
1170
diff
changeset
|
3734 |
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
|
3735 |
check_offset(1); |
03a38b7ad2e0
Add a collection of commands for key bindings (Lego12239)
Mikael Berthe <mikael@lilotux.net>
parents:
1170
diff
changeset
|
3736 |
} |
03a38b7ad2e0
Add a collection of commands for key bindings (Lego12239)
Mikael Berthe <mikael@lilotux.net>
parents:
1170
diff
changeset
|
3737 |
|
1177
10733d7de004
Refactor readline_accept_line() and readline_accept_line_down_hist()
Mikael Berthe <mikael@lilotux.net>
parents:
1176
diff
changeset
|
3738 |
// 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
|
3739 |
// Validate current command line. |
10733d7de004
Refactor readline_accept_line() and readline_accept_line_down_hist()
Mikael Berthe <mikael@lilotux.net>
parents:
1176
diff
changeset
|
3740 |
// If down_history is true, load the next history line. |
2164 | 3741 |
void readline_accept_line(int down_history) |
1172
334ae9f498f1
Add some more iline functions (Lego12239)
Mikael Berthe <mikael@lilotux.net>
parents:
1171
diff
changeset
|
3742 |
{ |
1780
e4378fbab5d7
Major API cleanup - bump API to 4
Mikael Berthe <mikael@lilotux.net>
parents:
1761
diff
changeset
|
3743 |
scr_check_auto_away(TRUE); |
1996
7837d5a3f509
Going back to the first buddy with /roster next_unread when there is no more unread messages.
Simon Jacquin
parents:
1985
diff
changeset
|
3744 |
last_activity_buddy = current_buddy; |
2164 | 3745 |
process_line(inputLine); |
1172
334ae9f498f1
Add some more iline functions (Lego12239)
Mikael Berthe <mikael@lilotux.net>
parents:
1171
diff
changeset
|
3746 |
// Add line to history |
334ae9f498f1
Add some more iline functions (Lego12239)
Mikael Berthe <mikael@lilotux.net>
parents:
1171
diff
changeset
|
3747 |
scr_cmdhisto_addline(inputLine); |
334ae9f498f1
Add some more iline functions (Lego12239)
Mikael Berthe <mikael@lilotux.net>
parents:
1171
diff
changeset
|
3748 |
// Reset the line |
334ae9f498f1
Add some more iline functions (Lego12239)
Mikael Berthe <mikael@lilotux.net>
parents:
1171
diff
changeset
|
3749 |
ptr_inputline = inputLine; |
334ae9f498f1
Add some more iline functions (Lego12239)
Mikael Berthe <mikael@lilotux.net>
parents:
1171
diff
changeset
|
3750 |
*ptr_inputline = 0; |
334ae9f498f1
Add some more iline functions (Lego12239)
Mikael Berthe <mikael@lilotux.net>
parents:
1171
diff
changeset
|
3751 |
inputline_offset = 0; |
334ae9f498f1
Add some more iline functions (Lego12239)
Mikael Berthe <mikael@lilotux.net>
parents:
1171
diff
changeset
|
3752 |
|
1177
10733d7de004
Refactor readline_accept_line() and readline_accept_line_down_hist()
Mikael Berthe <mikael@lilotux.net>
parents:
1176
diff
changeset
|
3753 |
if (down_history) { |
10733d7de004
Refactor readline_accept_line() and readline_accept_line_down_hist()
Mikael Berthe <mikael@lilotux.net>
parents:
1176
diff
changeset
|
3754 |
// 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
|
3755 |
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
|
3756 |
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
|
3757 |
// Reset backup history line |
10733d7de004
Refactor readline_accept_line() and readline_accept_line_down_hist()
Mikael Berthe <mikael@lilotux.net>
parents:
1176
diff
changeset
|
3758 |
cmdhisto_backup[0] = 0; |
10733d7de004
Refactor readline_accept_line() and readline_accept_line_down_hist()
Mikael Berthe <mikael@lilotux.net>
parents:
1176
diff
changeset
|
3759 |
} else { |
10733d7de004
Refactor readline_accept_line() and readline_accept_line_down_hist()
Mikael Berthe <mikael@lilotux.net>
parents:
1176
diff
changeset
|
3760 |
// Reset history line pointer |
10733d7de004
Refactor readline_accept_line() and readline_accept_line_down_hist()
Mikael Berthe <mikael@lilotux.net>
parents:
1176
diff
changeset
|
3761 |
cmdhisto_cur = NULL; |
10733d7de004
Refactor readline_accept_line() and readline_accept_line_down_hist()
Mikael Berthe <mikael@lilotux.net>
parents:
1176
diff
changeset
|
3762 |
} |
1172
334ae9f498f1
Add some more iline functions (Lego12239)
Mikael Berthe <mikael@lilotux.net>
parents:
1171
diff
changeset
|
3763 |
} |
334ae9f498f1
Add some more iline functions (Lego12239)
Mikael Berthe <mikael@lilotux.net>
parents:
1171
diff
changeset
|
3764 |
|
1985
0870005f7efc
Add command /iline clear_history
Mikael Berthe <mikael@lilotux.net>
parents:
1977
diff
changeset
|
3765 |
// readline_clear_history() |
0870005f7efc
Add command /iline clear_history
Mikael Berthe <mikael@lilotux.net>
parents:
1977
diff
changeset
|
3766 |
// Clear command line history. |
0870005f7efc
Add command /iline clear_history
Mikael Berthe <mikael@lilotux.net>
parents:
1977
diff
changeset
|
3767 |
void readline_clear_history(void) |
0870005f7efc
Add command /iline clear_history
Mikael Berthe <mikael@lilotux.net>
parents:
1977
diff
changeset
|
3768 |
{ |
0870005f7efc
Add command /iline clear_history
Mikael Berthe <mikael@lilotux.net>
parents:
1977
diff
changeset
|
3769 |
scr_cmdhisto_reset(); |
0870005f7efc
Add command /iline clear_history
Mikael Berthe <mikael@lilotux.net>
parents:
1977
diff
changeset
|
3770 |
} |
0870005f7efc
Add command /iline clear_history
Mikael Berthe <mikael@lilotux.net>
parents:
1977
diff
changeset
|
3771 |
|
1172
334ae9f498f1
Add some more iline functions (Lego12239)
Mikael Berthe <mikael@lilotux.net>
parents:
1171
diff
changeset
|
3772 |
void readline_cancel_completion(void) |
334ae9f498f1
Add some more iline functions (Lego12239)
Mikael Berthe <mikael@lilotux.net>
parents:
1171
diff
changeset
|
3773 |
{ |
334ae9f498f1
Add some more iline functions (Lego12239)
Mikael Berthe <mikael@lilotux.net>
parents:
1171
diff
changeset
|
3774 |
scr_cancel_current_completion(); |
334ae9f498f1
Add some more iline functions (Lego12239)
Mikael Berthe <mikael@lilotux.net>
parents:
1171
diff
changeset
|
3775 |
scr_end_current_completion(); |
334ae9f498f1
Add some more iline functions (Lego12239)
Mikael Berthe <mikael@lilotux.net>
parents:
1171
diff
changeset
|
3776 |
check_offset(-1); |
334ae9f498f1
Add some more iline functions (Lego12239)
Mikael Berthe <mikael@lilotux.net>
parents:
1171
diff
changeset
|
3777 |
} |
334ae9f498f1
Add some more iline functions (Lego12239)
Mikael Berthe <mikael@lilotux.net>
parents:
1171
diff
changeset
|
3778 |
|
2143
2f294c2b6778
Add a backward completion (Oleg)
Mikael Berthe <mikael@lilotux.net>
parents:
2136
diff
changeset
|
3779 |
void readline_do_completion(gboolean fwd) |
1172
334ae9f498f1
Add some more iline functions (Lego12239)
Mikael Berthe <mikael@lilotux.net>
parents:
1171
diff
changeset
|
3780 |
{ |
334ae9f498f1
Add some more iline functions (Lego12239)
Mikael Berthe <mikael@lilotux.net>
parents:
1171
diff
changeset
|
3781 |
int i, n; |
334ae9f498f1
Add some more iline functions (Lego12239)
Mikael Berthe <mikael@lilotux.net>
parents:
1171
diff
changeset
|
3782 |
|
1413 | 3783 |
if (multimode != 2) { |
1172
334ae9f498f1
Add some more iline functions (Lego12239)
Mikael Berthe <mikael@lilotux.net>
parents:
1171
diff
changeset
|
3784 |
// Not in verbatim multi-line mode |
2143
2f294c2b6778
Add a backward completion (Oleg)
Mikael Berthe <mikael@lilotux.net>
parents:
2136
diff
changeset
|
3785 |
scr_handle_tab(fwd); |
1172
334ae9f498f1
Add some more iline functions (Lego12239)
Mikael Berthe <mikael@lilotux.net>
parents:
1171
diff
changeset
|
3786 |
} else { |
334ae9f498f1
Add some more iline functions (Lego12239)
Mikael Berthe <mikael@lilotux.net>
parents:
1171
diff
changeset
|
3787 |
// Verbatim multi-line mode: expand tab |
334ae9f498f1
Add some more iline functions (Lego12239)
Mikael Berthe <mikael@lilotux.net>
parents:
1171
diff
changeset
|
3788 |
char tabstr[9]; |
334ae9f498f1
Add some more iline functions (Lego12239)
Mikael Berthe <mikael@lilotux.net>
parents:
1171
diff
changeset
|
3789 |
n = 8 - (ptr_inputline - inputLine) % 8; |
334ae9f498f1
Add some more iline functions (Lego12239)
Mikael Berthe <mikael@lilotux.net>
parents:
1171
diff
changeset
|
3790 |
for (i = 0; i < n; i++) |
334ae9f498f1
Add some more iline functions (Lego12239)
Mikael Berthe <mikael@lilotux.net>
parents:
1171
diff
changeset
|
3791 |
tabstr[i] = ' '; |
334ae9f498f1
Add some more iline functions (Lego12239)
Mikael Berthe <mikael@lilotux.net>
parents:
1171
diff
changeset
|
3792 |
tabstr[i] = '\0'; |
334ae9f498f1
Add some more iline functions (Lego12239)
Mikael Berthe <mikael@lilotux.net>
parents:
1171
diff
changeset
|
3793 |
scr_insert_text(tabstr); |
334ae9f498f1
Add some more iline functions (Lego12239)
Mikael Berthe <mikael@lilotux.net>
parents:
1171
diff
changeset
|
3794 |
} |
334ae9f498f1
Add some more iline functions (Lego12239)
Mikael Berthe <mikael@lilotux.net>
parents:
1171
diff
changeset
|
3795 |
check_offset(0); |
334ae9f498f1
Add some more iline functions (Lego12239)
Mikael Berthe <mikael@lilotux.net>
parents:
1171
diff
changeset
|
3796 |
} |
334ae9f498f1
Add some more iline functions (Lego12239)
Mikael Berthe <mikael@lilotux.net>
parents:
1171
diff
changeset
|
3797 |
|
334ae9f498f1
Add some more iline functions (Lego12239)
Mikael Berthe <mikael@lilotux.net>
parents:
1171
diff
changeset
|
3798 |
void readline_refresh_screen(void) |
334ae9f498f1
Add some more iline functions (Lego12239)
Mikael Berthe <mikael@lilotux.net>
parents:
1171
diff
changeset
|
3799 |
{ |
1780
e4378fbab5d7
Major API cleanup - bump API to 4
Mikael Berthe <mikael@lilotux.net>
parents:
1761
diff
changeset
|
3800 |
scr_check_auto_away(TRUE); |
2211
902f271743b0
Make readline_refresh_screen() re-enable the keypad
Mikael Berthe <mikael@lilotux.net>
parents:
2190
diff
changeset
|
3801 |
keypad(inputWnd, TRUE); |
1780
e4378fbab5d7
Major API cleanup - bump API to 4
Mikael Berthe <mikael@lilotux.net>
parents:
1761
diff
changeset
|
3802 |
parse_colors(); |
2231
387cea2a1a81
Fix resizing with --enable-sigwinch
Mikael Berthe <mikael@lilotux.net>
parents:
2226
diff
changeset
|
3803 |
scr_resize(); |
1172
334ae9f498f1
Add some more iline functions (Lego12239)
Mikael Berthe <mikael@lilotux.net>
parents:
1171
diff
changeset
|
3804 |
redrawwin(stdscr); |
334ae9f498f1
Add some more iline functions (Lego12239)
Mikael Berthe <mikael@lilotux.net>
parents:
1171
diff
changeset
|
3805 |
} |
334ae9f498f1
Add some more iline functions (Lego12239)
Mikael Berthe <mikael@lilotux.net>
parents:
1171
diff
changeset
|
3806 |
|
1503
c74cfe7fd848
Add option --show-roster to command chat_disable.
Mikael Berthe <mikael@lilotux.net>
parents:
1502
diff
changeset
|
3807 |
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
|
3808 |
{ |
1780
e4378fbab5d7
Major API cleanup - bump API to 4
Mikael Berthe <mikael@lilotux.net>
parents:
1761
diff
changeset
|
3809 |
scr_check_auto_away(TRUE); |
1950
aec86670047b
Automatically set readmark flag
Mikael Berthe <mikael@lilotux.net>
parents:
1949
diff
changeset
|
3810 |
if (chatmode) |
aec86670047b
Automatically set readmark flag
Mikael Berthe <mikael@lilotux.net>
parents:
1949
diff
changeset
|
3811 |
scr_buffer_readmark(TRUE); |
1172
334ae9f498f1
Add some more iline functions (Lego12239)
Mikael Berthe <mikael@lilotux.net>
parents:
1171
diff
changeset
|
3812 |
currentWindow = NULL; |
334ae9f498f1
Add some more iline functions (Lego12239)
Mikael Berthe <mikael@lilotux.net>
parents:
1171
diff
changeset
|
3813 |
chatmode = FALSE; |
334ae9f498f1
Add some more iline functions (Lego12239)
Mikael Berthe <mikael@lilotux.net>
parents:
1171
diff
changeset
|
3814 |
if (current_buddy) |
334ae9f498f1
Add some more iline functions (Lego12239)
Mikael Berthe <mikael@lilotux.net>
parents:
1171
diff
changeset
|
3815 |
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
|
3816 |
if (show_roster) |
1780
e4378fbab5d7
Major API cleanup - bump API to 4
Mikael Berthe <mikael@lilotux.net>
parents:
1761
diff
changeset
|
3817 |
scr_roster_visibility(1); |
e4378fbab5d7
Major API cleanup - bump API to 4
Mikael Berthe <mikael@lilotux.net>
parents:
1761
diff
changeset
|
3818 |
scr_update_chat_status(FALSE); |
1172
334ae9f498f1
Add some more iline functions (Lego12239)
Mikael Berthe <mikael@lilotux.net>
parents:
1171
diff
changeset
|
3819 |
top_panel(chatPanel); |
334ae9f498f1
Add some more iline functions (Lego12239)
Mikael Berthe <mikael@lilotux.net>
parents:
1171
diff
changeset
|
3820 |
top_panel(inputPanel); |
334ae9f498f1
Add some more iline functions (Lego12239)
Mikael Berthe <mikael@lilotux.net>
parents:
1171
diff
changeset
|
3821 |
update_panels(); |
334ae9f498f1
Add some more iline functions (Lego12239)
Mikael Berthe <mikael@lilotux.net>
parents:
1171
diff
changeset
|
3822 |
} |
334ae9f498f1
Add some more iline functions (Lego12239)
Mikael Berthe <mikael@lilotux.net>
parents:
1171
diff
changeset
|
3823 |
|
1190
be06bbe7e449
Add readline_hist_beginning_search_bwd/fwd functions
Mikael Berthe <mikael@lilotux.net>
parents:
1187
diff
changeset
|
3824 |
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
|
3825 |
{ |
03a38b7ad2e0
Add a collection of commands for key bindings (Lego12239)
Mikael Berthe <mikael@lilotux.net>
parents:
1170
diff
changeset
|
3826 |
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
|
3827 |
if (l) strcpy(inputLine, l); |
03a38b7ad2e0
Add a collection of commands for key bindings (Lego12239)
Mikael Berthe <mikael@lilotux.net>
parents:
1170
diff
changeset
|
3828 |
} |
03a38b7ad2e0
Add a collection of commands for key bindings (Lego12239)
Mikael Berthe <mikael@lilotux.net>
parents:
1170
diff
changeset
|
3829 |
|
1190
be06bbe7e449
Add readline_hist_beginning_search_bwd/fwd functions
Mikael Berthe <mikael@lilotux.net>
parents:
1187
diff
changeset
|
3830 |
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
|
3831 |
{ |
03a38b7ad2e0
Add a collection of commands for key bindings (Lego12239)
Mikael Berthe <mikael@lilotux.net>
parents:
1170
diff
changeset
|
3832 |
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
|
3833 |
if (l) strcpy(inputLine, l); |
03a38b7ad2e0
Add a collection of commands for key bindings (Lego12239)
Mikael Berthe <mikael@lilotux.net>
parents:
1170
diff
changeset
|
3834 |
} |
03a38b7ad2e0
Add a collection of commands for key bindings (Lego12239)
Mikael Berthe <mikael@lilotux.net>
parents:
1170
diff
changeset
|
3835 |
|
1190
be06bbe7e449
Add readline_hist_beginning_search_bwd/fwd functions
Mikael Berthe <mikael@lilotux.net>
parents:
1187
diff
changeset
|
3836 |
void readline_hist_prev(void) |
be06bbe7e449
Add readline_hist_beginning_search_bwd/fwd functions
Mikael Berthe <mikael@lilotux.net>
parents:
1187
diff
changeset
|
3837 |
{ |
be06bbe7e449
Add readline_hist_beginning_search_bwd/fwd functions
Mikael Berthe <mikael@lilotux.net>
parents:
1187
diff
changeset
|
3838 |
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
|
3839 |
if (l) { |
be06bbe7e449
Add readline_hist_beginning_search_bwd/fwd functions
Mikael Berthe <mikael@lilotux.net>
parents:
1187
diff
changeset
|
3840 |
strcpy(inputLine, l); |
be06bbe7e449
Add readline_hist_beginning_search_bwd/fwd functions
Mikael Berthe <mikael@lilotux.net>
parents:
1187
diff
changeset
|
3841 |
// Set the pointer at the EOL. |
be06bbe7e449
Add readline_hist_beginning_search_bwd/fwd functions
Mikael Berthe <mikael@lilotux.net>
parents:
1187
diff
changeset
|
3842 |
// 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
|
3843 |
readline_iline_start(); |
be06bbe7e449
Add readline_hist_beginning_search_bwd/fwd functions
Mikael Berthe <mikael@lilotux.net>
parents:
1187
diff
changeset
|
3844 |
readline_iline_end(); |
be06bbe7e449
Add readline_hist_beginning_search_bwd/fwd functions
Mikael Berthe <mikael@lilotux.net>
parents:
1187
diff
changeset
|
3845 |
} |
be06bbe7e449
Add readline_hist_beginning_search_bwd/fwd functions
Mikael Berthe <mikael@lilotux.net>
parents:
1187
diff
changeset
|
3846 |
} |
be06bbe7e449
Add readline_hist_beginning_search_bwd/fwd functions
Mikael Berthe <mikael@lilotux.net>
parents:
1187
diff
changeset
|
3847 |
|
be06bbe7e449
Add readline_hist_beginning_search_bwd/fwd functions
Mikael Berthe <mikael@lilotux.net>
parents:
1187
diff
changeset
|
3848 |
void readline_hist_next(void) |
be06bbe7e449
Add readline_hist_beginning_search_bwd/fwd functions
Mikael Berthe <mikael@lilotux.net>
parents:
1187
diff
changeset
|
3849 |
{ |
be06bbe7e449
Add readline_hist_beginning_search_bwd/fwd functions
Mikael Berthe <mikael@lilotux.net>
parents:
1187
diff
changeset
|
3850 |
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
|
3851 |
if (l) { |
be06bbe7e449
Add readline_hist_beginning_search_bwd/fwd functions
Mikael Berthe <mikael@lilotux.net>
parents:
1187
diff
changeset
|
3852 |
strcpy(inputLine, l); |
be06bbe7e449
Add readline_hist_beginning_search_bwd/fwd functions
Mikael Berthe <mikael@lilotux.net>
parents:
1187
diff
changeset
|
3853 |
// Set the pointer at the EOL. |
be06bbe7e449
Add readline_hist_beginning_search_bwd/fwd functions
Mikael Berthe <mikael@lilotux.net>
parents:
1187
diff
changeset
|
3854 |
// 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
|
3855 |
readline_iline_start(); |
be06bbe7e449
Add readline_hist_beginning_search_bwd/fwd functions
Mikael Berthe <mikael@lilotux.net>
parents:
1187
diff
changeset
|
3856 |
readline_iline_end(); |
be06bbe7e449
Add readline_hist_beginning_search_bwd/fwd functions
Mikael Berthe <mikael@lilotux.net>
parents:
1187
diff
changeset
|
3857 |
} |
be06bbe7e449
Add readline_hist_beginning_search_bwd/fwd functions
Mikael Berthe <mikael@lilotux.net>
parents:
1187
diff
changeset
|
3858 |
} |
be06bbe7e449
Add readline_hist_beginning_search_bwd/fwd functions
Mikael Berthe <mikael@lilotux.net>
parents:
1187
diff
changeset
|
3859 |
|
1171
03a38b7ad2e0
Add a collection of commands for key bindings (Lego12239)
Mikael Berthe <mikael@lilotux.net>
parents:
1170
diff
changeset
|
3860 |
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
|
3861 |
{ |
03a38b7ad2e0
Add a collection of commands for key bindings (Lego12239)
Mikael Berthe <mikael@lilotux.net>
parents:
1170
diff
changeset
|
3862 |
char *src, *c; |
03a38b7ad2e0
Add a collection of commands for key bindings (Lego12239)
Mikael Berthe <mikael@lilotux.net>
parents:
1170
diff
changeset
|
3863 |
|
03a38b7ad2e0
Add a collection of commands for key bindings (Lego12239)
Mikael Berthe <mikael@lilotux.net>
parents:
1170
diff
changeset
|
3864 |
if (ptr_inputline == (char*)&inputLine) |
03a38b7ad2e0
Add a collection of commands for key bindings (Lego12239)
Mikael Berthe <mikael@lilotux.net>
parents:
1170
diff
changeset
|
3865 |
return; |
03a38b7ad2e0
Add a collection of commands for key bindings (Lego12239)
Mikael Berthe <mikael@lilotux.net>
parents:
1170
diff
changeset
|
3866 |
|
03a38b7ad2e0
Add a collection of commands for key bindings (Lego12239)
Mikael Berthe <mikael@lilotux.net>
parents:
1170
diff
changeset
|
3867 |
src = ptr_inputline; |
03a38b7ad2e0
Add a collection of commands for key bindings (Lego12239)
Mikael Berthe <mikael@lilotux.net>
parents:
1170
diff
changeset
|
3868 |
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
|
3869 |
ptr_inputline = c; |
1903
75a0a22bbf78
Fix issue #54 -- command line corruption
Mikael Berthe <mikael@lilotux.net>
parents:
1863
diff
changeset
|
3870 |
_strmove(ptr_inputline, src); |
1171
03a38b7ad2e0
Add a collection of commands for key bindings (Lego12239)
Mikael Berthe <mikael@lilotux.net>
parents:
1170
diff
changeset
|
3871 |
check_offset(-1); |
03a38b7ad2e0
Add a collection of commands for key bindings (Lego12239)
Mikael Berthe <mikael@lilotux.net>
parents:
1170
diff
changeset
|
3872 |
} |
03a38b7ad2e0
Add a collection of commands for key bindings (Lego12239)
Mikael Berthe <mikael@lilotux.net>
parents:
1170
diff
changeset
|
3873 |
|
03a38b7ad2e0
Add a collection of commands for key bindings (Lego12239)
Mikael Berthe <mikael@lilotux.net>
parents:
1170
diff
changeset
|
3874 |
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
|
3875 |
{ |
03a38b7ad2e0
Add a collection of commands for key bindings (Lego12239)
Mikael Berthe <mikael@lilotux.net>
parents:
1170
diff
changeset
|
3876 |
if (!*ptr_inputline) |
03a38b7ad2e0
Add a collection of commands for key bindings (Lego12239)
Mikael Berthe <mikael@lilotux.net>
parents:
1170
diff
changeset
|
3877 |
return; |
03a38b7ad2e0
Add a collection of commands for key bindings (Lego12239)
Mikael Berthe <mikael@lilotux.net>
parents:
1170
diff
changeset
|
3878 |
|
1903
75a0a22bbf78
Fix issue #54 -- command line corruption
Mikael Berthe <mikael@lilotux.net>
parents:
1863
diff
changeset
|
3879 |
_strmove(ptr_inputline, next_char(ptr_inputline)); |
1171
03a38b7ad2e0
Add a collection of commands for key bindings (Lego12239)
Mikael Berthe <mikael@lilotux.net>
parents:
1170
diff
changeset
|
3880 |
} |
03a38b7ad2e0
Add a collection of commands for key bindings (Lego12239)
Mikael Berthe <mikael@lilotux.net>
parents:
1170
diff
changeset
|
3881 |
|
03a38b7ad2e0
Add a collection of commands for key bindings (Lego12239)
Mikael Berthe <mikael@lilotux.net>
parents:
1170
diff
changeset
|
3882 |
void readline_iline_start(void) |
03a38b7ad2e0
Add a collection of commands for key bindings (Lego12239)
Mikael Berthe <mikael@lilotux.net>
parents:
1170
diff
changeset
|
3883 |
{ |
03a38b7ad2e0
Add a collection of commands for key bindings (Lego12239)
Mikael Berthe <mikael@lilotux.net>
parents:
1170
diff
changeset
|
3884 |
ptr_inputline = inputLine; |
03a38b7ad2e0
Add a collection of commands for key bindings (Lego12239)
Mikael Berthe <mikael@lilotux.net>
parents:
1170
diff
changeset
|
3885 |
inputline_offset = 0; |
03a38b7ad2e0
Add a collection of commands for key bindings (Lego12239)
Mikael Berthe <mikael@lilotux.net>
parents:
1170
diff
changeset
|
3886 |
} |
03a38b7ad2e0
Add a collection of commands for key bindings (Lego12239)
Mikael Berthe <mikael@lilotux.net>
parents:
1170
diff
changeset
|
3887 |
|
03a38b7ad2e0
Add a collection of commands for key bindings (Lego12239)
Mikael Berthe <mikael@lilotux.net>
parents:
1170
diff
changeset
|
3888 |
void readline_iline_end(void) |
03a38b7ad2e0
Add a collection of commands for key bindings (Lego12239)
Mikael Berthe <mikael@lilotux.net>
parents:
1170
diff
changeset
|
3889 |
{ |
03a38b7ad2e0
Add a collection of commands for key bindings (Lego12239)
Mikael Berthe <mikael@lilotux.net>
parents:
1170
diff
changeset
|
3890 |
for (; *ptr_inputline; ptr_inputline++) ; |
03a38b7ad2e0
Add a collection of commands for key bindings (Lego12239)
Mikael Berthe <mikael@lilotux.net>
parents:
1170
diff
changeset
|
3891 |
check_offset(1); |
03a38b7ad2e0
Add a collection of commands for key bindings (Lego12239)
Mikael Berthe <mikael@lilotux.net>
parents:
1170
diff
changeset
|
3892 |
} |
03a38b7ad2e0
Add a collection of commands for key bindings (Lego12239)
Mikael Berthe <mikael@lilotux.net>
parents:
1170
diff
changeset
|
3893 |
|
03a38b7ad2e0
Add a collection of commands for key bindings (Lego12239)
Mikael Berthe <mikael@lilotux.net>
parents:
1170
diff
changeset
|
3894 |
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
|
3895 |
{ |
1863
2b013c0f949a
readline: Make backward_kill_iline() consistent with backward_kill_word()
Mikael Berthe <mikael@lilotux.net>
parents:
1821
diff
changeset
|
3896 |
char *dest = inputLine; |
2b013c0f949a
readline: Make backward_kill_iline() consistent with backward_kill_word()
Mikael Berthe <mikael@lilotux.net>
parents:
1821
diff
changeset
|
3897 |
|
2b013c0f949a
readline: Make backward_kill_iline() consistent with backward_kill_word()
Mikael Berthe <mikael@lilotux.net>
parents:
1821
diff
changeset
|
3898 |
if (ptr_inputline == inputLine) return; |
2b013c0f949a
readline: Make backward_kill_iline() consistent with backward_kill_word()
Mikael Berthe <mikael@lilotux.net>
parents:
1821
diff
changeset
|
3899 |
|
2b013c0f949a
readline: Make backward_kill_iline() consistent with backward_kill_word()
Mikael Berthe <mikael@lilotux.net>
parents:
1821
diff
changeset
|
3900 |
if (*dest == COMMAND_CHAR && ptr_inputline != dest+1) |
2b013c0f949a
readline: Make backward_kill_iline() consistent with backward_kill_word()
Mikael Berthe <mikael@lilotux.net>
parents:
1821
diff
changeset
|
3901 |
dest = next_char(dest); |
2b013c0f949a
readline: Make backward_kill_iline() consistent with backward_kill_word()
Mikael Berthe <mikael@lilotux.net>
parents:
1821
diff
changeset
|
3902 |
|
1903
75a0a22bbf78
Fix issue #54 -- command line corruption
Mikael Berthe <mikael@lilotux.net>
parents:
1863
diff
changeset
|
3903 |
_strmove(dest, ptr_inputline); |
1863
2b013c0f949a
readline: Make backward_kill_iline() consistent with backward_kill_word()
Mikael Berthe <mikael@lilotux.net>
parents:
1821
diff
changeset
|
3904 |
ptr_inputline = dest; |
1171
03a38b7ad2e0
Add a collection of commands for key bindings (Lego12239)
Mikael Berthe <mikael@lilotux.net>
parents:
1170
diff
changeset
|
3905 |
inputline_offset = 0; |
03a38b7ad2e0
Add a collection of commands for key bindings (Lego12239)
Mikael Berthe <mikael@lilotux.net>
parents:
1170
diff
changeset
|
3906 |
} |
03a38b7ad2e0
Add a collection of commands for key bindings (Lego12239)
Mikael Berthe <mikael@lilotux.net>
parents:
1170
diff
changeset
|
3907 |
|
03a38b7ad2e0
Add a collection of commands for key bindings (Lego12239)
Mikael Berthe <mikael@lilotux.net>
parents:
1170
diff
changeset
|
3908 |
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
|
3909 |
{ |
03a38b7ad2e0
Add a collection of commands for key bindings (Lego12239)
Mikael Berthe <mikael@lilotux.net>
parents:
1170
diff
changeset
|
3910 |
*ptr_inputline = 0; |
03a38b7ad2e0
Add a collection of commands for key bindings (Lego12239)
Mikael Berthe <mikael@lilotux.net>
parents:
1170
diff
changeset
|
3911 |
} |
03a38b7ad2e0
Add a collection of commands for key bindings (Lego12239)
Mikael Berthe <mikael@lilotux.net>
parents:
1170
diff
changeset
|
3912 |
|
03a38b7ad2e0
Add a collection of commands for key bindings (Lego12239)
Mikael Berthe <mikael@lilotux.net>
parents:
1170
diff
changeset
|
3913 |
void readline_send_multiline(void) |
03a38b7ad2e0
Add a collection of commands for key bindings (Lego12239)
Mikael Berthe <mikael@lilotux.net>
parents:
1170
diff
changeset
|
3914 |
{ |
03a38b7ad2e0
Add a collection of commands for key bindings (Lego12239)
Mikael Berthe <mikael@lilotux.net>
parents:
1170
diff
changeset
|
3915 |
// Validate current multi-line |
1413 | 3916 |
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
|
3917 |
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
|
3918 |
} |
03a38b7ad2e0
Add a collection of commands for key bindings (Lego12239)
Mikael Berthe <mikael@lilotux.net>
parents:
1170
diff
changeset
|
3919 |
|
1945
518740bcd78b
Add /iline iline_insert (Hermitifier)
Mikael Berthe <mikael@lilotux.net>
parents:
1942
diff
changeset
|
3920 |
void readline_insert(const char *toinsert) |
518740bcd78b
Add /iline iline_insert (Hermitifier)
Mikael Berthe <mikael@lilotux.net>
parents:
1942
diff
changeset
|
3921 |
{ |
518740bcd78b
Add /iline iline_insert (Hermitifier)
Mikael Berthe <mikael@lilotux.net>
parents:
1942
diff
changeset
|
3922 |
if (!toinsert || !*toinsert) return; |
518740bcd78b
Add /iline iline_insert (Hermitifier)
Mikael Berthe <mikael@lilotux.net>
parents:
1942
diff
changeset
|
3923 |
|
518740bcd78b
Add /iline iline_insert (Hermitifier)
Mikael Berthe <mikael@lilotux.net>
parents:
1942
diff
changeset
|
3924 |
scr_insert_text(toinsert); |
518740bcd78b
Add /iline iline_insert (Hermitifier)
Mikael Berthe <mikael@lilotux.net>
parents:
1942
diff
changeset
|
3925 |
check_offset(0); |
518740bcd78b
Add /iline iline_insert (Hermitifier)
Mikael Berthe <mikael@lilotux.net>
parents:
1942
diff
changeset
|
3926 |
} |
518740bcd78b
Add /iline iline_insert (Hermitifier)
Mikael Berthe <mikael@lilotux.net>
parents:
1942
diff
changeset
|
3927 |
|
98 | 3928 |
// which_row() |
3929 |
// 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
|
3930 |
// -2 -> normal text |
ddec224c2318
MUC: nickname completion
Mikael Berthe <mikael@lilotux.net>
parents:
499
diff
changeset
|
3931 |
// -1 -> room: nickname completion |
98 | 3932 |
// 0 -> command |
3933 |
// 1 -> parameter 1 (etc.) |
|
102 | 3934 |
// 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
|
3935 |
static int which_row(const char **p_row) |
98 | 3936 |
{ |
3937 |
int row = -1; |
|
3938 |
char *p; |
|
3939 |
int quote = FALSE; |
|
3940 |
||
3941 |
// Not a command? |
|
967 | 3942 |
if ((ptr_inputline == inputLine) || (inputLine[0] != COMMAND_CHAR)) { |
503
ddec224c2318
MUC: nickname completion
Mikael Berthe <mikael@lilotux.net>
parents:
499
diff
changeset
|
3943 |
if (!current_buddy) return -2; |
ddec224c2318
MUC: nickname completion
Mikael Berthe <mikael@lilotux.net>
parents:
499
diff
changeset
|
3944 |
if (buddy_gettype(BUDDATA(current_buddy)) == ROSTER_TYPE_ROOM) { |
ddec224c2318
MUC: nickname completion
Mikael Berthe <mikael@lilotux.net>
parents:
499
diff
changeset
|
3945 |
*p_row = inputLine; |
ddec224c2318
MUC: nickname completion
Mikael Berthe <mikael@lilotux.net>
parents:
499
diff
changeset
|
3946 |
return -1; |
ddec224c2318
MUC: nickname completion
Mikael Berthe <mikael@lilotux.net>
parents:
499
diff
changeset
|
3947 |
} |
ddec224c2318
MUC: nickname completion
Mikael Berthe <mikael@lilotux.net>
parents:
499
diff
changeset
|
3948 |
return -2; |
ddec224c2318
MUC: nickname completion
Mikael Berthe <mikael@lilotux.net>
parents:
499
diff
changeset
|
3949 |
} |
98 | 3950 |
|
3951 |
// This is a command |
|
3952 |
row = 0; |
|
930
a75f7a13df7b
UTF-8 terminal support (Reimar Döffinger)
Mikael Berthe <mikael@lilotux.net>
parents:
929
diff
changeset
|
3953 |
for (p = inputLine ; p < ptr_inputline ; p = next_char(p)) { |
98 | 3954 |
if (quote) { |
3955 |
if (*p == '"' && *(p-1) != '\\') |
|
3956 |
quote = FALSE; |
|
3957 |
continue; |
|
3958 |
} |
|
3959 |
if (*p == '"' && *(p-1) != '\\') { |
|
3960 |
quote = TRUE; |
|
121 | 3961 |
} else if (*p == ' ') { |
3962 |
if (*(p-1) != ' ') |
|
3963 |
row++; |
|
102 | 3964 |
*p_row = p+1; |
3965 |
} |
|
98 | 3966 |
} |
3967 |
return row; |
|
3968 |
} |
|
3969 |
||
143 | 3970 |
// scr_insert_text() |
3971 |
// Insert the given text at the current cursor position. |
|
3972 |
// The cursor is moved. We don't check if the cursor still is in the screen |
|
3973 |
// after, the caller should do that. |
|
336
eb994ee40029
Make some functions static
Mikael Berthe <mikael@lilotux.net>
parents:
332
diff
changeset
|
3974 |
static void scr_insert_text(const char *text) |
98 | 3975 |
{ |
3976 |
char tmpLine[INPUTLINE_LENGTH+1]; |
|
3977 |
int len = strlen(text); |
|
3978 |
// Check the line isn't too long |
|
3979 |
if (strlen(inputLine) + len >= INPUTLINE_LENGTH) { |
|
374
bd5638c21834
Improve logging system (traces)
Mikael Berthe <mikael@lilotux.net>
parents:
373
diff
changeset
|
3980 |
scr_LogPrint(LPRINT_LOGNORM, "Cannot insert text, line too long."); |
98 | 3981 |
return; |
3982 |
} |
|
3983 |
||
3984 |
strcpy(tmpLine, ptr_inputline); |
|
419 | 3985 |
strcpy(ptr_inputline, text); |
3986 |
ptr_inputline += len; |
|
98 | 3987 |
strcpy(ptr_inputline, tmpLine); |
3988 |
} |
|
3989 |
||
930
a75f7a13df7b
UTF-8 terminal support (Reimar Döffinger)
Mikael Berthe <mikael@lilotux.net>
parents:
929
diff
changeset
|
3990 |
static void scr_cancel_current_completion(void); |
a75f7a13df7b
UTF-8 terminal support (Reimar Döffinger)
Mikael Berthe <mikael@lilotux.net>
parents:
929
diff
changeset
|
3991 |
|
143 | 3992 |
// scr_handle_tab() |
3993 |
// Function called when tab is pressed. |
|
3994 |
// Initiate or continue a completion... |
|
2143
2f294c2b6778
Add a backward completion (Oleg)
Mikael Berthe <mikael@lilotux.net>
parents:
2136
diff
changeset
|
3995 |
// If fwd is false, a backward-completion is requested. |
2f294c2b6778
Add a backward completion (Oleg)
Mikael Berthe <mikael@lilotux.net>
parents:
2136
diff
changeset
|
3996 |
static void scr_handle_tab(gboolean fwd) |
98 | 3997 |
{ |
102 | 3998 |
int nrow; |
503
ddec224c2318
MUC: nickname completion
Mikael Berthe <mikael@lilotux.net>
parents:
499
diff
changeset
|
3999 |
const char *row; |
102 | 4000 |
const char *cchar; |
103 | 4001 |
guint compl_categ; |
98 | 4002 |
|
740 | 4003 |
row = inputLine; // (Kills a GCC warning) |
102 | 4004 |
nrow = which_row(&row); |
98 | 4005 |
|
503
ddec224c2318
MUC: nickname completion
Mikael Berthe <mikael@lilotux.net>
parents:
499
diff
changeset
|
4006 |
// a) No completion if no leading slash ('cause not a command), |
ddec224c2318
MUC: nickname completion
Mikael Berthe <mikael@lilotux.net>
parents:
499
diff
changeset
|
4007 |
// unless this is a room (then, it is a nickname completion) |
103 | 4008 |
// 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
|
4009 |
if ((nrow == -2) || (nrow == 3 && !completion_started) || nrow > 3) |
ddec224c2318
MUC: nickname completion
Mikael Berthe <mikael@lilotux.net>
parents:
499
diff
changeset
|
4010 |
return; |
102 | 4011 |
|
503
ddec224c2318
MUC: nickname completion
Mikael Berthe <mikael@lilotux.net>
parents:
499
diff
changeset
|
4012 |
if (nrow == 0) { // Command completion |
930
a75f7a13df7b
UTF-8 terminal support (Reimar Döffinger)
Mikael Berthe <mikael@lilotux.net>
parents:
929
diff
changeset
|
4013 |
row = next_char(inputLine); |
103 | 4014 |
compl_categ = COMPL_CMD; |
503
ddec224c2318
MUC: nickname completion
Mikael Berthe <mikael@lilotux.net>
parents:
499
diff
changeset
|
4015 |
} else if (nrow == -1) { // Nickname completion |
ddec224c2318
MUC: nickname completion
Mikael Berthe <mikael@lilotux.net>
parents:
499
diff
changeset
|
4016 |
compl_categ = COMPL_RESOURCE; |
ddec224c2318
MUC: nickname completion
Mikael Berthe <mikael@lilotux.net>
parents:
499
diff
changeset
|
4017 |
} else { // Other completion, depending on the command |
285 | 4018 |
int alias = FALSE; |
4019 |
cmd *com; |
|
4020 |
char *xpline = expandalias(inputLine); |
|
4021 |
com = cmd_get(xpline); |
|
4022 |
if (xpline != inputLine) { |
|
4023 |
// This is an alias, so we can't complete rows > 0 |
|
4024 |
alias = TRUE; |
|
4025 |
g_free(xpline); |
|
4026 |
} |
|
4027 |
if ((!com && (!alias || !completion_started)) || !row) { |
|
374
bd5638c21834
Improve logging system (traces)
Mikael Berthe <mikael@lilotux.net>
parents:
373
diff
changeset
|
4028 |
scr_LogPrint(LPRINT_NORMAL, "I cannot complete that..."); |
103 | 4029 |
return; |
4030 |
} |
|
285 | 4031 |
if (!alias) |
4032 |
compl_categ = com->completion_flags[nrow-1]; |
|
4033 |
else |
|
4034 |
compl_categ = 0; |
|
103 | 4035 |
} |
4036 |
||
4037 |
if (!completion_started) { |
|
1076
b9698c89f46d
Fix memory leak in scr_handle_tab()
Mikael Berthe <mikael@lilotux.net>
parents:
1075
diff
changeset
|
4038 |
guint dynlist; |
1927
3e3e73bb43f5
Do not call compl_get_category_list() needlessly
Mikael Berthe <mikael@lilotux.net>
parents:
1918
diff
changeset
|
4039 |
GSList *list; |
3e3e73bb43f5
Do not call compl_get_category_list() needlessly
Mikael Berthe <mikael@lilotux.net>
parents:
1918
diff
changeset
|
4040 |
|
3e3e73bb43f5
Do not call compl_get_category_list() needlessly
Mikael Berthe <mikael@lilotux.net>
parents:
1918
diff
changeset
|
4041 |
if (!compl_categ) |
3e3e73bb43f5
Do not call compl_get_category_list() needlessly
Mikael Berthe <mikael@lilotux.net>
parents:
1918
diff
changeset
|
4042 |
return; // Nothing to complete |
3e3e73bb43f5
Do not call compl_get_category_list() needlessly
Mikael Berthe <mikael@lilotux.net>
parents:
1918
diff
changeset
|
4043 |
|
3e3e73bb43f5
Do not call compl_get_category_list() needlessly
Mikael Berthe <mikael@lilotux.net>
parents:
1918
diff
changeset
|
4044 |
list = compl_get_category_list(compl_categ, &dynlist); |
103 | 4045 |
if (list) { |
1228
9a68fe4515dc
Improve MUC nickname completion
Mikael Berthe <mikael@lilotux.net>
parents:
1227
diff
changeset
|
4046 |
guint n; |
103 | 4047 |
char *prefix = g_strndup(row, ptr_inputline-row); |
4048 |
// Init completion |
|
1756
e2c084204583
Add (optional) suffix after nick completion in Multi-User Chats
Mikael Berthe <mikael@lilotux.net>
parents:
1748
diff
changeset
|
4049 |
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
|
4050 |
(compl_categ == COMPL_RESOURCE ? |
1793
c3ddb52f1055
Rename completion_muc_suffix to muc_completion_suffix
Myhailo Danylenko <isbear@ukrpost.net>
parents:
1791
diff
changeset
|
4051 |
settings_opt_get("muc_completion_suffix") : NULL)); |
103 | 4052 |
g_free(prefix); |
1228
9a68fe4515dc
Improve MUC nickname completion
Mikael Berthe <mikael@lilotux.net>
parents:
1227
diff
changeset
|
4053 |
if (n == 0 && nrow == -1) { |
9a68fe4515dc
Improve MUC nickname completion
Mikael Berthe <mikael@lilotux.net>
parents:
1227
diff
changeset
|
4054 |
// 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
|
4055 |
// 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
|
4056 |
row = prev_char(ptr_inputline, inputLine); |
9a68fe4515dc
Improve MUC nickname completion
Mikael Berthe <mikael@lilotux.net>
parents:
1227
diff
changeset
|
4057 |
while (row >= inputLine) { |
1239
eb9fc5d6d085
MUC: Nickname completion starts from any non-space character
Mikael Berthe <mikael@lilotux.net>
parents:
1229
diff
changeset
|
4058 |
if (iswspace(get_char(row)) || get_char(row) == '(') { |
1228
9a68fe4515dc
Improve MUC nickname completion
Mikael Berthe <mikael@lilotux.net>
parents:
1227
diff
changeset
|
4059 |
row = next_char((char*)row); |
9a68fe4515dc
Improve MUC nickname completion
Mikael Berthe <mikael@lilotux.net>
parents:
1227
diff
changeset
|
4060 |
break; |
9a68fe4515dc
Improve MUC nickname completion
Mikael Berthe <mikael@lilotux.net>
parents:
1227
diff
changeset
|
4061 |
} |
9a68fe4515dc
Improve MUC nickname completion
Mikael Berthe <mikael@lilotux.net>
parents:
1227
diff
changeset
|
4062 |
if (row == inputLine) |
9a68fe4515dc
Improve MUC nickname completion
Mikael Berthe <mikael@lilotux.net>
parents:
1227
diff
changeset
|
4063 |
break; |
9a68fe4515dc
Improve MUC nickname completion
Mikael Berthe <mikael@lilotux.net>
parents:
1227
diff
changeset
|
4064 |
row = prev_char((char*)row, inputLine); |
9a68fe4515dc
Improve MUC nickname completion
Mikael Berthe <mikael@lilotux.net>
parents:
1227
diff
changeset
|
4065 |
} |
9a68fe4515dc
Improve MUC nickname completion
Mikael Berthe <mikael@lilotux.net>
parents:
1227
diff
changeset
|
4066 |
// There's no need to try again if row == inputLine |
9a68fe4515dc
Improve MUC nickname completion
Mikael Berthe <mikael@lilotux.net>
parents:
1227
diff
changeset
|
4067 |
if (row > inputLine) { |
9a68fe4515dc
Improve MUC nickname completion
Mikael Berthe <mikael@lilotux.net>
parents:
1227
diff
changeset
|
4068 |
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
|
4069 |
new_completion(prefix, list, NULL); |
1228
9a68fe4515dc
Improve MUC nickname completion
Mikael Berthe <mikael@lilotux.net>
parents:
1227
diff
changeset
|
4070 |
g_free(prefix); |
9a68fe4515dc
Improve MUC nickname completion
Mikael Berthe <mikael@lilotux.net>
parents:
1227
diff
changeset
|
4071 |
} |
9a68fe4515dc
Improve MUC nickname completion
Mikael Berthe <mikael@lilotux.net>
parents:
1227
diff
changeset
|
4072 |
} |
1076
b9698c89f46d
Fix memory leak in scr_handle_tab()
Mikael Berthe <mikael@lilotux.net>
parents:
1075
diff
changeset
|
4073 |
// 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
|
4074 |
if (dynlist) { |
b9698c89f46d
Fix memory leak in scr_handle_tab()
Mikael Berthe <mikael@lilotux.net>
parents:
1075
diff
changeset
|
4075 |
GSList *slp; |
b9698c89f46d
Fix memory leak in scr_handle_tab()
Mikael Berthe <mikael@lilotux.net>
parents:
1075
diff
changeset
|
4076 |
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
|
4077 |
g_free(slp->data); |
b9698c89f46d
Fix memory leak in scr_handle_tab()
Mikael Berthe <mikael@lilotux.net>
parents:
1075
diff
changeset
|
4078 |
g_slist_free(list); |
b9698c89f46d
Fix memory leak in scr_handle_tab()
Mikael Berthe <mikael@lilotux.net>
parents:
1075
diff
changeset
|
4079 |
} |
103 | 4080 |
// Now complete |
2143
2f294c2b6778
Add a backward completion (Oleg)
Mikael Berthe <mikael@lilotux.net>
parents:
2136
diff
changeset
|
4081 |
cchar = complete(fwd); |
98 | 4082 |
if (cchar) |
4083 |
scr_insert_text(cchar); |
|
103 | 4084 |
completion_started = TRUE; |
98 | 4085 |
} |
103 | 4086 |
} else { // Completion already initialized |
930
a75f7a13df7b
UTF-8 terminal support (Reimar Döffinger)
Mikael Berthe <mikael@lilotux.net>
parents:
929
diff
changeset
|
4087 |
scr_cancel_current_completion(); |
103 | 4088 |
// Now complete again |
2143
2f294c2b6778
Add a backward completion (Oleg)
Mikael Berthe <mikael@lilotux.net>
parents:
2136
diff
changeset
|
4089 |
cchar = complete(fwd); |
103 | 4090 |
if (cchar) |
4091 |
scr_insert_text(cchar); |
|
102 | 4092 |
} |
98 | 4093 |
} |
4094 |
||
336
eb994ee40029
Make some functions static
Mikael Berthe <mikael@lilotux.net>
parents:
332
diff
changeset
|
4095 |
static void scr_cancel_current_completion(void) |
98 | 4096 |
{ |
4097 |
char *c; |
|
930
a75f7a13df7b
UTF-8 terminal support (Reimar Döffinger)
Mikael Berthe <mikael@lilotux.net>
parents:
929
diff
changeset
|
4098 |
char *src = ptr_inputline; |
98 | 4099 |
guint back = cancel_completion(); |
930
a75f7a13df7b
UTF-8 terminal support (Reimar Döffinger)
Mikael Berthe <mikael@lilotux.net>
parents:
929
diff
changeset
|
4100 |
guint i; |
98 | 4101 |
// Remove $back chars |
930
a75f7a13df7b
UTF-8 terminal support (Reimar Döffinger)
Mikael Berthe <mikael@lilotux.net>
parents:
929
diff
changeset
|
4102 |
for (i = 0; i < back; i++) |
a75f7a13df7b
UTF-8 terminal support (Reimar Döffinger)
Mikael Berthe <mikael@lilotux.net>
parents:
929
diff
changeset
|
4103 |
ptr_inputline = prev_char(ptr_inputline, inputLine); |
98 | 4104 |
c = ptr_inputline; |
930
a75f7a13df7b
UTF-8 terminal support (Reimar Döffinger)
Mikael Berthe <mikael@lilotux.net>
parents:
929
diff
changeset
|
4105 |
for ( ; *src ; ) |
a75f7a13df7b
UTF-8 terminal support (Reimar Döffinger)
Mikael Berthe <mikael@lilotux.net>
parents:
929
diff
changeset
|
4106 |
*c++ = *src++; |
a75f7a13df7b
UTF-8 terminal support (Reimar Döffinger)
Mikael Berthe <mikael@lilotux.net>
parents:
929
diff
changeset
|
4107 |
*c = 0; |
98 | 4108 |
} |
4109 |
||
336
eb994ee40029
Make some functions static
Mikael Berthe <mikael@lilotux.net>
parents:
332
diff
changeset
|
4110 |
static void scr_end_current_completion(void) |
98 | 4111 |
{ |
4112 |
done_completion(); |
|
4113 |
completion_started = FALSE; |
|
4114 |
} |
|
4115 |
||
24 | 4116 |
// check_offset(int direction) |
4117 |
// Check inputline_offset value, and make sure the cursor is inside the |
|
4118 |
// screen. |
|
336
eb994ee40029
Make some functions static
Mikael Berthe <mikael@lilotux.net>
parents:
332
diff
changeset
|
4119 |
static inline void check_offset(int direction) |
24 | 4120 |
{ |
930
a75f7a13df7b
UTF-8 terminal support (Reimar Döffinger)
Mikael Berthe <mikael@lilotux.net>
parents:
929
diff
changeset
|
4121 |
int i; |
a75f7a13df7b
UTF-8 terminal support (Reimar Döffinger)
Mikael Berthe <mikael@lilotux.net>
parents:
929
diff
changeset
|
4122 |
char *c = &inputLine[inputline_offset]; |
24 | 4123 |
// Left side |
4124 |
if (inputline_offset && direction <= 0) { |
|
930
a75f7a13df7b
UTF-8 terminal support (Reimar Döffinger)
Mikael Berthe <mikael@lilotux.net>
parents:
929
diff
changeset
|
4125 |
while (ptr_inputline <= c) { |
a75f7a13df7b
UTF-8 terminal support (Reimar Döffinger)
Mikael Berthe <mikael@lilotux.net>
parents:
929
diff
changeset
|
4126 |
for (i = 0; i < 5; i++) |
a75f7a13df7b
UTF-8 terminal support (Reimar Döffinger)
Mikael Berthe <mikael@lilotux.net>
parents:
929
diff
changeset
|
4127 |
c = prev_char(c, inputLine); |
a75f7a13df7b
UTF-8 terminal support (Reimar Döffinger)
Mikael Berthe <mikael@lilotux.net>
parents:
929
diff
changeset
|
4128 |
if (c == inputLine) |
828
319fc55b9a2b
Fix a bug in check_offset()
Mikael Berthe <mikael@lilotux.net>
parents:
827
diff
changeset
|
4129 |
break; |
24 | 4130 |
} |
4131 |
} |
|
4132 |
// Right side |
|
4133 |
if (direction >= 0) { |
|
932
fc6aaa223650
Fix a few problems with non-UTF-8 locales
Mikael Berthe <mikael@lilotux.net>
parents:
931
diff
changeset
|
4134 |
int delta = get_char_width(c); |
930
a75f7a13df7b
UTF-8 terminal support (Reimar Döffinger)
Mikael Berthe <mikael@lilotux.net>
parents:
929
diff
changeset
|
4135 |
while (ptr_inputline > c) { |
a75f7a13df7b
UTF-8 terminal support (Reimar Döffinger)
Mikael Berthe <mikael@lilotux.net>
parents:
929
diff
changeset
|
4136 |
c = next_char(c); |
932
fc6aaa223650
Fix a few problems with non-UTF-8 locales
Mikael Berthe <mikael@lilotux.net>
parents:
931
diff
changeset
|
4137 |
delta += get_char_width(c); |
930
a75f7a13df7b
UTF-8 terminal support (Reimar Döffinger)
Mikael Berthe <mikael@lilotux.net>
parents:
929
diff
changeset
|
4138 |
} |
a75f7a13df7b
UTF-8 terminal support (Reimar Döffinger)
Mikael Berthe <mikael@lilotux.net>
parents:
929
diff
changeset
|
4139 |
c = &inputLine[inputline_offset]; |
a75f7a13df7b
UTF-8 terminal support (Reimar Döffinger)
Mikael Berthe <mikael@lilotux.net>
parents:
929
diff
changeset
|
4140 |
while (delta >= maxX) { |
a75f7a13df7b
UTF-8 terminal support (Reimar Döffinger)
Mikael Berthe <mikael@lilotux.net>
parents:
929
diff
changeset
|
4141 |
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
|
4142 |
delta -= get_char_width(c); |
930
a75f7a13df7b
UTF-8 terminal support (Reimar Döffinger)
Mikael Berthe <mikael@lilotux.net>
parents:
929
diff
changeset
|
4143 |
c = next_char(c); |
a75f7a13df7b
UTF-8 terminal support (Reimar Döffinger)
Mikael Berthe <mikael@lilotux.net>
parents:
929
diff
changeset
|
4144 |
} |
a75f7a13df7b
UTF-8 terminal support (Reimar Döffinger)
Mikael Berthe <mikael@lilotux.net>
parents:
929
diff
changeset
|
4145 |
} |
24 | 4146 |
} |
930
a75f7a13df7b
UTF-8 terminal support (Reimar Döffinger)
Mikael Berthe <mikael@lilotux.net>
parents:
929
diff
changeset
|
4147 |
inputline_offset = c - inputLine; |
24 | 4148 |
} |
4149 |
||
1590
8d1bcc83ae32
Add support for spellchecking with Enchant (caolan)
Mikael Berthe <mikael@lilotux.net>
parents:
1579
diff
changeset
|
4150 |
#if defined(WITH_ENCHANT) || defined(WITH_ASPELL) |
1179 | 4151 |
// prints inputLine with underlined words when misspelled |
4152 |
static inline void print_checked_line(void) |
|
4153 |
{ |
|
4154 |
char *wprint_char_fmt = "%c"; |
|
4155 |
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
|
4156 |
int nrchar = maxX; |
1179 | 4157 |
char *ptrCur = inputLine + inputline_offset; |
4158 |
||
4159 |
#ifdef UNICODE |
|
4160 |
// We need this to display a single UTF-8 char... Any better solution? |
|
4161 |
if (utf8_mode) |
|
4162 |
wprint_char_fmt = "%lc"; |
|
4163 |
#endif |
|
4164 |
||
4165 |
wmove(inputWnd, 0, 0); // problem with backspace |
|
4166 |
||
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
|
4167 |
while (*ptrCur && nrchar-- > 0) { |
1179 | 4168 |
point = ptrCur - inputLine; |
4169 |
if (maskLine[point]) |
|
4170 |
wattrset(inputWnd, A_UNDERLINE); |
|
4171 |
wprintw(inputWnd, wprint_char_fmt, get_char(ptrCur)); |
|
4172 |
wattrset(inputWnd, A_NORMAL); |
|
4173 |
ptrCur = next_char(ptrCur); |
|
4174 |
} |
|
4175 |
} |
|
4176 |
#endif |
|
4177 |
||
336
eb994ee40029
Make some functions static
Mikael Berthe <mikael@lilotux.net>
parents:
332
diff
changeset
|
4178 |
static inline void refresh_inputline(void) |
312
f0b7ff2df7e8
Ctrl-C does not terminate mcabber
Mikael Berthe <mikael@lilotux.net>
parents:
307
diff
changeset
|
4179 |
{ |
1590
8d1bcc83ae32
Add support for spellchecking with Enchant (caolan)
Mikael Berthe <mikael@lilotux.net>
parents:
1579
diff
changeset
|
4180 |
#if defined(WITH_ENCHANT) || defined(WITH_ASPELL) |
2304
fa8365fb6ac2
[PATCH 1/3] New option: vi_mode
Holger Weiß <holger@zedat.fu-berlin.de>
parents:
2292
diff
changeset
|
4181 |
if (settings_opt_get_int("spell_enable") && |
fa8365fb6ac2
[PATCH 1/3] New option: vi_mode
Holger Weiß <holger@zedat.fu-berlin.de>
parents:
2292
diff
changeset
|
4182 |
(chatmode || !settings_opt_get_int("vi_mode"))) { |
1179 | 4183 |
memset(maskLine, 0, INPUTLINE_LENGTH+1); |
4184 |
spellcheck(inputLine, maskLine); |
|
4185 |
} |
|
4186 |
print_checked_line(); |
|
312
f0b7ff2df7e8
Ctrl-C does not terminate mcabber
Mikael Berthe <mikael@lilotux.net>
parents:
307
diff
changeset
|
4187 |
wclrtoeol(inputWnd); |
930
a75f7a13df7b
UTF-8 terminal support (Reimar Döffinger)
Mikael Berthe <mikael@lilotux.net>
parents:
929
diff
changeset
|
4188 |
if (*ptr_inputline) { |
a75f7a13df7b
UTF-8 terminal support (Reimar Döffinger)
Mikael Berthe <mikael@lilotux.net>
parents:
929
diff
changeset
|
4189 |
// 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
|
4190 |
// so I know of no better way. |
a75f7a13df7b
UTF-8 terminal support (Reimar Döffinger)
Mikael Berthe <mikael@lilotux.net>
parents:
929
diff
changeset
|
4191 |
char c = *ptr_inputline; |
a75f7a13df7b
UTF-8 terminal support (Reimar Döffinger)
Mikael Berthe <mikael@lilotux.net>
parents:
929
diff
changeset
|
4192 |
*ptr_inputline = 0; |
1179 | 4193 |
print_checked_line(); |
930
a75f7a13df7b
UTF-8 terminal support (Reimar Döffinger)
Mikael Berthe <mikael@lilotux.net>
parents:
929
diff
changeset
|
4194 |
*ptr_inputline = c; |
a75f7a13df7b
UTF-8 terminal support (Reimar Döffinger)
Mikael Berthe <mikael@lilotux.net>
parents:
929
diff
changeset
|
4195 |
} |
1179 | 4196 |
#else |
4197 |
mvwprintw(inputWnd, 0, 0, "%s", inputLine + inputline_offset); |
|
4198 |
wclrtoeol(inputWnd); |
|
4199 |
if (*ptr_inputline) { |
|
4200 |
// hack to set cursor pos. Characters can have different width, |
|
4201 |
// so I know of no better way. |
|
4202 |
char c = *ptr_inputline; |
|
4203 |
*ptr_inputline = 0; |
|
4204 |
mvwprintw(inputWnd, 0, 0, "%s", inputLine + inputline_offset); |
|
4205 |
*ptr_inputline = c; |
|
4206 |
} |
|
4207 |
#endif |
|
312
f0b7ff2df7e8
Ctrl-C does not terminate mcabber
Mikael Berthe <mikael@lilotux.net>
parents:
307
diff
changeset
|
4208 |
} |
f0b7ff2df7e8
Ctrl-C does not terminate mcabber
Mikael Berthe <mikael@lilotux.net>
parents:
307
diff
changeset
|
4209 |
|
389
6e895f397474
Ncurses changes + Ctrl-C does not send a signal anylore
Mikael Berthe <mikael@lilotux.net>
parents:
388
diff
changeset
|
4210 |
void scr_handle_CtrlC(void) |
312
f0b7ff2df7e8
Ctrl-C does not terminate mcabber
Mikael Berthe <mikael@lilotux.net>
parents:
307
diff
changeset
|
4211 |
{ |
365
ddb6593bedc9
Fix segfault when mcabber receives an INT signal (Ctrl-C) early
Mikael Berthe <mikael@lilotux.net>
parents:
364
diff
changeset
|
4212 |
if (!Curses) return; |
315
65aa05520556
First Ctrl-C now also leaves multi-line message mode
Mikael Berthe <mikael@lilotux.net>
parents:
314
diff
changeset
|
4213 |
// 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
|
4214 |
process_command(mkcmdstr("msay abort"), TRUE); |
312
f0b7ff2df7e8
Ctrl-C does not terminate mcabber
Mikael Berthe <mikael@lilotux.net>
parents:
307
diff
changeset
|
4215 |
// Same as Ctrl-g, now |
f0b7ff2df7e8
Ctrl-C does not terminate mcabber
Mikael Berthe <mikael@lilotux.net>
parents:
307
diff
changeset
|
4216 |
scr_cancel_current_completion(); |
f0b7ff2df7e8
Ctrl-C does not terminate mcabber
Mikael Berthe <mikael@lilotux.net>
parents:
307
diff
changeset
|
4217 |
scr_end_current_completion(); |
f0b7ff2df7e8
Ctrl-C does not terminate mcabber
Mikael Berthe <mikael@lilotux.net>
parents:
307
diff
changeset
|
4218 |
check_offset(-1); |
f0b7ff2df7e8
Ctrl-C does not terminate mcabber
Mikael Berthe <mikael@lilotux.net>
parents:
307
diff
changeset
|
4219 |
refresh_inputline(); |
f0b7ff2df7e8
Ctrl-C does not terminate mcabber
Mikael Berthe <mikael@lilotux.net>
parents:
307
diff
changeset
|
4220 |
} |
f0b7ff2df7e8
Ctrl-C does not terminate mcabber
Mikael Berthe <mikael@lilotux.net>
parents:
307
diff
changeset
|
4221 |
|
761
4532a9fe0e8c
Handle some keyboard escape sequences
Mikael Berthe <mikael@lilotux.net>
parents:
760
diff
changeset
|
4222 |
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
|
4223 |
{ |
4532a9fe0e8c
Handle some keyboard escape sequences
Mikael Berthe <mikael@lilotux.net>
parents:
760
diff
changeset
|
4224 |
keyseq *ks; |
4532a9fe0e8c
Handle some keyboard escape sequences
Mikael Berthe <mikael@lilotux.net>
parents:
760
diff
changeset
|
4225 |
|
4532a9fe0e8c
Handle some keyboard escape sequences
Mikael Berthe <mikael@lilotux.net>
parents:
760
diff
changeset
|
4226 |
// Let's make sure the length is correct |
4532a9fe0e8c
Handle some keyboard escape sequences
Mikael Berthe <mikael@lilotux.net>
parents:
760
diff
changeset
|
4227 |
if (strlen(seqstr) > MAX_KEYSEQ_LENGTH) { |
4532a9fe0e8c
Handle some keyboard escape sequences
Mikael Berthe <mikael@lilotux.net>
parents:
760
diff
changeset
|
4228 |
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
|
4229 |
return; |
4532a9fe0e8c
Handle some keyboard escape sequences
Mikael Berthe <mikael@lilotux.net>
parents:
760
diff
changeset
|
4230 |
} |
4532a9fe0e8c
Handle some keyboard escape sequences
Mikael Berthe <mikael@lilotux.net>
parents:
760
diff
changeset
|
4231 |
|
4532a9fe0e8c
Handle some keyboard escape sequences
Mikael Berthe <mikael@lilotux.net>
parents:
760
diff
changeset
|
4232 |
ks = g_new0(keyseq, 1); |
4532a9fe0e8c
Handle some keyboard escape sequences
Mikael Berthe <mikael@lilotux.net>
parents:
760
diff
changeset
|
4233 |
ks->seqstr = g_strdup(seqstr); |
4532a9fe0e8c
Handle some keyboard escape sequences
Mikael Berthe <mikael@lilotux.net>
parents:
760
diff
changeset
|
4234 |
ks->mkeycode = mkeycode; |
4532a9fe0e8c
Handle some keyboard escape sequences
Mikael Berthe <mikael@lilotux.net>
parents:
760
diff
changeset
|
4235 |
ks->value = value; |
4532a9fe0e8c
Handle some keyboard escape sequences
Mikael Berthe <mikael@lilotux.net>
parents:
760
diff
changeset
|
4236 |
keyseqlist = g_slist_append(keyseqlist, ks); |
4532a9fe0e8c
Handle some keyboard escape sequences
Mikael Berthe <mikael@lilotux.net>
parents:
760
diff
changeset
|
4237 |
} |
4532a9fe0e8c
Handle some keyboard escape sequences
Mikael Berthe <mikael@lilotux.net>
parents:
760
diff
changeset
|
4238 |
|
4532a9fe0e8c
Handle some keyboard escape sequences
Mikael Berthe <mikael@lilotux.net>
parents:
760
diff
changeset
|
4239 |
// match_keyseq(iseq, &ret) |
4532a9fe0e8c
Handle some keyboard escape sequences
Mikael Berthe <mikael@lilotux.net>
parents:
760
diff
changeset
|
4240 |
// Check if "iseq" is a known key escape sequence. |
4532a9fe0e8c
Handle some keyboard escape sequences
Mikael Berthe <mikael@lilotux.net>
parents:
760
diff
changeset
|
4241 |
// Return value: |
4532a9fe0e8c
Handle some keyboard escape sequences
Mikael Berthe <mikael@lilotux.net>
parents:
760
diff
changeset
|
4242 |
// -1 if "seq" matches no known sequence |
4532a9fe0e8c
Handle some keyboard escape sequences
Mikael Berthe <mikael@lilotux.net>
parents:
760
diff
changeset
|
4243 |
// 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
|
4244 |
// >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
|
4245 |
// and *ret is set to the matching keyseq structure. |
952 | 4246 |
static inline gint match_keyseq(int *iseq, keyseq **ret) |
373
af2f8ddf6a1b
Move (reorganize) functions
Mikael Berthe <mikael@lilotux.net>
parents:
370
diff
changeset
|
4247 |
{ |
761
4532a9fe0e8c
Handle some keyboard escape sequences
Mikael Berthe <mikael@lilotux.net>
parents:
760
diff
changeset
|
4248 |
GSList *ksl; |
4532a9fe0e8c
Handle some keyboard escape sequences
Mikael Berthe <mikael@lilotux.net>
parents:
760
diff
changeset
|
4249 |
keyseq *ksp; |
4532a9fe0e8c
Handle some keyboard escape sequences
Mikael Berthe <mikael@lilotux.net>
parents:
760
diff
changeset
|
4250 |
char *p, c; |
4532a9fe0e8c
Handle some keyboard escape sequences
Mikael Berthe <mikael@lilotux.net>
parents:
760
diff
changeset
|
4251 |
int *i; |
4532a9fe0e8c
Handle some keyboard escape sequences
Mikael Berthe <mikael@lilotux.net>
parents:
760
diff
changeset
|
4252 |
int needmore = FALSE; |
4532a9fe0e8c
Handle some keyboard escape sequences
Mikael Berthe <mikael@lilotux.net>
parents:
760
diff
changeset
|
4253 |
|
4532a9fe0e8c
Handle some keyboard escape sequences
Mikael Berthe <mikael@lilotux.net>
parents:
760
diff
changeset
|
4254 |
for (ksl = keyseqlist; ksl; ksl = g_slist_next(ksl)) { |
4532a9fe0e8c
Handle some keyboard escape sequences
Mikael Berthe <mikael@lilotux.net>
parents:
760
diff
changeset
|
4255 |
ksp = ksl->data; |
4532a9fe0e8c
Handle some keyboard escape sequences
Mikael Berthe <mikael@lilotux.net>
parents:
760
diff
changeset
|
4256 |
p = ksp->seqstr; |
4532a9fe0e8c
Handle some keyboard escape sequences
Mikael Berthe <mikael@lilotux.net>
parents:
760
diff
changeset
|
4257 |
i = iseq; |
4532a9fe0e8c
Handle some keyboard escape sequences
Mikael Berthe <mikael@lilotux.net>
parents:
760
diff
changeset
|
4258 |
while (1) { |
4532a9fe0e8c
Handle some keyboard escape sequences
Mikael Berthe <mikael@lilotux.net>
parents:
760
diff
changeset
|
4259 |
c = (unsigned char)*i; |
4532a9fe0e8c
Handle some keyboard escape sequences
Mikael Berthe <mikael@lilotux.net>
parents:
760
diff
changeset
|
4260 |
if (!*p && !c) { // Match |
4532a9fe0e8c
Handle some keyboard escape sequences
Mikael Berthe <mikael@lilotux.net>
parents:
760
diff
changeset
|
4261 |
(*ret) = ksp; |
4532a9fe0e8c
Handle some keyboard escape sequences
Mikael Berthe <mikael@lilotux.net>
parents:
760
diff
changeset
|
4262 |
return ksp->mkeycode; |
4532a9fe0e8c
Handle some keyboard escape sequences
Mikael Berthe <mikael@lilotux.net>
parents:
760
diff
changeset
|
4263 |
} |
4532a9fe0e8c
Handle some keyboard escape sequences
Mikael Berthe <mikael@lilotux.net>
parents:
760
diff
changeset
|
4264 |
if (!c) { |
4532a9fe0e8c
Handle some keyboard escape sequences
Mikael Berthe <mikael@lilotux.net>
parents:
760
diff
changeset
|
4265 |
// iseq is too short |
4532a9fe0e8c
Handle some keyboard escape sequences
Mikael Berthe <mikael@lilotux.net>
parents:
760
diff
changeset
|
4266 |
needmore = TRUE; |
4532a9fe0e8c
Handle some keyboard escape sequences
Mikael Berthe <mikael@lilotux.net>
parents:
760
diff
changeset
|
4267 |
break; |
4532a9fe0e8c
Handle some keyboard escape sequences
Mikael Berthe <mikael@lilotux.net>
parents:
760
diff
changeset
|
4268 |
} else if (!*p || c != *p) { |
4532a9fe0e8c
Handle some keyboard escape sequences
Mikael Berthe <mikael@lilotux.net>
parents:
760
diff
changeset
|
4269 |
// This isn't a match |
4532a9fe0e8c
Handle some keyboard escape sequences
Mikael Berthe <mikael@lilotux.net>
parents:
760
diff
changeset
|
4270 |
break; |
4532a9fe0e8c
Handle some keyboard escape sequences
Mikael Berthe <mikael@lilotux.net>
parents:
760
diff
changeset
|
4271 |
} |
4532a9fe0e8c
Handle some keyboard escape sequences
Mikael Berthe <mikael@lilotux.net>
parents:
760
diff
changeset
|
4272 |
p++; i++; |
4532a9fe0e8c
Handle some keyboard escape sequences
Mikael Berthe <mikael@lilotux.net>
parents:
760
diff
changeset
|
4273 |
} |
4532a9fe0e8c
Handle some keyboard escape sequences
Mikael Berthe <mikael@lilotux.net>
parents:
760
diff
changeset
|
4274 |
} |
4532a9fe0e8c
Handle some keyboard escape sequences
Mikael Berthe <mikael@lilotux.net>
parents:
760
diff
changeset
|
4275 |
|
4532a9fe0e8c
Handle some keyboard escape sequences
Mikael Berthe <mikael@lilotux.net>
parents:
760
diff
changeset
|
4276 |
if (needmore) |
4532a9fe0e8c
Handle some keyboard escape sequences
Mikael Berthe <mikael@lilotux.net>
parents:
760
diff
changeset
|
4277 |
return 0; |
4532a9fe0e8c
Handle some keyboard escape sequences
Mikael Berthe <mikael@lilotux.net>
parents:
760
diff
changeset
|
4278 |
return -1; |
4532a9fe0e8c
Handle some keyboard escape sequences
Mikael Berthe <mikael@lilotux.net>
parents:
760
diff
changeset
|
4279 |
} |
4532a9fe0e8c
Handle some keyboard escape sequences
Mikael Berthe <mikael@lilotux.net>
parents:
760
diff
changeset
|
4280 |
|
930
a75f7a13df7b
UTF-8 terminal support (Reimar Döffinger)
Mikael Berthe <mikael@lilotux.net>
parents:
929
diff
changeset
|
4281 |
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
|
4282 |
{ |
a75f7a13df7b
UTF-8 terminal support (Reimar Döffinger)
Mikael Berthe <mikael@lilotux.net>
parents:
929
diff
changeset
|
4283 |
int *strp = iseq; |
a75f7a13df7b
UTF-8 terminal support (Reimar Döffinger)
Mikael Berthe <mikael@lilotux.net>
parents:
929
diff
changeset
|
4284 |
unsigned c = *strp++; |
a75f7a13df7b
UTF-8 terminal support (Reimar Döffinger)
Mikael Berthe <mikael@lilotux.net>
parents:
929
diff
changeset
|
4285 |
unsigned mask = 0x80; |
a75f7a13df7b
UTF-8 terminal support (Reimar Döffinger)
Mikael Berthe <mikael@lilotux.net>
parents:
929
diff
changeset
|
4286 |
int len = -1; |
a75f7a13df7b
UTF-8 terminal support (Reimar Döffinger)
Mikael Berthe <mikael@lilotux.net>
parents:
929
diff
changeset
|
4287 |
while (c & mask) { |
a75f7a13df7b
UTF-8 terminal support (Reimar Döffinger)
Mikael Berthe <mikael@lilotux.net>
parents:
929
diff
changeset
|
4288 |
mask >>= 1; |
a75f7a13df7b
UTF-8 terminal support (Reimar Döffinger)
Mikael Berthe <mikael@lilotux.net>
parents:
929
diff
changeset
|
4289 |
len++; |
a75f7a13df7b
UTF-8 terminal support (Reimar Döffinger)
Mikael Berthe <mikael@lilotux.net>
parents:
929
diff
changeset
|
4290 |
} |
a75f7a13df7b
UTF-8 terminal support (Reimar Döffinger)
Mikael Berthe <mikael@lilotux.net>
parents:
929
diff
changeset
|
4291 |
if (len <= 0 || len > 4) |
a75f7a13df7b
UTF-8 terminal support (Reimar Döffinger)
Mikael Berthe <mikael@lilotux.net>
parents:
929
diff
changeset
|
4292 |
return -1; |
a75f7a13df7b
UTF-8 terminal support (Reimar Döffinger)
Mikael Berthe <mikael@lilotux.net>
parents:
929
diff
changeset
|
4293 |
c &= mask - 1; |
a75f7a13df7b
UTF-8 terminal support (Reimar Döffinger)
Mikael Berthe <mikael@lilotux.net>
parents:
929
diff
changeset
|
4294 |
while ((*strp & 0xc0) == 0x80) { |
a75f7a13df7b
UTF-8 terminal support (Reimar Döffinger)
Mikael Berthe <mikael@lilotux.net>
parents:
929
diff
changeset
|
4295 |
if (len-- <= 0) // can't happen |
a75f7a13df7b
UTF-8 terminal support (Reimar Döffinger)
Mikael Berthe <mikael@lilotux.net>
parents:
929
diff
changeset
|
4296 |
return -1; |
a75f7a13df7b
UTF-8 terminal support (Reimar Döffinger)
Mikael Berthe <mikael@lilotux.net>
parents:
929
diff
changeset
|
4297 |
c = (c << 6) | (*strp++ & 0x3f); |
a75f7a13df7b
UTF-8 terminal support (Reimar Döffinger)
Mikael Berthe <mikael@lilotux.net>
parents:
929
diff
changeset
|
4298 |
} |
a75f7a13df7b
UTF-8 terminal support (Reimar Döffinger)
Mikael Berthe <mikael@lilotux.net>
parents:
929
diff
changeset
|
4299 |
if (len) |
a75f7a13df7b
UTF-8 terminal support (Reimar Döffinger)
Mikael Berthe <mikael@lilotux.net>
parents:
929
diff
changeset
|
4300 |
return 0; |
a75f7a13df7b
UTF-8 terminal support (Reimar Döffinger)
Mikael Berthe <mikael@lilotux.net>
parents:
929
diff
changeset
|
4301 |
return c; |
a75f7a13df7b
UTF-8 terminal support (Reimar Döffinger)
Mikael Berthe <mikael@lilotux.net>
parents:
929
diff
changeset
|
4302 |
} |
a75f7a13df7b
UTF-8 terminal support (Reimar Döffinger)
Mikael Berthe <mikael@lilotux.net>
parents:
929
diff
changeset
|
4303 |
|
1780
e4378fbab5d7
Major API cleanup - bump API to 4
Mikael Berthe <mikael@lilotux.net>
parents:
1761
diff
changeset
|
4304 |
void scr_getch(keycode *kcode) |
761
4532a9fe0e8c
Handle some keyboard escape sequences
Mikael Berthe <mikael@lilotux.net>
parents:
760
diff
changeset
|
4305 |
{ |
769 | 4306 |
keyseq *mks = NULL; |
761
4532a9fe0e8c
Handle some keyboard escape sequences
Mikael Berthe <mikael@lilotux.net>
parents:
760
diff
changeset
|
4307 |
int ks[MAX_KEYSEQ_LENGTH+1]; |
4532a9fe0e8c
Handle some keyboard escape sequences
Mikael Berthe <mikael@lilotux.net>
parents:
760
diff
changeset
|
4308 |
int i; |
4532a9fe0e8c
Handle some keyboard escape sequences
Mikael Berthe <mikael@lilotux.net>
parents:
760
diff
changeset
|
4309 |
|
4532a9fe0e8c
Handle some keyboard escape sequences
Mikael Berthe <mikael@lilotux.net>
parents:
760
diff
changeset
|
4310 |
memset(kcode, 0, sizeof(keycode)); |
4532a9fe0e8c
Handle some keyboard escape sequences
Mikael Berthe <mikael@lilotux.net>
parents:
760
diff
changeset
|
4311 |
memset(ks, 0, sizeof(ks)); |
4532a9fe0e8c
Handle some keyboard escape sequences
Mikael Berthe <mikael@lilotux.net>
parents:
760
diff
changeset
|
4312 |
|
4532a9fe0e8c
Handle some keyboard escape sequences
Mikael Berthe <mikael@lilotux.net>
parents:
760
diff
changeset
|
4313 |
kcode->value = wgetch(inputWnd); |
930
a75f7a13df7b
UTF-8 terminal support (Reimar Döffinger)
Mikael Berthe <mikael@lilotux.net>
parents:
929
diff
changeset
|
4314 |
if (utf8_mode) { |
1058 | 4315 |
bool ismeta = (kcode->value == 27); |
1561 | 4316 |
#ifdef NCURSES_MOUSE_VERSION |
4317 |
bool ismouse = (kcode->value == KEY_MOUSE); |
|
4318 |
||
4319 |
if (ismouse) { |
|
4320 |
MEVENT mouse; |
|
4321 |
getmouse(&mouse); |
|
4322 |
kcode->value = mouse.bstate; |
|
4323 |
kcode->mcode = MKEY_MOUSE; |
|
4324 |
return; |
|
4325 |
} else if (ismeta) |
|
4326 |
#else |
|
1058 | 4327 |
if (ismeta) |
1561 | 4328 |
#endif |
944
aec71ebf98fa
Fix Meta + UTF-8 character
Mikael Berthe <mikael@lilotux.net>
parents:
940
diff
changeset
|
4329 |
ks[0] = wgetch(inputWnd); |
aec71ebf98fa
Fix Meta + UTF-8 character
Mikael Berthe <mikael@lilotux.net>
parents:
940
diff
changeset
|
4330 |
else |
aec71ebf98fa
Fix Meta + UTF-8 character
Mikael Berthe <mikael@lilotux.net>
parents:
940
diff
changeset
|
4331 |
ks[0] = kcode->value; |
aec71ebf98fa
Fix Meta + UTF-8 character
Mikael Berthe <mikael@lilotux.net>
parents:
940
diff
changeset
|
4332 |
|
930
a75f7a13df7b
UTF-8 terminal support (Reimar Döffinger)
Mikael Berthe <mikael@lilotux.net>
parents:
929
diff
changeset
|
4333 |
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
|
4334 |
int match = match_utf8_keyseq(ks); |
a75f7a13df7b
UTF-8 terminal support (Reimar Döffinger)
Mikael Berthe <mikael@lilotux.net>
parents:
929
diff
changeset
|
4335 |
if (match == -1) |
a75f7a13df7b
UTF-8 terminal support (Reimar Döffinger)
Mikael Berthe <mikael@lilotux.net>
parents:
929
diff
changeset
|
4336 |
break; |
a75f7a13df7b
UTF-8 terminal support (Reimar Döffinger)
Mikael Berthe <mikael@lilotux.net>
parents:
929
diff
changeset
|
4337 |
if (match > 0) { |
a75f7a13df7b
UTF-8 terminal support (Reimar Döffinger)
Mikael Berthe <mikael@lilotux.net>
parents:
929
diff
changeset
|
4338 |
kcode->value = match; |
a75f7a13df7b
UTF-8 terminal support (Reimar Döffinger)
Mikael Berthe <mikael@lilotux.net>
parents:
929
diff
changeset
|
4339 |
kcode->utf8 = 1; |
1058 | 4340 |
if (ismeta) |
944
aec71ebf98fa
Fix Meta + UTF-8 character
Mikael Berthe <mikael@lilotux.net>
parents:
940
diff
changeset
|
4341 |
kcode->mcode = MKEY_META; |
930
a75f7a13df7b
UTF-8 terminal support (Reimar Döffinger)
Mikael Berthe <mikael@lilotux.net>
parents:
929
diff
changeset
|
4342 |
return; |
a75f7a13df7b
UTF-8 terminal support (Reimar Döffinger)
Mikael Berthe <mikael@lilotux.net>
parents:
929
diff
changeset
|
4343 |
} |
a75f7a13df7b
UTF-8 terminal support (Reimar Döffinger)
Mikael Berthe <mikael@lilotux.net>
parents:
929
diff
changeset
|
4344 |
ks[i + 1] = wgetch(inputWnd); |
a75f7a13df7b
UTF-8 terminal support (Reimar Döffinger)
Mikael Berthe <mikael@lilotux.net>
parents:
929
diff
changeset
|
4345 |
if (ks[i + 1] == ERR) |
a75f7a13df7b
UTF-8 terminal support (Reimar Döffinger)
Mikael Berthe <mikael@lilotux.net>
parents:
929
diff
changeset
|
4346 |
break; |
a75f7a13df7b
UTF-8 terminal support (Reimar Döffinger)
Mikael Berthe <mikael@lilotux.net>
parents:
929
diff
changeset
|
4347 |
} |
a75f7a13df7b
UTF-8 terminal support (Reimar Döffinger)
Mikael Berthe <mikael@lilotux.net>
parents:
929
diff
changeset
|
4348 |
while (i > 0) |
a75f7a13df7b
UTF-8 terminal support (Reimar Döffinger)
Mikael Berthe <mikael@lilotux.net>
parents:
929
diff
changeset
|
4349 |
ungetch(ks[i--]); |
1058 | 4350 |
if (ismeta) |
944
aec71ebf98fa
Fix Meta + UTF-8 character
Mikael Berthe <mikael@lilotux.net>
parents:
940
diff
changeset
|
4351 |
ungetch(ks[0]); |
930
a75f7a13df7b
UTF-8 terminal support (Reimar Döffinger)
Mikael Berthe <mikael@lilotux.net>
parents:
929
diff
changeset
|
4352 |
memset(ks, 0, sizeof(ks)); |
a75f7a13df7b
UTF-8 terminal support (Reimar Döffinger)
Mikael Berthe <mikael@lilotux.net>
parents:
929
diff
changeset
|
4353 |
} |
761
4532a9fe0e8c
Handle some keyboard escape sequences
Mikael Berthe <mikael@lilotux.net>
parents:
760
diff
changeset
|
4354 |
if (kcode->value != 27) |
4532a9fe0e8c
Handle some keyboard escape sequences
Mikael Berthe <mikael@lilotux.net>
parents:
760
diff
changeset
|
4355 |
return; |
4532a9fe0e8c
Handle some keyboard escape sequences
Mikael Berthe <mikael@lilotux.net>
parents:
760
diff
changeset
|
4356 |
|
4532a9fe0e8c
Handle some keyboard escape sequences
Mikael Berthe <mikael@lilotux.net>
parents:
760
diff
changeset
|
4357 |
// Check for escape key sequence |
4532a9fe0e8c
Handle some keyboard escape sequences
Mikael Berthe <mikael@lilotux.net>
parents:
760
diff
changeset
|
4358 |
for (i=0; i < MAX_KEYSEQ_LENGTH; i++) { |
4532a9fe0e8c
Handle some keyboard escape sequences
Mikael Berthe <mikael@lilotux.net>
parents:
760
diff
changeset
|
4359 |
int match; |
4532a9fe0e8c
Handle some keyboard escape sequences
Mikael Berthe <mikael@lilotux.net>
parents:
760
diff
changeset
|
4360 |
ks[i] = wgetch(inputWnd); |
4532a9fe0e8c
Handle some keyboard escape sequences
Mikael Berthe <mikael@lilotux.net>
parents:
760
diff
changeset
|
4361 |
if (ks[i] == ERR) break; |
4532a9fe0e8c
Handle some keyboard escape sequences
Mikael Berthe <mikael@lilotux.net>
parents:
760
diff
changeset
|
4362 |
match = match_keyseq(ks, &mks); |
4532a9fe0e8c
Handle some keyboard escape sequences
Mikael Berthe <mikael@lilotux.net>
parents:
760
diff
changeset
|
4363 |
if (match == -1) { |
4532a9fe0e8c
Handle some keyboard escape sequences
Mikael Berthe <mikael@lilotux.net>
parents:
760
diff
changeset
|
4364 |
// 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
|
4365 |
i++; |
4532a9fe0e8c
Handle some keyboard escape sequences
Mikael Berthe <mikael@lilotux.net>
parents:
760
diff
changeset
|
4366 |
break; |
4532a9fe0e8c
Handle some keyboard escape sequences
Mikael Berthe <mikael@lilotux.net>
parents:
760
diff
changeset
|
4367 |
} |
4532a9fe0e8c
Handle some keyboard escape sequences
Mikael Berthe <mikael@lilotux.net>
parents:
760
diff
changeset
|
4368 |
if (match > 0) { |
4532a9fe0e8c
Handle some keyboard escape sequences
Mikael Berthe <mikael@lilotux.net>
parents:
760
diff
changeset
|
4369 |
// We have a matching sequence |
4532a9fe0e8c
Handle some keyboard escape sequences
Mikael Berthe <mikael@lilotux.net>
parents:
760
diff
changeset
|
4370 |
kcode->mcode = mks->mkeycode; |
4532a9fe0e8c
Handle some keyboard escape sequences
Mikael Berthe <mikael@lilotux.net>
parents:
760
diff
changeset
|
4371 |
kcode->value = mks->value; |
4532a9fe0e8c
Handle some keyboard escape sequences
Mikael Berthe <mikael@lilotux.net>
parents:
760
diff
changeset
|
4372 |
return; |
4532a9fe0e8c
Handle some keyboard escape sequences
Mikael Berthe <mikael@lilotux.net>
parents:
760
diff
changeset
|
4373 |
} |
4532a9fe0e8c
Handle some keyboard escape sequences
Mikael Berthe <mikael@lilotux.net>
parents:
760
diff
changeset
|
4374 |
} |
4532a9fe0e8c
Handle some keyboard escape sequences
Mikael Berthe <mikael@lilotux.net>
parents:
760
diff
changeset
|
4375 |
|
4532a9fe0e8c
Handle some keyboard escape sequences
Mikael Berthe <mikael@lilotux.net>
parents:
760
diff
changeset
|
4376 |
// No match. Let's return a meta-key. |
4532a9fe0e8c
Handle some keyboard escape sequences
Mikael Berthe <mikael@lilotux.net>
parents:
760
diff
changeset
|
4377 |
if (i > 0) { |
4532a9fe0e8c
Handle some keyboard escape sequences
Mikael Berthe <mikael@lilotux.net>
parents:
760
diff
changeset
|
4378 |
kcode->mcode = MKEY_META; |
4532a9fe0e8c
Handle some keyboard escape sequences
Mikael Berthe <mikael@lilotux.net>
parents:
760
diff
changeset
|
4379 |
kcode->value = ks[0]; |
4532a9fe0e8c
Handle some keyboard escape sequences
Mikael Berthe <mikael@lilotux.net>
parents:
760
diff
changeset
|
4380 |
} |
4532a9fe0e8c
Handle some keyboard escape sequences
Mikael Berthe <mikael@lilotux.net>
parents:
760
diff
changeset
|
4381 |
if (i > 1) { |
4532a9fe0e8c
Handle some keyboard escape sequences
Mikael Berthe <mikael@lilotux.net>
parents:
760
diff
changeset
|
4382 |
// 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
|
4383 |
while (i-- > 1) |
4532a9fe0e8c
Handle some keyboard escape sequences
Mikael Berthe <mikael@lilotux.net>
parents:
760
diff
changeset
|
4384 |
ungetch(ks[i]); |
4532a9fe0e8c
Handle some keyboard escape sequences
Mikael Berthe <mikael@lilotux.net>
parents:
760
diff
changeset
|
4385 |
} |
4532a9fe0e8c
Handle some keyboard escape sequences
Mikael Berthe <mikael@lilotux.net>
parents:
760
diff
changeset
|
4386 |
return; |
373
af2f8ddf6a1b
Move (reorganize) functions
Mikael Berthe <mikael@lilotux.net>
parents:
370
diff
changeset
|
4387 |
} |
af2f8ddf6a1b
Move (reorganize) functions
Mikael Berthe <mikael@lilotux.net>
parents:
370
diff
changeset
|
4388 |
|
1780
e4378fbab5d7
Major API cleanup - bump API to 4
Mikael Berthe <mikael@lilotux.net>
parents:
1761
diff
changeset
|
4389 |
void scr_do_update(void) |
939
12fa2ae6445d
Get rid of "busy-waiting" (Christof Meerwald)
Mikael Berthe <mikael@lilotux.net>
parents:
936
diff
changeset
|
4390 |
{ |
1942
3e39a336a992
Use guards for colors (Myhailo Danylenko)
Mikael Berthe <mikael@lilotux.net>
parents:
1935
diff
changeset
|
4391 |
if (colors_stalled) |
3e39a336a992
Use guards for colors (Myhailo Danylenko)
Mikael Berthe <mikael@lilotux.net>
parents:
1935
diff
changeset
|
4392 |
parse_colors(); |
939
12fa2ae6445d
Get rid of "busy-waiting" (Christof Meerwald)
Mikael Berthe <mikael@lilotux.net>
parents:
936
diff
changeset
|
4393 |
doupdate(); |
12fa2ae6445d
Get rid of "busy-waiting" (Christof Meerwald)
Mikael Berthe <mikael@lilotux.net>
parents:
936
diff
changeset
|
4394 |
} |
12fa2ae6445d
Get rid of "busy-waiting" (Christof Meerwald)
Mikael Berthe <mikael@lilotux.net>
parents:
936
diff
changeset
|
4395 |
|
2164 | 4396 |
static void bindcommand(keycode kcode) |
930
a75f7a13df7b
UTF-8 terminal support (Reimar Döffinger)
Mikael Berthe <mikael@lilotux.net>
parents:
929
diff
changeset
|
4397 |
{ |
945
17ef145f3326
Display and use UTF-8 key codes
Mikael Berthe <mikael@lilotux.net>
parents:
944
diff
changeset
|
4398 |
gchar asciikey[16], asciicode[16]; |
764
4e15322d315e
Allow binding of meta keys
Mikael Berthe <mikael@lilotux.net>
parents:
763
diff
changeset
|
4399 |
const gchar *boundcmd; |
4e15322d315e
Allow binding of meta keys
Mikael Berthe <mikael@lilotux.net>
parents:
763
diff
changeset
|
4400 |
|
945
17ef145f3326
Display and use UTF-8 key codes
Mikael Berthe <mikael@lilotux.net>
parents:
944
diff
changeset
|
4401 |
if (kcode.utf8) |
17ef145f3326
Display and use UTF-8 key codes
Mikael Berthe <mikael@lilotux.net>
parents:
944
diff
changeset
|
4402 |
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
|
4403 |
else |
17ef145f3326
Display and use UTF-8 key codes
Mikael Berthe <mikael@lilotux.net>
parents:
944
diff
changeset
|
4404 |
g_snprintf(asciicode, 15, "%d", kcode.value); |
17ef145f3326
Display and use UTF-8 key codes
Mikael Berthe <mikael@lilotux.net>
parents:
944
diff
changeset
|
4405 |
|
764
4e15322d315e
Allow binding of meta keys
Mikael Berthe <mikael@lilotux.net>
parents:
763
diff
changeset
|
4406 |
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
|
4407 |
g_snprintf(asciikey, 15, "%s", asciicode); |
764
4e15322d315e
Allow binding of meta keys
Mikael Berthe <mikael@lilotux.net>
parents:
763
diff
changeset
|
4408 |
else if (kcode.mcode == MKEY_META) |
945
17ef145f3326
Display and use UTF-8 key codes
Mikael Berthe <mikael@lilotux.net>
parents:
944
diff
changeset
|
4409 |
g_snprintf(asciikey, 15, "M%s", asciicode); |
1561 | 4410 |
else if (kcode.mcode == MKEY_MOUSE) |
4411 |
g_snprintf(asciikey, 15, "p%s", asciicode); |
|
764
4e15322d315e
Allow binding of meta keys
Mikael Berthe <mikael@lilotux.net>
parents:
763
diff
changeset
|
4412 |
else |
949
e3c49b2f8143
Fix bindings of special keys (MK*)
Mikael Berthe <mikael@lilotux.net>
parents:
945
diff
changeset
|
4413 |
g_snprintf(asciikey, 15, "MK%d", kcode.mcode); |
764
4e15322d315e
Allow binding of meta keys
Mikael Berthe <mikael@lilotux.net>
parents:
763
diff
changeset
|
4414 |
|
4e15322d315e
Allow binding of meta keys
Mikael Berthe <mikael@lilotux.net>
parents:
763
diff
changeset
|
4415 |
boundcmd = settings_get(SETTINGS_TYPE_BINDING, asciikey); |
4e15322d315e
Allow binding of meta keys
Mikael Berthe <mikael@lilotux.net>
parents:
763
diff
changeset
|
4416 |
|
4e15322d315e
Allow binding of meta keys
Mikael Berthe <mikael@lilotux.net>
parents:
763
diff
changeset
|
4417 |
if (boundcmd) { |
1357
7bbfb0073f88
Fix an UTF-8 problem in new hook_execute_internal() function
Mikael Berthe <mikael@lilotux.net>
parents:
1355
diff
changeset
|
4418 |
gchar *cmdline = from_utf8(boundcmd); |
1780
e4378fbab5d7
Major API cleanup - bump API to 4
Mikael Berthe <mikael@lilotux.net>
parents:
1761
diff
changeset
|
4419 |
scr_check_auto_away(TRUE); |
2164 | 4420 |
process_command(cmdline, TRUE); |
1058 | 4421 |
g_free(cmdline); |
2164 | 4422 |
return; |
764
4e15322d315e
Allow binding of meta keys
Mikael Berthe <mikael@lilotux.net>
parents:
763
diff
changeset
|
4423 |
} |
4e15322d315e
Allow binding of meta keys
Mikael Berthe <mikael@lilotux.net>
parents:
763
diff
changeset
|
4424 |
|
4e15322d315e
Allow binding of meta keys
Mikael Berthe <mikael@lilotux.net>
parents:
763
diff
changeset
|
4425 |
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
|
4426 |
#ifndef UNICODE |
764
4e15322d315e
Allow binding of meta keys
Mikael Berthe <mikael@lilotux.net>
parents:
763
diff
changeset
|
4427 |
if (utf8_mode) |
930
a75f7a13df7b
UTF-8 terminal support (Reimar Döffinger)
Mikael Berthe <mikael@lilotux.net>
parents:
929
diff
changeset
|
4428 |
scr_LogPrint(LPRINT_NORMAL, |
a75f7a13df7b
UTF-8 terminal support (Reimar Döffinger)
Mikael Berthe <mikael@lilotux.net>
parents:
929
diff
changeset
|
4429 |
"WARNING: Compiled without full UTF-8 support!"); |
a75f7a13df7b
UTF-8 terminal support (Reimar Döffinger)
Mikael Berthe <mikael@lilotux.net>
parents:
929
diff
changeset
|
4430 |
#endif |
764
4e15322d315e
Allow binding of meta keys
Mikael Berthe <mikael@lilotux.net>
parents:
763
diff
changeset
|
4431 |
} |
4e15322d315e
Allow binding of meta keys
Mikael Berthe <mikael@lilotux.net>
parents:
763
diff
changeset
|
4432 |
|
2304
fa8365fb6ac2
[PATCH 1/3] New option: vi_mode
Holger Weiß <holger@zedat.fu-berlin.de>
parents:
2292
diff
changeset
|
4433 |
static void scr_process_vi_arrow_key(int key) |
fa8365fb6ac2
[PATCH 1/3] New option: vi_mode
Holger Weiß <holger@zedat.fu-berlin.de>
parents:
2292
diff
changeset
|
4434 |
{ |
fa8365fb6ac2
[PATCH 1/3] New option: vi_mode
Holger Weiß <holger@zedat.fu-berlin.de>
parents:
2292
diff
changeset
|
4435 |
const char *l; |
fa8365fb6ac2
[PATCH 1/3] New option: vi_mode
Holger Weiß <holger@zedat.fu-berlin.de>
parents:
2292
diff
changeset
|
4436 |
char mask[INPUTLINE_LENGTH+1] = "/roster search "; |
fa8365fb6ac2
[PATCH 1/3] New option: vi_mode
Holger Weiß <holger@zedat.fu-berlin.de>
parents:
2292
diff
changeset
|
4437 |
size_t cmd_len = strlen(mask); |
fa8365fb6ac2
[PATCH 1/3] New option: vi_mode
Holger Weiß <holger@zedat.fu-berlin.de>
parents:
2292
diff
changeset
|
4438 |
size_t str_len = strlen(inputLine) - 1; |
fa8365fb6ac2
[PATCH 1/3] New option: vi_mode
Holger Weiß <holger@zedat.fu-berlin.de>
parents:
2292
diff
changeset
|
4439 |
|
fa8365fb6ac2
[PATCH 1/3] New option: vi_mode
Holger Weiß <holger@zedat.fu-berlin.de>
parents:
2292
diff
changeset
|
4440 |
switch (inputLine[0]) { |
fa8365fb6ac2
[PATCH 1/3] New option: vi_mode
Holger Weiß <holger@zedat.fu-berlin.de>
parents:
2292
diff
changeset
|
4441 |
case ':': |
fa8365fb6ac2
[PATCH 1/3] New option: vi_mode
Holger Weiß <holger@zedat.fu-berlin.de>
parents:
2292
diff
changeset
|
4442 |
inputLine[0] = '/'; |
fa8365fb6ac2
[PATCH 1/3] New option: vi_mode
Holger Weiß <holger@zedat.fu-berlin.de>
parents:
2292
diff
changeset
|
4443 |
if (key == KEY_UP) |
fa8365fb6ac2
[PATCH 1/3] New option: vi_mode
Holger Weiß <holger@zedat.fu-berlin.de>
parents:
2292
diff
changeset
|
4444 |
l = scr_cmdhisto_prev(inputLine, ptr_inputline - inputLine); |
fa8365fb6ac2
[PATCH 1/3] New option: vi_mode
Holger Weiß <holger@zedat.fu-berlin.de>
parents:
2292
diff
changeset
|
4445 |
else |
fa8365fb6ac2
[PATCH 1/3] New option: vi_mode
Holger Weiß <holger@zedat.fu-berlin.de>
parents:
2292
diff
changeset
|
4446 |
l = scr_cmdhisto_next(inputLine, ptr_inputline - inputLine); |
fa8365fb6ac2
[PATCH 1/3] New option: vi_mode
Holger Weiß <holger@zedat.fu-berlin.de>
parents:
2292
diff
changeset
|
4447 |
if (l) |
fa8365fb6ac2
[PATCH 1/3] New option: vi_mode
Holger Weiß <holger@zedat.fu-berlin.de>
parents:
2292
diff
changeset
|
4448 |
strcpy(inputLine, l); |
fa8365fb6ac2
[PATCH 1/3] New option: vi_mode
Holger Weiß <holger@zedat.fu-berlin.de>
parents:
2292
diff
changeset
|
4449 |
inputLine[0] = ':'; |
fa8365fb6ac2
[PATCH 1/3] New option: vi_mode
Holger Weiß <holger@zedat.fu-berlin.de>
parents:
2292
diff
changeset
|
4450 |
break; |
fa8365fb6ac2
[PATCH 1/3] New option: vi_mode
Holger Weiß <holger@zedat.fu-berlin.de>
parents:
2292
diff
changeset
|
4451 |
case '/': |
fa8365fb6ac2
[PATCH 1/3] New option: vi_mode
Holger Weiß <holger@zedat.fu-berlin.de>
parents:
2292
diff
changeset
|
4452 |
if (cmd_len + str_len > INPUTLINE_LENGTH) |
fa8365fb6ac2
[PATCH 1/3] New option: vi_mode
Holger Weiß <holger@zedat.fu-berlin.de>
parents:
2292
diff
changeset
|
4453 |
return; |
fa8365fb6ac2
[PATCH 1/3] New option: vi_mode
Holger Weiß <holger@zedat.fu-berlin.de>
parents:
2292
diff
changeset
|
4454 |
|
fa8365fb6ac2
[PATCH 1/3] New option: vi_mode
Holger Weiß <holger@zedat.fu-berlin.de>
parents:
2292
diff
changeset
|
4455 |
memcpy(mask + cmd_len, inputLine + 1, str_len + 1); |
fa8365fb6ac2
[PATCH 1/3] New option: vi_mode
Holger Weiß <holger@zedat.fu-berlin.de>
parents:
2292
diff
changeset
|
4456 |
if (key == KEY_UP) |
fa8365fb6ac2
[PATCH 1/3] New option: vi_mode
Holger Weiß <holger@zedat.fu-berlin.de>
parents:
2292
diff
changeset
|
4457 |
l = scr_cmdhisto_prev(mask, ptr_inputline - inputLine + cmd_len - 1); |
fa8365fb6ac2
[PATCH 1/3] New option: vi_mode
Holger Weiß <holger@zedat.fu-berlin.de>
parents:
2292
diff
changeset
|
4458 |
else |
fa8365fb6ac2
[PATCH 1/3] New option: vi_mode
Holger Weiß <holger@zedat.fu-berlin.de>
parents:
2292
diff
changeset
|
4459 |
l = scr_cmdhisto_next(mask, ptr_inputline - inputLine + cmd_len - 1); |
fa8365fb6ac2
[PATCH 1/3] New option: vi_mode
Holger Weiß <holger@zedat.fu-berlin.de>
parents:
2292
diff
changeset
|
4460 |
if (l) |
fa8365fb6ac2
[PATCH 1/3] New option: vi_mode
Holger Weiß <holger@zedat.fu-berlin.de>
parents:
2292
diff
changeset
|
4461 |
strcpy(inputLine + 1, l + cmd_len); |
fa8365fb6ac2
[PATCH 1/3] New option: vi_mode
Holger Weiß <holger@zedat.fu-berlin.de>
parents:
2292
diff
changeset
|
4462 |
break; |
fa8365fb6ac2
[PATCH 1/3] New option: vi_mode
Holger Weiß <holger@zedat.fu-berlin.de>
parents:
2292
diff
changeset
|
4463 |
default: |
fa8365fb6ac2
[PATCH 1/3] New option: vi_mode
Holger Weiß <holger@zedat.fu-berlin.de>
parents:
2292
diff
changeset
|
4464 |
if (key == KEY_UP) |
fa8365fb6ac2
[PATCH 1/3] New option: vi_mode
Holger Weiß <holger@zedat.fu-berlin.de>
parents:
2292
diff
changeset
|
4465 |
process_command(mkcmdstr("roster up"), TRUE); |
fa8365fb6ac2
[PATCH 1/3] New option: vi_mode
Holger Weiß <holger@zedat.fu-berlin.de>
parents:
2292
diff
changeset
|
4466 |
else |
fa8365fb6ac2
[PATCH 1/3] New option: vi_mode
Holger Weiß <holger@zedat.fu-berlin.de>
parents:
2292
diff
changeset
|
4467 |
process_command(mkcmdstr("roster down"), TRUE); |
fa8365fb6ac2
[PATCH 1/3] New option: vi_mode
Holger Weiß <holger@zedat.fu-berlin.de>
parents:
2292
diff
changeset
|
4468 |
break; |
fa8365fb6ac2
[PATCH 1/3] New option: vi_mode
Holger Weiß <holger@zedat.fu-berlin.de>
parents:
2292
diff
changeset
|
4469 |
} |
fa8365fb6ac2
[PATCH 1/3] New option: vi_mode
Holger Weiß <holger@zedat.fu-berlin.de>
parents:
2292
diff
changeset
|
4470 |
} |
fa8365fb6ac2
[PATCH 1/3] New option: vi_mode
Holger Weiß <holger@zedat.fu-berlin.de>
parents:
2292
diff
changeset
|
4471 |
|
1780
e4378fbab5d7
Major API cleanup - bump API to 4
Mikael Berthe <mikael@lilotux.net>
parents:
1761
diff
changeset
|
4472 |
// scr_process_key(key) |
44 | 4473 |
// 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
|
4474 |
void scr_process_key(keycode kcode) |
24 | 4475 |
{ |
761
4532a9fe0e8c
Handle some keyboard escape sequences
Mikael Berthe <mikael@lilotux.net>
parents:
760
diff
changeset
|
4476 |
int key = kcode.value; |
931
1cd6d694ac3c
Fix display of some UTF-8 chars
Mikael Berthe <mikael@lilotux.net>
parents:
930
diff
changeset
|
4477 |
int display_char = FALSE; |
2304
fa8365fb6ac2
[PATCH 1/3] New option: vi_mode
Holger Weiß <holger@zedat.fu-berlin.de>
parents:
2292
diff
changeset
|
4478 |
int vi_completion = FALSE; |
2305
5b1a63dc2b1a
[PATCH 2/3] Don't complete "/search" string in vi mode
Holger Weiß <holger@zedat.fu-berlin.de>
parents:
2304
diff
changeset
|
4479 |
int vi_search = FALSE; |
2304
fa8365fb6ac2
[PATCH 1/3] New option: vi_mode
Holger Weiß <holger@zedat.fu-berlin.de>
parents:
2292
diff
changeset
|
4480 |
static int ex_or_search_mode = FALSE; |
761
4532a9fe0e8c
Handle some keyboard escape sequences
Mikael Berthe <mikael@lilotux.net>
parents:
760
diff
changeset
|
4481 |
|
1381
40095d413da9
Fix compilation on OpenBSD
Mikael Berthe <mikael@lilotux.net>
parents:
1376
diff
changeset
|
4482 |
lock_chatstate = FALSE; |
990
35e7913affb7
Send events/chatstates notifications (JEP-22/JEP-85)
Mikael Berthe <mikael@lilotux.net>
parents:
987
diff
changeset
|
4483 |
|
761
4532a9fe0e8c
Handle some keyboard escape sequences
Mikael Berthe <mikael@lilotux.net>
parents:
760
diff
changeset
|
4484 |
switch (kcode.mcode) { |
4532a9fe0e8c
Handle some keyboard escape sequences
Mikael Berthe <mikael@lilotux.net>
parents:
760
diff
changeset
|
4485 |
case 0: |
1918
0fa6df17bc5c
Fix potential issue pointed out by franky's clang report
Mikael Berthe <mikael@lilotux.net>
parents:
1915
diff
changeset
|
4486 |
// key = kcode.value; |
761
4532a9fe0e8c
Handle some keyboard escape sequences
Mikael Berthe <mikael@lilotux.net>
parents:
760
diff
changeset
|
4487 |
break; |
4532a9fe0e8c
Handle some keyboard escape sequences
Mikael Berthe <mikael@lilotux.net>
parents:
760
diff
changeset
|
4488 |
case MKEY_EQUIV: |
1918
0fa6df17bc5c
Fix potential issue pointed out by franky's clang report
Mikael Berthe <mikael@lilotux.net>
parents:
1915
diff
changeset
|
4489 |
// key = kcode.value; |
761
4532a9fe0e8c
Handle some keyboard escape sequences
Mikael Berthe <mikael@lilotux.net>
parents:
760
diff
changeset
|
4490 |
break; |
4532a9fe0e8c
Handle some keyboard escape sequences
Mikael Berthe <mikael@lilotux.net>
parents:
760
diff
changeset
|
4491 |
case MKEY_META: |
4532a9fe0e8c
Handle some keyboard escape sequences
Mikael Berthe <mikael@lilotux.net>
parents:
760
diff
changeset
|
4492 |
default: |
2164 | 4493 |
bindcommand(kcode); |
764
4e15322d315e
Allow binding of meta keys
Mikael Berthe <mikael@lilotux.net>
parents:
763
diff
changeset
|
4494 |
key = ERR; // Do not process any further |
758 | 4495 |
} |
761
4532a9fe0e8c
Handle some keyboard escape sequences
Mikael Berthe <mikael@lilotux.net>
parents:
760
diff
changeset
|
4496 |
|
2304
fa8365fb6ac2
[PATCH 1/3] New option: vi_mode
Holger Weiß <holger@zedat.fu-berlin.de>
parents:
2292
diff
changeset
|
4497 |
if (settings_opt_get_int("vi_mode") && !chatmode) { |
fa8365fb6ac2
[PATCH 1/3] New option: vi_mode
Holger Weiß <holger@zedat.fu-berlin.de>
parents:
2292
diff
changeset
|
4498 |
int got_cmd_prefix = FALSE; |
fa8365fb6ac2
[PATCH 1/3] New option: vi_mode
Holger Weiß <holger@zedat.fu-berlin.de>
parents:
2292
diff
changeset
|
4499 |
int unrecognized = FALSE; |
fa8365fb6ac2
[PATCH 1/3] New option: vi_mode
Holger Weiß <holger@zedat.fu-berlin.de>
parents:
2292
diff
changeset
|
4500 |
static char search_cmd[INPUTLINE_LENGTH+1] = "/roster search "; |
fa8365fb6ac2
[PATCH 1/3] New option: vi_mode
Holger Weiß <holger@zedat.fu-berlin.de>
parents:
2292
diff
changeset
|
4501 |
|
fa8365fb6ac2
[PATCH 1/3] New option: vi_mode
Holger Weiß <holger@zedat.fu-berlin.de>
parents:
2292
diff
changeset
|
4502 |
if (key == KEY_UP || key == KEY_DOWN) { |
fa8365fb6ac2
[PATCH 1/3] New option: vi_mode
Holger Weiß <holger@zedat.fu-berlin.de>
parents:
2292
diff
changeset
|
4503 |
scr_process_vi_arrow_key(key); |
fa8365fb6ac2
[PATCH 1/3] New option: vi_mode
Holger Weiß <holger@zedat.fu-berlin.de>
parents:
2292
diff
changeset
|
4504 |
key = ERR; // Do not process any further |
fa8365fb6ac2
[PATCH 1/3] New option: vi_mode
Holger Weiß <holger@zedat.fu-berlin.de>
parents:
2292
diff
changeset
|
4505 |
} else if (ex_or_search_mode) { |
fa8365fb6ac2
[PATCH 1/3] New option: vi_mode
Holger Weiß <holger@zedat.fu-berlin.de>
parents:
2292
diff
changeset
|
4506 |
switch (key) { |
fa8365fb6ac2
[PATCH 1/3] New option: vi_mode
Holger Weiß <holger@zedat.fu-berlin.de>
parents:
2292
diff
changeset
|
4507 |
case 27: // Escape |
fa8365fb6ac2
[PATCH 1/3] New option: vi_mode
Holger Weiß <holger@zedat.fu-berlin.de>
parents:
2292
diff
changeset
|
4508 |
clear_inputline(); |
fa8365fb6ac2
[PATCH 1/3] New option: vi_mode
Holger Weiß <holger@zedat.fu-berlin.de>
parents:
2292
diff
changeset
|
4509 |
ex_or_search_mode = FALSE; |
fa8365fb6ac2
[PATCH 1/3] New option: vi_mode
Holger Weiß <holger@zedat.fu-berlin.de>
parents:
2292
diff
changeset
|
4510 |
break; |
fa8365fb6ac2
[PATCH 1/3] New option: vi_mode
Holger Weiß <holger@zedat.fu-berlin.de>
parents:
2292
diff
changeset
|
4511 |
case 9: // Tab |
fa8365fb6ac2
[PATCH 1/3] New option: vi_mode
Holger Weiß <holger@zedat.fu-berlin.de>
parents:
2292
diff
changeset
|
4512 |
case 353: // Shift-Tab |
2305
5b1a63dc2b1a
[PATCH 2/3] Don't complete "/search" string in vi mode
Holger Weiß <holger@zedat.fu-berlin.de>
parents:
2304
diff
changeset
|
4513 |
switch (inputLine[0]) { |
5b1a63dc2b1a
[PATCH 2/3] Don't complete "/search" string in vi mode
Holger Weiß <holger@zedat.fu-berlin.de>
parents:
2304
diff
changeset
|
4514 |
case ':': |
5b1a63dc2b1a
[PATCH 2/3] Don't complete "/search" string in vi mode
Holger Weiß <holger@zedat.fu-berlin.de>
parents:
2304
diff
changeset
|
4515 |
inputLine[0] = '/'; |
5b1a63dc2b1a
[PATCH 2/3] Don't complete "/search" string in vi mode
Holger Weiß <holger@zedat.fu-berlin.de>
parents:
2304
diff
changeset
|
4516 |
vi_completion = TRUE; |
5b1a63dc2b1a
[PATCH 2/3] Don't complete "/search" string in vi mode
Holger Weiß <holger@zedat.fu-berlin.de>
parents:
2304
diff
changeset
|
4517 |
break; |
5b1a63dc2b1a
[PATCH 2/3] Don't complete "/search" string in vi mode
Holger Weiß <holger@zedat.fu-berlin.de>
parents:
2304
diff
changeset
|
4518 |
case '/': |
5b1a63dc2b1a
[PATCH 2/3] Don't complete "/search" string in vi mode
Holger Weiß <holger@zedat.fu-berlin.de>
parents:
2304
diff
changeset
|
4519 |
vi_search = TRUE; |
5b1a63dc2b1a
[PATCH 2/3] Don't complete "/search" string in vi mode
Holger Weiß <holger@zedat.fu-berlin.de>
parents:
2304
diff
changeset
|
4520 |
break; |
2304
fa8365fb6ac2
[PATCH 1/3] New option: vi_mode
Holger Weiß <holger@zedat.fu-berlin.de>
parents:
2292
diff
changeset
|
4521 |
} |
fa8365fb6ac2
[PATCH 1/3] New option: vi_mode
Holger Weiß <holger@zedat.fu-berlin.de>
parents:
2292
diff
changeset
|
4522 |
break; |
fa8365fb6ac2
[PATCH 1/3] New option: vi_mode
Holger Weiß <holger@zedat.fu-berlin.de>
parents:
2292
diff
changeset
|
4523 |
case 13: // Enter |
fa8365fb6ac2
[PATCH 1/3] New option: vi_mode
Holger Weiß <holger@zedat.fu-berlin.de>
parents:
2292
diff
changeset
|
4524 |
case 343: // Enter on Maemo |
fa8365fb6ac2
[PATCH 1/3] New option: vi_mode
Holger Weiß <holger@zedat.fu-berlin.de>
parents:
2292
diff
changeset
|
4525 |
switch (inputLine[0]) { |
fa8365fb6ac2
[PATCH 1/3] New option: vi_mode
Holger Weiß <holger@zedat.fu-berlin.de>
parents:
2292
diff
changeset
|
4526 |
case ':': |
fa8365fb6ac2
[PATCH 1/3] New option: vi_mode
Holger Weiß <holger@zedat.fu-berlin.de>
parents:
2292
diff
changeset
|
4527 |
{ |
fa8365fb6ac2
[PATCH 1/3] New option: vi_mode
Holger Weiß <holger@zedat.fu-berlin.de>
parents:
2292
diff
changeset
|
4528 |
char *p = strchr(inputLine, 0); |
fa8365fb6ac2
[PATCH 1/3] New option: vi_mode
Holger Weiß <holger@zedat.fu-berlin.de>
parents:
2292
diff
changeset
|
4529 |
|
fa8365fb6ac2
[PATCH 1/3] New option: vi_mode
Holger Weiß <holger@zedat.fu-berlin.de>
parents:
2292
diff
changeset
|
4530 |
while (*--p == ' ' && p > inputLine) |
fa8365fb6ac2
[PATCH 1/3] New option: vi_mode
Holger Weiß <holger@zedat.fu-berlin.de>
parents:
2292
diff
changeset
|
4531 |
*p = 0; |
fa8365fb6ac2
[PATCH 1/3] New option: vi_mode
Holger Weiß <holger@zedat.fu-berlin.de>
parents:
2292
diff
changeset
|
4532 |
} |
fa8365fb6ac2
[PATCH 1/3] New option: vi_mode
Holger Weiß <holger@zedat.fu-berlin.de>
parents:
2292
diff
changeset
|
4533 |
if (!strcmp(inputLine, ":x") || |
fa8365fb6ac2
[PATCH 1/3] New option: vi_mode
Holger Weiß <holger@zedat.fu-berlin.de>
parents:
2292
diff
changeset
|
4534 |
!strcmp(inputLine, ":q") || |
fa8365fb6ac2
[PATCH 1/3] New option: vi_mode
Holger Weiß <holger@zedat.fu-berlin.de>
parents:
2292
diff
changeset
|
4535 |
!strcmp(inputLine, ":wq")) |
fa8365fb6ac2
[PATCH 1/3] New option: vi_mode
Holger Weiß <holger@zedat.fu-berlin.de>
parents:
2292
diff
changeset
|
4536 |
strcpy(inputLine, ":quit"); |
fa8365fb6ac2
[PATCH 1/3] New option: vi_mode
Holger Weiß <holger@zedat.fu-berlin.de>
parents:
2292
diff
changeset
|
4537 |
if (isdigit((int)(unsigned char)inputLine[1]) && |
fa8365fb6ac2
[PATCH 1/3] New option: vi_mode
Holger Weiß <holger@zedat.fu-berlin.de>
parents:
2292
diff
changeset
|
4538 |
strlen(inputLine) <= 9) { |
fa8365fb6ac2
[PATCH 1/3] New option: vi_mode
Holger Weiß <holger@zedat.fu-berlin.de>
parents:
2292
diff
changeset
|
4539 |
process_command(mkcmdstr("roster top"), TRUE); |
fa8365fb6ac2
[PATCH 1/3] New option: vi_mode
Holger Weiß <holger@zedat.fu-berlin.de>
parents:
2292
diff
changeset
|
4540 |
memcpy(inputLine + 13, inputLine + 1, 10); |
fa8365fb6ac2
[PATCH 1/3] New option: vi_mode
Holger Weiß <holger@zedat.fu-berlin.de>
parents:
2292
diff
changeset
|
4541 |
memcpy(inputLine + 1, "roster down ", 12); |
fa8365fb6ac2
[PATCH 1/3] New option: vi_mode
Holger Weiß <holger@zedat.fu-berlin.de>
parents:
2292
diff
changeset
|
4542 |
} |
fa8365fb6ac2
[PATCH 1/3] New option: vi_mode
Holger Weiß <holger@zedat.fu-berlin.de>
parents:
2292
diff
changeset
|
4543 |
inputLine[0] = '/'; |
fa8365fb6ac2
[PATCH 1/3] New option: vi_mode
Holger Weiß <holger@zedat.fu-berlin.de>
parents:
2292
diff
changeset
|
4544 |
process_command(inputLine, TRUE); |
fa8365fb6ac2
[PATCH 1/3] New option: vi_mode
Holger Weiß <holger@zedat.fu-berlin.de>
parents:
2292
diff
changeset
|
4545 |
scr_cmdhisto_addline(inputLine); |
fa8365fb6ac2
[PATCH 1/3] New option: vi_mode
Holger Weiß <holger@zedat.fu-berlin.de>
parents:
2292
diff
changeset
|
4546 |
break; |
fa8365fb6ac2
[PATCH 1/3] New option: vi_mode
Holger Weiß <holger@zedat.fu-berlin.de>
parents:
2292
diff
changeset
|
4547 |
case '/': |
fa8365fb6ac2
[PATCH 1/3] New option: vi_mode
Holger Weiß <holger@zedat.fu-berlin.de>
parents:
2292
diff
changeset
|
4548 |
{ |
fa8365fb6ac2
[PATCH 1/3] New option: vi_mode
Holger Weiß <holger@zedat.fu-berlin.de>
parents:
2292
diff
changeset
|
4549 |
size_t cmd_len = sizeof("/roster search ") - 1; |
fa8365fb6ac2
[PATCH 1/3] New option: vi_mode
Holger Weiß <holger@zedat.fu-berlin.de>
parents:
2292
diff
changeset
|
4550 |
size_t str_len = strlen(inputLine) - 1; |
fa8365fb6ac2
[PATCH 1/3] New option: vi_mode
Holger Weiß <holger@zedat.fu-berlin.de>
parents:
2292
diff
changeset
|
4551 |
|
fa8365fb6ac2
[PATCH 1/3] New option: vi_mode
Holger Weiß <holger@zedat.fu-berlin.de>
parents:
2292
diff
changeset
|
4552 |
if (cmd_len + str_len > INPUTLINE_LENGTH) |
fa8365fb6ac2
[PATCH 1/3] New option: vi_mode
Holger Weiß <holger@zedat.fu-berlin.de>
parents:
2292
diff
changeset
|
4553 |
return; |
fa8365fb6ac2
[PATCH 1/3] New option: vi_mode
Holger Weiß <holger@zedat.fu-berlin.de>
parents:
2292
diff
changeset
|
4554 |
|
fa8365fb6ac2
[PATCH 1/3] New option: vi_mode
Holger Weiß <holger@zedat.fu-berlin.de>
parents:
2292
diff
changeset
|
4555 |
memcpy(search_cmd + cmd_len, inputLine + 1, |
fa8365fb6ac2
[PATCH 1/3] New option: vi_mode
Holger Weiß <holger@zedat.fu-berlin.de>
parents:
2292
diff
changeset
|
4556 |
str_len + 1); |
fa8365fb6ac2
[PATCH 1/3] New option: vi_mode
Holger Weiß <holger@zedat.fu-berlin.de>
parents:
2292
diff
changeset
|
4557 |
} |
fa8365fb6ac2
[PATCH 1/3] New option: vi_mode
Holger Weiß <holger@zedat.fu-berlin.de>
parents:
2292
diff
changeset
|
4558 |
process_command(search_cmd, TRUE); |
fa8365fb6ac2
[PATCH 1/3] New option: vi_mode
Holger Weiß <holger@zedat.fu-berlin.de>
parents:
2292
diff
changeset
|
4559 |
scr_cmdhisto_addline(search_cmd); |
fa8365fb6ac2
[PATCH 1/3] New option: vi_mode
Holger Weiß <holger@zedat.fu-berlin.de>
parents:
2292
diff
changeset
|
4560 |
break; |
fa8365fb6ac2
[PATCH 1/3] New option: vi_mode
Holger Weiß <holger@zedat.fu-berlin.de>
parents:
2292
diff
changeset
|
4561 |
} |
fa8365fb6ac2
[PATCH 1/3] New option: vi_mode
Holger Weiß <holger@zedat.fu-berlin.de>
parents:
2292
diff
changeset
|
4562 |
ex_or_search_mode = FALSE; |
fa8365fb6ac2
[PATCH 1/3] New option: vi_mode
Holger Weiß <holger@zedat.fu-berlin.de>
parents:
2292
diff
changeset
|
4563 |
break; |
fa8365fb6ac2
[PATCH 1/3] New option: vi_mode
Holger Weiß <holger@zedat.fu-berlin.de>
parents:
2292
diff
changeset
|
4564 |
} |
fa8365fb6ac2
[PATCH 1/3] New option: vi_mode
Holger Weiß <holger@zedat.fu-berlin.de>
parents:
2292
diff
changeset
|
4565 |
} else if (key >= '0' && key <= '9') { |
fa8365fb6ac2
[PATCH 1/3] New option: vi_mode
Holger Weiß <holger@zedat.fu-berlin.de>
parents:
2292
diff
changeset
|
4566 |
got_cmd_prefix = TRUE; |
fa8365fb6ac2
[PATCH 1/3] New option: vi_mode
Holger Weiß <holger@zedat.fu-berlin.de>
parents:
2292
diff
changeset
|
4567 |
} else { |
fa8365fb6ac2
[PATCH 1/3] New option: vi_mode
Holger Weiß <holger@zedat.fu-berlin.de>
parents:
2292
diff
changeset
|
4568 |
switch (key) { |
fa8365fb6ac2
[PATCH 1/3] New option: vi_mode
Holger Weiß <holger@zedat.fu-berlin.de>
parents:
2292
diff
changeset
|
4569 |
case '/': |
fa8365fb6ac2
[PATCH 1/3] New option: vi_mode
Holger Weiß <holger@zedat.fu-berlin.de>
parents:
2292
diff
changeset
|
4570 |
case ':': |
fa8365fb6ac2
[PATCH 1/3] New option: vi_mode
Holger Weiß <holger@zedat.fu-berlin.de>
parents:
2292
diff
changeset
|
4571 |
ex_or_search_mode = TRUE; |
fa8365fb6ac2
[PATCH 1/3] New option: vi_mode
Holger Weiß <holger@zedat.fu-berlin.de>
parents:
2292
diff
changeset
|
4572 |
break; |
fa8365fb6ac2
[PATCH 1/3] New option: vi_mode
Holger Weiß <holger@zedat.fu-berlin.de>
parents:
2292
diff
changeset
|
4573 |
case ' ': |
fa8365fb6ac2
[PATCH 1/3] New option: vi_mode
Holger Weiß <holger@zedat.fu-berlin.de>
parents:
2292
diff
changeset
|
4574 |
process_command(mkcmdstr("group toggle"), TRUE); |
fa8365fb6ac2
[PATCH 1/3] New option: vi_mode
Holger Weiß <holger@zedat.fu-berlin.de>
parents:
2292
diff
changeset
|
4575 |
break; |
fa8365fb6ac2
[PATCH 1/3] New option: vi_mode
Holger Weiß <holger@zedat.fu-berlin.de>
parents:
2292
diff
changeset
|
4576 |
case '!': |
fa8365fb6ac2
[PATCH 1/3] New option: vi_mode
Holger Weiß <holger@zedat.fu-berlin.de>
parents:
2292
diff
changeset
|
4577 |
{ |
fa8365fb6ac2
[PATCH 1/3] New option: vi_mode
Holger Weiß <holger@zedat.fu-berlin.de>
parents:
2292
diff
changeset
|
4578 |
const char *bjid = buddy_getjid(BUDDATA(current_buddy)); |
fa8365fb6ac2
[PATCH 1/3] New option: vi_mode
Holger Weiß <holger@zedat.fu-berlin.de>
parents:
2292
diff
changeset
|
4579 |
|
fa8365fb6ac2
[PATCH 1/3] New option: vi_mode
Holger Weiß <holger@zedat.fu-berlin.de>
parents:
2292
diff
changeset
|
4580 |
if (bjid) { |
fa8365fb6ac2
[PATCH 1/3] New option: vi_mode
Holger Weiß <holger@zedat.fu-berlin.de>
parents:
2292
diff
changeset
|
4581 |
guint type = buddy_gettype(BUDDATA(current_buddy)); |
fa8365fb6ac2
[PATCH 1/3] New option: vi_mode
Holger Weiß <holger@zedat.fu-berlin.de>
parents:
2292
diff
changeset
|
4582 |
guint prio = buddy_getuiprio(BUDDATA(current_buddy)); |
fa8365fb6ac2
[PATCH 1/3] New option: vi_mode
Holger Weiß <holger@zedat.fu-berlin.de>
parents:
2292
diff
changeset
|
4583 |
|
fa8365fb6ac2
[PATCH 1/3] New option: vi_mode
Holger Weiß <holger@zedat.fu-berlin.de>
parents:
2292
diff
changeset
|
4584 |
if (type & ROSTER_TYPE_ROOM && |
fa8365fb6ac2
[PATCH 1/3] New option: vi_mode
Holger Weiß <holger@zedat.fu-berlin.de>
parents:
2292
diff
changeset
|
4585 |
prio < ROSTER_UI_PRIO_MUC_HL_MESSAGE) { |
fa8365fb6ac2
[PATCH 1/3] New option: vi_mode
Holger Weiß <holger@zedat.fu-berlin.de>
parents:
2292
diff
changeset
|
4586 |
roster_setuiprio(bjid, FALSE, |
fa8365fb6ac2
[PATCH 1/3] New option: vi_mode
Holger Weiß <holger@zedat.fu-berlin.de>
parents:
2292
diff
changeset
|
4587 |
ROSTER_UI_PRIO_MUC_HL_MESSAGE, prio_set); |
fa8365fb6ac2
[PATCH 1/3] New option: vi_mode
Holger Weiß <holger@zedat.fu-berlin.de>
parents:
2292
diff
changeset
|
4588 |
roster_msg_setflag(bjid, FALSE, TRUE); |
fa8365fb6ac2
[PATCH 1/3] New option: vi_mode
Holger Weiß <holger@zedat.fu-berlin.de>
parents:
2292
diff
changeset
|
4589 |
} else if (type & ROSTER_TYPE_USER && |
fa8365fb6ac2
[PATCH 1/3] New option: vi_mode
Holger Weiß <holger@zedat.fu-berlin.de>
parents:
2292
diff
changeset
|
4590 |
prio < ROSTER_UI_PRIO_ATTENTION_MESSAGE) { |
fa8365fb6ac2
[PATCH 1/3] New option: vi_mode
Holger Weiß <holger@zedat.fu-berlin.de>
parents:
2292
diff
changeset
|
4591 |
roster_setuiprio(bjid, FALSE, |
fa8365fb6ac2
[PATCH 1/3] New option: vi_mode
Holger Weiß <holger@zedat.fu-berlin.de>
parents:
2292
diff
changeset
|
4592 |
ROSTER_UI_PRIO_ATTENTION_MESSAGE, prio_set); |
fa8365fb6ac2
[PATCH 1/3] New option: vi_mode
Holger Weiß <holger@zedat.fu-berlin.de>
parents:
2292
diff
changeset
|
4593 |
roster_msg_setflag(bjid, FALSE, TRUE); |
fa8365fb6ac2
[PATCH 1/3] New option: vi_mode
Holger Weiß <holger@zedat.fu-berlin.de>
parents:
2292
diff
changeset
|
4594 |
} else { |
fa8365fb6ac2
[PATCH 1/3] New option: vi_mode
Holger Weiß <holger@zedat.fu-berlin.de>
parents:
2292
diff
changeset
|
4595 |
roster_msg_setflag(bjid, FALSE, FALSE); |
fa8365fb6ac2
[PATCH 1/3] New option: vi_mode
Holger Weiß <holger@zedat.fu-berlin.de>
parents:
2292
diff
changeset
|
4596 |
} |
fa8365fb6ac2
[PATCH 1/3] New option: vi_mode
Holger Weiß <holger@zedat.fu-berlin.de>
parents:
2292
diff
changeset
|
4597 |
scr_update_roster(); |
fa8365fb6ac2
[PATCH 1/3] New option: vi_mode
Holger Weiß <holger@zedat.fu-berlin.de>
parents:
2292
diff
changeset
|
4598 |
} |
fa8365fb6ac2
[PATCH 1/3] New option: vi_mode
Holger Weiß <holger@zedat.fu-berlin.de>
parents:
2292
diff
changeset
|
4599 |
} |
fa8365fb6ac2
[PATCH 1/3] New option: vi_mode
Holger Weiß <holger@zedat.fu-berlin.de>
parents:
2292
diff
changeset
|
4600 |
break; |
fa8365fb6ac2
[PATCH 1/3] New option: vi_mode
Holger Weiß <holger@zedat.fu-berlin.de>
parents:
2292
diff
changeset
|
4601 |
case '#': |
fa8365fb6ac2
[PATCH 1/3] New option: vi_mode
Holger Weiß <holger@zedat.fu-berlin.de>
parents:
2292
diff
changeset
|
4602 |
{ |
fa8365fb6ac2
[PATCH 1/3] New option: vi_mode
Holger Weiß <holger@zedat.fu-berlin.de>
parents:
2292
diff
changeset
|
4603 |
const char *bjid = buddy_getjid(BUDDATA(current_buddy)); |
fa8365fb6ac2
[PATCH 1/3] New option: vi_mode
Holger Weiß <holger@zedat.fu-berlin.de>
parents:
2292
diff
changeset
|
4604 |
|
fa8365fb6ac2
[PATCH 1/3] New option: vi_mode
Holger Weiß <holger@zedat.fu-berlin.de>
parents:
2292
diff
changeset
|
4605 |
if (bjid) { |
fa8365fb6ac2
[PATCH 1/3] New option: vi_mode
Holger Weiß <holger@zedat.fu-berlin.de>
parents:
2292
diff
changeset
|
4606 |
unsigned short bflags = buddy_getflags(BUDDATA(current_buddy)); |
fa8365fb6ac2
[PATCH 1/3] New option: vi_mode
Holger Weiß <holger@zedat.fu-berlin.de>
parents:
2292
diff
changeset
|
4607 |
|
fa8365fb6ac2
[PATCH 1/3] New option: vi_mode
Holger Weiß <holger@zedat.fu-berlin.de>
parents:
2292
diff
changeset
|
4608 |
if (bflags & ROSTER_FLAG_MSG) |
fa8365fb6ac2
[PATCH 1/3] New option: vi_mode
Holger Weiß <holger@zedat.fu-berlin.de>
parents:
2292
diff
changeset
|
4609 |
roster_msg_setflag(bjid, FALSE, FALSE); |
fa8365fb6ac2
[PATCH 1/3] New option: vi_mode
Holger Weiß <holger@zedat.fu-berlin.de>
parents:
2292
diff
changeset
|
4610 |
else |
fa8365fb6ac2
[PATCH 1/3] New option: vi_mode
Holger Weiß <holger@zedat.fu-berlin.de>
parents:
2292
diff
changeset
|
4611 |
roster_msg_setflag(bjid, FALSE, TRUE); |
fa8365fb6ac2
[PATCH 1/3] New option: vi_mode
Holger Weiß <holger@zedat.fu-berlin.de>
parents:
2292
diff
changeset
|
4612 |
|
fa8365fb6ac2
[PATCH 1/3] New option: vi_mode
Holger Weiß <holger@zedat.fu-berlin.de>
parents:
2292
diff
changeset
|
4613 |
scr_update_roster(); |
fa8365fb6ac2
[PATCH 1/3] New option: vi_mode
Holger Weiß <holger@zedat.fu-berlin.de>
parents:
2292
diff
changeset
|
4614 |
} |
fa8365fb6ac2
[PATCH 1/3] New option: vi_mode
Holger Weiß <holger@zedat.fu-berlin.de>
parents:
2292
diff
changeset
|
4615 |
} |
fa8365fb6ac2
[PATCH 1/3] New option: vi_mode
Holger Weiß <holger@zedat.fu-berlin.de>
parents:
2292
diff
changeset
|
4616 |
break; |
fa8365fb6ac2
[PATCH 1/3] New option: vi_mode
Holger Weiß <holger@zedat.fu-berlin.de>
parents:
2292
diff
changeset
|
4617 |
case '\'': |
fa8365fb6ac2
[PATCH 1/3] New option: vi_mode
Holger Weiß <holger@zedat.fu-berlin.de>
parents:
2292
diff
changeset
|
4618 |
if (inputLine[0] == '\'') |
fa8365fb6ac2
[PATCH 1/3] New option: vi_mode
Holger Weiß <holger@zedat.fu-berlin.de>
parents:
2292
diff
changeset
|
4619 |
process_command(mkcmdstr("roster alternate"), TRUE); |
fa8365fb6ac2
[PATCH 1/3] New option: vi_mode
Holger Weiß <holger@zedat.fu-berlin.de>
parents:
2292
diff
changeset
|
4620 |
else |
fa8365fb6ac2
[PATCH 1/3] New option: vi_mode
Holger Weiß <holger@zedat.fu-berlin.de>
parents:
2292
diff
changeset
|
4621 |
got_cmd_prefix = TRUE; |
fa8365fb6ac2
[PATCH 1/3] New option: vi_mode
Holger Weiß <holger@zedat.fu-berlin.de>
parents:
2292
diff
changeset
|
4622 |
break; |
fa8365fb6ac2
[PATCH 1/3] New option: vi_mode
Holger Weiß <holger@zedat.fu-berlin.de>
parents:
2292
diff
changeset
|
4623 |
case 'A': |
fa8365fb6ac2
[PATCH 1/3] New option: vi_mode
Holger Weiß <holger@zedat.fu-berlin.de>
parents:
2292
diff
changeset
|
4624 |
process_command(mkcmdstr("roster unread_first"), TRUE); |
fa8365fb6ac2
[PATCH 1/3] New option: vi_mode
Holger Weiß <holger@zedat.fu-berlin.de>
parents:
2292
diff
changeset
|
4625 |
break; |
fa8365fb6ac2
[PATCH 1/3] New option: vi_mode
Holger Weiß <holger@zedat.fu-berlin.de>
parents:
2292
diff
changeset
|
4626 |
case 'a': |
fa8365fb6ac2
[PATCH 1/3] New option: vi_mode
Holger Weiß <holger@zedat.fu-berlin.de>
parents:
2292
diff
changeset
|
4627 |
process_command(mkcmdstr("roster unread_next"), TRUE); |
fa8365fb6ac2
[PATCH 1/3] New option: vi_mode
Holger Weiß <holger@zedat.fu-berlin.de>
parents:
2292
diff
changeset
|
4628 |
break; |
fa8365fb6ac2
[PATCH 1/3] New option: vi_mode
Holger Weiß <holger@zedat.fu-berlin.de>
parents:
2292
diff
changeset
|
4629 |
case 'F': |
fa8365fb6ac2
[PATCH 1/3] New option: vi_mode
Holger Weiß <holger@zedat.fu-berlin.de>
parents:
2292
diff
changeset
|
4630 |
process_command(mkcmdstr("roster group_prev"), TRUE); |
fa8365fb6ac2
[PATCH 1/3] New option: vi_mode
Holger Weiß <holger@zedat.fu-berlin.de>
parents:
2292
diff
changeset
|
4631 |
break; |
fa8365fb6ac2
[PATCH 1/3] New option: vi_mode
Holger Weiß <holger@zedat.fu-berlin.de>
parents:
2292
diff
changeset
|
4632 |
case 'f': |
fa8365fb6ac2
[PATCH 1/3] New option: vi_mode
Holger Weiß <holger@zedat.fu-berlin.de>
parents:
2292
diff
changeset
|
4633 |
process_command(mkcmdstr("roster group_next"), TRUE); |
fa8365fb6ac2
[PATCH 1/3] New option: vi_mode
Holger Weiß <holger@zedat.fu-berlin.de>
parents:
2292
diff
changeset
|
4634 |
break; |
fa8365fb6ac2
[PATCH 1/3] New option: vi_mode
Holger Weiß <holger@zedat.fu-berlin.de>
parents:
2292
diff
changeset
|
4635 |
case 'G': |
fa8365fb6ac2
[PATCH 1/3] New option: vi_mode
Holger Weiß <holger@zedat.fu-berlin.de>
parents:
2292
diff
changeset
|
4636 |
process_command(mkcmdstr("roster bottom"), TRUE); |
fa8365fb6ac2
[PATCH 1/3] New option: vi_mode
Holger Weiß <holger@zedat.fu-berlin.de>
parents:
2292
diff
changeset
|
4637 |
break; |
fa8365fb6ac2
[PATCH 1/3] New option: vi_mode
Holger Weiß <holger@zedat.fu-berlin.de>
parents:
2292
diff
changeset
|
4638 |
case 'g': |
fa8365fb6ac2
[PATCH 1/3] New option: vi_mode
Holger Weiß <holger@zedat.fu-berlin.de>
parents:
2292
diff
changeset
|
4639 |
if (inputLine[0] == 'g') |
fa8365fb6ac2
[PATCH 1/3] New option: vi_mode
Holger Weiß <holger@zedat.fu-berlin.de>
parents:
2292
diff
changeset
|
4640 |
process_command(mkcmdstr("roster top"), TRUE); |
fa8365fb6ac2
[PATCH 1/3] New option: vi_mode
Holger Weiß <holger@zedat.fu-berlin.de>
parents:
2292
diff
changeset
|
4641 |
else { |
fa8365fb6ac2
[PATCH 1/3] New option: vi_mode
Holger Weiß <holger@zedat.fu-berlin.de>
parents:
2292
diff
changeset
|
4642 |
clear_inputline(); |
fa8365fb6ac2
[PATCH 1/3] New option: vi_mode
Holger Weiß <holger@zedat.fu-berlin.de>
parents:
2292
diff
changeset
|
4643 |
got_cmd_prefix = TRUE; |
fa8365fb6ac2
[PATCH 1/3] New option: vi_mode
Holger Weiß <holger@zedat.fu-berlin.de>
parents:
2292
diff
changeset
|
4644 |
} |
fa8365fb6ac2
[PATCH 1/3] New option: vi_mode
Holger Weiß <holger@zedat.fu-berlin.de>
parents:
2292
diff
changeset
|
4645 |
break; |
fa8365fb6ac2
[PATCH 1/3] New option: vi_mode
Holger Weiß <holger@zedat.fu-berlin.de>
parents:
2292
diff
changeset
|
4646 |
case 'i': |
fa8365fb6ac2
[PATCH 1/3] New option: vi_mode
Holger Weiß <holger@zedat.fu-berlin.de>
parents:
2292
diff
changeset
|
4647 |
open_chat_window(); |
fa8365fb6ac2
[PATCH 1/3] New option: vi_mode
Holger Weiß <holger@zedat.fu-berlin.de>
parents:
2292
diff
changeset
|
4648 |
break; |
fa8365fb6ac2
[PATCH 1/3] New option: vi_mode
Holger Weiß <holger@zedat.fu-berlin.de>
parents:
2292
diff
changeset
|
4649 |
case 'j': |
fa8365fb6ac2
[PATCH 1/3] New option: vi_mode
Holger Weiß <holger@zedat.fu-berlin.de>
parents:
2292
diff
changeset
|
4650 |
if (isdigit((int)(unsigned char)inputLine[0]) && |
fa8365fb6ac2
[PATCH 1/3] New option: vi_mode
Holger Weiß <holger@zedat.fu-berlin.de>
parents:
2292
diff
changeset
|
4651 |
strlen(inputLine) <= 9) { |
fa8365fb6ac2
[PATCH 1/3] New option: vi_mode
Holger Weiß <holger@zedat.fu-berlin.de>
parents:
2292
diff
changeset
|
4652 |
char down_cmd[32] = "/roster down "; |
fa8365fb6ac2
[PATCH 1/3] New option: vi_mode
Holger Weiß <holger@zedat.fu-berlin.de>
parents:
2292
diff
changeset
|
4653 |
|
fa8365fb6ac2
[PATCH 1/3] New option: vi_mode
Holger Weiß <holger@zedat.fu-berlin.de>
parents:
2292
diff
changeset
|
4654 |
strcat(down_cmd, inputLine); |
fa8365fb6ac2
[PATCH 1/3] New option: vi_mode
Holger Weiß <holger@zedat.fu-berlin.de>
parents:
2292
diff
changeset
|
4655 |
process_command(down_cmd, TRUE); |
fa8365fb6ac2
[PATCH 1/3] New option: vi_mode
Holger Weiß <holger@zedat.fu-berlin.de>
parents:
2292
diff
changeset
|
4656 |
} else |
fa8365fb6ac2
[PATCH 1/3] New option: vi_mode
Holger Weiß <holger@zedat.fu-berlin.de>
parents:
2292
diff
changeset
|
4657 |
process_command(mkcmdstr("roster down"), TRUE); |
fa8365fb6ac2
[PATCH 1/3] New option: vi_mode
Holger Weiß <holger@zedat.fu-berlin.de>
parents:
2292
diff
changeset
|
4658 |
break; |
fa8365fb6ac2
[PATCH 1/3] New option: vi_mode
Holger Weiß <holger@zedat.fu-berlin.de>
parents:
2292
diff
changeset
|
4659 |
case 'k': |
fa8365fb6ac2
[PATCH 1/3] New option: vi_mode
Holger Weiß <holger@zedat.fu-berlin.de>
parents:
2292
diff
changeset
|
4660 |
if (isdigit((int)(unsigned char)inputLine[0]) && |
fa8365fb6ac2
[PATCH 1/3] New option: vi_mode
Holger Weiß <holger@zedat.fu-berlin.de>
parents:
2292
diff
changeset
|
4661 |
strlen(inputLine) <= 9) { |
fa8365fb6ac2
[PATCH 1/3] New option: vi_mode
Holger Weiß <holger@zedat.fu-berlin.de>
parents:
2292
diff
changeset
|
4662 |
char up_cmd[32] = "/roster up "; |
fa8365fb6ac2
[PATCH 1/3] New option: vi_mode
Holger Weiß <holger@zedat.fu-berlin.de>
parents:
2292
diff
changeset
|
4663 |
|
fa8365fb6ac2
[PATCH 1/3] New option: vi_mode
Holger Weiß <holger@zedat.fu-berlin.de>
parents:
2292
diff
changeset
|
4664 |
strcat(up_cmd, inputLine); |
fa8365fb6ac2
[PATCH 1/3] New option: vi_mode
Holger Weiß <holger@zedat.fu-berlin.de>
parents:
2292
diff
changeset
|
4665 |
process_command(up_cmd, TRUE); |
fa8365fb6ac2
[PATCH 1/3] New option: vi_mode
Holger Weiß <holger@zedat.fu-berlin.de>
parents:
2292
diff
changeset
|
4666 |
} else |
fa8365fb6ac2
[PATCH 1/3] New option: vi_mode
Holger Weiß <holger@zedat.fu-berlin.de>
parents:
2292
diff
changeset
|
4667 |
process_command(mkcmdstr("roster up "), TRUE); |
fa8365fb6ac2
[PATCH 1/3] New option: vi_mode
Holger Weiß <holger@zedat.fu-berlin.de>
parents:
2292
diff
changeset
|
4668 |
break; |
fa8365fb6ac2
[PATCH 1/3] New option: vi_mode
Holger Weiß <holger@zedat.fu-berlin.de>
parents:
2292
diff
changeset
|
4669 |
case 'M': |
fa8365fb6ac2
[PATCH 1/3] New option: vi_mode
Holger Weiß <holger@zedat.fu-berlin.de>
parents:
2292
diff
changeset
|
4670 |
if (inputLine[0] == 'z') { |
fa8365fb6ac2
[PATCH 1/3] New option: vi_mode
Holger Weiß <holger@zedat.fu-berlin.de>
parents:
2292
diff
changeset
|
4671 |
GSList *groups = compl_list(ROSTER_TYPE_GROUP); |
fa8365fb6ac2
[PATCH 1/3] New option: vi_mode
Holger Weiß <holger@zedat.fu-berlin.de>
parents:
2292
diff
changeset
|
4672 |
GSList *g; |
fa8365fb6ac2
[PATCH 1/3] New option: vi_mode
Holger Weiß <holger@zedat.fu-berlin.de>
parents:
2292
diff
changeset
|
4673 |
|
fa8365fb6ac2
[PATCH 1/3] New option: vi_mode
Holger Weiß <holger@zedat.fu-berlin.de>
parents:
2292
diff
changeset
|
4674 |
for (g = groups; g; g = g_slist_next(g)) { |
fa8365fb6ac2
[PATCH 1/3] New option: vi_mode
Holger Weiß <holger@zedat.fu-berlin.de>
parents:
2292
diff
changeset
|
4675 |
char fold_cmd[128] = "/group fold "; |
fa8365fb6ac2
[PATCH 1/3] New option: vi_mode
Holger Weiß <holger@zedat.fu-berlin.de>
parents:
2292
diff
changeset
|
4676 |
size_t cmd_len = strlen(fold_cmd); |
fa8365fb6ac2
[PATCH 1/3] New option: vi_mode
Holger Weiß <holger@zedat.fu-berlin.de>
parents:
2292
diff
changeset
|
4677 |
size_t grp_len = strlen(g->data); |
fa8365fb6ac2
[PATCH 1/3] New option: vi_mode
Holger Weiß <holger@zedat.fu-berlin.de>
parents:
2292
diff
changeset
|
4678 |
|
fa8365fb6ac2
[PATCH 1/3] New option: vi_mode
Holger Weiß <holger@zedat.fu-berlin.de>
parents:
2292
diff
changeset
|
4679 |
if (cmd_len + grp_len + 1 > sizeof(fold_cmd)) |
fa8365fb6ac2
[PATCH 1/3] New option: vi_mode
Holger Weiß <holger@zedat.fu-berlin.de>
parents:
2292
diff
changeset
|
4680 |
continue; |
fa8365fb6ac2
[PATCH 1/3] New option: vi_mode
Holger Weiß <holger@zedat.fu-berlin.de>
parents:
2292
diff
changeset
|
4681 |
memcpy(fold_cmd + cmd_len, g->data, grp_len + 1); |
fa8365fb6ac2
[PATCH 1/3] New option: vi_mode
Holger Weiß <holger@zedat.fu-berlin.de>
parents:
2292
diff
changeset
|
4682 |
process_command(fold_cmd, TRUE); |
fa8365fb6ac2
[PATCH 1/3] New option: vi_mode
Holger Weiß <holger@zedat.fu-berlin.de>
parents:
2292
diff
changeset
|
4683 |
g_free(g->data); |
fa8365fb6ac2
[PATCH 1/3] New option: vi_mode
Holger Weiß <holger@zedat.fu-berlin.de>
parents:
2292
diff
changeset
|
4684 |
} |
fa8365fb6ac2
[PATCH 1/3] New option: vi_mode
Holger Weiß <holger@zedat.fu-berlin.de>
parents:
2292
diff
changeset
|
4685 |
g_slist_free(groups); |
fa8365fb6ac2
[PATCH 1/3] New option: vi_mode
Holger Weiß <holger@zedat.fu-berlin.de>
parents:
2292
diff
changeset
|
4686 |
} else |
fa8365fb6ac2
[PATCH 1/3] New option: vi_mode
Holger Weiß <holger@zedat.fu-berlin.de>
parents:
2292
diff
changeset
|
4687 |
unrecognized = TRUE; |
fa8365fb6ac2
[PATCH 1/3] New option: vi_mode
Holger Weiß <holger@zedat.fu-berlin.de>
parents:
2292
diff
changeset
|
4688 |
break; |
fa8365fb6ac2
[PATCH 1/3] New option: vi_mode
Holger Weiß <holger@zedat.fu-berlin.de>
parents:
2292
diff
changeset
|
4689 |
case 'n': |
fa8365fb6ac2
[PATCH 1/3] New option: vi_mode
Holger Weiß <holger@zedat.fu-berlin.de>
parents:
2292
diff
changeset
|
4690 |
process_command(search_cmd, TRUE); |
fa8365fb6ac2
[PATCH 1/3] New option: vi_mode
Holger Weiß <holger@zedat.fu-berlin.de>
parents:
2292
diff
changeset
|
4691 |
break; |
fa8365fb6ac2
[PATCH 1/3] New option: vi_mode
Holger Weiß <holger@zedat.fu-berlin.de>
parents:
2292
diff
changeset
|
4692 |
case 'O': |
fa8365fb6ac2
[PATCH 1/3] New option: vi_mode
Holger Weiß <holger@zedat.fu-berlin.de>
parents:
2292
diff
changeset
|
4693 |
process_command(mkcmdstr("roster unread_first"), TRUE); |
fa8365fb6ac2
[PATCH 1/3] New option: vi_mode
Holger Weiß <holger@zedat.fu-berlin.de>
parents:
2292
diff
changeset
|
4694 |
open_chat_window(); |
fa8365fb6ac2
[PATCH 1/3] New option: vi_mode
Holger Weiß <holger@zedat.fu-berlin.de>
parents:
2292
diff
changeset
|
4695 |
break; |
fa8365fb6ac2
[PATCH 1/3] New option: vi_mode
Holger Weiß <holger@zedat.fu-berlin.de>
parents:
2292
diff
changeset
|
4696 |
case 'o': |
fa8365fb6ac2
[PATCH 1/3] New option: vi_mode
Holger Weiß <holger@zedat.fu-berlin.de>
parents:
2292
diff
changeset
|
4697 |
process_command(mkcmdstr("roster unread_next"), TRUE); |
fa8365fb6ac2
[PATCH 1/3] New option: vi_mode
Holger Weiß <holger@zedat.fu-berlin.de>
parents:
2292
diff
changeset
|
4698 |
open_chat_window(); |
fa8365fb6ac2
[PATCH 1/3] New option: vi_mode
Holger Weiß <holger@zedat.fu-berlin.de>
parents:
2292
diff
changeset
|
4699 |
break; |
fa8365fb6ac2
[PATCH 1/3] New option: vi_mode
Holger Weiß <holger@zedat.fu-berlin.de>
parents:
2292
diff
changeset
|
4700 |
case 'R': |
fa8365fb6ac2
[PATCH 1/3] New option: vi_mode
Holger Weiß <holger@zedat.fu-berlin.de>
parents:
2292
diff
changeset
|
4701 |
if (inputLine[0] == 'z') { |
fa8365fb6ac2
[PATCH 1/3] New option: vi_mode
Holger Weiß <holger@zedat.fu-berlin.de>
parents:
2292
diff
changeset
|
4702 |
GSList *groups = compl_list(ROSTER_TYPE_GROUP); |
fa8365fb6ac2
[PATCH 1/3] New option: vi_mode
Holger Weiß <holger@zedat.fu-berlin.de>
parents:
2292
diff
changeset
|
4703 |
GSList *g; |
fa8365fb6ac2
[PATCH 1/3] New option: vi_mode
Holger Weiß <holger@zedat.fu-berlin.de>
parents:
2292
diff
changeset
|
4704 |
|
fa8365fb6ac2
[PATCH 1/3] New option: vi_mode
Holger Weiß <holger@zedat.fu-berlin.de>
parents:
2292
diff
changeset
|
4705 |
for (g = groups; g; g = g_slist_next(g)) { |
fa8365fb6ac2
[PATCH 1/3] New option: vi_mode
Holger Weiß <holger@zedat.fu-berlin.de>
parents:
2292
diff
changeset
|
4706 |
char fold_cmd[128] = "/group unfold "; |
fa8365fb6ac2
[PATCH 1/3] New option: vi_mode
Holger Weiß <holger@zedat.fu-berlin.de>
parents:
2292
diff
changeset
|
4707 |
size_t cmd_len = strlen(fold_cmd); |
fa8365fb6ac2
[PATCH 1/3] New option: vi_mode
Holger Weiß <holger@zedat.fu-berlin.de>
parents:
2292
diff
changeset
|
4708 |
size_t grp_len = strlen(g->data); |
fa8365fb6ac2
[PATCH 1/3] New option: vi_mode
Holger Weiß <holger@zedat.fu-berlin.de>
parents:
2292
diff
changeset
|
4709 |
|
fa8365fb6ac2
[PATCH 1/3] New option: vi_mode
Holger Weiß <holger@zedat.fu-berlin.de>
parents:
2292
diff
changeset
|
4710 |
if (cmd_len + grp_len + 1 > sizeof(fold_cmd)) |
fa8365fb6ac2
[PATCH 1/3] New option: vi_mode
Holger Weiß <holger@zedat.fu-berlin.de>
parents:
2292
diff
changeset
|
4711 |
continue; |
fa8365fb6ac2
[PATCH 1/3] New option: vi_mode
Holger Weiß <holger@zedat.fu-berlin.de>
parents:
2292
diff
changeset
|
4712 |
memcpy(fold_cmd + cmd_len, g->data, grp_len + 1); |
fa8365fb6ac2
[PATCH 1/3] New option: vi_mode
Holger Weiß <holger@zedat.fu-berlin.de>
parents:
2292
diff
changeset
|
4713 |
process_command(fold_cmd, TRUE); |
fa8365fb6ac2
[PATCH 1/3] New option: vi_mode
Holger Weiß <holger@zedat.fu-berlin.de>
parents:
2292
diff
changeset
|
4714 |
g_free(g->data); |
fa8365fb6ac2
[PATCH 1/3] New option: vi_mode
Holger Weiß <holger@zedat.fu-berlin.de>
parents:
2292
diff
changeset
|
4715 |
} |
fa8365fb6ac2
[PATCH 1/3] New option: vi_mode
Holger Weiß <holger@zedat.fu-berlin.de>
parents:
2292
diff
changeset
|
4716 |
g_slist_free(groups); |
fa8365fb6ac2
[PATCH 1/3] New option: vi_mode
Holger Weiß <holger@zedat.fu-berlin.de>
parents:
2292
diff
changeset
|
4717 |
} else |
fa8365fb6ac2
[PATCH 1/3] New option: vi_mode
Holger Weiß <holger@zedat.fu-berlin.de>
parents:
2292
diff
changeset
|
4718 |
unrecognized = TRUE; |
fa8365fb6ac2
[PATCH 1/3] New option: vi_mode
Holger Weiß <holger@zedat.fu-berlin.de>
parents:
2292
diff
changeset
|
4719 |
break; |
fa8365fb6ac2
[PATCH 1/3] New option: vi_mode
Holger Weiß <holger@zedat.fu-berlin.de>
parents:
2292
diff
changeset
|
4720 |
case 'Z': |
fa8365fb6ac2
[PATCH 1/3] New option: vi_mode
Holger Weiß <holger@zedat.fu-berlin.de>
parents:
2292
diff
changeset
|
4721 |
if (inputLine[0] == 'Z') |
fa8365fb6ac2
[PATCH 1/3] New option: vi_mode
Holger Weiß <holger@zedat.fu-berlin.de>
parents:
2292
diff
changeset
|
4722 |
process_command(mkcmdstr("quit"), TRUE); |
fa8365fb6ac2
[PATCH 1/3] New option: vi_mode
Holger Weiß <holger@zedat.fu-berlin.de>
parents:
2292
diff
changeset
|
4723 |
else { |
fa8365fb6ac2
[PATCH 1/3] New option: vi_mode
Holger Weiß <holger@zedat.fu-berlin.de>
parents:
2292
diff
changeset
|
4724 |
clear_inputline(); |
fa8365fb6ac2
[PATCH 1/3] New option: vi_mode
Holger Weiß <holger@zedat.fu-berlin.de>
parents:
2292
diff
changeset
|
4725 |
got_cmd_prefix = TRUE; |
fa8365fb6ac2
[PATCH 1/3] New option: vi_mode
Holger Weiß <holger@zedat.fu-berlin.de>
parents:
2292
diff
changeset
|
4726 |
} |
fa8365fb6ac2
[PATCH 1/3] New option: vi_mode
Holger Weiß <holger@zedat.fu-berlin.de>
parents:
2292
diff
changeset
|
4727 |
break; |
fa8365fb6ac2
[PATCH 1/3] New option: vi_mode
Holger Weiß <holger@zedat.fu-berlin.de>
parents:
2292
diff
changeset
|
4728 |
case 'z': |
fa8365fb6ac2
[PATCH 1/3] New option: vi_mode
Holger Weiß <holger@zedat.fu-berlin.de>
parents:
2292
diff
changeset
|
4729 |
clear_inputline(); |
fa8365fb6ac2
[PATCH 1/3] New option: vi_mode
Holger Weiß <holger@zedat.fu-berlin.de>
parents:
2292
diff
changeset
|
4730 |
got_cmd_prefix = TRUE; |
fa8365fb6ac2
[PATCH 1/3] New option: vi_mode
Holger Weiß <holger@zedat.fu-berlin.de>
parents:
2292
diff
changeset
|
4731 |
break; |
fa8365fb6ac2
[PATCH 1/3] New option: vi_mode
Holger Weiß <holger@zedat.fu-berlin.de>
parents:
2292
diff
changeset
|
4732 |
case 13: // Enter |
fa8365fb6ac2
[PATCH 1/3] New option: vi_mode
Holger Weiß <holger@zedat.fu-berlin.de>
parents:
2292
diff
changeset
|
4733 |
case 343: // Enter on Maemo |
fa8365fb6ac2
[PATCH 1/3] New option: vi_mode
Holger Weiß <holger@zedat.fu-berlin.de>
parents:
2292
diff
changeset
|
4734 |
break; |
fa8365fb6ac2
[PATCH 1/3] New option: vi_mode
Holger Weiß <holger@zedat.fu-berlin.de>
parents:
2292
diff
changeset
|
4735 |
default: |
fa8365fb6ac2
[PATCH 1/3] New option: vi_mode
Holger Weiß <holger@zedat.fu-berlin.de>
parents:
2292
diff
changeset
|
4736 |
unrecognized = TRUE; |
fa8365fb6ac2
[PATCH 1/3] New option: vi_mode
Holger Weiß <holger@zedat.fu-berlin.de>
parents:
2292
diff
changeset
|
4737 |
break; |
fa8365fb6ac2
[PATCH 1/3] New option: vi_mode
Holger Weiß <holger@zedat.fu-berlin.de>
parents:
2292
diff
changeset
|
4738 |
} |
fa8365fb6ac2
[PATCH 1/3] New option: vi_mode
Holger Weiß <holger@zedat.fu-berlin.de>
parents:
2292
diff
changeset
|
4739 |
cmdhisto_cur = NULL; |
fa8365fb6ac2
[PATCH 1/3] New option: vi_mode
Holger Weiß <holger@zedat.fu-berlin.de>
parents:
2292
diff
changeset
|
4740 |
} |
fa8365fb6ac2
[PATCH 1/3] New option: vi_mode
Holger Weiß <holger@zedat.fu-berlin.de>
parents:
2292
diff
changeset
|
4741 |
if (!ex_or_search_mode && !got_cmd_prefix) { |
fa8365fb6ac2
[PATCH 1/3] New option: vi_mode
Holger Weiß <holger@zedat.fu-berlin.de>
parents:
2292
diff
changeset
|
4742 |
clear_inputline(); |
fa8365fb6ac2
[PATCH 1/3] New option: vi_mode
Holger Weiß <holger@zedat.fu-berlin.de>
parents:
2292
diff
changeset
|
4743 |
if (!unrecognized) |
fa8365fb6ac2
[PATCH 1/3] New option: vi_mode
Holger Weiß <holger@zedat.fu-berlin.de>
parents:
2292
diff
changeset
|
4744 |
key = ERR; // Do not process any further |
fa8365fb6ac2
[PATCH 1/3] New option: vi_mode
Holger Weiß <holger@zedat.fu-berlin.de>
parents:
2292
diff
changeset
|
4745 |
} |
fa8365fb6ac2
[PATCH 1/3] New option: vi_mode
Holger Weiß <holger@zedat.fu-berlin.de>
parents:
2292
diff
changeset
|
4746 |
lock_chatstate = TRUE; |
fa8365fb6ac2
[PATCH 1/3] New option: vi_mode
Holger Weiß <holger@zedat.fu-berlin.de>
parents:
2292
diff
changeset
|
4747 |
} |
fa8365fb6ac2
[PATCH 1/3] New option: vi_mode
Holger Weiß <holger@zedat.fu-berlin.de>
parents:
2292
diff
changeset
|
4748 |
|
931
1cd6d694ac3c
Fix display of some UTF-8 chars
Mikael Berthe <mikael@lilotux.net>
parents:
930
diff
changeset
|
4749 |
if (kcode.utf8) { |
1cd6d694ac3c
Fix display of some UTF-8 chars
Mikael Berthe <mikael@lilotux.net>
parents:
930
diff
changeset
|
4750 |
if (key != ERR && !kcode.mcode) |
1cd6d694ac3c
Fix display of some UTF-8 chars
Mikael Berthe <mikael@lilotux.net>
parents:
930
diff
changeset
|
4751 |
display_char = TRUE; |
1cd6d694ac3c
Fix display of some UTF-8 chars
Mikael Berthe <mikael@lilotux.net>
parents:
930
diff
changeset
|
4752 |
goto display; |
1cd6d694ac3c
Fix display of some UTF-8 chars
Mikael Berthe <mikael@lilotux.net>
parents:
930
diff
changeset
|
4753 |
} |
1cd6d694ac3c
Fix display of some UTF-8 chars
Mikael Berthe <mikael@lilotux.net>
parents:
930
diff
changeset
|
4754 |
|
758 | 4755 |
switch (key) { |
761
4532a9fe0e8c
Handle some keyboard escape sequences
Mikael Berthe <mikael@lilotux.net>
parents:
760
diff
changeset
|
4756 |
case 0: |
4532a9fe0e8c
Handle some keyboard escape sequences
Mikael Berthe <mikael@lilotux.net>
parents:
760
diff
changeset
|
4757 |
case ERR: |
758 | 4758 |
break; |
1173
960f34ec22a2
Add init_bindings() for default key bindings (Lego12239)
Mikael Berthe <mikael@lilotux.net>
parents:
1172
diff
changeset
|
4759 |
case 9: // Tab |
2305
5b1a63dc2b1a
[PATCH 2/3] Don't complete "/search" string in vi mode
Holger Weiß <holger@zedat.fu-berlin.de>
parents:
2304
diff
changeset
|
4760 |
if (!vi_search) |
5b1a63dc2b1a
[PATCH 2/3] Don't complete "/search" string in vi mode
Holger Weiß <holger@zedat.fu-berlin.de>
parents:
2304
diff
changeset
|
4761 |
readline_do_completion(TRUE); // Forward-completion |
2143
2f294c2b6778
Add a backward completion (Oleg)
Mikael Berthe <mikael@lilotux.net>
parents:
2136
diff
changeset
|
4762 |
break; |
2f294c2b6778
Add a backward completion (Oleg)
Mikael Berthe <mikael@lilotux.net>
parents:
2136
diff
changeset
|
4763 |
case 353: // Shift-Tab |
2305
5b1a63dc2b1a
[PATCH 2/3] Don't complete "/search" string in vi mode
Holger Weiß <holger@zedat.fu-berlin.de>
parents:
2304
diff
changeset
|
4764 |
if (!vi_search) |
5b1a63dc2b1a
[PATCH 2/3] Don't complete "/search" string in vi mode
Holger Weiß <holger@zedat.fu-berlin.de>
parents:
2304
diff
changeset
|
4765 |
readline_do_completion(FALSE); // Backward-completion |
1173
960f34ec22a2
Add init_bindings() for default key bindings (Lego12239)
Mikael Berthe <mikael@lilotux.net>
parents:
1172
diff
changeset
|
4766 |
break; |
960f34ec22a2
Add init_bindings() for default key bindings (Lego12239)
Mikael Berthe <mikael@lilotux.net>
parents:
1172
diff
changeset
|
4767 |
case 13: // Enter |
1935
a06d9eab14c5
Handle the Enter key on Maemo systems (diSabler)
Mikael Berthe <mikael@lilotux.net>
parents:
1927
diff
changeset
|
4768 |
case 343: // Enter on Maemo |
2164 | 4769 |
readline_accept_line(FALSE); |
1173
960f34ec22a2
Add init_bindings() for default key bindings (Lego12239)
Mikael Berthe <mikael@lilotux.net>
parents:
1172
diff
changeset
|
4770 |
break; |
960f34ec22a2
Add init_bindings() for default key bindings (Lego12239)
Mikael Berthe <mikael@lilotux.net>
parents:
1172
diff
changeset
|
4771 |
case 3: // Ctrl-C |
960f34ec22a2
Add init_bindings() for default key bindings (Lego12239)
Mikael Berthe <mikael@lilotux.net>
parents:
1172
diff
changeset
|
4772 |
scr_handle_CtrlC(); |
960f34ec22a2
Add init_bindings() for default key bindings (Lego12239)
Mikael Berthe <mikael@lilotux.net>
parents:
1172
diff
changeset
|
4773 |
break; |
960f34ec22a2
Add init_bindings() for default key bindings (Lego12239)
Mikael Berthe <mikael@lilotux.net>
parents:
1172
diff
changeset
|
4774 |
case KEY_RESIZE: |
2231
387cea2a1a81
Fix resizing with --enable-sigwinch
Mikael Berthe <mikael@lilotux.net>
parents:
2226
diff
changeset
|
4775 |
scr_resize(); |
1173
960f34ec22a2
Add init_bindings() for default key bindings (Lego12239)
Mikael Berthe <mikael@lilotux.net>
parents:
1172
diff
changeset
|
4776 |
break; |
499
baa812f04f24
Reorganise process_key()
Mikael Berthe <mikael@lilotux.net>
parents:
480
diff
changeset
|
4777 |
default: |
931
1cd6d694ac3c
Fix display of some UTF-8 chars
Mikael Berthe <mikael@lilotux.net>
parents:
930
diff
changeset
|
4778 |
display_char = TRUE; |
1cd6d694ac3c
Fix display of some UTF-8 chars
Mikael Berthe <mikael@lilotux.net>
parents:
930
diff
changeset
|
4779 |
} // switch |
263 | 4780 |
|
931
1cd6d694ac3c
Fix display of some UTF-8 chars
Mikael Berthe <mikael@lilotux.net>
parents:
930
diff
changeset
|
4781 |
display: |
1cd6d694ac3c
Fix display of some UTF-8 chars
Mikael Berthe <mikael@lilotux.net>
parents:
930
diff
changeset
|
4782 |
if (display_char) { |
1394 | 4783 |
guint printable; |
4784 |
||
4785 |
if (kcode.utf8) { |
|
4786 |
printable = iswprint(key); |
|
4787 |
} else { |
|
4788 |
#ifdef __CYGWIN__ |
|
4789 |
printable = (isprint(key) || (key >= 161 && key <= 255)) |
|
4790 |
&& !is_speckey(key); |
|
4791 |
#else |
|
4792 |
printable = isprint(key) && !is_speckey(key); |
|
4793 |
#endif |
|
4794 |
} |
|
4795 |
if (printable) { |
|
931
1cd6d694ac3c
Fix display of some UTF-8 chars
Mikael Berthe <mikael@lilotux.net>
parents:
930
diff
changeset
|
4796 |
char tmpLine[INPUTLINE_LENGTH+1]; |
499
baa812f04f24
Reorganise process_key()
Mikael Berthe <mikael@lilotux.net>
parents:
480
diff
changeset
|
4797 |
|
931
1cd6d694ac3c
Fix display of some UTF-8 chars
Mikael Berthe <mikael@lilotux.net>
parents:
930
diff
changeset
|
4798 |
// Check the line isn't too long |
1cd6d694ac3c
Fix display of some UTF-8 chars
Mikael Berthe <mikael@lilotux.net>
parents:
930
diff
changeset
|
4799 |
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
|
4800 |
return; |
931
1cd6d694ac3c
Fix display of some UTF-8 chars
Mikael Berthe <mikael@lilotux.net>
parents:
930
diff
changeset
|
4801 |
|
1cd6d694ac3c
Fix display of some UTF-8 chars
Mikael Berthe <mikael@lilotux.net>
parents:
930
diff
changeset
|
4802 |
// Insert char |
1cd6d694ac3c
Fix display of some UTF-8 chars
Mikael Berthe <mikael@lilotux.net>
parents:
930
diff
changeset
|
4803 |
strcpy(tmpLine, ptr_inputline); |
1cd6d694ac3c
Fix display of some UTF-8 chars
Mikael Berthe <mikael@lilotux.net>
parents:
930
diff
changeset
|
4804 |
ptr_inputline = put_char(ptr_inputline, key); |
1cd6d694ac3c
Fix display of some UTF-8 chars
Mikael Berthe <mikael@lilotux.net>
parents:
930
diff
changeset
|
4805 |
strcpy(ptr_inputline, tmpLine); |
1cd6d694ac3c
Fix display of some UTF-8 chars
Mikael Berthe <mikael@lilotux.net>
parents:
930
diff
changeset
|
4806 |
check_offset(1); |
1cd6d694ac3c
Fix display of some UTF-8 chars
Mikael Berthe <mikael@lilotux.net>
parents:
930
diff
changeset
|
4807 |
} else { |
1cd6d694ac3c
Fix display of some UTF-8 chars
Mikael Berthe <mikael@lilotux.net>
parents:
930
diff
changeset
|
4808 |
// Look for a key binding. |
2164 | 4809 |
if (!kcode.utf8) |
4810 |
bindcommand(kcode); |
|
931
1cd6d694ac3c
Fix display of some UTF-8 chars
Mikael Berthe <mikael@lilotux.net>
parents:
930
diff
changeset
|
4811 |
} |
24 | 4812 |
} |
499
baa812f04f24
Reorganise process_key()
Mikael Berthe <mikael@lilotux.net>
parents:
480
diff
changeset
|
4813 |
|
2143
2f294c2b6778
Add a backward completion (Oleg)
Mikael Berthe <mikael@lilotux.net>
parents:
2136
diff
changeset
|
4814 |
if (completion_started && key != 9 && key != 353 && key != KEY_RESIZE) |
98 | 4815 |
scr_end_current_completion(); |
2304
fa8365fb6ac2
[PATCH 1/3] New option: vi_mode
Holger Weiß <holger@zedat.fu-berlin.de>
parents:
2292
diff
changeset
|
4816 |
else if (vi_completion) |
fa8365fb6ac2
[PATCH 1/3] New option: vi_mode
Holger Weiß <holger@zedat.fu-berlin.de>
parents:
2292
diff
changeset
|
4817 |
inputLine[0] = ':'; |
312
f0b7ff2df7e8
Ctrl-C does not terminate mcabber
Mikael Berthe <mikael@lilotux.net>
parents:
307
diff
changeset
|
4818 |
refresh_inputline(); |
990
35e7913affb7
Send events/chatstates notifications (JEP-22/JEP-85)
Mikael Berthe <mikael@lilotux.net>
parents:
987
diff
changeset
|
4819 |
|
2304
fa8365fb6ac2
[PATCH 1/3] New option: vi_mode
Holger Weiß <holger@zedat.fu-berlin.de>
parents:
2292
diff
changeset
|
4820 |
if (ex_or_search_mode && inputLine[0] != ':' && inputLine[0] != '/') |
fa8365fb6ac2
[PATCH 1/3] New option: vi_mode
Holger Weiß <holger@zedat.fu-berlin.de>
parents:
2292
diff
changeset
|
4821 |
ex_or_search_mode = FALSE; |
fa8365fb6ac2
[PATCH 1/3] New option: vi_mode
Holger Weiß <holger@zedat.fu-berlin.de>
parents:
2292
diff
changeset
|
4822 |
|
990
35e7913affb7
Send events/chatstates notifications (JEP-22/JEP-85)
Mikael Berthe <mikael@lilotux.net>
parents:
987
diff
changeset
|
4823 |
if (!lock_chatstate) { |
997 | 4824 |
// Set chat state to composing (1) if the user is currently composing, |
4825 |
// 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
|
4826 |
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
|
4827 |
set_chatstate(0); |
35e7913affb7
Send events/chatstates notifications (JEP-22/JEP-85)
Mikael Berthe <mikael@lilotux.net>
parents:
987
diff
changeset
|
4828 |
else |
35e7913affb7
Send events/chatstates notifications (JEP-22/JEP-85)
Mikael Berthe <mikael@lilotux.net>
parents:
987
diff
changeset
|
4829 |
set_chatstate(1); |
991
ef10906691bb
Chatstates: add composing timeout
Mikael Berthe <mikael@lilotux.net>
parents:
990
diff
changeset
|
4830 |
if (chatstate) |
ef10906691bb
Chatstates: add composing timeout
Mikael Berthe <mikael@lilotux.net>
parents:
990
diff
changeset
|
4831 |
time(&chatstate_timestamp); |
990
35e7913affb7
Send events/chatstates notifications (JEP-22/JEP-85)
Mikael Berthe <mikael@lilotux.net>
parents:
987
diff
changeset
|
4832 |
} |
1359
7daf906fbcdc
The command /quit can be used in bindings, hooks and sourced files
Mikael Berthe <mikael@lilotux.net>
parents:
1357
diff
changeset
|
4833 |
return; |
24 | 4834 |
} |
576 | 4835 |
|
1590
8d1bcc83ae32
Add support for spellchecking with Enchant (caolan)
Mikael Berthe <mikael@lilotux.net>
parents:
1579
diff
changeset
|
4836 |
#if defined(WITH_ENCHANT) || defined(WITH_ASPELL) |
2170
282531385f34
Multilanguage spell checking
Dmitry Potapov <potapov.d@gmail.com>
parents:
2165
diff
changeset
|
4837 |
static void spell_checker_free(gpointer data) |
282531385f34
Multilanguage spell checking
Dmitry Potapov <potapov.d@gmail.com>
parents:
2165
diff
changeset
|
4838 |
{ |
282531385f34
Multilanguage spell checking
Dmitry Potapov <potapov.d@gmail.com>
parents:
2165
diff
changeset
|
4839 |
spell_checker* sc = data; |
282531385f34
Multilanguage spell checking
Dmitry Potapov <potapov.d@gmail.com>
parents:
2165
diff
changeset
|
4840 |
#ifdef WITH_ENCHANT |
282531385f34
Multilanguage spell checking
Dmitry Potapov <potapov.d@gmail.com>
parents:
2165
diff
changeset
|
4841 |
enchant_broker_free_dict(sc->broker, sc->checker); |
282531385f34
Multilanguage spell checking
Dmitry Potapov <potapov.d@gmail.com>
parents:
2165
diff
changeset
|
4842 |
enchant_broker_free(sc->broker); |
282531385f34
Multilanguage spell checking
Dmitry Potapov <potapov.d@gmail.com>
parents:
2165
diff
changeset
|
4843 |
#endif |
282531385f34
Multilanguage spell checking
Dmitry Potapov <potapov.d@gmail.com>
parents:
2165
diff
changeset
|
4844 |
#ifdef WITH_ASPELL |
282531385f34
Multilanguage spell checking
Dmitry Potapov <potapov.d@gmail.com>
parents:
2165
diff
changeset
|
4845 |
delete_aspell_speller(sc->checker); |
282531385f34
Multilanguage spell checking
Dmitry Potapov <potapov.d@gmail.com>
parents:
2165
diff
changeset
|
4846 |
delete_aspell_config(sc->config); |
282531385f34
Multilanguage spell checking
Dmitry Potapov <potapov.d@gmail.com>
parents:
2165
diff
changeset
|
4847 |
#endif |
282531385f34
Multilanguage spell checking
Dmitry Potapov <potapov.d@gmail.com>
parents:
2165
diff
changeset
|
4848 |
g_free(sc); |
282531385f34
Multilanguage spell checking
Dmitry Potapov <potapov.d@gmail.com>
parents:
2165
diff
changeset
|
4849 |
} |
282531385f34
Multilanguage spell checking
Dmitry Potapov <potapov.d@gmail.com>
parents:
2165
diff
changeset
|
4850 |
|
282531385f34
Multilanguage spell checking
Dmitry Potapov <potapov.d@gmail.com>
parents:
2165
diff
changeset
|
4851 |
static spell_checker* new_spell_checker(const char* spell_lang) |
282531385f34
Multilanguage spell checking
Dmitry Potapov <potapov.d@gmail.com>
parents:
2165
diff
changeset
|
4852 |
{ |
282531385f34
Multilanguage spell checking
Dmitry Potapov <potapov.d@gmail.com>
parents:
2165
diff
changeset
|
4853 |
spell_checker* sc = g_new(spell_checker, 1); |
282531385f34
Multilanguage spell checking
Dmitry Potapov <potapov.d@gmail.com>
parents:
2165
diff
changeset
|
4854 |
#ifdef WITH_ASPELL |
282531385f34
Multilanguage spell checking
Dmitry Potapov <potapov.d@gmail.com>
parents:
2165
diff
changeset
|
4855 |
const char *spell_encoding = settings_opt_get("spell_encoding"); |
282531385f34
Multilanguage spell checking
Dmitry Potapov <potapov.d@gmail.com>
parents:
2165
diff
changeset
|
4856 |
AspellCanHaveError *possible_err; |
282531385f34
Multilanguage spell checking
Dmitry Potapov <potapov.d@gmail.com>
parents:
2165
diff
changeset
|
4857 |
sc->config = new_aspell_config(); |
282531385f34
Multilanguage spell checking
Dmitry Potapov <potapov.d@gmail.com>
parents:
2165
diff
changeset
|
4858 |
if (spell_encoding) |
282531385f34
Multilanguage spell checking
Dmitry Potapov <potapov.d@gmail.com>
parents:
2165
diff
changeset
|
4859 |
aspell_config_replace(sc->config, "encoding", spell_encoding); |
282531385f34
Multilanguage spell checking
Dmitry Potapov <potapov.d@gmail.com>
parents:
2165
diff
changeset
|
4860 |
aspell_config_replace(sc->config, "lang", spell_lang); |
282531385f34
Multilanguage spell checking
Dmitry Potapov <potapov.d@gmail.com>
parents:
2165
diff
changeset
|
4861 |
possible_err = new_aspell_speller(sc->config); |
282531385f34
Multilanguage spell checking
Dmitry Potapov <potapov.d@gmail.com>
parents:
2165
diff
changeset
|
4862 |
|
282531385f34
Multilanguage spell checking
Dmitry Potapov <potapov.d@gmail.com>
parents:
2165
diff
changeset
|
4863 |
if (aspell_error_number(possible_err) != 0) { |
282531385f34
Multilanguage spell checking
Dmitry Potapov <potapov.d@gmail.com>
parents:
2165
diff
changeset
|
4864 |
delete_aspell_config(sc->config); |
282531385f34
Multilanguage spell checking
Dmitry Potapov <potapov.d@gmail.com>
parents:
2165
diff
changeset
|
4865 |
g_free(sc); |
282531385f34
Multilanguage spell checking
Dmitry Potapov <potapov.d@gmail.com>
parents:
2165
diff
changeset
|
4866 |
sc = NULL; |
282531385f34
Multilanguage spell checking
Dmitry Potapov <potapov.d@gmail.com>
parents:
2165
diff
changeset
|
4867 |
} else { |
282531385f34
Multilanguage spell checking
Dmitry Potapov <potapov.d@gmail.com>
parents:
2165
diff
changeset
|
4868 |
sc->checker = to_aspell_speller(possible_err); |
282531385f34
Multilanguage spell checking
Dmitry Potapov <potapov.d@gmail.com>
parents:
2165
diff
changeset
|
4869 |
} |
282531385f34
Multilanguage spell checking
Dmitry Potapov <potapov.d@gmail.com>
parents:
2165
diff
changeset
|
4870 |
#endif |
282531385f34
Multilanguage spell checking
Dmitry Potapov <potapov.d@gmail.com>
parents:
2165
diff
changeset
|
4871 |
#ifdef WITH_ENCHANT |
282531385f34
Multilanguage spell checking
Dmitry Potapov <potapov.d@gmail.com>
parents:
2165
diff
changeset
|
4872 |
sc->broker = enchant_broker_init(); |
282531385f34
Multilanguage spell checking
Dmitry Potapov <potapov.d@gmail.com>
parents:
2165
diff
changeset
|
4873 |
sc->checker = enchant_broker_request_dict(sc->broker, spell_lang); |
282531385f34
Multilanguage spell checking
Dmitry Potapov <potapov.d@gmail.com>
parents:
2165
diff
changeset
|
4874 |
if (!sc->checker) { |
282531385f34
Multilanguage spell checking
Dmitry Potapov <potapov.d@gmail.com>
parents:
2165
diff
changeset
|
4875 |
enchant_broker_free(sc->broker); |
282531385f34
Multilanguage spell checking
Dmitry Potapov <potapov.d@gmail.com>
parents:
2165
diff
changeset
|
4876 |
g_free(sc); |
282531385f34
Multilanguage spell checking
Dmitry Potapov <potapov.d@gmail.com>
parents:
2165
diff
changeset
|
4877 |
sc = NULL; |
282531385f34
Multilanguage spell checking
Dmitry Potapov <potapov.d@gmail.com>
parents:
2165
diff
changeset
|
4878 |
} |
282531385f34
Multilanguage spell checking
Dmitry Potapov <potapov.d@gmail.com>
parents:
2165
diff
changeset
|
4879 |
#endif |
282531385f34
Multilanguage spell checking
Dmitry Potapov <potapov.d@gmail.com>
parents:
2165
diff
changeset
|
4880 |
return sc; |
282531385f34
Multilanguage spell checking
Dmitry Potapov <potapov.d@gmail.com>
parents:
2165
diff
changeset
|
4881 |
} |
282531385f34
Multilanguage spell checking
Dmitry Potapov <potapov.d@gmail.com>
parents:
2165
diff
changeset
|
4882 |
|
1590
8d1bcc83ae32
Add support for spellchecking with Enchant (caolan)
Mikael Berthe <mikael@lilotux.net>
parents:
1579
diff
changeset
|
4883 |
// initialization |
1179 | 4884 |
void spellcheck_init(void) |
4885 |
{ |
|
1590
8d1bcc83ae32
Add support for spellchecking with Enchant (caolan)
Mikael Berthe <mikael@lilotux.net>
parents:
1579
diff
changeset
|
4886 |
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
|
4887 |
const char *spell_lang = settings_opt_get("spell_lang"); |
2170
282531385f34
Multilanguage spell checking
Dmitry Potapov <potapov.d@gmail.com>
parents:
2165
diff
changeset
|
4888 |
gchar** langs; |
282531385f34
Multilanguage spell checking
Dmitry Potapov <potapov.d@gmail.com>
parents:
2165
diff
changeset
|
4889 |
gchar** lang_iter; |
282531385f34
Multilanguage spell checking
Dmitry Potapov <potapov.d@gmail.com>
parents:
2165
diff
changeset
|
4890 |
spell_checker* sc; |
1590
8d1bcc83ae32
Add support for spellchecking with Enchant (caolan)
Mikael Berthe <mikael@lilotux.net>
parents:
1579
diff
changeset
|
4891 |
|
8d1bcc83ae32
Add support for spellchecking with Enchant (caolan)
Mikael Berthe <mikael@lilotux.net>
parents:
1579
diff
changeset
|
4892 |
if (!spell_enable) |
1179 | 4893 |
return; |
4894 |
||
2170
282531385f34
Multilanguage spell checking
Dmitry Potapov <potapov.d@gmail.com>
parents:
2165
diff
changeset
|
4895 |
spellcheck_deinit(); |
2015
db8ec238cd2c
Fix segfault when spell checking is enabled and spell_lang is not set.
Mikael Berthe <mikael@lilotux.net>
parents:
2013
diff
changeset
|
4896 |
|
db8ec238cd2c
Fix segfault when spell checking is enabled and spell_lang is not set.
Mikael Berthe <mikael@lilotux.net>
parents:
2013
diff
changeset
|
4897 |
if (!spell_lang) { // Cannot initialize: language not specified |
db8ec238cd2c
Fix segfault when spell checking is enabled and spell_lang is not set.
Mikael Berthe <mikael@lilotux.net>
parents:
2013
diff
changeset
|
4898 |
scr_LogPrint(LPRINT_LOGNORM, "Error: Cannot initialize spell checker, language not specified."); |
db8ec238cd2c
Fix segfault when spell checking is enabled and spell_lang is not set.
Mikael Berthe <mikael@lilotux.net>
parents:
2013
diff
changeset
|
4899 |
scr_LogPrint(LPRINT_LOGNORM, "Please set the 'spell_lang' variable."); |
db8ec238cd2c
Fix segfault when spell checking is enabled and spell_lang is not set.
Mikael Berthe <mikael@lilotux.net>
parents:
2013
diff
changeset
|
4900 |
return; |
db8ec238cd2c
Fix segfault when spell checking is enabled and spell_lang is not set.
Mikael Berthe <mikael@lilotux.net>
parents:
2013
diff
changeset
|
4901 |
} |
db8ec238cd2c
Fix segfault when spell checking is enabled and spell_lang is not set.
Mikael Berthe <mikael@lilotux.net>
parents:
2013
diff
changeset
|
4902 |
|
2170
282531385f34
Multilanguage spell checking
Dmitry Potapov <potapov.d@gmail.com>
parents:
2165
diff
changeset
|
4903 |
langs = g_strsplit(spell_lang, " ", -1); |
282531385f34
Multilanguage spell checking
Dmitry Potapov <potapov.d@gmail.com>
parents:
2165
diff
changeset
|
4904 |
for (lang_iter = langs; *lang_iter; ++lang_iter) { |
282531385f34
Multilanguage spell checking
Dmitry Potapov <potapov.d@gmail.com>
parents:
2165
diff
changeset
|
4905 |
if (**lang_iter) { // Skip empty strings |
282531385f34
Multilanguage spell checking
Dmitry Potapov <potapov.d@gmail.com>
parents:
2165
diff
changeset
|
4906 |
sc = new_spell_checker(*lang_iter); |
282531385f34
Multilanguage spell checking
Dmitry Potapov <potapov.d@gmail.com>
parents:
2165
diff
changeset
|
4907 |
if (sc) { |
282531385f34
Multilanguage spell checking
Dmitry Potapov <potapov.d@gmail.com>
parents:
2165
diff
changeset
|
4908 |
spell_checkers = g_slist_append(spell_checkers, sc); |
2171
46d1182d45be
Spell checking: Fix wrong highlighting when no language can be used
Mikael Berthe <mikael@lilotux.net>
parents:
2170
diff
changeset
|
4909 |
} else { |
46d1182d45be
Spell checking: Fix wrong highlighting when no language can be used
Mikael Berthe <mikael@lilotux.net>
parents:
2170
diff
changeset
|
4910 |
scr_LogPrint(LPRINT_LOGNORM, |
46d1182d45be
Spell checking: Fix wrong highlighting when no language can be used
Mikael Berthe <mikael@lilotux.net>
parents:
2170
diff
changeset
|
4911 |
"Warning: Could not load spell checker language '%s'.", |
46d1182d45be
Spell checking: Fix wrong highlighting when no language can be used
Mikael Berthe <mikael@lilotux.net>
parents:
2170
diff
changeset
|
4912 |
*lang_iter); |
2170
282531385f34
Multilanguage spell checking
Dmitry Potapov <potapov.d@gmail.com>
parents:
2165
diff
changeset
|
4913 |
} |
282531385f34
Multilanguage spell checking
Dmitry Potapov <potapov.d@gmail.com>
parents:
2165
diff
changeset
|
4914 |
} |
1179 | 4915 |
} |
2170
282531385f34
Multilanguage spell checking
Dmitry Potapov <potapov.d@gmail.com>
parents:
2165
diff
changeset
|
4916 |
g_strfreev(langs); |
1179 | 4917 |
} |
4918 |
||
1590
8d1bcc83ae32
Add support for spellchecking with Enchant (caolan)
Mikael Berthe <mikael@lilotux.net>
parents:
1579
diff
changeset
|
4919 |
// Deinitialization of spellchecker |
1179 | 4920 |
void spellcheck_deinit(void) |
4921 |
{ |
|
2170
282531385f34
Multilanguage spell checking
Dmitry Potapov <potapov.d@gmail.com>
parents:
2165
diff
changeset
|
4922 |
g_slist_free_full(spell_checkers, spell_checker_free); |
282531385f34
Multilanguage spell checking
Dmitry Potapov <potapov.d@gmail.com>
parents:
2165
diff
changeset
|
4923 |
spell_checkers = NULL; |
282531385f34
Multilanguage spell checking
Dmitry Potapov <potapov.d@gmail.com>
parents:
2165
diff
changeset
|
4924 |
} |
282531385f34
Multilanguage spell checking
Dmitry Potapov <potapov.d@gmail.com>
parents:
2165
diff
changeset
|
4925 |
|
282531385f34
Multilanguage spell checking
Dmitry Potapov <potapov.d@gmail.com>
parents:
2165
diff
changeset
|
4926 |
typedef struct { |
282531385f34
Multilanguage spell checking
Dmitry Potapov <potapov.d@gmail.com>
parents:
2165
diff
changeset
|
4927 |
const char* str; |
282531385f34
Multilanguage spell checking
Dmitry Potapov <potapov.d@gmail.com>
parents:
2165
diff
changeset
|
4928 |
int len; |
282531385f34
Multilanguage spell checking
Dmitry Potapov <potapov.d@gmail.com>
parents:
2165
diff
changeset
|
4929 |
} spell_substring; |
282531385f34
Multilanguage spell checking
Dmitry Potapov <potapov.d@gmail.com>
parents:
2165
diff
changeset
|
4930 |
|
282531385f34
Multilanguage spell checking
Dmitry Potapov <potapov.d@gmail.com>
parents:
2165
diff
changeset
|
4931 |
static int spellcheckword(gconstpointer sc_ptr, gconstpointer substr_ptr) |
282531385f34
Multilanguage spell checking
Dmitry Potapov <potapov.d@gmail.com>
parents:
2165
diff
changeset
|
4932 |
{ |
282531385f34
Multilanguage spell checking
Dmitry Potapov <potapov.d@gmail.com>
parents:
2165
diff
changeset
|
4933 |
spell_checker* sc = (spell_checker*) sc_ptr; |
282531385f34
Multilanguage spell checking
Dmitry Potapov <potapov.d@gmail.com>
parents:
2165
diff
changeset
|
4934 |
spell_substring* substr = (spell_substring*) substr_ptr; |
1590
8d1bcc83ae32
Add support for spellchecking with Enchant (caolan)
Mikael Berthe <mikael@lilotux.net>
parents:
1579
diff
changeset
|
4935 |
#ifdef WITH_ENCHANT |
2170
282531385f34
Multilanguage spell checking
Dmitry Potapov <potapov.d@gmail.com>
parents:
2165
diff
changeset
|
4936 |
// enchant_dict_check will return 0 on good word |
282531385f34
Multilanguage spell checking
Dmitry Potapov <potapov.d@gmail.com>
parents:
2165
diff
changeset
|
4937 |
return enchant_dict_check(sc->checker, substr->str, substr->len); |
1590
8d1bcc83ae32
Add support for spellchecking with Enchant (caolan)
Mikael Berthe <mikael@lilotux.net>
parents:
1579
diff
changeset
|
4938 |
#endif |
8d1bcc83ae32
Add support for spellchecking with Enchant (caolan)
Mikael Berthe <mikael@lilotux.net>
parents:
1579
diff
changeset
|
4939 |
#ifdef WITH_ASPELL |
2170
282531385f34
Multilanguage spell checking
Dmitry Potapov <potapov.d@gmail.com>
parents:
2165
diff
changeset
|
4940 |
// aspell_speller_check will return 1 on good word, so we need to make it 0 |
282531385f34
Multilanguage spell checking
Dmitry Potapov <potapov.d@gmail.com>
parents:
2165
diff
changeset
|
4941 |
return aspell_speller_check(sc->checker, substr->str, substr->len) - 1; |
1590
8d1bcc83ae32
Add support for spellchecking with Enchant (caolan)
Mikael Berthe <mikael@lilotux.net>
parents:
1579
diff
changeset
|
4942 |
#endif |
2170
282531385f34
Multilanguage spell checking
Dmitry Potapov <potapov.d@gmail.com>
parents:
2165
diff
changeset
|
4943 |
return 0; // Keep compiler happy |
1179 | 4944 |
} |
4945 |
||
1590
8d1bcc83ae32
Add support for spellchecking with Enchant (caolan)
Mikael Berthe <mikael@lilotux.net>
parents:
1579
diff
changeset
|
4946 |
#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
|
4947 |
|
1179 | 4948 |
// Spell checking function |
4949 |
static void spellcheck(char *line, char *checked) |
|
4950 |
{ |
|
4951 |
const char *start, *line_start; |
|
2170
282531385f34
Multilanguage spell checking
Dmitry Potapov <potapov.d@gmail.com>
parents:
2165
diff
changeset
|
4952 |
spell_substring substr; |
1179 | 4953 |
|
4954 |
if (inputLine[0] == 0 || inputLine[0] == COMMAND_CHAR) |
|
4955 |
return; |
|
4956 |
||
2171
46d1182d45be
Spell checking: Fix wrong highlighting when no language can be used
Mikael Berthe <mikael@lilotux.net>
parents:
2170
diff
changeset
|
4957 |
// Give up early if not languages are loaded |
46d1182d45be
Spell checking: Fix wrong highlighting when no language can be used
Mikael Berthe <mikael@lilotux.net>
parents:
2170
diff
changeset
|
4958 |
if (!spell_checkers) |
46d1182d45be
Spell checking: Fix wrong highlighting when no language can be used
Mikael Berthe <mikael@lilotux.net>
parents:
2170
diff
changeset
|
4959 |
return; |
46d1182d45be
Spell checking: Fix wrong highlighting when no language can be used
Mikael Berthe <mikael@lilotux.net>
parents:
2170
diff
changeset
|
4960 |
|
1179 | 4961 |
line_start = line; |
4962 |
||
4963 |
while (*line) { |
|
4964 |
||
1590
8d1bcc83ae32
Add support for spellchecking with Enchant (caolan)
Mikael Berthe <mikael@lilotux.net>
parents:
1579
diff
changeset
|
4965 |
if (!spell_isalpha(line)) { |
1179 | 4966 |
line = next_char(line); |
4967 |
continue; |
|
4968 |
} |
|
4969 |
||
4970 |
if (!strncmp(line, "http://", 7)) { |
|
4971 |
line += 7; // : and / characters are 1 byte long in utf8, right? |
|
4972 |
||
4973 |
while (!strchr(" \t\r\n", *line)) |
|
4974 |
line = next_char(line); // i think line++ would be fine here? |
|
4975 |
||
4976 |
continue; |
|
4977 |
} |
|
4978 |
||
4979 |
if (!strncmp(line, "ftp://", 6)) { |
|
4980 |
line += 6; |
|
4981 |
||
4982 |
while (!strchr(" \t\r\n", *line)) |
|
4983 |
line = next_char(line); |
|
4984 |
||
4985 |
continue; |
|
4986 |
} |
|
4987 |
||
4988 |
start = line; |
|
4989 |
||
1590
8d1bcc83ae32
Add support for spellchecking with Enchant (caolan)
Mikael Berthe <mikael@lilotux.net>
parents:
1579
diff
changeset
|
4990 |
while (spell_isalpha(line)) |
1179 | 4991 |
line = next_char(line); |
4992 |
||
2170
282531385f34
Multilanguage spell checking
Dmitry Potapov <potapov.d@gmail.com>
parents:
2165
diff
changeset
|
4993 |
substr.str = start; |
282531385f34
Multilanguage spell checking
Dmitry Potapov <potapov.d@gmail.com>
parents:
2165
diff
changeset
|
4994 |
substr.len = line - start; |
282531385f34
Multilanguage spell checking
Dmitry Potapov <potapov.d@gmail.com>
parents:
2165
diff
changeset
|
4995 |
if (!g_slist_find_custom(spell_checkers, &substr, spellcheckword)) |
1590
8d1bcc83ae32
Add support for spellchecking with Enchant (caolan)
Mikael Berthe <mikael@lilotux.net>
parents:
1579
diff
changeset
|
4996 |
memset(&checked[start - line_start], SPELLBADCHAR, line - start); |
1179 | 4997 |
} |
4998 |
} |
|
4999 |
#endif |
|
5000 |
||
2304
fa8365fb6ac2
[PATCH 1/3] New option: vi_mode
Holger Weiß <holger@zedat.fu-berlin.de>
parents:
2292
diff
changeset
|
5001 |
static void open_chat_window(void) |
fa8365fb6ac2
[PATCH 1/3] New option: vi_mode
Holger Weiß <holger@zedat.fu-berlin.de>
parents:
2292
diff
changeset
|
5002 |
{ |
fa8365fb6ac2
[PATCH 1/3] New option: vi_mode
Holger Weiß <holger@zedat.fu-berlin.de>
parents:
2292
diff
changeset
|
5003 |
last_activity_buddy = current_buddy; |
fa8365fb6ac2
[PATCH 1/3] New option: vi_mode
Holger Weiß <holger@zedat.fu-berlin.de>
parents:
2292
diff
changeset
|
5004 |
scr_check_auto_away(TRUE); |
fa8365fb6ac2
[PATCH 1/3] New option: vi_mode
Holger Weiß <holger@zedat.fu-berlin.de>
parents:
2292
diff
changeset
|
5005 |
scr_set_chatmode(TRUE); |
fa8365fb6ac2
[PATCH 1/3] New option: vi_mode
Holger Weiß <holger@zedat.fu-berlin.de>
parents:
2292
diff
changeset
|
5006 |
scr_show_buddy_window(); |
fa8365fb6ac2
[PATCH 1/3] New option: vi_mode
Holger Weiß <holger@zedat.fu-berlin.de>
parents:
2292
diff
changeset
|
5007 |
} |
fa8365fb6ac2
[PATCH 1/3] New option: vi_mode
Holger Weiß <holger@zedat.fu-berlin.de>
parents:
2292
diff
changeset
|
5008 |
|
fa8365fb6ac2
[PATCH 1/3] New option: vi_mode
Holger Weiß <holger@zedat.fu-berlin.de>
parents:
2292
diff
changeset
|
5009 |
static void clear_inputline(void) |
fa8365fb6ac2
[PATCH 1/3] New option: vi_mode
Holger Weiß <holger@zedat.fu-berlin.de>
parents:
2292
diff
changeset
|
5010 |
{ |
fa8365fb6ac2
[PATCH 1/3] New option: vi_mode
Holger Weiß <holger@zedat.fu-berlin.de>
parents:
2292
diff
changeset
|
5011 |
ptr_inputline = inputLine; |
fa8365fb6ac2
[PATCH 1/3] New option: vi_mode
Holger Weiß <holger@zedat.fu-berlin.de>
parents:
2292
diff
changeset
|
5012 |
*ptr_inputline = 0; |
fa8365fb6ac2
[PATCH 1/3] New option: vi_mode
Holger Weiß <holger@zedat.fu-berlin.de>
parents:
2292
diff
changeset
|
5013 |
inputline_offset = 0; |
fa8365fb6ac2
[PATCH 1/3] New option: vi_mode
Holger Weiß <holger@zedat.fu-berlin.de>
parents:
2292
diff
changeset
|
5014 |
} |
fa8365fb6ac2
[PATCH 1/3] New option: vi_mode
Holger Weiß <holger@zedat.fu-berlin.de>
parents:
2292
diff
changeset
|
5015 |
|
1811 | 5016 |
/* vim: set et cindent cinoptions=>2\:2(0 ts=2 sw=2: For Vim users... */ |