Mercurial > ~mikael > mcabber > hg
annotate mcabber/mcabber/screen.c @ 2343:762ee698c8cd
Hide the log window when log_win_height <= 0
author | franky |
---|---|
date | Tue, 28 May 2019 22:28:49 +0200 |
parents | d7b52c883ca4 |
children | 1579ed96d501 |
rev | line source |
---|---|
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 |
2333
69d292ccf196
Fix multiple declarations issue with COLOR_ATTRIB
Andrey Utkin <andrey_utkin@gentoo.org>
parents:
2328
diff
changeset
|
62 int COLOR_ATTRIB[COLOR_max]; |
69d292ccf196
Fix multiple declarations issue with COLOR_ATTRIB
Andrey Utkin <andrey_utkin@gentoo.org>
parents:
2328
diff
changeset
|
63 |
2028
7b5bd6ad83b4
Add 'color_log' (text color in the log window)
Mikael Berthe <mikael@lilotux.net>
parents:
2015
diff
changeset
|
64 #define get_color(col) (COLOR_PAIR(col)|COLOR_ATTRIB[col]) |
1489
e9c71ce96dca
Fixed the colorhandling for mucnicks and /color roster
franky@veqlargh.fs
parents:
1488
diff
changeset
|
65 #define compose_color(col) (COLOR_PAIR(col->color_pair)|col->color_attrib) |
24 | 66 |
2342 | 67 #define DEFAULT_LOG_WIN_HEIGHT (5) |
701
6c100adfbfb6
Add setting "roster_width" (variable buddylist width)
Mikael Berthe <mikael@lilotux.net>
parents:
699
diff
changeset
|
68 #define DEFAULT_ROSTER_WIDTH 24 |
2342 | 69 #define CHAT_WIN_HEIGHT (maxY-2-1-Log_Win_Height) |
515
180f0a6e4ac9
Log window's height can be set by the user
Mikael Berthe <mikael@lilotux.net>
parents:
514
diff
changeset
|
70 |
2100
113d3b96ae3e
Add option 'attention_char'
Mikael Berthe <mikael@lilotux.net>
parents:
2098
diff
changeset
|
71 #define DEFAULT_ATTENTION_CHAR '!' |
113d3b96ae3e
Add option 'attention_char'
Mikael Berthe <mikael@lilotux.net>
parents:
2098
diff
changeset
|
72 |
1390 | 73 const char *LocaleCharSet = "C"; |
592
67a332121aea
Try UTF8 -> locale conversion with fallback
Mikael Berthe <mikael@lilotux.net>
parents:
580
diff
changeset
|
74 |
515
180f0a6e4ac9
Log window's height can be set by the user
Mikael Berthe <mikael@lilotux.net>
parents:
514
diff
changeset
|
75 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
|
76 static unsigned short int Roster_Width; |
1942
3e39a336a992
Use guards for colors (Myhailo Danylenko)
Mikael Berthe <mikael@lilotux.net>
parents:
1935
diff
changeset
|
77 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
|
78 |
1804
35a1250c111a
Display urgent/attention sign in the roster UI
Mikael Berthe <mikael@lilotux.net>
parents:
1802
diff
changeset
|
79 // Default attention sign trigger levels |
35a1250c111a
Display urgent/attention sign in the roster UI
Mikael Berthe <mikael@lilotux.net>
parents:
1802
diff
changeset
|
80 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
|
81 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
|
82 |
336
eb994ee40029
Make some functions static
Mikael Berthe <mikael@lilotux.net>
parents:
332
diff
changeset
|
83 static inline void check_offset(int); |
1172
334ae9f498f1
Add some more iline functions (Lego12239)
Mikael Berthe <mikael@lilotux.net>
parents:
1171
diff
changeset
|
84 static void scr_cancel_current_completion(void); |
334ae9f498f1
Add some more iline functions (Lego12239)
Mikael Berthe <mikael@lilotux.net>
parents:
1171
diff
changeset
|
85 static void scr_end_current_completion(void); |
334ae9f498f1
Add some more iline functions (Lego12239)
Mikael Berthe <mikael@lilotux.net>
parents:
1171
diff
changeset
|
86 static void scr_insert_text(const char*); |
2143
2f294c2b6778
Add a backward completion (Oleg)
Mikael Berthe <mikael@lilotux.net>
parents:
2136
diff
changeset
|
87 static void scr_handle_tab(gboolean fwd); |
151 | 88 |
2149
1b3add57c912
Try to display the GLib warnings in the log window
Mikael Berthe <mikael@lilotux.net>
parents:
2143
diff
changeset
|
89 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
|
90 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
|
91 |
2165 | 92 #ifdef XEP0085 |
1780
e4378fbab5d7
Major API cleanup - bump API to 4
Mikael Berthe <mikael@lilotux.net>
parents:
1761
diff
changeset
|
93 static gboolean scr_chatstates_timeout(); |
e4378fbab5d7
Major API cleanup - bump API to 4
Mikael Berthe <mikael@lilotux.net>
parents:
1761
diff
changeset
|
94 #endif |
e4378fbab5d7
Major API cleanup - bump API to 4
Mikael Berthe <mikael@lilotux.net>
parents:
1761
diff
changeset
|
95 |
1590
8d1bcc83ae32
Add support for spellchecking with Enchant (caolan)
Mikael Berthe <mikael@lilotux.net>
parents:
1579
diff
changeset
|
96 #if defined(WITH_ENCHANT) || defined(WITH_ASPELL) |
1179 | 97 static void spellcheck(char *, char *); |
98 #endif | |
99 | |
2304
fa8365fb6ac2
[PATCH 1/3] New option: vi_mode
Holger Weiß <holger@zedat.fu-berlin.de>
parents:
2292
diff
changeset
|
100 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
|
101 static void clear_inputline(void); |
fa8365fb6ac2
[PATCH 1/3] New option: vi_mode
Holger Weiß <holger@zedat.fu-berlin.de>
parents:
2292
diff
changeset
|
102 |
1078
7866dbaf67a6
Use a hash for the list of win buffers
Mikael Berthe <mikael@lilotux.net>
parents:
1077
diff
changeset
|
103 static GHashTable *winbufhash; |
24 | 104 |
822 | 105 typedef struct { |
2225
dc3b3ac1ba76
Free the buffdata structures when buffers are closed
Mikael Berthe <mikael@lilotux.net>
parents:
2222
diff
changeset
|
106 GList *hbuf; |
dc3b3ac1ba76
Free the buffdata structures when buffers are closed
Mikael Berthe <mikael@lilotux.net>
parents:
2222
diff
changeset
|
107 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
|
108 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
|
109 char lock; |
dc3b3ac1ba76
Free the buffdata structures when buffers are closed
Mikael Berthe <mikael@lilotux.net>
parents:
2222
diff
changeset
|
110 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
|
111 // e.g. with symlinked history |
2337 | 112 } buffdata_t; |
1157
5c857f0f0ab8
Moved all variables related to hbuf to an extra struct, bufdata
Frank Zschockelt
parents:
1156
diff
changeset
|
113 |
5c857f0f0ab8
Moved all variables related to hbuf to an extra struct, bufdata
Frank Zschockelt
parents:
1156
diff
changeset
|
114 typedef struct { |
24 | 115 WINDOW *win; |
108 | 116 PANEL *panel; |
2337 | 117 buffdata_t *bd; |
118 } winbuf_t; | |
24 | 119 |
1078
7866dbaf67a6
Use a hash for the list of win buffers
Mikael Berthe <mikael@lilotux.net>
parents:
1077
diff
changeset
|
120 struct dimensions { |
7866dbaf67a6
Use a hash for the list of win buffers
Mikael Berthe <mikael@lilotux.net>
parents:
1077
diff
changeset
|
121 int l; |
7866dbaf67a6
Use a hash for the list of win buffers
Mikael Berthe <mikael@lilotux.net>
parents:
1077
diff
changeset
|
122 int c; |
7866dbaf67a6
Use a hash for the list of win buffers
Mikael Berthe <mikael@lilotux.net>
parents:
1077
diff
changeset
|
123 }; |
24 | 124 |
1133
9dd28a56128f
Do not create one panel per contact
Mikael Berthe <mikael@lilotux.net>
parents:
1131
diff
changeset
|
125 static WINDOW *rosterWnd, *chatWnd, *activechatWnd, *inputWnd, *logWnd; |
711 | 126 static WINDOW *mainstatusWnd, *chatstatusWnd; |
1133
9dd28a56128f
Do not create one panel per contact
Mikael Berthe <mikael@lilotux.net>
parents:
1131
diff
changeset
|
127 static PANEL *rosterPanel, *chatPanel, *activechatPanel, *inputPanel; |
711 | 128 static PANEL *mainstatusPanel, *chatstatusPanel; |
129 static PANEL *logPanel; | |
24 | 130 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
|
131 static int prev_chatwidth; |
2337 | 132 static winbuf_t *statusWindow; |
133 static winbuf_t *currentWindow; | |
851
da03534e46c7
Add startup log messages to the status buffer
Mikael Berthe <mikael@lilotux.net>
parents:
850
diff
changeset
|
134 static GList *statushbuf; |
24 | 135 |
707
b26a0bde4cdb
Add /roster hide|show|toggle
Mikael Berthe <mikael@lilotux.net>
parents:
701
diff
changeset
|
136 static int roster_hidden; |
24 | 137 static int chatmode; |
238 | 138 static int multimode; |
807
f6cda389db48
Allow messages with a subject (/msay)
Mikael Berthe <mikael@lilotux.net>
parents:
806
diff
changeset
|
139 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
|
140 static int roster_no_leading_space; |
1780
e4378fbab5d7
Major API cleanup - bump API to 4
Mikael Berthe <mikael@lilotux.net>
parents:
1761
diff
changeset
|
141 |
332
a1901741890e
scr_LogPrint() can be called before ncurses initialization
Mikael Berthe <mikael@lilotux.net>
parents:
330
diff
changeset
|
142 static bool Curses; |
972
11b632d824f6
Add option 'log_win_on_top'
Mikael Berthe <mikael@lilotux.net>
parents:
967
diff
changeset
|
143 static bool log_win_on_top; |
973
e693cbe33802
Add option 'roster_win_on_right'
Mikael Berthe <mikael@lilotux.net>
parents:
972
diff
changeset
|
144 static bool roster_win_on_right; |
1677 | 145 static guint autoaway_source = 0; |
24 | 146 |
174 | 147 static char inputLine[INPUTLINE_LENGTH+1]; |
1590
8d1bcc83ae32
Add support for spellchecking with Enchant (caolan)
Mikael Berthe <mikael@lilotux.net>
parents:
1579
diff
changeset
|
148 #if defined(WITH_ENCHANT) || defined(WITH_ASPELL) |
1179 | 149 static char maskLine[INPUTLINE_LENGTH+1]; |
150 #endif | |
174 | 151 static char *ptr_inputline; |
152 static short int inputline_offset; | |
153 static int completion_started; | |
173 | 154 static GList *cmdhisto; |
155 static GList *cmdhisto_cur; | |
1127
fddf2fef7b83
Add option "cmdhistory_lines"
Mikael Berthe <mikael@lilotux.net>
parents:
1122
diff
changeset
|
156 static guint cmdhisto_nblines; |
174 | 157 static char cmdhisto_backup[INPUTLINE_LENGTH+1]; |
24 | 158 |
991
ef10906691bb
Chatstates: add composing timeout
Mikael Berthe <mikael@lilotux.net>
parents:
990
diff
changeset
|
159 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
|
160 static bool lock_chatstate; |
991
ef10906691bb
Chatstates: add composing timeout
Mikael Berthe <mikael@lilotux.net>
parents:
990
diff
changeset
|
161 static time_t chatstate_timestamp; |
1598 | 162 static guint chatstate_timeout_id = 0; |
1780
e4378fbab5d7
Major API cleanup - bump API to 4
Mikael Berthe <mikael@lilotux.net>
parents:
1761
diff
changeset
|
163 |
2292
f181418db215
Replace global variable update_roster with scr_update_roster()
franky
parents:
2291
diff
changeset
|
164 int _update_roster; |
1780
e4378fbab5d7
Major API cleanup - bump API to 4
Mikael Berthe <mikael@lilotux.net>
parents:
1761
diff
changeset
|
165 int utf8_mode; |
e4378fbab5d7
Major API cleanup - bump API to 4
Mikael Berthe <mikael@lilotux.net>
parents:
1761
diff
changeset
|
166 gboolean chatstates_disabled; |
e4378fbab5d7
Major API cleanup - bump API to 4
Mikael Berthe <mikael@lilotux.net>
parents:
1761
diff
changeset
|
167 gboolean Autoaway; |
990
35e7913affb7
Send events/chatstates notifications (JEP-22/JEP-85)
Mikael Berthe <mikael@lilotux.net>
parents:
987
diff
changeset
|
168 |
2334
6ad3cada768c
Fix multiple declarations issue with vi_mode
Andrey Utkin <andrey_utkin@gentoo.org>
parents:
2333
diff
changeset
|
169 gboolean vi_mode; |
6ad3cada768c
Fix multiple declarations issue with vi_mode
Andrey Utkin <andrey_utkin@gentoo.org>
parents:
2333
diff
changeset
|
170 |
761
4532a9fe0e8c
Handle some keyboard escape sequences
Mikael Berthe <mikael@lilotux.net>
parents:
760
diff
changeset
|
171 #define MAX_KEYSEQ_LENGTH 8 |
4532a9fe0e8c
Handle some keyboard escape sequences
Mikael Berthe <mikael@lilotux.net>
parents:
760
diff
changeset
|
172 |
4532a9fe0e8c
Handle some keyboard escape sequences
Mikael Berthe <mikael@lilotux.net>
parents:
760
diff
changeset
|
173 typedef struct { |
4532a9fe0e8c
Handle some keyboard escape sequences
Mikael Berthe <mikael@lilotux.net>
parents:
760
diff
changeset
|
174 char *seqstr; |
4532a9fe0e8c
Handle some keyboard escape sequences
Mikael Berthe <mikael@lilotux.net>
parents:
760
diff
changeset
|
175 guint mkeycode; |
4532a9fe0e8c
Handle some keyboard escape sequences
Mikael Berthe <mikael@lilotux.net>
parents:
760
diff
changeset
|
176 gint value; |
2337 | 177 } keyseq_t; |
761
4532a9fe0e8c
Handle some keyboard escape sequences
Mikael Berthe <mikael@lilotux.net>
parents:
760
diff
changeset
|
178 |
4532a9fe0e8c
Handle some keyboard escape sequences
Mikael Berthe <mikael@lilotux.net>
parents:
760
diff
changeset
|
179 GSList *keyseqlist; |
4532a9fe0e8c
Handle some keyboard escape sequences
Mikael Berthe <mikael@lilotux.net>
parents:
760
diff
changeset
|
180 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
|
181 |
1780
e4378fbab5d7
Major API cleanup - bump API to 4
Mikael Berthe <mikael@lilotux.net>
parents:
1761
diff
changeset
|
182 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
|
183 time_t timestamp, unsigned int prefix_flags, |
e4378fbab5d7
Major API cleanup - bump API to 4
Mikael Berthe <mikael@lilotux.net>
parents:
1761
diff
changeset
|
184 int force_show, unsigned mucnicklen, |
e4378fbab5d7
Major API cleanup - bump API to 4
Mikael Berthe <mikael@lilotux.net>
parents:
1761
diff
changeset
|
185 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 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
|
188 time_t timestamp, guint prefix_flags, |
e4378fbab5d7
Major API cleanup - bump API to 4
Mikael Berthe <mikael@lilotux.net>
parents:
1761
diff
changeset
|
189 unsigned mucnicklen, gpointer xep184); |
e4378fbab5d7
Major API cleanup - bump API to 4
Mikael Berthe <mikael@lilotux.net>
parents:
1761
diff
changeset
|
190 |
2338 | 191 void scr_update_buddy_window(void); |
192 void scr_set_chatmode(int enable); | |
1413 | 193 |
1590
8d1bcc83ae32
Add support for spellchecking with Enchant (caolan)
Mikael Berthe <mikael@lilotux.net>
parents:
1579
diff
changeset
|
194 #define SPELLBADCHAR 5 |
8d1bcc83ae32
Add support for spellchecking with Enchant (caolan)
Mikael Berthe <mikael@lilotux.net>
parents:
1579
diff
changeset
|
195 |
2170
282531385f34
Multilanguage spell checking
Dmitry Potapov <potapov.d@gmail.com>
parents:
2165
diff
changeset
|
196 #if defined(WITH_ENCHANT) || defined(WITH_ASPELL) |
282531385f34
Multilanguage spell checking
Dmitry Potapov <potapov.d@gmail.com>
parents:
2165
diff
changeset
|
197 typedef struct { |
1590
8d1bcc83ae32
Add support for spellchecking with Enchant (caolan)
Mikael Berthe <mikael@lilotux.net>
parents:
1579
diff
changeset
|
198 #ifdef WITH_ENCHANT |
2170
282531385f34
Multilanguage spell checking
Dmitry Potapov <potapov.d@gmail.com>
parents:
2165
diff
changeset
|
199 EnchantBroker *broker; |
282531385f34
Multilanguage spell checking
Dmitry Potapov <potapov.d@gmail.com>
parents:
2165
diff
changeset
|
200 EnchantDict *checker; |
1590
8d1bcc83ae32
Add support for spellchecking with Enchant (caolan)
Mikael Berthe <mikael@lilotux.net>
parents:
1579
diff
changeset
|
201 #endif |
8d1bcc83ae32
Add support for spellchecking with Enchant (caolan)
Mikael Berthe <mikael@lilotux.net>
parents:
1579
diff
changeset
|
202 #ifdef WITH_ASPELL |
2170
282531385f34
Multilanguage spell checking
Dmitry Potapov <potapov.d@gmail.com>
parents:
2165
diff
changeset
|
203 AspellConfig *config; |
282531385f34
Multilanguage spell checking
Dmitry Potapov <potapov.d@gmail.com>
parents:
2165
diff
changeset
|
204 AspellSpeller *checker; |
282531385f34
Multilanguage spell checking
Dmitry Potapov <potapov.d@gmail.com>
parents:
2165
diff
changeset
|
205 #endif |
2337 | 206 } spell_checker_t; |
2170
282531385f34
Multilanguage spell checking
Dmitry Potapov <potapov.d@gmail.com>
parents:
2165
diff
changeset
|
207 |
282531385f34
Multilanguage spell checking
Dmitry Potapov <potapov.d@gmail.com>
parents:
2165
diff
changeset
|
208 GSList* spell_checkers = NULL; |
1179 | 209 #endif |
24 | 210 |
1272
033576acac4c
Add configurable roster colors (Michal 'vorner' Vaner)
Mikael Berthe <mikael@lilotux.net>
parents:
1268
diff
changeset
|
211 typedef struct { |
2264
44bb9a033407
Revert patch c1eb68306520
Mikael Berthe <mikael@lilotux.net>
parents:
2231
diff
changeset
|
212 int color_pair; |
44bb9a033407
Revert patch c1eb68306520
Mikael Berthe <mikael@lilotux.net>
parents:
2231
diff
changeset
|
213 int color_attrib; |
2337 | 214 } ccolor_t; |
1489
e9c71ce96dca
Fixed the colorhandling for mucnicks and /color roster
franky@veqlargh.fs
parents:
1488
diff
changeset
|
215 |
e9c71ce96dca
Fixed the colorhandling for mucnicks and /color roster
franky@veqlargh.fs
parents:
1488
diff
changeset
|
216 typedef struct { |
1272
033576acac4c
Add configurable roster colors (Michal 'vorner' Vaner)
Mikael Berthe <mikael@lilotux.net>
parents:
1268
diff
changeset
|
217 char *status, *wildcard; |
2337 | 218 ccolor_t *color; |
1272
033576acac4c
Add configurable roster colors (Michal 'vorner' Vaner)
Mikael Berthe <mikael@lilotux.net>
parents:
1268
diff
changeset
|
219 GPatternSpec *compiled; |
2337 | 220 } rostercolor_t; |
1272
033576acac4c
Add configurable roster colors (Michal 'vorner' Vaner)
Mikael Berthe <mikael@lilotux.net>
parents:
1268
diff
changeset
|
221 |
1292
382ec54b584e
Muc nick coloring functionality
Michal 'vorner' Vaner <vorner@ucw.cz>
parents:
1291
diff
changeset
|
222 static GSList *rostercolrules = NULL; |
382ec54b584e
Muc nick coloring functionality
Michal 'vorner' Vaner <vorner@ucw.cz>
parents:
1291
diff
changeset
|
223 |
382ec54b584e
Muc nick coloring functionality
Michal 'vorner' Vaner <vorner@ucw.cz>
parents:
1291
diff
changeset
|
224 static GHashTable *muccolors = NULL, *nickcolors = NULL; |
382ec54b584e
Muc nick coloring functionality
Michal 'vorner' Vaner <vorner@ucw.cz>
parents:
1291
diff
changeset
|
225 |
382ec54b584e
Muc nick coloring functionality
Michal 'vorner' Vaner <vorner@ucw.cz>
parents:
1291
diff
changeset
|
226 typedef struct { |
1413 | 227 bool manual; // Manually set? |
2337 | 228 ccolor_t *color; |
229 } nickcolor_t; | |
1292
382ec54b584e
Muc nick coloring functionality
Michal 'vorner' Vaner <vorner@ucw.cz>
parents:
1291
diff
changeset
|
230 |
1489
e9c71ce96dca
Fixed the colorhandling for mucnicks and /color roster
franky@veqlargh.fs
parents:
1488
diff
changeset
|
231 static int nickcolcount = 0; |
2337 | 232 static ccolor_t ** nickcols = NULL; |
233 static muccol_t glob_muccol = MC_OFF; | |
1272
033576acac4c
Add configurable roster colors (Michal 'vorner' Vaner)
Mikael Berthe <mikael@lilotux.net>
parents:
1268
diff
changeset
|
234 |
99 | 235 /* Functions */ |
24 | 236 |
1780
e4378fbab5d7
Major API cleanup - bump API to 4
Mikael Berthe <mikael@lilotux.net>
parents:
1761
diff
changeset
|
237 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
|
238 { |
1489
e9c71ce96dca
Fixed the colorhandling for mucnicks and /color roster
franky@veqlargh.fs
parents:
1488
diff
changeset
|
239 int result; |
e9c71ce96dca
Fixed the colorhandling for mucnicks and /color roster
franky@veqlargh.fs
parents:
1488
diff
changeset
|
240 |
24 | 241 if (!strcmp(name, "default")) |
242 return -1; | |
243 if (!strcmp(name, "black")) | |
244 return COLOR_BLACK; | |
245 if (!strcmp(name, "red")) | |
246 return COLOR_RED; | |
247 if (!strcmp(name, "green")) | |
248 return COLOR_GREEN; | |
249 if (!strcmp(name, "yellow")) | |
250 return COLOR_YELLOW; | |
251 if (!strcmp(name, "blue")) | |
252 return COLOR_BLUE; | |
253 if (!strcmp(name, "magenta")) | |
254 return COLOR_MAGENTA; | |
255 if (!strcmp(name, "cyan")) | |
256 return COLOR_CYAN; | |
257 if (!strcmp(name, "white")) | |
258 return COLOR_WHITE; | |
259 | |
1417
783b47c9d963
Allow more than the 16 default colors (patch from mjs)
Mikael Berthe <mikael@lilotux.net>
parents:
1414
diff
changeset
|
260 // 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
|
261 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
|
262 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
|
263 return result; |
783b47c9d963
Allow more than the 16 default colors (patch from mjs)
Mikael Berthe <mikael@lilotux.net>
parents:
1414
diff
changeset
|
264 |
739
0d5fb1d9077c
Allow "bright" text colors
Mikael Berthe <mikael@lilotux.net>
parents:
735
diff
changeset
|
265 scr_LogPrint(LPRINT_LOGNORM, "ERROR: Wrong color: %s", name); |
24 | 266 return -1; |
267 } | |
268 | |
2337 | 269 static ccolor_t *get_user_color(const char *color) |
1295
33cb828282d5
Fix recognizing of bright colors
Michal 'vorner' Vaner <vorner@ucw.cz>
parents:
1294
diff
changeset
|
270 { |
1381
40095d413da9
Fix compilation on OpenBSD
Mikael Berthe <mikael@lilotux.net>
parents:
1376
diff
changeset
|
271 bool isbright = FALSE; |
1295
33cb828282d5
Fix recognizing of bright colors
Michal 'vorner' Vaner <vorner@ucw.cz>
parents:
1294
diff
changeset
|
272 int cl; |
2337 | 273 ccolor_t *ccol; |
1295
33cb828282d5
Fix recognizing of bright colors
Michal 'vorner' Vaner <vorner@ucw.cz>
parents:
1294
diff
changeset
|
274 if (!strncmp(color, "bright", 6)) { |
1381
40095d413da9
Fix compilation on OpenBSD
Mikael Berthe <mikael@lilotux.net>
parents:
1376
diff
changeset
|
275 isbright = TRUE; |
1295
33cb828282d5
Fix recognizing of bright colors
Michal 'vorner' Vaner <vorner@ucw.cz>
parents:
1294
diff
changeset
|
276 color += 6; |
33cb828282d5
Fix recognizing of bright colors
Michal 'vorner' Vaner <vorner@ucw.cz>
parents:
1294
diff
changeset
|
277 } |
1780
e4378fbab5d7
Major API cleanup - bump API to 4
Mikael Berthe <mikael@lilotux.net>
parents:
1761
diff
changeset
|
278 cl = find_color(color); |
1295
33cb828282d5
Fix recognizing of bright colors
Michal 'vorner' Vaner <vorner@ucw.cz>
parents:
1294
diff
changeset
|
279 if (cl < 0) |
1489
e9c71ce96dca
Fixed the colorhandling for mucnicks and /color roster
franky@veqlargh.fs
parents:
1488
diff
changeset
|
280 return NULL; |
2337 | 281 ccol = g_new0(ccolor_t, 1); |
1489
e9c71ce96dca
Fixed the colorhandling for mucnicks and /color roster
franky@veqlargh.fs
parents:
1488
diff
changeset
|
282 ccol->color_attrib = isbright ? A_BOLD : A_NORMAL; |
1729
e6e89b1d7831
Minor style and header updates
Mikael Berthe <mikael@lilotux.net>
parents:
1710
diff
changeset
|
283 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
|
284 return ccol; |
1295
33cb828282d5
Fix recognizing of bright colors
Michal 'vorner' Vaner <vorner@ucw.cz>
parents:
1294
diff
changeset
|
285 } |
33cb828282d5
Fix recognizing of bright colors
Michal 'vorner' Vaner <vorner@ucw.cz>
parents:
1294
diff
changeset
|
286 |
1292
382ec54b584e
Muc nick coloring functionality
Michal 'vorner' Vaner <vorner@ucw.cz>
parents:
1291
diff
changeset
|
287 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
|
288 GDestroyNotify value_destroy_func) |
1292
382ec54b584e
Muc nick coloring functionality
Michal 'vorner' Vaner <vorner@ucw.cz>
parents:
1291
diff
changeset
|
289 { |
1729
e6e89b1d7831
Minor style and header updates
Mikael Berthe <mikael@lilotux.net>
parents:
1710
diff
changeset
|
290 if (*table) // Have it already |
1292
382ec54b584e
Muc nick coloring functionality
Michal 'vorner' Vaner <vorner@ucw.cz>
parents:
1291
diff
changeset
|
291 return; |
382ec54b584e
Muc nick coloring functionality
Michal 'vorner' Vaner <vorner@ucw.cz>
parents:
1291
diff
changeset
|
292 *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
|
293 g_free, value_destroy_func); |
382ec54b584e
Muc nick coloring functionality
Michal 'vorner' Vaner <vorner@ucw.cz>
parents:
1291
diff
changeset
|
294 } |
382ec54b584e
Muc nick coloring functionality
Michal 'vorner' Vaner <vorner@ucw.cz>
parents:
1291
diff
changeset
|
295 |
382ec54b584e
Muc nick coloring functionality
Michal 'vorner' Vaner <vorner@ucw.cz>
parents:
1291
diff
changeset
|
296 // Sets the coloring mode for given MUC |
382ec54b584e
Muc nick coloring functionality
Michal 'vorner' Vaner <vorner@ucw.cz>
parents:
1291
diff
changeset
|
297 // 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
|
298 // muc - the JID of room |
382ec54b584e
Muc nick coloring functionality
Michal 'vorner' Vaner <vorner@ucw.cz>
parents:
1291
diff
changeset
|
299 // type - the new type |
2337 | 300 void scr_muc_color(const char *muc, muccol_t type) |
1292
382ec54b584e
Muc nick coloring functionality
Michal 'vorner' Vaner <vorner@ucw.cz>
parents:
1291
diff
changeset
|
301 { |
382ec54b584e
Muc nick coloring functionality
Michal 'vorner' Vaner <vorner@ucw.cz>
parents:
1291
diff
changeset
|
302 gchar *muclow = g_utf8_strdown(muc, -1); |
1729
e6e89b1d7831
Minor style and header updates
Mikael Berthe <mikael@lilotux.net>
parents:
1710
diff
changeset
|
303 if (type == MC_REMOVE) { // Remove it |
1292
382ec54b584e
Muc nick coloring functionality
Michal 'vorner' Vaner <vorner@ucw.cz>
parents:
1291
diff
changeset
|
304 if (strcmp(muc, "*")) { |
382ec54b584e
Muc nick coloring functionality
Michal 'vorner' Vaner <vorner@ucw.cz>
parents:
1291
diff
changeset
|
305 if (muccolors && g_hash_table_lookup(muccolors, muclow)) |
382ec54b584e
Muc nick coloring functionality
Michal 'vorner' Vaner <vorner@ucw.cz>
parents:
1291
diff
changeset
|
306 g_hash_table_remove(muccolors, muclow); |
382ec54b584e
Muc nick coloring functionality
Michal 'vorner' Vaner <vorner@ucw.cz>
parents:
1291
diff
changeset
|
307 } else { |
382ec54b584e
Muc nick coloring functionality
Michal 'vorner' Vaner <vorner@ucw.cz>
parents:
1291
diff
changeset
|
308 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
|
309 } |
382ec54b584e
Muc nick coloring functionality
Michal 'vorner' Vaner <vorner@ucw.cz>
parents:
1291
diff
changeset
|
310 g_free(muclow); |
1729
e6e89b1d7831
Minor style and header updates
Mikael Berthe <mikael@lilotux.net>
parents:
1710
diff
changeset
|
311 } else { // Add or overwrite |
1292
382ec54b584e
Muc nick coloring functionality
Michal 'vorner' Vaner <vorner@ucw.cz>
parents:
1291
diff
changeset
|
312 if (strcmp(muc, "*")) { |
2337 | 313 muccol_t *value = g_new(muccol_t, 1); |
1292
382ec54b584e
Muc nick coloring functionality
Michal 'vorner' Vaner <vorner@ucw.cz>
parents:
1291
diff
changeset
|
314 *value = type; |
1476
77afd831f8f7
Avoid mixed declarations and code
Mikael Berthe <mikael@lilotux.net>
parents:
1457
diff
changeset
|
315 ensure_string_htable(&muccolors, g_free); |
1292
382ec54b584e
Muc nick coloring functionality
Michal 'vorner' Vaner <vorner@ucw.cz>
parents:
1291
diff
changeset
|
316 g_hash_table_replace(muccolors, muclow, value); |
382ec54b584e
Muc nick coloring functionality
Michal 'vorner' Vaner <vorner@ucw.cz>
parents:
1291
diff
changeset
|
317 } else { |
382ec54b584e
Muc nick coloring functionality
Michal 'vorner' Vaner <vorner@ucw.cz>
parents:
1291
diff
changeset
|
318 glob_muccol = type; |
382ec54b584e
Muc nick coloring functionality
Michal 'vorner' Vaner <vorner@ucw.cz>
parents:
1291
diff
changeset
|
319 g_free(muclow); |
382ec54b584e
Muc nick coloring functionality
Michal 'vorner' Vaner <vorner@ucw.cz>
parents:
1291
diff
changeset
|
320 } |
382ec54b584e
Muc nick coloring functionality
Michal 'vorner' Vaner <vorner@ucw.cz>
parents:
1291
diff
changeset
|
321 } |
1729
e6e89b1d7831
Minor style and header updates
Mikael Berthe <mikael@lilotux.net>
parents:
1710
diff
changeset
|
322 // Need to redraw? |
1333
e30a9d907105
Minor coding style adjustments
Mikael Berthe <mikael@lilotux.net>
parents:
1314
diff
changeset
|
323 if (chatmode && |
e30a9d907105
Minor coding style adjustments
Mikael Berthe <mikael@lilotux.net>
parents:
1314
diff
changeset
|
324 ((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
|
325 scr_update_buddy_window(); |
1292
382ec54b584e
Muc nick coloring functionality
Michal 'vorner' Vaner <vorner@ucw.cz>
parents:
1291
diff
changeset
|
326 } |
382ec54b584e
Muc nick coloring functionality
Michal 'vorner' Vaner <vorner@ucw.cz>
parents:
1291
diff
changeset
|
327 |
382ec54b584e
Muc nick coloring functionality
Michal 'vorner' Vaner <vorner@ucw.cz>
parents:
1291
diff
changeset
|
328 // Sets the color for nick in MUC |
382ec54b584e
Muc nick coloring functionality
Michal 'vorner' Vaner <vorner@ucw.cz>
parents:
1291
diff
changeset
|
329 // 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
|
330 // 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
|
331 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
|
332 { |
1333
e30a9d907105
Minor coding style adjustments
Mikael Berthe <mikael@lilotux.net>
parents:
1314
diff
changeset
|
333 char *snick, *mnick; |
1381
40095d413da9
Fix compilation on OpenBSD
Mikael Berthe <mikael@lilotux.net>
parents:
1376
diff
changeset
|
334 bool need_update = FALSE; |
1333
e30a9d907105
Minor coding style adjustments
Mikael Berthe <mikael@lilotux.net>
parents:
1314
diff
changeset
|
335 snick = g_strdup_printf("<%s>", nick); |
e30a9d907105
Minor coding style adjustments
Mikael Berthe <mikael@lilotux.net>
parents:
1314
diff
changeset
|
336 mnick = g_strdup_printf("*%s ", nick); |
1729
e6e89b1d7831
Minor style and header updates
Mikael Berthe <mikael@lilotux.net>
parents:
1710
diff
changeset
|
337 if (!strcmp(color, "-")) { // Remove the color |
1292
382ec54b584e
Muc nick coloring functionality
Michal 'vorner' Vaner <vorner@ucw.cz>
parents:
1291
diff
changeset
|
338 if (nickcolors) { |
2337 | 339 nickcolor_t *nc = g_hash_table_lookup(nickcolors, snick); |
1729
e6e89b1d7831
Minor style and header updates
Mikael Berthe <mikael@lilotux.net>
parents:
1710
diff
changeset
|
340 if (nc) { // Have this nick already |
1381
40095d413da9
Fix compilation on OpenBSD
Mikael Berthe <mikael@lilotux.net>
parents:
1376
diff
changeset
|
341 nc->manual = FALSE; |
1292
382ec54b584e
Muc nick coloring functionality
Michal 'vorner' Vaner <vorner@ucw.cz>
parents:
1291
diff
changeset
|
342 nc = g_hash_table_lookup(nickcolors, mnick); |
1729
e6e89b1d7831
Minor style and header updates
Mikael Berthe <mikael@lilotux.net>
parents:
1710
diff
changeset
|
343 assert(nc); // Must have both at the same time |
1381
40095d413da9
Fix compilation on OpenBSD
Mikael Berthe <mikael@lilotux.net>
parents:
1376
diff
changeset
|
344 nc->manual = FALSE; |
1292
382ec54b584e
Muc nick coloring functionality
Michal 'vorner' Vaner <vorner@ucw.cz>
parents:
1291
diff
changeset
|
345 }// Else -> no color saved, nothing to delete |
382ec54b584e
Muc nick coloring functionality
Michal 'vorner' Vaner <vorner@ucw.cz>
parents:
1291
diff
changeset
|
346 } |
1729
e6e89b1d7831
Minor style and header updates
Mikael Berthe <mikael@lilotux.net>
parents:
1710
diff
changeset
|
347 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
|
348 g_free(mnick); |
1381
40095d413da9
Fix compilation on OpenBSD
Mikael Berthe <mikael@lilotux.net>
parents:
1376
diff
changeset
|
349 need_update = TRUE; |
1292
382ec54b584e
Muc nick coloring functionality
Michal 'vorner' Vaner <vorner@ucw.cz>
parents:
1291
diff
changeset
|
350 } else { |
2337 | 351 ccolor_t *cl = get_user_color(color); |
1489
e9c71ce96dca
Fixed the colorhandling for mucnicks and /color roster
franky@veqlargh.fs
parents:
1488
diff
changeset
|
352 if (!cl) { |
1292
382ec54b584e
Muc nick coloring functionality
Michal 'vorner' Vaner <vorner@ucw.cz>
parents:
1291
diff
changeset
|
353 scr_LogPrint(LPRINT_NORMAL, "No such color name"); |
382ec54b584e
Muc nick coloring functionality
Michal 'vorner' Vaner <vorner@ucw.cz>
parents:
1291
diff
changeset
|
354 g_free(snick); |
382ec54b584e
Muc nick coloring functionality
Michal 'vorner' Vaner <vorner@ucw.cz>
parents:
1291
diff
changeset
|
355 g_free(mnick); |
382ec54b584e
Muc nick coloring functionality
Michal 'vorner' Vaner <vorner@ucw.cz>
parents:
1291
diff
changeset
|
356 } else { |
2337 | 357 nickcolor_t *nc = g_new(nickcolor_t, 1); |
1292
382ec54b584e
Muc nick coloring functionality
Michal 'vorner' Vaner <vorner@ucw.cz>
parents:
1291
diff
changeset
|
358 ensure_string_htable(&nickcolors, NULL); |
1381
40095d413da9
Fix compilation on OpenBSD
Mikael Berthe <mikael@lilotux.net>
parents:
1376
diff
changeset
|
359 nc->manual = TRUE; |
1292
382ec54b584e
Muc nick coloring functionality
Michal 'vorner' Vaner <vorner@ucw.cz>
parents:
1291
diff
changeset
|
360 nc->color = cl; |
1729
e6e89b1d7831
Minor style and header updates
Mikael Berthe <mikael@lilotux.net>
parents:
1710
diff
changeset
|
361 // Free the struct, if any there already |
2264
44bb9a033407
Revert patch c1eb68306520
Mikael Berthe <mikael@lilotux.net>
parents:
2231
diff
changeset
|
362 g_free(g_hash_table_lookup(nickcolors, mnick)); |
1729
e6e89b1d7831
Minor style and header updates
Mikael Berthe <mikael@lilotux.net>
parents:
1710
diff
changeset
|
363 // Save the new ones |
1292
382ec54b584e
Muc nick coloring functionality
Michal 'vorner' Vaner <vorner@ucw.cz>
parents:
1291
diff
changeset
|
364 g_hash_table_replace(nickcolors, mnick, nc); |
382ec54b584e
Muc nick coloring functionality
Michal 'vorner' Vaner <vorner@ucw.cz>
parents:
1291
diff
changeset
|
365 g_hash_table_replace(nickcolors, snick, nc); |
1381
40095d413da9
Fix compilation on OpenBSD
Mikael Berthe <mikael@lilotux.net>
parents:
1376
diff
changeset
|
366 need_update = TRUE; |
1292
382ec54b584e
Muc nick coloring functionality
Michal 'vorner' Vaner <vorner@ucw.cz>
parents:
1291
diff
changeset
|
367 } |
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 if (need_update && chatmode && |
382ec54b584e
Muc nick coloring functionality
Michal 'vorner' Vaner <vorner@ucw.cz>
parents:
1291
diff
changeset
|
370 (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
|
371 scr_update_buddy_window(); |
1292
382ec54b584e
Muc nick coloring functionality
Michal 'vorner' Vaner <vorner@ucw.cz>
parents:
1291
diff
changeset
|
372 } |
382ec54b584e
Muc nick coloring functionality
Michal 'vorner' Vaner <vorner@ucw.cz>
parents:
1291
diff
changeset
|
373 |
2337 | 374 static void free_rostercolrule(rostercolor_t *col) |
1272
033576acac4c
Add configurable roster colors (Michal 'vorner' Vaner)
Mikael Berthe <mikael@lilotux.net>
parents:
1268
diff
changeset
|
375 { |
033576acac4c
Add configurable roster colors (Michal 'vorner' Vaner)
Mikael Berthe <mikael@lilotux.net>
parents:
1268
diff
changeset
|
376 g_free(col->status); |
033576acac4c
Add configurable roster colors (Michal 'vorner' Vaner)
Mikael Berthe <mikael@lilotux.net>
parents:
1268
diff
changeset
|
377 g_free(col->wildcard); |
1489
e9c71ce96dca
Fixed the colorhandling for mucnicks and /color roster
franky@veqlargh.fs
parents:
1488
diff
changeset
|
378 g_free(col->color); |
1272
033576acac4c
Add configurable roster colors (Michal 'vorner' Vaner)
Mikael Berthe <mikael@lilotux.net>
parents:
1268
diff
changeset
|
379 g_pattern_spec_free(col->compiled); |
033576acac4c
Add configurable roster colors (Michal 'vorner' Vaner)
Mikael Berthe <mikael@lilotux.net>
parents:
1268
diff
changeset
|
380 g_free(col); |
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 |
1284 | 383 // Removes all roster coloring rules |
1780
e4378fbab5d7
Major API cleanup - bump API to 4
Mikael Berthe <mikael@lilotux.net>
parents:
1761
diff
changeset
|
384 void scr_roster_clear_color(void) |
1272
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 GSList *head; |
033576acac4c
Add configurable roster colors (Michal 'vorner' Vaner)
Mikael Berthe <mikael@lilotux.net>
parents:
1268
diff
changeset
|
387 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
|
388 free_rostercolrule(head->data); |
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 g_slist_free(rostercolrules); |
033576acac4c
Add configurable roster colors (Michal 'vorner' Vaner)
Mikael Berthe <mikael@lilotux.net>
parents:
1268
diff
changeset
|
391 rostercolrules = NULL; |
2292
f181418db215
Replace global variable update_roster with scr_update_roster()
franky
parents:
2291
diff
changeset
|
392 scr_update_roster(); |
1272
033576acac4c
Add configurable roster colors (Michal 'vorner' Vaner)
Mikael Berthe <mikael@lilotux.net>
parents:
1268
diff
changeset
|
393 } |
033576acac4c
Add configurable roster colors (Michal 'vorner' Vaner)
Mikael Berthe <mikael@lilotux.net>
parents:
1268
diff
changeset
|
394 |
1284 | 395 // Adds, modifies or removes roster coloring rule |
396 // color set to "-" removes the rule, | |
397 // otherwise it is modified (if exists) or added | |
398 // | |
399 // Returns weather it was successfull (therefore the roster should be | |
400 // redrawed) or not. If it failed, for example because of invalid color | |
401 // name, it also prints the error. | |
1780
e4378fbab5d7
Major API cleanup - bump API to 4
Mikael Berthe <mikael@lilotux.net>
parents:
1761
diff
changeset
|
402 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
|
403 const char *color) |
1272
033576acac4c
Add configurable roster colors (Michal 'vorner' Vaner)
Mikael Berthe <mikael@lilotux.net>
parents:
1268
diff
changeset
|
404 { |
033576acac4c
Add configurable roster colors (Michal 'vorner' Vaner)
Mikael Berthe <mikael@lilotux.net>
parents:
1268
diff
changeset
|
405 GSList *head; |
033576acac4c
Add configurable roster colors (Michal 'vorner' Vaner)
Mikael Berthe <mikael@lilotux.net>
parents:
1268
diff
changeset
|
406 GSList *found = NULL; |
033576acac4c
Add configurable roster colors (Michal 'vorner' Vaner)
Mikael Berthe <mikael@lilotux.net>
parents:
1268
diff
changeset
|
407 for (head = rostercolrules; head; head = g_slist_next(head)) { |
2337 | 408 rostercolor_t *rc = head->data; |
1272
033576acac4c
Add configurable roster colors (Michal 'vorner' Vaner)
Mikael Berthe <mikael@lilotux.net>
parents:
1268
diff
changeset
|
409 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
|
410 found = head; |
033576acac4c
Add configurable roster colors (Michal 'vorner' Vaner)
Mikael Berthe <mikael@lilotux.net>
parents:
1268
diff
changeset
|
411 break; |
033576acac4c
Add configurable roster colors (Michal 'vorner' Vaner)
Mikael Berthe <mikael@lilotux.net>
parents:
1268
diff
changeset
|
412 } |
033576acac4c
Add configurable roster colors (Michal 'vorner' Vaner)
Mikael Berthe <mikael@lilotux.net>
parents:
1268
diff
changeset
|
413 } |
1729
e6e89b1d7831
Minor style and header updates
Mikael Berthe <mikael@lilotux.net>
parents:
1710
diff
changeset
|
414 if (!strcmp(color,"-")) { // Delete the rule |
1272
033576acac4c
Add configurable roster colors (Michal 'vorner' Vaner)
Mikael Berthe <mikael@lilotux.net>
parents:
1268
diff
changeset
|
415 if (found) { |
033576acac4c
Add configurable roster colors (Michal 'vorner' Vaner)
Mikael Berthe <mikael@lilotux.net>
parents:
1268
diff
changeset
|
416 free_rostercolrule(found->data); |
033576acac4c
Add configurable roster colors (Michal 'vorner' Vaner)
Mikael Berthe <mikael@lilotux.net>
parents:
1268
diff
changeset
|
417 rostercolrules = g_slist_delete_link(rostercolrules, found); |
2292
f181418db215
Replace global variable update_roster with scr_update_roster()
franky
parents:
2291
diff
changeset
|
418 scr_update_roster(); |
1272
033576acac4c
Add configurable roster colors (Michal 'vorner' Vaner)
Mikael Berthe <mikael@lilotux.net>
parents:
1268
diff
changeset
|
419 return TRUE; |
033576acac4c
Add configurable roster colors (Michal 'vorner' Vaner)
Mikael Berthe <mikael@lilotux.net>
parents:
1268
diff
changeset
|
420 } else { |
033576acac4c
Add configurable roster colors (Michal 'vorner' Vaner)
Mikael Berthe <mikael@lilotux.net>
parents:
1268
diff
changeset
|
421 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
|
422 return FALSE; |
033576acac4c
Add configurable roster colors (Michal 'vorner' Vaner)
Mikael Berthe <mikael@lilotux.net>
parents:
1268
diff
changeset
|
423 } |
033576acac4c
Add configurable roster colors (Michal 'vorner' Vaner)
Mikael Berthe <mikael@lilotux.net>
parents:
1268
diff
changeset
|
424 } else { |
2337 | 425 ccolor_t *cl = get_user_color(color); |
1489
e9c71ce96dca
Fixed the colorhandling for mucnicks and /color roster
franky@veqlargh.fs
parents:
1488
diff
changeset
|
426 if (!cl) { |
1272
033576acac4c
Add configurable roster colors (Michal 'vorner' Vaner)
Mikael Berthe <mikael@lilotux.net>
parents:
1268
diff
changeset
|
427 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
|
428 return FALSE; |
033576acac4c
Add configurable roster colors (Michal 'vorner' Vaner)
Mikael Berthe <mikael@lilotux.net>
parents:
1268
diff
changeset
|
429 } |
033576acac4c
Add configurable roster colors (Michal 'vorner' Vaner)
Mikael Berthe <mikael@lilotux.net>
parents:
1268
diff
changeset
|
430 if (found) { |
2337 | 431 rostercolor_t *rc = found->data; |
2264
44bb9a033407
Revert patch c1eb68306520
Mikael Berthe <mikael@lilotux.net>
parents:
2231
diff
changeset
|
432 g_free(rc->color); |
1272
033576acac4c
Add configurable roster colors (Michal 'vorner' Vaner)
Mikael Berthe <mikael@lilotux.net>
parents:
1268
diff
changeset
|
433 rc->color = cl; |
033576acac4c
Add configurable roster colors (Michal 'vorner' Vaner)
Mikael Berthe <mikael@lilotux.net>
parents:
1268
diff
changeset
|
434 } else { |
2337 | 435 rostercolor_t *rc = g_new(rostercolor_t, 1); |
1272
033576acac4c
Add configurable roster colors (Michal 'vorner' Vaner)
Mikael Berthe <mikael@lilotux.net>
parents:
1268
diff
changeset
|
436 rc->status = g_strdup(status); |
033576acac4c
Add configurable roster colors (Michal 'vorner' Vaner)
Mikael Berthe <mikael@lilotux.net>
parents:
1268
diff
changeset
|
437 rc->wildcard = g_strdup(wildcard); |
033576acac4c
Add configurable roster colors (Michal 'vorner' Vaner)
Mikael Berthe <mikael@lilotux.net>
parents:
1268
diff
changeset
|
438 rc->compiled = g_pattern_spec_new(wildcard); |
033576acac4c
Add configurable roster colors (Michal 'vorner' Vaner)
Mikael Berthe <mikael@lilotux.net>
parents:
1268
diff
changeset
|
439 rc->color = cl; |
033576acac4c
Add configurable roster colors (Michal 'vorner' Vaner)
Mikael Berthe <mikael@lilotux.net>
parents:
1268
diff
changeset
|
440 rostercolrules = g_slist_prepend(rostercolrules, rc); |
033576acac4c
Add configurable roster colors (Michal 'vorner' Vaner)
Mikael Berthe <mikael@lilotux.net>
parents:
1268
diff
changeset
|
441 } |
2292
f181418db215
Replace global variable update_roster with scr_update_roster()
franky
parents:
2291
diff
changeset
|
442 scr_update_roster(); |
1272
033576acac4c
Add configurable roster colors (Michal 'vorner' Vaner)
Mikael Berthe <mikael@lilotux.net>
parents:
1268
diff
changeset
|
443 return TRUE; |
033576acac4c
Add configurable roster colors (Michal 'vorner' Vaner)
Mikael Berthe <mikael@lilotux.net>
parents:
1268
diff
changeset
|
444 } |
033576acac4c
Add configurable roster colors (Michal 'vorner' Vaner)
Mikael Berthe <mikael@lilotux.net>
parents:
1268
diff
changeset
|
445 } |
033576acac4c
Add configurable roster colors (Michal 'vorner' Vaner)
Mikael Berthe <mikael@lilotux.net>
parents:
1268
diff
changeset
|
446 |
1780
e4378fbab5d7
Major API cleanup - bump API to 4
Mikael Berthe <mikael@lilotux.net>
parents:
1761
diff
changeset
|
447 static void parse_colors(void) |
24 | 448 { |
739
0d5fb1d9077c
Allow "bright" text colors
Mikael Berthe <mikael@lilotux.net>
parents:
735
diff
changeset
|
449 const char *colors[] = { |
24 | 450 "", "", |
267 | 451 "general", |
785
7e0562e3bc83
Replace color_highlight with color_msgout
Mikael Berthe <mikael@lilotux.net>
parents:
779
diff
changeset
|
452 "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
|
453 "msghl", |
711 | 454 "status", |
2028
7b5bd6ad83b4
Add 'color_log' (text color in the log window)
Mikael Berthe <mikael@lilotux.net>
parents:
2015
diff
changeset
|
455 "log", |
712 | 456 "roster", |
457 "rostersel", | |
723
23068490d063
Add text color when the selected buddy has an unread message
Mikael Berthe <mikael@lilotux.net>
parents:
721
diff
changeset
|
458 "rosterselmsg", |
712 | 459 "rosternewmsg", |
1268
dbc907b2d92f
Add configurable colors for info and incoming messages (Michal 'vorner' Vaner)
Mikael Berthe <mikael@lilotux.net>
parents:
1254
diff
changeset
|
460 "info", |
dbc907b2d92f
Add configurable colors for info and incoming messages (Michal 'vorner' Vaner)
Mikael Berthe <mikael@lilotux.net>
parents:
1254
diff
changeset
|
461 "msgin", |
1960 | 462 "readmark", |
2090
16b04d64ec88
Add option to highlight timestamp added by server.
Hermitifier
parents:
2074
diff
changeset
|
463 "timestamp", |
24 | 464 NULL |
465 }; | |
466 | |
281
f562b9af2de7
Add "const" specifier in prototypes
Mikael Berthe <mikael@lilotux.net>
parents:
279
diff
changeset
|
467 const char *color; |
f562b9af2de7
Add "const" specifier in prototypes
Mikael Berthe <mikael@lilotux.net>
parents:
279
diff
changeset
|
468 const char *background = settings_opt_get("color_background"); |
712 | 469 const char *backselected = settings_opt_get("color_bgrostersel"); |
470 const char *backstatus = settings_opt_get("color_bgstatus"); | |
739
0d5fb1d9077c
Allow "bright" text colors
Mikael Berthe <mikael@lilotux.net>
parents:
735
diff
changeset
|
471 char *tmp; |
0d5fb1d9077c
Allow "bright" text colors
Mikael Berthe <mikael@lilotux.net>
parents:
735
diff
changeset
|
472 int i; |
0d5fb1d9077c
Allow "bright" text colors
Mikael Berthe <mikael@lilotux.net>
parents:
735
diff
changeset
|
473 |
0d5fb1d9077c
Allow "bright" text colors
Mikael Berthe <mikael@lilotux.net>
parents:
735
diff
changeset
|
474 // Initialize color attributes |
0d5fb1d9077c
Allow "bright" text colors
Mikael Berthe <mikael@lilotux.net>
parents:
735
diff
changeset
|
475 memset(COLOR_ATTRIB, 0, sizeof(COLOR_ATTRIB)); |
24 | 476 |
267 | 477 // Default values |
711 | 478 if (!background) background = "black"; |
267 | 479 if (!backselected) backselected = "cyan"; |
711 | 480 if (!backstatus) backstatus = "blue"; |
267 | 481 |
739
0d5fb1d9077c
Allow "bright" text colors
Mikael Berthe <mikael@lilotux.net>
parents:
735
diff
changeset
|
482 for (i=0; colors[i]; i++) { |
0d5fb1d9077c
Allow "bright" text colors
Mikael Berthe <mikael@lilotux.net>
parents:
735
diff
changeset
|
483 tmp = g_strdup_printf("color_%s", colors[i]); |
279
f5dd437c057b
Rewrite the settings system
Mikael Berthe <mikael@lilotux.net>
parents:
276
diff
changeset
|
484 color = settings_opt_get(tmp); |
739
0d5fb1d9077c
Allow "bright" text colors
Mikael Berthe <mikael@lilotux.net>
parents:
735
diff
changeset
|
485 g_free(tmp); |
0d5fb1d9077c
Allow "bright" text colors
Mikael Berthe <mikael@lilotux.net>
parents:
735
diff
changeset
|
486 |
0d5fb1d9077c
Allow "bright" text colors
Mikael Berthe <mikael@lilotux.net>
parents:
735
diff
changeset
|
487 if (color) { |
0d5fb1d9077c
Allow "bright" text colors
Mikael Berthe <mikael@lilotux.net>
parents:
735
diff
changeset
|
488 if (!strncmp(color, "bright", 6)) { |
0d5fb1d9077c
Allow "bright" text colors
Mikael Berthe <mikael@lilotux.net>
parents:
735
diff
changeset
|
489 COLOR_ATTRIB[i+1] = A_BOLD; |
0d5fb1d9077c
Allow "bright" text colors
Mikael Berthe <mikael@lilotux.net>
parents:
735
diff
changeset
|
490 color += 6; |
0d5fb1d9077c
Allow "bright" text colors
Mikael Berthe <mikael@lilotux.net>
parents:
735
diff
changeset
|
491 } |
0d5fb1d9077c
Allow "bright" text colors
Mikael Berthe <mikael@lilotux.net>
parents:
735
diff
changeset
|
492 } |
24 | 493 |
494 switch (i + 1) { | |
739
0d5fb1d9077c
Allow "bright" text colors
Mikael Berthe <mikael@lilotux.net>
parents:
735
diff
changeset
|
495 case 1: |
0d5fb1d9077c
Allow "bright" text colors
Mikael Berthe <mikael@lilotux.net>
parents:
735
diff
changeset
|
496 init_pair(1, COLOR_BLACK, COLOR_WHITE); |
0d5fb1d9077c
Allow "bright" text colors
Mikael Berthe <mikael@lilotux.net>
parents:
735
diff
changeset
|
497 break; |
0d5fb1d9077c
Allow "bright" text colors
Mikael Berthe <mikael@lilotux.net>
parents:
735
diff
changeset
|
498 case 2: |
0d5fb1d9077c
Allow "bright" text colors
Mikael Berthe <mikael@lilotux.net>
parents:
735
diff
changeset
|
499 init_pair(2, COLOR_WHITE, COLOR_BLACK); |
0d5fb1d9077c
Allow "bright" text colors
Mikael Berthe <mikael@lilotux.net>
parents:
735
diff
changeset
|
500 break; |
0d5fb1d9077c
Allow "bright" text colors
Mikael Berthe <mikael@lilotux.net>
parents:
735
diff
changeset
|
501 case COLOR_GENERAL: |
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_WHITE), |
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; |
785
7e0562e3bc83
Replace color_highlight with color_msgout
Mikael Berthe <mikael@lilotux.net>
parents:
779
diff
changeset
|
505 case COLOR_MSGOUT: |
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_CYAN), |
e4378fbab5d7
Major API cleanup - bump API to 4
Mikael Berthe <mikael@lilotux.net>
parents:
1761
diff
changeset
|
507 find_color(background)); |
739
0d5fb1d9077c
Allow "bright" text colors
Mikael Berthe <mikael@lilotux.net>
parents:
735
diff
changeset
|
508 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
|
509 case COLOR_MSGHL: |
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_YELLOW), |
e4378fbab5d7
Major API cleanup - bump API to 4
Mikael Berthe <mikael@lilotux.net>
parents:
1761
diff
changeset
|
511 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
|
512 break; |
739
0d5fb1d9077c
Allow "bright" text colors
Mikael Berthe <mikael@lilotux.net>
parents:
735
diff
changeset
|
513 case COLOR_STATUS: |
1780
e4378fbab5d7
Major API cleanup - bump API to 4
Mikael Berthe <mikael@lilotux.net>
parents:
1761
diff
changeset
|
514 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
|
515 find_color(backstatus)); |
739
0d5fb1d9077c
Allow "bright" text colors
Mikael Berthe <mikael@lilotux.net>
parents:
735
diff
changeset
|
516 break; |
2028
7b5bd6ad83b4
Add 'color_log' (text color in the log window)
Mikael Berthe <mikael@lilotux.net>
parents:
2015
diff
changeset
|
517 case COLOR_LOG: |
7b5bd6ad83b4
Add 'color_log' (text color in the log window)
Mikael Berthe <mikael@lilotux.net>
parents:
2015
diff
changeset
|
518 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
|
519 find_color(background)); |
7b5bd6ad83b4
Add 'color_log' (text color in the log window)
Mikael Berthe <mikael@lilotux.net>
parents:
2015
diff
changeset
|
520 break; |
739
0d5fb1d9077c
Allow "bright" text colors
Mikael Berthe <mikael@lilotux.net>
parents:
735
diff
changeset
|
521 case COLOR_ROSTER: |
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_GREEN), |
e4378fbab5d7
Major API cleanup - bump API to 4
Mikael Berthe <mikael@lilotux.net>
parents:
1761
diff
changeset
|
523 find_color(background)); |
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_ROSTERSEL: |
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_BLUE), |
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_ROSTERSELNMSG: |
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(backselected)); |
739
0d5fb1d9077c
Allow "bright" text colors
Mikael Berthe <mikael@lilotux.net>
parents:
735
diff
changeset
|
532 break; |
0d5fb1d9077c
Allow "bright" text colors
Mikael Berthe <mikael@lilotux.net>
parents:
735
diff
changeset
|
533 case COLOR_ROSTERNMSG: |
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_RED), |
e4378fbab5d7
Major API cleanup - bump API to 4
Mikael Berthe <mikael@lilotux.net>
parents:
1761
diff
changeset
|
535 find_color(background)); |
739
0d5fb1d9077c
Allow "bright" text colors
Mikael Berthe <mikael@lilotux.net>
parents:
735
diff
changeset
|
536 break; |
1268
dbc907b2d92f
Add configurable colors for info and incoming messages (Michal 'vorner' Vaner)
Mikael Berthe <mikael@lilotux.net>
parents:
1254
diff
changeset
|
537 case COLOR_INFO: |
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; |
dbc907b2d92f
Add configurable colors for info and incoming messages (Michal 'vorner' Vaner)
Mikael Berthe <mikael@lilotux.net>
parents:
1254
diff
changeset
|
541 case COLOR_MSGIN: |
1780
e4378fbab5d7
Major API cleanup - bump API to 4
Mikael Berthe <mikael@lilotux.net>
parents:
1761
diff
changeset
|
542 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
|
543 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
|
544 break; |
1960 | 545 case COLOR_READMARK: |
546 init_pair(i+1, ((color) ? find_color(color) : COLOR_RED), | |
547 find_color(background)); | |
548 break; | |
2090
16b04d64ec88
Add option to highlight timestamp added by server.
Hermitifier
parents:
2074
diff
changeset
|
549 case COLOR_TIMESTAMP: |
16b04d64ec88
Add option to highlight timestamp added by server.
Hermitifier
parents:
2074
diff
changeset
|
550 init_pair(i+1, ((color) ? find_color(color) : COLOR_WHITE), |
16b04d64ec88
Add option to highlight timestamp added by server.
Hermitifier
parents:
2074
diff
changeset
|
551 find_color(background)); |
16b04d64ec88
Add option to highlight timestamp added by server.
Hermitifier
parents:
2074
diff
changeset
|
552 break; |
24 | 553 } |
554 } | |
1489
e9c71ce96dca
Fixed the colorhandling for mucnicks and /color roster
franky@veqlargh.fs
parents:
1488
diff
changeset
|
555 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
|
556 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
|
557 |
1298
af035a304bec
colorable muc nick fix
Michal 'vorner' Vaner <vorner@ucw.cz>
parents:
1296
diff
changeset
|
558 if (!nickcols) { |
1314
248e3f69dd9e
Fix a bug in the nick_colors variable parsing
Mikael Berthe <mikael@lilotux.net>
parents:
1311
diff
changeset
|
559 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
|
560 if (ncolors) { |
1314
248e3f69dd9e
Fix a bug in the nick_colors variable parsing
Mikael Berthe <mikael@lilotux.net>
parents:
1311
diff
changeset
|
561 char *ncolor_start, *ncolor_end; |
248e3f69dd9e
Fix a bug in the nick_colors variable parsing
Mikael Berthe <mikael@lilotux.net>
parents:
1311
diff
changeset
|
562 ncolor_start = ncolor_end = ncolors; |
248e3f69dd9e
Fix a bug in the nick_colors variable parsing
Mikael Berthe <mikael@lilotux.net>
parents:
1311
diff
changeset
|
563 |
248e3f69dd9e
Fix a bug in the nick_colors variable parsing
Mikael Berthe <mikael@lilotux.net>
parents:
1311
diff
changeset
|
564 while (*ncolor_end) |
248e3f69dd9e
Fix a bug in the nick_colors variable parsing
Mikael Berthe <mikael@lilotux.net>
parents:
1311
diff
changeset
|
565 ncolor_end++; |
248e3f69dd9e
Fix a bug in the nick_colors variable parsing
Mikael Berthe <mikael@lilotux.net>
parents:
1311
diff
changeset
|
566 |
248e3f69dd9e
Fix a bug in the nick_colors variable parsing
Mikael Berthe <mikael@lilotux.net>
parents:
1311
diff
changeset
|
567 while (ncolors < ncolor_end && *ncolors) { |
1298
af035a304bec
colorable muc nick fix
Michal 'vorner' Vaner <vorner@ucw.cz>
parents:
1296
diff
changeset
|
568 if ((*ncolors == ' ') || (*ncolors == '\t')) { |
1314
248e3f69dd9e
Fix a bug in the nick_colors variable parsing
Mikael Berthe <mikael@lilotux.net>
parents:
1311
diff
changeset
|
569 ncolors++; |
1292
382ec54b584e
Muc nick coloring functionality
Michal 'vorner' Vaner <vorner@ucw.cz>
parents:
1291
diff
changeset
|
570 } else { |
1298
af035a304bec
colorable muc nick fix
Michal 'vorner' Vaner <vorner@ucw.cz>
parents:
1296
diff
changeset
|
571 char *end = ncolors; |
2337 | 572 ccolor_t *cl; |
1298
af035a304bec
colorable muc nick fix
Michal 'vorner' Vaner <vorner@ucw.cz>
parents:
1296
diff
changeset
|
573 while (*end && (*end != ' ') && (*end != '\t')) |
af035a304bec
colorable muc nick fix
Michal 'vorner' Vaner <vorner@ucw.cz>
parents:
1296
diff
changeset
|
574 end++; |
af035a304bec
colorable muc nick fix
Michal 'vorner' Vaner <vorner@ucw.cz>
parents:
1296
diff
changeset
|
575 *end = '\0'; |
1314
248e3f69dd9e
Fix a bug in the nick_colors variable parsing
Mikael Berthe <mikael@lilotux.net>
parents:
1311
diff
changeset
|
576 cl = get_user_color(ncolors); |
1489
e9c71ce96dca
Fixed the colorhandling for mucnicks and /color roster
franky@veqlargh.fs
parents:
1488
diff
changeset
|
577 if (!cl) { |
1298
af035a304bec
colorable muc nick fix
Michal 'vorner' Vaner <vorner@ucw.cz>
parents:
1296
diff
changeset
|
578 scr_LogPrint(LPRINT_NORMAL, "Unknown color %s", ncolors); |
af035a304bec
colorable muc nick fix
Michal 'vorner' Vaner <vorner@ucw.cz>
parents:
1296
diff
changeset
|
579 } else { |
af035a304bec
colorable muc nick fix
Michal 'vorner' Vaner <vorner@ucw.cz>
parents:
1296
diff
changeset
|
580 nickcols = g_realloc(nickcols, (++nickcolcount) * sizeof *nickcols); |
af035a304bec
colorable muc nick fix
Michal 'vorner' Vaner <vorner@ucw.cz>
parents:
1296
diff
changeset
|
581 nickcols[nickcolcount-1] = cl; |
af035a304bec
colorable muc nick fix
Michal 'vorner' Vaner <vorner@ucw.cz>
parents:
1296
diff
changeset
|
582 } |
1314
248e3f69dd9e
Fix a bug in the nick_colors variable parsing
Mikael Berthe <mikael@lilotux.net>
parents:
1311
diff
changeset
|
583 ncolors = end+1; |
1292
382ec54b584e
Muc nick coloring functionality
Michal 'vorner' Vaner <vorner@ucw.cz>
parents:
1291
diff
changeset
|
584 } |
382ec54b584e
Muc nick coloring functionality
Michal 'vorner' Vaner <vorner@ucw.cz>
parents:
1291
diff
changeset
|
585 } |
1298
af035a304bec
colorable muc nick fix
Michal 'vorner' Vaner <vorner@ucw.cz>
parents:
1296
diff
changeset
|
586 g_free(ncolor_start); |
1292
382ec54b584e
Muc nick coloring functionality
Michal 'vorner' Vaner <vorner@ucw.cz>
parents:
1291
diff
changeset
|
587 } |
1729
e6e89b1d7831
Minor style and header updates
Mikael Berthe <mikael@lilotux.net>
parents:
1710
diff
changeset
|
588 if (!nickcols) { // Fallback to have something |
1298
af035a304bec
colorable muc nick fix
Michal 'vorner' Vaner <vorner@ucw.cz>
parents:
1296
diff
changeset
|
589 nickcolcount = 1; |
2337 | 590 nickcols = g_new(ccolor_t*, 1); |
591 *nickcols = g_new(ccolor_t, 1); | |
1489
e9c71ce96dca
Fixed the colorhandling for mucnicks and /color roster
franky@veqlargh.fs
parents:
1488
diff
changeset
|
592 (*nickcols)->color_pair = COLOR_GENERAL; |
e9c71ce96dca
Fixed the colorhandling for mucnicks and /color roster
franky@veqlargh.fs
parents:
1488
diff
changeset
|
593 (*nickcols)->color_attrib = A_NORMAL; |
1298
af035a304bec
colorable muc nick fix
Michal 'vorner' Vaner <vorner@ucw.cz>
parents:
1296
diff
changeset
|
594 } |
1292
382ec54b584e
Muc nick coloring functionality
Michal 'vorner' Vaner <vorner@ucw.cz>
parents:
1291
diff
changeset
|
595 } |
1942
3e39a336a992
Use guards for colors (Myhailo Danylenko)
Mikael Berthe <mikael@lilotux.net>
parents:
1935
diff
changeset
|
596 |
3e39a336a992
Use guards for colors (Myhailo Danylenko)
Mikael Berthe <mikael@lilotux.net>
parents:
1935
diff
changeset
|
597 colors_stalled = FALSE; |
24 | 598 } |
599 | |
765
72626e9d60bd
Create init_keycodes(), add 2 screen escape sequences
Mikael Berthe <mikael@lilotux.net>
parents:
764
diff
changeset
|
600 static void init_keycodes(void) |
373
af2f8ddf6a1b
Move (reorganize) functions
Mikael Berthe <mikael@lilotux.net>
parents:
370
diff
changeset
|
601 { |
761
4532a9fe0e8c
Handle some keyboard escape sequences
Mikael Berthe <mikael@lilotux.net>
parents:
760
diff
changeset
|
602 add_keyseq("O5A", MKEY_EQUIV, 521); // Ctrl-Up |
4532a9fe0e8c
Handle some keyboard escape sequences
Mikael Berthe <mikael@lilotux.net>
parents:
760
diff
changeset
|
603 add_keyseq("O5B", MKEY_EQUIV, 514); // Ctrl-Down |
4532a9fe0e8c
Handle some keyboard escape sequences
Mikael Berthe <mikael@lilotux.net>
parents:
760
diff
changeset
|
604 add_keyseq("O5C", MKEY_EQUIV, 518); // Ctrl-Right |
4532a9fe0e8c
Handle some keyboard escape sequences
Mikael Berthe <mikael@lilotux.net>
parents:
760
diff
changeset
|
605 add_keyseq("O5D", MKEY_EQUIV, 516); // Ctrl-Left |
763 | 606 add_keyseq("O6A", MKEY_EQUIV, 520); // Shift-Up |
607 add_keyseq("O6B", MKEY_EQUIV, 513); // Shift-Down | |
608 add_keyseq("O6C", MKEY_EQUIV, 402); // Shift-Right | |
609 add_keyseq("O6D", MKEY_EQUIV, 393); // Shift-Left | |
610 add_keyseq("O2A", MKEY_EQUIV, 520); // Shift-Up | |
611 add_keyseq("O2B", MKEY_EQUIV, 513); // Shift-Down | |
612 add_keyseq("O2C", MKEY_EQUIV, 402); // Shift-Right | |
613 add_keyseq("O2D", MKEY_EQUIV, 393); // Shift-Left | |
614 add_keyseq("[5^", MKEY_CTRL_PGUP, 0); // Ctrl-PageUp | |
615 add_keyseq("[6^", MKEY_CTRL_PGDOWN, 0); // Ctrl-PageDown | |
616 add_keyseq("[5@", MKEY_CTRL_SHIFT_PGUP, 0); // Ctrl-Shift-PageUp | |
617 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
|
618 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
|
619 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
|
620 add_keyseq("[8^", MKEY_CTRL_END, 0); // Ctrl-End |
32d5298f9f8d
Add a few keycode sequences
Mikael Berthe <mikael@lilotux.net>
parents:
790
diff
changeset
|
621 add_keyseq("[7^", MKEY_CTRL_HOME, 0); // Ctrl-Home |
32d5298f9f8d
Add a few keycode sequences
Mikael Berthe <mikael@lilotux.net>
parents:
790
diff
changeset
|
622 add_keyseq("[2^", MKEY_CTRL_INS, 0); // Ctrl-Insert |
32d5298f9f8d
Add a few keycode sequences
Mikael Berthe <mikael@lilotux.net>
parents:
790
diff
changeset
|
623 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
|
624 |
4532a9fe0e8c
Handle some keyboard escape sequences
Mikael Berthe <mikael@lilotux.net>
parents:
760
diff
changeset
|
625 // Xterm |
4532a9fe0e8c
Handle some keyboard escape sequences
Mikael Berthe <mikael@lilotux.net>
parents:
760
diff
changeset
|
626 add_keyseq("[1;5A", MKEY_EQUIV, 521); // Ctrl-Up |
4532a9fe0e8c
Handle some keyboard escape sequences
Mikael Berthe <mikael@lilotux.net>
parents:
760
diff
changeset
|
627 add_keyseq("[1;5B", MKEY_EQUIV, 514); // Ctrl-Down |
4532a9fe0e8c
Handle some keyboard escape sequences
Mikael Berthe <mikael@lilotux.net>
parents:
760
diff
changeset
|
628 add_keyseq("[1;5C", MKEY_EQUIV, 518); // Ctrl-Right |
4532a9fe0e8c
Handle some keyboard escape sequences
Mikael Berthe <mikael@lilotux.net>
parents:
760
diff
changeset
|
629 add_keyseq("[1;5D", MKEY_EQUIV, 516); // Ctrl-Left |
4532a9fe0e8c
Handle some keyboard escape sequences
Mikael Berthe <mikael@lilotux.net>
parents:
760
diff
changeset
|
630 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
|
631 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
|
632 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
|
633 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
|
634 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
|
635 add_keyseq("[1;6F", MKEY_CTRL_SHIFT_END, 0); // Ctrl-Shift-End |
763 | 636 add_keyseq("[1;2A", MKEY_EQUIV, 521); // Shift-Up |
637 add_keyseq("[1;2B", MKEY_EQUIV, 514); // Shift-Down | |
638 add_keyseq("[5;5~", MKEY_CTRL_PGUP, 0); // Ctrl-PageUp | |
639 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
|
640 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
|
641 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
|
642 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
|
643 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
|
644 |
768
0f6d25a02450
Add PuTTY escape keys for Ctrl-arrows
Mikael Berthe <mikael@lilotux.net>
parents:
766
diff
changeset
|
645 // PuTTY |
0f6d25a02450
Add PuTTY escape keys for Ctrl-arrows
Mikael Berthe <mikael@lilotux.net>
parents:
766
diff
changeset
|
646 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
|
647 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
|
648 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
|
649 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
|
650 |
762
96d46e00524a
Add some key escape sequences for screen
Mikael Berthe <mikael@lilotux.net>
parents:
761
diff
changeset
|
651 // screen |
96d46e00524a
Add some key escape sequences for screen
Mikael Berthe <mikael@lilotux.net>
parents:
761
diff
changeset
|
652 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
|
653 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
|
654 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
|
655 add_keyseq("Od", MKEY_EQUIV, 516); // Ctrl-Left |
763 | 656 add_keyseq("[a", MKEY_EQUIV, 520); // Shift-Up |
657 add_keyseq("[b", MKEY_EQUIV, 513); // Shift-Down | |
658 add_keyseq("[c", MKEY_EQUIV, 402); // Shift-Right | |
659 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
|
660 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
|
661 add_keyseq("[6$", MKEY_SHIFT_PGDOWN, 0); // Shift-PageDown |
1170 | 662 |
663 // VT100 | |
664 add_keyseq("[H", MKEY_EQUIV, KEY_HOME); // Home | |
665 add_keyseq("[F", MKEY_EQUIV, KEY_END); // End | |
666 | |
667 // Konsole Linux | |
668 add_keyseq("[1~", MKEY_EQUIV, KEY_HOME); // Home | |
669 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
|
670 } |
72626e9d60bd
Create init_keycodes(), add 2 screen escape sequences
Mikael Berthe <mikael@lilotux.net>
parents:
764
diff
changeset
|
671 |
1176
547a8ca7c1a8
Move init_bindings() to screen.c, with a few updates
Mikael Berthe <mikael@lilotux.net>
parents:
1173
diff
changeset
|
672 // scr_init_bindings() |
547a8ca7c1a8
Move init_bindings() to screen.c, with a few updates
Mikael Berthe <mikael@lilotux.net>
parents:
1173
diff
changeset
|
673 // Create default key bindings |
547a8ca7c1a8
Move init_bindings() to screen.c, with a few updates
Mikael Berthe <mikael@lilotux.net>
parents:
1173
diff
changeset
|
674 // 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
|
675 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
|
676 { |
547a8ca7c1a8
Move init_bindings() to screen.c, with a few updates
Mikael Berthe <mikael@lilotux.net>
parents:
1173
diff
changeset
|
677 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
|
678 |
547a8ca7c1a8
Move init_bindings() to screen.c, with a few updates
Mikael Berthe <mikael@lilotux.net>
parents:
1173
diff
changeset
|
679 // 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
|
680 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
|
681 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
|
682 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
|
683 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
|
684 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
|
685 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
|
686 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
|
687 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
|
688 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
|
689 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
|
690 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
|
691 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
|
692 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
|
693 "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
|
694 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
|
695 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
|
696 "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
|
697 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
|
698 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
|
699 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
|
700 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
|
701 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
|
702 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
|
703 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
|
704 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
|
705 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
|
706 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
|
707 // 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
|
708 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
|
709 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
|
710 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
|
711 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
|
712 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
|
713 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
|
714 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
|
715 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
|
716 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
|
717 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
|
718 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
|
719 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
|
720 // Ctrl-Left (2 codes): |
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, "515", "iline bword"); |
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, "516", "iline bword"); |
547a8ca7c1a8
Move init_bindings() to screen.c, with a few updates
Mikael Berthe <mikael@lilotux.net>
parents:
1173
diff
changeset
|
723 // Ctrl-Right (2 codes): |
547a8ca7c1a8
Move init_bindings() to screen.c, with a few updates
Mikael Berthe <mikael@lilotux.net>
parents:
1173
diff
changeset
|
724 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
|
725 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
|
726 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
|
727 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
|
728 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
|
729 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
|
730 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
|
731 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
|
732 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
|
733 |
1208
0dbe51d1e62e
Add default binding for F1 (265) to /help
Mikael Berthe <mikael@lilotux.net>
parents:
1205
diff
changeset
|
734 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
|
735 |
1176
547a8ca7c1a8
Move init_bindings() to screen.c, with a few updates
Mikael Berthe <mikael@lilotux.net>
parents:
1173
diff
changeset
|
736 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
|
737 } |
547a8ca7c1a8
Move init_bindings() to screen.c, with a few updates
Mikael Berthe <mikael@lilotux.net>
parents:
1173
diff
changeset
|
738 |
1229
e9ea1497ac9d
Fix a key binding issue on FreeBSD
Mikael Berthe <mikael@lilotux.net>
parents:
1228
diff
changeset
|
739 // is_speckey(key) |
e9ea1497ac9d
Fix a key binding issue on FreeBSD
Mikael Berthe <mikael@lilotux.net>
parents:
1228
diff
changeset
|
740 // 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
|
741 // 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
|
742 // isprint(KEY_PPAGE) returns TRUE... |
e9ea1497ac9d
Fix a key binding issue on FreeBSD
Mikael Berthe <mikael@lilotux.net>
parents:
1228
diff
changeset
|
743 static int is_speckey(int key) |
e9ea1497ac9d
Fix a key binding issue on FreeBSD
Mikael Berthe <mikael@lilotux.net>
parents:
1228
diff
changeset
|
744 { |
e9ea1497ac9d
Fix a key binding issue on FreeBSD
Mikael Berthe <mikael@lilotux.net>
parents:
1228
diff
changeset
|
745 switch (key) { |
e9ea1497ac9d
Fix a key binding issue on FreeBSD
Mikael Berthe <mikael@lilotux.net>
parents:
1228
diff
changeset
|
746 case 127: |
e9ea1497ac9d
Fix a key binding issue on FreeBSD
Mikael Berthe <mikael@lilotux.net>
parents:
1228
diff
changeset
|
747 case 393: |
e9ea1497ac9d
Fix a key binding issue on FreeBSD
Mikael Berthe <mikael@lilotux.net>
parents:
1228
diff
changeset
|
748 case 402: |
e9ea1497ac9d
Fix a key binding issue on FreeBSD
Mikael Berthe <mikael@lilotux.net>
parents:
1228
diff
changeset
|
749 case KEY_BACKSPACE: |
e9ea1497ac9d
Fix a key binding issue on FreeBSD
Mikael Berthe <mikael@lilotux.net>
parents:
1228
diff
changeset
|
750 case KEY_DC: |
e9ea1497ac9d
Fix a key binding issue on FreeBSD
Mikael Berthe <mikael@lilotux.net>
parents:
1228
diff
changeset
|
751 case KEY_LEFT: |
e9ea1497ac9d
Fix a key binding issue on FreeBSD
Mikael Berthe <mikael@lilotux.net>
parents:
1228
diff
changeset
|
752 case KEY_RIGHT: |
e9ea1497ac9d
Fix a key binding issue on FreeBSD
Mikael Berthe <mikael@lilotux.net>
parents:
1228
diff
changeset
|
753 case KEY_UP: |
e9ea1497ac9d
Fix a key binding issue on FreeBSD
Mikael Berthe <mikael@lilotux.net>
parents:
1228
diff
changeset
|
754 case KEY_DOWN: |
e9ea1497ac9d
Fix a key binding issue on FreeBSD
Mikael Berthe <mikael@lilotux.net>
parents:
1228
diff
changeset
|
755 case KEY_PPAGE: |
e9ea1497ac9d
Fix a key binding issue on FreeBSD
Mikael Berthe <mikael@lilotux.net>
parents:
1228
diff
changeset
|
756 case KEY_NPAGE: |
e9ea1497ac9d
Fix a key binding issue on FreeBSD
Mikael Berthe <mikael@lilotux.net>
parents:
1228
diff
changeset
|
757 case KEY_HOME: |
e9ea1497ac9d
Fix a key binding issue on FreeBSD
Mikael Berthe <mikael@lilotux.net>
parents:
1228
diff
changeset
|
758 case KEY_END: |
e9ea1497ac9d
Fix a key binding issue on FreeBSD
Mikael Berthe <mikael@lilotux.net>
parents:
1228
diff
changeset
|
759 case KEY_EOL: |
e9ea1497ac9d
Fix a key binding issue on FreeBSD
Mikael Berthe <mikael@lilotux.net>
parents:
1228
diff
changeset
|
760 return TRUE; |
e9ea1497ac9d
Fix a key binding issue on FreeBSD
Mikael Berthe <mikael@lilotux.net>
parents:
1228
diff
changeset
|
761 } |
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 // Fn keys |
e9ea1497ac9d
Fix a key binding issue on FreeBSD
Mikael Berthe <mikael@lilotux.net>
parents:
1228
diff
changeset
|
764 if (key >= 265 && key < 265+12) |
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 // Special key combinations |
e9ea1497ac9d
Fix a key binding issue on FreeBSD
Mikael Berthe <mikael@lilotux.net>
parents:
1228
diff
changeset
|
768 if (key >= 513 && key <= 521) |
e9ea1497ac9d
Fix a key binding issue on FreeBSD
Mikael Berthe <mikael@lilotux.net>
parents:
1228
diff
changeset
|
769 return TRUE; |
e9ea1497ac9d
Fix a key binding issue on FreeBSD
Mikael Berthe <mikael@lilotux.net>
parents:
1228
diff
changeset
|
770 |
e9ea1497ac9d
Fix a key binding issue on FreeBSD
Mikael Berthe <mikael@lilotux.net>
parents:
1228
diff
changeset
|
771 return FALSE; |
e9ea1497ac9d
Fix a key binding issue on FreeBSD
Mikael Berthe <mikael@lilotux.net>
parents:
1228
diff
changeset
|
772 } |
e9ea1497ac9d
Fix a key binding issue on FreeBSD
Mikael Berthe <mikael@lilotux.net>
parents:
1228
diff
changeset
|
773 |
1780
e4378fbab5d7
Major API cleanup - bump API to 4
Mikael Berthe <mikael@lilotux.net>
parents:
1761
diff
changeset
|
774 void scr_init_locale_charset(void) |
779
057ffe7c43dc
Initialize locale charset earlier
Mikael Berthe <mikael@lilotux.net>
parents:
773
diff
changeset
|
775 { |
1651
d0a0d96ed5d5
Set all locale variables
Myhailo Danylenko <isbear@ukrpost.net>
parents:
1602
diff
changeset
|
776 setlocale(LC_ALL, ""); |
1382
1447c5296977
Fix locale charset detection on some BSD systems
Mikael Berthe <mikael@lilotux.net>
parents:
1381
diff
changeset
|
777 #ifdef HAVE_LOCALCHARSET_H |
1447c5296977
Fix locale charset detection on some BSD systems
Mikael Berthe <mikael@lilotux.net>
parents:
1381
diff
changeset
|
778 LocaleCharSet = locale_charset(); |
1447c5296977
Fix locale charset detection on some BSD systems
Mikael Berthe <mikael@lilotux.net>
parents:
1381
diff
changeset
|
779 #else |
779
057ffe7c43dc
Initialize locale charset earlier
Mikael Berthe <mikael@lilotux.net>
parents:
773
diff
changeset
|
780 LocaleCharSet = nl_langinfo(CODESET); |
1382
1447c5296977
Fix locale charset detection on some BSD systems
Mikael Berthe <mikael@lilotux.net>
parents:
1381
diff
changeset
|
781 #endif |
779
057ffe7c43dc
Initialize locale charset earlier
Mikael Berthe <mikael@lilotux.net>
parents:
773
diff
changeset
|
782 utf8_mode = (strcmp(LocaleCharSet, "UTF-8") == 0); |
057ffe7c43dc
Initialize locale charset earlier
Mikael Berthe <mikael@lilotux.net>
parents:
773
diff
changeset
|
783 } |
057ffe7c43dc
Initialize locale charset earlier
Mikael Berthe <mikael@lilotux.net>
parents:
773
diff
changeset
|
784 |
1780
e4378fbab5d7
Major API cleanup - bump API to 4
Mikael Berthe <mikael@lilotux.net>
parents:
1761
diff
changeset
|
785 gboolean scr_curses_status(void) |
1733
a9b0364c0cb2
Fix segfault introduced in previous commit
Mikael Berthe <mikael@lilotux.net>
parents:
1729
diff
changeset
|
786 { |
a9b0364c0cb2
Fix segfault introduced in previous commit
Mikael Berthe <mikael@lilotux.net>
parents:
1729
diff
changeset
|
787 return Curses; |
a9b0364c0cb2
Fix segfault introduced in previous commit
Mikael Berthe <mikael@lilotux.net>
parents:
1729
diff
changeset
|
788 } |
a9b0364c0cb2
Fix segfault introduced in previous commit
Mikael Berthe <mikael@lilotux.net>
parents:
1729
diff
changeset
|
789 |
2309
e00ae0763468
Do not use litteral command char (':', '/')
Mikael Berthe <mikael@lilotux.net>
parents:
2308
diff
changeset
|
790 static gchar *scr_vi_mode_guard(const gchar *key, const gchar *new_value) |
e00ae0763468
Do not use litteral command char (':', '/')
Mikael Berthe <mikael@lilotux.net>
parents:
2308
diff
changeset
|
791 { |
e00ae0763468
Do not use litteral command char (':', '/')
Mikael Berthe <mikael@lilotux.net>
parents:
2308
diff
changeset
|
792 int new_mode = 0; |
e00ae0763468
Do not use litteral command char (':', '/')
Mikael Berthe <mikael@lilotux.net>
parents:
2308
diff
changeset
|
793 if (new_value) |
e00ae0763468
Do not use litteral command char (':', '/')
Mikael Berthe <mikael@lilotux.net>
parents:
2308
diff
changeset
|
794 new_mode = atoi(new_value); |
e00ae0763468
Do not use litteral command char (':', '/')
Mikael Berthe <mikael@lilotux.net>
parents:
2308
diff
changeset
|
795 if (new_mode == 0 || new_mode == 1) |
e00ae0763468
Do not use litteral command char (':', '/')
Mikael Berthe <mikael@lilotux.net>
parents:
2308
diff
changeset
|
796 vi_mode = new_mode; |
e00ae0763468
Do not use litteral command char (':', '/')
Mikael Berthe <mikael@lilotux.net>
parents:
2308
diff
changeset
|
797 return g_strdup(new_value); |
e00ae0763468
Do not use litteral command char (':', '/')
Mikael Berthe <mikael@lilotux.net>
parents:
2308
diff
changeset
|
798 } |
e00ae0763468
Do not use litteral command char (':', '/')
Mikael Berthe <mikael@lilotux.net>
parents:
2308
diff
changeset
|
799 |
1942
3e39a336a992
Use guards for colors (Myhailo Danylenko)
Mikael Berthe <mikael@lilotux.net>
parents:
1935
diff
changeset
|
800 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
|
801 { |
3e39a336a992
Use guards for colors (Myhailo Danylenko)
Mikael Berthe <mikael@lilotux.net>
parents:
1935
diff
changeset
|
802 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
|
803 colors_stalled = TRUE; |
3e39a336a992
Use guards for colors (Myhailo Danylenko)
Mikael Berthe <mikael@lilotux.net>
parents:
1935
diff
changeset
|
804 return g_strdup(new_value); |
3e39a336a992
Use guards for colors (Myhailo Danylenko)
Mikael Berthe <mikael@lilotux.net>
parents:
1935
diff
changeset
|
805 } |
3e39a336a992
Use guards for colors (Myhailo Danylenko)
Mikael Berthe <mikael@lilotux.net>
parents:
1935
diff
changeset
|
806 |
1780
e4378fbab5d7
Major API cleanup - bump API to 4
Mikael Berthe <mikael@lilotux.net>
parents:
1761
diff
changeset
|
807 void scr_init_curses(void) |
765
72626e9d60bd
Create init_keycodes(), add 2 screen escape sequences
Mikael Berthe <mikael@lilotux.net>
parents:
764
diff
changeset
|
808 { |
72626e9d60bd
Create init_keycodes(), add 2 screen escape sequences
Mikael Berthe <mikael@lilotux.net>
parents:
764
diff
changeset
|
809 /* Key sequences initialization */ |
72626e9d60bd
Create init_keycodes(), add 2 screen escape sequences
Mikael Berthe <mikael@lilotux.net>
parents:
764
diff
changeset
|
810 init_keycodes(); |
762
96d46e00524a
Add some key escape sequences for screen
Mikael Berthe <mikael@lilotux.net>
parents:
761
diff
changeset
|
811 |
373
af2f8ddf6a1b
Move (reorganize) functions
Mikael Berthe <mikael@lilotux.net>
parents:
370
diff
changeset
|
812 initscr(); |
382
4c6e8392e465
Use nodelay() instead of halfdelay()
Mikael Berthe <mikael@lilotux.net>
parents:
374
diff
changeset
|
813 raw(); |
373
af2f8ddf6a1b
Move (reorganize) functions
Mikael Berthe <mikael@lilotux.net>
parents:
370
diff
changeset
|
814 noecho(); |
389
6e895f397474
Ncurses changes + Ctrl-C does not send a signal anylore
Mikael Berthe <mikael@lilotux.net>
parents:
388
diff
changeset
|
815 nonl(); |
6e895f397474
Ncurses changes + Ctrl-C does not send a signal anylore
Mikael Berthe <mikael@lilotux.net>
parents:
388
diff
changeset
|
816 intrflush(stdscr, FALSE); |
373
af2f8ddf6a1b
Move (reorganize) functions
Mikael Berthe <mikael@lilotux.net>
parents:
370
diff
changeset
|
817 start_color(); |
af2f8ddf6a1b
Move (reorganize) functions
Mikael Berthe <mikael@lilotux.net>
parents:
370
diff
changeset
|
818 use_default_colors(); |
1561 | 819 #ifdef NCURSES_MOUSE_VERSION |
1563 | 820 if (settings_opt_get_int("use_mouse")) |
821 mousemask(ALL_MOUSE_EVENTS, NULL); | |
1561 | 822 #endif |
373
af2f8ddf6a1b
Move (reorganize) functions
Mikael Berthe <mikael@lilotux.net>
parents:
370
diff
changeset
|
823 |
1386 | 824 if (settings_opt_get("escdelay")) { |
825 #ifdef HAVE_ESCDELAY | |
826 ESCDELAY = (unsigned) settings_opt_get_int("escdelay"); | |
827 #else | |
828 scr_LogPrint(LPRINT_LOGNORM, "ERROR: no ESCDELAY support."); | |
829 #endif | |
830 } | |
831 | |
2309
e00ae0763468
Do not use litteral command char (':', '/')
Mikael Berthe <mikael@lilotux.net>
parents:
2308
diff
changeset
|
832 // Set up vi_mode guard |
e00ae0763468
Do not use litteral command char (':', '/')
Mikael Berthe <mikael@lilotux.net>
parents:
2308
diff
changeset
|
833 settings_set_guard("vi_mode", scr_vi_mode_guard); |
2311
962c98e4864d
Correctly initialize vi_mode when it is set in configuration file
Mikael Berthe <mikael@lilotux.net>
parents:
2309
diff
changeset
|
834 if (settings_opt_get_int("vi_mode") == 1) |
962c98e4864d
Correctly initialize vi_mode when it is set in configuration file
Mikael Berthe <mikael@lilotux.net>
parents:
2309
diff
changeset
|
835 vi_mode = true; |
2309
e00ae0763468
Do not use litteral command char (':', '/')
Mikael Berthe <mikael@lilotux.net>
parents:
2308
diff
changeset
|
836 |
1780
e4378fbab5d7
Major API cleanup - bump API to 4
Mikael Berthe <mikael@lilotux.net>
parents:
1761
diff
changeset
|
837 parse_colors(); |
373
af2f8ddf6a1b
Move (reorganize) functions
Mikael Berthe <mikael@lilotux.net>
parents:
370
diff
changeset
|
838 |
1942
3e39a336a992
Use guards for colors (Myhailo Danylenko)
Mikael Berthe <mikael@lilotux.net>
parents:
1935
diff
changeset
|
839 settings_set_guard("color_background", scr_color_guard); |
3e39a336a992
Use guards for colors (Myhailo Danylenko)
Mikael Berthe <mikael@lilotux.net>
parents:
1935
diff
changeset
|
840 settings_set_guard("color_general", scr_color_guard); |
3e39a336a992
Use guards for colors (Myhailo Danylenko)
Mikael Berthe <mikael@lilotux.net>
parents:
1935
diff
changeset
|
841 settings_set_guard("color_info", scr_color_guard); |
3e39a336a992
Use guards for colors (Myhailo Danylenko)
Mikael Berthe <mikael@lilotux.net>
parents:
1935
diff
changeset
|
842 settings_set_guard("color_msgin", scr_color_guard); |
3e39a336a992
Use guards for colors (Myhailo Danylenko)
Mikael Berthe <mikael@lilotux.net>
parents:
1935
diff
changeset
|
843 settings_set_guard("color_msgout", scr_color_guard); |
3e39a336a992
Use guards for colors (Myhailo Danylenko)
Mikael Berthe <mikael@lilotux.net>
parents:
1935
diff
changeset
|
844 settings_set_guard("color_msghl", scr_color_guard); |
3e39a336a992
Use guards for colors (Myhailo Danylenko)
Mikael Berthe <mikael@lilotux.net>
parents:
1935
diff
changeset
|
845 settings_set_guard("color_bgstatus", scr_color_guard); |
3e39a336a992
Use guards for colors (Myhailo Danylenko)
Mikael Berthe <mikael@lilotux.net>
parents:
1935
diff
changeset
|
846 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
|
847 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
|
848 settings_set_guard("color_roster", scr_color_guard); |
3e39a336a992
Use guards for colors (Myhailo Danylenko)
Mikael Berthe <mikael@lilotux.net>
parents:
1935
diff
changeset
|
849 settings_set_guard("color_bgrostersel", scr_color_guard); |
3e39a336a992
Use guards for colors (Myhailo Danylenko)
Mikael Berthe <mikael@lilotux.net>
parents:
1935
diff
changeset
|
850 settings_set_guard("color_rostersel", scr_color_guard); |
3e39a336a992
Use guards for colors (Myhailo Danylenko)
Mikael Berthe <mikael@lilotux.net>
parents:
1935
diff
changeset
|
851 settings_set_guard("color_rosterselmsg", scr_color_guard); |
3e39a336a992
Use guards for colors (Myhailo Danylenko)
Mikael Berthe <mikael@lilotux.net>
parents:
1935
diff
changeset
|
852 settings_set_guard("color_rosternewmsg", scr_color_guard); |
2090
16b04d64ec88
Add option to highlight timestamp added by server.
Hermitifier
parents:
2074
diff
changeset
|
853 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
|
854 |
373
af2f8ddf6a1b
Move (reorganize) functions
Mikael Berthe <mikael@lilotux.net>
parents:
370
diff
changeset
|
855 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
|
856 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
|
857 // 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
|
858 // 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
|
859 |
373
af2f8ddf6a1b
Move (reorganize) functions
Mikael Berthe <mikael@lilotux.net>
parents:
370
diff
changeset
|
860 inputLine[0] = 0; |
af2f8ddf6a1b
Move (reorganize) functions
Mikael Berthe <mikael@lilotux.net>
parents:
370
diff
changeset
|
861 ptr_inputline = inputLine; |
af2f8ddf6a1b
Move (reorganize) functions
Mikael Berthe <mikael@lilotux.net>
parents:
370
diff
changeset
|
862 |
966
d9acb7f2a3d1
Do not set Curses variable too early
Mikael Berthe <mikael@lilotux.net>
parents:
961
diff
changeset
|
863 Curses = TRUE; |
2149
1b3add57c912
Try to display the GLib warnings in the log window
Mikael Berthe <mikael@lilotux.net>
parents:
2143
diff
changeset
|
864 |
1b3add57c912
Try to display the GLib warnings in the log window
Mikael Berthe <mikael@lilotux.net>
parents:
2143
diff
changeset
|
865 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
|
866 return; |
af2f8ddf6a1b
Move (reorganize) functions
Mikael Berthe <mikael@lilotux.net>
parents:
370
diff
changeset
|
867 } |
af2f8ddf6a1b
Move (reorganize) functions
Mikael Berthe <mikael@lilotux.net>
parents:
370
diff
changeset
|
868 |
1780
e4378fbab5d7
Major API cleanup - bump API to 4
Mikael Berthe <mikael@lilotux.net>
parents:
1761
diff
changeset
|
869 void scr_terminate_curses(void) |
373
af2f8ddf6a1b
Move (reorganize) functions
Mikael Berthe <mikael@lilotux.net>
parents:
370
diff
changeset
|
870 { |
af2f8ddf6a1b
Move (reorganize) functions
Mikael Berthe <mikael@lilotux.net>
parents:
370
diff
changeset
|
871 if (!Curses) return; |
af2f8ddf6a1b
Move (reorganize) functions
Mikael Berthe <mikael@lilotux.net>
parents:
370
diff
changeset
|
872 clear(); |
af2f8ddf6a1b
Move (reorganize) functions
Mikael Berthe <mikael@lilotux.net>
parents:
370
diff
changeset
|
873 refresh(); |
af2f8ddf6a1b
Move (reorganize) functions
Mikael Berthe <mikael@lilotux.net>
parents:
370
diff
changeset
|
874 endwin(); |
af2f8ddf6a1b
Move (reorganize) functions
Mikael Berthe <mikael@lilotux.net>
parents:
370
diff
changeset
|
875 Curses = FALSE; |
af2f8ddf6a1b
Move (reorganize) functions
Mikael Berthe <mikael@lilotux.net>
parents:
370
diff
changeset
|
876 return; |
af2f8ddf6a1b
Move (reorganize) functions
Mikael Berthe <mikael@lilotux.net>
parents:
370
diff
changeset
|
877 } |
af2f8ddf6a1b
Move (reorganize) functions
Mikael Berthe <mikael@lilotux.net>
parents:
370
diff
changeset
|
878 |
1780
e4378fbab5d7
Major API cleanup - bump API to 4
Mikael Berthe <mikael@lilotux.net>
parents:
1761
diff
changeset
|
879 void scr_beep(void) |
675
ae7016aae014
New "beep_on_message" option
Mikael Berthe <mikael@lilotux.net>
parents:
667
diff
changeset
|
880 { |
ae7016aae014
New "beep_on_message" option
Mikael Berthe <mikael@lilotux.net>
parents:
667
diff
changeset
|
881 beep(); |
ae7016aae014
New "beep_on_message" option
Mikael Berthe <mikael@lilotux.net>
parents:
667
diff
changeset
|
882 } |
ae7016aae014
New "beep_on_message" option
Mikael Berthe <mikael@lilotux.net>
parents:
667
diff
changeset
|
883 |
1286
02ad6200df26
Add selectable time prefixes (vorner)
Mikael Berthe <mikael@lilotux.net>
parents:
1284
diff
changeset
|
884 // 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
|
885 static const char *timeprefixes[] = { |
02ad6200df26
Add selectable time prefixes (vorner)
Mikael Berthe <mikael@lilotux.net>
parents:
1284
diff
changeset
|
886 "%m-%d %H:%M ", |
02ad6200df26
Add selectable time prefixes (vorner)
Mikael Berthe <mikael@lilotux.net>
parents:
1284
diff
changeset
|
887 "%H:%M ", |
02ad6200df26
Add selectable time prefixes (vorner)
Mikael Berthe <mikael@lilotux.net>
parents:
1284
diff
changeset
|
888 " " |
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 |
02ad6200df26
Add selectable time prefixes (vorner)
Mikael Berthe <mikael@lilotux.net>
parents:
1284
diff
changeset
|
891 static const char *spectimeprefixes[] = { |
02ad6200df26
Add selectable time prefixes (vorner)
Mikael Berthe <mikael@lilotux.net>
parents:
1284
diff
changeset
|
892 "%m-%d %H:%M:%S ", |
02ad6200df26
Add selectable time prefixes (vorner)
Mikael Berthe <mikael@lilotux.net>
parents:
1284
diff
changeset
|
893 "%H:%M:%S ", |
02ad6200df26
Add selectable time prefixes (vorner)
Mikael Berthe <mikael@lilotux.net>
parents:
1284
diff
changeset
|
894 " " |
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 |
02ad6200df26
Add selectable time prefixes (vorner)
Mikael Berthe <mikael@lilotux.net>
parents:
1284
diff
changeset
|
897 static int timepreflengths[] = { |
1376
a0deb5124ebf
Check time_prefix value before using it
Mikael Berthe <mikael@lilotux.net>
parents:
1359
diff
changeset
|
898 // (length of the corresponding timeprefix + 5) |
1286
02ad6200df26
Add selectable time prefixes (vorner)
Mikael Berthe <mikael@lilotux.net>
parents:
1284
diff
changeset
|
899 17, |
02ad6200df26
Add selectable time prefixes (vorner)
Mikael Berthe <mikael@lilotux.net>
parents:
1284
diff
changeset
|
900 11, |
02ad6200df26
Add selectable time prefixes (vorner)
Mikael Berthe <mikael@lilotux.net>
parents:
1284
diff
changeset
|
901 6 |
02ad6200df26
Add selectable time prefixes (vorner)
Mikael Berthe <mikael@lilotux.net>
parents:
1284
diff
changeset
|
902 }; |
02ad6200df26
Add selectable time prefixes (vorner)
Mikael Berthe <mikael@lilotux.net>
parents:
1284
diff
changeset
|
903 |
1486
f83a51eaa5ed
Fix multiline output in /buffer save
Mikael Berthe <mikael@lilotux.net>
parents:
1485
diff
changeset
|
904 static const char *gettprefix(void) |
1286
02ad6200df26
Add selectable time prefixes (vorner)
Mikael Berthe <mikael@lilotux.net>
parents:
1284
diff
changeset
|
905 { |
1376
a0deb5124ebf
Check time_prefix value before using it
Mikael Berthe <mikael@lilotux.net>
parents:
1359
diff
changeset
|
906 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
|
907 return timeprefixes[(n < 3 ? n : 0)]; |
1286
02ad6200df26
Add selectable time prefixes (vorner)
Mikael Berthe <mikael@lilotux.net>
parents:
1284
diff
changeset
|
908 } |
02ad6200df26
Add selectable time prefixes (vorner)
Mikael Berthe <mikael@lilotux.net>
parents:
1284
diff
changeset
|
909 |
1486
f83a51eaa5ed
Fix multiline output in /buffer save
Mikael Berthe <mikael@lilotux.net>
parents:
1485
diff
changeset
|
910 static const char *getspectprefix(void) |
1286
02ad6200df26
Add selectable time prefixes (vorner)
Mikael Berthe <mikael@lilotux.net>
parents:
1284
diff
changeset
|
911 { |
1376
a0deb5124ebf
Check time_prefix value before using it
Mikael Berthe <mikael@lilotux.net>
parents:
1359
diff
changeset
|
912 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
|
913 return spectimeprefixes[(n < 3 ? n : 0)]; |
1286
02ad6200df26
Add selectable time prefixes (vorner)
Mikael Berthe <mikael@lilotux.net>
parents:
1284
diff
changeset
|
914 } |
02ad6200df26
Add selectable time prefixes (vorner)
Mikael Berthe <mikael@lilotux.net>
parents:
1284
diff
changeset
|
915 |
1487 | 916 guint scr_getprefixwidth(void) |
1286
02ad6200df26
Add selectable time prefixes (vorner)
Mikael Berthe <mikael@lilotux.net>
parents:
1284
diff
changeset
|
917 { |
1376
a0deb5124ebf
Check time_prefix value before using it
Mikael Berthe <mikael@lilotux.net>
parents:
1359
diff
changeset
|
918 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
|
919 return timepreflengths[(n < 3 ? n : 0)]; |
1286
02ad6200df26
Add selectable time prefixes (vorner)
Mikael Berthe <mikael@lilotux.net>
parents:
1284
diff
changeset
|
920 } |
02ad6200df26
Add selectable time prefixes (vorner)
Mikael Berthe <mikael@lilotux.net>
parents:
1284
diff
changeset
|
921 |
1761
61f0482d3993
Limit = alignment to 1/3 of screen in option list
Myhailo Danylenko <isbear@ukrpost.net>
parents:
1756
diff
changeset
|
922 guint scr_gettextwidth(void) |
61f0482d3993
Limit = alignment to 1/3 of screen in option list
Myhailo Danylenko <isbear@ukrpost.net>
parents:
1756
diff
changeset
|
923 { |
2325
c5665d3191aa
Prevent assigning negative values to unsigned variables
Michał Kępień <bitbucket@kempniu.pl>
parents:
2324
diff
changeset
|
924 int used_width = Roster_Width + scr_getprefixwidth(); |
c5665d3191aa
Prevent assigning negative values to unsigned variables
Michał Kępień <bitbucket@kempniu.pl>
parents:
2324
diff
changeset
|
925 return maxX > used_width ? maxX - used_width : 0; |
1761
61f0482d3993
Limit = alignment to 1/3 of screen in option list
Myhailo Danylenko <isbear@ukrpost.net>
parents:
1756
diff
changeset
|
926 } |
61f0482d3993
Limit = alignment to 1/3 of screen in option list
Myhailo Danylenko <isbear@ukrpost.net>
parents:
1756
diff
changeset
|
927 |
1791
6e0a8bfb3a01
Add scr_gettextheight()
Myhailo Danylenko <isbear@ukrpost.net>
parents:
1783
diff
changeset
|
928 guint scr_gettextheight(void) |
6e0a8bfb3a01
Add scr_gettextheight()
Myhailo Danylenko <isbear@ukrpost.net>
parents:
1783
diff
changeset
|
929 { |
6e0a8bfb3a01
Add scr_gettextheight()
Myhailo Danylenko <isbear@ukrpost.net>
parents:
1783
diff
changeset
|
930 // log window, two status bars and one input line |
6e0a8bfb3a01
Add scr_gettextheight()
Myhailo Danylenko <isbear@ukrpost.net>
parents:
1783
diff
changeset
|
931 return maxY - Log_Win_Height - 3; |
6e0a8bfb3a01
Add scr_gettextheight()
Myhailo Danylenko <isbear@ukrpost.net>
parents:
1783
diff
changeset
|
932 } |
6e0a8bfb3a01
Add scr_gettextheight()
Myhailo Danylenko <isbear@ukrpost.net>
parents:
1783
diff
changeset
|
933 |
1819
d13315366ba5
Add scr_getlogwinheight()
Mikael Berthe <mikael@lilotux.net>
parents:
1815
diff
changeset
|
934 guint scr_getlogwinheight(void) |
d13315366ba5
Add scr_getlogwinheight()
Mikael Berthe <mikael@lilotux.net>
parents:
1815
diff
changeset
|
935 { |
2342 | 936 return Log_Win_Height; |
1819
d13315366ba5
Add scr_getlogwinheight()
Mikael Berthe <mikael@lilotux.net>
parents:
1815
diff
changeset
|
937 } |
d13315366ba5
Add scr_getlogwinheight()
Mikael Berthe <mikael@lilotux.net>
parents:
1815
diff
changeset
|
938 |
1518
63dc211a4c1a
New command: /echo (display a message in the log window)
Mikael Berthe <mikael@lilotux.net>
parents:
1515
diff
changeset
|
939 // scr_print_logwindow(string) |
63dc211a4c1a
New command: /echo (display a message in the log window)
Mikael Berthe <mikael@lilotux.net>
parents:
1515
diff
changeset
|
940 // 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
|
941 // 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
|
942 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
|
943 { |
63dc211a4c1a
New command: /echo (display a message in the log window)
Mikael Berthe <mikael@lilotux.net>
parents:
1515
diff
changeset
|
944 time_t timestamp; |
63dc211a4c1a
New command: /echo (display a message in the log window)
Mikael Berthe <mikael@lilotux.net>
parents:
1515
diff
changeset
|
945 char strtimestamp[64]; |
63dc211a4c1a
New command: /echo (display a message in the log window)
Mikael Berthe <mikael@lilotux.net>
parents:
1515
diff
changeset
|
946 |
63dc211a4c1a
New command: /echo (display a message in the log window)
Mikael Berthe <mikael@lilotux.net>
parents:
1515
diff
changeset
|
947 timestamp = time(NULL); |
63dc211a4c1a
New command: /echo (display a message in the log window)
Mikael Berthe <mikael@lilotux.net>
parents:
1515
diff
changeset
|
948 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
|
949 if (Curses) { |
63dc211a4c1a
New command: /echo (display a message in the log window)
Mikael Berthe <mikael@lilotux.net>
parents:
1515
diff
changeset
|
950 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
|
951 update_panels(); |
63dc211a4c1a
New command: /echo (display a message in the log window)
Mikael Berthe <mikael@lilotux.net>
parents:
1515
diff
changeset
|
952 } else { |
63dc211a4c1a
New command: /echo (display a message in the log window)
Mikael Berthe <mikael@lilotux.net>
parents:
1515
diff
changeset
|
953 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
|
954 } |
63dc211a4c1a
New command: /echo (display a message in the log window)
Mikael Berthe <mikael@lilotux.net>
parents:
1515
diff
changeset
|
955 } |
63dc211a4c1a
New command: /echo (display a message in the log window)
Mikael Berthe <mikael@lilotux.net>
parents:
1515
diff
changeset
|
956 |
1783
af3de54ef986
Convert scr_LogPrint() to scr_log_print()
Mikael Berthe <mikael@lilotux.net>
parents:
1780
diff
changeset
|
957 // scr_log_print(...) |
1518
63dc211a4c1a
New command: /echo (display a message in the log window)
Mikael Berthe <mikael@lilotux.net>
parents:
1515
diff
changeset
|
958 // 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
|
959 // 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
|
960 // 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
|
961 void scr_log_print(unsigned int flag, const char *fmt, ...) |
373
af2f8ddf6a1b
Move (reorganize) functions
Mikael Berthe <mikael@lilotux.net>
parents:
370
diff
changeset
|
962 { |
af2f8ddf6a1b
Move (reorganize) functions
Mikael Berthe <mikael@lilotux.net>
parents:
370
diff
changeset
|
963 time_t timestamp; |
857
ef35a2bb40d7
scr_LogPrint(): do not use static buffer size
Mikael Berthe <mikael@lilotux.net>
parents:
851
diff
changeset
|
964 char strtimestamp[64]; |
858
2683ad5d1003
Improve scr_LogPrint() for log/debug messages
Mikael Berthe <mikael@lilotux.net>
parents:
857
diff
changeset
|
965 char *buffer, *btext; |
1075
03bc225ad763
Improve scr_LogPrint() readability
Mikael Berthe <mikael@lilotux.net>
parents:
1072
diff
changeset
|
966 char *convbuf1 = NULL, *convbuf2 = NULL; |
373
af2f8ddf6a1b
Move (reorganize) functions
Mikael Berthe <mikael@lilotux.net>
parents:
370
diff
changeset
|
967 va_list ap; |
af2f8ddf6a1b
Move (reorganize) functions
Mikael Berthe <mikael@lilotux.net>
parents:
370
diff
changeset
|
968 |
771
ce4f8a2129a4
scr_LogPrint() can display UTF-8 strings
Mikael Berthe <mikael@lilotux.net>
parents:
770
diff
changeset
|
969 if (!(flag & ~LPRINT_NOTUTF8)) return; // Shouldn't happen |
374
bd5638c21834
Improve logging system (traces)
Mikael Berthe <mikael@lilotux.net>
parents:
373
diff
changeset
|
970 |
857
ef35a2bb40d7
scr_LogPrint(): do not use static buffer size
Mikael Berthe <mikael@lilotux.net>
parents:
851
diff
changeset
|
971 timestamp = time(NULL); |
ef35a2bb40d7
scr_LogPrint(): do not use static buffer size
Mikael Berthe <mikael@lilotux.net>
parents:
851
diff
changeset
|
972 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
|
973 va_start(ap, fmt); |
858
2683ad5d1003
Improve scr_LogPrint() for log/debug messages
Mikael Berthe <mikael@lilotux.net>
parents:
857
diff
changeset
|
974 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
|
975 va_end(ap); |
373
af2f8ddf6a1b
Move (reorganize) functions
Mikael Berthe <mikael@lilotux.net>
parents:
370
diff
changeset
|
976 |
374
bd5638c21834
Improve logging system (traces)
Mikael Berthe <mikael@lilotux.net>
parents:
373
diff
changeset
|
977 if (flag & LPRINT_NORMAL) { |
771
ce4f8a2129a4
scr_LogPrint() can display UTF-8 strings
Mikael Berthe <mikael@lilotux.net>
parents:
770
diff
changeset
|
978 char *buffer_locale; |
851
da03534e46c7
Add startup log messages to the status buffer
Mikael Berthe <mikael@lilotux.net>
parents:
850
diff
changeset
|
979 char *buf_specialwindow; |
da03534e46c7
Add startup log messages to the status buffer
Mikael Berthe <mikael@lilotux.net>
parents:
850
diff
changeset
|
980 |
858
2683ad5d1003
Improve scr_LogPrint() for log/debug messages
Mikael Berthe <mikael@lilotux.net>
parents:
857
diff
changeset
|
981 buffer = g_strdup_printf("%s %s", strtimestamp, btext); |
2683ad5d1003
Improve scr_LogPrint() for log/debug messages
Mikael Berthe <mikael@lilotux.net>
parents:
857
diff
changeset
|
982 |
851
da03534e46c7
Add startup log messages to the status buffer
Mikael Berthe <mikael@lilotux.net>
parents:
850
diff
changeset
|
983 // 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
|
984 if (!(flag & LPRINT_NOTUTF8)) |
1075
03bc225ad763
Improve scr_LogPrint() readability
Mikael Berthe <mikael@lilotux.net>
parents:
1072
diff
changeset
|
985 buffer_locale = convbuf1 = from_utf8(buffer); |
771
ce4f8a2129a4
scr_LogPrint() can display UTF-8 strings
Mikael Berthe <mikael@lilotux.net>
parents:
770
diff
changeset
|
986 else |
ce4f8a2129a4
scr_LogPrint() can display UTF-8 strings
Mikael Berthe <mikael@lilotux.net>
parents:
770
diff
changeset
|
987 buffer_locale = buffer; |
851
da03534e46c7
Add startup log messages to the status buffer
Mikael Berthe <mikael@lilotux.net>
parents:
850
diff
changeset
|
988 |
884
9e6d9f0cf9eb
scr_LogPrint(): Add a warning for UTF-8 -> locale conversion failures
Mikael Berthe <mikael@lilotux.net>
parents:
880
diff
changeset
|
989 if (!buffer_locale) { |
9e6d9f0cf9eb
scr_LogPrint(): Add a warning for UTF-8 -> locale conversion failures
Mikael Berthe <mikael@lilotux.net>
parents:
880
diff
changeset
|
990 wprintw(logWnd, |
9e6d9f0cf9eb
scr_LogPrint(): Add a warning for UTF-8 -> locale conversion failures
Mikael Berthe <mikael@lilotux.net>
parents:
880
diff
changeset
|
991 "\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
|
992 update_panels(); |
9e6d9f0cf9eb
scr_LogPrint(): Add a warning for UTF-8 -> locale conversion failures
Mikael Berthe <mikael@lilotux.net>
parents:
880
diff
changeset
|
993 g_free(buffer); |
897
a05b5a16a06a
Fix memory leak in scr_LogPrint()
Mikael Berthe <mikael@lilotux.net>
parents:
891
diff
changeset
|
994 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
|
995 return; |
9e6d9f0cf9eb
scr_LogPrint(): Add a warning for UTF-8 -> locale conversion failures
Mikael Berthe <mikael@lilotux.net>
parents:
880
diff
changeset
|
996 } |
9e6d9f0cf9eb
scr_LogPrint(): Add a warning for UTF-8 -> locale conversion failures
Mikael Berthe <mikael@lilotux.net>
parents:
880
diff
changeset
|
997 |
851
da03534e46c7
Add startup log messages to the status buffer
Mikael Berthe <mikael@lilotux.net>
parents:
850
diff
changeset
|
998 // 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
|
999 if (flag & LPRINT_NOTUTF8) |
1075
03bc225ad763
Improve scr_LogPrint() readability
Mikael Berthe <mikael@lilotux.net>
parents:
1072
diff
changeset
|
1000 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
|
1001 else |
858
2683ad5d1003
Improve scr_LogPrint() for log/debug messages
Mikael Berthe <mikael@lilotux.net>
parents:
857
diff
changeset
|
1002 buf_specialwindow = btext; |
851
da03534e46c7
Add startup log messages to the status buffer
Mikael Berthe <mikael@lilotux.net>
parents:
850
diff
changeset
|
1003 |
374
bd5638c21834
Improve logging system (traces)
Mikael Berthe <mikael@lilotux.net>
parents:
373
diff
changeset
|
1004 if (Curses) { |
771
ce4f8a2129a4
scr_LogPrint() can display UTF-8 strings
Mikael Berthe <mikael@lilotux.net>
parents:
770
diff
changeset
|
1005 wprintw(logWnd, "\n%s", buffer_locale); |
374
bd5638c21834
Improve logging system (traces)
Mikael Berthe <mikael@lilotux.net>
parents:
373
diff
changeset
|
1006 update_panels(); |
1780
e4378fbab5d7
Major API cleanup - bump API to 4
Mikael Berthe <mikael@lilotux.net>
parents:
1761
diff
changeset
|
1007 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
|
1008 HBB_PREFIX_SPECIAL, FALSE, 0, NULL); |
374
bd5638c21834
Improve logging system (traces)
Mikael Berthe <mikael@lilotux.net>
parents:
373
diff
changeset
|
1009 } else { |
771
ce4f8a2129a4
scr_LogPrint() can display UTF-8 strings
Mikael Berthe <mikael@lilotux.net>
parents:
770
diff
changeset
|
1010 printf("%s\n", buffer_locale); |
851
da03534e46c7
Add startup log messages to the status buffer
Mikael Berthe <mikael@lilotux.net>
parents:
850
diff
changeset
|
1011 // 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
|
1012 hbuf_add_line(&statushbuf, buf_specialwindow, timestamp, |
1602 | 1013 HBB_PREFIX_SPECIAL, 0, 0, 0, NULL); |
374
bd5638c21834
Improve logging system (traces)
Mikael Berthe <mikael@lilotux.net>
parents:
373
diff
changeset
|
1014 } |
851
da03534e46c7
Add startup log messages to the status buffer
Mikael Berthe <mikael@lilotux.net>
parents:
850
diff
changeset
|
1015 |
1075
03bc225ad763
Improve scr_LogPrint() readability
Mikael Berthe <mikael@lilotux.net>
parents:
1072
diff
changeset
|
1016 g_free(convbuf1); |
03bc225ad763
Improve scr_LogPrint() readability
Mikael Berthe <mikael@lilotux.net>
parents:
1072
diff
changeset
|
1017 g_free(convbuf2); |
858
2683ad5d1003
Improve scr_LogPrint() for log/debug messages
Mikael Berthe <mikael@lilotux.net>
parents:
857
diff
changeset
|
1018 g_free(buffer); |
374
bd5638c21834
Improve logging system (traces)
Mikael Berthe <mikael@lilotux.net>
parents:
373
diff
changeset
|
1019 } |
412
9c640ee3bae3
Display full date in the log file
Mikael Berthe <mikael@lilotux.net>
parents:
393
diff
changeset
|
1020 |
857
ef35a2bb40d7
scr_LogPrint(): do not use static buffer size
Mikael Berthe <mikael@lilotux.net>
parents:
851
diff
changeset
|
1021 if (flag & (LPRINT_LOG|LPRINT_DEBUG)) { |
ef35a2bb40d7
scr_LogPrint(): do not use static buffer size
Mikael Berthe <mikael@lilotux.net>
parents:
851
diff
changeset
|
1022 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
|
1023 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
|
1024 ut_write_log(flag, buffer); |
857
ef35a2bb40d7
scr_LogPrint(): do not use static buffer size
Mikael Berthe <mikael@lilotux.net>
parents:
851
diff
changeset
|
1025 g_free(buffer); |
373
af2f8ddf6a1b
Move (reorganize) functions
Mikael Berthe <mikael@lilotux.net>
parents:
370
diff
changeset
|
1026 } |
897
a05b5a16a06a
Fix memory leak in scr_LogPrint()
Mikael Berthe <mikael@lilotux.net>
parents:
891
diff
changeset
|
1027 g_free(btext); |
373
af2f8ddf6a1b
Move (reorganize) functions
Mikael Berthe <mikael@lilotux.net>
parents:
370
diff
changeset
|
1028 } |
af2f8ddf6a1b
Move (reorganize) functions
Mikael Berthe <mikael@lilotux.net>
parents:
370
diff
changeset
|
1029 |
2149
1b3add57c912
Try to display the GLib warnings in the log window
Mikael Berthe <mikael@lilotux.net>
parents:
2143
diff
changeset
|
1030 // 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
|
1031 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
|
1032 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
|
1033 { |
1b3add57c912
Try to display the GLib warnings in the log window
Mikael Berthe <mikael@lilotux.net>
parents:
2143
diff
changeset
|
1034 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
|
1035 } |
1b3add57c912
Try to display the GLib warnings in the log window
Mikael Berthe <mikael@lilotux.net>
parents:
2143
diff
changeset
|
1036 |
2337 | 1037 static winbuf_t *scr_search_window(const char *winId, int special) |
1156
cae430fcd385
Mcabber will load symlinked histories only once, now.
Frank Zschockelt
parents:
1154
diff
changeset
|
1038 { |
cae430fcd385
Mcabber will load symlinked histories only once, now.
Frank Zschockelt
parents:
1154
diff
changeset
|
1039 char *id; |
2337 | 1040 winbuf_t *wbp; |
1156
cae430fcd385
Mcabber will load symlinked histories only once, now.
Frank Zschockelt
parents:
1154
diff
changeset
|
1041 |
cae430fcd385
Mcabber will load symlinked histories only once, now.
Frank Zschockelt
parents:
1154
diff
changeset
|
1042 if (special) |
cae430fcd385
Mcabber will load symlinked histories only once, now.
Frank Zschockelt
parents:
1154
diff
changeset
|
1043 return statusWindow; // Only one special window atm. |
cae430fcd385
Mcabber will load symlinked histories only once, now.
Frank Zschockelt
parents:
1154
diff
changeset
|
1044 |
cae430fcd385
Mcabber will load symlinked histories only once, now.
Frank Zschockelt
parents:
1154
diff
changeset
|
1045 if (!winId) |
cae430fcd385
Mcabber will load symlinked histories only once, now.
Frank Zschockelt
parents:
1154
diff
changeset
|
1046 return NULL; |
cae430fcd385
Mcabber will load symlinked histories only once, now.
Frank Zschockelt
parents:
1154
diff
changeset
|
1047 |
cae430fcd385
Mcabber will load symlinked histories only once, now.
Frank Zschockelt
parents:
1154
diff
changeset
|
1048 id = g_strdup(winId); |
cae430fcd385
Mcabber will load symlinked histories only once, now.
Frank Zschockelt
parents:
1154
diff
changeset
|
1049 mc_strtolower(id); |
cae430fcd385
Mcabber will load symlinked histories only once, now.
Frank Zschockelt
parents:
1154
diff
changeset
|
1050 wbp = g_hash_table_lookup(winbufhash, id); |
cae430fcd385
Mcabber will load symlinked histories only once, now.
Frank Zschockelt
parents:
1154
diff
changeset
|
1051 g_free(id); |
cae430fcd385
Mcabber will load symlinked histories only once, now.
Frank Zschockelt
parents:
1154
diff
changeset
|
1052 return wbp; |
cae430fcd385
Mcabber will load symlinked histories only once, now.
Frank Zschockelt
parents:
1154
diff
changeset
|
1053 } |
cae430fcd385
Mcabber will load symlinked histories only once, now.
Frank Zschockelt
parents:
1154
diff
changeset
|
1054 |
1780
e4378fbab5d7
Major API cleanup - bump API to 4
Mikael Berthe <mikael@lilotux.net>
parents:
1761
diff
changeset
|
1055 int scr_buddy_buffer_exists(const char *bjid) |
1156
cae430fcd385
Mcabber will load symlinked histories only once, now.
Frank Zschockelt
parents:
1154
diff
changeset
|
1056 { |
1780
e4378fbab5d7
Major API cleanup - bump API to 4
Mikael Berthe <mikael@lilotux.net>
parents:
1761
diff
changeset
|
1057 return (scr_search_window(bjid, FALSE) != NULL); |
1156
cae430fcd385
Mcabber will load symlinked histories only once, now.
Frank Zschockelt
parents:
1154
diff
changeset
|
1058 } |
cae430fcd385
Mcabber will load symlinked histories only once, now.
Frank Zschockelt
parents:
1154
diff
changeset
|
1059 |
1133
9dd28a56128f
Do not create one panel per contact
Mikael Berthe <mikael@lilotux.net>
parents:
1131
diff
changeset
|
1060 // scr_new_buddy(title, dontshow) |
1139 | 1061 // Note: title (aka winId/jid) can be NULL for special buffers |
2337 | 1062 static winbuf_t *scr_new_buddy(const char *title, int dont_show) |
24 | 1063 { |
2337 | 1064 winbuf_t *tmp; |
2225
dc3b3ac1ba76
Free the buffdata structures when buffers are closed
Mikael Berthe <mikael@lilotux.net>
parents:
2222
diff
changeset
|
1065 char *id; |
393 | 1066 |
2337 | 1067 tmp = g_new0(winbuf_t, 1); |
24 | 1068 |
1133
9dd28a56128f
Do not create one panel per contact
Mikael Berthe <mikael@lilotux.net>
parents:
1131
diff
changeset
|
1069 tmp->win = activechatWnd; |
9dd28a56128f
Do not create one panel per contact
Mikael Berthe <mikael@lilotux.net>
parents:
1131
diff
changeset
|
1070 tmp->panel = activechatPanel; |
24 | 1071 |
143 | 1072 if (!dont_show) { |
24 | 1073 currentWindow = tmp; |
1074 } else { | |
1075 if (currentWindow) | |
1076 top_panel(currentWindow->panel); | |
1077 else | |
1078 top_panel(chatPanel); | |
1079 } | |
143 | 1080 update_panels(); |
24 | 1081 |
849
42c43a88d823
Status buffer management
Mikael Berthe <mikael@lilotux.net>
parents:
848
diff
changeset
|
1082 // 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
|
1083 if (!title) { |
2337 | 1084 tmp->bd = g_new0(buffdata_t, 1); |
2225
dc3b3ac1ba76
Free the buffdata structures when buffers are closed
Mikael Berthe <mikael@lilotux.net>
parents:
2222
diff
changeset
|
1085 return tmp; |
849
42c43a88d823
Status buffer management
Mikael Berthe <mikael@lilotux.net>
parents:
848
diff
changeset
|
1086 } |
2225
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 id = hlog_get_log_jid(title); |
dc3b3ac1ba76
Free the buffdata structures when buffers are closed
Mikael Berthe <mikael@lilotux.net>
parents:
2222
diff
changeset
|
1089 if (id) { |
dc3b3ac1ba76
Free the buffdata structures when buffers are closed
Mikael Berthe <mikael@lilotux.net>
parents:
2222
diff
changeset
|
1090 // 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
|
1091 // Let's check if the target JID buffer has already been created. |
2337 | 1092 winbuf_t *wb = scr_search_window(id, FALSE); |
2225
dc3b3ac1ba76
Free the buffdata structures when buffers are closed
Mikael Berthe <mikael@lilotux.net>
parents:
2222
diff
changeset
|
1093 if (!wb) |
dc3b3ac1ba76
Free the buffdata structures when buffers are closed
Mikael Berthe <mikael@lilotux.net>
parents:
2222
diff
changeset
|
1094 wb = scr_new_buddy(id, TRUE); |
dc3b3ac1ba76
Free the buffdata structures when buffers are closed
Mikael Berthe <mikael@lilotux.net>
parents:
2222
diff
changeset
|
1095 tmp->bd = wb->bd; |
dc3b3ac1ba76
Free the buffdata structures when buffers are closed
Mikael Berthe <mikael@lilotux.net>
parents:
2222
diff
changeset
|
1096 tmp->bd->refcount++; |
dc3b3ac1ba76
Free the buffdata structures when buffers are closed
Mikael Berthe <mikael@lilotux.net>
parents:
2222
diff
changeset
|
1097 g_free(id); |
dc3b3ac1ba76
Free the buffdata structures when buffers are closed
Mikael Berthe <mikael@lilotux.net>
parents:
2222
diff
changeset
|
1098 } else { // Load buddy history from file (if enabled) |
2337 | 1099 tmp->bd = g_new0(buffdata_t, 1); |
2325
c5665d3191aa
Prevent assigning negative values to unsigned variables
Michał Kępień <bitbucket@kempniu.pl>
parents:
2324
diff
changeset
|
1100 hlog_read_history(title, &tmp->bd->hbuf, scr_gettextwidth()); |
2225
dc3b3ac1ba76
Free the buffdata structures when buffers are closed
Mikael Berthe <mikael@lilotux.net>
parents:
2222
diff
changeset
|
1101 |
dc3b3ac1ba76
Free the buffdata structures when buffers are closed
Mikael Berthe <mikael@lilotux.net>
parents:
2222
diff
changeset
|
1102 // 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
|
1103 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
|
1104 } |
dc3b3ac1ba76
Free the buffdata structures when buffers are closed
Mikael Berthe <mikael@lilotux.net>
parents:
2222
diff
changeset
|
1105 |
dc3b3ac1ba76
Free the buffdata structures when buffers are closed
Mikael Berthe <mikael@lilotux.net>
parents:
2222
diff
changeset
|
1106 id = g_strdup(title); |
dc3b3ac1ba76
Free the buffdata structures when buffers are closed
Mikael Berthe <mikael@lilotux.net>
parents:
2222
diff
changeset
|
1107 mc_strtolower(id); |
dc3b3ac1ba76
Free the buffdata structures when buffers are closed
Mikael Berthe <mikael@lilotux.net>
parents:
2222
diff
changeset
|
1108 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
|
1109 |
24 | 1110 return tmp; |
1111 } | |
1112 | |
1483
e74cc83e7158
Refactor scr_UpdateWindow()
Mikael Berthe <mikael@lilotux.net>
parents:
1476
diff
changeset
|
1113 // scr_line_prefix(line, pref, preflen) |
e74cc83e7158
Refactor scr_UpdateWindow()
Mikael Berthe <mikael@lilotux.net>
parents:
1476
diff
changeset
|
1114 // Use data from the hbb_line structure and write the prefix |
e74cc83e7158
Refactor scr_UpdateWindow()
Mikael Berthe <mikael@lilotux.net>
parents:
1476
diff
changeset
|
1115 // to pref (not exceeding preflen, trailing null byte included). |
2090
16b04d64ec88
Add option to highlight timestamp added by server.
Hermitifier
parents:
2074
diff
changeset
|
1116 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
|
1117 { |
e74cc83e7158
Refactor scr_UpdateWindow()
Mikael Berthe <mikael@lilotux.net>
parents:
1476
diff
changeset
|
1118 char date[64]; |
2090
16b04d64ec88
Add option to highlight timestamp added by server.
Hermitifier
parents:
2074
diff
changeset
|
1119 size_t timepreflen = 0; |
1483
e74cc83e7158
Refactor scr_UpdateWindow()
Mikael Berthe <mikael@lilotux.net>
parents:
1476
diff
changeset
|
1120 |
e74cc83e7158
Refactor scr_UpdateWindow()
Mikael Berthe <mikael@lilotux.net>
parents:
1476
diff
changeset
|
1121 if (line->timestamp && |
e74cc83e7158
Refactor scr_UpdateWindow()
Mikael Berthe <mikael@lilotux.net>
parents:
1476
diff
changeset
|
1122 !(line->flags & (HBB_PREFIX_SPECIAL|HBB_PREFIX_CONT))) { |
2090
16b04d64ec88
Add option to highlight timestamp added by server.
Hermitifier
parents:
2074
diff
changeset
|
1123 timepreflen = strftime(date, 30, gettprefix(), localtime(&line->timestamp)); |
1483
e74cc83e7158
Refactor scr_UpdateWindow()
Mikael Berthe <mikael@lilotux.net>
parents:
1476
diff
changeset
|
1124 } else |
e74cc83e7158
Refactor scr_UpdateWindow()
Mikael Berthe <mikael@lilotux.net>
parents:
1476
diff
changeset
|
1125 strcpy(date, " "); |
e74cc83e7158
Refactor scr_UpdateWindow()
Mikael Berthe <mikael@lilotux.net>
parents:
1476
diff
changeset
|
1126 |
e74cc83e7158
Refactor scr_UpdateWindow()
Mikael Berthe <mikael@lilotux.net>
parents:
1476
diff
changeset
|
1127 if (!(line->flags & HBB_PREFIX_CONT)) { |
e74cc83e7158
Refactor scr_UpdateWindow()
Mikael Berthe <mikael@lilotux.net>
parents:
1476
diff
changeset
|
1128 if (line->flags & HBB_PREFIX_INFO) { |
e74cc83e7158
Refactor scr_UpdateWindow()
Mikael Berthe <mikael@lilotux.net>
parents:
1476
diff
changeset
|
1129 char dir = '*'; |
e74cc83e7158
Refactor scr_UpdateWindow()
Mikael Berthe <mikael@lilotux.net>
parents:
1476
diff
changeset
|
1130 if (line->flags & HBB_PREFIX_IN) |
e74cc83e7158
Refactor scr_UpdateWindow()
Mikael Berthe <mikael@lilotux.net>
parents:
1476
diff
changeset
|
1131 dir = '<'; |
e74cc83e7158
Refactor scr_UpdateWindow()
Mikael Berthe <mikael@lilotux.net>
parents:
1476
diff
changeset
|
1132 else if (line->flags & HBB_PREFIX_OUT) |
e74cc83e7158
Refactor scr_UpdateWindow()
Mikael Berthe <mikael@lilotux.net>
parents:
1476
diff
changeset
|
1133 dir = '>'; |
e74cc83e7158
Refactor scr_UpdateWindow()
Mikael Berthe <mikael@lilotux.net>
parents:
1476
diff
changeset
|
1134 g_snprintf(pref, preflen, "%s*%c* ", date, dir); |
e74cc83e7158
Refactor scr_UpdateWindow()
Mikael Berthe <mikael@lilotux.net>
parents:
1476
diff
changeset
|
1135 } else if (line->flags & HBB_PREFIX_ERR) { |
e74cc83e7158
Refactor scr_UpdateWindow()
Mikael Berthe <mikael@lilotux.net>
parents:
1476
diff
changeset
|
1136 char dir = '#'; |
e74cc83e7158
Refactor scr_UpdateWindow()
Mikael Berthe <mikael@lilotux.net>
parents:
1476
diff
changeset
|
1137 if (line->flags & HBB_PREFIX_IN) |
e74cc83e7158
Refactor scr_UpdateWindow()
Mikael Berthe <mikael@lilotux.net>
parents:
1476
diff
changeset
|
1138 dir = '<'; |
e74cc83e7158
Refactor scr_UpdateWindow()
Mikael Berthe <mikael@lilotux.net>
parents:
1476
diff
changeset
|
1139 else if (line->flags & HBB_PREFIX_OUT) |
e74cc83e7158
Refactor scr_UpdateWindow()
Mikael Berthe <mikael@lilotux.net>
parents:
1476
diff
changeset
|
1140 dir = '>'; |
e74cc83e7158
Refactor scr_UpdateWindow()
Mikael Berthe <mikael@lilotux.net>
parents:
1476
diff
changeset
|
1141 g_snprintf(pref, preflen, "%s#%c# ", date, dir); |
e74cc83e7158
Refactor scr_UpdateWindow()
Mikael Berthe <mikael@lilotux.net>
parents:
1476
diff
changeset
|
1142 } 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
|
1143 char cryptflag; |
7b36b91a4388
New UI message flag (O) when OTR is used
Mikael Berthe <mikael@lilotux.net>
parents:
1483
diff
changeset
|
1144 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
|
1145 cryptflag = '~'; |
7b36b91a4388
New UI message flag (O) when OTR is used
Mikael Berthe <mikael@lilotux.net>
parents:
1483
diff
changeset
|
1146 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
|
1147 cryptflag = 'O'; |
7b36b91a4388
New UI message flag (O) when OTR is used
Mikael Berthe <mikael@lilotux.net>
parents:
1483
diff
changeset
|
1148 else |
7b36b91a4388
New UI message flag (O) when OTR is used
Mikael Berthe <mikael@lilotux.net>
parents:
1483
diff
changeset
|
1149 cryptflag = '='; |
1483
e74cc83e7158
Refactor scr_UpdateWindow()
Mikael Berthe <mikael@lilotux.net>
parents:
1476
diff
changeset
|
1150 g_snprintf(pref, preflen, "%s<%c= ", date, cryptflag); |
e74cc83e7158
Refactor scr_UpdateWindow()
Mikael Berthe <mikael@lilotux.net>
parents:
1476
diff
changeset
|
1151 } else if (line->flags & HBB_PREFIX_OUT) { |
1602 | 1152 char cryptflag, receiptflag; |
1484
7b36b91a4388
New UI message flag (O) when OTR is used
Mikael Berthe <mikael@lilotux.net>
parents:
1483
diff
changeset
|
1153 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
|
1154 cryptflag = '~'; |
7b36b91a4388
New UI message flag (O) when OTR is used
Mikael Berthe <mikael@lilotux.net>
parents:
1483
diff
changeset
|
1155 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
|
1156 cryptflag = 'O'; |
7b36b91a4388
New UI message flag (O) when OTR is used
Mikael Berthe <mikael@lilotux.net>
parents:
1483
diff
changeset
|
1157 else |
1488
b393b8cee171
Fix small mistake in changeset 7b36b91a4388
Mikael Berthe <mikael@lilotux.net>
parents:
1487
diff
changeset
|
1158 cryptflag = '-'; |
1602 | 1159 if (line->flags & HBB_PREFIX_RECEIPT) |
1160 receiptflag = 'r'; | |
1161 else | |
1162 receiptflag = '-'; | |
1163 g_snprintf(pref, preflen, "%s%c%c> ", date, receiptflag, cryptflag); | |
1483
e74cc83e7158
Refactor scr_UpdateWindow()
Mikael Berthe <mikael@lilotux.net>
parents:
1476
diff
changeset
|
1164 } else if (line->flags & HBB_PREFIX_SPECIAL) { |
2090
16b04d64ec88
Add option to highlight timestamp added by server.
Hermitifier
parents:
2074
diff
changeset
|
1165 timepreflen = strftime(date, 30, getspectprefix(), localtime(&line->timestamp)); |
1483
e74cc83e7158
Refactor scr_UpdateWindow()
Mikael Berthe <mikael@lilotux.net>
parents:
1476
diff
changeset
|
1166 g_snprintf(pref, preflen, "%s ", date); |
e74cc83e7158
Refactor scr_UpdateWindow()
Mikael Berthe <mikael@lilotux.net>
parents:
1476
diff
changeset
|
1167 } else { |
e74cc83e7158
Refactor scr_UpdateWindow()
Mikael Berthe <mikael@lilotux.net>
parents:
1476
diff
changeset
|
1168 g_snprintf(pref, preflen, "%s ", date); |
e74cc83e7158
Refactor scr_UpdateWindow()
Mikael Berthe <mikael@lilotux.net>
parents:
1476
diff
changeset
|
1169 } |
e74cc83e7158
Refactor scr_UpdateWindow()
Mikael Berthe <mikael@lilotux.net>
parents:
1476
diff
changeset
|
1170 } else { |
e74cc83e7158
Refactor scr_UpdateWindow()
Mikael Berthe <mikael@lilotux.net>
parents:
1476
diff
changeset
|
1171 g_snprintf(pref, preflen, " "); |
e74cc83e7158
Refactor scr_UpdateWindow()
Mikael Berthe <mikael@lilotux.net>
parents:
1476
diff
changeset
|
1172 } |
2090
16b04d64ec88
Add option to highlight timestamp added by server.
Hermitifier
parents:
2074
diff
changeset
|
1173 return timepreflen; |
1483
e74cc83e7158
Refactor scr_UpdateWindow()
Mikael Berthe <mikael@lilotux.net>
parents:
1476
diff
changeset
|
1174 } |
e74cc83e7158
Refactor scr_UpdateWindow()
Mikael Berthe <mikael@lilotux.net>
parents:
1476
diff
changeset
|
1175 |
1780
e4378fbab5d7
Major API cleanup - bump API to 4
Mikael Berthe <mikael@lilotux.net>
parents:
1761
diff
changeset
|
1176 // scr_update_window() |
143 | 1177 // (Re-)Display the given chat window. |
2337 | 1178 static void scr_update_window(winbuf_t *win_entry) |
74 | 1179 { |
1948 | 1180 int n, mark_offset = 0; |
1486
f83a51eaa5ed
Fix multiline output in /buffer save
Mikael Berthe <mikael@lilotux.net>
parents:
1485
diff
changeset
|
1181 guint prefixwidth; |
1483
e74cc83e7158
Refactor scr_UpdateWindow()
Mikael Berthe <mikael@lilotux.net>
parents:
1476
diff
changeset
|
1182 char pref[96]; |
184 | 1183 hbb_line **lines, *line; |
74 | 1184 GList *hbuf_head; |
1965
ec737f5f1d6f
Couple of readmark-related bugfixes
Mikael Berthe <mikael@lilotux.net>
parents:
1961
diff
changeset
|
1185 int color = COLOR_GENERAL; |
1948 | 1186 bool readmark = FALSE; |
1187 bool skipline = FALSE; | |
2098
c4a68361883f
Lock buffer automatically when scrolled up, unlock when at bottom ("buffer_smart_scrolling" setting)
Hermitifier
parents:
2090
diff
changeset
|
1188 int autolock; |
c4a68361883f
Lock buffer automatically when scrolled up, unlock when at bottom ("buffer_smart_scrolling" setting)
Hermitifier
parents:
2090
diff
changeset
|
1189 |
c4a68361883f
Lock buffer automatically when scrolled up, unlock when at bottom ("buffer_smart_scrolling" setting)
Hermitifier
parents:
2090
diff
changeset
|
1190 autolock = settings_opt_get_int("buffer_smart_scrolling"); |
74 | 1191 |
1487 | 1192 prefixwidth = scr_getprefixwidth(); |
1486
f83a51eaa5ed
Fix multiline output in /buffer save
Mikael Berthe <mikael@lilotux.net>
parents:
1485
diff
changeset
|
1193 prefixwidth = MIN(prefixwidth, sizeof pref); |
108 | 1194 |
1195 // Should the window be empty? | |
1157
5c857f0f0ab8
Moved all variables related to hbuf to an extra struct, bufdata
Frank Zschockelt
parents:
1156
diff
changeset
|
1196 if (win_entry->bd->cleared) { |
168 | 1197 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
|
1198 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
|
1199 scr_buffer_scroll_lock(0); |
108 | 1200 return; |
1201 } | |
1202 | |
1160
14f5876b5555
Slight optimization + line wrapping
Mikael Berthe <mikael@lilotux.net>
parents:
1159
diff
changeset
|
1203 // 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
|
1204 // we are displaying the last messages. |
105 | 1205 |
74 | 1206 // We will show the last CHAT_WIN_HEIGHT lines. |
1207 // Let's find out where it begins. | |
1160
14f5876b5555
Slight optimization + line wrapping
Mikael Berthe <mikael@lilotux.net>
parents:
1159
diff
changeset
|
1208 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
|
1209 win_entry->bd->top) == -1)) { |
105 | 1210 // 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
|
1211 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
|
1212 hbuf_head = win_entry->bd->hbuf; |
5c857f0f0ab8
Moved all variables related to hbuf to an extra struct, bufdata
Frank Zschockelt
parents:
1156
diff
changeset
|
1213 win_entry->bd->top = NULL; // (Just to make sure) |
105 | 1214 n = 0; |
1215 while (hbuf_head && (n < CHAT_WIN_HEIGHT-1) && g_list_previous(hbuf_head)) { | |
1216 hbuf_head = g_list_previous(hbuf_head); | |
1217 n++; | |
1218 } | |
873
ee39f6d94d43
Add /buffer {scroll_lock|scroll_unlock|toggle_scroll}
Mikael Berthe <mikael@lilotux.net>
parents:
866
diff
changeset
|
1219 // 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
|
1220 if (win_entry->bd->lock) |
5c857f0f0ab8
Moved all variables related to hbuf to an extra struct, bufdata
Frank Zschockelt
parents:
1156
diff
changeset
|
1221 win_entry->bd->top = hbuf_head; |
105 | 1222 } else |
1157
5c857f0f0ab8
Moved all variables related to hbuf to an extra struct, bufdata
Frank Zschockelt
parents:
1156
diff
changeset
|
1223 hbuf_head = win_entry->bd->top; |
74 | 1224 |
2098
c4a68361883f
Lock buffer automatically when scrolled up, unlock when at bottom ("buffer_smart_scrolling" setting)
Hermitifier
parents:
2090
diff
changeset
|
1225 // 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
|
1226 lines = hbuf_get_lines(hbuf_head, CHAT_WIN_HEIGHT+1); |
74 | 1227 |
1948 | 1228 if (CHAT_WIN_HEIGHT > 1) { |
1229 // Do we have a read mark? | |
1230 for (n = 0; n < CHAT_WIN_HEIGHT; n++) { | |
1231 line = *(lines+n); | |
1954
256cfc706ae5
Update readmark support
Mikael Berthe <mikael@lilotux.net>
parents:
1950
diff
changeset
|
1232 if (line) { |
256cfc706ae5
Update readmark support
Mikael Berthe <mikael@lilotux.net>
parents:
1950
diff
changeset
|
1233 if (line->flags & HBB_PREFIX_READMARK) { |
256cfc706ae5
Update readmark support
Mikael Berthe <mikael@lilotux.net>
parents:
1950
diff
changeset
|
1234 // 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
|
1235 if (n+1 < CHAT_WIN_HEIGHT && *(lines+n+1)) { |
256cfc706ae5
Update readmark support
Mikael Berthe <mikael@lilotux.net>
parents:
1950
diff
changeset
|
1236 readmark = TRUE; |
256cfc706ae5
Update readmark support
Mikael Berthe <mikael@lilotux.net>
parents:
1950
diff
changeset
|
1237 skipline = TRUE; |
256cfc706ae5
Update readmark support
Mikael Berthe <mikael@lilotux.net>
parents:
1950
diff
changeset
|
1238 mark_offset = -1; |
256cfc706ae5
Update readmark support
Mikael Berthe <mikael@lilotux.net>
parents:
1950
diff
changeset
|
1239 } |
256cfc706ae5
Update readmark support
Mikael Berthe <mikael@lilotux.net>
parents:
1950
diff
changeset
|
1240 } |
256cfc706ae5
Update readmark support
Mikael Berthe <mikael@lilotux.net>
parents:
1950
diff
changeset
|
1241 } else if (readmark) { |
256cfc706ae5
Update readmark support
Mikael Berthe <mikael@lilotux.net>
parents:
1950
diff
changeset
|
1242 // 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
|
1243 skipline = FALSE; |
256cfc706ae5
Update readmark support
Mikael Berthe <mikael@lilotux.net>
parents:
1950
diff
changeset
|
1244 mark_offset = 0; |
1948 | 1245 } |
1246 } | |
1247 } | |
1248 | |
1249 // Display the lines | |
1250 for (n = 0 ; n < CHAT_WIN_HEIGHT; n++) { | |
2090
16b04d64ec88
Add option to highlight timestamp added by server.
Hermitifier
parents:
2074
diff
changeset
|
1251 int timelen; |
1948 | 1252 int winy = n + mark_offset; |
1253 wmove(win_entry->win, winy, 0); | |
184 | 1254 line = *(lines+n); |
1255 if (line) { | |
1948 | 1256 if (skipline) |
1257 goto scr_update_window_skipline; | |
1258 | |
1204
e802ec0c02d2
Basic support for nick highlighting in MUC rooms (the whole line is colored)
Mikael Berthe <mikael@lilotux.net>
parents:
1190
diff
changeset
|
1259 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
|
1260 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
|
1261 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
|
1262 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
|
1263 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
|
1264 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
|
1265 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
|
1266 color = COLOR_MSGIN; |
9f64f548ac16
Better way of writing the nick
Michal 'vorner' Vaner <vorner@ucw.cz>
parents:
1290
diff
changeset
|
1267 else |
9f64f548ac16
Better way of writing the nick
Michal 'vorner' Vaner <vorner@ucw.cz>
parents:
1290
diff
changeset
|
1268 color = COLOR_GENERAL; |
9f64f548ac16
Better way of writing the nick
Michal 'vorner' Vaner <vorner@ucw.cz>
parents:
1290
diff
changeset
|
1269 |
9f64f548ac16
Better way of writing the nick
Michal 'vorner' Vaner <vorner@ucw.cz>
parents:
1290
diff
changeset
|
1270 if (color != COLOR_GENERAL) |
2328 | 1271 wbkgdset(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
|
1272 |
1483
e74cc83e7158
Refactor scr_UpdateWindow()
Mikael Berthe <mikael@lilotux.net>
parents:
1476
diff
changeset
|
1273 // Generate the prefix area and display it |
2090
16b04d64ec88
Add option to highlight timestamp added by server.
Hermitifier
parents:
2074
diff
changeset
|
1274 |
16b04d64ec88
Add option to highlight timestamp added by server.
Hermitifier
parents:
2074
diff
changeset
|
1275 timelen = scr_line_prefix(line, pref, prefixwidth); |
16b04d64ec88
Add option to highlight timestamp added by server.
Hermitifier
parents:
2074
diff
changeset
|
1276 if (timelen && line->flags & HBB_PREFIX_DELAYED) { |
16b04d64ec88
Add option to highlight timestamp added by server.
Hermitifier
parents:
2074
diff
changeset
|
1277 char tmp; |
16b04d64ec88
Add option to highlight timestamp added by server.
Hermitifier
parents:
2074
diff
changeset
|
1278 |
16b04d64ec88
Add option to highlight timestamp added by server.
Hermitifier
parents:
2074
diff
changeset
|
1279 tmp = pref[timelen]; |
16b04d64ec88
Add option to highlight timestamp added by server.
Hermitifier
parents:
2074
diff
changeset
|
1280 pref[timelen] = '\0'; |
2328 | 1281 wbkgdset(win_entry->win, get_color(COLOR_TIMESTAMP)); |
2090
16b04d64ec88
Add option to highlight timestamp added by server.
Hermitifier
parents:
2074
diff
changeset
|
1282 wprintw(win_entry->win, pref); |
16b04d64ec88
Add option to highlight timestamp added by server.
Hermitifier
parents:
2074
diff
changeset
|
1283 pref[timelen] = tmp; |
2328 | 1284 wbkgdset(win_entry->win, get_color(color)); |
2090
16b04d64ec88
Add option to highlight timestamp added by server.
Hermitifier
parents:
2074
diff
changeset
|
1285 wprintw(win_entry->win, pref+timelen); |
16b04d64ec88
Add option to highlight timestamp added by server.
Hermitifier
parents:
2074
diff
changeset
|
1286 } else |
16b04d64ec88
Add option to highlight timestamp added by server.
Hermitifier
parents:
2074
diff
changeset
|
1287 wprintw(win_entry->win, pref); |
729
39f67cade02c
Use bold font for outgoing messages
Mikael Berthe <mikael@lilotux.net>
parents:
728
diff
changeset
|
1288 |
1286
02ad6200df26
Add selectable time prefixes (vorner)
Mikael Berthe <mikael@lilotux.net>
parents:
1284
diff
changeset
|
1289 // Make sure we are at the right position |
1948 | 1290 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
|
1291 |
a0deb5124ebf
Check time_prefix value before using it
Mikael Berthe <mikael@lilotux.net>
parents:
1359
diff
changeset
|
1292 // The MUC nick - overwrite with proper color |
1294
86caabe72f3a
Color only incoming messages
Michal 'vorner' Vaner <vorner@ucw.cz>
parents:
1292
diff
changeset
|
1293 if (line->mucnicklen) { |
1476
77afd831f8f7
Avoid mixed declarations and code
Mikael Berthe <mikael@lilotux.net>
parents:
1457
diff
changeset
|
1294 char *mucjid; |
77afd831f8f7
Avoid mixed declarations and code
Mikael Berthe <mikael@lilotux.net>
parents:
1457
diff
changeset
|
1295 char tmp; |
2337 | 1296 nickcolor_t *actual = NULL; |
1297 muccol_t type, *typetmp; | |
1476
77afd831f8f7
Avoid mixed declarations and code
Mikael Berthe <mikael@lilotux.net>
parents:
1457
diff
changeset
|
1298 |
1376
a0deb5124ebf
Check time_prefix value before using it
Mikael Berthe <mikael@lilotux.net>
parents:
1359
diff
changeset
|
1299 // Store the char after the nick |
1476
77afd831f8f7
Avoid mixed declarations and code
Mikael Berthe <mikael@lilotux.net>
parents:
1457
diff
changeset
|
1300 tmp = line->text[line->mucnicklen]; |
77afd831f8f7
Avoid mixed declarations and code
Mikael Berthe <mikael@lilotux.net>
parents:
1457
diff
changeset
|
1301 type = glob_muccol; |
1376
a0deb5124ebf
Check time_prefix value before using it
Mikael Berthe <mikael@lilotux.net>
parents:
1359
diff
changeset
|
1302 // 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
|
1303 line->text[line->mucnicklen] = '\0'; |
1476
77afd831f8f7
Avoid mixed declarations and code
Mikael Berthe <mikael@lilotux.net>
parents:
1457
diff
changeset
|
1304 mucjid = g_utf8_strdown(CURRENT_JID, -1); |
1292
382ec54b584e
Muc nick coloring functionality
Michal 'vorner' Vaner <vorner@ucw.cz>
parents:
1291
diff
changeset
|
1305 if (muccolors) { |
382ec54b584e
Muc nick coloring functionality
Michal 'vorner' Vaner <vorner@ucw.cz>
parents:
1291
diff
changeset
|
1306 typetmp = g_hash_table_lookup(muccolors, mucjid); |
382ec54b584e
Muc nick coloring functionality
Michal 'vorner' Vaner <vorner@ucw.cz>
parents:
1291
diff
changeset
|
1307 if (typetmp) |
382ec54b584e
Muc nick coloring functionality
Michal 'vorner' Vaner <vorner@ucw.cz>
parents:
1291
diff
changeset
|
1308 type = *typetmp; |
382ec54b584e
Muc nick coloring functionality
Michal 'vorner' Vaner <vorner@ucw.cz>
parents:
1291
diff
changeset
|
1309 } |
382ec54b584e
Muc nick coloring functionality
Michal 'vorner' Vaner <vorner@ucw.cz>
parents:
1291
diff
changeset
|
1310 g_free(mucjid); |
1510
f6d4e20b9caa
MUC nickname colors depend on nicknames now
Maxim Vuets <maxim.vuets@gmail.com>
parents:
1505
diff
changeset
|
1311 // 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
|
1312 if ((type == MC_ALL) && (!nickcolors || |
382ec54b584e
Muc nick coloring functionality
Michal 'vorner' Vaner <vorner@ucw.cz>
parents:
1291
diff
changeset
|
1313 !g_hash_table_lookup(nickcolors, line->text))) { |
1476
77afd831f8f7
Avoid mixed declarations and code
Mikael Berthe <mikael@lilotux.net>
parents:
1457
diff
changeset
|
1314 char *snick, *mnick; |
2337 | 1315 nickcolor_t *nc; |
1510
f6d4e20b9caa
MUC nickname colors depend on nicknames now
Maxim Vuets <maxim.vuets@gmail.com>
parents:
1505
diff
changeset
|
1316 const char *p = line->text; |
f6d4e20b9caa
MUC nickname colors depend on nicknames now
Maxim Vuets <maxim.vuets@gmail.com>
parents:
1505
diff
changeset
|
1317 unsigned int nicksum = 0; |
1476
77afd831f8f7
Avoid mixed declarations and code
Mikael Berthe <mikael@lilotux.net>
parents:
1457
diff
changeset
|
1318 snick = g_strdup(line->text); |
77afd831f8f7
Avoid mixed declarations and code
Mikael Berthe <mikael@lilotux.net>
parents:
1457
diff
changeset
|
1319 mnick = g_strdup(line->text); |
2337 | 1320 nc = g_new(nickcolor_t, 1); |
1292
382ec54b584e
Muc nick coloring functionality
Michal 'vorner' Vaner <vorner@ucw.cz>
parents:
1291
diff
changeset
|
1321 ensure_string_htable(&nickcolors, NULL); |
1510
f6d4e20b9caa
MUC nickname colors depend on nicknames now
Maxim Vuets <maxim.vuets@gmail.com>
parents:
1505
diff
changeset
|
1322 while (*p) |
f6d4e20b9caa
MUC nickname colors depend on nicknames now
Maxim Vuets <maxim.vuets@gmail.com>
parents:
1505
diff
changeset
|
1323 nicksum += *p++; |
f6d4e20b9caa
MUC nickname colors depend on nicknames now
Maxim Vuets <maxim.vuets@gmail.com>
parents:
1505
diff
changeset
|
1324 nc->color = nickcols[nicksum % nickcolcount]; |
1381
40095d413da9
Fix compilation on OpenBSD
Mikael Berthe <mikael@lilotux.net>
parents:
1376
diff
changeset
|
1325 nc->manual = FALSE; |
1292
382ec54b584e
Muc nick coloring functionality
Michal 'vorner' Vaner <vorner@ucw.cz>
parents:
1291
diff
changeset
|
1326 *snick = '<'; |
382ec54b584e
Muc nick coloring functionality
Michal 'vorner' Vaner <vorner@ucw.cz>
parents:
1291
diff
changeset
|
1327 snick[strlen(snick)-1] = '>'; |
382ec54b584e
Muc nick coloring functionality
Michal 'vorner' Vaner <vorner@ucw.cz>
parents:
1291
diff
changeset
|
1328 *mnick = '*'; |
382ec54b584e
Muc nick coloring functionality
Michal 'vorner' Vaner <vorner@ucw.cz>
parents:
1291
diff
changeset
|
1329 mnick[strlen(mnick)-1] = ' '; |
1376
a0deb5124ebf
Check time_prefix value before using it
Mikael Berthe <mikael@lilotux.net>
parents:
1359
diff
changeset
|
1330 // Insert them |
1292
382ec54b584e
Muc nick coloring functionality
Michal 'vorner' Vaner <vorner@ucw.cz>
parents:
1291
diff
changeset
|
1331 g_hash_table_insert(nickcolors, snick, nc); |
382ec54b584e
Muc nick coloring functionality
Michal 'vorner' Vaner <vorner@ucw.cz>
parents:
1291
diff
changeset
|
1332 g_hash_table_insert(nickcolors, mnick, nc); |
382ec54b584e
Muc nick coloring functionality
Michal 'vorner' Vaner <vorner@ucw.cz>
parents:
1291
diff
changeset
|
1333 } |
382ec54b584e
Muc nick coloring functionality
Michal 'vorner' Vaner <vorner@ucw.cz>
parents:
1291
diff
changeset
|
1334 if (nickcolors) |
382ec54b584e
Muc nick coloring functionality
Michal 'vorner' Vaner <vorner@ucw.cz>
parents:
1291
diff
changeset
|
1335 actual = g_hash_table_lookup(nickcolors, line->text); |
1294
86caabe72f3a
Color only incoming messages
Michal 'vorner' Vaner <vorner@ucw.cz>
parents:
1292
diff
changeset
|
1336 if (actual && ((type == MC_ALL) || (actual->manual)) |
86caabe72f3a
Color only incoming messages
Michal 'vorner' Vaner <vorner@ucw.cz>
parents:
1292
diff
changeset
|
1337 && (line->flags & HBB_PREFIX_IN) && |
86caabe72f3a
Color only incoming messages
Michal 'vorner' Vaner <vorner@ucw.cz>
parents:
1292
diff
changeset
|
1338 (!(line->flags & HBB_PREFIX_HLIGHT_OUT))) |
2328 | 1339 wbkgdset(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
|
1340 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
|
1341 // Return the char |
1290
e42f48103609
Drawing the MUC nicks by a different color
Michal 'vorner' Vaner <vorner@ucw.cz>
parents:
1286
diff
changeset
|
1342 line->text[line->mucnicklen] = tmp; |
1376
a0deb5124ebf
Check time_prefix value before using it
Mikael Berthe <mikael@lilotux.net>
parents:
1359
diff
changeset
|
1343 // Return the color back |
2328 | 1344 wbkgdset(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
|
1345 } |
729
39f67cade02c
Use bold font for outgoing messages
Mikael Berthe <mikael@lilotux.net>
parents:
728
diff
changeset
|
1346 |
1333
e30a9d907105
Minor coding style adjustments
Mikael Berthe <mikael@lilotux.net>
parents:
1314
diff
changeset
|
1347 // Display text line |
e30a9d907105
Minor coding style adjustments
Mikael Berthe <mikael@lilotux.net>
parents:
1314
diff
changeset
|
1348 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
|
1349 wclrtoeol(win_entry->win); |
9f64f548ac16
Better way of writing the nick
Michal 'vorner' Vaner <vorner@ucw.cz>
parents:
1290
diff
changeset
|
1350 |
2328 | 1351 // Restore default ("general") color |
1352 if (color != COLOR_GENERAL) | |
1353 wbkgdset(win_entry->win, get_color(COLOR_GENERAL)); | |
1354 | |
1948 | 1355 scr_update_window_skipline: |
1356 skipline = FALSE; | |
1357 if (readmark && line->flags & HBB_PREFIX_READMARK) { | |
1358 int i, w; | |
1359 mark_offset++; | |
1360 | |
1361 // Display the mark | |
1362 winy = n + mark_offset; | |
1363 wmove(win_entry->win, winy, 0); | |
2328 | 1364 wbkgdset(win_entry->win, get_color(COLOR_READMARK)); |
1948 | 1365 g_snprintf(pref, prefixwidth, " == "); |
1366 wprintw(win_entry->win, pref); | |
1367 w = scr_gettextwidth() / 3; | |
1368 for (i=0; i<w; i++) | |
1369 wprintw(win_entry->win, "== "); | |
1370 wclrtoeol(win_entry->win); | |
2328 | 1371 wbkgdset(win_entry->win, get_color(COLOR_GENERAL)); |
1948 | 1372 } |
184 | 1373 g_free(line->text); |
898
c65b71dcda94
Fix memory leak in scr_UpdateWindow()
Mikael Berthe <mikael@lilotux.net>
parents:
897
diff
changeset
|
1374 g_free(line); |
168 | 1375 } else { |
1376 wclrtobot(win_entry->win); | |
1377 break; | |
75 | 1378 } |
74 | 1379 } |
2098
c4a68361883f
Lock buffer automatically when scrolled up, unlock when at bottom ("buffer_smart_scrolling" setting)
Hermitifier
parents:
2090
diff
changeset
|
1380 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
|
1381 if (line) { |
c4a68361883f
Lock buffer automatically when scrolled up, unlock when at bottom ("buffer_smart_scrolling" setting)
Hermitifier
parents:
2090
diff
changeset
|
1382 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
|
1383 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
|
1384 scr_buffer_readmark(TRUE); |
c4a68361883f
Lock buffer automatically when scrolled up, unlock when at bottom ("buffer_smart_scrolling" setting)
Hermitifier
parents:
2090
diff
changeset
|
1385 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
|
1386 } |
c4a68361883f
Lock buffer automatically when scrolled up, unlock when at bottom ("buffer_smart_scrolling" setting)
Hermitifier
parents:
2090
diff
changeset
|
1387 g_free(line->text); |
c4a68361883f
Lock buffer automatically when scrolled up, unlock when at bottom ("buffer_smart_scrolling" setting)
Hermitifier
parents:
2090
diff
changeset
|
1388 g_free(line); |
c4a68361883f
Lock buffer automatically when scrolled up, unlock when at bottom ("buffer_smart_scrolling" setting)
Hermitifier
parents:
2090
diff
changeset
|
1389 } 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
|
1390 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
|
1391 } |
c4a68361883f
Lock buffer automatically when scrolled up, unlock when at bottom ("buffer_smart_scrolling" setting)
Hermitifier
parents:
2090
diff
changeset
|
1392 |
74 | 1393 g_free(lines); |
1394 } | |
1159
53c0c5be43fa
Small fixes, typos and cleanups
Mikael Berthe <mikael@lilotux.net>
parents:
1157
diff
changeset
|
1395 |
2337 | 1396 static winbuf_t *scr_create_window(const char *winId, int special, int dont_show) |
1154 | 1397 { |
1398 if (special) { | |
1399 if (!statusWindow) { | |
1400 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
|
1401 statusWindow->bd->hbuf = statushbuf; |
1154 | 1402 } |
1403 return statusWindow; | |
1404 } else { | |
1405 return scr_new_buddy(winId, dont_show); | |
1406 } | |
1407 } | |
1408 | |
1780
e4378fbab5d7
Major API cleanup - bump API to 4
Mikael Berthe <mikael@lilotux.net>
parents:
1761
diff
changeset
|
1409 // scr_show_window() |
143 | 1410 // Display the chat window with the given identifier. |
849
42c43a88d823
Status buffer management
Mikael Berthe <mikael@lilotux.net>
parents:
848
diff
changeset
|
1411 // "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
|
1412 static void scr_show_window(const char *winId, int special) |
24 | 1413 { |
2337 | 1414 winbuf_t *win_entry; |
849
42c43a88d823
Status buffer management
Mikael Berthe <mikael@lilotux.net>
parents:
848
diff
changeset
|
1415 |
1780
e4378fbab5d7
Major API cleanup - bump API to 4
Mikael Berthe <mikael@lilotux.net>
parents:
1761
diff
changeset
|
1416 win_entry = scr_search_window(winId, special); |
74 | 1417 |
849
42c43a88d823
Status buffer management
Mikael Berthe <mikael@lilotux.net>
parents:
848
diff
changeset
|
1418 if (!win_entry) { |
1780
e4378fbab5d7
Major API cleanup - bump API to 4
Mikael Berthe <mikael@lilotux.net>
parents:
1761
diff
changeset
|
1419 win_entry = scr_create_window(winId, special, FALSE); |
849
42c43a88d823
Status buffer management
Mikael Berthe <mikael@lilotux.net>
parents:
848
diff
changeset
|
1420 } |
74 | 1421 |
180 | 1422 top_panel(win_entry->panel); |
1423 currentWindow = win_entry; | |
1424 chatmode = TRUE; | |
1157
5c857f0f0ab8
Moved all variables related to hbuf to an extra struct, bufdata
Frank Zschockelt
parents:
1156
diff
changeset
|
1425 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
|
1426 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
|
1427 if (!special) |
849
42c43a88d823
Status buffer management
Mikael Berthe <mikael@lilotux.net>
parents:
848
diff
changeset
|
1428 roster_setflags(winId, ROSTER_FLAG_LOCK, TRUE); |
2292
f181418db215
Replace global variable update_roster with scr_update_roster()
franky
parents:
2291
diff
changeset
|
1429 scr_update_roster(); |
74 | 1430 |
180 | 1431 // Refresh the window |
1780
e4378fbab5d7
Major API cleanup - bump API to 4
Mikael Berthe <mikael@lilotux.net>
parents:
1761
diff
changeset
|
1432 scr_update_window(win_entry); |
180 | 1433 |
1434 // Finished :) | |
1435 update_panels(); | |
142 | 1436 |
1437 top_panel(inputPanel); | |
24 | 1438 } |
1439 | |
1780
e4378fbab5d7
Major API cleanup - bump API to 4
Mikael Berthe <mikael@lilotux.net>
parents:
1761
diff
changeset
|
1440 // scr_show_buddy_window() |
143 | 1441 // 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
|
1442 void scr_show_buddy_window(void) |
24 | 1443 { |
1058 | 1444 const gchar *bjid; |
140 | 1445 |
2312
def5f64c253d
Rebuild the buddylist after disconnect/before buddylist search
franky
parents:
2311
diff
changeset
|
1446 buddylist_build(); |
849
42c43a88d823
Status buffer management
Mikael Berthe <mikael@lilotux.net>
parents:
848
diff
changeset
|
1447 if (!current_buddy) { |
1058 | 1448 bjid = NULL; |
849
42c43a88d823
Status buffer management
Mikael Berthe <mikael@lilotux.net>
parents:
848
diff
changeset
|
1449 } else { |
1058 | 1450 bjid = CURRENT_JID; |
849
42c43a88d823
Status buffer management
Mikael Berthe <mikael@lilotux.net>
parents:
848
diff
changeset
|
1451 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
|
1452 scr_show_window(buddy_getname(BUDDATA(current_buddy)), TRUE); |
849
42c43a88d823
Status buffer management
Mikael Berthe <mikael@lilotux.net>
parents:
848
diff
changeset
|
1453 return; |
42c43a88d823
Status buffer management
Mikael Berthe <mikael@lilotux.net>
parents:
848
diff
changeset
|
1454 } |
42c43a88d823
Status buffer management
Mikael Berthe <mikael@lilotux.net>
parents:
848
diff
changeset
|
1455 } |
140 | 1456 |
1058 | 1457 if (!bjid) { |
140 | 1458 top_panel(chatPanel); |
143 | 1459 top_panel(inputPanel); |
140 | 1460 currentWindow = NULL; |
105 | 1461 return; |
140 | 1462 } |
1463 | |
2324
4ddd6f5c3ffc
Add support for displaying the number of unread messages for each roster entry
Michał Kępień <bitbucket@kempniu.pl>
parents:
2313
diff
changeset
|
1464 roster_msg_update_unread(bjid, FALSE); |
1780
e4378fbab5d7
Major API cleanup - bump API to 4
Mikael Berthe <mikael@lilotux.net>
parents:
1761
diff
changeset
|
1465 scr_show_window(bjid, FALSE); |
24 | 1466 } |
1467 | |
1780
e4378fbab5d7
Major API cleanup - bump API to 4
Mikael Berthe <mikael@lilotux.net>
parents:
1761
diff
changeset
|
1468 // scr_update_buddy_window() |
865
cee8d6be04e1
Improve changeset a3db3ee8b99e, do not enable chatmode when refreshing
Mikael Berthe <mikael@lilotux.net>
parents:
858
diff
changeset
|
1469 // (Re)Display the current window. |
1780
e4378fbab5d7
Major API cleanup - bump API to 4
Mikael Berthe <mikael@lilotux.net>
parents:
1761
diff
changeset
|
1470 // 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
|
1471 // else display the chat window. |
2338 | 1472 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
|
1473 { |
cee8d6be04e1
Improve changeset a3db3ee8b99e, do not enable chatmode when refreshing
Mikael Berthe <mikael@lilotux.net>
parents:
858
diff
changeset
|
1474 if (chatmode) { |
1780
e4378fbab5d7
Major API cleanup - bump API to 4
Mikael Berthe <mikael@lilotux.net>
parents:
1761
diff
changeset
|
1475 scr_show_buddy_window(); |
865
cee8d6be04e1
Improve changeset a3db3ee8b99e, do not enable chatmode when refreshing
Mikael Berthe <mikael@lilotux.net>
parents:
858
diff
changeset
|
1476 return; |
cee8d6be04e1
Improve changeset a3db3ee8b99e, do not enable chatmode when refreshing
Mikael Berthe <mikael@lilotux.net>
parents:
858
diff
changeset
|
1477 } |
cee8d6be04e1
Improve changeset a3db3ee8b99e, do not enable chatmode when refreshing
Mikael Berthe <mikael@lilotux.net>
parents:
858
diff
changeset
|
1478 |
cee8d6be04e1
Improve changeset a3db3ee8b99e, do not enable chatmode when refreshing
Mikael Berthe <mikael@lilotux.net>
parents:
858
diff
changeset
|
1479 top_panel(chatPanel); |
cee8d6be04e1
Improve changeset a3db3ee8b99e, do not enable chatmode when refreshing
Mikael Berthe <mikael@lilotux.net>
parents:
858
diff
changeset
|
1480 top_panel(inputPanel); |
cee8d6be04e1
Improve changeset a3db3ee8b99e, do not enable chatmode when refreshing
Mikael Berthe <mikael@lilotux.net>
parents:
858
diff
changeset
|
1481 } |
cee8d6be04e1
Improve changeset a3db3ee8b99e, do not enable chatmode when refreshing
Mikael Berthe <mikael@lilotux.net>
parents:
858
diff
changeset
|
1482 |
1780
e4378fbab5d7
Major API cleanup - bump API to 4
Mikael Berthe <mikael@lilotux.net>
parents:
1761
diff
changeset
|
1483 // scr_write_in_window() |
143 | 1484 // 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
|
1485 // Use winId == NULL for the special status buffer. |
143 | 1486 // Lines are splitted when they are too long to fit in the chat window. |
1487 // 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
|
1488 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
|
1489 time_t timestamp, unsigned int prefix_flags, |
e4378fbab5d7
Major API cleanup - bump API to 4
Mikael Berthe <mikael@lilotux.net>
parents:
1761
diff
changeset
|
1490 int force_show, unsigned mucnicklen, |
e4378fbab5d7
Major API cleanup - bump API to 4
Mikael Berthe <mikael@lilotux.net>
parents:
1761
diff
changeset
|
1491 gpointer xep184) |
24 | 1492 { |
2337 | 1493 winbuf_t *win_entry; |
772
464be13343a9
Store most data in UTF-8 internally
Mikael Berthe <mikael@lilotux.net>
parents:
771
diff
changeset
|
1494 char *text_locale; |
24 | 1495 int dont_show = FALSE; |
849
42c43a88d823
Status buffer management
Mikael Berthe <mikael@lilotux.net>
parents:
848
diff
changeset
|
1496 int special; |
1142
0e27177882c7
Small fix for the max_history_blocks option
Mikael Berthe <mikael@lilotux.net>
parents:
1141
diff
changeset
|
1497 guint num_history_blocks; |
873
ee39f6d94d43
Add /buffer {scroll_lock|scroll_unlock|toggle_scroll}
Mikael Berthe <mikael@lilotux.net>
parents:
866
diff
changeset
|
1498 bool setmsgflg = FALSE; |
2190
ee3a40ffcd8b
New option: 'clear_unread_on_carbon'
Holger Weiß <holger@zedat.fu-berlin.de>
parents:
2181
diff
changeset
|
1499 bool clearmsgflg = FALSE; |
1296
7a0eaa53bd53
Further nick colors fixes
Michal 'vorner' Vaner <vorner@ucw.cz>
parents:
1295
diff
changeset
|
1500 char *nicktmp, *nicklocaltmp; |
24 | 1501 |
74 | 1502 // Look for the window entry. |
849
42c43a88d823
Status buffer management
Mikael Berthe <mikael@lilotux.net>
parents:
848
diff
changeset
|
1503 special = (winId == NULL); |
1780
e4378fbab5d7
Major API cleanup - bump API to 4
Mikael Berthe <mikael@lilotux.net>
parents:
1761
diff
changeset
|
1504 win_entry = scr_search_window(winId, special); |
74 | 1505 |
1506 // Do we have to really show the window? | |
24 | 1507 if (!chatmode) |
1508 dont_show = TRUE; | |
74 | 1509 else if ((!force_show) && ((!currentWindow || (currentWindow != win_entry)))) |
24 | 1510 dont_show = TRUE; |
1511 | |
74 | 1512 // 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
|
1513 if (!win_entry) { |
1780
e4378fbab5d7
Major API cleanup - bump API to 4
Mikael Berthe <mikael@lilotux.net>
parents:
1761
diff
changeset
|
1514 win_entry = scr_create_window(winId, special, dont_show); |
24 | 1515 } |
1516 | |
220 | 1517 // 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
|
1518 if (win_entry->bd->cleared) |
5c857f0f0ab8
Moved all variables related to hbuf to an extra struct, bufdata
Frank Zschockelt
parents:
1156
diff
changeset
|
1519 win_entry->bd->top = g_list_last(win_entry->bd->hbuf); |
220 | 1520 |
1142
0e27177882c7
Small fix for the max_history_blocks option
Mikael Berthe <mikael@lilotux.net>
parents:
1141
diff
changeset
|
1521 // 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
|
1522 // top is set. |
1157
5c857f0f0ab8
Moved all variables related to hbuf to an extra struct, bufdata
Frank Zschockelt
parents:
1156
diff
changeset
|
1523 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
|
1524 num_history_blocks = 0U; |
0e27177882c7
Small fix for the max_history_blocks option
Mikael Berthe <mikael@lilotux.net>
parents:
1141
diff
changeset
|
1525 else |
0e27177882c7
Small fix for the max_history_blocks option
Mikael Berthe <mikael@lilotux.net>
parents:
1141
diff
changeset
|
1526 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
|
1527 |
772
464be13343a9
Store most data in UTF-8 internally
Mikael Berthe <mikael@lilotux.net>
parents:
771
diff
changeset
|
1528 text_locale = from_utf8(text); |
1729
e6e89b1d7831
Minor style and header updates
Mikael Berthe <mikael@lilotux.net>
parents:
1710
diff
changeset
|
1529 // Convert the nick alone and compute its length |
1296
7a0eaa53bd53
Further nick colors fixes
Michal 'vorner' Vaner <vorner@ucw.cz>
parents:
1295
diff
changeset
|
1530 if (mucnicklen) { |
7a0eaa53bd53
Further nick colors fixes
Michal 'vorner' Vaner <vorner@ucw.cz>
parents:
1295
diff
changeset
|
1531 nicktmp = g_strndup(text, mucnicklen); |
7a0eaa53bd53
Further nick colors fixes
Michal 'vorner' Vaner <vorner@ucw.cz>
parents:
1295
diff
changeset
|
1532 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
|
1533 if (nicklocaltmp) |
0fa6df17bc5c
Fix potential issue pointed out by franky's clang report
Mikael Berthe <mikael@lilotux.net>
parents:
1915
diff
changeset
|
1534 mucnicklen = strlen(nicklocaltmp); |
1296
7a0eaa53bd53
Further nick colors fixes
Michal 'vorner' Vaner <vorner@ucw.cz>
parents:
1295
diff
changeset
|
1535 g_free(nicklocaltmp); |
7a0eaa53bd53
Further nick colors fixes
Michal 'vorner' Vaner <vorner@ucw.cz>
parents:
1295
diff
changeset
|
1536 g_free(nicktmp); |
7a0eaa53bd53
Further nick colors fixes
Michal 'vorner' Vaner <vorner@ucw.cz>
parents:
1295
diff
changeset
|
1537 } |
1157
5c857f0f0ab8
Moved all variables related to hbuf to an extra struct, bufdata
Frank Zschockelt
parents:
1156
diff
changeset
|
1538 hbuf_add_line(&win_entry->bd->hbuf, text_locale, timestamp, prefix_flags, |
2325
c5665d3191aa
Prevent assigning negative values to unsigned variables
Michał Kępień <bitbucket@kempniu.pl>
parents:
2324
diff
changeset
|
1539 scr_gettextwidth(), num_history_blocks, mucnicklen, xep184); |
772
464be13343a9
Store most data in UTF-8 internally
Mikael Berthe <mikael@lilotux.net>
parents:
771
diff
changeset
|
1540 g_free(text_locale); |
74 | 1541 |
1157
5c857f0f0ab8
Moved all variables related to hbuf to an extra struct, bufdata
Frank Zschockelt
parents:
1156
diff
changeset
|
1542 if (win_entry->bd->cleared) { |
5c857f0f0ab8
Moved all variables related to hbuf to an extra struct, bufdata
Frank Zschockelt
parents:
1156
diff
changeset
|
1543 win_entry->bd->cleared = FALSE; |
5c857f0f0ab8
Moved all variables related to hbuf to an extra struct, bufdata
Frank Zschockelt
parents:
1156
diff
changeset
|
1544 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
|
1545 win_entry->bd->top = g_list_next(win_entry->bd->top); |
220 | 1546 } |
1547 | |
1548 // 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
|
1549 if (!win_entry->bd->lock && win_entry->bd->top) { |
220 | 1550 int dist; |
1157
5c857f0f0ab8
Moved all variables related to hbuf to an extra struct, bufdata
Frank Zschockelt
parents:
1156
diff
changeset
|
1551 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
|
1552 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
|
1553 g_list_position(first, win_entry->bd->top); |
220 | 1554 if (dist >= CHAT_WIN_HEIGHT) |
1157
5c857f0f0ab8
Moved all variables related to hbuf to an extra struct, bufdata
Frank Zschockelt
parents:
1156
diff
changeset
|
1555 win_entry->bd->top = NULL; |
108 | 1556 } |
1557 | |
24 | 1558 if (!dont_show) { |
1157
5c857f0f0ab8
Moved all variables related to hbuf to an extra struct, bufdata
Frank Zschockelt
parents:
1156
diff
changeset
|
1559 if (win_entry->bd->lock) |
873
ee39f6d94d43
Add /buffer {scroll_lock|scroll_unlock|toggle_scroll}
Mikael Berthe <mikael@lilotux.net>
parents:
866
diff
changeset
|
1560 setmsgflg = TRUE; |
1955
fad27c72a229
Don't update readmark when buffer scroll_lock is set
Mikael Berthe <mikael@lilotux.net>
parents:
1954
diff
changeset
|
1561 else |
1961
39021fd6b0e1
Try to improve readmarks in some cases
Mikael Berthe <mikael@lilotux.net>
parents:
1960
diff
changeset
|
1562 // 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
|
1563 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
|
1564 hbuf_set_readmark(win_entry->bd->hbuf, FALSE); |
74 | 1565 // Show and refresh the window |
1566 top_panel(win_entry->panel); | |
1780
e4378fbab5d7
Major API cleanup - bump API to 4
Mikael Berthe <mikael@lilotux.net>
parents:
1761
diff
changeset
|
1567 scr_update_window(win_entry); |
142 | 1568 top_panel(inputPanel); |
24 | 1569 update_panels(); |
2190
ee3a40ffcd8b
New option: 'clear_unread_on_carbon'
Holger Weiß <holger@zedat.fu-berlin.de>
parents:
2181
diff
changeset
|
1570 } 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
|
1571 prefix_flags & HBB_PREFIX_OUT && |
ee3a40ffcd8b
New option: 'clear_unread_on_carbon'
Holger Weiß <holger@zedat.fu-berlin.de>
parents:
2181
diff
changeset
|
1572 prefix_flags & HBB_PREFIX_CARBON) { |
ee3a40ffcd8b
New option: 'clear_unread_on_carbon'
Holger Weiß <holger@zedat.fu-berlin.de>
parents:
2181
diff
changeset
|
1573 clearmsgflg = TRUE; |
873
ee39f6d94d43
Add /buffer {scroll_lock|scroll_unlock|toggle_scroll}
Mikael Berthe <mikael@lilotux.net>
parents:
866
diff
changeset
|
1574 } 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
|
1575 setmsgflg = TRUE; |
ee39f6d94d43
Add /buffer {scroll_lock|scroll_unlock|toggle_scroll}
Mikael Berthe <mikael@lilotux.net>
parents:
866
diff
changeset
|
1576 } |
2190
ee3a40ffcd8b
New option: 'clear_unread_on_carbon'
Holger Weiß <holger@zedat.fu-berlin.de>
parents:
2181
diff
changeset
|
1577 if (!special) { |
ee3a40ffcd8b
New option: 'clear_unread_on_carbon'
Holger Weiß <holger@zedat.fu-berlin.de>
parents:
2181
diff
changeset
|
1578 if (clearmsgflg) { |
2324
4ddd6f5c3ffc
Add support for displaying the number of unread messages for each roster entry
Michał Kępień <bitbucket@kempniu.pl>
parents:
2313
diff
changeset
|
1579 roster_msg_update_unread(winId, FALSE); |
2190
ee3a40ffcd8b
New option: 'clear_unread_on_carbon'
Holger Weiß <holger@zedat.fu-berlin.de>
parents:
2181
diff
changeset
|
1580 roster_msg_setflag(winId, FALSE, FALSE); |
2292
f181418db215
Replace global variable update_roster with scr_update_roster()
franky
parents:
2291
diff
changeset
|
1581 scr_update_roster(); |
2190
ee3a40ffcd8b
New option: 'clear_unread_on_carbon'
Holger Weiß <holger@zedat.fu-berlin.de>
parents:
2181
diff
changeset
|
1582 } else if (setmsgflg) { |
2324
4ddd6f5c3ffc
Add support for displaying the number of unread messages for each roster entry
Michał Kępień <bitbucket@kempniu.pl>
parents:
2313
diff
changeset
|
1583 roster_msg_update_unread(winId, TRUE); |
2190
ee3a40ffcd8b
New option: 'clear_unread_on_carbon'
Holger Weiß <holger@zedat.fu-berlin.de>
parents:
2181
diff
changeset
|
1584 roster_msg_setflag(winId, FALSE, TRUE); |
2292
f181418db215
Replace global variable update_roster with scr_update_roster()
franky
parents:
2291
diff
changeset
|
1585 scr_update_roster(); |
2190
ee3a40ffcd8b
New option: 'clear_unread_on_carbon'
Holger Weiß <holger@zedat.fu-berlin.de>
parents:
2181
diff
changeset
|
1586 } |
24 | 1587 } |
1588 } | |
1589 | |
2101
f56c214a19dc
Add a guard for 'attention_char'
Mikael Berthe <mikael@lilotux.net>
parents:
2100
diff
changeset
|
1590 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
|
1591 { |
2292
f181418db215
Replace global variable update_roster with scr_update_roster()
franky
parents:
2291
diff
changeset
|
1592 scr_update_roster(); |
2101
f56c214a19dc
Add a guard for 'attention_char'
Mikael Berthe <mikael@lilotux.net>
parents:
2100
diff
changeset
|
1593 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
|
1594 guint sign; |
f56c214a19dc
Add a guard for 'attention_char'
Mikael Berthe <mikael@lilotux.net>
parents:
2100
diff
changeset
|
1595 char *c; |
f56c214a19dc
Add a guard for 'attention_char'
Mikael Berthe <mikael@lilotux.net>
parents:
2100
diff
changeset
|
1596 if (!new_value || !*new_value) |
f56c214a19dc
Add a guard for 'attention_char'
Mikael Berthe <mikael@lilotux.net>
parents:
2100
diff
changeset
|
1597 return NULL; |
f56c214a19dc
Add a guard for 'attention_char'
Mikael Berthe <mikael@lilotux.net>
parents:
2100
diff
changeset
|
1598 sign = get_char(new_value); |
f56c214a19dc
Add a guard for 'attention_char'
Mikael Berthe <mikael@lilotux.net>
parents:
2100
diff
changeset
|
1599 c = next_char((char*)new_value); |
f56c214a19dc
Add a guard for 'attention_char'
Mikael Berthe <mikael@lilotux.net>
parents:
2100
diff
changeset
|
1600 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
|
1601 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
|
1602 return NULL; |
f56c214a19dc
Add a guard for 'attention_char'
Mikael Berthe <mikael@lilotux.net>
parents:
2100
diff
changeset
|
1603 } |
f56c214a19dc
Add a guard for 'attention_char'
Mikael Berthe <mikael@lilotux.net>
parents:
2100
diff
changeset
|
1604 // 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
|
1605 return g_strdup(new_value); |
f56c214a19dc
Add a guard for 'attention_char'
Mikael Berthe <mikael@lilotux.net>
parents:
2100
diff
changeset
|
1606 } |
f56c214a19dc
Add a guard for 'attention_char'
Mikael Berthe <mikael@lilotux.net>
parents:
2100
diff
changeset
|
1607 return g_strdup(new_value); |
f56c214a19dc
Add a guard for 'attention_char'
Mikael Berthe <mikael@lilotux.net>
parents:
2100
diff
changeset
|
1608 } |
f56c214a19dc
Add a guard for 'attention_char'
Mikael Berthe <mikael@lilotux.net>
parents:
2100
diff
changeset
|
1609 |
f56c214a19dc
Add a guard for 'attention_char'
Mikael Berthe <mikael@lilotux.net>
parents:
2100
diff
changeset
|
1610 // scr_init_settings() |
f56c214a19dc
Add a guard for 'attention_char'
Mikael Berthe <mikael@lilotux.net>
parents:
2100
diff
changeset
|
1611 // Create guards for UI settings |
f56c214a19dc
Add a guard for 'attention_char'
Mikael Berthe <mikael@lilotux.net>
parents:
2100
diff
changeset
|
1612 void scr_init_settings(void) |
f56c214a19dc
Add a guard for 'attention_char'
Mikael Berthe <mikael@lilotux.net>
parents:
2100
diff
changeset
|
1613 { |
f56c214a19dc
Add a guard for 'attention_char'
Mikael Berthe <mikael@lilotux.net>
parents:
2100
diff
changeset
|
1614 settings_set_guard("attention_char", attention_sign_guard); |
f56c214a19dc
Add a guard for 'attention_char'
Mikael Berthe <mikael@lilotux.net>
parents:
2100
diff
changeset
|
1615 } |
f56c214a19dc
Add a guard for 'attention_char'
Mikael Berthe <mikael@lilotux.net>
parents:
2100
diff
changeset
|
1616 |
2100
113d3b96ae3e
Add option 'attention_char'
Mikael Berthe <mikael@lilotux.net>
parents:
2098
diff
changeset
|
1617 static unsigned int attention_sign(void) |
113d3b96ae3e
Add option 'attention_char'
Mikael Berthe <mikael@lilotux.net>
parents:
2098
diff
changeset
|
1618 { |
113d3b96ae3e
Add option 'attention_char'
Mikael Berthe <mikael@lilotux.net>
parents:
2098
diff
changeset
|
1619 const char *as = settings_opt_get("attention_char"); |
113d3b96ae3e
Add option 'attention_char'
Mikael Berthe <mikael@lilotux.net>
parents:
2098
diff
changeset
|
1620 if (!as) |
113d3b96ae3e
Add option 'attention_char'
Mikael Berthe <mikael@lilotux.net>
parents:
2098
diff
changeset
|
1621 return DEFAULT_ATTENTION_CHAR; |
2101
f56c214a19dc
Add a guard for 'attention_char'
Mikael Berthe <mikael@lilotux.net>
parents:
2100
diff
changeset
|
1622 return get_char(as); |
2100
113d3b96ae3e
Add option 'attention_char'
Mikael Berthe <mikael@lilotux.net>
parents:
2098
diff
changeset
|
1623 } |
113d3b96ae3e
Add option 'attention_char'
Mikael Berthe <mikael@lilotux.net>
parents:
2098
diff
changeset
|
1624 |
1780
e4378fbab5d7
Major API cleanup - bump API to 4
Mikael Berthe <mikael@lilotux.net>
parents:
1761
diff
changeset
|
1625 // scr_update_main_status(forceupdate) |
713 | 1626 // Redraw the main (bottom) status line. |
1780
e4378fbab5d7
Major API cleanup - bump API to 4
Mikael Berthe <mikael@lilotux.net>
parents:
1761
diff
changeset
|
1627 // 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
|
1628 // 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
|
1629 void scr_update_main_status(int forceupdate) |
713 | 1630 { |
1598 | 1631 char *sm = from_utf8(xmpp_getstatusmsg()); |
1514 | 1632 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
|
1633 guint prio = 0; |
1d8f9135e000
Use smarter message flag in the main status line
Mikael Berthe <mikael@lilotux.net>
parents:
1974
diff
changeset
|
1634 gpointer unread_ptr; |
2100
113d3b96ae3e
Add option 'attention_char'
Mikael Berthe <mikael@lilotux.net>
parents:
2098
diff
changeset
|
1635 guint unreadchar; |
1977
1d8f9135e000
Use smarter message flag in the main status line
Mikael Berthe <mikael@lilotux.net>
parents:
1974
diff
changeset
|
1636 |
1d8f9135e000
Use smarter message flag in the main status line
Mikael Berthe <mikael@lilotux.net>
parents:
1974
diff
changeset
|
1637 unread_ptr = unread_msg(NULL); |
1d8f9135e000
Use smarter message flag in the main status line
Mikael Berthe <mikael@lilotux.net>
parents:
1974
diff
changeset
|
1638 if (unread_ptr) { |
1d8f9135e000
Use smarter message flag in the main status line
Mikael Berthe <mikael@lilotux.net>
parents:
1974
diff
changeset
|
1639 prio = buddy_getuiprio(unread_ptr); |
1d8f9135e000
Use smarter message flag in the main status line
Mikael Berthe <mikael@lilotux.net>
parents:
1974
diff
changeset
|
1640 // 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
|
1641 // priority is 1. |
1d8f9135e000
Use smarter message flag in the main status line
Mikael Berthe <mikael@lilotux.net>
parents:
1974
diff
changeset
|
1642 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
|
1643 prio = 1; |
1d8f9135e000
Use smarter message flag in the main status line
Mikael Berthe <mikael@lilotux.net>
parents:
1974
diff
changeset
|
1644 } |
1d8f9135e000
Use smarter message flag in the main status line
Mikael Berthe <mikael@lilotux.net>
parents:
1974
diff
changeset
|
1645 |
1d8f9135e000
Use smarter message flag in the main status line
Mikael Berthe <mikael@lilotux.net>
parents:
1974
diff
changeset
|
1646 // Status bar unread message flag |
1d8f9135e000
Use smarter message flag in the main status line
Mikael Berthe <mikael@lilotux.net>
parents:
1974
diff
changeset
|
1647 if (prio >= ROSTER_UI_PRIO_MUC_HL_MESSAGE) |
2100
113d3b96ae3e
Add option 'attention_char'
Mikael Berthe <mikael@lilotux.net>
parents:
2098
diff
changeset
|
1648 unreadchar = attention_sign(); |
1977
1d8f9135e000
Use smarter message flag in the main status line
Mikael Berthe <mikael@lilotux.net>
parents:
1974
diff
changeset
|
1649 else if (prio > 0) |
1d8f9135e000
Use smarter message flag in the main status line
Mikael Berthe <mikael@lilotux.net>
parents:
1974
diff
changeset
|
1650 unreadchar = '#'; |
1d8f9135e000
Use smarter message flag in the main status line
Mikael Berthe <mikael@lilotux.net>
parents:
1974
diff
changeset
|
1651 else |
1d8f9135e000
Use smarter message flag in the main status line
Mikael Berthe <mikael@lilotux.net>
parents:
1974
diff
changeset
|
1652 unreadchar = ' '; |
713 | 1653 |
1654 werase(mainstatusWnd); | |
1515 | 1655 if (info) { |
1519 | 1656 char *info_locale = from_utf8(info); |
2100
113d3b96ae3e
Add option 'attention_char'
Mikael Berthe <mikael@lilotux.net>
parents:
2098
diff
changeset
|
1657 mvwprintw(mainstatusWnd, 0, 0, "%lc[%c] %s %s", unreadchar, |
1598 | 1658 imstatus2char[xmpp_getstatus()], |
1519 | 1659 info_locale, (sm ? sm : "")); |
1660 g_free(info_locale); | |
1515 | 1661 } else |
2100
113d3b96ae3e
Add option 'attention_char'
Mikael Berthe <mikael@lilotux.net>
parents:
2098
diff
changeset
|
1662 mvwprintw(mainstatusWnd, 0, 0, "%lc[%c] %s", unreadchar, |
1598 | 1663 imstatus2char[xmpp_getstatus()], (sm ? sm : "")); |
724
264375fe7159
Fix a roster refresh issue
Mikael Berthe <mikael@lilotux.net>
parents:
723
diff
changeset
|
1664 if (forceupdate) { |
264375fe7159
Fix a roster refresh issue
Mikael Berthe <mikael@lilotux.net>
parents:
723
diff
changeset
|
1665 top_panel(inputPanel); |
264375fe7159
Fix a roster refresh issue
Mikael Berthe <mikael@lilotux.net>
parents:
723
diff
changeset
|
1666 update_panels(); |
264375fe7159
Fix a roster refresh issue
Mikael Berthe <mikael@lilotux.net>
parents:
723
diff
changeset
|
1667 } |
773
e25b8a348ebd
Screen updating functions use UTF-8
Mikael Berthe <mikael@lilotux.net>
parents:
772
diff
changeset
|
1668 g_free(sm); |
713 | 1669 } |
1670 | |
1780
e4378fbab5d7
Major API cleanup - bump API to 4
Mikael Berthe <mikael@lilotux.net>
parents:
1761
diff
changeset
|
1671 // scr_draw_main_window() |
157 | 1672 // Set fullinit to TRUE to also create panels. Set it to FALSE for a resize. |
151 | 1673 // |
1674 // I think it could be improved a _lot_ but I'm really not an ncurses | |
1675 // expert... :-\ Mikael. | |
1676 // | |
1780
e4378fbab5d7
Major API cleanup - bump API to 4
Mikael Berthe <mikael@lilotux.net>
parents:
1761
diff
changeset
|
1677 void scr_draw_main_window(unsigned int fullinit) |
24 | 1678 { |
701
6c100adfbfb6
Add setting "roster_width" (variable buddylist width)
Mikael Berthe <mikael@lilotux.net>
parents:
699
diff
changeset
|
1679 int requested_size; |
961
95659cf9ea1a
Display mcabber version in the status window
Mikael Berthe <mikael@lilotux.net>
parents:
952
diff
changeset
|
1680 gchar *ver, *message; |
972
11b632d824f6
Add option 'log_win_on_top'
Mikael Berthe <mikael@lilotux.net>
parents:
967
diff
changeset
|
1681 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
|
1682 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
|
1683 |
2009
a859ed648638
Replace the option « no_space_before_items » with « roster_no_leading_space ».
Simon Jacquin <simon@jacquin.me>
parents:
2008
diff
changeset
|
1684 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
|
1685 |
2343 | 1686 if (NULL == settings_opt_get("log_win_height")) |
1687 requested_size = DEFAULT_LOG_WIN_HEIGHT; | |
1688 else | |
1689 requested_size = settings_opt_get_int("log_win_height"); | |
701
6c100adfbfb6
Add setting "roster_width" (variable buddylist width)
Mikael Berthe <mikael@lilotux.net>
parents:
699
diff
changeset
|
1690 if (requested_size > 0) { |
6c100adfbfb6
Add setting "roster_width" (variable buddylist width)
Mikael Berthe <mikael@lilotux.net>
parents:
699
diff
changeset
|
1691 if (maxY > requested_size + 3) |
2342 | 1692 Log_Win_Height = requested_size; |
518
9480a76471b6
Update Log_Win_Height when refreshing the screen
Mikael Berthe <mikael@lilotux.net>
parents:
515
diff
changeset
|
1693 else |
2342 | 1694 Log_Win_Height = ((maxY > 5) ? (maxY - 4) : 1); |
2343 | 1695 } else if (requested_size <= 0) { |
1696 Log_Win_Height = 0; | |
518
9480a76471b6
Update Log_Win_Height when refreshing the screen
Mikael Berthe <mikael@lilotux.net>
parents:
515
diff
changeset
|
1697 } |
9480a76471b6
Update Log_Win_Height when refreshing the screen
Mikael Berthe <mikael@lilotux.net>
parents:
515
diff
changeset
|
1698 |
2342 | 1699 if (maxY < Log_Win_Height+4) { |
518
9480a76471b6
Update Log_Win_Height when refreshing the screen
Mikael Berthe <mikael@lilotux.net>
parents:
515
diff
changeset
|
1700 if (maxY < 5) { |
2342 | 1701 Log_Win_Height = 1; |
1702 maxY = 5; | |
518
9480a76471b6
Update Log_Win_Height when refreshing the screen
Mikael Berthe <mikael@lilotux.net>
parents:
515
diff
changeset
|
1703 } else { |
2342 | 1704 Log_Win_Height = maxY - 4; |
518
9480a76471b6
Update Log_Win_Height when refreshing the screen
Mikael Berthe <mikael@lilotux.net>
parents:
515
diff
changeset
|
1705 } |
9480a76471b6
Update Log_Win_Height when refreshing the screen
Mikael Berthe <mikael@lilotux.net>
parents:
515
diff
changeset
|
1706 } |
9480a76471b6
Update Log_Win_Height when refreshing the screen
Mikael Berthe <mikael@lilotux.net>
parents:
515
diff
changeset
|
1707 |
707
b26a0bde4cdb
Add /roster hide|show|toggle
Mikael Berthe <mikael@lilotux.net>
parents:
701
diff
changeset
|
1708 if (roster_hidden) { |
b26a0bde4cdb
Add /roster hide|show|toggle
Mikael Berthe <mikael@lilotux.net>
parents:
701
diff
changeset
|
1709 Roster_Width = 0; |
b26a0bde4cdb
Add /roster hide|show|toggle
Mikael Berthe <mikael@lilotux.net>
parents:
701
diff
changeset
|
1710 } else { |
b26a0bde4cdb
Add /roster hide|show|toggle
Mikael Berthe <mikael@lilotux.net>
parents:
701
diff
changeset
|
1711 requested_size = settings_opt_get_int("roster_width"); |
b26a0bde4cdb
Add /roster hide|show|toggle
Mikael Berthe <mikael@lilotux.net>
parents:
701
diff
changeset
|
1712 if (requested_size > 1) |
b26a0bde4cdb
Add /roster hide|show|toggle
Mikael Berthe <mikael@lilotux.net>
parents:
701
diff
changeset
|
1713 Roster_Width = requested_size; |
b26a0bde4cdb
Add /roster hide|show|toggle
Mikael Berthe <mikael@lilotux.net>
parents:
701
diff
changeset
|
1714 else if (requested_size == 1) |
b26a0bde4cdb
Add /roster hide|show|toggle
Mikael Berthe <mikael@lilotux.net>
parents:
701
diff
changeset
|
1715 Roster_Width = 2; |
b26a0bde4cdb
Add /roster hide|show|toggle
Mikael Berthe <mikael@lilotux.net>
parents:
701
diff
changeset
|
1716 else |
b26a0bde4cdb
Add /roster hide|show|toggle
Mikael Berthe <mikael@lilotux.net>
parents:
701
diff
changeset
|
1717 Roster_Width = DEFAULT_ROSTER_WIDTH; |
b26a0bde4cdb
Add /roster hide|show|toggle
Mikael Berthe <mikael@lilotux.net>
parents:
701
diff
changeset
|
1718 } |
701
6c100adfbfb6
Add setting "roster_width" (variable buddylist width)
Mikael Berthe <mikael@lilotux.net>
parents:
699
diff
changeset
|
1719 |
972
11b632d824f6
Add option 'log_win_on_top'
Mikael Berthe <mikael@lilotux.net>
parents:
967
diff
changeset
|
1720 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
|
1721 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
|
1722 |
11b632d824f6
Add option 'log_win_on_top'
Mikael Berthe <mikael@lilotux.net>
parents:
967
diff
changeset
|
1723 if (log_win_on_top) { |
11b632d824f6
Add option 'log_win_on_top'
Mikael Berthe <mikael@lilotux.net>
parents:
967
diff
changeset
|
1724 log_y_pos = 0; |
2342 | 1725 chatstatus_y_pos = Log_Win_Height; |
1726 chat_y_pos = Log_Win_Height + 1; | |
972
11b632d824f6
Add option 'log_win_on_top'
Mikael Berthe <mikael@lilotux.net>
parents:
967
diff
changeset
|
1727 } else { |
11b632d824f6
Add option 'log_win_on_top'
Mikael Berthe <mikael@lilotux.net>
parents:
967
diff
changeset
|
1728 chat_y_pos = 0; |
11b632d824f6
Add option 'log_win_on_top'
Mikael Berthe <mikael@lilotux.net>
parents:
967
diff
changeset
|
1729 chatstatus_y_pos = CHAT_WIN_HEIGHT; |
2342 | 1730 log_y_pos = CHAT_WIN_HEIGHT + 1; |
972
11b632d824f6
Add option 'log_win_on_top'
Mikael Berthe <mikael@lilotux.net>
parents:
967
diff
changeset
|
1731 } |
11b632d824f6
Add option 'log_win_on_top'
Mikael Berthe <mikael@lilotux.net>
parents:
967
diff
changeset
|
1732 |
973
e693cbe33802
Add option 'roster_win_on_right'
Mikael Berthe <mikael@lilotux.net>
parents:
972
diff
changeset
|
1733 if (roster_win_on_right) { |
e693cbe33802
Add option 'roster_win_on_right'
Mikael Berthe <mikael@lilotux.net>
parents:
972
diff
changeset
|
1734 roster_x_pos = maxX - Roster_Width; |
e693cbe33802
Add option 'roster_win_on_right'
Mikael Berthe <mikael@lilotux.net>
parents:
972
diff
changeset
|
1735 chat_x_pos = 0; |
e693cbe33802
Add option 'roster_win_on_right'
Mikael Berthe <mikael@lilotux.net>
parents:
972
diff
changeset
|
1736 } else { |
e693cbe33802
Add option 'roster_win_on_right'
Mikael Berthe <mikael@lilotux.net>
parents:
972
diff
changeset
|
1737 roster_x_pos = 0; |
e693cbe33802
Add option 'roster_win_on_right'
Mikael Berthe <mikael@lilotux.net>
parents:
972
diff
changeset
|
1738 chat_x_pos = Roster_Width; |
e693cbe33802
Add option 'roster_win_on_right'
Mikael Berthe <mikael@lilotux.net>
parents:
972
diff
changeset
|
1739 } |
e693cbe33802
Add option 'roster_win_on_right'
Mikael Berthe <mikael@lilotux.net>
parents:
972
diff
changeset
|
1740 |
157 | 1741 if (fullinit) { |
1078
7866dbaf67a6
Use a hash for the list of win buffers
Mikael Berthe <mikael@lilotux.net>
parents:
1077
diff
changeset
|
1742 if (!winbufhash) |
2222
ce1043326bbc
Fix a small leak when a window is closed
Mikael Berthe <mikael@lilotux.net>
parents:
2211
diff
changeset
|
1743 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
|
1744 g_free, g_free); |
157 | 1745 /* Create windows */ |
973
e693cbe33802
Add option 'roster_win_on_right'
Mikael Berthe <mikael@lilotux.net>
parents:
972
diff
changeset
|
1746 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
|
1747 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
|
1748 chat_x_pos); |
1133
9dd28a56128f
Do not create one panel per contact
Mikael Berthe <mikael@lilotux.net>
parents:
1131
diff
changeset
|
1749 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
|
1750 chat_x_pos); |
2342 | 1751 logWnd = newwin(Log_Win_Height, maxX, log_y_pos, 0); |
972
11b632d824f6
Add option 'log_win_on_top'
Mikael Berthe <mikael@lilotux.net>
parents:
967
diff
changeset
|
1752 chatstatusWnd = newwin(1, maxX, chatstatus_y_pos, 0); |
711 | 1753 mainstatusWnd = newwin(1, maxX, maxY-2, 0); |
157 | 1754 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
|
1755 if (!rosterWnd || !chatWnd || !logWnd || !inputWnd) { |
1780
e4378fbab5d7
Major API cleanup - bump API to 4
Mikael Berthe <mikael@lilotux.net>
parents:
1761
diff
changeset
|
1756 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
|
1757 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
|
1758 exit(EXIT_FAILURE); |
6e4e667c5571
Fix a segfault when starting mcabber in a really small terminal
Mikael Berthe <mikael@lilotux.net>
parents:
339
diff
changeset
|
1759 } |
739
0d5fb1d9077c
Allow "bright" text colors
Mikael Berthe <mikael@lilotux.net>
parents:
735
diff
changeset
|
1760 wbkgd(rosterWnd, get_color(COLOR_GENERAL)); |
0d5fb1d9077c
Allow "bright" text colors
Mikael Berthe <mikael@lilotux.net>
parents:
735
diff
changeset
|
1761 wbkgd(chatWnd, get_color(COLOR_GENERAL)); |
1133
9dd28a56128f
Do not create one panel per contact
Mikael Berthe <mikael@lilotux.net>
parents:
1131
diff
changeset
|
1762 wbkgd(activechatWnd, get_color(COLOR_GENERAL)); |
2328 | 1763 wbkgd(logWnd, get_color(COLOR_LOG)); |
739
0d5fb1d9077c
Allow "bright" text colors
Mikael Berthe <mikael@lilotux.net>
parents:
735
diff
changeset
|
1764 wbkgd(chatstatusWnd, get_color(COLOR_STATUS)); |
0d5fb1d9077c
Allow "bright" text colors
Mikael Berthe <mikael@lilotux.net>
parents:
735
diff
changeset
|
1765 wbkgd(mainstatusWnd, get_color(COLOR_STATUS)); |
157 | 1766 } else { |
701
6c100adfbfb6
Add setting "roster_width" (variable buddylist width)
Mikael Berthe <mikael@lilotux.net>
parents:
699
diff
changeset
|
1767 /* Resize/move windows */ |
6c100adfbfb6
Add setting "roster_width" (variable buddylist width)
Mikael Berthe <mikael@lilotux.net>
parents:
699
diff
changeset
|
1768 wresize(rosterWnd, CHAT_WIN_HEIGHT, Roster_Width); |
6c100adfbfb6
Add setting "roster_width" (variable buddylist width)
Mikael Berthe <mikael@lilotux.net>
parents:
699
diff
changeset
|
1769 wresize(chatWnd, CHAT_WIN_HEIGHT, maxX - Roster_Width); |
2342 | 1770 wresize(logWnd, Log_Win_Height, maxX); |
157 | 1771 |
973
e693cbe33802
Add option 'roster_win_on_right'
Mikael Berthe <mikael@lilotux.net>
parents:
972
diff
changeset
|
1772 mvwin(chatWnd, chat_y_pos, chat_x_pos); |
e693cbe33802
Add option 'roster_win_on_right'
Mikael Berthe <mikael@lilotux.net>
parents:
972
diff
changeset
|
1773 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
|
1774 mvwin(logWnd, log_y_pos, 0); |
157 | 1775 |
711 | 1776 // Resize & move chat status window |
1777 wresize(chatstatusWnd, 1, maxX); | |
972
11b632d824f6
Add option 'log_win_on_top'
Mikael Berthe <mikael@lilotux.net>
parents:
967
diff
changeset
|
1778 mvwin(chatstatusWnd, chatstatus_y_pos, 0); |
711 | 1779 // Resize & move main status window |
1780 wresize(mainstatusWnd, 1, maxX); | |
1781 mvwin(mainstatusWnd, maxY-2, 0); | |
1782 // Resize & move input line window | |
157 | 1783 wresize(inputWnd, 1, maxX); |
1784 mvwin(inputWnd, maxY-1, 0); | |
168 | 1785 |
1786 werase(chatWnd); | |
157 | 1787 } |
151 | 1788 |
1789 /* Draw/init windows */ | |
1790 | |
961
95659cf9ea1a
Display mcabber version in the status window
Mikael Berthe <mikael@lilotux.net>
parents:
952
diff
changeset
|
1791 ver = mcabber_version(); |
95659cf9ea1a
Display mcabber version in the status window
Mikael Berthe <mikael@lilotux.net>
parents:
952
diff
changeset
|
1792 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
|
1793 mvwprintw(chatWnd, 0, 0, message); |
1455
bec235cd28a8
Misc. documentation updates
Mikael Berthe <mikael@lilotux.net>
parents:
1454
diff
changeset
|
1794 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
|
1795 g_free(ver); |
95659cf9ea1a
Display mcabber version in the status window
Mikael Berthe <mikael@lilotux.net>
parents:
952
diff
changeset
|
1796 g_free(message); |
24 | 1797 |
157 | 1798 // Auto-scrolling in log window |
74 | 1799 scrollok(logWnd, TRUE); |
24 | 1800 |
1801 | |
151 | 1802 if (fullinit) { |
157 | 1803 // Enable keypad (+ special keys) |
1804 keypad(inputWnd, TRUE); | |
1457
3a537b4d7f8d
Fix UTF-8 on MirBSD (Thorsten Glaser)
Mikael Berthe <mikael@lilotux.net>
parents:
1455
diff
changeset
|
1805 #ifdef __MirBSD__ |
3a537b4d7f8d
Fix UTF-8 on MirBSD (Thorsten Glaser)
Mikael Berthe <mikael@lilotux.net>
parents:
1455
diff
changeset
|
1806 wtimeout(inputWnd, 50 /* ms */); |
3a537b4d7f8d
Fix UTF-8 on MirBSD (Thorsten Glaser)
Mikael Berthe <mikael@lilotux.net>
parents:
1455
diff
changeset
|
1807 #else |
382
4c6e8392e465
Use nodelay() instead of halfdelay()
Mikael Berthe <mikael@lilotux.net>
parents:
374
diff
changeset
|
1808 nodelay(inputWnd, TRUE); |
1457
3a537b4d7f8d
Fix UTF-8 on MirBSD (Thorsten Glaser)
Mikael Berthe <mikael@lilotux.net>
parents:
1455
diff
changeset
|
1809 #endif |
157 | 1810 |
151 | 1811 // Create panels |
1812 rosterPanel = new_panel(rosterWnd); | |
1813 chatPanel = new_panel(chatWnd); | |
1133
9dd28a56128f
Do not create one panel per contact
Mikael Berthe <mikael@lilotux.net>
parents:
1131
diff
changeset
|
1814 activechatPanel = new_panel(activechatWnd); |
151 | 1815 logPanel = new_panel(logWnd); |
711 | 1816 chatstatusPanel = new_panel(chatstatusWnd); |
1817 mainstatusPanel = new_panel(mainstatusWnd); | |
151 | 1818 inputPanel = new_panel(inputWnd); |
232 | 1819 |
849
42c43a88d823
Status buffer management
Mikael Berthe <mikael@lilotux.net>
parents:
848
diff
changeset
|
1820 // 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
|
1821 // is added |
2291
0d350e979bde
Don't rebuild the buddylist multiple times before a screen refresh
franky
parents:
2288
diff
changeset
|
1822 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
|
1823 |
6ca9a65df21f
Do not rewrap buffer lines when the chat window width doesn't change
Mikael Berthe <mikael@lilotux.net>
parents:
1089
diff
changeset
|
1824 // 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
|
1825 // from rewrapping buffers when the width doesn't change. |
1487 | 1826 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
|
1827 // 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
|
1828 hbuf_rebuild(&statushbuf, prev_chatwidth); |
849
42c43a88d823
Status buffer management
Mikael Berthe <mikael@lilotux.net>
parents:
848
diff
changeset
|
1829 |
930
a75f7a13df7b
UTF-8 terminal support (Reimar Döffinger)
Mikael Berthe <mikael@lilotux.net>
parents:
929
diff
changeset
|
1830 #ifndef UNICODE |
232 | 1831 if (utf8_mode) |
930
a75f7a13df7b
UTF-8 terminal support (Reimar Döffinger)
Mikael Berthe <mikael@lilotux.net>
parents:
929
diff
changeset
|
1832 scr_LogPrint(LPRINT_NORMAL, |
a75f7a13df7b
UTF-8 terminal support (Reimar Döffinger)
Mikael Berthe <mikael@lilotux.net>
parents:
929
diff
changeset
|
1833 "WARNING: Compiled without full UTF-8 support!"); |
a75f7a13df7b
UTF-8 terminal support (Reimar Döffinger)
Mikael Berthe <mikael@lilotux.net>
parents:
929
diff
changeset
|
1834 #endif |
157 | 1835 } else { |
1836 // Update panels | |
1837 replace_panel(rosterPanel, rosterWnd); | |
1838 replace_panel(chatPanel, chatWnd); | |
1839 replace_panel(logPanel, logWnd); | |
711 | 1840 replace_panel(chatstatusPanel, chatstatusWnd); |
1841 replace_panel(mainstatusPanel, mainstatusWnd); | |
157 | 1842 replace_panel(inputPanel, inputWnd); |
151 | 1843 } |
1844 | |
2343 | 1845 if (0 == Log_Win_Height) { |
1846 hide_panel(logPanel); | |
1847 } else { | |
1848 show_panel(logPanel); | |
1849 } | |
1850 | |
151 | 1851 // We'll need to redraw the roster |
2292
f181418db215
Replace global variable update_roster with scr_update_roster()
franky
parents:
2291
diff
changeset
|
1852 scr_update_roster(); |
24 | 1853 return; |
1854 } | |
1855 | |
1078
7866dbaf67a6
Use a hash for the list of win buffers
Mikael Berthe <mikael@lilotux.net>
parents:
1077
diff
changeset
|
1856 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
|
1857 { |
2337 | 1858 winbuf_t *wbp = value; |
1078
7866dbaf67a6
Use a hash for the list of win buffers
Mikael Berthe <mikael@lilotux.net>
parents:
1077
diff
changeset
|
1859 struct dimensions *dim = data; |
973
e693cbe33802
Add option 'roster_win_on_right'
Mikael Berthe <mikael@lilotux.net>
parents:
972
diff
changeset
|
1860 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
|
1861 int new_chatwidth; |
972
11b632d824f6
Add option 'log_win_on_top'
Mikael Berthe <mikael@lilotux.net>
parents:
967
diff
changeset
|
1862 |
1078
7866dbaf67a6
Use a hash for the list of win buffers
Mikael Berthe <mikael@lilotux.net>
parents:
1077
diff
changeset
|
1863 if (!(wbp && wbp->win)) |
7866dbaf67a6
Use a hash for the list of win buffers
Mikael Berthe <mikael@lilotux.net>
parents:
1077
diff
changeset
|
1864 return; |
7866dbaf67a6
Use a hash for the list of win buffers
Mikael Berthe <mikael@lilotux.net>
parents:
1077
diff
changeset
|
1865 |
972
11b632d824f6
Add option 'log_win_on_top'
Mikael Berthe <mikael@lilotux.net>
parents:
967
diff
changeset
|
1866 if (log_win_on_top) |
2342 | 1867 chat_y_pos = Log_Win_Height + 1; |
972
11b632d824f6
Add option 'log_win_on_top'
Mikael Berthe <mikael@lilotux.net>
parents:
967
diff
changeset
|
1868 else |
11b632d824f6
Add option 'log_win_on_top'
Mikael Berthe <mikael@lilotux.net>
parents:
967
diff
changeset
|
1869 chat_y_pos = 0; |
11b632d824f6
Add option 'log_win_on_top'
Mikael Berthe <mikael@lilotux.net>
parents:
967
diff
changeset
|
1870 |
973
e693cbe33802
Add option 'roster_win_on_right'
Mikael Berthe <mikael@lilotux.net>
parents:
972
diff
changeset
|
1871 if (roster_win_on_right) |
e693cbe33802
Add option 'roster_win_on_right'
Mikael Berthe <mikael@lilotux.net>
parents:
972
diff
changeset
|
1872 chat_x_pos = 0; |
e693cbe33802
Add option 'roster_win_on_right'
Mikael Berthe <mikael@lilotux.net>
parents:
972
diff
changeset
|
1873 else |
e693cbe33802
Add option 'roster_win_on_right'
Mikael Berthe <mikael@lilotux.net>
parents:
972
diff
changeset
|
1874 chat_x_pos = Roster_Width; |
e693cbe33802
Add option 'roster_win_on_right'
Mikael Berthe <mikael@lilotux.net>
parents:
972
diff
changeset
|
1875 |
849
42c43a88d823
Status buffer management
Mikael Berthe <mikael@lilotux.net>
parents:
848
diff
changeset
|
1876 // Resize/move buddy window |
1078
7866dbaf67a6
Use a hash for the list of win buffers
Mikael Berthe <mikael@lilotux.net>
parents:
1077
diff
changeset
|
1877 wresize(wbp->win, dim->l, dim->c); |
973
e693cbe33802
Add option 'roster_win_on_right'
Mikael Berthe <mikael@lilotux.net>
parents:
972
diff
changeset
|
1878 mvwin(wbp->win, chat_y_pos, chat_x_pos); |
849
42c43a88d823
Status buffer management
Mikael Berthe <mikael@lilotux.net>
parents:
848
diff
changeset
|
1879 werase(wbp->win); |
42c43a88d823
Status buffer management
Mikael Berthe <mikael@lilotux.net>
parents:
848
diff
changeset
|
1880 // If a panel exists, replace the old window with the new |
42c43a88d823
Status buffer management
Mikael Berthe <mikael@lilotux.net>
parents:
848
diff
changeset
|
1881 if (wbp->panel) |
42c43a88d823
Status buffer management
Mikael Berthe <mikael@lilotux.net>
parents:
848
diff
changeset
|
1882 replace_panel(wbp->panel, wbp->win); |
42c43a88d823
Status buffer management
Mikael Berthe <mikael@lilotux.net>
parents:
848
diff
changeset
|
1883 // Redo line wrapping |
1157
5c857f0f0ab8
Moved all variables related to hbuf to an extra struct, bufdata
Frank Zschockelt
parents:
1156
diff
changeset
|
1884 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
|
1885 |
1487 | 1886 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
|
1887 if (new_chatwidth != prev_chatwidth) |
1157
5c857f0f0ab8
Moved all variables related to hbuf to an extra struct, bufdata
Frank Zschockelt
parents:
1156
diff
changeset
|
1888 hbuf_rebuild(&wbp->bd->hbuf, new_chatwidth); |
849
42c43a88d823
Status buffer management
Mikael Berthe <mikael@lilotux.net>
parents:
848
diff
changeset
|
1889 } |
42c43a88d823
Status buffer management
Mikael Berthe <mikael@lilotux.net>
parents:
848
diff
changeset
|
1890 |
2231
387cea2a1a81
Fix resizing with --enable-sigwinch
Mikael Berthe <mikael@lilotux.net>
parents:
2226
diff
changeset
|
1891 // scr_resize() |
151 | 1892 // Function called when the window is resized. |
157 | 1893 // - Resize windows |
151 | 1894 // - Rewrap lines in each buddy buffer |
2231
387cea2a1a81
Fix resizing with --enable-sigwinch
Mikael Berthe <mikael@lilotux.net>
parents:
2226
diff
changeset
|
1895 void scr_resize(void) |
151 | 1896 { |
1078
7866dbaf67a6
Use a hash for the list of win buffers
Mikael Berthe <mikael@lilotux.net>
parents:
1077
diff
changeset
|
1897 struct dimensions dim; |
151 | 1898 |
1899 // First, update the global variables | |
1900 getmaxyx(stdscr, maxY, maxX); | |
1780
e4378fbab5d7
Major API cleanup - bump API to 4
Mikael Berthe <mikael@lilotux.net>
parents:
1761
diff
changeset
|
1901 // 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
|
1902 |
151 | 1903 // Make sure the cursor stays inside the window |
1904 check_offset(0); | |
1905 | |
157 | 1906 // Resize windows and update panels |
1780
e4378fbab5d7
Major API cleanup - bump API to 4
Mikael Berthe <mikael@lilotux.net>
parents:
1761
diff
changeset
|
1907 scr_draw_main_window(FALSE); |
151 | 1908 |
1909 // Resize all buddy windows | |
1078
7866dbaf67a6
Use a hash for the list of win buffers
Mikael Berthe <mikael@lilotux.net>
parents:
1077
diff
changeset
|
1910 dim.l = CHAT_WIN_HEIGHT; |
7866dbaf67a6
Use a hash for the list of win buffers
Mikael Berthe <mikael@lilotux.net>
parents:
1077
diff
changeset
|
1911 dim.c = maxX - Roster_Width; |
7866dbaf67a6
Use a hash for the list of win buffers
Mikael Berthe <mikael@lilotux.net>
parents:
1077
diff
changeset
|
1912 if (dim.c < 1) |
7866dbaf67a6
Use a hash for the list of win buffers
Mikael Berthe <mikael@lilotux.net>
parents:
1077
diff
changeset
|
1913 dim.c = 1; |
7866dbaf67a6
Use a hash for the list of win buffers
Mikael Berthe <mikael@lilotux.net>
parents:
1077
diff
changeset
|
1914 |
7866dbaf67a6
Use a hash for the list of win buffers
Mikael Berthe <mikael@lilotux.net>
parents:
1077
diff
changeset
|
1915 // Resize all buffers |
7866dbaf67a6
Use a hash for the list of win buffers
Mikael Berthe <mikael@lilotux.net>
parents:
1077
diff
changeset
|
1916 g_hash_table_foreach(winbufhash, resize_win_buffer, &dim); |
151 | 1917 |
849
42c43a88d823
Status buffer management
Mikael Berthe <mikael@lilotux.net>
parents:
848
diff
changeset
|
1918 // Resize/move special status buffer |
42c43a88d823
Status buffer management
Mikael Berthe <mikael@lilotux.net>
parents:
848
diff
changeset
|
1919 if (statusWindow) |
1078
7866dbaf67a6
Use a hash for the list of win buffers
Mikael Berthe <mikael@lilotux.net>
parents:
1077
diff
changeset
|
1920 resize_win_buffer(NULL, statusWindow, &dim); |
849
42c43a88d823
Status buffer management
Mikael Berthe <mikael@lilotux.net>
parents:
848
diff
changeset
|
1921 |
1093
6ca9a65df21f
Do not rewrap buffer lines when the chat window width doesn't change
Mikael Berthe <mikael@lilotux.net>
parents:
1089
diff
changeset
|
1922 // Update prev_chatwidth, now that all buffers have been resized |
1487 | 1923 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
|
1924 |
151 | 1925 // Refresh current buddy window |
157 | 1926 if (chatmode) |
1780
e4378fbab5d7
Major API cleanup - bump API to 4
Mikael Berthe <mikael@lilotux.net>
parents:
1761
diff
changeset
|
1927 scr_show_buddy_window(); |
151 | 1928 } |
1929 | |
2231
387cea2a1a81
Fix resizing with --enable-sigwinch
Mikael Berthe <mikael@lilotux.net>
parents:
2226
diff
changeset
|
1930 #ifdef USE_SIGWINCH |
387cea2a1a81
Fix resizing with --enable-sigwinch
Mikael Berthe <mikael@lilotux.net>
parents:
2226
diff
changeset
|
1931 void sigwinch_resize(void) |
387cea2a1a81
Fix resizing with --enable-sigwinch
Mikael Berthe <mikael@lilotux.net>
parents:
2226
diff
changeset
|
1932 { |
387cea2a1a81
Fix resizing with --enable-sigwinch
Mikael Berthe <mikael@lilotux.net>
parents:
2226
diff
changeset
|
1933 struct winsize size; |
387cea2a1a81
Fix resizing with --enable-sigwinch
Mikael Berthe <mikael@lilotux.net>
parents:
2226
diff
changeset
|
1934 if (ioctl(STDIN_FILENO, TIOCGWINSZ, &size) != -1) |
387cea2a1a81
Fix resizing with --enable-sigwinch
Mikael Berthe <mikael@lilotux.net>
parents:
2226
diff
changeset
|
1935 resizeterm(size.ws_row, size.ws_col); |
387cea2a1a81
Fix resizing with --enable-sigwinch
Mikael Berthe <mikael@lilotux.net>
parents:
2226
diff
changeset
|
1936 scr_resize(); |
387cea2a1a81
Fix resizing with --enable-sigwinch
Mikael Berthe <mikael@lilotux.net>
parents:
2226
diff
changeset
|
1937 } |
387cea2a1a81
Fix resizing with --enable-sigwinch
Mikael Berthe <mikael@lilotux.net>
parents:
2226
diff
changeset
|
1938 #endif |
387cea2a1a81
Fix resizing with --enable-sigwinch
Mikael Berthe <mikael@lilotux.net>
parents:
2226
diff
changeset
|
1939 |
1780
e4378fbab5d7
Major API cleanup - bump API to 4
Mikael Berthe <mikael@lilotux.net>
parents:
1761
diff
changeset
|
1940 // scr_update_chat_status(forceupdate) |
713 | 1941 // Redraw the buddy status bar. |
939
12fa2ae6445d
Get rid of "busy-waiting" (Christof Meerwald)
Mikael Berthe <mikael@lilotux.net>
parents:
936
diff
changeset
|
1942 // 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
|
1943 void scr_update_chat_status(int forceupdate) |
713 | 1944 { |
848
a9161d2dc414
Introduce special buffer stuff
Mikael Berthe <mikael@lilotux.net>
parents:
843
diff
changeset
|
1945 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
|
1946 const char *btypetext = "Unknown"; |
717
8ce2bfdc4143
Reindent update_chat_status_window()
Mikael Berthe <mikael@lilotux.net>
parents:
716
diff
changeset
|
1947 const char *fullname; |
2013
8dc418af3e72
Allow to select to which buddy resource messages go. Closes issue #55
Hermitifier
parents:
2012
diff
changeset
|
1948 char *fullnameres = NULL; |
8dc418af3e72
Allow to select to which buddy resource messages go. Closes issue #55
Hermitifier
parents:
2012
diff
changeset
|
1949 const char *activeres; |
717
8ce2bfdc4143
Reindent update_chat_status_window()
Mikael Berthe <mikael@lilotux.net>
parents:
716
diff
changeset
|
1950 const char *msg = NULL; |
8ce2bfdc4143
Reindent update_chat_status_window()
Mikael Berthe <mikael@lilotux.net>
parents:
716
diff
changeset
|
1951 char status; |
773
e25b8a348ebd
Screen updating functions use UTF-8
Mikael Berthe <mikael@lilotux.net>
parents:
772
diff
changeset
|
1952 char *buf, *buf_locale; |
713 | 1953 |
718
b41799901abd
Add a new_message flag (#) in the main status line
Mikael Berthe <mikael@lilotux.net>
parents:
717
diff
changeset
|
1954 // 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
|
1955 // 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
|
1956 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
|
1957 |
806
3521e34f722a
Fix a segfault when not connected to a server
Mikael Berthe <mikael@lilotux.net>
parents:
797
diff
changeset
|
1958 // Clear the line |
3521e34f722a
Fix a segfault when not connected to a server
Mikael Berthe <mikael@lilotux.net>
parents:
797
diff
changeset
|
1959 werase(chatstatusWnd); |
3521e34f722a
Fix a segfault when not connected to a server
Mikael Berthe <mikael@lilotux.net>
parents:
797
diff
changeset
|
1960 |
3521e34f722a
Fix a segfault when not connected to a server
Mikael Berthe <mikael@lilotux.net>
parents:
797
diff
changeset
|
1961 if (!current_buddy) { |
3521e34f722a
Fix a segfault when not connected to a server
Mikael Berthe <mikael@lilotux.net>
parents:
797
diff
changeset
|
1962 if (forceupdate) { |
3521e34f722a
Fix a segfault when not connected to a server
Mikael Berthe <mikael@lilotux.net>
parents:
797
diff
changeset
|
1963 update_panels(); |
3521e34f722a
Fix a segfault when not connected to a server
Mikael Berthe <mikael@lilotux.net>
parents:
797
diff
changeset
|
1964 } |
3521e34f722a
Fix a segfault when not connected to a server
Mikael Berthe <mikael@lilotux.net>
parents:
797
diff
changeset
|
1965 return; |
3521e34f722a
Fix a segfault when not connected to a server
Mikael Berthe <mikael@lilotux.net>
parents:
797
diff
changeset
|
1966 } |
3521e34f722a
Fix a segfault when not connected to a server
Mikael Berthe <mikael@lilotux.net>
parents:
797
diff
changeset
|
1967 |
717
8ce2bfdc4143
Reindent update_chat_status_window()
Mikael Berthe <mikael@lilotux.net>
parents:
716
diff
changeset
|
1968 fullname = buddy_getname(BUDDATA(current_buddy)); |
8ce2bfdc4143
Reindent update_chat_status_window()
Mikael Berthe <mikael@lilotux.net>
parents:
716
diff
changeset
|
1969 btype = buddy_gettype(BUDDATA(current_buddy)); |
713 | 1970 |
1502
50dbbca69b55
Small style improvement of buddy status line
Maxim Vuets <maxim.vuets@gmail.com>
parents:
1489
diff
changeset
|
1971 isgrp = ismuc = isspe = 0; |
50dbbca69b55
Small style improvement of buddy status line
Maxim Vuets <maxim.vuets@gmail.com>
parents:
1489
diff
changeset
|
1972 if (btype & ROSTER_TYPE_USER) { |
50dbbca69b55
Small style improvement of buddy status line
Maxim Vuets <maxim.vuets@gmail.com>
parents:
1489
diff
changeset
|
1973 btypetext = "Buddy"; |
50dbbca69b55
Small style improvement of buddy status line
Maxim Vuets <maxim.vuets@gmail.com>
parents:
1489
diff
changeset
|
1974 } else if (btype & ROSTER_TYPE_GROUP) { |
50dbbca69b55
Small style improvement of buddy status line
Maxim Vuets <maxim.vuets@gmail.com>
parents:
1489
diff
changeset
|
1975 btypetext = "Group"; |
50dbbca69b55
Small style improvement of buddy status line
Maxim Vuets <maxim.vuets@gmail.com>
parents:
1489
diff
changeset
|
1976 isgrp = 1; |
50dbbca69b55
Small style improvement of buddy status line
Maxim Vuets <maxim.vuets@gmail.com>
parents:
1489
diff
changeset
|
1977 } else if (btype & ROSTER_TYPE_AGENT) { |
50dbbca69b55
Small style improvement of buddy status line
Maxim Vuets <maxim.vuets@gmail.com>
parents:
1489
diff
changeset
|
1978 btypetext = "Agent"; |
50dbbca69b55
Small style improvement of buddy status line
Maxim Vuets <maxim.vuets@gmail.com>
parents:
1489
diff
changeset
|
1979 } else if (btype & ROSTER_TYPE_ROOM) { |
50dbbca69b55
Small style improvement of buddy status line
Maxim Vuets <maxim.vuets@gmail.com>
parents:
1489
diff
changeset
|
1980 btypetext = "Room"; |
50dbbca69b55
Small style improvement of buddy status line
Maxim Vuets <maxim.vuets@gmail.com>
parents:
1489
diff
changeset
|
1981 ismuc = 1; |
50dbbca69b55
Small style improvement of buddy status line
Maxim Vuets <maxim.vuets@gmail.com>
parents:
1489
diff
changeset
|
1982 } else if (btype & ROSTER_TYPE_SPECIAL) { |
50dbbca69b55
Small style improvement of buddy status line
Maxim Vuets <maxim.vuets@gmail.com>
parents:
1489
diff
changeset
|
1983 btypetext = "Special buffer"; |
50dbbca69b55
Small style improvement of buddy status line
Maxim Vuets <maxim.vuets@gmail.com>
parents:
1489
diff
changeset
|
1984 isspe = 1; |
50dbbca69b55
Small style improvement of buddy status line
Maxim Vuets <maxim.vuets@gmail.com>
parents:
1489
diff
changeset
|
1985 } |
713 | 1986 |
1513
9d78b571e693
Show '#' for unread message per buddy on the buddy status line
Maxim Vuets <maxim.vuets@gmail.com>
parents:
1511
diff
changeset
|
1987 if (chatmode) { |
9d78b571e693
Show '#' for unread message per buddy on the buddy status line
Maxim Vuets <maxim.vuets@gmail.com>
parents:
1511
diff
changeset
|
1988 wprintw(chatstatusWnd, "~"); |
9d78b571e693
Show '#' for unread message per buddy on the buddy status line
Maxim Vuets <maxim.vuets@gmail.com>
parents:
1511
diff
changeset
|
1989 } else { |
9d78b571e693
Show '#' for unread message per buddy on the buddy status line
Maxim Vuets <maxim.vuets@gmail.com>
parents:
1511
diff
changeset
|
1990 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
|
1991 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
|
1992 // 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
|
1993 wprintw(chatstatusWnd, "#"); |
9d78b571e693
Show '#' for unread message per buddy on the buddy status line
Maxim Vuets <maxim.vuets@gmail.com>
parents:
1511
diff
changeset
|
1994 } |
9d78b571e693
Show '#' for unread message per buddy on the buddy status line
Maxim Vuets <maxim.vuets@gmail.com>
parents:
1511
diff
changeset
|
1995 } |
9d78b571e693
Show '#' for unread message per buddy on the buddy status line
Maxim Vuets <maxim.vuets@gmail.com>
parents:
1511
diff
changeset
|
1996 |
874
293e8955075c
Display a flag in the chat status line when the buffer is locked
Mikael Berthe <mikael@lilotux.net>
parents:
873
diff
changeset
|
1997 if (chatmode && !isgrp) { |
2337 | 1998 winbuf_t *win_entry; |
1780
e4378fbab5d7
Major API cleanup - bump API to 4
Mikael Berthe <mikael@lilotux.net>
parents:
1761
diff
changeset
|
1999 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
|
2000 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
|
2001 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
|
2002 } |
293e8955075c
Display a flag in the chat status line when the buffer is locked
Mikael Berthe <mikael@lilotux.net>
parents:
873
diff
changeset
|
2003 |
848
a9161d2dc414
Introduce special buffer stuff
Mikael Berthe <mikael@lilotux.net>
parents:
843
diff
changeset
|
2004 if (isgrp || isspe) { |
773
e25b8a348ebd
Screen updating functions use UTF-8
Mikael Berthe <mikael@lilotux.net>
parents:
772
diff
changeset
|
2005 buf_locale = from_utf8(fullname); |
1502
50dbbca69b55
Small style improvement of buddy status line
Maxim Vuets <maxim.vuets@gmail.com>
parents:
1489
diff
changeset
|
2006 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
|
2007 g_free(buf_locale); |
716
ba1137a01078
Add a chatmode flag (©) in the chat status line
Mikael Berthe <mikael@lilotux.net>
parents:
715
diff
changeset
|
2008 if (forceupdate) { |
ba1137a01078
Add a chatmode flag (©) in the chat status line
Mikael Berthe <mikael@lilotux.net>
parents:
715
diff
changeset
|
2009 update_panels(); |
ba1137a01078
Add a chatmode flag (©) in the chat status line
Mikael Berthe <mikael@lilotux.net>
parents:
715
diff
changeset
|
2010 } |
717
8ce2bfdc4143
Reindent update_chat_status_window()
Mikael Berthe <mikael@lilotux.net>
parents:
716
diff
changeset
|
2011 return; |
8ce2bfdc4143
Reindent update_chat_status_window()
Mikael Berthe <mikael@lilotux.net>
parents:
716
diff
changeset
|
2012 } |
8ce2bfdc4143
Reindent update_chat_status_window()
Mikael Berthe <mikael@lilotux.net>
parents:
716
diff
changeset
|
2013 |
8ce2bfdc4143
Reindent update_chat_status_window()
Mikael Berthe <mikael@lilotux.net>
parents:
716
diff
changeset
|
2014 status = '?'; |
8ce2bfdc4143
Reindent update_chat_status_window()
Mikael Berthe <mikael@lilotux.net>
parents:
716
diff
changeset
|
2015 |
2013
8dc418af3e72
Allow to select to which buddy resource messages go. Closes issue #55
Hermitifier
parents:
2012
diff
changeset
|
2016 activeres = buddy_getactiveresource(BUDDATA(current_buddy)); |
8dc418af3e72
Allow to select to which buddy resource messages go. Closes issue #55
Hermitifier
parents:
2012
diff
changeset
|
2017 |
717
8ce2bfdc4143
Reindent update_chat_status_window()
Mikael Berthe <mikael@lilotux.net>
parents:
716
diff
changeset
|
2018 if (ismuc) { |
8ce2bfdc4143
Reindent update_chat_status_window()
Mikael Berthe <mikael@lilotux.net>
parents:
716
diff
changeset
|
2019 if (buddy_getinsideroom(BUDDATA(current_buddy))) |
8ce2bfdc4143
Reindent update_chat_status_window()
Mikael Berthe <mikael@lilotux.net>
parents:
716
diff
changeset
|
2020 status = 'C'; |
8ce2bfdc4143
Reindent update_chat_status_window()
Mikael Berthe <mikael@lilotux.net>
parents:
716
diff
changeset
|
2021 else |
8ce2bfdc4143
Reindent update_chat_status_window()
Mikael Berthe <mikael@lilotux.net>
parents:
716
diff
changeset
|
2022 status = 'x'; |
1598 | 2023 } else if (xmpp_getstatus() != offline) { |
717
8ce2bfdc4143
Reindent update_chat_status_window()
Mikael Berthe <mikael@lilotux.net>
parents:
716
diff
changeset
|
2024 enum imstatus budstate; |
2013
8dc418af3e72
Allow to select to which buddy resource messages go. Closes issue #55
Hermitifier
parents:
2012
diff
changeset
|
2025 budstate = buddy_getstatus(BUDDATA(current_buddy), activeres); |
790
5d4ad1d77da4
Kill a few gcc4 warnings
Mikael Berthe <mikael@lilotux.net>
parents:
785
diff
changeset
|
2026 if (budstate < imstatus_size) |
717
8ce2bfdc4143
Reindent update_chat_status_window()
Mikael Berthe <mikael@lilotux.net>
parents:
716
diff
changeset
|
2027 status = imstatus2char[budstate]; |
8ce2bfdc4143
Reindent update_chat_status_window()
Mikael Berthe <mikael@lilotux.net>
parents:
716
diff
changeset
|
2028 } |
8ce2bfdc4143
Reindent update_chat_status_window()
Mikael Berthe <mikael@lilotux.net>
parents:
716
diff
changeset
|
2029 |
1502
50dbbca69b55
Small style improvement of buddy status line
Maxim Vuets <maxim.vuets@gmail.com>
parents:
1489
diff
changeset
|
2030 // No status message for MUC rooms |
50dbbca69b55
Small style improvement of buddy status line
Maxim Vuets <maxim.vuets@gmail.com>
parents:
1489
diff
changeset
|
2031 if (!ismuc) { |
2013
8dc418af3e72
Allow to select to which buddy resource messages go. Closes issue #55
Hermitifier
parents:
2012
diff
changeset
|
2032 if (activeres) { |
8dc418af3e72
Allow to select to which buddy resource messages go. Closes issue #55
Hermitifier
parents:
2012
diff
changeset
|
2033 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
|
2034 fullname = fullnameres; |
8dc418af3e72
Allow to select to which buddy resource messages go. Closes issue #55
Hermitifier
parents:
2012
diff
changeset
|
2035 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
|
2036 } else { |
8dc418af3e72
Allow to select to which buddy resource messages go. Closes issue #55
Hermitifier
parents:
2012
diff
changeset
|
2037 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
|
2038 resources = buddy_getresources(BUDDATA(current_buddy)); |
8dc418af3e72
Allow to select to which buddy resource messages go. Closes issue #55
Hermitifier
parents:
2012
diff
changeset
|
2039 |
8dc418af3e72
Allow to select to which buddy resource messages go. Closes issue #55
Hermitifier
parents:
2012
diff
changeset
|
2040 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
|
2041 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
|
2042 // 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
|
2043 if (!p_next_res) |
8dc418af3e72
Allow to select to which buddy resource messages go. Closes issue #55
Hermitifier
parents:
2012
diff
changeset
|
2044 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
|
2045 g_free(p_res->data); |
8dc418af3e72
Allow to select to which buddy resource messages go. Closes issue #55
Hermitifier
parents:
2012
diff
changeset
|
2046 } |
8dc418af3e72
Allow to select to which buddy resource messages go. Closes issue #55
Hermitifier
parents:
2012
diff
changeset
|
2047 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
|
2048 } |
1502
50dbbca69b55
Small style improvement of buddy status line
Maxim Vuets <maxim.vuets@gmail.com>
parents:
1489
diff
changeset
|
2049 } else { |
721
9cf31c9b1dc4
Use room topic as a description in the chat status line
Mikael Berthe <mikael@lilotux.net>
parents:
720
diff
changeset
|
2050 msg = buddy_gettopic(BUDDATA(current_buddy)); |
717
8ce2bfdc4143
Reindent update_chat_status_window()
Mikael Berthe <mikael@lilotux.net>
parents:
716
diff
changeset
|
2051 } |
1502
50dbbca69b55
Small style improvement of buddy status line
Maxim Vuets <maxim.vuets@gmail.com>
parents:
1489
diff
changeset
|
2052 |
50dbbca69b55
Small style improvement of buddy status line
Maxim Vuets <maxim.vuets@gmail.com>
parents:
1489
diff
changeset
|
2053 if (msg) |
50dbbca69b55
Small style improvement of buddy status line
Maxim Vuets <maxim.vuets@gmail.com>
parents:
1489
diff
changeset
|
2054 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
|
2055 else |
50dbbca69b55
Small style improvement of buddy status line
Maxim Vuets <maxim.vuets@gmail.com>
parents:
1489
diff
changeset
|
2056 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
|
2057 replace_nl_with_dots(buf); |
773
e25b8a348ebd
Screen updating functions use UTF-8
Mikael Berthe <mikael@lilotux.net>
parents:
772
diff
changeset
|
2058 buf_locale = from_utf8(buf); |
e25b8a348ebd
Screen updating functions use UTF-8
Mikael Berthe <mikael@lilotux.net>
parents:
772
diff
changeset
|
2059 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
|
2060 g_free(fullnameres); |
773
e25b8a348ebd
Screen updating functions use UTF-8
Mikael Berthe <mikael@lilotux.net>
parents:
772
diff
changeset
|
2061 g_free(buf_locale); |
717
8ce2bfdc4143
Reindent update_chat_status_window()
Mikael Berthe <mikael@lilotux.net>
parents:
716
diff
changeset
|
2062 g_free(buf); |
8ce2bfdc4143
Reindent update_chat_status_window()
Mikael Berthe <mikael@lilotux.net>
parents:
716
diff
changeset
|
2063 |
996
f4d6570e2628
Chatstates: display contact chatstate in the chat status bar
Mikael Berthe <mikael@lilotux.net>
parents:
993
diff
changeset
|
2064 // 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
|
2065 if (btype & ROSTER_TYPE_USER) { |
f4d6570e2628
Chatstates: display contact chatstate in the chat status bar
Mikael Berthe <mikael@lilotux.net>
parents:
993
diff
changeset
|
2066 char eventchar = 0; |
f4d6570e2628
Chatstates: display contact chatstate in the chat status bar
Mikael Berthe <mikael@lilotux.net>
parents:
993
diff
changeset
|
2067 guint event; |
f4d6570e2628
Chatstates: display contact chatstate in the chat status bar
Mikael Berthe <mikael@lilotux.net>
parents:
993
diff
changeset
|
2068 |
2013
8dc418af3e72
Allow to select to which buddy resource messages go. Closes issue #55
Hermitifier
parents:
2012
diff
changeset
|
2069 // 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
|
2070 // 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
|
2071 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
|
2072 |
f4d6570e2628
Chatstates: display contact chatstate in the chat status bar
Mikael Berthe <mikael@lilotux.net>
parents:
993
diff
changeset
|
2073 if (event == ROSTER_EVENT_ACTIVE) |
f4d6570e2628
Chatstates: display contact chatstate in the chat status bar
Mikael Berthe <mikael@lilotux.net>
parents:
993
diff
changeset
|
2074 eventchar = 'A'; |
f4d6570e2628
Chatstates: display contact chatstate in the chat status bar
Mikael Berthe <mikael@lilotux.net>
parents:
993
diff
changeset
|
2075 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
|
2076 eventchar = 'C'; |
f4d6570e2628
Chatstates: display contact chatstate in the chat status bar
Mikael Berthe <mikael@lilotux.net>
parents:
993
diff
changeset
|
2077 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
|
2078 eventchar = 'P'; |
f4d6570e2628
Chatstates: display contact chatstate in the chat status bar
Mikael Berthe <mikael@lilotux.net>
parents:
993
diff
changeset
|
2079 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
|
2080 eventchar = 'I'; |
f4d6570e2628
Chatstates: display contact chatstate in the chat status bar
Mikael Berthe <mikael@lilotux.net>
parents:
993
diff
changeset
|
2081 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
|
2082 eventchar = 'G'; |
f4d6570e2628
Chatstates: display contact chatstate in the chat status bar
Mikael Berthe <mikael@lilotux.net>
parents:
993
diff
changeset
|
2083 |
f4d6570e2628
Chatstates: display contact chatstate in the chat status bar
Mikael Berthe <mikael@lilotux.net>
parents:
993
diff
changeset
|
2084 if (eventchar) |
f4d6570e2628
Chatstates: display contact chatstate in the chat status bar
Mikael Berthe <mikael@lilotux.net>
parents:
993
diff
changeset
|
2085 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
|
2086 } |
f4d6570e2628
Chatstates: display contact chatstate in the chat status bar
Mikael Berthe <mikael@lilotux.net>
parents:
993
diff
changeset
|
2087 |
f4d6570e2628
Chatstates: display contact chatstate in the chat status bar
Mikael Berthe <mikael@lilotux.net>
parents:
993
diff
changeset
|
2088 |
717
8ce2bfdc4143
Reindent update_chat_status_window()
Mikael Berthe <mikael@lilotux.net>
parents:
716
diff
changeset
|
2089 if (forceupdate) { |
8ce2bfdc4143
Reindent update_chat_status_window()
Mikael Berthe <mikael@lilotux.net>
parents:
716
diff
changeset
|
2090 update_panels(); |
8ce2bfdc4143
Reindent update_chat_status_window()
Mikael Berthe <mikael@lilotux.net>
parents:
716
diff
changeset
|
2091 } |
713 | 2092 } |
2093 | |
1504
9fafea381eb8
Show the number of unfiltered contacts in folded groups
franky
parents:
1503
diff
changeset
|
2094 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
|
2095 { |
9fafea381eb8
Show the number of unfiltered contacts in folded groups
franky
parents:
1503
diff
changeset
|
2096 int *p = param; |
9fafea381eb8
Show the number of unfiltered contacts in folded groups
franky
parents:
1503
diff
changeset
|
2097 if (buddylist_is_status_filtered(buddy_getstatus(rosterdata, NULL))) |
9fafea381eb8
Show the number of unfiltered contacts in folded groups
franky
parents:
1503
diff
changeset
|
2098 *p=*p+1; |
9fafea381eb8
Show the number of unfiltered contacts in folded groups
franky
parents:
1503
diff
changeset
|
2099 } |
9fafea381eb8
Show the number of unfiltered contacts in folded groups
franky
parents:
1503
diff
changeset
|
2100 |
1780
e4378fbab5d7
Major API cleanup - bump API to 4
Mikael Berthe <mikael@lilotux.net>
parents:
1761
diff
changeset
|
2101 // scr_draw_roster() |
328
83d129adde03
Add set_current_buddy() function, to reduce code duplication
Mikael Berthe <mikael@lilotux.net>
parents:
325
diff
changeset
|
2102 // 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
|
2103 void scr_draw_roster(void) |
24 | 2104 { |
735 | 2105 static int offset = 0; |
2324
4ddd6f5c3ffc
Add support for displaying the number of unread messages for each roster entry
Michał Kępień <bitbucket@kempniu.pl>
parents:
2313
diff
changeset
|
2106 char *name, *rline, *unread; |
81 | 2107 int maxx, maxy; |
2108 GList *buddy; | |
2109 int i, n; | |
2110 int rOffset; | |
713 | 2111 int cursor_backup; |
2100
113d3b96ae3e
Add option 'attention_char'
Mikael Berthe <mikael@lilotux.net>
parents:
2098
diff
changeset
|
2112 guint status, pending; |
1598 | 2113 enum imstatus currentstatus = xmpp_getstatus(); |
973
e693cbe33802
Add option 'roster_win_on_right'
Mikael Berthe <mikael@lilotux.net>
parents:
972
diff
changeset
|
2114 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
|
2115 int prefix_length; |
2136
54548cf8f646
screen.c: Remove one memory allocation in scr_draw_roster()
Mikael Berthe <mikael@lilotux.net>
parents:
2101
diff
changeset
|
2116 char space[2] = " "; |
81 | 2117 |
123 | 2118 // We can reset update_roster |
2292
f181418db215
Replace global variable update_roster with scr_update_roster()
franky
parents:
2291
diff
changeset
|
2119 if (_update_roster == FALSE) |
f181418db215
Replace global variable update_roster with scr_update_roster()
franky
parents:
2291
diff
changeset
|
2120 return; |
f181418db215
Replace global variable update_roster with scr_update_roster()
franky
parents:
2291
diff
changeset
|
2121 _update_roster = FALSE; |
123 | 2122 |
2291
0d350e979bde
Don't rebuild the buddylist multiple times before a screen refresh
franky
parents:
2288
diff
changeset
|
2123 buddylist_build(); |
0d350e979bde
Don't rebuild the buddylist multiple times before a screen refresh
franky
parents:
2288
diff
changeset
|
2124 |
81 | 2125 getmaxyx(rosterWnd, maxy, maxx); |
701
6c100adfbfb6
Add setting "roster_width" (variable buddylist width)
Mikael Berthe <mikael@lilotux.net>
parents:
699
diff
changeset
|
2126 maxx--; // Last char is for vertical border |
81 | 2127 |
713 | 2128 cursor_backup = curs_set(0); |
2129 | |
724
264375fe7159
Fix a roster refresh issue
Mikael Berthe <mikael@lilotux.net>
parents:
723
diff
changeset
|
2130 if (!buddylist) |
264375fe7159
Fix a roster refresh issue
Mikael Berthe <mikael@lilotux.net>
parents:
723
diff
changeset
|
2131 offset = 0; |
264375fe7159
Fix a roster refresh issue
Mikael Berthe <mikael@lilotux.net>
parents:
723
diff
changeset
|
2132 else |
1780
e4378fbab5d7
Major API cleanup - bump API to 4
Mikael Berthe <mikael@lilotux.net>
parents:
1761
diff
changeset
|
2133 scr_update_chat_status(FALSE); |
724
264375fe7159
Fix a roster refresh issue
Mikael Berthe <mikael@lilotux.net>
parents:
723
diff
changeset
|
2134 |
701
6c100adfbfb6
Add setting "roster_width" (variable buddylist width)
Mikael Berthe <mikael@lilotux.net>
parents:
699
diff
changeset
|
2135 // Cleanup of roster window |
2328 | 2136 wbkgdset(rosterWnd, get_color(COLOR_GENERAL)); // clear background color |
168 | 2137 werase(rosterWnd); |
81 | 2138 |
707
b26a0bde4cdb
Add /roster hide|show|toggle
Mikael Berthe <mikael@lilotux.net>
parents:
701
diff
changeset
|
2139 if (Roster_Width) { |
973
e693cbe33802
Add option 'roster_win_on_right'
Mikael Berthe <mikael@lilotux.net>
parents:
972
diff
changeset
|
2140 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
|
2141 // Redraw the vertical line (not very good...) |
b26a0bde4cdb
Add /roster hide|show|toggle
Mikael Berthe <mikael@lilotux.net>
parents:
701
diff
changeset
|
2142 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
|
2143 mvwaddch(rosterWnd, i, line_x_pos, ACS_VLINE); |
707
b26a0bde4cdb
Add /roster hide|show|toggle
Mikael Berthe <mikael@lilotux.net>
parents:
701
diff
changeset
|
2144 } |
b26a0bde4cdb
Add /roster hide|show|toggle
Mikael Berthe <mikael@lilotux.net>
parents:
701
diff
changeset
|
2145 |
b26a0bde4cdb
Add /roster hide|show|toggle
Mikael Berthe <mikael@lilotux.net>
parents:
701
diff
changeset
|
2146 // 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
|
2147 if (!buddylist || !Roster_Width) { |
123 | 2148 update_panels(); |
713 | 2149 curs_set(cursor_backup); |
81 | 2150 return; |
2151 } | |
2152 | |
84 | 2153 // Update offset if necessary |
680
1f8987e0e56c
Try to display as many buddylist items as possible
Mikael Berthe <mikael@lilotux.net>
parents:
679
diff
changeset
|
2154 // 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
|
2155 i = g_list_length(buddylist) - maxy; |
682
f3945593432e
Small fix in scr_DrawRoster()
Mikael Berthe <mikael@lilotux.net>
parents:
680
diff
changeset
|
2156 if (i < 0) |
f3945593432e
Small fix in scr_DrawRoster()
Mikael Berthe <mikael@lilotux.net>
parents:
680
diff
changeset
|
2157 i = 0; |
f3945593432e
Small fix in scr_DrawRoster()
Mikael Berthe <mikael@lilotux.net>
parents:
680
diff
changeset
|
2158 if (i < offset) |
680
1f8987e0e56c
Try to display as many buddylist items as possible
Mikael Berthe <mikael@lilotux.net>
parents:
679
diff
changeset
|
2159 offset = i; |
1f8987e0e56c
Try to display as many buddylist items as possible
Mikael Berthe <mikael@lilotux.net>
parents:
679
diff
changeset
|
2160 // b) Make sure the current_buddy is visible |
84 | 2161 i = g_list_position(buddylist, current_buddy); |
2162 if (i == -1) { // This is bad | |
374
bd5638c21834
Improve logging system (traces)
Mikael Berthe <mikael@lilotux.net>
parents:
373
diff
changeset
|
2163 scr_LogPrint(LPRINT_NORMAL, "Doh! Can't find current selected buddy!!"); |
713 | 2164 curs_set(cursor_backup); |
84 | 2165 return; |
2166 } else if (i < offset) { | |
2167 offset = i; | |
2168 } else if (i+1 > offset + maxy) { | |
2169 offset = i + 1 - maxy; | |
2170 } | |
81 | 2171 |
973
e693cbe33802
Add option 'roster_win_on_right'
Mikael Berthe <mikael@lilotux.net>
parents:
972
diff
changeset
|
2172 if (roster_win_on_right) |
e693cbe33802
Add option 'roster_win_on_right'
Mikael Berthe <mikael@lilotux.net>
parents:
972
diff
changeset
|
2173 x_pos = 1; // 1 char offset (vertical line) |
e693cbe33802
Add option 'roster_win_on_right'
Mikael Berthe <mikael@lilotux.net>
parents:
972
diff
changeset
|
2174 else |
e693cbe33802
Add option 'roster_win_on_right'
Mikael Berthe <mikael@lilotux.net>
parents:
972
diff
changeset
|
2175 x_pos = 0; |
e693cbe33802
Add option 'roster_win_on_right'
Mikael Berthe <mikael@lilotux.net>
parents:
972
diff
changeset
|
2176 |
2009
a859ed648638
Replace the option « no_space_before_items » with « roster_no_leading_space ».
Simon Jacquin <simon@jacquin.me>
parents:
2008
diff
changeset
|
2177 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
|
2178 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
|
2179 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
|
2180 } else { |
6c02ccb14c1c
Added an option to remove the extra space before items in the roster.
Simon Jacquin <simon@jacquin.me>
parents:
1997
diff
changeset
|
2181 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
|
2182 } |
6c02ccb14c1c
Added an option to remove the extra space before items in the roster.
Simon Jacquin <simon@jacquin.me>
parents:
1997
diff
changeset
|
2183 |
1026
fc6060707022
[BP] Fixes truncating utf-8 buddy names (Myhailo Danylenko)
Mikael Berthe <mikael@lilotux.net>
parents:
966
diff
changeset
|
2184 name = g_new0(char, 4*Roster_Width); |
2324
4ddd6f5c3ffc
Add support for displaying the number of unread messages for each roster entry
Michał Kępień <bitbucket@kempniu.pl>
parents:
2313
diff
changeset
|
2185 unread = g_new0(char, Roster_Width+1);; |
1026
fc6060707022
[BP] Fixes truncating utf-8 buddy names (Myhailo Danylenko)
Mikael Berthe <mikael@lilotux.net>
parents:
966
diff
changeset
|
2186 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
|
2187 |
81 | 2188 buddy = buddylist; |
2189 rOffset = offset; | |
2190 | |
84 | 2191 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
|
2192 unsigned short bflags, btype; |
35a1250c111a
Display urgent/attention sign in the roster UI
Mikael Berthe <mikael@lilotux.net>
parents:
1802
diff
changeset
|
2193 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
|
2194 guint isurg; |
773
e25b8a348ebd
Screen updating functions use UTF-8
Mikael Berthe <mikael@lilotux.net>
parents:
772
diff
changeset
|
2195 gchar *rline_locale; |
713 | 2196 |
2197 bflags = buddy_getflags(BUDDATA(buddy)); | |
2198 btype = buddy_gettype(BUDDATA(buddy)); | |
2199 | |
2200 ismsg = bflags & ROSTER_FLAG_MSG; | |
2201 ishid = bflags & ROSTER_FLAG_HIDE; | |
2202 isgrp = btype & ROSTER_TYPE_GROUP; | |
2203 ismuc = btype & ROSTER_TYPE_ROOM; | |
848
a9161d2dc414
Introduce special buffer stuff
Mikael Berthe <mikael@lilotux.net>
parents:
843
diff
changeset
|
2204 isspe = btype & ROSTER_TYPE_SPECIAL; |
1804
35a1250c111a
Display urgent/attention sign in the roster UI
Mikael Berthe <mikael@lilotux.net>
parents:
1802
diff
changeset
|
2205 isurg = buddy_getuiprio(BUDDATA(buddy)); |
81 | 2206 |
2207 if (rOffset > 0) { | |
2208 rOffset--; | |
2209 continue; | |
2210 } | |
2211 | |
713 | 2212 status = '?'; |
2213 pending = ' '; | |
2214 | |
2280
f1eebfdd6db7
Improve efficiency with high number of MUC resources
Mikael Berthe <mikael@lilotux.net>
parents:
2268
diff
changeset
|
2215 if (!ismuc) { |
f1eebfdd6db7
Improve efficiency with high number of MUC resources
Mikael Berthe <mikael@lilotux.net>
parents:
2268
diff
changeset
|
2216 // 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
|
2217 GSList *resources = buddy_getresources(BUDDATA(buddy)); |
f1eebfdd6db7
Improve efficiency with high number of MUC resources
Mikael Berthe <mikael@lilotux.net>
parents:
2268
diff
changeset
|
2218 GSList *p_res; |
f1eebfdd6db7
Improve efficiency with high number of MUC resources
Mikael Berthe <mikael@lilotux.net>
parents:
2268
diff
changeset
|
2219 |
f1eebfdd6db7
Improve efficiency with high number of MUC resources
Mikael Berthe <mikael@lilotux.net>
parents:
2268
diff
changeset
|
2220 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
|
2221 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
|
2222 p_res ? p_res->data : ""); |
f1eebfdd6db7
Improve efficiency with high number of MUC resources
Mikael Berthe <mikael@lilotux.net>
parents:
2268
diff
changeset
|
2223 if ((events & ROSTER_EVENT_PAUSED) && pending != '+') |
f1eebfdd6db7
Improve efficiency with high number of MUC resources
Mikael Berthe <mikael@lilotux.net>
parents:
2268
diff
changeset
|
2224 pending = '.'; |
f1eebfdd6db7
Improve efficiency with high number of MUC resources
Mikael Berthe <mikael@lilotux.net>
parents:
2268
diff
changeset
|
2225 if (events & ROSTER_EVENT_COMPOSING) |
f1eebfdd6db7
Improve efficiency with high number of MUC resources
Mikael Berthe <mikael@lilotux.net>
parents:
2268
diff
changeset
|
2226 pending = '+'; |
f1eebfdd6db7
Improve efficiency with high number of MUC resources
Mikael Berthe <mikael@lilotux.net>
parents:
2268
diff
changeset
|
2227 g_free(p_res->data); |
f1eebfdd6db7
Improve efficiency with high number of MUC resources
Mikael Berthe <mikael@lilotux.net>
parents:
2268
diff
changeset
|
2228 } |
f1eebfdd6db7
Improve efficiency with high number of MUC resources
Mikael Berthe <mikael@lilotux.net>
parents:
2268
diff
changeset
|
2229 g_slist_free(resources); |
986
ed697234bd39
Chat states receival (Alexis Hildebrandt)
Mikael Berthe <mikael@lilotux.net>
parents:
981
diff
changeset
|
2230 } |
ed697234bd39
Chat states receival (Alexis Hildebrandt)
Mikael Berthe <mikael@lilotux.net>
parents:
981
diff
changeset
|
2231 |
149 | 2232 // Display message notice if there is a message flag, but not |
2233 // for unfolded groups. | |
2234 if (ismsg && (!isgrp || ishid)) { | |
81 | 2235 pending = '#'; |
2236 } | |
2237 | |
713 | 2238 if (ismuc) { |
2239 if (buddy_getinsideroom(BUDDATA(buddy))) | |
2240 status = 'C'; | |
2241 else | |
2242 status = 'x'; | |
2243 } else if (currentstatus != offline) { | |
2244 enum imstatus budstate; | |
2245 budstate = buddy_getstatus(BUDDATA(buddy), NULL); | |
790
5d4ad1d77da4
Kill a few gcc4 warnings
Mikael Berthe <mikael@lilotux.net>
parents:
785
diff
changeset
|
2246 if (budstate < imstatus_size) |
713 | 2247 status = imstatus2char[budstate]; |
2248 } | |
81 | 2249 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
|
2250 if (pending == '#') |
2328 | 2251 wbkgdset(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
|
2252 else |
2328 | 2253 wbkgdset(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
|
2254 // 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
|
2255 wmove(rosterWnd, i, x_pos); |
81 | 2256 for (n = 0; n < maxx; n++) |
2257 waddch(rosterWnd, ' '); | |
2258 } else { | |
149 | 2259 if (pending == '#') |
2328 | 2260 wbkgdset(rosterWnd, get_color(COLOR_ROSTERNMSG)); |
1272
033576acac4c
Add configurable roster colors (Michal 'vorner' Vaner)
Mikael Berthe <mikael@lilotux.net>
parents:
1268
diff
changeset
|
2261 else { |
033576acac4c
Add configurable roster colors (Michal 'vorner' Vaner)
Mikael Berthe <mikael@lilotux.net>
parents:
1268
diff
changeset
|
2262 int color = get_color(COLOR_ROSTER); |
1729
e6e89b1d7831
Minor style and header updates
Mikael Berthe <mikael@lilotux.net>
parents:
1710
diff
changeset
|
2263 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
|
2264 GSList *head; |
1804
35a1250c111a
Display urgent/attention sign in the roster UI
Mikael Berthe <mikael@lilotux.net>
parents:
1802
diff
changeset
|
2265 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
|
2266 for (head = rostercolrules; head; head = g_slist_next(head)) { |
2337 | 2267 rostercolor_t *rc = head->data; |
1804
35a1250c111a
Display urgent/attention sign in the roster UI
Mikael Berthe <mikael@lilotux.net>
parents:
1802
diff
changeset
|
2268 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
|
2269 (!strcmp("*", rc->status) || strchr(rc->status, status))) { |
1489
e9c71ce96dca
Fixed the colorhandling for mucnicks and /color roster
franky@veqlargh.fs
parents:
1488
diff
changeset
|
2270 color = compose_color(rc->color); |
1272
033576acac4c
Add configurable roster colors (Michal 'vorner' Vaner)
Mikael Berthe <mikael@lilotux.net>
parents:
1268
diff
changeset
|
2271 break; |
033576acac4c
Add configurable roster colors (Michal 'vorner' Vaner)
Mikael Berthe <mikael@lilotux.net>
parents:
1268
diff
changeset
|
2272 } |
033576acac4c
Add configurable roster colors (Michal 'vorner' Vaner)
Mikael Berthe <mikael@lilotux.net>
parents:
1268
diff
changeset
|
2273 } |
033576acac4c
Add configurable roster colors (Michal 'vorner' Vaner)
Mikael Berthe <mikael@lilotux.net>
parents:
1268
diff
changeset
|
2274 } |
2328 | 2275 wbkgdset(rosterWnd, color); |
1272
033576acac4c
Add configurable roster colors (Michal 'vorner' Vaner)
Mikael Berthe <mikael@lilotux.net>
parents:
1268
diff
changeset
|
2276 } |
81 | 2277 } |
2278 | |
2324
4ddd6f5c3ffc
Add support for displaying the number of unread messages for each roster entry
Michał Kępień <bitbucket@kempniu.pl>
parents:
2313
diff
changeset
|
2279 name[0] = 0; |
4ddd6f5c3ffc
Add support for displaying the number of unread messages for each roster entry
Michał Kępień <bitbucket@kempniu.pl>
parents:
2313
diff
changeset
|
2280 unread[0] = 0; |
4ddd6f5c3ffc
Add support for displaying the number of unread messages for each roster entry
Michał Kępień <bitbucket@kempniu.pl>
parents:
2313
diff
changeset
|
2281 if (Roster_Width > prefix_length) { |
2007
6c02ccb14c1c
Added an option to remove the extra space before items in the roster.
Simon Jacquin <simon@jacquin.me>
parents:
1997
diff
changeset
|
2282 g_utf8_strncpy(name, buddy_getname(BUDDATA(buddy)), Roster_Width-prefix_length); |
2324
4ddd6f5c3ffc
Add support for displaying the number of unread messages for each roster entry
Michał Kępień <bitbucket@kempniu.pl>
parents:
2313
diff
changeset
|
2283 if (settings_opt_get_int("roster_show_unread_count")) { |
4ddd6f5c3ffc
Add support for displaying the number of unread messages for each roster entry
Michał Kępień <bitbucket@kempniu.pl>
parents:
2313
diff
changeset
|
2284 guint unread_count = buddy_getunread(BUDDATA(buddy)); |
4ddd6f5c3ffc
Add support for displaying the number of unread messages for each roster entry
Michał Kępień <bitbucket@kempniu.pl>
parents:
2313
diff
changeset
|
2285 glong name_length = g_utf8_strlen(name, 4*Roster_Width); |
4ddd6f5c3ffc
Add support for displaying the number of unread messages for each roster entry
Michał Kępień <bitbucket@kempniu.pl>
parents:
2313
diff
changeset
|
2286 if (unread_count > 0 && Roster_Width > prefix_length + name_length) { |
4ddd6f5c3ffc
Add support for displaying the number of unread messages for each roster entry
Michał Kępień <bitbucket@kempniu.pl>
parents:
2313
diff
changeset
|
2287 snprintf(unread, Roster_Width-(prefix_length+name_length)+1, " (%u)", unread_count); |
4ddd6f5c3ffc
Add support for displaying the number of unread messages for each roster entry
Michał Kępień <bitbucket@kempniu.pl>
parents:
2313
diff
changeset
|
2288 } |
4ddd6f5c3ffc
Add support for displaying the number of unread messages for each roster entry
Michał Kępień <bitbucket@kempniu.pl>
parents:
2313
diff
changeset
|
2289 } |
4ddd6f5c3ffc
Add support for displaying the number of unread messages for each roster entry
Michał Kępień <bitbucket@kempniu.pl>
parents:
2313
diff
changeset
|
2290 } |
701
6c100adfbfb6
Add setting "roster_width" (variable buddylist width)
Mikael Berthe <mikael@lilotux.net>
parents:
699
diff
changeset
|
2291 |
1804
35a1250c111a
Display urgent/attention sign in the roster UI
Mikael Berthe <mikael@lilotux.net>
parents:
1802
diff
changeset
|
2292 if (pending == '#') { |
35a1250c111a
Display urgent/attention sign in the roster UI
Mikael Berthe <mikael@lilotux.net>
parents:
1802
diff
changeset
|
2293 // Attention sign? |
35a1250c111a
Display urgent/attention sign in the roster UI
Mikael Berthe <mikael@lilotux.net>
parents:
1802
diff
changeset
|
2294 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
|
2295 (!ismuc && isurg >= ui_attn_sign_prio_level)) |
2100
113d3b96ae3e
Add option 'attention_char'
Mikael Berthe <mikael@lilotux.net>
parents:
2098
diff
changeset
|
2296 pending = attention_sign(); |
1804
35a1250c111a
Display urgent/attention sign in the roster UI
Mikael Berthe <mikael@lilotux.net>
parents:
1802
diff
changeset
|
2297 } |
35a1250c111a
Display urgent/attention sign in the roster UI
Mikael Berthe <mikael@lilotux.net>
parents:
1802
diff
changeset
|
2298 |
149 | 2299 if (isgrp) { |
1598 | 2300 if (ishid) { |
1504
9fafea381eb8
Show the number of unfiltered contacts in folded groups
franky
parents:
1503
diff
changeset
|
2301 int group_count = 0; |
9fafea381eb8
Show the number of unfiltered contacts in folded groups
franky
parents:
1503
diff
changeset
|
2302 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
|
2303 &group_count); |
2100
113d3b96ae3e
Add option 'attention_char'
Mikael Berthe <mikael@lilotux.net>
parents:
2098
diff
changeset
|
2304 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
|
2305 name, group_count); |
1579
a2dd83167bc9
Fix display error in the roster
Mikael Berthe <mikael@lilotux.net>
parents:
1573
diff
changeset
|
2306 /* 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
|
2307 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
|
2308 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
|
2309 } |
133 | 2310 else |
2100
113d3b96ae3e
Add option 'attention_char'
Mikael Berthe <mikael@lilotux.net>
parents:
2098
diff
changeset
|
2311 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
|
2312 } else if (isspe) { |
2100
113d3b96ae3e
Add option 'attention_char'
Mikael Berthe <mikael@lilotux.net>
parents:
2098
diff
changeset
|
2313 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
|
2314 } else { |
824
37ef269330f0
Show incomplete subscriptions in the roster
Mikael Berthe <mikael@lilotux.net>
parents:
822
diff
changeset
|
2315 char sepleft = '['; |
37ef269330f0
Show incomplete subscriptions in the roster
Mikael Berthe <mikael@lilotux.net>
parents:
822
diff
changeset
|
2316 char sepright = ']'; |
37ef269330f0
Show incomplete subscriptions in the roster
Mikael Berthe <mikael@lilotux.net>
parents:
822
diff
changeset
|
2317 if (btype & ROSTER_TYPE_USER) { |
37ef269330f0
Show incomplete subscriptions in the roster
Mikael Berthe <mikael@lilotux.net>
parents:
822
diff
changeset
|
2318 guint subtype = buddy_getsubscription(BUDDATA(buddy)); |
832
7c210263c661
Small scr_DrawRoster() fix
Mikael Berthe <mikael@lilotux.net>
parents:
828
diff
changeset
|
2319 if (status == '_' && !(subtype & sub_to)) |
824
37ef269330f0
Show incomplete subscriptions in the roster
Mikael Berthe <mikael@lilotux.net>
parents:
822
diff
changeset
|
2320 status = '?'; |
37ef269330f0
Show incomplete subscriptions in the roster
Mikael Berthe <mikael@lilotux.net>
parents:
822
diff
changeset
|
2321 if (!(subtype & sub_from)) { |
37ef269330f0
Show incomplete subscriptions in the roster
Mikael Berthe <mikael@lilotux.net>
parents:
822
diff
changeset
|
2322 sepleft = '{'; |
37ef269330f0
Show incomplete subscriptions in the roster
Mikael Berthe <mikael@lilotux.net>
parents:
822
diff
changeset
|
2323 sepright = '}'; |
37ef269330f0
Show incomplete subscriptions in the roster
Mikael Berthe <mikael@lilotux.net>
parents:
822
diff
changeset
|
2324 } |
37ef269330f0
Show incomplete subscriptions in the roster
Mikael Berthe <mikael@lilotux.net>
parents:
822
diff
changeset
|
2325 } |
2324
4ddd6f5c3ffc
Add support for displaying the number of unread messages for each roster entry
Michał Kępień <bitbucket@kempniu.pl>
parents:
2313
diff
changeset
|
2326 snprintf(rline, 4*Roster_Width, "%s%lc%c%c%c %s%s", |
4ddd6f5c3ffc
Add support for displaying the number of unread messages for each roster entry
Michał Kępień <bitbucket@kempniu.pl>
parents:
2313
diff
changeset
|
2327 space, pending, sepleft, status, sepright, name, unread); |
133 | 2328 } |
84 | 2329 |
773
e25b8a348ebd
Screen updating functions use UTF-8
Mikael Berthe <mikael@lilotux.net>
parents:
772
diff
changeset
|
2330 rline_locale = from_utf8(rline); |
981
553b8ecf901f
Fixes truncating of utf-8 buddy names (again)
Myhailo Danylenko <isbear@ukrpost.net>
parents:
980
diff
changeset
|
2331 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
|
2332 g_free(rline_locale); |
84 | 2333 i++; |
81 | 2334 } |
2335 | |
701
6c100adfbfb6
Add setting "roster_width" (variable buddylist width)
Mikael Berthe <mikael@lilotux.net>
parents:
699
diff
changeset
|
2336 g_free(rline); |
2324
4ddd6f5c3ffc
Add support for displaying the number of unread messages for each roster entry
Michał Kępień <bitbucket@kempniu.pl>
parents:
2313
diff
changeset
|
2337 g_free(unread); |
701
6c100adfbfb6
Add setting "roster_width" (variable buddylist width)
Mikael Berthe <mikael@lilotux.net>
parents:
699
diff
changeset
|
2338 g_free(name); |
142 | 2339 top_panel(inputPanel); |
81 | 2340 update_panels(); |
713 | 2341 curs_set(cursor_backup); |
24 | 2342 } |
2343 | |
2292
f181418db215
Replace global variable update_roster with scr_update_roster()
franky
parents:
2291
diff
changeset
|
2344 void scr_update_roster(void) |
f181418db215
Replace global variable update_roster with scr_update_roster()
franky
parents:
2291
diff
changeset
|
2345 { |
f181418db215
Replace global variable update_roster with scr_update_roster()
franky
parents:
2291
diff
changeset
|
2346 _update_roster = TRUE; |
f181418db215
Replace global variable update_roster with scr_update_roster()
franky
parents:
2291
diff
changeset
|
2347 } |
f181418db215
Replace global variable update_roster with scr_update_roster()
franky
parents:
2291
diff
changeset
|
2348 |
f181418db215
Replace global variable update_roster with scr_update_roster()
franky
parents:
2291
diff
changeset
|
2349 |
1780
e4378fbab5d7
Major API cleanup - bump API to 4
Mikael Berthe <mikael@lilotux.net>
parents:
1761
diff
changeset
|
2350 // scr_roster_visibility(status) |
707
b26a0bde4cdb
Add /roster hide|show|toggle
Mikael Berthe <mikael@lilotux.net>
parents:
701
diff
changeset
|
2351 // Set the roster visibility: |
b26a0bde4cdb
Add /roster hide|show|toggle
Mikael Berthe <mikael@lilotux.net>
parents:
701
diff
changeset
|
2352 // status=1 Show roster |
b26a0bde4cdb
Add /roster hide|show|toggle
Mikael Berthe <mikael@lilotux.net>
parents:
701
diff
changeset
|
2353 // status=0 Hide roster |
b26a0bde4cdb
Add /roster hide|show|toggle
Mikael Berthe <mikael@lilotux.net>
parents:
701
diff
changeset
|
2354 // status=-1 Toggle roster status |
1780
e4378fbab5d7
Major API cleanup - bump API to 4
Mikael Berthe <mikael@lilotux.net>
parents:
1761
diff
changeset
|
2355 void scr_roster_visibility(int status) |
707
b26a0bde4cdb
Add /roster hide|show|toggle
Mikael Berthe <mikael@lilotux.net>
parents:
701
diff
changeset
|
2356 { |
708
ed326697e4ed
scr_RosterVisibility(): do not refresh when it is not needed
Mikael Berthe <mikael@lilotux.net>
parents:
707
diff
changeset
|
2357 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
|
2358 |
707
b26a0bde4cdb
Add /roster hide|show|toggle
Mikael Berthe <mikael@lilotux.net>
parents:
701
diff
changeset
|
2359 if (status > 0) |
b26a0bde4cdb
Add /roster hide|show|toggle
Mikael Berthe <mikael@lilotux.net>
parents:
701
diff
changeset
|
2360 roster_hidden = FALSE; |
b26a0bde4cdb
Add /roster hide|show|toggle
Mikael Berthe <mikael@lilotux.net>
parents:
701
diff
changeset
|
2361 else if (status == 0) |
b26a0bde4cdb
Add /roster hide|show|toggle
Mikael Berthe <mikael@lilotux.net>
parents:
701
diff
changeset
|
2362 roster_hidden = TRUE; |
b26a0bde4cdb
Add /roster hide|show|toggle
Mikael Berthe <mikael@lilotux.net>
parents:
701
diff
changeset
|
2363 else |
b26a0bde4cdb
Add /roster hide|show|toggle
Mikael Berthe <mikael@lilotux.net>
parents:
701
diff
changeset
|
2364 roster_hidden = !roster_hidden; |
b26a0bde4cdb
Add /roster hide|show|toggle
Mikael Berthe <mikael@lilotux.net>
parents:
701
diff
changeset
|
2365 |
708
ed326697e4ed
scr_RosterVisibility(): do not refresh when it is not needed
Mikael Berthe <mikael@lilotux.net>
parents:
707
diff
changeset
|
2366 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
|
2367 // Recalculate windows size and redraw |
2231
387cea2a1a81
Fix resizing with --enable-sigwinch
Mikael Berthe <mikael@lilotux.net>
parents:
2226
diff
changeset
|
2368 scr_resize(); |
708
ed326697e4ed
scr_RosterVisibility(): do not refresh when it is not needed
Mikael Berthe <mikael@lilotux.net>
parents:
707
diff
changeset
|
2369 redrawwin(stdscr); |
ed326697e4ed
scr_RosterVisibility(): do not refresh when it is not needed
Mikael Berthe <mikael@lilotux.net>
parents:
707
diff
changeset
|
2370 } |
707
b26a0bde4cdb
Add /roster hide|show|toggle
Mikael Berthe <mikael@lilotux.net>
parents:
701
diff
changeset
|
2371 } |
b26a0bde4cdb
Add /roster hide|show|toggle
Mikael Berthe <mikael@lilotux.net>
parents:
701
diff
changeset
|
2372 |
1780
e4378fbab5d7
Major API cleanup - bump API to 4
Mikael Berthe <mikael@lilotux.net>
parents:
1761
diff
changeset
|
2373 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
|
2374 time_t timestamp, guint prefix_flags, |
e4378fbab5d7
Major API cleanup - bump API to 4
Mikael Berthe <mikael@lilotux.net>
parents:
1761
diff
changeset
|
2375 unsigned mucnicklen, gpointer xep184) |
24 | 2376 { |
727
1c3620668857
Expand tabs when reading history files
Mikael Berthe <mikael@lilotux.net>
parents:
726
diff
changeset
|
2377 char *xtext; |
725
1aff92625bdb
Expand tabs when receiving a message
Mikael Berthe <mikael@lilotux.net>
parents:
724
diff
changeset
|
2378 |
2090
16b04d64ec88
Add option to highlight timestamp added by server.
Hermitifier
parents:
2074
diff
changeset
|
2379 if (!timestamp) |
16b04d64ec88
Add option to highlight timestamp added by server.
Hermitifier
parents:
2074
diff
changeset
|
2380 timestamp = time(NULL); |
16b04d64ec88
Add option to highlight timestamp added by server.
Hermitifier
parents:
2074
diff
changeset
|
2381 else |
16b04d64ec88
Add option to highlight timestamp added by server.
Hermitifier
parents:
2074
diff
changeset
|
2382 prefix_flags |= HBB_PREFIX_DELAYED; |
725
1aff92625bdb
Expand tabs when receiving a message
Mikael Berthe <mikael@lilotux.net>
parents:
724
diff
changeset
|
2383 |
1122
648fe6f715a6
Filter out ^M (0x0d) characters in incoming messages
Mikael Berthe <mikael@lilotux.net>
parents:
1115
diff
changeset
|
2384 xtext = ut_expand_tabs(text); // Expand tabs and filter out some chars |
726 | 2385 |
1780
e4378fbab5d7
Major API cleanup - bump API to 4
Mikael Berthe <mikael@lilotux.net>
parents:
1761
diff
changeset
|
2386 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
|
2387 xep184); |
725
1aff92625bdb
Expand tabs when receiving a message
Mikael Berthe <mikael@lilotux.net>
parents:
724
diff
changeset
|
2388 |
1aff92625bdb
Expand tabs when receiving a message
Mikael Berthe <mikael@lilotux.net>
parents:
724
diff
changeset
|
2389 if (xtext != (char*)text) |
1aff92625bdb
Expand tabs when receiving a message
Mikael Berthe <mikael@lilotux.net>
parents:
724
diff
changeset
|
2390 g_free(xtext); |
24 | 2391 } |
2392 | |
726 | 2393 // 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
|
2394 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
|
2395 time_t timestamp, |
af3de54ef986
Convert scr_LogPrint() to scr_log_print()
Mikael Berthe <mikael@lilotux.net>
parents:
1780
diff
changeset
|
2396 guint prefix, unsigned mucnicklen) |
726 | 2397 { |
1055
6eb1efea75d0
PGP: Visual encryption flag
Mikael Berthe <mikael@lilotux.net>
parents:
1050
diff
changeset
|
2398 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
|
2399 ~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
|
2400 ~HBB_PREFIX_PGPCRYPT & ~HBB_PREFIX_OTRCRYPT & ~HBB_PREFIX_CARBON)) |
726 | 2401 prefix |= HBB_PREFIX_IN; |
2402 | |
1780
e4378fbab5d7
Major API cleanup - bump API to 4
Mikael Berthe <mikael@lilotux.net>
parents:
1761
diff
changeset
|
2403 scr_write_message(jidfrom, text, timestamp, prefix, mucnicklen, NULL); |
726 | 2404 } |
2405 | |
1783
af3de54ef986
Convert scr_LogPrint() to scr_log_print()
Mikael Berthe <mikael@lilotux.net>
parents:
1780
diff
changeset
|
2406 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
|
2407 guint prefix, gpointer xep184) |
47 | 2408 { |
1115
922a9ae1a17e
Fix /say_to to a member of a folded group
Mikael Berthe <mikael@lilotux.net>
parents:
1093
diff
changeset
|
2409 GSList *roster_elt; |
922a9ae1a17e
Fix /say_to to a member of a folded group
Mikael Berthe <mikael@lilotux.net>
parents:
1093
diff
changeset
|
2410 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
|
2411 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
|
2412 |
1780
e4378fbab5d7
Major API cleanup - bump API to 4
Mikael Berthe <mikael@lilotux.net>
parents:
1761
diff
changeset
|
2413 scr_write_message(jidto, text, |
e4378fbab5d7
Major API cleanup - bump API to 4
Mikael Berthe <mikael@lilotux.net>
parents:
1761
diff
changeset
|
2414 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
|
2415 |
922a9ae1a17e
Fix /say_to to a member of a folded group
Mikael Berthe <mikael@lilotux.net>
parents:
1093
diff
changeset
|
2416 // 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
|
2417 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
|
2418 scr_show_window(jidto, FALSE); |
47 | 2419 } |
2420 | |
2032
f740c4128f76
Fix receipts handling according to recent XEP updates
Myhailo Danylenko <isbear@ukrpost.net>
parents:
2029
diff
changeset
|
2421 void scr_remove_receipt_flag(const char *bjid, gconstpointer xep184) |
1602 | 2422 { |
2337 | 2423 winbuf_t *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
|
2424 if (win_entry && xep184) { |
1602 | 2425 hbuf_remove_receipt(win_entry->bd->hbuf, xep184); |
2426 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
|
2427 scr_update_buddy_window(); |
1602 | 2428 } |
2429 } | |
2430 | |
935
97e6a6da2b2c
Fix ncurses #include (again)
Mikael Berthe <mikael@lilotux.net>
parents:
933
diff
changeset
|
2431 static inline void set_autoaway(bool setaway) |
373
af2f8ddf6a1b
Move (reorganize) functions
Mikael Berthe <mikael@lilotux.net>
parents:
370
diff
changeset
|
2432 { |
af2f8ddf6a1b
Move (reorganize) functions
Mikael Berthe <mikael@lilotux.net>
parents:
370
diff
changeset
|
2433 static enum imstatus oldstatus; |
521 | 2434 static char *oldmsg; |
373
af2f8ddf6a1b
Move (reorganize) functions
Mikael Berthe <mikael@lilotux.net>
parents:
370
diff
changeset
|
2435 Autoaway = setaway; |
af2f8ddf6a1b
Move (reorganize) functions
Mikael Berthe <mikael@lilotux.net>
parents:
370
diff
changeset
|
2436 |
af2f8ddf6a1b
Move (reorganize) functions
Mikael Berthe <mikael@lilotux.net>
parents:
370
diff
changeset
|
2437 if (setaway) { |
521 | 2438 const char *msg, *prevmsg; |
1598 | 2439 oldstatus = xmpp_getstatus(); |
521 | 2440 if (oldmsg) { |
2441 g_free(oldmsg); | |
2442 oldmsg = NULL; | |
2443 } | |
1598 | 2444 prevmsg = xmpp_getstatusmsg(); |
373
af2f8ddf6a1b
Move (reorganize) functions
Mikael Berthe <mikael@lilotux.net>
parents:
370
diff
changeset
|
2445 msg = settings_opt_get("message_autoaway"); |
521 | 2446 if (!msg) |
2447 msg = prevmsg; | |
2448 if (prevmsg) | |
2449 oldmsg = g_strdup(prevmsg); | |
1598 | 2450 xmpp_setstatus(away, NULL, msg, FALSE); |
373
af2f8ddf6a1b
Move (reorganize) functions
Mikael Berthe <mikael@lilotux.net>
parents:
370
diff
changeset
|
2451 } else { |
af2f8ddf6a1b
Move (reorganize) functions
Mikael Berthe <mikael@lilotux.net>
parents:
370
diff
changeset
|
2452 // Back |
1598 | 2453 xmpp_setstatus(oldstatus, NULL, (oldmsg ? oldmsg : ""), FALSE); |
521 | 2454 if (oldmsg) { |
2455 g_free(oldmsg); | |
2456 oldmsg = NULL; | |
2457 } | |
373
af2f8ddf6a1b
Move (reorganize) functions
Mikael Berthe <mikael@lilotux.net>
parents:
370
diff
changeset
|
2458 } |
af2f8ddf6a1b
Move (reorganize) functions
Mikael Berthe <mikael@lilotux.net>
parents:
370
diff
changeset
|
2459 } |
af2f8ddf6a1b
Move (reorganize) functions
Mikael Berthe <mikael@lilotux.net>
parents:
370
diff
changeset
|
2460 |
991
ef10906691bb
Chatstates: add composing timeout
Mikael Berthe <mikael@lilotux.net>
parents:
990
diff
changeset
|
2461 // set_chatstate(state) |
ef10906691bb
Chatstates: add composing timeout
Mikael Berthe <mikael@lilotux.net>
parents:
990
diff
changeset
|
2462 // Set the current chat state (0=active, 1=composing, 2=paused) |
1598 | 2463 // 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
|
2464 static void set_chatstate(int state) |
991
ef10906691bb
Chatstates: add composing timeout
Mikael Berthe <mikael@lilotux.net>
parents:
990
diff
changeset
|
2465 { |
2165 | 2466 #ifdef XEP0085 |
993
0759f4c7da68
Add option 'disable_chatstates'
Mikael Berthe <mikael@lilotux.net>
parents:
992
diff
changeset
|
2467 if (chatstates_disabled) |
0759f4c7da68
Add option 'disable_chatstates'
Mikael Berthe <mikael@lilotux.net>
parents:
992
diff
changeset
|
2468 return; |
991
ef10906691bb
Chatstates: add composing timeout
Mikael Berthe <mikael@lilotux.net>
parents:
990
diff
changeset
|
2469 if (!chatmode) |
ef10906691bb
Chatstates: add composing timeout
Mikael Berthe <mikael@lilotux.net>
parents:
990
diff
changeset
|
2470 state = 0; |
ef10906691bb
Chatstates: add composing timeout
Mikael Berthe <mikael@lilotux.net>
parents:
990
diff
changeset
|
2471 if (state != chatstate) { |
ef10906691bb
Chatstates: add composing timeout
Mikael Berthe <mikael@lilotux.net>
parents:
990
diff
changeset
|
2472 chatstate = state; |
ef10906691bb
Chatstates: add composing timeout
Mikael Berthe <mikael@lilotux.net>
parents:
990
diff
changeset
|
2473 if (current_buddy && |
ef10906691bb
Chatstates: add composing timeout
Mikael Berthe <mikael@lilotux.net>
parents:
990
diff
changeset
|
2474 buddy_gettype(BUDDATA(current_buddy)) == ROSTER_TYPE_USER) { |
ef10906691bb
Chatstates: add composing timeout
Mikael Berthe <mikael@lilotux.net>
parents:
990
diff
changeset
|
2475 guint jep_state; |
1598 | 2476 if (chatstate == 1) { |
2477 if (chatstate_timeout_id == 0) | |
2478 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
|
2479 scr_chatstates_timeout, |
1598 | 2480 NULL); |
991
ef10906691bb
Chatstates: add composing timeout
Mikael Berthe <mikael@lilotux.net>
parents:
990
diff
changeset
|
2481 jep_state = ROSTER_EVENT_COMPOSING; |
1598 | 2482 } |
991
ef10906691bb
Chatstates: add composing timeout
Mikael Berthe <mikael@lilotux.net>
parents:
990
diff
changeset
|
2483 else if (chatstate == 2) |
ef10906691bb
Chatstates: add composing timeout
Mikael Berthe <mikael@lilotux.net>
parents:
990
diff
changeset
|
2484 jep_state = ROSTER_EVENT_PAUSED; |
ef10906691bb
Chatstates: add composing timeout
Mikael Berthe <mikael@lilotux.net>
parents:
990
diff
changeset
|
2485 else |
ef10906691bb
Chatstates: add composing timeout
Mikael Berthe <mikael@lilotux.net>
parents:
990
diff
changeset
|
2486 jep_state = ROSTER_EVENT_ACTIVE; |
1598 | 2487 xmpp_send_chatstate(BUDDATA(current_buddy), jep_state); |
991
ef10906691bb
Chatstates: add composing timeout
Mikael Berthe <mikael@lilotux.net>
parents:
990
diff
changeset
|
2488 } |
ef10906691bb
Chatstates: add composing timeout
Mikael Berthe <mikael@lilotux.net>
parents:
990
diff
changeset
|
2489 if (!chatstate) |
ef10906691bb
Chatstates: add composing timeout
Mikael Berthe <mikael@lilotux.net>
parents:
990
diff
changeset
|
2490 chatstate_timestamp = 0; |
ef10906691bb
Chatstates: add composing timeout
Mikael Berthe <mikael@lilotux.net>
parents:
990
diff
changeset
|
2491 } |
ef10906691bb
Chatstates: add composing timeout
Mikael Berthe <mikael@lilotux.net>
parents:
990
diff
changeset
|
2492 #endif |
ef10906691bb
Chatstates: add composing timeout
Mikael Berthe <mikael@lilotux.net>
parents:
990
diff
changeset
|
2493 } |
ef10906691bb
Chatstates: add composing timeout
Mikael Berthe <mikael@lilotux.net>
parents:
990
diff
changeset
|
2494 |
2165 | 2495 #ifdef XEP0085 |
1780
e4378fbab5d7
Major API cleanup - bump API to 4
Mikael Berthe <mikael@lilotux.net>
parents:
1761
diff
changeset
|
2496 static gboolean scr_chatstates_timeout(void) |
991
ef10906691bb
Chatstates: add composing timeout
Mikael Berthe <mikael@lilotux.net>
parents:
990
diff
changeset
|
2497 { |
1598 | 2498 time_t now; |
2499 time(&now); | |
991
ef10906691bb
Chatstates: add composing timeout
Mikael Berthe <mikael@lilotux.net>
parents:
990
diff
changeset
|
2500 // Check if we're currently composing... |
1598 | 2501 if (chatstate != 1 || !chatstate_timestamp) { |
2502 chatstate_timeout_id = 0; | |
2503 return FALSE; | |
2504 } | |
991
ef10906691bb
Chatstates: add composing timeout
Mikael Berthe <mikael@lilotux.net>
parents:
990
diff
changeset
|
2505 |
ef10906691bb
Chatstates: add composing timeout
Mikael Berthe <mikael@lilotux.net>
parents:
990
diff
changeset
|
2506 // 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
|
2507 if (now >= chatstate_timestamp + COMPOSING_TIMEOUT) { |
ef10906691bb
Chatstates: add composing timeout
Mikael Berthe <mikael@lilotux.net>
parents:
990
diff
changeset
|
2508 chatstate_timestamp = now; |
ef10906691bb
Chatstates: add composing timeout
Mikael Berthe <mikael@lilotux.net>
parents:
990
diff
changeset
|
2509 set_chatstate(2); |
1598 | 2510 chatstate_timeout_id = 0; |
2511 return FALSE; | |
991
ef10906691bb
Chatstates: add composing timeout
Mikael Berthe <mikael@lilotux.net>
parents:
990
diff
changeset
|
2512 } |
1598 | 2513 return TRUE; |
991
ef10906691bb
Chatstates: add composing timeout
Mikael Berthe <mikael@lilotux.net>
parents:
990
diff
changeset
|
2514 } |
ef10906691bb
Chatstates: add composing timeout
Mikael Berthe <mikael@lilotux.net>
parents:
990
diff
changeset
|
2515 #endif |
ef10906691bb
Chatstates: add composing timeout
Mikael Berthe <mikael@lilotux.net>
parents:
990
diff
changeset
|
2516 |
1677 | 2517 static gboolean scr_autoaway_timeout_callback(gpointer data) |
2518 { | |
2519 enum imstatus cur_st = xmpp_getstatus(); | |
2520 if (cur_st != available && cur_st != freeforchat) | |
2521 // Some non-user-originated status changes, let's wait more. | |
2522 // Maybe the proper fix for that will be set global variable | |
2523 // "autoaway_delayed" and check that variable in postconnect | |
2524 // hook (afaik, only source for such status changes are | |
2525 // error disconnects). | |
2526 return TRUE; | |
2527 set_autoaway(TRUE); | |
2528 // source will be destroyed after return | |
2529 autoaway_source = 0; | |
2530 return FALSE; | |
2531 } | |
2532 | |
1780
e4378fbab5d7
Major API cleanup - bump API to 4
Mikael Berthe <mikael@lilotux.net>
parents:
1761
diff
changeset
|
2533 static void scr_reinstall_autoaway_timeout(void) |
1677 | 2534 { |
2535 unsigned int autoaway_timeout = settings_opt_get_int("autoaway"); | |
2536 enum imstatus cur_st = xmpp_getstatus(); | |
2537 if (autoaway_source) { | |
2538 g_source_remove(autoaway_source); | |
2539 autoaway_source = 0; | |
2540 } | |
2541 if (autoaway_timeout && (cur_st == available || cur_st == freeforchat)) | |
2542 autoaway_source = g_timeout_add_seconds(autoaway_timeout, | |
2543 scr_autoaway_timeout_callback, | |
2544 NULL); | |
2545 } | |
2546 | |
2547 // 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
|
2548 void scr_check_auto_away(int activity) |
24 | 2549 { |
1677 | 2550 if (Autoaway && activity) { |
1780
e4378fbab5d7
Major API cleanup - bump API to 4
Mikael Berthe <mikael@lilotux.net>
parents:
1761
diff
changeset
|
2551 scr_reinstall_autoaway_timeout(); |
1677 | 2552 set_autoaway(FALSE); |
2553 } else if (activity || !autoaway_source) | |
1780
e4378fbab5d7
Major API cleanup - bump API to 4
Mikael Berthe <mikael@lilotux.net>
parents:
1761
diff
changeset
|
2554 scr_reinstall_autoaway_timeout(); |
24 | 2555 } |
2556 | |
328
83d129adde03
Add set_current_buddy() function, to reduce code duplication
Mikael Berthe <mikael@lilotux.net>
parents:
325
diff
changeset
|
2557 // set_current_buddy(newbuddy) |
83d129adde03
Add set_current_buddy() function, to reduce code duplication
Mikael Berthe <mikael@lilotux.net>
parents:
325
diff
changeset
|
2558 // 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
|
2559 // 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
|
2560 static void set_current_buddy(GList *newbuddy) |
24 | 2561 { |
328
83d129adde03
Add set_current_buddy() function, to reduce code duplication
Mikael Berthe <mikael@lilotux.net>
parents:
325
diff
changeset
|
2562 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
|
2563 /* 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
|
2564 * 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
|
2565 * buddy_getstatus() call. |
83d129adde03
Add set_current_buddy() function, to reduce code duplication
Mikael Berthe <mikael@lilotux.net>
parents:
325
diff
changeset
|
2566 */ |
83d129adde03
Add set_current_buddy() function, to reduce code duplication
Mikael Berthe <mikael@lilotux.net>
parents:
325
diff
changeset
|
2567 |
329
7c53bf62a2a2
scr_RosterUnreadMessage() uses set_current_buddy()
Mikael Berthe <mikael@lilotux.net>
parents:
328
diff
changeset
|
2568 if (!current_buddy || !newbuddy) return; |
7c53bf62a2a2
scr_RosterUnreadMessage() uses set_current_buddy()
Mikael Berthe <mikael@lilotux.net>
parents:
328
diff
changeset
|
2569 if (newbuddy == current_buddy) return; |
24 | 2570 |
990
35e7913affb7
Send events/chatstates notifications (JEP-22/JEP-85)
Mikael Berthe <mikael@lilotux.net>
parents:
987
diff
changeset
|
2571 // 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
|
2572 set_chatstate(0); |
35e7913affb7
Send events/chatstates notifications (JEP-22/JEP-85)
Mikael Berthe <mikael@lilotux.net>
parents:
987
diff
changeset
|
2573 // 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
|
2574 lock_chatstate = TRUE; |
990
35e7913affb7
Send events/chatstates notifications (JEP-22/JEP-85)
Mikael Berthe <mikael@lilotux.net>
parents:
987
diff
changeset
|
2575 |
438
b44be19d6229
Handle multiple resources for the same buddy
Mikael Berthe <mikael@lilotux.net>
parents:
419
diff
changeset
|
2576 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
|
2577 buddy_setflags(BUDDATA(current_buddy), ROSTER_FLAG_LOCK, FALSE); |
1950
aec86670047b
Automatically set readmark flag
Mikael Berthe <mikael@lilotux.net>
parents:
1949
diff
changeset
|
2578 if (chatmode) { |
aec86670047b
Automatically set readmark flag
Mikael Berthe <mikael@lilotux.net>
parents:
1949
diff
changeset
|
2579 scr_buffer_readmark(TRUE); |
330 | 2580 alternate_buddy = current_buddy; |
1950
aec86670047b
Automatically set readmark flag
Mikael Berthe <mikael@lilotux.net>
parents:
1949
diff
changeset
|
2581 } |
328
83d129adde03
Add set_current_buddy() function, to reduce code duplication
Mikael Berthe <mikael@lilotux.net>
parents:
325
diff
changeset
|
2582 current_buddy = newbuddy; |
83d129adde03
Add set_current_buddy() function, to reduce code duplication
Mikael Berthe <mikael@lilotux.net>
parents:
325
diff
changeset
|
2583 // 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
|
2584 if (chatmode) { |
328
83d129adde03
Add set_current_buddy() function, to reduce code duplication
Mikael Berthe <mikael@lilotux.net>
parents:
325
diff
changeset
|
2585 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
|
2586 // 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
|
2587 scr_buffer_readmark(-1); |
39021fd6b0e1
Try to improve readmarks in some cases
Mikael Berthe <mikael@lilotux.net>
parents:
1960
diff
changeset
|
2588 } |
2292
f181418db215
Replace global variable update_roster with scr_update_roster()
franky
parents:
2291
diff
changeset
|
2589 // 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
|
2590 // displayed anymore |
1311
0dda8238af21
Implement "/roster display"
Mikael Berthe <mikael@lilotux.net>
parents:
1298
diff
changeset
|
2591 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
|
2592 buddylist_defer_build(); |
2292
f181418db215
Replace global variable update_roster with scr_update_roster()
franky
parents:
2291
diff
changeset
|
2593 scr_update_roster(); |
24 | 2594 } |
2595 | |
1780
e4378fbab5d7
Major API cleanup - bump API to 4
Mikael Berthe <mikael@lilotux.net>
parents:
1761
diff
changeset
|
2596 // scr_roster_top() |
143 | 2597 // 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
|
2598 void scr_roster_top(void) |
104 | 2599 { |
328
83d129adde03
Add set_current_buddy() function, to reduce code duplication
Mikael Berthe <mikael@lilotux.net>
parents:
325
diff
changeset
|
2600 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
|
2601 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
|
2602 last_activity_buddy = current_buddy; |
1780
e4378fbab5d7
Major API cleanup - bump API to 4
Mikael Berthe <mikael@lilotux.net>
parents:
1761
diff
changeset
|
2603 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
|
2604 } |
104 | 2605 } |
2606 | |
1780
e4378fbab5d7
Major API cleanup - bump API to 4
Mikael Berthe <mikael@lilotux.net>
parents:
1761
diff
changeset
|
2607 // scr_roster_bottom() |
143 | 2608 // 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
|
2609 void scr_roster_bottom(void) |
104 | 2610 { |
328
83d129adde03
Add set_current_buddy() function, to reduce code duplication
Mikael Berthe <mikael@lilotux.net>
parents:
325
diff
changeset
|
2611 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
|
2612 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
|
2613 last_activity_buddy = current_buddy; |
1780
e4378fbab5d7
Major API cleanup - bump API to 4
Mikael Berthe <mikael@lilotux.net>
parents:
1761
diff
changeset
|
2614 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
|
2615 } |
104 | 2616 } |
2617 | |
1780
e4378fbab5d7
Major API cleanup - bump API to 4
Mikael Berthe <mikael@lilotux.net>
parents:
1761
diff
changeset
|
2618 // 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
|
2619 // 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
|
2620 // (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
|
2621 void scr_roster_up_down(int updown, unsigned int n) |
81 | 2622 { |
1573
ece4f26bf9ff
Add count parameter to roster up/down command
Mikael Berthe <mikael@lilotux.net>
parents:
1566
diff
changeset
|
2623 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
|
2624 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
|
2625 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
|
2626 |
7f06eb956734
Correctly set the alternate buffer after roster up|down N with N > 1
Mikael Berthe <mikael@lilotux.net>
parents:
2036
diff
changeset
|
2627 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
|
2628 return; |
1573
ece4f26bf9ff
Add count parameter to roster up/down command
Mikael Berthe <mikael@lilotux.net>
parents:
1566
diff
changeset
|
2629 |
2047
a60b933d04cc
Refactor scr_roster_up_down()
Mikael Berthe <mikael@lilotux.net>
parents:
2045
diff
changeset
|
2630 for (i = 0; i < n; i++) { |
a60b933d04cc
Refactor scr_roster_up_down()
Mikael Berthe <mikael@lilotux.net>
parents:
2045
diff
changeset
|
2631 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
|
2632 tmp_buddy = g_list_previous(new_buddy); |
2047
a60b933d04cc
Refactor scr_roster_up_down()
Mikael Berthe <mikael@lilotux.net>
parents:
2045
diff
changeset
|
2633 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
|
2634 tmp_buddy = g_list_next(new_buddy); |
2047
a60b933d04cc
Refactor scr_roster_up_down()
Mikael Berthe <mikael@lilotux.net>
parents:
2045
diff
changeset
|
2635 if (tmp_buddy) |
a60b933d04cc
Refactor scr_roster_up_down()
Mikael Berthe <mikael@lilotux.net>
parents:
2045
diff
changeset
|
2636 new_buddy = tmp_buddy; |
1573
ece4f26bf9ff
Add count parameter to roster up/down command
Mikael Berthe <mikael@lilotux.net>
parents:
1566
diff
changeset
|
2637 } |
2045
7f06eb956734
Correctly set the alternate buffer after roster up|down N with N > 1
Mikael Berthe <mikael@lilotux.net>
parents:
2036
diff
changeset
|
2638 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
|
2639 return; |
7f06eb956734
Correctly set the alternate buffer after roster up|down N with N > 1
Mikael Berthe <mikael@lilotux.net>
parents:
2036
diff
changeset
|
2640 |
7f06eb956734
Correctly set the alternate buffer after roster up|down N with N > 1
Mikael Berthe <mikael@lilotux.net>
parents:
2036
diff
changeset
|
2641 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
|
2642 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
|
2643 last_activity_buddy = current_buddy; |
1780
e4378fbab5d7
Major API cleanup - bump API to 4
Mikael Berthe <mikael@lilotux.net>
parents:
1761
diff
changeset
|
2644 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
|
2645 } |
81 | 2646 } |
2647 | |
1780
e4378fbab5d7
Major API cleanup - bump API to 4
Mikael Berthe <mikael@lilotux.net>
parents:
1761
diff
changeset
|
2648 // 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
|
2649 // 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
|
2650 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
|
2651 { |
5e2e647e781b
Add command /roster group_prev|group_next and update documentation
Mikael Berthe <mikael@lilotux.net>
parents:
1083
diff
changeset
|
2652 GList *bud; |
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 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
|
2655 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
|
2656 if (!bud) |
5e2e647e781b
Add command /roster group_prev|group_next and update documentation
Mikael Berthe <mikael@lilotux.net>
parents:
1083
diff
changeset
|
2657 break; |
5e2e647e781b
Add command /roster group_prev|group_next and update documentation
Mikael Berthe <mikael@lilotux.net>
parents:
1083
diff
changeset
|
2658 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
|
2659 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
|
2660 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
|
2661 last_activity_buddy = current_buddy; |
1780
e4378fbab5d7
Major API cleanup - bump API to 4
Mikael Berthe <mikael@lilotux.net>
parents:
1761
diff
changeset
|
2662 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
|
2663 } |
1086
5e2e647e781b
Add command /roster group_prev|group_next and update documentation
Mikael Berthe <mikael@lilotux.net>
parents:
1083
diff
changeset
|
2664 break; |
5e2e647e781b
Add command /roster group_prev|group_next and update documentation
Mikael Berthe <mikael@lilotux.net>
parents:
1083
diff
changeset
|
2665 } |
5e2e647e781b
Add command /roster group_prev|group_next and update documentation
Mikael Berthe <mikael@lilotux.net>
parents:
1083
diff
changeset
|
2666 } |
5e2e647e781b
Add command /roster group_prev|group_next and update documentation
Mikael Berthe <mikael@lilotux.net>
parents:
1083
diff
changeset
|
2667 } |
5e2e647e781b
Add command /roster group_prev|group_next and update documentation
Mikael Berthe <mikael@lilotux.net>
parents:
1083
diff
changeset
|
2668 |
1780
e4378fbab5d7
Major API cleanup - bump API to 4
Mikael Berthe <mikael@lilotux.net>
parents:
1761
diff
changeset
|
2669 // 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
|
2670 // 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
|
2671 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
|
2672 { |
5e2e647e781b
Add command /roster group_prev|group_next and update documentation
Mikael Berthe <mikael@lilotux.net>
parents:
1083
diff
changeset
|
2673 GList *bud; |
5e2e647e781b
Add command /roster group_prev|group_next and update documentation
Mikael Berthe <mikael@lilotux.net>
parents:
1083
diff
changeset
|
2674 |
5e2e647e781b
Add command /roster group_prev|group_next and update documentation
Mikael Berthe <mikael@lilotux.net>
parents:
1083
diff
changeset
|
2675 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
|
2676 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
|
2677 if (!bud) |
5e2e647e781b
Add command /roster group_prev|group_next and update documentation
Mikael Berthe <mikael@lilotux.net>
parents:
1083
diff
changeset
|
2678 break; |
5e2e647e781b
Add command /roster group_prev|group_next and update documentation
Mikael Berthe <mikael@lilotux.net>
parents:
1083
diff
changeset
|
2679 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
|
2680 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
|
2681 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
|
2682 last_activity_buddy = current_buddy; |
1780
e4378fbab5d7
Major API cleanup - bump API to 4
Mikael Berthe <mikael@lilotux.net>
parents:
1761
diff
changeset
|
2683 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
|
2684 } |
1086
5e2e647e781b
Add command /roster group_prev|group_next and update documentation
Mikael Berthe <mikael@lilotux.net>
parents:
1083
diff
changeset
|
2685 break; |
5e2e647e781b
Add command /roster group_prev|group_next and update documentation
Mikael Berthe <mikael@lilotux.net>
parents:
1083
diff
changeset
|
2686 } |
5e2e647e781b
Add command /roster group_prev|group_next and update documentation
Mikael Berthe <mikael@lilotux.net>
parents:
1083
diff
changeset
|
2687 } |
5e2e647e781b
Add command /roster group_prev|group_next and update documentation
Mikael Berthe <mikael@lilotux.net>
parents:
1083
diff
changeset
|
2688 } |
5e2e647e781b
Add command /roster group_prev|group_next and update documentation
Mikael Berthe <mikael@lilotux.net>
parents:
1083
diff
changeset
|
2689 |
1780
e4378fbab5d7
Major API cleanup - bump API to 4
Mikael Berthe <mikael@lilotux.net>
parents:
1761
diff
changeset
|
2690 // scr_roster_search(str) |
265 | 2691 // 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
|
2692 void scr_roster_search(char *str) |
265 | 2693 { |
328
83d129adde03
Add set_current_buddy() function, to reduce code duplication
Mikael Berthe <mikael@lilotux.net>
parents:
325
diff
changeset
|
2694 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
|
2695 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
|
2696 last_activity_buddy = current_buddy; |
1780
e4378fbab5d7
Major API cleanup - bump API to 4
Mikael Berthe <mikael@lilotux.net>
parents:
1761
diff
changeset
|
2697 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
|
2698 } |
265 | 2699 } |
2700 | |
1780
e4378fbab5d7
Major API cleanup - bump API to 4
Mikael Berthe <mikael@lilotux.net>
parents:
1761
diff
changeset
|
2701 // scr_roster_jump_jid(bjid) |
1058 | 2702 // Jump to buddy bjid. |
480 | 2703 // 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
|
2704 void scr_roster_jump_jid(char *barejid) |
480 | 2705 { |
2706 GSList *roster_elt; | |
2707 // Look for an existing buddy | |
2708 roster_elt = roster_find(barejid, jidsearch, | |
2709 ROSTER_TYPE_USER|ROSTER_TYPE_AGENT|ROSTER_TYPE_ROOM); | |
2710 // Create it if necessary | |
2711 if (!roster_elt) | |
603 | 2712 roster_elt = roster_add_user(barejid, NULL, NULL, ROSTER_TYPE_USER, |
1355 | 2713 sub_none, -1); |
480 | 2714 // Set a lock to see it in the buddylist |
2715 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
|
2716 buddylist_defer_build(); |
480 | 2717 // Jump to the buddy |
2718 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
|
2719 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
|
2720 last_activity_buddy = current_buddy; |
1780
e4378fbab5d7
Major API cleanup - bump API to 4
Mikael Berthe <mikael@lilotux.net>
parents:
1761
diff
changeset
|
2721 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
|
2722 } |
480 | 2723 } |
2724 | |
1780
e4378fbab5d7
Major API cleanup - bump API to 4
Mikael Berthe <mikael@lilotux.net>
parents:
1761
diff
changeset
|
2725 // scr_roster_unread_message(next) |
236 | 2726 // Go to a new message. If next is not null, try to go to the next new |
2727 // message. If it is not possible or if next is NULL, go to the first new | |
2728 // message from unread_list. | |
1780
e4378fbab5d7
Major API cleanup - bump API to 4
Mikael Berthe <mikael@lilotux.net>
parents:
1761
diff
changeset
|
2729 void scr_roster_unread_message(int next) |
236 | 2730 { |
329
7c53bf62a2a2
scr_RosterUnreadMessage() uses set_current_buddy()
Mikael Berthe <mikael@lilotux.net>
parents:
328
diff
changeset
|
2731 gpointer unread_ptr; |
7c53bf62a2a2
scr_RosterUnreadMessage() uses set_current_buddy()
Mikael Berthe <mikael@lilotux.net>
parents:
328
diff
changeset
|
2732 gpointer refbuddata; |
7c53bf62a2a2
scr_RosterUnreadMessage() uses set_current_buddy()
Mikael Berthe <mikael@lilotux.net>
parents:
328
diff
changeset
|
2733 GList *nbuddy; |
236 | 2734 |
329
7c53bf62a2a2
scr_RosterUnreadMessage() uses set_current_buddy()
Mikael Berthe <mikael@lilotux.net>
parents:
328
diff
changeset
|
2735 if (!current_buddy) return; |
236 | 2736 |
329
7c53bf62a2a2
scr_RosterUnreadMessage() uses set_current_buddy()
Mikael Berthe <mikael@lilotux.net>
parents:
328
diff
changeset
|
2737 if (next) refbuddata = BUDDATA(current_buddy); |
7c53bf62a2a2
scr_RosterUnreadMessage() uses set_current_buddy()
Mikael Berthe <mikael@lilotux.net>
parents:
328
diff
changeset
|
2738 else refbuddata = NULL; |
236 | 2739 |
329
7c53bf62a2a2
scr_RosterUnreadMessage() uses set_current_buddy()
Mikael Berthe <mikael@lilotux.net>
parents:
328
diff
changeset
|
2740 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
|
2741 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
|
2742 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
|
2743 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
|
2744 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
|
2745 } |
236 | 2746 |
889
ae93e69aaaaf
Fix up pending message flag for the status special buffer
Mikael Berthe <mikael@lilotux.net>
parents:
888
diff
changeset
|
2747 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
|
2748 gpointer ngroup; |
ae93e69aaaaf
Fix up pending message flag for the status special buffer
Mikael Berthe <mikael@lilotux.net>
parents:
888
diff
changeset
|
2749 // 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
|
2750 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
|
2751 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
|
2752 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
|
2753 buddylist_defer_build(); |
889
ae93e69aaaaf
Fix up pending message flag for the status special buffer
Mikael Berthe <mikael@lilotux.net>
parents:
888
diff
changeset
|
2754 } |
329
7c53bf62a2a2
scr_RosterUnreadMessage() uses set_current_buddy()
Mikael Berthe <mikael@lilotux.net>
parents:
328
diff
changeset
|
2755 } |
236 | 2756 |
2312
def5f64c253d
Rebuild the buddylist after disconnect/before buddylist search
franky
parents:
2311
diff
changeset
|
2757 buddylist_build(); |
329
7c53bf62a2a2
scr_RosterUnreadMessage() uses set_current_buddy()
Mikael Berthe <mikael@lilotux.net>
parents:
328
diff
changeset
|
2758 nbuddy = g_list_find(buddylist, unread_ptr); |
7c53bf62a2a2
scr_RosterUnreadMessage() uses set_current_buddy()
Mikael Berthe <mikael@lilotux.net>
parents:
328
diff
changeset
|
2759 if (nbuddy) { |
7c53bf62a2a2
scr_RosterUnreadMessage() uses set_current_buddy()
Mikael Berthe <mikael@lilotux.net>
parents:
328
diff
changeset
|
2760 set_current_buddy(nbuddy); |
1780
e4378fbab5d7
Major API cleanup - bump API to 4
Mikael Berthe <mikael@lilotux.net>
parents:
1761
diff
changeset
|
2761 if (chatmode) scr_show_buddy_window(); |
374
bd5638c21834
Improve logging system (traces)
Mikael Berthe <mikael@lilotux.net>
parents:
373
diff
changeset
|
2762 } else |
bd5638c21834
Improve logging system (traces)
Mikael Berthe <mikael@lilotux.net>
parents:
373
diff
changeset
|
2763 scr_LogPrint(LPRINT_LOGNORM, "Error: nbuddy == NULL"); // should not happen |
236 | 2764 } |
2765 | |
2160
798baf5db4eb
Add /roster next_open_buffer
Mikael Berthe <mikael@lilotux.net>
parents:
2149
diff
changeset
|
2766 // scr_roster_next_open_buffer() |
798baf5db4eb
Add /roster next_open_buffer
Mikael Berthe <mikael@lilotux.net>
parents:
2149
diff
changeset
|
2767 // Jump to the next open buffer (experimental XXX) |
798baf5db4eb
Add /roster next_open_buffer
Mikael Berthe <mikael@lilotux.net>
parents:
2149
diff
changeset
|
2768 // This implementation ignores the hidden entries (folded groups). |
798baf5db4eb
Add /roster next_open_buffer
Mikael Berthe <mikael@lilotux.net>
parents:
2149
diff
changeset
|
2769 void scr_roster_next_open_buffer(void) |
798baf5db4eb
Add /roster next_open_buffer
Mikael Berthe <mikael@lilotux.net>
parents:
2149
diff
changeset
|
2770 { |
798baf5db4eb
Add /roster next_open_buffer
Mikael Berthe <mikael@lilotux.net>
parents:
2149
diff
changeset
|
2771 GList *bud = current_buddy; |
798baf5db4eb
Add /roster next_open_buffer
Mikael Berthe <mikael@lilotux.net>
parents:
2149
diff
changeset
|
2772 |
798baf5db4eb
Add /roster next_open_buffer
Mikael Berthe <mikael@lilotux.net>
parents:
2149
diff
changeset
|
2773 if (!current_buddy) return; |
798baf5db4eb
Add /roster next_open_buffer
Mikael Berthe <mikael@lilotux.net>
parents:
2149
diff
changeset
|
2774 |
798baf5db4eb
Add /roster next_open_buffer
Mikael Berthe <mikael@lilotux.net>
parents:
2149
diff
changeset
|
2775 for (;;) { |
798baf5db4eb
Add /roster next_open_buffer
Mikael Berthe <mikael@lilotux.net>
parents:
2149
diff
changeset
|
2776 guint budtype; |
798baf5db4eb
Add /roster next_open_buffer
Mikael Berthe <mikael@lilotux.net>
parents:
2149
diff
changeset
|
2777 bud = g_list_next(bud); |
798baf5db4eb
Add /roster next_open_buffer
Mikael Berthe <mikael@lilotux.net>
parents:
2149
diff
changeset
|
2778 // End of list: jump to the first entry |
798baf5db4eb
Add /roster next_open_buffer
Mikael Berthe <mikael@lilotux.net>
parents:
2149
diff
changeset
|
2779 if (!bud) |
798baf5db4eb
Add /roster next_open_buffer
Mikael Berthe <mikael@lilotux.net>
parents:
2149
diff
changeset
|
2780 bud = buddylist; |
798baf5db4eb
Add /roster next_open_buffer
Mikael Berthe <mikael@lilotux.net>
parents:
2149
diff
changeset
|
2781 // Check if we're back to the initial position |
798baf5db4eb
Add /roster next_open_buffer
Mikael Berthe <mikael@lilotux.net>
parents:
2149
diff
changeset
|
2782 if (bud == current_buddy) |
798baf5db4eb
Add /roster next_open_buffer
Mikael Berthe <mikael@lilotux.net>
parents:
2149
diff
changeset
|
2783 break; |
798baf5db4eb
Add /roster next_open_buffer
Mikael Berthe <mikael@lilotux.net>
parents:
2149
diff
changeset
|
2784 // Ignore the special buffer(s), groups |
798baf5db4eb
Add /roster next_open_buffer
Mikael Berthe <mikael@lilotux.net>
parents:
2149
diff
changeset
|
2785 budtype = buddy_gettype(BUDDATA(bud)); |
798baf5db4eb
Add /roster next_open_buffer
Mikael Berthe <mikael@lilotux.net>
parents:
2149
diff
changeset
|
2786 if (budtype & (ROSTER_TYPE_GROUP | ROSTER_TYPE_SPECIAL)) |
798baf5db4eb
Add /roster next_open_buffer
Mikael Berthe <mikael@lilotux.net>
parents:
2149
diff
changeset
|
2787 continue; |
798baf5db4eb
Add /roster next_open_buffer
Mikael Berthe <mikael@lilotux.net>
parents:
2149
diff
changeset
|
2788 |
798baf5db4eb
Add /roster next_open_buffer
Mikael Berthe <mikael@lilotux.net>
parents:
2149
diff
changeset
|
2789 // Check if a buffer/window exists |
798baf5db4eb
Add /roster next_open_buffer
Mikael Berthe <mikael@lilotux.net>
parents:
2149
diff
changeset
|
2790 if (scr_search_window(buddy_getjid(BUDDATA(bud)), 0)) { |
798baf5db4eb
Add /roster next_open_buffer
Mikael Berthe <mikael@lilotux.net>
parents:
2149
diff
changeset
|
2791 set_current_buddy(bud); |
798baf5db4eb
Add /roster next_open_buffer
Mikael Berthe <mikael@lilotux.net>
parents:
2149
diff
changeset
|
2792 if (chatmode) { |
798baf5db4eb
Add /roster next_open_buffer
Mikael Berthe <mikael@lilotux.net>
parents:
2149
diff
changeset
|
2793 last_activity_buddy = current_buddy; |
798baf5db4eb
Add /roster next_open_buffer
Mikael Berthe <mikael@lilotux.net>
parents:
2149
diff
changeset
|
2794 scr_show_buddy_window(); |
798baf5db4eb
Add /roster next_open_buffer
Mikael Berthe <mikael@lilotux.net>
parents:
2149
diff
changeset
|
2795 } |
798baf5db4eb
Add /roster next_open_buffer
Mikael Berthe <mikael@lilotux.net>
parents:
2149
diff
changeset
|
2796 break; |
798baf5db4eb
Add /roster next_open_buffer
Mikael Berthe <mikael@lilotux.net>
parents:
2149
diff
changeset
|
2797 } |
798baf5db4eb
Add /roster next_open_buffer
Mikael Berthe <mikael@lilotux.net>
parents:
2149
diff
changeset
|
2798 } |
798baf5db4eb
Add /roster next_open_buffer
Mikael Berthe <mikael@lilotux.net>
parents:
2149
diff
changeset
|
2799 } |
798baf5db4eb
Add /roster next_open_buffer
Mikael Berthe <mikael@lilotux.net>
parents:
2149
diff
changeset
|
2800 |
1780
e4378fbab5d7
Major API cleanup - bump API to 4
Mikael Berthe <mikael@lilotux.net>
parents:
1761
diff
changeset
|
2801 // scr_roster_jump_alternate() |
330 | 2802 // 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
|
2803 void scr_roster_jump_alternate(void) |
105 | 2804 { |
330 | 2805 if (!alternate_buddy || g_list_position(buddylist, alternate_buddy) == -1) |
2806 return; | |
2807 set_current_buddy(alternate_buddy); | |
1997
555e342556e7
/roster alternate also changes last_activity_buddy.
Simon Jacquin
parents:
1996
diff
changeset
|
2808 if (chatmode) { |
555e342556e7
/roster alternate also changes last_activity_buddy.
Simon Jacquin
parents:
1996
diff
changeset
|
2809 last_activity_buddy = current_buddy; |
1780
e4378fbab5d7
Major API cleanup - bump API to 4
Mikael Berthe <mikael@lilotux.net>
parents:
1761
diff
changeset
|
2810 scr_show_buddy_window(); |
1997
555e342556e7
/roster alternate also changes last_activity_buddy.
Simon Jacquin
parents:
1996
diff
changeset
|
2811 } |
330 | 2812 } |
2813 | |
1780
e4378fbab5d7
Major API cleanup - bump API to 4
Mikael Berthe <mikael@lilotux.net>
parents:
1761
diff
changeset
|
2814 // scr_roster_display(filter) |
1311
0dda8238af21
Implement "/roster display"
Mikael Berthe <mikael@lilotux.net>
parents:
1298
diff
changeset
|
2815 // 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
|
2816 // mask is displayed. |
1780
e4378fbab5d7
Major API cleanup - bump API to 4
Mikael Berthe <mikael@lilotux.net>
parents:
1761
diff
changeset
|
2817 void scr_roster_display(const char *filter) |
1311
0dda8238af21
Implement "/roster display"
Mikael Berthe <mikael@lilotux.net>
parents:
1298
diff
changeset
|
2818 { |
0dda8238af21
Implement "/roster display"
Mikael Berthe <mikael@lilotux.net>
parents:
1298
diff
changeset
|
2819 guchar status; |
0dda8238af21
Implement "/roster display"
Mikael Berthe <mikael@lilotux.net>
parents:
1298
diff
changeset
|
2820 enum imstatus budstate; |
0dda8238af21
Implement "/roster display"
Mikael Berthe <mikael@lilotux.net>
parents:
1298
diff
changeset
|
2821 char strfilter[imstatus_size+1]; |
0dda8238af21
Implement "/roster display"
Mikael Berthe <mikael@lilotux.net>
parents:
1298
diff
changeset
|
2822 char *psfilter; |
0dda8238af21
Implement "/roster display"
Mikael Berthe <mikael@lilotux.net>
parents:
1298
diff
changeset
|
2823 |
0dda8238af21
Implement "/roster display"
Mikael Berthe <mikael@lilotux.net>
parents:
1298
diff
changeset
|
2824 if (filter && *filter) { |
0dda8238af21
Implement "/roster display"
Mikael Berthe <mikael@lilotux.net>
parents:
1298
diff
changeset
|
2825 int show_all = (*filter == '*'); |
0dda8238af21
Implement "/roster display"
Mikael Berthe <mikael@lilotux.net>
parents:
1298
diff
changeset
|
2826 status = 0; |
0dda8238af21
Implement "/roster display"
Mikael Berthe <mikael@lilotux.net>
parents:
1298
diff
changeset
|
2827 for (budstate = 0; budstate < imstatus_size-1; budstate++) |
0dda8238af21
Implement "/roster display"
Mikael Berthe <mikael@lilotux.net>
parents:
1298
diff
changeset
|
2828 if (strchr(filter, imstatus2char[budstate]) || show_all) |
0dda8238af21
Implement "/roster display"
Mikael Berthe <mikael@lilotux.net>
parents:
1298
diff
changeset
|
2829 status |= 1<<budstate; |
0dda8238af21
Implement "/roster display"
Mikael Berthe <mikael@lilotux.net>
parents:
1298
diff
changeset
|
2830 buddylist_set_filter(status); |
2291
0d350e979bde
Don't rebuild the buddylist multiple times before a screen refresh
franky
parents:
2288
diff
changeset
|
2831 buddylist_defer_build(); |
2292
f181418db215
Replace global variable update_roster with scr_update_roster()
franky
parents:
2291
diff
changeset
|
2832 scr_update_roster(); |
1311
0dda8238af21
Implement "/roster display"
Mikael Berthe <mikael@lilotux.net>
parents:
1298
diff
changeset
|
2833 return; |
0dda8238af21
Implement "/roster display"
Mikael Berthe <mikael@lilotux.net>
parents:
1298
diff
changeset
|
2834 } |
0dda8238af21
Implement "/roster display"
Mikael Berthe <mikael@lilotux.net>
parents:
1298
diff
changeset
|
2835 |
0dda8238af21
Implement "/roster display"
Mikael Berthe <mikael@lilotux.net>
parents:
1298
diff
changeset
|
2836 // Display current filter |
0dda8238af21
Implement "/roster display"
Mikael Berthe <mikael@lilotux.net>
parents:
1298
diff
changeset
|
2837 psfilter = strfilter; |
0dda8238af21
Implement "/roster display"
Mikael Berthe <mikael@lilotux.net>
parents:
1298
diff
changeset
|
2838 status = buddylist_get_filter(); |
0dda8238af21
Implement "/roster display"
Mikael Berthe <mikael@lilotux.net>
parents:
1298
diff
changeset
|
2839 for (budstate = 0; budstate < imstatus_size-1; budstate++) |
0dda8238af21
Implement "/roster display"
Mikael Berthe <mikael@lilotux.net>
parents:
1298
diff
changeset
|
2840 if (status & 1<<budstate) |
0dda8238af21
Implement "/roster display"
Mikael Berthe <mikael@lilotux.net>
parents:
1298
diff
changeset
|
2841 *psfilter++ = imstatus2char[budstate]; |
0dda8238af21
Implement "/roster display"
Mikael Berthe <mikael@lilotux.net>
parents:
1298
diff
changeset
|
2842 *psfilter = '\0'; |
0dda8238af21
Implement "/roster display"
Mikael Berthe <mikael@lilotux.net>
parents:
1298
diff
changeset
|
2843 scr_LogPrint(LPRINT_NORMAL, "Roster status filter: %s", strfilter); |
0dda8238af21
Implement "/roster display"
Mikael Berthe <mikael@lilotux.net>
parents:
1298
diff
changeset
|
2844 } |
0dda8238af21
Implement "/roster display"
Mikael Berthe <mikael@lilotux.net>
parents:
1298
diff
changeset
|
2845 |
1780
e4378fbab5d7
Major API cleanup - bump API to 4
Mikael Berthe <mikael@lilotux.net>
parents:
1761
diff
changeset
|
2846 // scr_buffer_scroll_up_down() |
508
5a2132ba2220
Add "/buffer up" and "/buffer down"
Mikael Berthe <mikael@lilotux.net>
parents:
503
diff
changeset
|
2847 // Scroll up/down the current buddy window, |
5a2132ba2220
Add "/buffer up" and "/buffer down"
Mikael Berthe <mikael@lilotux.net>
parents:
503
diff
changeset
|
2848 // - half a screen if nblines is 0, |
5a2132ba2220
Add "/buffer up" and "/buffer down"
Mikael Berthe <mikael@lilotux.net>
parents:
503
diff
changeset
|
2849 // - 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
|
2850 void scr_buffer_scroll_up_down(int updown, unsigned int nblines) |
105 | 2851 { |
2337 | 2852 winbuf_t *win_entry; |
508
5a2132ba2220
Add "/buffer up" and "/buffer down"
Mikael Berthe <mikael@lilotux.net>
parents:
503
diff
changeset
|
2853 int n, nbl; |
105 | 2854 GList *hbuf_top; |
849
42c43a88d823
Status buffer management
Mikael Berthe <mikael@lilotux.net>
parents:
848
diff
changeset
|
2855 guint isspe; |
105 | 2856 |
2857 // Get win_entry | |
361
51ff319947c3
Code cleanup/optimization
Mikael Berthe <mikael@lilotux.net>
parents:
358
diff
changeset
|
2858 if (!current_buddy) return; |
849
42c43a88d823
Status buffer management
Mikael Berthe <mikael@lilotux.net>
parents:
848
diff
changeset
|
2859 |
42c43a88d823
Status buffer management
Mikael Berthe <mikael@lilotux.net>
parents:
848
diff
changeset
|
2860 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
|
2861 win_entry = scr_search_window(CURRENT_JID, isspe); |
361
51ff319947c3
Code cleanup/optimization
Mikael Berthe <mikael@lilotux.net>
parents:
358
diff
changeset
|
2862 if (!win_entry) return; |
105 | 2863 |
508
5a2132ba2220
Add "/buffer up" and "/buffer down"
Mikael Berthe <mikael@lilotux.net>
parents:
503
diff
changeset
|
2864 if (!nblines) { |
5a2132ba2220
Add "/buffer up" and "/buffer down"
Mikael Berthe <mikael@lilotux.net>
parents:
503
diff
changeset
|
2865 // Scroll half a screen (or less) |
512 | 2866 nbl = CHAT_WIN_HEIGHT/2; |
508
5a2132ba2220
Add "/buffer up" and "/buffer down"
Mikael Berthe <mikael@lilotux.net>
parents:
503
diff
changeset
|
2867 } else { |
5a2132ba2220
Add "/buffer up" and "/buffer down"
Mikael Berthe <mikael@lilotux.net>
parents:
503
diff
changeset
|
2868 nbl = nblines; |
5a2132ba2220
Add "/buffer up" and "/buffer down"
Mikael Berthe <mikael@lilotux.net>
parents:
503
diff
changeset
|
2869 } |
1157
5c857f0f0ab8
Moved all variables related to hbuf to an extra struct, bufdata
Frank Zschockelt
parents:
1156
diff
changeset
|
2870 hbuf_top = win_entry->bd->top; |
105 | 2871 |
361
51ff319947c3
Code cleanup/optimization
Mikael Berthe <mikael@lilotux.net>
parents:
358
diff
changeset
|
2872 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
|
2873 n = 0; |
361
51ff319947c3
Code cleanup/optimization
Mikael Berthe <mikael@lilotux.net>
parents:
358
diff
changeset
|
2874 if (!hbuf_top) { |
1157
5c857f0f0ab8
Moved all variables related to hbuf to an extra struct, bufdata
Frank Zschockelt
parents:
1156
diff
changeset
|
2875 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
|
2876 if (!win_entry->bd->cleared) { |
512 | 2877 if (!nblines) nbl = nbl*3 - 1; |
2878 else nbl += CHAT_WIN_HEIGHT - 1; | |
2879 } else { | |
1157
5c857f0f0ab8
Moved all variables related to hbuf to an extra struct, bufdata
Frank Zschockelt
parents:
1156
diff
changeset
|
2880 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
|
2881 n++; // We'll scroll one line less |
512 | 2882 } |
361
51ff319947c3
Code cleanup/optimization
Mikael Berthe <mikael@lilotux.net>
parents:
358
diff
changeset
|
2883 } |
1969
d9255c408027
Improve (fix) buffer up 1 when the screen is cleared
Mikael Berthe <mikael@lilotux.net>
parents:
1968
diff
changeset
|
2884 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
|
2885 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
|
2886 win_entry->bd->top = hbuf_top; |
361
51ff319947c3
Code cleanup/optimization
Mikael Berthe <mikael@lilotux.net>
parents:
358
diff
changeset
|
2887 } else { // DOWN |
508
5a2132ba2220
Add "/buffer up" and "/buffer down"
Mikael Berthe <mikael@lilotux.net>
parents:
503
diff
changeset
|
2888 for (n=0 ; hbuf_top && n < nbl ; n++) |
361
51ff319947c3
Code cleanup/optimization
Mikael Berthe <mikael@lilotux.net>
parents:
358
diff
changeset
|
2889 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
|
2890 win_entry->bd->top = hbuf_top; |
361
51ff319947c3
Code cleanup/optimization
Mikael Berthe <mikael@lilotux.net>
parents:
358
diff
changeset
|
2891 // Check if we are at the bottom |
51ff319947c3
Code cleanup/optimization
Mikael Berthe <mikael@lilotux.net>
parents:
358
diff
changeset
|
2892 for (n=0 ; hbuf_top && n < CHAT_WIN_HEIGHT-1 ; n++) |
51ff319947c3
Code cleanup/optimization
Mikael Berthe <mikael@lilotux.net>
parents:
358
diff
changeset
|
2893 hbuf_top = g_list_next(hbuf_top); |
51ff319947c3
Code cleanup/optimization
Mikael Berthe <mikael@lilotux.net>
parents:
358
diff
changeset
|
2894 if (!hbuf_top) |
1157
5c857f0f0ab8
Moved all variables related to hbuf to an extra struct, bufdata
Frank Zschockelt
parents:
1156
diff
changeset
|
2895 win_entry->bd->top = NULL; // End reached |
361
51ff319947c3
Code cleanup/optimization
Mikael Berthe <mikael@lilotux.net>
parents:
358
diff
changeset
|
2896 } |
105 | 2897 |
2898 // Refresh the window | |
1780
e4378fbab5d7
Major API cleanup - bump API to 4
Mikael Berthe <mikael@lilotux.net>
parents:
1761
diff
changeset
|
2899 scr_update_window(win_entry); |
105 | 2900 |
2901 // Finished :) | |
2902 update_panels(); | |
2903 } | |
2904 | |
1780
e4378fbab5d7
Major API cleanup - bump API to 4
Mikael Berthe <mikael@lilotux.net>
parents:
1761
diff
changeset
|
2905 // scr_buffer_clear() |
143 | 2906 // 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
|
2907 void scr_buffer_clear(void) |
108 | 2908 { |
2337 | 2909 winbuf_t *win_entry; |
849
42c43a88d823
Status buffer management
Mikael Berthe <mikael@lilotux.net>
parents:
848
diff
changeset
|
2910 guint isspe; |
108 | 2911 |
2912 // Get win_entry | |
361
51ff319947c3
Code cleanup/optimization
Mikael Berthe <mikael@lilotux.net>
parents:
358
diff
changeset
|
2913 if (!current_buddy) return; |
849
42c43a88d823
Status buffer management
Mikael Berthe <mikael@lilotux.net>
parents:
848
diff
changeset
|
2914 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
|
2915 win_entry = scr_search_window(CURRENT_JID, isspe); |
361
51ff319947c3
Code cleanup/optimization
Mikael Berthe <mikael@lilotux.net>
parents:
358
diff
changeset
|
2916 if (!win_entry) return; |
108 | 2917 |
1157
5c857f0f0ab8
Moved all variables related to hbuf to an extra struct, bufdata
Frank Zschockelt
parents:
1156
diff
changeset
|
2918 win_entry->bd->cleared = TRUE; |
5c857f0f0ab8
Moved all variables related to hbuf to an extra struct, bufdata
Frank Zschockelt
parents:
1156
diff
changeset
|
2919 win_entry->bd->top = NULL; |
108 | 2920 |
2921 // Refresh the window | |
1780
e4378fbab5d7
Major API cleanup - bump API to 4
Mikael Berthe <mikael@lilotux.net>
parents:
1761
diff
changeset
|
2922 scr_update_window(win_entry); |
108 | 2923 |
2924 // Finished :) | |
2925 update_panels(); | |
2926 } | |
2927 | |
1138
8ba4b1e8b42d
Add command /buffer close_all
Mikael Berthe <mikael@lilotux.net>
parents:
1137
diff
changeset
|
2928 // buffer_purge() |
8ba4b1e8b42d
Add command /buffer close_all
Mikael Berthe <mikael@lilotux.net>
parents:
1137
diff
changeset
|
2929 // key: winId/jid |
2337 | 2930 // value: winbuf_t structure |
1138
8ba4b1e8b42d
Add command /buffer close_all
Mikael Berthe <mikael@lilotux.net>
parents:
1137
diff
changeset
|
2931 // 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
|
2932 // 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
|
2933 // Returns TRUE IFF the win_entry can be closed and freed. |
2012 | 2934 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
|
2935 { |
1225
0e9e9724d643
Fix a bad type cast in buffer_purge()
Mikael Berthe <mikael@lilotux.net>
parents:
1209
diff
changeset
|
2936 int *p_closebuf = data; |
2337 | 2937 winbuf_t *win_entry = value; |
2012 | 2938 gboolean retval = FALSE; |
1138
8ba4b1e8b42d
Add command /buffer close_all
Mikael Berthe <mikael@lilotux.net>
parents:
1137
diff
changeset
|
2939 |
8ba4b1e8b42d
Add command /buffer close_all
Mikael Berthe <mikael@lilotux.net>
parents:
1137
diff
changeset
|
2940 // Delete the current hbuf |
2225
dc3b3ac1ba76
Free the buffdata structures when buffers are closed
Mikael Berthe <mikael@lilotux.net>
parents:
2222
diff
changeset
|
2941 // 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
|
2942 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
|
2943 hbuf_free(&win_entry->bd->hbuf); |
1138
8ba4b1e8b42d
Add command /buffer close_all
Mikael Berthe <mikael@lilotux.net>
parents:
1137
diff
changeset
|
2944 |
1225
0e9e9724d643
Fix a bad type cast in buffer_purge()
Mikael Berthe <mikael@lilotux.net>
parents:
1209
diff
changeset
|
2945 if (*p_closebuf) { |
2013
8dc418af3e72
Allow to select to which buddy resource messages go. Closes issue #55
Hermitifier
parents:
2012
diff
changeset
|
2946 GSList *roster_elt; |
2012 | 2947 retval = TRUE; |
2013
8dc418af3e72
Allow to select to which buddy resource messages go. Closes issue #55
Hermitifier
parents:
2012
diff
changeset
|
2948 roster_elt = roster_find(key, jidsearch, |
8dc418af3e72
Allow to select to which buddy resource messages go. Closes issue #55
Hermitifier
parents:
2012
diff
changeset
|
2949 ROSTER_TYPE_USER|ROSTER_TYPE_AGENT); |
8dc418af3e72
Allow to select to which buddy resource messages go. Closes issue #55
Hermitifier
parents:
2012
diff
changeset
|
2950 if (roster_elt) |
8dc418af3e72
Allow to select to which buddy resource messages go. Closes issue #55
Hermitifier
parents:
2012
diff
changeset
|
2951 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
|
2952 if (win_entry->bd->refcount) { |
dc3b3ac1ba76
Free the buffdata structures when buffers are closed
Mikael Berthe <mikael@lilotux.net>
parents:
2222
diff
changeset
|
2953 win_entry->bd->refcount--; |
dc3b3ac1ba76
Free the buffdata structures when buffers are closed
Mikael Berthe <mikael@lilotux.net>
parents:
2222
diff
changeset
|
2954 } else { |
dc3b3ac1ba76
Free the buffdata structures when buffers are closed
Mikael Berthe <mikael@lilotux.net>
parents:
2222
diff
changeset
|
2955 g_free(win_entry->bd); |
dc3b3ac1ba76
Free the buffdata structures when buffers are closed
Mikael Berthe <mikael@lilotux.net>
parents:
2222
diff
changeset
|
2956 win_entry->bd = NULL; |
dc3b3ac1ba76
Free the buffdata structures when buffers are closed
Mikael Berthe <mikael@lilotux.net>
parents:
2222
diff
changeset
|
2957 } |
1138
8ba4b1e8b42d
Add command /buffer close_all
Mikael Berthe <mikael@lilotux.net>
parents:
1137
diff
changeset
|
2958 } else { |
1157
5c857f0f0ab8
Moved all variables related to hbuf to an extra struct, bufdata
Frank Zschockelt
parents:
1156
diff
changeset
|
2959 win_entry->bd->cleared = FALSE; |
5c857f0f0ab8
Moved all variables related to hbuf to an extra struct, bufdata
Frank Zschockelt
parents:
1156
diff
changeset
|
2960 win_entry->bd->top = NULL; |
1138
8ba4b1e8b42d
Add command /buffer close_all
Mikael Berthe <mikael@lilotux.net>
parents:
1137
diff
changeset
|
2961 } |
2012 | 2962 return retval; |
1138
8ba4b1e8b42d
Add command /buffer close_all
Mikael Berthe <mikael@lilotux.net>
parents:
1137
diff
changeset
|
2963 } |
8ba4b1e8b42d
Add command /buffer close_all
Mikael Berthe <mikael@lilotux.net>
parents:
1137
diff
changeset
|
2964 |
1780
e4378fbab5d7
Major API cleanup - bump API to 4
Mikael Berthe <mikael@lilotux.net>
parents:
1761
diff
changeset
|
2965 // scr_buffer_purge(closebuf, jid) |
1279
8bbc764139ef
Implement /buffer close|purge [jid]
Mikael Berthe <mikael@lilotux.net>
parents:
1272
diff
changeset
|
2966 // 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
|
2967 // 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
|
2968 void scr_buffer_purge(int closebuf, const char *jid) |
866 | 2969 { |
2337 | 2970 winbuf_t *win_entry; |
866 | 2971 guint isspe; |
1279
8bbc764139ef
Implement /buffer close|purge [jid]
Mikael Berthe <mikael@lilotux.net>
parents:
1272
diff
changeset
|
2972 const char *cjid; |
2222
ce1043326bbc
Fix a small leak when a window is closed
Mikael Berthe <mikael@lilotux.net>
parents:
2211
diff
changeset
|
2973 char *ljid = NULL; |
1345
8e4e741787be
Small change to buffer close
Mikael Berthe <mikael@lilotux.net>
parents:
1333
diff
changeset
|
2974 guint hold_chatmode = FALSE; |
1279
8bbc764139ef
Implement /buffer close|purge [jid]
Mikael Berthe <mikael@lilotux.net>
parents:
1272
diff
changeset
|
2975 |
8bbc764139ef
Implement /buffer close|purge [jid]
Mikael Berthe <mikael@lilotux.net>
parents:
1272
diff
changeset
|
2976 if (jid) { |
8bbc764139ef
Implement /buffer close|purge [jid]
Mikael Berthe <mikael@lilotux.net>
parents:
1272
diff
changeset
|
2977 isspe = FALSE; |
2222
ce1043326bbc
Fix a small leak when a window is closed
Mikael Berthe <mikael@lilotux.net>
parents:
2211
diff
changeset
|
2978 ljid = g_strdup(jid); |
ce1043326bbc
Fix a small leak when a window is closed
Mikael Berthe <mikael@lilotux.net>
parents:
2211
diff
changeset
|
2979 mc_strtolower(ljid); |
ce1043326bbc
Fix a small leak when a window is closed
Mikael Berthe <mikael@lilotux.net>
parents:
2211
diff
changeset
|
2980 cjid = ljid; |
1345
8e4e741787be
Small change to buffer close
Mikael Berthe <mikael@lilotux.net>
parents:
1333
diff
changeset
|
2981 // 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
|
2982 // 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
|
2983 if (closebuf && current_buddy) { |
8e4e741787be
Small change to buffer close
Mikael Berthe <mikael@lilotux.net>
parents:
1333
diff
changeset
|
2984 if (buddy_gettype(BUDDATA(current_buddy)) & ROSTER_TYPE_SPECIAL || |
8e4e741787be
Small change to buffer close
Mikael Berthe <mikael@lilotux.net>
parents:
1333
diff
changeset
|
2985 strcasecmp(jid, CURRENT_JID)) |
8e4e741787be
Small change to buffer close
Mikael Berthe <mikael@lilotux.net>
parents:
1333
diff
changeset
|
2986 hold_chatmode = TRUE; |
8e4e741787be
Small change to buffer close
Mikael Berthe <mikael@lilotux.net>
parents:
1333
diff
changeset
|
2987 } |
1279
8bbc764139ef
Implement /buffer close|purge [jid]
Mikael Berthe <mikael@lilotux.net>
parents:
1272
diff
changeset
|
2988 } else { |
8bbc764139ef
Implement /buffer close|purge [jid]
Mikael Berthe <mikael@lilotux.net>
parents:
1272
diff
changeset
|
2989 // Get win_entry |
8bbc764139ef
Implement /buffer close|purge [jid]
Mikael Berthe <mikael@lilotux.net>
parents:
1272
diff
changeset
|
2990 if (!current_buddy) return; |
8bbc764139ef
Implement /buffer close|purge [jid]
Mikael Berthe <mikael@lilotux.net>
parents:
1272
diff
changeset
|
2991 cjid = CURRENT_JID; |
8bbc764139ef
Implement /buffer close|purge [jid]
Mikael Berthe <mikael@lilotux.net>
parents:
1272
diff
changeset
|
2992 isspe = buddy_gettype(BUDDATA(current_buddy)) & ROSTER_TYPE_SPECIAL; |
8bbc764139ef
Implement /buffer close|purge [jid]
Mikael Berthe <mikael@lilotux.net>
parents:
1272
diff
changeset
|
2993 } |
1780
e4378fbab5d7
Major API cleanup - bump API to 4
Mikael Berthe <mikael@lilotux.net>
parents:
1761
diff
changeset
|
2994 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
|
2995 if (!win_entry) { |
ce1043326bbc
Fix a small leak when a window is closed
Mikael Berthe <mikael@lilotux.net>
parents:
2211
diff
changeset
|
2996 g_free(ljid); |
ce1043326bbc
Fix a small leak when a window is closed
Mikael Berthe <mikael@lilotux.net>
parents:
2211
diff
changeset
|
2997 return; |
ce1043326bbc
Fix a small leak when a window is closed
Mikael Berthe <mikael@lilotux.net>
parents:
2211
diff
changeset
|
2998 } |
866 | 2999 |
1138
8ba4b1e8b42d
Add command /buffer close_all
Mikael Berthe <mikael@lilotux.net>
parents:
1137
diff
changeset
|
3000 if (!isspe) { |
2222
ce1043326bbc
Fix a small leak when a window is closed
Mikael Berthe <mikael@lilotux.net>
parents:
2211
diff
changeset
|
3001 if (buffer_purge((gpointer)cjid, win_entry, &closebuf)) |
2012 | 3002 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
|
3003 roster_msg_setflag(cjid, FALSE, FALSE); |
1345
8e4e741787be
Small change to buffer close
Mikael Berthe <mikael@lilotux.net>
parents:
1333
diff
changeset
|
3004 if (closebuf && !hold_chatmode) { |
1138
8ba4b1e8b42d
Add command /buffer close_all
Mikael Berthe <mikael@lilotux.net>
parents:
1137
diff
changeset
|
3005 scr_set_chatmode(FALSE); |
8ba4b1e8b42d
Add command /buffer close_all
Mikael Berthe <mikael@lilotux.net>
parents:
1137
diff
changeset
|
3006 currentWindow = NULL; |
8ba4b1e8b42d
Add command /buffer close_all
Mikael Berthe <mikael@lilotux.net>
parents:
1137
diff
changeset
|
3007 } |
8ba4b1e8b42d
Add command /buffer close_all
Mikael Berthe <mikael@lilotux.net>
parents:
1137
diff
changeset
|
3008 } else { |
8ba4b1e8b42d
Add command /buffer close_all
Mikael Berthe <mikael@lilotux.net>
parents:
1137
diff
changeset
|
3009 // (Special buffer) |
8ba4b1e8b42d
Add command /buffer close_all
Mikael Berthe <mikael@lilotux.net>
parents:
1137
diff
changeset
|
3010 // Reset the current hbuf |
1157
5c857f0f0ab8
Moved all variables related to hbuf to an extra struct, bufdata
Frank Zschockelt
parents:
1156
diff
changeset
|
3011 hbuf_free(&win_entry->bd->hbuf); |
866 | 3012 // Currently it can only be the status buffer |
3013 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
|
3014 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
|
3015 |
1157
5c857f0f0ab8
Moved all variables related to hbuf to an extra struct, bufdata
Frank Zschockelt
parents:
1156
diff
changeset
|
3016 win_entry->bd->cleared = FALSE; |
5c857f0f0ab8
Moved all variables related to hbuf to an extra struct, bufdata
Frank Zschockelt
parents:
1156
diff
changeset
|
3017 win_entry->bd->top = NULL; |
866 | 3018 } |
3019 | |
2292
f181418db215
Replace global variable update_roster with scr_update_roster()
franky
parents:
2291
diff
changeset
|
3020 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
|
3021 |
1138
8ba4b1e8b42d
Add command /buffer close_all
Mikael Berthe <mikael@lilotux.net>
parents:
1137
diff
changeset
|
3022 // Refresh the window |
1780
e4378fbab5d7
Major API cleanup - bump API to 4
Mikael Berthe <mikael@lilotux.net>
parents:
1761
diff
changeset
|
3023 scr_update_buddy_window(); |
1138
8ba4b1e8b42d
Add command /buffer close_all
Mikael Berthe <mikael@lilotux.net>
parents:
1137
diff
changeset
|
3024 |
8ba4b1e8b42d
Add command /buffer close_all
Mikael Berthe <mikael@lilotux.net>
parents:
1137
diff
changeset
|
3025 // Finished :) |
8ba4b1e8b42d
Add command /buffer close_all
Mikael Berthe <mikael@lilotux.net>
parents:
1137
diff
changeset
|
3026 update_panels(); |
2222
ce1043326bbc
Fix a small leak when a window is closed
Mikael Berthe <mikael@lilotux.net>
parents:
2211
diff
changeset
|
3027 |
ce1043326bbc
Fix a small leak when a window is closed
Mikael Berthe <mikael@lilotux.net>
parents:
2211
diff
changeset
|
3028 g_free(ljid); |
1138
8ba4b1e8b42d
Add command /buffer close_all
Mikael Berthe <mikael@lilotux.net>
parents:
1137
diff
changeset
|
3029 } |
8ba4b1e8b42d
Add command /buffer close_all
Mikael Berthe <mikael@lilotux.net>
parents:
1137
diff
changeset
|
3030 |
1780
e4378fbab5d7
Major API cleanup - bump API to 4
Mikael Berthe <mikael@lilotux.net>
parents:
1761
diff
changeset
|
3031 // scr_buffer_purge_all(closebuf) |
e4378fbab5d7
Major API cleanup - bump API to 4
Mikael Berthe <mikael@lilotux.net>
parents:
1761
diff
changeset
|
3032 // Purge all existing buffers. |
e4378fbab5d7
Major API cleanup - bump API to 4
Mikael Berthe <mikael@lilotux.net>
parents:
1761
diff
changeset
|
3033 // 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
|
3034 void scr_buffer_purge_all(int closebuf) |
1138
8ba4b1e8b42d
Add command /buffer close_all
Mikael Berthe <mikael@lilotux.net>
parents:
1137
diff
changeset
|
3035 { |
2222
ce1043326bbc
Fix a small leak when a window is closed
Mikael Berthe <mikael@lilotux.net>
parents:
2211
diff
changeset
|
3036 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
|
3037 |
8ba4b1e8b42d
Add command /buffer close_all
Mikael Berthe <mikael@lilotux.net>
parents:
1137
diff
changeset
|
3038 if (closebuf) { |
1135
5d7c05932b13
Add command /buffer close
Mikael Berthe <mikael@lilotux.net>
parents:
1133
diff
changeset
|
3039 scr_set_chatmode(FALSE); |
1137
5752017f6e2b
Fix a bug in /buffer close
Mikael Berthe <mikael@lilotux.net>
parents:
1135
diff
changeset
|
3040 currentWindow = NULL; |
1135
5d7c05932b13
Add command /buffer close
Mikael Berthe <mikael@lilotux.net>
parents:
1133
diff
changeset
|
3041 } |
5d7c05932b13
Add command /buffer close
Mikael Berthe <mikael@lilotux.net>
parents:
1133
diff
changeset
|
3042 |
866 | 3043 // Refresh the window |
1780
e4378fbab5d7
Major API cleanup - bump API to 4
Mikael Berthe <mikael@lilotux.net>
parents:
1761
diff
changeset
|
3044 scr_update_buddy_window(); |
866 | 3045 |
3046 // Finished :) | |
3047 update_panels(); | |
3048 } | |
3049 | |
1780
e4378fbab5d7
Major API cleanup - bump API to 4
Mikael Berthe <mikael@lilotux.net>
parents:
1761
diff
changeset
|
3050 // scr_buffer_scroll_lock(lock) |
873
ee39f6d94d43
Add /buffer {scroll_lock|scroll_unlock|toggle_scroll}
Mikael Berthe <mikael@lilotux.net>
parents:
866
diff
changeset
|
3051 // Lock/unlock the current buddy buffer |
ee39f6d94d43
Add /buffer {scroll_lock|scroll_unlock|toggle_scroll}
Mikael Berthe <mikael@lilotux.net>
parents:
866
diff
changeset
|
3052 // lock = 1 : lock |
ee39f6d94d43
Add /buffer {scroll_lock|scroll_unlock|toggle_scroll}
Mikael Berthe <mikael@lilotux.net>
parents:
866
diff
changeset
|
3053 // lock = 0 : unlock |
ee39f6d94d43
Add /buffer {scroll_lock|scroll_unlock|toggle_scroll}
Mikael Berthe <mikael@lilotux.net>
parents:
866
diff
changeset
|
3054 // lock = -1: toggle lock status |
1780
e4378fbab5d7
Major API cleanup - bump API to 4
Mikael Berthe <mikael@lilotux.net>
parents:
1761
diff
changeset
|
3055 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
|
3056 { |
2337 | 3057 winbuf_t *win_entry; |
873
ee39f6d94d43
Add /buffer {scroll_lock|scroll_unlock|toggle_scroll}
Mikael Berthe <mikael@lilotux.net>
parents:
866
diff
changeset
|
3058 guint isspe; |
ee39f6d94d43
Add /buffer {scroll_lock|scroll_unlock|toggle_scroll}
Mikael Berthe <mikael@lilotux.net>
parents:
866
diff
changeset
|
3059 |
ee39f6d94d43
Add /buffer {scroll_lock|scroll_unlock|toggle_scroll}
Mikael Berthe <mikael@lilotux.net>
parents:
866
diff
changeset
|
3060 // Get win_entry |
ee39f6d94d43
Add /buffer {scroll_lock|scroll_unlock|toggle_scroll}
Mikael Berthe <mikael@lilotux.net>
parents:
866
diff
changeset
|
3061 if (!current_buddy) return; |
ee39f6d94d43
Add /buffer {scroll_lock|scroll_unlock|toggle_scroll}
Mikael Berthe <mikael@lilotux.net>
parents:
866
diff
changeset
|
3062 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
|
3063 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
|
3064 if (!win_entry) return; |
ee39f6d94d43
Add /buffer {scroll_lock|scroll_unlock|toggle_scroll}
Mikael Berthe <mikael@lilotux.net>
parents:
866
diff
changeset
|
3065 |
ee39f6d94d43
Add /buffer {scroll_lock|scroll_unlock|toggle_scroll}
Mikael Berthe <mikael@lilotux.net>
parents:
866
diff
changeset
|
3066 if (lock == -1) |
1157
5c857f0f0ab8
Moved all variables related to hbuf to an extra struct, bufdata
Frank Zschockelt
parents:
1156
diff
changeset
|
3067 lock = !win_entry->bd->lock; |
873
ee39f6d94d43
Add /buffer {scroll_lock|scroll_unlock|toggle_scroll}
Mikael Berthe <mikael@lilotux.net>
parents:
866
diff
changeset
|
3068 |
ee39f6d94d43
Add /buffer {scroll_lock|scroll_unlock|toggle_scroll}
Mikael Berthe <mikael@lilotux.net>
parents:
866
diff
changeset
|
3069 if (lock) { |
1157
5c857f0f0ab8
Moved all variables related to hbuf to an extra struct, bufdata
Frank Zschockelt
parents:
1156
diff
changeset
|
3070 win_entry->bd->lock = TRUE; |
873
ee39f6d94d43
Add /buffer {scroll_lock|scroll_unlock|toggle_scroll}
Mikael Berthe <mikael@lilotux.net>
parents:
866
diff
changeset
|
3071 } else { |
1157
5c857f0f0ab8
Moved all variables related to hbuf to an extra struct, bufdata
Frank Zschockelt
parents:
1156
diff
changeset
|
3072 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
|
3073 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
|
3074 win_entry->bd->top = NULL; |
873
ee39f6d94d43
Add /buffer {scroll_lock|scroll_unlock|toggle_scroll}
Mikael Berthe <mikael@lilotux.net>
parents:
866
diff
changeset
|
3075 } |
ee39f6d94d43
Add /buffer {scroll_lock|scroll_unlock|toggle_scroll}
Mikael Berthe <mikael@lilotux.net>
parents:
866
diff
changeset
|
3076 |
ee39f6d94d43
Add /buffer {scroll_lock|scroll_unlock|toggle_scroll}
Mikael Berthe <mikael@lilotux.net>
parents:
866
diff
changeset
|
3077 // 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
|
3078 // 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
|
3079 // 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
|
3080 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
|
3081 chatmode = TRUE; |
1780
e4378fbab5d7
Major API cleanup - bump API to 4
Mikael Berthe <mikael@lilotux.net>
parents:
1761
diff
changeset
|
3082 scr_show_buddy_window(); |
873
ee39f6d94d43
Add /buffer {scroll_lock|scroll_unlock|toggle_scroll}
Mikael Berthe <mikael@lilotux.net>
parents:
866
diff
changeset
|
3083 chatmode = FALSE; |
ee39f6d94d43
Add /buffer {scroll_lock|scroll_unlock|toggle_scroll}
Mikael Berthe <mikael@lilotux.net>
parents:
866
diff
changeset
|
3084 } |
ee39f6d94d43
Add /buffer {scroll_lock|scroll_unlock|toggle_scroll}
Mikael Berthe <mikael@lilotux.net>
parents:
866
diff
changeset
|
3085 |
ee39f6d94d43
Add /buffer {scroll_lock|scroll_unlock|toggle_scroll}
Mikael Berthe <mikael@lilotux.net>
parents:
866
diff
changeset
|
3086 // Refresh the window |
1780
e4378fbab5d7
Major API cleanup - bump API to 4
Mikael Berthe <mikael@lilotux.net>
parents:
1761
diff
changeset
|
3087 scr_update_buddy_window(); |
873
ee39f6d94d43
Add /buffer {scroll_lock|scroll_unlock|toggle_scroll}
Mikael Berthe <mikael@lilotux.net>
parents:
866
diff
changeset
|
3088 |
ee39f6d94d43
Add /buffer {scroll_lock|scroll_unlock|toggle_scroll}
Mikael Berthe <mikael@lilotux.net>
parents:
866
diff
changeset
|
3089 // Finished :) |
ee39f6d94d43
Add /buffer {scroll_lock|scroll_unlock|toggle_scroll}
Mikael Berthe <mikael@lilotux.net>
parents:
866
diff
changeset
|
3090 update_panels(); |
ee39f6d94d43
Add /buffer {scroll_lock|scroll_unlock|toggle_scroll}
Mikael Berthe <mikael@lilotux.net>
parents:
866
diff
changeset
|
3091 } |
ee39f6d94d43
Add /buffer {scroll_lock|scroll_unlock|toggle_scroll}
Mikael Berthe <mikael@lilotux.net>
parents:
866
diff
changeset
|
3092 |
1961
39021fd6b0e1
Try to improve readmarks in some cases
Mikael Berthe <mikael@lilotux.net>
parents:
1960
diff
changeset
|
3093 // scr_buffer_readmark(action) |
39021fd6b0e1
Try to improve readmarks in some cases
Mikael Berthe <mikael@lilotux.net>
parents:
1960
diff
changeset
|
3094 // 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
|
3095 // 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
|
3096 // If action = 0, reset the readmark flag |
39021fd6b0e1
Try to improve readmarks in some cases
Mikael Berthe <mikael@lilotux.net>
parents:
1960
diff
changeset
|
3097 // 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
|
3098 void scr_buffer_readmark(gchar action) |
1949
13d18777a629
Add scr_buffer_readmark()
Mikael Berthe <mikael@lilotux.net>
parents:
1948
diff
changeset
|
3099 { |
2337 | 3100 winbuf_t *win_entry; |
1949
13d18777a629
Add scr_buffer_readmark()
Mikael Berthe <mikael@lilotux.net>
parents:
1948
diff
changeset
|
3101 guint isspe; |
2098
c4a68361883f
Lock buffer automatically when scrolled up, unlock when at bottom ("buffer_smart_scrolling" setting)
Hermitifier
parents:
2090
diff
changeset
|
3102 int autolock; |
1949
13d18777a629
Add scr_buffer_readmark()
Mikael Berthe <mikael@lilotux.net>
parents:
1948
diff
changeset
|
3103 |
13d18777a629
Add scr_buffer_readmark()
Mikael Berthe <mikael@lilotux.net>
parents:
1948
diff
changeset
|
3104 // Get win_entry |
13d18777a629
Add scr_buffer_readmark()
Mikael Berthe <mikael@lilotux.net>
parents:
1948
diff
changeset
|
3105 if (!current_buddy) return; |
13d18777a629
Add scr_buffer_readmark()
Mikael Berthe <mikael@lilotux.net>
parents:
1948
diff
changeset
|
3106 isspe = buddy_gettype(BUDDATA(current_buddy)) & ROSTER_TYPE_SPECIAL; |
13d18777a629
Add scr_buffer_readmark()
Mikael Berthe <mikael@lilotux.net>
parents:
1948
diff
changeset
|
3107 if (isspe) return; // Maybe not necessary |
13d18777a629
Add scr_buffer_readmark()
Mikael Berthe <mikael@lilotux.net>
parents:
1948
diff
changeset
|
3108 win_entry = scr_search_window(CURRENT_JID, isspe); |
13d18777a629
Add scr_buffer_readmark()
Mikael Berthe <mikael@lilotux.net>
parents:
1948
diff
changeset
|
3109 if (!win_entry) return; |
13d18777a629
Add scr_buffer_readmark()
Mikael Berthe <mikael@lilotux.net>
parents:
1948
diff
changeset
|
3110 |
2098
c4a68361883f
Lock buffer automatically when scrolled up, unlock when at bottom ("buffer_smart_scrolling" setting)
Hermitifier
parents:
2090
diff
changeset
|
3111 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
|
3112 if (!win_entry->bd->lock || autolock) { |
1961
39021fd6b0e1
Try to improve readmarks in some cases
Mikael Berthe <mikael@lilotux.net>
parents:
1960
diff
changeset
|
3113 if (action >= 0) |
39021fd6b0e1
Try to improve readmarks in some cases
Mikael Berthe <mikael@lilotux.net>
parents:
1960
diff
changeset
|
3114 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
|
3115 else |
39021fd6b0e1
Try to improve readmarks in some cases
Mikael Berthe <mikael@lilotux.net>
parents:
1960
diff
changeset
|
3116 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
|
3117 } |
1949
13d18777a629
Add scr_buffer_readmark()
Mikael Berthe <mikael@lilotux.net>
parents:
1948
diff
changeset
|
3118 } |
13d18777a629
Add scr_buffer_readmark()
Mikael Berthe <mikael@lilotux.net>
parents:
1948
diff
changeset
|
3119 |
13d18777a629
Add scr_buffer_readmark()
Mikael Berthe <mikael@lilotux.net>
parents:
1948
diff
changeset
|
3120 |
1780
e4378fbab5d7
Major API cleanup - bump API to 4
Mikael Berthe <mikael@lilotux.net>
parents:
1761
diff
changeset
|
3121 // scr_buffer_top_bottom() |
361
51ff319947c3
Code cleanup/optimization
Mikael Berthe <mikael@lilotux.net>
parents:
358
diff
changeset
|
3122 // Jump to the head/tail of the current buddy window |
51ff319947c3
Code cleanup/optimization
Mikael Berthe <mikael@lilotux.net>
parents:
358
diff
changeset
|
3123 // (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
|
3124 void scr_buffer_top_bottom(int topbottom) |
187 | 3125 { |
2337 | 3126 winbuf_t *win_entry; |
849
42c43a88d823
Status buffer management
Mikael Berthe <mikael@lilotux.net>
parents:
848
diff
changeset
|
3127 guint isspe; |
187 | 3128 |
3129 // Get win_entry | |
3130 if (!current_buddy) return; | |
849
42c43a88d823
Status buffer management
Mikael Berthe <mikael@lilotux.net>
parents:
848
diff
changeset
|
3131 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
|
3132 win_entry = scr_search_window(CURRENT_JID, isspe); |
187 | 3133 if (!win_entry) return; |
3134 | |
1157
5c857f0f0ab8
Moved all variables related to hbuf to an extra struct, bufdata
Frank Zschockelt
parents:
1156
diff
changeset
|
3135 win_entry->bd->cleared = FALSE; |
361
51ff319947c3
Code cleanup/optimization
Mikael Berthe <mikael@lilotux.net>
parents:
358
diff
changeset
|
3136 if (topbottom == 1) |
1157
5c857f0f0ab8
Moved all variables related to hbuf to an extra struct, bufdata
Frank Zschockelt
parents:
1156
diff
changeset
|
3137 win_entry->bd->top = NULL; |
361
51ff319947c3
Code cleanup/optimization
Mikael Berthe <mikael@lilotux.net>
parents:
358
diff
changeset
|
3138 else |
1157
5c857f0f0ab8
Moved all variables related to hbuf to an extra struct, bufdata
Frank Zschockelt
parents:
1156
diff
changeset
|
3139 win_entry->bd->top = g_list_first(win_entry->bd->hbuf); |
187 | 3140 |
3141 // Refresh the window | |
1780
e4378fbab5d7
Major API cleanup - bump API to 4
Mikael Berthe <mikael@lilotux.net>
parents:
1761
diff
changeset
|
3142 scr_update_window(win_entry); |
187 | 3143 |
3144 // Finished :) | |
3145 update_panels(); | |
3146 } | |
3147 | |
1780
e4378fbab5d7
Major API cleanup - bump API to 4
Mikael Berthe <mikael@lilotux.net>
parents:
1761
diff
changeset
|
3148 // scr_buffer_search(direction, text) |
370
dd9e2eb52916
Add /buffer search_{backward,forward}
Mikael Berthe <mikael@lilotux.net>
parents:
369
diff
changeset
|
3149 // Jump to the next line containing text |
dd9e2eb52916
Add /buffer search_{backward,forward}
Mikael Berthe <mikael@lilotux.net>
parents:
369
diff
changeset
|
3150 // (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
|
3151 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
|
3152 { |
2337 | 3153 winbuf_t *win_entry; |
370
dd9e2eb52916
Add /buffer search_{backward,forward}
Mikael Berthe <mikael@lilotux.net>
parents:
369
diff
changeset
|
3154 GList *current_line, *search_res; |
849
42c43a88d823
Status buffer management
Mikael Berthe <mikael@lilotux.net>
parents:
848
diff
changeset
|
3155 guint isspe; |
370
dd9e2eb52916
Add /buffer search_{backward,forward}
Mikael Berthe <mikael@lilotux.net>
parents:
369
diff
changeset
|
3156 |
dd9e2eb52916
Add /buffer search_{backward,forward}
Mikael Berthe <mikael@lilotux.net>
parents:
369
diff
changeset
|
3157 // Get win_entry |
dd9e2eb52916
Add /buffer search_{backward,forward}
Mikael Berthe <mikael@lilotux.net>
parents:
369
diff
changeset
|
3158 if (!current_buddy) return; |
849
42c43a88d823
Status buffer management
Mikael Berthe <mikael@lilotux.net>
parents:
848
diff
changeset
|
3159 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
|
3160 win_entry = scr_search_window(CURRENT_JID, isspe); |
370
dd9e2eb52916
Add /buffer search_{backward,forward}
Mikael Berthe <mikael@lilotux.net>
parents:
369
diff
changeset
|
3161 if (!win_entry) return; |
dd9e2eb52916
Add /buffer search_{backward,forward}
Mikael Berthe <mikael@lilotux.net>
parents:
369
diff
changeset
|
3162 |
1157
5c857f0f0ab8
Moved all variables related to hbuf to an extra struct, bufdata
Frank Zschockelt
parents:
1156
diff
changeset
|
3163 if (win_entry->bd->top) |
5c857f0f0ab8
Moved all variables related to hbuf to an extra struct, bufdata
Frank Zschockelt
parents:
1156
diff
changeset
|
3164 current_line = win_entry->bd->top; |
370
dd9e2eb52916
Add /buffer search_{backward,forward}
Mikael Berthe <mikael@lilotux.net>
parents:
369
diff
changeset
|
3165 else |
1157
5c857f0f0ab8
Moved all variables related to hbuf to an extra struct, bufdata
Frank Zschockelt
parents:
1156
diff
changeset
|
3166 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
|
3167 |
dd9e2eb52916
Add /buffer search_{backward,forward}
Mikael Berthe <mikael@lilotux.net>
parents:
369
diff
changeset
|
3168 search_res = hbuf_search(current_line, direction, text); |
dd9e2eb52916
Add /buffer search_{backward,forward}
Mikael Berthe <mikael@lilotux.net>
parents:
369
diff
changeset
|
3169 |
dd9e2eb52916
Add /buffer search_{backward,forward}
Mikael Berthe <mikael@lilotux.net>
parents:
369
diff
changeset
|
3170 if (search_res) { |
1157
5c857f0f0ab8
Moved all variables related to hbuf to an extra struct, bufdata
Frank Zschockelt
parents:
1156
diff
changeset
|
3171 win_entry->bd->cleared = FALSE; |
5c857f0f0ab8
Moved all variables related to hbuf to an extra struct, bufdata
Frank Zschockelt
parents:
1156
diff
changeset
|
3172 win_entry->bd->top = search_res; |
370
dd9e2eb52916
Add /buffer search_{backward,forward}
Mikael Berthe <mikael@lilotux.net>
parents:
369
diff
changeset
|
3173 |
dd9e2eb52916
Add /buffer search_{backward,forward}
Mikael Berthe <mikael@lilotux.net>
parents:
369
diff
changeset
|
3174 // Refresh the window |
1780
e4378fbab5d7
Major API cleanup - bump API to 4
Mikael Berthe <mikael@lilotux.net>
parents:
1761
diff
changeset
|
3175 scr_update_window(win_entry); |
370
dd9e2eb52916
Add /buffer search_{backward,forward}
Mikael Berthe <mikael@lilotux.net>
parents:
369
diff
changeset
|
3176 |
dd9e2eb52916
Add /buffer search_{backward,forward}
Mikael Berthe <mikael@lilotux.net>
parents:
369
diff
changeset
|
3177 // Finished :) |
dd9e2eb52916
Add /buffer search_{backward,forward}
Mikael Berthe <mikael@lilotux.net>
parents:
369
diff
changeset
|
3178 update_panels(); |
dd9e2eb52916
Add /buffer search_{backward,forward}
Mikael Berthe <mikael@lilotux.net>
parents:
369
diff
changeset
|
3179 } else |
1957
e3e8fb918d56
Be more verbose when the buffer search commands are not successful
Mikael Berthe <mikael@lilotux.net>
parents:
1956
diff
changeset
|
3180 scr_LogPrint(LPRINT_NORMAL, "Search string not found."); |
370
dd9e2eb52916
Add /buffer search_{backward,forward}
Mikael Berthe <mikael@lilotux.net>
parents:
369
diff
changeset
|
3181 } |
dd9e2eb52916
Add /buffer search_{backward,forward}
Mikael Berthe <mikael@lilotux.net>
parents:
369
diff
changeset
|
3182 |
1780
e4378fbab5d7
Major API cleanup - bump API to 4
Mikael Berthe <mikael@lilotux.net>
parents:
1761
diff
changeset
|
3183 // scr_buffer_percent(n) |
462 | 3184 // 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
|
3185 void scr_buffer_percent(int pc) |
462 | 3186 { |
2337 | 3187 winbuf_t *win_entry; |
462 | 3188 GList *search_res; |
849
42c43a88d823
Status buffer management
Mikael Berthe <mikael@lilotux.net>
parents:
848
diff
changeset
|
3189 guint isspe; |
462 | 3190 |
3191 // Get win_entry | |
3192 if (!current_buddy) return; | |
849
42c43a88d823
Status buffer management
Mikael Berthe <mikael@lilotux.net>
parents:
848
diff
changeset
|
3193 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
|
3194 win_entry = scr_search_window(CURRENT_JID, isspe); |
462 | 3195 if (!win_entry) return; |
3196 | |
3197 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
|
3198 scr_LogPrint(LPRINT_NORMAL, "Bad %% value"); |
462 | 3199 return; |
3200 } | |
3201 | |
1157
5c857f0f0ab8
Moved all variables related to hbuf to an extra struct, bufdata
Frank Zschockelt
parents:
1156
diff
changeset
|
3202 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
|
3203 |
5c857f0f0ab8
Moved all variables related to hbuf to an extra struct, bufdata
Frank Zschockelt
parents:
1156
diff
changeset
|
3204 win_entry->bd->cleared = FALSE; |
5c857f0f0ab8
Moved all variables related to hbuf to an extra struct, bufdata
Frank Zschockelt
parents:
1156
diff
changeset
|
3205 win_entry->bd->top = search_res; |
462 | 3206 |
3207 // Refresh the window | |
1780
e4378fbab5d7
Major API cleanup - bump API to 4
Mikael Berthe <mikael@lilotux.net>
parents:
1761
diff
changeset
|
3208 scr_update_window(win_entry); |
462 | 3209 |
3210 // Finished :) | |
3211 update_panels(); | |
3212 } | |
3213 | |
1780
e4378fbab5d7
Major API cleanup - bump API to 4
Mikael Berthe <mikael@lilotux.net>
parents:
1761
diff
changeset
|
3214 // scr_buffer_date(t) |
464 | 3215 // Jump to the first line after date t in the buffer |
3216 // 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
|
3217 void scr_buffer_date(time_t t) |
464 | 3218 { |
2337 | 3219 winbuf_t *win_entry; |
464 | 3220 GList *search_res; |
849
42c43a88d823
Status buffer management
Mikael Berthe <mikael@lilotux.net>
parents:
848
diff
changeset
|
3221 guint isspe; |
464 | 3222 |
3223 // Get win_entry | |
3224 if (!current_buddy) return; | |
849
42c43a88d823
Status buffer management
Mikael Berthe <mikael@lilotux.net>
parents:
848
diff
changeset
|
3225 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
|
3226 win_entry = scr_search_window(CURRENT_JID, isspe); |
464 | 3227 if (!win_entry) return; |
3228 | |
1157
5c857f0f0ab8
Moved all variables related to hbuf to an extra struct, bufdata
Frank Zschockelt
parents:
1156
diff
changeset
|
3229 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
|
3230 |
5c857f0f0ab8
Moved all variables related to hbuf to an extra struct, bufdata
Frank Zschockelt
parents:
1156
diff
changeset
|
3231 win_entry->bd->cleared = FALSE; |
5c857f0f0ab8
Moved all variables related to hbuf to an extra struct, bufdata
Frank Zschockelt
parents:
1156
diff
changeset
|
3232 win_entry->bd->top = search_res; |
464 | 3233 |
1957
e3e8fb918d56
Be more verbose when the buffer search commands are not successful
Mikael Berthe <mikael@lilotux.net>
parents:
1956
diff
changeset
|
3234 if (!search_res) |
e3e8fb918d56
Be more verbose when the buffer search commands are not successful
Mikael Berthe <mikael@lilotux.net>
parents:
1956
diff
changeset
|
3235 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
|
3236 |
464 | 3237 // Refresh the window |
1780
e4378fbab5d7
Major API cleanup - bump API to 4
Mikael Berthe <mikael@lilotux.net>
parents:
1761
diff
changeset
|
3238 scr_update_window(win_entry); |
464 | 3239 |
3240 // Finished :) | |
3241 update_panels(); | |
3242 } | |
3243 | |
1956
f309f343070c
Add command /buffer readmark
Mikael Berthe <mikael@lilotux.net>
parents:
1955
diff
changeset
|
3244 // scr_buffer_jump_readmark() |
f309f343070c
Add command /buffer readmark
Mikael Berthe <mikael@lilotux.net>
parents:
1955
diff
changeset
|
3245 // Jump to the buffer readmark, if there's one |
f309f343070c
Add command /buffer readmark
Mikael Berthe <mikael@lilotux.net>
parents:
1955
diff
changeset
|
3246 void scr_buffer_jump_readmark(void) |
f309f343070c
Add command /buffer readmark
Mikael Berthe <mikael@lilotux.net>
parents:
1955
diff
changeset
|
3247 { |
2337 | 3248 winbuf_t *win_entry; |
1956
f309f343070c
Add command /buffer readmark
Mikael Berthe <mikael@lilotux.net>
parents:
1955
diff
changeset
|
3249 GList *search_res; |
f309f343070c
Add command /buffer readmark
Mikael Berthe <mikael@lilotux.net>
parents:
1955
diff
changeset
|
3250 guint isspe; |
f309f343070c
Add command /buffer readmark
Mikael Berthe <mikael@lilotux.net>
parents:
1955
diff
changeset
|
3251 |
f309f343070c
Add command /buffer readmark
Mikael Berthe <mikael@lilotux.net>
parents:
1955
diff
changeset
|
3252 // Get win_entry |
f309f343070c
Add command /buffer readmark
Mikael Berthe <mikael@lilotux.net>
parents:
1955
diff
changeset
|
3253 if (!current_buddy) return; |
f309f343070c
Add command /buffer readmark
Mikael Berthe <mikael@lilotux.net>
parents:
1955
diff
changeset
|
3254 isspe = buddy_gettype(BUDDATA(current_buddy)) & ROSTER_TYPE_SPECIAL; |
f309f343070c
Add command /buffer readmark
Mikael Berthe <mikael@lilotux.net>
parents:
1955
diff
changeset
|
3255 if (isspe) return; |
f309f343070c
Add command /buffer readmark
Mikael Berthe <mikael@lilotux.net>
parents:
1955
diff
changeset
|
3256 win_entry = scr_search_window(CURRENT_JID, isspe); |
f309f343070c
Add command /buffer readmark
Mikael Berthe <mikael@lilotux.net>
parents:
1955
diff
changeset
|
3257 if (!win_entry) return; |
f309f343070c
Add command /buffer readmark
Mikael Berthe <mikael@lilotux.net>
parents:
1955
diff
changeset
|
3258 |
f309f343070c
Add command /buffer readmark
Mikael Berthe <mikael@lilotux.net>
parents:
1955
diff
changeset
|
3259 search_res = hbuf_jump_readmark(win_entry->bd->hbuf); |
f309f343070c
Add command /buffer readmark
Mikael Berthe <mikael@lilotux.net>
parents:
1955
diff
changeset
|
3260 |
1968
83d7c7daea6a
buffer readmark: don't update the screen when there is no mark
Mikael Berthe <mikael@lilotux.net>
parents:
1965
diff
changeset
|
3261 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
|
3262 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
|
3263 return; |
83d7c7daea6a
buffer readmark: don't update the screen when there is no mark
Mikael Berthe <mikael@lilotux.net>
parents:
1965
diff
changeset
|
3264 } |
83d7c7daea6a
buffer readmark: don't update the screen when there is no mark
Mikael Berthe <mikael@lilotux.net>
parents:
1965
diff
changeset
|
3265 |
1956
f309f343070c
Add command /buffer readmark
Mikael Berthe <mikael@lilotux.net>
parents:
1955
diff
changeset
|
3266 win_entry->bd->cleared = FALSE; |
f309f343070c
Add command /buffer readmark
Mikael Berthe <mikael@lilotux.net>
parents:
1955
diff
changeset
|
3267 win_entry->bd->top = search_res; |
f309f343070c
Add command /buffer readmark
Mikael Berthe <mikael@lilotux.net>
parents:
1955
diff
changeset
|
3268 |
f309f343070c
Add command /buffer readmark
Mikael Berthe <mikael@lilotux.net>
parents:
1955
diff
changeset
|
3269 // Refresh the window |
f309f343070c
Add command /buffer readmark
Mikael Berthe <mikael@lilotux.net>
parents:
1955
diff
changeset
|
3270 scr_update_window(win_entry); |
f309f343070c
Add command /buffer readmark
Mikael Berthe <mikael@lilotux.net>
parents:
1955
diff
changeset
|
3271 |
f309f343070c
Add command /buffer readmark
Mikael Berthe <mikael@lilotux.net>
parents:
1955
diff
changeset
|
3272 // Finished :) |
f309f343070c
Add command /buffer readmark
Mikael Berthe <mikael@lilotux.net>
parents:
1955
diff
changeset
|
3273 update_panels(); |
f309f343070c
Add command /buffer readmark
Mikael Berthe <mikael@lilotux.net>
parents:
1955
diff
changeset
|
3274 } |
f309f343070c
Add command /buffer readmark
Mikael Berthe <mikael@lilotux.net>
parents:
1955
diff
changeset
|
3275 |
1780
e4378fbab5d7
Major API cleanup - bump API to 4
Mikael Berthe <mikael@lilotux.net>
parents:
1761
diff
changeset
|
3276 // scr_buffer_dump(filename) |
e4378fbab5d7
Major API cleanup - bump API to 4
Mikael Berthe <mikael@lilotux.net>
parents:
1761
diff
changeset
|
3277 // 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
|
3278 void scr_buffer_dump(const char *file) |
1485
0121b6f3047c
New command: /buffer save
Mikael Berthe <mikael@lilotux.net>
parents:
1484
diff
changeset
|
3279 { |
0121b6f3047c
New command: /buffer save
Mikael Berthe <mikael@lilotux.net>
parents:
1484
diff
changeset
|
3280 char *extfname; |
0121b6f3047c
New command: /buffer save
Mikael Berthe <mikael@lilotux.net>
parents:
1484
diff
changeset
|
3281 |
0121b6f3047c
New command: /buffer save
Mikael Berthe <mikael@lilotux.net>
parents:
1484
diff
changeset
|
3282 if (!currentWindow) { |
0121b6f3047c
New command: /buffer save
Mikael Berthe <mikael@lilotux.net>
parents:
1484
diff
changeset
|
3283 scr_LogPrint(LPRINT_NORMAL, "No current buffer!"); |
0121b6f3047c
New command: /buffer save
Mikael Berthe <mikael@lilotux.net>
parents:
1484
diff
changeset
|
3284 return; |
0121b6f3047c
New command: /buffer save
Mikael Berthe <mikael@lilotux.net>
parents:
1484
diff
changeset
|
3285 } |
0121b6f3047c
New command: /buffer save
Mikael Berthe <mikael@lilotux.net>
parents:
1484
diff
changeset
|
3286 |
0121b6f3047c
New command: /buffer save
Mikael Berthe <mikael@lilotux.net>
parents:
1484
diff
changeset
|
3287 if (!file || !*file) { |
0121b6f3047c
New command: /buffer save
Mikael Berthe <mikael@lilotux.net>
parents:
1484
diff
changeset
|
3288 scr_LogPrint(LPRINT_NORMAL, "Missing parameter (file name)!"); |
0121b6f3047c
New command: /buffer save
Mikael Berthe <mikael@lilotux.net>
parents:
1484
diff
changeset
|
3289 return; |
0121b6f3047c
New command: /buffer save
Mikael Berthe <mikael@lilotux.net>
parents:
1484
diff
changeset
|
3290 } |
0121b6f3047c
New command: /buffer save
Mikael Berthe <mikael@lilotux.net>
parents:
1484
diff
changeset
|
3291 |
0121b6f3047c
New command: /buffer save
Mikael Berthe <mikael@lilotux.net>
parents:
1484
diff
changeset
|
3292 extfname = expand_filename(file); |
0121b6f3047c
New command: /buffer save
Mikael Berthe <mikael@lilotux.net>
parents:
1484
diff
changeset
|
3293 hbuf_dump_to_file(currentWindow->bd->hbuf, extfname); |
0121b6f3047c
New command: /buffer save
Mikael Berthe <mikael@lilotux.net>
parents:
1484
diff
changeset
|
3294 g_free(extfname); |
0121b6f3047c
New command: /buffer save
Mikael Berthe <mikael@lilotux.net>
parents:
1484
diff
changeset
|
3295 } |
0121b6f3047c
New command: /buffer save
Mikael Berthe <mikael@lilotux.net>
parents:
1484
diff
changeset
|
3296 |
1226
2521efbf3b72
New (debug) subcommand, buffer list
Mikael Berthe <mikael@lilotux.net>
parents:
1225
diff
changeset
|
3297 // buffer_list() |
2521efbf3b72
New (debug) subcommand, buffer list
Mikael Berthe <mikael@lilotux.net>
parents:
1225
diff
changeset
|
3298 // key: winId/jid |
2337 | 3299 // value: winbuf_t structure |
1226
2521efbf3b72
New (debug) subcommand, buffer list
Mikael Berthe <mikael@lilotux.net>
parents:
1225
diff
changeset
|
3300 // data: none. |
2521efbf3b72
New (debug) subcommand, buffer list
Mikael Berthe <mikael@lilotux.net>
parents:
1225
diff
changeset
|
3301 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
|
3302 { |
1227
79c396678f1b
Make buffer list display the number of allocated HBB blocks
Mikael Berthe <mikael@lilotux.net>
parents:
1226
diff
changeset
|
3303 GList *head; |
2337 | 3304 winbuf_t *win_entry = value; |
1227
79c396678f1b
Make buffer list display the number of allocated HBB blocks
Mikael Berthe <mikael@lilotux.net>
parents:
1226
diff
changeset
|
3305 |
79c396678f1b
Make buffer list display the number of allocated HBB blocks
Mikael Berthe <mikael@lilotux.net>
parents:
1226
diff
changeset
|
3306 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
|
3307 |
1686
393c05fba337
Use G_GNUC_PRINTF to check scr_LogPrint arguments
Myhailo Danylenko <isbear@ukrpost.net>
parents:
1677
diff
changeset
|
3308 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
|
3309 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
|
3310 } |
2521efbf3b72
New (debug) subcommand, buffer list
Mikael Berthe <mikael@lilotux.net>
parents:
1225
diff
changeset
|
3311 |
1780
e4378fbab5d7
Major API cleanup - bump API to 4
Mikael Berthe <mikael@lilotux.net>
parents:
1761
diff
changeset
|
3312 void scr_buffer_list(void) |
1226
2521efbf3b72
New (debug) subcommand, buffer list
Mikael Berthe <mikael@lilotux.net>
parents:
1225
diff
changeset
|
3313 { |
2521efbf3b72
New (debug) subcommand, buffer list
Mikael Berthe <mikael@lilotux.net>
parents:
1225
diff
changeset
|
3314 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
|
3315 buffer_list("[status]", statusWindow, NULL); |
1226
2521efbf3b72
New (debug) subcommand, buffer list
Mikael Berthe <mikael@lilotux.net>
parents:
1225
diff
changeset
|
3316 g_hash_table_foreach(winbufhash, buffer_list, NULL); |
2521efbf3b72
New (debug) subcommand, buffer list
Mikael Berthe <mikael@lilotux.net>
parents:
1225
diff
changeset
|
3317 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
|
3318 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
|
3319 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
|
3320 ROSTER_UI_PRIO_STATUS_WIN_MESSAGE, prio_max); |
1226
2521efbf3b72
New (debug) subcommand, buffer list
Mikael Berthe <mikael@lilotux.net>
parents:
1225
diff
changeset
|
3321 } |
2521efbf3b72
New (debug) subcommand, buffer list
Mikael Berthe <mikael@lilotux.net>
parents:
1225
diff
changeset
|
3322 |
143 | 3323 // scr_set_chatmode() |
261 | 3324 // Public function to (un)set chatmode... |
2338 | 3325 void scr_set_chatmode(int enable) |
129 | 3326 { |
1961
39021fd6b0e1
Try to improve readmarks in some cases
Mikael Berthe <mikael@lilotux.net>
parents:
1960
diff
changeset
|
3327 gboolean enter_chatmode = enable && chatmode == FALSE; |
129 | 3328 chatmode = enable; |
1780
e4378fbab5d7
Major API cleanup - bump API to 4
Mikael Berthe <mikael@lilotux.net>
parents:
1761
diff
changeset
|
3329 scr_update_chat_status(TRUE); |
1961
39021fd6b0e1
Try to improve readmarks in some cases
Mikael Berthe <mikael@lilotux.net>
parents:
1960
diff
changeset
|
3330 if (enter_chatmode) |
39021fd6b0e1
Try to improve readmarks in some cases
Mikael Berthe <mikael@lilotux.net>
parents:
1960
diff
changeset
|
3331 scr_buffer_readmark(-1); |
129 | 3332 } |
3333 | |
1129
1a109ebf3f24
Add option "events_ignore_active_window"
Mikael Berthe <mikael@lilotux.net>
parents:
1127
diff
changeset
|
3334 // scr_get_chatmode() |
1a109ebf3f24
Add option "events_ignore_active_window"
Mikael Berthe <mikael@lilotux.net>
parents:
1127
diff
changeset
|
3335 // Public function to get chatmode state. |
2338 | 3336 int scr_get_chatmode(void) |
1129
1a109ebf3f24
Add option "events_ignore_active_window"
Mikael Berthe <mikael@lilotux.net>
parents:
1127
diff
changeset
|
3337 { |
1a109ebf3f24
Add option "events_ignore_active_window"
Mikael Berthe <mikael@lilotux.net>
parents:
1127
diff
changeset
|
3338 return chatmode; |
1a109ebf3f24
Add option "events_ignore_active_window"
Mikael Berthe <mikael@lilotux.net>
parents:
1127
diff
changeset
|
3339 } |
1a109ebf3f24
Add option "events_ignore_active_window"
Mikael Berthe <mikael@lilotux.net>
parents:
1127
diff
changeset
|
3340 |
238 | 3341 // scr_get_multimode() |
261 | 3342 // Public function to get multimode status... |
2338 | 3343 int scr_get_multimode(void) |
238 | 3344 { |
3345 return multimode; | |
3346 } | |
3347 | |
654
d7fe7b88e4fc
MUC: Set the new_message flag when joining a room
Mikael Berthe <mikael@lilotux.net>
parents:
652
diff
changeset
|
3348 // 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
|
3349 // Set the message flag unless we're already in the jid buffer window |
1058 | 3350 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
|
3351 { |
891
78f4971578dd
Add a "special" parameter to scr_setmsgflag_if_needed()
Mikael Berthe <mikael@lilotux.net>
parents:
889
diff
changeset
|
3352 const char *current_id; |
873
ee39f6d94d43
Add /buffer {scroll_lock|scroll_unlock|toggle_scroll}
Mikael Berthe <mikael@lilotux.net>
parents:
866
diff
changeset
|
3353 bool iscurrentlocked = FALSE; |
667
86bc3295a4db
Fix segfault in scr_setmsgflag_if_needed()
Mikael Berthe <mikael@lilotux.net>
parents:
658
diff
changeset
|
3354 |
1058 | 3355 if (!bjid) |
849
42c43a88d823
Status buffer management
Mikael Berthe <mikael@lilotux.net>
parents:
848
diff
changeset
|
3356 return; |
42c43a88d823
Status buffer management
Mikael Berthe <mikael@lilotux.net>
parents:
848
diff
changeset
|
3357 |
873
ee39f6d94d43
Add /buffer {scroll_lock|scroll_unlock|toggle_scroll}
Mikael Berthe <mikael@lilotux.net>
parents:
866
diff
changeset
|
3358 if (current_buddy) { |
891
78f4971578dd
Add a "special" parameter to scr_setmsgflag_if_needed()
Mikael Berthe <mikael@lilotux.net>
parents:
889
diff
changeset
|
3359 if (special) |
78f4971578dd
Add a "special" parameter to scr_setmsgflag_if_needed()
Mikael Berthe <mikael@lilotux.net>
parents:
889
diff
changeset
|
3360 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
|
3361 else |
78f4971578dd
Add a "special" parameter to scr_setmsgflag_if_needed()
Mikael Berthe <mikael@lilotux.net>
parents:
889
diff
changeset
|
3362 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
|
3363 if (current_id) { |
2337 | 3364 winbuf_t *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
|
3365 if (!win_entry) return; |
1157
5c857f0f0ab8
Moved all variables related to hbuf to an extra struct, bufdata
Frank Zschockelt
parents:
1156
diff
changeset
|
3366 iscurrentlocked = win_entry->bd->lock; |
873
ee39f6d94d43
Add /buffer {scroll_lock|scroll_unlock|toggle_scroll}
Mikael Berthe <mikael@lilotux.net>
parents:
866
diff
changeset
|
3367 } |
ee39f6d94d43
Add /buffer {scroll_lock|scroll_unlock|toggle_scroll}
Mikael Berthe <mikael@lilotux.net>
parents:
866
diff
changeset
|
3368 } else { |
891
78f4971578dd
Add a "special" parameter to scr_setmsgflag_if_needed()
Mikael Berthe <mikael@lilotux.net>
parents:
889
diff
changeset
|
3369 current_id = NULL; |
873
ee39f6d94d43
Add /buffer {scroll_lock|scroll_unlock|toggle_scroll}
Mikael Berthe <mikael@lilotux.net>
parents:
866
diff
changeset
|
3370 } |
1821
60db836ad98a
Move some "update_roster" updates to a better place
Mikael Berthe <mikael@lilotux.net>
parents:
1819
diff
changeset
|
3371 if (!chatmode || !current_id || strcmp(bjid, current_id) || iscurrentlocked) { |
1058 | 3372 roster_msg_setflag(bjid, special, TRUE); |
2292
f181418db215
Replace global variable update_roster with scr_update_roster()
franky
parents:
2291
diff
changeset
|
3373 scr_update_roster(); |
1821
60db836ad98a
Move some "update_roster" updates to a better place
Mikael Berthe <mikael@lilotux.net>
parents:
1819
diff
changeset
|
3374 } |
654
d7fe7b88e4fc
MUC: Set the new_message flag when joining a room
Mikael Berthe <mikael@lilotux.net>
parents:
652
diff
changeset
|
3375 } |
d7fe7b88e4fc
MUC: Set the new_message flag when joining a room
Mikael Berthe <mikael@lilotux.net>
parents:
652
diff
changeset
|
3376 |
1802
b135572fcd26
Add urgent flag per screen buffer
Mikael Berthe <mikael@lilotux.net>
parents:
1793
diff
changeset
|
3377 // 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
|
3378 // 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
|
3379 // 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
|
3380 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
|
3381 guint value, enum setuiprio_ops action) |
b135572fcd26
Add urgent flag per screen buffer
Mikael Berthe <mikael@lilotux.net>
parents:
1793
diff
changeset
|
3382 { |
b135572fcd26
Add urgent flag per screen buffer
Mikael Berthe <mikael@lilotux.net>
parents:
1793
diff
changeset
|
3383 const char *current_id; |
2337 | 3384 winbuf_t *wb; |
1802
b135572fcd26
Add urgent flag per screen buffer
Mikael Berthe <mikael@lilotux.net>
parents:
1793
diff
changeset
|
3385 bool iscurrentlocked = FALSE; |
b135572fcd26
Add urgent flag per screen buffer
Mikael Berthe <mikael@lilotux.net>
parents:
1793
diff
changeset
|
3386 |
b135572fcd26
Add urgent flag per screen buffer
Mikael Berthe <mikael@lilotux.net>
parents:
1793
diff
changeset
|
3387 if (!bjid) |
b135572fcd26
Add urgent flag per screen buffer
Mikael Berthe <mikael@lilotux.net>
parents:
1793
diff
changeset
|
3388 return; |
b135572fcd26
Add urgent flag per screen buffer
Mikael Berthe <mikael@lilotux.net>
parents:
1793
diff
changeset
|
3389 |
b135572fcd26
Add urgent flag per screen buffer
Mikael Berthe <mikael@lilotux.net>
parents:
1793
diff
changeset
|
3390 wb = scr_search_window(bjid, special); |
b135572fcd26
Add urgent flag per screen buffer
Mikael Berthe <mikael@lilotux.net>
parents:
1793
diff
changeset
|
3391 if (!wb) |
b135572fcd26
Add urgent flag per screen buffer
Mikael Berthe <mikael@lilotux.net>
parents:
1793
diff
changeset
|
3392 return; |
b135572fcd26
Add urgent flag per screen buffer
Mikael Berthe <mikael@lilotux.net>
parents:
1793
diff
changeset
|
3393 |
b135572fcd26
Add urgent flag per screen buffer
Mikael Berthe <mikael@lilotux.net>
parents:
1793
diff
changeset
|
3394 if (current_buddy) { |
b135572fcd26
Add urgent flag per screen buffer
Mikael Berthe <mikael@lilotux.net>
parents:
1793
diff
changeset
|
3395 if (special) |
b135572fcd26
Add urgent flag per screen buffer
Mikael Berthe <mikael@lilotux.net>
parents:
1793
diff
changeset
|
3396 current_id = buddy_getname(BUDDATA(current_buddy)); |
b135572fcd26
Add urgent flag per screen buffer
Mikael Berthe <mikael@lilotux.net>
parents:
1793
diff
changeset
|
3397 else |
b135572fcd26
Add urgent flag per screen buffer
Mikael Berthe <mikael@lilotux.net>
parents:
1793
diff
changeset
|
3398 current_id = buddy_getjid(BUDDATA(current_buddy)); |
b135572fcd26
Add urgent flag per screen buffer
Mikael Berthe <mikael@lilotux.net>
parents:
1793
diff
changeset
|
3399 if (current_id) { |
2337 | 3400 winbuf_t *win_entry = scr_search_window(current_id, special); |
1802
b135572fcd26
Add urgent flag per screen buffer
Mikael Berthe <mikael@lilotux.net>
parents:
1793
diff
changeset
|
3401 if (!win_entry) return; |
b135572fcd26
Add urgent flag per screen buffer
Mikael Berthe <mikael@lilotux.net>
parents:
1793
diff
changeset
|
3402 iscurrentlocked = win_entry->bd->lock; |
b135572fcd26
Add urgent flag per screen buffer
Mikael Berthe <mikael@lilotux.net>
parents:
1793
diff
changeset
|
3403 } |
b135572fcd26
Add urgent flag per screen buffer
Mikael Berthe <mikael@lilotux.net>
parents:
1793
diff
changeset
|
3404 } else { |
b135572fcd26
Add urgent flag per screen buffer
Mikael Berthe <mikael@lilotux.net>
parents:
1793
diff
changeset
|
3405 current_id = NULL; |
b135572fcd26
Add urgent flag per screen buffer
Mikael Berthe <mikael@lilotux.net>
parents:
1793
diff
changeset
|
3406 } |
b135572fcd26
Add urgent flag per screen buffer
Mikael Berthe <mikael@lilotux.net>
parents:
1793
diff
changeset
|
3407 |
1821
60db836ad98a
Move some "update_roster" updates to a better place
Mikael Berthe <mikael@lilotux.net>
parents:
1819
diff
changeset
|
3408 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
|
3409 roster_setuiprio(bjid, special, value, action); |
2292
f181418db215
Replace global variable update_roster with scr_update_roster()
franky
parents:
2291
diff
changeset
|
3410 scr_update_roster(); |
1821
60db836ad98a
Move some "update_roster" updates to a better place
Mikael Berthe <mikael@lilotux.net>
parents:
1819
diff
changeset
|
3411 } |
1802
b135572fcd26
Add urgent flag per screen buffer
Mikael Berthe <mikael@lilotux.net>
parents:
1793
diff
changeset
|
3412 } |
b135572fcd26
Add urgent flag per screen buffer
Mikael Berthe <mikael@lilotux.net>
parents:
1793
diff
changeset
|
3413 |
238 | 3414 // scr_set_multimode() |
261 | 3415 // Public function to (un)set multimode... |
260
33e1a05864a6
Add "verbatim multi-line" mode, with commands disabled
mikael@frmp8452
parents:
252
diff
changeset
|
3416 // Convention: |
33e1a05864a6
Add "verbatim multi-line" mode, with commands disabled
mikael@frmp8452
parents:
252
diff
changeset
|
3417 // 0 = disabled / 1 = multimode / 2 = multimode verbatim (commands disabled) |
1413 | 3418 void scr_set_multimode(int enable, char *subject) |
238 | 3419 { |
807
f6cda389db48
Allow messages with a subject (/msay)
Mikael Berthe <mikael@lilotux.net>
parents:
806
diff
changeset
|
3420 g_free(multiline); |
f6cda389db48
Allow messages with a subject (/msay)
Mikael Berthe <mikael@lilotux.net>
parents:
806
diff
changeset
|
3421 multiline = NULL; |
f6cda389db48
Allow messages with a subject (/msay)
Mikael Berthe <mikael@lilotux.net>
parents:
806
diff
changeset
|
3422 |
f6cda389db48
Allow messages with a subject (/msay)
Mikael Berthe <mikael@lilotux.net>
parents:
806
diff
changeset
|
3423 g_free(multimode_subj); |
f6cda389db48
Allow messages with a subject (/msay)
Mikael Berthe <mikael@lilotux.net>
parents:
806
diff
changeset
|
3424 if (enable && subject) |
f6cda389db48
Allow messages with a subject (/msay)
Mikael Berthe <mikael@lilotux.net>
parents:
806
diff
changeset
|
3425 multimode_subj = g_strdup(subject); |
f6cda389db48
Allow messages with a subject (/msay)
Mikael Berthe <mikael@lilotux.net>
parents:
806
diff
changeset
|
3426 else |
f6cda389db48
Allow messages with a subject (/msay)
Mikael Berthe <mikael@lilotux.net>
parents:
806
diff
changeset
|
3427 multimode_subj = NULL; |
f6cda389db48
Allow messages with a subject (/msay)
Mikael Berthe <mikael@lilotux.net>
parents:
806
diff
changeset
|
3428 |
260
33e1a05864a6
Add "verbatim multi-line" mode, with commands disabled
mikael@frmp8452
parents:
252
diff
changeset
|
3429 multimode = enable; |
238 | 3430 } |
3431 | |
3432 // scr_get_multiline() | |
261 | 3433 // Public function to get the current multi-line. |
1413 | 3434 const char *scr_get_multiline(void) |
238 | 3435 { |
3436 if (multimode && multiline) | |
3437 return multiline; | |
807
f6cda389db48
Allow messages with a subject (/msay)
Mikael Berthe <mikael@lilotux.net>
parents:
806
diff
changeset
|
3438 return NULL; |
f6cda389db48
Allow messages with a subject (/msay)
Mikael Berthe <mikael@lilotux.net>
parents:
806
diff
changeset
|
3439 } |
f6cda389db48
Allow messages with a subject (/msay)
Mikael Berthe <mikael@lilotux.net>
parents:
806
diff
changeset
|
3440 |
f6cda389db48
Allow messages with a subject (/msay)
Mikael Berthe <mikael@lilotux.net>
parents:
806
diff
changeset
|
3441 // scr_get_multimode_subj() |
f6cda389db48
Allow messages with a subject (/msay)
Mikael Berthe <mikael@lilotux.net>
parents:
806
diff
changeset
|
3442 // Public function to get the multi-line subject, if any. |
1413 | 3443 const char *scr_get_multimode_subj(void) |
807
f6cda389db48
Allow messages with a subject (/msay)
Mikael Berthe <mikael@lilotux.net>
parents:
806
diff
changeset
|
3444 { |
f6cda389db48
Allow messages with a subject (/msay)
Mikael Berthe <mikael@lilotux.net>
parents:
806
diff
changeset
|
3445 if (multimode) |
f6cda389db48
Allow messages with a subject (/msay)
Mikael Berthe <mikael@lilotux.net>
parents:
806
diff
changeset
|
3446 return multimode_subj; |
f6cda389db48
Allow messages with a subject (/msay)
Mikael Berthe <mikael@lilotux.net>
parents:
806
diff
changeset
|
3447 return NULL; |
238 | 3448 } |
3449 | |
3450 // scr_append_multiline(line) | |
3451 // Public function to append a line to the current multi-line message. | |
3452 // Skip empty leading lines. | |
3453 void scr_append_multiline(const char *line) | |
3454 { | |
3455 static int num; | |
3456 | |
3457 if (!multimode) { | |
374
bd5638c21834
Improve logging system (traces)
Mikael Berthe <mikael@lilotux.net>
parents:
373
diff
changeset
|
3458 scr_LogPrint(LPRINT_NORMAL, "Error: Not in multi-line message mode!"); |
238 | 3459 return; |
3460 } | |
3461 if (multiline) { | |
3462 int len = strlen(multiline)+strlen(line)+2; | |
252 | 3463 if (len >= HBB_BLOCKSIZE - 1) { |
238 | 3464 // We don't handle single messages with size > HBB_BLOCKSIZE |
3465 // (see hbuf) | |
374
bd5638c21834
Improve logging system (traces)
Mikael Berthe <mikael@lilotux.net>
parents:
373
diff
changeset
|
3466 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
|
3467 "this line has not been added."); |
bd5638c21834
Improve logging system (traces)
Mikael Berthe <mikael@lilotux.net>
parents:
373
diff
changeset
|
3468 scr_LogPrint(LPRINT_NORMAL, "Please send this part now..."); |
238 | 3469 return; |
3470 } | |
276
627925d885de
Limit the number of lines in multi-line messages
Mikael Berthe <mikael@lilotux.net>
parents:
271
diff
changeset
|
3471 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
|
3472 // 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
|
3473 // (It should be < 1000 yet) |
374
bd5638c21834
Improve logging system (traces)
Mikael Berthe <mikael@lilotux.net>
parents:
373
diff
changeset
|
3474 scr_LogPrint(LPRINT_NORMAL, "Your message has too many lines, " |
bd5638c21834
Improve logging system (traces)
Mikael Berthe <mikael@lilotux.net>
parents:
373
diff
changeset
|
3475 "this one has not been added."); |
bd5638c21834
Improve logging system (traces)
Mikael Berthe <mikael@lilotux.net>
parents:
373
diff
changeset
|
3476 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
|
3477 return; |
627925d885de
Limit the number of lines in multi-line messages
Mikael Berthe <mikael@lilotux.net>
parents:
271
diff
changeset
|
3478 } |
238 | 3479 multiline = g_renew(char, multiline, len); |
3480 strcat(multiline, "\n"); | |
3481 strcat(multiline, line); | |
3482 num++; | |
3483 } else { | |
3484 // First message line (we skip leading empty lines) | |
3485 num = 0; | |
3486 if (line[0]) { | |
419 | 3487 multiline = g_strdup(line); |
238 | 3488 num++; |
3489 } else | |
3490 return; | |
3491 } | |
772
464be13343a9
Store most data in UTF-8 internally
Mikael Berthe <mikael@lilotux.net>
parents:
771
diff
changeset
|
3492 scr_LogPrint(LPRINT_NORMAL|LPRINT_NOTUTF8, |
464be13343a9
Store most data in UTF-8 internally
Mikael Berthe <mikael@lilotux.net>
parents:
771
diff
changeset
|
3493 "Multi-line mode: line #%d added [%.25s...", num, line); |
238 | 3494 } |
3495 | |
173 | 3496 // scr_cmdhisto_addline() |
3497 // Add a line to the inputLine history | |
1985
0870005f7efc
Add command /iline clear_history
Mikael Berthe <mikael@lilotux.net>
parents:
1977
diff
changeset
|
3498 static void scr_cmdhisto_addline(char *line) |
173 | 3499 { |
1127
fddf2fef7b83
Add option "cmdhistory_lines"
Mikael Berthe <mikael@lilotux.net>
parents:
1122
diff
changeset
|
3500 int max_histo_lines; |
fddf2fef7b83
Add option "cmdhistory_lines"
Mikael Berthe <mikael@lilotux.net>
parents:
1122
diff
changeset
|
3501 |
fddf2fef7b83
Add option "cmdhistory_lines"
Mikael Berthe <mikael@lilotux.net>
parents:
1122
diff
changeset
|
3502 if (!line || !*line) |
fddf2fef7b83
Add option "cmdhistory_lines"
Mikael Berthe <mikael@lilotux.net>
parents:
1122
diff
changeset
|
3503 return; |
fddf2fef7b83
Add option "cmdhistory_lines"
Mikael Berthe <mikael@lilotux.net>
parents:
1122
diff
changeset
|
3504 |
fddf2fef7b83
Add option "cmdhistory_lines"
Mikael Berthe <mikael@lilotux.net>
parents:
1122
diff
changeset
|
3505 max_histo_lines = settings_opt_get_int("cmdhistory_lines"); |
fddf2fef7b83
Add option "cmdhistory_lines"
Mikael Berthe <mikael@lilotux.net>
parents:
1122
diff
changeset
|
3506 |
fddf2fef7b83
Add option "cmdhistory_lines"
Mikael Berthe <mikael@lilotux.net>
parents:
1122
diff
changeset
|
3507 if (max_histo_lines < 0) |
fddf2fef7b83
Add option "cmdhistory_lines"
Mikael Berthe <mikael@lilotux.net>
parents:
1122
diff
changeset
|
3508 max_histo_lines = 1; |
fddf2fef7b83
Add option "cmdhistory_lines"
Mikael Berthe <mikael@lilotux.net>
parents:
1122
diff
changeset
|
3509 |
fddf2fef7b83
Add option "cmdhistory_lines"
Mikael Berthe <mikael@lilotux.net>
parents:
1122
diff
changeset
|
3510 if (max_histo_lines) |
fddf2fef7b83
Add option "cmdhistory_lines"
Mikael Berthe <mikael@lilotux.net>
parents:
1122
diff
changeset
|
3511 while (cmdhisto_nblines >= (guint)max_histo_lines) { |
fddf2fef7b83
Add option "cmdhistory_lines"
Mikael Berthe <mikael@lilotux.net>
parents:
1122
diff
changeset
|
3512 if (cmdhisto_cur && cmdhisto_cur == cmdhisto) |
fddf2fef7b83
Add option "cmdhistory_lines"
Mikael Berthe <mikael@lilotux.net>
parents:
1122
diff
changeset
|
3513 break; |
fddf2fef7b83
Add option "cmdhistory_lines"
Mikael Berthe <mikael@lilotux.net>
parents:
1122
diff
changeset
|
3514 g_free(cmdhisto->data); |
fddf2fef7b83
Add option "cmdhistory_lines"
Mikael Berthe <mikael@lilotux.net>
parents:
1122
diff
changeset
|
3515 cmdhisto = g_list_delete_link(cmdhisto, cmdhisto); |
fddf2fef7b83
Add option "cmdhistory_lines"
Mikael Berthe <mikael@lilotux.net>
parents:
1122
diff
changeset
|
3516 cmdhisto_nblines--; |
fddf2fef7b83
Add option "cmdhistory_lines"
Mikael Berthe <mikael@lilotux.net>
parents:
1122
diff
changeset
|
3517 } |
173 | 3518 |
3519 cmdhisto = g_list_append(cmdhisto, g_strdup(line)); | |
1127
fddf2fef7b83
Add option "cmdhistory_lines"
Mikael Berthe <mikael@lilotux.net>
parents:
1122
diff
changeset
|
3520 cmdhisto_nblines++; |
173 | 3521 } |
3522 | |
1985
0870005f7efc
Add command /iline clear_history
Mikael Berthe <mikael@lilotux.net>
parents:
1977
diff
changeset
|
3523 // scr_cmdhisto_reset() |
0870005f7efc
Add command /iline clear_history
Mikael Berthe <mikael@lilotux.net>
parents:
1977
diff
changeset
|
3524 // Reset the inputLine history |
0870005f7efc
Add command /iline clear_history
Mikael Berthe <mikael@lilotux.net>
parents:
1977
diff
changeset
|
3525 static void scr_cmdhisto_reset(void) |
0870005f7efc
Add command /iline clear_history
Mikael Berthe <mikael@lilotux.net>
parents:
1977
diff
changeset
|
3526 { |
0870005f7efc
Add command /iline clear_history
Mikael Berthe <mikael@lilotux.net>
parents:
1977
diff
changeset
|
3527 while (cmdhisto_nblines) { |
0870005f7efc
Add command /iline clear_history
Mikael Berthe <mikael@lilotux.net>
parents:
1977
diff
changeset
|
3528 g_free(cmdhisto->data); |
0870005f7efc
Add command /iline clear_history
Mikael Berthe <mikael@lilotux.net>
parents:
1977
diff
changeset
|
3529 cmdhisto = g_list_delete_link(cmdhisto, cmdhisto); |
0870005f7efc
Add command /iline clear_history
Mikael Berthe <mikael@lilotux.net>
parents:
1977
diff
changeset
|
3530 cmdhisto_nblines--; |
0870005f7efc
Add command /iline clear_history
Mikael Berthe <mikael@lilotux.net>
parents:
1977
diff
changeset
|
3531 } |
0870005f7efc
Add command /iline clear_history
Mikael Berthe <mikael@lilotux.net>
parents:
1977
diff
changeset
|
3532 cmdhisto_backup[0] = 0; |
0870005f7efc
Add command /iline clear_history
Mikael Berthe <mikael@lilotux.net>
parents:
1977
diff
changeset
|
3533 cmdhisto_cur = NULL; |
0870005f7efc
Add command /iline clear_history
Mikael Berthe <mikael@lilotux.net>
parents:
1977
diff
changeset
|
3534 } |
0870005f7efc
Add command /iline clear_history
Mikael Berthe <mikael@lilotux.net>
parents:
1977
diff
changeset
|
3535 |
173 | 3536 // scr_cmdhisto_prev() |
3537 // Look for previous line beginning w/ the given mask in the inputLine history | |
175 | 3538 // Returns NULL if none found |
336
eb994ee40029
Make some functions static
Mikael Berthe <mikael@lilotux.net>
parents:
332
diff
changeset
|
3539 static const char *scr_cmdhisto_prev(char *mask, guint len) |
173 | 3540 { |
3541 GList *hl; | |
3542 if (!cmdhisto_cur) { | |
3543 hl = g_list_last(cmdhisto); | |
174 | 3544 if (hl) { // backup current line |
3545 strncpy(cmdhisto_backup, mask, INPUTLINE_LENGTH); | |
3546 } | |
173 | 3547 } else { |
3548 hl = g_list_previous(cmdhisto_cur); | |
3549 } | |
3550 while (hl) { | |
3551 if (!strncmp((char*)hl->data, mask, len)) { | |
3552 // Found a match | |
3553 cmdhisto_cur = hl; | |
3554 return (const char*)hl->data; | |
3555 } | |
3556 hl = g_list_previous(hl); | |
3557 } | |
3558 return NULL; | |
3559 } | |
3560 | |
3561 // scr_cmdhisto_next() | |
3562 // Look for next line beginning w/ the given mask in the inputLine history | |
175 | 3563 // Returns NULL if none found |
336
eb994ee40029
Make some functions static
Mikael Berthe <mikael@lilotux.net>
parents:
332
diff
changeset
|
3564 static const char *scr_cmdhisto_next(char *mask, guint len) |
173 | 3565 { |
3566 GList *hl; | |
3567 if (!cmdhisto_cur) return NULL; | |
3568 hl = cmdhisto_cur; | |
3569 while ((hl = g_list_next(hl)) != NULL) | |
3570 if (!strncmp((char*)hl->data, mask, len)) { | |
3571 // Found a match | |
3572 cmdhisto_cur = hl; | |
3573 return (const char*)hl->data; | |
3574 } | |
175 | 3575 // If the "backuped" line matches, we'll use it |
3576 if (strncmp(cmdhisto_backup, mask, len)) return NULL; // No match | |
174 | 3577 cmdhisto_cur = NULL; |
3578 return cmdhisto_backup; | |
173 | 3579 } |
3580 | |
1903
75a0a22bbf78
Fix issue #54 -- command line corruption
Mikael Berthe <mikael@lilotux.net>
parents:
1863
diff
changeset
|
3581 static char *_strmove(char *dst, const char *src) |
75a0a22bbf78
Fix issue #54 -- command line corruption
Mikael Berthe <mikael@lilotux.net>
parents:
1863
diff
changeset
|
3582 { |
75a0a22bbf78
Fix issue #54 -- command line corruption
Mikael Berthe <mikael@lilotux.net>
parents:
1863
diff
changeset
|
3583 char *dest = dst; |
75a0a22bbf78
Fix issue #54 -- command line corruption
Mikael Berthe <mikael@lilotux.net>
parents:
1863
diff
changeset
|
3584 while ((*dest++ = *src++) != '\0') |
75a0a22bbf78
Fix issue #54 -- command line corruption
Mikael Berthe <mikael@lilotux.net>
parents:
1863
diff
changeset
|
3585 ; |
75a0a22bbf78
Fix issue #54 -- command line corruption
Mikael Berthe <mikael@lilotux.net>
parents:
1863
diff
changeset
|
3586 return dest; |
75a0a22bbf78
Fix issue #54 -- command line corruption
Mikael Berthe <mikael@lilotux.net>
parents:
1863
diff
changeset
|
3587 } |
75a0a22bbf78
Fix issue #54 -- command line corruption
Mikael Berthe <mikael@lilotux.net>
parents:
1863
diff
changeset
|
3588 |
195 | 3589 // readline_transpose_chars() |
3590 // Drag the character before point forward over the character at | |
3591 // point, moving point forward as well. If point is at the end of | |
3592 // the line, then this transposes the two characters before point. | |
1059 | 3593 void readline_transpose_chars(void) |
195 | 3594 { |
930
a75f7a13df7b
UTF-8 terminal support (Reimar Döffinger)
Mikael Berthe <mikael@lilotux.net>
parents:
929
diff
changeset
|
3595 char *c1, *c2; |
a75f7a13df7b
UTF-8 terminal support (Reimar Döffinger)
Mikael Berthe <mikael@lilotux.net>
parents:
929
diff
changeset
|
3596 unsigned a, b; |
195 | 3597 |
3598 if (ptr_inputline == inputLine) return; | |
3599 | |
3600 if (!*ptr_inputline) { // We're at EOL | |
3601 // 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
|
3602 if (ptr_inputline == prev_char(ptr_inputline, inputLine)) return; |
195 | 3603 // Transpose the two previous characters |
930
a75f7a13df7b
UTF-8 terminal support (Reimar Döffinger)
Mikael Berthe <mikael@lilotux.net>
parents:
929
diff
changeset
|
3604 c2 = prev_char(ptr_inputline, inputLine); |
a75f7a13df7b
UTF-8 terminal support (Reimar Döffinger)
Mikael Berthe <mikael@lilotux.net>
parents:
929
diff
changeset
|
3605 c1 = prev_char(c2, inputLine); |
a75f7a13df7b
UTF-8 terminal support (Reimar Döffinger)
Mikael Berthe <mikael@lilotux.net>
parents:
929
diff
changeset
|
3606 a = get_char(c1); |
a75f7a13df7b
UTF-8 terminal support (Reimar Döffinger)
Mikael Berthe <mikael@lilotux.net>
parents:
929
diff
changeset
|
3607 b = get_char(c2); |
a75f7a13df7b
UTF-8 terminal support (Reimar Döffinger)
Mikael Berthe <mikael@lilotux.net>
parents:
929
diff
changeset
|
3608 put_char(put_char(c1, b), a); |
195 | 3609 } else { |
196 | 3610 // 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
|
3611 c2 = ptr_inputline; |
a75f7a13df7b
UTF-8 terminal support (Reimar Döffinger)
Mikael Berthe <mikael@lilotux.net>
parents:
929
diff
changeset
|
3612 c1 = prev_char(c2, inputLine); |
a75f7a13df7b
UTF-8 terminal support (Reimar Döffinger)
Mikael Berthe <mikael@lilotux.net>
parents:
929
diff
changeset
|
3613 a = get_char(c1); |
a75f7a13df7b
UTF-8 terminal support (Reimar Döffinger)
Mikael Berthe <mikael@lilotux.net>
parents:
929
diff
changeset
|
3614 b = get_char(c2); |
a75f7a13df7b
UTF-8 terminal support (Reimar Döffinger)
Mikael Berthe <mikael@lilotux.net>
parents:
929
diff
changeset
|
3615 put_char(put_char(c1, b), a); |
195 | 3616 check_offset(1); |
3617 } | |
3618 } | |
3619 | |
1171
03a38b7ad2e0
Add a collection of commands for key bindings (Lego12239)
Mikael Berthe <mikael@lilotux.net>
parents:
1170
diff
changeset
|
3620 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
|
3621 { |
03a38b7ad2e0
Add a collection of commands for key bindings (Lego12239)
Mikael Berthe <mikael@lilotux.net>
parents:
1170
diff
changeset
|
3622 char *c, *old = ptr_inputline; |
03a38b7ad2e0
Add a collection of commands for key bindings (Lego12239)
Mikael Berthe <mikael@lilotux.net>
parents:
1170
diff
changeset
|
3623 int spaceallowed = 1; |
03a38b7ad2e0
Add a collection of commands for key bindings (Lego12239)
Mikael Berthe <mikael@lilotux.net>
parents:
1170
diff
changeset
|
3624 |
03a38b7ad2e0
Add a collection of commands for key bindings (Lego12239)
Mikael Berthe <mikael@lilotux.net>
parents:
1170
diff
changeset
|
3625 if (! *ptr_inputline) return; |
03a38b7ad2e0
Add a collection of commands for key bindings (Lego12239)
Mikael Berthe <mikael@lilotux.net>
parents:
1170
diff
changeset
|
3626 |
03a38b7ad2e0
Add a collection of commands for key bindings (Lego12239)
Mikael Berthe <mikael@lilotux.net>
parents:
1170
diff
changeset
|
3627 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
|
3628 if (!iswalnum(get_char(c))) { |
03a38b7ad2e0
Add a collection of commands for key bindings (Lego12239)
Mikael Berthe <mikael@lilotux.net>
parents:
1170
diff
changeset
|
3629 if (iswblank(get_char(c))) { |
03a38b7ad2e0
Add a collection of commands for key bindings (Lego12239)
Mikael Berthe <mikael@lilotux.net>
parents:
1170
diff
changeset
|
3630 if (!spaceallowed) break; |
03a38b7ad2e0
Add a collection of commands for key bindings (Lego12239)
Mikael Berthe <mikael@lilotux.net>
parents:
1170
diff
changeset
|
3631 } else spaceallowed = 0; |
03a38b7ad2e0
Add a collection of commands for key bindings (Lego12239)
Mikael Berthe <mikael@lilotux.net>
parents:
1170
diff
changeset
|
3632 } else spaceallowed = 0; |
03a38b7ad2e0
Add a collection of commands for key bindings (Lego12239)
Mikael Berthe <mikael@lilotux.net>
parents:
1170
diff
changeset
|
3633 } |
03a38b7ad2e0
Add a collection of commands for key bindings (Lego12239)
Mikael Berthe <mikael@lilotux.net>
parents:
1170
diff
changeset
|
3634 |
03a38b7ad2e0
Add a collection of commands for key bindings (Lego12239)
Mikael Berthe <mikael@lilotux.net>
parents:
1170
diff
changeset
|
3635 // Modify the line |
03a38b7ad2e0
Add a collection of commands for key bindings (Lego12239)
Mikael Berthe <mikael@lilotux.net>
parents:
1170
diff
changeset
|
3636 for (;;) { |
03a38b7ad2e0
Add a collection of commands for key bindings (Lego12239)
Mikael Berthe <mikael@lilotux.net>
parents:
1170
diff
changeset
|
3637 *old = *c++; |
03a38b7ad2e0
Add a collection of commands for key bindings (Lego12239)
Mikael Berthe <mikael@lilotux.net>
parents:
1170
diff
changeset
|
3638 if (!*old++) break; |
03a38b7ad2e0
Add a collection of commands for key bindings (Lego12239)
Mikael Berthe <mikael@lilotux.net>
parents:
1170
diff
changeset
|
3639 } |
03a38b7ad2e0
Add a collection of commands for key bindings (Lego12239)
Mikael Berthe <mikael@lilotux.net>
parents:
1170
diff
changeset
|
3640 } |
03a38b7ad2e0
Add a collection of commands for key bindings (Lego12239)
Mikael Berthe <mikael@lilotux.net>
parents:
1170
diff
changeset
|
3641 |
195 | 3642 // readline_backward_kill_word() |
194 | 3643 // Kill the word before the cursor, in input line |
1059 | 3644 void readline_backward_kill_word(void) |
194 | 3645 { |
3646 char *c, *old = ptr_inputline; | |
3647 int spaceallowed = 1; | |
3648 | |
3649 if (ptr_inputline == inputLine) return; | |
3650 | |
930
a75f7a13df7b
UTF-8 terminal support (Reimar Döffinger)
Mikael Berthe <mikael@lilotux.net>
parents:
929
diff
changeset
|
3651 c = prev_char(ptr_inputline, inputLine); |
a75f7a13df7b
UTF-8 terminal support (Reimar Döffinger)
Mikael Berthe <mikael@lilotux.net>
parents:
929
diff
changeset
|
3652 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
|
3653 if (!iswalnum(get_char(c))) { |
933
ede9260be93d
Input line: Improve word-related functions
Mikael Berthe <mikael@lilotux.net>
parents:
932
diff
changeset
|
3654 if (iswblank(get_char(c))) { |
194 | 3655 if (!spaceallowed) break; |
933
ede9260be93d
Input line: Improve word-related functions
Mikael Berthe <mikael@lilotux.net>
parents:
932
diff
changeset
|
3656 } else spaceallowed = 0; |
194 | 3657 } 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
|
3658 } |
194 | 3659 |
1280
8b621f980321
readline_backward_kill_word() makes a stop at the "command" character
Mikael Berthe <mikael@lilotux.net>
parents:
1279
diff
changeset
|
3660 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
|
3661 c = next_char(c); |
2072
0722fe4b7580
Small fix for readline_backward_kill_word()
Mikael Berthe <mikael@lilotux.net>
parents:
2047
diff
changeset
|
3662 } 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
|
3663 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
|
3664 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
|
3665 } |
194 | 3666 |
3667 // Modify the line | |
3668 ptr_inputline = c; | |
1903
75a0a22bbf78
Fix issue #54 -- command line corruption
Mikael Berthe <mikael@lilotux.net>
parents:
1863
diff
changeset
|
3669 _strmove(ptr_inputline, old); |
195 | 3670 check_offset(-1); |
194 | 3671 } |
3672 | |
759
a681dc477c7f
Add readline_backward_word and readline_forward_word (Ctrl-Left/Ctrl-Right)
Mikael Berthe <mikael@lilotux.net>
parents:
758
diff
changeset
|
3673 // readline_backward_word() |
2074
e04b6dfbb054
Some whitespace cleanup
Mikael Berthe <mikael@lilotux.net>
parents:
2072
diff
changeset
|
3674 // Move back to the start of the current or previous word |
1059 | 3675 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
|
3676 { |
1172
334ae9f498f1
Add some more iline functions (Lego12239)
Mikael Berthe <mikael@lilotux.net>
parents:
1171
diff
changeset
|
3677 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
|
3678 |
a681dc477c7f
Add readline_backward_word and readline_forward_word (Ctrl-Left/Ctrl-Right)
Mikael Berthe <mikael@lilotux.net>
parents:
758
diff
changeset
|
3679 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
|
3680 |
1172
334ae9f498f1
Add some more iline functions (Lego12239)
Mikael Berthe <mikael@lilotux.net>
parents:
1171
diff
changeset
|
3681 if (iswalnum(get_char(ptr_inputline)) && |
334ae9f498f1
Add some more iline functions (Lego12239)
Mikael Berthe <mikael@lilotux.net>
parents:
1171
diff
changeset
|
3682 !iswalnum(get_char(prev_char(ptr_inputline, inputLine)))) |
334ae9f498f1
Add some more iline functions (Lego12239)
Mikael Berthe <mikael@lilotux.net>
parents:
1171
diff
changeset
|
3683 i--; |
334ae9f498f1
Add some more iline functions (Lego12239)
Mikael Berthe <mikael@lilotux.net>
parents:
1171
diff
changeset
|
3684 |
1333
e30a9d907105
Minor coding style adjustments
Mikael Berthe <mikael@lilotux.net>
parents:
1314
diff
changeset
|
3685 for ( ; |
e30a9d907105
Minor coding style adjustments
Mikael Berthe <mikael@lilotux.net>
parents:
1314
diff
changeset
|
3686 ptr_inputline > inputLine; |
e30a9d907105
Minor coding style adjustments
Mikael Berthe <mikael@lilotux.net>
parents:
1314
diff
changeset
|
3687 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
|
3688 if (!iswalnum(get_char(ptr_inputline))) { |
1172
334ae9f498f1
Add some more iline functions (Lego12239)
Mikael Berthe <mikael@lilotux.net>
parents:
1171
diff
changeset
|
3689 if (i) { |
334ae9f498f1
Add some more iline functions (Lego12239)
Mikael Berthe <mikael@lilotux.net>
parents:
1171
diff
changeset
|
3690 ptr_inputline = next_char(ptr_inputline); |
334ae9f498f1
Add some more iline functions (Lego12239)
Mikael Berthe <mikael@lilotux.net>
parents:
1171
diff
changeset
|
3691 break; |
334ae9f498f1
Add some more iline functions (Lego12239)
Mikael Berthe <mikael@lilotux.net>
parents:
1171
diff
changeset
|
3692 } |
334ae9f498f1
Add some more iline functions (Lego12239)
Mikael Berthe <mikael@lilotux.net>
parents:
1171
diff
changeset
|
3693 } 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
|
3694 } |
a681dc477c7f
Add readline_backward_word and readline_forward_word (Ctrl-Left/Ctrl-Right)
Mikael Berthe <mikael@lilotux.net>
parents:
758
diff
changeset
|
3695 |
a681dc477c7f
Add readline_backward_word and readline_forward_word (Ctrl-Left/Ctrl-Right)
Mikael Berthe <mikael@lilotux.net>
parents:
758
diff
changeset
|
3696 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
|
3697 } |
a681dc477c7f
Add readline_backward_word and readline_forward_word (Ctrl-Left/Ctrl-Right)
Mikael Berthe <mikael@lilotux.net>
parents:
758
diff
changeset
|
3698 |
a681dc477c7f
Add readline_backward_word and readline_forward_word (Ctrl-Left/Ctrl-Right)
Mikael Berthe <mikael@lilotux.net>
parents:
758
diff
changeset
|
3699 // 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
|
3700 // Move forward to the end of the next word |
1059 | 3701 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
|
3702 { |
1172
334ae9f498f1
Add some more iline functions (Lego12239)
Mikael Berthe <mikael@lilotux.net>
parents:
1171
diff
changeset
|
3703 int stopsymbol_allowed = 1; |
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 stopsymbol_allowed = 0; |
334ae9f498f1
Add some more iline functions (Lego12239)
Mikael Berthe <mikael@lilotux.net>
parents:
1171
diff
changeset
|
3709 ptr_inputline = next_char(ptr_inputline); |
334ae9f498f1
Add some more iline functions (Lego12239)
Mikael Berthe <mikael@lilotux.net>
parents:
1171
diff
changeset
|
3710 } |
334ae9f498f1
Add some more iline functions (Lego12239)
Mikael Berthe <mikael@lilotux.net>
parents:
1171
diff
changeset
|
3711 |
334ae9f498f1
Add some more iline functions (Lego12239)
Mikael Berthe <mikael@lilotux.net>
parents:
1171
diff
changeset
|
3712 check_offset(1); |
334ae9f498f1
Add some more iline functions (Lego12239)
Mikael Berthe <mikael@lilotux.net>
parents:
1171
diff
changeset
|
3713 } |
334ae9f498f1
Add some more iline functions (Lego12239)
Mikael Berthe <mikael@lilotux.net>
parents:
1171
diff
changeset
|
3714 |
334ae9f498f1
Add some more iline functions (Lego12239)
Mikael Berthe <mikael@lilotux.net>
parents:
1171
diff
changeset
|
3715 void readline_updowncase_word(int upcase) |
334ae9f498f1
Add some more iline functions (Lego12239)
Mikael Berthe <mikael@lilotux.net>
parents:
1171
diff
changeset
|
3716 { |
334ae9f498f1
Add some more iline functions (Lego12239)
Mikael Berthe <mikael@lilotux.net>
parents:
1171
diff
changeset
|
3717 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
|
3718 |
a681dc477c7f
Add readline_backward_word and readline_forward_word (Ctrl-Left/Ctrl-Right)
Mikael Berthe <mikael@lilotux.net>
parents:
758
diff
changeset
|
3719 while (*ptr_inputline) { |
930
a75f7a13df7b
UTF-8 terminal support (Reimar Döffinger)
Mikael Berthe <mikael@lilotux.net>
parents:
929
diff
changeset
|
3720 if (!iswalnum(get_char(ptr_inputline))) { |
1172
334ae9f498f1
Add some more iline functions (Lego12239)
Mikael Berthe <mikael@lilotux.net>
parents:
1171
diff
changeset
|
3721 if (!stopsymbol_allowed) break; |
334ae9f498f1
Add some more iline functions (Lego12239)
Mikael Berthe <mikael@lilotux.net>
parents:
1171
diff
changeset
|
3722 } else { |
334ae9f498f1
Add some more iline functions (Lego12239)
Mikael Berthe <mikael@lilotux.net>
parents:
1171
diff
changeset
|
3723 stopsymbol_allowed = 0; |
334ae9f498f1
Add some more iline functions (Lego12239)
Mikael Berthe <mikael@lilotux.net>
parents:
1171
diff
changeset
|
3724 if (upcase) |
1748
51a23403cc80
Fix readline_updowncase_word() and readline_capitalize_word() wrt UTF-8
Mikael Berthe <mikael@lilotux.net>
parents:
1743
diff
changeset
|
3725 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
|
3726 else |
1748
51a23403cc80
Fix readline_updowncase_word() and readline_capitalize_word() wrt UTF-8
Mikael Berthe <mikael@lilotux.net>
parents:
1743
diff
changeset
|
3727 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
|
3728 } |
334ae9f498f1
Add some more iline functions (Lego12239)
Mikael Berthe <mikael@lilotux.net>
parents:
1171
diff
changeset
|
3729 ptr_inputline = next_char(ptr_inputline); |
334ae9f498f1
Add some more iline functions (Lego12239)
Mikael Berthe <mikael@lilotux.net>
parents:
1171
diff
changeset
|
3730 } |
334ae9f498f1
Add some more iline functions (Lego12239)
Mikael Berthe <mikael@lilotux.net>
parents:
1171
diff
changeset
|
3731 |
334ae9f498f1
Add some more iline functions (Lego12239)
Mikael Berthe <mikael@lilotux.net>
parents:
1171
diff
changeset
|
3732 check_offset(1); |
334ae9f498f1
Add some more iline functions (Lego12239)
Mikael Berthe <mikael@lilotux.net>
parents:
1171
diff
changeset
|
3733 } |
334ae9f498f1
Add some more iline functions (Lego12239)
Mikael Berthe <mikael@lilotux.net>
parents:
1171
diff
changeset
|
3734 |
334ae9f498f1
Add some more iline functions (Lego12239)
Mikael Berthe <mikael@lilotux.net>
parents:
1171
diff
changeset
|
3735 void readline_capitalize_word(void) |
334ae9f498f1
Add some more iline functions (Lego12239)
Mikael Berthe <mikael@lilotux.net>
parents:
1171
diff
changeset
|
3736 { |
334ae9f498f1
Add some more iline functions (Lego12239)
Mikael Berthe <mikael@lilotux.net>
parents:
1171
diff
changeset
|
3737 int stopsymbol_allowed = 1; |
334ae9f498f1
Add some more iline functions (Lego12239)
Mikael Berthe <mikael@lilotux.net>
parents:
1171
diff
changeset
|
3738 int upcased = 0; |
334ae9f498f1
Add some more iline functions (Lego12239)
Mikael Berthe <mikael@lilotux.net>
parents:
1171
diff
changeset
|
3739 |
334ae9f498f1
Add some more iline functions (Lego12239)
Mikael Berthe <mikael@lilotux.net>
parents:
1171
diff
changeset
|
3740 while (*ptr_inputline) { |
334ae9f498f1
Add some more iline functions (Lego12239)
Mikael Berthe <mikael@lilotux.net>
parents:
1171
diff
changeset
|
3741 if (!iswalnum(get_char(ptr_inputline))) { |
334ae9f498f1
Add some more iline functions (Lego12239)
Mikael Berthe <mikael@lilotux.net>
parents:
1171
diff
changeset
|
3742 if (!stopsymbol_allowed) break; |
334ae9f498f1
Add some more iline functions (Lego12239)
Mikael Berthe <mikael@lilotux.net>
parents:
1171
diff
changeset
|
3743 } else { |
334ae9f498f1
Add some more iline functions (Lego12239)
Mikael Berthe <mikael@lilotux.net>
parents:
1171
diff
changeset
|
3744 stopsymbol_allowed = 0; |
334ae9f498f1
Add some more iline functions (Lego12239)
Mikael Berthe <mikael@lilotux.net>
parents:
1171
diff
changeset
|
3745 if (!upcased) { |
1748
51a23403cc80
Fix readline_updowncase_word() and readline_capitalize_word() wrt UTF-8
Mikael Berthe <mikael@lilotux.net>
parents:
1743
diff
changeset
|
3746 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
|
3747 upcased = 1; |
1748
51a23403cc80
Fix readline_updowncase_word() and readline_capitalize_word() wrt UTF-8
Mikael Berthe <mikael@lilotux.net>
parents:
1743
diff
changeset
|
3748 } else |
51a23403cc80
Fix readline_updowncase_word() and readline_capitalize_word() wrt UTF-8
Mikael Berthe <mikael@lilotux.net>
parents:
1743
diff
changeset
|
3749 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
|
3750 } |
334ae9f498f1
Add some more iline functions (Lego12239)
Mikael Berthe <mikael@lilotux.net>
parents:
1171
diff
changeset
|
3751 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
|
3752 } |
a681dc477c7f
Add readline_backward_word and readline_forward_word (Ctrl-Left/Ctrl-Right)
Mikael Berthe <mikael@lilotux.net>
parents:
758
diff
changeset
|
3753 |
a681dc477c7f
Add readline_backward_word and readline_forward_word (Ctrl-Left/Ctrl-Right)
Mikael Berthe <mikael@lilotux.net>
parents:
758
diff
changeset
|
3754 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
|
3755 } |
a681dc477c7f
Add readline_backward_word and readline_forward_word (Ctrl-Left/Ctrl-Right)
Mikael Berthe <mikael@lilotux.net>
parents:
758
diff
changeset
|
3756 |
1171
03a38b7ad2e0
Add a collection of commands for key bindings (Lego12239)
Mikael Berthe <mikael@lilotux.net>
parents:
1170
diff
changeset
|
3757 void readline_backward_char(void) |
03a38b7ad2e0
Add a collection of commands for key bindings (Lego12239)
Mikael Berthe <mikael@lilotux.net>
parents:
1170
diff
changeset
|
3758 { |
03a38b7ad2e0
Add a collection of commands for key bindings (Lego12239)
Mikael Berthe <mikael@lilotux.net>
parents:
1170
diff
changeset
|
3759 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
|
3760 |
03a38b7ad2e0
Add a collection of commands for key bindings (Lego12239)
Mikael Berthe <mikael@lilotux.net>
parents:
1170
diff
changeset
|
3761 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
|
3762 check_offset(-1); |
03a38b7ad2e0
Add a collection of commands for key bindings (Lego12239)
Mikael Berthe <mikael@lilotux.net>
parents:
1170
diff
changeset
|
3763 } |
03a38b7ad2e0
Add a collection of commands for key bindings (Lego12239)
Mikael Berthe <mikael@lilotux.net>
parents:
1170
diff
changeset
|
3764 |
03a38b7ad2e0
Add a collection of commands for key bindings (Lego12239)
Mikael Berthe <mikael@lilotux.net>
parents:
1170
diff
changeset
|
3765 void readline_forward_char(void) |
03a38b7ad2e0
Add a collection of commands for key bindings (Lego12239)
Mikael Berthe <mikael@lilotux.net>
parents:
1170
diff
changeset
|
3766 { |
03a38b7ad2e0
Add a collection of commands for key bindings (Lego12239)
Mikael Berthe <mikael@lilotux.net>
parents:
1170
diff
changeset
|
3767 if (!*ptr_inputline) return; |
03a38b7ad2e0
Add a collection of commands for key bindings (Lego12239)
Mikael Berthe <mikael@lilotux.net>
parents:
1170
diff
changeset
|
3768 |
03a38b7ad2e0
Add a collection of commands for key bindings (Lego12239)
Mikael Berthe <mikael@lilotux.net>
parents:
1170
diff
changeset
|
3769 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
|
3770 check_offset(1); |
03a38b7ad2e0
Add a collection of commands for key bindings (Lego12239)
Mikael Berthe <mikael@lilotux.net>
parents:
1170
diff
changeset
|
3771 } |
03a38b7ad2e0
Add a collection of commands for key bindings (Lego12239)
Mikael Berthe <mikael@lilotux.net>
parents:
1170
diff
changeset
|
3772 |
1177
10733d7de004
Refactor readline_accept_line() and readline_accept_line_down_hist()
Mikael Berthe <mikael@lilotux.net>
parents:
1176
diff
changeset
|
3773 // 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
|
3774 // Validate current command line. |
10733d7de004
Refactor readline_accept_line() and readline_accept_line_down_hist()
Mikael Berthe <mikael@lilotux.net>
parents:
1176
diff
changeset
|
3775 // If down_history is true, load the next history line. |
2164 | 3776 void readline_accept_line(int down_history) |
1172
334ae9f498f1
Add some more iline functions (Lego12239)
Mikael Berthe <mikael@lilotux.net>
parents:
1171
diff
changeset
|
3777 { |
1780
e4378fbab5d7
Major API cleanup - bump API to 4
Mikael Berthe <mikael@lilotux.net>
parents:
1761
diff
changeset
|
3778 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
|
3779 last_activity_buddy = current_buddy; |
2164 | 3780 process_line(inputLine); |
1172
334ae9f498f1
Add some more iline functions (Lego12239)
Mikael Berthe <mikael@lilotux.net>
parents:
1171
diff
changeset
|
3781 // Add line to history |
334ae9f498f1
Add some more iline functions (Lego12239)
Mikael Berthe <mikael@lilotux.net>
parents:
1171
diff
changeset
|
3782 scr_cmdhisto_addline(inputLine); |
334ae9f498f1
Add some more iline functions (Lego12239)
Mikael Berthe <mikael@lilotux.net>
parents:
1171
diff
changeset
|
3783 // Reset the line |
334ae9f498f1
Add some more iline functions (Lego12239)
Mikael Berthe <mikael@lilotux.net>
parents:
1171
diff
changeset
|
3784 ptr_inputline = inputLine; |
334ae9f498f1
Add some more iline functions (Lego12239)
Mikael Berthe <mikael@lilotux.net>
parents:
1171
diff
changeset
|
3785 *ptr_inputline = 0; |
334ae9f498f1
Add some more iline functions (Lego12239)
Mikael Berthe <mikael@lilotux.net>
parents:
1171
diff
changeset
|
3786 inputline_offset = 0; |
334ae9f498f1
Add some more iline functions (Lego12239)
Mikael Berthe <mikael@lilotux.net>
parents:
1171
diff
changeset
|
3787 |
1177
10733d7de004
Refactor readline_accept_line() and readline_accept_line_down_hist()
Mikael Berthe <mikael@lilotux.net>
parents:
1176
diff
changeset
|
3788 if (down_history) { |
10733d7de004
Refactor readline_accept_line() and readline_accept_line_down_hist()
Mikael Berthe <mikael@lilotux.net>
parents:
1176
diff
changeset
|
3789 // 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
|
3790 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
|
3791 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
|
3792 // Reset backup history line |
10733d7de004
Refactor readline_accept_line() and readline_accept_line_down_hist()
Mikael Berthe <mikael@lilotux.net>
parents:
1176
diff
changeset
|
3793 cmdhisto_backup[0] = 0; |
10733d7de004
Refactor readline_accept_line() and readline_accept_line_down_hist()
Mikael Berthe <mikael@lilotux.net>
parents:
1176
diff
changeset
|
3794 } else { |
10733d7de004
Refactor readline_accept_line() and readline_accept_line_down_hist()
Mikael Berthe <mikael@lilotux.net>
parents:
1176
diff
changeset
|
3795 // Reset history line pointer |
10733d7de004
Refactor readline_accept_line() and readline_accept_line_down_hist()
Mikael Berthe <mikael@lilotux.net>
parents:
1176
diff
changeset
|
3796 cmdhisto_cur = NULL; |
10733d7de004
Refactor readline_accept_line() and readline_accept_line_down_hist()
Mikael Berthe <mikael@lilotux.net>
parents:
1176
diff
changeset
|
3797 } |
1172
334ae9f498f1
Add some more iline functions (Lego12239)
Mikael Berthe <mikael@lilotux.net>
parents:
1171
diff
changeset
|
3798 } |
334ae9f498f1
Add some more iline functions (Lego12239)
Mikael Berthe <mikael@lilotux.net>
parents:
1171
diff
changeset
|
3799 |
1985
0870005f7efc
Add command /iline clear_history
Mikael Berthe <mikael@lilotux.net>
parents:
1977
diff
changeset
|
3800 // readline_clear_history() |
0870005f7efc
Add command /iline clear_history
Mikael Berthe <mikael@lilotux.net>
parents:
1977
diff
changeset
|
3801 // Clear command line history. |
0870005f7efc
Add command /iline clear_history
Mikael Berthe <mikael@lilotux.net>
parents:
1977
diff
changeset
|
3802 void readline_clear_history(void) |
0870005f7efc
Add command /iline clear_history
Mikael Berthe <mikael@lilotux.net>
parents:
1977
diff
changeset
|
3803 { |
0870005f7efc
Add command /iline clear_history
Mikael Berthe <mikael@lilotux.net>
parents:
1977
diff
changeset
|
3804 scr_cmdhisto_reset(); |
0870005f7efc
Add command /iline clear_history
Mikael Berthe <mikael@lilotux.net>
parents:
1977
diff
changeset
|
3805 } |
0870005f7efc
Add command /iline clear_history
Mikael Berthe <mikael@lilotux.net>
parents:
1977
diff
changeset
|
3806 |
1172
334ae9f498f1
Add some more iline functions (Lego12239)
Mikael Berthe <mikael@lilotux.net>
parents:
1171
diff
changeset
|
3807 void readline_cancel_completion(void) |
334ae9f498f1
Add some more iline functions (Lego12239)
Mikael Berthe <mikael@lilotux.net>
parents:
1171
diff
changeset
|
3808 { |
334ae9f498f1
Add some more iline functions (Lego12239)
Mikael Berthe <mikael@lilotux.net>
parents:
1171
diff
changeset
|
3809 scr_cancel_current_completion(); |
334ae9f498f1
Add some more iline functions (Lego12239)
Mikael Berthe <mikael@lilotux.net>
parents:
1171
diff
changeset
|
3810 scr_end_current_completion(); |
334ae9f498f1
Add some more iline functions (Lego12239)
Mikael Berthe <mikael@lilotux.net>
parents:
1171
diff
changeset
|
3811 check_offset(-1); |
334ae9f498f1
Add some more iline functions (Lego12239)
Mikael Berthe <mikael@lilotux.net>
parents:
1171
diff
changeset
|
3812 } |
334ae9f498f1
Add some more iline functions (Lego12239)
Mikael Berthe <mikael@lilotux.net>
parents:
1171
diff
changeset
|
3813 |
2143
2f294c2b6778
Add a backward completion (Oleg)
Mikael Berthe <mikael@lilotux.net>
parents:
2136
diff
changeset
|
3814 void readline_do_completion(gboolean fwd) |
1172
334ae9f498f1
Add some more iline functions (Lego12239)
Mikael Berthe <mikael@lilotux.net>
parents:
1171
diff
changeset
|
3815 { |
334ae9f498f1
Add some more iline functions (Lego12239)
Mikael Berthe <mikael@lilotux.net>
parents:
1171
diff
changeset
|
3816 int i, n; |
334ae9f498f1
Add some more iline functions (Lego12239)
Mikael Berthe <mikael@lilotux.net>
parents:
1171
diff
changeset
|
3817 |
1413 | 3818 if (multimode != 2) { |
1172
334ae9f498f1
Add some more iline functions (Lego12239)
Mikael Berthe <mikael@lilotux.net>
parents:
1171
diff
changeset
|
3819 // Not in verbatim multi-line mode |
2143
2f294c2b6778
Add a backward completion (Oleg)
Mikael Berthe <mikael@lilotux.net>
parents:
2136
diff
changeset
|
3820 scr_handle_tab(fwd); |
1172
334ae9f498f1
Add some more iline functions (Lego12239)
Mikael Berthe <mikael@lilotux.net>
parents:
1171
diff
changeset
|
3821 } else { |
334ae9f498f1
Add some more iline functions (Lego12239)
Mikael Berthe <mikael@lilotux.net>
parents:
1171
diff
changeset
|
3822 // Verbatim multi-line mode: expand tab |
334ae9f498f1
Add some more iline functions (Lego12239)
Mikael Berthe <mikael@lilotux.net>
parents:
1171
diff
changeset
|
3823 char tabstr[9]; |
334ae9f498f1
Add some more iline functions (Lego12239)
Mikael Berthe <mikael@lilotux.net>
parents:
1171
diff
changeset
|
3824 n = 8 - (ptr_inputline - inputLine) % 8; |
334ae9f498f1
Add some more iline functions (Lego12239)
Mikael Berthe <mikael@lilotux.net>
parents:
1171
diff
changeset
|
3825 for (i = 0; i < n; i++) |
334ae9f498f1
Add some more iline functions (Lego12239)
Mikael Berthe <mikael@lilotux.net>
parents:
1171
diff
changeset
|
3826 tabstr[i] = ' '; |
334ae9f498f1
Add some more iline functions (Lego12239)
Mikael Berthe <mikael@lilotux.net>
parents:
1171
diff
changeset
|
3827 tabstr[i] = '\0'; |
334ae9f498f1
Add some more iline functions (Lego12239)
Mikael Berthe <mikael@lilotux.net>
parents:
1171
diff
changeset
|
3828 scr_insert_text(tabstr); |
334ae9f498f1
Add some more iline functions (Lego12239)
Mikael Berthe <mikael@lilotux.net>
parents:
1171
diff
changeset
|
3829 } |
334ae9f498f1
Add some more iline functions (Lego12239)
Mikael Berthe <mikael@lilotux.net>
parents:
1171
diff
changeset
|
3830 check_offset(0); |
334ae9f498f1
Add some more iline functions (Lego12239)
Mikael Berthe <mikael@lilotux.net>
parents:
1171
diff
changeset
|
3831 } |
334ae9f498f1
Add some more iline functions (Lego12239)
Mikael Berthe <mikael@lilotux.net>
parents:
1171
diff
changeset
|
3832 |
334ae9f498f1
Add some more iline functions (Lego12239)
Mikael Berthe <mikael@lilotux.net>
parents:
1171
diff
changeset
|
3833 void readline_refresh_screen(void) |
334ae9f498f1
Add some more iline functions (Lego12239)
Mikael Berthe <mikael@lilotux.net>
parents:
1171
diff
changeset
|
3834 { |
1780
e4378fbab5d7
Major API cleanup - bump API to 4
Mikael Berthe <mikael@lilotux.net>
parents:
1761
diff
changeset
|
3835 scr_check_auto_away(TRUE); |
2211
902f271743b0
Make readline_refresh_screen() re-enable the keypad
Mikael Berthe <mikael@lilotux.net>
parents:
2190
diff
changeset
|
3836 keypad(inputWnd, TRUE); |
1780
e4378fbab5d7
Major API cleanup - bump API to 4
Mikael Berthe <mikael@lilotux.net>
parents:
1761
diff
changeset
|
3837 parse_colors(); |
2231
387cea2a1a81
Fix resizing with --enable-sigwinch
Mikael Berthe <mikael@lilotux.net>
parents:
2226
diff
changeset
|
3838 scr_resize(); |
1172
334ae9f498f1
Add some more iline functions (Lego12239)
Mikael Berthe <mikael@lilotux.net>
parents:
1171
diff
changeset
|
3839 redrawwin(stdscr); |
334ae9f498f1
Add some more iline functions (Lego12239)
Mikael Berthe <mikael@lilotux.net>
parents:
1171
diff
changeset
|
3840 } |
334ae9f498f1
Add some more iline functions (Lego12239)
Mikael Berthe <mikael@lilotux.net>
parents:
1171
diff
changeset
|
3841 |
1503
c74cfe7fd848
Add option --show-roster to command chat_disable.
Mikael Berthe <mikael@lilotux.net>
parents:
1502
diff
changeset
|
3842 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
|
3843 { |
1780
e4378fbab5d7
Major API cleanup - bump API to 4
Mikael Berthe <mikael@lilotux.net>
parents:
1761
diff
changeset
|
3844 scr_check_auto_away(TRUE); |
2306
7afb9a0c6409
[PATCH 3/3] Clear input line when switching to vi mode
Holger Weiß <holger@zedat.fu-berlin.de>
parents:
2305
diff
changeset
|
3845 if (chatmode) { |
1950
aec86670047b
Automatically set readmark flag
Mikael Berthe <mikael@lilotux.net>
parents:
1949
diff
changeset
|
3846 scr_buffer_readmark(TRUE); |
2309
e00ae0763468
Do not use litteral command char (':', '/')
Mikael Berthe <mikael@lilotux.net>
parents:
2308
diff
changeset
|
3847 if (vi_mode) |
2306
7afb9a0c6409
[PATCH 3/3] Clear input line when switching to vi mode
Holger Weiß <holger@zedat.fu-berlin.de>
parents:
2305
diff
changeset
|
3848 clear_inputline(); |
7afb9a0c6409
[PATCH 3/3] Clear input line when switching to vi mode
Holger Weiß <holger@zedat.fu-berlin.de>
parents:
2305
diff
changeset
|
3849 } |
1172
334ae9f498f1
Add some more iline functions (Lego12239)
Mikael Berthe <mikael@lilotux.net>
parents:
1171
diff
changeset
|
3850 currentWindow = NULL; |
334ae9f498f1
Add some more iline functions (Lego12239)
Mikael Berthe <mikael@lilotux.net>
parents:
1171
diff
changeset
|
3851 chatmode = FALSE; |
334ae9f498f1
Add some more iline functions (Lego12239)
Mikael Berthe <mikael@lilotux.net>
parents:
1171
diff
changeset
|
3852 if (current_buddy) |
334ae9f498f1
Add some more iline functions (Lego12239)
Mikael Berthe <mikael@lilotux.net>
parents:
1171
diff
changeset
|
3853 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
|
3854 if (show_roster) |
1780
e4378fbab5d7
Major API cleanup - bump API to 4
Mikael Berthe <mikael@lilotux.net>
parents:
1761
diff
changeset
|
3855 scr_roster_visibility(1); |
e4378fbab5d7
Major API cleanup - bump API to 4
Mikael Berthe <mikael@lilotux.net>
parents:
1761
diff
changeset
|
3856 scr_update_chat_status(FALSE); |
1172
334ae9f498f1
Add some more iline functions (Lego12239)
Mikael Berthe <mikael@lilotux.net>
parents:
1171
diff
changeset
|
3857 top_panel(chatPanel); |
334ae9f498f1
Add some more iline functions (Lego12239)
Mikael Berthe <mikael@lilotux.net>
parents:
1171
diff
changeset
|
3858 top_panel(inputPanel); |
334ae9f498f1
Add some more iline functions (Lego12239)
Mikael Berthe <mikael@lilotux.net>
parents:
1171
diff
changeset
|
3859 update_panels(); |
334ae9f498f1
Add some more iline functions (Lego12239)
Mikael Berthe <mikael@lilotux.net>
parents:
1171
diff
changeset
|
3860 } |
334ae9f498f1
Add some more iline functions (Lego12239)
Mikael Berthe <mikael@lilotux.net>
parents:
1171
diff
changeset
|
3861 |
1190
be06bbe7e449
Add readline_hist_beginning_search_bwd/fwd functions
Mikael Berthe <mikael@lilotux.net>
parents:
1187
diff
changeset
|
3862 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
|
3863 { |
03a38b7ad2e0
Add a collection of commands for key bindings (Lego12239)
Mikael Berthe <mikael@lilotux.net>
parents:
1170
diff
changeset
|
3864 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
|
3865 if (l) strcpy(inputLine, l); |
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 |
1190
be06bbe7e449
Add readline_hist_beginning_search_bwd/fwd functions
Mikael Berthe <mikael@lilotux.net>
parents:
1187
diff
changeset
|
3868 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
|
3869 { |
03a38b7ad2e0
Add a collection of commands for key bindings (Lego12239)
Mikael Berthe <mikael@lilotux.net>
parents:
1170
diff
changeset
|
3870 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
|
3871 if (l) strcpy(inputLine, l); |
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 |
1190
be06bbe7e449
Add readline_hist_beginning_search_bwd/fwd functions
Mikael Berthe <mikael@lilotux.net>
parents:
1187
diff
changeset
|
3874 void readline_hist_prev(void) |
be06bbe7e449
Add readline_hist_beginning_search_bwd/fwd functions
Mikael Berthe <mikael@lilotux.net>
parents:
1187
diff
changeset
|
3875 { |
be06bbe7e449
Add readline_hist_beginning_search_bwd/fwd functions
Mikael Berthe <mikael@lilotux.net>
parents:
1187
diff
changeset
|
3876 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
|
3877 if (l) { |
be06bbe7e449
Add readline_hist_beginning_search_bwd/fwd functions
Mikael Berthe <mikael@lilotux.net>
parents:
1187
diff
changeset
|
3878 strcpy(inputLine, l); |
be06bbe7e449
Add readline_hist_beginning_search_bwd/fwd functions
Mikael Berthe <mikael@lilotux.net>
parents:
1187
diff
changeset
|
3879 // Set the pointer at the EOL. |
be06bbe7e449
Add readline_hist_beginning_search_bwd/fwd functions
Mikael Berthe <mikael@lilotux.net>
parents:
1187
diff
changeset
|
3880 // 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
|
3881 readline_iline_start(); |
be06bbe7e449
Add readline_hist_beginning_search_bwd/fwd functions
Mikael Berthe <mikael@lilotux.net>
parents:
1187
diff
changeset
|
3882 readline_iline_end(); |
be06bbe7e449
Add readline_hist_beginning_search_bwd/fwd functions
Mikael Berthe <mikael@lilotux.net>
parents:
1187
diff
changeset
|
3883 } |
be06bbe7e449
Add readline_hist_beginning_search_bwd/fwd functions
Mikael Berthe <mikael@lilotux.net>
parents:
1187
diff
changeset
|
3884 } |
be06bbe7e449
Add readline_hist_beginning_search_bwd/fwd functions
Mikael Berthe <mikael@lilotux.net>
parents:
1187
diff
changeset
|
3885 |
be06bbe7e449
Add readline_hist_beginning_search_bwd/fwd functions
Mikael Berthe <mikael@lilotux.net>
parents:
1187
diff
changeset
|
3886 void readline_hist_next(void) |
be06bbe7e449
Add readline_hist_beginning_search_bwd/fwd functions
Mikael Berthe <mikael@lilotux.net>
parents:
1187
diff
changeset
|
3887 { |
be06bbe7e449
Add readline_hist_beginning_search_bwd/fwd functions
Mikael Berthe <mikael@lilotux.net>
parents:
1187
diff
changeset
|
3888 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
|
3889 if (l) { |
be06bbe7e449
Add readline_hist_beginning_search_bwd/fwd functions
Mikael Berthe <mikael@lilotux.net>
parents:
1187
diff
changeset
|
3890 strcpy(inputLine, l); |
be06bbe7e449
Add readline_hist_beginning_search_bwd/fwd functions
Mikael Berthe <mikael@lilotux.net>
parents:
1187
diff
changeset
|
3891 // Set the pointer at the EOL. |
be06bbe7e449
Add readline_hist_beginning_search_bwd/fwd functions
Mikael Berthe <mikael@lilotux.net>
parents:
1187
diff
changeset
|
3892 // 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
|
3893 readline_iline_start(); |
be06bbe7e449
Add readline_hist_beginning_search_bwd/fwd functions
Mikael Berthe <mikael@lilotux.net>
parents:
1187
diff
changeset
|
3894 readline_iline_end(); |
be06bbe7e449
Add readline_hist_beginning_search_bwd/fwd functions
Mikael Berthe <mikael@lilotux.net>
parents:
1187
diff
changeset
|
3895 } |
be06bbe7e449
Add readline_hist_beginning_search_bwd/fwd functions
Mikael Berthe <mikael@lilotux.net>
parents:
1187
diff
changeset
|
3896 } |
be06bbe7e449
Add readline_hist_beginning_search_bwd/fwd functions
Mikael Berthe <mikael@lilotux.net>
parents:
1187
diff
changeset
|
3897 |
1171
03a38b7ad2e0
Add a collection of commands for key bindings (Lego12239)
Mikael Berthe <mikael@lilotux.net>
parents:
1170
diff
changeset
|
3898 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
|
3899 { |
03a38b7ad2e0
Add a collection of commands for key bindings (Lego12239)
Mikael Berthe <mikael@lilotux.net>
parents:
1170
diff
changeset
|
3900 char *src, *c; |
03a38b7ad2e0
Add a collection of commands for key bindings (Lego12239)
Mikael Berthe <mikael@lilotux.net>
parents:
1170
diff
changeset
|
3901 |
03a38b7ad2e0
Add a collection of commands for key bindings (Lego12239)
Mikael Berthe <mikael@lilotux.net>
parents:
1170
diff
changeset
|
3902 if (ptr_inputline == (char*)&inputLine) |
03a38b7ad2e0
Add a collection of commands for key bindings (Lego12239)
Mikael Berthe <mikael@lilotux.net>
parents:
1170
diff
changeset
|
3903 return; |
03a38b7ad2e0
Add a collection of commands for key bindings (Lego12239)
Mikael Berthe <mikael@lilotux.net>
parents:
1170
diff
changeset
|
3904 |
03a38b7ad2e0
Add a collection of commands for key bindings (Lego12239)
Mikael Berthe <mikael@lilotux.net>
parents:
1170
diff
changeset
|
3905 src = ptr_inputline; |
03a38b7ad2e0
Add a collection of commands for key bindings (Lego12239)
Mikael Berthe <mikael@lilotux.net>
parents:
1170
diff
changeset
|
3906 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
|
3907 ptr_inputline = c; |
1903
75a0a22bbf78
Fix issue #54 -- command line corruption
Mikael Berthe <mikael@lilotux.net>
parents:
1863
diff
changeset
|
3908 _strmove(ptr_inputline, src); |
1171
03a38b7ad2e0
Add a collection of commands for key bindings (Lego12239)
Mikael Berthe <mikael@lilotux.net>
parents:
1170
diff
changeset
|
3909 check_offset(-1); |
03a38b7ad2e0
Add a collection of commands for key bindings (Lego12239)
Mikael Berthe <mikael@lilotux.net>
parents:
1170
diff
changeset
|
3910 } |
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 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
|
3913 { |
03a38b7ad2e0
Add a collection of commands for key bindings (Lego12239)
Mikael Berthe <mikael@lilotux.net>
parents:
1170
diff
changeset
|
3914 if (!*ptr_inputline) |
03a38b7ad2e0
Add a collection of commands for key bindings (Lego12239)
Mikael Berthe <mikael@lilotux.net>
parents:
1170
diff
changeset
|
3915 return; |
03a38b7ad2e0
Add a collection of commands for key bindings (Lego12239)
Mikael Berthe <mikael@lilotux.net>
parents:
1170
diff
changeset
|
3916 |
1903
75a0a22bbf78
Fix issue #54 -- command line corruption
Mikael Berthe <mikael@lilotux.net>
parents:
1863
diff
changeset
|
3917 _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
|
3918 } |
03a38b7ad2e0
Add a collection of commands for key bindings (Lego12239)
Mikael Berthe <mikael@lilotux.net>
parents:
1170
diff
changeset
|
3919 |
03a38b7ad2e0
Add a collection of commands for key bindings (Lego12239)
Mikael Berthe <mikael@lilotux.net>
parents:
1170
diff
changeset
|
3920 void readline_iline_start(void) |
03a38b7ad2e0
Add a collection of commands for key bindings (Lego12239)
Mikael Berthe <mikael@lilotux.net>
parents:
1170
diff
changeset
|
3921 { |
03a38b7ad2e0
Add a collection of commands for key bindings (Lego12239)
Mikael Berthe <mikael@lilotux.net>
parents:
1170
diff
changeset
|
3922 ptr_inputline = inputLine; |
03a38b7ad2e0
Add a collection of commands for key bindings (Lego12239)
Mikael Berthe <mikael@lilotux.net>
parents:
1170
diff
changeset
|
3923 inputline_offset = 0; |
03a38b7ad2e0
Add a collection of commands for key bindings (Lego12239)
Mikael Berthe <mikael@lilotux.net>
parents:
1170
diff
changeset
|
3924 } |
03a38b7ad2e0
Add a collection of commands for key bindings (Lego12239)
Mikael Berthe <mikael@lilotux.net>
parents:
1170
diff
changeset
|
3925 |
03a38b7ad2e0
Add a collection of commands for key bindings (Lego12239)
Mikael Berthe <mikael@lilotux.net>
parents:
1170
diff
changeset
|
3926 void readline_iline_end(void) |
03a38b7ad2e0
Add a collection of commands for key bindings (Lego12239)
Mikael Berthe <mikael@lilotux.net>
parents:
1170
diff
changeset
|
3927 { |
03a38b7ad2e0
Add a collection of commands for key bindings (Lego12239)
Mikael Berthe <mikael@lilotux.net>
parents:
1170
diff
changeset
|
3928 for (; *ptr_inputline; ptr_inputline++) ; |
03a38b7ad2e0
Add a collection of commands for key bindings (Lego12239)
Mikael Berthe <mikael@lilotux.net>
parents:
1170
diff
changeset
|
3929 check_offset(1); |
03a38b7ad2e0
Add a collection of commands for key bindings (Lego12239)
Mikael Berthe <mikael@lilotux.net>
parents:
1170
diff
changeset
|
3930 } |
03a38b7ad2e0
Add a collection of commands for key bindings (Lego12239)
Mikael Berthe <mikael@lilotux.net>
parents:
1170
diff
changeset
|
3931 |
03a38b7ad2e0
Add a collection of commands for key bindings (Lego12239)
Mikael Berthe <mikael@lilotux.net>
parents:
1170
diff
changeset
|
3932 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
|
3933 { |
1863
2b013c0f949a
readline: Make backward_kill_iline() consistent with backward_kill_word()
Mikael Berthe <mikael@lilotux.net>
parents:
1821
diff
changeset
|
3934 char *dest = inputLine; |
2b013c0f949a
readline: Make backward_kill_iline() consistent with backward_kill_word()
Mikael Berthe <mikael@lilotux.net>
parents:
1821
diff
changeset
|
3935 |
2b013c0f949a
readline: Make backward_kill_iline() consistent with backward_kill_word()
Mikael Berthe <mikael@lilotux.net>
parents:
1821
diff
changeset
|
3936 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
|
3937 |
2b013c0f949a
readline: Make backward_kill_iline() consistent with backward_kill_word()
Mikael Berthe <mikael@lilotux.net>
parents:
1821
diff
changeset
|
3938 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
|
3939 dest = next_char(dest); |
2b013c0f949a
readline: Make backward_kill_iline() consistent with backward_kill_word()
Mikael Berthe <mikael@lilotux.net>
parents:
1821
diff
changeset
|
3940 |
1903
75a0a22bbf78
Fix issue #54 -- command line corruption
Mikael Berthe <mikael@lilotux.net>
parents:
1863
diff
changeset
|
3941 _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
|
3942 ptr_inputline = dest; |
1171
03a38b7ad2e0
Add a collection of commands for key bindings (Lego12239)
Mikael Berthe <mikael@lilotux.net>
parents:
1170
diff
changeset
|
3943 inputline_offset = 0; |
03a38b7ad2e0
Add a collection of commands for key bindings (Lego12239)
Mikael Berthe <mikael@lilotux.net>
parents:
1170
diff
changeset
|
3944 } |
03a38b7ad2e0
Add a collection of commands for key bindings (Lego12239)
Mikael Berthe <mikael@lilotux.net>
parents:
1170
diff
changeset
|
3945 |
03a38b7ad2e0
Add a collection of commands for key bindings (Lego12239)
Mikael Berthe <mikael@lilotux.net>
parents:
1170
diff
changeset
|
3946 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
|
3947 { |
03a38b7ad2e0
Add a collection of commands for key bindings (Lego12239)
Mikael Berthe <mikael@lilotux.net>
parents:
1170
diff
changeset
|
3948 *ptr_inputline = 0; |
03a38b7ad2e0
Add a collection of commands for key bindings (Lego12239)
Mikael Berthe <mikael@lilotux.net>
parents:
1170
diff
changeset
|
3949 } |
03a38b7ad2e0
Add a collection of commands for key bindings (Lego12239)
Mikael Berthe <mikael@lilotux.net>
parents:
1170
diff
changeset
|
3950 |
03a38b7ad2e0
Add a collection of commands for key bindings (Lego12239)
Mikael Berthe <mikael@lilotux.net>
parents:
1170
diff
changeset
|
3951 void readline_send_multiline(void) |
03a38b7ad2e0
Add a collection of commands for key bindings (Lego12239)
Mikael Berthe <mikael@lilotux.net>
parents:
1170
diff
changeset
|
3952 { |
03a38b7ad2e0
Add a collection of commands for key bindings (Lego12239)
Mikael Berthe <mikael@lilotux.net>
parents:
1170
diff
changeset
|
3953 // Validate current multi-line |
1413 | 3954 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
|
3955 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
|
3956 } |
03a38b7ad2e0
Add a collection of commands for key bindings (Lego12239)
Mikael Berthe <mikael@lilotux.net>
parents:
1170
diff
changeset
|
3957 |
1945
518740bcd78b
Add /iline iline_insert (Hermitifier)
Mikael Berthe <mikael@lilotux.net>
parents:
1942
diff
changeset
|
3958 void readline_insert(const char *toinsert) |
518740bcd78b
Add /iline iline_insert (Hermitifier)
Mikael Berthe <mikael@lilotux.net>
parents:
1942
diff
changeset
|
3959 { |
518740bcd78b
Add /iline iline_insert (Hermitifier)
Mikael Berthe <mikael@lilotux.net>
parents:
1942
diff
changeset
|
3960 if (!toinsert || !*toinsert) return; |
518740bcd78b
Add /iline iline_insert (Hermitifier)
Mikael Berthe <mikael@lilotux.net>
parents:
1942
diff
changeset
|
3961 |
518740bcd78b
Add /iline iline_insert (Hermitifier)
Mikael Berthe <mikael@lilotux.net>
parents:
1942
diff
changeset
|
3962 scr_insert_text(toinsert); |
518740bcd78b
Add /iline iline_insert (Hermitifier)
Mikael Berthe <mikael@lilotux.net>
parents:
1942
diff
changeset
|
3963 check_offset(0); |
518740bcd78b
Add /iline iline_insert (Hermitifier)
Mikael Berthe <mikael@lilotux.net>
parents:
1942
diff
changeset
|
3964 } |
518740bcd78b
Add /iline iline_insert (Hermitifier)
Mikael Berthe <mikael@lilotux.net>
parents:
1942
diff
changeset
|
3965 |
98 | 3966 // which_row() |
3967 // 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
|
3968 // -2 -> normal text |
ddec224c2318
MUC: nickname completion
Mikael Berthe <mikael@lilotux.net>
parents:
499
diff
changeset
|
3969 // -1 -> room: nickname completion |
98 | 3970 // 0 -> command |
3971 // 1 -> parameter 1 (etc.) | |
102 | 3972 // 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
|
3973 static int which_row(const char **p_row) |
98 | 3974 { |
3975 int row = -1; | |
3976 char *p; | |
3977 int quote = FALSE; | |
3978 | |
3979 // Not a command? | |
967 | 3980 if ((ptr_inputline == inputLine) || (inputLine[0] != COMMAND_CHAR)) { |
503
ddec224c2318
MUC: nickname completion
Mikael Berthe <mikael@lilotux.net>
parents:
499
diff
changeset
|
3981 if (!current_buddy) return -2; |
ddec224c2318
MUC: nickname completion
Mikael Berthe <mikael@lilotux.net>
parents:
499
diff
changeset
|
3982 if (buddy_gettype(BUDDATA(current_buddy)) == ROSTER_TYPE_ROOM) { |
ddec224c2318
MUC: nickname completion
Mikael Berthe <mikael@lilotux.net>
parents:
499
diff
changeset
|
3983 *p_row = inputLine; |
ddec224c2318
MUC: nickname completion
Mikael Berthe <mikael@lilotux.net>
parents:
499
diff
changeset
|
3984 return -1; |
ddec224c2318
MUC: nickname completion
Mikael Berthe <mikael@lilotux.net>
parents:
499
diff
changeset
|
3985 } |
ddec224c2318
MUC: nickname completion
Mikael Berthe <mikael@lilotux.net>
parents:
499
diff
changeset
|
3986 return -2; |
ddec224c2318
MUC: nickname completion
Mikael Berthe <mikael@lilotux.net>
parents:
499
diff
changeset
|
3987 } |
98 | 3988 |
3989 // This is a command | |
3990 row = 0; | |
930
a75f7a13df7b
UTF-8 terminal support (Reimar Döffinger)
Mikael Berthe <mikael@lilotux.net>
parents:
929
diff
changeset
|
3991 for (p = inputLine ; p < ptr_inputline ; p = next_char(p)) { |
98 | 3992 if (quote) { |
3993 if (*p == '"' && *(p-1) != '\\') | |
3994 quote = FALSE; | |
3995 continue; | |
3996 } | |
3997 if (*p == '"' && *(p-1) != '\\') { | |
3998 quote = TRUE; | |
121 | 3999 } else if (*p == ' ') { |
4000 if (*(p-1) != ' ') | |
4001 row++; | |
102 | 4002 *p_row = p+1; |
4003 } | |
98 | 4004 } |
4005 return row; | |
4006 } | |
4007 | |
143 | 4008 // scr_insert_text() |
4009 // Insert the given text at the current cursor position. | |
4010 // The cursor is moved. We don't check if the cursor still is in the screen | |
4011 // after, the caller should do that. | |
336
eb994ee40029
Make some functions static
Mikael Berthe <mikael@lilotux.net>
parents:
332
diff
changeset
|
4012 static void scr_insert_text(const char *text) |
98 | 4013 { |
4014 char tmpLine[INPUTLINE_LENGTH+1]; | |
4015 int len = strlen(text); | |
4016 // Check the line isn't too long | |
4017 if (strlen(inputLine) + len >= INPUTLINE_LENGTH) { | |
374
bd5638c21834
Improve logging system (traces)
Mikael Berthe <mikael@lilotux.net>
parents:
373
diff
changeset
|
4018 scr_LogPrint(LPRINT_LOGNORM, "Cannot insert text, line too long."); |
98 | 4019 return; |
4020 } | |
4021 | |
4022 strcpy(tmpLine, ptr_inputline); | |
419 | 4023 strcpy(ptr_inputline, text); |
4024 ptr_inputline += len; | |
98 | 4025 strcpy(ptr_inputline, tmpLine); |
4026 } | |
4027 | |
930
a75f7a13df7b
UTF-8 terminal support (Reimar Döffinger)
Mikael Berthe <mikael@lilotux.net>
parents:
929
diff
changeset
|
4028 static void scr_cancel_current_completion(void); |
a75f7a13df7b
UTF-8 terminal support (Reimar Döffinger)
Mikael Berthe <mikael@lilotux.net>
parents:
929
diff
changeset
|
4029 |
143 | 4030 // scr_handle_tab() |
4031 // Function called when tab is pressed. | |
4032 // Initiate or continue a completion... | |
2143
2f294c2b6778
Add a backward completion (Oleg)
Mikael Berthe <mikael@lilotux.net>
parents:
2136
diff
changeset
|
4033 // If fwd is false, a backward-completion is requested. |
2f294c2b6778
Add a backward completion (Oleg)
Mikael Berthe <mikael@lilotux.net>
parents:
2136
diff
changeset
|
4034 static void scr_handle_tab(gboolean fwd) |
98 | 4035 { |
102 | 4036 int nrow; |
503
ddec224c2318
MUC: nickname completion
Mikael Berthe <mikael@lilotux.net>
parents:
499
diff
changeset
|
4037 const char *row; |
102 | 4038 const char *cchar; |
103 | 4039 guint compl_categ; |
98 | 4040 |
740 | 4041 row = inputLine; // (Kills a GCC warning) |
102 | 4042 nrow = which_row(&row); |
98 | 4043 |
503
ddec224c2318
MUC: nickname completion
Mikael Berthe <mikael@lilotux.net>
parents:
499
diff
changeset
|
4044 // a) No completion if no leading slash ('cause not a command), |
ddec224c2318
MUC: nickname completion
Mikael Berthe <mikael@lilotux.net>
parents:
499
diff
changeset
|
4045 // unless this is a room (then, it is a nickname completion) |
103 | 4046 // 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
|
4047 if ((nrow == -2) || (nrow == 3 && !completion_started) || nrow > 3) |
ddec224c2318
MUC: nickname completion
Mikael Berthe <mikael@lilotux.net>
parents:
499
diff
changeset
|
4048 return; |
102 | 4049 |
503
ddec224c2318
MUC: nickname completion
Mikael Berthe <mikael@lilotux.net>
parents:
499
diff
changeset
|
4050 if (nrow == 0) { // Command completion |
930
a75f7a13df7b
UTF-8 terminal support (Reimar Döffinger)
Mikael Berthe <mikael@lilotux.net>
parents:
929
diff
changeset
|
4051 row = next_char(inputLine); |
103 | 4052 compl_categ = COMPL_CMD; |
503
ddec224c2318
MUC: nickname completion
Mikael Berthe <mikael@lilotux.net>
parents:
499
diff
changeset
|
4053 } else if (nrow == -1) { // Nickname completion |
ddec224c2318
MUC: nickname completion
Mikael Berthe <mikael@lilotux.net>
parents:
499
diff
changeset
|
4054 compl_categ = COMPL_RESOURCE; |
ddec224c2318
MUC: nickname completion
Mikael Berthe <mikael@lilotux.net>
parents:
499
diff
changeset
|
4055 } else { // Other completion, depending on the command |
285 | 4056 int alias = FALSE; |
4057 cmd *com; | |
4058 char *xpline = expandalias(inputLine); | |
4059 com = cmd_get(xpline); | |
4060 if (xpline != inputLine) { | |
4061 // This is an alias, so we can't complete rows > 0 | |
4062 alias = TRUE; | |
4063 g_free(xpline); | |
4064 } | |
4065 if ((!com && (!alias || !completion_started)) || !row) { | |
374
bd5638c21834
Improve logging system (traces)
Mikael Berthe <mikael@lilotux.net>
parents:
373
diff
changeset
|
4066 scr_LogPrint(LPRINT_NORMAL, "I cannot complete that..."); |
103 | 4067 return; |
4068 } | |
285 | 4069 if (!alias) |
4070 compl_categ = com->completion_flags[nrow-1]; | |
4071 else | |
4072 compl_categ = 0; | |
103 | 4073 } |
4074 | |
4075 if (!completion_started) { | |
1076
b9698c89f46d
Fix memory leak in scr_handle_tab()
Mikael Berthe <mikael@lilotux.net>
parents:
1075
diff
changeset
|
4076 guint dynlist; |
1927
3e3e73bb43f5
Do not call compl_get_category_list() needlessly
Mikael Berthe <mikael@lilotux.net>
parents:
1918
diff
changeset
|
4077 GSList *list; |
3e3e73bb43f5
Do not call compl_get_category_list() needlessly
Mikael Berthe <mikael@lilotux.net>
parents:
1918
diff
changeset
|
4078 |
3e3e73bb43f5
Do not call compl_get_category_list() needlessly
Mikael Berthe <mikael@lilotux.net>
parents:
1918
diff
changeset
|
4079 if (!compl_categ) |
3e3e73bb43f5
Do not call compl_get_category_list() needlessly
Mikael Berthe <mikael@lilotux.net>
parents:
1918
diff
changeset
|
4080 return; // Nothing to complete |
3e3e73bb43f5
Do not call compl_get_category_list() needlessly
Mikael Berthe <mikael@lilotux.net>
parents:
1918
diff
changeset
|
4081 |
3e3e73bb43f5
Do not call compl_get_category_list() needlessly
Mikael Berthe <mikael@lilotux.net>
parents:
1918
diff
changeset
|
4082 list = compl_get_category_list(compl_categ, &dynlist); |
103 | 4083 if (list) { |
1228
9a68fe4515dc
Improve MUC nickname completion
Mikael Berthe <mikael@lilotux.net>
parents:
1227
diff
changeset
|
4084 guint n; |
103 | 4085 char *prefix = g_strndup(row, ptr_inputline-row); |
4086 // Init completion | |
1756
e2c084204583
Add (optional) suffix after nick completion in Multi-User Chats
Mikael Berthe <mikael@lilotux.net>
parents:
1748
diff
changeset
|
4087 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
|
4088 (compl_categ == COMPL_RESOURCE ? |
1793
c3ddb52f1055
Rename completion_muc_suffix to muc_completion_suffix
Myhailo Danylenko <isbear@ukrpost.net>
parents:
1791
diff
changeset
|
4089 settings_opt_get("muc_completion_suffix") : NULL)); |
103 | 4090 g_free(prefix); |
1228
9a68fe4515dc
Improve MUC nickname completion
Mikael Berthe <mikael@lilotux.net>
parents:
1227
diff
changeset
|
4091 if (n == 0 && nrow == -1) { |
9a68fe4515dc
Improve MUC nickname completion
Mikael Berthe <mikael@lilotux.net>
parents:
1227
diff
changeset
|
4092 // 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
|
4093 // 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
|
4094 row = prev_char(ptr_inputline, inputLine); |
9a68fe4515dc
Improve MUC nickname completion
Mikael Berthe <mikael@lilotux.net>
parents:
1227
diff
changeset
|
4095 while (row >= inputLine) { |
1239
eb9fc5d6d085
MUC: Nickname completion starts from any non-space character
Mikael Berthe <mikael@lilotux.net>
parents:
1229
diff
changeset
|
4096 if (iswspace(get_char(row)) || get_char(row) == '(') { |
1228
9a68fe4515dc
Improve MUC nickname completion
Mikael Berthe <mikael@lilotux.net>
parents:
1227
diff
changeset
|
4097 row = next_char((char*)row); |
9a68fe4515dc
Improve MUC nickname completion
Mikael Berthe <mikael@lilotux.net>
parents:
1227
diff
changeset
|
4098 break; |
9a68fe4515dc
Improve MUC nickname completion
Mikael Berthe <mikael@lilotux.net>
parents:
1227
diff
changeset
|
4099 } |
9a68fe4515dc
Improve MUC nickname completion
Mikael Berthe <mikael@lilotux.net>
parents:
1227
diff
changeset
|
4100 if (row == inputLine) |
9a68fe4515dc
Improve MUC nickname completion
Mikael Berthe <mikael@lilotux.net>
parents:
1227
diff
changeset
|
4101 break; |
9a68fe4515dc
Improve MUC nickname completion
Mikael Berthe <mikael@lilotux.net>
parents:
1227
diff
changeset
|
4102 row = prev_char((char*)row, inputLine); |
9a68fe4515dc
Improve MUC nickname completion
Mikael Berthe <mikael@lilotux.net>
parents:
1227
diff
changeset
|
4103 } |
9a68fe4515dc
Improve MUC nickname completion
Mikael Berthe <mikael@lilotux.net>
parents:
1227
diff
changeset
|
4104 // There's no need to try again if row == inputLine |
9a68fe4515dc
Improve MUC nickname completion
Mikael Berthe <mikael@lilotux.net>
parents:
1227
diff
changeset
|
4105 if (row > inputLine) { |
9a68fe4515dc
Improve MUC nickname completion
Mikael Berthe <mikael@lilotux.net>
parents:
1227
diff
changeset
|
4106 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
|
4107 new_completion(prefix, list, NULL); |
1228
9a68fe4515dc
Improve MUC nickname completion
Mikael Berthe <mikael@lilotux.net>
parents:
1227
diff
changeset
|
4108 g_free(prefix); |
9a68fe4515dc
Improve MUC nickname completion
Mikael Berthe <mikael@lilotux.net>
parents:
1227
diff
changeset
|
4109 } |
9a68fe4515dc
Improve MUC nickname completion
Mikael Berthe <mikael@lilotux.net>
parents:
1227
diff
changeset
|
4110 } |
1076
b9698c89f46d
Fix memory leak in scr_handle_tab()
Mikael Berthe <mikael@lilotux.net>
parents:
1075
diff
changeset
|
4111 // 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
|
4112 if (dynlist) { |
b9698c89f46d
Fix memory leak in scr_handle_tab()
Mikael Berthe <mikael@lilotux.net>
parents:
1075
diff
changeset
|
4113 GSList *slp; |
b9698c89f46d
Fix memory leak in scr_handle_tab()
Mikael Berthe <mikael@lilotux.net>
parents:
1075
diff
changeset
|
4114 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
|
4115 g_free(slp->data); |
b9698c89f46d
Fix memory leak in scr_handle_tab()
Mikael Berthe <mikael@lilotux.net>
parents:
1075
diff
changeset
|
4116 g_slist_free(list); |
b9698c89f46d
Fix memory leak in scr_handle_tab()
Mikael Berthe <mikael@lilotux.net>
parents:
1075
diff
changeset
|
4117 } |
103 | 4118 // Now complete |
2143
2f294c2b6778
Add a backward completion (Oleg)
Mikael Berthe <mikael@lilotux.net>
parents:
2136
diff
changeset
|
4119 cchar = complete(fwd); |
98 | 4120 if (cchar) |
4121 scr_insert_text(cchar); | |
103 | 4122 completion_started = TRUE; |
98 | 4123 } |
103 | 4124 } else { // Completion already initialized |
930
a75f7a13df7b
UTF-8 terminal support (Reimar Döffinger)
Mikael Berthe <mikael@lilotux.net>
parents:
929
diff
changeset
|
4125 scr_cancel_current_completion(); |
103 | 4126 // Now complete again |
2143
2f294c2b6778
Add a backward completion (Oleg)
Mikael Berthe <mikael@lilotux.net>
parents:
2136
diff
changeset
|
4127 cchar = complete(fwd); |
103 | 4128 if (cchar) |
4129 scr_insert_text(cchar); | |
102 | 4130 } |
98 | 4131 } |
4132 | |
336
eb994ee40029
Make some functions static
Mikael Berthe <mikael@lilotux.net>
parents:
332
diff
changeset
|
4133 static void scr_cancel_current_completion(void) |
98 | 4134 { |
4135 char *c; | |
930
a75f7a13df7b
UTF-8 terminal support (Reimar Döffinger)
Mikael Berthe <mikael@lilotux.net>
parents:
929
diff
changeset
|
4136 char *src = ptr_inputline; |
98 | 4137 guint back = cancel_completion(); |
930
a75f7a13df7b
UTF-8 terminal support (Reimar Döffinger)
Mikael Berthe <mikael@lilotux.net>
parents:
929
diff
changeset
|
4138 guint i; |
98 | 4139 // Remove $back chars |
930
a75f7a13df7b
UTF-8 terminal support (Reimar Döffinger)
Mikael Berthe <mikael@lilotux.net>
parents:
929
diff
changeset
|
4140 for (i = 0; i < back; i++) |
a75f7a13df7b
UTF-8 terminal support (Reimar Döffinger)
Mikael Berthe <mikael@lilotux.net>
parents:
929
diff
changeset
|
4141 ptr_inputline = prev_char(ptr_inputline, inputLine); |
98 | 4142 c = ptr_inputline; |
930
a75f7a13df7b
UTF-8 terminal support (Reimar Döffinger)
Mikael Berthe <mikael@lilotux.net>
parents:
929
diff
changeset
|
4143 for ( ; *src ; ) |
a75f7a13df7b
UTF-8 terminal support (Reimar Döffinger)
Mikael Berthe <mikael@lilotux.net>
parents:
929
diff
changeset
|
4144 *c++ = *src++; |
a75f7a13df7b
UTF-8 terminal support (Reimar Döffinger)
Mikael Berthe <mikael@lilotux.net>
parents:
929
diff
changeset
|
4145 *c = 0; |
98 | 4146 } |
4147 | |
336
eb994ee40029
Make some functions static
Mikael Berthe <mikael@lilotux.net>
parents:
332
diff
changeset
|
4148 static void scr_end_current_completion(void) |
98 | 4149 { |
4150 done_completion(); | |
4151 completion_started = FALSE; | |
4152 } | |
4153 | |
24 | 4154 // check_offset(int direction) |
4155 // Check inputline_offset value, and make sure the cursor is inside the | |
4156 // screen. | |
336
eb994ee40029
Make some functions static
Mikael Berthe <mikael@lilotux.net>
parents:
332
diff
changeset
|
4157 static inline void check_offset(int direction) |
24 | 4158 { |
930
a75f7a13df7b
UTF-8 terminal support (Reimar Döffinger)
Mikael Berthe <mikael@lilotux.net>
parents:
929
diff
changeset
|
4159 int i; |
a75f7a13df7b
UTF-8 terminal support (Reimar Döffinger)
Mikael Berthe <mikael@lilotux.net>
parents:
929
diff
changeset
|
4160 char *c = &inputLine[inputline_offset]; |
24 | 4161 // Left side |
4162 if (inputline_offset && direction <= 0) { | |
930
a75f7a13df7b
UTF-8 terminal support (Reimar Döffinger)
Mikael Berthe <mikael@lilotux.net>
parents:
929
diff
changeset
|
4163 while (ptr_inputline <= c) { |
a75f7a13df7b
UTF-8 terminal support (Reimar Döffinger)
Mikael Berthe <mikael@lilotux.net>
parents:
929
diff
changeset
|
4164 for (i = 0; i < 5; i++) |
a75f7a13df7b
UTF-8 terminal support (Reimar Döffinger)
Mikael Berthe <mikael@lilotux.net>
parents:
929
diff
changeset
|
4165 c = prev_char(c, inputLine); |
a75f7a13df7b
UTF-8 terminal support (Reimar Döffinger)
Mikael Berthe <mikael@lilotux.net>
parents:
929
diff
changeset
|
4166 if (c == inputLine) |
828
319fc55b9a2b
Fix a bug in check_offset()
Mikael Berthe <mikael@lilotux.net>
parents:
827
diff
changeset
|
4167 break; |
24 | 4168 } |
4169 } | |
4170 // Right side | |
4171 if (direction >= 0) { | |
932
fc6aaa223650
Fix a few problems with non-UTF-8 locales
Mikael Berthe <mikael@lilotux.net>
parents:
931
diff
changeset
|
4172 int delta = get_char_width(c); |
930
a75f7a13df7b
UTF-8 terminal support (Reimar Döffinger)
Mikael Berthe <mikael@lilotux.net>
parents:
929
diff
changeset
|
4173 while (ptr_inputline > c) { |
a75f7a13df7b
UTF-8 terminal support (Reimar Döffinger)
Mikael Berthe <mikael@lilotux.net>
parents:
929
diff
changeset
|
4174 c = next_char(c); |
932
fc6aaa223650
Fix a few problems with non-UTF-8 locales
Mikael Berthe <mikael@lilotux.net>
parents:
931
diff
changeset
|
4175 delta += get_char_width(c); |
930
a75f7a13df7b
UTF-8 terminal support (Reimar Döffinger)
Mikael Berthe <mikael@lilotux.net>
parents:
929
diff
changeset
|
4176 } |
a75f7a13df7b
UTF-8 terminal support (Reimar Döffinger)
Mikael Berthe <mikael@lilotux.net>
parents:
929
diff
changeset
|
4177 c = &inputLine[inputline_offset]; |
a75f7a13df7b
UTF-8 terminal support (Reimar Döffinger)
Mikael Berthe <mikael@lilotux.net>
parents:
929
diff
changeset
|
4178 while (delta >= maxX) { |
a75f7a13df7b
UTF-8 terminal support (Reimar Döffinger)
Mikael Berthe <mikael@lilotux.net>
parents:
929
diff
changeset
|
4179 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
|
4180 delta -= get_char_width(c); |
930
a75f7a13df7b
UTF-8 terminal support (Reimar Döffinger)
Mikael Berthe <mikael@lilotux.net>
parents:
929
diff
changeset
|
4181 c = next_char(c); |
a75f7a13df7b
UTF-8 terminal support (Reimar Döffinger)
Mikael Berthe <mikael@lilotux.net>
parents:
929
diff
changeset
|
4182 } |
a75f7a13df7b
UTF-8 terminal support (Reimar Döffinger)
Mikael Berthe <mikael@lilotux.net>
parents:
929
diff
changeset
|
4183 } |
24 | 4184 } |
930
a75f7a13df7b
UTF-8 terminal support (Reimar Döffinger)
Mikael Berthe <mikael@lilotux.net>
parents:
929
diff
changeset
|
4185 inputline_offset = c - inputLine; |
24 | 4186 } |
4187 | |
1590
8d1bcc83ae32
Add support for spellchecking with Enchant (caolan)
Mikael Berthe <mikael@lilotux.net>
parents:
1579
diff
changeset
|
4188 #if defined(WITH_ENCHANT) || defined(WITH_ASPELL) |
1179 | 4189 // prints inputLine with underlined words when misspelled |
4190 static inline void print_checked_line(void) | |
4191 { | |
4192 char *wprint_char_fmt = "%c"; | |
4193 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
|
4194 int nrchar = maxX; |
1179 | 4195 char *ptrCur = inputLine + inputline_offset; |
4196 | |
4197 #ifdef UNICODE | |
4198 // We need this to display a single UTF-8 char... Any better solution? | |
4199 if (utf8_mode) | |
4200 wprint_char_fmt = "%lc"; | |
4201 #endif | |
4202 | |
4203 wmove(inputWnd, 0, 0); // problem with backspace | |
4204 | |
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
|
4205 while (*ptrCur && nrchar-- > 0) { |
1179 | 4206 point = ptrCur - inputLine; |
4207 if (maskLine[point]) | |
4208 wattrset(inputWnd, A_UNDERLINE); | |
4209 wprintw(inputWnd, wprint_char_fmt, get_char(ptrCur)); | |
4210 wattrset(inputWnd, A_NORMAL); | |
4211 ptrCur = next_char(ptrCur); | |
4212 } | |
4213 } | |
4214 #endif | |
4215 | |
336
eb994ee40029
Make some functions static
Mikael Berthe <mikael@lilotux.net>
parents:
332
diff
changeset
|
4216 static inline void refresh_inputline(void) |
312
f0b7ff2df7e8
Ctrl-C does not terminate mcabber
Mikael Berthe <mikael@lilotux.net>
parents:
307
diff
changeset
|
4217 { |
1590
8d1bcc83ae32
Add support for spellchecking with Enchant (caolan)
Mikael Berthe <mikael@lilotux.net>
parents:
1579
diff
changeset
|
4218 #if defined(WITH_ENCHANT) || defined(WITH_ASPELL) |
2309
e00ae0763468
Do not use litteral command char (':', '/')
Mikael Berthe <mikael@lilotux.net>
parents:
2308
diff
changeset
|
4219 if (settings_opt_get_int("spell_enable") && (chatmode || !vi_mode)) { |
1179 | 4220 memset(maskLine, 0, INPUTLINE_LENGTH+1); |
4221 spellcheck(inputLine, maskLine); | |
4222 } | |
4223 print_checked_line(); | |
312
f0b7ff2df7e8
Ctrl-C does not terminate mcabber
Mikael Berthe <mikael@lilotux.net>
parents:
307
diff
changeset
|
4224 wclrtoeol(inputWnd); |
930
a75f7a13df7b
UTF-8 terminal support (Reimar Döffinger)
Mikael Berthe <mikael@lilotux.net>
parents:
929
diff
changeset
|
4225 if (*ptr_inputline) { |
a75f7a13df7b
UTF-8 terminal support (Reimar Döffinger)
Mikael Berthe <mikael@lilotux.net>
parents:
929
diff
changeset
|
4226 // 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
|
4227 // so I know of no better way. |
a75f7a13df7b
UTF-8 terminal support (Reimar Döffinger)
Mikael Berthe <mikael@lilotux.net>
parents:
929
diff
changeset
|
4228 char c = *ptr_inputline; |
a75f7a13df7b
UTF-8 terminal support (Reimar Döffinger)
Mikael Berthe <mikael@lilotux.net>
parents:
929
diff
changeset
|
4229 *ptr_inputline = 0; |
1179 | 4230 print_checked_line(); |
930
a75f7a13df7b
UTF-8 terminal support (Reimar Döffinger)
Mikael Berthe <mikael@lilotux.net>
parents:
929
diff
changeset
|
4231 *ptr_inputline = c; |
a75f7a13df7b
UTF-8 terminal support (Reimar Döffinger)
Mikael Berthe <mikael@lilotux.net>
parents:
929
diff
changeset
|
4232 } |
1179 | 4233 #else |
4234 mvwprintw(inputWnd, 0, 0, "%s", inputLine + inputline_offset); | |
4235 wclrtoeol(inputWnd); | |
4236 if (*ptr_inputline) { | |
4237 // hack to set cursor pos. Characters can have different width, | |
4238 // so I know of no better way. | |
4239 char c = *ptr_inputline; | |
4240 *ptr_inputline = 0; | |
4241 mvwprintw(inputWnd, 0, 0, "%s", inputLine + inputline_offset); | |
4242 *ptr_inputline = c; | |
4243 } | |
4244 #endif | |
312
f0b7ff2df7e8
Ctrl-C does not terminate mcabber
Mikael Berthe <mikael@lilotux.net>
parents:
307
diff
changeset
|
4245 } |
f0b7ff2df7e8
Ctrl-C does not terminate mcabber
Mikael Berthe <mikael@lilotux.net>
parents:
307
diff
changeset
|
4246 |
389
6e895f397474
Ncurses changes + Ctrl-C does not send a signal anylore
Mikael Berthe <mikael@lilotux.net>
parents:
388
diff
changeset
|
4247 void scr_handle_CtrlC(void) |
312
f0b7ff2df7e8
Ctrl-C does not terminate mcabber
Mikael Berthe <mikael@lilotux.net>
parents:
307
diff
changeset
|
4248 { |
365
ddb6593bedc9
Fix segfault when mcabber receives an INT signal (Ctrl-C) early
Mikael Berthe <mikael@lilotux.net>
parents:
364
diff
changeset
|
4249 if (!Curses) return; |
315
65aa05520556
First Ctrl-C now also leaves multi-line message mode
Mikael Berthe <mikael@lilotux.net>
parents:
314
diff
changeset
|
4250 // 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
|
4251 process_command(mkcmdstr("msay abort"), TRUE); |
312
f0b7ff2df7e8
Ctrl-C does not terminate mcabber
Mikael Berthe <mikael@lilotux.net>
parents:
307
diff
changeset
|
4252 // Same as Ctrl-g, now |
f0b7ff2df7e8
Ctrl-C does not terminate mcabber
Mikael Berthe <mikael@lilotux.net>
parents:
307
diff
changeset
|
4253 scr_cancel_current_completion(); |
f0b7ff2df7e8
Ctrl-C does not terminate mcabber
Mikael Berthe <mikael@lilotux.net>
parents:
307
diff
changeset
|
4254 scr_end_current_completion(); |
f0b7ff2df7e8
Ctrl-C does not terminate mcabber
Mikael Berthe <mikael@lilotux.net>
parents:
307
diff
changeset
|
4255 check_offset(-1); |
f0b7ff2df7e8
Ctrl-C does not terminate mcabber
Mikael Berthe <mikael@lilotux.net>
parents:
307
diff
changeset
|
4256 refresh_inputline(); |
f0b7ff2df7e8
Ctrl-C does not terminate mcabber
Mikael Berthe <mikael@lilotux.net>
parents:
307
diff
changeset
|
4257 } |
f0b7ff2df7e8
Ctrl-C does not terminate mcabber
Mikael Berthe <mikael@lilotux.net>
parents:
307
diff
changeset
|
4258 |
761
4532a9fe0e8c
Handle some keyboard escape sequences
Mikael Berthe <mikael@lilotux.net>
parents:
760
diff
changeset
|
4259 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
|
4260 { |
2337 | 4261 keyseq_t *ks; |
761
4532a9fe0e8c
Handle some keyboard escape sequences
Mikael Berthe <mikael@lilotux.net>
parents:
760
diff
changeset
|
4262 |
4532a9fe0e8c
Handle some keyboard escape sequences
Mikael Berthe <mikael@lilotux.net>
parents:
760
diff
changeset
|
4263 // Let's make sure the length is correct |
4532a9fe0e8c
Handle some keyboard escape sequences
Mikael Berthe <mikael@lilotux.net>
parents:
760
diff
changeset
|
4264 if (strlen(seqstr) > MAX_KEYSEQ_LENGTH) { |
4532a9fe0e8c
Handle some keyboard escape sequences
Mikael Berthe <mikael@lilotux.net>
parents:
760
diff
changeset
|
4265 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
|
4266 return; |
4532a9fe0e8c
Handle some keyboard escape sequences
Mikael Berthe <mikael@lilotux.net>
parents:
760
diff
changeset
|
4267 } |
4532a9fe0e8c
Handle some keyboard escape sequences
Mikael Berthe <mikael@lilotux.net>
parents:
760
diff
changeset
|
4268 |
2337 | 4269 ks = g_new0(keyseq_t, 1); |
761
4532a9fe0e8c
Handle some keyboard escape sequences
Mikael Berthe <mikael@lilotux.net>
parents:
760
diff
changeset
|
4270 ks->seqstr = g_strdup(seqstr); |
4532a9fe0e8c
Handle some keyboard escape sequences
Mikael Berthe <mikael@lilotux.net>
parents:
760
diff
changeset
|
4271 ks->mkeycode = mkeycode; |
4532a9fe0e8c
Handle some keyboard escape sequences
Mikael Berthe <mikael@lilotux.net>
parents:
760
diff
changeset
|
4272 ks->value = value; |
4532a9fe0e8c
Handle some keyboard escape sequences
Mikael Berthe <mikael@lilotux.net>
parents:
760
diff
changeset
|
4273 keyseqlist = g_slist_append(keyseqlist, ks); |
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 // match_keyseq(iseq, &ret) |
4532a9fe0e8c
Handle some keyboard escape sequences
Mikael Berthe <mikael@lilotux.net>
parents:
760
diff
changeset
|
4277 // Check if "iseq" is a known key escape sequence. |
4532a9fe0e8c
Handle some keyboard escape sequences
Mikael Berthe <mikael@lilotux.net>
parents:
760
diff
changeset
|
4278 // Return value: |
4532a9fe0e8c
Handle some keyboard escape sequences
Mikael Berthe <mikael@lilotux.net>
parents:
760
diff
changeset
|
4279 // -1 if "seq" matches no known sequence |
4532a9fe0e8c
Handle some keyboard escape sequences
Mikael Berthe <mikael@lilotux.net>
parents:
760
diff
changeset
|
4280 // 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
|
4281 // >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
|
4282 // and *ret is set to the matching keyseq structure. |
2337 | 4283 static inline gint match_keyseq(int *iseq, keyseq_t **ret) |
373
af2f8ddf6a1b
Move (reorganize) functions
Mikael Berthe <mikael@lilotux.net>
parents:
370
diff
changeset
|
4284 { |
761
4532a9fe0e8c
Handle some keyboard escape sequences
Mikael Berthe <mikael@lilotux.net>
parents:
760
diff
changeset
|
4285 GSList *ksl; |
2337 | 4286 keyseq_t *ksp; |
761
4532a9fe0e8c
Handle some keyboard escape sequences
Mikael Berthe <mikael@lilotux.net>
parents:
760
diff
changeset
|
4287 char *p, c; |
4532a9fe0e8c
Handle some keyboard escape sequences
Mikael Berthe <mikael@lilotux.net>
parents:
760
diff
changeset
|
4288 int *i; |
4532a9fe0e8c
Handle some keyboard escape sequences
Mikael Berthe <mikael@lilotux.net>
parents:
760
diff
changeset
|
4289 int needmore = FALSE; |
4532a9fe0e8c
Handle some keyboard escape sequences
Mikael Berthe <mikael@lilotux.net>
parents:
760
diff
changeset
|
4290 |
4532a9fe0e8c
Handle some keyboard escape sequences
Mikael Berthe <mikael@lilotux.net>
parents:
760
diff
changeset
|
4291 for (ksl = keyseqlist; ksl; ksl = g_slist_next(ksl)) { |
4532a9fe0e8c
Handle some keyboard escape sequences
Mikael Berthe <mikael@lilotux.net>
parents:
760
diff
changeset
|
4292 ksp = ksl->data; |
4532a9fe0e8c
Handle some keyboard escape sequences
Mikael Berthe <mikael@lilotux.net>
parents:
760
diff
changeset
|
4293 p = ksp->seqstr; |
4532a9fe0e8c
Handle some keyboard escape sequences
Mikael Berthe <mikael@lilotux.net>
parents:
760
diff
changeset
|
4294 i = iseq; |
4532a9fe0e8c
Handle some keyboard escape sequences
Mikael Berthe <mikael@lilotux.net>
parents:
760
diff
changeset
|
4295 while (1) { |
4532a9fe0e8c
Handle some keyboard escape sequences
Mikael Berthe <mikael@lilotux.net>
parents:
760
diff
changeset
|
4296 c = (unsigned char)*i; |
4532a9fe0e8c
Handle some keyboard escape sequences
Mikael Berthe <mikael@lilotux.net>
parents:
760
diff
changeset
|
4297 if (!*p && !c) { // Match |
4532a9fe0e8c
Handle some keyboard escape sequences
Mikael Berthe <mikael@lilotux.net>
parents:
760
diff
changeset
|
4298 (*ret) = ksp; |
4532a9fe0e8c
Handle some keyboard escape sequences
Mikael Berthe <mikael@lilotux.net>
parents:
760
diff
changeset
|
4299 return ksp->mkeycode; |
4532a9fe0e8c
Handle some keyboard escape sequences
Mikael Berthe <mikael@lilotux.net>
parents:
760
diff
changeset
|
4300 } |
4532a9fe0e8c
Handle some keyboard escape sequences
Mikael Berthe <mikael@lilotux.net>
parents:
760
diff
changeset
|
4301 if (!c) { |
4532a9fe0e8c
Handle some keyboard escape sequences
Mikael Berthe <mikael@lilotux.net>
parents:
760
diff
changeset
|
4302 // iseq is too short |
4532a9fe0e8c
Handle some keyboard escape sequences
Mikael Berthe <mikael@lilotux.net>
parents:
760
diff
changeset
|
4303 needmore = TRUE; |
4532a9fe0e8c
Handle some keyboard escape sequences
Mikael Berthe <mikael@lilotux.net>
parents:
760
diff
changeset
|
4304 break; |
4532a9fe0e8c
Handle some keyboard escape sequences
Mikael Berthe <mikael@lilotux.net>
parents:
760
diff
changeset
|
4305 } else if (!*p || c != *p) { |
4532a9fe0e8c
Handle some keyboard escape sequences
Mikael Berthe <mikael@lilotux.net>
parents:
760
diff
changeset
|
4306 // This isn't a match |
4532a9fe0e8c
Handle some keyboard escape sequences
Mikael Berthe <mikael@lilotux.net>
parents:
760
diff
changeset
|
4307 break; |
4532a9fe0e8c
Handle some keyboard escape sequences
Mikael Berthe <mikael@lilotux.net>
parents:
760
diff
changeset
|
4308 } |
4532a9fe0e8c
Handle some keyboard escape sequences
Mikael Berthe <mikael@lilotux.net>
parents:
760
diff
changeset
|
4309 p++; i++; |
4532a9fe0e8c
Handle some keyboard escape sequences
Mikael Berthe <mikael@lilotux.net>
parents:
760
diff
changeset
|
4310 } |
4532a9fe0e8c
Handle some keyboard escape sequences
Mikael Berthe <mikael@lilotux.net>
parents:
760
diff
changeset
|
4311 } |
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 if (needmore) |
4532a9fe0e8c
Handle some keyboard escape sequences
Mikael Berthe <mikael@lilotux.net>
parents:
760
diff
changeset
|
4314 return 0; |
4532a9fe0e8c
Handle some keyboard escape sequences
Mikael Berthe <mikael@lilotux.net>
parents:
760
diff
changeset
|
4315 return -1; |
4532a9fe0e8c
Handle some keyboard escape sequences
Mikael Berthe <mikael@lilotux.net>
parents:
760
diff
changeset
|
4316 } |
4532a9fe0e8c
Handle some keyboard escape sequences
Mikael Berthe <mikael@lilotux.net>
parents:
760
diff
changeset
|
4317 |
930
a75f7a13df7b
UTF-8 terminal support (Reimar Döffinger)
Mikael Berthe <mikael@lilotux.net>
parents:
929
diff
changeset
|
4318 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
|
4319 { |
a75f7a13df7b
UTF-8 terminal support (Reimar Döffinger)
Mikael Berthe <mikael@lilotux.net>
parents:
929
diff
changeset
|
4320 int *strp = iseq; |
a75f7a13df7b
UTF-8 terminal support (Reimar Döffinger)
Mikael Berthe <mikael@lilotux.net>
parents:
929
diff
changeset
|
4321 unsigned c = *strp++; |
a75f7a13df7b
UTF-8 terminal support (Reimar Döffinger)
Mikael Berthe <mikael@lilotux.net>
parents:
929
diff
changeset
|
4322 unsigned mask = 0x80; |
a75f7a13df7b
UTF-8 terminal support (Reimar Döffinger)
Mikael Berthe <mikael@lilotux.net>
parents:
929
diff
changeset
|
4323 int len = -1; |
a75f7a13df7b
UTF-8 terminal support (Reimar Döffinger)
Mikael Berthe <mikael@lilotux.net>
parents:
929
diff
changeset
|
4324 while (c & mask) { |
a75f7a13df7b
UTF-8 terminal support (Reimar Döffinger)
Mikael Berthe <mikael@lilotux.net>
parents:
929
diff
changeset
|
4325 mask >>= 1; |
a75f7a13df7b
UTF-8 terminal support (Reimar Döffinger)
Mikael Berthe <mikael@lilotux.net>
parents:
929
diff
changeset
|
4326 len++; |
a75f7a13df7b
UTF-8 terminal support (Reimar Döffinger)
Mikael Berthe <mikael@lilotux.net>
parents:
929
diff
changeset
|
4327 } |
a75f7a13df7b
UTF-8 terminal support (Reimar Döffinger)
Mikael Berthe <mikael@lilotux.net>
parents:
929
diff
changeset
|
4328 if (len <= 0 || len > 4) |
a75f7a13df7b
UTF-8 terminal support (Reimar Döffinger)
Mikael Berthe <mikael@lilotux.net>
parents:
929
diff
changeset
|
4329 return -1; |
a75f7a13df7b
UTF-8 terminal support (Reimar Döffinger)
Mikael Berthe <mikael@lilotux.net>
parents:
929
diff
changeset
|
4330 c &= mask - 1; |
a75f7a13df7b
UTF-8 terminal support (Reimar Döffinger)
Mikael Berthe <mikael@lilotux.net>
parents:
929
diff
changeset
|
4331 while ((*strp & 0xc0) == 0x80) { |
a75f7a13df7b
UTF-8 terminal support (Reimar Döffinger)
Mikael Berthe <mikael@lilotux.net>
parents:
929
diff
changeset
|
4332 if (len-- <= 0) // can't happen |
a75f7a13df7b
UTF-8 terminal support (Reimar Döffinger)
Mikael Berthe <mikael@lilotux.net>
parents:
929
diff
changeset
|
4333 return -1; |
a75f7a13df7b
UTF-8 terminal support (Reimar Döffinger)
Mikael Berthe <mikael@lilotux.net>
parents:
929
diff
changeset
|
4334 c = (c << 6) | (*strp++ & 0x3f); |
a75f7a13df7b
UTF-8 terminal support (Reimar Döffinger)
Mikael Berthe <mikael@lilotux.net>
parents:
929
diff
changeset
|
4335 } |
a75f7a13df7b
UTF-8 terminal support (Reimar Döffinger)
Mikael Berthe <mikael@lilotux.net>
parents:
929
diff
changeset
|
4336 if (len) |
a75f7a13df7b
UTF-8 terminal support (Reimar Döffinger)
Mikael Berthe <mikael@lilotux.net>
parents:
929
diff
changeset
|
4337 return 0; |
a75f7a13df7b
UTF-8 terminal support (Reimar Döffinger)
Mikael Berthe <mikael@lilotux.net>
parents:
929
diff
changeset
|
4338 return c; |
a75f7a13df7b
UTF-8 terminal support (Reimar Döffinger)
Mikael Berthe <mikael@lilotux.net>
parents:
929
diff
changeset
|
4339 } |
a75f7a13df7b
UTF-8 terminal support (Reimar Döffinger)
Mikael Berthe <mikael@lilotux.net>
parents:
929
diff
changeset
|
4340 |
2337 | 4341 void scr_getch(keycode_t *kcode) |
761
4532a9fe0e8c
Handle some keyboard escape sequences
Mikael Berthe <mikael@lilotux.net>
parents:
760
diff
changeset
|
4342 { |
2337 | 4343 keyseq_t *mks = NULL; |
761
4532a9fe0e8c
Handle some keyboard escape sequences
Mikael Berthe <mikael@lilotux.net>
parents:
760
diff
changeset
|
4344 int ks[MAX_KEYSEQ_LENGTH+1]; |
4532a9fe0e8c
Handle some keyboard escape sequences
Mikael Berthe <mikael@lilotux.net>
parents:
760
diff
changeset
|
4345 int i; |
4532a9fe0e8c
Handle some keyboard escape sequences
Mikael Berthe <mikael@lilotux.net>
parents:
760
diff
changeset
|
4346 |
2337 | 4347 memset(kcode, 0, sizeof(keycode_t)); |
761
4532a9fe0e8c
Handle some keyboard escape sequences
Mikael Berthe <mikael@lilotux.net>
parents:
760
diff
changeset
|
4348 memset(ks, 0, sizeof(ks)); |
4532a9fe0e8c
Handle some keyboard escape sequences
Mikael Berthe <mikael@lilotux.net>
parents:
760
diff
changeset
|
4349 |
4532a9fe0e8c
Handle some keyboard escape sequences
Mikael Berthe <mikael@lilotux.net>
parents:
760
diff
changeset
|
4350 kcode->value = wgetch(inputWnd); |
930
a75f7a13df7b
UTF-8 terminal support (Reimar Döffinger)
Mikael Berthe <mikael@lilotux.net>
parents:
929
diff
changeset
|
4351 if (utf8_mode) { |
1058 | 4352 bool ismeta = (kcode->value == 27); |
1561 | 4353 #ifdef NCURSES_MOUSE_VERSION |
4354 bool ismouse = (kcode->value == KEY_MOUSE); | |
4355 | |
4356 if (ismouse) { | |
4357 MEVENT mouse; | |
4358 getmouse(&mouse); | |
4359 kcode->value = mouse.bstate; | |
4360 kcode->mcode = MKEY_MOUSE; | |
4361 return; | |
4362 } else if (ismeta) | |
4363 #else | |
1058 | 4364 if (ismeta) |
1561 | 4365 #endif |
944
aec71ebf98fa
Fix Meta + UTF-8 character
Mikael Berthe <mikael@lilotux.net>
parents:
940
diff
changeset
|
4366 ks[0] = wgetch(inputWnd); |
aec71ebf98fa
Fix Meta + UTF-8 character
Mikael Berthe <mikael@lilotux.net>
parents:
940
diff
changeset
|
4367 else |
aec71ebf98fa
Fix Meta + UTF-8 character
Mikael Berthe <mikael@lilotux.net>
parents:
940
diff
changeset
|
4368 ks[0] = kcode->value; |
aec71ebf98fa
Fix Meta + UTF-8 character
Mikael Berthe <mikael@lilotux.net>
parents:
940
diff
changeset
|
4369 |
930
a75f7a13df7b
UTF-8 terminal support (Reimar Döffinger)
Mikael Berthe <mikael@lilotux.net>
parents:
929
diff
changeset
|
4370 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
|
4371 int match = match_utf8_keyseq(ks); |
a75f7a13df7b
UTF-8 terminal support (Reimar Döffinger)
Mikael Berthe <mikael@lilotux.net>
parents:
929
diff
changeset
|
4372 if (match == -1) |
a75f7a13df7b
UTF-8 terminal support (Reimar Döffinger)
Mikael Berthe <mikael@lilotux.net>
parents:
929
diff
changeset
|
4373 break; |
a75f7a13df7b
UTF-8 terminal support (Reimar Döffinger)
Mikael Berthe <mikael@lilotux.net>
parents:
929
diff
changeset
|
4374 if (match > 0) { |
a75f7a13df7b
UTF-8 terminal support (Reimar Döffinger)
Mikael Berthe <mikael@lilotux.net>
parents:
929
diff
changeset
|
4375 kcode->value = match; |
a75f7a13df7b
UTF-8 terminal support (Reimar Döffinger)
Mikael Berthe <mikael@lilotux.net>
parents:
929
diff
changeset
|
4376 kcode->utf8 = 1; |
1058 | 4377 if (ismeta) |
944
aec71ebf98fa
Fix Meta + UTF-8 character
Mikael Berthe <mikael@lilotux.net>
parents:
940
diff
changeset
|
4378 kcode->mcode = MKEY_META; |
930
a75f7a13df7b
UTF-8 terminal support (Reimar Döffinger)
Mikael Berthe <mikael@lilotux.net>
parents:
929
diff
changeset
|
4379 return; |
a75f7a13df7b
UTF-8 terminal support (Reimar Döffinger)
Mikael Berthe <mikael@lilotux.net>
parents:
929
diff
changeset
|
4380 } |
a75f7a13df7b
UTF-8 terminal support (Reimar Döffinger)
Mikael Berthe <mikael@lilotux.net>
parents:
929
diff
changeset
|
4381 ks[i + 1] = wgetch(inputWnd); |
a75f7a13df7b
UTF-8 terminal support (Reimar Döffinger)
Mikael Berthe <mikael@lilotux.net>
parents:
929
diff
changeset
|
4382 if (ks[i + 1] == ERR) |
a75f7a13df7b
UTF-8 terminal support (Reimar Döffinger)
Mikael Berthe <mikael@lilotux.net>
parents:
929
diff
changeset
|
4383 break; |
a75f7a13df7b
UTF-8 terminal support (Reimar Döffinger)
Mikael Berthe <mikael@lilotux.net>
parents:
929
diff
changeset
|
4384 } |
a75f7a13df7b
UTF-8 terminal support (Reimar Döffinger)
Mikael Berthe <mikael@lilotux.net>
parents:
929
diff
changeset
|
4385 while (i > 0) |
a75f7a13df7b
UTF-8 terminal support (Reimar Döffinger)
Mikael Berthe <mikael@lilotux.net>
parents:
929
diff
changeset
|
4386 ungetch(ks[i--]); |
1058 | 4387 if (ismeta) |
944
aec71ebf98fa
Fix Meta + UTF-8 character
Mikael Berthe <mikael@lilotux.net>
parents:
940
diff
changeset
|
4388 ungetch(ks[0]); |
930
a75f7a13df7b
UTF-8 terminal support (Reimar Döffinger)
Mikael Berthe <mikael@lilotux.net>
parents:
929
diff
changeset
|
4389 memset(ks, 0, sizeof(ks)); |
a75f7a13df7b
UTF-8 terminal support (Reimar Döffinger)
Mikael Berthe <mikael@lilotux.net>
parents:
929
diff
changeset
|
4390 } |
761
4532a9fe0e8c
Handle some keyboard escape sequences
Mikael Berthe <mikael@lilotux.net>
parents:
760
diff
changeset
|
4391 if (kcode->value != 27) |
4532a9fe0e8c
Handle some keyboard escape sequences
Mikael Berthe <mikael@lilotux.net>
parents:
760
diff
changeset
|
4392 return; |
4532a9fe0e8c
Handle some keyboard escape sequences
Mikael Berthe <mikael@lilotux.net>
parents:
760
diff
changeset
|
4393 |
4532a9fe0e8c
Handle some keyboard escape sequences
Mikael Berthe <mikael@lilotux.net>
parents:
760
diff
changeset
|
4394 // Check for escape key sequence |
4532a9fe0e8c
Handle some keyboard escape sequences
Mikael Berthe <mikael@lilotux.net>
parents:
760
diff
changeset
|
4395 for (i=0; i < MAX_KEYSEQ_LENGTH; i++) { |
4532a9fe0e8c
Handle some keyboard escape sequences
Mikael Berthe <mikael@lilotux.net>
parents:
760
diff
changeset
|
4396 int match; |
4532a9fe0e8c
Handle some keyboard escape sequences
Mikael Berthe <mikael@lilotux.net>
parents:
760
diff
changeset
|
4397 ks[i] = wgetch(inputWnd); |
4532a9fe0e8c
Handle some keyboard escape sequences
Mikael Berthe <mikael@lilotux.net>
parents:
760
diff
changeset
|
4398 if (ks[i] == ERR) break; |
4532a9fe0e8c
Handle some keyboard escape sequences
Mikael Berthe <mikael@lilotux.net>
parents:
760
diff
changeset
|
4399 match = match_keyseq(ks, &mks); |
4532a9fe0e8c
Handle some keyboard escape sequences
Mikael Berthe <mikael@lilotux.net>
parents:
760
diff
changeset
|
4400 if (match == -1) { |
4532a9fe0e8c
Handle some keyboard escape sequences
Mikael Berthe <mikael@lilotux.net>
parents:
760
diff
changeset
|
4401 // 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
|
4402 i++; |
4532a9fe0e8c
Handle some keyboard escape sequences
Mikael Berthe <mikael@lilotux.net>
parents:
760
diff
changeset
|
4403 break; |
4532a9fe0e8c
Handle some keyboard escape sequences
Mikael Berthe <mikael@lilotux.net>
parents:
760
diff
changeset
|
4404 } |
4532a9fe0e8c
Handle some keyboard escape sequences
Mikael Berthe <mikael@lilotux.net>
parents:
760
diff
changeset
|
4405 if (match > 0) { |
4532a9fe0e8c
Handle some keyboard escape sequences
Mikael Berthe <mikael@lilotux.net>
parents:
760
diff
changeset
|
4406 // We have a matching sequence |
4532a9fe0e8c
Handle some keyboard escape sequences
Mikael Berthe <mikael@lilotux.net>
parents:
760
diff
changeset
|
4407 kcode->mcode = mks->mkeycode; |
4532a9fe0e8c
Handle some keyboard escape sequences
Mikael Berthe <mikael@lilotux.net>
parents:
760
diff
changeset
|
4408 kcode->value = mks->value; |
4532a9fe0e8c
Handle some keyboard escape sequences
Mikael Berthe <mikael@lilotux.net>
parents:
760
diff
changeset
|
4409 return; |
4532a9fe0e8c
Handle some keyboard escape sequences
Mikael Berthe <mikael@lilotux.net>
parents:
760
diff
changeset
|
4410 } |
4532a9fe0e8c
Handle some keyboard escape sequences
Mikael Berthe <mikael@lilotux.net>
parents:
760
diff
changeset
|
4411 } |
4532a9fe0e8c
Handle some keyboard escape sequences
Mikael Berthe <mikael@lilotux.net>
parents:
760
diff
changeset
|
4412 |
4532a9fe0e8c
Handle some keyboard escape sequences
Mikael Berthe <mikael@lilotux.net>
parents:
760
diff
changeset
|
4413 // No match. Let's return a meta-key. |
4532a9fe0e8c
Handle some keyboard escape sequences
Mikael Berthe <mikael@lilotux.net>
parents:
760
diff
changeset
|
4414 if (i > 0) { |
4532a9fe0e8c
Handle some keyboard escape sequences
Mikael Berthe <mikael@lilotux.net>
parents:
760
diff
changeset
|
4415 kcode->mcode = MKEY_META; |
4532a9fe0e8c
Handle some keyboard escape sequences
Mikael Berthe <mikael@lilotux.net>
parents:
760
diff
changeset
|
4416 kcode->value = ks[0]; |
4532a9fe0e8c
Handle some keyboard escape sequences
Mikael Berthe <mikael@lilotux.net>
parents:
760
diff
changeset
|
4417 } |
4532a9fe0e8c
Handle some keyboard escape sequences
Mikael Berthe <mikael@lilotux.net>
parents:
760
diff
changeset
|
4418 if (i > 1) { |
4532a9fe0e8c
Handle some keyboard escape sequences
Mikael Berthe <mikael@lilotux.net>
parents:
760
diff
changeset
|
4419 // 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
|
4420 while (i-- > 1) |
4532a9fe0e8c
Handle some keyboard escape sequences
Mikael Berthe <mikael@lilotux.net>
parents:
760
diff
changeset
|
4421 ungetch(ks[i]); |
4532a9fe0e8c
Handle some keyboard escape sequences
Mikael Berthe <mikael@lilotux.net>
parents:
760
diff
changeset
|
4422 } |
4532a9fe0e8c
Handle some keyboard escape sequences
Mikael Berthe <mikael@lilotux.net>
parents:
760
diff
changeset
|
4423 return; |
373
af2f8ddf6a1b
Move (reorganize) functions
Mikael Berthe <mikael@lilotux.net>
parents:
370
diff
changeset
|
4424 } |
af2f8ddf6a1b
Move (reorganize) functions
Mikael Berthe <mikael@lilotux.net>
parents:
370
diff
changeset
|
4425 |
1780
e4378fbab5d7
Major API cleanup - bump API to 4
Mikael Berthe <mikael@lilotux.net>
parents:
1761
diff
changeset
|
4426 void scr_do_update(void) |
939
12fa2ae6445d
Get rid of "busy-waiting" (Christof Meerwald)
Mikael Berthe <mikael@lilotux.net>
parents:
936
diff
changeset
|
4427 { |
1942
3e39a336a992
Use guards for colors (Myhailo Danylenko)
Mikael Berthe <mikael@lilotux.net>
parents:
1935
diff
changeset
|
4428 if (colors_stalled) |
3e39a336a992
Use guards for colors (Myhailo Danylenko)
Mikael Berthe <mikael@lilotux.net>
parents:
1935
diff
changeset
|
4429 parse_colors(); |
939
12fa2ae6445d
Get rid of "busy-waiting" (Christof Meerwald)
Mikael Berthe <mikael@lilotux.net>
parents:
936
diff
changeset
|
4430 doupdate(); |
12fa2ae6445d
Get rid of "busy-waiting" (Christof Meerwald)
Mikael Berthe <mikael@lilotux.net>
parents:
936
diff
changeset
|
4431 } |
12fa2ae6445d
Get rid of "busy-waiting" (Christof Meerwald)
Mikael Berthe <mikael@lilotux.net>
parents:
936
diff
changeset
|
4432 |
2337 | 4433 static void bindcommand(keycode_t kcode) |
930
a75f7a13df7b
UTF-8 terminal support (Reimar Döffinger)
Mikael Berthe <mikael@lilotux.net>
parents:
929
diff
changeset
|
4434 { |
945
17ef145f3326
Display and use UTF-8 key codes
Mikael Berthe <mikael@lilotux.net>
parents:
944
diff
changeset
|
4435 gchar asciikey[16], asciicode[16]; |
764
4e15322d315e
Allow binding of meta keys
Mikael Berthe <mikael@lilotux.net>
parents:
763
diff
changeset
|
4436 const gchar *boundcmd; |
4e15322d315e
Allow binding of meta keys
Mikael Berthe <mikael@lilotux.net>
parents:
763
diff
changeset
|
4437 |
945
17ef145f3326
Display and use UTF-8 key codes
Mikael Berthe <mikael@lilotux.net>
parents:
944
diff
changeset
|
4438 if (kcode.utf8) |
17ef145f3326
Display and use UTF-8 key codes
Mikael Berthe <mikael@lilotux.net>
parents:
944
diff
changeset
|
4439 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
|
4440 else |
17ef145f3326
Display and use UTF-8 key codes
Mikael Berthe <mikael@lilotux.net>
parents:
944
diff
changeset
|
4441 g_snprintf(asciicode, 15, "%d", kcode.value); |
17ef145f3326
Display and use UTF-8 key codes
Mikael Berthe <mikael@lilotux.net>
parents:
944
diff
changeset
|
4442 |
764
4e15322d315e
Allow binding of meta keys
Mikael Berthe <mikael@lilotux.net>
parents:
763
diff
changeset
|
4443 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
|
4444 g_snprintf(asciikey, 15, "%s", asciicode); |
764
4e15322d315e
Allow binding of meta keys
Mikael Berthe <mikael@lilotux.net>
parents:
763
diff
changeset
|
4445 else if (kcode.mcode == MKEY_META) |
945
17ef145f3326
Display and use UTF-8 key codes
Mikael Berthe <mikael@lilotux.net>
parents:
944
diff
changeset
|
4446 g_snprintf(asciikey, 15, "M%s", asciicode); |
1561 | 4447 else if (kcode.mcode == MKEY_MOUSE) |
4448 g_snprintf(asciikey, 15, "p%s", asciicode); | |
764
4e15322d315e
Allow binding of meta keys
Mikael Berthe <mikael@lilotux.net>
parents:
763
diff
changeset
|
4449 else |
949
e3c49b2f8143
Fix bindings of special keys (MK*)
Mikael Berthe <mikael@lilotux.net>
parents:
945
diff
changeset
|
4450 g_snprintf(asciikey, 15, "MK%d", kcode.mcode); |
764
4e15322d315e
Allow binding of meta keys
Mikael Berthe <mikael@lilotux.net>
parents:
763
diff
changeset
|
4451 |
4e15322d315e
Allow binding of meta keys
Mikael Berthe <mikael@lilotux.net>
parents:
763
diff
changeset
|
4452 boundcmd = settings_get(SETTINGS_TYPE_BINDING, asciikey); |
4e15322d315e
Allow binding of meta keys
Mikael Berthe <mikael@lilotux.net>
parents:
763
diff
changeset
|
4453 |
4e15322d315e
Allow binding of meta keys
Mikael Berthe <mikael@lilotux.net>
parents:
763
diff
changeset
|
4454 if (boundcmd) { |
1357
7bbfb0073f88
Fix an UTF-8 problem in new hook_execute_internal() function
Mikael Berthe <mikael@lilotux.net>
parents:
1355
diff
changeset
|
4455 gchar *cmdline = from_utf8(boundcmd); |
1780
e4378fbab5d7
Major API cleanup - bump API to 4
Mikael Berthe <mikael@lilotux.net>
parents:
1761
diff
changeset
|
4456 scr_check_auto_away(TRUE); |
2164 | 4457 process_command(cmdline, TRUE); |
1058 | 4458 g_free(cmdline); |
2164 | 4459 return; |
764
4e15322d315e
Allow binding of meta keys
Mikael Berthe <mikael@lilotux.net>
parents:
763
diff
changeset
|
4460 } |
4e15322d315e
Allow binding of meta keys
Mikael Berthe <mikael@lilotux.net>
parents:
763
diff
changeset
|
4461 |
4e15322d315e
Allow binding of meta keys
Mikael Berthe <mikael@lilotux.net>
parents:
763
diff
changeset
|
4462 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
|
4463 #ifndef UNICODE |
764
4e15322d315e
Allow binding of meta keys
Mikael Berthe <mikael@lilotux.net>
parents:
763
diff
changeset
|
4464 if (utf8_mode) |
930
a75f7a13df7b
UTF-8 terminal support (Reimar Döffinger)
Mikael Berthe <mikael@lilotux.net>
parents:
929
diff
changeset
|
4465 scr_LogPrint(LPRINT_NORMAL, |
a75f7a13df7b
UTF-8 terminal support (Reimar Döffinger)
Mikael Berthe <mikael@lilotux.net>
parents:
929
diff
changeset
|
4466 "WARNING: Compiled without full UTF-8 support!"); |
a75f7a13df7b
UTF-8 terminal support (Reimar Döffinger)
Mikael Berthe <mikael@lilotux.net>
parents:
929
diff
changeset
|
4467 #endif |
764
4e15322d315e
Allow binding of meta keys
Mikael Berthe <mikael@lilotux.net>
parents:
763
diff
changeset
|
4468 } |
4e15322d315e
Allow binding of meta keys
Mikael Berthe <mikael@lilotux.net>
parents:
763
diff
changeset
|
4469 |
2304
fa8365fb6ac2
[PATCH 1/3] New option: vi_mode
Holger Weiß <holger@zedat.fu-berlin.de>
parents:
2292
diff
changeset
|
4470 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
|
4471 { |
fa8365fb6ac2
[PATCH 1/3] New option: vi_mode
Holger Weiß <holger@zedat.fu-berlin.de>
parents:
2292
diff
changeset
|
4472 const char *l; |
2309
e00ae0763468
Do not use litteral command char (':', '/')
Mikael Berthe <mikael@lilotux.net>
parents:
2308
diff
changeset
|
4473 char mask[INPUTLINE_LENGTH+1]; |
2304
fa8365fb6ac2
[PATCH 1/3] New option: vi_mode
Holger Weiß <holger@zedat.fu-berlin.de>
parents:
2292
diff
changeset
|
4474 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
|
4475 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
|
4476 |
2309
e00ae0763468
Do not use litteral command char (':', '/')
Mikael Berthe <mikael@lilotux.net>
parents:
2308
diff
changeset
|
4477 strncpy(mask, mkcmdstr("roster search "), INPUTLINE_LENGTH); |
e00ae0763468
Do not use litteral command char (':', '/')
Mikael Berthe <mikael@lilotux.net>
parents:
2308
diff
changeset
|
4478 |
e00ae0763468
Do not use litteral command char (':', '/')
Mikael Berthe <mikael@lilotux.net>
parents:
2308
diff
changeset
|
4479 if (inputLine[0] == COMMAND_CHAR) { |
e00ae0763468
Do not use litteral command char (':', '/')
Mikael Berthe <mikael@lilotux.net>
parents:
2308
diff
changeset
|
4480 if (!chatmode) { // Command mode |
e00ae0763468
Do not use litteral command char (':', '/')
Mikael Berthe <mikael@lilotux.net>
parents:
2308
diff
changeset
|
4481 if (key == KEY_UP) |
e00ae0763468
Do not use litteral command char (':', '/')
Mikael Berthe <mikael@lilotux.net>
parents:
2308
diff
changeset
|
4482 l = scr_cmdhisto_prev(inputLine, ptr_inputline - inputLine); |
e00ae0763468
Do not use litteral command char (':', '/')
Mikael Berthe <mikael@lilotux.net>
parents:
2308
diff
changeset
|
4483 else |
e00ae0763468
Do not use litteral command char (':', '/')
Mikael Berthe <mikael@lilotux.net>
parents:
2308
diff
changeset
|
4484 l = scr_cmdhisto_next(inputLine, ptr_inputline - inputLine); |
e00ae0763468
Do not use litteral command char (':', '/')
Mikael Berthe <mikael@lilotux.net>
parents:
2308
diff
changeset
|
4485 if (l) |
e00ae0763468
Do not use litteral command char (':', '/')
Mikael Berthe <mikael@lilotux.net>
parents:
2308
diff
changeset
|
4486 strcpy(inputLine, l); |
e00ae0763468
Do not use litteral command char (':', '/')
Mikael Berthe <mikael@lilotux.net>
parents:
2308
diff
changeset
|
4487 |
e00ae0763468
Do not use litteral command char (':', '/')
Mikael Berthe <mikael@lilotux.net>
parents:
2308
diff
changeset
|
4488 return; |
e00ae0763468
Do not use litteral command char (':', '/')
Mikael Berthe <mikael@lilotux.net>
parents:
2308
diff
changeset
|
4489 } |
e00ae0763468
Do not use litteral command char (':', '/')
Mikael Berthe <mikael@lilotux.net>
parents:
2308
diff
changeset
|
4490 |
e00ae0763468
Do not use litteral command char (':', '/')
Mikael Berthe <mikael@lilotux.net>
parents:
2308
diff
changeset
|
4491 // Chat mode |
e00ae0763468
Do not use litteral command char (':', '/')
Mikael Berthe <mikael@lilotux.net>
parents:
2308
diff
changeset
|
4492 |
e00ae0763468
Do not use litteral command char (':', '/')
Mikael Berthe <mikael@lilotux.net>
parents:
2308
diff
changeset
|
4493 if (cmd_len + str_len > INPUTLINE_LENGTH) |
e00ae0763468
Do not use litteral command char (':', '/')
Mikael Berthe <mikael@lilotux.net>
parents:
2308
diff
changeset
|
4494 return; |
e00ae0763468
Do not use litteral command char (':', '/')
Mikael Berthe <mikael@lilotux.net>
parents:
2308
diff
changeset
|
4495 |
e00ae0763468
Do not use litteral command char (':', '/')
Mikael Berthe <mikael@lilotux.net>
parents:
2308
diff
changeset
|
4496 memcpy(mask + cmd_len, inputLine + 1, str_len + 1); |
e00ae0763468
Do not use litteral command char (':', '/')
Mikael Berthe <mikael@lilotux.net>
parents:
2308
diff
changeset
|
4497 if (key == KEY_UP) |
e00ae0763468
Do not use litteral command char (':', '/')
Mikael Berthe <mikael@lilotux.net>
parents:
2308
diff
changeset
|
4498 l = scr_cmdhisto_prev(mask, ptr_inputline - inputLine + cmd_len - 1); |
e00ae0763468
Do not use litteral command char (':', '/')
Mikael Berthe <mikael@lilotux.net>
parents:
2308
diff
changeset
|
4499 else |
e00ae0763468
Do not use litteral command char (':', '/')
Mikael Berthe <mikael@lilotux.net>
parents:
2308
diff
changeset
|
4500 l = scr_cmdhisto_next(mask, ptr_inputline - inputLine + cmd_len - 1); |
e00ae0763468
Do not use litteral command char (':', '/')
Mikael Berthe <mikael@lilotux.net>
parents:
2308
diff
changeset
|
4501 if (l) |
e00ae0763468
Do not use litteral command char (':', '/')
Mikael Berthe <mikael@lilotux.net>
parents:
2308
diff
changeset
|
4502 strcpy(inputLine + 1, l + cmd_len); |
e00ae0763468
Do not use litteral command char (':', '/')
Mikael Berthe <mikael@lilotux.net>
parents:
2308
diff
changeset
|
4503 |
e00ae0763468
Do not use litteral command char (':', '/')
Mikael Berthe <mikael@lilotux.net>
parents:
2308
diff
changeset
|
4504 return; |
2304
fa8365fb6ac2
[PATCH 1/3] New option: vi_mode
Holger Weiß <holger@zedat.fu-berlin.de>
parents:
2292
diff
changeset
|
4505 } |
2309
e00ae0763468
Do not use litteral command char (':', '/')
Mikael Berthe <mikael@lilotux.net>
parents:
2308
diff
changeset
|
4506 |
e00ae0763468
Do not use litteral command char (':', '/')
Mikael Berthe <mikael@lilotux.net>
parents:
2308
diff
changeset
|
4507 if (inputLine[0] == VI_SEARCH_COMMAND_CHAR) |
e00ae0763468
Do not use litteral command char (':', '/')
Mikael Berthe <mikael@lilotux.net>
parents:
2308
diff
changeset
|
4508 return; |
e00ae0763468
Do not use litteral command char (':', '/')
Mikael Berthe <mikael@lilotux.net>
parents:
2308
diff
changeset
|
4509 |
e00ae0763468
Do not use litteral command char (':', '/')
Mikael Berthe <mikael@lilotux.net>
parents:
2308
diff
changeset
|
4510 if (key == KEY_UP) |
e00ae0763468
Do not use litteral command char (':', '/')
Mikael Berthe <mikael@lilotux.net>
parents:
2308
diff
changeset
|
4511 process_command(mkcmdstr("roster up"), TRUE); |
e00ae0763468
Do not use litteral command char (':', '/')
Mikael Berthe <mikael@lilotux.net>
parents:
2308
diff
changeset
|
4512 else if (key == KEY_DOWN) |
e00ae0763468
Do not use litteral command char (':', '/')
Mikael Berthe <mikael@lilotux.net>
parents:
2308
diff
changeset
|
4513 process_command(mkcmdstr("roster down"), TRUE); |
2304
fa8365fb6ac2
[PATCH 1/3] New option: vi_mode
Holger Weiß <holger@zedat.fu-berlin.de>
parents:
2292
diff
changeset
|
4514 } |
fa8365fb6ac2
[PATCH 1/3] New option: vi_mode
Holger Weiß <holger@zedat.fu-berlin.de>
parents:
2292
diff
changeset
|
4515 |
1780
e4378fbab5d7
Major API cleanup - bump API to 4
Mikael Berthe <mikael@lilotux.net>
parents:
1761
diff
changeset
|
4516 // scr_process_key(key) |
44 | 4517 // Handle the pressed key, in the command line (bottom). |
2337 | 4518 void scr_process_key(keycode_t kcode) |
24 | 4519 { |
761
4532a9fe0e8c
Handle some keyboard escape sequences
Mikael Berthe <mikael@lilotux.net>
parents:
760
diff
changeset
|
4520 int key = kcode.value; |
931
1cd6d694ac3c
Fix display of some UTF-8 chars
Mikael Berthe <mikael@lilotux.net>
parents:
930
diff
changeset
|
4521 int display_char = 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
|
4522 int vi_search = FALSE; |
2304
fa8365fb6ac2
[PATCH 1/3] New option: vi_mode
Holger Weiß <holger@zedat.fu-berlin.de>
parents:
2292
diff
changeset
|
4523 static int ex_or_search_mode = FALSE; |
761
4532a9fe0e8c
Handle some keyboard escape sequences
Mikael Berthe <mikael@lilotux.net>
parents:
760
diff
changeset
|
4524 |
1381
40095d413da9
Fix compilation on OpenBSD
Mikael Berthe <mikael@lilotux.net>
parents:
1376
diff
changeset
|
4525 lock_chatstate = FALSE; |
990
35e7913affb7
Send events/chatstates notifications (JEP-22/JEP-85)
Mikael Berthe <mikael@lilotux.net>
parents:
987
diff
changeset
|
4526 |
761
4532a9fe0e8c
Handle some keyboard escape sequences
Mikael Berthe <mikael@lilotux.net>
parents:
760
diff
changeset
|
4527 switch (kcode.mcode) { |
4532a9fe0e8c
Handle some keyboard escape sequences
Mikael Berthe <mikael@lilotux.net>
parents:
760
diff
changeset
|
4528 case 0: |
1918
0fa6df17bc5c
Fix potential issue pointed out by franky's clang report
Mikael Berthe <mikael@lilotux.net>
parents:
1915
diff
changeset
|
4529 // key = kcode.value; |
761
4532a9fe0e8c
Handle some keyboard escape sequences
Mikael Berthe <mikael@lilotux.net>
parents:
760
diff
changeset
|
4530 break; |
4532a9fe0e8c
Handle some keyboard escape sequences
Mikael Berthe <mikael@lilotux.net>
parents:
760
diff
changeset
|
4531 case MKEY_EQUIV: |
1918
0fa6df17bc5c
Fix potential issue pointed out by franky's clang report
Mikael Berthe <mikael@lilotux.net>
parents:
1915
diff
changeset
|
4532 // key = kcode.value; |
761
4532a9fe0e8c
Handle some keyboard escape sequences
Mikael Berthe <mikael@lilotux.net>
parents:
760
diff
changeset
|
4533 break; |
4532a9fe0e8c
Handle some keyboard escape sequences
Mikael Berthe <mikael@lilotux.net>
parents:
760
diff
changeset
|
4534 case MKEY_META: |
4532a9fe0e8c
Handle some keyboard escape sequences
Mikael Berthe <mikael@lilotux.net>
parents:
760
diff
changeset
|
4535 default: |
2164 | 4536 bindcommand(kcode); |
764
4e15322d315e
Allow binding of meta keys
Mikael Berthe <mikael@lilotux.net>
parents:
763
diff
changeset
|
4537 key = ERR; // Do not process any further |
758 | 4538 } |
761
4532a9fe0e8c
Handle some keyboard escape sequences
Mikael Berthe <mikael@lilotux.net>
parents:
760
diff
changeset
|
4539 |
2309
e00ae0763468
Do not use litteral command char (':', '/')
Mikael Berthe <mikael@lilotux.net>
parents:
2308
diff
changeset
|
4540 if (vi_mode && !chatmode) { |
2304
fa8365fb6ac2
[PATCH 1/3] New option: vi_mode
Holger Weiß <holger@zedat.fu-berlin.de>
parents:
2292
diff
changeset
|
4541 int got_cmd_prefix = FALSE; |
fa8365fb6ac2
[PATCH 1/3] New option: vi_mode
Holger Weiß <holger@zedat.fu-berlin.de>
parents:
2292
diff
changeset
|
4542 int unrecognized = FALSE; |
2309
e00ae0763468
Do not use litteral command char (':', '/')
Mikael Berthe <mikael@lilotux.net>
parents:
2308
diff
changeset
|
4543 static char search_cmd[INPUTLINE_LENGTH+1] = ""; |
2304
fa8365fb6ac2
[PATCH 1/3] New option: vi_mode
Holger Weiß <holger@zedat.fu-berlin.de>
parents:
2292
diff
changeset
|
4544 |
fa8365fb6ac2
[PATCH 1/3] New option: vi_mode
Holger Weiß <holger@zedat.fu-berlin.de>
parents:
2292
diff
changeset
|
4545 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
|
4546 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
|
4547 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
|
4548 } 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
|
4549 switch (key) { |
fa8365fb6ac2
[PATCH 1/3] New option: vi_mode
Holger Weiß <holger@zedat.fu-berlin.de>
parents:
2292
diff
changeset
|
4550 case 27: // Escape |
fa8365fb6ac2
[PATCH 1/3] New option: vi_mode
Holger Weiß <holger@zedat.fu-berlin.de>
parents:
2292
diff
changeset
|
4551 clear_inputline(); |
fa8365fb6ac2
[PATCH 1/3] New option: vi_mode
Holger Weiß <holger@zedat.fu-berlin.de>
parents:
2292
diff
changeset
|
4552 ex_or_search_mode = FALSE; |
fa8365fb6ac2
[PATCH 1/3] New option: vi_mode
Holger Weiß <holger@zedat.fu-berlin.de>
parents:
2292
diff
changeset
|
4553 break; |
fa8365fb6ac2
[PATCH 1/3] New option: vi_mode
Holger Weiß <holger@zedat.fu-berlin.de>
parents:
2292
diff
changeset
|
4554 case 9: // Tab |
fa8365fb6ac2
[PATCH 1/3] New option: vi_mode
Holger Weiß <holger@zedat.fu-berlin.de>
parents:
2292
diff
changeset
|
4555 case 353: // Shift-Tab |
2309
e00ae0763468
Do not use litteral command char (':', '/')
Mikael Berthe <mikael@lilotux.net>
parents:
2308
diff
changeset
|
4556 if (inputLine[0] == VI_SEARCH_COMMAND_CHAR) |
e00ae0763468
Do not use litteral command char (':', '/')
Mikael Berthe <mikael@lilotux.net>
parents:
2308
diff
changeset
|
4557 vi_search = TRUE; |
2304
fa8365fb6ac2
[PATCH 1/3] New option: vi_mode
Holger Weiß <holger@zedat.fu-berlin.de>
parents:
2292
diff
changeset
|
4558 break; |
fa8365fb6ac2
[PATCH 1/3] New option: vi_mode
Holger Weiß <holger@zedat.fu-berlin.de>
parents:
2292
diff
changeset
|
4559 case 13: // Enter |
fa8365fb6ac2
[PATCH 1/3] New option: vi_mode
Holger Weiß <holger@zedat.fu-berlin.de>
parents:
2292
diff
changeset
|
4560 case 343: // Enter on Maemo |
2309
e00ae0763468
Do not use litteral command char (':', '/')
Mikael Berthe <mikael@lilotux.net>
parents:
2308
diff
changeset
|
4561 if (inputLine[0] == COMMAND_CHAR) { |
e00ae0763468
Do not use litteral command char (':', '/')
Mikael Berthe <mikael@lilotux.net>
parents:
2308
diff
changeset
|
4562 { |
e00ae0763468
Do not use litteral command char (':', '/')
Mikael Berthe <mikael@lilotux.net>
parents:
2308
diff
changeset
|
4563 char *p = strchr(inputLine, 0); |
e00ae0763468
Do not use litteral command char (':', '/')
Mikael Berthe <mikael@lilotux.net>
parents:
2308
diff
changeset
|
4564 |
e00ae0763468
Do not use litteral command char (':', '/')
Mikael Berthe <mikael@lilotux.net>
parents:
2308
diff
changeset
|
4565 while (*--p == ' ' && p > inputLine) |
e00ae0763468
Do not use litteral command char (':', '/')
Mikael Berthe <mikael@lilotux.net>
parents:
2308
diff
changeset
|
4566 *p = 0; |
e00ae0763468
Do not use litteral command char (':', '/')
Mikael Berthe <mikael@lilotux.net>
parents:
2308
diff
changeset
|
4567 } |
e00ae0763468
Do not use litteral command char (':', '/')
Mikael Berthe <mikael@lilotux.net>
parents:
2308
diff
changeset
|
4568 if (!strcmp(inputLine, mkcmdstr("x")) || |
e00ae0763468
Do not use litteral command char (':', '/')
Mikael Berthe <mikael@lilotux.net>
parents:
2308
diff
changeset
|
4569 !strcmp(inputLine, mkcmdstr("q")) || |
e00ae0763468
Do not use litteral command char (':', '/')
Mikael Berthe <mikael@lilotux.net>
parents:
2308
diff
changeset
|
4570 !strcmp(inputLine, mkcmdstr("wq"))) |
e00ae0763468
Do not use litteral command char (':', '/')
Mikael Berthe <mikael@lilotux.net>
parents:
2308
diff
changeset
|
4571 strcpy(inputLine, mkcmdstr("quit")); |
e00ae0763468
Do not use litteral command char (':', '/')
Mikael Berthe <mikael@lilotux.net>
parents:
2308
diff
changeset
|
4572 if (isdigit((int)(unsigned char)inputLine[1]) && |
e00ae0763468
Do not use litteral command char (':', '/')
Mikael Berthe <mikael@lilotux.net>
parents:
2308
diff
changeset
|
4573 strlen(inputLine) <= 9) { |
e00ae0763468
Do not use litteral command char (':', '/')
Mikael Berthe <mikael@lilotux.net>
parents:
2308
diff
changeset
|
4574 process_command(mkcmdstr("roster top"), TRUE); |
e00ae0763468
Do not use litteral command char (':', '/')
Mikael Berthe <mikael@lilotux.net>
parents:
2308
diff
changeset
|
4575 memcpy(inputLine + 13, inputLine + 1, 10); |
e00ae0763468
Do not use litteral command char (':', '/')
Mikael Berthe <mikael@lilotux.net>
parents:
2308
diff
changeset
|
4576 memcpy(inputLine + 1, "roster down ", 12); |
e00ae0763468
Do not use litteral command char (':', '/')
Mikael Berthe <mikael@lilotux.net>
parents:
2308
diff
changeset
|
4577 } |
e00ae0763468
Do not use litteral command char (':', '/')
Mikael Berthe <mikael@lilotux.net>
parents:
2308
diff
changeset
|
4578 inputLine[0] = COMMAND_CHAR; |
e00ae0763468
Do not use litteral command char (':', '/')
Mikael Berthe <mikael@lilotux.net>
parents:
2308
diff
changeset
|
4579 process_command(inputLine, TRUE); |
e00ae0763468
Do not use litteral command char (':', '/')
Mikael Berthe <mikael@lilotux.net>
parents:
2308
diff
changeset
|
4580 scr_cmdhisto_addline(inputLine); |
e00ae0763468
Do not use litteral command char (':', '/')
Mikael Berthe <mikael@lilotux.net>
parents:
2308
diff
changeset
|
4581 } else if (inputLine[0] == VI_SEARCH_COMMAND_CHAR) { |
e00ae0763468
Do not use litteral command char (':', '/')
Mikael Berthe <mikael@lilotux.net>
parents:
2308
diff
changeset
|
4582 size_t cmd_len; |
e00ae0763468
Do not use litteral command char (':', '/')
Mikael Berthe <mikael@lilotux.net>
parents:
2308
diff
changeset
|
4583 size_t str_len = strlen(inputLine) - 1; |
e00ae0763468
Do not use litteral command char (':', '/')
Mikael Berthe <mikael@lilotux.net>
parents:
2308
diff
changeset
|
4584 |
e00ae0763468
Do not use litteral command char (':', '/')
Mikael Berthe <mikael@lilotux.net>
parents:
2308
diff
changeset
|
4585 strncpy(search_cmd, mkcmdstr("roster search "), INPUTLINE_LENGTH); |
e00ae0763468
Do not use litteral command char (':', '/')
Mikael Berthe <mikael@lilotux.net>
parents:
2308
diff
changeset
|
4586 cmd_len = strlen(search_cmd); |
e00ae0763468
Do not use litteral command char (':', '/')
Mikael Berthe <mikael@lilotux.net>
parents:
2308
diff
changeset
|
4587 |
e00ae0763468
Do not use litteral command char (':', '/')
Mikael Berthe <mikael@lilotux.net>
parents:
2308
diff
changeset
|
4588 if (cmd_len + str_len > INPUTLINE_LENGTH) |
e00ae0763468
Do not use litteral command char (':', '/')
Mikael Berthe <mikael@lilotux.net>
parents:
2308
diff
changeset
|
4589 return; |
e00ae0763468
Do not use litteral command char (':', '/')
Mikael Berthe <mikael@lilotux.net>
parents:
2308
diff
changeset
|
4590 |
e00ae0763468
Do not use litteral command char (':', '/')
Mikael Berthe <mikael@lilotux.net>
parents:
2308
diff
changeset
|
4591 memcpy(search_cmd + cmd_len, inputLine + 1, str_len + 1); |
e00ae0763468
Do not use litteral command char (':', '/')
Mikael Berthe <mikael@lilotux.net>
parents:
2308
diff
changeset
|
4592 |
e00ae0763468
Do not use litteral command char (':', '/')
Mikael Berthe <mikael@lilotux.net>
parents:
2308
diff
changeset
|
4593 process_command(search_cmd, TRUE); |
e00ae0763468
Do not use litteral command char (':', '/')
Mikael Berthe <mikael@lilotux.net>
parents:
2308
diff
changeset
|
4594 scr_cmdhisto_addline(search_cmd); |
e00ae0763468
Do not use litteral command char (':', '/')
Mikael Berthe <mikael@lilotux.net>
parents:
2308
diff
changeset
|
4595 } else if (inputLine[0] == 0) { |
e00ae0763468
Do not use litteral command char (':', '/')
Mikael Berthe <mikael@lilotux.net>
parents:
2308
diff
changeset
|
4596 if (buddy_gettype(BUDDATA(current_buddy)) == |
e00ae0763468
Do not use litteral command char (':', '/')
Mikael Berthe <mikael@lilotux.net>
parents:
2308
diff
changeset
|
4597 ROSTER_TYPE_GROUP) |
e00ae0763468
Do not use litteral command char (':', '/')
Mikael Berthe <mikael@lilotux.net>
parents:
2308
diff
changeset
|
4598 process_command(mkcmdstr("group toggle"), TRUE); |
e00ae0763468
Do not use litteral command char (':', '/')
Mikael Berthe <mikael@lilotux.net>
parents:
2308
diff
changeset
|
4599 else |
e00ae0763468
Do not use litteral command char (':', '/')
Mikael Berthe <mikael@lilotux.net>
parents:
2308
diff
changeset
|
4600 open_chat_window(); |
2304
fa8365fb6ac2
[PATCH 1/3] New option: vi_mode
Holger Weiß <holger@zedat.fu-berlin.de>
parents:
2292
diff
changeset
|
4601 } |
fa8365fb6ac2
[PATCH 1/3] New option: vi_mode
Holger Weiß <holger@zedat.fu-berlin.de>
parents:
2292
diff
changeset
|
4602 ex_or_search_mode = FALSE; |
fa8365fb6ac2
[PATCH 1/3] New option: vi_mode
Holger Weiß <holger@zedat.fu-berlin.de>
parents:
2292
diff
changeset
|
4603 } |
fa8365fb6ac2
[PATCH 1/3] New option: vi_mode
Holger Weiß <holger@zedat.fu-berlin.de>
parents:
2292
diff
changeset
|
4604 } 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
|
4605 got_cmd_prefix = TRUE; |
2309
e00ae0763468
Do not use litteral command char (':', '/')
Mikael Berthe <mikael@lilotux.net>
parents:
2308
diff
changeset
|
4606 } else if (key == COMMAND_CHAR || key == VI_SEARCH_COMMAND_CHAR) { |
e00ae0763468
Do not use litteral command char (':', '/')
Mikael Berthe <mikael@lilotux.net>
parents:
2308
diff
changeset
|
4607 ex_or_search_mode = TRUE; |
e00ae0763468
Do not use litteral command char (':', '/')
Mikael Berthe <mikael@lilotux.net>
parents:
2308
diff
changeset
|
4608 cmdhisto_cur = NULL; |
2304
fa8365fb6ac2
[PATCH 1/3] New option: vi_mode
Holger Weiß <holger@zedat.fu-berlin.de>
parents:
2292
diff
changeset
|
4609 } else { |
fa8365fb6ac2
[PATCH 1/3] New option: vi_mode
Holger Weiß <holger@zedat.fu-berlin.de>
parents:
2292
diff
changeset
|
4610 switch (key) { |
fa8365fb6ac2
[PATCH 1/3] New option: vi_mode
Holger Weiß <holger@zedat.fu-berlin.de>
parents:
2292
diff
changeset
|
4611 case ' ': |
fa8365fb6ac2
[PATCH 1/3] New option: vi_mode
Holger Weiß <holger@zedat.fu-berlin.de>
parents:
2292
diff
changeset
|
4612 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
|
4613 break; |
fa8365fb6ac2
[PATCH 1/3] New option: vi_mode
Holger Weiß <holger@zedat.fu-berlin.de>
parents:
2292
diff
changeset
|
4614 case '!': |
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 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
|
4617 |
fa8365fb6ac2
[PATCH 1/3] New option: vi_mode
Holger Weiß <holger@zedat.fu-berlin.de>
parents:
2292
diff
changeset
|
4618 if (bjid) { |
fa8365fb6ac2
[PATCH 1/3] New option: vi_mode
Holger Weiß <holger@zedat.fu-berlin.de>
parents:
2292
diff
changeset
|
4619 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
|
4620 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
|
4621 |
fa8365fb6ac2
[PATCH 1/3] New option: vi_mode
Holger Weiß <holger@zedat.fu-berlin.de>
parents:
2292
diff
changeset
|
4622 if (type & ROSTER_TYPE_ROOM && |
fa8365fb6ac2
[PATCH 1/3] New option: vi_mode
Holger Weiß <holger@zedat.fu-berlin.de>
parents:
2292
diff
changeset
|
4623 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
|
4624 roster_setuiprio(bjid, FALSE, |
fa8365fb6ac2
[PATCH 1/3] New option: vi_mode
Holger Weiß <holger@zedat.fu-berlin.de>
parents:
2292
diff
changeset
|
4625 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
|
4626 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
|
4627 } 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
|
4628 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
|
4629 roster_setuiprio(bjid, FALSE, |
fa8365fb6ac2
[PATCH 1/3] New option: vi_mode
Holger Weiß <holger@zedat.fu-berlin.de>
parents:
2292
diff
changeset
|
4630 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
|
4631 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
|
4632 } else { |
fa8365fb6ac2
[PATCH 1/3] New option: vi_mode
Holger Weiß <holger@zedat.fu-berlin.de>
parents:
2292
diff
changeset
|
4633 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
|
4634 } |
fa8365fb6ac2
[PATCH 1/3] New option: vi_mode
Holger Weiß <holger@zedat.fu-berlin.de>
parents:
2292
diff
changeset
|
4635 scr_update_roster(); |
fa8365fb6ac2
[PATCH 1/3] New option: vi_mode
Holger Weiß <holger@zedat.fu-berlin.de>
parents:
2292
diff
changeset
|
4636 } |
fa8365fb6ac2
[PATCH 1/3] New option: vi_mode
Holger Weiß <holger@zedat.fu-berlin.de>
parents:
2292
diff
changeset
|
4637 } |
fa8365fb6ac2
[PATCH 1/3] New option: vi_mode
Holger Weiß <holger@zedat.fu-berlin.de>
parents:
2292
diff
changeset
|
4638 break; |
fa8365fb6ac2
[PATCH 1/3] New option: vi_mode
Holger Weiß <holger@zedat.fu-berlin.de>
parents:
2292
diff
changeset
|
4639 case '#': |
fa8365fb6ac2
[PATCH 1/3] New option: vi_mode
Holger Weiß <holger@zedat.fu-berlin.de>
parents:
2292
diff
changeset
|
4640 { |
fa8365fb6ac2
[PATCH 1/3] New option: vi_mode
Holger Weiß <holger@zedat.fu-berlin.de>
parents:
2292
diff
changeset
|
4641 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
|
4642 |
fa8365fb6ac2
[PATCH 1/3] New option: vi_mode
Holger Weiß <holger@zedat.fu-berlin.de>
parents:
2292
diff
changeset
|
4643 if (bjid) { |
fa8365fb6ac2
[PATCH 1/3] New option: vi_mode
Holger Weiß <holger@zedat.fu-berlin.de>
parents:
2292
diff
changeset
|
4644 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
|
4645 |
fa8365fb6ac2
[PATCH 1/3] New option: vi_mode
Holger Weiß <holger@zedat.fu-berlin.de>
parents:
2292
diff
changeset
|
4646 if (bflags & ROSTER_FLAG_MSG) |
fa8365fb6ac2
[PATCH 1/3] New option: vi_mode
Holger Weiß <holger@zedat.fu-berlin.de>
parents:
2292
diff
changeset
|
4647 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
|
4648 else |
fa8365fb6ac2
[PATCH 1/3] New option: vi_mode
Holger Weiß <holger@zedat.fu-berlin.de>
parents:
2292
diff
changeset
|
4649 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
|
4650 |
fa8365fb6ac2
[PATCH 1/3] New option: vi_mode
Holger Weiß <holger@zedat.fu-berlin.de>
parents:
2292
diff
changeset
|
4651 scr_update_roster(); |
fa8365fb6ac2
[PATCH 1/3] New option: vi_mode
Holger Weiß <holger@zedat.fu-berlin.de>
parents:
2292
diff
changeset
|
4652 } |
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 break; |
fa8365fb6ac2
[PATCH 1/3] New option: vi_mode
Holger Weiß <holger@zedat.fu-berlin.de>
parents:
2292
diff
changeset
|
4655 case '\'': |
fa8365fb6ac2
[PATCH 1/3] New option: vi_mode
Holger Weiß <holger@zedat.fu-berlin.de>
parents:
2292
diff
changeset
|
4656 if (inputLine[0] == '\'') |
fa8365fb6ac2
[PATCH 1/3] New option: vi_mode
Holger Weiß <holger@zedat.fu-berlin.de>
parents:
2292
diff
changeset
|
4657 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
|
4658 else |
fa8365fb6ac2
[PATCH 1/3] New option: vi_mode
Holger Weiß <holger@zedat.fu-berlin.de>
parents:
2292
diff
changeset
|
4659 got_cmd_prefix = TRUE; |
fa8365fb6ac2
[PATCH 1/3] New option: vi_mode
Holger Weiß <holger@zedat.fu-berlin.de>
parents:
2292
diff
changeset
|
4660 break; |
fa8365fb6ac2
[PATCH 1/3] New option: vi_mode
Holger Weiß <holger@zedat.fu-berlin.de>
parents:
2292
diff
changeset
|
4661 case 'A': |
fa8365fb6ac2
[PATCH 1/3] New option: vi_mode
Holger Weiß <holger@zedat.fu-berlin.de>
parents:
2292
diff
changeset
|
4662 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
|
4663 break; |
fa8365fb6ac2
[PATCH 1/3] New option: vi_mode
Holger Weiß <holger@zedat.fu-berlin.de>
parents:
2292
diff
changeset
|
4664 case 'a': |
fa8365fb6ac2
[PATCH 1/3] New option: vi_mode
Holger Weiß <holger@zedat.fu-berlin.de>
parents:
2292
diff
changeset
|
4665 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
|
4666 break; |
fa8365fb6ac2
[PATCH 1/3] New option: vi_mode
Holger Weiß <holger@zedat.fu-berlin.de>
parents:
2292
diff
changeset
|
4667 case 'F': |
fa8365fb6ac2
[PATCH 1/3] New option: vi_mode
Holger Weiß <holger@zedat.fu-berlin.de>
parents:
2292
diff
changeset
|
4668 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
|
4669 break; |
fa8365fb6ac2
[PATCH 1/3] New option: vi_mode
Holger Weiß <holger@zedat.fu-berlin.de>
parents:
2292
diff
changeset
|
4670 case 'f': |
fa8365fb6ac2
[PATCH 1/3] New option: vi_mode
Holger Weiß <holger@zedat.fu-berlin.de>
parents:
2292
diff
changeset
|
4671 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
|
4672 break; |
fa8365fb6ac2
[PATCH 1/3] New option: vi_mode
Holger Weiß <holger@zedat.fu-berlin.de>
parents:
2292
diff
changeset
|
4673 case 'G': |
fa8365fb6ac2
[PATCH 1/3] New option: vi_mode
Holger Weiß <holger@zedat.fu-berlin.de>
parents:
2292
diff
changeset
|
4674 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
|
4675 break; |
fa8365fb6ac2
[PATCH 1/3] New option: vi_mode
Holger Weiß <holger@zedat.fu-berlin.de>
parents:
2292
diff
changeset
|
4676 case 'g': |
fa8365fb6ac2
[PATCH 1/3] New option: vi_mode
Holger Weiß <holger@zedat.fu-berlin.de>
parents:
2292
diff
changeset
|
4677 if (inputLine[0] == 'g') |
fa8365fb6ac2
[PATCH 1/3] New option: vi_mode
Holger Weiß <holger@zedat.fu-berlin.de>
parents:
2292
diff
changeset
|
4678 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
|
4679 else { |
fa8365fb6ac2
[PATCH 1/3] New option: vi_mode
Holger Weiß <holger@zedat.fu-berlin.de>
parents:
2292
diff
changeset
|
4680 clear_inputline(); |
fa8365fb6ac2
[PATCH 1/3] New option: vi_mode
Holger Weiß <holger@zedat.fu-berlin.de>
parents:
2292
diff
changeset
|
4681 got_cmd_prefix = TRUE; |
fa8365fb6ac2
[PATCH 1/3] New option: vi_mode
Holger Weiß <holger@zedat.fu-berlin.de>
parents:
2292
diff
changeset
|
4682 } |
fa8365fb6ac2
[PATCH 1/3] New option: vi_mode
Holger Weiß <holger@zedat.fu-berlin.de>
parents:
2292
diff
changeset
|
4683 break; |
fa8365fb6ac2
[PATCH 1/3] New option: vi_mode
Holger Weiß <holger@zedat.fu-berlin.de>
parents:
2292
diff
changeset
|
4684 case 'i': |
fa8365fb6ac2
[PATCH 1/3] New option: vi_mode
Holger Weiß <holger@zedat.fu-berlin.de>
parents:
2292
diff
changeset
|
4685 open_chat_window(); |
fa8365fb6ac2
[PATCH 1/3] New option: vi_mode
Holger Weiß <holger@zedat.fu-berlin.de>
parents:
2292
diff
changeset
|
4686 break; |
fa8365fb6ac2
[PATCH 1/3] New option: vi_mode
Holger Weiß <holger@zedat.fu-berlin.de>
parents:
2292
diff
changeset
|
4687 case 'j': |
fa8365fb6ac2
[PATCH 1/3] New option: vi_mode
Holger Weiß <holger@zedat.fu-berlin.de>
parents:
2292
diff
changeset
|
4688 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
|
4689 strlen(inputLine) <= 9) { |
2326
54b4272de463
Silence compiler warnings (-Wformat-truncation, -Wstringop-truncation)
Michał Kępień <bitbucket@kempniu.pl>
parents:
2325
diff
changeset
|
4690 char down_cmd[24]; |
54b4272de463
Silence compiler warnings (-Wformat-truncation, -Wstringop-truncation)
Michał Kępień <bitbucket@kempniu.pl>
parents:
2325
diff
changeset
|
4691 snprintf (down_cmd, sizeof(down_cmd), "%.13s%.9s", |
54b4272de463
Silence compiler warnings (-Wformat-truncation, -Wstringop-truncation)
Michał Kępień <bitbucket@kempniu.pl>
parents:
2325
diff
changeset
|
4692 mkcmdstr("roster down "), inputLine); |
2304
fa8365fb6ac2
[PATCH 1/3] New option: vi_mode
Holger Weiß <holger@zedat.fu-berlin.de>
parents:
2292
diff
changeset
|
4693 process_command(down_cmd, TRUE); |
fa8365fb6ac2
[PATCH 1/3] New option: vi_mode
Holger Weiß <holger@zedat.fu-berlin.de>
parents:
2292
diff
changeset
|
4694 } else |
fa8365fb6ac2
[PATCH 1/3] New option: vi_mode
Holger Weiß <holger@zedat.fu-berlin.de>
parents:
2292
diff
changeset
|
4695 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
|
4696 break; |
fa8365fb6ac2
[PATCH 1/3] New option: vi_mode
Holger Weiß <holger@zedat.fu-berlin.de>
parents:
2292
diff
changeset
|
4697 case 'k': |
fa8365fb6ac2
[PATCH 1/3] New option: vi_mode
Holger Weiß <holger@zedat.fu-berlin.de>
parents:
2292
diff
changeset
|
4698 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
|
4699 strlen(inputLine) <= 9) { |
2326
54b4272de463
Silence compiler warnings (-Wformat-truncation, -Wstringop-truncation)
Michał Kępień <bitbucket@kempniu.pl>
parents:
2325
diff
changeset
|
4700 char up_cmd[24]; |
54b4272de463
Silence compiler warnings (-Wformat-truncation, -Wstringop-truncation)
Michał Kępień <bitbucket@kempniu.pl>
parents:
2325
diff
changeset
|
4701 snprintf (up_cmd, sizeof(up_cmd), "%.11s%.9s", |
54b4272de463
Silence compiler warnings (-Wformat-truncation, -Wstringop-truncation)
Michał Kępień <bitbucket@kempniu.pl>
parents:
2325
diff
changeset
|
4702 mkcmdstr("roster up "), inputLine); |
2304
fa8365fb6ac2
[PATCH 1/3] New option: vi_mode
Holger Weiß <holger@zedat.fu-berlin.de>
parents:
2292
diff
changeset
|
4703 process_command(up_cmd, TRUE); |
fa8365fb6ac2
[PATCH 1/3] New option: vi_mode
Holger Weiß <holger@zedat.fu-berlin.de>
parents:
2292
diff
changeset
|
4704 } else |
fa8365fb6ac2
[PATCH 1/3] New option: vi_mode
Holger Weiß <holger@zedat.fu-berlin.de>
parents:
2292
diff
changeset
|
4705 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
|
4706 break; |
fa8365fb6ac2
[PATCH 1/3] New option: vi_mode
Holger Weiß <holger@zedat.fu-berlin.de>
parents:
2292
diff
changeset
|
4707 case 'M': |
fa8365fb6ac2
[PATCH 1/3] New option: vi_mode
Holger Weiß <holger@zedat.fu-berlin.de>
parents:
2292
diff
changeset
|
4708 if (inputLine[0] == 'z') { |
fa8365fb6ac2
[PATCH 1/3] New option: vi_mode
Holger Weiß <holger@zedat.fu-berlin.de>
parents:
2292
diff
changeset
|
4709 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
|
4710 GSList *g; |
fa8365fb6ac2
[PATCH 1/3] New option: vi_mode
Holger Weiß <holger@zedat.fu-berlin.de>
parents:
2292
diff
changeset
|
4711 |
fa8365fb6ac2
[PATCH 1/3] New option: vi_mode
Holger Weiß <holger@zedat.fu-berlin.de>
parents:
2292
diff
changeset
|
4712 for (g = groups; g; g = g_slist_next(g)) { |
2309
e00ae0763468
Do not use litteral command char (':', '/')
Mikael Berthe <mikael@lilotux.net>
parents:
2308
diff
changeset
|
4713 char fold_cmd[256]; |
e00ae0763468
Do not use litteral command char (':', '/')
Mikael Berthe <mikael@lilotux.net>
parents:
2308
diff
changeset
|
4714 size_t cmd_len, grp_len; |
e00ae0763468
Do not use litteral command char (':', '/')
Mikael Berthe <mikael@lilotux.net>
parents:
2308
diff
changeset
|
4715 |
e00ae0763468
Do not use litteral command char (':', '/')
Mikael Berthe <mikael@lilotux.net>
parents:
2308
diff
changeset
|
4716 strncpy(fold_cmd, mkcmdstr("group fold "), 32); |
e00ae0763468
Do not use litteral command char (':', '/')
Mikael Berthe <mikael@lilotux.net>
parents:
2308
diff
changeset
|
4717 cmd_len = strlen(fold_cmd); |
e00ae0763468
Do not use litteral command char (':', '/')
Mikael Berthe <mikael@lilotux.net>
parents:
2308
diff
changeset
|
4718 grp_len = strlen(g->data); |
2304
fa8365fb6ac2
[PATCH 1/3] New option: vi_mode
Holger Weiß <holger@zedat.fu-berlin.de>
parents:
2292
diff
changeset
|
4719 |
fa8365fb6ac2
[PATCH 1/3] New option: vi_mode
Holger Weiß <holger@zedat.fu-berlin.de>
parents:
2292
diff
changeset
|
4720 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
|
4721 continue; |
fa8365fb6ac2
[PATCH 1/3] New option: vi_mode
Holger Weiß <holger@zedat.fu-berlin.de>
parents:
2292
diff
changeset
|
4722 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
|
4723 process_command(fold_cmd, TRUE); |
fa8365fb6ac2
[PATCH 1/3] New option: vi_mode
Holger Weiß <holger@zedat.fu-berlin.de>
parents:
2292
diff
changeset
|
4724 g_free(g->data); |
fa8365fb6ac2
[PATCH 1/3] New option: vi_mode
Holger Weiß <holger@zedat.fu-berlin.de>
parents:
2292
diff
changeset
|
4725 } |
fa8365fb6ac2
[PATCH 1/3] New option: vi_mode
Holger Weiß <holger@zedat.fu-berlin.de>
parents:
2292
diff
changeset
|
4726 g_slist_free(groups); |
fa8365fb6ac2
[PATCH 1/3] New option: vi_mode
Holger Weiß <holger@zedat.fu-berlin.de>
parents:
2292
diff
changeset
|
4727 } else |
fa8365fb6ac2
[PATCH 1/3] New option: vi_mode
Holger Weiß <holger@zedat.fu-berlin.de>
parents:
2292
diff
changeset
|
4728 unrecognized = TRUE; |
fa8365fb6ac2
[PATCH 1/3] New option: vi_mode
Holger Weiß <holger@zedat.fu-berlin.de>
parents:
2292
diff
changeset
|
4729 break; |
fa8365fb6ac2
[PATCH 1/3] New option: vi_mode
Holger Weiß <holger@zedat.fu-berlin.de>
parents:
2292
diff
changeset
|
4730 case 'n': |
fa8365fb6ac2
[PATCH 1/3] New option: vi_mode
Holger Weiß <holger@zedat.fu-berlin.de>
parents:
2292
diff
changeset
|
4731 process_command(search_cmd, TRUE); |
fa8365fb6ac2
[PATCH 1/3] New option: vi_mode
Holger Weiß <holger@zedat.fu-berlin.de>
parents:
2292
diff
changeset
|
4732 break; |
fa8365fb6ac2
[PATCH 1/3] New option: vi_mode
Holger Weiß <holger@zedat.fu-berlin.de>
parents:
2292
diff
changeset
|
4733 case 'O': |
fa8365fb6ac2
[PATCH 1/3] New option: vi_mode
Holger Weiß <holger@zedat.fu-berlin.de>
parents:
2292
diff
changeset
|
4734 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
|
4735 open_chat_window(); |
fa8365fb6ac2
[PATCH 1/3] New option: vi_mode
Holger Weiß <holger@zedat.fu-berlin.de>
parents:
2292
diff
changeset
|
4736 break; |
fa8365fb6ac2
[PATCH 1/3] New option: vi_mode
Holger Weiß <holger@zedat.fu-berlin.de>
parents:
2292
diff
changeset
|
4737 case 'o': |
fa8365fb6ac2
[PATCH 1/3] New option: vi_mode
Holger Weiß <holger@zedat.fu-berlin.de>
parents:
2292
diff
changeset
|
4738 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
|
4739 open_chat_window(); |
fa8365fb6ac2
[PATCH 1/3] New option: vi_mode
Holger Weiß <holger@zedat.fu-berlin.de>
parents:
2292
diff
changeset
|
4740 break; |
fa8365fb6ac2
[PATCH 1/3] New option: vi_mode
Holger Weiß <holger@zedat.fu-berlin.de>
parents:
2292
diff
changeset
|
4741 case 'R': |
fa8365fb6ac2
[PATCH 1/3] New option: vi_mode
Holger Weiß <holger@zedat.fu-berlin.de>
parents:
2292
diff
changeset
|
4742 if (inputLine[0] == 'z') { |
fa8365fb6ac2
[PATCH 1/3] New option: vi_mode
Holger Weiß <holger@zedat.fu-berlin.de>
parents:
2292
diff
changeset
|
4743 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
|
4744 GSList *g; |
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 for (g = groups; g; g = g_slist_next(g)) { |
2309
e00ae0763468
Do not use litteral command char (':', '/')
Mikael Berthe <mikael@lilotux.net>
parents:
2308
diff
changeset
|
4747 char fold_cmd[256]; |
e00ae0763468
Do not use litteral command char (':', '/')
Mikael Berthe <mikael@lilotux.net>
parents:
2308
diff
changeset
|
4748 size_t cmd_len, grp_len; |
e00ae0763468
Do not use litteral command char (':', '/')
Mikael Berthe <mikael@lilotux.net>
parents:
2308
diff
changeset
|
4749 |
e00ae0763468
Do not use litteral command char (':', '/')
Mikael Berthe <mikael@lilotux.net>
parents:
2308
diff
changeset
|
4750 strncpy(fold_cmd, mkcmdstr("group unfold "), 32); |
e00ae0763468
Do not use litteral command char (':', '/')
Mikael Berthe <mikael@lilotux.net>
parents:
2308
diff
changeset
|
4751 cmd_len = strlen(fold_cmd); |
e00ae0763468
Do not use litteral command char (':', '/')
Mikael Berthe <mikael@lilotux.net>
parents:
2308
diff
changeset
|
4752 grp_len = strlen(g->data); |
2304
fa8365fb6ac2
[PATCH 1/3] New option: vi_mode
Holger Weiß <holger@zedat.fu-berlin.de>
parents:
2292
diff
changeset
|
4753 |
fa8365fb6ac2
[PATCH 1/3] New option: vi_mode
Holger Weiß <holger@zedat.fu-berlin.de>
parents:
2292
diff
changeset
|
4754 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
|
4755 continue; |
fa8365fb6ac2
[PATCH 1/3] New option: vi_mode
Holger Weiß <holger@zedat.fu-berlin.de>
parents:
2292
diff
changeset
|
4756 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
|
4757 process_command(fold_cmd, TRUE); |
fa8365fb6ac2
[PATCH 1/3] New option: vi_mode
Holger Weiß <holger@zedat.fu-berlin.de>
parents:
2292
diff
changeset
|
4758 g_free(g->data); |
fa8365fb6ac2
[PATCH 1/3] New option: vi_mode
Holger Weiß <holger@zedat.fu-berlin.de>
parents:
2292
diff
changeset
|
4759 } |
fa8365fb6ac2
[PATCH 1/3] New option: vi_mode
Holger Weiß <holger@zedat.fu-berlin.de>
parents:
2292
diff
changeset
|
4760 g_slist_free(groups); |
fa8365fb6ac2
[PATCH 1/3] New option: vi_mode
Holger Weiß <holger@zedat.fu-berlin.de>
parents:
2292
diff
changeset
|
4761 } else |
fa8365fb6ac2
[PATCH 1/3] New option: vi_mode
Holger Weiß <holger@zedat.fu-berlin.de>
parents:
2292
diff
changeset
|
4762 unrecognized = TRUE; |
fa8365fb6ac2
[PATCH 1/3] New option: vi_mode
Holger Weiß <holger@zedat.fu-berlin.de>
parents:
2292
diff
changeset
|
4763 break; |
fa8365fb6ac2
[PATCH 1/3] New option: vi_mode
Holger Weiß <holger@zedat.fu-berlin.de>
parents:
2292
diff
changeset
|
4764 case 'Z': |
fa8365fb6ac2
[PATCH 1/3] New option: vi_mode
Holger Weiß <holger@zedat.fu-berlin.de>
parents:
2292
diff
changeset
|
4765 if (inputLine[0] == 'Z') |
fa8365fb6ac2
[PATCH 1/3] New option: vi_mode
Holger Weiß <holger@zedat.fu-berlin.de>
parents:
2292
diff
changeset
|
4766 process_command(mkcmdstr("quit"), TRUE); |
fa8365fb6ac2
[PATCH 1/3] New option: vi_mode
Holger Weiß <holger@zedat.fu-berlin.de>
parents:
2292
diff
changeset
|
4767 else { |
fa8365fb6ac2
[PATCH 1/3] New option: vi_mode
Holger Weiß <holger@zedat.fu-berlin.de>
parents:
2292
diff
changeset
|
4768 clear_inputline(); |
fa8365fb6ac2
[PATCH 1/3] New option: vi_mode
Holger Weiß <holger@zedat.fu-berlin.de>
parents:
2292
diff
changeset
|
4769 got_cmd_prefix = TRUE; |
fa8365fb6ac2
[PATCH 1/3] New option: vi_mode
Holger Weiß <holger@zedat.fu-berlin.de>
parents:
2292
diff
changeset
|
4770 } |
fa8365fb6ac2
[PATCH 1/3] New option: vi_mode
Holger Weiß <holger@zedat.fu-berlin.de>
parents:
2292
diff
changeset
|
4771 break; |
fa8365fb6ac2
[PATCH 1/3] New option: vi_mode
Holger Weiß <holger@zedat.fu-berlin.de>
parents:
2292
diff
changeset
|
4772 case 'z': |
fa8365fb6ac2
[PATCH 1/3] New option: vi_mode
Holger Weiß <holger@zedat.fu-berlin.de>
parents:
2292
diff
changeset
|
4773 clear_inputline(); |
fa8365fb6ac2
[PATCH 1/3] New option: vi_mode
Holger Weiß <holger@zedat.fu-berlin.de>
parents:
2292
diff
changeset
|
4774 got_cmd_prefix = TRUE; |
fa8365fb6ac2
[PATCH 1/3] New option: vi_mode
Holger Weiß <holger@zedat.fu-berlin.de>
parents:
2292
diff
changeset
|
4775 break; |
fa8365fb6ac2
[PATCH 1/3] New option: vi_mode
Holger Weiß <holger@zedat.fu-berlin.de>
parents:
2292
diff
changeset
|
4776 case 13: // Enter |
fa8365fb6ac2
[PATCH 1/3] New option: vi_mode
Holger Weiß <holger@zedat.fu-berlin.de>
parents:
2292
diff
changeset
|
4777 case 343: // Enter on Maemo |
2308
e8c8665c824e
Let <Enter> (un)fold groups in vi mode
Holger Weiß <holger@zedat.fu-berlin.de>
parents:
2307
diff
changeset
|
4778 if (inputLine[0] == 0) { |
e8c8665c824e
Let <Enter> (un)fold groups in vi mode
Holger Weiß <holger@zedat.fu-berlin.de>
parents:
2307
diff
changeset
|
4779 if (buddy_gettype(BUDDATA(current_buddy)) == ROSTER_TYPE_GROUP) |
e8c8665c824e
Let <Enter> (un)fold groups in vi mode
Holger Weiß <holger@zedat.fu-berlin.de>
parents:
2307
diff
changeset
|
4780 process_command(mkcmdstr("group toggle"), TRUE); |
e8c8665c824e
Let <Enter> (un)fold groups in vi mode
Holger Weiß <holger@zedat.fu-berlin.de>
parents:
2307
diff
changeset
|
4781 else |
e8c8665c824e
Let <Enter> (un)fold groups in vi mode
Holger Weiß <holger@zedat.fu-berlin.de>
parents:
2307
diff
changeset
|
4782 open_chat_window(); |
e8c8665c824e
Let <Enter> (un)fold groups in vi mode
Holger Weiß <holger@zedat.fu-berlin.de>
parents:
2307
diff
changeset
|
4783 } |
2304
fa8365fb6ac2
[PATCH 1/3] New option: vi_mode
Holger Weiß <holger@zedat.fu-berlin.de>
parents:
2292
diff
changeset
|
4784 break; |
fa8365fb6ac2
[PATCH 1/3] New option: vi_mode
Holger Weiß <holger@zedat.fu-berlin.de>
parents:
2292
diff
changeset
|
4785 default: |
fa8365fb6ac2
[PATCH 1/3] New option: vi_mode
Holger Weiß <holger@zedat.fu-berlin.de>
parents:
2292
diff
changeset
|
4786 unrecognized = TRUE; |
fa8365fb6ac2
[PATCH 1/3] New option: vi_mode
Holger Weiß <holger@zedat.fu-berlin.de>
parents:
2292
diff
changeset
|
4787 break; |
fa8365fb6ac2
[PATCH 1/3] New option: vi_mode
Holger Weiß <holger@zedat.fu-berlin.de>
parents:
2292
diff
changeset
|
4788 } |
fa8365fb6ac2
[PATCH 1/3] New option: vi_mode
Holger Weiß <holger@zedat.fu-berlin.de>
parents:
2292
diff
changeset
|
4789 cmdhisto_cur = NULL; |
fa8365fb6ac2
[PATCH 1/3] New option: vi_mode
Holger Weiß <holger@zedat.fu-berlin.de>
parents:
2292
diff
changeset
|
4790 } |
fa8365fb6ac2
[PATCH 1/3] New option: vi_mode
Holger Weiß <holger@zedat.fu-berlin.de>
parents:
2292
diff
changeset
|
4791 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
|
4792 clear_inputline(); |
fa8365fb6ac2
[PATCH 1/3] New option: vi_mode
Holger Weiß <holger@zedat.fu-berlin.de>
parents:
2292
diff
changeset
|
4793 if (!unrecognized) |
fa8365fb6ac2
[PATCH 1/3] New option: vi_mode
Holger Weiß <holger@zedat.fu-berlin.de>
parents:
2292
diff
changeset
|
4794 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
|
4795 } |
fa8365fb6ac2
[PATCH 1/3] New option: vi_mode
Holger Weiß <holger@zedat.fu-berlin.de>
parents:
2292
diff
changeset
|
4796 lock_chatstate = TRUE; |
fa8365fb6ac2
[PATCH 1/3] New option: vi_mode
Holger Weiß <holger@zedat.fu-berlin.de>
parents:
2292
diff
changeset
|
4797 } |
fa8365fb6ac2
[PATCH 1/3] New option: vi_mode
Holger Weiß <holger@zedat.fu-berlin.de>
parents:
2292
diff
changeset
|
4798 |
931
1cd6d694ac3c
Fix display of some UTF-8 chars
Mikael Berthe <mikael@lilotux.net>
parents:
930
diff
changeset
|
4799 if (kcode.utf8) { |
1cd6d694ac3c
Fix display of some UTF-8 chars
Mikael Berthe <mikael@lilotux.net>
parents:
930
diff
changeset
|
4800 if (key != ERR && !kcode.mcode) |
1cd6d694ac3c
Fix display of some UTF-8 chars
Mikael Berthe <mikael@lilotux.net>
parents:
930
diff
changeset
|
4801 display_char = TRUE; |
1cd6d694ac3c
Fix display of some UTF-8 chars
Mikael Berthe <mikael@lilotux.net>
parents:
930
diff
changeset
|
4802 goto display; |
1cd6d694ac3c
Fix display of some UTF-8 chars
Mikael Berthe <mikael@lilotux.net>
parents:
930
diff
changeset
|
4803 } |
1cd6d694ac3c
Fix display of some UTF-8 chars
Mikael Berthe <mikael@lilotux.net>
parents:
930
diff
changeset
|
4804 |
758 | 4805 switch (key) { |
761
4532a9fe0e8c
Handle some keyboard escape sequences
Mikael Berthe <mikael@lilotux.net>
parents:
760
diff
changeset
|
4806 case 0: |
4532a9fe0e8c
Handle some keyboard escape sequences
Mikael Berthe <mikael@lilotux.net>
parents:
760
diff
changeset
|
4807 case ERR: |
758 | 4808 break; |
1173
960f34ec22a2
Add init_bindings() for default key bindings (Lego12239)
Mikael Berthe <mikael@lilotux.net>
parents:
1172
diff
changeset
|
4809 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
|
4810 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
|
4811 readline_do_completion(TRUE); // Forward-completion |
2143
2f294c2b6778
Add a backward completion (Oleg)
Mikael Berthe <mikael@lilotux.net>
parents:
2136
diff
changeset
|
4812 break; |
2f294c2b6778
Add a backward completion (Oleg)
Mikael Berthe <mikael@lilotux.net>
parents:
2136
diff
changeset
|
4813 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
|
4814 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
|
4815 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
|
4816 break; |
960f34ec22a2
Add init_bindings() for default key bindings (Lego12239)
Mikael Berthe <mikael@lilotux.net>
parents:
1172
diff
changeset
|
4817 case 13: // Enter |
1935
a06d9eab14c5
Handle the Enter key on Maemo systems (diSabler)
Mikael Berthe <mikael@lilotux.net>
parents:
1927
diff
changeset
|
4818 case 343: // Enter on Maemo |
2164 | 4819 readline_accept_line(FALSE); |
1173
960f34ec22a2
Add init_bindings() for default key bindings (Lego12239)
Mikael Berthe <mikael@lilotux.net>
parents:
1172
diff
changeset
|
4820 break; |
960f34ec22a2
Add init_bindings() for default key bindings (Lego12239)
Mikael Berthe <mikael@lilotux.net>
parents:
1172
diff
changeset
|
4821 case 3: // Ctrl-C |
960f34ec22a2
Add init_bindings() for default key bindings (Lego12239)
Mikael Berthe <mikael@lilotux.net>
parents:
1172
diff
changeset
|
4822 scr_handle_CtrlC(); |
960f34ec22a2
Add init_bindings() for default key bindings (Lego12239)
Mikael Berthe <mikael@lilotux.net>
parents:
1172
diff
changeset
|
4823 break; |
960f34ec22a2
Add init_bindings() for default key bindings (Lego12239)
Mikael Berthe <mikael@lilotux.net>
parents:
1172
diff
changeset
|
4824 case KEY_RESIZE: |
2231
387cea2a1a81
Fix resizing with --enable-sigwinch
Mikael Berthe <mikael@lilotux.net>
parents:
2226
diff
changeset
|
4825 scr_resize(); |
1173
960f34ec22a2
Add init_bindings() for default key bindings (Lego12239)
Mikael Berthe <mikael@lilotux.net>
parents:
1172
diff
changeset
|
4826 break; |
499
baa812f04f24
Reorganise process_key()
Mikael Berthe <mikael@lilotux.net>
parents:
480
diff
changeset
|
4827 default: |
931
1cd6d694ac3c
Fix display of some UTF-8 chars
Mikael Berthe <mikael@lilotux.net>
parents:
930
diff
changeset
|
4828 display_char = TRUE; |
1cd6d694ac3c
Fix display of some UTF-8 chars
Mikael Berthe <mikael@lilotux.net>
parents:
930
diff
changeset
|
4829 } // switch |
263 | 4830 |
931
1cd6d694ac3c
Fix display of some UTF-8 chars
Mikael Berthe <mikael@lilotux.net>
parents:
930
diff
changeset
|
4831 display: |
1cd6d694ac3c
Fix display of some UTF-8 chars
Mikael Berthe <mikael@lilotux.net>
parents:
930
diff
changeset
|
4832 if (display_char) { |
1394 | 4833 guint printable; |
4834 | |
4835 if (kcode.utf8) { | |
4836 printable = iswprint(key); | |
4837 } else { | |
4838 #ifdef __CYGWIN__ | |
4839 printable = (isprint(key) || (key >= 161 && key <= 255)) | |
4840 && !is_speckey(key); | |
4841 #else | |
4842 printable = isprint(key) && !is_speckey(key); | |
4843 #endif | |
4844 } | |
4845 if (printable) { | |
931
1cd6d694ac3c
Fix display of some UTF-8 chars
Mikael Berthe <mikael@lilotux.net>
parents:
930
diff
changeset
|
4846 char tmpLine[INPUTLINE_LENGTH+1]; |
499
baa812f04f24
Reorganise process_key()
Mikael Berthe <mikael@lilotux.net>
parents:
480
diff
changeset
|
4847 |
931
1cd6d694ac3c
Fix display of some UTF-8 chars
Mikael Berthe <mikael@lilotux.net>
parents:
930
diff
changeset
|
4848 // Check the line isn't too long |
1cd6d694ac3c
Fix display of some UTF-8 chars
Mikael Berthe <mikael@lilotux.net>
parents:
930
diff
changeset
|
4849 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
|
4850 return; |
931
1cd6d694ac3c
Fix display of some UTF-8 chars
Mikael Berthe <mikael@lilotux.net>
parents:
930
diff
changeset
|
4851 |
1cd6d694ac3c
Fix display of some UTF-8 chars
Mikael Berthe <mikael@lilotux.net>
parents:
930
diff
changeset
|
4852 // Insert char |
1cd6d694ac3c
Fix display of some UTF-8 chars
Mikael Berthe <mikael@lilotux.net>
parents:
930
diff
changeset
|
4853 strcpy(tmpLine, ptr_inputline); |
1cd6d694ac3c
Fix display of some UTF-8 chars
Mikael Berthe <mikael@lilotux.net>
parents:
930
diff
changeset
|
4854 ptr_inputline = put_char(ptr_inputline, key); |
1cd6d694ac3c
Fix display of some UTF-8 chars
Mikael Berthe <mikael@lilotux.net>
parents:
930
diff
changeset
|
4855 strcpy(ptr_inputline, tmpLine); |
1cd6d694ac3c
Fix display of some UTF-8 chars
Mikael Berthe <mikael@lilotux.net>
parents:
930
diff
changeset
|
4856 check_offset(1); |
1cd6d694ac3c
Fix display of some UTF-8 chars
Mikael Berthe <mikael@lilotux.net>
parents:
930
diff
changeset
|
4857 } else { |
1cd6d694ac3c
Fix display of some UTF-8 chars
Mikael Berthe <mikael@lilotux.net>
parents:
930
diff
changeset
|
4858 // Look for a key binding. |
2164 | 4859 if (!kcode.utf8) |
4860 bindcommand(kcode); | |
931
1cd6d694ac3c
Fix display of some UTF-8 chars
Mikael Berthe <mikael@lilotux.net>
parents:
930
diff
changeset
|
4861 } |
24 | 4862 } |
499
baa812f04f24
Reorganise process_key()
Mikael Berthe <mikael@lilotux.net>
parents:
480
diff
changeset
|
4863 |
2143
2f294c2b6778
Add a backward completion (Oleg)
Mikael Berthe <mikael@lilotux.net>
parents:
2136
diff
changeset
|
4864 if (completion_started && key != 9 && key != 353 && key != KEY_RESIZE) |
98 | 4865 scr_end_current_completion(); |
312
f0b7ff2df7e8
Ctrl-C does not terminate mcabber
Mikael Berthe <mikael@lilotux.net>
parents:
307
diff
changeset
|
4866 refresh_inputline(); |
990
35e7913affb7
Send events/chatstates notifications (JEP-22/JEP-85)
Mikael Berthe <mikael@lilotux.net>
parents:
987
diff
changeset
|
4867 |
2309
e00ae0763468
Do not use litteral command char (':', '/')
Mikael Berthe <mikael@lilotux.net>
parents:
2308
diff
changeset
|
4868 if (ex_or_search_mode && |
e00ae0763468
Do not use litteral command char (':', '/')
Mikael Berthe <mikael@lilotux.net>
parents:
2308
diff
changeset
|
4869 inputLine[0] != COMMAND_CHAR && inputLine[0] != VI_SEARCH_COMMAND_CHAR) |
2304
fa8365fb6ac2
[PATCH 1/3] New option: vi_mode
Holger Weiß <holger@zedat.fu-berlin.de>
parents:
2292
diff
changeset
|
4870 ex_or_search_mode = FALSE; |
fa8365fb6ac2
[PATCH 1/3] New option: vi_mode
Holger Weiß <holger@zedat.fu-berlin.de>
parents:
2292
diff
changeset
|
4871 |
990
35e7913affb7
Send events/chatstates notifications (JEP-22/JEP-85)
Mikael Berthe <mikael@lilotux.net>
parents:
987
diff
changeset
|
4872 if (!lock_chatstate) { |
997 | 4873 // Set chat state to composing (1) if the user is currently composing, |
4874 // 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
|
4875 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
|
4876 set_chatstate(0); |
35e7913affb7
Send events/chatstates notifications (JEP-22/JEP-85)
Mikael Berthe <mikael@lilotux.net>
parents:
987
diff
changeset
|
4877 else |
35e7913affb7
Send events/chatstates notifications (JEP-22/JEP-85)
Mikael Berthe <mikael@lilotux.net>
parents:
987
diff
changeset
|
4878 set_chatstate(1); |
991
ef10906691bb
Chatstates: add composing timeout
Mikael Berthe <mikael@lilotux.net>
parents:
990
diff
changeset
|
4879 if (chatstate) |
ef10906691bb
Chatstates: add composing timeout
Mikael Berthe <mikael@lilotux.net>
parents:
990
diff
changeset
|
4880 time(&chatstate_timestamp); |
990
35e7913affb7
Send events/chatstates notifications (JEP-22/JEP-85)
Mikael Berthe <mikael@lilotux.net>
parents:
987
diff
changeset
|
4881 } |
1359
7daf906fbcdc
The command /quit can be used in bindings, hooks and sourced files
Mikael Berthe <mikael@lilotux.net>
parents:
1357
diff
changeset
|
4882 return; |
24 | 4883 } |
576 | 4884 |
1590
8d1bcc83ae32
Add support for spellchecking with Enchant (caolan)
Mikael Berthe <mikael@lilotux.net>
parents:
1579
diff
changeset
|
4885 #if defined(WITH_ENCHANT) || defined(WITH_ASPELL) |
2170
282531385f34
Multilanguage spell checking
Dmitry Potapov <potapov.d@gmail.com>
parents:
2165
diff
changeset
|
4886 static void spell_checker_free(gpointer data) |
282531385f34
Multilanguage spell checking
Dmitry Potapov <potapov.d@gmail.com>
parents:
2165
diff
changeset
|
4887 { |
2337 | 4888 spell_checker_t *sc = data; |
2170
282531385f34
Multilanguage spell checking
Dmitry Potapov <potapov.d@gmail.com>
parents:
2165
diff
changeset
|
4889 #ifdef WITH_ENCHANT |
282531385f34
Multilanguage spell checking
Dmitry Potapov <potapov.d@gmail.com>
parents:
2165
diff
changeset
|
4890 enchant_broker_free_dict(sc->broker, sc->checker); |
282531385f34
Multilanguage spell checking
Dmitry Potapov <potapov.d@gmail.com>
parents:
2165
diff
changeset
|
4891 enchant_broker_free(sc->broker); |
282531385f34
Multilanguage spell checking
Dmitry Potapov <potapov.d@gmail.com>
parents:
2165
diff
changeset
|
4892 #endif |
282531385f34
Multilanguage spell checking
Dmitry Potapov <potapov.d@gmail.com>
parents:
2165
diff
changeset
|
4893 #ifdef WITH_ASPELL |
282531385f34
Multilanguage spell checking
Dmitry Potapov <potapov.d@gmail.com>
parents:
2165
diff
changeset
|
4894 delete_aspell_speller(sc->checker); |
282531385f34
Multilanguage spell checking
Dmitry Potapov <potapov.d@gmail.com>
parents:
2165
diff
changeset
|
4895 delete_aspell_config(sc->config); |
282531385f34
Multilanguage spell checking
Dmitry Potapov <potapov.d@gmail.com>
parents:
2165
diff
changeset
|
4896 #endif |
282531385f34
Multilanguage spell checking
Dmitry Potapov <potapov.d@gmail.com>
parents:
2165
diff
changeset
|
4897 g_free(sc); |
282531385f34
Multilanguage spell checking
Dmitry Potapov <potapov.d@gmail.com>
parents:
2165
diff
changeset
|
4898 } |
282531385f34
Multilanguage spell checking
Dmitry Potapov <potapov.d@gmail.com>
parents:
2165
diff
changeset
|
4899 |
2337 | 4900 static spell_checker_t* new_spell_checker(const char* spell_lang) |
2170
282531385f34
Multilanguage spell checking
Dmitry Potapov <potapov.d@gmail.com>
parents:
2165
diff
changeset
|
4901 { |
2337 | 4902 spell_checker_t *sc = g_new(spell_checker_t, 1); |
2170
282531385f34
Multilanguage spell checking
Dmitry Potapov <potapov.d@gmail.com>
parents:
2165
diff
changeset
|
4903 #ifdef WITH_ASPELL |
282531385f34
Multilanguage spell checking
Dmitry Potapov <potapov.d@gmail.com>
parents:
2165
diff
changeset
|
4904 const char *spell_encoding = settings_opt_get("spell_encoding"); |
282531385f34
Multilanguage spell checking
Dmitry Potapov <potapov.d@gmail.com>
parents:
2165
diff
changeset
|
4905 AspellCanHaveError *possible_err; |
282531385f34
Multilanguage spell checking
Dmitry Potapov <potapov.d@gmail.com>
parents:
2165
diff
changeset
|
4906 sc->config = new_aspell_config(); |
282531385f34
Multilanguage spell checking
Dmitry Potapov <potapov.d@gmail.com>
parents:
2165
diff
changeset
|
4907 if (spell_encoding) |
282531385f34
Multilanguage spell checking
Dmitry Potapov <potapov.d@gmail.com>
parents:
2165
diff
changeset
|
4908 aspell_config_replace(sc->config, "encoding", spell_encoding); |
282531385f34
Multilanguage spell checking
Dmitry Potapov <potapov.d@gmail.com>
parents:
2165
diff
changeset
|
4909 aspell_config_replace(sc->config, "lang", spell_lang); |
282531385f34
Multilanguage spell checking
Dmitry Potapov <potapov.d@gmail.com>
parents:
2165
diff
changeset
|
4910 possible_err = new_aspell_speller(sc->config); |
282531385f34
Multilanguage spell checking
Dmitry Potapov <potapov.d@gmail.com>
parents:
2165
diff
changeset
|
4911 |
282531385f34
Multilanguage spell checking
Dmitry Potapov <potapov.d@gmail.com>
parents:
2165
diff
changeset
|
4912 if (aspell_error_number(possible_err) != 0) { |
282531385f34
Multilanguage spell checking
Dmitry Potapov <potapov.d@gmail.com>
parents:
2165
diff
changeset
|
4913 delete_aspell_config(sc->config); |
282531385f34
Multilanguage spell checking
Dmitry Potapov <potapov.d@gmail.com>
parents:
2165
diff
changeset
|
4914 g_free(sc); |
282531385f34
Multilanguage spell checking
Dmitry Potapov <potapov.d@gmail.com>
parents:
2165
diff
changeset
|
4915 sc = NULL; |
282531385f34
Multilanguage spell checking
Dmitry Potapov <potapov.d@gmail.com>
parents:
2165
diff
changeset
|
4916 } else { |
282531385f34
Multilanguage spell checking
Dmitry Potapov <potapov.d@gmail.com>
parents:
2165
diff
changeset
|
4917 sc->checker = to_aspell_speller(possible_err); |
282531385f34
Multilanguage spell checking
Dmitry Potapov <potapov.d@gmail.com>
parents:
2165
diff
changeset
|
4918 } |
282531385f34
Multilanguage spell checking
Dmitry Potapov <potapov.d@gmail.com>
parents:
2165
diff
changeset
|
4919 #endif |
282531385f34
Multilanguage spell checking
Dmitry Potapov <potapov.d@gmail.com>
parents:
2165
diff
changeset
|
4920 #ifdef WITH_ENCHANT |
282531385f34
Multilanguage spell checking
Dmitry Potapov <potapov.d@gmail.com>
parents:
2165
diff
changeset
|
4921 sc->broker = enchant_broker_init(); |
282531385f34
Multilanguage spell checking
Dmitry Potapov <potapov.d@gmail.com>
parents:
2165
diff
changeset
|
4922 sc->checker = enchant_broker_request_dict(sc->broker, spell_lang); |
282531385f34
Multilanguage spell checking
Dmitry Potapov <potapov.d@gmail.com>
parents:
2165
diff
changeset
|
4923 if (!sc->checker) { |
282531385f34
Multilanguage spell checking
Dmitry Potapov <potapov.d@gmail.com>
parents:
2165
diff
changeset
|
4924 enchant_broker_free(sc->broker); |
282531385f34
Multilanguage spell checking
Dmitry Potapov <potapov.d@gmail.com>
parents:
2165
diff
changeset
|
4925 g_free(sc); |
282531385f34
Multilanguage spell checking
Dmitry Potapov <potapov.d@gmail.com>
parents:
2165
diff
changeset
|
4926 sc = NULL; |
282531385f34
Multilanguage spell checking
Dmitry Potapov <potapov.d@gmail.com>
parents:
2165
diff
changeset
|
4927 } |
282531385f34
Multilanguage spell checking
Dmitry Potapov <potapov.d@gmail.com>
parents:
2165
diff
changeset
|
4928 #endif |
282531385f34
Multilanguage spell checking
Dmitry Potapov <potapov.d@gmail.com>
parents:
2165
diff
changeset
|
4929 return sc; |
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 |
1590
8d1bcc83ae32
Add support for spellchecking with Enchant (caolan)
Mikael Berthe <mikael@lilotux.net>
parents:
1579
diff
changeset
|
4932 // initialization |
1179 | 4933 void spellcheck_init(void) |
4934 { | |
1590
8d1bcc83ae32
Add support for spellchecking with Enchant (caolan)
Mikael Berthe <mikael@lilotux.net>
parents:
1579
diff
changeset
|
4935 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
|
4936 const char *spell_lang = settings_opt_get("spell_lang"); |
2337 | 4937 gchar **langs; |
4938 gchar **lang_iter; | |
4939 spell_checker_t *sc; | |
1590
8d1bcc83ae32
Add support for spellchecking with Enchant (caolan)
Mikael Berthe <mikael@lilotux.net>
parents:
1579
diff
changeset
|
4940 |
8d1bcc83ae32
Add support for spellchecking with Enchant (caolan)
Mikael Berthe <mikael@lilotux.net>
parents:
1579
diff
changeset
|
4941 if (!spell_enable) |
1179 | 4942 return; |
4943 | |
2170
282531385f34
Multilanguage spell checking
Dmitry Potapov <potapov.d@gmail.com>
parents:
2165
diff
changeset
|
4944 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
|
4945 |
db8ec238cd2c
Fix segfault when spell checking is enabled and spell_lang is not set.
Mikael Berthe <mikael@lilotux.net>
parents:
2013
diff
changeset
|
4946 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
|
4947 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
|
4948 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
|
4949 return; |
db8ec238cd2c
Fix segfault when spell checking is enabled and spell_lang is not set.
Mikael Berthe <mikael@lilotux.net>
parents:
2013
diff
changeset
|
4950 } |
db8ec238cd2c
Fix segfault when spell checking is enabled and spell_lang is not set.
Mikael Berthe <mikael@lilotux.net>
parents:
2013
diff
changeset
|
4951 |
2170
282531385f34
Multilanguage spell checking
Dmitry Potapov <potapov.d@gmail.com>
parents:
2165
diff
changeset
|
4952 langs = g_strsplit(spell_lang, " ", -1); |
282531385f34
Multilanguage spell checking
Dmitry Potapov <potapov.d@gmail.com>
parents:
2165
diff
changeset
|
4953 for (lang_iter = langs; *lang_iter; ++lang_iter) { |
282531385f34
Multilanguage spell checking
Dmitry Potapov <potapov.d@gmail.com>
parents:
2165
diff
changeset
|
4954 if (**lang_iter) { // Skip empty strings |
282531385f34
Multilanguage spell checking
Dmitry Potapov <potapov.d@gmail.com>
parents:
2165
diff
changeset
|
4955 sc = new_spell_checker(*lang_iter); |
282531385f34
Multilanguage spell checking
Dmitry Potapov <potapov.d@gmail.com>
parents:
2165
diff
changeset
|
4956 if (sc) { |
282531385f34
Multilanguage spell checking
Dmitry Potapov <potapov.d@gmail.com>
parents:
2165
diff
changeset
|
4957 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
|
4958 } else { |
46d1182d45be
Spell checking: Fix wrong highlighting when no language can be used
Mikael Berthe <mikael@lilotux.net>
parents:
2170
diff
changeset
|
4959 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
|
4960 "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
|
4961 *lang_iter); |
2170
282531385f34
Multilanguage spell checking
Dmitry Potapov <potapov.d@gmail.com>
parents:
2165
diff
changeset
|
4962 } |
282531385f34
Multilanguage spell checking
Dmitry Potapov <potapov.d@gmail.com>
parents:
2165
diff
changeset
|
4963 } |
1179 | 4964 } |
2170
282531385f34
Multilanguage spell checking
Dmitry Potapov <potapov.d@gmail.com>
parents:
2165
diff
changeset
|
4965 g_strfreev(langs); |
1179 | 4966 } |
4967 | |
1590
8d1bcc83ae32
Add support for spellchecking with Enchant (caolan)
Mikael Berthe <mikael@lilotux.net>
parents:
1579
diff
changeset
|
4968 // Deinitialization of spellchecker |
1179 | 4969 void spellcheck_deinit(void) |
4970 { | |
2313
70f8ae7d690e
Do not use g_slist_free_full() which requires glib2 2.28.0 (Frank Bergmann)
Mikael Berthe <mikael@lilotux.net>
parents:
2312
diff
changeset
|
4971 g_slist_foreach (spell_checkers, (GFunc) spell_checker_free, NULL); |
70f8ae7d690e
Do not use g_slist_free_full() which requires glib2 2.28.0 (Frank Bergmann)
Mikael Berthe <mikael@lilotux.net>
parents:
2312
diff
changeset
|
4972 g_slist_free (spell_checkers); |
2170
282531385f34
Multilanguage spell checking
Dmitry Potapov <potapov.d@gmail.com>
parents:
2165
diff
changeset
|
4973 spell_checkers = NULL; |
282531385f34
Multilanguage spell checking
Dmitry Potapov <potapov.d@gmail.com>
parents:
2165
diff
changeset
|
4974 } |
282531385f34
Multilanguage spell checking
Dmitry Potapov <potapov.d@gmail.com>
parents:
2165
diff
changeset
|
4975 |
282531385f34
Multilanguage spell checking
Dmitry Potapov <potapov.d@gmail.com>
parents:
2165
diff
changeset
|
4976 typedef struct { |
282531385f34
Multilanguage spell checking
Dmitry Potapov <potapov.d@gmail.com>
parents:
2165
diff
changeset
|
4977 const char* str; |
282531385f34
Multilanguage spell checking
Dmitry Potapov <potapov.d@gmail.com>
parents:
2165
diff
changeset
|
4978 int len; |
2337 | 4979 } spell_substring_t; |
2170
282531385f34
Multilanguage spell checking
Dmitry Potapov <potapov.d@gmail.com>
parents:
2165
diff
changeset
|
4980 |
282531385f34
Multilanguage spell checking
Dmitry Potapov <potapov.d@gmail.com>
parents:
2165
diff
changeset
|
4981 static int spellcheckword(gconstpointer sc_ptr, gconstpointer substr_ptr) |
282531385f34
Multilanguage spell checking
Dmitry Potapov <potapov.d@gmail.com>
parents:
2165
diff
changeset
|
4982 { |
2337 | 4983 spell_checker_t *sc = (spell_checker_t*) sc_ptr; |
4984 spell_substring_t *substr = (spell_substring_t*) substr_ptr; | |
1590
8d1bcc83ae32
Add support for spellchecking with Enchant (caolan)
Mikael Berthe <mikael@lilotux.net>
parents:
1579
diff
changeset
|
4985 #ifdef WITH_ENCHANT |
2170
282531385f34
Multilanguage spell checking
Dmitry Potapov <potapov.d@gmail.com>
parents:
2165
diff
changeset
|
4986 // enchant_dict_check will return 0 on good word |
282531385f34
Multilanguage spell checking
Dmitry Potapov <potapov.d@gmail.com>
parents:
2165
diff
changeset
|
4987 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
|
4988 #endif |
8d1bcc83ae32
Add support for spellchecking with Enchant (caolan)
Mikael Berthe <mikael@lilotux.net>
parents:
1579
diff
changeset
|
4989 #ifdef WITH_ASPELL |
2170
282531385f34
Multilanguage spell checking
Dmitry Potapov <potapov.d@gmail.com>
parents:
2165
diff
changeset
|
4990 // 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
|
4991 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
|
4992 #endif |
2170
282531385f34
Multilanguage spell checking
Dmitry Potapov <potapov.d@gmail.com>
parents:
2165
diff
changeset
|
4993 return 0; // Keep compiler happy |
1179 | 4994 } |
4995 | |
1590
8d1bcc83ae32
Add support for spellchecking with Enchant (caolan)
Mikael Berthe <mikael@lilotux.net>
parents:
1579
diff
changeset
|
4996 #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
|
4997 |
1179 | 4998 // Spell checking function |
4999 static void spellcheck(char *line, char *checked) | |
5000 { | |
5001 const char *start, *line_start; | |
2337 | 5002 spell_substring_t substr; |
1179 | 5003 |
5004 if (inputLine[0] == 0 || inputLine[0] == COMMAND_CHAR) | |
5005 return; | |
5006 | |
2171
46d1182d45be
Spell checking: Fix wrong highlighting when no language can be used
Mikael Berthe <mikael@lilotux.net>
parents:
2170
diff
changeset
|
5007 // 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
|
5008 if (!spell_checkers) |
46d1182d45be
Spell checking: Fix wrong highlighting when no language can be used
Mikael Berthe <mikael@lilotux.net>
parents:
2170
diff
changeset
|
5009 return; |
46d1182d45be
Spell checking: Fix wrong highlighting when no language can be used
Mikael Berthe <mikael@lilotux.net>
parents:
2170
diff
changeset
|
5010 |
1179 | 5011 line_start = line; |
5012 | |
5013 while (*line) { | |
5014 | |
1590
8d1bcc83ae32
Add support for spellchecking with Enchant (caolan)
Mikael Berthe <mikael@lilotux.net>
parents:
1579
diff
changeset
|
5015 if (!spell_isalpha(line)) { |
1179 | 5016 line = next_char(line); |
5017 continue; | |
5018 } | |
5019 | |
5020 if (!strncmp(line, "http://", 7)) { | |
5021 line += 7; // : and / characters are 1 byte long in utf8, right? | |
5022 | |
5023 while (!strchr(" \t\r\n", *line)) | |
5024 line = next_char(line); // i think line++ would be fine here? | |
5025 | |
5026 continue; | |
5027 } | |
5028 | |
5029 if (!strncmp(line, "ftp://", 6)) { | |
5030 line += 6; | |
5031 | |
5032 while (!strchr(" \t\r\n", *line)) | |
5033 line = next_char(line); | |
5034 | |
5035 continue; | |
5036 } | |
5037 | |
5038 start = line; | |
5039 | |
1590
8d1bcc83ae32
Add support for spellchecking with Enchant (caolan)
Mikael Berthe <mikael@lilotux.net>
parents:
1579
diff
changeset
|
5040 while (spell_isalpha(line)) |
1179 | 5041 line = next_char(line); |
5042 | |
2170
282531385f34
Multilanguage spell checking
Dmitry Potapov <potapov.d@gmail.com>
parents:
2165
diff
changeset
|
5043 substr.str = start; |
282531385f34
Multilanguage spell checking
Dmitry Potapov <potapov.d@gmail.com>
parents:
2165
diff
changeset
|
5044 substr.len = line - start; |
282531385f34
Multilanguage spell checking
Dmitry Potapov <potapov.d@gmail.com>
parents:
2165
diff
changeset
|
5045 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
|
5046 memset(&checked[start - line_start], SPELLBADCHAR, line - start); |
1179 | 5047 } |
5048 } | |
5049 #endif | |
5050 | |
2304
fa8365fb6ac2
[PATCH 1/3] New option: vi_mode
Holger Weiß <holger@zedat.fu-berlin.de>
parents:
2292
diff
changeset
|
5051 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
|
5052 { |
fa8365fb6ac2
[PATCH 1/3] New option: vi_mode
Holger Weiß <holger@zedat.fu-berlin.de>
parents:
2292
diff
changeset
|
5053 last_activity_buddy = current_buddy; |
fa8365fb6ac2
[PATCH 1/3] New option: vi_mode
Holger Weiß <holger@zedat.fu-berlin.de>
parents:
2292
diff
changeset
|
5054 scr_check_auto_away(TRUE); |
fa8365fb6ac2
[PATCH 1/3] New option: vi_mode
Holger Weiß <holger@zedat.fu-berlin.de>
parents:
2292
diff
changeset
|
5055 scr_set_chatmode(TRUE); |
fa8365fb6ac2
[PATCH 1/3] New option: vi_mode
Holger Weiß <holger@zedat.fu-berlin.de>
parents:
2292
diff
changeset
|
5056 scr_show_buddy_window(); |
fa8365fb6ac2
[PATCH 1/3] New option: vi_mode
Holger Weiß <holger@zedat.fu-berlin.de>
parents:
2292
diff
changeset
|
5057 } |
fa8365fb6ac2
[PATCH 1/3] New option: vi_mode
Holger Weiß <holger@zedat.fu-berlin.de>
parents:
2292
diff
changeset
|
5058 |
fa8365fb6ac2
[PATCH 1/3] New option: vi_mode
Holger Weiß <holger@zedat.fu-berlin.de>
parents:
2292
diff
changeset
|
5059 static void clear_inputline(void) |
fa8365fb6ac2
[PATCH 1/3] New option: vi_mode
Holger Weiß <holger@zedat.fu-berlin.de>
parents:
2292
diff
changeset
|
5060 { |
fa8365fb6ac2
[PATCH 1/3] New option: vi_mode
Holger Weiß <holger@zedat.fu-berlin.de>
parents:
2292
diff
changeset
|
5061 ptr_inputline = inputLine; |
fa8365fb6ac2
[PATCH 1/3] New option: vi_mode
Holger Weiß <holger@zedat.fu-berlin.de>
parents:
2292
diff
changeset
|
5062 *ptr_inputline = 0; |
fa8365fb6ac2
[PATCH 1/3] New option: vi_mode
Holger Weiß <holger@zedat.fu-berlin.de>
parents:
2292
diff
changeset
|
5063 inputline_offset = 0; |
fa8365fb6ac2
[PATCH 1/3] New option: vi_mode
Holger Weiß <holger@zedat.fu-berlin.de>
parents:
2292
diff
changeset
|
5064 } |
fa8365fb6ac2
[PATCH 1/3] New option: vi_mode
Holger Weiß <holger@zedat.fu-berlin.de>
parents:
2292
diff
changeset
|
5065 |
1811 | 5066 /* vim: set et cindent cinoptions=>2\:2(0 ts=2 sw=2: For Vim users... */ |