Mercurial > hg
annotate mcabber/mcabber/screen.c @ 2170:282531385f34
Multilanguage spell checking
author | Dmitry Potapov <potapov.d@gmail.com> |
---|---|
date | Sun, 15 Feb 2015 16:23:30 +0100 |
parents | db6ca1e1e082 |
children | 46d1182d45be |
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 | |
18 * along with this program; if not, write to the Free Software | |
19 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 | |
20 * USA | |
21 */ | |
22 | |
24 | 23 #include <stdio.h> |
24 #include <stdlib.h> | |
25 #include <string.h> | |
26 #include <time.h> | |
27 #include <ctype.h> | |
1382
1447c5296977
Fix locale charset detection on some BSD systems
Mikael Berthe <mikael@lilotux.net>
parents:
1381
diff
changeset
|
28 |
1447c5296977
Fix locale charset detection on some BSD systems
Mikael Berthe <mikael@lilotux.net>
parents:
1381
diff
changeset
|
29 #include <config.h> |
24 | 30 #include <locale.h> |
1292
382ec54b584e
Muc nick coloring functionality
Michal 'vorner' Vaner <vorner@ucw.cz>
parents:
1291
diff
changeset
|
31 #include <assert.h> |
1454
6b98dc22946d
Add optional SIGWINCH handler (Markus Hennecke)
Mikael Berthe <mikael@lilotux.net>
parents:
1424
diff
changeset
|
32 #ifdef USE_SIGWINCH |
6b98dc22946d
Add optional SIGWINCH handler (Markus Hennecke)
Mikael Berthe <mikael@lilotux.net>
parents:
1424
diff
changeset
|
33 # include <sys/ioctl.h> |
6b98dc22946d
Add optional SIGWINCH handler (Markus Hennecke)
Mikael Berthe <mikael@lilotux.net>
parents:
1424
diff
changeset
|
34 # include <termios.h> |
6b98dc22946d
Add optional SIGWINCH handler (Markus Hennecke)
Mikael Berthe <mikael@lilotux.net>
parents:
1424
diff
changeset
|
35 # include <unistd.h> |
6b98dc22946d
Add optional SIGWINCH handler (Markus Hennecke)
Mikael Berthe <mikael@lilotux.net>
parents:
1424
diff
changeset
|
36 #endif |
929 | 37 |
1382
1447c5296977
Fix locale charset detection on some BSD systems
Mikael Berthe <mikael@lilotux.net>
parents:
1381
diff
changeset
|
38 #ifdef HAVE_LOCALCHARSET_H |
1447c5296977
Fix locale charset detection on some BSD systems
Mikael Berthe <mikael@lilotux.net>
parents:
1381
diff
changeset
|
39 # include <localcharset.h> |
1447c5296977
Fix locale charset detection on some BSD systems
Mikael Berthe <mikael@lilotux.net>
parents:
1381
diff
changeset
|
40 #else |
1447c5296977
Fix locale charset detection on some BSD systems
Mikael Berthe <mikael@lilotux.net>
parents:
1381
diff
changeset
|
41 # include <langinfo.h> |
1447c5296977
Fix locale charset detection on some BSD systems
Mikael Berthe <mikael@lilotux.net>
parents:
1381
diff
changeset
|
42 #endif |
1447c5296977
Fix locale charset detection on some BSD systems
Mikael Berthe <mikael@lilotux.net>
parents:
1381
diff
changeset
|
43 |
1590
8d1bcc83ae32
Add support for spellchecking with Enchant (caolan)
Mikael Berthe <mikael@lilotux.net>
parents:
1579
diff
changeset
|
44 #ifdef WITH_ENCHANT |
8d1bcc83ae32
Add support for spellchecking with Enchant (caolan)
Mikael Berthe <mikael@lilotux.net>
parents:
1579
diff
changeset
|
45 # include <enchant.h> |
2015
db8ec238cd2c
Fix segfault when spell checking is enabled and spell_lang is not set.
Mikael Berthe <mikael@lilotux.net>
parents:
2013
diff
changeset
|
46 #else |
db8ec238cd2c
Fix segfault when spell checking is enabled and spell_lang is not set.
Mikael Berthe <mikael@lilotux.net>
parents:
2013
diff
changeset
|
47 # ifdef WITH_ASPELL |
db8ec238cd2c
Fix segfault when spell checking is enabled and spell_lang is not set.
Mikael Berthe <mikael@lilotux.net>
parents:
2013
diff
changeset
|
48 # include <aspell.h> |
db8ec238cd2c
Fix segfault when spell checking is enabled and spell_lang is not set.
Mikael Berthe <mikael@lilotux.net>
parents:
2013
diff
changeset
|
49 # endif |
1179 | 50 #endif |
51 | |
24 | 52 #include "screen.h" |
930
a75f7a13df7b
UTF-8 terminal support (Reimar Döffinger)
Mikael Berthe <mikael@lilotux.net>
parents:
929
diff
changeset
|
53 #include "utf8.h" |
81 | 54 #include "hbuf.h" |
47 | 55 #include "commands.h" |
95 | 56 #include "compl.h" |
81 | 57 #include "roster.h" |
180 | 58 #include "histolog.h" |
279
f5dd437c057b
Rewrite the settings system
Mikael Berthe <mikael@lilotux.net>
parents:
276
diff
changeset
|
59 #include "settings.h" |
81 | 60 #include "utils.h" |
1598 | 61 #include "xmpp.h" |
1653
fca9a4c17432
Improve UI latency and CPU usage
Myhailo Danylenko <isbear@ukrpost.net>
parents:
1651
diff
changeset
|
62 #include "main.h" |
24 | 63 |
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 |
515
180f0a6e4ac9
Log window's height can be set by the user
Mikael Berthe <mikael@lilotux.net>
parents:
514
diff
changeset
|
67 #define DEFAULT_LOG_WIN_HEIGHT (5+2) |
701
6c100adfbfb6
Add setting "roster_width" (variable buddylist width)
Mikael Berthe <mikael@lilotux.net>
parents:
699
diff
changeset
|
68 #define DEFAULT_ROSTER_WIDTH 24 |
515
180f0a6e4ac9
Log window's height can be set by the user
Mikael Berthe <mikael@lilotux.net>
parents:
514
diff
changeset
|
69 #define CHAT_WIN_HEIGHT (maxY-1-Log_Win_Height) |
180f0a6e4ac9
Log window's height can be set by the user
Mikael Berthe <mikael@lilotux.net>
parents:
514
diff
changeset
|
70 |
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 | |
1078
7866dbaf67a6
Use a hash for the list of win buffers
Mikael Berthe <mikael@lilotux.net>
parents:
1077
diff
changeset
|
100 static GHashTable *winbufhash; |
24 | 101 |
822 | 102 typedef struct { |
1157
5c857f0f0ab8
Moved all variables related to hbuf to an extra struct, bufdata
Frank Zschockelt
parents:
1156
diff
changeset
|
103 GList *hbuf; |
5c857f0f0ab8
Moved all variables related to hbuf to an extra struct, bufdata
Frank Zschockelt
parents:
1156
diff
changeset
|
104 GList *top; // If top is NULL, we'll display the last lines |
5c857f0f0ab8
Moved all variables related to hbuf to an extra struct, bufdata
Frank Zschockelt
parents:
1156
diff
changeset
|
105 char cleared; // For ex, user has issued a /clear command... |
5c857f0f0ab8
Moved all variables related to hbuf to an extra struct, bufdata
Frank Zschockelt
parents:
1156
diff
changeset
|
106 char lock; |
5c857f0f0ab8
Moved all variables related to hbuf to an extra struct, bufdata
Frank Zschockelt
parents:
1156
diff
changeset
|
107 } buffdata; |
5c857f0f0ab8
Moved all variables related to hbuf to an extra struct, bufdata
Frank Zschockelt
parents:
1156
diff
changeset
|
108 |
5c857f0f0ab8
Moved all variables related to hbuf to an extra struct, bufdata
Frank Zschockelt
parents:
1156
diff
changeset
|
109 typedef struct { |
24 | 110 WINDOW *win; |
108 | 111 PANEL *panel; |
1157
5c857f0f0ab8
Moved all variables related to hbuf to an extra struct, bufdata
Frank Zschockelt
parents:
1156
diff
changeset
|
112 buffdata *bd; |
822 | 113 } winbuf; |
24 | 114 |
1078
7866dbaf67a6
Use a hash for the list of win buffers
Mikael Berthe <mikael@lilotux.net>
parents:
1077
diff
changeset
|
115 struct dimensions { |
7866dbaf67a6
Use a hash for the list of win buffers
Mikael Berthe <mikael@lilotux.net>
parents:
1077
diff
changeset
|
116 int l; |
7866dbaf67a6
Use a hash for the list of win buffers
Mikael Berthe <mikael@lilotux.net>
parents:
1077
diff
changeset
|
117 int c; |
7866dbaf67a6
Use a hash for the list of win buffers
Mikael Berthe <mikael@lilotux.net>
parents:
1077
diff
changeset
|
118 }; |
24 | 119 |
1133
9dd28a56128f
Do not create one panel per contact
Mikael Berthe <mikael@lilotux.net>
parents:
1131
diff
changeset
|
120 static WINDOW *rosterWnd, *chatWnd, *activechatWnd, *inputWnd, *logWnd; |
711 | 121 static WINDOW *mainstatusWnd, *chatstatusWnd; |
1133
9dd28a56128f
Do not create one panel per contact
Mikael Berthe <mikael@lilotux.net>
parents:
1131
diff
changeset
|
122 static PANEL *rosterPanel, *chatPanel, *activechatPanel, *inputPanel; |
711 | 123 static PANEL *mainstatusPanel, *chatstatusPanel; |
124 static PANEL *logPanel; | |
24 | 125 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
|
126 static int prev_chatwidth; |
849
42c43a88d823
Status buffer management
Mikael Berthe <mikael@lilotux.net>
parents:
848
diff
changeset
|
127 static winbuf *statusWindow; |
822 | 128 static winbuf *currentWindow; |
851
da03534e46c7
Add startup log messages to the status buffer
Mikael Berthe <mikael@lilotux.net>
parents:
850
diff
changeset
|
129 static GList *statushbuf; |
24 | 130 |
707
b26a0bde4cdb
Add /roster hide|show|toggle
Mikael Berthe <mikael@lilotux.net>
parents:
701
diff
changeset
|
131 static int roster_hidden; |
24 | 132 static int chatmode; |
238 | 133 static int multimode; |
807
f6cda389db48
Allow messages with a subject (/msay)
Mikael Berthe <mikael@lilotux.net>
parents:
806
diff
changeset
|
134 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
|
135 static int roster_no_leading_space; |
1780
e4378fbab5d7
Major API cleanup - bump API to 4
Mikael Berthe <mikael@lilotux.net>
parents:
1761
diff
changeset
|
136 |
332
a1901741890e
scr_LogPrint() can be called before ncurses initialization
Mikael Berthe <mikael@lilotux.net>
parents:
330
diff
changeset
|
137 static bool Curses; |
972
11b632d824f6
Add option 'log_win_on_top'
Mikael Berthe <mikael@lilotux.net>
parents:
967
diff
changeset
|
138 static bool log_win_on_top; |
973
e693cbe33802
Add option 'roster_win_on_right'
Mikael Berthe <mikael@lilotux.net>
parents:
972
diff
changeset
|
139 static bool roster_win_on_right; |
1677 | 140 static guint autoaway_source = 0; |
24 | 141 |
174 | 142 static char inputLine[INPUTLINE_LENGTH+1]; |
1590
8d1bcc83ae32
Add support for spellchecking with Enchant (caolan)
Mikael Berthe <mikael@lilotux.net>
parents:
1579
diff
changeset
|
143 #if defined(WITH_ENCHANT) || defined(WITH_ASPELL) |
1179 | 144 static char maskLine[INPUTLINE_LENGTH+1]; |
145 #endif | |
174 | 146 static char *ptr_inputline; |
147 static short int inputline_offset; | |
148 static int completion_started; | |
173 | 149 static GList *cmdhisto; |
150 static GList *cmdhisto_cur; | |
1127
fddf2fef7b83
Add option "cmdhistory_lines"
Mikael Berthe <mikael@lilotux.net>
parents:
1122
diff
changeset
|
151 static guint cmdhisto_nblines; |
174 | 152 static char cmdhisto_backup[INPUTLINE_LENGTH+1]; |
24 | 153 |
991
ef10906691bb
Chatstates: add composing timeout
Mikael Berthe <mikael@lilotux.net>
parents:
990
diff
changeset
|
154 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
|
155 static bool lock_chatstate; |
991
ef10906691bb
Chatstates: add composing timeout
Mikael Berthe <mikael@lilotux.net>
parents:
990
diff
changeset
|
156 static time_t chatstate_timestamp; |
1598 | 157 static guint chatstate_timeout_id = 0; |
1780
e4378fbab5d7
Major API cleanup - bump API to 4
Mikael Berthe <mikael@lilotux.net>
parents:
1761
diff
changeset
|
158 |
e4378fbab5d7
Major API cleanup - bump API to 4
Mikael Berthe <mikael@lilotux.net>
parents:
1761
diff
changeset
|
159 int update_roster; |
e4378fbab5d7
Major API cleanup - bump API to 4
Mikael Berthe <mikael@lilotux.net>
parents:
1761
diff
changeset
|
160 int utf8_mode; |
e4378fbab5d7
Major API cleanup - bump API to 4
Mikael Berthe <mikael@lilotux.net>
parents:
1761
diff
changeset
|
161 gboolean chatstates_disabled; |
e4378fbab5d7
Major API cleanup - bump API to 4
Mikael Berthe <mikael@lilotux.net>
parents:
1761
diff
changeset
|
162 gboolean Autoaway; |
990
35e7913affb7
Send events/chatstates notifications (JEP-22/JEP-85)
Mikael Berthe <mikael@lilotux.net>
parents:
987
diff
changeset
|
163 |
761
4532a9fe0e8c
Handle some keyboard escape sequences
Mikael Berthe <mikael@lilotux.net>
parents:
760
diff
changeset
|
164 #define MAX_KEYSEQ_LENGTH 8 |
4532a9fe0e8c
Handle some keyboard escape sequences
Mikael Berthe <mikael@lilotux.net>
parents:
760
diff
changeset
|
165 |
4532a9fe0e8c
Handle some keyboard escape sequences
Mikael Berthe <mikael@lilotux.net>
parents:
760
diff
changeset
|
166 typedef struct { |
4532a9fe0e8c
Handle some keyboard escape sequences
Mikael Berthe <mikael@lilotux.net>
parents:
760
diff
changeset
|
167 char *seqstr; |
4532a9fe0e8c
Handle some keyboard escape sequences
Mikael Berthe <mikael@lilotux.net>
parents:
760
diff
changeset
|
168 guint mkeycode; |
4532a9fe0e8c
Handle some keyboard escape sequences
Mikael Berthe <mikael@lilotux.net>
parents:
760
diff
changeset
|
169 gint value; |
4532a9fe0e8c
Handle some keyboard escape sequences
Mikael Berthe <mikael@lilotux.net>
parents:
760
diff
changeset
|
170 } keyseq; |
4532a9fe0e8c
Handle some keyboard escape sequences
Mikael Berthe <mikael@lilotux.net>
parents:
760
diff
changeset
|
171 |
4532a9fe0e8c
Handle some keyboard escape sequences
Mikael Berthe <mikael@lilotux.net>
parents:
760
diff
changeset
|
172 GSList *keyseqlist; |
4532a9fe0e8c
Handle some keyboard escape sequences
Mikael Berthe <mikael@lilotux.net>
parents:
760
diff
changeset
|
173 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
|
174 |
1780
e4378fbab5d7
Major API cleanup - bump API to 4
Mikael Berthe <mikael@lilotux.net>
parents:
1761
diff
changeset
|
175 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
|
176 time_t timestamp, unsigned int prefix_flags, |
e4378fbab5d7
Major API cleanup - bump API to 4
Mikael Berthe <mikael@lilotux.net>
parents:
1761
diff
changeset
|
177 int force_show, unsigned mucnicklen, |
e4378fbab5d7
Major API cleanup - bump API to 4
Mikael Berthe <mikael@lilotux.net>
parents:
1761
diff
changeset
|
178 gpointer xep184); |
e4378fbab5d7
Major API cleanup - bump API to 4
Mikael Berthe <mikael@lilotux.net>
parents:
1761
diff
changeset
|
179 |
e4378fbab5d7
Major API cleanup - bump API to 4
Mikael Berthe <mikael@lilotux.net>
parents:
1761
diff
changeset
|
180 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
|
181 time_t timestamp, guint prefix_flags, |
e4378fbab5d7
Major API cleanup - bump API to 4
Mikael Berthe <mikael@lilotux.net>
parents:
1761
diff
changeset
|
182 unsigned mucnicklen, gpointer xep184); |
e4378fbab5d7
Major API cleanup - bump API to 4
Mikael Berthe <mikael@lilotux.net>
parents:
1761
diff
changeset
|
183 |
e4378fbab5d7
Major API cleanup - bump API to 4
Mikael Berthe <mikael@lilotux.net>
parents:
1761
diff
changeset
|
184 inline void scr_update_buddy_window(void); |
1413 | 185 inline void scr_set_chatmode(int enable); |
186 | |
1590
8d1bcc83ae32
Add support for spellchecking with Enchant (caolan)
Mikael Berthe <mikael@lilotux.net>
parents:
1579
diff
changeset
|
187 #define SPELLBADCHAR 5 |
8d1bcc83ae32
Add support for spellchecking with Enchant (caolan)
Mikael Berthe <mikael@lilotux.net>
parents:
1579
diff
changeset
|
188 |
2170
282531385f34
Multilanguage spell checking
Dmitry Potapov <potapov.d@gmail.com>
parents:
2165
diff
changeset
|
189 #if defined(WITH_ENCHANT) || defined(WITH_ASPELL) |
282531385f34
Multilanguage spell checking
Dmitry Potapov <potapov.d@gmail.com>
parents:
2165
diff
changeset
|
190 typedef struct { |
1590
8d1bcc83ae32
Add support for spellchecking with Enchant (caolan)
Mikael Berthe <mikael@lilotux.net>
parents:
1579
diff
changeset
|
191 #ifdef WITH_ENCHANT |
2170
282531385f34
Multilanguage spell checking
Dmitry Potapov <potapov.d@gmail.com>
parents:
2165
diff
changeset
|
192 EnchantBroker *broker; |
282531385f34
Multilanguage spell checking
Dmitry Potapov <potapov.d@gmail.com>
parents:
2165
diff
changeset
|
193 EnchantDict *checker; |
1590
8d1bcc83ae32
Add support for spellchecking with Enchant (caolan)
Mikael Berthe <mikael@lilotux.net>
parents:
1579
diff
changeset
|
194 #endif |
8d1bcc83ae32
Add support for spellchecking with Enchant (caolan)
Mikael Berthe <mikael@lilotux.net>
parents:
1579
diff
changeset
|
195 #ifdef WITH_ASPELL |
2170
282531385f34
Multilanguage spell checking
Dmitry Potapov <potapov.d@gmail.com>
parents:
2165
diff
changeset
|
196 AspellConfig *config; |
282531385f34
Multilanguage spell checking
Dmitry Potapov <potapov.d@gmail.com>
parents:
2165
diff
changeset
|
197 AspellSpeller *checker; |
282531385f34
Multilanguage spell checking
Dmitry Potapov <potapov.d@gmail.com>
parents:
2165
diff
changeset
|
198 #endif |
282531385f34
Multilanguage spell checking
Dmitry Potapov <potapov.d@gmail.com>
parents:
2165
diff
changeset
|
199 } spell_checker; |
282531385f34
Multilanguage spell checking
Dmitry Potapov <potapov.d@gmail.com>
parents:
2165
diff
changeset
|
200 |
282531385f34
Multilanguage spell checking
Dmitry Potapov <potapov.d@gmail.com>
parents:
2165
diff
changeset
|
201 GSList* spell_checkers = NULL; |
1179 | 202 #endif |
24 | 203 |
1272
033576acac4c
Add configurable roster colors (Michal 'vorner' Vaner)
Mikael Berthe <mikael@lilotux.net>
parents:
1268
diff
changeset
|
204 typedef struct { |
1489
e9c71ce96dca
Fixed the colorhandling for mucnicks and /color roster
franky@veqlargh.fs
parents:
1488
diff
changeset
|
205 int color_pair; |
e9c71ce96dca
Fixed the colorhandling for mucnicks and /color roster
franky@veqlargh.fs
parents:
1488
diff
changeset
|
206 int color_attrib; |
e9c71ce96dca
Fixed the colorhandling for mucnicks and /color roster
franky@veqlargh.fs
parents:
1488
diff
changeset
|
207 } ccolor; |
e9c71ce96dca
Fixed the colorhandling for mucnicks and /color roster
franky@veqlargh.fs
parents:
1488
diff
changeset
|
208 |
e9c71ce96dca
Fixed the colorhandling for mucnicks and /color roster
franky@veqlargh.fs
parents:
1488
diff
changeset
|
209 typedef struct { |
1272
033576acac4c
Add configurable roster colors (Michal 'vorner' Vaner)
Mikael Berthe <mikael@lilotux.net>
parents:
1268
diff
changeset
|
210 char *status, *wildcard; |
1598 | 211 ccolor *color; |
1272
033576acac4c
Add configurable roster colors (Michal 'vorner' Vaner)
Mikael Berthe <mikael@lilotux.net>
parents:
1268
diff
changeset
|
212 GPatternSpec *compiled; |
033576acac4c
Add configurable roster colors (Michal 'vorner' Vaner)
Mikael Berthe <mikael@lilotux.net>
parents:
1268
diff
changeset
|
213 } rostercolor; |
033576acac4c
Add configurable roster colors (Michal 'vorner' Vaner)
Mikael Berthe <mikael@lilotux.net>
parents:
1268
diff
changeset
|
214 |
1292
382ec54b584e
Muc nick coloring functionality
Michal 'vorner' Vaner <vorner@ucw.cz>
parents:
1291
diff
changeset
|
215 static GSList *rostercolrules = NULL; |
382ec54b584e
Muc nick coloring functionality
Michal 'vorner' Vaner <vorner@ucw.cz>
parents:
1291
diff
changeset
|
216 |
382ec54b584e
Muc nick coloring functionality
Michal 'vorner' Vaner <vorner@ucw.cz>
parents:
1291
diff
changeset
|
217 static GHashTable *muccolors = NULL, *nickcolors = NULL; |
382ec54b584e
Muc nick coloring functionality
Michal 'vorner' Vaner <vorner@ucw.cz>
parents:
1291
diff
changeset
|
218 |
382ec54b584e
Muc nick coloring functionality
Michal 'vorner' Vaner <vorner@ucw.cz>
parents:
1291
diff
changeset
|
219 typedef struct { |
1413 | 220 bool manual; // Manually set? |
1598 | 221 ccolor *color; |
1292
382ec54b584e
Muc nick coloring functionality
Michal 'vorner' Vaner <vorner@ucw.cz>
parents:
1291
diff
changeset
|
222 } nickcolor; |
382ec54b584e
Muc nick coloring functionality
Michal 'vorner' Vaner <vorner@ucw.cz>
parents:
1291
diff
changeset
|
223 |
1489
e9c71ce96dca
Fixed the colorhandling for mucnicks and /color roster
franky@veqlargh.fs
parents:
1488
diff
changeset
|
224 static int nickcolcount = 0; |
e9c71ce96dca
Fixed the colorhandling for mucnicks and /color roster
franky@veqlargh.fs
parents:
1488
diff
changeset
|
225 static ccolor ** nickcols = NULL; |
1292
382ec54b584e
Muc nick coloring functionality
Michal 'vorner' Vaner <vorner@ucw.cz>
parents:
1291
diff
changeset
|
226 static muccoltype glob_muccol = MC_OFF; |
1272
033576acac4c
Add configurable roster colors (Michal 'vorner' Vaner)
Mikael Berthe <mikael@lilotux.net>
parents:
1268
diff
changeset
|
227 |
99 | 228 /* Functions */ |
24 | 229 |
1780
e4378fbab5d7
Major API cleanup - bump API to 4
Mikael Berthe <mikael@lilotux.net>
parents:
1761
diff
changeset
|
230 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
|
231 { |
1489
e9c71ce96dca
Fixed the colorhandling for mucnicks and /color roster
franky@veqlargh.fs
parents:
1488
diff
changeset
|
232 int result; |
e9c71ce96dca
Fixed the colorhandling for mucnicks and /color roster
franky@veqlargh.fs
parents:
1488
diff
changeset
|
233 |
24 | 234 if (!strcmp(name, "default")) |
235 return -1; | |
236 if (!strcmp(name, "black")) | |
237 return COLOR_BLACK; | |
238 if (!strcmp(name, "red")) | |
239 return COLOR_RED; | |
240 if (!strcmp(name, "green")) | |
241 return COLOR_GREEN; | |
242 if (!strcmp(name, "yellow")) | |
243 return COLOR_YELLOW; | |
244 if (!strcmp(name, "blue")) | |
245 return COLOR_BLUE; | |
246 if (!strcmp(name, "magenta")) | |
247 return COLOR_MAGENTA; | |
248 if (!strcmp(name, "cyan")) | |
249 return COLOR_CYAN; | |
250 if (!strcmp(name, "white")) | |
251 return COLOR_WHITE; | |
252 | |
1417
783b47c9d963
Allow more than the 16 default colors (patch from mjs)
Mikael Berthe <mikael@lilotux.net>
parents:
1414
diff
changeset
|
253 // 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
|
254 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
|
255 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
|
256 return result; |
783b47c9d963
Allow more than the 16 default colors (patch from mjs)
Mikael Berthe <mikael@lilotux.net>
parents:
1414
diff
changeset
|
257 |
739
0d5fb1d9077c
Allow "bright" text colors
Mikael Berthe <mikael@lilotux.net>
parents:
735
diff
changeset
|
258 scr_LogPrint(LPRINT_LOGNORM, "ERROR: Wrong color: %s", name); |
24 | 259 return -1; |
260 } | |
261 | |
1598 | 262 static ccolor *get_user_color(const char *color) |
1295
33cb828282d5
Fix recognizing of bright colors
Michal 'vorner' Vaner <vorner@ucw.cz>
parents:
1294
diff
changeset
|
263 { |
1381
40095d413da9
Fix compilation on OpenBSD
Mikael Berthe <mikael@lilotux.net>
parents:
1376
diff
changeset
|
264 bool isbright = FALSE; |
1295
33cb828282d5
Fix recognizing of bright colors
Michal 'vorner' Vaner <vorner@ucw.cz>
parents:
1294
diff
changeset
|
265 int cl; |
1598 | 266 ccolor *ccol; |
1295
33cb828282d5
Fix recognizing of bright colors
Michal 'vorner' Vaner <vorner@ucw.cz>
parents:
1294
diff
changeset
|
267 if (!strncmp(color, "bright", 6)) { |
1381
40095d413da9
Fix compilation on OpenBSD
Mikael Berthe <mikael@lilotux.net>
parents:
1376
diff
changeset
|
268 isbright = TRUE; |
1295
33cb828282d5
Fix recognizing of bright colors
Michal 'vorner' Vaner <vorner@ucw.cz>
parents:
1294
diff
changeset
|
269 color += 6; |
33cb828282d5
Fix recognizing of bright colors
Michal 'vorner' Vaner <vorner@ucw.cz>
parents:
1294
diff
changeset
|
270 } |
1780
e4378fbab5d7
Major API cleanup - bump API to 4
Mikael Berthe <mikael@lilotux.net>
parents:
1761
diff
changeset
|
271 cl = find_color(color); |
1295
33cb828282d5
Fix recognizing of bright colors
Michal 'vorner' Vaner <vorner@ucw.cz>
parents:
1294
diff
changeset
|
272 if (cl < 0) |
1489
e9c71ce96dca
Fixed the colorhandling for mucnicks and /color roster
franky@veqlargh.fs
parents:
1488
diff
changeset
|
273 return NULL; |
e9c71ce96dca
Fixed the colorhandling for mucnicks and /color roster
franky@veqlargh.fs
parents:
1488
diff
changeset
|
274 ccol = g_new0(ccolor, 1); |
e9c71ce96dca
Fixed the colorhandling for mucnicks and /color roster
franky@veqlargh.fs
parents:
1488
diff
changeset
|
275 ccol->color_attrib = isbright ? A_BOLD : A_NORMAL; |
1729
e6e89b1d7831
Minor style and header updates
Mikael Berthe <mikael@lilotux.net>
parents:
1710
diff
changeset
|
276 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
|
277 return ccol; |
1295
33cb828282d5
Fix recognizing of bright colors
Michal 'vorner' Vaner <vorner@ucw.cz>
parents:
1294
diff
changeset
|
278 } |
33cb828282d5
Fix recognizing of bright colors
Michal 'vorner' Vaner <vorner@ucw.cz>
parents:
1294
diff
changeset
|
279 |
1292
382ec54b584e
Muc nick coloring functionality
Michal 'vorner' Vaner <vorner@ucw.cz>
parents:
1291
diff
changeset
|
280 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
|
281 GDestroyNotify value_destroy_func) |
1292
382ec54b584e
Muc nick coloring functionality
Michal 'vorner' Vaner <vorner@ucw.cz>
parents:
1291
diff
changeset
|
282 { |
1729
e6e89b1d7831
Minor style and header updates
Mikael Berthe <mikael@lilotux.net>
parents:
1710
diff
changeset
|
283 if (*table) // Have it already |
1292
382ec54b584e
Muc nick coloring functionality
Michal 'vorner' Vaner <vorner@ucw.cz>
parents:
1291
diff
changeset
|
284 return; |
382ec54b584e
Muc nick coloring functionality
Michal 'vorner' Vaner <vorner@ucw.cz>
parents:
1291
diff
changeset
|
285 *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
|
286 g_free, value_destroy_func); |
382ec54b584e
Muc nick coloring functionality
Michal 'vorner' Vaner <vorner@ucw.cz>
parents:
1291
diff
changeset
|
287 } |
382ec54b584e
Muc nick coloring functionality
Michal 'vorner' Vaner <vorner@ucw.cz>
parents:
1291
diff
changeset
|
288 |
382ec54b584e
Muc nick coloring functionality
Michal 'vorner' Vaner <vorner@ucw.cz>
parents:
1291
diff
changeset
|
289 // Sets the coloring mode for given MUC |
382ec54b584e
Muc nick coloring functionality
Michal 'vorner' Vaner <vorner@ucw.cz>
parents:
1291
diff
changeset
|
290 // 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
|
291 // muc - the JID of room |
382ec54b584e
Muc nick coloring functionality
Michal 'vorner' Vaner <vorner@ucw.cz>
parents:
1291
diff
changeset
|
292 // type - the new type |
1780
e4378fbab5d7
Major API cleanup - bump API to 4
Mikael Berthe <mikael@lilotux.net>
parents:
1761
diff
changeset
|
293 void scr_muc_color(const char *muc, muccoltype type) |
1292
382ec54b584e
Muc nick coloring functionality
Michal 'vorner' Vaner <vorner@ucw.cz>
parents:
1291
diff
changeset
|
294 { |
382ec54b584e
Muc nick coloring functionality
Michal 'vorner' Vaner <vorner@ucw.cz>
parents:
1291
diff
changeset
|
295 gchar *muclow = g_utf8_strdown(muc, -1); |
1729
e6e89b1d7831
Minor style and header updates
Mikael Berthe <mikael@lilotux.net>
parents:
1710
diff
changeset
|
296 if (type == MC_REMOVE) { // Remove it |
1292
382ec54b584e
Muc nick coloring functionality
Michal 'vorner' Vaner <vorner@ucw.cz>
parents:
1291
diff
changeset
|
297 if (strcmp(muc, "*")) { |
382ec54b584e
Muc nick coloring functionality
Michal 'vorner' Vaner <vorner@ucw.cz>
parents:
1291
diff
changeset
|
298 if (muccolors && g_hash_table_lookup(muccolors, muclow)) |
382ec54b584e
Muc nick coloring functionality
Michal 'vorner' Vaner <vorner@ucw.cz>
parents:
1291
diff
changeset
|
299 g_hash_table_remove(muccolors, muclow); |
382ec54b584e
Muc nick coloring functionality
Michal 'vorner' Vaner <vorner@ucw.cz>
parents:
1291
diff
changeset
|
300 } else { |
382ec54b584e
Muc nick coloring functionality
Michal 'vorner' Vaner <vorner@ucw.cz>
parents:
1291
diff
changeset
|
301 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
|
302 } |
382ec54b584e
Muc nick coloring functionality
Michal 'vorner' Vaner <vorner@ucw.cz>
parents:
1291
diff
changeset
|
303 g_free(muclow); |
1729
e6e89b1d7831
Minor style and header updates
Mikael Berthe <mikael@lilotux.net>
parents:
1710
diff
changeset
|
304 } else { // Add or overwrite |
1292
382ec54b584e
Muc nick coloring functionality
Michal 'vorner' Vaner <vorner@ucw.cz>
parents:
1291
diff
changeset
|
305 if (strcmp(muc, "*")) { |
382ec54b584e
Muc nick coloring functionality
Michal 'vorner' Vaner <vorner@ucw.cz>
parents:
1291
diff
changeset
|
306 muccoltype *value = g_new(muccoltype, 1); |
382ec54b584e
Muc nick coloring functionality
Michal 'vorner' Vaner <vorner@ucw.cz>
parents:
1291
diff
changeset
|
307 *value = type; |
1476
77afd831f8f7
Avoid mixed declarations and code
Mikael Berthe <mikael@lilotux.net>
parents:
1457
diff
changeset
|
308 ensure_string_htable(&muccolors, g_free); |
1292
382ec54b584e
Muc nick coloring functionality
Michal 'vorner' Vaner <vorner@ucw.cz>
parents:
1291
diff
changeset
|
309 g_hash_table_replace(muccolors, muclow, value); |
382ec54b584e
Muc nick coloring functionality
Michal 'vorner' Vaner <vorner@ucw.cz>
parents:
1291
diff
changeset
|
310 } else { |
382ec54b584e
Muc nick coloring functionality
Michal 'vorner' Vaner <vorner@ucw.cz>
parents:
1291
diff
changeset
|
311 glob_muccol = type; |
382ec54b584e
Muc nick coloring functionality
Michal 'vorner' Vaner <vorner@ucw.cz>
parents:
1291
diff
changeset
|
312 g_free(muclow); |
382ec54b584e
Muc nick coloring functionality
Michal 'vorner' Vaner <vorner@ucw.cz>
parents:
1291
diff
changeset
|
313 } |
382ec54b584e
Muc nick coloring functionality
Michal 'vorner' Vaner <vorner@ucw.cz>
parents:
1291
diff
changeset
|
314 } |
1729
e6e89b1d7831
Minor style and header updates
Mikael Berthe <mikael@lilotux.net>
parents:
1710
diff
changeset
|
315 // Need to redraw? |
1333
e30a9d907105
Minor coding style adjustments
Mikael Berthe <mikael@lilotux.net>
parents:
1314
diff
changeset
|
316 if (chatmode && |
e30a9d907105
Minor coding style adjustments
Mikael Berthe <mikael@lilotux.net>
parents:
1314
diff
changeset
|
317 ((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
|
318 scr_update_buddy_window(); |
1292
382ec54b584e
Muc nick coloring functionality
Michal 'vorner' Vaner <vorner@ucw.cz>
parents:
1291
diff
changeset
|
319 } |
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 // Sets the color for nick in MUC |
382ec54b584e
Muc nick coloring functionality
Michal 'vorner' Vaner <vorner@ucw.cz>
parents:
1291
diff
changeset
|
322 // 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
|
323 // 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
|
324 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
|
325 { |
1333
e30a9d907105
Minor coding style adjustments
Mikael Berthe <mikael@lilotux.net>
parents:
1314
diff
changeset
|
326 char *snick, *mnick; |
1381
40095d413da9
Fix compilation on OpenBSD
Mikael Berthe <mikael@lilotux.net>
parents:
1376
diff
changeset
|
327 bool need_update = FALSE; |
1333
e30a9d907105
Minor coding style adjustments
Mikael Berthe <mikael@lilotux.net>
parents:
1314
diff
changeset
|
328 snick = g_strdup_printf("<%s>", nick); |
e30a9d907105
Minor coding style adjustments
Mikael Berthe <mikael@lilotux.net>
parents:
1314
diff
changeset
|
329 mnick = g_strdup_printf("*%s ", nick); |
1729
e6e89b1d7831
Minor style and header updates
Mikael Berthe <mikael@lilotux.net>
parents:
1710
diff
changeset
|
330 if (!strcmp(color, "-")) { // Remove the color |
1292
382ec54b584e
Muc nick coloring functionality
Michal 'vorner' Vaner <vorner@ucw.cz>
parents:
1291
diff
changeset
|
331 if (nickcolors) { |
382ec54b584e
Muc nick coloring functionality
Michal 'vorner' Vaner <vorner@ucw.cz>
parents:
1291
diff
changeset
|
332 nickcolor *nc = g_hash_table_lookup(nickcolors, snick); |
1729
e6e89b1d7831
Minor style and header updates
Mikael Berthe <mikael@lilotux.net>
parents:
1710
diff
changeset
|
333 if (nc) { // Have this nick already |
1381
40095d413da9
Fix compilation on OpenBSD
Mikael Berthe <mikael@lilotux.net>
parents:
1376
diff
changeset
|
334 nc->manual = FALSE; |
1292
382ec54b584e
Muc nick coloring functionality
Michal 'vorner' Vaner <vorner@ucw.cz>
parents:
1291
diff
changeset
|
335 nc = g_hash_table_lookup(nickcolors, mnick); |
1729
e6e89b1d7831
Minor style and header updates
Mikael Berthe <mikael@lilotux.net>
parents:
1710
diff
changeset
|
336 assert(nc); // Must have both at the same time |
1381
40095d413da9
Fix compilation on OpenBSD
Mikael Berthe <mikael@lilotux.net>
parents:
1376
diff
changeset
|
337 nc->manual = FALSE; |
1292
382ec54b584e
Muc nick coloring functionality
Michal 'vorner' Vaner <vorner@ucw.cz>
parents:
1291
diff
changeset
|
338 }// Else -> no color saved, nothing to delete |
382ec54b584e
Muc nick coloring functionality
Michal 'vorner' Vaner <vorner@ucw.cz>
parents:
1291
diff
changeset
|
339 } |
1729
e6e89b1d7831
Minor style and header updates
Mikael Berthe <mikael@lilotux.net>
parents:
1710
diff
changeset
|
340 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
|
341 g_free(mnick); |
1381
40095d413da9
Fix compilation on OpenBSD
Mikael Berthe <mikael@lilotux.net>
parents:
1376
diff
changeset
|
342 need_update = TRUE; |
1292
382ec54b584e
Muc nick coloring functionality
Michal 'vorner' Vaner <vorner@ucw.cz>
parents:
1291
diff
changeset
|
343 } else { |
1598 | 344 ccolor *cl = get_user_color(color); |
1489
e9c71ce96dca
Fixed the colorhandling for mucnicks and /color roster
franky@veqlargh.fs
parents:
1488
diff
changeset
|
345 if (!cl) { |
1292
382ec54b584e
Muc nick coloring functionality
Michal 'vorner' Vaner <vorner@ucw.cz>
parents:
1291
diff
changeset
|
346 scr_LogPrint(LPRINT_NORMAL, "No such color name"); |
382ec54b584e
Muc nick coloring functionality
Michal 'vorner' Vaner <vorner@ucw.cz>
parents:
1291
diff
changeset
|
347 g_free(snick); |
382ec54b584e
Muc nick coloring functionality
Michal 'vorner' Vaner <vorner@ucw.cz>
parents:
1291
diff
changeset
|
348 g_free(mnick); |
382ec54b584e
Muc nick coloring functionality
Michal 'vorner' Vaner <vorner@ucw.cz>
parents:
1291
diff
changeset
|
349 } else { |
382ec54b584e
Muc nick coloring functionality
Michal 'vorner' Vaner <vorner@ucw.cz>
parents:
1291
diff
changeset
|
350 nickcolor *nc = g_new(nickcolor, 1); |
382ec54b584e
Muc nick coloring functionality
Michal 'vorner' Vaner <vorner@ucw.cz>
parents:
1291
diff
changeset
|
351 ensure_string_htable(&nickcolors, NULL); |
1381
40095d413da9
Fix compilation on OpenBSD
Mikael Berthe <mikael@lilotux.net>
parents:
1376
diff
changeset
|
352 nc->manual = TRUE; |
1292
382ec54b584e
Muc nick coloring functionality
Michal 'vorner' Vaner <vorner@ucw.cz>
parents:
1291
diff
changeset
|
353 nc->color = cl; |
1729
e6e89b1d7831
Minor style and header updates
Mikael Berthe <mikael@lilotux.net>
parents:
1710
diff
changeset
|
354 // Free the struct, if any there already |
1292
382ec54b584e
Muc nick coloring functionality
Michal 'vorner' Vaner <vorner@ucw.cz>
parents:
1291
diff
changeset
|
355 g_free(g_hash_table_lookup(nickcolors, mnick)); |
1729
e6e89b1d7831
Minor style and header updates
Mikael Berthe <mikael@lilotux.net>
parents:
1710
diff
changeset
|
356 // Save the new ones |
1292
382ec54b584e
Muc nick coloring functionality
Michal 'vorner' Vaner <vorner@ucw.cz>
parents:
1291
diff
changeset
|
357 g_hash_table_replace(nickcolors, mnick, nc); |
382ec54b584e
Muc nick coloring functionality
Michal 'vorner' Vaner <vorner@ucw.cz>
parents:
1291
diff
changeset
|
358 g_hash_table_replace(nickcolors, snick, nc); |
1381
40095d413da9
Fix compilation on OpenBSD
Mikael Berthe <mikael@lilotux.net>
parents:
1376
diff
changeset
|
359 need_update = TRUE; |
1292
382ec54b584e
Muc nick coloring functionality
Michal 'vorner' Vaner <vorner@ucw.cz>
parents:
1291
diff
changeset
|
360 } |
382ec54b584e
Muc nick coloring functionality
Michal 'vorner' Vaner <vorner@ucw.cz>
parents:
1291
diff
changeset
|
361 } |
382ec54b584e
Muc nick coloring functionality
Michal 'vorner' Vaner <vorner@ucw.cz>
parents:
1291
diff
changeset
|
362 if (need_update && chatmode && |
382ec54b584e
Muc nick coloring functionality
Michal 'vorner' Vaner <vorner@ucw.cz>
parents:
1291
diff
changeset
|
363 (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
|
364 scr_update_buddy_window(); |
1292
382ec54b584e
Muc nick coloring functionality
Michal 'vorner' Vaner <vorner@ucw.cz>
parents:
1291
diff
changeset
|
365 } |
382ec54b584e
Muc nick coloring functionality
Michal 'vorner' Vaner <vorner@ucw.cz>
parents:
1291
diff
changeset
|
366 |
1272
033576acac4c
Add configurable roster colors (Michal 'vorner' Vaner)
Mikael Berthe <mikael@lilotux.net>
parents:
1268
diff
changeset
|
367 static void free_rostercolrule(rostercolor *col) |
033576acac4c
Add configurable roster colors (Michal 'vorner' Vaner)
Mikael Berthe <mikael@lilotux.net>
parents:
1268
diff
changeset
|
368 { |
033576acac4c
Add configurable roster colors (Michal 'vorner' Vaner)
Mikael Berthe <mikael@lilotux.net>
parents:
1268
diff
changeset
|
369 g_free(col->status); |
033576acac4c
Add configurable roster colors (Michal 'vorner' Vaner)
Mikael Berthe <mikael@lilotux.net>
parents:
1268
diff
changeset
|
370 g_free(col->wildcard); |
1489
e9c71ce96dca
Fixed the colorhandling for mucnicks and /color roster
franky@veqlargh.fs
parents:
1488
diff
changeset
|
371 g_free(col->color); |
1272
033576acac4c
Add configurable roster colors (Michal 'vorner' Vaner)
Mikael Berthe <mikael@lilotux.net>
parents:
1268
diff
changeset
|
372 g_pattern_spec_free(col->compiled); |
033576acac4c
Add configurable roster colors (Michal 'vorner' Vaner)
Mikael Berthe <mikael@lilotux.net>
parents:
1268
diff
changeset
|
373 g_free(col); |
033576acac4c
Add configurable roster colors (Michal 'vorner' Vaner)
Mikael Berthe <mikael@lilotux.net>
parents:
1268
diff
changeset
|
374 } |
033576acac4c
Add configurable roster colors (Michal 'vorner' Vaner)
Mikael Berthe <mikael@lilotux.net>
parents:
1268
diff
changeset
|
375 |
1284 | 376 // Removes all roster coloring rules |
1780
e4378fbab5d7
Major API cleanup - bump API to 4
Mikael Berthe <mikael@lilotux.net>
parents:
1761
diff
changeset
|
377 void scr_roster_clear_color(void) |
1272
033576acac4c
Add configurable roster colors (Michal 'vorner' Vaner)
Mikael Berthe <mikael@lilotux.net>
parents:
1268
diff
changeset
|
378 { |
033576acac4c
Add configurable roster colors (Michal 'vorner' Vaner)
Mikael Berthe <mikael@lilotux.net>
parents:
1268
diff
changeset
|
379 GSList *head; |
033576acac4c
Add configurable roster colors (Michal 'vorner' Vaner)
Mikael Berthe <mikael@lilotux.net>
parents:
1268
diff
changeset
|
380 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
|
381 free_rostercolrule(head->data); |
033576acac4c
Add configurable roster colors (Michal 'vorner' Vaner)
Mikael Berthe <mikael@lilotux.net>
parents:
1268
diff
changeset
|
382 } |
033576acac4c
Add configurable roster colors (Michal 'vorner' Vaner)
Mikael Berthe <mikael@lilotux.net>
parents:
1268
diff
changeset
|
383 g_slist_free(rostercolrules); |
033576acac4c
Add configurable roster colors (Michal 'vorner' Vaner)
Mikael Berthe <mikael@lilotux.net>
parents:
1268
diff
changeset
|
384 rostercolrules = NULL; |
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 |
1284 | 387 // Adds, modifies or removes roster coloring rule |
388 // color set to "-" removes the rule, | |
389 // otherwise it is modified (if exists) or added | |
390 // | |
391 // Returns weather it was successfull (therefore the roster should be | |
392 // redrawed) or not. If it failed, for example because of invalid color | |
393 // name, it also prints the error. | |
1780
e4378fbab5d7
Major API cleanup - bump API to 4
Mikael Berthe <mikael@lilotux.net>
parents:
1761
diff
changeset
|
394 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
|
395 const char *color) |
1272
033576acac4c
Add configurable roster colors (Michal 'vorner' Vaner)
Mikael Berthe <mikael@lilotux.net>
parents:
1268
diff
changeset
|
396 { |
033576acac4c
Add configurable roster colors (Michal 'vorner' Vaner)
Mikael Berthe <mikael@lilotux.net>
parents:
1268
diff
changeset
|
397 GSList *head; |
033576acac4c
Add configurable roster colors (Michal 'vorner' Vaner)
Mikael Berthe <mikael@lilotux.net>
parents:
1268
diff
changeset
|
398 GSList *found = NULL; |
033576acac4c
Add configurable roster colors (Michal 'vorner' Vaner)
Mikael Berthe <mikael@lilotux.net>
parents:
1268
diff
changeset
|
399 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
|
400 rostercolor *rc = head->data; |
033576acac4c
Add configurable roster colors (Michal 'vorner' Vaner)
Mikael Berthe <mikael@lilotux.net>
parents:
1268
diff
changeset
|
401 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
|
402 found = head; |
033576acac4c
Add configurable roster colors (Michal 'vorner' Vaner)
Mikael Berthe <mikael@lilotux.net>
parents:
1268
diff
changeset
|
403 break; |
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 } |
1729
e6e89b1d7831
Minor style and header updates
Mikael Berthe <mikael@lilotux.net>
parents:
1710
diff
changeset
|
406 if (!strcmp(color,"-")) { // Delete the rule |
1272
033576acac4c
Add configurable roster colors (Michal 'vorner' Vaner)
Mikael Berthe <mikael@lilotux.net>
parents:
1268
diff
changeset
|
407 if (found) { |
033576acac4c
Add configurable roster colors (Michal 'vorner' Vaner)
Mikael Berthe <mikael@lilotux.net>
parents:
1268
diff
changeset
|
408 free_rostercolrule(found->data); |
033576acac4c
Add configurable roster colors (Michal 'vorner' Vaner)
Mikael Berthe <mikael@lilotux.net>
parents:
1268
diff
changeset
|
409 rostercolrules = g_slist_delete_link(rostercolrules, found); |
033576acac4c
Add configurable roster colors (Michal 'vorner' Vaner)
Mikael Berthe <mikael@lilotux.net>
parents:
1268
diff
changeset
|
410 return TRUE; |
033576acac4c
Add configurable roster colors (Michal 'vorner' Vaner)
Mikael Berthe <mikael@lilotux.net>
parents:
1268
diff
changeset
|
411 } else { |
033576acac4c
Add configurable roster colors (Michal 'vorner' Vaner)
Mikael Berthe <mikael@lilotux.net>
parents:
1268
diff
changeset
|
412 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
|
413 return FALSE; |
033576acac4c
Add configurable roster colors (Michal 'vorner' Vaner)
Mikael Berthe <mikael@lilotux.net>
parents:
1268
diff
changeset
|
414 } |
033576acac4c
Add configurable roster colors (Michal 'vorner' Vaner)
Mikael Berthe <mikael@lilotux.net>
parents:
1268
diff
changeset
|
415 } else { |
1598 | 416 ccolor *cl = get_user_color(color); |
1489
e9c71ce96dca
Fixed the colorhandling for mucnicks and /color roster
franky@veqlargh.fs
parents:
1488
diff
changeset
|
417 if (!cl) { |
1272
033576acac4c
Add configurable roster colors (Michal 'vorner' Vaner)
Mikael Berthe <mikael@lilotux.net>
parents:
1268
diff
changeset
|
418 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
|
419 return FALSE; |
033576acac4c
Add configurable roster colors (Michal 'vorner' Vaner)
Mikael Berthe <mikael@lilotux.net>
parents:
1268
diff
changeset
|
420 } |
033576acac4c
Add configurable roster colors (Michal 'vorner' Vaner)
Mikael Berthe <mikael@lilotux.net>
parents:
1268
diff
changeset
|
421 if (found) { |
033576acac4c
Add configurable roster colors (Michal 'vorner' Vaner)
Mikael Berthe <mikael@lilotux.net>
parents:
1268
diff
changeset
|
422 rostercolor *rc = found->data; |
1489
e9c71ce96dca
Fixed the colorhandling for mucnicks and /color roster
franky@veqlargh.fs
parents:
1488
diff
changeset
|
423 g_free(rc->color); |
1272
033576acac4c
Add configurable roster colors (Michal 'vorner' Vaner)
Mikael Berthe <mikael@lilotux.net>
parents:
1268
diff
changeset
|
424 rc->color = cl; |
033576acac4c
Add configurable roster colors (Michal 'vorner' Vaner)
Mikael Berthe <mikael@lilotux.net>
parents:
1268
diff
changeset
|
425 } else { |
033576acac4c
Add configurable roster colors (Michal 'vorner' Vaner)
Mikael Berthe <mikael@lilotux.net>
parents:
1268
diff
changeset
|
426 rostercolor *rc = g_new(rostercolor, 1); |
033576acac4c
Add configurable roster colors (Michal 'vorner' Vaner)
Mikael Berthe <mikael@lilotux.net>
parents:
1268
diff
changeset
|
427 rc->status = g_strdup(status); |
033576acac4c
Add configurable roster colors (Michal 'vorner' Vaner)
Mikael Berthe <mikael@lilotux.net>
parents:
1268
diff
changeset
|
428 rc->wildcard = g_strdup(wildcard); |
033576acac4c
Add configurable roster colors (Michal 'vorner' Vaner)
Mikael Berthe <mikael@lilotux.net>
parents:
1268
diff
changeset
|
429 rc->compiled = g_pattern_spec_new(wildcard); |
033576acac4c
Add configurable roster colors (Michal 'vorner' Vaner)
Mikael Berthe <mikael@lilotux.net>
parents:
1268
diff
changeset
|
430 rc->color = cl; |
033576acac4c
Add configurable roster colors (Michal 'vorner' Vaner)
Mikael Berthe <mikael@lilotux.net>
parents:
1268
diff
changeset
|
431 rostercolrules = g_slist_prepend(rostercolrules, rc); |
033576acac4c
Add configurable roster colors (Michal 'vorner' Vaner)
Mikael Berthe <mikael@lilotux.net>
parents:
1268
diff
changeset
|
432 } |
033576acac4c
Add configurable roster colors (Michal 'vorner' Vaner)
Mikael Berthe <mikael@lilotux.net>
parents:
1268
diff
changeset
|
433 return TRUE; |
033576acac4c
Add configurable roster colors (Michal 'vorner' Vaner)
Mikael Berthe <mikael@lilotux.net>
parents:
1268
diff
changeset
|
434 } |
033576acac4c
Add configurable roster colors (Michal 'vorner' Vaner)
Mikael Berthe <mikael@lilotux.net>
parents:
1268
diff
changeset
|
435 } |
033576acac4c
Add configurable roster colors (Michal 'vorner' Vaner)
Mikael Berthe <mikael@lilotux.net>
parents:
1268
diff
changeset
|
436 |
1780
e4378fbab5d7
Major API cleanup - bump API to 4
Mikael Berthe <mikael@lilotux.net>
parents:
1761
diff
changeset
|
437 static void parse_colors(void) |
24 | 438 { |
739
0d5fb1d9077c
Allow "bright" text colors
Mikael Berthe <mikael@lilotux.net>
parents:
735
diff
changeset
|
439 const char *colors[] = { |
24 | 440 "", "", |
267 | 441 "general", |
785
7e0562e3bc83
Replace color_highlight with color_msgout
Mikael Berthe <mikael@lilotux.net>
parents:
779
diff
changeset
|
442 "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
|
443 "msghl", |
711 | 444 "status", |
2028
7b5bd6ad83b4
Add 'color_log' (text color in the log window)
Mikael Berthe <mikael@lilotux.net>
parents:
2015
diff
changeset
|
445 "log", |
712 | 446 "roster", |
447 "rostersel", | |
723
23068490d063
Add text color when the selected buddy has an unread message
Mikael Berthe <mikael@lilotux.net>
parents:
721
diff
changeset
|
448 "rosterselmsg", |
712 | 449 "rosternewmsg", |
1268
dbc907b2d92f
Add configurable colors for info and incoming messages (Michal 'vorner' Vaner)
Mikael Berthe <mikael@lilotux.net>
parents:
1254
diff
changeset
|
450 "info", |
dbc907b2d92f
Add configurable colors for info and incoming messages (Michal 'vorner' Vaner)
Mikael Berthe <mikael@lilotux.net>
parents:
1254
diff
changeset
|
451 "msgin", |
1960 | 452 "readmark", |
2090
16b04d64ec88
Add option to highlight timestamp added by server.
Hermitifier
parents:
2074
diff
changeset
|
453 "timestamp", |
24 | 454 NULL |
455 }; | |
456 | |
281
f562b9af2de7
Add "const" specifier in prototypes
Mikael Berthe <mikael@lilotux.net>
parents:
279
diff
changeset
|
457 const char *color; |
f562b9af2de7
Add "const" specifier in prototypes
Mikael Berthe <mikael@lilotux.net>
parents:
279
diff
changeset
|
458 const char *background = settings_opt_get("color_background"); |
712 | 459 const char *backselected = settings_opt_get("color_bgrostersel"); |
460 const char *backstatus = settings_opt_get("color_bgstatus"); | |
739
0d5fb1d9077c
Allow "bright" text colors
Mikael Berthe <mikael@lilotux.net>
parents:
735
diff
changeset
|
461 char *tmp; |
0d5fb1d9077c
Allow "bright" text colors
Mikael Berthe <mikael@lilotux.net>
parents:
735
diff
changeset
|
462 int i; |
0d5fb1d9077c
Allow "bright" text colors
Mikael Berthe <mikael@lilotux.net>
parents:
735
diff
changeset
|
463 |
0d5fb1d9077c
Allow "bright" text colors
Mikael Berthe <mikael@lilotux.net>
parents:
735
diff
changeset
|
464 // Initialize color attributes |
0d5fb1d9077c
Allow "bright" text colors
Mikael Berthe <mikael@lilotux.net>
parents:
735
diff
changeset
|
465 memset(COLOR_ATTRIB, 0, sizeof(COLOR_ATTRIB)); |
24 | 466 |
267 | 467 // Default values |
711 | 468 if (!background) background = "black"; |
267 | 469 if (!backselected) backselected = "cyan"; |
711 | 470 if (!backstatus) backstatus = "blue"; |
267 | 471 |
739
0d5fb1d9077c
Allow "bright" text colors
Mikael Berthe <mikael@lilotux.net>
parents:
735
diff
changeset
|
472 for (i=0; colors[i]; i++) { |
0d5fb1d9077c
Allow "bright" text colors
Mikael Berthe <mikael@lilotux.net>
parents:
735
diff
changeset
|
473 tmp = g_strdup_printf("color_%s", colors[i]); |
279
f5dd437c057b
Rewrite the settings system
Mikael Berthe <mikael@lilotux.net>
parents:
276
diff
changeset
|
474 color = settings_opt_get(tmp); |
739
0d5fb1d9077c
Allow "bright" text colors
Mikael Berthe <mikael@lilotux.net>
parents:
735
diff
changeset
|
475 g_free(tmp); |
0d5fb1d9077c
Allow "bright" text colors
Mikael Berthe <mikael@lilotux.net>
parents:
735
diff
changeset
|
476 |
0d5fb1d9077c
Allow "bright" text colors
Mikael Berthe <mikael@lilotux.net>
parents:
735
diff
changeset
|
477 if (color) { |
0d5fb1d9077c
Allow "bright" text colors
Mikael Berthe <mikael@lilotux.net>
parents:
735
diff
changeset
|
478 if (!strncmp(color, "bright", 6)) { |
0d5fb1d9077c
Allow "bright" text colors
Mikael Berthe <mikael@lilotux.net>
parents:
735
diff
changeset
|
479 COLOR_ATTRIB[i+1] = A_BOLD; |
0d5fb1d9077c
Allow "bright" text colors
Mikael Berthe <mikael@lilotux.net>
parents:
735
diff
changeset
|
480 color += 6; |
0d5fb1d9077c
Allow "bright" text colors
Mikael Berthe <mikael@lilotux.net>
parents:
735
diff
changeset
|
481 } |
0d5fb1d9077c
Allow "bright" text colors
Mikael Berthe <mikael@lilotux.net>
parents:
735
diff
changeset
|
482 } |
24 | 483 |
484 switch (i + 1) { | |
739
0d5fb1d9077c
Allow "bright" text colors
Mikael Berthe <mikael@lilotux.net>
parents:
735
diff
changeset
|
485 case 1: |
0d5fb1d9077c
Allow "bright" text colors
Mikael Berthe <mikael@lilotux.net>
parents:
735
diff
changeset
|
486 init_pair(1, COLOR_BLACK, COLOR_WHITE); |
0d5fb1d9077c
Allow "bright" text colors
Mikael Berthe <mikael@lilotux.net>
parents:
735
diff
changeset
|
487 break; |
0d5fb1d9077c
Allow "bright" text colors
Mikael Berthe <mikael@lilotux.net>
parents:
735
diff
changeset
|
488 case 2: |
0d5fb1d9077c
Allow "bright" text colors
Mikael Berthe <mikael@lilotux.net>
parents:
735
diff
changeset
|
489 init_pair(2, COLOR_WHITE, COLOR_BLACK); |
0d5fb1d9077c
Allow "bright" text colors
Mikael Berthe <mikael@lilotux.net>
parents:
735
diff
changeset
|
490 break; |
0d5fb1d9077c
Allow "bright" text colors
Mikael Berthe <mikael@lilotux.net>
parents:
735
diff
changeset
|
491 case COLOR_GENERAL: |
1780
e4378fbab5d7
Major API cleanup - bump API to 4
Mikael Berthe <mikael@lilotux.net>
parents:
1761
diff
changeset
|
492 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
|
493 find_color(background)); |
739
0d5fb1d9077c
Allow "bright" text colors
Mikael Berthe <mikael@lilotux.net>
parents:
735
diff
changeset
|
494 break; |
785
7e0562e3bc83
Replace color_highlight with color_msgout
Mikael Berthe <mikael@lilotux.net>
parents:
779
diff
changeset
|
495 case COLOR_MSGOUT: |
1780
e4378fbab5d7
Major API cleanup - bump API to 4
Mikael Berthe <mikael@lilotux.net>
parents:
1761
diff
changeset
|
496 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
|
497 find_color(background)); |
739
0d5fb1d9077c
Allow "bright" text colors
Mikael Berthe <mikael@lilotux.net>
parents:
735
diff
changeset
|
498 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
|
499 case COLOR_MSGHL: |
1780
e4378fbab5d7
Major API cleanup - bump API to 4
Mikael Berthe <mikael@lilotux.net>
parents:
1761
diff
changeset
|
500 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
|
501 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
|
502 break; |
739
0d5fb1d9077c
Allow "bright" text colors
Mikael Berthe <mikael@lilotux.net>
parents:
735
diff
changeset
|
503 case COLOR_STATUS: |
1780
e4378fbab5d7
Major API cleanup - bump API to 4
Mikael Berthe <mikael@lilotux.net>
parents:
1761
diff
changeset
|
504 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
|
505 find_color(backstatus)); |
739
0d5fb1d9077c
Allow "bright" text colors
Mikael Berthe <mikael@lilotux.net>
parents:
735
diff
changeset
|
506 break; |
2028
7b5bd6ad83b4
Add 'color_log' (text color in the log window)
Mikael Berthe <mikael@lilotux.net>
parents:
2015
diff
changeset
|
507 case COLOR_LOG: |
7b5bd6ad83b4
Add 'color_log' (text color in the log window)
Mikael Berthe <mikael@lilotux.net>
parents:
2015
diff
changeset
|
508 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
|
509 find_color(background)); |
7b5bd6ad83b4
Add 'color_log' (text color in the log window)
Mikael Berthe <mikael@lilotux.net>
parents:
2015
diff
changeset
|
510 break; |
739
0d5fb1d9077c
Allow "bright" text colors
Mikael Berthe <mikael@lilotux.net>
parents:
735
diff
changeset
|
511 case COLOR_ROSTER: |
1780
e4378fbab5d7
Major API cleanup - bump API to 4
Mikael Berthe <mikael@lilotux.net>
parents:
1761
diff
changeset
|
512 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
|
513 find_color(background)); |
739
0d5fb1d9077c
Allow "bright" text colors
Mikael Berthe <mikael@lilotux.net>
parents:
735
diff
changeset
|
514 break; |
0d5fb1d9077c
Allow "bright" text colors
Mikael Berthe <mikael@lilotux.net>
parents:
735
diff
changeset
|
515 case COLOR_ROSTERSEL: |
1780
e4378fbab5d7
Major API cleanup - bump API to 4
Mikael Berthe <mikael@lilotux.net>
parents:
1761
diff
changeset
|
516 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
|
517 find_color(backselected)); |
739
0d5fb1d9077c
Allow "bright" text colors
Mikael Berthe <mikael@lilotux.net>
parents:
735
diff
changeset
|
518 break; |
0d5fb1d9077c
Allow "bright" text colors
Mikael Berthe <mikael@lilotux.net>
parents:
735
diff
changeset
|
519 case COLOR_ROSTERSELNMSG: |
1780
e4378fbab5d7
Major API cleanup - bump API to 4
Mikael Berthe <mikael@lilotux.net>
parents:
1761
diff
changeset
|
520 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
|
521 find_color(backselected)); |
739
0d5fb1d9077c
Allow "bright" text colors
Mikael Berthe <mikael@lilotux.net>
parents:
735
diff
changeset
|
522 break; |
0d5fb1d9077c
Allow "bright" text colors
Mikael Berthe <mikael@lilotux.net>
parents:
735
diff
changeset
|
523 case COLOR_ROSTERNMSG: |
1780
e4378fbab5d7
Major API cleanup - bump API to 4
Mikael Berthe <mikael@lilotux.net>
parents:
1761
diff
changeset
|
524 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
|
525 find_color(background)); |
739
0d5fb1d9077c
Allow "bright" text colors
Mikael Berthe <mikael@lilotux.net>
parents:
735
diff
changeset
|
526 break; |
1268
dbc907b2d92f
Add configurable colors for info and incoming messages (Michal 'vorner' Vaner)
Mikael Berthe <mikael@lilotux.net>
parents:
1254
diff
changeset
|
527 case COLOR_INFO: |
1780
e4378fbab5d7
Major API cleanup - bump API to 4
Mikael Berthe <mikael@lilotux.net>
parents:
1761
diff
changeset
|
528 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
|
529 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
|
530 break; |
dbc907b2d92f
Add configurable colors for info and incoming messages (Michal 'vorner' Vaner)
Mikael Berthe <mikael@lilotux.net>
parents:
1254
diff
changeset
|
531 case COLOR_MSGIN: |
1780
e4378fbab5d7
Major API cleanup - bump API to 4
Mikael Berthe <mikael@lilotux.net>
parents:
1761
diff
changeset
|
532 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
|
533 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
|
534 break; |
1960 | 535 case COLOR_READMARK: |
536 init_pair(i+1, ((color) ? find_color(color) : COLOR_RED), | |
537 find_color(background)); | |
538 break; | |
2090
16b04d64ec88
Add option to highlight timestamp added by server.
Hermitifier
parents:
2074
diff
changeset
|
539 case COLOR_TIMESTAMP: |
16b04d64ec88
Add option to highlight timestamp added by server.
Hermitifier
parents:
2074
diff
changeset
|
540 init_pair(i+1, ((color) ? find_color(color) : COLOR_WHITE), |
16b04d64ec88
Add option to highlight timestamp added by server.
Hermitifier
parents:
2074
diff
changeset
|
541 find_color(background)); |
16b04d64ec88
Add option to highlight timestamp added by server.
Hermitifier
parents:
2074
diff
changeset
|
542 break; |
24 | 543 } |
544 } | |
1489
e9c71ce96dca
Fixed the colorhandling for mucnicks and /color roster
franky@veqlargh.fs
parents:
1488
diff
changeset
|
545 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
|
546 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
|
547 |
1298
af035a304bec
colorable muc nick fix
Michal 'vorner' Vaner <vorner@ucw.cz>
parents:
1296
diff
changeset
|
548 if (!nickcols) { |
1314
248e3f69dd9e
Fix a bug in the nick_colors variable parsing
Mikael Berthe <mikael@lilotux.net>
parents:
1311
diff
changeset
|
549 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
|
550 if (ncolors) { |
1314
248e3f69dd9e
Fix a bug in the nick_colors variable parsing
Mikael Berthe <mikael@lilotux.net>
parents:
1311
diff
changeset
|
551 char *ncolor_start, *ncolor_end; |
248e3f69dd9e
Fix a bug in the nick_colors variable parsing
Mikael Berthe <mikael@lilotux.net>
parents:
1311
diff
changeset
|
552 ncolor_start = ncolor_end = ncolors; |
248e3f69dd9e
Fix a bug in the nick_colors variable parsing
Mikael Berthe <mikael@lilotux.net>
parents:
1311
diff
changeset
|
553 |
248e3f69dd9e
Fix a bug in the nick_colors variable parsing
Mikael Berthe <mikael@lilotux.net>
parents:
1311
diff
changeset
|
554 while (*ncolor_end) |
248e3f69dd9e
Fix a bug in the nick_colors variable parsing
Mikael Berthe <mikael@lilotux.net>
parents:
1311
diff
changeset
|
555 ncolor_end++; |
248e3f69dd9e
Fix a bug in the nick_colors variable parsing
Mikael Berthe <mikael@lilotux.net>
parents:
1311
diff
changeset
|
556 |
248e3f69dd9e
Fix a bug in the nick_colors variable parsing
Mikael Berthe <mikael@lilotux.net>
parents:
1311
diff
changeset
|
557 while (ncolors < ncolor_end && *ncolors) { |
1298
af035a304bec
colorable muc nick fix
Michal 'vorner' Vaner <vorner@ucw.cz>
parents:
1296
diff
changeset
|
558 if ((*ncolors == ' ') || (*ncolors == '\t')) { |
1314
248e3f69dd9e
Fix a bug in the nick_colors variable parsing
Mikael Berthe <mikael@lilotux.net>
parents:
1311
diff
changeset
|
559 ncolors++; |
1292
382ec54b584e
Muc nick coloring functionality
Michal 'vorner' Vaner <vorner@ucw.cz>
parents:
1291
diff
changeset
|
560 } else { |
1298
af035a304bec
colorable muc nick fix
Michal 'vorner' Vaner <vorner@ucw.cz>
parents:
1296
diff
changeset
|
561 char *end = ncolors; |
1598 | 562 ccolor *cl; |
1298
af035a304bec
colorable muc nick fix
Michal 'vorner' Vaner <vorner@ucw.cz>
parents:
1296
diff
changeset
|
563 while (*end && (*end != ' ') && (*end != '\t')) |
af035a304bec
colorable muc nick fix
Michal 'vorner' Vaner <vorner@ucw.cz>
parents:
1296
diff
changeset
|
564 end++; |
af035a304bec
colorable muc nick fix
Michal 'vorner' Vaner <vorner@ucw.cz>
parents:
1296
diff
changeset
|
565 *end = '\0'; |
1314
248e3f69dd9e
Fix a bug in the nick_colors variable parsing
Mikael Berthe <mikael@lilotux.net>
parents:
1311
diff
changeset
|
566 cl = get_user_color(ncolors); |
1489
e9c71ce96dca
Fixed the colorhandling for mucnicks and /color roster
franky@veqlargh.fs
parents:
1488
diff
changeset
|
567 if (!cl) { |
1298
af035a304bec
colorable muc nick fix
Michal 'vorner' Vaner <vorner@ucw.cz>
parents:
1296
diff
changeset
|
568 scr_LogPrint(LPRINT_NORMAL, "Unknown color %s", ncolors); |
af035a304bec
colorable muc nick fix
Michal 'vorner' Vaner <vorner@ucw.cz>
parents:
1296
diff
changeset
|
569 } else { |
af035a304bec
colorable muc nick fix
Michal 'vorner' Vaner <vorner@ucw.cz>
parents:
1296
diff
changeset
|
570 nickcols = g_realloc(nickcols, (++nickcolcount) * sizeof *nickcols); |
af035a304bec
colorable muc nick fix
Michal 'vorner' Vaner <vorner@ucw.cz>
parents:
1296
diff
changeset
|
571 nickcols[nickcolcount-1] = cl; |
af035a304bec
colorable muc nick fix
Michal 'vorner' Vaner <vorner@ucw.cz>
parents:
1296
diff
changeset
|
572 } |
1314
248e3f69dd9e
Fix a bug in the nick_colors variable parsing
Mikael Berthe <mikael@lilotux.net>
parents:
1311
diff
changeset
|
573 ncolors = end+1; |
1292
382ec54b584e
Muc nick coloring functionality
Michal 'vorner' Vaner <vorner@ucw.cz>
parents:
1291
diff
changeset
|
574 } |
382ec54b584e
Muc nick coloring functionality
Michal 'vorner' Vaner <vorner@ucw.cz>
parents:
1291
diff
changeset
|
575 } |
1298
af035a304bec
colorable muc nick fix
Michal 'vorner' Vaner <vorner@ucw.cz>
parents:
1296
diff
changeset
|
576 g_free(ncolor_start); |
1292
382ec54b584e
Muc nick coloring functionality
Michal 'vorner' Vaner <vorner@ucw.cz>
parents:
1291
diff
changeset
|
577 } |
1729
e6e89b1d7831
Minor style and header updates
Mikael Berthe <mikael@lilotux.net>
parents:
1710
diff
changeset
|
578 if (!nickcols) { // Fallback to have something |
1298
af035a304bec
colorable muc nick fix
Michal 'vorner' Vaner <vorner@ucw.cz>
parents:
1296
diff
changeset
|
579 nickcolcount = 1; |
1489
e9c71ce96dca
Fixed the colorhandling for mucnicks and /color roster
franky@veqlargh.fs
parents:
1488
diff
changeset
|
580 nickcols = g_new(ccolor*, 1); |
e9c71ce96dca
Fixed the colorhandling for mucnicks and /color roster
franky@veqlargh.fs
parents:
1488
diff
changeset
|
581 *nickcols = g_new(ccolor, 1); |
e9c71ce96dca
Fixed the colorhandling for mucnicks and /color roster
franky@veqlargh.fs
parents:
1488
diff
changeset
|
582 (*nickcols)->color_pair = COLOR_GENERAL; |
e9c71ce96dca
Fixed the colorhandling for mucnicks and /color roster
franky@veqlargh.fs
parents:
1488
diff
changeset
|
583 (*nickcols)->color_attrib = A_NORMAL; |
1298
af035a304bec
colorable muc nick fix
Michal 'vorner' Vaner <vorner@ucw.cz>
parents:
1296
diff
changeset
|
584 } |
1292
382ec54b584e
Muc nick coloring functionality
Michal 'vorner' Vaner <vorner@ucw.cz>
parents:
1291
diff
changeset
|
585 } |
1942
3e39a336a992
Use guards for colors (Myhailo Danylenko)
Mikael Berthe <mikael@lilotux.net>
parents:
1935
diff
changeset
|
586 |
3e39a336a992
Use guards for colors (Myhailo Danylenko)
Mikael Berthe <mikael@lilotux.net>
parents:
1935
diff
changeset
|
587 colors_stalled = FALSE; |
24 | 588 } |
589 | |
765
72626e9d60bd
Create init_keycodes(), add 2 screen escape sequences
Mikael Berthe <mikael@lilotux.net>
parents:
764
diff
changeset
|
590 static void init_keycodes(void) |
373
af2f8ddf6a1b
Move (reorganize) functions
Mikael Berthe <mikael@lilotux.net>
parents:
370
diff
changeset
|
591 { |
761
4532a9fe0e8c
Handle some keyboard escape sequences
Mikael Berthe <mikael@lilotux.net>
parents:
760
diff
changeset
|
592 add_keyseq("O5A", MKEY_EQUIV, 521); // Ctrl-Up |
4532a9fe0e8c
Handle some keyboard escape sequences
Mikael Berthe <mikael@lilotux.net>
parents:
760
diff
changeset
|
593 add_keyseq("O5B", MKEY_EQUIV, 514); // Ctrl-Down |
4532a9fe0e8c
Handle some keyboard escape sequences
Mikael Berthe <mikael@lilotux.net>
parents:
760
diff
changeset
|
594 add_keyseq("O5C", MKEY_EQUIV, 518); // Ctrl-Right |
4532a9fe0e8c
Handle some keyboard escape sequences
Mikael Berthe <mikael@lilotux.net>
parents:
760
diff
changeset
|
595 add_keyseq("O5D", MKEY_EQUIV, 516); // Ctrl-Left |
763 | 596 add_keyseq("O6A", MKEY_EQUIV, 520); // Shift-Up |
597 add_keyseq("O6B", MKEY_EQUIV, 513); // Shift-Down | |
598 add_keyseq("O6C", MKEY_EQUIV, 402); // Shift-Right | |
599 add_keyseq("O6D", MKEY_EQUIV, 393); // Shift-Left | |
600 add_keyseq("O2A", MKEY_EQUIV, 520); // Shift-Up | |
601 add_keyseq("O2B", MKEY_EQUIV, 513); // Shift-Down | |
602 add_keyseq("O2C", MKEY_EQUIV, 402); // Shift-Right | |
603 add_keyseq("O2D", MKEY_EQUIV, 393); // Shift-Left | |
604 add_keyseq("[5^", MKEY_CTRL_PGUP, 0); // Ctrl-PageUp | |
605 add_keyseq("[6^", MKEY_CTRL_PGDOWN, 0); // Ctrl-PageDown | |
606 add_keyseq("[5@", MKEY_CTRL_SHIFT_PGUP, 0); // Ctrl-Shift-PageUp | |
607 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
|
608 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
|
609 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
|
610 add_keyseq("[8^", MKEY_CTRL_END, 0); // Ctrl-End |
32d5298f9f8d
Add a few keycode sequences
Mikael Berthe <mikael@lilotux.net>
parents:
790
diff
changeset
|
611 add_keyseq("[7^", MKEY_CTRL_HOME, 0); // Ctrl-Home |
32d5298f9f8d
Add a few keycode sequences
Mikael Berthe <mikael@lilotux.net>
parents:
790
diff
changeset
|
612 add_keyseq("[2^", MKEY_CTRL_INS, 0); // Ctrl-Insert |
32d5298f9f8d
Add a few keycode sequences
Mikael Berthe <mikael@lilotux.net>
parents:
790
diff
changeset
|
613 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
|
614 |
4532a9fe0e8c
Handle some keyboard escape sequences
Mikael Berthe <mikael@lilotux.net>
parents:
760
diff
changeset
|
615 // Xterm |
4532a9fe0e8c
Handle some keyboard escape sequences
Mikael Berthe <mikael@lilotux.net>
parents:
760
diff
changeset
|
616 add_keyseq("[1;5A", MKEY_EQUIV, 521); // Ctrl-Up |
4532a9fe0e8c
Handle some keyboard escape sequences
Mikael Berthe <mikael@lilotux.net>
parents:
760
diff
changeset
|
617 add_keyseq("[1;5B", MKEY_EQUIV, 514); // Ctrl-Down |
4532a9fe0e8c
Handle some keyboard escape sequences
Mikael Berthe <mikael@lilotux.net>
parents:
760
diff
changeset
|
618 add_keyseq("[1;5C", MKEY_EQUIV, 518); // Ctrl-Right |
4532a9fe0e8c
Handle some keyboard escape sequences
Mikael Berthe <mikael@lilotux.net>
parents:
760
diff
changeset
|
619 add_keyseq("[1;5D", MKEY_EQUIV, 516); // Ctrl-Left |
4532a9fe0e8c
Handle some keyboard escape sequences
Mikael Berthe <mikael@lilotux.net>
parents:
760
diff
changeset
|
620 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
|
621 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
|
622 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
|
623 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
|
624 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
|
625 add_keyseq("[1;6F", MKEY_CTRL_SHIFT_END, 0); // Ctrl-Shift-End |
763 | 626 add_keyseq("[1;2A", MKEY_EQUIV, 521); // Shift-Up |
627 add_keyseq("[1;2B", MKEY_EQUIV, 514); // Shift-Down | |
628 add_keyseq("[5;5~", MKEY_CTRL_PGUP, 0); // Ctrl-PageUp | |
629 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
|
630 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
|
631 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
|
632 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
|
633 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
|
634 |
768
0f6d25a02450
Add PuTTY escape keys for Ctrl-arrows
Mikael Berthe <mikael@lilotux.net>
parents:
766
diff
changeset
|
635 // PuTTY |
0f6d25a02450
Add PuTTY escape keys for Ctrl-arrows
Mikael Berthe <mikael@lilotux.net>
parents:
766
diff
changeset
|
636 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
|
637 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
|
638 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
|
639 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
|
640 |
762
96d46e00524a
Add some key escape sequences for screen
Mikael Berthe <mikael@lilotux.net>
parents:
761
diff
changeset
|
641 // screen |
96d46e00524a
Add some key escape sequences for screen
Mikael Berthe <mikael@lilotux.net>
parents:
761
diff
changeset
|
642 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
|
643 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
|
644 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
|
645 add_keyseq("Od", MKEY_EQUIV, 516); // Ctrl-Left |
763 | 646 add_keyseq("[a", MKEY_EQUIV, 520); // Shift-Up |
647 add_keyseq("[b", MKEY_EQUIV, 513); // Shift-Down | |
648 add_keyseq("[c", MKEY_EQUIV, 402); // Shift-Right | |
649 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
|
650 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
|
651 add_keyseq("[6$", MKEY_SHIFT_PGDOWN, 0); // Shift-PageDown |
1170 | 652 |
653 // VT100 | |
654 add_keyseq("[H", MKEY_EQUIV, KEY_HOME); // Home | |
655 add_keyseq("[F", MKEY_EQUIV, KEY_END); // End | |
656 | |
657 // Konsole Linux | |
658 add_keyseq("[1~", MKEY_EQUIV, KEY_HOME); // Home | |
659 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
|
660 } |
72626e9d60bd
Create init_keycodes(), add 2 screen escape sequences
Mikael Berthe <mikael@lilotux.net>
parents:
764
diff
changeset
|
661 |
1176
547a8ca7c1a8
Move init_bindings() to screen.c, with a few updates
Mikael Berthe <mikael@lilotux.net>
parents:
1173
diff
changeset
|
662 // scr_init_bindings() |
547a8ca7c1a8
Move init_bindings() to screen.c, with a few updates
Mikael Berthe <mikael@lilotux.net>
parents:
1173
diff
changeset
|
663 // Create default key bindings |
547a8ca7c1a8
Move init_bindings() to screen.c, with a few updates
Mikael Berthe <mikael@lilotux.net>
parents:
1173
diff
changeset
|
664 // 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
|
665 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
|
666 { |
547a8ca7c1a8
Move init_bindings() to screen.c, with a few updates
Mikael Berthe <mikael@lilotux.net>
parents:
1173
diff
changeset
|
667 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
|
668 |
547a8ca7c1a8
Move init_bindings() to screen.c, with a few updates
Mikael Berthe <mikael@lilotux.net>
parents:
1173
diff
changeset
|
669 // 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
|
670 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
|
671 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
|
672 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
|
673 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
|
674 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
|
675 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
|
676 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
|
677 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
|
678 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
|
679 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
|
680 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
|
681 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
|
682 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
|
683 "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
|
684 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
|
685 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
|
686 "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
|
687 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
|
688 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
|
689 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
|
690 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
|
691 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
|
692 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
|
693 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
|
694 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
|
695 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
|
696 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
|
697 // 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
|
698 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
|
699 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
|
700 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
|
701 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
|
702 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
|
703 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
|
704 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
|
705 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
|
706 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
|
707 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
|
708 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
|
709 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
|
710 // Ctrl-Left (2 codes): |
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, "515", "iline bword"); |
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, "516", "iline bword"); |
547a8ca7c1a8
Move init_bindings() to screen.c, with a few updates
Mikael Berthe <mikael@lilotux.net>
parents:
1173
diff
changeset
|
713 // Ctrl-Right (2 codes): |
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, "517", "iline fword"); |
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, "518", "iline fword"); |
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, "12", "screen_refresh"); // Ctrl-l |
1503
c74cfe7fd848
Add option --show-roster to command chat_disable.
Mikael Berthe <mikael@lilotux.net>
parents:
1502
diff
changeset
|
717 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
|
718 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
|
719 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
|
720 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
|
721 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
|
722 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
|
723 |
1208
0dbe51d1e62e
Add default binding for F1 (265) to /help
Mikael Berthe <mikael@lilotux.net>
parents:
1205
diff
changeset
|
724 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
|
725 |
1176
547a8ca7c1a8
Move init_bindings() to screen.c, with a few updates
Mikael Berthe <mikael@lilotux.net>
parents:
1173
diff
changeset
|
726 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
|
727 } |
547a8ca7c1a8
Move init_bindings() to screen.c, with a few updates
Mikael Berthe <mikael@lilotux.net>
parents:
1173
diff
changeset
|
728 |
1229
e9ea1497ac9d
Fix a key binding issue on FreeBSD
Mikael Berthe <mikael@lilotux.net>
parents:
1228
diff
changeset
|
729 // is_speckey(key) |
e9ea1497ac9d
Fix a key binding issue on FreeBSD
Mikael Berthe <mikael@lilotux.net>
parents:
1228
diff
changeset
|
730 // 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
|
731 // 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
|
732 // isprint(KEY_PPAGE) returns TRUE... |
e9ea1497ac9d
Fix a key binding issue on FreeBSD
Mikael Berthe <mikael@lilotux.net>
parents:
1228
diff
changeset
|
733 static int is_speckey(int key) |
e9ea1497ac9d
Fix a key binding issue on FreeBSD
Mikael Berthe <mikael@lilotux.net>
parents:
1228
diff
changeset
|
734 { |
e9ea1497ac9d
Fix a key binding issue on FreeBSD
Mikael Berthe <mikael@lilotux.net>
parents:
1228
diff
changeset
|
735 switch (key) { |
e9ea1497ac9d
Fix a key binding issue on FreeBSD
Mikael Berthe <mikael@lilotux.net>
parents:
1228
diff
changeset
|
736 case 127: |
e9ea1497ac9d
Fix a key binding issue on FreeBSD
Mikael Berthe <mikael@lilotux.net>
parents:
1228
diff
changeset
|
737 case 393: |
e9ea1497ac9d
Fix a key binding issue on FreeBSD
Mikael Berthe <mikael@lilotux.net>
parents:
1228
diff
changeset
|
738 case 402: |
e9ea1497ac9d
Fix a key binding issue on FreeBSD
Mikael Berthe <mikael@lilotux.net>
parents:
1228
diff
changeset
|
739 case KEY_BACKSPACE: |
e9ea1497ac9d
Fix a key binding issue on FreeBSD
Mikael Berthe <mikael@lilotux.net>
parents:
1228
diff
changeset
|
740 case KEY_DC: |
e9ea1497ac9d
Fix a key binding issue on FreeBSD
Mikael Berthe <mikael@lilotux.net>
parents:
1228
diff
changeset
|
741 case KEY_LEFT: |
e9ea1497ac9d
Fix a key binding issue on FreeBSD
Mikael Berthe <mikael@lilotux.net>
parents:
1228
diff
changeset
|
742 case KEY_RIGHT: |
e9ea1497ac9d
Fix a key binding issue on FreeBSD
Mikael Berthe <mikael@lilotux.net>
parents:
1228
diff
changeset
|
743 case KEY_UP: |
e9ea1497ac9d
Fix a key binding issue on FreeBSD
Mikael Berthe <mikael@lilotux.net>
parents:
1228
diff
changeset
|
744 case KEY_DOWN: |
e9ea1497ac9d
Fix a key binding issue on FreeBSD
Mikael Berthe <mikael@lilotux.net>
parents:
1228
diff
changeset
|
745 case KEY_PPAGE: |
e9ea1497ac9d
Fix a key binding issue on FreeBSD
Mikael Berthe <mikael@lilotux.net>
parents:
1228
diff
changeset
|
746 case KEY_NPAGE: |
e9ea1497ac9d
Fix a key binding issue on FreeBSD
Mikael Berthe <mikael@lilotux.net>
parents:
1228
diff
changeset
|
747 case KEY_HOME: |
e9ea1497ac9d
Fix a key binding issue on FreeBSD
Mikael Berthe <mikael@lilotux.net>
parents:
1228
diff
changeset
|
748 case KEY_END: |
e9ea1497ac9d
Fix a key binding issue on FreeBSD
Mikael Berthe <mikael@lilotux.net>
parents:
1228
diff
changeset
|
749 case KEY_EOL: |
e9ea1497ac9d
Fix a key binding issue on FreeBSD
Mikael Berthe <mikael@lilotux.net>
parents:
1228
diff
changeset
|
750 return TRUE; |
e9ea1497ac9d
Fix a key binding issue on FreeBSD
Mikael Berthe <mikael@lilotux.net>
parents:
1228
diff
changeset
|
751 } |
e9ea1497ac9d
Fix a key binding issue on FreeBSD
Mikael Berthe <mikael@lilotux.net>
parents:
1228
diff
changeset
|
752 |
e9ea1497ac9d
Fix a key binding issue on FreeBSD
Mikael Berthe <mikael@lilotux.net>
parents:
1228
diff
changeset
|
753 // Fn keys |
e9ea1497ac9d
Fix a key binding issue on FreeBSD
Mikael Berthe <mikael@lilotux.net>
parents:
1228
diff
changeset
|
754 if (key >= 265 && key < 265+12) |
e9ea1497ac9d
Fix a key binding issue on FreeBSD
Mikael Berthe <mikael@lilotux.net>
parents:
1228
diff
changeset
|
755 return TRUE; |
e9ea1497ac9d
Fix a key binding issue on FreeBSD
Mikael Berthe <mikael@lilotux.net>
parents:
1228
diff
changeset
|
756 |
e9ea1497ac9d
Fix a key binding issue on FreeBSD
Mikael Berthe <mikael@lilotux.net>
parents:
1228
diff
changeset
|
757 // Special key combinations |
e9ea1497ac9d
Fix a key binding issue on FreeBSD
Mikael Berthe <mikael@lilotux.net>
parents:
1228
diff
changeset
|
758 if (key >= 513 && key <= 521) |
e9ea1497ac9d
Fix a key binding issue on FreeBSD
Mikael Berthe <mikael@lilotux.net>
parents:
1228
diff
changeset
|
759 return TRUE; |
e9ea1497ac9d
Fix a key binding issue on FreeBSD
Mikael Berthe <mikael@lilotux.net>
parents:
1228
diff
changeset
|
760 |
e9ea1497ac9d
Fix a key binding issue on FreeBSD
Mikael Berthe <mikael@lilotux.net>
parents:
1228
diff
changeset
|
761 return FALSE; |
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 |
1780
e4378fbab5d7
Major API cleanup - bump API to 4
Mikael Berthe <mikael@lilotux.net>
parents:
1761
diff
changeset
|
764 void scr_init_locale_charset(void) |
779
057ffe7c43dc
Initialize locale charset earlier
Mikael Berthe <mikael@lilotux.net>
parents:
773
diff
changeset
|
765 { |
1651
d0a0d96ed5d5
Set all locale variables
Myhailo Danylenko <isbear@ukrpost.net>
parents:
1602
diff
changeset
|
766 setlocale(LC_ALL, ""); |
1382
1447c5296977
Fix locale charset detection on some BSD systems
Mikael Berthe <mikael@lilotux.net>
parents:
1381
diff
changeset
|
767 #ifdef HAVE_LOCALCHARSET_H |
1447c5296977
Fix locale charset detection on some BSD systems
Mikael Berthe <mikael@lilotux.net>
parents:
1381
diff
changeset
|
768 LocaleCharSet = locale_charset(); |
1447c5296977
Fix locale charset detection on some BSD systems
Mikael Berthe <mikael@lilotux.net>
parents:
1381
diff
changeset
|
769 #else |
779
057ffe7c43dc
Initialize locale charset earlier
Mikael Berthe <mikael@lilotux.net>
parents:
773
diff
changeset
|
770 LocaleCharSet = nl_langinfo(CODESET); |
1382
1447c5296977
Fix locale charset detection on some BSD systems
Mikael Berthe <mikael@lilotux.net>
parents:
1381
diff
changeset
|
771 #endif |
779
057ffe7c43dc
Initialize locale charset earlier
Mikael Berthe <mikael@lilotux.net>
parents:
773
diff
changeset
|
772 utf8_mode = (strcmp(LocaleCharSet, "UTF-8") == 0); |
057ffe7c43dc
Initialize locale charset earlier
Mikael Berthe <mikael@lilotux.net>
parents:
773
diff
changeset
|
773 } |
057ffe7c43dc
Initialize locale charset earlier
Mikael Berthe <mikael@lilotux.net>
parents:
773
diff
changeset
|
774 |
1780
e4378fbab5d7
Major API cleanup - bump API to 4
Mikael Berthe <mikael@lilotux.net>
parents:
1761
diff
changeset
|
775 gboolean scr_curses_status(void) |
1733
a9b0364c0cb2
Fix segfault introduced in previous commit
Mikael Berthe <mikael@lilotux.net>
parents:
1729
diff
changeset
|
776 { |
a9b0364c0cb2
Fix segfault introduced in previous commit
Mikael Berthe <mikael@lilotux.net>
parents:
1729
diff
changeset
|
777 return Curses; |
a9b0364c0cb2
Fix segfault introduced in previous commit
Mikael Berthe <mikael@lilotux.net>
parents:
1729
diff
changeset
|
778 } |
a9b0364c0cb2
Fix segfault introduced in previous commit
Mikael Berthe <mikael@lilotux.net>
parents:
1729
diff
changeset
|
779 |
1942
3e39a336a992
Use guards for colors (Myhailo Danylenko)
Mikael Berthe <mikael@lilotux.net>
parents:
1935
diff
changeset
|
780 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
|
781 { |
3e39a336a992
Use guards for colors (Myhailo Danylenko)
Mikael Berthe <mikael@lilotux.net>
parents:
1935
diff
changeset
|
782 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
|
783 colors_stalled = TRUE; |
3e39a336a992
Use guards for colors (Myhailo Danylenko)
Mikael Berthe <mikael@lilotux.net>
parents:
1935
diff
changeset
|
784 return g_strdup(new_value); |
3e39a336a992
Use guards for colors (Myhailo Danylenko)
Mikael Berthe <mikael@lilotux.net>
parents:
1935
diff
changeset
|
785 } |
3e39a336a992
Use guards for colors (Myhailo Danylenko)
Mikael Berthe <mikael@lilotux.net>
parents:
1935
diff
changeset
|
786 |
1780
e4378fbab5d7
Major API cleanup - bump API to 4
Mikael Berthe <mikael@lilotux.net>
parents:
1761
diff
changeset
|
787 void scr_init_curses(void) |
765
72626e9d60bd
Create init_keycodes(), add 2 screen escape sequences
Mikael Berthe <mikael@lilotux.net>
parents:
764
diff
changeset
|
788 { |
72626e9d60bd
Create init_keycodes(), add 2 screen escape sequences
Mikael Berthe <mikael@lilotux.net>
parents:
764
diff
changeset
|
789 /* Key sequences initialization */ |
72626e9d60bd
Create init_keycodes(), add 2 screen escape sequences
Mikael Berthe <mikael@lilotux.net>
parents:
764
diff
changeset
|
790 init_keycodes(); |
762
96d46e00524a
Add some key escape sequences for screen
Mikael Berthe <mikael@lilotux.net>
parents:
761
diff
changeset
|
791 |
373
af2f8ddf6a1b
Move (reorganize) functions
Mikael Berthe <mikael@lilotux.net>
parents:
370
diff
changeset
|
792 initscr(); |
382
4c6e8392e465
Use nodelay() instead of halfdelay()
Mikael Berthe <mikael@lilotux.net>
parents:
374
diff
changeset
|
793 raw(); |
373
af2f8ddf6a1b
Move (reorganize) functions
Mikael Berthe <mikael@lilotux.net>
parents:
370
diff
changeset
|
794 noecho(); |
389
6e895f397474
Ncurses changes + Ctrl-C does not send a signal anylore
Mikael Berthe <mikael@lilotux.net>
parents:
388
diff
changeset
|
795 nonl(); |
6e895f397474
Ncurses changes + Ctrl-C does not send a signal anylore
Mikael Berthe <mikael@lilotux.net>
parents:
388
diff
changeset
|
796 intrflush(stdscr, FALSE); |
373
af2f8ddf6a1b
Move (reorganize) functions
Mikael Berthe <mikael@lilotux.net>
parents:
370
diff
changeset
|
797 start_color(); |
af2f8ddf6a1b
Move (reorganize) functions
Mikael Berthe <mikael@lilotux.net>
parents:
370
diff
changeset
|
798 use_default_colors(); |
1561 | 799 #ifdef NCURSES_MOUSE_VERSION |
1563 | 800 if (settings_opt_get_int("use_mouse")) |
801 mousemask(ALL_MOUSE_EVENTS, NULL); | |
1561 | 802 #endif |
373
af2f8ddf6a1b
Move (reorganize) functions
Mikael Berthe <mikael@lilotux.net>
parents:
370
diff
changeset
|
803 |
1386 | 804 if (settings_opt_get("escdelay")) { |
805 #ifdef HAVE_ESCDELAY | |
806 ESCDELAY = (unsigned) settings_opt_get_int("escdelay"); | |
807 #else | |
808 scr_LogPrint(LPRINT_LOGNORM, "ERROR: no ESCDELAY support."); | |
809 #endif | |
810 } | |
811 | |
1780
e4378fbab5d7
Major API cleanup - bump API to 4
Mikael Berthe <mikael@lilotux.net>
parents:
1761
diff
changeset
|
812 parse_colors(); |
373
af2f8ddf6a1b
Move (reorganize) functions
Mikael Berthe <mikael@lilotux.net>
parents:
370
diff
changeset
|
813 |
1942
3e39a336a992
Use guards for colors (Myhailo Danylenko)
Mikael Berthe <mikael@lilotux.net>
parents:
1935
diff
changeset
|
814 settings_set_guard("color_background", scr_color_guard); |
3e39a336a992
Use guards for colors (Myhailo Danylenko)
Mikael Berthe <mikael@lilotux.net>
parents:
1935
diff
changeset
|
815 settings_set_guard("color_general", scr_color_guard); |
3e39a336a992
Use guards for colors (Myhailo Danylenko)
Mikael Berthe <mikael@lilotux.net>
parents:
1935
diff
changeset
|
816 settings_set_guard("color_info", scr_color_guard); |
3e39a336a992
Use guards for colors (Myhailo Danylenko)
Mikael Berthe <mikael@lilotux.net>
parents:
1935
diff
changeset
|
817 settings_set_guard("color_msgin", scr_color_guard); |
3e39a336a992
Use guards for colors (Myhailo Danylenko)
Mikael Berthe <mikael@lilotux.net>
parents:
1935
diff
changeset
|
818 settings_set_guard("color_msgout", scr_color_guard); |
3e39a336a992
Use guards for colors (Myhailo Danylenko)
Mikael Berthe <mikael@lilotux.net>
parents:
1935
diff
changeset
|
819 settings_set_guard("color_msghl", scr_color_guard); |
3e39a336a992
Use guards for colors (Myhailo Danylenko)
Mikael Berthe <mikael@lilotux.net>
parents:
1935
diff
changeset
|
820 settings_set_guard("color_bgstatus", scr_color_guard); |
3e39a336a992
Use guards for colors (Myhailo Danylenko)
Mikael Berthe <mikael@lilotux.net>
parents:
1935
diff
changeset
|
821 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
|
822 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
|
823 settings_set_guard("color_roster", scr_color_guard); |
3e39a336a992
Use guards for colors (Myhailo Danylenko)
Mikael Berthe <mikael@lilotux.net>
parents:
1935
diff
changeset
|
824 settings_set_guard("color_bgrostersel", scr_color_guard); |
3e39a336a992
Use guards for colors (Myhailo Danylenko)
Mikael Berthe <mikael@lilotux.net>
parents:
1935
diff
changeset
|
825 settings_set_guard("color_rostersel", scr_color_guard); |
3e39a336a992
Use guards for colors (Myhailo Danylenko)
Mikael Berthe <mikael@lilotux.net>
parents:
1935
diff
changeset
|
826 settings_set_guard("color_rosterselmsg", scr_color_guard); |
3e39a336a992
Use guards for colors (Myhailo Danylenko)
Mikael Berthe <mikael@lilotux.net>
parents:
1935
diff
changeset
|
827 settings_set_guard("color_rosternewmsg", scr_color_guard); |
2090
16b04d64ec88
Add option to highlight timestamp added by server.
Hermitifier
parents:
2074
diff
changeset
|
828 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
|
829 |
373
af2f8ddf6a1b
Move (reorganize) functions
Mikael Berthe <mikael@lilotux.net>
parents:
370
diff
changeset
|
830 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
|
831 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
|
832 // 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
|
833 // 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
|
834 |
373
af2f8ddf6a1b
Move (reorganize) functions
Mikael Berthe <mikael@lilotux.net>
parents:
370
diff
changeset
|
835 inputLine[0] = 0; |
af2f8ddf6a1b
Move (reorganize) functions
Mikael Berthe <mikael@lilotux.net>
parents:
370
diff
changeset
|
836 ptr_inputline = inputLine; |
af2f8ddf6a1b
Move (reorganize) functions
Mikael Berthe <mikael@lilotux.net>
parents:
370
diff
changeset
|
837 |
966
d9acb7f2a3d1
Do not set Curses variable too early
Mikael Berthe <mikael@lilotux.net>
parents:
961
diff
changeset
|
838 Curses = TRUE; |
2149
1b3add57c912
Try to display the GLib warnings in the log window
Mikael Berthe <mikael@lilotux.net>
parents:
2143
diff
changeset
|
839 |
1b3add57c912
Try to display the GLib warnings in the log window
Mikael Berthe <mikael@lilotux.net>
parents:
2143
diff
changeset
|
840 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
|
841 return; |
af2f8ddf6a1b
Move (reorganize) functions
Mikael Berthe <mikael@lilotux.net>
parents:
370
diff
changeset
|
842 } |
af2f8ddf6a1b
Move (reorganize) functions
Mikael Berthe <mikael@lilotux.net>
parents:
370
diff
changeset
|
843 |
1780
e4378fbab5d7
Major API cleanup - bump API to 4
Mikael Berthe <mikael@lilotux.net>
parents:
1761
diff
changeset
|
844 void scr_terminate_curses(void) |
373
af2f8ddf6a1b
Move (reorganize) functions
Mikael Berthe <mikael@lilotux.net>
parents:
370
diff
changeset
|
845 { |
af2f8ddf6a1b
Move (reorganize) functions
Mikael Berthe <mikael@lilotux.net>
parents:
370
diff
changeset
|
846 if (!Curses) return; |
af2f8ddf6a1b
Move (reorganize) functions
Mikael Berthe <mikael@lilotux.net>
parents:
370
diff
changeset
|
847 clear(); |
af2f8ddf6a1b
Move (reorganize) functions
Mikael Berthe <mikael@lilotux.net>
parents:
370
diff
changeset
|
848 refresh(); |
af2f8ddf6a1b
Move (reorganize) functions
Mikael Berthe <mikael@lilotux.net>
parents:
370
diff
changeset
|
849 endwin(); |
af2f8ddf6a1b
Move (reorganize) functions
Mikael Berthe <mikael@lilotux.net>
parents:
370
diff
changeset
|
850 Curses = FALSE; |
af2f8ddf6a1b
Move (reorganize) functions
Mikael Berthe <mikael@lilotux.net>
parents:
370
diff
changeset
|
851 return; |
af2f8ddf6a1b
Move (reorganize) functions
Mikael Berthe <mikael@lilotux.net>
parents:
370
diff
changeset
|
852 } |
af2f8ddf6a1b
Move (reorganize) functions
Mikael Berthe <mikael@lilotux.net>
parents:
370
diff
changeset
|
853 |
1780
e4378fbab5d7
Major API cleanup - bump API to 4
Mikael Berthe <mikael@lilotux.net>
parents:
1761
diff
changeset
|
854 void scr_beep(void) |
675
ae7016aae014
New "beep_on_message" option
Mikael Berthe <mikael@lilotux.net>
parents:
667
diff
changeset
|
855 { |
ae7016aae014
New "beep_on_message" option
Mikael Berthe <mikael@lilotux.net>
parents:
667
diff
changeset
|
856 beep(); |
ae7016aae014
New "beep_on_message" option
Mikael Berthe <mikael@lilotux.net>
parents:
667
diff
changeset
|
857 } |
ae7016aae014
New "beep_on_message" option
Mikael Berthe <mikael@lilotux.net>
parents:
667
diff
changeset
|
858 |
1286
02ad6200df26
Add selectable time prefixes (vorner)
Mikael Berthe <mikael@lilotux.net>
parents:
1284
diff
changeset
|
859 // 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
|
860 static const char *timeprefixes[] = { |
02ad6200df26
Add selectable time prefixes (vorner)
Mikael Berthe <mikael@lilotux.net>
parents:
1284
diff
changeset
|
861 "%m-%d %H:%M ", |
02ad6200df26
Add selectable time prefixes (vorner)
Mikael Berthe <mikael@lilotux.net>
parents:
1284
diff
changeset
|
862 "%H:%M ", |
02ad6200df26
Add selectable time prefixes (vorner)
Mikael Berthe <mikael@lilotux.net>
parents:
1284
diff
changeset
|
863 " " |
02ad6200df26
Add selectable time prefixes (vorner)
Mikael Berthe <mikael@lilotux.net>
parents:
1284
diff
changeset
|
864 }; |
02ad6200df26
Add selectable time prefixes (vorner)
Mikael Berthe <mikael@lilotux.net>
parents:
1284
diff
changeset
|
865 |
02ad6200df26
Add selectable time prefixes (vorner)
Mikael Berthe <mikael@lilotux.net>
parents:
1284
diff
changeset
|
866 static const char *spectimeprefixes[] = { |
02ad6200df26
Add selectable time prefixes (vorner)
Mikael Berthe <mikael@lilotux.net>
parents:
1284
diff
changeset
|
867 "%m-%d %H:%M:%S ", |
02ad6200df26
Add selectable time prefixes (vorner)
Mikael Berthe <mikael@lilotux.net>
parents:
1284
diff
changeset
|
868 "%H:%M:%S ", |
02ad6200df26
Add selectable time prefixes (vorner)
Mikael Berthe <mikael@lilotux.net>
parents:
1284
diff
changeset
|
869 " " |
02ad6200df26
Add selectable time prefixes (vorner)
Mikael Berthe <mikael@lilotux.net>
parents:
1284
diff
changeset
|
870 }; |
02ad6200df26
Add selectable time prefixes (vorner)
Mikael Berthe <mikael@lilotux.net>
parents:
1284
diff
changeset
|
871 |
02ad6200df26
Add selectable time prefixes (vorner)
Mikael Berthe <mikael@lilotux.net>
parents:
1284
diff
changeset
|
872 static int timepreflengths[] = { |
1376
a0deb5124ebf
Check time_prefix value before using it
Mikael Berthe <mikael@lilotux.net>
parents:
1359
diff
changeset
|
873 // (length of the corresponding timeprefix + 5) |
1286
02ad6200df26
Add selectable time prefixes (vorner)
Mikael Berthe <mikael@lilotux.net>
parents:
1284
diff
changeset
|
874 17, |
02ad6200df26
Add selectable time prefixes (vorner)
Mikael Berthe <mikael@lilotux.net>
parents:
1284
diff
changeset
|
875 11, |
02ad6200df26
Add selectable time prefixes (vorner)
Mikael Berthe <mikael@lilotux.net>
parents:
1284
diff
changeset
|
876 6 |
02ad6200df26
Add selectable time prefixes (vorner)
Mikael Berthe <mikael@lilotux.net>
parents:
1284
diff
changeset
|
877 }; |
02ad6200df26
Add selectable time prefixes (vorner)
Mikael Berthe <mikael@lilotux.net>
parents:
1284
diff
changeset
|
878 |
1486
f83a51eaa5ed
Fix multiline output in /buffer save
Mikael Berthe <mikael@lilotux.net>
parents:
1485
diff
changeset
|
879 static const char *gettprefix(void) |
1286
02ad6200df26
Add selectable time prefixes (vorner)
Mikael Berthe <mikael@lilotux.net>
parents:
1284
diff
changeset
|
880 { |
1376
a0deb5124ebf
Check time_prefix value before using it
Mikael Berthe <mikael@lilotux.net>
parents:
1359
diff
changeset
|
881 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
|
882 return timeprefixes[(n < 3 ? n : 0)]; |
1286
02ad6200df26
Add selectable time prefixes (vorner)
Mikael Berthe <mikael@lilotux.net>
parents:
1284
diff
changeset
|
883 } |
02ad6200df26
Add selectable time prefixes (vorner)
Mikael Berthe <mikael@lilotux.net>
parents:
1284
diff
changeset
|
884 |
1486
f83a51eaa5ed
Fix multiline output in /buffer save
Mikael Berthe <mikael@lilotux.net>
parents:
1485
diff
changeset
|
885 static const char *getspectprefix(void) |
1286
02ad6200df26
Add selectable time prefixes (vorner)
Mikael Berthe <mikael@lilotux.net>
parents:
1284
diff
changeset
|
886 { |
1376
a0deb5124ebf
Check time_prefix value before using it
Mikael Berthe <mikael@lilotux.net>
parents:
1359
diff
changeset
|
887 guint n = settings_opt_get_int("time_prefix"); |
a0deb5124ebf
Check time_prefix value before using it
Mikael Berthe <mikael@lilotux.net>
parents:
1359
diff
changeset
|
888 return spectimeprefixes[(n < 3 ? n : 0)]; |
1286
02ad6200df26
Add selectable time prefixes (vorner)
Mikael Berthe <mikael@lilotux.net>
parents:
1284
diff
changeset
|
889 } |
02ad6200df26
Add selectable time prefixes (vorner)
Mikael Berthe <mikael@lilotux.net>
parents:
1284
diff
changeset
|
890 |
1487 | 891 guint scr_getprefixwidth(void) |
1286
02ad6200df26
Add selectable time prefixes (vorner)
Mikael Berthe <mikael@lilotux.net>
parents:
1284
diff
changeset
|
892 { |
1376
a0deb5124ebf
Check time_prefix value before using it
Mikael Berthe <mikael@lilotux.net>
parents:
1359
diff
changeset
|
893 guint n = settings_opt_get_int("time_prefix"); |
a0deb5124ebf
Check time_prefix value before using it
Mikael Berthe <mikael@lilotux.net>
parents:
1359
diff
changeset
|
894 return timepreflengths[(n < 3 ? n : 0)]; |
1286
02ad6200df26
Add selectable time prefixes (vorner)
Mikael Berthe <mikael@lilotux.net>
parents:
1284
diff
changeset
|
895 } |
02ad6200df26
Add selectable time prefixes (vorner)
Mikael Berthe <mikael@lilotux.net>
parents:
1284
diff
changeset
|
896 |
1761
61f0482d3993
Limit = alignment to 1/3 of screen in option list
Myhailo Danylenko <isbear@ukrpost.net>
parents:
1756
diff
changeset
|
897 guint scr_gettextwidth(void) |
61f0482d3993
Limit = alignment to 1/3 of screen in option list
Myhailo Danylenko <isbear@ukrpost.net>
parents:
1756
diff
changeset
|
898 { |
61f0482d3993
Limit = alignment to 1/3 of screen in option list
Myhailo Danylenko <isbear@ukrpost.net>
parents:
1756
diff
changeset
|
899 return maxX - Roster_Width - scr_getprefixwidth(); |
61f0482d3993
Limit = alignment to 1/3 of screen in option list
Myhailo Danylenko <isbear@ukrpost.net>
parents:
1756
diff
changeset
|
900 } |
61f0482d3993
Limit = alignment to 1/3 of screen in option list
Myhailo Danylenko <isbear@ukrpost.net>
parents:
1756
diff
changeset
|
901 |
1791
6e0a8bfb3a01
Add scr_gettextheight()
Myhailo Danylenko <isbear@ukrpost.net>
parents:
1783
diff
changeset
|
902 guint scr_gettextheight(void) |
6e0a8bfb3a01
Add scr_gettextheight()
Myhailo Danylenko <isbear@ukrpost.net>
parents:
1783
diff
changeset
|
903 { |
6e0a8bfb3a01
Add scr_gettextheight()
Myhailo Danylenko <isbear@ukrpost.net>
parents:
1783
diff
changeset
|
904 // log window, two status bars and one input line |
6e0a8bfb3a01
Add scr_gettextheight()
Myhailo Danylenko <isbear@ukrpost.net>
parents:
1783
diff
changeset
|
905 return maxY - Log_Win_Height - 3; |
6e0a8bfb3a01
Add scr_gettextheight()
Myhailo Danylenko <isbear@ukrpost.net>
parents:
1783
diff
changeset
|
906 } |
6e0a8bfb3a01
Add scr_gettextheight()
Myhailo Danylenko <isbear@ukrpost.net>
parents:
1783
diff
changeset
|
907 |
1819
d13315366ba5
Add scr_getlogwinheight()
Mikael Berthe <mikael@lilotux.net>
parents:
1815
diff
changeset
|
908 guint scr_getlogwinheight(void) |
d13315366ba5
Add scr_getlogwinheight()
Mikael Berthe <mikael@lilotux.net>
parents:
1815
diff
changeset
|
909 { |
d13315366ba5
Add scr_getlogwinheight()
Mikael Berthe <mikael@lilotux.net>
parents:
1815
diff
changeset
|
910 if (Log_Win_Height >= 2) |
d13315366ba5
Add scr_getlogwinheight()
Mikael Berthe <mikael@lilotux.net>
parents:
1815
diff
changeset
|
911 return Log_Win_Height - 2; |
d13315366ba5
Add scr_getlogwinheight()
Mikael Berthe <mikael@lilotux.net>
parents:
1815
diff
changeset
|
912 return 0; |
d13315366ba5
Add scr_getlogwinheight()
Mikael Berthe <mikael@lilotux.net>
parents:
1815
diff
changeset
|
913 } |
d13315366ba5
Add scr_getlogwinheight()
Mikael Berthe <mikael@lilotux.net>
parents:
1815
diff
changeset
|
914 |
1518
63dc211a4c1a
New command: /echo (display a message in the log window)
Mikael Berthe <mikael@lilotux.net>
parents:
1515
diff
changeset
|
915 // scr_print_logwindow(string) |
63dc211a4c1a
New command: /echo (display a message in the log window)
Mikael Berthe <mikael@lilotux.net>
parents:
1515
diff
changeset
|
916 // 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
|
917 // 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
|
918 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
|
919 { |
63dc211a4c1a
New command: /echo (display a message in the log window)
Mikael Berthe <mikael@lilotux.net>
parents:
1515
diff
changeset
|
920 time_t timestamp; |
63dc211a4c1a
New command: /echo (display a message in the log window)
Mikael Berthe <mikael@lilotux.net>
parents:
1515
diff
changeset
|
921 char strtimestamp[64]; |
63dc211a4c1a
New command: /echo (display a message in the log window)
Mikael Berthe <mikael@lilotux.net>
parents:
1515
diff
changeset
|
922 |
63dc211a4c1a
New command: /echo (display a message in the log window)
Mikael Berthe <mikael@lilotux.net>
parents:
1515
diff
changeset
|
923 timestamp = time(NULL); |
63dc211a4c1a
New command: /echo (display a message in the log window)
Mikael Berthe <mikael@lilotux.net>
parents:
1515
diff
changeset
|
924 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
|
925 if (Curses) { |
63dc211a4c1a
New command: /echo (display a message in the log window)
Mikael Berthe <mikael@lilotux.net>
parents:
1515
diff
changeset
|
926 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
|
927 update_panels(); |
63dc211a4c1a
New command: /echo (display a message in the log window)
Mikael Berthe <mikael@lilotux.net>
parents:
1515
diff
changeset
|
928 } else { |
63dc211a4c1a
New command: /echo (display a message in the log window)
Mikael Berthe <mikael@lilotux.net>
parents:
1515
diff
changeset
|
929 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
|
930 } |
63dc211a4c1a
New command: /echo (display a message in the log window)
Mikael Berthe <mikael@lilotux.net>
parents:
1515
diff
changeset
|
931 } |
63dc211a4c1a
New command: /echo (display a message in the log window)
Mikael Berthe <mikael@lilotux.net>
parents:
1515
diff
changeset
|
932 |
1783
af3de54ef986
Convert scr_LogPrint() to scr_log_print()
Mikael Berthe <mikael@lilotux.net>
parents:
1780
diff
changeset
|
933 // scr_log_print(...) |
1518
63dc211a4c1a
New command: /echo (display a message in the log window)
Mikael Berthe <mikael@lilotux.net>
parents:
1515
diff
changeset
|
934 // 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
|
935 // 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
|
936 // 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
|
937 void scr_log_print(unsigned int flag, const char *fmt, ...) |
373
af2f8ddf6a1b
Move (reorganize) functions
Mikael Berthe <mikael@lilotux.net>
parents:
370
diff
changeset
|
938 { |
af2f8ddf6a1b
Move (reorganize) functions
Mikael Berthe <mikael@lilotux.net>
parents:
370
diff
changeset
|
939 time_t timestamp; |
857
ef35a2bb40d7
scr_LogPrint(): do not use static buffer size
Mikael Berthe <mikael@lilotux.net>
parents:
851
diff
changeset
|
940 char strtimestamp[64]; |
858
2683ad5d1003
Improve scr_LogPrint() for log/debug messages
Mikael Berthe <mikael@lilotux.net>
parents:
857
diff
changeset
|
941 char *buffer, *btext; |
1075
03bc225ad763
Improve scr_LogPrint() readability
Mikael Berthe <mikael@lilotux.net>
parents:
1072
diff
changeset
|
942 char *convbuf1 = NULL, *convbuf2 = NULL; |
373
af2f8ddf6a1b
Move (reorganize) functions
Mikael Berthe <mikael@lilotux.net>
parents:
370
diff
changeset
|
943 va_list ap; |
af2f8ddf6a1b
Move (reorganize) functions
Mikael Berthe <mikael@lilotux.net>
parents:
370
diff
changeset
|
944 |
771
ce4f8a2129a4
scr_LogPrint() can display UTF-8 strings
Mikael Berthe <mikael@lilotux.net>
parents:
770
diff
changeset
|
945 if (!(flag & ~LPRINT_NOTUTF8)) return; // Shouldn't happen |
374
bd5638c21834
Improve logging system (traces)
Mikael Berthe <mikael@lilotux.net>
parents:
373
diff
changeset
|
946 |
857
ef35a2bb40d7
scr_LogPrint(): do not use static buffer size
Mikael Berthe <mikael@lilotux.net>
parents:
851
diff
changeset
|
947 timestamp = time(NULL); |
ef35a2bb40d7
scr_LogPrint(): do not use static buffer size
Mikael Berthe <mikael@lilotux.net>
parents:
851
diff
changeset
|
948 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
|
949 va_start(ap, fmt); |
858
2683ad5d1003
Improve scr_LogPrint() for log/debug messages
Mikael Berthe <mikael@lilotux.net>
parents:
857
diff
changeset
|
950 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
|
951 va_end(ap); |
373
af2f8ddf6a1b
Move (reorganize) functions
Mikael Berthe <mikael@lilotux.net>
parents:
370
diff
changeset
|
952 |
374
bd5638c21834
Improve logging system (traces)
Mikael Berthe <mikael@lilotux.net>
parents:
373
diff
changeset
|
953 if (flag & LPRINT_NORMAL) { |
771
ce4f8a2129a4
scr_LogPrint() can display UTF-8 strings
Mikael Berthe <mikael@lilotux.net>
parents:
770
diff
changeset
|
954 char *buffer_locale; |
851
da03534e46c7
Add startup log messages to the status buffer
Mikael Berthe <mikael@lilotux.net>
parents:
850
diff
changeset
|
955 char *buf_specialwindow; |
da03534e46c7
Add startup log messages to the status buffer
Mikael Berthe <mikael@lilotux.net>
parents:
850
diff
changeset
|
956 |
858
2683ad5d1003
Improve scr_LogPrint() for log/debug messages
Mikael Berthe <mikael@lilotux.net>
parents:
857
diff
changeset
|
957 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
|
958 |
851
da03534e46c7
Add startup log messages to the status buffer
Mikael Berthe <mikael@lilotux.net>
parents:
850
diff
changeset
|
959 // 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
|
960 if (!(flag & LPRINT_NOTUTF8)) |
1075
03bc225ad763
Improve scr_LogPrint() readability
Mikael Berthe <mikael@lilotux.net>
parents:
1072
diff
changeset
|
961 buffer_locale = convbuf1 = from_utf8(buffer); |
771
ce4f8a2129a4
scr_LogPrint() can display UTF-8 strings
Mikael Berthe <mikael@lilotux.net>
parents:
770
diff
changeset
|
962 else |
ce4f8a2129a4
scr_LogPrint() can display UTF-8 strings
Mikael Berthe <mikael@lilotux.net>
parents:
770
diff
changeset
|
963 buffer_locale = buffer; |
851
da03534e46c7
Add startup log messages to the status buffer
Mikael Berthe <mikael@lilotux.net>
parents:
850
diff
changeset
|
964 |
884
9e6d9f0cf9eb
scr_LogPrint(): Add a warning for UTF-8 -> locale conversion failures
Mikael Berthe <mikael@lilotux.net>
parents:
880
diff
changeset
|
965 if (!buffer_locale) { |
9e6d9f0cf9eb
scr_LogPrint(): Add a warning for UTF-8 -> locale conversion failures
Mikael Berthe <mikael@lilotux.net>
parents:
880
diff
changeset
|
966 wprintw(logWnd, |
9e6d9f0cf9eb
scr_LogPrint(): Add a warning for UTF-8 -> locale conversion failures
Mikael Berthe <mikael@lilotux.net>
parents:
880
diff
changeset
|
967 "\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
|
968 update_panels(); |
9e6d9f0cf9eb
scr_LogPrint(): Add a warning for UTF-8 -> locale conversion failures
Mikael Berthe <mikael@lilotux.net>
parents:
880
diff
changeset
|
969 g_free(buffer); |
897
a05b5a16a06a
Fix memory leak in scr_LogPrint()
Mikael Berthe <mikael@lilotux.net>
parents:
891
diff
changeset
|
970 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
|
971 return; |
9e6d9f0cf9eb
scr_LogPrint(): Add a warning for UTF-8 -> locale conversion failures
Mikael Berthe <mikael@lilotux.net>
parents:
880
diff
changeset
|
972 } |
9e6d9f0cf9eb
scr_LogPrint(): Add a warning for UTF-8 -> locale conversion failures
Mikael Berthe <mikael@lilotux.net>
parents:
880
diff
changeset
|
973 |
851
da03534e46c7
Add startup log messages to the status buffer
Mikael Berthe <mikael@lilotux.net>
parents:
850
diff
changeset
|
974 // 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
|
975 if (flag & LPRINT_NOTUTF8) |
1075
03bc225ad763
Improve scr_LogPrint() readability
Mikael Berthe <mikael@lilotux.net>
parents:
1072
diff
changeset
|
976 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
|
977 else |
858
2683ad5d1003
Improve scr_LogPrint() for log/debug messages
Mikael Berthe <mikael@lilotux.net>
parents:
857
diff
changeset
|
978 buf_specialwindow = btext; |
851
da03534e46c7
Add startup log messages to the status buffer
Mikael Berthe <mikael@lilotux.net>
parents:
850
diff
changeset
|
979 |
374
bd5638c21834
Improve logging system (traces)
Mikael Berthe <mikael@lilotux.net>
parents:
373
diff
changeset
|
980 if (Curses) { |
771
ce4f8a2129a4
scr_LogPrint() can display UTF-8 strings
Mikael Berthe <mikael@lilotux.net>
parents:
770
diff
changeset
|
981 wprintw(logWnd, "\n%s", buffer_locale); |
374
bd5638c21834
Improve logging system (traces)
Mikael Berthe <mikael@lilotux.net>
parents:
373
diff
changeset
|
982 update_panels(); |
1780
e4378fbab5d7
Major API cleanup - bump API to 4
Mikael Berthe <mikael@lilotux.net>
parents:
1761
diff
changeset
|
983 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
|
984 HBB_PREFIX_SPECIAL, FALSE, 0, NULL); |
374
bd5638c21834
Improve logging system (traces)
Mikael Berthe <mikael@lilotux.net>
parents:
373
diff
changeset
|
985 } else { |
771
ce4f8a2129a4
scr_LogPrint() can display UTF-8 strings
Mikael Berthe <mikael@lilotux.net>
parents:
770
diff
changeset
|
986 printf("%s\n", buffer_locale); |
851
da03534e46c7
Add startup log messages to the status buffer
Mikael Berthe <mikael@lilotux.net>
parents:
850
diff
changeset
|
987 // 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
|
988 hbuf_add_line(&statushbuf, buf_specialwindow, timestamp, |
1602 | 989 HBB_PREFIX_SPECIAL, 0, 0, 0, NULL); |
374
bd5638c21834
Improve logging system (traces)
Mikael Berthe <mikael@lilotux.net>
parents:
373
diff
changeset
|
990 } |
851
da03534e46c7
Add startup log messages to the status buffer
Mikael Berthe <mikael@lilotux.net>
parents:
850
diff
changeset
|
991 |
1075
03bc225ad763
Improve scr_LogPrint() readability
Mikael Berthe <mikael@lilotux.net>
parents:
1072
diff
changeset
|
992 g_free(convbuf1); |
03bc225ad763
Improve scr_LogPrint() readability
Mikael Berthe <mikael@lilotux.net>
parents:
1072
diff
changeset
|
993 g_free(convbuf2); |
858
2683ad5d1003
Improve scr_LogPrint() for log/debug messages
Mikael Berthe <mikael@lilotux.net>
parents:
857
diff
changeset
|
994 g_free(buffer); |
374
bd5638c21834
Improve logging system (traces)
Mikael Berthe <mikael@lilotux.net>
parents:
373
diff
changeset
|
995 } |
412
9c640ee3bae3
Display full date in the log file
Mikael Berthe <mikael@lilotux.net>
parents:
393
diff
changeset
|
996 |
857
ef35a2bb40d7
scr_LogPrint(): do not use static buffer size
Mikael Berthe <mikael@lilotux.net>
parents:
851
diff
changeset
|
997 if (flag & (LPRINT_LOG|LPRINT_DEBUG)) { |
ef35a2bb40d7
scr_LogPrint(): do not use static buffer size
Mikael Berthe <mikael@lilotux.net>
parents:
851
diff
changeset
|
998 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
|
999 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
|
1000 ut_write_log(flag, buffer); |
857
ef35a2bb40d7
scr_LogPrint(): do not use static buffer size
Mikael Berthe <mikael@lilotux.net>
parents:
851
diff
changeset
|
1001 g_free(buffer); |
373
af2f8ddf6a1b
Move (reorganize) functions
Mikael Berthe <mikael@lilotux.net>
parents:
370
diff
changeset
|
1002 } |
897
a05b5a16a06a
Fix memory leak in scr_LogPrint()
Mikael Berthe <mikael@lilotux.net>
parents:
891
diff
changeset
|
1003 g_free(btext); |
373
af2f8ddf6a1b
Move (reorganize) functions
Mikael Berthe <mikael@lilotux.net>
parents:
370
diff
changeset
|
1004 } |
af2f8ddf6a1b
Move (reorganize) functions
Mikael Berthe <mikael@lilotux.net>
parents:
370
diff
changeset
|
1005 |
2149
1b3add57c912
Try to display the GLib warnings in the log window
Mikael Berthe <mikael@lilotux.net>
parents:
2143
diff
changeset
|
1006 // 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
|
1007 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
|
1008 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
|
1009 { |
1b3add57c912
Try to display the GLib warnings in the log window
Mikael Berthe <mikael@lilotux.net>
parents:
2143
diff
changeset
|
1010 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
|
1011 } |
1b3add57c912
Try to display the GLib warnings in the log window
Mikael Berthe <mikael@lilotux.net>
parents:
2143
diff
changeset
|
1012 |
1780
e4378fbab5d7
Major API cleanup - bump API to 4
Mikael Berthe <mikael@lilotux.net>
parents:
1761
diff
changeset
|
1013 static winbuf *scr_search_window(const char *winId, int special) |
1156
cae430fcd385
Mcabber will load symlinked histories only once, now.
Frank Zschockelt
parents:
1154
diff
changeset
|
1014 { |
cae430fcd385
Mcabber will load symlinked histories only once, now.
Frank Zschockelt
parents:
1154
diff
changeset
|
1015 char *id; |
cae430fcd385
Mcabber will load symlinked histories only once, now.
Frank Zschockelt
parents:
1154
diff
changeset
|
1016 winbuf *wbp; |
cae430fcd385
Mcabber will load symlinked histories only once, now.
Frank Zschockelt
parents:
1154
diff
changeset
|
1017 |
cae430fcd385
Mcabber will load symlinked histories only once, now.
Frank Zschockelt
parents:
1154
diff
changeset
|
1018 if (special) |
cae430fcd385
Mcabber will load symlinked histories only once, now.
Frank Zschockelt
parents:
1154
diff
changeset
|
1019 return statusWindow; // Only one special window atm. |
cae430fcd385
Mcabber will load symlinked histories only once, now.
Frank Zschockelt
parents:
1154
diff
changeset
|
1020 |
cae430fcd385
Mcabber will load symlinked histories only once, now.
Frank Zschockelt
parents:
1154
diff
changeset
|
1021 if (!winId) |
cae430fcd385
Mcabber will load symlinked histories only once, now.
Frank Zschockelt
parents:
1154
diff
changeset
|
1022 return NULL; |
cae430fcd385
Mcabber will load symlinked histories only once, now.
Frank Zschockelt
parents:
1154
diff
changeset
|
1023 |
cae430fcd385
Mcabber will load symlinked histories only once, now.
Frank Zschockelt
parents:
1154
diff
changeset
|
1024 id = g_strdup(winId); |
cae430fcd385
Mcabber will load symlinked histories only once, now.
Frank Zschockelt
parents:
1154
diff
changeset
|
1025 mc_strtolower(id); |
cae430fcd385
Mcabber will load symlinked histories only once, now.
Frank Zschockelt
parents:
1154
diff
changeset
|
1026 wbp = g_hash_table_lookup(winbufhash, id); |
cae430fcd385
Mcabber will load symlinked histories only once, now.
Frank Zschockelt
parents:
1154
diff
changeset
|
1027 g_free(id); |
cae430fcd385
Mcabber will load symlinked histories only once, now.
Frank Zschockelt
parents:
1154
diff
changeset
|
1028 return wbp; |
cae430fcd385
Mcabber will load symlinked histories only once, now.
Frank Zschockelt
parents:
1154
diff
changeset
|
1029 } |
cae430fcd385
Mcabber will load symlinked histories only once, now.
Frank Zschockelt
parents:
1154
diff
changeset
|
1030 |
1780
e4378fbab5d7
Major API cleanup - bump API to 4
Mikael Berthe <mikael@lilotux.net>
parents:
1761
diff
changeset
|
1031 int scr_buddy_buffer_exists(const char *bjid) |
1156
cae430fcd385
Mcabber will load symlinked histories only once, now.
Frank Zschockelt
parents:
1154
diff
changeset
|
1032 { |
1780
e4378fbab5d7
Major API cleanup - bump API to 4
Mikael Berthe <mikael@lilotux.net>
parents:
1761
diff
changeset
|
1033 return (scr_search_window(bjid, FALSE) != NULL); |
1156
cae430fcd385
Mcabber will load symlinked histories only once, now.
Frank Zschockelt
parents:
1154
diff
changeset
|
1034 } |
cae430fcd385
Mcabber will load symlinked histories only once, now.
Frank Zschockelt
parents:
1154
diff
changeset
|
1035 |
1133
9dd28a56128f
Do not create one panel per contact
Mikael Berthe <mikael@lilotux.net>
parents:
1131
diff
changeset
|
1036 // scr_new_buddy(title, dontshow) |
1139 | 1037 // Note: title (aka winId/jid) can be NULL for special buffers |
1133
9dd28a56128f
Do not create one panel per contact
Mikael Berthe <mikael@lilotux.net>
parents:
1131
diff
changeset
|
1038 static winbuf *scr_new_buddy(const char *title, int dont_show) |
24 | 1039 { |
822 | 1040 winbuf *tmp; |
393 | 1041 |
822 | 1042 tmp = g_new0(winbuf, 1); |
24 | 1043 |
1133
9dd28a56128f
Do not create one panel per contact
Mikael Berthe <mikael@lilotux.net>
parents:
1131
diff
changeset
|
1044 tmp->win = activechatWnd; |
9dd28a56128f
Do not create one panel per contact
Mikael Berthe <mikael@lilotux.net>
parents:
1131
diff
changeset
|
1045 tmp->panel = activechatPanel; |
24 | 1046 |
143 | 1047 if (!dont_show) { |
24 | 1048 currentWindow = tmp; |
1049 } else { | |
1050 if (currentWindow) | |
1051 top_panel(currentWindow->panel); | |
1052 else | |
1053 top_panel(chatPanel); | |
1054 } | |
143 | 1055 update_panels(); |
24 | 1056 |
849
42c43a88d823
Status buffer management
Mikael Berthe <mikael@lilotux.net>
parents:
848
diff
changeset
|
1057 // If title is NULL, this is a special buffer |
42c43a88d823
Status buffer management
Mikael Berthe <mikael@lilotux.net>
parents:
848
diff
changeset
|
1058 if (title) { |
1078
7866dbaf67a6
Use a hash for the list of win buffers
Mikael Berthe <mikael@lilotux.net>
parents:
1077
diff
changeset
|
1059 char *id; |
1156
cae430fcd385
Mcabber will load symlinked histories only once, now.
Frank Zschockelt
parents:
1154
diff
changeset
|
1060 id = hlog_get_log_jid(title); |
cae430fcd385
Mcabber will load symlinked histories only once, now.
Frank Zschockelt
parents:
1154
diff
changeset
|
1061 if (id) { |
1780
e4378fbab5d7
Major API cleanup - bump API to 4
Mikael Berthe <mikael@lilotux.net>
parents:
1761
diff
changeset
|
1062 winbuf *wb = scr_search_window(id, FALSE); |
1160
14f5876b5555
Slight optimization + line wrapping
Mikael Berthe <mikael@lilotux.net>
parents:
1159
diff
changeset
|
1063 if (!wb) |
14f5876b5555
Slight optimization + line wrapping
Mikael Berthe <mikael@lilotux.net>
parents:
1159
diff
changeset
|
1064 wb = scr_new_buddy(id, TRUE); |
14f5876b5555
Slight optimization + line wrapping
Mikael Berthe <mikael@lilotux.net>
parents:
1159
diff
changeset
|
1065 tmp->bd=wb->bd; |
1156
cae430fcd385
Mcabber will load symlinked histories only once, now.
Frank Zschockelt
parents:
1154
diff
changeset
|
1066 g_free(id); |
1159
53c0c5be43fa
Small fixes, typos and cleanups
Mikael Berthe <mikael@lilotux.net>
parents:
1157
diff
changeset
|
1067 } else { // Load buddy history from file (if enabled) |
1157
5c857f0f0ab8
Moved all variables related to hbuf to an extra struct, bufdata
Frank Zschockelt
parents:
1156
diff
changeset
|
1068 tmp->bd = g_new0(buffdata, 1); |
1159
53c0c5be43fa
Small fixes, typos and cleanups
Mikael Berthe <mikael@lilotux.net>
parents:
1157
diff
changeset
|
1069 hlog_read_history(title, &tmp->bd->hbuf, |
1487 | 1070 maxX - Roster_Width - scr_getprefixwidth()); |
1965
ec737f5f1d6f
Couple of readmark-related bugfixes
Mikael Berthe <mikael@lilotux.net>
parents:
1961
diff
changeset
|
1071 |
ec737f5f1d6f
Couple of readmark-related bugfixes
Mikael Berthe <mikael@lilotux.net>
parents:
1961
diff
changeset
|
1072 // Set a readmark to separate new content |
ec737f5f1d6f
Couple of readmark-related bugfixes
Mikael Berthe <mikael@lilotux.net>
parents:
1961
diff
changeset
|
1073 hbuf_set_readmark(tmp->bd->hbuf, TRUE); |
1157
5c857f0f0ab8
Moved all variables related to hbuf to an extra struct, bufdata
Frank Zschockelt
parents:
1156
diff
changeset
|
1074 } |
181 | 1075 |
1078
7866dbaf67a6
Use a hash for the list of win buffers
Mikael Berthe <mikael@lilotux.net>
parents:
1077
diff
changeset
|
1076 id = g_strdup(title); |
7866dbaf67a6
Use a hash for the list of win buffers
Mikael Berthe <mikael@lilotux.net>
parents:
1077
diff
changeset
|
1077 mc_strtolower(id); |
7866dbaf67a6
Use a hash for the list of win buffers
Mikael Berthe <mikael@lilotux.net>
parents:
1077
diff
changeset
|
1078 g_hash_table_insert(winbufhash, id, tmp); |
1157
5c857f0f0ab8
Moved all variables related to hbuf to an extra struct, bufdata
Frank Zschockelt
parents:
1156
diff
changeset
|
1079 } else { |
1159
53c0c5be43fa
Small fixes, typos and cleanups
Mikael Berthe <mikael@lilotux.net>
parents:
1157
diff
changeset
|
1080 tmp->bd = g_new0(buffdata, 1); |
849
42c43a88d823
Status buffer management
Mikael Berthe <mikael@lilotux.net>
parents:
848
diff
changeset
|
1081 } |
24 | 1082 return tmp; |
1083 } | |
1084 | |
1483
e74cc83e7158
Refactor scr_UpdateWindow()
Mikael Berthe <mikael@lilotux.net>
parents:
1476
diff
changeset
|
1085 // scr_line_prefix(line, pref, preflen) |
e74cc83e7158
Refactor scr_UpdateWindow()
Mikael Berthe <mikael@lilotux.net>
parents:
1476
diff
changeset
|
1086 // Use data from the hbb_line structure and write the prefix |
e74cc83e7158
Refactor scr_UpdateWindow()
Mikael Berthe <mikael@lilotux.net>
parents:
1476
diff
changeset
|
1087 // to pref (not exceeding preflen, trailing null byte included). |
2090
16b04d64ec88
Add option to highlight timestamp added by server.
Hermitifier
parents:
2074
diff
changeset
|
1088 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
|
1089 { |
e74cc83e7158
Refactor scr_UpdateWindow()
Mikael Berthe <mikael@lilotux.net>
parents:
1476
diff
changeset
|
1090 char date[64]; |
2090
16b04d64ec88
Add option to highlight timestamp added by server.
Hermitifier
parents:
2074
diff
changeset
|
1091 size_t timepreflen = 0; |
1483
e74cc83e7158
Refactor scr_UpdateWindow()
Mikael Berthe <mikael@lilotux.net>
parents:
1476
diff
changeset
|
1092 |
e74cc83e7158
Refactor scr_UpdateWindow()
Mikael Berthe <mikael@lilotux.net>
parents:
1476
diff
changeset
|
1093 if (line->timestamp && |
e74cc83e7158
Refactor scr_UpdateWindow()
Mikael Berthe <mikael@lilotux.net>
parents:
1476
diff
changeset
|
1094 !(line->flags & (HBB_PREFIX_SPECIAL|HBB_PREFIX_CONT))) { |
2090
16b04d64ec88
Add option to highlight timestamp added by server.
Hermitifier
parents:
2074
diff
changeset
|
1095 timepreflen = strftime(date, 30, gettprefix(), localtime(&line->timestamp)); |
1483
e74cc83e7158
Refactor scr_UpdateWindow()
Mikael Berthe <mikael@lilotux.net>
parents:
1476
diff
changeset
|
1096 } else |
e74cc83e7158
Refactor scr_UpdateWindow()
Mikael Berthe <mikael@lilotux.net>
parents:
1476
diff
changeset
|
1097 strcpy(date, " "); |
e74cc83e7158
Refactor scr_UpdateWindow()
Mikael Berthe <mikael@lilotux.net>
parents:
1476
diff
changeset
|
1098 |
e74cc83e7158
Refactor scr_UpdateWindow()
Mikael Berthe <mikael@lilotux.net>
parents:
1476
diff
changeset
|
1099 if (!(line->flags & HBB_PREFIX_CONT)) { |
e74cc83e7158
Refactor scr_UpdateWindow()
Mikael Berthe <mikael@lilotux.net>
parents:
1476
diff
changeset
|
1100 if (line->flags & HBB_PREFIX_INFO) { |
e74cc83e7158
Refactor scr_UpdateWindow()
Mikael Berthe <mikael@lilotux.net>
parents:
1476
diff
changeset
|
1101 char dir = '*'; |
e74cc83e7158
Refactor scr_UpdateWindow()
Mikael Berthe <mikael@lilotux.net>
parents:
1476
diff
changeset
|
1102 if (line->flags & HBB_PREFIX_IN) |
e74cc83e7158
Refactor scr_UpdateWindow()
Mikael Berthe <mikael@lilotux.net>
parents:
1476
diff
changeset
|
1103 dir = '<'; |
e74cc83e7158
Refactor scr_UpdateWindow()
Mikael Berthe <mikael@lilotux.net>
parents:
1476
diff
changeset
|
1104 else if (line->flags & HBB_PREFIX_OUT) |
e74cc83e7158
Refactor scr_UpdateWindow()
Mikael Berthe <mikael@lilotux.net>
parents:
1476
diff
changeset
|
1105 dir = '>'; |
e74cc83e7158
Refactor scr_UpdateWindow()
Mikael Berthe <mikael@lilotux.net>
parents:
1476
diff
changeset
|
1106 g_snprintf(pref, preflen, "%s*%c* ", date, dir); |
e74cc83e7158
Refactor scr_UpdateWindow()
Mikael Berthe <mikael@lilotux.net>
parents:
1476
diff
changeset
|
1107 } else if (line->flags & HBB_PREFIX_ERR) { |
e74cc83e7158
Refactor scr_UpdateWindow()
Mikael Berthe <mikael@lilotux.net>
parents:
1476
diff
changeset
|
1108 char dir = '#'; |
e74cc83e7158
Refactor scr_UpdateWindow()
Mikael Berthe <mikael@lilotux.net>
parents:
1476
diff
changeset
|
1109 if (line->flags & HBB_PREFIX_IN) |
e74cc83e7158
Refactor scr_UpdateWindow()
Mikael Berthe <mikael@lilotux.net>
parents:
1476
diff
changeset
|
1110 dir = '<'; |
e74cc83e7158
Refactor scr_UpdateWindow()
Mikael Berthe <mikael@lilotux.net>
parents:
1476
diff
changeset
|
1111 else if (line->flags & HBB_PREFIX_OUT) |
e74cc83e7158
Refactor scr_UpdateWindow()
Mikael Berthe <mikael@lilotux.net>
parents:
1476
diff
changeset
|
1112 dir = '>'; |
e74cc83e7158
Refactor scr_UpdateWindow()
Mikael Berthe <mikael@lilotux.net>
parents:
1476
diff
changeset
|
1113 g_snprintf(pref, preflen, "%s#%c# ", date, dir); |
e74cc83e7158
Refactor scr_UpdateWindow()
Mikael Berthe <mikael@lilotux.net>
parents:
1476
diff
changeset
|
1114 } 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
|
1115 char cryptflag; |
7b36b91a4388
New UI message flag (O) when OTR is used
Mikael Berthe <mikael@lilotux.net>
parents:
1483
diff
changeset
|
1116 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
|
1117 cryptflag = '~'; |
7b36b91a4388
New UI message flag (O) when OTR is used
Mikael Berthe <mikael@lilotux.net>
parents:
1483
diff
changeset
|
1118 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
|
1119 cryptflag = 'O'; |
7b36b91a4388
New UI message flag (O) when OTR is used
Mikael Berthe <mikael@lilotux.net>
parents:
1483
diff
changeset
|
1120 else |
7b36b91a4388
New UI message flag (O) when OTR is used
Mikael Berthe <mikael@lilotux.net>
parents:
1483
diff
changeset
|
1121 cryptflag = '='; |
1483
e74cc83e7158
Refactor scr_UpdateWindow()
Mikael Berthe <mikael@lilotux.net>
parents:
1476
diff
changeset
|
1122 g_snprintf(pref, preflen, "%s<%c= ", date, cryptflag); |
e74cc83e7158
Refactor scr_UpdateWindow()
Mikael Berthe <mikael@lilotux.net>
parents:
1476
diff
changeset
|
1123 } else if (line->flags & HBB_PREFIX_OUT) { |
1602 | 1124 char cryptflag, receiptflag; |
1484
7b36b91a4388
New UI message flag (O) when OTR is used
Mikael Berthe <mikael@lilotux.net>
parents:
1483
diff
changeset
|
1125 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
|
1126 cryptflag = '~'; |
7b36b91a4388
New UI message flag (O) when OTR is used
Mikael Berthe <mikael@lilotux.net>
parents:
1483
diff
changeset
|
1127 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
|
1128 cryptflag = 'O'; |
7b36b91a4388
New UI message flag (O) when OTR is used
Mikael Berthe <mikael@lilotux.net>
parents:
1483
diff
changeset
|
1129 else |
1488
b393b8cee171
Fix small mistake in changeset 7b36b91a4388
Mikael Berthe <mikael@lilotux.net>
parents:
1487
diff
changeset
|
1130 cryptflag = '-'; |
1602 | 1131 if (line->flags & HBB_PREFIX_RECEIPT) |
1132 receiptflag = 'r'; | |
1133 else | |
1134 receiptflag = '-'; | |
1135 g_snprintf(pref, preflen, "%s%c%c> ", date, receiptflag, cryptflag); | |
1483
e74cc83e7158
Refactor scr_UpdateWindow()
Mikael Berthe <mikael@lilotux.net>
parents:
1476
diff
changeset
|
1136 } else if (line->flags & HBB_PREFIX_SPECIAL) { |
2090
16b04d64ec88
Add option to highlight timestamp added by server.
Hermitifier
parents:
2074
diff
changeset
|
1137 timepreflen = strftime(date, 30, getspectprefix(), localtime(&line->timestamp)); |
1483
e74cc83e7158
Refactor scr_UpdateWindow()
Mikael Berthe <mikael@lilotux.net>
parents:
1476
diff
changeset
|
1138 g_snprintf(pref, preflen, "%s ", date); |
e74cc83e7158
Refactor scr_UpdateWindow()
Mikael Berthe <mikael@lilotux.net>
parents:
1476
diff
changeset
|
1139 } else { |
e74cc83e7158
Refactor scr_UpdateWindow()
Mikael Berthe <mikael@lilotux.net>
parents:
1476
diff
changeset
|
1140 g_snprintf(pref, preflen, "%s ", date); |
e74cc83e7158
Refactor scr_UpdateWindow()
Mikael Berthe <mikael@lilotux.net>
parents:
1476
diff
changeset
|
1141 } |
e74cc83e7158
Refactor scr_UpdateWindow()
Mikael Berthe <mikael@lilotux.net>
parents:
1476
diff
changeset
|
1142 } else { |
e74cc83e7158
Refactor scr_UpdateWindow()
Mikael Berthe <mikael@lilotux.net>
parents:
1476
diff
changeset
|
1143 g_snprintf(pref, preflen, " "); |
e74cc83e7158
Refactor scr_UpdateWindow()
Mikael Berthe <mikael@lilotux.net>
parents:
1476
diff
changeset
|
1144 } |
2090
16b04d64ec88
Add option to highlight timestamp added by server.
Hermitifier
parents:
2074
diff
changeset
|
1145 return timepreflen; |
1483
e74cc83e7158
Refactor scr_UpdateWindow()
Mikael Berthe <mikael@lilotux.net>
parents:
1476
diff
changeset
|
1146 } |
e74cc83e7158
Refactor scr_UpdateWindow()
Mikael Berthe <mikael@lilotux.net>
parents:
1476
diff
changeset
|
1147 |
1780
e4378fbab5d7
Major API cleanup - bump API to 4
Mikael Berthe <mikael@lilotux.net>
parents:
1761
diff
changeset
|
1148 // scr_update_window() |
143 | 1149 // (Re-)Display the given chat window. |
1780
e4378fbab5d7
Major API cleanup - bump API to 4
Mikael Berthe <mikael@lilotux.net>
parents:
1761
diff
changeset
|
1150 static void scr_update_window(winbuf *win_entry) |
74 | 1151 { |
1948 | 1152 int n, mark_offset = 0; |
1486
f83a51eaa5ed
Fix multiline output in /buffer save
Mikael Berthe <mikael@lilotux.net>
parents:
1485
diff
changeset
|
1153 guint prefixwidth; |
1483
e74cc83e7158
Refactor scr_UpdateWindow()
Mikael Berthe <mikael@lilotux.net>
parents:
1476
diff
changeset
|
1154 char pref[96]; |
184 | 1155 hbb_line **lines, *line; |
74 | 1156 GList *hbuf_head; |
1965
ec737f5f1d6f
Couple of readmark-related bugfixes
Mikael Berthe <mikael@lilotux.net>
parents:
1961
diff
changeset
|
1157 int color = COLOR_GENERAL; |
1948 | 1158 bool readmark = FALSE; |
1159 bool skipline = FALSE; | |
2098
c4a68361883f
Lock buffer automatically when scrolled up, unlock when at bottom ("buffer_smart_scrolling" setting)
Hermitifier
parents:
2090
diff
changeset
|
1160 int autolock; |
c4a68361883f
Lock buffer automatically when scrolled up, unlock when at bottom ("buffer_smart_scrolling" setting)
Hermitifier
parents:
2090
diff
changeset
|
1161 |
c4a68361883f
Lock buffer automatically when scrolled up, unlock when at bottom ("buffer_smart_scrolling" setting)
Hermitifier
parents:
2090
diff
changeset
|
1162 autolock = settings_opt_get_int("buffer_smart_scrolling"); |
74 | 1163 |
1487 | 1164 prefixwidth = scr_getprefixwidth(); |
1486
f83a51eaa5ed
Fix multiline output in /buffer save
Mikael Berthe <mikael@lilotux.net>
parents:
1485
diff
changeset
|
1165 prefixwidth = MIN(prefixwidth, sizeof pref); |
108 | 1166 |
1167 // Should the window be empty? | |
1157
5c857f0f0ab8
Moved all variables related to hbuf to an extra struct, bufdata
Frank Zschockelt
parents:
1156
diff
changeset
|
1168 if (win_entry->bd->cleared) { |
168 | 1169 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
|
1170 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
|
1171 scr_buffer_scroll_lock(0); |
108 | 1172 return; |
1173 } | |
1174 | |
1160
14f5876b5555
Slight optimization + line wrapping
Mikael Berthe <mikael@lilotux.net>
parents:
1159
diff
changeset
|
1175 // 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
|
1176 // we are displaying the last messages. |
105 | 1177 |
74 | 1178 // We will show the last CHAT_WIN_HEIGHT lines. |
1179 // Let's find out where it begins. | |
1160
14f5876b5555
Slight optimization + line wrapping
Mikael Berthe <mikael@lilotux.net>
parents:
1159
diff
changeset
|
1180 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
|
1181 win_entry->bd->top) == -1)) { |
105 | 1182 // 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
|
1183 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
|
1184 hbuf_head = win_entry->bd->hbuf; |
5c857f0f0ab8
Moved all variables related to hbuf to an extra struct, bufdata
Frank Zschockelt
parents:
1156
diff
changeset
|
1185 win_entry->bd->top = NULL; // (Just to make sure) |
105 | 1186 n = 0; |
1187 while (hbuf_head && (n < CHAT_WIN_HEIGHT-1) && g_list_previous(hbuf_head)) { | |
1188 hbuf_head = g_list_previous(hbuf_head); | |
1189 n++; | |
1190 } | |
873
ee39f6d94d43
Add /buffer {scroll_lock|scroll_unlock|toggle_scroll}
Mikael Berthe <mikael@lilotux.net>
parents:
866
diff
changeset
|
1191 // 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
|
1192 if (win_entry->bd->lock) |
5c857f0f0ab8
Moved all variables related to hbuf to an extra struct, bufdata
Frank Zschockelt
parents:
1156
diff
changeset
|
1193 win_entry->bd->top = hbuf_head; |
105 | 1194 } else |
1157
5c857f0f0ab8
Moved all variables related to hbuf to an extra struct, bufdata
Frank Zschockelt
parents:
1156
diff
changeset
|
1195 hbuf_head = win_entry->bd->top; |
74 | 1196 |
2098
c4a68361883f
Lock buffer automatically when scrolled up, unlock when at bottom ("buffer_smart_scrolling" setting)
Hermitifier
parents:
2090
diff
changeset
|
1197 // 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
|
1198 lines = hbuf_get_lines(hbuf_head, CHAT_WIN_HEIGHT+1); |
74 | 1199 |
1948 | 1200 if (CHAT_WIN_HEIGHT > 1) { |
1201 // Do we have a read mark? | |
1202 for (n = 0; n < CHAT_WIN_HEIGHT; n++) { | |
1203 line = *(lines+n); | |
1954
256cfc706ae5
Update readmark support
Mikael Berthe <mikael@lilotux.net>
parents:
1950
diff
changeset
|
1204 if (line) { |
256cfc706ae5
Update readmark support
Mikael Berthe <mikael@lilotux.net>
parents:
1950
diff
changeset
|
1205 if (line->flags & HBB_PREFIX_READMARK) { |
256cfc706ae5
Update readmark support
Mikael Berthe <mikael@lilotux.net>
parents:
1950
diff
changeset
|
1206 // 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
|
1207 if (n+1 < CHAT_WIN_HEIGHT && *(lines+n+1)) { |
256cfc706ae5
Update readmark support
Mikael Berthe <mikael@lilotux.net>
parents:
1950
diff
changeset
|
1208 readmark = TRUE; |
256cfc706ae5
Update readmark support
Mikael Berthe <mikael@lilotux.net>
parents:
1950
diff
changeset
|
1209 skipline = TRUE; |
256cfc706ae5
Update readmark support
Mikael Berthe <mikael@lilotux.net>
parents:
1950
diff
changeset
|
1210 mark_offset = -1; |
256cfc706ae5
Update readmark support
Mikael Berthe <mikael@lilotux.net>
parents:
1950
diff
changeset
|
1211 } |
256cfc706ae5
Update readmark support
Mikael Berthe <mikael@lilotux.net>
parents:
1950
diff
changeset
|
1212 } |
256cfc706ae5
Update readmark support
Mikael Berthe <mikael@lilotux.net>
parents:
1950
diff
changeset
|
1213 } else if (readmark) { |
256cfc706ae5
Update readmark support
Mikael Berthe <mikael@lilotux.net>
parents:
1950
diff
changeset
|
1214 // 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
|
1215 skipline = FALSE; |
256cfc706ae5
Update readmark support
Mikael Berthe <mikael@lilotux.net>
parents:
1950
diff
changeset
|
1216 mark_offset = 0; |
1948 | 1217 } |
1218 } | |
1219 } | |
1220 | |
1221 // Display the lines | |
1222 for (n = 0 ; n < CHAT_WIN_HEIGHT; n++) { | |
2090
16b04d64ec88
Add option to highlight timestamp added by server.
Hermitifier
parents:
2074
diff
changeset
|
1223 int timelen; |
1948 | 1224 int winy = n + mark_offset; |
1225 wmove(win_entry->win, winy, 0); | |
184 | 1226 line = *(lines+n); |
1227 if (line) { | |
1948 | 1228 if (skipline) |
1229 goto scr_update_window_skipline; | |
1230 | |
1204
e802ec0c02d2
Basic support for nick highlighting in MUC rooms (the whole line is colored)
Mikael Berthe <mikael@lilotux.net>
parents:
1190
diff
changeset
|
1231 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
|
1232 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
|
1233 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
|
1234 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
|
1235 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
|
1236 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
|
1237 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
|
1238 color = COLOR_MSGIN; |
9f64f548ac16
Better way of writing the nick
Michal 'vorner' Vaner <vorner@ucw.cz>
parents:
1290
diff
changeset
|
1239 else |
9f64f548ac16
Better way of writing the nick
Michal 'vorner' Vaner <vorner@ucw.cz>
parents:
1290
diff
changeset
|
1240 color = COLOR_GENERAL; |
9f64f548ac16
Better way of writing the nick
Michal 'vorner' Vaner <vorner@ucw.cz>
parents:
1290
diff
changeset
|
1241 |
9f64f548ac16
Better way of writing the nick
Michal 'vorner' Vaner <vorner@ucw.cz>
parents:
1290
diff
changeset
|
1242 if (color != COLOR_GENERAL) |
9f64f548ac16
Better way of writing the nick
Michal 'vorner' Vaner <vorner@ucw.cz>
parents:
1290
diff
changeset
|
1243 wattrset(win_entry->win, get_color(color)); |
1268
dbc907b2d92f
Add configurable colors for info and incoming messages (Michal 'vorner' Vaner)
Mikael Berthe <mikael@lilotux.net>
parents:
1254
diff
changeset
|
1244 |
1483
e74cc83e7158
Refactor scr_UpdateWindow()
Mikael Berthe <mikael@lilotux.net>
parents:
1476
diff
changeset
|
1245 // Generate the prefix area and display it |
2090
16b04d64ec88
Add option to highlight timestamp added by server.
Hermitifier
parents:
2074
diff
changeset
|
1246 |
16b04d64ec88
Add option to highlight timestamp added by server.
Hermitifier
parents:
2074
diff
changeset
|
1247 timelen = scr_line_prefix(line, pref, prefixwidth); |
16b04d64ec88
Add option to highlight timestamp added by server.
Hermitifier
parents:
2074
diff
changeset
|
1248 if (timelen && line->flags & HBB_PREFIX_DELAYED) { |
16b04d64ec88
Add option to highlight timestamp added by server.
Hermitifier
parents:
2074
diff
changeset
|
1249 char tmp; |
16b04d64ec88
Add option to highlight timestamp added by server.
Hermitifier
parents:
2074
diff
changeset
|
1250 |
16b04d64ec88
Add option to highlight timestamp added by server.
Hermitifier
parents:
2074
diff
changeset
|
1251 tmp = pref[timelen]; |
16b04d64ec88
Add option to highlight timestamp added by server.
Hermitifier
parents:
2074
diff
changeset
|
1252 pref[timelen] = '\0'; |
16b04d64ec88
Add option to highlight timestamp added by server.
Hermitifier
parents:
2074
diff
changeset
|
1253 wattrset(win_entry->win, get_color(COLOR_TIMESTAMP)); |
16b04d64ec88
Add option to highlight timestamp added by server.
Hermitifier
parents:
2074
diff
changeset
|
1254 wprintw(win_entry->win, pref); |
16b04d64ec88
Add option to highlight timestamp added by server.
Hermitifier
parents:
2074
diff
changeset
|
1255 pref[timelen] = tmp; |
16b04d64ec88
Add option to highlight timestamp added by server.
Hermitifier
parents:
2074
diff
changeset
|
1256 wattrset(win_entry->win, get_color(color)); |
16b04d64ec88
Add option to highlight timestamp added by server.
Hermitifier
parents:
2074
diff
changeset
|
1257 wprintw(win_entry->win, pref+timelen); |
16b04d64ec88
Add option to highlight timestamp added by server.
Hermitifier
parents:
2074
diff
changeset
|
1258 } else |
16b04d64ec88
Add option to highlight timestamp added by server.
Hermitifier
parents:
2074
diff
changeset
|
1259 wprintw(win_entry->win, pref); |
729
39f67cade02c
Use bold font for outgoing messages
Mikael Berthe <mikael@lilotux.net>
parents:
728
diff
changeset
|
1260 |
1286
02ad6200df26
Add selectable time prefixes (vorner)
Mikael Berthe <mikael@lilotux.net>
parents:
1284
diff
changeset
|
1261 // Make sure we are at the right position |
1948 | 1262 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
|
1263 |
a0deb5124ebf
Check time_prefix value before using it
Mikael Berthe <mikael@lilotux.net>
parents:
1359
diff
changeset
|
1264 // The MUC nick - overwrite with proper color |
1294
86caabe72f3a
Color only incoming messages
Michal 'vorner' Vaner <vorner@ucw.cz>
parents:
1292
diff
changeset
|
1265 if (line->mucnicklen) { |
1476
77afd831f8f7
Avoid mixed declarations and code
Mikael Berthe <mikael@lilotux.net>
parents:
1457
diff
changeset
|
1266 char *mucjid; |
77afd831f8f7
Avoid mixed declarations and code
Mikael Berthe <mikael@lilotux.net>
parents:
1457
diff
changeset
|
1267 char tmp; |
77afd831f8f7
Avoid mixed declarations and code
Mikael Berthe <mikael@lilotux.net>
parents:
1457
diff
changeset
|
1268 nickcolor *actual = NULL; |
77afd831f8f7
Avoid mixed declarations and code
Mikael Berthe <mikael@lilotux.net>
parents:
1457
diff
changeset
|
1269 muccoltype type, *typetmp; |
77afd831f8f7
Avoid mixed declarations and code
Mikael Berthe <mikael@lilotux.net>
parents:
1457
diff
changeset
|
1270 |
1376
a0deb5124ebf
Check time_prefix value before using it
Mikael Berthe <mikael@lilotux.net>
parents:
1359
diff
changeset
|
1271 // Store the char after the nick |
1476
77afd831f8f7
Avoid mixed declarations and code
Mikael Berthe <mikael@lilotux.net>
parents:
1457
diff
changeset
|
1272 tmp = line->text[line->mucnicklen]; |
77afd831f8f7
Avoid mixed declarations and code
Mikael Berthe <mikael@lilotux.net>
parents:
1457
diff
changeset
|
1273 type = glob_muccol; |
1376
a0deb5124ebf
Check time_prefix value before using it
Mikael Berthe <mikael@lilotux.net>
parents:
1359
diff
changeset
|
1274 // 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
|
1275 line->text[line->mucnicklen] = '\0'; |
1476
77afd831f8f7
Avoid mixed declarations and code
Mikael Berthe <mikael@lilotux.net>
parents:
1457
diff
changeset
|
1276 mucjid = g_utf8_strdown(CURRENT_JID, -1); |
1292
382ec54b584e
Muc nick coloring functionality
Michal 'vorner' Vaner <vorner@ucw.cz>
parents:
1291
diff
changeset
|
1277 if (muccolors) { |
382ec54b584e
Muc nick coloring functionality
Michal 'vorner' Vaner <vorner@ucw.cz>
parents:
1291
diff
changeset
|
1278 typetmp = g_hash_table_lookup(muccolors, mucjid); |
382ec54b584e
Muc nick coloring functionality
Michal 'vorner' Vaner <vorner@ucw.cz>
parents:
1291
diff
changeset
|
1279 if (typetmp) |
382ec54b584e
Muc nick coloring functionality
Michal 'vorner' Vaner <vorner@ucw.cz>
parents:
1291
diff
changeset
|
1280 type = *typetmp; |
382ec54b584e
Muc nick coloring functionality
Michal 'vorner' Vaner <vorner@ucw.cz>
parents:
1291
diff
changeset
|
1281 } |
382ec54b584e
Muc nick coloring functionality
Michal 'vorner' Vaner <vorner@ucw.cz>
parents:
1291
diff
changeset
|
1282 g_free(mucjid); |
1510
f6d4e20b9caa
MUC nickname colors depend on nicknames now
Maxim Vuets <maxim.vuets@gmail.com>
parents:
1505
diff
changeset
|
1283 // 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
|
1284 if ((type == MC_ALL) && (!nickcolors || |
382ec54b584e
Muc nick coloring functionality
Michal 'vorner' Vaner <vorner@ucw.cz>
parents:
1291
diff
changeset
|
1285 !g_hash_table_lookup(nickcolors, line->text))) { |
1476
77afd831f8f7
Avoid mixed declarations and code
Mikael Berthe <mikael@lilotux.net>
parents:
1457
diff
changeset
|
1286 char *snick, *mnick; |
77afd831f8f7
Avoid mixed declarations and code
Mikael Berthe <mikael@lilotux.net>
parents:
1457
diff
changeset
|
1287 nickcolor *nc; |
1510
f6d4e20b9caa
MUC nickname colors depend on nicknames now
Maxim Vuets <maxim.vuets@gmail.com>
parents:
1505
diff
changeset
|
1288 const char *p = line->text; |
f6d4e20b9caa
MUC nickname colors depend on nicknames now
Maxim Vuets <maxim.vuets@gmail.com>
parents:
1505
diff
changeset
|
1289 unsigned int nicksum = 0; |
1476
77afd831f8f7
Avoid mixed declarations and code
Mikael Berthe <mikael@lilotux.net>
parents:
1457
diff
changeset
|
1290 snick = g_strdup(line->text); |
77afd831f8f7
Avoid mixed declarations and code
Mikael Berthe <mikael@lilotux.net>
parents:
1457
diff
changeset
|
1291 mnick = g_strdup(line->text); |
77afd831f8f7
Avoid mixed declarations and code
Mikael Berthe <mikael@lilotux.net>
parents:
1457
diff
changeset
|
1292 nc = g_new(nickcolor, 1); |
1292
382ec54b584e
Muc nick coloring functionality
Michal 'vorner' Vaner <vorner@ucw.cz>
parents:
1291
diff
changeset
|
1293 ensure_string_htable(&nickcolors, NULL); |
1510
f6d4e20b9caa
MUC nickname colors depend on nicknames now
Maxim Vuets <maxim.vuets@gmail.com>
parents:
1505
diff
changeset
|
1294 while (*p) |
f6d4e20b9caa
MUC nickname colors depend on nicknames now
Maxim Vuets <maxim.vuets@gmail.com>
parents:
1505
diff
changeset
|
1295 nicksum += *p++; |
f6d4e20b9caa
MUC nickname colors depend on nicknames now
Maxim Vuets <maxim.vuets@gmail.com>
parents:
1505
diff
changeset
|
1296 nc->color = nickcols[nicksum % nickcolcount]; |
1381
40095d413da9
Fix compilation on OpenBSD
Mikael Berthe <mikael@lilotux.net>
parents:
1376
diff
changeset
|
1297 nc->manual = FALSE; |
1292
382ec54b584e
Muc nick coloring functionality
Michal 'vorner' Vaner <vorner@ucw.cz>
parents:
1291
diff
changeset
|
1298 *snick = '<'; |
382ec54b584e
Muc nick coloring functionality
Michal 'vorner' Vaner <vorner@ucw.cz>
parents:
1291
diff
changeset
|
1299 snick[strlen(snick)-1] = '>'; |
382ec54b584e
Muc nick coloring functionality
Michal 'vorner' Vaner <vorner@ucw.cz>
parents:
1291
diff
changeset
|
1300 *mnick = '*'; |
382ec54b584e
Muc nick coloring functionality
Michal 'vorner' Vaner <vorner@ucw.cz>
parents:
1291
diff
changeset
|
1301 mnick[strlen(mnick)-1] = ' '; |
1376
a0deb5124ebf
Check time_prefix value before using it
Mikael Berthe <mikael@lilotux.net>
parents:
1359
diff
changeset
|
1302 // Insert them |
1292
382ec54b584e
Muc nick coloring functionality
Michal 'vorner' Vaner <vorner@ucw.cz>
parents:
1291
diff
changeset
|
1303 g_hash_table_insert(nickcolors, snick, nc); |
382ec54b584e
Muc nick coloring functionality
Michal 'vorner' Vaner <vorner@ucw.cz>
parents:
1291
diff
changeset
|
1304 g_hash_table_insert(nickcolors, mnick, nc); |
382ec54b584e
Muc nick coloring functionality
Michal 'vorner' Vaner <vorner@ucw.cz>
parents:
1291
diff
changeset
|
1305 } |
382ec54b584e
Muc nick coloring functionality
Michal 'vorner' Vaner <vorner@ucw.cz>
parents:
1291
diff
changeset
|
1306 if (nickcolors) |
382ec54b584e
Muc nick coloring functionality
Michal 'vorner' Vaner <vorner@ucw.cz>
parents:
1291
diff
changeset
|
1307 actual = g_hash_table_lookup(nickcolors, line->text); |
1294
86caabe72f3a
Color only incoming messages
Michal 'vorner' Vaner <vorner@ucw.cz>
parents:
1292
diff
changeset
|
1308 if (actual && ((type == MC_ALL) || (actual->manual)) |
86caabe72f3a
Color only incoming messages
Michal 'vorner' Vaner <vorner@ucw.cz>
parents:
1292
diff
changeset
|
1309 && (line->flags & HBB_PREFIX_IN) && |
86caabe72f3a
Color only incoming messages
Michal 'vorner' Vaner <vorner@ucw.cz>
parents:
1292
diff
changeset
|
1310 (!(line->flags & HBB_PREFIX_HLIGHT_OUT))) |
1489
e9c71ce96dca
Fixed the colorhandling for mucnicks and /color roster
franky@veqlargh.fs
parents:
1488
diff
changeset
|
1311 wattrset(win_entry->win, compose_color(actual->color)); |
1290
e42f48103609
Drawing the MUC nicks by a different color
Michal 'vorner' Vaner <vorner@ucw.cz>
parents:
1286
diff
changeset
|
1312 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
|
1313 // Return the char |
1290
e42f48103609
Drawing the MUC nicks by a different color
Michal 'vorner' Vaner <vorner@ucw.cz>
parents:
1286
diff
changeset
|
1314 line->text[line->mucnicklen] = tmp; |
1376
a0deb5124ebf
Check time_prefix value before using it
Mikael Berthe <mikael@lilotux.net>
parents:
1359
diff
changeset
|
1315 // Return the color back |
1291
9f64f548ac16
Better way of writing the nick
Michal 'vorner' Vaner <vorner@ucw.cz>
parents:
1290
diff
changeset
|
1316 wattrset(win_entry->win, get_color(color)); |
1290
e42f48103609
Drawing the MUC nicks by a different color
Michal 'vorner' Vaner <vorner@ucw.cz>
parents:
1286
diff
changeset
|
1317 } |
729
39f67cade02c
Use bold font for outgoing messages
Mikael Berthe <mikael@lilotux.net>
parents:
728
diff
changeset
|
1318 |
1333
e30a9d907105
Minor coding style adjustments
Mikael Berthe <mikael@lilotux.net>
parents:
1314
diff
changeset
|
1319 // Display text line |
e30a9d907105
Minor coding style adjustments
Mikael Berthe <mikael@lilotux.net>
parents:
1314
diff
changeset
|
1320 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
|
1321 wclrtoeol(win_entry->win); |
9f64f548ac16
Better way of writing the nick
Michal 'vorner' Vaner <vorner@ucw.cz>
parents:
1290
diff
changeset
|
1322 |
1948 | 1323 scr_update_window_skipline: |
1324 skipline = FALSE; | |
1325 if (readmark && line->flags & HBB_PREFIX_READMARK) { | |
1326 int i, w; | |
1327 mark_offset++; | |
1328 | |
1329 // Display the mark | |
1330 winy = n + mark_offset; | |
1331 wmove(win_entry->win, winy, 0); | |
1965
ec737f5f1d6f
Couple of readmark-related bugfixes
Mikael Berthe <mikael@lilotux.net>
parents:
1961
diff
changeset
|
1332 color = COLOR_READMARK; |
ec737f5f1d6f
Couple of readmark-related bugfixes
Mikael Berthe <mikael@lilotux.net>
parents:
1961
diff
changeset
|
1333 wattrset(win_entry->win, get_color(color)); |
1948 | 1334 g_snprintf(pref, prefixwidth, " == "); |
1335 wprintw(win_entry->win, pref); | |
1336 w = scr_gettextwidth() / 3; | |
1337 for (i=0; i<w; i++) | |
1338 wprintw(win_entry->win, "== "); | |
1339 wclrtoeol(win_entry->win); | |
1960 | 1340 wattrset(win_entry->win, get_color(COLOR_GENERAL)); |
1948 | 1341 } |
1342 | |
1965
ec737f5f1d6f
Couple of readmark-related bugfixes
Mikael Berthe <mikael@lilotux.net>
parents:
1961
diff
changeset
|
1343 // Restore default ("general") color |
ec737f5f1d6f
Couple of readmark-related bugfixes
Mikael Berthe <mikael@lilotux.net>
parents:
1961
diff
changeset
|
1344 if (color != COLOR_GENERAL) |
ec737f5f1d6f
Couple of readmark-related bugfixes
Mikael Berthe <mikael@lilotux.net>
parents:
1961
diff
changeset
|
1345 wattrset(win_entry->win, get_color(COLOR_GENERAL)); |
ec737f5f1d6f
Couple of readmark-related bugfixes
Mikael Berthe <mikael@lilotux.net>
parents:
1961
diff
changeset
|
1346 |
184 | 1347 g_free(line->text); |
898
c65b71dcda94
Fix memory leak in scr_UpdateWindow()
Mikael Berthe <mikael@lilotux.net>
parents:
897
diff
changeset
|
1348 g_free(line); |
168 | 1349 } else { |
1350 wclrtobot(win_entry->win); | |
1351 break; | |
75 | 1352 } |
74 | 1353 } |
2098
c4a68361883f
Lock buffer automatically when scrolled up, unlock when at bottom ("buffer_smart_scrolling" setting)
Hermitifier
parents:
2090
diff
changeset
|
1354 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
|
1355 if (line) { |
c4a68361883f
Lock buffer automatically when scrolled up, unlock when at bottom ("buffer_smart_scrolling" setting)
Hermitifier
parents:
2090
diff
changeset
|
1356 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
|
1357 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
|
1358 scr_buffer_readmark(TRUE); |
c4a68361883f
Lock buffer automatically when scrolled up, unlock when at bottom ("buffer_smart_scrolling" setting)
Hermitifier
parents:
2090
diff
changeset
|
1359 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
|
1360 } |
c4a68361883f
Lock buffer automatically when scrolled up, unlock when at bottom ("buffer_smart_scrolling" setting)
Hermitifier
parents:
2090
diff
changeset
|
1361 g_free(line->text); |
c4a68361883f
Lock buffer automatically when scrolled up, unlock when at bottom ("buffer_smart_scrolling" setting)
Hermitifier
parents:
2090
diff
changeset
|
1362 g_free(line); |
c4a68361883f
Lock buffer automatically when scrolled up, unlock when at bottom ("buffer_smart_scrolling" setting)
Hermitifier
parents:
2090
diff
changeset
|
1363 } 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
|
1364 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
|
1365 } |
c4a68361883f
Lock buffer automatically when scrolled up, unlock when at bottom ("buffer_smart_scrolling" setting)
Hermitifier
parents:
2090
diff
changeset
|
1366 |
74 | 1367 g_free(lines); |
1368 } | |
1159
53c0c5be43fa
Small fixes, typos and cleanups
Mikael Berthe <mikael@lilotux.net>
parents:
1157
diff
changeset
|
1369 |
1780
e4378fbab5d7
Major API cleanup - bump API to 4
Mikael Berthe <mikael@lilotux.net>
parents:
1761
diff
changeset
|
1370 static winbuf *scr_create_window(const char *winId, int special, int dont_show) |
1154 | 1371 { |
1372 if (special) { | |
1373 if (!statusWindow) { | |
1374 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
|
1375 statusWindow->bd->hbuf = statushbuf; |
1154 | 1376 } |
1377 return statusWindow; | |
1378 } else { | |
1379 return scr_new_buddy(winId, dont_show); | |
1380 } | |
1381 } | |
1382 | |
1780
e4378fbab5d7
Major API cleanup - bump API to 4
Mikael Berthe <mikael@lilotux.net>
parents:
1761
diff
changeset
|
1383 // scr_show_window() |
143 | 1384 // Display the chat window with the given identifier. |
849
42c43a88d823
Status buffer management
Mikael Berthe <mikael@lilotux.net>
parents:
848
diff
changeset
|
1385 // "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
|
1386 static void scr_show_window(const char *winId, int special) |
24 | 1387 { |
849
42c43a88d823
Status buffer management
Mikael Berthe <mikael@lilotux.net>
parents:
848
diff
changeset
|
1388 winbuf *win_entry; |
42c43a88d823
Status buffer management
Mikael Berthe <mikael@lilotux.net>
parents:
848
diff
changeset
|
1389 |
1780
e4378fbab5d7
Major API cleanup - bump API to 4
Mikael Berthe <mikael@lilotux.net>
parents:
1761
diff
changeset
|
1390 win_entry = scr_search_window(winId, special); |
74 | 1391 |
849
42c43a88d823
Status buffer management
Mikael Berthe <mikael@lilotux.net>
parents:
848
diff
changeset
|
1392 if (!win_entry) { |
1780
e4378fbab5d7
Major API cleanup - bump API to 4
Mikael Berthe <mikael@lilotux.net>
parents:
1761
diff
changeset
|
1393 win_entry = scr_create_window(winId, special, FALSE); |
849
42c43a88d823
Status buffer management
Mikael Berthe <mikael@lilotux.net>
parents:
848
diff
changeset
|
1394 } |
74 | 1395 |
180 | 1396 top_panel(win_entry->panel); |
1397 currentWindow = win_entry; | |
1398 chatmode = TRUE; | |
1157
5c857f0f0ab8
Moved all variables related to hbuf to an extra struct, bufdata
Frank Zschockelt
parents:
1156
diff
changeset
|
1399 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
|
1400 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
|
1401 if (!special) |
849
42c43a88d823
Status buffer management
Mikael Berthe <mikael@lilotux.net>
parents:
848
diff
changeset
|
1402 roster_setflags(winId, ROSTER_FLAG_LOCK, TRUE); |
874
293e8955075c
Display a flag in the chat status line when the buffer is locked
Mikael Berthe <mikael@lilotux.net>
parents:
873
diff
changeset
|
1403 update_roster = TRUE; |
74 | 1404 |
180 | 1405 // Refresh the window |
1780
e4378fbab5d7
Major API cleanup - bump API to 4
Mikael Berthe <mikael@lilotux.net>
parents:
1761
diff
changeset
|
1406 scr_update_window(win_entry); |
180 | 1407 |
1408 // Finished :) | |
1409 update_panels(); | |
142 | 1410 |
1411 top_panel(inputPanel); | |
24 | 1412 } |
1413 | |
1780
e4378fbab5d7
Major API cleanup - bump API to 4
Mikael Berthe <mikael@lilotux.net>
parents:
1761
diff
changeset
|
1414 // scr_show_buddy_window() |
143 | 1415 // 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
|
1416 void scr_show_buddy_window(void) |
24 | 1417 { |
1058 | 1418 const gchar *bjid; |
140 | 1419 |
849
42c43a88d823
Status buffer management
Mikael Berthe <mikael@lilotux.net>
parents:
848
diff
changeset
|
1420 if (!current_buddy) { |
1058 | 1421 bjid = NULL; |
849
42c43a88d823
Status buffer management
Mikael Berthe <mikael@lilotux.net>
parents:
848
diff
changeset
|
1422 } else { |
1058 | 1423 bjid = CURRENT_JID; |
849
42c43a88d823
Status buffer management
Mikael Berthe <mikael@lilotux.net>
parents:
848
diff
changeset
|
1424 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
|
1425 scr_show_window(buddy_getname(BUDDATA(current_buddy)), TRUE); |
849
42c43a88d823
Status buffer management
Mikael Berthe <mikael@lilotux.net>
parents:
848
diff
changeset
|
1426 return; |
42c43a88d823
Status buffer management
Mikael Berthe <mikael@lilotux.net>
parents:
848
diff
changeset
|
1427 } |
42c43a88d823
Status buffer management
Mikael Berthe <mikael@lilotux.net>
parents:
848
diff
changeset
|
1428 } |
140 | 1429 |
1058 | 1430 if (!bjid) { |
140 | 1431 top_panel(chatPanel); |
143 | 1432 top_panel(inputPanel); |
140 | 1433 currentWindow = NULL; |
105 | 1434 return; |
140 | 1435 } |
1436 | |
1780
e4378fbab5d7
Major API cleanup - bump API to 4
Mikael Berthe <mikael@lilotux.net>
parents:
1761
diff
changeset
|
1437 scr_show_window(bjid, FALSE); |
24 | 1438 } |
1439 | |
1780
e4378fbab5d7
Major API cleanup - bump API to 4
Mikael Berthe <mikael@lilotux.net>
parents:
1761
diff
changeset
|
1440 // scr_update_buddy_window() |
865
cee8d6be04e1
Improve changeset a3db3ee8b99e, do not enable chatmode when refreshing
Mikael Berthe <mikael@lilotux.net>
parents:
858
diff
changeset
|
1441 // (Re)Display the current window. |
1780
e4378fbab5d7
Major API cleanup - bump API to 4
Mikael Berthe <mikael@lilotux.net>
parents:
1761
diff
changeset
|
1442 // 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
|
1443 // else display the chat window. |
1780
e4378fbab5d7
Major API cleanup - bump API to 4
Mikael Berthe <mikael@lilotux.net>
parents:
1761
diff
changeset
|
1444 inline void scr_update_buddy_window(void) |
865
cee8d6be04e1
Improve changeset a3db3ee8b99e, do not enable chatmode when refreshing
Mikael Berthe <mikael@lilotux.net>
parents:
858
diff
changeset
|
1445 { |
cee8d6be04e1
Improve changeset a3db3ee8b99e, do not enable chatmode when refreshing
Mikael Berthe <mikael@lilotux.net>
parents:
858
diff
changeset
|
1446 if (chatmode) { |
1780
e4378fbab5d7
Major API cleanup - bump API to 4
Mikael Berthe <mikael@lilotux.net>
parents:
1761
diff
changeset
|
1447 scr_show_buddy_window(); |
865
cee8d6be04e1
Improve changeset a3db3ee8b99e, do not enable chatmode when refreshing
Mikael Berthe <mikael@lilotux.net>
parents:
858
diff
changeset
|
1448 return; |
cee8d6be04e1
Improve changeset a3db3ee8b99e, do not enable chatmode when refreshing
Mikael Berthe <mikael@lilotux.net>
parents:
858
diff
changeset
|
1449 } |
cee8d6be04e1
Improve changeset a3db3ee8b99e, do not enable chatmode when refreshing
Mikael Berthe <mikael@lilotux.net>
parents:
858
diff
changeset
|
1450 |
cee8d6be04e1
Improve changeset a3db3ee8b99e, do not enable chatmode when refreshing
Mikael Berthe <mikael@lilotux.net>
parents:
858
diff
changeset
|
1451 top_panel(chatPanel); |
cee8d6be04e1
Improve changeset a3db3ee8b99e, do not enable chatmode when refreshing
Mikael Berthe <mikael@lilotux.net>
parents:
858
diff
changeset
|
1452 top_panel(inputPanel); |
cee8d6be04e1
Improve changeset a3db3ee8b99e, do not enable chatmode when refreshing
Mikael Berthe <mikael@lilotux.net>
parents:
858
diff
changeset
|
1453 } |
cee8d6be04e1
Improve changeset a3db3ee8b99e, do not enable chatmode when refreshing
Mikael Berthe <mikael@lilotux.net>
parents:
858
diff
changeset
|
1454 |
1780
e4378fbab5d7
Major API cleanup - bump API to 4
Mikael Berthe <mikael@lilotux.net>
parents:
1761
diff
changeset
|
1455 // scr_write_in_window() |
143 | 1456 // 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
|
1457 // Use winId == NULL for the special status buffer. |
143 | 1458 // Lines are splitted when they are too long to fit in the chat window. |
1459 // 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
|
1460 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
|
1461 time_t timestamp, unsigned int prefix_flags, |
e4378fbab5d7
Major API cleanup - bump API to 4
Mikael Berthe <mikael@lilotux.net>
parents:
1761
diff
changeset
|
1462 int force_show, unsigned mucnicklen, |
e4378fbab5d7
Major API cleanup - bump API to 4
Mikael Berthe <mikael@lilotux.net>
parents:
1761
diff
changeset
|
1463 gpointer xep184) |
24 | 1464 { |
822 | 1465 winbuf *win_entry; |
772
464be13343a9
Store most data in UTF-8 internally
Mikael Berthe <mikael@lilotux.net>
parents:
771
diff
changeset
|
1466 char *text_locale; |
24 | 1467 int dont_show = FALSE; |
849
42c43a88d823
Status buffer management
Mikael Berthe <mikael@lilotux.net>
parents:
848
diff
changeset
|
1468 int special; |
1142
0e27177882c7
Small fix for the max_history_blocks option
Mikael Berthe <mikael@lilotux.net>
parents:
1141
diff
changeset
|
1469 guint num_history_blocks; |
873
ee39f6d94d43
Add /buffer {scroll_lock|scroll_unlock|toggle_scroll}
Mikael Berthe <mikael@lilotux.net>
parents:
866
diff
changeset
|
1470 bool setmsgflg = FALSE; |
1296
7a0eaa53bd53
Further nick colors fixes
Michal 'vorner' Vaner <vorner@ucw.cz>
parents:
1295
diff
changeset
|
1471 char *nicktmp, *nicklocaltmp; |
24 | 1472 |
74 | 1473 // Look for the window entry. |
849
42c43a88d823
Status buffer management
Mikael Berthe <mikael@lilotux.net>
parents:
848
diff
changeset
|
1474 special = (winId == NULL); |
1780
e4378fbab5d7
Major API cleanup - bump API to 4
Mikael Berthe <mikael@lilotux.net>
parents:
1761
diff
changeset
|
1475 win_entry = scr_search_window(winId, special); |
74 | 1476 |
1477 // Do we have to really show the window? | |
24 | 1478 if (!chatmode) |
1479 dont_show = TRUE; | |
74 | 1480 else if ((!force_show) && ((!currentWindow || (currentWindow != win_entry)))) |
24 | 1481 dont_show = TRUE; |
1482 | |
74 | 1483 // 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
|
1484 if (!win_entry) { |
1780
e4378fbab5d7
Major API cleanup - bump API to 4
Mikael Berthe <mikael@lilotux.net>
parents:
1761
diff
changeset
|
1485 win_entry = scr_create_window(winId, special, dont_show); |
24 | 1486 } |
1487 | |
220 | 1488 // 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
|
1489 if (win_entry->bd->cleared) |
5c857f0f0ab8
Moved all variables related to hbuf to an extra struct, bufdata
Frank Zschockelt
parents:
1156
diff
changeset
|
1490 win_entry->bd->top = g_list_last(win_entry->bd->hbuf); |
220 | 1491 |
1142
0e27177882c7
Small fix for the max_history_blocks option
Mikael Berthe <mikael@lilotux.net>
parents:
1141
diff
changeset
|
1492 // 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
|
1493 // top is set. |
1157
5c857f0f0ab8
Moved all variables related to hbuf to an extra struct, bufdata
Frank Zschockelt
parents:
1156
diff
changeset
|
1494 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
|
1495 num_history_blocks = 0U; |
0e27177882c7
Small fix for the max_history_blocks option
Mikael Berthe <mikael@lilotux.net>
parents:
1141
diff
changeset
|
1496 else |
0e27177882c7
Small fix for the max_history_blocks option
Mikael Berthe <mikael@lilotux.net>
parents:
1141
diff
changeset
|
1497 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
|
1498 |
772
464be13343a9
Store most data in UTF-8 internally
Mikael Berthe <mikael@lilotux.net>
parents:
771
diff
changeset
|
1499 text_locale = from_utf8(text); |
1729
e6e89b1d7831
Minor style and header updates
Mikael Berthe <mikael@lilotux.net>
parents:
1710
diff
changeset
|
1500 // Convert the nick alone and compute its length |
1296
7a0eaa53bd53
Further nick colors fixes
Michal 'vorner' Vaner <vorner@ucw.cz>
parents:
1295
diff
changeset
|
1501 if (mucnicklen) { |
7a0eaa53bd53
Further nick colors fixes
Michal 'vorner' Vaner <vorner@ucw.cz>
parents:
1295
diff
changeset
|
1502 nicktmp = g_strndup(text, mucnicklen); |
7a0eaa53bd53
Further nick colors fixes
Michal 'vorner' Vaner <vorner@ucw.cz>
parents:
1295
diff
changeset
|
1503 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
|
1504 if (nicklocaltmp) |
0fa6df17bc5c
Fix potential issue pointed out by franky's clang report
Mikael Berthe <mikael@lilotux.net>
parents:
1915
diff
changeset
|
1505 mucnicklen = strlen(nicklocaltmp); |
1296
7a0eaa53bd53
Further nick colors fixes
Michal 'vorner' Vaner <vorner@ucw.cz>
parents:
1295
diff
changeset
|
1506 g_free(nicklocaltmp); |
7a0eaa53bd53
Further nick colors fixes
Michal 'vorner' Vaner <vorner@ucw.cz>
parents:
1295
diff
changeset
|
1507 g_free(nicktmp); |
7a0eaa53bd53
Further nick colors fixes
Michal 'vorner' Vaner <vorner@ucw.cz>
parents:
1295
diff
changeset
|
1508 } |
1157
5c857f0f0ab8
Moved all variables related to hbuf to an extra struct, bufdata
Frank Zschockelt
parents:
1156
diff
changeset
|
1509 hbuf_add_line(&win_entry->bd->hbuf, text_locale, timestamp, prefix_flags, |
1487 | 1510 maxX - Roster_Width - scr_getprefixwidth(), num_history_blocks, |
1602 | 1511 mucnicklen, xep184); |
772
464be13343a9
Store most data in UTF-8 internally
Mikael Berthe <mikael@lilotux.net>
parents:
771
diff
changeset
|
1512 g_free(text_locale); |
74 | 1513 |
1157
5c857f0f0ab8
Moved all variables related to hbuf to an extra struct, bufdata
Frank Zschockelt
parents:
1156
diff
changeset
|
1514 if (win_entry->bd->cleared) { |
5c857f0f0ab8
Moved all variables related to hbuf to an extra struct, bufdata
Frank Zschockelt
parents:
1156
diff
changeset
|
1515 win_entry->bd->cleared = FALSE; |
5c857f0f0ab8
Moved all variables related to hbuf to an extra struct, bufdata
Frank Zschockelt
parents:
1156
diff
changeset
|
1516 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
|
1517 win_entry->bd->top = g_list_next(win_entry->bd->top); |
220 | 1518 } |
1519 | |
1520 // 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
|
1521 if (!win_entry->bd->lock && win_entry->bd->top) { |
220 | 1522 int dist; |
1157
5c857f0f0ab8
Moved all variables related to hbuf to an extra struct, bufdata
Frank Zschockelt
parents:
1156
diff
changeset
|
1523 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
|
1524 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
|
1525 g_list_position(first, win_entry->bd->top); |
220 | 1526 if (dist >= CHAT_WIN_HEIGHT) |
1157
5c857f0f0ab8
Moved all variables related to hbuf to an extra struct, bufdata
Frank Zschockelt
parents:
1156
diff
changeset
|
1527 win_entry->bd->top = NULL; |
108 | 1528 } |
1529 | |
24 | 1530 if (!dont_show) { |
1157
5c857f0f0ab8
Moved all variables related to hbuf to an extra struct, bufdata
Frank Zschockelt
parents:
1156
diff
changeset
|
1531 if (win_entry->bd->lock) |
873
ee39f6d94d43
Add /buffer {scroll_lock|scroll_unlock|toggle_scroll}
Mikael Berthe <mikael@lilotux.net>
parents:
866
diff
changeset
|
1532 setmsgflg = TRUE; |
1955
fad27c72a229
Don't update readmark when buffer scroll_lock is set
Mikael Berthe <mikael@lilotux.net>
parents:
1954
diff
changeset
|
1533 else |
1961
39021fd6b0e1
Try to improve readmarks in some cases
Mikael Berthe <mikael@lilotux.net>
parents:
1960
diff
changeset
|
1534 // 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
|
1535 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
|
1536 hbuf_set_readmark(win_entry->bd->hbuf, FALSE); |
74 | 1537 // Show and refresh the window |
1538 top_panel(win_entry->panel); | |
1780
e4378fbab5d7
Major API cleanup - bump API to 4
Mikael Berthe <mikael@lilotux.net>
parents:
1761
diff
changeset
|
1539 scr_update_window(win_entry); |
142 | 1540 top_panel(inputPanel); |
24 | 1541 update_panels(); |
873
ee39f6d94d43
Add /buffer {scroll_lock|scroll_unlock|toggle_scroll}
Mikael Berthe <mikael@lilotux.net>
parents:
866
diff
changeset
|
1542 } 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
|
1543 setmsgflg = TRUE; |
ee39f6d94d43
Add /buffer {scroll_lock|scroll_unlock|toggle_scroll}
Mikael Berthe <mikael@lilotux.net>
parents:
866
diff
changeset
|
1544 } |
ee39f6d94d43
Add /buffer {scroll_lock|scroll_unlock|toggle_scroll}
Mikael Berthe <mikael@lilotux.net>
parents:
866
diff
changeset
|
1545 if (setmsgflg && !special) { |
889
ae93e69aaaaf
Fix up pending message flag for the status special buffer
Mikael Berthe <mikael@lilotux.net>
parents:
888
diff
changeset
|
1546 if (special && !winId) |
ae93e69aaaaf
Fix up pending message flag for the status special buffer
Mikael Berthe <mikael@lilotux.net>
parents:
888
diff
changeset
|
1547 winId = SPECIAL_BUFFER_STATUS_ID; |
ae93e69aaaaf
Fix up pending message flag for the status special buffer
Mikael Berthe <mikael@lilotux.net>
parents:
888
diff
changeset
|
1548 roster_msg_setflag(winId, special, TRUE); |
30 | 1549 update_roster = TRUE; |
24 | 1550 } |
1551 } | |
1552 | |
2101
f56c214a19dc
Add a guard for 'attention_char'
Mikael Berthe <mikael@lilotux.net>
parents:
2100
diff
changeset
|
1553 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
|
1554 { |
f56c214a19dc
Add a guard for 'attention_char'
Mikael Berthe <mikael@lilotux.net>
parents:
2100
diff
changeset
|
1555 update_roster = TRUE; |
f56c214a19dc
Add a guard for 'attention_char'
Mikael Berthe <mikael@lilotux.net>
parents:
2100
diff
changeset
|
1556 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
|
1557 guint sign; |
f56c214a19dc
Add a guard for 'attention_char'
Mikael Berthe <mikael@lilotux.net>
parents:
2100
diff
changeset
|
1558 char *c; |
f56c214a19dc
Add a guard for 'attention_char'
Mikael Berthe <mikael@lilotux.net>
parents:
2100
diff
changeset
|
1559 if (!new_value || !*new_value) |
f56c214a19dc
Add a guard for 'attention_char'
Mikael Berthe <mikael@lilotux.net>
parents:
2100
diff
changeset
|
1560 return NULL; |
f56c214a19dc
Add a guard for 'attention_char'
Mikael Berthe <mikael@lilotux.net>
parents:
2100
diff
changeset
|
1561 sign = get_char(new_value); |
f56c214a19dc
Add a guard for 'attention_char'
Mikael Berthe <mikael@lilotux.net>
parents:
2100
diff
changeset
|
1562 c = next_char((char*)new_value); |
f56c214a19dc
Add a guard for 'attention_char'
Mikael Berthe <mikael@lilotux.net>
parents:
2100
diff
changeset
|
1563 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
|
1564 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
|
1565 return NULL; |
f56c214a19dc
Add a guard for 'attention_char'
Mikael Berthe <mikael@lilotux.net>
parents:
2100
diff
changeset
|
1566 } |
f56c214a19dc
Add a guard for 'attention_char'
Mikael Berthe <mikael@lilotux.net>
parents:
2100
diff
changeset
|
1567 // 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
|
1568 return g_strdup(new_value); |
f56c214a19dc
Add a guard for 'attention_char'
Mikael Berthe <mikael@lilotux.net>
parents:
2100
diff
changeset
|
1569 } |
f56c214a19dc
Add a guard for 'attention_char'
Mikael Berthe <mikael@lilotux.net>
parents:
2100
diff
changeset
|
1570 return g_strdup(new_value); |
f56c214a19dc
Add a guard for 'attention_char'
Mikael Berthe <mikael@lilotux.net>
parents:
2100
diff
changeset
|
1571 } |
f56c214a19dc
Add a guard for 'attention_char'
Mikael Berthe <mikael@lilotux.net>
parents:
2100
diff
changeset
|
1572 |
f56c214a19dc
Add a guard for 'attention_char'
Mikael Berthe <mikael@lilotux.net>
parents:
2100
diff
changeset
|
1573 // scr_init_settings() |
f56c214a19dc
Add a guard for 'attention_char'
Mikael Berthe <mikael@lilotux.net>
parents:
2100
diff
changeset
|
1574 // Create guards for UI settings |
f56c214a19dc
Add a guard for 'attention_char'
Mikael Berthe <mikael@lilotux.net>
parents:
2100
diff
changeset
|
1575 void scr_init_settings(void) |
f56c214a19dc
Add a guard for 'attention_char'
Mikael Berthe <mikael@lilotux.net>
parents:
2100
diff
changeset
|
1576 { |
f56c214a19dc
Add a guard for 'attention_char'
Mikael Berthe <mikael@lilotux.net>
parents:
2100
diff
changeset
|
1577 settings_set_guard("attention_char", attention_sign_guard); |
f56c214a19dc
Add a guard for 'attention_char'
Mikael Berthe <mikael@lilotux.net>
parents:
2100
diff
changeset
|
1578 } |
f56c214a19dc
Add a guard for 'attention_char'
Mikael Berthe <mikael@lilotux.net>
parents:
2100
diff
changeset
|
1579 |
2100
113d3b96ae3e
Add option 'attention_char'
Mikael Berthe <mikael@lilotux.net>
parents:
2098
diff
changeset
|
1580 static unsigned int attention_sign(void) |
113d3b96ae3e
Add option 'attention_char'
Mikael Berthe <mikael@lilotux.net>
parents:
2098
diff
changeset
|
1581 { |
113d3b96ae3e
Add option 'attention_char'
Mikael Berthe <mikael@lilotux.net>
parents:
2098
diff
changeset
|
1582 const char *as = settings_opt_get("attention_char"); |
113d3b96ae3e
Add option 'attention_char'
Mikael Berthe <mikael@lilotux.net>
parents:
2098
diff
changeset
|
1583 if (!as) |
113d3b96ae3e
Add option 'attention_char'
Mikael Berthe <mikael@lilotux.net>
parents:
2098
diff
changeset
|
1584 return DEFAULT_ATTENTION_CHAR; |
2101
f56c214a19dc
Add a guard for 'attention_char'
Mikael Berthe <mikael@lilotux.net>
parents:
2100
diff
changeset
|
1585 return get_char(as); |
2100
113d3b96ae3e
Add option 'attention_char'
Mikael Berthe <mikael@lilotux.net>
parents:
2098
diff
changeset
|
1586 } |
113d3b96ae3e
Add option 'attention_char'
Mikael Berthe <mikael@lilotux.net>
parents:
2098
diff
changeset
|
1587 |
1780
e4378fbab5d7
Major API cleanup - bump API to 4
Mikael Berthe <mikael@lilotux.net>
parents:
1761
diff
changeset
|
1588 // scr_update_main_status(forceupdate) |
713 | 1589 // Redraw the main (bottom) status line. |
1780
e4378fbab5d7
Major API cleanup - bump API to 4
Mikael Berthe <mikael@lilotux.net>
parents:
1761
diff
changeset
|
1590 // 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
|
1591 // 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
|
1592 void scr_update_main_status(int forceupdate) |
713 | 1593 { |
1598 | 1594 char *sm = from_utf8(xmpp_getstatusmsg()); |
1514 | 1595 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
|
1596 guint prio = 0; |
1d8f9135e000
Use smarter message flag in the main status line
Mikael Berthe <mikael@lilotux.net>
parents:
1974
diff
changeset
|
1597 gpointer unread_ptr; |
2100
113d3b96ae3e
Add option 'attention_char'
Mikael Berthe <mikael@lilotux.net>
parents:
2098
diff
changeset
|
1598 guint unreadchar; |
1977
1d8f9135e000
Use smarter message flag in the main status line
Mikael Berthe <mikael@lilotux.net>
parents:
1974
diff
changeset
|
1599 |
1d8f9135e000
Use smarter message flag in the main status line
Mikael Berthe <mikael@lilotux.net>
parents:
1974
diff
changeset
|
1600 unread_ptr = unread_msg(NULL); |
1d8f9135e000
Use smarter message flag in the main status line
Mikael Berthe <mikael@lilotux.net>
parents:
1974
diff
changeset
|
1601 if (unread_ptr) { |
1d8f9135e000
Use smarter message flag in the main status line
Mikael Berthe <mikael@lilotux.net>
parents:
1974
diff
changeset
|
1602 prio = buddy_getuiprio(unread_ptr); |
1d8f9135e000
Use smarter message flag in the main status line
Mikael Berthe <mikael@lilotux.net>
parents:
1974
diff
changeset
|
1603 // 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
|
1604 // priority is 1. |
1d8f9135e000
Use smarter message flag in the main status line
Mikael Berthe <mikael@lilotux.net>
parents:
1974
diff
changeset
|
1605 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
|
1606 prio = 1; |
1d8f9135e000
Use smarter message flag in the main status line
Mikael Berthe <mikael@lilotux.net>
parents:
1974
diff
changeset
|
1607 } |
1d8f9135e000
Use smarter message flag in the main status line
Mikael Berthe <mikael@lilotux.net>
parents:
1974
diff
changeset
|
1608 |
1d8f9135e000
Use smarter message flag in the main status line
Mikael Berthe <mikael@lilotux.net>
parents:
1974
diff
changeset
|
1609 // Status bar unread message flag |
1d8f9135e000
Use smarter message flag in the main status line
Mikael Berthe <mikael@lilotux.net>
parents:
1974
diff
changeset
|
1610 if (prio >= ROSTER_UI_PRIO_MUC_HL_MESSAGE) |
2100
113d3b96ae3e
Add option 'attention_char'
Mikael Berthe <mikael@lilotux.net>
parents:
2098
diff
changeset
|
1611 unreadchar = attention_sign(); |
1977
1d8f9135e000
Use smarter message flag in the main status line
Mikael Berthe <mikael@lilotux.net>
parents:
1974
diff
changeset
|
1612 else if (prio > 0) |
1d8f9135e000
Use smarter message flag in the main status line
Mikael Berthe <mikael@lilotux.net>
parents:
1974
diff
changeset
|
1613 unreadchar = '#'; |
1d8f9135e000
Use smarter message flag in the main status line
Mikael Berthe <mikael@lilotux.net>
parents:
1974
diff
changeset
|
1614 else |
1d8f9135e000
Use smarter message flag in the main status line
Mikael Berthe <mikael@lilotux.net>
parents:
1974
diff
changeset
|
1615 unreadchar = ' '; |
713 | 1616 |
1617 werase(mainstatusWnd); | |
1515 | 1618 if (info) { |
1519 | 1619 char *info_locale = from_utf8(info); |
2100
113d3b96ae3e
Add option 'attention_char'
Mikael Berthe <mikael@lilotux.net>
parents:
2098
diff
changeset
|
1620 mvwprintw(mainstatusWnd, 0, 0, "%lc[%c] %s %s", unreadchar, |
1598 | 1621 imstatus2char[xmpp_getstatus()], |
1519 | 1622 info_locale, (sm ? sm : "")); |
1623 g_free(info_locale); | |
1515 | 1624 } else |
2100
113d3b96ae3e
Add option 'attention_char'
Mikael Berthe <mikael@lilotux.net>
parents:
2098
diff
changeset
|
1625 mvwprintw(mainstatusWnd, 0, 0, "%lc[%c] %s", unreadchar, |
1598 | 1626 imstatus2char[xmpp_getstatus()], (sm ? sm : "")); |
724
264375fe7159
Fix a roster refresh issue
Mikael Berthe <mikael@lilotux.net>
parents:
723
diff
changeset
|
1627 if (forceupdate) { |
264375fe7159
Fix a roster refresh issue
Mikael Berthe <mikael@lilotux.net>
parents:
723
diff
changeset
|
1628 top_panel(inputPanel); |
264375fe7159
Fix a roster refresh issue
Mikael Berthe <mikael@lilotux.net>
parents:
723
diff
changeset
|
1629 update_panels(); |
264375fe7159
Fix a roster refresh issue
Mikael Berthe <mikael@lilotux.net>
parents:
723
diff
changeset
|
1630 } |
773
e25b8a348ebd
Screen updating functions use UTF-8
Mikael Berthe <mikael@lilotux.net>
parents:
772
diff
changeset
|
1631 g_free(sm); |
713 | 1632 } |
1633 | |
1780
e4378fbab5d7
Major API cleanup - bump API to 4
Mikael Berthe <mikael@lilotux.net>
parents:
1761
diff
changeset
|
1634 // scr_draw_main_window() |
157 | 1635 // Set fullinit to TRUE to also create panels. Set it to FALSE for a resize. |
151 | 1636 // |
1637 // I think it could be improved a _lot_ but I'm really not an ncurses | |
1638 // expert... :-\ Mikael. | |
1639 // | |
1780
e4378fbab5d7
Major API cleanup - bump API to 4
Mikael Berthe <mikael@lilotux.net>
parents:
1761
diff
changeset
|
1640 void scr_draw_main_window(unsigned int fullinit) |
24 | 1641 { |
701
6c100adfbfb6
Add setting "roster_width" (variable buddylist width)
Mikael Berthe <mikael@lilotux.net>
parents:
699
diff
changeset
|
1642 int requested_size; |
961
95659cf9ea1a
Display mcabber version in the status window
Mikael Berthe <mikael@lilotux.net>
parents:
952
diff
changeset
|
1643 gchar *ver, *message; |
972
11b632d824f6
Add option 'log_win_on_top'
Mikael Berthe <mikael@lilotux.net>
parents:
967
diff
changeset
|
1644 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
|
1645 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
|
1646 |
2009
a859ed648638
Replace the option « no_space_before_items » with « roster_no_leading_space ».
Simon Jacquin <simon@jacquin.me>
parents:
2008
diff
changeset
|
1647 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
|
1648 |
518
9480a76471b6
Update Log_Win_Height when refreshing the screen
Mikael Berthe <mikael@lilotux.net>
parents:
515
diff
changeset
|
1649 Log_Win_Height = DEFAULT_LOG_WIN_HEIGHT; |
701
6c100adfbfb6
Add setting "roster_width" (variable buddylist width)
Mikael Berthe <mikael@lilotux.net>
parents:
699
diff
changeset
|
1650 requested_size = settings_opt_get_int("log_win_height"); |
6c100adfbfb6
Add setting "roster_width" (variable buddylist width)
Mikael Berthe <mikael@lilotux.net>
parents:
699
diff
changeset
|
1651 if (requested_size > 0) { |
6c100adfbfb6
Add setting "roster_width" (variable buddylist width)
Mikael Berthe <mikael@lilotux.net>
parents:
699
diff
changeset
|
1652 if (maxY > requested_size + 3) |
6c100adfbfb6
Add setting "roster_width" (variable buddylist width)
Mikael Berthe <mikael@lilotux.net>
parents:
699
diff
changeset
|
1653 Log_Win_Height = requested_size + 2; |
518
9480a76471b6
Update Log_Win_Height when refreshing the screen
Mikael Berthe <mikael@lilotux.net>
parents:
515
diff
changeset
|
1654 else |
9480a76471b6
Update Log_Win_Height when refreshing the screen
Mikael Berthe <mikael@lilotux.net>
parents:
515
diff
changeset
|
1655 Log_Win_Height = ((maxY > 5) ? (maxY - 2) : 3); |
701
6c100adfbfb6
Add setting "roster_width" (variable buddylist width)
Mikael Berthe <mikael@lilotux.net>
parents:
699
diff
changeset
|
1656 } else if (requested_size < 0) { |
518
9480a76471b6
Update Log_Win_Height when refreshing the screen
Mikael Berthe <mikael@lilotux.net>
parents:
515
diff
changeset
|
1657 Log_Win_Height = 3; |
9480a76471b6
Update Log_Win_Height when refreshing the screen
Mikael Berthe <mikael@lilotux.net>
parents:
515
diff
changeset
|
1658 } |
9480a76471b6
Update Log_Win_Height when refreshing the screen
Mikael Berthe <mikael@lilotux.net>
parents:
515
diff
changeset
|
1659 |
9480a76471b6
Update Log_Win_Height when refreshing the screen
Mikael Berthe <mikael@lilotux.net>
parents:
515
diff
changeset
|
1660 if (maxY < Log_Win_Height+2) { |
9480a76471b6
Update Log_Win_Height when refreshing the screen
Mikael Berthe <mikael@lilotux.net>
parents:
515
diff
changeset
|
1661 if (maxY < 5) { |
9480a76471b6
Update Log_Win_Height when refreshing the screen
Mikael Berthe <mikael@lilotux.net>
parents:
515
diff
changeset
|
1662 Log_Win_Height = 3; |
9480a76471b6
Update Log_Win_Height when refreshing the screen
Mikael Berthe <mikael@lilotux.net>
parents:
515
diff
changeset
|
1663 maxY = Log_Win_Height+2; |
9480a76471b6
Update Log_Win_Height when refreshing the screen
Mikael Berthe <mikael@lilotux.net>
parents:
515
diff
changeset
|
1664 } else { |
9480a76471b6
Update Log_Win_Height when refreshing the screen
Mikael Berthe <mikael@lilotux.net>
parents:
515
diff
changeset
|
1665 Log_Win_Height = maxY - 2; |
9480a76471b6
Update Log_Win_Height when refreshing the screen
Mikael Berthe <mikael@lilotux.net>
parents:
515
diff
changeset
|
1666 } |
9480a76471b6
Update Log_Win_Height when refreshing the screen
Mikael Berthe <mikael@lilotux.net>
parents:
515
diff
changeset
|
1667 } |
9480a76471b6
Update Log_Win_Height when refreshing the screen
Mikael Berthe <mikael@lilotux.net>
parents:
515
diff
changeset
|
1668 |
707
b26a0bde4cdb
Add /roster hide|show|toggle
Mikael Berthe <mikael@lilotux.net>
parents:
701
diff
changeset
|
1669 if (roster_hidden) { |
b26a0bde4cdb
Add /roster hide|show|toggle
Mikael Berthe <mikael@lilotux.net>
parents:
701
diff
changeset
|
1670 Roster_Width = 0; |
b26a0bde4cdb
Add /roster hide|show|toggle
Mikael Berthe <mikael@lilotux.net>
parents:
701
diff
changeset
|
1671 } else { |
b26a0bde4cdb
Add /roster hide|show|toggle
Mikael Berthe <mikael@lilotux.net>
parents:
701
diff
changeset
|
1672 requested_size = settings_opt_get_int("roster_width"); |
b26a0bde4cdb
Add /roster hide|show|toggle
Mikael Berthe <mikael@lilotux.net>
parents:
701
diff
changeset
|
1673 if (requested_size > 1) |
b26a0bde4cdb
Add /roster hide|show|toggle
Mikael Berthe <mikael@lilotux.net>
parents:
701
diff
changeset
|
1674 Roster_Width = requested_size; |
b26a0bde4cdb
Add /roster hide|show|toggle
Mikael Berthe <mikael@lilotux.net>
parents:
701
diff
changeset
|
1675 else if (requested_size == 1) |
b26a0bde4cdb
Add /roster hide|show|toggle
Mikael Berthe <mikael@lilotux.net>
parents:
701
diff
changeset
|
1676 Roster_Width = 2; |
b26a0bde4cdb
Add /roster hide|show|toggle
Mikael Berthe <mikael@lilotux.net>
parents:
701
diff
changeset
|
1677 else |
b26a0bde4cdb
Add /roster hide|show|toggle
Mikael Berthe <mikael@lilotux.net>
parents:
701
diff
changeset
|
1678 Roster_Width = DEFAULT_ROSTER_WIDTH; |
b26a0bde4cdb
Add /roster hide|show|toggle
Mikael Berthe <mikael@lilotux.net>
parents:
701
diff
changeset
|
1679 } |
701
6c100adfbfb6
Add setting "roster_width" (variable buddylist width)
Mikael Berthe <mikael@lilotux.net>
parents:
699
diff
changeset
|
1680 |
972
11b632d824f6
Add option 'log_win_on_top'
Mikael Berthe <mikael@lilotux.net>
parents:
967
diff
changeset
|
1681 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
|
1682 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
|
1683 |
11b632d824f6
Add option 'log_win_on_top'
Mikael Berthe <mikael@lilotux.net>
parents:
967
diff
changeset
|
1684 if (log_win_on_top) { |
11b632d824f6
Add option 'log_win_on_top'
Mikael Berthe <mikael@lilotux.net>
parents:
967
diff
changeset
|
1685 chat_y_pos = Log_Win_Height-1; |
11b632d824f6
Add option 'log_win_on_top'
Mikael Berthe <mikael@lilotux.net>
parents:
967
diff
changeset
|
1686 log_y_pos = 0; |
11b632d824f6
Add option 'log_win_on_top'
Mikael Berthe <mikael@lilotux.net>
parents:
967
diff
changeset
|
1687 chatstatus_y_pos = Log_Win_Height-2; |
11b632d824f6
Add option 'log_win_on_top'
Mikael Berthe <mikael@lilotux.net>
parents:
967
diff
changeset
|
1688 } else { |
11b632d824f6
Add option 'log_win_on_top'
Mikael Berthe <mikael@lilotux.net>
parents:
967
diff
changeset
|
1689 chat_y_pos = 0; |
11b632d824f6
Add option 'log_win_on_top'
Mikael Berthe <mikael@lilotux.net>
parents:
967
diff
changeset
|
1690 log_y_pos = CHAT_WIN_HEIGHT+1; |
11b632d824f6
Add option 'log_win_on_top'
Mikael Berthe <mikael@lilotux.net>
parents:
967
diff
changeset
|
1691 chatstatus_y_pos = CHAT_WIN_HEIGHT; |
11b632d824f6
Add option 'log_win_on_top'
Mikael Berthe <mikael@lilotux.net>
parents:
967
diff
changeset
|
1692 } |
11b632d824f6
Add option 'log_win_on_top'
Mikael Berthe <mikael@lilotux.net>
parents:
967
diff
changeset
|
1693 |
973
e693cbe33802
Add option 'roster_win_on_right'
Mikael Berthe <mikael@lilotux.net>
parents:
972
diff
changeset
|
1694 if (roster_win_on_right) { |
e693cbe33802
Add option 'roster_win_on_right'
Mikael Berthe <mikael@lilotux.net>
parents:
972
diff
changeset
|
1695 roster_x_pos = maxX - Roster_Width; |
e693cbe33802
Add option 'roster_win_on_right'
Mikael Berthe <mikael@lilotux.net>
parents:
972
diff
changeset
|
1696 chat_x_pos = 0; |
e693cbe33802
Add option 'roster_win_on_right'
Mikael Berthe <mikael@lilotux.net>
parents:
972
diff
changeset
|
1697 } else { |
e693cbe33802
Add option 'roster_win_on_right'
Mikael Berthe <mikael@lilotux.net>
parents:
972
diff
changeset
|
1698 roster_x_pos = 0; |
e693cbe33802
Add option 'roster_win_on_right'
Mikael Berthe <mikael@lilotux.net>
parents:
972
diff
changeset
|
1699 chat_x_pos = Roster_Width; |
e693cbe33802
Add option 'roster_win_on_right'
Mikael Berthe <mikael@lilotux.net>
parents:
972
diff
changeset
|
1700 } |
e693cbe33802
Add option 'roster_win_on_right'
Mikael Berthe <mikael@lilotux.net>
parents:
972
diff
changeset
|
1701 |
157 | 1702 if (fullinit) { |
1078
7866dbaf67a6
Use a hash for the list of win buffers
Mikael Berthe <mikael@lilotux.net>
parents:
1077
diff
changeset
|
1703 if (!winbufhash) |
7866dbaf67a6
Use a hash for the list of win buffers
Mikael Berthe <mikael@lilotux.net>
parents:
1077
diff
changeset
|
1704 winbufhash = g_hash_table_new_full(g_str_hash, g_str_equal, g_free, NULL); |
157 | 1705 /* Create windows */ |
973
e693cbe33802
Add option 'roster_win_on_right'
Mikael Berthe <mikael@lilotux.net>
parents:
972
diff
changeset
|
1706 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
|
1707 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
|
1708 chat_x_pos); |
1133
9dd28a56128f
Do not create one panel per contact
Mikael Berthe <mikael@lilotux.net>
parents:
1131
diff
changeset
|
1709 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
|
1710 chat_x_pos); |
972
11b632d824f6
Add option 'log_win_on_top'
Mikael Berthe <mikael@lilotux.net>
parents:
967
diff
changeset
|
1711 logWnd = newwin(Log_Win_Height-2, maxX, log_y_pos, 0); |
11b632d824f6
Add option 'log_win_on_top'
Mikael Berthe <mikael@lilotux.net>
parents:
967
diff
changeset
|
1712 chatstatusWnd = newwin(1, maxX, chatstatus_y_pos, 0); |
711 | 1713 mainstatusWnd = newwin(1, maxX, maxY-2, 0); |
157 | 1714 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
|
1715 if (!rosterWnd || !chatWnd || !logWnd || !inputWnd) { |
1780
e4378fbab5d7
Major API cleanup - bump API to 4
Mikael Berthe <mikael@lilotux.net>
parents:
1761
diff
changeset
|
1716 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
|
1717 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
|
1718 exit(EXIT_FAILURE); |
6e4e667c5571
Fix a segfault when starting mcabber in a really small terminal
Mikael Berthe <mikael@lilotux.net>
parents:
339
diff
changeset
|
1719 } |
739
0d5fb1d9077c
Allow "bright" text colors
Mikael Berthe <mikael@lilotux.net>
parents:
735
diff
changeset
|
1720 wbkgd(rosterWnd, get_color(COLOR_GENERAL)); |
0d5fb1d9077c
Allow "bright" text colors
Mikael Berthe <mikael@lilotux.net>
parents:
735
diff
changeset
|
1721 wbkgd(chatWnd, get_color(COLOR_GENERAL)); |
1133
9dd28a56128f
Do not create one panel per contact
Mikael Berthe <mikael@lilotux.net>
parents:
1131
diff
changeset
|
1722 wbkgd(activechatWnd, get_color(COLOR_GENERAL)); |
739
0d5fb1d9077c
Allow "bright" text colors
Mikael Berthe <mikael@lilotux.net>
parents:
735
diff
changeset
|
1723 wbkgd(logWnd, get_color(COLOR_GENERAL)); |
0d5fb1d9077c
Allow "bright" text colors
Mikael Berthe <mikael@lilotux.net>
parents:
735
diff
changeset
|
1724 wbkgd(chatstatusWnd, get_color(COLOR_STATUS)); |
0d5fb1d9077c
Allow "bright" text colors
Mikael Berthe <mikael@lilotux.net>
parents:
735
diff
changeset
|
1725 wbkgd(mainstatusWnd, get_color(COLOR_STATUS)); |
2028
7b5bd6ad83b4
Add 'color_log' (text color in the log window)
Mikael Berthe <mikael@lilotux.net>
parents:
2015
diff
changeset
|
1726 |
7b5bd6ad83b4
Add 'color_log' (text color in the log window)
Mikael Berthe <mikael@lilotux.net>
parents:
2015
diff
changeset
|
1727 wattrset(logWnd, get_color(COLOR_LOG)); |
157 | 1728 } else { |
701
6c100adfbfb6
Add setting "roster_width" (variable buddylist width)
Mikael Berthe <mikael@lilotux.net>
parents:
699
diff
changeset
|
1729 /* Resize/move windows */ |
6c100adfbfb6
Add setting "roster_width" (variable buddylist width)
Mikael Berthe <mikael@lilotux.net>
parents:
699
diff
changeset
|
1730 wresize(rosterWnd, CHAT_WIN_HEIGHT, Roster_Width); |
6c100adfbfb6
Add setting "roster_width" (variable buddylist width)
Mikael Berthe <mikael@lilotux.net>
parents:
699
diff
changeset
|
1731 wresize(chatWnd, CHAT_WIN_HEIGHT, maxX - Roster_Width); |
711 | 1732 wresize(logWnd, Log_Win_Height-2, maxX); |
157 | 1733 |
973
e693cbe33802
Add option 'roster_win_on_right'
Mikael Berthe <mikael@lilotux.net>
parents:
972
diff
changeset
|
1734 mvwin(chatWnd, chat_y_pos, chat_x_pos); |
e693cbe33802
Add option 'roster_win_on_right'
Mikael Berthe <mikael@lilotux.net>
parents:
972
diff
changeset
|
1735 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
|
1736 mvwin(logWnd, log_y_pos, 0); |
157 | 1737 |
711 | 1738 // Resize & move chat status window |
1739 wresize(chatstatusWnd, 1, maxX); | |
972
11b632d824f6
Add option 'log_win_on_top'
Mikael Berthe <mikael@lilotux.net>
parents:
967
diff
changeset
|
1740 mvwin(chatstatusWnd, chatstatus_y_pos, 0); |
711 | 1741 // Resize & move main status window |
1742 wresize(mainstatusWnd, 1, maxX); | |
1743 mvwin(mainstatusWnd, maxY-2, 0); | |
1744 // Resize & move input line window | |
157 | 1745 wresize(inputWnd, 1, maxX); |
1746 mvwin(inputWnd, maxY-1, 0); | |
168 | 1747 |
1748 werase(chatWnd); | |
157 | 1749 } |
151 | 1750 |
1751 /* Draw/init windows */ | |
1752 | |
961
95659cf9ea1a
Display mcabber version in the status window
Mikael Berthe <mikael@lilotux.net>
parents:
952
diff
changeset
|
1753 ver = mcabber_version(); |
95659cf9ea1a
Display mcabber version in the status window
Mikael Berthe <mikael@lilotux.net>
parents:
952
diff
changeset
|
1754 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
|
1755 mvwprintw(chatWnd, 0, 0, message); |
1455
bec235cd28a8
Misc. documentation updates
Mikael Berthe <mikael@lilotux.net>
parents:
1454
diff
changeset
|
1756 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
|
1757 g_free(ver); |
95659cf9ea1a
Display mcabber version in the status window
Mikael Berthe <mikael@lilotux.net>
parents:
952
diff
changeset
|
1758 g_free(message); |
24 | 1759 |
157 | 1760 // Auto-scrolling in log window |
74 | 1761 scrollok(logWnd, TRUE); |
24 | 1762 |
1763 | |
151 | 1764 if (fullinit) { |
157 | 1765 // Enable keypad (+ special keys) |
1766 keypad(inputWnd, TRUE); | |
1457
3a537b4d7f8d
Fix UTF-8 on MirBSD (Thorsten Glaser)
Mikael Berthe <mikael@lilotux.net>
parents:
1455
diff
changeset
|
1767 #ifdef __MirBSD__ |
3a537b4d7f8d
Fix UTF-8 on MirBSD (Thorsten Glaser)
Mikael Berthe <mikael@lilotux.net>
parents:
1455
diff
changeset
|
1768 wtimeout(inputWnd, 50 /* ms */); |
3a537b4d7f8d
Fix UTF-8 on MirBSD (Thorsten Glaser)
Mikael Berthe <mikael@lilotux.net>
parents:
1455
diff
changeset
|
1769 #else |
382
4c6e8392e465
Use nodelay() instead of halfdelay()
Mikael Berthe <mikael@lilotux.net>
parents:
374
diff
changeset
|
1770 nodelay(inputWnd, TRUE); |
1457
3a537b4d7f8d
Fix UTF-8 on MirBSD (Thorsten Glaser)
Mikael Berthe <mikael@lilotux.net>
parents:
1455
diff
changeset
|
1771 #endif |
157 | 1772 |
151 | 1773 // Create panels |
1774 rosterPanel = new_panel(rosterWnd); | |
1775 chatPanel = new_panel(chatWnd); | |
1133
9dd28a56128f
Do not create one panel per contact
Mikael Berthe <mikael@lilotux.net>
parents:
1131
diff
changeset
|
1776 activechatPanel = new_panel(activechatWnd); |
151 | 1777 logPanel = new_panel(logWnd); |
711 | 1778 chatstatusPanel = new_panel(chatstatusWnd); |
1779 mainstatusPanel = new_panel(mainstatusWnd); | |
151 | 1780 inputPanel = new_panel(inputWnd); |
232 | 1781 |
849
42c43a88d823
Status buffer management
Mikael Berthe <mikael@lilotux.net>
parents:
848
diff
changeset
|
1782 // 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
|
1783 // is added |
42c43a88d823
Status buffer management
Mikael Berthe <mikael@lilotux.net>
parents:
848
diff
changeset
|
1784 buddylist_build(); |
1093
6ca9a65df21f
Do not rewrap buffer lines when the chat window width doesn't change
Mikael Berthe <mikael@lilotux.net>
parents:
1089
diff
changeset
|
1785 |
6ca9a65df21f
Do not rewrap buffer lines when the chat window width doesn't change
Mikael Berthe <mikael@lilotux.net>
parents:
1089
diff
changeset
|
1786 // 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
|
1787 // from rewrapping buffers when the width doesn't change. |
1487 | 1788 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
|
1789 // 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
|
1790 hbuf_rebuild(&statushbuf, prev_chatwidth); |
849
42c43a88d823
Status buffer management
Mikael Berthe <mikael@lilotux.net>
parents:
848
diff
changeset
|
1791 |
930
a75f7a13df7b
UTF-8 terminal support (Reimar Döffinger)
Mikael Berthe <mikael@lilotux.net>
parents:
929
diff
changeset
|
1792 #ifndef UNICODE |
232 | 1793 if (utf8_mode) |
930
a75f7a13df7b
UTF-8 terminal support (Reimar Döffinger)
Mikael Berthe <mikael@lilotux.net>
parents:
929
diff
changeset
|
1794 scr_LogPrint(LPRINT_NORMAL, |
a75f7a13df7b
UTF-8 terminal support (Reimar Döffinger)
Mikael Berthe <mikael@lilotux.net>
parents:
929
diff
changeset
|
1795 "WARNING: Compiled without full UTF-8 support!"); |
a75f7a13df7b
UTF-8 terminal support (Reimar Döffinger)
Mikael Berthe <mikael@lilotux.net>
parents:
929
diff
changeset
|
1796 #endif |
157 | 1797 } else { |
1798 // Update panels | |
1799 replace_panel(rosterPanel, rosterWnd); | |
1800 replace_panel(chatPanel, chatWnd); | |
1801 replace_panel(logPanel, logWnd); | |
711 | 1802 replace_panel(chatstatusPanel, chatstatusWnd); |
1803 replace_panel(mainstatusPanel, mainstatusWnd); | |
157 | 1804 replace_panel(inputPanel, inputWnd); |
151 | 1805 } |
1806 | |
1807 // We'll need to redraw the roster | |
149 | 1808 update_roster = TRUE; |
24 | 1809 return; |
1810 } | |
1811 | |
1078
7866dbaf67a6
Use a hash for the list of win buffers
Mikael Berthe <mikael@lilotux.net>
parents:
1077
diff
changeset
|
1812 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
|
1813 { |
1078
7866dbaf67a6
Use a hash for the list of win buffers
Mikael Berthe <mikael@lilotux.net>
parents:
1077
diff
changeset
|
1814 winbuf *wbp = value; |
7866dbaf67a6
Use a hash for the list of win buffers
Mikael Berthe <mikael@lilotux.net>
parents:
1077
diff
changeset
|
1815 struct dimensions *dim = data; |
973
e693cbe33802
Add option 'roster_win_on_right'
Mikael Berthe <mikael@lilotux.net>
parents:
972
diff
changeset
|
1816 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
|
1817 int new_chatwidth; |
972
11b632d824f6
Add option 'log_win_on_top'
Mikael Berthe <mikael@lilotux.net>
parents:
967
diff
changeset
|
1818 |
1078
7866dbaf67a6
Use a hash for the list of win buffers
Mikael Berthe <mikael@lilotux.net>
parents:
1077
diff
changeset
|
1819 if (!(wbp && wbp->win)) |
7866dbaf67a6
Use a hash for the list of win buffers
Mikael Berthe <mikael@lilotux.net>
parents:
1077
diff
changeset
|
1820 return; |
7866dbaf67a6
Use a hash for the list of win buffers
Mikael Berthe <mikael@lilotux.net>
parents:
1077
diff
changeset
|
1821 |
972
11b632d824f6
Add option 'log_win_on_top'
Mikael Berthe <mikael@lilotux.net>
parents:
967
diff
changeset
|
1822 if (log_win_on_top) |
11b632d824f6
Add option 'log_win_on_top'
Mikael Berthe <mikael@lilotux.net>
parents:
967
diff
changeset
|
1823 chat_y_pos = Log_Win_Height-1; |
11b632d824f6
Add option 'log_win_on_top'
Mikael Berthe <mikael@lilotux.net>
parents:
967
diff
changeset
|
1824 else |
11b632d824f6
Add option 'log_win_on_top'
Mikael Berthe <mikael@lilotux.net>
parents:
967
diff
changeset
|
1825 chat_y_pos = 0; |
11b632d824f6
Add option 'log_win_on_top'
Mikael Berthe <mikael@lilotux.net>
parents:
967
diff
changeset
|
1826 |
973
e693cbe33802
Add option 'roster_win_on_right'
Mikael Berthe <mikael@lilotux.net>
parents:
972
diff
changeset
|
1827 if (roster_win_on_right) |
e693cbe33802
Add option 'roster_win_on_right'
Mikael Berthe <mikael@lilotux.net>
parents:
972
diff
changeset
|
1828 chat_x_pos = 0; |
e693cbe33802
Add option 'roster_win_on_right'
Mikael Berthe <mikael@lilotux.net>
parents:
972
diff
changeset
|
1829 else |
e693cbe33802
Add option 'roster_win_on_right'
Mikael Berthe <mikael@lilotux.net>
parents:
972
diff
changeset
|
1830 chat_x_pos = Roster_Width; |
e693cbe33802
Add option 'roster_win_on_right'
Mikael Berthe <mikael@lilotux.net>
parents:
972
diff
changeset
|
1831 |
849
42c43a88d823
Status buffer management
Mikael Berthe <mikael@lilotux.net>
parents:
848
diff
changeset
|
1832 // Resize/move buddy window |
1078
7866dbaf67a6
Use a hash for the list of win buffers
Mikael Berthe <mikael@lilotux.net>
parents:
1077
diff
changeset
|
1833 wresize(wbp->win, dim->l, dim->c); |
973
e693cbe33802
Add option 'roster_win_on_right'
Mikael Berthe <mikael@lilotux.net>
parents:
972
diff
changeset
|
1834 mvwin(wbp->win, chat_y_pos, chat_x_pos); |
849
42c43a88d823
Status buffer management
Mikael Berthe <mikael@lilotux.net>
parents:
848
diff
changeset
|
1835 werase(wbp->win); |
42c43a88d823
Status buffer management
Mikael Berthe <mikael@lilotux.net>
parents:
848
diff
changeset
|
1836 // If a panel exists, replace the old window with the new |
42c43a88d823
Status buffer management
Mikael Berthe <mikael@lilotux.net>
parents:
848
diff
changeset
|
1837 if (wbp->panel) |
42c43a88d823
Status buffer management
Mikael Berthe <mikael@lilotux.net>
parents:
848
diff
changeset
|
1838 replace_panel(wbp->panel, wbp->win); |
42c43a88d823
Status buffer management
Mikael Berthe <mikael@lilotux.net>
parents:
848
diff
changeset
|
1839 // Redo line wrapping |
1157
5c857f0f0ab8
Moved all variables related to hbuf to an extra struct, bufdata
Frank Zschockelt
parents:
1156
diff
changeset
|
1840 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
|
1841 |
1487 | 1842 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
|
1843 if (new_chatwidth != prev_chatwidth) |
1157
5c857f0f0ab8
Moved all variables related to hbuf to an extra struct, bufdata
Frank Zschockelt
parents:
1156
diff
changeset
|
1844 hbuf_rebuild(&wbp->bd->hbuf, new_chatwidth); |
849
42c43a88d823
Status buffer management
Mikael Berthe <mikael@lilotux.net>
parents:
848
diff
changeset
|
1845 } |
42c43a88d823
Status buffer management
Mikael Berthe <mikael@lilotux.net>
parents:
848
diff
changeset
|
1846 |
151 | 1847 // scr_Resize() |
1848 // Function called when the window is resized. | |
157 | 1849 // - Resize windows |
151 | 1850 // - Rewrap lines in each buddy buffer |
1059 | 1851 void scr_Resize(void) |
151 | 1852 { |
1078
7866dbaf67a6
Use a hash for the list of win buffers
Mikael Berthe <mikael@lilotux.net>
parents:
1077
diff
changeset
|
1853 struct dimensions dim; |
151 | 1854 |
1855 // First, update the global variables | |
1856 getmaxyx(stdscr, maxY, maxX); | |
1780
e4378fbab5d7
Major API cleanup - bump API to 4
Mikael Berthe <mikael@lilotux.net>
parents:
1761
diff
changeset
|
1857 // 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
|
1858 |
151 | 1859 // Make sure the cursor stays inside the window |
1860 check_offset(0); | |
1861 | |
157 | 1862 // Resize windows and update panels |
1780
e4378fbab5d7
Major API cleanup - bump API to 4
Mikael Berthe <mikael@lilotux.net>
parents:
1761
diff
changeset
|
1863 scr_draw_main_window(FALSE); |
151 | 1864 |
1865 // Resize all buddy windows | |
1078
7866dbaf67a6
Use a hash for the list of win buffers
Mikael Berthe <mikael@lilotux.net>
parents:
1077
diff
changeset
|
1866 dim.l = CHAT_WIN_HEIGHT; |
7866dbaf67a6
Use a hash for the list of win buffers
Mikael Berthe <mikael@lilotux.net>
parents:
1077
diff
changeset
|
1867 dim.c = maxX - Roster_Width; |
7866dbaf67a6
Use a hash for the list of win buffers
Mikael Berthe <mikael@lilotux.net>
parents:
1077
diff
changeset
|
1868 if (dim.c < 1) |
7866dbaf67a6
Use a hash for the list of win buffers
Mikael Berthe <mikael@lilotux.net>
parents:
1077
diff
changeset
|
1869 dim.c = 1; |
7866dbaf67a6
Use a hash for the list of win buffers
Mikael Berthe <mikael@lilotux.net>
parents:
1077
diff
changeset
|
1870 |
7866dbaf67a6
Use a hash for the list of win buffers
Mikael Berthe <mikael@lilotux.net>
parents:
1077
diff
changeset
|
1871 // Resize all buffers |
7866dbaf67a6
Use a hash for the list of win buffers
Mikael Berthe <mikael@lilotux.net>
parents:
1077
diff
changeset
|
1872 g_hash_table_foreach(winbufhash, resize_win_buffer, &dim); |
151 | 1873 |
849
42c43a88d823
Status buffer management
Mikael Berthe <mikael@lilotux.net>
parents:
848
diff
changeset
|
1874 // Resize/move special status buffer |
42c43a88d823
Status buffer management
Mikael Berthe <mikael@lilotux.net>
parents:
848
diff
changeset
|
1875 if (statusWindow) |
1078
7866dbaf67a6
Use a hash for the list of win buffers
Mikael Berthe <mikael@lilotux.net>
parents:
1077
diff
changeset
|
1876 resize_win_buffer(NULL, statusWindow, &dim); |
849
42c43a88d823
Status buffer management
Mikael Berthe <mikael@lilotux.net>
parents:
848
diff
changeset
|
1877 |
1093
6ca9a65df21f
Do not rewrap buffer lines when the chat window width doesn't change
Mikael Berthe <mikael@lilotux.net>
parents:
1089
diff
changeset
|
1878 // Update prev_chatwidth, now that all buffers have been resized |
1487 | 1879 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
|
1880 |
151 | 1881 // Refresh current buddy window |
157 | 1882 if (chatmode) |
1780
e4378fbab5d7
Major API cleanup - bump API to 4
Mikael Berthe <mikael@lilotux.net>
parents:
1761
diff
changeset
|
1883 scr_show_buddy_window(); |
151 | 1884 } |
1885 | |
1780
e4378fbab5d7
Major API cleanup - bump API to 4
Mikael Berthe <mikael@lilotux.net>
parents:
1761
diff
changeset
|
1886 // scr_update_chat_status(forceupdate) |
713 | 1887 // Redraw the buddy status bar. |
939
12fa2ae6445d
Get rid of "busy-waiting" (Christof Meerwald)
Mikael Berthe <mikael@lilotux.net>
parents:
936
diff
changeset
|
1888 // 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
|
1889 void scr_update_chat_status(int forceupdate) |
713 | 1890 { |
848
a9161d2dc414
Introduce special buffer stuff
Mikael Berthe <mikael@lilotux.net>
parents:
843
diff
changeset
|
1891 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
|
1892 const char *btypetext = "Unknown"; |
717
8ce2bfdc4143
Reindent update_chat_status_window()
Mikael Berthe <mikael@lilotux.net>
parents:
716
diff
changeset
|
1893 const char *fullname; |
2013
8dc418af3e72
Allow to select to which buddy resource messages go. Closes issue #55
Hermitifier
parents:
2012
diff
changeset
|
1894 char *fullnameres = NULL; |
8dc418af3e72
Allow to select to which buddy resource messages go. Closes issue #55
Hermitifier
parents:
2012
diff
changeset
|
1895 const char *activeres; |
717
8ce2bfdc4143
Reindent update_chat_status_window()
Mikael Berthe <mikael@lilotux.net>
parents:
716
diff
changeset
|
1896 const char *msg = NULL; |
8ce2bfdc4143
Reindent update_chat_status_window()
Mikael Berthe <mikael@lilotux.net>
parents:
716
diff
changeset
|
1897 char status; |
773
e25b8a348ebd
Screen updating functions use UTF-8
Mikael Berthe <mikael@lilotux.net>
parents:
772
diff
changeset
|
1898 char *buf, *buf_locale; |
713 | 1899 |
718
b41799901abd
Add a new_message flag (#) in the main status line
Mikael Berthe <mikael@lilotux.net>
parents:
717
diff
changeset
|
1900 // 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
|
1901 // 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
|
1902 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
|
1903 |
806
3521e34f722a
Fix a segfault when not connected to a server
Mikael Berthe <mikael@lilotux.net>
parents:
797
diff
changeset
|
1904 // Clear the line |
3521e34f722a
Fix a segfault when not connected to a server
Mikael Berthe <mikael@lilotux.net>
parents:
797
diff
changeset
|
1905 werase(chatstatusWnd); |
3521e34f722a
Fix a segfault when not connected to a server
Mikael Berthe <mikael@lilotux.net>
parents:
797
diff
changeset
|
1906 |
3521e34f722a
Fix a segfault when not connected to a server
Mikael Berthe <mikael@lilotux.net>
parents:
797
diff
changeset
|
1907 if (!current_buddy) { |
3521e34f722a
Fix a segfault when not connected to a server
Mikael Berthe <mikael@lilotux.net>
parents:
797
diff
changeset
|
1908 if (forceupdate) { |
3521e34f722a
Fix a segfault when not connected to a server
Mikael Berthe <mikael@lilotux.net>
parents:
797
diff
changeset
|
1909 update_panels(); |
3521e34f722a
Fix a segfault when not connected to a server
Mikael Berthe <mikael@lilotux.net>
parents:
797
diff
changeset
|
1910 } |
3521e34f722a
Fix a segfault when not connected to a server
Mikael Berthe <mikael@lilotux.net>
parents:
797
diff
changeset
|
1911 return; |
3521e34f722a
Fix a segfault when not connected to a server
Mikael Berthe <mikael@lilotux.net>
parents:
797
diff
changeset
|
1912 } |
3521e34f722a
Fix a segfault when not connected to a server
Mikael Berthe <mikael@lilotux.net>
parents:
797
diff
changeset
|
1913 |
717
8ce2bfdc4143
Reindent update_chat_status_window()
Mikael Berthe <mikael@lilotux.net>
parents:
716
diff
changeset
|
1914 fullname = buddy_getname(BUDDATA(current_buddy)); |
8ce2bfdc4143
Reindent update_chat_status_window()
Mikael Berthe <mikael@lilotux.net>
parents:
716
diff
changeset
|
1915 btype = buddy_gettype(BUDDATA(current_buddy)); |
713 | 1916 |
1502
50dbbca69b55
Small style improvement of buddy status line
Maxim Vuets <maxim.vuets@gmail.com>
parents:
1489
diff
changeset
|
1917 isgrp = ismuc = isspe = 0; |
50dbbca69b55
Small style improvement of buddy status line
Maxim Vuets <maxim.vuets@gmail.com>
parents:
1489
diff
changeset
|
1918 if (btype & ROSTER_TYPE_USER) { |
50dbbca69b55
Small style improvement of buddy status line
Maxim Vuets <maxim.vuets@gmail.com>
parents:
1489
diff
changeset
|
1919 btypetext = "Buddy"; |
50dbbca69b55
Small style improvement of buddy status line
Maxim Vuets <maxim.vuets@gmail.com>
parents:
1489
diff
changeset
|
1920 } else if (btype & ROSTER_TYPE_GROUP) { |
50dbbca69b55
Small style improvement of buddy status line
Maxim Vuets <maxim.vuets@gmail.com>
parents:
1489
diff
changeset
|
1921 btypetext = "Group"; |
50dbbca69b55
Small style improvement of buddy status line
Maxim Vuets <maxim.vuets@gmail.com>
parents:
1489
diff
changeset
|
1922 isgrp = 1; |
50dbbca69b55
Small style improvement of buddy status line
Maxim Vuets <maxim.vuets@gmail.com>
parents:
1489
diff
changeset
|
1923 } else if (btype & ROSTER_TYPE_AGENT) { |
50dbbca69b55
Small style improvement of buddy status line
Maxim Vuets <maxim.vuets@gmail.com>
parents:
1489
diff
changeset
|
1924 btypetext = "Agent"; |
50dbbca69b55
Small style improvement of buddy status line
Maxim Vuets <maxim.vuets@gmail.com>
parents:
1489
diff
changeset
|
1925 } else if (btype & ROSTER_TYPE_ROOM) { |
50dbbca69b55
Small style improvement of buddy status line
Maxim Vuets <maxim.vuets@gmail.com>
parents:
1489
diff
changeset
|
1926 btypetext = "Room"; |
50dbbca69b55
Small style improvement of buddy status line
Maxim Vuets <maxim.vuets@gmail.com>
parents:
1489
diff
changeset
|
1927 ismuc = 1; |
50dbbca69b55
Small style improvement of buddy status line
Maxim Vuets <maxim.vuets@gmail.com>
parents:
1489
diff
changeset
|
1928 } else if (btype & ROSTER_TYPE_SPECIAL) { |
50dbbca69b55
Small style improvement of buddy status line
Maxim Vuets <maxim.vuets@gmail.com>
parents:
1489
diff
changeset
|
1929 btypetext = "Special buffer"; |
50dbbca69b55
Small style improvement of buddy status line
Maxim Vuets <maxim.vuets@gmail.com>
parents:
1489
diff
changeset
|
1930 isspe = 1; |
50dbbca69b55
Small style improvement of buddy status line
Maxim Vuets <maxim.vuets@gmail.com>
parents:
1489
diff
changeset
|
1931 } |
713 | 1932 |
1513
9d78b571e693
Show '#' for unread message per buddy on the buddy status line
Maxim Vuets <maxim.vuets@gmail.com>
parents:
1511
diff
changeset
|
1933 if (chatmode) { |
9d78b571e693
Show '#' for unread message per buddy on the buddy status line
Maxim Vuets <maxim.vuets@gmail.com>
parents:
1511
diff
changeset
|
1934 wprintw(chatstatusWnd, "~"); |
9d78b571e693
Show '#' for unread message per buddy on the buddy status line
Maxim Vuets <maxim.vuets@gmail.com>
parents:
1511
diff
changeset
|
1935 } else { |
9d78b571e693
Show '#' for unread message per buddy on the buddy status line
Maxim Vuets <maxim.vuets@gmail.com>
parents:
1511
diff
changeset
|
1936 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
|
1937 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
|
1938 // 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
|
1939 wprintw(chatstatusWnd, "#"); |
9d78b571e693
Show '#' for unread message per buddy on the buddy status line
Maxim Vuets <maxim.vuets@gmail.com>
parents:
1511
diff
changeset
|
1940 } |
9d78b571e693
Show '#' for unread message per buddy on the buddy status line
Maxim Vuets <maxim.vuets@gmail.com>
parents:
1511
diff
changeset
|
1941 } |
9d78b571e693
Show '#' for unread message per buddy on the buddy status line
Maxim Vuets <maxim.vuets@gmail.com>
parents:
1511
diff
changeset
|
1942 |
874
293e8955075c
Display a flag in the chat status line when the buffer is locked
Mikael Berthe <mikael@lilotux.net>
parents:
873
diff
changeset
|
1943 if (chatmode && !isgrp) { |
293e8955075c
Display a flag in the chat status line when the buffer is locked
Mikael Berthe <mikael@lilotux.net>
parents:
873
diff
changeset
|
1944 winbuf *win_entry; |
1780
e4378fbab5d7
Major API cleanup - bump API to 4
Mikael Berthe <mikael@lilotux.net>
parents:
1761
diff
changeset
|
1945 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
|
1946 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
|
1947 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
|
1948 } |
293e8955075c
Display a flag in the chat status line when the buffer is locked
Mikael Berthe <mikael@lilotux.net>
parents:
873
diff
changeset
|
1949 |
848
a9161d2dc414
Introduce special buffer stuff
Mikael Berthe <mikael@lilotux.net>
parents:
843
diff
changeset
|
1950 if (isgrp || isspe) { |
773
e25b8a348ebd
Screen updating functions use UTF-8
Mikael Berthe <mikael@lilotux.net>
parents:
772
diff
changeset
|
1951 buf_locale = from_utf8(fullname); |
1502
50dbbca69b55
Small style improvement of buddy status line
Maxim Vuets <maxim.vuets@gmail.com>
parents:
1489
diff
changeset
|
1952 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
|
1953 g_free(buf_locale); |
716
ba1137a01078
Add a chatmode flag (©) in the chat status line
Mikael Berthe <mikael@lilotux.net>
parents:
715
diff
changeset
|
1954 if (forceupdate) { |
ba1137a01078
Add a chatmode flag (©) in the chat status line
Mikael Berthe <mikael@lilotux.net>
parents:
715
diff
changeset
|
1955 update_panels(); |
ba1137a01078
Add a chatmode flag (©) in the chat status line
Mikael Berthe <mikael@lilotux.net>
parents:
715
diff
changeset
|
1956 } |
717
8ce2bfdc4143
Reindent update_chat_status_window()
Mikael Berthe <mikael@lilotux.net>
parents:
716
diff
changeset
|
1957 return; |
8ce2bfdc4143
Reindent update_chat_status_window()
Mikael Berthe <mikael@lilotux.net>
parents:
716
diff
changeset
|
1958 } |
8ce2bfdc4143
Reindent update_chat_status_window()
Mikael Berthe <mikael@lilotux.net>
parents:
716
diff
changeset
|
1959 |
8ce2bfdc4143
Reindent update_chat_status_window()
Mikael Berthe <mikael@lilotux.net>
parents:
716
diff
changeset
|
1960 status = '?'; |
8ce2bfdc4143
Reindent update_chat_status_window()
Mikael Berthe <mikael@lilotux.net>
parents:
716
diff
changeset
|
1961 |
2013
8dc418af3e72
Allow to select to which buddy resource messages go. Closes issue #55
Hermitifier
parents:
2012
diff
changeset
|
1962 activeres = buddy_getactiveresource(BUDDATA(current_buddy)); |
8dc418af3e72
Allow to select to which buddy resource messages go. Closes issue #55
Hermitifier
parents:
2012
diff
changeset
|
1963 |
717
8ce2bfdc4143
Reindent update_chat_status_window()
Mikael Berthe <mikael@lilotux.net>
parents:
716
diff
changeset
|
1964 if (ismuc) { |
8ce2bfdc4143
Reindent update_chat_status_window()
Mikael Berthe <mikael@lilotux.net>
parents:
716
diff
changeset
|
1965 if (buddy_getinsideroom(BUDDATA(current_buddy))) |
8ce2bfdc4143
Reindent update_chat_status_window()
Mikael Berthe <mikael@lilotux.net>
parents:
716
diff
changeset
|
1966 status = 'C'; |
8ce2bfdc4143
Reindent update_chat_status_window()
Mikael Berthe <mikael@lilotux.net>
parents:
716
diff
changeset
|
1967 else |
8ce2bfdc4143
Reindent update_chat_status_window()
Mikael Berthe <mikael@lilotux.net>
parents:
716
diff
changeset
|
1968 status = 'x'; |
1598 | 1969 } else if (xmpp_getstatus() != offline) { |
717
8ce2bfdc4143
Reindent update_chat_status_window()
Mikael Berthe <mikael@lilotux.net>
parents:
716
diff
changeset
|
1970 enum imstatus budstate; |
2013
8dc418af3e72
Allow to select to which buddy resource messages go. Closes issue #55
Hermitifier
parents:
2012
diff
changeset
|
1971 budstate = buddy_getstatus(BUDDATA(current_buddy), activeres); |
790
5d4ad1d77da4
Kill a few gcc4 warnings
Mikael Berthe <mikael@lilotux.net>
parents:
785
diff
changeset
|
1972 if (budstate < imstatus_size) |
717
8ce2bfdc4143
Reindent update_chat_status_window()
Mikael Berthe <mikael@lilotux.net>
parents:
716
diff
changeset
|
1973 status = imstatus2char[budstate]; |
8ce2bfdc4143
Reindent update_chat_status_window()
Mikael Berthe <mikael@lilotux.net>
parents:
716
diff
changeset
|
1974 } |
8ce2bfdc4143
Reindent update_chat_status_window()
Mikael Berthe <mikael@lilotux.net>
parents:
716
diff
changeset
|
1975 |
1502
50dbbca69b55
Small style improvement of buddy status line
Maxim Vuets <maxim.vuets@gmail.com>
parents:
1489
diff
changeset
|
1976 // No status message for MUC rooms |
50dbbca69b55
Small style improvement of buddy status line
Maxim Vuets <maxim.vuets@gmail.com>
parents:
1489
diff
changeset
|
1977 if (!ismuc) { |
2013
8dc418af3e72
Allow to select to which buddy resource messages go. Closes issue #55
Hermitifier
parents:
2012
diff
changeset
|
1978 if (activeres) { |
8dc418af3e72
Allow to select to which buddy resource messages go. Closes issue #55
Hermitifier
parents:
2012
diff
changeset
|
1979 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
|
1980 fullname = fullnameres; |
8dc418af3e72
Allow to select to which buddy resource messages go. Closes issue #55
Hermitifier
parents:
2012
diff
changeset
|
1981 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
|
1982 } else { |
8dc418af3e72
Allow to select to which buddy resource messages go. Closes issue #55
Hermitifier
parents:
2012
diff
changeset
|
1983 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
|
1984 resources = buddy_getresources(BUDDATA(current_buddy)); |
8dc418af3e72
Allow to select to which buddy resource messages go. Closes issue #55
Hermitifier
parents:
2012
diff
changeset
|
1985 |
8dc418af3e72
Allow to select to which buddy resource messages go. Closes issue #55
Hermitifier
parents:
2012
diff
changeset
|
1986 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
|
1987 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
|
1988 // 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
|
1989 if (!p_next_res) |
8dc418af3e72
Allow to select to which buddy resource messages go. Closes issue #55
Hermitifier
parents:
2012
diff
changeset
|
1990 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
|
1991 g_free(p_res->data); |
8dc418af3e72
Allow to select to which buddy resource messages go. Closes issue #55
Hermitifier
parents:
2012
diff
changeset
|
1992 } |
8dc418af3e72
Allow to select to which buddy resource messages go. Closes issue #55
Hermitifier
parents:
2012
diff
changeset
|
1993 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
|
1994 } |
1502
50dbbca69b55
Small style improvement of buddy status line
Maxim Vuets <maxim.vuets@gmail.com>
parents:
1489
diff
changeset
|
1995 } else { |
721
9cf31c9b1dc4
Use room topic as a description in the chat status line
Mikael Berthe <mikael@lilotux.net>
parents:
720
diff
changeset
|
1996 msg = buddy_gettopic(BUDDATA(current_buddy)); |
717
8ce2bfdc4143
Reindent update_chat_status_window()
Mikael Berthe <mikael@lilotux.net>
parents:
716
diff
changeset
|
1997 } |
1502
50dbbca69b55
Small style improvement of buddy status line
Maxim Vuets <maxim.vuets@gmail.com>
parents:
1489
diff
changeset
|
1998 |
50dbbca69b55
Small style improvement of buddy status line
Maxim Vuets <maxim.vuets@gmail.com>
parents:
1489
diff
changeset
|
1999 if (msg) |
50dbbca69b55
Small style improvement of buddy status line
Maxim Vuets <maxim.vuets@gmail.com>
parents:
1489
diff
changeset
|
2000 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
|
2001 else |
50dbbca69b55
Small style improvement of buddy status line
Maxim Vuets <maxim.vuets@gmail.com>
parents:
1489
diff
changeset
|
2002 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
|
2003 replace_nl_with_dots(buf); |
773
e25b8a348ebd
Screen updating functions use UTF-8
Mikael Berthe <mikael@lilotux.net>
parents:
772
diff
changeset
|
2004 buf_locale = from_utf8(buf); |
e25b8a348ebd
Screen updating functions use UTF-8
Mikael Berthe <mikael@lilotux.net>
parents:
772
diff
changeset
|
2005 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
|
2006 g_free(fullnameres); |
773
e25b8a348ebd
Screen updating functions use UTF-8
Mikael Berthe <mikael@lilotux.net>
parents:
772
diff
changeset
|
2007 g_free(buf_locale); |
717
8ce2bfdc4143
Reindent update_chat_status_window()
Mikael Berthe <mikael@lilotux.net>
parents:
716
diff
changeset
|
2008 g_free(buf); |
8ce2bfdc4143
Reindent update_chat_status_window()
Mikael Berthe <mikael@lilotux.net>
parents:
716
diff
changeset
|
2009 |
996
f4d6570e2628
Chatstates: display contact chatstate in the chat status bar
Mikael Berthe <mikael@lilotux.net>
parents:
993
diff
changeset
|
2010 // 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
|
2011 if (btype & ROSTER_TYPE_USER) { |
f4d6570e2628
Chatstates: display contact chatstate in the chat status bar
Mikael Berthe <mikael@lilotux.net>
parents:
993
diff
changeset
|
2012 char eventchar = 0; |
f4d6570e2628
Chatstates: display contact chatstate in the chat status bar
Mikael Berthe <mikael@lilotux.net>
parents:
993
diff
changeset
|
2013 guint event; |
f4d6570e2628
Chatstates: display contact chatstate in the chat status bar
Mikael Berthe <mikael@lilotux.net>
parents:
993
diff
changeset
|
2014 |
2013
8dc418af3e72
Allow to select to which buddy resource messages go. Closes issue #55
Hermitifier
parents:
2012
diff
changeset
|
2015 // 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
|
2016 // 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
|
2017 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
|
2018 |
f4d6570e2628
Chatstates: display contact chatstate in the chat status bar
Mikael Berthe <mikael@lilotux.net>
parents:
993
diff
changeset
|
2019 if (event == ROSTER_EVENT_ACTIVE) |
f4d6570e2628
Chatstates: display contact chatstate in the chat status bar
Mikael Berthe <mikael@lilotux.net>
parents:
993
diff
changeset
|
2020 eventchar = 'A'; |
f4d6570e2628
Chatstates: display contact chatstate in the chat status bar
Mikael Berthe <mikael@lilotux.net>
parents:
993
diff
changeset
|
2021 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
|
2022 eventchar = 'C'; |
f4d6570e2628
Chatstates: display contact chatstate in the chat status bar
Mikael Berthe <mikael@lilotux.net>
parents:
993
diff
changeset
|
2023 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
|
2024 eventchar = 'P'; |
f4d6570e2628
Chatstates: display contact chatstate in the chat status bar
Mikael Berthe <mikael@lilotux.net>
parents:
993
diff
changeset
|
2025 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
|
2026 eventchar = 'I'; |
f4d6570e2628
Chatstates: display contact chatstate in the chat status bar
Mikael Berthe <mikael@lilotux.net>
parents:
993
diff
changeset
|
2027 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
|
2028 eventchar = 'G'; |
f4d6570e2628
Chatstates: display contact chatstate in the chat status bar
Mikael Berthe <mikael@lilotux.net>
parents:
993
diff
changeset
|
2029 |
f4d6570e2628
Chatstates: display contact chatstate in the chat status bar
Mikael Berthe <mikael@lilotux.net>
parents:
993
diff
changeset
|
2030 if (eventchar) |
f4d6570e2628
Chatstates: display contact chatstate in the chat status bar
Mikael Berthe <mikael@lilotux.net>
parents:
993
diff
changeset
|
2031 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
|
2032 } |
f4d6570e2628
Chatstates: display contact chatstate in the chat status bar
Mikael Berthe <mikael@lilotux.net>
parents:
993
diff
changeset
|
2033 |
f4d6570e2628
Chatstates: display contact chatstate in the chat status bar
Mikael Berthe <mikael@lilotux.net>
parents:
993
diff
changeset
|
2034 |
717
8ce2bfdc4143
Reindent update_chat_status_window()
Mikael Berthe <mikael@lilotux.net>
parents:
716
diff
changeset
|
2035 if (forceupdate) { |
8ce2bfdc4143
Reindent update_chat_status_window()
Mikael Berthe <mikael@lilotux.net>
parents:
716
diff
changeset
|
2036 update_panels(); |
8ce2bfdc4143
Reindent update_chat_status_window()
Mikael Berthe <mikael@lilotux.net>
parents:
716
diff
changeset
|
2037 } |
713 | 2038 } |
2039 | |
1504
9fafea381eb8
Show the number of unfiltered contacts in folded groups
franky
parents:
1503
diff
changeset
|
2040 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
|
2041 { |
9fafea381eb8
Show the number of unfiltered contacts in folded groups
franky
parents:
1503
diff
changeset
|
2042 int *p = param; |
9fafea381eb8
Show the number of unfiltered contacts in folded groups
franky
parents:
1503
diff
changeset
|
2043 if (buddylist_is_status_filtered(buddy_getstatus(rosterdata, NULL))) |
9fafea381eb8
Show the number of unfiltered contacts in folded groups
franky
parents:
1503
diff
changeset
|
2044 *p=*p+1; |
9fafea381eb8
Show the number of unfiltered contacts in folded groups
franky
parents:
1503
diff
changeset
|
2045 } |
9fafea381eb8
Show the number of unfiltered contacts in folded groups
franky
parents:
1503
diff
changeset
|
2046 |
1780
e4378fbab5d7
Major API cleanup - bump API to 4
Mikael Berthe <mikael@lilotux.net>
parents:
1761
diff
changeset
|
2047 // scr_draw_roster() |
328
83d129adde03
Add set_current_buddy() function, to reduce code duplication
Mikael Berthe <mikael@lilotux.net>
parents:
325
diff
changeset
|
2048 // 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
|
2049 void scr_draw_roster(void) |
24 | 2050 { |
735 | 2051 static int offset = 0; |
701
6c100adfbfb6
Add setting "roster_width" (variable buddylist width)
Mikael Berthe <mikael@lilotux.net>
parents:
699
diff
changeset
|
2052 char *name, *rline; |
81 | 2053 int maxx, maxy; |
2054 GList *buddy; | |
2055 int i, n; | |
2056 int rOffset; | |
713 | 2057 int cursor_backup; |
2100
113d3b96ae3e
Add option 'attention_char'
Mikael Berthe <mikael@lilotux.net>
parents:
2098
diff
changeset
|
2058 guint status, pending; |
1598 | 2059 enum imstatus currentstatus = xmpp_getstatus(); |
973
e693cbe33802
Add option 'roster_win_on_right'
Mikael Berthe <mikael@lilotux.net>
parents:
972
diff
changeset
|
2060 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
|
2061 int prefix_length; |
2136
54548cf8f646
screen.c: Remove one memory allocation in scr_draw_roster()
Mikael Berthe <mikael@lilotux.net>
parents:
2101
diff
changeset
|
2062 char space[2] = " "; |
81 | 2063 |
123 | 2064 // We can reset update_roster |
2065 update_roster = FALSE; | |
2066 | |
81 | 2067 getmaxyx(rosterWnd, maxy, maxx); |
701
6c100adfbfb6
Add setting "roster_width" (variable buddylist width)
Mikael Berthe <mikael@lilotux.net>
parents:
699
diff
changeset
|
2068 maxx--; // Last char is for vertical border |
81 | 2069 |
713 | 2070 cursor_backup = curs_set(0); |
2071 | |
724
264375fe7159
Fix a roster refresh issue
Mikael Berthe <mikael@lilotux.net>
parents:
723
diff
changeset
|
2072 if (!buddylist) |
264375fe7159
Fix a roster refresh issue
Mikael Berthe <mikael@lilotux.net>
parents:
723
diff
changeset
|
2073 offset = 0; |
264375fe7159
Fix a roster refresh issue
Mikael Berthe <mikael@lilotux.net>
parents:
723
diff
changeset
|
2074 else |
1780
e4378fbab5d7
Major API cleanup - bump API to 4
Mikael Berthe <mikael@lilotux.net>
parents:
1761
diff
changeset
|
2075 scr_update_chat_status(FALSE); |
724
264375fe7159
Fix a roster refresh issue
Mikael Berthe <mikael@lilotux.net>
parents:
723
diff
changeset
|
2076 |
701
6c100adfbfb6
Add setting "roster_width" (variable buddylist width)
Mikael Berthe <mikael@lilotux.net>
parents:
699
diff
changeset
|
2077 // Cleanup of roster window |
168 | 2078 werase(rosterWnd); |
81 | 2079 |
707
b26a0bde4cdb
Add /roster hide|show|toggle
Mikael Berthe <mikael@lilotux.net>
parents:
701
diff
changeset
|
2080 if (Roster_Width) { |
973
e693cbe33802
Add option 'roster_win_on_right'
Mikael Berthe <mikael@lilotux.net>
parents:
972
diff
changeset
|
2081 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
|
2082 // Redraw the vertical line (not very good...) |
739
0d5fb1d9077c
Allow "bright" text colors
Mikael Berthe <mikael@lilotux.net>
parents:
735
diff
changeset
|
2083 wattrset(rosterWnd, get_color(COLOR_GENERAL)); |
707
b26a0bde4cdb
Add /roster hide|show|toggle
Mikael Berthe <mikael@lilotux.net>
parents:
701
diff
changeset
|
2084 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
|
2085 mvwaddch(rosterWnd, i, line_x_pos, ACS_VLINE); |
707
b26a0bde4cdb
Add /roster hide|show|toggle
Mikael Berthe <mikael@lilotux.net>
parents:
701
diff
changeset
|
2086 } |
b26a0bde4cdb
Add /roster hide|show|toggle
Mikael Berthe <mikael@lilotux.net>
parents:
701
diff
changeset
|
2087 |
b26a0bde4cdb
Add /roster hide|show|toggle
Mikael Berthe <mikael@lilotux.net>
parents:
701
diff
changeset
|
2088 // 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
|
2089 if (!buddylist || !Roster_Width) { |
123 | 2090 update_panels(); |
713 | 2091 curs_set(cursor_backup); |
81 | 2092 return; |
2093 } | |
2094 | |
84 | 2095 // Update offset if necessary |
680
1f8987e0e56c
Try to display as many buddylist items as possible
Mikael Berthe <mikael@lilotux.net>
parents:
679
diff
changeset
|
2096 // 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
|
2097 i = g_list_length(buddylist) - maxy; |
682
f3945593432e
Small fix in scr_DrawRoster()
Mikael Berthe <mikael@lilotux.net>
parents:
680
diff
changeset
|
2098 if (i < 0) |
f3945593432e
Small fix in scr_DrawRoster()
Mikael Berthe <mikael@lilotux.net>
parents:
680
diff
changeset
|
2099 i = 0; |
f3945593432e
Small fix in scr_DrawRoster()
Mikael Berthe <mikael@lilotux.net>
parents:
680
diff
changeset
|
2100 if (i < offset) |
680
1f8987e0e56c
Try to display as many buddylist items as possible
Mikael Berthe <mikael@lilotux.net>
parents:
679
diff
changeset
|
2101 offset = i; |
1f8987e0e56c
Try to display as many buddylist items as possible
Mikael Berthe <mikael@lilotux.net>
parents:
679
diff
changeset
|
2102 // b) Make sure the current_buddy is visible |
84 | 2103 i = g_list_position(buddylist, current_buddy); |
2104 if (i == -1) { // This is bad | |
374
bd5638c21834
Improve logging system (traces)
Mikael Berthe <mikael@lilotux.net>
parents:
373
diff
changeset
|
2105 scr_LogPrint(LPRINT_NORMAL, "Doh! Can't find current selected buddy!!"); |
713 | 2106 curs_set(cursor_backup); |
84 | 2107 return; |
2108 } else if (i < offset) { | |
2109 offset = i; | |
2110 } else if (i+1 > offset + maxy) { | |
2111 offset = i + 1 - maxy; | |
2112 } | |
81 | 2113 |
973
e693cbe33802
Add option 'roster_win_on_right'
Mikael Berthe <mikael@lilotux.net>
parents:
972
diff
changeset
|
2114 if (roster_win_on_right) |
e693cbe33802
Add option 'roster_win_on_right'
Mikael Berthe <mikael@lilotux.net>
parents:
972
diff
changeset
|
2115 x_pos = 1; // 1 char offset (vertical line) |
e693cbe33802
Add option 'roster_win_on_right'
Mikael Berthe <mikael@lilotux.net>
parents:
972
diff
changeset
|
2116 else |
e693cbe33802
Add option 'roster_win_on_right'
Mikael Berthe <mikael@lilotux.net>
parents:
972
diff
changeset
|
2117 x_pos = 0; |
e693cbe33802
Add option 'roster_win_on_right'
Mikael Berthe <mikael@lilotux.net>
parents:
972
diff
changeset
|
2118 |
2009
a859ed648638
Replace the option « no_space_before_items » with « roster_no_leading_space ».
Simon Jacquin <simon@jacquin.me>
parents:
2008
diff
changeset
|
2119 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
|
2120 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
|
2121 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
|
2122 } else { |
6c02ccb14c1c
Added an option to remove the extra space before items in the roster.
Simon Jacquin <simon@jacquin.me>
parents:
1997
diff
changeset
|
2123 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
|
2124 } |
6c02ccb14c1c
Added an option to remove the extra space before items in the roster.
Simon Jacquin <simon@jacquin.me>
parents:
1997
diff
changeset
|
2125 |
1026
fc6060707022
[BP] Fixes truncating utf-8 buddy names (Myhailo Danylenko)
Mikael Berthe <mikael@lilotux.net>
parents:
966
diff
changeset
|
2126 name = g_new0(char, 4*Roster_Width); |
fc6060707022
[BP] Fixes truncating utf-8 buddy names (Myhailo Danylenko)
Mikael Berthe <mikael@lilotux.net>
parents:
966
diff
changeset
|
2127 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
|
2128 |
81 | 2129 buddy = buddylist; |
2130 rOffset = offset; | |
2131 | |
84 | 2132 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
|
2133 unsigned short bflags, btype; |
35a1250c111a
Display urgent/attention sign in the roster UI
Mikael Berthe <mikael@lilotux.net>
parents:
1802
diff
changeset
|
2134 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
|
2135 guint isurg; |
773
e25b8a348ebd
Screen updating functions use UTF-8
Mikael Berthe <mikael@lilotux.net>
parents:
772
diff
changeset
|
2136 gchar *rline_locale; |
1072
2a3cfb98bd5e
Fix memory leaks after calls to buddy_getresources()
Mikael Berthe <mikael@lilotux.net>
parents:
1059
diff
changeset
|
2137 GSList *resources, *p_res; |
713 | 2138 |
2139 bflags = buddy_getflags(BUDDATA(buddy)); | |
2140 btype = buddy_gettype(BUDDATA(buddy)); | |
2141 | |
2142 ismsg = bflags & ROSTER_FLAG_MSG; | |
2143 ishid = bflags & ROSTER_FLAG_HIDE; | |
2144 isgrp = btype & ROSTER_TYPE_GROUP; | |
2145 ismuc = btype & ROSTER_TYPE_ROOM; | |
848
a9161d2dc414
Introduce special buffer stuff
Mikael Berthe <mikael@lilotux.net>
parents:
843
diff
changeset
|
2146 isspe = btype & ROSTER_TYPE_SPECIAL; |
1804
35a1250c111a
Display urgent/attention sign in the roster UI
Mikael Berthe <mikael@lilotux.net>
parents:
1802
diff
changeset
|
2147 isurg = buddy_getuiprio(BUDDATA(buddy)); |
81 | 2148 |
2149 if (rOffset > 0) { | |
2150 rOffset--; | |
2151 continue; | |
2152 } | |
2153 | |
713 | 2154 status = '?'; |
2155 pending = ' '; | |
2156 | |
986
ed697234bd39
Chat states receival (Alexis Hildebrandt)
Mikael Berthe <mikael@lilotux.net>
parents:
981
diff
changeset
|
2157 resources = buddy_getresources(BUDDATA(buddy)); |
1072
2a3cfb98bd5e
Fix memory leaks after calls to buddy_getresources()
Mikael Berthe <mikael@lilotux.net>
parents:
1059
diff
changeset
|
2158 for (p_res = resources ; p_res ; p_res = g_slist_next(p_res)) { |
986
ed697234bd39
Chat states receival (Alexis Hildebrandt)
Mikael Berthe <mikael@lilotux.net>
parents:
981
diff
changeset
|
2159 guint events = buddy_resource_getevents(BUDDATA(buddy), |
1072
2a3cfb98bd5e
Fix memory leaks after calls to buddy_getresources()
Mikael Berthe <mikael@lilotux.net>
parents:
1059
diff
changeset
|
2160 p_res ? p_res->data : ""); |
2a3cfb98bd5e
Fix memory leaks after calls to buddy_getresources()
Mikael Berthe <mikael@lilotux.net>
parents:
1059
diff
changeset
|
2161 if ((events & ROSTER_EVENT_PAUSED) && pending != '+') |
992
b37348c2aa79
Chatstates: display "paused" states in the roster
Mikael Berthe <mikael@lilotux.net>
parents:
991
diff
changeset
|
2162 pending = '.'; |
1072
2a3cfb98bd5e
Fix memory leaks after calls to buddy_getresources()
Mikael Berthe <mikael@lilotux.net>
parents:
1059
diff
changeset
|
2163 if (events & ROSTER_EVENT_COMPOSING) |
987
f47e312560af
Improve JEP22 + JEP85 support
Mikael Berthe <mikael@lilotux.net>
parents:
986
diff
changeset
|
2164 pending = '+'; |
1072
2a3cfb98bd5e
Fix memory leaks after calls to buddy_getresources()
Mikael Berthe <mikael@lilotux.net>
parents:
1059
diff
changeset
|
2165 g_free(p_res->data); |
986
ed697234bd39
Chat states receival (Alexis Hildebrandt)
Mikael Berthe <mikael@lilotux.net>
parents:
981
diff
changeset
|
2166 } |
1072
2a3cfb98bd5e
Fix memory leaks after calls to buddy_getresources()
Mikael Berthe <mikael@lilotux.net>
parents:
1059
diff
changeset
|
2167 g_slist_free(resources); |
986
ed697234bd39
Chat states receival (Alexis Hildebrandt)
Mikael Berthe <mikael@lilotux.net>
parents:
981
diff
changeset
|
2168 |
149 | 2169 // Display message notice if there is a message flag, but not |
2170 // for unfolded groups. | |
2171 if (ismsg && (!isgrp || ishid)) { | |
81 | 2172 pending = '#'; |
2173 } | |
2174 | |
713 | 2175 if (ismuc) { |
2176 if (buddy_getinsideroom(BUDDATA(buddy))) | |
2177 status = 'C'; | |
2178 else | |
2179 status = 'x'; | |
2180 } else if (currentstatus != offline) { | |
2181 enum imstatus budstate; | |
2182 budstate = buddy_getstatus(BUDDATA(buddy), NULL); | |
790
5d4ad1d77da4
Kill a few gcc4 warnings
Mikael Berthe <mikael@lilotux.net>
parents:
785
diff
changeset
|
2183 if (budstate < imstatus_size) |
713 | 2184 status = imstatus2char[budstate]; |
2185 } | |
81 | 2186 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
|
2187 if (pending == '#') |
739
0d5fb1d9077c
Allow "bright" text colors
Mikael Berthe <mikael@lilotux.net>
parents:
735
diff
changeset
|
2188 wattrset(rosterWnd, get_color(COLOR_ROSTERSELNMSG)); |
723
23068490d063
Add text color when the selected buddy has an unread message
Mikael Berthe <mikael@lilotux.net>
parents:
721
diff
changeset
|
2189 else |
739
0d5fb1d9077c
Allow "bright" text colors
Mikael Berthe <mikael@lilotux.net>
parents:
735
diff
changeset
|
2190 wattrset(rosterWnd, get_color(COLOR_ROSTERSEL)); |
723
23068490d063
Add text color when the selected buddy has an unread message
Mikael Berthe <mikael@lilotux.net>
parents:
721
diff
changeset
|
2191 // 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
|
2192 wmove(rosterWnd, i, x_pos); |
81 | 2193 for (n = 0; n < maxx; n++) |
2194 waddch(rosterWnd, ' '); | |
2195 } else { | |
149 | 2196 if (pending == '#') |
739
0d5fb1d9077c
Allow "bright" text colors
Mikael Berthe <mikael@lilotux.net>
parents:
735
diff
changeset
|
2197 wattrset(rosterWnd, get_color(COLOR_ROSTERNMSG)); |
1272
033576acac4c
Add configurable roster colors (Michal 'vorner' Vaner)
Mikael Berthe <mikael@lilotux.net>
parents:
1268
diff
changeset
|
2198 else { |
033576acac4c
Add configurable roster colors (Michal 'vorner' Vaner)
Mikael Berthe <mikael@lilotux.net>
parents:
1268
diff
changeset
|
2199 int color = get_color(COLOR_ROSTER); |
1729
e6e89b1d7831
Minor style and header updates
Mikael Berthe <mikael@lilotux.net>
parents:
1710
diff
changeset
|
2200 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
|
2201 GSList *head; |
1804
35a1250c111a
Display urgent/attention sign in the roster UI
Mikael Berthe <mikael@lilotux.net>
parents:
1802
diff
changeset
|
2202 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
|
2203 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
|
2204 rostercolor *rc = head->data; |
1804
35a1250c111a
Display urgent/attention sign in the roster UI
Mikael Berthe <mikael@lilotux.net>
parents:
1802
diff
changeset
|
2205 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
|
2206 (!strcmp("*", rc->status) || strchr(rc->status, status))) { |
1489
e9c71ce96dca
Fixed the colorhandling for mucnicks and /color roster
franky@veqlargh.fs
parents:
1488
diff
changeset
|
2207 color = compose_color(rc->color); |
1272
033576acac4c
Add configurable roster colors (Michal 'vorner' Vaner)
Mikael Berthe <mikael@lilotux.net>
parents:
1268
diff
changeset
|
2208 break; |
033576acac4c
Add configurable roster colors (Michal 'vorner' Vaner)
Mikael Berthe <mikael@lilotux.net>
parents:
1268
diff
changeset
|
2209 } |
033576acac4c
Add configurable roster colors (Michal 'vorner' Vaner)
Mikael Berthe <mikael@lilotux.net>
parents:
1268
diff
changeset
|
2210 } |
033576acac4c
Add configurable roster colors (Michal 'vorner' Vaner)
Mikael Berthe <mikael@lilotux.net>
parents:
1268
diff
changeset
|
2211 } |
033576acac4c
Add configurable roster colors (Michal 'vorner' Vaner)
Mikael Berthe <mikael@lilotux.net>
parents:
1268
diff
changeset
|
2212 wattrset(rosterWnd, color); |
033576acac4c
Add configurable roster colors (Michal 'vorner' Vaner)
Mikael Berthe <mikael@lilotux.net>
parents:
1268
diff
changeset
|
2213 } |
81 | 2214 } |
2215 | |
2007
6c02ccb14c1c
Added an option to remove the extra space before items in the roster.
Simon Jacquin <simon@jacquin.me>
parents:
1997
diff
changeset
|
2216 if (Roster_Width > prefix_length) |
6c02ccb14c1c
Added an option to remove the extra space before items in the roster.
Simon Jacquin <simon@jacquin.me>
parents:
1997
diff
changeset
|
2217 g_utf8_strncpy(name, buddy_getname(BUDDATA(buddy)), Roster_Width-prefix_length); |
701
6c100adfbfb6
Add setting "roster_width" (variable buddylist width)
Mikael Berthe <mikael@lilotux.net>
parents:
699
diff
changeset
|
2218 else |
6c100adfbfb6
Add setting "roster_width" (variable buddylist width)
Mikael Berthe <mikael@lilotux.net>
parents:
699
diff
changeset
|
2219 name[0] = 0; |
6c100adfbfb6
Add setting "roster_width" (variable buddylist width)
Mikael Berthe <mikael@lilotux.net>
parents:
699
diff
changeset
|
2220 |
1804
35a1250c111a
Display urgent/attention sign in the roster UI
Mikael Berthe <mikael@lilotux.net>
parents:
1802
diff
changeset
|
2221 if (pending == '#') { |
35a1250c111a
Display urgent/attention sign in the roster UI
Mikael Berthe <mikael@lilotux.net>
parents:
1802
diff
changeset
|
2222 // Attention sign? |
35a1250c111a
Display urgent/attention sign in the roster UI
Mikael Berthe <mikael@lilotux.net>
parents:
1802
diff
changeset
|
2223 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
|
2224 (!ismuc && isurg >= ui_attn_sign_prio_level)) |
2100
113d3b96ae3e
Add option 'attention_char'
Mikael Berthe <mikael@lilotux.net>
parents:
2098
diff
changeset
|
2225 pending = attention_sign(); |
1804
35a1250c111a
Display urgent/attention sign in the roster UI
Mikael Berthe <mikael@lilotux.net>
parents:
1802
diff
changeset
|
2226 } |
35a1250c111a
Display urgent/attention sign in the roster UI
Mikael Berthe <mikael@lilotux.net>
parents:
1802
diff
changeset
|
2227 |
149 | 2228 if (isgrp) { |
1598 | 2229 if (ishid) { |
1504
9fafea381eb8
Show the number of unfiltered contacts in folded groups
franky
parents:
1503
diff
changeset
|
2230 int group_count = 0; |
9fafea381eb8
Show the number of unfiltered contacts in folded groups
franky
parents:
1503
diff
changeset
|
2231 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
|
2232 &group_count); |
2100
113d3b96ae3e
Add option 'attention_char'
Mikael Berthe <mikael@lilotux.net>
parents:
2098
diff
changeset
|
2233 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
|
2234 name, group_count); |
1579
a2dd83167bc9
Fix display error in the roster
Mikael Berthe <mikael@lilotux.net>
parents:
1573
diff
changeset
|
2235 /* 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
|
2236 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
|
2237 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
|
2238 } |
133 | 2239 else |
2100
113d3b96ae3e
Add option 'attention_char'
Mikael Berthe <mikael@lilotux.net>
parents:
2098
diff
changeset
|
2240 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
|
2241 } else if (isspe) { |
2100
113d3b96ae3e
Add option 'attention_char'
Mikael Berthe <mikael@lilotux.net>
parents:
2098
diff
changeset
|
2242 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
|
2243 } else { |
824
37ef269330f0
Show incomplete subscriptions in the roster
Mikael Berthe <mikael@lilotux.net>
parents:
822
diff
changeset
|
2244 char sepleft = '['; |
37ef269330f0
Show incomplete subscriptions in the roster
Mikael Berthe <mikael@lilotux.net>
parents:
822
diff
changeset
|
2245 char sepright = ']'; |
37ef269330f0
Show incomplete subscriptions in the roster
Mikael Berthe <mikael@lilotux.net>
parents:
822
diff
changeset
|
2246 if (btype & ROSTER_TYPE_USER) { |
37ef269330f0
Show incomplete subscriptions in the roster
Mikael Berthe <mikael@lilotux.net>
parents:
822
diff
changeset
|
2247 guint subtype = buddy_getsubscription(BUDDATA(buddy)); |
832
7c210263c661
Small scr_DrawRoster() fix
Mikael Berthe <mikael@lilotux.net>
parents:
828
diff
changeset
|
2248 if (status == '_' && !(subtype & sub_to)) |
824
37ef269330f0
Show incomplete subscriptions in the roster
Mikael Berthe <mikael@lilotux.net>
parents:
822
diff
changeset
|
2249 status = '?'; |
37ef269330f0
Show incomplete subscriptions in the roster
Mikael Berthe <mikael@lilotux.net>
parents:
822
diff
changeset
|
2250 if (!(subtype & sub_from)) { |
37ef269330f0
Show incomplete subscriptions in the roster
Mikael Berthe <mikael@lilotux.net>
parents:
822
diff
changeset
|
2251 sepleft = '{'; |
37ef269330f0
Show incomplete subscriptions in the roster
Mikael Berthe <mikael@lilotux.net>
parents:
822
diff
changeset
|
2252 sepright = '}'; |
37ef269330f0
Show incomplete subscriptions in the roster
Mikael Berthe <mikael@lilotux.net>
parents:
822
diff
changeset
|
2253 } |
37ef269330f0
Show incomplete subscriptions in the roster
Mikael Berthe <mikael@lilotux.net>
parents:
822
diff
changeset
|
2254 } |
2100
113d3b96ae3e
Add option 'attention_char'
Mikael Berthe <mikael@lilotux.net>
parents:
2098
diff
changeset
|
2255 snprintf(rline, 4*Roster_Width, "%s%lc%c%c%c %s", |
113d3b96ae3e
Add option 'attention_char'
Mikael Berthe <mikael@lilotux.net>
parents:
2098
diff
changeset
|
2256 space, pending, sepleft, status, sepright, name); |
133 | 2257 } |
84 | 2258 |
773
e25b8a348ebd
Screen updating functions use UTF-8
Mikael Berthe <mikael@lilotux.net>
parents:
772
diff
changeset
|
2259 rline_locale = from_utf8(rline); |
981
553b8ecf901f
Fixes truncating of utf-8 buddy names (again)
Myhailo Danylenko <isbear@ukrpost.net>
parents:
980
diff
changeset
|
2260 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
|
2261 g_free(rline_locale); |
84 | 2262 i++; |
81 | 2263 } |
2264 | |
701
6c100adfbfb6
Add setting "roster_width" (variable buddylist width)
Mikael Berthe <mikael@lilotux.net>
parents:
699
diff
changeset
|
2265 g_free(rline); |
6c100adfbfb6
Add setting "roster_width" (variable buddylist width)
Mikael Berthe <mikael@lilotux.net>
parents:
699
diff
changeset
|
2266 g_free(name); |
142 | 2267 top_panel(inputPanel); |
81 | 2268 update_panels(); |
713 | 2269 curs_set(cursor_backup); |
24 | 2270 } |
2271 | |
1780
e4378fbab5d7
Major API cleanup - bump API to 4
Mikael Berthe <mikael@lilotux.net>
parents:
1761
diff
changeset
|
2272 // scr_roster_visibility(status) |
707
b26a0bde4cdb
Add /roster hide|show|toggle
Mikael Berthe <mikael@lilotux.net>
parents:
701
diff
changeset
|
2273 // Set the roster visibility: |
b26a0bde4cdb
Add /roster hide|show|toggle
Mikael Berthe <mikael@lilotux.net>
parents:
701
diff
changeset
|
2274 // status=1 Show roster |
b26a0bde4cdb
Add /roster hide|show|toggle
Mikael Berthe <mikael@lilotux.net>
parents:
701
diff
changeset
|
2275 // status=0 Hide roster |
b26a0bde4cdb
Add /roster hide|show|toggle
Mikael Berthe <mikael@lilotux.net>
parents:
701
diff
changeset
|
2276 // status=-1 Toggle roster status |
1780
e4378fbab5d7
Major API cleanup - bump API to 4
Mikael Berthe <mikael@lilotux.net>
parents:
1761
diff
changeset
|
2277 void scr_roster_visibility(int status) |
707
b26a0bde4cdb
Add /roster hide|show|toggle
Mikael Berthe <mikael@lilotux.net>
parents:
701
diff
changeset
|
2278 { |
708
ed326697e4ed
scr_RosterVisibility(): do not refresh when it is not needed
Mikael Berthe <mikael@lilotux.net>
parents:
707
diff
changeset
|
2279 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
|
2280 |
707
b26a0bde4cdb
Add /roster hide|show|toggle
Mikael Berthe <mikael@lilotux.net>
parents:
701
diff
changeset
|
2281 if (status > 0) |
b26a0bde4cdb
Add /roster hide|show|toggle
Mikael Berthe <mikael@lilotux.net>
parents:
701
diff
changeset
|
2282 roster_hidden = FALSE; |
b26a0bde4cdb
Add /roster hide|show|toggle
Mikael Berthe <mikael@lilotux.net>
parents:
701
diff
changeset
|
2283 else if (status == 0) |
b26a0bde4cdb
Add /roster hide|show|toggle
Mikael Berthe <mikael@lilotux.net>
parents:
701
diff
changeset
|
2284 roster_hidden = TRUE; |
b26a0bde4cdb
Add /roster hide|show|toggle
Mikael Berthe <mikael@lilotux.net>
parents:
701
diff
changeset
|
2285 else |
b26a0bde4cdb
Add /roster hide|show|toggle
Mikael Berthe <mikael@lilotux.net>
parents:
701
diff
changeset
|
2286 roster_hidden = !roster_hidden; |
b26a0bde4cdb
Add /roster hide|show|toggle
Mikael Berthe <mikael@lilotux.net>
parents:
701
diff
changeset
|
2287 |
708
ed326697e4ed
scr_RosterVisibility(): do not refresh when it is not needed
Mikael Berthe <mikael@lilotux.net>
parents:
707
diff
changeset
|
2288 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
|
2289 // Recalculate windows size and redraw |
ed326697e4ed
scr_RosterVisibility(): do not refresh when it is not needed
Mikael Berthe <mikael@lilotux.net>
parents:
707
diff
changeset
|
2290 scr_Resize(); |
ed326697e4ed
scr_RosterVisibility(): do not refresh when it is not needed
Mikael Berthe <mikael@lilotux.net>
parents:
707
diff
changeset
|
2291 redrawwin(stdscr); |
ed326697e4ed
scr_RosterVisibility(): do not refresh when it is not needed
Mikael Berthe <mikael@lilotux.net>
parents:
707
diff
changeset
|
2292 } |
707
b26a0bde4cdb
Add /roster hide|show|toggle
Mikael Berthe <mikael@lilotux.net>
parents:
701
diff
changeset
|
2293 } |
b26a0bde4cdb
Add /roster hide|show|toggle
Mikael Berthe <mikael@lilotux.net>
parents:
701
diff
changeset
|
2294 |
1780
e4378fbab5d7
Major API cleanup - bump API to 4
Mikael Berthe <mikael@lilotux.net>
parents:
1761
diff
changeset
|
2295 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
|
2296 time_t timestamp, guint prefix_flags, |
e4378fbab5d7
Major API cleanup - bump API to 4
Mikael Berthe <mikael@lilotux.net>
parents:
1761
diff
changeset
|
2297 unsigned mucnicklen, gpointer xep184) |
24 | 2298 { |
727
1c3620668857
Expand tabs when reading history files
Mikael Berthe <mikael@lilotux.net>
parents:
726
diff
changeset
|
2299 char *xtext; |
725
1aff92625bdb
Expand tabs when receiving a message
Mikael Berthe <mikael@lilotux.net>
parents:
724
diff
changeset
|
2300 |
2090
16b04d64ec88
Add option to highlight timestamp added by server.
Hermitifier
parents:
2074
diff
changeset
|
2301 if (!timestamp) |
16b04d64ec88
Add option to highlight timestamp added by server.
Hermitifier
parents:
2074
diff
changeset
|
2302 timestamp = time(NULL); |
16b04d64ec88
Add option to highlight timestamp added by server.
Hermitifier
parents:
2074
diff
changeset
|
2303 else |
16b04d64ec88
Add option to highlight timestamp added by server.
Hermitifier
parents:
2074
diff
changeset
|
2304 prefix_flags |= HBB_PREFIX_DELAYED; |
725
1aff92625bdb
Expand tabs when receiving a message
Mikael Berthe <mikael@lilotux.net>
parents:
724
diff
changeset
|
2305 |
1122
648fe6f715a6
Filter out ^M (0x0d) characters in incoming messages
Mikael Berthe <mikael@lilotux.net>
parents:
1115
diff
changeset
|
2306 xtext = ut_expand_tabs(text); // Expand tabs and filter out some chars |
726 | 2307 |
1780
e4378fbab5d7
Major API cleanup - bump API to 4
Mikael Berthe <mikael@lilotux.net>
parents:
1761
diff
changeset
|
2308 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
|
2309 xep184); |
725
1aff92625bdb
Expand tabs when receiving a message
Mikael Berthe <mikael@lilotux.net>
parents:
724
diff
changeset
|
2310 |
1aff92625bdb
Expand tabs when receiving a message
Mikael Berthe <mikael@lilotux.net>
parents:
724
diff
changeset
|
2311 if (xtext != (char*)text) |
1aff92625bdb
Expand tabs when receiving a message
Mikael Berthe <mikael@lilotux.net>
parents:
724
diff
changeset
|
2312 g_free(xtext); |
24 | 2313 } |
2314 | |
726 | 2315 // 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
|
2316 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
|
2317 time_t timestamp, |
af3de54ef986
Convert scr_LogPrint() to scr_log_print()
Mikael Berthe <mikael@lilotux.net>
parents:
1780
diff
changeset
|
2318 guint prefix, unsigned mucnicklen) |
726 | 2319 { |
1055
6eb1efea75d0
PGP: Visual encryption flag
Mikael Berthe <mikael@lilotux.net>
parents:
1050
diff
changeset
|
2320 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
|
2321 ~HBB_PREFIX_NOFLAG & ~HBB_PREFIX_HLIGHT & ~HBB_PREFIX_HLIGHT_OUT & |
1484
7b36b91a4388
New UI message flag (O) when OTR is used
Mikael Berthe <mikael@lilotux.net>
parents:
1483
diff
changeset
|
2322 ~HBB_PREFIX_PGPCRYPT & ~HBB_PREFIX_OTRCRYPT)) |
726 | 2323 prefix |= HBB_PREFIX_IN; |
2324 | |
1780
e4378fbab5d7
Major API cleanup - bump API to 4
Mikael Berthe <mikael@lilotux.net>
parents:
1761
diff
changeset
|
2325 scr_write_message(jidfrom, text, timestamp, prefix, mucnicklen, NULL); |
726 | 2326 } |
2327 | |
1783
af3de54ef986
Convert scr_LogPrint() to scr_log_print()
Mikael Berthe <mikael@lilotux.net>
parents:
1780
diff
changeset
|
2328 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
|
2329 guint prefix, gpointer xep184) |
47 | 2330 { |
1115
922a9ae1a17e
Fix /say_to to a member of a folded group
Mikael Berthe <mikael@lilotux.net>
parents:
1093
diff
changeset
|
2331 GSList *roster_elt; |
922a9ae1a17e
Fix /say_to to a member of a folded group
Mikael Berthe <mikael@lilotux.net>
parents:
1093
diff
changeset
|
2332 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
|
2333 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
|
2334 |
1780
e4378fbab5d7
Major API cleanup - bump API to 4
Mikael Berthe <mikael@lilotux.net>
parents:
1761
diff
changeset
|
2335 scr_write_message(jidto, text, |
e4378fbab5d7
Major API cleanup - bump API to 4
Mikael Berthe <mikael@lilotux.net>
parents:
1761
diff
changeset
|
2336 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
|
2337 |
922a9ae1a17e
Fix /say_to to a member of a folded group
Mikael Berthe <mikael@lilotux.net>
parents:
1093
diff
changeset
|
2338 // 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
|
2339 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
|
2340 scr_show_window(jidto, FALSE); |
47 | 2341 } |
2342 | |
2032
f740c4128f76
Fix receipts handling according to recent XEP updates
Myhailo Danylenko <isbear@ukrpost.net>
parents:
2029
diff
changeset
|
2343 void scr_remove_receipt_flag(const char *bjid, gconstpointer xep184) |
1602 | 2344 { |
1780
e4378fbab5d7
Major API cleanup - bump API to 4
Mikael Berthe <mikael@lilotux.net>
parents:
1761
diff
changeset
|
2345 winbuf *win_entry = scr_search_window(bjid, FALSE); |
2036
f8958ab545ac
Make message delivery receipts more backward-compatible
Mikael Berthe <mikael@lilotux.net>
parents:
2032
diff
changeset
|
2346 if (win_entry && xep184) { |
1602 | 2347 hbuf_remove_receipt(win_entry->bd->hbuf, xep184); |
2348 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
|
2349 scr_update_buddy_window(); |
1602 | 2350 } |
2351 } | |
2352 | |
935
97e6a6da2b2c
Fix ncurses #include (again)
Mikael Berthe <mikael@lilotux.net>
parents:
933
diff
changeset
|
2353 static inline void set_autoaway(bool setaway) |
373
af2f8ddf6a1b
Move (reorganize) functions
Mikael Berthe <mikael@lilotux.net>
parents:
370
diff
changeset
|
2354 { |
af2f8ddf6a1b
Move (reorganize) functions
Mikael Berthe <mikael@lilotux.net>
parents:
370
diff
changeset
|
2355 static enum imstatus oldstatus; |
521 | 2356 static char *oldmsg; |
373
af2f8ddf6a1b
Move (reorganize) functions
Mikael Berthe <mikael@lilotux.net>
parents:
370
diff
changeset
|
2357 Autoaway = setaway; |
af2f8ddf6a1b
Move (reorganize) functions
Mikael Berthe <mikael@lilotux.net>
parents:
370
diff
changeset
|
2358 |
af2f8ddf6a1b
Move (reorganize) functions
Mikael Berthe <mikael@lilotux.net>
parents:
370
diff
changeset
|
2359 if (setaway) { |
521 | 2360 const char *msg, *prevmsg; |
1598 | 2361 oldstatus = xmpp_getstatus(); |
521 | 2362 if (oldmsg) { |
2363 g_free(oldmsg); | |
2364 oldmsg = NULL; | |
2365 } | |
1598 | 2366 prevmsg = xmpp_getstatusmsg(); |
373
af2f8ddf6a1b
Move (reorganize) functions
Mikael Berthe <mikael@lilotux.net>
parents:
370
diff
changeset
|
2367 msg = settings_opt_get("message_autoaway"); |
521 | 2368 if (!msg) |
2369 msg = prevmsg; | |
2370 if (prevmsg) | |
2371 oldmsg = g_strdup(prevmsg); | |
1598 | 2372 xmpp_setstatus(away, NULL, msg, FALSE); |
373
af2f8ddf6a1b
Move (reorganize) functions
Mikael Berthe <mikael@lilotux.net>
parents:
370
diff
changeset
|
2373 } else { |
af2f8ddf6a1b
Move (reorganize) functions
Mikael Berthe <mikael@lilotux.net>
parents:
370
diff
changeset
|
2374 // Back |
1598 | 2375 xmpp_setstatus(oldstatus, NULL, (oldmsg ? oldmsg : ""), FALSE); |
521 | 2376 if (oldmsg) { |
2377 g_free(oldmsg); | |
2378 oldmsg = NULL; | |
2379 } | |
373
af2f8ddf6a1b
Move (reorganize) functions
Mikael Berthe <mikael@lilotux.net>
parents:
370
diff
changeset
|
2380 } |
af2f8ddf6a1b
Move (reorganize) functions
Mikael Berthe <mikael@lilotux.net>
parents:
370
diff
changeset
|
2381 } |
af2f8ddf6a1b
Move (reorganize) functions
Mikael Berthe <mikael@lilotux.net>
parents:
370
diff
changeset
|
2382 |
991
ef10906691bb
Chatstates: add composing timeout
Mikael Berthe <mikael@lilotux.net>
parents:
990
diff
changeset
|
2383 // set_chatstate(state) |
ef10906691bb
Chatstates: add composing timeout
Mikael Berthe <mikael@lilotux.net>
parents:
990
diff
changeset
|
2384 // Set the current chat state (0=active, 1=composing, 2=paused) |
1598 | 2385 // 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
|
2386 static void set_chatstate(int state) |
991
ef10906691bb
Chatstates: add composing timeout
Mikael Berthe <mikael@lilotux.net>
parents:
990
diff
changeset
|
2387 { |
2165 | 2388 #ifdef XEP0085 |
993
0759f4c7da68
Add option 'disable_chatstates'
Mikael Berthe <mikael@lilotux.net>
parents:
992
diff
changeset
|
2389 if (chatstates_disabled) |
0759f4c7da68
Add option 'disable_chatstates'
Mikael Berthe <mikael@lilotux.net>
parents:
992
diff
changeset
|
2390 return; |
991
ef10906691bb
Chatstates: add composing timeout
Mikael Berthe <mikael@lilotux.net>
parents:
990
diff
changeset
|
2391 if (!chatmode) |
ef10906691bb
Chatstates: add composing timeout
Mikael Berthe <mikael@lilotux.net>
parents:
990
diff
changeset
|
2392 state = 0; |
ef10906691bb
Chatstates: add composing timeout
Mikael Berthe <mikael@lilotux.net>
parents:
990
diff
changeset
|
2393 if (state != chatstate) { |
ef10906691bb
Chatstates: add composing timeout
Mikael Berthe <mikael@lilotux.net>
parents:
990
diff
changeset
|
2394 chatstate = state; |
ef10906691bb
Chatstates: add composing timeout
Mikael Berthe <mikael@lilotux.net>
parents:
990
diff
changeset
|
2395 if (current_buddy && |
ef10906691bb
Chatstates: add composing timeout
Mikael Berthe <mikael@lilotux.net>
parents:
990
diff
changeset
|
2396 buddy_gettype(BUDDATA(current_buddy)) == ROSTER_TYPE_USER) { |
ef10906691bb
Chatstates: add composing timeout
Mikael Berthe <mikael@lilotux.net>
parents:
990
diff
changeset
|
2397 guint jep_state; |
1598 | 2398 if (chatstate == 1) { |
2399 if (chatstate_timeout_id == 0) | |
2400 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
|
2401 scr_chatstates_timeout, |
1598 | 2402 NULL); |
991
ef10906691bb
Chatstates: add composing timeout
Mikael Berthe <mikael@lilotux.net>
parents:
990
diff
changeset
|
2403 jep_state = ROSTER_EVENT_COMPOSING; |
1598 | 2404 } |
991
ef10906691bb
Chatstates: add composing timeout
Mikael Berthe <mikael@lilotux.net>
parents:
990
diff
changeset
|
2405 else if (chatstate == 2) |
ef10906691bb
Chatstates: add composing timeout
Mikael Berthe <mikael@lilotux.net>
parents:
990
diff
changeset
|
2406 jep_state = ROSTER_EVENT_PAUSED; |
ef10906691bb
Chatstates: add composing timeout
Mikael Berthe <mikael@lilotux.net>
parents:
990
diff
changeset
|
2407 else |
ef10906691bb
Chatstates: add composing timeout
Mikael Berthe <mikael@lilotux.net>
parents:
990
diff
changeset
|
2408 jep_state = ROSTER_EVENT_ACTIVE; |
1598 | 2409 xmpp_send_chatstate(BUDDATA(current_buddy), jep_state); |
991
ef10906691bb
Chatstates: add composing timeout
Mikael Berthe <mikael@lilotux.net>
parents:
990
diff
changeset
|
2410 } |
ef10906691bb
Chatstates: add composing timeout
Mikael Berthe <mikael@lilotux.net>
parents:
990
diff
changeset
|
2411 if (!chatstate) |
ef10906691bb
Chatstates: add composing timeout
Mikael Berthe <mikael@lilotux.net>
parents:
990
diff
changeset
|
2412 chatstate_timestamp = 0; |
ef10906691bb
Chatstates: add composing timeout
Mikael Berthe <mikael@lilotux.net>
parents:
990
diff
changeset
|
2413 } |
ef10906691bb
Chatstates: add composing timeout
Mikael Berthe <mikael@lilotux.net>
parents:
990
diff
changeset
|
2414 #endif |
ef10906691bb
Chatstates: add composing timeout
Mikael Berthe <mikael@lilotux.net>
parents:
990
diff
changeset
|
2415 } |
ef10906691bb
Chatstates: add composing timeout
Mikael Berthe <mikael@lilotux.net>
parents:
990
diff
changeset
|
2416 |
2165 | 2417 #ifdef XEP0085 |
1780
e4378fbab5d7
Major API cleanup - bump API to 4
Mikael Berthe <mikael@lilotux.net>
parents:
1761
diff
changeset
|
2418 static gboolean scr_chatstates_timeout(void) |
991
ef10906691bb
Chatstates: add composing timeout
Mikael Berthe <mikael@lilotux.net>
parents:
990
diff
changeset
|
2419 { |
1598 | 2420 time_t now; |
2421 time(&now); | |
991
ef10906691bb
Chatstates: add composing timeout
Mikael Berthe <mikael@lilotux.net>
parents:
990
diff
changeset
|
2422 // Check if we're currently composing... |
1598 | 2423 if (chatstate != 1 || !chatstate_timestamp) { |
2424 chatstate_timeout_id = 0; | |
2425 return FALSE; | |
2426 } | |
991
ef10906691bb
Chatstates: add composing timeout
Mikael Berthe <mikael@lilotux.net>
parents:
990
diff
changeset
|
2427 |
ef10906691bb
Chatstates: add composing timeout
Mikael Berthe <mikael@lilotux.net>
parents:
990
diff
changeset
|
2428 // 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
|
2429 if (now >= chatstate_timestamp + COMPOSING_TIMEOUT) { |
ef10906691bb
Chatstates: add composing timeout
Mikael Berthe <mikael@lilotux.net>
parents:
990
diff
changeset
|
2430 chatstate_timestamp = now; |
ef10906691bb
Chatstates: add composing timeout
Mikael Berthe <mikael@lilotux.net>
parents:
990
diff
changeset
|
2431 set_chatstate(2); |
1598 | 2432 chatstate_timeout_id = 0; |
2433 return FALSE; | |
991
ef10906691bb
Chatstates: add composing timeout
Mikael Berthe <mikael@lilotux.net>
parents:
990
diff
changeset
|
2434 } |
1598 | 2435 return TRUE; |
991
ef10906691bb
Chatstates: add composing timeout
Mikael Berthe <mikael@lilotux.net>
parents:
990
diff
changeset
|
2436 } |
ef10906691bb
Chatstates: add composing timeout
Mikael Berthe <mikael@lilotux.net>
parents:
990
diff
changeset
|
2437 #endif |
ef10906691bb
Chatstates: add composing timeout
Mikael Berthe <mikael@lilotux.net>
parents:
990
diff
changeset
|
2438 |
1677 | 2439 static gboolean scr_autoaway_timeout_callback(gpointer data) |
2440 { | |
2441 enum imstatus cur_st = xmpp_getstatus(); | |
2442 if (cur_st != available && cur_st != freeforchat) | |
2443 // Some non-user-originated status changes, let's wait more. | |
2444 // Maybe the proper fix for that will be set global variable | |
2445 // "autoaway_delayed" and check that variable in postconnect | |
2446 // hook (afaik, only source for such status changes are | |
2447 // error disconnects). | |
2448 return TRUE; | |
2449 set_autoaway(TRUE); | |
2450 // source will be destroyed after return | |
2451 autoaway_source = 0; | |
2452 return FALSE; | |
2453 } | |
2454 | |
1780
e4378fbab5d7
Major API cleanup - bump API to 4
Mikael Berthe <mikael@lilotux.net>
parents:
1761
diff
changeset
|
2455 static void scr_reinstall_autoaway_timeout(void) |
1677 | 2456 { |
2457 unsigned int autoaway_timeout = settings_opt_get_int("autoaway"); | |
2458 enum imstatus cur_st = xmpp_getstatus(); | |
2459 if (autoaway_source) { | |
2460 g_source_remove(autoaway_source); | |
2461 autoaway_source = 0; | |
2462 } | |
2463 if (autoaway_timeout && (cur_st == available || cur_st == freeforchat)) | |
2464 autoaway_source = g_timeout_add_seconds(autoaway_timeout, | |
2465 scr_autoaway_timeout_callback, | |
2466 NULL); | |
2467 } | |
2468 | |
2469 // 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
|
2470 void scr_check_auto_away(int activity) |
24 | 2471 { |
1677 | 2472 if (Autoaway && activity) { |
1780
e4378fbab5d7
Major API cleanup - bump API to 4
Mikael Berthe <mikael@lilotux.net>
parents:
1761
diff
changeset
|
2473 scr_reinstall_autoaway_timeout(); |
1677 | 2474 set_autoaway(FALSE); |
2475 } else if (activity || !autoaway_source) | |
1780
e4378fbab5d7
Major API cleanup - bump API to 4
Mikael Berthe <mikael@lilotux.net>
parents:
1761
diff
changeset
|
2476 scr_reinstall_autoaway_timeout(); |
24 | 2477 } |
2478 | |
328
83d129adde03
Add set_current_buddy() function, to reduce code duplication
Mikael Berthe <mikael@lilotux.net>
parents:
325
diff
changeset
|
2479 // set_current_buddy(newbuddy) |
83d129adde03
Add set_current_buddy() function, to reduce code duplication
Mikael Berthe <mikael@lilotux.net>
parents:
325
diff
changeset
|
2480 // 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
|
2481 // 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
|
2482 static void set_current_buddy(GList *newbuddy) |
24 | 2483 { |
328
83d129adde03
Add set_current_buddy() function, to reduce code duplication
Mikael Berthe <mikael@lilotux.net>
parents:
325
diff
changeset
|
2484 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
|
2485 /* 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
|
2486 * 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
|
2487 * buddy_getstatus() call. |
83d129adde03
Add set_current_buddy() function, to reduce code duplication
Mikael Berthe <mikael@lilotux.net>
parents:
325
diff
changeset
|
2488 */ |
83d129adde03
Add set_current_buddy() function, to reduce code duplication
Mikael Berthe <mikael@lilotux.net>
parents:
325
diff
changeset
|
2489 |
329
7c53bf62a2a2
scr_RosterUnreadMessage() uses set_current_buddy()
Mikael Berthe <mikael@lilotux.net>
parents:
328
diff
changeset
|
2490 if (!current_buddy || !newbuddy) return; |
7c53bf62a2a2
scr_RosterUnreadMessage() uses set_current_buddy()
Mikael Berthe <mikael@lilotux.net>
parents:
328
diff
changeset
|
2491 if (newbuddy == current_buddy) return; |
24 | 2492 |
990
35e7913affb7
Send events/chatstates notifications (JEP-22/JEP-85)
Mikael Berthe <mikael@lilotux.net>
parents:
987
diff
changeset
|
2493 // 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
|
2494 set_chatstate(0); |
35e7913affb7
Send events/chatstates notifications (JEP-22/JEP-85)
Mikael Berthe <mikael@lilotux.net>
parents:
987
diff
changeset
|
2495 // 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
|
2496 lock_chatstate = TRUE; |
990
35e7913affb7
Send events/chatstates notifications (JEP-22/JEP-85)
Mikael Berthe <mikael@lilotux.net>
parents:
987
diff
changeset
|
2497 |
438
b44be19d6229
Handle multiple resources for the same buddy
Mikael Berthe <mikael@lilotux.net>
parents:
419
diff
changeset
|
2498 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
|
2499 buddy_setflags(BUDDATA(current_buddy), ROSTER_FLAG_LOCK, FALSE); |
1950
aec86670047b
Automatically set readmark flag
Mikael Berthe <mikael@lilotux.net>
parents:
1949
diff
changeset
|
2500 if (chatmode) { |
aec86670047b
Automatically set readmark flag
Mikael Berthe <mikael@lilotux.net>
parents:
1949
diff
changeset
|
2501 scr_buffer_readmark(TRUE); |
330 | 2502 alternate_buddy = current_buddy; |
1950
aec86670047b
Automatically set readmark flag
Mikael Berthe <mikael@lilotux.net>
parents:
1949
diff
changeset
|
2503 } |
328
83d129adde03
Add set_current_buddy() function, to reduce code duplication
Mikael Berthe <mikael@lilotux.net>
parents:
325
diff
changeset
|
2504 current_buddy = newbuddy; |
83d129adde03
Add set_current_buddy() function, to reduce code duplication
Mikael Berthe <mikael@lilotux.net>
parents:
325
diff
changeset
|
2505 // 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
|
2506 if (chatmode) { |
328
83d129adde03
Add set_current_buddy() function, to reduce code duplication
Mikael Berthe <mikael@lilotux.net>
parents:
325
diff
changeset
|
2507 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
|
2508 // 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
|
2509 scr_buffer_readmark(-1); |
39021fd6b0e1
Try to improve readmarks in some cases
Mikael Berthe <mikael@lilotux.net>
parents:
1960
diff
changeset
|
2510 } |
328
83d129adde03
Add set_current_buddy() function, to reduce code duplication
Mikael Berthe <mikael@lilotux.net>
parents:
325
diff
changeset
|
2511 // We should rebuild the buddylist but not everytime |
1311
0dda8238af21
Implement "/roster display"
Mikael Berthe <mikael@lilotux.net>
parents:
1298
diff
changeset
|
2512 if (!(buddylist_get_filter() & 1<<prev_st)) |
328
83d129adde03
Add set_current_buddy() function, to reduce code duplication
Mikael Berthe <mikael@lilotux.net>
parents:
325
diff
changeset
|
2513 buddylist_build(); |
83d129adde03
Add set_current_buddy() function, to reduce code duplication
Mikael Berthe <mikael@lilotux.net>
parents:
325
diff
changeset
|
2514 update_roster = TRUE; |
24 | 2515 } |
2516 | |
1780
e4378fbab5d7
Major API cleanup - bump API to 4
Mikael Berthe <mikael@lilotux.net>
parents:
1761
diff
changeset
|
2517 // scr_roster_top() |
143 | 2518 // 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
|
2519 void scr_roster_top(void) |
104 | 2520 { |
328
83d129adde03
Add set_current_buddy() function, to reduce code duplication
Mikael Berthe <mikael@lilotux.net>
parents:
325
diff
changeset
|
2521 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
|
2522 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
|
2523 last_activity_buddy = current_buddy; |
1780
e4378fbab5d7
Major API cleanup - bump API to 4
Mikael Berthe <mikael@lilotux.net>
parents:
1761
diff
changeset
|
2524 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
|
2525 } |
104 | 2526 } |
2527 | |
1780
e4378fbab5d7
Major API cleanup - bump API to 4
Mikael Berthe <mikael@lilotux.net>
parents:
1761
diff
changeset
|
2528 // scr_roster_bottom() |
143 | 2529 // 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
|
2530 void scr_roster_bottom(void) |
104 | 2531 { |
328
83d129adde03
Add set_current_buddy() function, to reduce code duplication
Mikael Berthe <mikael@lilotux.net>
parents:
325
diff
changeset
|
2532 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
|
2533 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
|
2534 last_activity_buddy = current_buddy; |
1780
e4378fbab5d7
Major API cleanup - bump API to 4
Mikael Berthe <mikael@lilotux.net>
parents:
1761
diff
changeset
|
2535 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
|
2536 } |
104 | 2537 } |
2538 | |
1780
e4378fbab5d7
Major API cleanup - bump API to 4
Mikael Berthe <mikael@lilotux.net>
parents:
1761
diff
changeset
|
2539 // 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
|
2540 // 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
|
2541 // (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
|
2542 void scr_roster_up_down(int updown, unsigned int n) |
81 | 2543 { |
1573
ece4f26bf9ff
Add count parameter to roster up/down command
Mikael Berthe <mikael@lilotux.net>
parents:
1566
diff
changeset
|
2544 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
|
2545 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
|
2546 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
|
2547 |
7f06eb956734
Correctly set the alternate buffer after roster up|down N with N > 1
Mikael Berthe <mikael@lilotux.net>
parents:
2036
diff
changeset
|
2548 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
|
2549 return; |
1573
ece4f26bf9ff
Add count parameter to roster up/down command
Mikael Berthe <mikael@lilotux.net>
parents:
1566
diff
changeset
|
2550 |
2047
a60b933d04cc
Refactor scr_roster_up_down()
Mikael Berthe <mikael@lilotux.net>
parents:
2045
diff
changeset
|
2551 for (i = 0; i < n; i++) { |
a60b933d04cc
Refactor scr_roster_up_down()
Mikael Berthe <mikael@lilotux.net>
parents:
2045
diff
changeset
|
2552 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
|
2553 tmp_buddy = g_list_previous(new_buddy); |
2047
a60b933d04cc
Refactor scr_roster_up_down()
Mikael Berthe <mikael@lilotux.net>
parents:
2045
diff
changeset
|
2554 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
|
2555 tmp_buddy = g_list_next(new_buddy); |
2047
a60b933d04cc
Refactor scr_roster_up_down()
Mikael Berthe <mikael@lilotux.net>
parents:
2045
diff
changeset
|
2556 if (tmp_buddy) |
a60b933d04cc
Refactor scr_roster_up_down()
Mikael Berthe <mikael@lilotux.net>
parents:
2045
diff
changeset
|
2557 new_buddy = tmp_buddy; |
1573
ece4f26bf9ff
Add count parameter to roster up/down command
Mikael Berthe <mikael@lilotux.net>
parents:
1566
diff
changeset
|
2558 } |
2045
7f06eb956734
Correctly set the alternate buffer after roster up|down N with N > 1
Mikael Berthe <mikael@lilotux.net>
parents:
2036
diff
changeset
|
2559 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
|
2560 return; |
7f06eb956734
Correctly set the alternate buffer after roster up|down N with N > 1
Mikael Berthe <mikael@lilotux.net>
parents:
2036
diff
changeset
|
2561 |
7f06eb956734
Correctly set the alternate buffer after roster up|down N with N > 1
Mikael Berthe <mikael@lilotux.net>
parents:
2036
diff
changeset
|
2562 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
|
2563 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
|
2564 last_activity_buddy = current_buddy; |
1780
e4378fbab5d7
Major API cleanup - bump API to 4
Mikael Berthe <mikael@lilotux.net>
parents:
1761
diff
changeset
|
2565 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
|
2566 } |
81 | 2567 } |
2568 | |
1780
e4378fbab5d7
Major API cleanup - bump API to 4
Mikael Berthe <mikael@lilotux.net>
parents:
1761
diff
changeset
|
2569 // 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
|
2570 // 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
|
2571 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
|
2572 { |
5e2e647e781b
Add command /roster group_prev|group_next and update documentation
Mikael Berthe <mikael@lilotux.net>
parents:
1083
diff
changeset
|
2573 GList *bud; |
5e2e647e781b
Add command /roster group_prev|group_next and update documentation
Mikael Berthe <mikael@lilotux.net>
parents:
1083
diff
changeset
|
2574 |
5e2e647e781b
Add command /roster group_prev|group_next and update documentation
Mikael Berthe <mikael@lilotux.net>
parents:
1083
diff
changeset
|
2575 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
|
2576 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
|
2577 if (!bud) |
5e2e647e781b
Add command /roster group_prev|group_next and update documentation
Mikael Berthe <mikael@lilotux.net>
parents:
1083
diff
changeset
|
2578 break; |
5e2e647e781b
Add command /roster group_prev|group_next and update documentation
Mikael Berthe <mikael@lilotux.net>
parents:
1083
diff
changeset
|
2579 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
|
2580 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
|
2581 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
|
2582 last_activity_buddy = current_buddy; |
1780
e4378fbab5d7
Major API cleanup - bump API to 4
Mikael Berthe <mikael@lilotux.net>
parents:
1761
diff
changeset
|
2583 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
|
2584 } |
1086
5e2e647e781b
Add command /roster group_prev|group_next and update documentation
Mikael Berthe <mikael@lilotux.net>
parents:
1083
diff
changeset
|
2585 break; |
5e2e647e781b
Add command /roster group_prev|group_next and update documentation
Mikael Berthe <mikael@lilotux.net>
parents:
1083
diff
changeset
|
2586 } |
5e2e647e781b
Add command /roster group_prev|group_next and update documentation
Mikael Berthe <mikael@lilotux.net>
parents:
1083
diff
changeset
|
2587 } |
5e2e647e781b
Add command /roster group_prev|group_next and update documentation
Mikael Berthe <mikael@lilotux.net>
parents:
1083
diff
changeset
|
2588 } |
5e2e647e781b
Add command /roster group_prev|group_next and update documentation
Mikael Berthe <mikael@lilotux.net>
parents:
1083
diff
changeset
|
2589 |
1780
e4378fbab5d7
Major API cleanup - bump API to 4
Mikael Berthe <mikael@lilotux.net>
parents:
1761
diff
changeset
|
2590 // 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
|
2591 // 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
|
2592 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
|
2593 { |
5e2e647e781b
Add command /roster group_prev|group_next and update documentation
Mikael Berthe <mikael@lilotux.net>
parents:
1083
diff
changeset
|
2594 GList *bud; |
5e2e647e781b
Add command /roster group_prev|group_next and update documentation
Mikael Berthe <mikael@lilotux.net>
parents:
1083
diff
changeset
|
2595 |
5e2e647e781b
Add command /roster group_prev|group_next and update documentation
Mikael Berthe <mikael@lilotux.net>
parents:
1083
diff
changeset
|
2596 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
|
2597 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
|
2598 if (!bud) |
5e2e647e781b
Add command /roster group_prev|group_next and update documentation
Mikael Berthe <mikael@lilotux.net>
parents:
1083
diff
changeset
|
2599 break; |
5e2e647e781b
Add command /roster group_prev|group_next and update documentation
Mikael Berthe <mikael@lilotux.net>
parents:
1083
diff
changeset
|
2600 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
|
2601 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
|
2602 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
|
2603 last_activity_buddy = current_buddy; |
1780
e4378fbab5d7
Major API cleanup - bump API to 4
Mikael Berthe <mikael@lilotux.net>
parents:
1761
diff
changeset
|
2604 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
|
2605 } |
1086
5e2e647e781b
Add command /roster group_prev|group_next and update documentation
Mikael Berthe <mikael@lilotux.net>
parents:
1083
diff
changeset
|
2606 break; |
5e2e647e781b
Add command /roster group_prev|group_next and update documentation
Mikael Berthe <mikael@lilotux.net>
parents:
1083
diff
changeset
|
2607 } |
5e2e647e781b
Add command /roster group_prev|group_next and update documentation
Mikael Berthe <mikael@lilotux.net>
parents:
1083
diff
changeset
|
2608 } |
5e2e647e781b
Add command /roster group_prev|group_next and update documentation
Mikael Berthe <mikael@lilotux.net>
parents:
1083
diff
changeset
|
2609 } |
5e2e647e781b
Add command /roster group_prev|group_next and update documentation
Mikael Berthe <mikael@lilotux.net>
parents:
1083
diff
changeset
|
2610 |
1780
e4378fbab5d7
Major API cleanup - bump API to 4
Mikael Berthe <mikael@lilotux.net>
parents:
1761
diff
changeset
|
2611 // scr_roster_search(str) |
265 | 2612 // 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
|
2613 void scr_roster_search(char *str) |
265 | 2614 { |
328
83d129adde03
Add set_current_buddy() function, to reduce code duplication
Mikael Berthe <mikael@lilotux.net>
parents:
325
diff
changeset
|
2615 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
|
2616 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
|
2617 last_activity_buddy = current_buddy; |
1780
e4378fbab5d7
Major API cleanup - bump API to 4
Mikael Berthe <mikael@lilotux.net>
parents:
1761
diff
changeset
|
2618 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
|
2619 } |
265 | 2620 } |
2621 | |
1780
e4378fbab5d7
Major API cleanup - bump API to 4
Mikael Berthe <mikael@lilotux.net>
parents:
1761
diff
changeset
|
2622 // scr_roster_jump_jid(bjid) |
1058 | 2623 // Jump to buddy bjid. |
480 | 2624 // 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
|
2625 void scr_roster_jump_jid(char *barejid) |
480 | 2626 { |
2627 GSList *roster_elt; | |
2628 // Look for an existing buddy | |
2629 roster_elt = roster_find(barejid, jidsearch, | |
2630 ROSTER_TYPE_USER|ROSTER_TYPE_AGENT|ROSTER_TYPE_ROOM); | |
2631 // Create it if necessary | |
2632 if (!roster_elt) | |
603 | 2633 roster_elt = roster_add_user(barejid, NULL, NULL, ROSTER_TYPE_USER, |
1355 | 2634 sub_none, -1); |
480 | 2635 // Set a lock to see it in the buddylist |
2636 buddy_setflags(BUDDATA(roster_elt), ROSTER_FLAG_LOCK, TRUE); | |
2637 buddylist_build(); | |
2638 // Jump to the buddy | |
2639 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
|
2640 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
|
2641 last_activity_buddy = current_buddy; |
1780
e4378fbab5d7
Major API cleanup - bump API to 4
Mikael Berthe <mikael@lilotux.net>
parents:
1761
diff
changeset
|
2642 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
|
2643 } |
480 | 2644 } |
2645 | |
1780
e4378fbab5d7
Major API cleanup - bump API to 4
Mikael Berthe <mikael@lilotux.net>
parents:
1761
diff
changeset
|
2646 // scr_roster_unread_message(next) |
236 | 2647 // Go to a new message. If next is not null, try to go to the next new |
2648 // message. If it is not possible or if next is NULL, go to the first new | |
2649 // message from unread_list. | |
1780
e4378fbab5d7
Major API cleanup - bump API to 4
Mikael Berthe <mikael@lilotux.net>
parents:
1761
diff
changeset
|
2650 void scr_roster_unread_message(int next) |
236 | 2651 { |
329
7c53bf62a2a2
scr_RosterUnreadMessage() uses set_current_buddy()
Mikael Berthe <mikael@lilotux.net>
parents:
328
diff
changeset
|
2652 gpointer unread_ptr; |
7c53bf62a2a2
scr_RosterUnreadMessage() uses set_current_buddy()
Mikael Berthe <mikael@lilotux.net>
parents:
328
diff
changeset
|
2653 gpointer refbuddata; |
7c53bf62a2a2
scr_RosterUnreadMessage() uses set_current_buddy()
Mikael Berthe <mikael@lilotux.net>
parents:
328
diff
changeset
|
2654 GList *nbuddy; |
236 | 2655 |
329
7c53bf62a2a2
scr_RosterUnreadMessage() uses set_current_buddy()
Mikael Berthe <mikael@lilotux.net>
parents:
328
diff
changeset
|
2656 if (!current_buddy) return; |
236 | 2657 |
329
7c53bf62a2a2
scr_RosterUnreadMessage() uses set_current_buddy()
Mikael Berthe <mikael@lilotux.net>
parents:
328
diff
changeset
|
2658 if (next) refbuddata = BUDDATA(current_buddy); |
7c53bf62a2a2
scr_RosterUnreadMessage() uses set_current_buddy()
Mikael Berthe <mikael@lilotux.net>
parents:
328
diff
changeset
|
2659 else refbuddata = NULL; |
236 | 2660 |
329
7c53bf62a2a2
scr_RosterUnreadMessage() uses set_current_buddy()
Mikael Berthe <mikael@lilotux.net>
parents:
328
diff
changeset
|
2661 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
|
2662 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
|
2663 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
|
2664 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
|
2665 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
|
2666 } |
236 | 2667 |
889
ae93e69aaaaf
Fix up pending message flag for the status special buffer
Mikael Berthe <mikael@lilotux.net>
parents:
888
diff
changeset
|
2668 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
|
2669 gpointer ngroup; |
ae93e69aaaaf
Fix up pending message flag for the status special buffer
Mikael Berthe <mikael@lilotux.net>
parents:
888
diff
changeset
|
2670 // 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
|
2671 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
|
2672 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
|
2673 buddy_setflags(ngroup, ROSTER_FLAG_HIDE, FALSE); |
ae93e69aaaaf
Fix up pending message flag for the status special buffer
Mikael Berthe <mikael@lilotux.net>
parents:
888
diff
changeset
|
2674 buddylist_build(); |
ae93e69aaaaf
Fix up pending message flag for the status special buffer
Mikael Berthe <mikael@lilotux.net>
parents:
888
diff
changeset
|
2675 } |
329
7c53bf62a2a2
scr_RosterUnreadMessage() uses set_current_buddy()
Mikael Berthe <mikael@lilotux.net>
parents:
328
diff
changeset
|
2676 } |
236 | 2677 |
329
7c53bf62a2a2
scr_RosterUnreadMessage() uses set_current_buddy()
Mikael Berthe <mikael@lilotux.net>
parents:
328
diff
changeset
|
2678 nbuddy = g_list_find(buddylist, unread_ptr); |
7c53bf62a2a2
scr_RosterUnreadMessage() uses set_current_buddy()
Mikael Berthe <mikael@lilotux.net>
parents:
328
diff
changeset
|
2679 if (nbuddy) { |
7c53bf62a2a2
scr_RosterUnreadMessage() uses set_current_buddy()
Mikael Berthe <mikael@lilotux.net>
parents:
328
diff
changeset
|
2680 set_current_buddy(nbuddy); |
1780
e4378fbab5d7
Major API cleanup - bump API to 4
Mikael Berthe <mikael@lilotux.net>
parents:
1761
diff
changeset
|
2681 if (chatmode) scr_show_buddy_window(); |
374
bd5638c21834
Improve logging system (traces)
Mikael Berthe <mikael@lilotux.net>
parents:
373
diff
changeset
|
2682 } else |
bd5638c21834
Improve logging system (traces)
Mikael Berthe <mikael@lilotux.net>
parents:
373
diff
changeset
|
2683 scr_LogPrint(LPRINT_LOGNORM, "Error: nbuddy == NULL"); // should not happen |
236 | 2684 } |
2685 | |
2160
798baf5db4eb
Add /roster next_open_buffer
Mikael Berthe <mikael@lilotux.net>
parents:
2149
diff
changeset
|
2686 // scr_roster_next_open_buffer() |
798baf5db4eb
Add /roster next_open_buffer
Mikael Berthe <mikael@lilotux.net>
parents:
2149
diff
changeset
|
2687 // Jump to the next open buffer (experimental XXX) |
798baf5db4eb
Add /roster next_open_buffer
Mikael Berthe <mikael@lilotux.net>
parents:
2149
diff
changeset
|
2688 // This implementation ignores the hidden entries (folded groups). |
798baf5db4eb
Add /roster next_open_buffer
Mikael Berthe <mikael@lilotux.net>
parents:
2149
diff
changeset
|
2689 void scr_roster_next_open_buffer(void) |
798baf5db4eb
Add /roster next_open_buffer
Mikael Berthe <mikael@lilotux.net>
parents:
2149
diff
changeset
|
2690 { |
798baf5db4eb
Add /roster next_open_buffer
Mikael Berthe <mikael@lilotux.net>
parents:
2149
diff
changeset
|
2691 GList *bud = current_buddy; |
798baf5db4eb
Add /roster next_open_buffer
Mikael Berthe <mikael@lilotux.net>
parents:
2149
diff
changeset
|
2692 |
798baf5db4eb
Add /roster next_open_buffer
Mikael Berthe <mikael@lilotux.net>
parents:
2149
diff
changeset
|
2693 if (!current_buddy) return; |
798baf5db4eb
Add /roster next_open_buffer
Mikael Berthe <mikael@lilotux.net>
parents:
2149
diff
changeset
|
2694 |
798baf5db4eb
Add /roster next_open_buffer
Mikael Berthe <mikael@lilotux.net>
parents:
2149
diff
changeset
|
2695 for (;;) { |
798baf5db4eb
Add /roster next_open_buffer
Mikael Berthe <mikael@lilotux.net>
parents:
2149
diff
changeset
|
2696 guint budtype; |
798baf5db4eb
Add /roster next_open_buffer
Mikael Berthe <mikael@lilotux.net>
parents:
2149
diff
changeset
|
2697 bud = g_list_next(bud); |
798baf5db4eb
Add /roster next_open_buffer
Mikael Berthe <mikael@lilotux.net>
parents:
2149
diff
changeset
|
2698 // End of list: jump to the first entry |
798baf5db4eb
Add /roster next_open_buffer
Mikael Berthe <mikael@lilotux.net>
parents:
2149
diff
changeset
|
2699 if (!bud) |
798baf5db4eb
Add /roster next_open_buffer
Mikael Berthe <mikael@lilotux.net>
parents:
2149
diff
changeset
|
2700 bud = buddylist; |
798baf5db4eb
Add /roster next_open_buffer
Mikael Berthe <mikael@lilotux.net>
parents:
2149
diff
changeset
|
2701 // Check if we're back to the initial position |
798baf5db4eb
Add /roster next_open_buffer
Mikael Berthe <mikael@lilotux.net>
parents:
2149
diff
changeset
|
2702 if (bud == current_buddy) |
798baf5db4eb
Add /roster next_open_buffer
Mikael Berthe <mikael@lilotux.net>
parents:
2149
diff
changeset
|
2703 break; |
798baf5db4eb
Add /roster next_open_buffer
Mikael Berthe <mikael@lilotux.net>
parents:
2149
diff
changeset
|
2704 // Ignore the special buffer(s), groups |
798baf5db4eb
Add /roster next_open_buffer
Mikael Berthe <mikael@lilotux.net>
parents:
2149
diff
changeset
|
2705 budtype = buddy_gettype(BUDDATA(bud)); |
798baf5db4eb
Add /roster next_open_buffer
Mikael Berthe <mikael@lilotux.net>
parents:
2149
diff
changeset
|
2706 if (budtype & (ROSTER_TYPE_GROUP | ROSTER_TYPE_SPECIAL)) |
798baf5db4eb
Add /roster next_open_buffer
Mikael Berthe <mikael@lilotux.net>
parents:
2149
diff
changeset
|
2707 continue; |
798baf5db4eb
Add /roster next_open_buffer
Mikael Berthe <mikael@lilotux.net>
parents:
2149
diff
changeset
|
2708 |
798baf5db4eb
Add /roster next_open_buffer
Mikael Berthe <mikael@lilotux.net>
parents:
2149
diff
changeset
|
2709 // Check if a buffer/window exists |
798baf5db4eb
Add /roster next_open_buffer
Mikael Berthe <mikael@lilotux.net>
parents:
2149
diff
changeset
|
2710 if (scr_search_window(buddy_getjid(BUDDATA(bud)), 0)) { |
798baf5db4eb
Add /roster next_open_buffer
Mikael Berthe <mikael@lilotux.net>
parents:
2149
diff
changeset
|
2711 set_current_buddy(bud); |
798baf5db4eb
Add /roster next_open_buffer
Mikael Berthe <mikael@lilotux.net>
parents:
2149
diff
changeset
|
2712 if (chatmode) { |
798baf5db4eb
Add /roster next_open_buffer
Mikael Berthe <mikael@lilotux.net>
parents:
2149
diff
changeset
|
2713 last_activity_buddy = current_buddy; |
798baf5db4eb
Add /roster next_open_buffer
Mikael Berthe <mikael@lilotux.net>
parents:
2149
diff
changeset
|
2714 scr_show_buddy_window(); |
798baf5db4eb
Add /roster next_open_buffer
Mikael Berthe <mikael@lilotux.net>
parents:
2149
diff
changeset
|
2715 } |
798baf5db4eb
Add /roster next_open_buffer
Mikael Berthe <mikael@lilotux.net>
parents:
2149
diff
changeset
|
2716 break; |
798baf5db4eb
Add /roster next_open_buffer
Mikael Berthe <mikael@lilotux.net>
parents:
2149
diff
changeset
|
2717 } |
798baf5db4eb
Add /roster next_open_buffer
Mikael Berthe <mikael@lilotux.net>
parents:
2149
diff
changeset
|
2718 } |
798baf5db4eb
Add /roster next_open_buffer
Mikael Berthe <mikael@lilotux.net>
parents:
2149
diff
changeset
|
2719 } |
798baf5db4eb
Add /roster next_open_buffer
Mikael Berthe <mikael@lilotux.net>
parents:
2149
diff
changeset
|
2720 |
1780
e4378fbab5d7
Major API cleanup - bump API to 4
Mikael Berthe <mikael@lilotux.net>
parents:
1761
diff
changeset
|
2721 // scr_roster_jump_alternate() |
330 | 2722 // 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
|
2723 void scr_roster_jump_alternate(void) |
105 | 2724 { |
330 | 2725 if (!alternate_buddy || g_list_position(buddylist, alternate_buddy) == -1) |
2726 return; | |
2727 set_current_buddy(alternate_buddy); | |
1997
555e342556e7
/roster alternate also changes last_activity_buddy.
Simon Jacquin
parents:
1996
diff
changeset
|
2728 if (chatmode) { |
555e342556e7
/roster alternate also changes last_activity_buddy.
Simon Jacquin
parents:
1996
diff
changeset
|
2729 last_activity_buddy = current_buddy; |
1780
e4378fbab5d7
Major API cleanup - bump API to 4
Mikael Berthe <mikael@lilotux.net>
parents:
1761
diff
changeset
|
2730 scr_show_buddy_window(); |
1997
555e342556e7
/roster alternate also changes last_activity_buddy.
Simon Jacquin
parents:
1996
diff
changeset
|
2731 } |
330 | 2732 } |
2733 | |
1780
e4378fbab5d7
Major API cleanup - bump API to 4
Mikael Berthe <mikael@lilotux.net>
parents:
1761
diff
changeset
|
2734 // scr_roster_display(filter) |
1311
0dda8238af21
Implement "/roster display"
Mikael Berthe <mikael@lilotux.net>
parents:
1298
diff
changeset
|
2735 // 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
|
2736 // mask is displayed. |
1780
e4378fbab5d7
Major API cleanup - bump API to 4
Mikael Berthe <mikael@lilotux.net>
parents:
1761
diff
changeset
|
2737 void scr_roster_display(const char *filter) |
1311
0dda8238af21
Implement "/roster display"
Mikael Berthe <mikael@lilotux.net>
parents:
1298
diff
changeset
|
2738 { |
0dda8238af21
Implement "/roster display"
Mikael Berthe <mikael@lilotux.net>
parents:
1298
diff
changeset
|
2739 guchar status; |
0dda8238af21
Implement "/roster display"
Mikael Berthe <mikael@lilotux.net>
parents:
1298
diff
changeset
|
2740 enum imstatus budstate; |
0dda8238af21
Implement "/roster display"
Mikael Berthe <mikael@lilotux.net>
parents:
1298
diff
changeset
|
2741 char strfilter[imstatus_size+1]; |
0dda8238af21
Implement "/roster display"
Mikael Berthe <mikael@lilotux.net>
parents:
1298
diff
changeset
|
2742 char *psfilter; |
0dda8238af21
Implement "/roster display"
Mikael Berthe <mikael@lilotux.net>
parents:
1298
diff
changeset
|
2743 |
0dda8238af21
Implement "/roster display"
Mikael Berthe <mikael@lilotux.net>
parents:
1298
diff
changeset
|
2744 if (filter && *filter) { |
0dda8238af21
Implement "/roster display"
Mikael Berthe <mikael@lilotux.net>
parents:
1298
diff
changeset
|
2745 int show_all = (*filter == '*'); |
0dda8238af21
Implement "/roster display"
Mikael Berthe <mikael@lilotux.net>
parents:
1298
diff
changeset
|
2746 status = 0; |
0dda8238af21
Implement "/roster display"
Mikael Berthe <mikael@lilotux.net>
parents:
1298
diff
changeset
|
2747 for (budstate = 0; budstate < imstatus_size-1; budstate++) |
0dda8238af21
Implement "/roster display"
Mikael Berthe <mikael@lilotux.net>
parents:
1298
diff
changeset
|
2748 if (strchr(filter, imstatus2char[budstate]) || show_all) |
0dda8238af21
Implement "/roster display"
Mikael Berthe <mikael@lilotux.net>
parents:
1298
diff
changeset
|
2749 status |= 1<<budstate; |
0dda8238af21
Implement "/roster display"
Mikael Berthe <mikael@lilotux.net>
parents:
1298
diff
changeset
|
2750 buddylist_set_filter(status); |
0dda8238af21
Implement "/roster display"
Mikael Berthe <mikael@lilotux.net>
parents:
1298
diff
changeset
|
2751 buddylist_build(); |
0dda8238af21
Implement "/roster display"
Mikael Berthe <mikael@lilotux.net>
parents:
1298
diff
changeset
|
2752 update_roster = TRUE; |
0dda8238af21
Implement "/roster display"
Mikael Berthe <mikael@lilotux.net>
parents:
1298
diff
changeset
|
2753 return; |
0dda8238af21
Implement "/roster display"
Mikael Berthe <mikael@lilotux.net>
parents:
1298
diff
changeset
|
2754 } |
0dda8238af21
Implement "/roster display"
Mikael Berthe <mikael@lilotux.net>
parents:
1298
diff
changeset
|
2755 |
0dda8238af21
Implement "/roster display"
Mikael Berthe <mikael@lilotux.net>
parents:
1298
diff
changeset
|
2756 // Display current filter |
0dda8238af21
Implement "/roster display"
Mikael Berthe <mikael@lilotux.net>
parents:
1298
diff
changeset
|
2757 psfilter = strfilter; |
0dda8238af21
Implement "/roster display"
Mikael Berthe <mikael@lilotux.net>
parents:
1298
diff
changeset
|
2758 status = buddylist_get_filter(); |
0dda8238af21
Implement "/roster display"
Mikael Berthe <mikael@lilotux.net>
parents:
1298
diff
changeset
|
2759 for (budstate = 0; budstate < imstatus_size-1; budstate++) |
0dda8238af21
Implement "/roster display"
Mikael Berthe <mikael@lilotux.net>
parents:
1298
diff
changeset
|
2760 if (status & 1<<budstate) |
0dda8238af21
Implement "/roster display"
Mikael Berthe <mikael@lilotux.net>
parents:
1298
diff
changeset
|
2761 *psfilter++ = imstatus2char[budstate]; |
0dda8238af21
Implement "/roster display"
Mikael Berthe <mikael@lilotux.net>
parents:
1298
diff
changeset
|
2762 *psfilter = '\0'; |
0dda8238af21
Implement "/roster display"
Mikael Berthe <mikael@lilotux.net>
parents:
1298
diff
changeset
|
2763 scr_LogPrint(LPRINT_NORMAL, "Roster status filter: %s", strfilter); |
0dda8238af21
Implement "/roster display"
Mikael Berthe <mikael@lilotux.net>
parents:
1298
diff
changeset
|
2764 } |
0dda8238af21
Implement "/roster display"
Mikael Berthe <mikael@lilotux.net>
parents:
1298
diff
changeset
|
2765 |
1780
e4378fbab5d7
Major API cleanup - bump API to 4
Mikael Berthe <mikael@lilotux.net>
parents:
1761
diff
changeset
|
2766 // scr_buffer_scroll_up_down() |
508
5a2132ba2220
Add "/buffer up" and "/buffer down"
Mikael Berthe <mikael@lilotux.net>
parents:
503
diff
changeset
|
2767 // Scroll up/down the current buddy window, |
5a2132ba2220
Add "/buffer up" and "/buffer down"
Mikael Berthe <mikael@lilotux.net>
parents:
503
diff
changeset
|
2768 // - half a screen if nblines is 0, |
5a2132ba2220
Add "/buffer up" and "/buffer down"
Mikael Berthe <mikael@lilotux.net>
parents:
503
diff
changeset
|
2769 // - 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
|
2770 void scr_buffer_scroll_up_down(int updown, unsigned int nblines) |
105 | 2771 { |
822 | 2772 winbuf *win_entry; |
508
5a2132ba2220
Add "/buffer up" and "/buffer down"
Mikael Berthe <mikael@lilotux.net>
parents:
503
diff
changeset
|
2773 int n, nbl; |
105 | 2774 GList *hbuf_top; |
849
42c43a88d823
Status buffer management
Mikael Berthe <mikael@lilotux.net>
parents:
848
diff
changeset
|
2775 guint isspe; |
105 | 2776 |
2777 // Get win_entry | |
361
51ff319947c3
Code cleanup/optimization
Mikael Berthe <mikael@lilotux.net>
parents:
358
diff
changeset
|
2778 if (!current_buddy) return; |
849
42c43a88d823
Status buffer management
Mikael Berthe <mikael@lilotux.net>
parents:
848
diff
changeset
|
2779 |
42c43a88d823
Status buffer management
Mikael Berthe <mikael@lilotux.net>
parents:
848
diff
changeset
|
2780 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
|
2781 win_entry = scr_search_window(CURRENT_JID, isspe); |
361
51ff319947c3
Code cleanup/optimization
Mikael Berthe <mikael@lilotux.net>
parents:
358
diff
changeset
|
2782 if (!win_entry) return; |
105 | 2783 |
508
5a2132ba2220
Add "/buffer up" and "/buffer down"
Mikael Berthe <mikael@lilotux.net>
parents:
503
diff
changeset
|
2784 if (!nblines) { |
5a2132ba2220
Add "/buffer up" and "/buffer down"
Mikael Berthe <mikael@lilotux.net>
parents:
503
diff
changeset
|
2785 // Scroll half a screen (or less) |
512 | 2786 nbl = CHAT_WIN_HEIGHT/2; |
508
5a2132ba2220
Add "/buffer up" and "/buffer down"
Mikael Berthe <mikael@lilotux.net>
parents:
503
diff
changeset
|
2787 } else { |
5a2132ba2220
Add "/buffer up" and "/buffer down"
Mikael Berthe <mikael@lilotux.net>
parents:
503
diff
changeset
|
2788 nbl = nblines; |
5a2132ba2220
Add "/buffer up" and "/buffer down"
Mikael Berthe <mikael@lilotux.net>
parents:
503
diff
changeset
|
2789 } |
1157
5c857f0f0ab8
Moved all variables related to hbuf to an extra struct, bufdata
Frank Zschockelt
parents:
1156
diff
changeset
|
2790 hbuf_top = win_entry->bd->top; |
105 | 2791 |
361
51ff319947c3
Code cleanup/optimization
Mikael Berthe <mikael@lilotux.net>
parents:
358
diff
changeset
|
2792 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
|
2793 n = 0; |
361
51ff319947c3
Code cleanup/optimization
Mikael Berthe <mikael@lilotux.net>
parents:
358
diff
changeset
|
2794 if (!hbuf_top) { |
1157
5c857f0f0ab8
Moved all variables related to hbuf to an extra struct, bufdata
Frank Zschockelt
parents:
1156
diff
changeset
|
2795 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
|
2796 if (!win_entry->bd->cleared) { |
512 | 2797 if (!nblines) nbl = nbl*3 - 1; |
2798 else nbl += CHAT_WIN_HEIGHT - 1; | |
2799 } else { | |
1157
5c857f0f0ab8
Moved all variables related to hbuf to an extra struct, bufdata
Frank Zschockelt
parents:
1156
diff
changeset
|
2800 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
|
2801 n++; // We'll scroll one line less |
512 | 2802 } |
361
51ff319947c3
Code cleanup/optimization
Mikael Berthe <mikael@lilotux.net>
parents:
358
diff
changeset
|
2803 } |
1969
d9255c408027
Improve (fix) buffer up 1 when the screen is cleared
Mikael Berthe <mikael@lilotux.net>
parents:
1968
diff
changeset
|
2804 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
|
2805 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
|
2806 win_entry->bd->top = hbuf_top; |
361
51ff319947c3
Code cleanup/optimization
Mikael Berthe <mikael@lilotux.net>
parents:
358
diff
changeset
|
2807 } else { // DOWN |
508
5a2132ba2220
Add "/buffer up" and "/buffer down"
Mikael Berthe <mikael@lilotux.net>
parents:
503
diff
changeset
|
2808 for (n=0 ; hbuf_top && n < nbl ; n++) |
361
51ff319947c3
Code cleanup/optimization
Mikael Berthe <mikael@lilotux.net>
parents:
358
diff
changeset
|
2809 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
|
2810 win_entry->bd->top = hbuf_top; |
361
51ff319947c3
Code cleanup/optimization
Mikael Berthe <mikael@lilotux.net>
parents:
358
diff
changeset
|
2811 // Check if we are at the bottom |
51ff319947c3
Code cleanup/optimization
Mikael Berthe <mikael@lilotux.net>
parents:
358
diff
changeset
|
2812 for (n=0 ; hbuf_top && n < CHAT_WIN_HEIGHT-1 ; n++) |
51ff319947c3
Code cleanup/optimization
Mikael Berthe <mikael@lilotux.net>
parents:
358
diff
changeset
|
2813 hbuf_top = g_list_next(hbuf_top); |
51ff319947c3
Code cleanup/optimization
Mikael Berthe <mikael@lilotux.net>
parents:
358
diff
changeset
|
2814 if (!hbuf_top) |
1157
5c857f0f0ab8
Moved all variables related to hbuf to an extra struct, bufdata
Frank Zschockelt
parents:
1156
diff
changeset
|
2815 win_entry->bd->top = NULL; // End reached |
361
51ff319947c3
Code cleanup/optimization
Mikael Berthe <mikael@lilotux.net>
parents:
358
diff
changeset
|
2816 } |
105 | 2817 |
2818 // Refresh the window | |
1780
e4378fbab5d7
Major API cleanup - bump API to 4
Mikael Berthe <mikael@lilotux.net>
parents:
1761
diff
changeset
|
2819 scr_update_window(win_entry); |
105 | 2820 |
2821 // Finished :) | |
2822 update_panels(); | |
2823 } | |
2824 | |
1780
e4378fbab5d7
Major API cleanup - bump API to 4
Mikael Berthe <mikael@lilotux.net>
parents:
1761
diff
changeset
|
2825 // scr_buffer_clear() |
143 | 2826 // 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
|
2827 void scr_buffer_clear(void) |
108 | 2828 { |
822 | 2829 winbuf *win_entry; |
849
42c43a88d823
Status buffer management
Mikael Berthe <mikael@lilotux.net>
parents:
848
diff
changeset
|
2830 guint isspe; |
108 | 2831 |
2832 // Get win_entry | |
361
51ff319947c3
Code cleanup/optimization
Mikael Berthe <mikael@lilotux.net>
parents:
358
diff
changeset
|
2833 if (!current_buddy) return; |
849
42c43a88d823
Status buffer management
Mikael Berthe <mikael@lilotux.net>
parents:
848
diff
changeset
|
2834 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
|
2835 win_entry = scr_search_window(CURRENT_JID, isspe); |
361
51ff319947c3
Code cleanup/optimization
Mikael Berthe <mikael@lilotux.net>
parents:
358
diff
changeset
|
2836 if (!win_entry) return; |
108 | 2837 |
1157
5c857f0f0ab8
Moved all variables related to hbuf to an extra struct, bufdata
Frank Zschockelt
parents:
1156
diff
changeset
|
2838 win_entry->bd->cleared = TRUE; |
5c857f0f0ab8
Moved all variables related to hbuf to an extra struct, bufdata
Frank Zschockelt
parents:
1156
diff
changeset
|
2839 win_entry->bd->top = NULL; |
108 | 2840 |
2841 // Refresh the window | |
1780
e4378fbab5d7
Major API cleanup - bump API to 4
Mikael Berthe <mikael@lilotux.net>
parents:
1761
diff
changeset
|
2842 scr_update_window(win_entry); |
108 | 2843 |
2844 // Finished :) | |
2845 update_panels(); | |
2846 } | |
2847 | |
1138
8ba4b1e8b42d
Add command /buffer close_all
Mikael Berthe <mikael@lilotux.net>
parents:
1137
diff
changeset
|
2848 // buffer_purge() |
8ba4b1e8b42d
Add command /buffer close_all
Mikael Berthe <mikael@lilotux.net>
parents:
1137
diff
changeset
|
2849 // key: winId/jid |
8ba4b1e8b42d
Add command /buffer close_all
Mikael Berthe <mikael@lilotux.net>
parents:
1137
diff
changeset
|
2850 // value: winbuf structure |
8ba4b1e8b42d
Add command /buffer close_all
Mikael Berthe <mikael@lilotux.net>
parents:
1137
diff
changeset
|
2851 // 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
|
2852 // NOTE: does not work for special buffers. |
2012 | 2853 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
|
2854 { |
1225
0e9e9724d643
Fix a bad type cast in buffer_purge()
Mikael Berthe <mikael@lilotux.net>
parents:
1209
diff
changeset
|
2855 int *p_closebuf = data; |
1138
8ba4b1e8b42d
Add command /buffer close_all
Mikael Berthe <mikael@lilotux.net>
parents:
1137
diff
changeset
|
2856 winbuf *win_entry = value; |
2012 | 2857 gboolean retval = FALSE; |
1138
8ba4b1e8b42d
Add command /buffer close_all
Mikael Berthe <mikael@lilotux.net>
parents:
1137
diff
changeset
|
2858 |
8ba4b1e8b42d
Add command /buffer close_all
Mikael Berthe <mikael@lilotux.net>
parents:
1137
diff
changeset
|
2859 // Delete the current hbuf |
1157
5c857f0f0ab8
Moved all variables related to hbuf to an extra struct, bufdata
Frank Zschockelt
parents:
1156
diff
changeset
|
2860 hbuf_free(&win_entry->bd->hbuf); |
1138
8ba4b1e8b42d
Add command /buffer close_all
Mikael Berthe <mikael@lilotux.net>
parents:
1137
diff
changeset
|
2861 |
1225
0e9e9724d643
Fix a bad type cast in buffer_purge()
Mikael Berthe <mikael@lilotux.net>
parents:
1209
diff
changeset
|
2862 if (*p_closebuf) { |
2013
8dc418af3e72
Allow to select to which buddy resource messages go. Closes issue #55
Hermitifier
parents:
2012
diff
changeset
|
2863 GSList *roster_elt; |
2012 | 2864 retval = TRUE; |
2013
8dc418af3e72
Allow to select to which buddy resource messages go. Closes issue #55
Hermitifier
parents:
2012
diff
changeset
|
2865 roster_elt = roster_find(key, jidsearch, |
8dc418af3e72
Allow to select to which buddy resource messages go. Closes issue #55
Hermitifier
parents:
2012
diff
changeset
|
2866 ROSTER_TYPE_USER|ROSTER_TYPE_AGENT); |
8dc418af3e72
Allow to select to which buddy resource messages go. Closes issue #55
Hermitifier
parents:
2012
diff
changeset
|
2867 if (roster_elt) |
8dc418af3e72
Allow to select to which buddy resource messages go. Closes issue #55
Hermitifier
parents:
2012
diff
changeset
|
2868 buddy_setactiveresource(roster_elt->data, NULL); |
1138
8ba4b1e8b42d
Add command /buffer close_all
Mikael Berthe <mikael@lilotux.net>
parents:
1137
diff
changeset
|
2869 } else { |
1157
5c857f0f0ab8
Moved all variables related to hbuf to an extra struct, bufdata
Frank Zschockelt
parents:
1156
diff
changeset
|
2870 win_entry->bd->cleared = FALSE; |
5c857f0f0ab8
Moved all variables related to hbuf to an extra struct, bufdata
Frank Zschockelt
parents:
1156
diff
changeset
|
2871 win_entry->bd->top = NULL; |
1138
8ba4b1e8b42d
Add command /buffer close_all
Mikael Berthe <mikael@lilotux.net>
parents:
1137
diff
changeset
|
2872 } |
2012 | 2873 return retval; |
1138
8ba4b1e8b42d
Add command /buffer close_all
Mikael Berthe <mikael@lilotux.net>
parents:
1137
diff
changeset
|
2874 } |
8ba4b1e8b42d
Add command /buffer close_all
Mikael Berthe <mikael@lilotux.net>
parents:
1137
diff
changeset
|
2875 |
1780
e4378fbab5d7
Major API cleanup - bump API to 4
Mikael Berthe <mikael@lilotux.net>
parents:
1761
diff
changeset
|
2876 // scr_buffer_purge(closebuf, jid) |
1279
8bbc764139ef
Implement /buffer close|purge [jid]
Mikael Berthe <mikael@lilotux.net>
parents:
1272
diff
changeset
|
2877 // 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
|
2878 // 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
|
2879 void scr_buffer_purge(int closebuf, const char *jid) |
866 | 2880 { |
2881 winbuf *win_entry; | |
2882 guint isspe; | |
1225
0e9e9724d643
Fix a bad type cast in buffer_purge()
Mikael Berthe <mikael@lilotux.net>
parents:
1209
diff
changeset
|
2883 guint *p_closebuf; |
1279
8bbc764139ef
Implement /buffer close|purge [jid]
Mikael Berthe <mikael@lilotux.net>
parents:
1272
diff
changeset
|
2884 const char *cjid; |
1345
8e4e741787be
Small change to buffer close
Mikael Berthe <mikael@lilotux.net>
parents:
1333
diff
changeset
|
2885 guint hold_chatmode = FALSE; |
1279
8bbc764139ef
Implement /buffer close|purge [jid]
Mikael Berthe <mikael@lilotux.net>
parents:
1272
diff
changeset
|
2886 |
8bbc764139ef
Implement /buffer close|purge [jid]
Mikael Berthe <mikael@lilotux.net>
parents:
1272
diff
changeset
|
2887 if (jid) { |
8bbc764139ef
Implement /buffer close|purge [jid]
Mikael Berthe <mikael@lilotux.net>
parents:
1272
diff
changeset
|
2888 cjid = jid; |
8bbc764139ef
Implement /buffer close|purge [jid]
Mikael Berthe <mikael@lilotux.net>
parents:
1272
diff
changeset
|
2889 isspe = FALSE; |
1345
8e4e741787be
Small change to buffer close
Mikael Berthe <mikael@lilotux.net>
parents:
1333
diff
changeset
|
2890 // 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
|
2891 // 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
|
2892 if (closebuf && current_buddy) { |
8e4e741787be
Small change to buffer close
Mikael Berthe <mikael@lilotux.net>
parents:
1333
diff
changeset
|
2893 if (buddy_gettype(BUDDATA(current_buddy)) & ROSTER_TYPE_SPECIAL || |
8e4e741787be
Small change to buffer close
Mikael Berthe <mikael@lilotux.net>
parents:
1333
diff
changeset
|
2894 strcasecmp(jid, CURRENT_JID)) |
8e4e741787be
Small change to buffer close
Mikael Berthe <mikael@lilotux.net>
parents:
1333
diff
changeset
|
2895 hold_chatmode = TRUE; |
8e4e741787be
Small change to buffer close
Mikael Berthe <mikael@lilotux.net>
parents:
1333
diff
changeset
|
2896 } |
1279
8bbc764139ef
Implement /buffer close|purge [jid]
Mikael Berthe <mikael@lilotux.net>
parents:
1272
diff
changeset
|
2897 } else { |
8bbc764139ef
Implement /buffer close|purge [jid]
Mikael Berthe <mikael@lilotux.net>
parents:
1272
diff
changeset
|
2898 // Get win_entry |
8bbc764139ef
Implement /buffer close|purge [jid]
Mikael Berthe <mikael@lilotux.net>
parents:
1272
diff
changeset
|
2899 if (!current_buddy) return; |
8bbc764139ef
Implement /buffer close|purge [jid]
Mikael Berthe <mikael@lilotux.net>
parents:
1272
diff
changeset
|
2900 cjid = CURRENT_JID; |
8bbc764139ef
Implement /buffer close|purge [jid]
Mikael Berthe <mikael@lilotux.net>
parents:
1272
diff
changeset
|
2901 isspe = buddy_gettype(BUDDATA(current_buddy)) & ROSTER_TYPE_SPECIAL; |
8bbc764139ef
Implement /buffer close|purge [jid]
Mikael Berthe <mikael@lilotux.net>
parents:
1272
diff
changeset
|
2902 } |
1780
e4378fbab5d7
Major API cleanup - bump API to 4
Mikael Berthe <mikael@lilotux.net>
parents:
1761
diff
changeset
|
2903 win_entry = scr_search_window(cjid, isspe); |
866 | 2904 if (!win_entry) return; |
2905 | |
1138
8ba4b1e8b42d
Add command /buffer close_all
Mikael Berthe <mikael@lilotux.net>
parents:
1137
diff
changeset
|
2906 if (!isspe) { |
1225
0e9e9724d643
Fix a bad type cast in buffer_purge()
Mikael Berthe <mikael@lilotux.net>
parents:
1209
diff
changeset
|
2907 p_closebuf = g_new(guint, 1); |
0e9e9724d643
Fix a bad type cast in buffer_purge()
Mikael Berthe <mikael@lilotux.net>
parents:
1209
diff
changeset
|
2908 *p_closebuf = closebuf; |
2012 | 2909 if(buffer_purge((gpointer)cjid, win_entry, p_closebuf)) |
2910 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
|
2911 roster_msg_setflag(cjid, FALSE, FALSE); |
1225
0e9e9724d643
Fix a bad type cast in buffer_purge()
Mikael Berthe <mikael@lilotux.net>
parents:
1209
diff
changeset
|
2912 g_free(p_closebuf); |
1345
8e4e741787be
Small change to buffer close
Mikael Berthe <mikael@lilotux.net>
parents:
1333
diff
changeset
|
2913 if (closebuf && !hold_chatmode) { |
1138
8ba4b1e8b42d
Add command /buffer close_all
Mikael Berthe <mikael@lilotux.net>
parents:
1137
diff
changeset
|
2914 scr_set_chatmode(FALSE); |
8ba4b1e8b42d
Add command /buffer close_all
Mikael Berthe <mikael@lilotux.net>
parents:
1137
diff
changeset
|
2915 currentWindow = NULL; |
8ba4b1e8b42d
Add command /buffer close_all
Mikael Berthe <mikael@lilotux.net>
parents:
1137
diff
changeset
|
2916 } |
8ba4b1e8b42d
Add command /buffer close_all
Mikael Berthe <mikael@lilotux.net>
parents:
1137
diff
changeset
|
2917 } else { |
8ba4b1e8b42d
Add command /buffer close_all
Mikael Berthe <mikael@lilotux.net>
parents:
1137
diff
changeset
|
2918 // (Special buffer) |
8ba4b1e8b42d
Add command /buffer close_all
Mikael Berthe <mikael@lilotux.net>
parents:
1137
diff
changeset
|
2919 // Reset the current hbuf |
1157
5c857f0f0ab8
Moved all variables related to hbuf to an extra struct, bufdata
Frank Zschockelt
parents:
1156
diff
changeset
|
2920 hbuf_free(&win_entry->bd->hbuf); |
866 | 2921 // Currently it can only be the status buffer |
2922 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
|
2923 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
|
2924 |
1157
5c857f0f0ab8
Moved all variables related to hbuf to an extra struct, bufdata
Frank Zschockelt
parents:
1156
diff
changeset
|
2925 win_entry->bd->cleared = FALSE; |
5c857f0f0ab8
Moved all variables related to hbuf to an extra struct, bufdata
Frank Zschockelt
parents:
1156
diff
changeset
|
2926 win_entry->bd->top = NULL; |
866 | 2927 } |
2928 | |
1700
87dd0a8f1a9c
Remove the "new message" flag when a buffer is purged with /buffer purge
Mikael Berthe <mikael@lilotux.net>
parents:
1694
diff
changeset
|
2929 update_roster = TRUE; |
87dd0a8f1a9c
Remove the "new message" flag when a buffer is purged with /buffer purge
Mikael Berthe <mikael@lilotux.net>
parents:
1694
diff
changeset
|
2930 |
1138
8ba4b1e8b42d
Add command /buffer close_all
Mikael Berthe <mikael@lilotux.net>
parents:
1137
diff
changeset
|
2931 // Refresh the window |
1780
e4378fbab5d7
Major API cleanup - bump API to 4
Mikael Berthe <mikael@lilotux.net>
parents:
1761
diff
changeset
|
2932 scr_update_buddy_window(); |
1138
8ba4b1e8b42d
Add command /buffer close_all
Mikael Berthe <mikael@lilotux.net>
parents:
1137
diff
changeset
|
2933 |
8ba4b1e8b42d
Add command /buffer close_all
Mikael Berthe <mikael@lilotux.net>
parents:
1137
diff
changeset
|
2934 // Finished :) |
8ba4b1e8b42d
Add command /buffer close_all
Mikael Berthe <mikael@lilotux.net>
parents:
1137
diff
changeset
|
2935 update_panels(); |
8ba4b1e8b42d
Add command /buffer close_all
Mikael Berthe <mikael@lilotux.net>
parents:
1137
diff
changeset
|
2936 } |
8ba4b1e8b42d
Add command /buffer close_all
Mikael Berthe <mikael@lilotux.net>
parents:
1137
diff
changeset
|
2937 |
1780
e4378fbab5d7
Major API cleanup - bump API to 4
Mikael Berthe <mikael@lilotux.net>
parents:
1761
diff
changeset
|
2938 // scr_buffer_purge_all(closebuf) |
e4378fbab5d7
Major API cleanup - bump API to 4
Mikael Berthe <mikael@lilotux.net>
parents:
1761
diff
changeset
|
2939 // Purge all existing buffers. |
e4378fbab5d7
Major API cleanup - bump API to 4
Mikael Berthe <mikael@lilotux.net>
parents:
1761
diff
changeset
|
2940 // 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
|
2941 void scr_buffer_purge_all(int closebuf) |
1138
8ba4b1e8b42d
Add command /buffer close_all
Mikael Berthe <mikael@lilotux.net>
parents:
1137
diff
changeset
|
2942 { |
1225
0e9e9724d643
Fix a bad type cast in buffer_purge()
Mikael Berthe <mikael@lilotux.net>
parents:
1209
diff
changeset
|
2943 guint *p_closebuf; |
0e9e9724d643
Fix a bad type cast in buffer_purge()
Mikael Berthe <mikael@lilotux.net>
parents:
1209
diff
changeset
|
2944 p_closebuf = g_new(guint, 1); |
0e9e9724d643
Fix a bad type cast in buffer_purge()
Mikael Berthe <mikael@lilotux.net>
parents:
1209
diff
changeset
|
2945 |
0e9e9724d643
Fix a bad type cast in buffer_purge()
Mikael Berthe <mikael@lilotux.net>
parents:
1209
diff
changeset
|
2946 *p_closebuf = closebuf; |
2012 | 2947 g_hash_table_foreach_remove(winbufhash, buffer_purge, p_closebuf); |
1225
0e9e9724d643
Fix a bad type cast in buffer_purge()
Mikael Berthe <mikael@lilotux.net>
parents:
1209
diff
changeset
|
2948 g_free(p_closebuf); |
1138
8ba4b1e8b42d
Add command /buffer close_all
Mikael Berthe <mikael@lilotux.net>
parents:
1137
diff
changeset
|
2949 |
8ba4b1e8b42d
Add command /buffer close_all
Mikael Berthe <mikael@lilotux.net>
parents:
1137
diff
changeset
|
2950 if (closebuf) { |
1135
5d7c05932b13
Add command /buffer close
Mikael Berthe <mikael@lilotux.net>
parents:
1133
diff
changeset
|
2951 scr_set_chatmode(FALSE); |
1137
5752017f6e2b
Fix a bug in /buffer close
Mikael Berthe <mikael@lilotux.net>
parents:
1135
diff
changeset
|
2952 currentWindow = NULL; |
1135
5d7c05932b13
Add command /buffer close
Mikael Berthe <mikael@lilotux.net>
parents:
1133
diff
changeset
|
2953 } |
5d7c05932b13
Add command /buffer close
Mikael Berthe <mikael@lilotux.net>
parents:
1133
diff
changeset
|
2954 |
866 | 2955 // Refresh the window |
1780
e4378fbab5d7
Major API cleanup - bump API to 4
Mikael Berthe <mikael@lilotux.net>
parents:
1761
diff
changeset
|
2956 scr_update_buddy_window(); |
866 | 2957 |
2958 // Finished :) | |
2959 update_panels(); | |
2960 } | |
2961 | |
1780
e4378fbab5d7
Major API cleanup - bump API to 4
Mikael Berthe <mikael@lilotux.net>
parents:
1761
diff
changeset
|
2962 // scr_buffer_scroll_lock(lock) |
873
ee39f6d94d43
Add /buffer {scroll_lock|scroll_unlock|toggle_scroll}
Mikael Berthe <mikael@lilotux.net>
parents:
866
diff
changeset
|
2963 // Lock/unlock the current buddy buffer |
ee39f6d94d43
Add /buffer {scroll_lock|scroll_unlock|toggle_scroll}
Mikael Berthe <mikael@lilotux.net>
parents:
866
diff
changeset
|
2964 // lock = 1 : lock |
ee39f6d94d43
Add /buffer {scroll_lock|scroll_unlock|toggle_scroll}
Mikael Berthe <mikael@lilotux.net>
parents:
866
diff
changeset
|
2965 // lock = 0 : unlock |
ee39f6d94d43
Add /buffer {scroll_lock|scroll_unlock|toggle_scroll}
Mikael Berthe <mikael@lilotux.net>
parents:
866
diff
changeset
|
2966 // lock = -1: toggle lock status |
1780
e4378fbab5d7
Major API cleanup - bump API to 4
Mikael Berthe <mikael@lilotux.net>
parents:
1761
diff
changeset
|
2967 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
|
2968 { |
ee39f6d94d43
Add /buffer {scroll_lock|scroll_unlock|toggle_scroll}
Mikael Berthe <mikael@lilotux.net>
parents:
866
diff
changeset
|
2969 winbuf *win_entry; |
ee39f6d94d43
Add /buffer {scroll_lock|scroll_unlock|toggle_scroll}
Mikael Berthe <mikael@lilotux.net>
parents:
866
diff
changeset
|
2970 guint isspe; |
ee39f6d94d43
Add /buffer {scroll_lock|scroll_unlock|toggle_scroll}
Mikael Berthe <mikael@lilotux.net>
parents:
866
diff
changeset
|
2971 |
ee39f6d94d43
Add /buffer {scroll_lock|scroll_unlock|toggle_scroll}
Mikael Berthe <mikael@lilotux.net>
parents:
866
diff
changeset
|
2972 // Get win_entry |
ee39f6d94d43
Add /buffer {scroll_lock|scroll_unlock|toggle_scroll}
Mikael Berthe <mikael@lilotux.net>
parents:
866
diff
changeset
|
2973 if (!current_buddy) return; |
ee39f6d94d43
Add /buffer {scroll_lock|scroll_unlock|toggle_scroll}
Mikael Berthe <mikael@lilotux.net>
parents:
866
diff
changeset
|
2974 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
|
2975 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
|
2976 if (!win_entry) return; |
ee39f6d94d43
Add /buffer {scroll_lock|scroll_unlock|toggle_scroll}
Mikael Berthe <mikael@lilotux.net>
parents:
866
diff
changeset
|
2977 |
ee39f6d94d43
Add /buffer {scroll_lock|scroll_unlock|toggle_scroll}
Mikael Berthe <mikael@lilotux.net>
parents:
866
diff
changeset
|
2978 if (lock == -1) |
1157
5c857f0f0ab8
Moved all variables related to hbuf to an extra struct, bufdata
Frank Zschockelt
parents:
1156
diff
changeset
|
2979 lock = !win_entry->bd->lock; |
873
ee39f6d94d43
Add /buffer {scroll_lock|scroll_unlock|toggle_scroll}
Mikael Berthe <mikael@lilotux.net>
parents:
866
diff
changeset
|
2980 |
ee39f6d94d43
Add /buffer {scroll_lock|scroll_unlock|toggle_scroll}
Mikael Berthe <mikael@lilotux.net>
parents:
866
diff
changeset
|
2981 if (lock) { |
1157
5c857f0f0ab8
Moved all variables related to hbuf to an extra struct, bufdata
Frank Zschockelt
parents:
1156
diff
changeset
|
2982 win_entry->bd->lock = TRUE; |
873
ee39f6d94d43
Add /buffer {scroll_lock|scroll_unlock|toggle_scroll}
Mikael Berthe <mikael@lilotux.net>
parents:
866
diff
changeset
|
2983 } else { |
1157
5c857f0f0ab8
Moved all variables related to hbuf to an extra struct, bufdata
Frank Zschockelt
parents:
1156
diff
changeset
|
2984 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
|
2985 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
|
2986 win_entry->bd->top = NULL; |
873
ee39f6d94d43
Add /buffer {scroll_lock|scroll_unlock|toggle_scroll}
Mikael Berthe <mikael@lilotux.net>
parents:
866
diff
changeset
|
2987 } |
ee39f6d94d43
Add /buffer {scroll_lock|scroll_unlock|toggle_scroll}
Mikael Berthe <mikael@lilotux.net>
parents:
866
diff
changeset
|
2988 |
ee39f6d94d43
Add /buffer {scroll_lock|scroll_unlock|toggle_scroll}
Mikael Berthe <mikael@lilotux.net>
parents:
866
diff
changeset
|
2989 // 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
|
2990 // 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
|
2991 // 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
|
2992 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
|
2993 chatmode = TRUE; |
1780
e4378fbab5d7
Major API cleanup - bump API to 4
Mikael Berthe <mikael@lilotux.net>
parents:
1761
diff
changeset
|
2994 scr_show_buddy_window(); |
873
ee39f6d94d43
Add /buffer {scroll_lock|scroll_unlock|toggle_scroll}
Mikael Berthe <mikael@lilotux.net>
parents:
866
diff
changeset
|
2995 chatmode = FALSE; |
ee39f6d94d43
Add /buffer {scroll_lock|scroll_unlock|toggle_scroll}
Mikael Berthe <mikael@lilotux.net>
parents:
866
diff
changeset
|
2996 } |
ee39f6d94d43
Add /buffer {scroll_lock|scroll_unlock|toggle_scroll}
Mikael Berthe <mikael@lilotux.net>
parents:
866
diff
changeset
|
2997 |
ee39f6d94d43
Add /buffer {scroll_lock|scroll_unlock|toggle_scroll}
Mikael Berthe <mikael@lilotux.net>
parents:
866
diff
changeset
|
2998 // Refresh the window |
1780
e4378fbab5d7
Major API cleanup - bump API to 4
Mikael Berthe <mikael@lilotux.net>
parents:
1761
diff
changeset
|
2999 scr_update_buddy_window(); |
873
ee39f6d94d43
Add /buffer {scroll_lock|scroll_unlock|toggle_scroll}
Mikael Berthe <mikael@lilotux.net>
parents:
866
diff
changeset
|
3000 |
ee39f6d94d43
Add /buffer {scroll_lock|scroll_unlock|toggle_scroll}
Mikael Berthe <mikael@lilotux.net>
parents:
866
diff
changeset
|
3001 // Finished :) |
ee39f6d94d43
Add /buffer {scroll_lock|scroll_unlock|toggle_scroll}
Mikael Berthe <mikael@lilotux.net>
parents:
866
diff
changeset
|
3002 update_panels(); |
ee39f6d94d43
Add /buffer {scroll_lock|scroll_unlock|toggle_scroll}
Mikael Berthe <mikael@lilotux.net>
parents:
866
diff
changeset
|
3003 } |
ee39f6d94d43
Add /buffer {scroll_lock|scroll_unlock|toggle_scroll}
Mikael Berthe <mikael@lilotux.net>
parents:
866
diff
changeset
|
3004 |
1961
39021fd6b0e1
Try to improve readmarks in some cases
Mikael Berthe <mikael@lilotux.net>
parents:
1960
diff
changeset
|
3005 // scr_buffer_readmark(action) |
39021fd6b0e1
Try to improve readmarks in some cases
Mikael Berthe <mikael@lilotux.net>
parents:
1960
diff
changeset
|
3006 // 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
|
3007 // 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
|
3008 // If action = 0, reset the readmark flag |
39021fd6b0e1
Try to improve readmarks in some cases
Mikael Berthe <mikael@lilotux.net>
parents:
1960
diff
changeset
|
3009 // 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
|
3010 void scr_buffer_readmark(gchar action) |
1949
13d18777a629
Add scr_buffer_readmark()
Mikael Berthe <mikael@lilotux.net>
parents:
1948
diff
changeset
|
3011 { |
13d18777a629
Add scr_buffer_readmark()
Mikael Berthe <mikael@lilotux.net>
parents:
1948
diff
changeset
|
3012 winbuf *win_entry; |
13d18777a629
Add scr_buffer_readmark()
Mikael Berthe <mikael@lilotux.net>
parents:
1948
diff
changeset
|
3013 guint isspe; |
2098
c4a68361883f
Lock buffer automatically when scrolled up, unlock when at bottom ("buffer_smart_scrolling" setting)
Hermitifier
parents:
2090
diff
changeset
|
3014 int autolock; |
1949
13d18777a629
Add scr_buffer_readmark()
Mikael Berthe <mikael@lilotux.net>
parents:
1948
diff
changeset
|
3015 |
13d18777a629
Add scr_buffer_readmark()
Mikael Berthe <mikael@lilotux.net>
parents:
1948
diff
changeset
|
3016 // Get win_entry |
13d18777a629
Add scr_buffer_readmark()
Mikael Berthe <mikael@lilotux.net>
parents:
1948
diff
changeset
|
3017 if (!current_buddy) return; |
13d18777a629
Add scr_buffer_readmark()
Mikael Berthe <mikael@lilotux.net>
parents:
1948
diff
changeset
|
3018 isspe = buddy_gettype(BUDDATA(current_buddy)) & ROSTER_TYPE_SPECIAL; |
13d18777a629
Add scr_buffer_readmark()
Mikael Berthe <mikael@lilotux.net>
parents:
1948
diff
changeset
|
3019 if (isspe) return; // Maybe not necessary |
13d18777a629
Add scr_buffer_readmark()
Mikael Berthe <mikael@lilotux.net>
parents:
1948
diff
changeset
|
3020 win_entry = scr_search_window(CURRENT_JID, isspe); |
13d18777a629
Add scr_buffer_readmark()
Mikael Berthe <mikael@lilotux.net>
parents:
1948
diff
changeset
|
3021 if (!win_entry) return; |
13d18777a629
Add scr_buffer_readmark()
Mikael Berthe <mikael@lilotux.net>
parents:
1948
diff
changeset
|
3022 |
2098
c4a68361883f
Lock buffer automatically when scrolled up, unlock when at bottom ("buffer_smart_scrolling" setting)
Hermitifier
parents:
2090
diff
changeset
|
3023 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
|
3024 if (!win_entry->bd->lock || autolock) { |
1961
39021fd6b0e1
Try to improve readmarks in some cases
Mikael Berthe <mikael@lilotux.net>
parents:
1960
diff
changeset
|
3025 if (action >= 0) |
39021fd6b0e1
Try to improve readmarks in some cases
Mikael Berthe <mikael@lilotux.net>
parents:
1960
diff
changeset
|
3026 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
|
3027 else |
39021fd6b0e1
Try to improve readmarks in some cases
Mikael Berthe <mikael@lilotux.net>
parents:
1960
diff
changeset
|
3028 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
|
3029 } |
1949
13d18777a629
Add scr_buffer_readmark()
Mikael Berthe <mikael@lilotux.net>
parents:
1948
diff
changeset
|
3030 } |
13d18777a629
Add scr_buffer_readmark()
Mikael Berthe <mikael@lilotux.net>
parents:
1948
diff
changeset
|
3031 |
13d18777a629
Add scr_buffer_readmark()
Mikael Berthe <mikael@lilotux.net>
parents:
1948
diff
changeset
|
3032 |
1780
e4378fbab5d7
Major API cleanup - bump API to 4
Mikael Berthe <mikael@lilotux.net>
parents:
1761
diff
changeset
|
3033 // scr_buffer_top_bottom() |
361
51ff319947c3
Code cleanup/optimization
Mikael Berthe <mikael@lilotux.net>
parents:
358
diff
changeset
|
3034 // Jump to the head/tail of the current buddy window |
51ff319947c3
Code cleanup/optimization
Mikael Berthe <mikael@lilotux.net>
parents:
358
diff
changeset
|
3035 // (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
|
3036 void scr_buffer_top_bottom(int topbottom) |
187 | 3037 { |
822 | 3038 winbuf *win_entry; |
849
42c43a88d823
Status buffer management
Mikael Berthe <mikael@lilotux.net>
parents:
848
diff
changeset
|
3039 guint isspe; |
187 | 3040 |
3041 // Get win_entry | |
3042 if (!current_buddy) return; | |
849
42c43a88d823
Status buffer management
Mikael Berthe <mikael@lilotux.net>
parents:
848
diff
changeset
|
3043 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
|
3044 win_entry = scr_search_window(CURRENT_JID, isspe); |
187 | 3045 if (!win_entry) return; |
3046 | |
1157
5c857f0f0ab8
Moved all variables related to hbuf to an extra struct, bufdata
Frank Zschockelt
parents:
1156
diff
changeset
|
3047 win_entry->bd->cleared = FALSE; |
361
51ff319947c3
Code cleanup/optimization
Mikael Berthe <mikael@lilotux.net>
parents:
358
diff
changeset
|
3048 if (topbottom == 1) |
1157
5c857f0f0ab8
Moved all variables related to hbuf to an extra struct, bufdata
Frank Zschockelt
parents:
1156
diff
changeset
|
3049 win_entry->bd->top = NULL; |
361
51ff319947c3
Code cleanup/optimization
Mikael Berthe <mikael@lilotux.net>
parents:
358
diff
changeset
|
3050 else |
1157
5c857f0f0ab8
Moved all variables related to hbuf to an extra struct, bufdata
Frank Zschockelt
parents:
1156
diff
changeset
|
3051 win_entry->bd->top = g_list_first(win_entry->bd->hbuf); |
187 | 3052 |
3053 // Refresh the window | |
1780
e4378fbab5d7
Major API cleanup - bump API to 4
Mikael Berthe <mikael@lilotux.net>
parents:
1761
diff
changeset
|
3054 scr_update_window(win_entry); |
187 | 3055 |
3056 // Finished :) | |
3057 update_panels(); | |
3058 } | |
3059 | |
1780
e4378fbab5d7
Major API cleanup - bump API to 4
Mikael Berthe <mikael@lilotux.net>
parents:
1761
diff
changeset
|
3060 // scr_buffer_search(direction, text) |
370
dd9e2eb52916
Add /buffer search_{backward,forward}
Mikael Berthe <mikael@lilotux.net>
parents:
369
diff
changeset
|
3061 // Jump to the next line containing text |
dd9e2eb52916
Add /buffer search_{backward,forward}
Mikael Berthe <mikael@lilotux.net>
parents:
369
diff
changeset
|
3062 // (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
|
3063 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
|
3064 { |
822 | 3065 winbuf *win_entry; |
370
dd9e2eb52916
Add /buffer search_{backward,forward}
Mikael Berthe <mikael@lilotux.net>
parents:
369
diff
changeset
|
3066 GList *current_line, *search_res; |
849
42c43a88d823
Status buffer management
Mikael Berthe <mikael@lilotux.net>
parents:
848
diff
changeset
|
3067 guint isspe; |
370
dd9e2eb52916
Add /buffer search_{backward,forward}
Mikael Berthe <mikael@lilotux.net>
parents:
369
diff
changeset
|
3068 |
dd9e2eb52916
Add /buffer search_{backward,forward}
Mikael Berthe <mikael@lilotux.net>
parents:
369
diff
changeset
|
3069 // Get win_entry |
dd9e2eb52916
Add /buffer search_{backward,forward}
Mikael Berthe <mikael@lilotux.net>
parents:
369
diff
changeset
|
3070 if (!current_buddy) return; |
849
42c43a88d823
Status buffer management
Mikael Berthe <mikael@lilotux.net>
parents:
848
diff
changeset
|
3071 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
|
3072 win_entry = scr_search_window(CURRENT_JID, isspe); |
370
dd9e2eb52916
Add /buffer search_{backward,forward}
Mikael Berthe <mikael@lilotux.net>
parents:
369
diff
changeset
|
3073 if (!win_entry) return; |
dd9e2eb52916
Add /buffer search_{backward,forward}
Mikael Berthe <mikael@lilotux.net>
parents:
369
diff
changeset
|
3074 |
1157
5c857f0f0ab8
Moved all variables related to hbuf to an extra struct, bufdata
Frank Zschockelt
parents:
1156
diff
changeset
|
3075 if (win_entry->bd->top) |
5c857f0f0ab8
Moved all variables related to hbuf to an extra struct, bufdata
Frank Zschockelt
parents:
1156
diff
changeset
|
3076 current_line = win_entry->bd->top; |
370
dd9e2eb52916
Add /buffer search_{backward,forward}
Mikael Berthe <mikael@lilotux.net>
parents:
369
diff
changeset
|
3077 else |
1157
5c857f0f0ab8
Moved all variables related to hbuf to an extra struct, bufdata
Frank Zschockelt
parents:
1156
diff
changeset
|
3078 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
|
3079 |
dd9e2eb52916
Add /buffer search_{backward,forward}
Mikael Berthe <mikael@lilotux.net>
parents:
369
diff
changeset
|
3080 search_res = hbuf_search(current_line, direction, text); |
dd9e2eb52916
Add /buffer search_{backward,forward}
Mikael Berthe <mikael@lilotux.net>
parents:
369
diff
changeset
|
3081 |
dd9e2eb52916
Add /buffer search_{backward,forward}
Mikael Berthe <mikael@lilotux.net>
parents:
369
diff
changeset
|
3082 if (search_res) { |
1157
5c857f0f0ab8
Moved all variables related to hbuf to an extra struct, bufdata
Frank Zschockelt
parents:
1156
diff
changeset
|
3083 win_entry->bd->cleared = FALSE; |
5c857f0f0ab8
Moved all variables related to hbuf to an extra struct, bufdata
Frank Zschockelt
parents:
1156
diff
changeset
|
3084 win_entry->bd->top = search_res; |
370
dd9e2eb52916
Add /buffer search_{backward,forward}
Mikael Berthe <mikael@lilotux.net>
parents:
369
diff
changeset
|
3085 |
dd9e2eb52916
Add /buffer search_{backward,forward}
Mikael Berthe <mikael@lilotux.net>
parents:
369
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_window(win_entry); |
370
dd9e2eb52916
Add /buffer search_{backward,forward}
Mikael Berthe <mikael@lilotux.net>
parents:
369
diff
changeset
|
3088 |
dd9e2eb52916
Add /buffer search_{backward,forward}
Mikael Berthe <mikael@lilotux.net>
parents:
369
diff
changeset
|
3089 // Finished :) |
dd9e2eb52916
Add /buffer search_{backward,forward}
Mikael Berthe <mikael@lilotux.net>
parents:
369
diff
changeset
|
3090 update_panels(); |
dd9e2eb52916
Add /buffer search_{backward,forward}
Mikael Berthe <mikael@lilotux.net>
parents:
369
diff
changeset
|
3091 } else |
1957
e3e8fb918d56
Be more verbose when the buffer search commands are not successful
Mikael Berthe <mikael@lilotux.net>
parents:
1956
diff
changeset
|
3092 scr_LogPrint(LPRINT_NORMAL, "Search string not found."); |
370
dd9e2eb52916
Add /buffer search_{backward,forward}
Mikael Berthe <mikael@lilotux.net>
parents:
369
diff
changeset
|
3093 } |
dd9e2eb52916
Add /buffer search_{backward,forward}
Mikael Berthe <mikael@lilotux.net>
parents:
369
diff
changeset
|
3094 |
1780
e4378fbab5d7
Major API cleanup - bump API to 4
Mikael Berthe <mikael@lilotux.net>
parents:
1761
diff
changeset
|
3095 // scr_buffer_percent(n) |
462 | 3096 // 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
|
3097 void scr_buffer_percent(int pc) |
462 | 3098 { |
822 | 3099 winbuf *win_entry; |
462 | 3100 GList *search_res; |
849
42c43a88d823
Status buffer management
Mikael Berthe <mikael@lilotux.net>
parents:
848
diff
changeset
|
3101 guint isspe; |
462 | 3102 |
3103 // Get win_entry | |
3104 if (!current_buddy) return; | |
849
42c43a88d823
Status buffer management
Mikael Berthe <mikael@lilotux.net>
parents:
848
diff
changeset
|
3105 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
|
3106 win_entry = scr_search_window(CURRENT_JID, isspe); |
462 | 3107 if (!win_entry) return; |
3108 | |
3109 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
|
3110 scr_LogPrint(LPRINT_NORMAL, "Bad %% value"); |
462 | 3111 return; |
3112 } | |
3113 | |
1157
5c857f0f0ab8
Moved all variables related to hbuf to an extra struct, bufdata
Frank Zschockelt
parents:
1156
diff
changeset
|
3114 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
|
3115 |
5c857f0f0ab8
Moved all variables related to hbuf to an extra struct, bufdata
Frank Zschockelt
parents:
1156
diff
changeset
|
3116 win_entry->bd->cleared = FALSE; |
5c857f0f0ab8
Moved all variables related to hbuf to an extra struct, bufdata
Frank Zschockelt
parents:
1156
diff
changeset
|
3117 win_entry->bd->top = search_res; |
462 | 3118 |
3119 // Refresh the window | |
1780
e4378fbab5d7
Major API cleanup - bump API to 4
Mikael Berthe <mikael@lilotux.net>
parents:
1761
diff
changeset
|
3120 scr_update_window(win_entry); |
462 | 3121 |
3122 // Finished :) | |
3123 update_panels(); | |
3124 } | |
3125 | |
1780
e4378fbab5d7
Major API cleanup - bump API to 4
Mikael Berthe <mikael@lilotux.net>
parents:
1761
diff
changeset
|
3126 // scr_buffer_date(t) |
464 | 3127 // Jump to the first line after date t in the buffer |
3128 // 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
|
3129 void scr_buffer_date(time_t t) |
464 | 3130 { |
822 | 3131 winbuf *win_entry; |
464 | 3132 GList *search_res; |
849
42c43a88d823
Status buffer management
Mikael Berthe <mikael@lilotux.net>
parents:
848
diff
changeset
|
3133 guint isspe; |
464 | 3134 |
3135 // Get win_entry | |
3136 if (!current_buddy) return; | |
849
42c43a88d823
Status buffer management
Mikael Berthe <mikael@lilotux.net>
parents:
848
diff
changeset
|
3137 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
|
3138 win_entry = scr_search_window(CURRENT_JID, isspe); |
464 | 3139 if (!win_entry) return; |
3140 | |
1157
5c857f0f0ab8
Moved all variables related to hbuf to an extra struct, bufdata
Frank Zschockelt
parents:
1156
diff
changeset
|
3141 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
|
3142 |
5c857f0f0ab8
Moved all variables related to hbuf to an extra struct, bufdata
Frank Zschockelt
parents:
1156
diff
changeset
|
3143 win_entry->bd->cleared = FALSE; |
5c857f0f0ab8
Moved all variables related to hbuf to an extra struct, bufdata
Frank Zschockelt
parents:
1156
diff
changeset
|
3144 win_entry->bd->top = search_res; |
464 | 3145 |
1957
e3e8fb918d56
Be more verbose when the buffer search commands are not successful
Mikael Berthe <mikael@lilotux.net>
parents:
1956
diff
changeset
|
3146 if (!search_res) |
e3e8fb918d56
Be more verbose when the buffer search commands are not successful
Mikael Berthe <mikael@lilotux.net>
parents:
1956
diff
changeset
|
3147 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
|
3148 |
464 | 3149 // Refresh the window |
1780
e4378fbab5d7
Major API cleanup - bump API to 4
Mikael Berthe <mikael@lilotux.net>
parents:
1761
diff
changeset
|
3150 scr_update_window(win_entry); |
464 | 3151 |
3152 // Finished :) | |
3153 update_panels(); | |
3154 } | |
3155 | |
1956
f309f343070c
Add command /buffer readmark
Mikael Berthe <mikael@lilotux.net>
parents:
1955
diff
changeset
|
3156 // scr_buffer_jump_readmark() |
f309f343070c
Add command /buffer readmark
Mikael Berthe <mikael@lilotux.net>
parents:
1955
diff
changeset
|
3157 // Jump to the buffer readmark, if there's one |
f309f343070c
Add command /buffer readmark
Mikael Berthe <mikael@lilotux.net>
parents:
1955
diff
changeset
|
3158 void scr_buffer_jump_readmark(void) |
f309f343070c
Add command /buffer readmark
Mikael Berthe <mikael@lilotux.net>
parents:
1955
diff
changeset
|
3159 { |
f309f343070c
Add command /buffer readmark
Mikael Berthe <mikael@lilotux.net>
parents:
1955
diff
changeset
|
3160 winbuf *win_entry; |
f309f343070c
Add command /buffer readmark
Mikael Berthe <mikael@lilotux.net>
parents:
1955
diff
changeset
|
3161 GList *search_res; |
f309f343070c
Add command /buffer readmark
Mikael Berthe <mikael@lilotux.net>
parents:
1955
diff
changeset
|
3162 guint isspe; |
f309f343070c
Add command /buffer readmark
Mikael Berthe <mikael@lilotux.net>
parents:
1955
diff
changeset
|
3163 |
f309f343070c
Add command /buffer readmark
Mikael Berthe <mikael@lilotux.net>
parents:
1955
diff
changeset
|
3164 // Get win_entry |
f309f343070c
Add command /buffer readmark
Mikael Berthe <mikael@lilotux.net>
parents:
1955
diff
changeset
|
3165 if (!current_buddy) return; |
f309f343070c
Add command /buffer readmark
Mikael Berthe <mikael@lilotux.net>
parents:
1955
diff
changeset
|
3166 isspe = buddy_gettype(BUDDATA(current_buddy)) & ROSTER_TYPE_SPECIAL; |
f309f343070c
Add command /buffer readmark
Mikael Berthe <mikael@lilotux.net>
parents:
1955
diff
changeset
|
3167 if (isspe) return; |
f309f343070c
Add command /buffer readmark
Mikael Berthe <mikael@lilotux.net>
parents:
1955
diff
changeset
|
3168 win_entry = scr_search_window(CURRENT_JID, isspe); |
f309f343070c
Add command /buffer readmark
Mikael Berthe <mikael@lilotux.net>
parents:
1955
diff
changeset
|
3169 if (!win_entry) return; |
f309f343070c
Add command /buffer readmark
Mikael Berthe <mikael@lilotux.net>
parents:
1955
diff
changeset
|
3170 |
f309f343070c
Add command /buffer readmark
Mikael Berthe <mikael@lilotux.net>
parents:
1955
diff
changeset
|
3171 search_res = hbuf_jump_readmark(win_entry->bd->hbuf); |
f309f343070c
Add command /buffer readmark
Mikael Berthe <mikael@lilotux.net>
parents:
1955
diff
changeset
|
3172 |
1968
83d7c7daea6a
buffer readmark: don't update the screen when there is no mark
Mikael Berthe <mikael@lilotux.net>
parents:
1965
diff
changeset
|
3173 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
|
3174 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
|
3175 return; |
83d7c7daea6a
buffer readmark: don't update the screen when there is no mark
Mikael Berthe <mikael@lilotux.net>
parents:
1965
diff
changeset
|
3176 } |
83d7c7daea6a
buffer readmark: don't update the screen when there is no mark
Mikael Berthe <mikael@lilotux.net>
parents:
1965
diff
changeset
|
3177 |
1956
f309f343070c
Add command /buffer readmark
Mikael Berthe <mikael@lilotux.net>
parents:
1955
diff
changeset
|
3178 win_entry->bd->cleared = FALSE; |
f309f343070c
Add command /buffer readmark
Mikael Berthe <mikael@lilotux.net>
parents:
1955
diff
changeset
|
3179 win_entry->bd->top = search_res; |
f309f343070c
Add command /buffer readmark
Mikael Berthe <mikael@lilotux.net>
parents:
1955
diff
changeset
|
3180 |
f309f343070c
Add command /buffer readmark
Mikael Berthe <mikael@lilotux.net>
parents:
1955
diff
changeset
|
3181 // Refresh the window |
f309f343070c
Add command /buffer readmark
Mikael Berthe <mikael@lilotux.net>
parents:
1955
diff
changeset
|
3182 scr_update_window(win_entry); |
f309f343070c
Add command /buffer readmark
Mikael Berthe <mikael@lilotux.net>
parents:
1955
diff
changeset
|
3183 |
f309f343070c
Add command /buffer readmark
Mikael Berthe <mikael@lilotux.net>
parents:
1955
diff
changeset
|
3184 // Finished :) |
f309f343070c
Add command /buffer readmark
Mikael Berthe <mikael@lilotux.net>
parents:
1955
diff
changeset
|
3185 update_panels(); |
f309f343070c
Add command /buffer readmark
Mikael Berthe <mikael@lilotux.net>
parents:
1955
diff
changeset
|
3186 } |
f309f343070c
Add command /buffer readmark
Mikael Berthe <mikael@lilotux.net>
parents:
1955
diff
changeset
|
3187 |
1780
e4378fbab5d7
Major API cleanup - bump API to 4
Mikael Berthe <mikael@lilotux.net>
parents:
1761
diff
changeset
|
3188 // scr_buffer_dump(filename) |
e4378fbab5d7
Major API cleanup - bump API to 4
Mikael Berthe <mikael@lilotux.net>
parents:
1761
diff
changeset
|
3189 // 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
|
3190 void scr_buffer_dump(const char *file) |
1485
0121b6f3047c
New command: /buffer save
Mikael Berthe <mikael@lilotux.net>
parents:
1484
diff
changeset
|
3191 { |
0121b6f3047c
New command: /buffer save
Mikael Berthe <mikael@lilotux.net>
parents:
1484
diff
changeset
|
3192 char *extfname; |
0121b6f3047c
New command: /buffer save
Mikael Berthe <mikael@lilotux.net>
parents:
1484
diff
changeset
|
3193 |
0121b6f3047c
New command: /buffer save
Mikael Berthe <mikael@lilotux.net>
parents:
1484
diff
changeset
|
3194 if (!currentWindow) { |
0121b6f3047c
New command: /buffer save
Mikael Berthe <mikael@lilotux.net>
parents:
1484
diff
changeset
|
3195 scr_LogPrint(LPRINT_NORMAL, "No current buffer!"); |
0121b6f3047c
New command: /buffer save
Mikael Berthe <mikael@lilotux.net>
parents:
1484
diff
changeset
|
3196 return; |
0121b6f3047c
New command: /buffer save
Mikael Berthe <mikael@lilotux.net>
parents:
1484
diff
changeset
|
3197 } |
0121b6f3047c
New command: /buffer save
Mikael Berthe <mikael@lilotux.net>
parents:
1484
diff
changeset
|
3198 |
0121b6f3047c
New command: /buffer save
Mikael Berthe <mikael@lilotux.net>
parents:
1484
diff
changeset
|
3199 if (!file || !*file) { |
0121b6f3047c
New command: /buffer save
Mikael Berthe <mikael@lilotux.net>
parents:
1484
diff
changeset
|
3200 scr_LogPrint(LPRINT_NORMAL, "Missing parameter (file name)!"); |
0121b6f3047c
New command: /buffer save
Mikael Berthe <mikael@lilotux.net>
parents:
1484
diff
changeset
|
3201 return; |
0121b6f3047c
New command: /buffer save
Mikael Berthe <mikael@lilotux.net>
parents:
1484
diff
changeset
|
3202 } |
0121b6f3047c
New command: /buffer save
Mikael Berthe <mikael@lilotux.net>
parents:
1484
diff
changeset
|
3203 |
0121b6f3047c
New command: /buffer save
Mikael Berthe <mikael@lilotux.net>
parents:
1484
diff
changeset
|
3204 extfname = expand_filename(file); |
0121b6f3047c
New command: /buffer save
Mikael Berthe <mikael@lilotux.net>
parents:
1484
diff
changeset
|
3205 hbuf_dump_to_file(currentWindow->bd->hbuf, extfname); |
0121b6f3047c
New command: /buffer save
Mikael Berthe <mikael@lilotux.net>
parents:
1484
diff
changeset
|
3206 g_free(extfname); |
0121b6f3047c
New command: /buffer save
Mikael Berthe <mikael@lilotux.net>
parents:
1484
diff
changeset
|
3207 } |
0121b6f3047c
New command: /buffer save
Mikael Berthe <mikael@lilotux.net>
parents:
1484
diff
changeset
|
3208 |
1226
2521efbf3b72
New (debug) subcommand, buffer list
Mikael Berthe <mikael@lilotux.net>
parents:
1225
diff
changeset
|
3209 // buffer_list() |
2521efbf3b72
New (debug) subcommand, buffer list
Mikael Berthe <mikael@lilotux.net>
parents:
1225
diff
changeset
|
3210 // key: winId/jid |
2521efbf3b72
New (debug) subcommand, buffer list
Mikael Berthe <mikael@lilotux.net>
parents:
1225
diff
changeset
|
3211 // value: winbuf structure |
2521efbf3b72
New (debug) subcommand, buffer list
Mikael Berthe <mikael@lilotux.net>
parents:
1225
diff
changeset
|
3212 // data: none. |
2521efbf3b72
New (debug) subcommand, buffer list
Mikael Berthe <mikael@lilotux.net>
parents:
1225
diff
changeset
|
3213 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
|
3214 { |
1227
79c396678f1b
Make buffer list display the number of allocated HBB blocks
Mikael Berthe <mikael@lilotux.net>
parents:
1226
diff
changeset
|
3215 GList *head; |
1226
2521efbf3b72
New (debug) subcommand, buffer list
Mikael Berthe <mikael@lilotux.net>
parents:
1225
diff
changeset
|
3216 winbuf *win_entry = value; |
1227
79c396678f1b
Make buffer list display the number of allocated HBB blocks
Mikael Berthe <mikael@lilotux.net>
parents:
1226
diff
changeset
|
3217 |
79c396678f1b
Make buffer list display the number of allocated HBB blocks
Mikael Berthe <mikael@lilotux.net>
parents:
1226
diff
changeset
|
3218 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
|
3219 |
1686
393c05fba337
Use G_GNUC_PRINTF to check scr_LogPrint arguments
Myhailo Danylenko <isbear@ukrpost.net>
parents:
1677
diff
changeset
|
3220 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
|
3221 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
|
3222 } |
2521efbf3b72
New (debug) subcommand, buffer list
Mikael Berthe <mikael@lilotux.net>
parents:
1225
diff
changeset
|
3223 |
1780
e4378fbab5d7
Major API cleanup - bump API to 4
Mikael Berthe <mikael@lilotux.net>
parents:
1761
diff
changeset
|
3224 void scr_buffer_list(void) |
1226
2521efbf3b72
New (debug) subcommand, buffer list
Mikael Berthe <mikael@lilotux.net>
parents:
1225
diff
changeset
|
3225 { |
2521efbf3b72
New (debug) subcommand, buffer list
Mikael Berthe <mikael@lilotux.net>
parents:
1225
diff
changeset
|
3226 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
|
3227 buffer_list("[status]", statusWindow, NULL); |
1226
2521efbf3b72
New (debug) subcommand, buffer list
Mikael Berthe <mikael@lilotux.net>
parents:
1225
diff
changeset
|
3228 g_hash_table_foreach(winbufhash, buffer_list, NULL); |
2521efbf3b72
New (debug) subcommand, buffer list
Mikael Berthe <mikael@lilotux.net>
parents:
1225
diff
changeset
|
3229 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
|
3230 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
|
3231 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
|
3232 ROSTER_UI_PRIO_STATUS_WIN_MESSAGE, prio_max); |
1226
2521efbf3b72
New (debug) subcommand, buffer list
Mikael Berthe <mikael@lilotux.net>
parents:
1225
diff
changeset
|
3233 } |
2521efbf3b72
New (debug) subcommand, buffer list
Mikael Berthe <mikael@lilotux.net>
parents:
1225
diff
changeset
|
3234 |
143 | 3235 // scr_set_chatmode() |
261 | 3236 // Public function to (un)set chatmode... |
129 | 3237 inline void scr_set_chatmode(int enable) |
3238 { | |
1961
39021fd6b0e1
Try to improve readmarks in some cases
Mikael Berthe <mikael@lilotux.net>
parents:
1960
diff
changeset
|
3239 gboolean enter_chatmode = enable && chatmode == FALSE; |
129 | 3240 chatmode = enable; |
1780
e4378fbab5d7
Major API cleanup - bump API to 4
Mikael Berthe <mikael@lilotux.net>
parents:
1761
diff
changeset
|
3241 scr_update_chat_status(TRUE); |
1961
39021fd6b0e1
Try to improve readmarks in some cases
Mikael Berthe <mikael@lilotux.net>
parents:
1960
diff
changeset
|
3242 if (enter_chatmode) |
39021fd6b0e1
Try to improve readmarks in some cases
Mikael Berthe <mikael@lilotux.net>
parents:
1960
diff
changeset
|
3243 scr_buffer_readmark(-1); |
129 | 3244 } |
3245 | |
1129
1a109ebf3f24
Add option "events_ignore_active_window"
Mikael Berthe <mikael@lilotux.net>
parents:
1127
diff
changeset
|
3246 // scr_get_chatmode() |
1a109ebf3f24
Add option "events_ignore_active_window"
Mikael Berthe <mikael@lilotux.net>
parents:
1127
diff
changeset
|
3247 // Public function to get chatmode state. |
1a109ebf3f24
Add option "events_ignore_active_window"
Mikael Berthe <mikael@lilotux.net>
parents:
1127
diff
changeset
|
3248 inline int scr_get_chatmode(void) |
1a109ebf3f24
Add option "events_ignore_active_window"
Mikael Berthe <mikael@lilotux.net>
parents:
1127
diff
changeset
|
3249 { |
1a109ebf3f24
Add option "events_ignore_active_window"
Mikael Berthe <mikael@lilotux.net>
parents:
1127
diff
changeset
|
3250 return chatmode; |
1a109ebf3f24
Add option "events_ignore_active_window"
Mikael Berthe <mikael@lilotux.net>
parents:
1127
diff
changeset
|
3251 } |
1a109ebf3f24
Add option "events_ignore_active_window"
Mikael Berthe <mikael@lilotux.net>
parents:
1127
diff
changeset
|
3252 |
238 | 3253 // scr_get_multimode() |
261 | 3254 // Public function to get multimode status... |
1059 | 3255 inline int scr_get_multimode(void) |
238 | 3256 { |
3257 return multimode; | |
3258 } | |
3259 | |
654
d7fe7b88e4fc
MUC: Set the new_message flag when joining a room
Mikael Berthe <mikael@lilotux.net>
parents:
652
diff
changeset
|
3260 // 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
|
3261 // Set the message flag unless we're already in the jid buffer window |
1058 | 3262 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
|
3263 { |
891
78f4971578dd
Add a "special" parameter to scr_setmsgflag_if_needed()
Mikael Berthe <mikael@lilotux.net>
parents:
889
diff
changeset
|
3264 const char *current_id; |
873
ee39f6d94d43
Add /buffer {scroll_lock|scroll_unlock|toggle_scroll}
Mikael Berthe <mikael@lilotux.net>
parents:
866
diff
changeset
|
3265 bool iscurrentlocked = FALSE; |
667
86bc3295a4db
Fix segfault in scr_setmsgflag_if_needed()
Mikael Berthe <mikael@lilotux.net>
parents:
658
diff
changeset
|
3266 |
1058 | 3267 if (!bjid) |
849
42c43a88d823
Status buffer management
Mikael Berthe <mikael@lilotux.net>
parents:
848
diff
changeset
|
3268 return; |
42c43a88d823
Status buffer management
Mikael Berthe <mikael@lilotux.net>
parents:
848
diff
changeset
|
3269 |
873
ee39f6d94d43
Add /buffer {scroll_lock|scroll_unlock|toggle_scroll}
Mikael Berthe <mikael@lilotux.net>
parents:
866
diff
changeset
|
3270 if (current_buddy) { |
891
78f4971578dd
Add a "special" parameter to scr_setmsgflag_if_needed()
Mikael Berthe <mikael@lilotux.net>
parents:
889
diff
changeset
|
3271 if (special) |
78f4971578dd
Add a "special" parameter to scr_setmsgflag_if_needed()
Mikael Berthe <mikael@lilotux.net>
parents:
889
diff
changeset
|
3272 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
|
3273 else |
78f4971578dd
Add a "special" parameter to scr_setmsgflag_if_needed()
Mikael Berthe <mikael@lilotux.net>
parents:
889
diff
changeset
|
3274 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
|
3275 if (current_id) { |
1780
e4378fbab5d7
Major API cleanup - bump API to 4
Mikael Berthe <mikael@lilotux.net>
parents:
1761
diff
changeset
|
3276 winbuf *win_entry = scr_search_window(current_id, special); |
888
578d2034e971
scr_setmsgflag_if_needed(): Add a check after scr_SearchWindow()
Mikael Berthe <mikael@lilotux.net>
parents:
884
diff
changeset
|
3277 if (!win_entry) return; |
1157
5c857f0f0ab8
Moved all variables related to hbuf to an extra struct, bufdata
Frank Zschockelt
parents:
1156
diff
changeset
|
3278 iscurrentlocked = win_entry->bd->lock; |
873
ee39f6d94d43
Add /buffer {scroll_lock|scroll_unlock|toggle_scroll}
Mikael Berthe <mikael@lilotux.net>
parents:
866
diff
changeset
|
3279 } |
ee39f6d94d43
Add /buffer {scroll_lock|scroll_unlock|toggle_scroll}
Mikael Berthe <mikael@lilotux.net>
parents:
866
diff
changeset
|
3280 } else { |
891
78f4971578dd
Add a "special" parameter to scr_setmsgflag_if_needed()
Mikael Berthe <mikael@lilotux.net>
parents:
889
diff
changeset
|
3281 current_id = NULL; |
873
ee39f6d94d43
Add /buffer {scroll_lock|scroll_unlock|toggle_scroll}
Mikael Berthe <mikael@lilotux.net>
parents:
866
diff
changeset
|
3282 } |
1821
60db836ad98a
Move some "update_roster" updates to a better place
Mikael Berthe <mikael@lilotux.net>
parents:
1819
diff
changeset
|
3283 if (!chatmode || !current_id || strcmp(bjid, current_id) || iscurrentlocked) { |
1058 | 3284 roster_msg_setflag(bjid, special, TRUE); |
1821
60db836ad98a
Move some "update_roster" updates to a better place
Mikael Berthe <mikael@lilotux.net>
parents:
1819
diff
changeset
|
3285 update_roster = TRUE; |
60db836ad98a
Move some "update_roster" updates to a better place
Mikael Berthe <mikael@lilotux.net>
parents:
1819
diff
changeset
|
3286 } |
654
d7fe7b88e4fc
MUC: Set the new_message flag when joining a room
Mikael Berthe <mikael@lilotux.net>
parents:
652
diff
changeset
|
3287 } |
d7fe7b88e4fc
MUC: Set the new_message flag when joining a room
Mikael Berthe <mikael@lilotux.net>
parents:
652
diff
changeset
|
3288 |
1802
b135572fcd26
Add urgent flag per screen buffer
Mikael Berthe <mikael@lilotux.net>
parents:
1793
diff
changeset
|
3289 // 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
|
3290 // 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
|
3291 // 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
|
3292 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
|
3293 guint value, enum setuiprio_ops action) |
b135572fcd26
Add urgent flag per screen buffer
Mikael Berthe <mikael@lilotux.net>
parents:
1793
diff
changeset
|
3294 { |
b135572fcd26
Add urgent flag per screen buffer
Mikael Berthe <mikael@lilotux.net>
parents:
1793
diff
changeset
|
3295 const char *current_id; |
b135572fcd26
Add urgent flag per screen buffer
Mikael Berthe <mikael@lilotux.net>
parents:
1793
diff
changeset
|
3296 winbuf *wb; |
b135572fcd26
Add urgent flag per screen buffer
Mikael Berthe <mikael@lilotux.net>
parents:
1793
diff
changeset
|
3297 bool iscurrentlocked = FALSE; |
b135572fcd26
Add urgent flag per screen buffer
Mikael Berthe <mikael@lilotux.net>
parents:
1793
diff
changeset
|
3298 |
b135572fcd26
Add urgent flag per screen buffer
Mikael Berthe <mikael@lilotux.net>
parents:
1793
diff
changeset
|
3299 if (!bjid) |
b135572fcd26
Add urgent flag per screen buffer
Mikael Berthe <mikael@lilotux.net>
parents:
1793
diff
changeset
|
3300 return; |
b135572fcd26
Add urgent flag per screen buffer
Mikael Berthe <mikael@lilotux.net>
parents:
1793
diff
changeset
|
3301 |
b135572fcd26
Add urgent flag per screen buffer
Mikael Berthe <mikael@lilotux.net>
parents:
1793
diff
changeset
|
3302 wb = scr_search_window(bjid, special); |
b135572fcd26
Add urgent flag per screen buffer
Mikael Berthe <mikael@lilotux.net>
parents:
1793
diff
changeset
|
3303 if (!wb) |
b135572fcd26
Add urgent flag per screen buffer
Mikael Berthe <mikael@lilotux.net>
parents:
1793
diff
changeset
|
3304 return; |
b135572fcd26
Add urgent flag per screen buffer
Mikael Berthe <mikael@lilotux.net>
parents:
1793
diff
changeset
|
3305 |
b135572fcd26
Add urgent flag per screen buffer
Mikael Berthe <mikael@lilotux.net>
parents:
1793
diff
changeset
|
3306 if (current_buddy) { |
b135572fcd26
Add urgent flag per screen buffer
Mikael Berthe <mikael@lilotux.net>
parents:
1793
diff
changeset
|
3307 if (special) |
b135572fcd26
Add urgent flag per screen buffer
Mikael Berthe <mikael@lilotux.net>
parents:
1793
diff
changeset
|
3308 current_id = buddy_getname(BUDDATA(current_buddy)); |
b135572fcd26
Add urgent flag per screen buffer
Mikael Berthe <mikael@lilotux.net>
parents:
1793
diff
changeset
|
3309 else |
b135572fcd26
Add urgent flag per screen buffer
Mikael Berthe <mikael@lilotux.net>
parents:
1793
diff
changeset
|
3310 current_id = buddy_getjid(BUDDATA(current_buddy)); |
b135572fcd26
Add urgent flag per screen buffer
Mikael Berthe <mikael@lilotux.net>
parents:
1793
diff
changeset
|
3311 if (current_id) { |
b135572fcd26
Add urgent flag per screen buffer
Mikael Berthe <mikael@lilotux.net>
parents:
1793
diff
changeset
|
3312 winbuf *win_entry = scr_search_window(current_id, special); |
b135572fcd26
Add urgent flag per screen buffer
Mikael Berthe <mikael@lilotux.net>
parents:
1793
diff
changeset
|
3313 if (!win_entry) return; |
b135572fcd26
Add urgent flag per screen buffer
Mikael Berthe <mikael@lilotux.net>
parents:
1793
diff
changeset
|
3314 iscurrentlocked = win_entry->bd->lock; |
b135572fcd26
Add urgent flag per screen buffer
Mikael Berthe <mikael@lilotux.net>
parents:
1793
diff
changeset
|
3315 } |
b135572fcd26
Add urgent flag per screen buffer
Mikael Berthe <mikael@lilotux.net>
parents:
1793
diff
changeset
|
3316 } else { |
b135572fcd26
Add urgent flag per screen buffer
Mikael Berthe <mikael@lilotux.net>
parents:
1793
diff
changeset
|
3317 current_id = NULL; |
b135572fcd26
Add urgent flag per screen buffer
Mikael Berthe <mikael@lilotux.net>
parents:
1793
diff
changeset
|
3318 } |
b135572fcd26
Add urgent flag per screen buffer
Mikael Berthe <mikael@lilotux.net>
parents:
1793
diff
changeset
|
3319 |
1821
60db836ad98a
Move some "update_roster" updates to a better place
Mikael Berthe <mikael@lilotux.net>
parents:
1819
diff
changeset
|
3320 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
|
3321 roster_setuiprio(bjid, special, value, action); |
1821
60db836ad98a
Move some "update_roster" updates to a better place
Mikael Berthe <mikael@lilotux.net>
parents:
1819
diff
changeset
|
3322 update_roster = TRUE; |
60db836ad98a
Move some "update_roster" updates to a better place
Mikael Berthe <mikael@lilotux.net>
parents:
1819
diff
changeset
|
3323 } |
1802
b135572fcd26
Add urgent flag per screen buffer
Mikael Berthe <mikael@lilotux.net>
parents:
1793
diff
changeset
|
3324 } |
b135572fcd26
Add urgent flag per screen buffer
Mikael Berthe <mikael@lilotux.net>
parents:
1793
diff
changeset
|
3325 |
238 | 3326 // scr_set_multimode() |
261 | 3327 // Public function to (un)set multimode... |
260
33e1a05864a6
Add "verbatim multi-line" mode, with commands disabled
mikael@frmp8452
parents:
252
diff
changeset
|
3328 // Convention: |
33e1a05864a6
Add "verbatim multi-line" mode, with commands disabled
mikael@frmp8452
parents:
252
diff
changeset
|
3329 // 0 = disabled / 1 = multimode / 2 = multimode verbatim (commands disabled) |
1413 | 3330 void scr_set_multimode(int enable, char *subject) |
238 | 3331 { |
807
f6cda389db48
Allow messages with a subject (/msay)
Mikael Berthe <mikael@lilotux.net>
parents:
806
diff
changeset
|
3332 g_free(multiline); |
f6cda389db48
Allow messages with a subject (/msay)
Mikael Berthe <mikael@lilotux.net>
parents:
806
diff
changeset
|
3333 multiline = NULL; |
f6cda389db48
Allow messages with a subject (/msay)
Mikael Berthe <mikael@lilotux.net>
parents:
806
diff
changeset
|
3334 |
f6cda389db48
Allow messages with a subject (/msay)
Mikael Berthe <mikael@lilotux.net>
parents:
806
diff
changeset
|
3335 g_free(multimode_subj); |
f6cda389db48
Allow messages with a subject (/msay)
Mikael Berthe <mikael@lilotux.net>
parents:
806
diff
changeset
|
3336 if (enable && subject) |
f6cda389db48
Allow messages with a subject (/msay)
Mikael Berthe <mikael@lilotux.net>
parents:
806
diff
changeset
|
3337 multimode_subj = g_strdup(subject); |
f6cda389db48
Allow messages with a subject (/msay)
Mikael Berthe <mikael@lilotux.net>
parents:
806
diff
changeset
|
3338 else |
f6cda389db48
Allow messages with a subject (/msay)
Mikael Berthe <mikael@lilotux.net>
parents:
806
diff
changeset
|
3339 multimode_subj = NULL; |
f6cda389db48
Allow messages with a subject (/msay)
Mikael Berthe <mikael@lilotux.net>
parents:
806
diff
changeset
|
3340 |
260
33e1a05864a6
Add "verbatim multi-line" mode, with commands disabled
mikael@frmp8452
parents:
252
diff
changeset
|
3341 multimode = enable; |
238 | 3342 } |
3343 | |
3344 // scr_get_multiline() | |
261 | 3345 // Public function to get the current multi-line. |
1413 | 3346 const char *scr_get_multiline(void) |
238 | 3347 { |
3348 if (multimode && multiline) | |
3349 return multiline; | |
807
f6cda389db48
Allow messages with a subject (/msay)
Mikael Berthe <mikael@lilotux.net>
parents:
806
diff
changeset
|
3350 return NULL; |
f6cda389db48
Allow messages with a subject (/msay)
Mikael Berthe <mikael@lilotux.net>
parents:
806
diff
changeset
|
3351 } |
f6cda389db48
Allow messages with a subject (/msay)
Mikael Berthe <mikael@lilotux.net>
parents:
806
diff
changeset
|
3352 |
f6cda389db48
Allow messages with a subject (/msay)
Mikael Berthe <mikael@lilotux.net>
parents:
806
diff
changeset
|
3353 // scr_get_multimode_subj() |
f6cda389db48
Allow messages with a subject (/msay)
Mikael Berthe <mikael@lilotux.net>
parents:
806
diff
changeset
|
3354 // Public function to get the multi-line subject, if any. |
1413 | 3355 const char *scr_get_multimode_subj(void) |
807
f6cda389db48
Allow messages with a subject (/msay)
Mikael Berthe <mikael@lilotux.net>
parents:
806
diff
changeset
|
3356 { |
f6cda389db48
Allow messages with a subject (/msay)
Mikael Berthe <mikael@lilotux.net>
parents:
806
diff
changeset
|
3357 if (multimode) |
f6cda389db48
Allow messages with a subject (/msay)
Mikael Berthe <mikael@lilotux.net>
parents:
806
diff
changeset
|
3358 return multimode_subj; |
f6cda389db48
Allow messages with a subject (/msay)
Mikael Berthe <mikael@lilotux.net>
parents:
806
diff
changeset
|
3359 return NULL; |
238 | 3360 } |
3361 | |
3362 // scr_append_multiline(line) | |
3363 // Public function to append a line to the current multi-line message. | |
3364 // Skip empty leading lines. | |
3365 void scr_append_multiline(const char *line) | |
3366 { | |
3367 static int num; | |
3368 | |
3369 if (!multimode) { | |
374
bd5638c21834
Improve logging system (traces)
Mikael Berthe <mikael@lilotux.net>
parents:
373
diff
changeset
|
3370 scr_LogPrint(LPRINT_NORMAL, "Error: Not in multi-line message mode!"); |
238 | 3371 return; |
3372 } | |
3373 if (multiline) { | |
3374 int len = strlen(multiline)+strlen(line)+2; | |
252 | 3375 if (len >= HBB_BLOCKSIZE - 1) { |
238 | 3376 // We don't handle single messages with size > HBB_BLOCKSIZE |
3377 // (see hbuf) | |
374
bd5638c21834
Improve logging system (traces)
Mikael Berthe <mikael@lilotux.net>
parents:
373
diff
changeset
|
3378 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
|
3379 "this line has not been added."); |
bd5638c21834
Improve logging system (traces)
Mikael Berthe <mikael@lilotux.net>
parents:
373
diff
changeset
|
3380 scr_LogPrint(LPRINT_NORMAL, "Please send this part now..."); |
238 | 3381 return; |
3382 } | |
276
627925d885de
Limit the number of lines in multi-line messages
Mikael Berthe <mikael@lilotux.net>
parents:
271
diff
changeset
|
3383 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
|
3384 // 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
|
3385 // (It should be < 1000 yet) |
374
bd5638c21834
Improve logging system (traces)
Mikael Berthe <mikael@lilotux.net>
parents:
373
diff
changeset
|
3386 scr_LogPrint(LPRINT_NORMAL, "Your message has too many lines, " |
bd5638c21834
Improve logging system (traces)
Mikael Berthe <mikael@lilotux.net>
parents:
373
diff
changeset
|
3387 "this one has not been added."); |
bd5638c21834
Improve logging system (traces)
Mikael Berthe <mikael@lilotux.net>
parents:
373
diff
changeset
|
3388 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
|
3389 return; |
627925d885de
Limit the number of lines in multi-line messages
Mikael Berthe <mikael@lilotux.net>
parents:
271
diff
changeset
|
3390 } |
238 | 3391 multiline = g_renew(char, multiline, len); |
3392 strcat(multiline, "\n"); | |
3393 strcat(multiline, line); | |
3394 num++; | |
3395 } else { | |
3396 // First message line (we skip leading empty lines) | |
3397 num = 0; | |
3398 if (line[0]) { | |
419 | 3399 multiline = g_strdup(line); |
238 | 3400 num++; |
3401 } else | |
3402 return; | |
3403 } | |
772
464be13343a9
Store most data in UTF-8 internally
Mikael Berthe <mikael@lilotux.net>
parents:
771
diff
changeset
|
3404 scr_LogPrint(LPRINT_NORMAL|LPRINT_NOTUTF8, |
464be13343a9
Store most data in UTF-8 internally
Mikael Berthe <mikael@lilotux.net>
parents:
771
diff
changeset
|
3405 "Multi-line mode: line #%d added [%.25s...", num, line); |
238 | 3406 } |
3407 | |
173 | 3408 // scr_cmdhisto_addline() |
3409 // Add a line to the inputLine history | |
1985
0870005f7efc
Add command /iline clear_history
Mikael Berthe <mikael@lilotux.net>
parents:
1977
diff
changeset
|
3410 static void scr_cmdhisto_addline(char *line) |
173 | 3411 { |
1127
fddf2fef7b83
Add option "cmdhistory_lines"
Mikael Berthe <mikael@lilotux.net>
parents:
1122
diff
changeset
|
3412 int max_histo_lines; |
fddf2fef7b83
Add option "cmdhistory_lines"
Mikael Berthe <mikael@lilotux.net>
parents:
1122
diff
changeset
|
3413 |
fddf2fef7b83
Add option "cmdhistory_lines"
Mikael Berthe <mikael@lilotux.net>
parents:
1122
diff
changeset
|
3414 if (!line || !*line) |
fddf2fef7b83
Add option "cmdhistory_lines"
Mikael Berthe <mikael@lilotux.net>
parents:
1122
diff
changeset
|
3415 return; |
fddf2fef7b83
Add option "cmdhistory_lines"
Mikael Berthe <mikael@lilotux.net>
parents:
1122
diff
changeset
|
3416 |
fddf2fef7b83
Add option "cmdhistory_lines"
Mikael Berthe <mikael@lilotux.net>
parents:
1122
diff
changeset
|
3417 max_histo_lines = settings_opt_get_int("cmdhistory_lines"); |
fddf2fef7b83
Add option "cmdhistory_lines"
Mikael Berthe <mikael@lilotux.net>
parents:
1122
diff
changeset
|
3418 |
fddf2fef7b83
Add option "cmdhistory_lines"
Mikael Berthe <mikael@lilotux.net>
parents:
1122
diff
changeset
|
3419 if (max_histo_lines < 0) |
fddf2fef7b83
Add option "cmdhistory_lines"
Mikael Berthe <mikael@lilotux.net>
parents:
1122
diff
changeset
|
3420 max_histo_lines = 1; |
fddf2fef7b83
Add option "cmdhistory_lines"
Mikael Berthe <mikael@lilotux.net>
parents:
1122
diff
changeset
|
3421 |
fddf2fef7b83
Add option "cmdhistory_lines"
Mikael Berthe <mikael@lilotux.net>
parents:
1122
diff
changeset
|
3422 if (max_histo_lines) |
fddf2fef7b83
Add option "cmdhistory_lines"
Mikael Berthe <mikael@lilotux.net>
parents:
1122
diff
changeset
|
3423 while (cmdhisto_nblines >= (guint)max_histo_lines) { |
fddf2fef7b83
Add option "cmdhistory_lines"
Mikael Berthe <mikael@lilotux.net>
parents:
1122
diff
changeset
|
3424 if (cmdhisto_cur && cmdhisto_cur == cmdhisto) |
fddf2fef7b83
Add option "cmdhistory_lines"
Mikael Berthe <mikael@lilotux.net>
parents:
1122
diff
changeset
|
3425 break; |
fddf2fef7b83
Add option "cmdhistory_lines"
Mikael Berthe <mikael@lilotux.net>
parents:
1122
diff
changeset
|
3426 g_free(cmdhisto->data); |
fddf2fef7b83
Add option "cmdhistory_lines"
Mikael Berthe <mikael@lilotux.net>
parents:
1122
diff
changeset
|
3427 cmdhisto = g_list_delete_link(cmdhisto, cmdhisto); |
fddf2fef7b83
Add option "cmdhistory_lines"
Mikael Berthe <mikael@lilotux.net>
parents:
1122
diff
changeset
|
3428 cmdhisto_nblines--; |
fddf2fef7b83
Add option "cmdhistory_lines"
Mikael Berthe <mikael@lilotux.net>
parents:
1122
diff
changeset
|
3429 } |
173 | 3430 |
3431 cmdhisto = g_list_append(cmdhisto, g_strdup(line)); | |
1127
fddf2fef7b83
Add option "cmdhistory_lines"
Mikael Berthe <mikael@lilotux.net>
parents:
1122
diff
changeset
|
3432 cmdhisto_nblines++; |
173 | 3433 } |
3434 | |
1985
0870005f7efc
Add command /iline clear_history
Mikael Berthe <mikael@lilotux.net>
parents:
1977
diff
changeset
|
3435 // scr_cmdhisto_reset() |
0870005f7efc
Add command /iline clear_history
Mikael Berthe <mikael@lilotux.net>
parents:
1977
diff
changeset
|
3436 // Reset the inputLine history |
0870005f7efc
Add command /iline clear_history
Mikael Berthe <mikael@lilotux.net>
parents:
1977
diff
changeset
|
3437 static void scr_cmdhisto_reset(void) |
0870005f7efc
Add command /iline clear_history
Mikael Berthe <mikael@lilotux.net>
parents:
1977
diff
changeset
|
3438 { |
0870005f7efc
Add command /iline clear_history
Mikael Berthe <mikael@lilotux.net>
parents:
1977
diff
changeset
|
3439 while (cmdhisto_nblines) { |
0870005f7efc
Add command /iline clear_history
Mikael Berthe <mikael@lilotux.net>
parents:
1977
diff
changeset
|
3440 g_free(cmdhisto->data); |
0870005f7efc
Add command /iline clear_history
Mikael Berthe <mikael@lilotux.net>
parents:
1977
diff
changeset
|
3441 cmdhisto = g_list_delete_link(cmdhisto, cmdhisto); |
0870005f7efc
Add command /iline clear_history
Mikael Berthe <mikael@lilotux.net>
parents:
1977
diff
changeset
|
3442 cmdhisto_nblines--; |
0870005f7efc
Add command /iline clear_history
Mikael Berthe <mikael@lilotux.net>
parents:
1977
diff
changeset
|
3443 } |
0870005f7efc
Add command /iline clear_history
Mikael Berthe <mikael@lilotux.net>
parents:
1977
diff
changeset
|
3444 cmdhisto_backup[0] = 0; |
0870005f7efc
Add command /iline clear_history
Mikael Berthe <mikael@lilotux.net>
parents:
1977
diff
changeset
|
3445 cmdhisto_cur = NULL; |
0870005f7efc
Add command /iline clear_history
Mikael Berthe <mikael@lilotux.net>
parents:
1977
diff
changeset
|
3446 } |
0870005f7efc
Add command /iline clear_history
Mikael Berthe <mikael@lilotux.net>
parents:
1977
diff
changeset
|
3447 |
173 | 3448 // scr_cmdhisto_prev() |
3449 // Look for previous line beginning w/ the given mask in the inputLine history | |
175 | 3450 // Returns NULL if none found |
336
eb994ee40029
Make some functions static
Mikael Berthe <mikael@lilotux.net>
parents:
332
diff
changeset
|
3451 static const char *scr_cmdhisto_prev(char *mask, guint len) |
173 | 3452 { |
3453 GList *hl; | |
3454 if (!cmdhisto_cur) { | |
3455 hl = g_list_last(cmdhisto); | |
174 | 3456 if (hl) { // backup current line |
3457 strncpy(cmdhisto_backup, mask, INPUTLINE_LENGTH); | |
3458 } | |
173 | 3459 } else { |
3460 hl = g_list_previous(cmdhisto_cur); | |
3461 } | |
3462 while (hl) { | |
3463 if (!strncmp((char*)hl->data, mask, len)) { | |
3464 // Found a match | |
3465 cmdhisto_cur = hl; | |
3466 return (const char*)hl->data; | |
3467 } | |
3468 hl = g_list_previous(hl); | |
3469 } | |
3470 return NULL; | |
3471 } | |
3472 | |
3473 // scr_cmdhisto_next() | |
3474 // Look for next line beginning w/ the given mask in the inputLine history | |
175 | 3475 // Returns NULL if none found |
336
eb994ee40029
Make some functions static
Mikael Berthe <mikael@lilotux.net>
parents:
332
diff
changeset
|
3476 static const char *scr_cmdhisto_next(char *mask, guint len) |
173 | 3477 { |
3478 GList *hl; | |
3479 if (!cmdhisto_cur) return NULL; | |
3480 hl = cmdhisto_cur; | |
3481 while ((hl = g_list_next(hl)) != NULL) | |
3482 if (!strncmp((char*)hl->data, mask, len)) { | |
3483 // Found a match | |
3484 cmdhisto_cur = hl; | |
3485 return (const char*)hl->data; | |
3486 } | |
175 | 3487 // If the "backuped" line matches, we'll use it |
3488 if (strncmp(cmdhisto_backup, mask, len)) return NULL; // No match | |
174 | 3489 cmdhisto_cur = NULL; |
3490 return cmdhisto_backup; | |
173 | 3491 } |
3492 | |
1903
75a0a22bbf78
Fix issue #54 -- command line corruption
Mikael Berthe <mikael@lilotux.net>
parents:
1863
diff
changeset
|
3493 static char *_strmove(char *dst, const char *src) |
75a0a22bbf78
Fix issue #54 -- command line corruption
Mikael Berthe <mikael@lilotux.net>
parents:
1863
diff
changeset
|
3494 { |
75a0a22bbf78
Fix issue #54 -- command line corruption
Mikael Berthe <mikael@lilotux.net>
parents:
1863
diff
changeset
|
3495 char *dest = dst; |
75a0a22bbf78
Fix issue #54 -- command line corruption
Mikael Berthe <mikael@lilotux.net>
parents:
1863
diff
changeset
|
3496 while ((*dest++ = *src++) != '\0') |
75a0a22bbf78
Fix issue #54 -- command line corruption
Mikael Berthe <mikael@lilotux.net>
parents:
1863
diff
changeset
|
3497 ; |
75a0a22bbf78
Fix issue #54 -- command line corruption
Mikael Berthe <mikael@lilotux.net>
parents:
1863
diff
changeset
|
3498 return dest; |
75a0a22bbf78
Fix issue #54 -- command line corruption
Mikael Berthe <mikael@lilotux.net>
parents:
1863
diff
changeset
|
3499 } |
75a0a22bbf78
Fix issue #54 -- command line corruption
Mikael Berthe <mikael@lilotux.net>
parents:
1863
diff
changeset
|
3500 |
195 | 3501 // readline_transpose_chars() |
3502 // Drag the character before point forward over the character at | |
3503 // point, moving point forward as well. If point is at the end of | |
3504 // the line, then this transposes the two characters before point. | |
1059 | 3505 void readline_transpose_chars(void) |
195 | 3506 { |
930
a75f7a13df7b
UTF-8 terminal support (Reimar Döffinger)
Mikael Berthe <mikael@lilotux.net>
parents:
929
diff
changeset
|
3507 char *c1, *c2; |
a75f7a13df7b
UTF-8 terminal support (Reimar Döffinger)
Mikael Berthe <mikael@lilotux.net>
parents:
929
diff
changeset
|
3508 unsigned a, b; |
195 | 3509 |
3510 if (ptr_inputline == inputLine) return; | |
3511 | |
3512 if (!*ptr_inputline) { // We're at EOL | |
3513 // 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
|
3514 if (ptr_inputline == prev_char(ptr_inputline, inputLine)) return; |
195 | 3515 // Transpose the two previous characters |
930
a75f7a13df7b
UTF-8 terminal support (Reimar Döffinger)
Mikael Berthe <mikael@lilotux.net>
parents:
929
diff
changeset
|
3516 c2 = prev_char(ptr_inputline, inputLine); |
a75f7a13df7b
UTF-8 terminal support (Reimar Döffinger)
Mikael Berthe <mikael@lilotux.net>
parents:
929
diff
changeset
|
3517 c1 = prev_char(c2, inputLine); |
a75f7a13df7b
UTF-8 terminal support (Reimar Döffinger)
Mikael Berthe <mikael@lilotux.net>
parents:
929
diff
changeset
|
3518 a = get_char(c1); |
a75f7a13df7b
UTF-8 terminal support (Reimar Döffinger)
Mikael Berthe <mikael@lilotux.net>
parents:
929
diff
changeset
|
3519 b = get_char(c2); |
a75f7a13df7b
UTF-8 terminal support (Reimar Döffinger)
Mikael Berthe <mikael@lilotux.net>
parents:
929
diff
changeset
|
3520 put_char(put_char(c1, b), a); |
195 | 3521 } else { |
196 | 3522 // 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
|
3523 c2 = ptr_inputline; |
a75f7a13df7b
UTF-8 terminal support (Reimar Döffinger)
Mikael Berthe <mikael@lilotux.net>
parents:
929
diff
changeset
|
3524 c1 = prev_char(c2, inputLine); |
a75f7a13df7b
UTF-8 terminal support (Reimar Döffinger)
Mikael Berthe <mikael@lilotux.net>
parents:
929
diff
changeset
|
3525 a = get_char(c1); |
a75f7a13df7b
UTF-8 terminal support (Reimar Döffinger)
Mikael Berthe <mikael@lilotux.net>
parents:
929
diff
changeset
|
3526 b = get_char(c2); |
a75f7a13df7b
UTF-8 terminal support (Reimar Döffinger)
Mikael Berthe <mikael@lilotux.net>
parents:
929
diff
changeset
|
3527 put_char(put_char(c1, b), a); |
195 | 3528 check_offset(1); |
3529 } | |
3530 } | |
3531 | |
1171
03a38b7ad2e0
Add a collection of commands for key bindings (Lego12239)
Mikael Berthe <mikael@lilotux.net>
parents:
1170
diff
changeset
|
3532 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
|
3533 { |
03a38b7ad2e0
Add a collection of commands for key bindings (Lego12239)
Mikael Berthe <mikael@lilotux.net>
parents:
1170
diff
changeset
|
3534 char *c, *old = ptr_inputline; |
03a38b7ad2e0
Add a collection of commands for key bindings (Lego12239)
Mikael Berthe <mikael@lilotux.net>
parents:
1170
diff
changeset
|
3535 int spaceallowed = 1; |
03a38b7ad2e0
Add a collection of commands for key bindings (Lego12239)
Mikael Berthe <mikael@lilotux.net>
parents:
1170
diff
changeset
|
3536 |
03a38b7ad2e0
Add a collection of commands for key bindings (Lego12239)
Mikael Berthe <mikael@lilotux.net>
parents:
1170
diff
changeset
|
3537 if (! *ptr_inputline) return; |
03a38b7ad2e0
Add a collection of commands for key bindings (Lego12239)
Mikael Berthe <mikael@lilotux.net>
parents:
1170
diff
changeset
|
3538 |
03a38b7ad2e0
Add a collection of commands for key bindings (Lego12239)
Mikael Berthe <mikael@lilotux.net>
parents:
1170
diff
changeset
|
3539 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
|
3540 if (!iswalnum(get_char(c))) { |
03a38b7ad2e0
Add a collection of commands for key bindings (Lego12239)
Mikael Berthe <mikael@lilotux.net>
parents:
1170
diff
changeset
|
3541 if (iswblank(get_char(c))) { |
03a38b7ad2e0
Add a collection of commands for key bindings (Lego12239)
Mikael Berthe <mikael@lilotux.net>
parents:
1170
diff
changeset
|
3542 if (!spaceallowed) break; |
03a38b7ad2e0
Add a collection of commands for key bindings (Lego12239)
Mikael Berthe <mikael@lilotux.net>
parents:
1170
diff
changeset
|
3543 } else spaceallowed = 0; |
03a38b7ad2e0
Add a collection of commands for key bindings (Lego12239)
Mikael Berthe <mikael@lilotux.net>
parents:
1170
diff
changeset
|
3544 } else spaceallowed = 0; |
03a38b7ad2e0
Add a collection of commands for key bindings (Lego12239)
Mikael Berthe <mikael@lilotux.net>
parents:
1170
diff
changeset
|
3545 } |
03a38b7ad2e0
Add a collection of commands for key bindings (Lego12239)
Mikael Berthe <mikael@lilotux.net>
parents:
1170
diff
changeset
|
3546 |
03a38b7ad2e0
Add a collection of commands for key bindings (Lego12239)
Mikael Berthe <mikael@lilotux.net>
parents:
1170
diff
changeset
|
3547 // Modify the line |
03a38b7ad2e0
Add a collection of commands for key bindings (Lego12239)
Mikael Berthe <mikael@lilotux.net>
parents:
1170
diff
changeset
|
3548 for (;;) { |
03a38b7ad2e0
Add a collection of commands for key bindings (Lego12239)
Mikael Berthe <mikael@lilotux.net>
parents:
1170
diff
changeset
|
3549 *old = *c++; |
03a38b7ad2e0
Add a collection of commands for key bindings (Lego12239)
Mikael Berthe <mikael@lilotux.net>
parents:
1170
diff
changeset
|
3550 if (!*old++) break; |
03a38b7ad2e0
Add a collection of commands for key bindings (Lego12239)
Mikael Berthe <mikael@lilotux.net>
parents:
1170
diff
changeset
|
3551 } |
03a38b7ad2e0
Add a collection of commands for key bindings (Lego12239)
Mikael Berthe <mikael@lilotux.net>
parents:
1170
diff
changeset
|
3552 } |
03a38b7ad2e0
Add a collection of commands for key bindings (Lego12239)
Mikael Berthe <mikael@lilotux.net>
parents:
1170
diff
changeset
|
3553 |
195 | 3554 // readline_backward_kill_word() |
194 | 3555 // Kill the word before the cursor, in input line |
1059 | 3556 void readline_backward_kill_word(void) |
194 | 3557 { |
3558 char *c, *old = ptr_inputline; | |
3559 int spaceallowed = 1; | |
3560 | |
3561 if (ptr_inputline == inputLine) return; | |
3562 | |
930
a75f7a13df7b
UTF-8 terminal support (Reimar Döffinger)
Mikael Berthe <mikael@lilotux.net>
parents:
929
diff
changeset
|
3563 c = prev_char(ptr_inputline, inputLine); |
a75f7a13df7b
UTF-8 terminal support (Reimar Döffinger)
Mikael Berthe <mikael@lilotux.net>
parents:
929
diff
changeset
|
3564 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
|
3565 if (!iswalnum(get_char(c))) { |
933
ede9260be93d
Input line: Improve word-related functions
Mikael Berthe <mikael@lilotux.net>
parents:
932
diff
changeset
|
3566 if (iswblank(get_char(c))) { |
194 | 3567 if (!spaceallowed) break; |
933
ede9260be93d
Input line: Improve word-related functions
Mikael Berthe <mikael@lilotux.net>
parents:
932
diff
changeset
|
3568 } else spaceallowed = 0; |
194 | 3569 } 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
|
3570 } |
194 | 3571 |
1280
8b621f980321
readline_backward_kill_word() makes a stop at the "command" character
Mikael Berthe <mikael@lilotux.net>
parents:
1279
diff
changeset
|
3572 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
|
3573 c = next_char(c); |
2072
0722fe4b7580
Small fix for readline_backward_kill_word()
Mikael Berthe <mikael@lilotux.net>
parents:
2047
diff
changeset
|
3574 } 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
|
3575 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
|
3576 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
|
3577 } |
194 | 3578 |
3579 // Modify the line | |
3580 ptr_inputline = c; | |
1903
75a0a22bbf78
Fix issue #54 -- command line corruption
Mikael Berthe <mikael@lilotux.net>
parents:
1863
diff
changeset
|
3581 _strmove(ptr_inputline, old); |
195 | 3582 check_offset(-1); |
194 | 3583 } |
3584 | |
759
a681dc477c7f
Add readline_backward_word and readline_forward_word (Ctrl-Left/Ctrl-Right)
Mikael Berthe <mikael@lilotux.net>
parents:
758
diff
changeset
|
3585 // readline_backward_word() |
2074
e04b6dfbb054
Some whitespace cleanup
Mikael Berthe <mikael@lilotux.net>
parents:
2072
diff
changeset
|
3586 // Move back to the start of the current or previous word |
1059 | 3587 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
|
3588 { |
1172
334ae9f498f1
Add some more iline functions (Lego12239)
Mikael Berthe <mikael@lilotux.net>
parents:
1171
diff
changeset
|
3589 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
|
3590 |
a681dc477c7f
Add readline_backward_word and readline_forward_word (Ctrl-Left/Ctrl-Right)
Mikael Berthe <mikael@lilotux.net>
parents:
758
diff
changeset
|
3591 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
|
3592 |
1172
334ae9f498f1
Add some more iline functions (Lego12239)
Mikael Berthe <mikael@lilotux.net>
parents:
1171
diff
changeset
|
3593 if (iswalnum(get_char(ptr_inputline)) && |
334ae9f498f1
Add some more iline functions (Lego12239)
Mikael Berthe <mikael@lilotux.net>
parents:
1171
diff
changeset
|
3594 !iswalnum(get_char(prev_char(ptr_inputline, inputLine)))) |
334ae9f498f1
Add some more iline functions (Lego12239)
Mikael Berthe <mikael@lilotux.net>
parents:
1171
diff
changeset
|
3595 i--; |
334ae9f498f1
Add some more iline functions (Lego12239)
Mikael Berthe <mikael@lilotux.net>
parents:
1171
diff
changeset
|
3596 |
1333
e30a9d907105
Minor coding style adjustments
Mikael Berthe <mikael@lilotux.net>
parents:
1314
diff
changeset
|
3597 for ( ; |
e30a9d907105
Minor coding style adjustments
Mikael Berthe <mikael@lilotux.net>
parents:
1314
diff
changeset
|
3598 ptr_inputline > inputLine; |
e30a9d907105
Minor coding style adjustments
Mikael Berthe <mikael@lilotux.net>
parents:
1314
diff
changeset
|
3599 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
|
3600 if (!iswalnum(get_char(ptr_inputline))) { |
1172
334ae9f498f1
Add some more iline functions (Lego12239)
Mikael Berthe <mikael@lilotux.net>
parents:
1171
diff
changeset
|
3601 if (i) { |
334ae9f498f1
Add some more iline functions (Lego12239)
Mikael Berthe <mikael@lilotux.net>
parents:
1171
diff
changeset
|
3602 ptr_inputline = next_char(ptr_inputline); |
334ae9f498f1
Add some more iline functions (Lego12239)
Mikael Berthe <mikael@lilotux.net>
parents:
1171
diff
changeset
|
3603 break; |
334ae9f498f1
Add some more iline functions (Lego12239)
Mikael Berthe <mikael@lilotux.net>
parents:
1171
diff
changeset
|
3604 } |
334ae9f498f1
Add some more iline functions (Lego12239)
Mikael Berthe <mikael@lilotux.net>
parents:
1171
diff
changeset
|
3605 } 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
|
3606 } |
a681dc477c7f
Add readline_backward_word and readline_forward_word (Ctrl-Left/Ctrl-Right)
Mikael Berthe <mikael@lilotux.net>
parents:
758
diff
changeset
|
3607 |
a681dc477c7f
Add readline_backward_word and readline_forward_word (Ctrl-Left/Ctrl-Right)
Mikael Berthe <mikael@lilotux.net>
parents:
758
diff
changeset
|
3608 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
|
3609 } |
a681dc477c7f
Add readline_backward_word and readline_forward_word (Ctrl-Left/Ctrl-Right)
Mikael Berthe <mikael@lilotux.net>
parents:
758
diff
changeset
|
3610 |
a681dc477c7f
Add readline_backward_word and readline_forward_word (Ctrl-Left/Ctrl-Right)
Mikael Berthe <mikael@lilotux.net>
parents:
758
diff
changeset
|
3611 // 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
|
3612 // Move forward to the end of the next word |
1059 | 3613 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
|
3614 { |
1172
334ae9f498f1
Add some more iline functions (Lego12239)
Mikael Berthe <mikael@lilotux.net>
parents:
1171
diff
changeset
|
3615 int stopsymbol_allowed = 1; |
334ae9f498f1
Add some more iline functions (Lego12239)
Mikael Berthe <mikael@lilotux.net>
parents:
1171
diff
changeset
|
3616 |
334ae9f498f1
Add some more iline functions (Lego12239)
Mikael Berthe <mikael@lilotux.net>
parents:
1171
diff
changeset
|
3617 while (*ptr_inputline) { |
334ae9f498f1
Add some more iline functions (Lego12239)
Mikael Berthe <mikael@lilotux.net>
parents:
1171
diff
changeset
|
3618 if (!iswalnum(get_char(ptr_inputline))) { |
334ae9f498f1
Add some more iline functions (Lego12239)
Mikael Berthe <mikael@lilotux.net>
parents:
1171
diff
changeset
|
3619 if (!stopsymbol_allowed) break; |
334ae9f498f1
Add some more iline functions (Lego12239)
Mikael Berthe <mikael@lilotux.net>
parents:
1171
diff
changeset
|
3620 } else stopsymbol_allowed = 0; |
334ae9f498f1
Add some more iline functions (Lego12239)
Mikael Berthe <mikael@lilotux.net>
parents:
1171
diff
changeset
|
3621 ptr_inputline = next_char(ptr_inputline); |
334ae9f498f1
Add some more iline functions (Lego12239)
Mikael Berthe <mikael@lilotux.net>
parents:
1171
diff
changeset
|
3622 } |
334ae9f498f1
Add some more iline functions (Lego12239)
Mikael Berthe <mikael@lilotux.net>
parents:
1171
diff
changeset
|
3623 |
334ae9f498f1
Add some more iline functions (Lego12239)
Mikael Berthe <mikael@lilotux.net>
parents:
1171
diff
changeset
|
3624 check_offset(1); |
334ae9f498f1
Add some more iline functions (Lego12239)
Mikael Berthe <mikael@lilotux.net>
parents:
1171
diff
changeset
|
3625 } |
334ae9f498f1
Add some more iline functions (Lego12239)
Mikael Berthe <mikael@lilotux.net>
parents:
1171
diff
changeset
|
3626 |
334ae9f498f1
Add some more iline functions (Lego12239)
Mikael Berthe <mikael@lilotux.net>
parents:
1171
diff
changeset
|
3627 void readline_updowncase_word(int upcase) |
334ae9f498f1
Add some more iline functions (Lego12239)
Mikael Berthe <mikael@lilotux.net>
parents:
1171
diff
changeset
|
3628 { |
334ae9f498f1
Add some more iline functions (Lego12239)
Mikael Berthe <mikael@lilotux.net>
parents:
1171
diff
changeset
|
3629 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
|
3630 |
a681dc477c7f
Add readline_backward_word and readline_forward_word (Ctrl-Left/Ctrl-Right)
Mikael Berthe <mikael@lilotux.net>
parents:
758
diff
changeset
|
3631 while (*ptr_inputline) { |
930
a75f7a13df7b
UTF-8 terminal support (Reimar Döffinger)
Mikael Berthe <mikael@lilotux.net>
parents:
929
diff
changeset
|
3632 if (!iswalnum(get_char(ptr_inputline))) { |
1172
334ae9f498f1
Add some more iline functions (Lego12239)
Mikael Berthe <mikael@lilotux.net>
parents:
1171
diff
changeset
|
3633 if (!stopsymbol_allowed) break; |
334ae9f498f1
Add some more iline functions (Lego12239)
Mikael Berthe <mikael@lilotux.net>
parents:
1171
diff
changeset
|
3634 } else { |
334ae9f498f1
Add some more iline functions (Lego12239)
Mikael Berthe <mikael@lilotux.net>
parents:
1171
diff
changeset
|
3635 stopsymbol_allowed = 0; |
334ae9f498f1
Add some more iline functions (Lego12239)
Mikael Berthe <mikael@lilotux.net>
parents:
1171
diff
changeset
|
3636 if (upcase) |
1748
51a23403cc80
Fix readline_updowncase_word() and readline_capitalize_word() wrt UTF-8
Mikael Berthe <mikael@lilotux.net>
parents:
1743
diff
changeset
|
3637 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
|
3638 else |
1748
51a23403cc80
Fix readline_updowncase_word() and readline_capitalize_word() wrt UTF-8
Mikael Berthe <mikael@lilotux.net>
parents:
1743
diff
changeset
|
3639 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
|
3640 } |
334ae9f498f1
Add some more iline functions (Lego12239)
Mikael Berthe <mikael@lilotux.net>
parents:
1171
diff
changeset
|
3641 ptr_inputline = next_char(ptr_inputline); |
334ae9f498f1
Add some more iline functions (Lego12239)
Mikael Berthe <mikael@lilotux.net>
parents:
1171
diff
changeset
|
3642 } |
334ae9f498f1
Add some more iline functions (Lego12239)
Mikael Berthe <mikael@lilotux.net>
parents:
1171
diff
changeset
|
3643 |
334ae9f498f1
Add some more iline functions (Lego12239)
Mikael Berthe <mikael@lilotux.net>
parents:
1171
diff
changeset
|
3644 check_offset(1); |
334ae9f498f1
Add some more iline functions (Lego12239)
Mikael Berthe <mikael@lilotux.net>
parents:
1171
diff
changeset
|
3645 } |
334ae9f498f1
Add some more iline functions (Lego12239)
Mikael Berthe <mikael@lilotux.net>
parents:
1171
diff
changeset
|
3646 |
334ae9f498f1
Add some more iline functions (Lego12239)
Mikael Berthe <mikael@lilotux.net>
parents:
1171
diff
changeset
|
3647 void readline_capitalize_word(void) |
334ae9f498f1
Add some more iline functions (Lego12239)
Mikael Berthe <mikael@lilotux.net>
parents:
1171
diff
changeset
|
3648 { |
334ae9f498f1
Add some more iline functions (Lego12239)
Mikael Berthe <mikael@lilotux.net>
parents:
1171
diff
changeset
|
3649 int stopsymbol_allowed = 1; |
334ae9f498f1
Add some more iline functions (Lego12239)
Mikael Berthe <mikael@lilotux.net>
parents:
1171
diff
changeset
|
3650 int upcased = 0; |
334ae9f498f1
Add some more iline functions (Lego12239)
Mikael Berthe <mikael@lilotux.net>
parents:
1171
diff
changeset
|
3651 |
334ae9f498f1
Add some more iline functions (Lego12239)
Mikael Berthe <mikael@lilotux.net>
parents:
1171
diff
changeset
|
3652 while (*ptr_inputline) { |
334ae9f498f1
Add some more iline functions (Lego12239)
Mikael Berthe <mikael@lilotux.net>
parents:
1171
diff
changeset
|
3653 if (!iswalnum(get_char(ptr_inputline))) { |
334ae9f498f1
Add some more iline functions (Lego12239)
Mikael Berthe <mikael@lilotux.net>
parents:
1171
diff
changeset
|
3654 if (!stopsymbol_allowed) break; |
334ae9f498f1
Add some more iline functions (Lego12239)
Mikael Berthe <mikael@lilotux.net>
parents:
1171
diff
changeset
|
3655 } else { |
334ae9f498f1
Add some more iline functions (Lego12239)
Mikael Berthe <mikael@lilotux.net>
parents:
1171
diff
changeset
|
3656 stopsymbol_allowed = 0; |
334ae9f498f1
Add some more iline functions (Lego12239)
Mikael Berthe <mikael@lilotux.net>
parents:
1171
diff
changeset
|
3657 if (!upcased) { |
1748
51a23403cc80
Fix readline_updowncase_word() and readline_capitalize_word() wrt UTF-8
Mikael Berthe <mikael@lilotux.net>
parents:
1743
diff
changeset
|
3658 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
|
3659 upcased = 1; |
1748
51a23403cc80
Fix readline_updowncase_word() and readline_capitalize_word() wrt UTF-8
Mikael Berthe <mikael@lilotux.net>
parents:
1743
diff
changeset
|
3660 } else |
51a23403cc80
Fix readline_updowncase_word() and readline_capitalize_word() wrt UTF-8
Mikael Berthe <mikael@lilotux.net>
parents:
1743
diff
changeset
|
3661 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
|
3662 } |
334ae9f498f1
Add some more iline functions (Lego12239)
Mikael Berthe <mikael@lilotux.net>
parents:
1171
diff
changeset
|
3663 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
|
3664 } |
a681dc477c7f
Add readline_backward_word and readline_forward_word (Ctrl-Left/Ctrl-Right)
Mikael Berthe <mikael@lilotux.net>
parents:
758
diff
changeset
|
3665 |
a681dc477c7f
Add readline_backward_word and readline_forward_word (Ctrl-Left/Ctrl-Right)
Mikael Berthe <mikael@lilotux.net>
parents:
758
diff
changeset
|
3666 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
|
3667 } |
a681dc477c7f
Add readline_backward_word and readline_forward_word (Ctrl-Left/Ctrl-Right)
Mikael Berthe <mikael@lilotux.net>
parents:
758
diff
changeset
|
3668 |
1171
03a38b7ad2e0
Add a collection of commands for key bindings (Lego12239)
Mikael Berthe <mikael@lilotux.net>
parents:
1170
diff
changeset
|
3669 void readline_backward_char(void) |
03a38b7ad2e0
Add a collection of commands for key bindings (Lego12239)
Mikael Berthe <mikael@lilotux.net>
parents:
1170
diff
changeset
|
3670 { |
03a38b7ad2e0
Add a collection of commands for key bindings (Lego12239)
Mikael Berthe <mikael@lilotux.net>
parents:
1170
diff
changeset
|
3671 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
|
3672 |
03a38b7ad2e0
Add a collection of commands for key bindings (Lego12239)
Mikael Berthe <mikael@lilotux.net>
parents:
1170
diff
changeset
|
3673 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
|
3674 check_offset(-1); |
03a38b7ad2e0
Add a collection of commands for key bindings (Lego12239)
Mikael Berthe <mikael@lilotux.net>
parents:
1170
diff
changeset
|
3675 } |
03a38b7ad2e0
Add a collection of commands for key bindings (Lego12239)
Mikael Berthe <mikael@lilotux.net>
parents:
1170
diff
changeset
|
3676 |
03a38b7ad2e0
Add a collection of commands for key bindings (Lego12239)
Mikael Berthe <mikael@lilotux.net>
parents:
1170
diff
changeset
|
3677 void readline_forward_char(void) |
03a38b7ad2e0
Add a collection of commands for key bindings (Lego12239)
Mikael Berthe <mikael@lilotux.net>
parents:
1170
diff
changeset
|
3678 { |
03a38b7ad2e0
Add a collection of commands for key bindings (Lego12239)
Mikael Berthe <mikael@lilotux.net>
parents:
1170
diff
changeset
|
3679 if (!*ptr_inputline) return; |
03a38b7ad2e0
Add a collection of commands for key bindings (Lego12239)
Mikael Berthe <mikael@lilotux.net>
parents:
1170
diff
changeset
|
3680 |
03a38b7ad2e0
Add a collection of commands for key bindings (Lego12239)
Mikael Berthe <mikael@lilotux.net>
parents:
1170
diff
changeset
|
3681 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
|
3682 check_offset(1); |
03a38b7ad2e0
Add a collection of commands for key bindings (Lego12239)
Mikael Berthe <mikael@lilotux.net>
parents:
1170
diff
changeset
|
3683 } |
03a38b7ad2e0
Add a collection of commands for key bindings (Lego12239)
Mikael Berthe <mikael@lilotux.net>
parents:
1170
diff
changeset
|
3684 |
1177
10733d7de004
Refactor readline_accept_line() and readline_accept_line_down_hist()
Mikael Berthe <mikael@lilotux.net>
parents:
1176
diff
changeset
|
3685 // 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
|
3686 // Validate current command line. |
10733d7de004
Refactor readline_accept_line() and readline_accept_line_down_hist()
Mikael Berthe <mikael@lilotux.net>
parents:
1176
diff
changeset
|
3687 // If down_history is true, load the next history line. |
2164 | 3688 void readline_accept_line(int down_history) |
1172
334ae9f498f1
Add some more iline functions (Lego12239)
Mikael Berthe <mikael@lilotux.net>
parents:
1171
diff
changeset
|
3689 { |
1780
e4378fbab5d7
Major API cleanup - bump API to 4
Mikael Berthe <mikael@lilotux.net>
parents:
1761
diff
changeset
|
3690 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
|
3691 last_activity_buddy = current_buddy; |
2164 | 3692 process_line(inputLine); |
1172
334ae9f498f1
Add some more iline functions (Lego12239)
Mikael Berthe <mikael@lilotux.net>
parents:
1171
diff
changeset
|
3693 // Add line to history |
334ae9f498f1
Add some more iline functions (Lego12239)
Mikael Berthe <mikael@lilotux.net>
parents:
1171
diff
changeset
|
3694 scr_cmdhisto_addline(inputLine); |
334ae9f498f1
Add some more iline functions (Lego12239)
Mikael Berthe <mikael@lilotux.net>
parents:
1171
diff
changeset
|
3695 // Reset the line |
334ae9f498f1
Add some more iline functions (Lego12239)
Mikael Berthe <mikael@lilotux.net>
parents:
1171
diff
changeset
|
3696 ptr_inputline = inputLine; |
334ae9f498f1
Add some more iline functions (Lego12239)
Mikael Berthe <mikael@lilotux.net>
parents:
1171
diff
changeset
|
3697 *ptr_inputline = 0; |
334ae9f498f1
Add some more iline functions (Lego12239)
Mikael Berthe <mikael@lilotux.net>
parents:
1171
diff
changeset
|
3698 inputline_offset = 0; |
334ae9f498f1
Add some more iline functions (Lego12239)
Mikael Berthe <mikael@lilotux.net>
parents:
1171
diff
changeset
|
3699 |
1177
10733d7de004
Refactor readline_accept_line() and readline_accept_line_down_hist()
Mikael Berthe <mikael@lilotux.net>
parents:
1176
diff
changeset
|
3700 if (down_history) { |
10733d7de004
Refactor readline_accept_line() and readline_accept_line_down_hist()
Mikael Berthe <mikael@lilotux.net>
parents:
1176
diff
changeset
|
3701 // 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
|
3702 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
|
3703 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
|
3704 // Reset backup history line |
10733d7de004
Refactor readline_accept_line() and readline_accept_line_down_hist()
Mikael Berthe <mikael@lilotux.net>
parents:
1176
diff
changeset
|
3705 cmdhisto_backup[0] = 0; |
10733d7de004
Refactor readline_accept_line() and readline_accept_line_down_hist()
Mikael Berthe <mikael@lilotux.net>
parents:
1176
diff
changeset
|
3706 } else { |
10733d7de004
Refactor readline_accept_line() and readline_accept_line_down_hist()
Mikael Berthe <mikael@lilotux.net>
parents:
1176
diff
changeset
|
3707 // Reset history line pointer |
10733d7de004
Refactor readline_accept_line() and readline_accept_line_down_hist()
Mikael Berthe <mikael@lilotux.net>
parents:
1176
diff
changeset
|
3708 cmdhisto_cur = NULL; |
10733d7de004
Refactor readline_accept_line() and readline_accept_line_down_hist()
Mikael Berthe <mikael@lilotux.net>
parents:
1176
diff
changeset
|
3709 } |
1172
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 |
1985
0870005f7efc
Add command /iline clear_history
Mikael Berthe <mikael@lilotux.net>
parents:
1977
diff
changeset
|
3712 // readline_clear_history() |
0870005f7efc
Add command /iline clear_history
Mikael Berthe <mikael@lilotux.net>
parents:
1977
diff
changeset
|
3713 // Clear command line history. |
0870005f7efc
Add command /iline clear_history
Mikael Berthe <mikael@lilotux.net>
parents:
1977
diff
changeset
|
3714 void readline_clear_history(void) |
0870005f7efc
Add command /iline clear_history
Mikael Berthe <mikael@lilotux.net>
parents:
1977
diff
changeset
|
3715 { |
0870005f7efc
Add command /iline clear_history
Mikael Berthe <mikael@lilotux.net>
parents:
1977
diff
changeset
|
3716 scr_cmdhisto_reset(); |
0870005f7efc
Add command /iline clear_history
Mikael Berthe <mikael@lilotux.net>
parents:
1977
diff
changeset
|
3717 } |
0870005f7efc
Add command /iline clear_history
Mikael Berthe <mikael@lilotux.net>
parents:
1977
diff
changeset
|
3718 |
1172
334ae9f498f1
Add some more iline functions (Lego12239)
Mikael Berthe <mikael@lilotux.net>
parents:
1171
diff
changeset
|
3719 void readline_cancel_completion(void) |
334ae9f498f1
Add some more iline functions (Lego12239)
Mikael Berthe <mikael@lilotux.net>
parents:
1171
diff
changeset
|
3720 { |
334ae9f498f1
Add some more iline functions (Lego12239)
Mikael Berthe <mikael@lilotux.net>
parents:
1171
diff
changeset
|
3721 scr_cancel_current_completion(); |
334ae9f498f1
Add some more iline functions (Lego12239)
Mikael Berthe <mikael@lilotux.net>
parents:
1171
diff
changeset
|
3722 scr_end_current_completion(); |
334ae9f498f1
Add some more iline functions (Lego12239)
Mikael Berthe <mikael@lilotux.net>
parents:
1171
diff
changeset
|
3723 check_offset(-1); |
334ae9f498f1
Add some more iline functions (Lego12239)
Mikael Berthe <mikael@lilotux.net>
parents:
1171
diff
changeset
|
3724 } |
334ae9f498f1
Add some more iline functions (Lego12239)
Mikael Berthe <mikael@lilotux.net>
parents:
1171
diff
changeset
|
3725 |
2143
2f294c2b6778
Add a backward completion (Oleg)
Mikael Berthe <mikael@lilotux.net>
parents:
2136
diff
changeset
|
3726 void readline_do_completion(gboolean fwd) |
1172
334ae9f498f1
Add some more iline functions (Lego12239)
Mikael Berthe <mikael@lilotux.net>
parents:
1171
diff
changeset
|
3727 { |
334ae9f498f1
Add some more iline functions (Lego12239)
Mikael Berthe <mikael@lilotux.net>
parents:
1171
diff
changeset
|
3728 int i, n; |
334ae9f498f1
Add some more iline functions (Lego12239)
Mikael Berthe <mikael@lilotux.net>
parents:
1171
diff
changeset
|
3729 |
1413 | 3730 if (multimode != 2) { |
1172
334ae9f498f1
Add some more iline functions (Lego12239)
Mikael Berthe <mikael@lilotux.net>
parents:
1171
diff
changeset
|
3731 // Not in verbatim multi-line mode |
2143
2f294c2b6778
Add a backward completion (Oleg)
Mikael Berthe <mikael@lilotux.net>
parents:
2136
diff
changeset
|
3732 scr_handle_tab(fwd); |
1172
334ae9f498f1
Add some more iline functions (Lego12239)
Mikael Berthe <mikael@lilotux.net>
parents:
1171
diff
changeset
|
3733 } else { |
334ae9f498f1
Add some more iline functions (Lego12239)
Mikael Berthe <mikael@lilotux.net>
parents:
1171
diff
changeset
|
3734 // Verbatim multi-line mode: expand tab |
334ae9f498f1
Add some more iline functions (Lego12239)
Mikael Berthe <mikael@lilotux.net>
parents:
1171
diff
changeset
|
3735 char tabstr[9]; |
334ae9f498f1
Add some more iline functions (Lego12239)
Mikael Berthe <mikael@lilotux.net>
parents:
1171
diff
changeset
|
3736 n = 8 - (ptr_inputline - inputLine) % 8; |
334ae9f498f1
Add some more iline functions (Lego12239)
Mikael Berthe <mikael@lilotux.net>
parents:
1171
diff
changeset
|
3737 for (i = 0; i < n; i++) |
334ae9f498f1
Add some more iline functions (Lego12239)
Mikael Berthe <mikael@lilotux.net>
parents:
1171
diff
changeset
|
3738 tabstr[i] = ' '; |
334ae9f498f1
Add some more iline functions (Lego12239)
Mikael Berthe <mikael@lilotux.net>
parents:
1171
diff
changeset
|
3739 tabstr[i] = '\0'; |
334ae9f498f1
Add some more iline functions (Lego12239)
Mikael Berthe <mikael@lilotux.net>
parents:
1171
diff
changeset
|
3740 scr_insert_text(tabstr); |
334ae9f498f1
Add some more iline functions (Lego12239)
Mikael Berthe <mikael@lilotux.net>
parents:
1171
diff
changeset
|
3741 } |
334ae9f498f1
Add some more iline functions (Lego12239)
Mikael Berthe <mikael@lilotux.net>
parents:
1171
diff
changeset
|
3742 check_offset(0); |
334ae9f498f1
Add some more iline functions (Lego12239)
Mikael Berthe <mikael@lilotux.net>
parents:
1171
diff
changeset
|
3743 } |
334ae9f498f1
Add some more iline functions (Lego12239)
Mikael Berthe <mikael@lilotux.net>
parents:
1171
diff
changeset
|
3744 |
334ae9f498f1
Add some more iline functions (Lego12239)
Mikael Berthe <mikael@lilotux.net>
parents:
1171
diff
changeset
|
3745 void readline_refresh_screen(void) |
334ae9f498f1
Add some more iline functions (Lego12239)
Mikael Berthe <mikael@lilotux.net>
parents:
1171
diff
changeset
|
3746 { |
1780
e4378fbab5d7
Major API cleanup - bump API to 4
Mikael Berthe <mikael@lilotux.net>
parents:
1761
diff
changeset
|
3747 scr_check_auto_away(TRUE); |
e4378fbab5d7
Major API cleanup - bump API to 4
Mikael Berthe <mikael@lilotux.net>
parents:
1761
diff
changeset
|
3748 parse_colors(); |
1172
334ae9f498f1
Add some more iline functions (Lego12239)
Mikael Berthe <mikael@lilotux.net>
parents:
1171
diff
changeset
|
3749 scr_Resize(); |
334ae9f498f1
Add some more iline functions (Lego12239)
Mikael Berthe <mikael@lilotux.net>
parents:
1171
diff
changeset
|
3750 redrawwin(stdscr); |
334ae9f498f1
Add some more iline functions (Lego12239)
Mikael Berthe <mikael@lilotux.net>
parents:
1171
diff
changeset
|
3751 } |
334ae9f498f1
Add some more iline functions (Lego12239)
Mikael Berthe <mikael@lilotux.net>
parents:
1171
diff
changeset
|
3752 |
1503
c74cfe7fd848
Add option --show-roster to command chat_disable.
Mikael Berthe <mikael@lilotux.net>
parents:
1502
diff
changeset
|
3753 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
|
3754 { |
1780
e4378fbab5d7
Major API cleanup - bump API to 4
Mikael Berthe <mikael@lilotux.net>
parents:
1761
diff
changeset
|
3755 scr_check_auto_away(TRUE); |
1950
aec86670047b
Automatically set readmark flag
Mikael Berthe <mikael@lilotux.net>
parents:
1949
diff
changeset
|
3756 if (chatmode) |
aec86670047b
Automatically set readmark flag
Mikael Berthe <mikael@lilotux.net>
parents:
1949
diff
changeset
|
3757 scr_buffer_readmark(TRUE); |
1172
334ae9f498f1
Add some more iline functions (Lego12239)
Mikael Berthe <mikael@lilotux.net>
parents:
1171
diff
changeset
|
3758 currentWindow = NULL; |
334ae9f498f1
Add some more iline functions (Lego12239)
Mikael Berthe <mikael@lilotux.net>
parents:
1171
diff
changeset
|
3759 chatmode = FALSE; |
334ae9f498f1
Add some more iline functions (Lego12239)
Mikael Berthe <mikael@lilotux.net>
parents:
1171
diff
changeset
|
3760 if (current_buddy) |
334ae9f498f1
Add some more iline functions (Lego12239)
Mikael Berthe <mikael@lilotux.net>
parents:
1171
diff
changeset
|
3761 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
|
3762 if (show_roster) |
1780
e4378fbab5d7
Major API cleanup - bump API to 4
Mikael Berthe <mikael@lilotux.net>
parents:
1761
diff
changeset
|
3763 scr_roster_visibility(1); |
e4378fbab5d7
Major API cleanup - bump API to 4
Mikael Berthe <mikael@lilotux.net>
parents:
1761
diff
changeset
|
3764 scr_update_chat_status(FALSE); |
1172
334ae9f498f1
Add some more iline functions (Lego12239)
Mikael Berthe <mikael@lilotux.net>
parents:
1171
diff
changeset
|
3765 top_panel(chatPanel); |
334ae9f498f1
Add some more iline functions (Lego12239)
Mikael Berthe <mikael@lilotux.net>
parents:
1171
diff
changeset
|
3766 top_panel(inputPanel); |
334ae9f498f1
Add some more iline functions (Lego12239)
Mikael Berthe <mikael@lilotux.net>
parents:
1171
diff
changeset
|
3767 update_panels(); |
334ae9f498f1
Add some more iline functions (Lego12239)
Mikael Berthe <mikael@lilotux.net>
parents:
1171
diff
changeset
|
3768 } |
334ae9f498f1
Add some more iline functions (Lego12239)
Mikael Berthe <mikael@lilotux.net>
parents:
1171
diff
changeset
|
3769 |
1190
be06bbe7e449
Add readline_hist_beginning_search_bwd/fwd functions
Mikael Berthe <mikael@lilotux.net>
parents:
1187
diff
changeset
|
3770 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
|
3771 { |
03a38b7ad2e0
Add a collection of commands for key bindings (Lego12239)
Mikael Berthe <mikael@lilotux.net>
parents:
1170
diff
changeset
|
3772 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
|
3773 if (l) strcpy(inputLine, l); |
03a38b7ad2e0
Add a collection of commands for key bindings (Lego12239)
Mikael Berthe <mikael@lilotux.net>
parents:
1170
diff
changeset
|
3774 } |
03a38b7ad2e0
Add a collection of commands for key bindings (Lego12239)
Mikael Berthe <mikael@lilotux.net>
parents:
1170
diff
changeset
|
3775 |
1190
be06bbe7e449
Add readline_hist_beginning_search_bwd/fwd functions
Mikael Berthe <mikael@lilotux.net>
parents:
1187
diff
changeset
|
3776 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
|
3777 { |
03a38b7ad2e0
Add a collection of commands for key bindings (Lego12239)
Mikael Berthe <mikael@lilotux.net>
parents:
1170
diff
changeset
|
3778 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
|
3779 if (l) strcpy(inputLine, l); |
03a38b7ad2e0
Add a collection of commands for key bindings (Lego12239)
Mikael Berthe <mikael@lilotux.net>
parents:
1170
diff
changeset
|
3780 } |
03a38b7ad2e0
Add a collection of commands for key bindings (Lego12239)
Mikael Berthe <mikael@lilotux.net>
parents:
1170
diff
changeset
|
3781 |
1190
be06bbe7e449
Add readline_hist_beginning_search_bwd/fwd functions
Mikael Berthe <mikael@lilotux.net>
parents:
1187
diff
changeset
|
3782 void readline_hist_prev(void) |
be06bbe7e449
Add readline_hist_beginning_search_bwd/fwd functions
Mikael Berthe <mikael@lilotux.net>
parents:
1187
diff
changeset
|
3783 { |
be06bbe7e449
Add readline_hist_beginning_search_bwd/fwd functions
Mikael Berthe <mikael@lilotux.net>
parents:
1187
diff
changeset
|
3784 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
|
3785 if (l) { |
be06bbe7e449
Add readline_hist_beginning_search_bwd/fwd functions
Mikael Berthe <mikael@lilotux.net>
parents:
1187
diff
changeset
|
3786 strcpy(inputLine, l); |
be06bbe7e449
Add readline_hist_beginning_search_bwd/fwd functions
Mikael Berthe <mikael@lilotux.net>
parents:
1187
diff
changeset
|
3787 // Set the pointer at the EOL. |
be06bbe7e449
Add readline_hist_beginning_search_bwd/fwd functions
Mikael Berthe <mikael@lilotux.net>
parents:
1187
diff
changeset
|
3788 // 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
|
3789 readline_iline_start(); |
be06bbe7e449
Add readline_hist_beginning_search_bwd/fwd functions
Mikael Berthe <mikael@lilotux.net>
parents:
1187
diff
changeset
|
3790 readline_iline_end(); |
be06bbe7e449
Add readline_hist_beginning_search_bwd/fwd functions
Mikael Berthe <mikael@lilotux.net>
parents:
1187
diff
changeset
|
3791 } |
be06bbe7e449
Add readline_hist_beginning_search_bwd/fwd functions
Mikael Berthe <mikael@lilotux.net>
parents:
1187
diff
changeset
|
3792 } |
be06bbe7e449
Add readline_hist_beginning_search_bwd/fwd functions
Mikael Berthe <mikael@lilotux.net>
parents:
1187
diff
changeset
|
3793 |
be06bbe7e449
Add readline_hist_beginning_search_bwd/fwd functions
Mikael Berthe <mikael@lilotux.net>
parents:
1187
diff
changeset
|
3794 void readline_hist_next(void) |
be06bbe7e449
Add readline_hist_beginning_search_bwd/fwd functions
Mikael Berthe <mikael@lilotux.net>
parents:
1187
diff
changeset
|
3795 { |
be06bbe7e449
Add readline_hist_beginning_search_bwd/fwd functions
Mikael Berthe <mikael@lilotux.net>
parents:
1187
diff
changeset
|
3796 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
|
3797 if (l) { |
be06bbe7e449
Add readline_hist_beginning_search_bwd/fwd functions
Mikael Berthe <mikael@lilotux.net>
parents:
1187
diff
changeset
|
3798 strcpy(inputLine, l); |
be06bbe7e449
Add readline_hist_beginning_search_bwd/fwd functions
Mikael Berthe <mikael@lilotux.net>
parents:
1187
diff
changeset
|
3799 // Set the pointer at the EOL. |
be06bbe7e449
Add readline_hist_beginning_search_bwd/fwd functions
Mikael Berthe <mikael@lilotux.net>
parents:
1187
diff
changeset
|
3800 // 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
|
3801 readline_iline_start(); |
be06bbe7e449
Add readline_hist_beginning_search_bwd/fwd functions
Mikael Berthe <mikael@lilotux.net>
parents:
1187
diff
changeset
|
3802 readline_iline_end(); |
be06bbe7e449
Add readline_hist_beginning_search_bwd/fwd functions
Mikael Berthe <mikael@lilotux.net>
parents:
1187
diff
changeset
|
3803 } |
be06bbe7e449
Add readline_hist_beginning_search_bwd/fwd functions
Mikael Berthe <mikael@lilotux.net>
parents:
1187
diff
changeset
|
3804 } |
be06bbe7e449
Add readline_hist_beginning_search_bwd/fwd functions
Mikael Berthe <mikael@lilotux.net>
parents:
1187
diff
changeset
|
3805 |
1171
03a38b7ad2e0
Add a collection of commands for key bindings (Lego12239)
Mikael Berthe <mikael@lilotux.net>
parents:
1170
diff
changeset
|
3806 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
|
3807 { |
03a38b7ad2e0
Add a collection of commands for key bindings (Lego12239)
Mikael Berthe <mikael@lilotux.net>
parents:
1170
diff
changeset
|
3808 char *src, *c; |
03a38b7ad2e0
Add a collection of commands for key bindings (Lego12239)
Mikael Berthe <mikael@lilotux.net>
parents:
1170
diff
changeset
|
3809 |
03a38b7ad2e0
Add a collection of commands for key bindings (Lego12239)
Mikael Berthe <mikael@lilotux.net>
parents:
1170
diff
changeset
|
3810 if (ptr_inputline == (char*)&inputLine) |
03a38b7ad2e0
Add a collection of commands for key bindings (Lego12239)
Mikael Berthe <mikael@lilotux.net>
parents:
1170
diff
changeset
|
3811 return; |
03a38b7ad2e0
Add a collection of commands for key bindings (Lego12239)
Mikael Berthe <mikael@lilotux.net>
parents:
1170
diff
changeset
|
3812 |
03a38b7ad2e0
Add a collection of commands for key bindings (Lego12239)
Mikael Berthe <mikael@lilotux.net>
parents:
1170
diff
changeset
|
3813 src = ptr_inputline; |
03a38b7ad2e0
Add a collection of commands for key bindings (Lego12239)
Mikael Berthe <mikael@lilotux.net>
parents:
1170
diff
changeset
|
3814 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
|
3815 ptr_inputline = c; |
1903
75a0a22bbf78
Fix issue #54 -- command line corruption
Mikael Berthe <mikael@lilotux.net>
parents:
1863
diff
changeset
|
3816 _strmove(ptr_inputline, src); |
1171
03a38b7ad2e0
Add a collection of commands for key bindings (Lego12239)
Mikael Berthe <mikael@lilotux.net>
parents:
1170
diff
changeset
|
3817 check_offset(-1); |
03a38b7ad2e0
Add a collection of commands for key bindings (Lego12239)
Mikael Berthe <mikael@lilotux.net>
parents:
1170
diff
changeset
|
3818 } |
03a38b7ad2e0
Add a collection of commands for key bindings (Lego12239)
Mikael Berthe <mikael@lilotux.net>
parents:
1170
diff
changeset
|
3819 |
03a38b7ad2e0
Add a collection of commands for key bindings (Lego12239)
Mikael Berthe <mikael@lilotux.net>
parents:
1170
diff
changeset
|
3820 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
|
3821 { |
03a38b7ad2e0
Add a collection of commands for key bindings (Lego12239)
Mikael Berthe <mikael@lilotux.net>
parents:
1170
diff
changeset
|
3822 if (!*ptr_inputline) |
03a38b7ad2e0
Add a collection of commands for key bindings (Lego12239)
Mikael Berthe <mikael@lilotux.net>
parents:
1170
diff
changeset
|
3823 return; |
03a38b7ad2e0
Add a collection of commands for key bindings (Lego12239)
Mikael Berthe <mikael@lilotux.net>
parents:
1170
diff
changeset
|
3824 |
1903
75a0a22bbf78
Fix issue #54 -- command line corruption
Mikael Berthe <mikael@lilotux.net>
parents:
1863
diff
changeset
|
3825 _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
|
3826 } |
03a38b7ad2e0
Add a collection of commands for key bindings (Lego12239)
Mikael Berthe <mikael@lilotux.net>
parents:
1170
diff
changeset
|
3827 |
03a38b7ad2e0
Add a collection of commands for key bindings (Lego12239)
Mikael Berthe <mikael@lilotux.net>
parents:
1170
diff
changeset
|
3828 void readline_iline_start(void) |
03a38b7ad2e0
Add a collection of commands for key bindings (Lego12239)
Mikael Berthe <mikael@lilotux.net>
parents:
1170
diff
changeset
|
3829 { |
03a38b7ad2e0
Add a collection of commands for key bindings (Lego12239)
Mikael Berthe <mikael@lilotux.net>
parents:
1170
diff
changeset
|
3830 ptr_inputline = inputLine; |
03a38b7ad2e0
Add a collection of commands for key bindings (Lego12239)
Mikael Berthe <mikael@lilotux.net>
parents:
1170
diff
changeset
|
3831 inputline_offset = 0; |
03a38b7ad2e0
Add a collection of commands for key bindings (Lego12239)
Mikael Berthe <mikael@lilotux.net>
parents:
1170
diff
changeset
|
3832 } |
03a38b7ad2e0
Add a collection of commands for key bindings (Lego12239)
Mikael Berthe <mikael@lilotux.net>
parents:
1170
diff
changeset
|
3833 |
03a38b7ad2e0
Add a collection of commands for key bindings (Lego12239)
Mikael Berthe <mikael@lilotux.net>
parents:
1170
diff
changeset
|
3834 void readline_iline_end(void) |
03a38b7ad2e0
Add a collection of commands for key bindings (Lego12239)
Mikael Berthe <mikael@lilotux.net>
parents:
1170
diff
changeset
|
3835 { |
03a38b7ad2e0
Add a collection of commands for key bindings (Lego12239)
Mikael Berthe <mikael@lilotux.net>
parents:
1170
diff
changeset
|
3836 for (; *ptr_inputline; ptr_inputline++) ; |
03a38b7ad2e0
Add a collection of commands for key bindings (Lego12239)
Mikael Berthe <mikael@lilotux.net>
parents:
1170
diff
changeset
|
3837 check_offset(1); |
03a38b7ad2e0
Add a collection of commands for key bindings (Lego12239)
Mikael Berthe <mikael@lilotux.net>
parents:
1170
diff
changeset
|
3838 } |
03a38b7ad2e0
Add a collection of commands for key bindings (Lego12239)
Mikael Berthe <mikael@lilotux.net>
parents:
1170
diff
changeset
|
3839 |
03a38b7ad2e0
Add a collection of commands for key bindings (Lego12239)
Mikael Berthe <mikael@lilotux.net>
parents:
1170
diff
changeset
|
3840 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
|
3841 { |
1863
2b013c0f949a
readline: Make backward_kill_iline() consistent with backward_kill_word()
Mikael Berthe <mikael@lilotux.net>
parents:
1821
diff
changeset
|
3842 char *dest = inputLine; |
2b013c0f949a
readline: Make backward_kill_iline() consistent with backward_kill_word()
Mikael Berthe <mikael@lilotux.net>
parents:
1821
diff
changeset
|
3843 |
2b013c0f949a
readline: Make backward_kill_iline() consistent with backward_kill_word()
Mikael Berthe <mikael@lilotux.net>
parents:
1821
diff
changeset
|
3844 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
|
3845 |
2b013c0f949a
readline: Make backward_kill_iline() consistent with backward_kill_word()
Mikael Berthe <mikael@lilotux.net>
parents:
1821
diff
changeset
|
3846 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
|
3847 dest = next_char(dest); |
2b013c0f949a
readline: Make backward_kill_iline() consistent with backward_kill_word()
Mikael Berthe <mikael@lilotux.net>
parents:
1821
diff
changeset
|
3848 |
1903
75a0a22bbf78
Fix issue #54 -- command line corruption
Mikael Berthe <mikael@lilotux.net>
parents:
1863
diff
changeset
|
3849 _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
|
3850 ptr_inputline = dest; |
1171
03a38b7ad2e0
Add a collection of commands for key bindings (Lego12239)
Mikael Berthe <mikael@lilotux.net>
parents:
1170
diff
changeset
|
3851 inputline_offset = 0; |
03a38b7ad2e0
Add a collection of commands for key bindings (Lego12239)
Mikael Berthe <mikael@lilotux.net>
parents:
1170
diff
changeset
|
3852 } |
03a38b7ad2e0
Add a collection of commands for key bindings (Lego12239)
Mikael Berthe <mikael@lilotux.net>
parents:
1170
diff
changeset
|
3853 |
03a38b7ad2e0
Add a collection of commands for key bindings (Lego12239)
Mikael Berthe <mikael@lilotux.net>
parents:
1170
diff
changeset
|
3854 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
|
3855 { |
03a38b7ad2e0
Add a collection of commands for key bindings (Lego12239)
Mikael Berthe <mikael@lilotux.net>
parents:
1170
diff
changeset
|
3856 *ptr_inputline = 0; |
03a38b7ad2e0
Add a collection of commands for key bindings (Lego12239)
Mikael Berthe <mikael@lilotux.net>
parents:
1170
diff
changeset
|
3857 } |
03a38b7ad2e0
Add a collection of commands for key bindings (Lego12239)
Mikael Berthe <mikael@lilotux.net>
parents:
1170
diff
changeset
|
3858 |
03a38b7ad2e0
Add a collection of commands for key bindings (Lego12239)
Mikael Berthe <mikael@lilotux.net>
parents:
1170
diff
changeset
|
3859 void readline_send_multiline(void) |
03a38b7ad2e0
Add a collection of commands for key bindings (Lego12239)
Mikael Berthe <mikael@lilotux.net>
parents:
1170
diff
changeset
|
3860 { |
03a38b7ad2e0
Add a collection of commands for key bindings (Lego12239)
Mikael Berthe <mikael@lilotux.net>
parents:
1170
diff
changeset
|
3861 // Validate current multi-line |
1413 | 3862 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
|
3863 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
|
3864 } |
03a38b7ad2e0
Add a collection of commands for key bindings (Lego12239)
Mikael Berthe <mikael@lilotux.net>
parents:
1170
diff
changeset
|
3865 |
1945
518740bcd78b
Add /iline iline_insert (Hermitifier)
Mikael Berthe <mikael@lilotux.net>
parents:
1942
diff
changeset
|
3866 void readline_insert(const char *toinsert) |
518740bcd78b
Add /iline iline_insert (Hermitifier)
Mikael Berthe <mikael@lilotux.net>
parents:
1942
diff
changeset
|
3867 { |
518740bcd78b
Add /iline iline_insert (Hermitifier)
Mikael Berthe <mikael@lilotux.net>
parents:
1942
diff
changeset
|
3868 if (!toinsert || !*toinsert) return; |
518740bcd78b
Add /iline iline_insert (Hermitifier)
Mikael Berthe <mikael@lilotux.net>
parents:
1942
diff
changeset
|
3869 |
518740bcd78b
Add /iline iline_insert (Hermitifier)
Mikael Berthe <mikael@lilotux.net>
parents:
1942
diff
changeset
|
3870 scr_insert_text(toinsert); |
518740bcd78b
Add /iline iline_insert (Hermitifier)
Mikael Berthe <mikael@lilotux.net>
parents:
1942
diff
changeset
|
3871 check_offset(0); |
518740bcd78b
Add /iline iline_insert (Hermitifier)
Mikael Berthe <mikael@lilotux.net>
parents:
1942
diff
changeset
|
3872 } |
518740bcd78b
Add /iline iline_insert (Hermitifier)
Mikael Berthe <mikael@lilotux.net>
parents:
1942
diff
changeset
|
3873 |
98 | 3874 // which_row() |
3875 // 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
|
3876 // -2 -> normal text |
ddec224c2318
MUC: nickname completion
Mikael Berthe <mikael@lilotux.net>
parents:
499
diff
changeset
|
3877 // -1 -> room: nickname completion |
98 | 3878 // 0 -> command |
3879 // 1 -> parameter 1 (etc.) | |
102 | 3880 // 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
|
3881 static int which_row(const char **p_row) |
98 | 3882 { |
3883 int row = -1; | |
3884 char *p; | |
3885 int quote = FALSE; | |
3886 | |
3887 // Not a command? | |
967 | 3888 if ((ptr_inputline == inputLine) || (inputLine[0] != COMMAND_CHAR)) { |
503
ddec224c2318
MUC: nickname completion
Mikael Berthe <mikael@lilotux.net>
parents:
499
diff
changeset
|
3889 if (!current_buddy) return -2; |
ddec224c2318
MUC: nickname completion
Mikael Berthe <mikael@lilotux.net>
parents:
499
diff
changeset
|
3890 if (buddy_gettype(BUDDATA(current_buddy)) == ROSTER_TYPE_ROOM) { |
ddec224c2318
MUC: nickname completion
Mikael Berthe <mikael@lilotux.net>
parents:
499
diff
changeset
|
3891 *p_row = inputLine; |
ddec224c2318
MUC: nickname completion
Mikael Berthe <mikael@lilotux.net>
parents:
499
diff
changeset
|
3892 return -1; |
ddec224c2318
MUC: nickname completion
Mikael Berthe <mikael@lilotux.net>
parents:
499
diff
changeset
|
3893 } |
ddec224c2318
MUC: nickname completion
Mikael Berthe <mikael@lilotux.net>
parents:
499
diff
changeset
|
3894 return -2; |
ddec224c2318
MUC: nickname completion
Mikael Berthe <mikael@lilotux.net>
parents:
499
diff
changeset
|
3895 } |
98 | 3896 |
3897 // This is a command | |
3898 row = 0; | |
930
a75f7a13df7b
UTF-8 terminal support (Reimar Döffinger)
Mikael Berthe <mikael@lilotux.net>
parents:
929
diff
changeset
|
3899 for (p = inputLine ; p < ptr_inputline ; p = next_char(p)) { |
98 | 3900 if (quote) { |
3901 if (*p == '"' && *(p-1) != '\\') | |
3902 quote = FALSE; | |
3903 continue; | |
3904 } | |
3905 if (*p == '"' && *(p-1) != '\\') { | |
3906 quote = TRUE; | |
121 | 3907 } else if (*p == ' ') { |
3908 if (*(p-1) != ' ') | |
3909 row++; | |
102 | 3910 *p_row = p+1; |
3911 } | |
98 | 3912 } |
3913 return row; | |
3914 } | |
3915 | |
143 | 3916 // scr_insert_text() |
3917 // Insert the given text at the current cursor position. | |
3918 // The cursor is moved. We don't check if the cursor still is in the screen | |
3919 // after, the caller should do that. | |
336
eb994ee40029
Make some functions static
Mikael Berthe <mikael@lilotux.net>
parents:
332
diff
changeset
|
3920 static void scr_insert_text(const char *text) |
98 | 3921 { |
3922 char tmpLine[INPUTLINE_LENGTH+1]; | |
3923 int len = strlen(text); | |
3924 // Check the line isn't too long | |
3925 if (strlen(inputLine) + len >= INPUTLINE_LENGTH) { | |
374
bd5638c21834
Improve logging system (traces)
Mikael Berthe <mikael@lilotux.net>
parents:
373
diff
changeset
|
3926 scr_LogPrint(LPRINT_LOGNORM, "Cannot insert text, line too long."); |
98 | 3927 return; |
3928 } | |
3929 | |
3930 strcpy(tmpLine, ptr_inputline); | |
419 | 3931 strcpy(ptr_inputline, text); |
3932 ptr_inputline += len; | |
98 | 3933 strcpy(ptr_inputline, tmpLine); |
3934 } | |
3935 | |
930
a75f7a13df7b
UTF-8 terminal support (Reimar Döffinger)
Mikael Berthe <mikael@lilotux.net>
parents:
929
diff
changeset
|
3936 static void scr_cancel_current_completion(void); |
a75f7a13df7b
UTF-8 terminal support (Reimar Döffinger)
Mikael Berthe <mikael@lilotux.net>
parents:
929
diff
changeset
|
3937 |
143 | 3938 // scr_handle_tab() |
3939 // Function called when tab is pressed. | |
3940 // Initiate or continue a completion... | |
2143
2f294c2b6778
Add a backward completion (Oleg)
Mikael Berthe <mikael@lilotux.net>
parents:
2136
diff
changeset
|
3941 // If fwd is false, a backward-completion is requested. |
2f294c2b6778
Add a backward completion (Oleg)
Mikael Berthe <mikael@lilotux.net>
parents:
2136
diff
changeset
|
3942 static void scr_handle_tab(gboolean fwd) |
98 | 3943 { |
102 | 3944 int nrow; |
503
ddec224c2318
MUC: nickname completion
Mikael Berthe <mikael@lilotux.net>
parents:
499
diff
changeset
|
3945 const char *row; |
102 | 3946 const char *cchar; |
103 | 3947 guint compl_categ; |
98 | 3948 |
740 | 3949 row = inputLine; // (Kills a GCC warning) |
102 | 3950 nrow = which_row(&row); |
98 | 3951 |
503
ddec224c2318
MUC: nickname completion
Mikael Berthe <mikael@lilotux.net>
parents:
499
diff
changeset
|
3952 // a) No completion if no leading slash ('cause not a command), |
ddec224c2318
MUC: nickname completion
Mikael Berthe <mikael@lilotux.net>
parents:
499
diff
changeset
|
3953 // unless this is a room (then, it is a nickname completion) |
103 | 3954 // 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
|
3955 if ((nrow == -2) || (nrow == 3 && !completion_started) || nrow > 3) |
ddec224c2318
MUC: nickname completion
Mikael Berthe <mikael@lilotux.net>
parents:
499
diff
changeset
|
3956 return; |
102 | 3957 |
503
ddec224c2318
MUC: nickname completion
Mikael Berthe <mikael@lilotux.net>
parents:
499
diff
changeset
|
3958 if (nrow == 0) { // Command completion |
930
a75f7a13df7b
UTF-8 terminal support (Reimar Döffinger)
Mikael Berthe <mikael@lilotux.net>
parents:
929
diff
changeset
|
3959 row = next_char(inputLine); |
103 | 3960 compl_categ = COMPL_CMD; |
503
ddec224c2318
MUC: nickname completion
Mikael Berthe <mikael@lilotux.net>
parents:
499
diff
changeset
|
3961 } else if (nrow == -1) { // Nickname completion |
ddec224c2318
MUC: nickname completion
Mikael Berthe <mikael@lilotux.net>
parents:
499
diff
changeset
|
3962 compl_categ = COMPL_RESOURCE; |
ddec224c2318
MUC: nickname completion
Mikael Berthe <mikael@lilotux.net>
parents:
499
diff
changeset
|
3963 } else { // Other completion, depending on the command |
285 | 3964 int alias = FALSE; |
3965 cmd *com; | |
3966 char *xpline = expandalias(inputLine); | |
3967 com = cmd_get(xpline); | |
3968 if (xpline != inputLine) { | |
3969 // This is an alias, so we can't complete rows > 0 | |
3970 alias = TRUE; | |
3971 g_free(xpline); | |
3972 } | |
3973 if ((!com && (!alias || !completion_started)) || !row) { | |
374
bd5638c21834
Improve logging system (traces)
Mikael Berthe <mikael@lilotux.net>
parents:
373
diff
changeset
|
3974 scr_LogPrint(LPRINT_NORMAL, "I cannot complete that..."); |
103 | 3975 return; |
3976 } | |
285 | 3977 if (!alias) |
3978 compl_categ = com->completion_flags[nrow-1]; | |
3979 else | |
3980 compl_categ = 0; | |
103 | 3981 } |
3982 | |
3983 if (!completion_started) { | |
1076
b9698c89f46d
Fix memory leak in scr_handle_tab()
Mikael Berthe <mikael@lilotux.net>
parents:
1075
diff
changeset
|
3984 guint dynlist; |
1927
3e3e73bb43f5
Do not call compl_get_category_list() needlessly
Mikael Berthe <mikael@lilotux.net>
parents:
1918
diff
changeset
|
3985 GSList *list; |
3e3e73bb43f5
Do not call compl_get_category_list() needlessly
Mikael Berthe <mikael@lilotux.net>
parents:
1918
diff
changeset
|
3986 |
3e3e73bb43f5
Do not call compl_get_category_list() needlessly
Mikael Berthe <mikael@lilotux.net>
parents:
1918
diff
changeset
|
3987 if (!compl_categ) |
3e3e73bb43f5
Do not call compl_get_category_list() needlessly
Mikael Berthe <mikael@lilotux.net>
parents:
1918
diff
changeset
|
3988 return; // Nothing to complete |
3e3e73bb43f5
Do not call compl_get_category_list() needlessly
Mikael Berthe <mikael@lilotux.net>
parents:
1918
diff
changeset
|
3989 |
3e3e73bb43f5
Do not call compl_get_category_list() needlessly
Mikael Berthe <mikael@lilotux.net>
parents:
1918
diff
changeset
|
3990 list = compl_get_category_list(compl_categ, &dynlist); |
103 | 3991 if (list) { |
1228
9a68fe4515dc
Improve MUC nickname completion
Mikael Berthe <mikael@lilotux.net>
parents:
1227
diff
changeset
|
3992 guint n; |
103 | 3993 char *prefix = g_strndup(row, ptr_inputline-row); |
3994 // Init completion | |
1756
e2c084204583
Add (optional) suffix after nick completion in Multi-User Chats
Mikael Berthe <mikael@lilotux.net>
parents:
1748
diff
changeset
|
3995 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
|
3996 (compl_categ == COMPL_RESOURCE ? |
1793
c3ddb52f1055
Rename completion_muc_suffix to muc_completion_suffix
Myhailo Danylenko <isbear@ukrpost.net>
parents:
1791
diff
changeset
|
3997 settings_opt_get("muc_completion_suffix") : NULL)); |
103 | 3998 g_free(prefix); |
1228
9a68fe4515dc
Improve MUC nickname completion
Mikael Berthe <mikael@lilotux.net>
parents:
1227
diff
changeset
|
3999 if (n == 0 && nrow == -1) { |
9a68fe4515dc
Improve MUC nickname completion
Mikael Berthe <mikael@lilotux.net>
parents:
1227
diff
changeset
|
4000 // 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
|
4001 // 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
|
4002 row = prev_char(ptr_inputline, inputLine); |
9a68fe4515dc
Improve MUC nickname completion
Mikael Berthe <mikael@lilotux.net>
parents:
1227
diff
changeset
|
4003 while (row >= inputLine) { |
1239
eb9fc5d6d085
MUC: Nickname completion starts from any non-space character
Mikael Berthe <mikael@lilotux.net>
parents:
1229
diff
changeset
|
4004 if (iswspace(get_char(row)) || get_char(row) == '(') { |
1228
9a68fe4515dc
Improve MUC nickname completion
Mikael Berthe <mikael@lilotux.net>
parents:
1227
diff
changeset
|
4005 row = next_char((char*)row); |
9a68fe4515dc
Improve MUC nickname completion
Mikael Berthe <mikael@lilotux.net>
parents:
1227
diff
changeset
|
4006 break; |
9a68fe4515dc
Improve MUC nickname completion
Mikael Berthe <mikael@lilotux.net>
parents:
1227
diff
changeset
|
4007 } |
9a68fe4515dc
Improve MUC nickname completion
Mikael Berthe <mikael@lilotux.net>
parents:
1227
diff
changeset
|
4008 if (row == inputLine) |
9a68fe4515dc
Improve MUC nickname completion
Mikael Berthe <mikael@lilotux.net>
parents:
1227
diff
changeset
|
4009 break; |
9a68fe4515dc
Improve MUC nickname completion
Mikael Berthe <mikael@lilotux.net>
parents:
1227
diff
changeset
|
4010 row = prev_char((char*)row, inputLine); |
9a68fe4515dc
Improve MUC nickname completion
Mikael Berthe <mikael@lilotux.net>
parents:
1227
diff
changeset
|
4011 } |
9a68fe4515dc
Improve MUC nickname completion
Mikael Berthe <mikael@lilotux.net>
parents:
1227
diff
changeset
|
4012 // There's no need to try again if row == inputLine |
9a68fe4515dc
Improve MUC nickname completion
Mikael Berthe <mikael@lilotux.net>
parents:
1227
diff
changeset
|
4013 if (row > inputLine) { |
9a68fe4515dc
Improve MUC nickname completion
Mikael Berthe <mikael@lilotux.net>
parents:
1227
diff
changeset
|
4014 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
|
4015 new_completion(prefix, list, NULL); |
1228
9a68fe4515dc
Improve MUC nickname completion
Mikael Berthe <mikael@lilotux.net>
parents:
1227
diff
changeset
|
4016 g_free(prefix); |
9a68fe4515dc
Improve MUC nickname completion
Mikael Berthe <mikael@lilotux.net>
parents:
1227
diff
changeset
|
4017 } |
9a68fe4515dc
Improve MUC nickname completion
Mikael Berthe <mikael@lilotux.net>
parents:
1227
diff
changeset
|
4018 } |
1076
b9698c89f46d
Fix memory leak in scr_handle_tab()
Mikael Berthe <mikael@lilotux.net>
parents:
1075
diff
changeset
|
4019 // 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
|
4020 if (dynlist) { |
b9698c89f46d
Fix memory leak in scr_handle_tab()
Mikael Berthe <mikael@lilotux.net>
parents:
1075
diff
changeset
|
4021 GSList *slp; |
b9698c89f46d
Fix memory leak in scr_handle_tab()
Mikael Berthe <mikael@lilotux.net>
parents:
1075
diff
changeset
|
4022 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
|
4023 g_free(slp->data); |
b9698c89f46d
Fix memory leak in scr_handle_tab()
Mikael Berthe <mikael@lilotux.net>
parents:
1075
diff
changeset
|
4024 g_slist_free(list); |
b9698c89f46d
Fix memory leak in scr_handle_tab()
Mikael Berthe <mikael@lilotux.net>
parents:
1075
diff
changeset
|
4025 } |
103 | 4026 // Now complete |
2143
2f294c2b6778
Add a backward completion (Oleg)
Mikael Berthe <mikael@lilotux.net>
parents:
2136
diff
changeset
|
4027 cchar = complete(fwd); |
98 | 4028 if (cchar) |
4029 scr_insert_text(cchar); | |
103 | 4030 completion_started = TRUE; |
98 | 4031 } |
103 | 4032 } else { // Completion already initialized |
930
a75f7a13df7b
UTF-8 terminal support (Reimar Döffinger)
Mikael Berthe <mikael@lilotux.net>
parents:
929
diff
changeset
|
4033 scr_cancel_current_completion(); |
103 | 4034 // Now complete again |
2143
2f294c2b6778
Add a backward completion (Oleg)
Mikael Berthe <mikael@lilotux.net>
parents:
2136
diff
changeset
|
4035 cchar = complete(fwd); |
103 | 4036 if (cchar) |
4037 scr_insert_text(cchar); | |
102 | 4038 } |
98 | 4039 } |
4040 | |
336
eb994ee40029
Make some functions static
Mikael Berthe <mikael@lilotux.net>
parents:
332
diff
changeset
|
4041 static void scr_cancel_current_completion(void) |
98 | 4042 { |
4043 char *c; | |
930
a75f7a13df7b
UTF-8 terminal support (Reimar Döffinger)
Mikael Berthe <mikael@lilotux.net>
parents:
929
diff
changeset
|
4044 char *src = ptr_inputline; |
98 | 4045 guint back = cancel_completion(); |
930
a75f7a13df7b
UTF-8 terminal support (Reimar Döffinger)
Mikael Berthe <mikael@lilotux.net>
parents:
929
diff
changeset
|
4046 guint i; |
98 | 4047 // Remove $back chars |
930
a75f7a13df7b
UTF-8 terminal support (Reimar Döffinger)
Mikael Berthe <mikael@lilotux.net>
parents:
929
diff
changeset
|
4048 for (i = 0; i < back; i++) |
a75f7a13df7b
UTF-8 terminal support (Reimar Döffinger)
Mikael Berthe <mikael@lilotux.net>
parents:
929
diff
changeset
|
4049 ptr_inputline = prev_char(ptr_inputline, inputLine); |
98 | 4050 c = ptr_inputline; |
930
a75f7a13df7b
UTF-8 terminal support (Reimar Döffinger)
Mikael Berthe <mikael@lilotux.net>
parents:
929
diff
changeset
|
4051 for ( ; *src ; ) |
a75f7a13df7b
UTF-8 terminal support (Reimar Döffinger)
Mikael Berthe <mikael@lilotux.net>
parents:
929
diff
changeset
|
4052 *c++ = *src++; |
a75f7a13df7b
UTF-8 terminal support (Reimar Döffinger)
Mikael Berthe <mikael@lilotux.net>
parents:
929
diff
changeset
|
4053 *c = 0; |
98 | 4054 } |
4055 | |
336
eb994ee40029
Make some functions static
Mikael Berthe <mikael@lilotux.net>
parents:
332
diff
changeset
|
4056 static void scr_end_current_completion(void) |
98 | 4057 { |
4058 done_completion(); | |
4059 completion_started = FALSE; | |
4060 } | |
4061 | |
24 | 4062 // check_offset(int direction) |
4063 // Check inputline_offset value, and make sure the cursor is inside the | |
4064 // screen. | |
336
eb994ee40029
Make some functions static
Mikael Berthe <mikael@lilotux.net>
parents:
332
diff
changeset
|
4065 static inline void check_offset(int direction) |
24 | 4066 { |
930
a75f7a13df7b
UTF-8 terminal support (Reimar Döffinger)
Mikael Berthe <mikael@lilotux.net>
parents:
929
diff
changeset
|
4067 int i; |
a75f7a13df7b
UTF-8 terminal support (Reimar Döffinger)
Mikael Berthe <mikael@lilotux.net>
parents:
929
diff
changeset
|
4068 char *c = &inputLine[inputline_offset]; |
24 | 4069 // Left side |
4070 if (inputline_offset && direction <= 0) { | |
930
a75f7a13df7b
UTF-8 terminal support (Reimar Döffinger)
Mikael Berthe <mikael@lilotux.net>
parents:
929
diff
changeset
|
4071 while (ptr_inputline <= c) { |
a75f7a13df7b
UTF-8 terminal support (Reimar Döffinger)
Mikael Berthe <mikael@lilotux.net>
parents:
929
diff
changeset
|
4072 for (i = 0; i < 5; i++) |
a75f7a13df7b
UTF-8 terminal support (Reimar Döffinger)
Mikael Berthe <mikael@lilotux.net>
parents:
929
diff
changeset
|
4073 c = prev_char(c, inputLine); |
a75f7a13df7b
UTF-8 terminal support (Reimar Döffinger)
Mikael Berthe <mikael@lilotux.net>
parents:
929
diff
changeset
|
4074 if (c == inputLine) |
828
319fc55b9a2b
Fix a bug in check_offset()
Mikael Berthe <mikael@lilotux.net>
parents:
827
diff
changeset
|
4075 break; |
24 | 4076 } |
4077 } | |
4078 // Right side | |
4079 if (direction >= 0) { | |
932
fc6aaa223650
Fix a few problems with non-UTF-8 locales
Mikael Berthe <mikael@lilotux.net>
parents:
931
diff
changeset
|
4080 int delta = get_char_width(c); |
930
a75f7a13df7b
UTF-8 terminal support (Reimar Döffinger)
Mikael Berthe <mikael@lilotux.net>
parents:
929
diff
changeset
|
4081 while (ptr_inputline > c) { |
a75f7a13df7b
UTF-8 terminal support (Reimar Döffinger)
Mikael Berthe <mikael@lilotux.net>
parents:
929
diff
changeset
|
4082 c = next_char(c); |
932
fc6aaa223650
Fix a few problems with non-UTF-8 locales
Mikael Berthe <mikael@lilotux.net>
parents:
931
diff
changeset
|
4083 delta += get_char_width(c); |
930
a75f7a13df7b
UTF-8 terminal support (Reimar Döffinger)
Mikael Berthe <mikael@lilotux.net>
parents:
929
diff
changeset
|
4084 } |
a75f7a13df7b
UTF-8 terminal support (Reimar Döffinger)
Mikael Berthe <mikael@lilotux.net>
parents:
929
diff
changeset
|
4085 c = &inputLine[inputline_offset]; |
a75f7a13df7b
UTF-8 terminal support (Reimar Döffinger)
Mikael Berthe <mikael@lilotux.net>
parents:
929
diff
changeset
|
4086 while (delta >= maxX) { |
a75f7a13df7b
UTF-8 terminal support (Reimar Döffinger)
Mikael Berthe <mikael@lilotux.net>
parents:
929
diff
changeset
|
4087 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
|
4088 delta -= get_char_width(c); |
930
a75f7a13df7b
UTF-8 terminal support (Reimar Döffinger)
Mikael Berthe <mikael@lilotux.net>
parents:
929
diff
changeset
|
4089 c = next_char(c); |
a75f7a13df7b
UTF-8 terminal support (Reimar Döffinger)
Mikael Berthe <mikael@lilotux.net>
parents:
929
diff
changeset
|
4090 } |
a75f7a13df7b
UTF-8 terminal support (Reimar Döffinger)
Mikael Berthe <mikael@lilotux.net>
parents:
929
diff
changeset
|
4091 } |
24 | 4092 } |
930
a75f7a13df7b
UTF-8 terminal support (Reimar Döffinger)
Mikael Berthe <mikael@lilotux.net>
parents:
929
diff
changeset
|
4093 inputline_offset = c - inputLine; |
24 | 4094 } |
4095 | |
1590
8d1bcc83ae32
Add support for spellchecking with Enchant (caolan)
Mikael Berthe <mikael@lilotux.net>
parents:
1579
diff
changeset
|
4096 #if defined(WITH_ENCHANT) || defined(WITH_ASPELL) |
1179 | 4097 // prints inputLine with underlined words when misspelled |
4098 static inline void print_checked_line(void) | |
4099 { | |
4100 char *wprint_char_fmt = "%c"; | |
4101 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
|
4102 int nrchar = maxX; |
1179 | 4103 char *ptrCur = inputLine + inputline_offset; |
4104 | |
4105 #ifdef UNICODE | |
4106 // We need this to display a single UTF-8 char... Any better solution? | |
4107 if (utf8_mode) | |
4108 wprint_char_fmt = "%lc"; | |
4109 #endif | |
4110 | |
4111 wmove(inputWnd, 0, 0); // problem with backspace | |
4112 | |
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
|
4113 while (*ptrCur && nrchar-- > 0) { |
1179 | 4114 point = ptrCur - inputLine; |
4115 if (maskLine[point]) | |
4116 wattrset(inputWnd, A_UNDERLINE); | |
4117 wprintw(inputWnd, wprint_char_fmt, get_char(ptrCur)); | |
4118 wattrset(inputWnd, A_NORMAL); | |
4119 ptrCur = next_char(ptrCur); | |
4120 } | |
4121 } | |
4122 #endif | |
4123 | |
336
eb994ee40029
Make some functions static
Mikael Berthe <mikael@lilotux.net>
parents:
332
diff
changeset
|
4124 static inline void refresh_inputline(void) |
312
f0b7ff2df7e8
Ctrl-C does not terminate mcabber
Mikael Berthe <mikael@lilotux.net>
parents:
307
diff
changeset
|
4125 { |
1590
8d1bcc83ae32
Add support for spellchecking with Enchant (caolan)
Mikael Berthe <mikael@lilotux.net>
parents:
1579
diff
changeset
|
4126 #if defined(WITH_ENCHANT) || defined(WITH_ASPELL) |
8d1bcc83ae32
Add support for spellchecking with Enchant (caolan)
Mikael Berthe <mikael@lilotux.net>
parents:
1579
diff
changeset
|
4127 if (settings_opt_get_int("spell_enable")) { |
1179 | 4128 memset(maskLine, 0, INPUTLINE_LENGTH+1); |
4129 spellcheck(inputLine, maskLine); | |
4130 } | |
4131 print_checked_line(); | |
312
f0b7ff2df7e8
Ctrl-C does not terminate mcabber
Mikael Berthe <mikael@lilotux.net>
parents:
307
diff
changeset
|
4132 wclrtoeol(inputWnd); |
930
a75f7a13df7b
UTF-8 terminal support (Reimar Döffinger)
Mikael Berthe <mikael@lilotux.net>
parents:
929
diff
changeset
|
4133 if (*ptr_inputline) { |
a75f7a13df7b
UTF-8 terminal support (Reimar Döffinger)
Mikael Berthe <mikael@lilotux.net>
parents:
929
diff
changeset
|
4134 // 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
|
4135 // so I know of no better way. |
a75f7a13df7b
UTF-8 terminal support (Reimar Döffinger)
Mikael Berthe <mikael@lilotux.net>
parents:
929
diff
changeset
|
4136 char c = *ptr_inputline; |
a75f7a13df7b
UTF-8 terminal support (Reimar Döffinger)
Mikael Berthe <mikael@lilotux.net>
parents:
929
diff
changeset
|
4137 *ptr_inputline = 0; |
1179 | 4138 print_checked_line(); |
930
a75f7a13df7b
UTF-8 terminal support (Reimar Döffinger)
Mikael Berthe <mikael@lilotux.net>
parents:
929
diff
changeset
|
4139 *ptr_inputline = c; |
a75f7a13df7b
UTF-8 terminal support (Reimar Döffinger)
Mikael Berthe <mikael@lilotux.net>
parents:
929
diff
changeset
|
4140 } |
1179 | 4141 #else |
4142 mvwprintw(inputWnd, 0, 0, "%s", inputLine + inputline_offset); | |
4143 wclrtoeol(inputWnd); | |
4144 if (*ptr_inputline) { | |
4145 // hack to set cursor pos. Characters can have different width, | |
4146 // so I know of no better way. | |
4147 char c = *ptr_inputline; | |
4148 *ptr_inputline = 0; | |
4149 mvwprintw(inputWnd, 0, 0, "%s", inputLine + inputline_offset); | |
4150 *ptr_inputline = c; | |
4151 } | |
4152 #endif | |
312
f0b7ff2df7e8
Ctrl-C does not terminate mcabber
Mikael Berthe <mikael@lilotux.net>
parents:
307
diff
changeset
|
4153 } |
f0b7ff2df7e8
Ctrl-C does not terminate mcabber
Mikael Berthe <mikael@lilotux.net>
parents:
307
diff
changeset
|
4154 |
389
6e895f397474
Ncurses changes + Ctrl-C does not send a signal anylore
Mikael Berthe <mikael@lilotux.net>
parents:
388
diff
changeset
|
4155 void scr_handle_CtrlC(void) |
312
f0b7ff2df7e8
Ctrl-C does not terminate mcabber
Mikael Berthe <mikael@lilotux.net>
parents:
307
diff
changeset
|
4156 { |
365
ddb6593bedc9
Fix segfault when mcabber receives an INT signal (Ctrl-C) early
Mikael Berthe <mikael@lilotux.net>
parents:
364
diff
changeset
|
4157 if (!Curses) return; |
315
65aa05520556
First Ctrl-C now also leaves multi-line message mode
Mikael Berthe <mikael@lilotux.net>
parents:
314
diff
changeset
|
4158 // 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
|
4159 process_command(mkcmdstr("msay abort"), TRUE); |
312
f0b7ff2df7e8
Ctrl-C does not terminate mcabber
Mikael Berthe <mikael@lilotux.net>
parents:
307
diff
changeset
|
4160 // Same as Ctrl-g, now |
f0b7ff2df7e8
Ctrl-C does not terminate mcabber
Mikael Berthe <mikael@lilotux.net>
parents:
307
diff
changeset
|
4161 scr_cancel_current_completion(); |
f0b7ff2df7e8
Ctrl-C does not terminate mcabber
Mikael Berthe <mikael@lilotux.net>
parents:
307
diff
changeset
|
4162 scr_end_current_completion(); |
f0b7ff2df7e8
Ctrl-C does not terminate mcabber
Mikael Berthe <mikael@lilotux.net>
parents:
307
diff
changeset
|
4163 check_offset(-1); |
f0b7ff2df7e8
Ctrl-C does not terminate mcabber
Mikael Berthe <mikael@lilotux.net>
parents:
307
diff
changeset
|
4164 refresh_inputline(); |
f0b7ff2df7e8
Ctrl-C does not terminate mcabber
Mikael Berthe <mikael@lilotux.net>
parents:
307
diff
changeset
|
4165 } |
f0b7ff2df7e8
Ctrl-C does not terminate mcabber
Mikael Berthe <mikael@lilotux.net>
parents:
307
diff
changeset
|
4166 |
761
4532a9fe0e8c
Handle some keyboard escape sequences
Mikael Berthe <mikael@lilotux.net>
parents:
760
diff
changeset
|
4167 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
|
4168 { |
4532a9fe0e8c
Handle some keyboard escape sequences
Mikael Berthe <mikael@lilotux.net>
parents:
760
diff
changeset
|
4169 keyseq *ks; |
4532a9fe0e8c
Handle some keyboard escape sequences
Mikael Berthe <mikael@lilotux.net>
parents:
760
diff
changeset
|
4170 |
4532a9fe0e8c
Handle some keyboard escape sequences
Mikael Berthe <mikael@lilotux.net>
parents:
760
diff
changeset
|
4171 // Let's make sure the length is correct |
4532a9fe0e8c
Handle some keyboard escape sequences
Mikael Berthe <mikael@lilotux.net>
parents:
760
diff
changeset
|
4172 if (strlen(seqstr) > MAX_KEYSEQ_LENGTH) { |
4532a9fe0e8c
Handle some keyboard escape sequences
Mikael Berthe <mikael@lilotux.net>
parents:
760
diff
changeset
|
4173 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
|
4174 return; |
4532a9fe0e8c
Handle some keyboard escape sequences
Mikael Berthe <mikael@lilotux.net>
parents:
760
diff
changeset
|
4175 } |
4532a9fe0e8c
Handle some keyboard escape sequences
Mikael Berthe <mikael@lilotux.net>
parents:
760
diff
changeset
|
4176 |
4532a9fe0e8c
Handle some keyboard escape sequences
Mikael Berthe <mikael@lilotux.net>
parents:
760
diff
changeset
|
4177 ks = g_new0(keyseq, 1); |
4532a9fe0e8c
Handle some keyboard escape sequences
Mikael Berthe <mikael@lilotux.net>
parents:
760
diff
changeset
|
4178 ks->seqstr = g_strdup(seqstr); |
4532a9fe0e8c
Handle some keyboard escape sequences
Mikael Berthe <mikael@lilotux.net>
parents:
760
diff
changeset
|
4179 ks->mkeycode = mkeycode; |
4532a9fe0e8c
Handle some keyboard escape sequences
Mikael Berthe <mikael@lilotux.net>
parents:
760
diff
changeset
|
4180 ks->value = value; |
4532a9fe0e8c
Handle some keyboard escape sequences
Mikael Berthe <mikael@lilotux.net>
parents:
760
diff
changeset
|
4181 keyseqlist = g_slist_append(keyseqlist, ks); |
4532a9fe0e8c
Handle some keyboard escape sequences
Mikael Berthe <mikael@lilotux.net>
parents:
760
diff
changeset
|
4182 } |
4532a9fe0e8c
Handle some keyboard escape sequences
Mikael Berthe <mikael@lilotux.net>
parents:
760
diff
changeset
|
4183 |
4532a9fe0e8c
Handle some keyboard escape sequences
Mikael Berthe <mikael@lilotux.net>
parents:
760
diff
changeset
|
4184 // match_keyseq(iseq, &ret) |
4532a9fe0e8c
Handle some keyboard escape sequences
Mikael Berthe <mikael@lilotux.net>
parents:
760
diff
changeset
|
4185 // Check if "iseq" is a known key escape sequence. |
4532a9fe0e8c
Handle some keyboard escape sequences
Mikael Berthe <mikael@lilotux.net>
parents:
760
diff
changeset
|
4186 // Return value: |
4532a9fe0e8c
Handle some keyboard escape sequences
Mikael Berthe <mikael@lilotux.net>
parents:
760
diff
changeset
|
4187 // -1 if "seq" matches no known sequence |
4532a9fe0e8c
Handle some keyboard escape sequences
Mikael Berthe <mikael@lilotux.net>
parents:
760
diff
changeset
|
4188 // 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
|
4189 // >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
|
4190 // and *ret is set to the matching keyseq structure. |
952 | 4191 static inline gint match_keyseq(int *iseq, keyseq **ret) |
373
af2f8ddf6a1b
Move (reorganize) functions
Mikael Berthe <mikael@lilotux.net>
parents:
370
diff
changeset
|
4192 { |
761
4532a9fe0e8c
Handle some keyboard escape sequences
Mikael Berthe <mikael@lilotux.net>
parents:
760
diff
changeset
|
4193 GSList *ksl; |
4532a9fe0e8c
Handle some keyboard escape sequences
Mikael Berthe <mikael@lilotux.net>
parents:
760
diff
changeset
|
4194 keyseq *ksp; |
4532a9fe0e8c
Handle some keyboard escape sequences
Mikael Berthe <mikael@lilotux.net>
parents:
760
diff
changeset
|
4195 char *p, c; |
4532a9fe0e8c
Handle some keyboard escape sequences
Mikael Berthe <mikael@lilotux.net>
parents:
760
diff
changeset
|
4196 int *i; |
4532a9fe0e8c
Handle some keyboard escape sequences
Mikael Berthe <mikael@lilotux.net>
parents:
760
diff
changeset
|
4197 int needmore = FALSE; |
4532a9fe0e8c
Handle some keyboard escape sequences
Mikael Berthe <mikael@lilotux.net>
parents:
760
diff
changeset
|
4198 |
4532a9fe0e8c
Handle some keyboard escape sequences
Mikael Berthe <mikael@lilotux.net>
parents:
760
diff
changeset
|
4199 for (ksl = keyseqlist; ksl; ksl = g_slist_next(ksl)) { |
4532a9fe0e8c
Handle some keyboard escape sequences
Mikael Berthe <mikael@lilotux.net>
parents:
760
diff
changeset
|
4200 ksp = ksl->data; |
4532a9fe0e8c
Handle some keyboard escape sequences
Mikael Berthe <mikael@lilotux.net>
parents:
760
diff
changeset
|
4201 p = ksp->seqstr; |
4532a9fe0e8c
Handle some keyboard escape sequences
Mikael Berthe <mikael@lilotux.net>
parents:
760
diff
changeset
|
4202 i = iseq; |
4532a9fe0e8c
Handle some keyboard escape sequences
Mikael Berthe <mikael@lilotux.net>
parents:
760
diff
changeset
|
4203 while (1) { |
4532a9fe0e8c
Handle some keyboard escape sequences
Mikael Berthe <mikael@lilotux.net>
parents:
760
diff
changeset
|
4204 c = (unsigned char)*i; |
4532a9fe0e8c
Handle some keyboard escape sequences
Mikael Berthe <mikael@lilotux.net>
parents:
760
diff
changeset
|
4205 if (!*p && !c) { // Match |
4532a9fe0e8c
Handle some keyboard escape sequences
Mikael Berthe <mikael@lilotux.net>
parents:
760
diff
changeset
|
4206 (*ret) = ksp; |
4532a9fe0e8c
Handle some keyboard escape sequences
Mikael Berthe <mikael@lilotux.net>
parents:
760
diff
changeset
|
4207 return ksp->mkeycode; |
4532a9fe0e8c
Handle some keyboard escape sequences
Mikael Berthe <mikael@lilotux.net>
parents:
760
diff
changeset
|
4208 } |
4532a9fe0e8c
Handle some keyboard escape sequences
Mikael Berthe <mikael@lilotux.net>
parents:
760
diff
changeset
|
4209 if (!c) { |
4532a9fe0e8c
Handle some keyboard escape sequences
Mikael Berthe <mikael@lilotux.net>
parents:
760
diff
changeset
|
4210 // iseq is too short |
4532a9fe0e8c
Handle some keyboard escape sequences
Mikael Berthe <mikael@lilotux.net>
parents:
760
diff
changeset
|
4211 needmore = TRUE; |
4532a9fe0e8c
Handle some keyboard escape sequences
Mikael Berthe <mikael@lilotux.net>
parents:
760
diff
changeset
|
4212 break; |
4532a9fe0e8c
Handle some keyboard escape sequences
Mikael Berthe <mikael@lilotux.net>
parents:
760
diff
changeset
|
4213 } else if (!*p || c != *p) { |
4532a9fe0e8c
Handle some keyboard escape sequences
Mikael Berthe <mikael@lilotux.net>
parents:
760
diff
changeset
|
4214 // This isn't a match |
4532a9fe0e8c
Handle some keyboard escape sequences
Mikael Berthe <mikael@lilotux.net>
parents:
760
diff
changeset
|
4215 break; |
4532a9fe0e8c
Handle some keyboard escape sequences
Mikael Berthe <mikael@lilotux.net>
parents:
760
diff
changeset
|
4216 } |
4532a9fe0e8c
Handle some keyboard escape sequences
Mikael Berthe <mikael@lilotux.net>
parents:
760
diff
changeset
|
4217 p++; i++; |
4532a9fe0e8c
Handle some keyboard escape sequences
Mikael Berthe <mikael@lilotux.net>
parents:
760
diff
changeset
|
4218 } |
4532a9fe0e8c
Handle some keyboard escape sequences
Mikael Berthe <mikael@lilotux.net>
parents:
760
diff
changeset
|
4219 } |
4532a9fe0e8c
Handle some keyboard escape sequences
Mikael Berthe <mikael@lilotux.net>
parents:
760
diff
changeset
|
4220 |
4532a9fe0e8c
Handle some keyboard escape sequences
Mikael Berthe <mikael@lilotux.net>
parents:
760
diff
changeset
|
4221 if (needmore) |
4532a9fe0e8c
Handle some keyboard escape sequences
Mikael Berthe <mikael@lilotux.net>
parents:
760
diff
changeset
|
4222 return 0; |
4532a9fe0e8c
Handle some keyboard escape sequences
Mikael Berthe <mikael@lilotux.net>
parents:
760
diff
changeset
|
4223 return -1; |
4532a9fe0e8c
Handle some keyboard escape sequences
Mikael Berthe <mikael@lilotux.net>
parents:
760
diff
changeset
|
4224 } |
4532a9fe0e8c
Handle some keyboard escape sequences
Mikael Berthe <mikael@lilotux.net>
parents:
760
diff
changeset
|
4225 |
930
a75f7a13df7b
UTF-8 terminal support (Reimar Döffinger)
Mikael Berthe <mikael@lilotux.net>
parents:
929
diff
changeset
|
4226 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
|
4227 { |
a75f7a13df7b
UTF-8 terminal support (Reimar Döffinger)
Mikael Berthe <mikael@lilotux.net>
parents:
929
diff
changeset
|
4228 int *strp = iseq; |
a75f7a13df7b
UTF-8 terminal support (Reimar Döffinger)
Mikael Berthe <mikael@lilotux.net>
parents:
929
diff
changeset
|
4229 unsigned c = *strp++; |
a75f7a13df7b
UTF-8 terminal support (Reimar Döffinger)
Mikael Berthe <mikael@lilotux.net>
parents:
929
diff
changeset
|
4230 unsigned mask = 0x80; |
a75f7a13df7b
UTF-8 terminal support (Reimar Döffinger)
Mikael Berthe <mikael@lilotux.net>
parents:
929
diff
changeset
|
4231 int len = -1; |
a75f7a13df7b
UTF-8 terminal support (Reimar Döffinger)
Mikael Berthe <mikael@lilotux.net>
parents:
929
diff
changeset
|
4232 while (c & mask) { |
a75f7a13df7b
UTF-8 terminal support (Reimar Döffinger)
Mikael Berthe <mikael@lilotux.net>
parents:
929
diff
changeset
|
4233 mask >>= 1; |
a75f7a13df7b
UTF-8 terminal support (Reimar Döffinger)
Mikael Berthe <mikael@lilotux.net>
parents:
929
diff
changeset
|
4234 len++; |
a75f7a13df7b
UTF-8 terminal support (Reimar Döffinger)
Mikael Berthe <mikael@lilotux.net>
parents:
929
diff
changeset
|
4235 } |
a75f7a13df7b
UTF-8 terminal support (Reimar Döffinger)
Mikael Berthe <mikael@lilotux.net>
parents:
929
diff
changeset
|
4236 if (len <= 0 || len > 4) |
a75f7a13df7b
UTF-8 terminal support (Reimar Döffinger)
Mikael Berthe <mikael@lilotux.net>
parents:
929
diff
changeset
|
4237 return -1; |
a75f7a13df7b
UTF-8 terminal support (Reimar Döffinger)
Mikael Berthe <mikael@lilotux.net>
parents:
929
diff
changeset
|
4238 c &= mask - 1; |
a75f7a13df7b
UTF-8 terminal support (Reimar Döffinger)
Mikael Berthe <mikael@lilotux.net>
parents:
929
diff
changeset
|
4239 while ((*strp & 0xc0) == 0x80) { |
a75f7a13df7b
UTF-8 terminal support (Reimar Döffinger)
Mikael Berthe <mikael@lilotux.net>
parents:
929
diff
changeset
|
4240 if (len-- <= 0) // can't happen |
a75f7a13df7b
UTF-8 terminal support (Reimar Döffinger)
Mikael Berthe <mikael@lilotux.net>
parents:
929
diff
changeset
|
4241 return -1; |
a75f7a13df7b
UTF-8 terminal support (Reimar Döffinger)
Mikael Berthe <mikael@lilotux.net>
parents:
929
diff
changeset
|
4242 c = (c << 6) | (*strp++ & 0x3f); |
a75f7a13df7b
UTF-8 terminal support (Reimar Döffinger)
Mikael Berthe <mikael@lilotux.net>
parents:
929
diff
changeset
|
4243 } |
a75f7a13df7b
UTF-8 terminal support (Reimar Döffinger)
Mikael Berthe <mikael@lilotux.net>
parents:
929
diff
changeset
|
4244 if (len) |
a75f7a13df7b
UTF-8 terminal support (Reimar Döffinger)
Mikael Berthe <mikael@lilotux.net>
parents:
929
diff
changeset
|
4245 return 0; |
a75f7a13df7b
UTF-8 terminal support (Reimar Döffinger)
Mikael Berthe <mikael@lilotux.net>
parents:
929
diff
changeset
|
4246 return c; |
a75f7a13df7b
UTF-8 terminal support (Reimar Döffinger)
Mikael Berthe <mikael@lilotux.net>
parents:
929
diff
changeset
|
4247 } |
a75f7a13df7b
UTF-8 terminal support (Reimar Döffinger)
Mikael Berthe <mikael@lilotux.net>
parents:
929
diff
changeset
|
4248 |
1780
e4378fbab5d7
Major API cleanup - bump API to 4
Mikael Berthe <mikael@lilotux.net>
parents:
1761
diff
changeset
|
4249 void scr_getch(keycode *kcode) |
761
4532a9fe0e8c
Handle some keyboard escape sequences
Mikael Berthe <mikael@lilotux.net>
parents:
760
diff
changeset
|
4250 { |
769 | 4251 keyseq *mks = NULL; |
761
4532a9fe0e8c
Handle some keyboard escape sequences
Mikael Berthe <mikael@lilotux.net>
parents:
760
diff
changeset
|
4252 int ks[MAX_KEYSEQ_LENGTH+1]; |
4532a9fe0e8c
Handle some keyboard escape sequences
Mikael Berthe <mikael@lilotux.net>
parents:
760
diff
changeset
|
4253 int i; |
4532a9fe0e8c
Handle some keyboard escape sequences
Mikael Berthe <mikael@lilotux.net>
parents:
760
diff
changeset
|
4254 |
4532a9fe0e8c
Handle some keyboard escape sequences
Mikael Berthe <mikael@lilotux.net>
parents:
760
diff
changeset
|
4255 memset(kcode, 0, sizeof(keycode)); |
4532a9fe0e8c
Handle some keyboard escape sequences
Mikael Berthe <mikael@lilotux.net>
parents:
760
diff
changeset
|
4256 memset(ks, 0, sizeof(ks)); |
4532a9fe0e8c
Handle some keyboard escape sequences
Mikael Berthe <mikael@lilotux.net>
parents:
760
diff
changeset
|
4257 |
4532a9fe0e8c
Handle some keyboard escape sequences
Mikael Berthe <mikael@lilotux.net>
parents:
760
diff
changeset
|
4258 kcode->value = wgetch(inputWnd); |
930
a75f7a13df7b
UTF-8 terminal support (Reimar Döffinger)
Mikael Berthe <mikael@lilotux.net>
parents:
929
diff
changeset
|
4259 if (utf8_mode) { |
1058 | 4260 bool ismeta = (kcode->value == 27); |
1561 | 4261 #ifdef NCURSES_MOUSE_VERSION |
4262 bool ismouse = (kcode->value == KEY_MOUSE); | |
4263 | |
4264 if (ismouse) { | |
4265 MEVENT mouse; | |
4266 getmouse(&mouse); | |
4267 kcode->value = mouse.bstate; | |
4268 kcode->mcode = MKEY_MOUSE; | |
4269 return; | |
4270 } else if (ismeta) | |
4271 #else | |
1058 | 4272 if (ismeta) |
1561 | 4273 #endif |
944
aec71ebf98fa
Fix Meta + UTF-8 character
Mikael Berthe <mikael@lilotux.net>
parents:
940
diff
changeset
|
4274 ks[0] = wgetch(inputWnd); |
aec71ebf98fa
Fix Meta + UTF-8 character
Mikael Berthe <mikael@lilotux.net>
parents:
940
diff
changeset
|
4275 else |
aec71ebf98fa
Fix Meta + UTF-8 character
Mikael Berthe <mikael@lilotux.net>
parents:
940
diff
changeset
|
4276 ks[0] = kcode->value; |
aec71ebf98fa
Fix Meta + UTF-8 character
Mikael Berthe <mikael@lilotux.net>
parents:
940
diff
changeset
|
4277 |
930
a75f7a13df7b
UTF-8 terminal support (Reimar Döffinger)
Mikael Berthe <mikael@lilotux.net>
parents:
929
diff
changeset
|
4278 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
|
4279 int match = match_utf8_keyseq(ks); |
a75f7a13df7b
UTF-8 terminal support (Reimar Döffinger)
Mikael Berthe <mikael@lilotux.net>
parents:
929
diff
changeset
|
4280 if (match == -1) |
a75f7a13df7b
UTF-8 terminal support (Reimar Döffinger)
Mikael Berthe <mikael@lilotux.net>
parents:
929
diff
changeset
|
4281 break; |
a75f7a13df7b
UTF-8 terminal support (Reimar Döffinger)
Mikael Berthe <mikael@lilotux.net>
parents:
929
diff
changeset
|
4282 if (match > 0) { |
a75f7a13df7b
UTF-8 terminal support (Reimar Döffinger)
Mikael Berthe <mikael@lilotux.net>
parents:
929
diff
changeset
|
4283 kcode->value = match; |
a75f7a13df7b
UTF-8 terminal support (Reimar Döffinger)
Mikael Berthe <mikael@lilotux.net>
parents:
929
diff
changeset
|
4284 kcode->utf8 = 1; |
1058 | 4285 if (ismeta) |
944
aec71ebf98fa
Fix Meta + UTF-8 character
Mikael Berthe <mikael@lilotux.net>
parents:
940
diff
changeset
|
4286 kcode->mcode = MKEY_META; |
930
a75f7a13df7b
UTF-8 terminal support (Reimar Döffinger)
Mikael Berthe <mikael@lilotux.net>
parents:
929
diff
changeset
|
4287 return; |
a75f7a13df7b
UTF-8 terminal support (Reimar Döffinger)
Mikael Berthe <mikael@lilotux.net>
parents:
929
diff
changeset
|
4288 } |
a75f7a13df7b
UTF-8 terminal support (Reimar Döffinger)
Mikael Berthe <mikael@lilotux.net>
parents:
929
diff
changeset
|
4289 ks[i + 1] = wgetch(inputWnd); |
a75f7a13df7b
UTF-8 terminal support (Reimar Döffinger)
Mikael Berthe <mikael@lilotux.net>
parents:
929
diff
changeset
|
4290 if (ks[i + 1] == ERR) |
a75f7a13df7b
UTF-8 terminal support (Reimar Döffinger)
Mikael Berthe <mikael@lilotux.net>
parents:
929
diff
changeset
|
4291 break; |
a75f7a13df7b
UTF-8 terminal support (Reimar Döffinger)
Mikael Berthe <mikael@lilotux.net>
parents:
929
diff
changeset
|
4292 } |
a75f7a13df7b
UTF-8 terminal support (Reimar Döffinger)
Mikael Berthe <mikael@lilotux.net>
parents:
929
diff
changeset
|
4293 while (i > 0) |
a75f7a13df7b
UTF-8 terminal support (Reimar Döffinger)
Mikael Berthe <mikael@lilotux.net>
parents:
929
diff
changeset
|
4294 ungetch(ks[i--]); |
1058 | 4295 if (ismeta) |
944
aec71ebf98fa
Fix Meta + UTF-8 character
Mikael Berthe <mikael@lilotux.net>
parents:
940
diff
changeset
|
4296 ungetch(ks[0]); |
930
a75f7a13df7b
UTF-8 terminal support (Reimar Döffinger)
Mikael Berthe <mikael@lilotux.net>
parents:
929
diff
changeset
|
4297 memset(ks, 0, sizeof(ks)); |
a75f7a13df7b
UTF-8 terminal support (Reimar Döffinger)
Mikael Berthe <mikael@lilotux.net>
parents:
929
diff
changeset
|
4298 } |
761
4532a9fe0e8c
Handle some keyboard escape sequences
Mikael Berthe <mikael@lilotux.net>
parents:
760
diff
changeset
|
4299 if (kcode->value != 27) |
4532a9fe0e8c
Handle some keyboard escape sequences
Mikael Berthe <mikael@lilotux.net>
parents:
760
diff
changeset
|
4300 return; |
4532a9fe0e8c
Handle some keyboard escape sequences
Mikael Berthe <mikael@lilotux.net>
parents:
760
diff
changeset
|
4301 |
4532a9fe0e8c
Handle some keyboard escape sequences
Mikael Berthe <mikael@lilotux.net>
parents:
760
diff
changeset
|
4302 // Check for escape key sequence |
4532a9fe0e8c
Handle some keyboard escape sequences
Mikael Berthe <mikael@lilotux.net>
parents:
760
diff
changeset
|
4303 for (i=0; i < MAX_KEYSEQ_LENGTH; i++) { |
4532a9fe0e8c
Handle some keyboard escape sequences
Mikael Berthe <mikael@lilotux.net>
parents:
760
diff
changeset
|
4304 int match; |
4532a9fe0e8c
Handle some keyboard escape sequences
Mikael Berthe <mikael@lilotux.net>
parents:
760
diff
changeset
|
4305 ks[i] = wgetch(inputWnd); |
4532a9fe0e8c
Handle some keyboard escape sequences
Mikael Berthe <mikael@lilotux.net>
parents:
760
diff
changeset
|
4306 if (ks[i] == ERR) break; |
4532a9fe0e8c
Handle some keyboard escape sequences
Mikael Berthe <mikael@lilotux.net>
parents:
760
diff
changeset
|
4307 match = match_keyseq(ks, &mks); |
4532a9fe0e8c
Handle some keyboard escape sequences
Mikael Berthe <mikael@lilotux.net>
parents:
760
diff
changeset
|
4308 if (match == -1) { |
4532a9fe0e8c
Handle some keyboard escape sequences
Mikael Berthe <mikael@lilotux.net>
parents:
760
diff
changeset
|
4309 // 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
|
4310 i++; |
4532a9fe0e8c
Handle some keyboard escape sequences
Mikael Berthe <mikael@lilotux.net>
parents:
760
diff
changeset
|
4311 break; |
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 (match > 0) { |
4532a9fe0e8c
Handle some keyboard escape sequences
Mikael Berthe <mikael@lilotux.net>
parents:
760
diff
changeset
|
4314 // We have a matching sequence |
4532a9fe0e8c
Handle some keyboard escape sequences
Mikael Berthe <mikael@lilotux.net>
parents:
760
diff
changeset
|
4315 kcode->mcode = mks->mkeycode; |
4532a9fe0e8c
Handle some keyboard escape sequences
Mikael Berthe <mikael@lilotux.net>
parents:
760
diff
changeset
|
4316 kcode->value = mks->value; |
4532a9fe0e8c
Handle some keyboard escape sequences
Mikael Berthe <mikael@lilotux.net>
parents:
760
diff
changeset
|
4317 return; |
4532a9fe0e8c
Handle some keyboard escape sequences
Mikael Berthe <mikael@lilotux.net>
parents:
760
diff
changeset
|
4318 } |
4532a9fe0e8c
Handle some keyboard escape sequences
Mikael Berthe <mikael@lilotux.net>
parents:
760
diff
changeset
|
4319 } |
4532a9fe0e8c
Handle some keyboard escape sequences
Mikael Berthe <mikael@lilotux.net>
parents:
760
diff
changeset
|
4320 |
4532a9fe0e8c
Handle some keyboard escape sequences
Mikael Berthe <mikael@lilotux.net>
parents:
760
diff
changeset
|
4321 // No match. Let's return a meta-key. |
4532a9fe0e8c
Handle some keyboard escape sequences
Mikael Berthe <mikael@lilotux.net>
parents:
760
diff
changeset
|
4322 if (i > 0) { |
4532a9fe0e8c
Handle some keyboard escape sequences
Mikael Berthe <mikael@lilotux.net>
parents:
760
diff
changeset
|
4323 kcode->mcode = MKEY_META; |
4532a9fe0e8c
Handle some keyboard escape sequences
Mikael Berthe <mikael@lilotux.net>
parents:
760
diff
changeset
|
4324 kcode->value = ks[0]; |
4532a9fe0e8c
Handle some keyboard escape sequences
Mikael Berthe <mikael@lilotux.net>
parents:
760
diff
changeset
|
4325 } |
4532a9fe0e8c
Handle some keyboard escape sequences
Mikael Berthe <mikael@lilotux.net>
parents:
760
diff
changeset
|
4326 if (i > 1) { |
4532a9fe0e8c
Handle some keyboard escape sequences
Mikael Berthe <mikael@lilotux.net>
parents:
760
diff
changeset
|
4327 // 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
|
4328 while (i-- > 1) |
4532a9fe0e8c
Handle some keyboard escape sequences
Mikael Berthe <mikael@lilotux.net>
parents:
760
diff
changeset
|
4329 ungetch(ks[i]); |
4532a9fe0e8c
Handle some keyboard escape sequences
Mikael Berthe <mikael@lilotux.net>
parents:
760
diff
changeset
|
4330 } |
4532a9fe0e8c
Handle some keyboard escape sequences
Mikael Berthe <mikael@lilotux.net>
parents:
760
diff
changeset
|
4331 return; |
373
af2f8ddf6a1b
Move (reorganize) functions
Mikael Berthe <mikael@lilotux.net>
parents:
370
diff
changeset
|
4332 } |
af2f8ddf6a1b
Move (reorganize) functions
Mikael Berthe <mikael@lilotux.net>
parents:
370
diff
changeset
|
4333 |
1780
e4378fbab5d7
Major API cleanup - bump API to 4
Mikael Berthe <mikael@lilotux.net>
parents:
1761
diff
changeset
|
4334 void scr_do_update(void) |
939
12fa2ae6445d
Get rid of "busy-waiting" (Christof Meerwald)
Mikael Berthe <mikael@lilotux.net>
parents:
936
diff
changeset
|
4335 { |
1942
3e39a336a992
Use guards for colors (Myhailo Danylenko)
Mikael Berthe <mikael@lilotux.net>
parents:
1935
diff
changeset
|
4336 if (colors_stalled) |
3e39a336a992
Use guards for colors (Myhailo Danylenko)
Mikael Berthe <mikael@lilotux.net>
parents:
1935
diff
changeset
|
4337 parse_colors(); |
939
12fa2ae6445d
Get rid of "busy-waiting" (Christof Meerwald)
Mikael Berthe <mikael@lilotux.net>
parents:
936
diff
changeset
|
4338 doupdate(); |
12fa2ae6445d
Get rid of "busy-waiting" (Christof Meerwald)
Mikael Berthe <mikael@lilotux.net>
parents:
936
diff
changeset
|
4339 } |
12fa2ae6445d
Get rid of "busy-waiting" (Christof Meerwald)
Mikael Berthe <mikael@lilotux.net>
parents:
936
diff
changeset
|
4340 |
2164 | 4341 static void bindcommand(keycode kcode) |
930
a75f7a13df7b
UTF-8 terminal support (Reimar Döffinger)
Mikael Berthe <mikael@lilotux.net>
parents:
929
diff
changeset
|
4342 { |
945
17ef145f3326
Display and use UTF-8 key codes
Mikael Berthe <mikael@lilotux.net>
parents:
944
diff
changeset
|
4343 gchar asciikey[16], asciicode[16]; |
764
4e15322d315e
Allow binding of meta keys
Mikael Berthe <mikael@lilotux.net>
parents:
763
diff
changeset
|
4344 const gchar *boundcmd; |
4e15322d315e
Allow binding of meta keys
Mikael Berthe <mikael@lilotux.net>
parents:
763
diff
changeset
|
4345 |
945
17ef145f3326
Display and use UTF-8 key codes
Mikael Berthe <mikael@lilotux.net>
parents:
944
diff
changeset
|
4346 if (kcode.utf8) |
17ef145f3326
Display and use UTF-8 key codes
Mikael Berthe <mikael@lilotux.net>
parents:
944
diff
changeset
|
4347 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
|
4348 else |
17ef145f3326
Display and use UTF-8 key codes
Mikael Berthe <mikael@lilotux.net>
parents:
944
diff
changeset
|
4349 g_snprintf(asciicode, 15, "%d", kcode.value); |
17ef145f3326
Display and use UTF-8 key codes
Mikael Berthe <mikael@lilotux.net>
parents:
944
diff
changeset
|
4350 |
764
4e15322d315e
Allow binding of meta keys
Mikael Berthe <mikael@lilotux.net>
parents:
763
diff
changeset
|
4351 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
|
4352 g_snprintf(asciikey, 15, "%s", asciicode); |
764
4e15322d315e
Allow binding of meta keys
Mikael Berthe <mikael@lilotux.net>
parents:
763
diff
changeset
|
4353 else if (kcode.mcode == MKEY_META) |
945
17ef145f3326
Display and use UTF-8 key codes
Mikael Berthe <mikael@lilotux.net>
parents:
944
diff
changeset
|
4354 g_snprintf(asciikey, 15, "M%s", asciicode); |
1561 | 4355 else if (kcode.mcode == MKEY_MOUSE) |
4356 g_snprintf(asciikey, 15, "p%s", asciicode); | |
764
4e15322d315e
Allow binding of meta keys
Mikael Berthe <mikael@lilotux.net>
parents:
763
diff
changeset
|
4357 else |
949
e3c49b2f8143
Fix bindings of special keys (MK*)
Mikael Berthe <mikael@lilotux.net>
parents:
945
diff
changeset
|
4358 g_snprintf(asciikey, 15, "MK%d", kcode.mcode); |
764
4e15322d315e
Allow binding of meta keys
Mikael Berthe <mikael@lilotux.net>
parents:
763
diff
changeset
|
4359 |
4e15322d315e
Allow binding of meta keys
Mikael Berthe <mikael@lilotux.net>
parents:
763
diff
changeset
|
4360 boundcmd = settings_get(SETTINGS_TYPE_BINDING, asciikey); |
4e15322d315e
Allow binding of meta keys
Mikael Berthe <mikael@lilotux.net>
parents:
763
diff
changeset
|
4361 |
4e15322d315e
Allow binding of meta keys
Mikael Berthe <mikael@lilotux.net>
parents:
763
diff
changeset
|
4362 if (boundcmd) { |
1357
7bbfb0073f88
Fix an UTF-8 problem in new hook_execute_internal() function
Mikael Berthe <mikael@lilotux.net>
parents:
1355
diff
changeset
|
4363 gchar *cmdline = from_utf8(boundcmd); |
1780
e4378fbab5d7
Major API cleanup - bump API to 4
Mikael Berthe <mikael@lilotux.net>
parents:
1761
diff
changeset
|
4364 scr_check_auto_away(TRUE); |
2164 | 4365 process_command(cmdline, TRUE); |
1058 | 4366 g_free(cmdline); |
2164 | 4367 return; |
764
4e15322d315e
Allow binding of meta keys
Mikael Berthe <mikael@lilotux.net>
parents:
763
diff
changeset
|
4368 } |
4e15322d315e
Allow binding of meta keys
Mikael Berthe <mikael@lilotux.net>
parents:
763
diff
changeset
|
4369 |
4e15322d315e
Allow binding of meta keys
Mikael Berthe <mikael@lilotux.net>
parents:
763
diff
changeset
|
4370 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
|
4371 #ifndef UNICODE |
764
4e15322d315e
Allow binding of meta keys
Mikael Berthe <mikael@lilotux.net>
parents:
763
diff
changeset
|
4372 if (utf8_mode) |
930
a75f7a13df7b
UTF-8 terminal support (Reimar Döffinger)
Mikael Berthe <mikael@lilotux.net>
parents:
929
diff
changeset
|
4373 scr_LogPrint(LPRINT_NORMAL, |
a75f7a13df7b
UTF-8 terminal support (Reimar Döffinger)
Mikael Berthe <mikael@lilotux.net>
parents:
929
diff
changeset
|
4374 "WARNING: Compiled without full UTF-8 support!"); |
a75f7a13df7b
UTF-8 terminal support (Reimar Döffinger)
Mikael Berthe <mikael@lilotux.net>
parents:
929
diff
changeset
|
4375 #endif |
764
4e15322d315e
Allow binding of meta keys
Mikael Berthe <mikael@lilotux.net>
parents:
763
diff
changeset
|
4376 } |
4e15322d315e
Allow binding of meta keys
Mikael Berthe <mikael@lilotux.net>
parents:
763
diff
changeset
|
4377 |
1780
e4378fbab5d7
Major API cleanup - bump API to 4
Mikael Berthe <mikael@lilotux.net>
parents:
1761
diff
changeset
|
4378 // scr_process_key(key) |
44 | 4379 // Handle the pressed key, in the command line (bottom). |
1780
e4378fbab5d7
Major API cleanup - bump API to 4
Mikael Berthe <mikael@lilotux.net>
parents:
1761
diff
changeset
|
4380 void scr_process_key(keycode kcode) |
24 | 4381 { |
761
4532a9fe0e8c
Handle some keyboard escape sequences
Mikael Berthe <mikael@lilotux.net>
parents:
760
diff
changeset
|
4382 int key = kcode.value; |
931
1cd6d694ac3c
Fix display of some UTF-8 chars
Mikael Berthe <mikael@lilotux.net>
parents:
930
diff
changeset
|
4383 int display_char = FALSE; |
761
4532a9fe0e8c
Handle some keyboard escape sequences
Mikael Berthe <mikael@lilotux.net>
parents:
760
diff
changeset
|
4384 |
1381
40095d413da9
Fix compilation on OpenBSD
Mikael Berthe <mikael@lilotux.net>
parents:
1376
diff
changeset
|
4385 lock_chatstate = FALSE; |
990
35e7913affb7
Send events/chatstates notifications (JEP-22/JEP-85)
Mikael Berthe <mikael@lilotux.net>
parents:
987
diff
changeset
|
4386 |
761
4532a9fe0e8c
Handle some keyboard escape sequences
Mikael Berthe <mikael@lilotux.net>
parents:
760
diff
changeset
|
4387 switch (kcode.mcode) { |
4532a9fe0e8c
Handle some keyboard escape sequences
Mikael Berthe <mikael@lilotux.net>
parents:
760
diff
changeset
|
4388 case 0: |
1918
0fa6df17bc5c
Fix potential issue pointed out by franky's clang report
Mikael Berthe <mikael@lilotux.net>
parents:
1915
diff
changeset
|
4389 // key = kcode.value; |
761
4532a9fe0e8c
Handle some keyboard escape sequences
Mikael Berthe <mikael@lilotux.net>
parents:
760
diff
changeset
|
4390 break; |
4532a9fe0e8c
Handle some keyboard escape sequences
Mikael Berthe <mikael@lilotux.net>
parents:
760
diff
changeset
|
4391 case MKEY_EQUIV: |
1918
0fa6df17bc5c
Fix potential issue pointed out by franky's clang report
Mikael Berthe <mikael@lilotux.net>
parents:
1915
diff
changeset
|
4392 // key = kcode.value; |
761
4532a9fe0e8c
Handle some keyboard escape sequences
Mikael Berthe <mikael@lilotux.net>
parents:
760
diff
changeset
|
4393 break; |
4532a9fe0e8c
Handle some keyboard escape sequences
Mikael Berthe <mikael@lilotux.net>
parents:
760
diff
changeset
|
4394 case MKEY_META: |
4532a9fe0e8c
Handle some keyboard escape sequences
Mikael Berthe <mikael@lilotux.net>
parents:
760
diff
changeset
|
4395 default: |
2164 | 4396 bindcommand(kcode); |
764
4e15322d315e
Allow binding of meta keys
Mikael Berthe <mikael@lilotux.net>
parents:
763
diff
changeset
|
4397 key = ERR; // Do not process any further |
758 | 4398 } |
761
4532a9fe0e8c
Handle some keyboard escape sequences
Mikael Berthe <mikael@lilotux.net>
parents:
760
diff
changeset
|
4399 |
931
1cd6d694ac3c
Fix display of some UTF-8 chars
Mikael Berthe <mikael@lilotux.net>
parents:
930
diff
changeset
|
4400 if (kcode.utf8) { |
1cd6d694ac3c
Fix display of some UTF-8 chars
Mikael Berthe <mikael@lilotux.net>
parents:
930
diff
changeset
|
4401 if (key != ERR && !kcode.mcode) |
1cd6d694ac3c
Fix display of some UTF-8 chars
Mikael Berthe <mikael@lilotux.net>
parents:
930
diff
changeset
|
4402 display_char = TRUE; |
1cd6d694ac3c
Fix display of some UTF-8 chars
Mikael Berthe <mikael@lilotux.net>
parents:
930
diff
changeset
|
4403 goto display; |
1cd6d694ac3c
Fix display of some UTF-8 chars
Mikael Berthe <mikael@lilotux.net>
parents:
930
diff
changeset
|
4404 } |
1cd6d694ac3c
Fix display of some UTF-8 chars
Mikael Berthe <mikael@lilotux.net>
parents:
930
diff
changeset
|
4405 |
758 | 4406 switch (key) { |
761
4532a9fe0e8c
Handle some keyboard escape sequences
Mikael Berthe <mikael@lilotux.net>
parents:
760
diff
changeset
|
4407 case 0: |
4532a9fe0e8c
Handle some keyboard escape sequences
Mikael Berthe <mikael@lilotux.net>
parents:
760
diff
changeset
|
4408 case ERR: |
758 | 4409 break; |
1173
960f34ec22a2
Add init_bindings() for default key bindings (Lego12239)
Mikael Berthe <mikael@lilotux.net>
parents:
1172
diff
changeset
|
4410 case 9: // Tab |
2143
2f294c2b6778
Add a backward completion (Oleg)
Mikael Berthe <mikael@lilotux.net>
parents:
2136
diff
changeset
|
4411 readline_do_completion(TRUE); // Forward-completion |
2f294c2b6778
Add a backward completion (Oleg)
Mikael Berthe <mikael@lilotux.net>
parents:
2136
diff
changeset
|
4412 break; |
2f294c2b6778
Add a backward completion (Oleg)
Mikael Berthe <mikael@lilotux.net>
parents:
2136
diff
changeset
|
4413 case 353: // Shift-Tab |
2f294c2b6778
Add a backward completion (Oleg)
Mikael Berthe <mikael@lilotux.net>
parents:
2136
diff
changeset
|
4414 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
|
4415 break; |
960f34ec22a2
Add init_bindings() for default key bindings (Lego12239)
Mikael Berthe <mikael@lilotux.net>
parents:
1172
diff
changeset
|
4416 case 13: // Enter |
1935
a06d9eab14c5
Handle the Enter key on Maemo systems (diSabler)
Mikael Berthe <mikael@lilotux.net>
parents:
1927
diff
changeset
|
4417 case 343: // Enter on Maemo |
2164 | 4418 readline_accept_line(FALSE); |
1173
960f34ec22a2
Add init_bindings() for default key bindings (Lego12239)
Mikael Berthe <mikael@lilotux.net>
parents:
1172
diff
changeset
|
4419 break; |
960f34ec22a2
Add init_bindings() for default key bindings (Lego12239)
Mikael Berthe <mikael@lilotux.net>
parents:
1172
diff
changeset
|
4420 case 3: // Ctrl-C |
960f34ec22a2
Add init_bindings() for default key bindings (Lego12239)
Mikael Berthe <mikael@lilotux.net>
parents:
1172
diff
changeset
|
4421 scr_handle_CtrlC(); |
960f34ec22a2
Add init_bindings() for default key bindings (Lego12239)
Mikael Berthe <mikael@lilotux.net>
parents:
1172
diff
changeset
|
4422 break; |
960f34ec22a2
Add init_bindings() for default key bindings (Lego12239)
Mikael Berthe <mikael@lilotux.net>
parents:
1172
diff
changeset
|
4423 case KEY_RESIZE: |
1454
6b98dc22946d
Add optional SIGWINCH handler (Markus Hennecke)
Mikael Berthe <mikael@lilotux.net>
parents:
1424
diff
changeset
|
4424 #ifdef USE_SIGWINCH |
6b98dc22946d
Add optional SIGWINCH handler (Markus Hennecke)
Mikael Berthe <mikael@lilotux.net>
parents:
1424
diff
changeset
|
4425 { |
1660
dc03a24198a9
Do not call do_screen_refresh() on SIGWINCH
Mikael Berthe <mikael@lilotux.net>
parents:
1653
diff
changeset
|
4426 struct winsize size; |
dc03a24198a9
Do not call do_screen_refresh() on SIGWINCH
Mikael Berthe <mikael@lilotux.net>
parents:
1653
diff
changeset
|
4427 if (ioctl(STDIN_FILENO, TIOCGWINSZ, &size) != -1) |
dc03a24198a9
Do not call do_screen_refresh() on SIGWINCH
Mikael Berthe <mikael@lilotux.net>
parents:
1653
diff
changeset
|
4428 resizeterm(size.ws_row, size.ws_col); |
1454
6b98dc22946d
Add optional SIGWINCH handler (Markus Hennecke)
Mikael Berthe <mikael@lilotux.net>
parents:
1424
diff
changeset
|
4429 } |
1660
dc03a24198a9
Do not call do_screen_refresh() on SIGWINCH
Mikael Berthe <mikael@lilotux.net>
parents:
1653
diff
changeset
|
4430 #endif |
1173
960f34ec22a2
Add init_bindings() for default key bindings (Lego12239)
Mikael Berthe <mikael@lilotux.net>
parents:
1172
diff
changeset
|
4431 scr_Resize(); |
960f34ec22a2
Add init_bindings() for default key bindings (Lego12239)
Mikael Berthe <mikael@lilotux.net>
parents:
1172
diff
changeset
|
4432 break; |
499
baa812f04f24
Reorganise process_key()
Mikael Berthe <mikael@lilotux.net>
parents:
480
diff
changeset
|
4433 default: |
931
1cd6d694ac3c
Fix display of some UTF-8 chars
Mikael Berthe <mikael@lilotux.net>
parents:
930
diff
changeset
|
4434 display_char = TRUE; |
1cd6d694ac3c
Fix display of some UTF-8 chars
Mikael Berthe <mikael@lilotux.net>
parents:
930
diff
changeset
|
4435 } // switch |
263 | 4436 |
931
1cd6d694ac3c
Fix display of some UTF-8 chars
Mikael Berthe <mikael@lilotux.net>
parents:
930
diff
changeset
|
4437 display: |
1cd6d694ac3c
Fix display of some UTF-8 chars
Mikael Berthe <mikael@lilotux.net>
parents:
930
diff
changeset
|
4438 if (display_char) { |
1394 | 4439 guint printable; |
4440 | |
4441 if (kcode.utf8) { | |
4442 printable = iswprint(key); | |
4443 } else { | |
4444 #ifdef __CYGWIN__ | |
4445 printable = (isprint(key) || (key >= 161 && key <= 255)) | |
4446 && !is_speckey(key); | |
4447 #else | |
4448 printable = isprint(key) && !is_speckey(key); | |
4449 #endif | |
4450 } | |
4451 if (printable) { | |
931
1cd6d694ac3c
Fix display of some UTF-8 chars
Mikael Berthe <mikael@lilotux.net>
parents:
930
diff
changeset
|
4452 char tmpLine[INPUTLINE_LENGTH+1]; |
499
baa812f04f24
Reorganise process_key()
Mikael Berthe <mikael@lilotux.net>
parents:
480
diff
changeset
|
4453 |
931
1cd6d694ac3c
Fix display of some UTF-8 chars
Mikael Berthe <mikael@lilotux.net>
parents:
930
diff
changeset
|
4454 // Check the line isn't too long |
1cd6d694ac3c
Fix display of some UTF-8 chars
Mikael Berthe <mikael@lilotux.net>
parents:
930
diff
changeset
|
4455 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
|
4456 return; |
931
1cd6d694ac3c
Fix display of some UTF-8 chars
Mikael Berthe <mikael@lilotux.net>
parents:
930
diff
changeset
|
4457 |
1cd6d694ac3c
Fix display of some UTF-8 chars
Mikael Berthe <mikael@lilotux.net>
parents:
930
diff
changeset
|
4458 // Insert char |
1cd6d694ac3c
Fix display of some UTF-8 chars
Mikael Berthe <mikael@lilotux.net>
parents:
930
diff
changeset
|
4459 strcpy(tmpLine, ptr_inputline); |
1cd6d694ac3c
Fix display of some UTF-8 chars
Mikael Berthe <mikael@lilotux.net>
parents:
930
diff
changeset
|
4460 ptr_inputline = put_char(ptr_inputline, key); |
1cd6d694ac3c
Fix display of some UTF-8 chars
Mikael Berthe <mikael@lilotux.net>
parents:
930
diff
changeset
|
4461 strcpy(ptr_inputline, tmpLine); |
1cd6d694ac3c
Fix display of some UTF-8 chars
Mikael Berthe <mikael@lilotux.net>
parents:
930
diff
changeset
|
4462 check_offset(1); |
1cd6d694ac3c
Fix display of some UTF-8 chars
Mikael Berthe <mikael@lilotux.net>
parents:
930
diff
changeset
|
4463 } else { |
1cd6d694ac3c
Fix display of some UTF-8 chars
Mikael Berthe <mikael@lilotux.net>
parents:
930
diff
changeset
|
4464 // Look for a key binding. |
2164 | 4465 if (!kcode.utf8) |
4466 bindcommand(kcode); | |
931
1cd6d694ac3c
Fix display of some UTF-8 chars
Mikael Berthe <mikael@lilotux.net>
parents:
930
diff
changeset
|
4467 } |
24 | 4468 } |
499
baa812f04f24
Reorganise process_key()
Mikael Berthe <mikael@lilotux.net>
parents:
480
diff
changeset
|
4469 |
2143
2f294c2b6778
Add a backward completion (Oleg)
Mikael Berthe <mikael@lilotux.net>
parents:
2136
diff
changeset
|
4470 if (completion_started && key != 9 && key != 353 && key != KEY_RESIZE) |
98 | 4471 scr_end_current_completion(); |
312
f0b7ff2df7e8
Ctrl-C does not terminate mcabber
Mikael Berthe <mikael@lilotux.net>
parents:
307
diff
changeset
|
4472 refresh_inputline(); |
990
35e7913affb7
Send events/chatstates notifications (JEP-22/JEP-85)
Mikael Berthe <mikael@lilotux.net>
parents:
987
diff
changeset
|
4473 |
35e7913affb7
Send events/chatstates notifications (JEP-22/JEP-85)
Mikael Berthe <mikael@lilotux.net>
parents:
987
diff
changeset
|
4474 if (!lock_chatstate) { |
997 | 4475 // Set chat state to composing (1) if the user is currently composing, |
4476 // 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
|
4477 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
|
4478 set_chatstate(0); |
35e7913affb7
Send events/chatstates notifications (JEP-22/JEP-85)
Mikael Berthe <mikael@lilotux.net>
parents:
987
diff
changeset
|
4479 else |
35e7913affb7
Send events/chatstates notifications (JEP-22/JEP-85)
Mikael Berthe <mikael@lilotux.net>
parents:
987
diff
changeset
|
4480 set_chatstate(1); |
991
ef10906691bb
Chatstates: add composing timeout
Mikael Berthe <mikael@lilotux.net>
parents:
990
diff
changeset
|
4481 if (chatstate) |
ef10906691bb
Chatstates: add composing timeout
Mikael Berthe <mikael@lilotux.net>
parents:
990
diff
changeset
|
4482 time(&chatstate_timestamp); |
990
35e7913affb7
Send events/chatstates notifications (JEP-22/JEP-85)
Mikael Berthe <mikael@lilotux.net>
parents:
987
diff
changeset
|
4483 } |
1359
7daf906fbcdc
The command /quit can be used in bindings, hooks and sourced files
Mikael Berthe <mikael@lilotux.net>
parents:
1357
diff
changeset
|
4484 return; |
24 | 4485 } |
576 | 4486 |
1590
8d1bcc83ae32
Add support for spellchecking with Enchant (caolan)
Mikael Berthe <mikael@lilotux.net>
parents:
1579
diff
changeset
|
4487 #if defined(WITH_ENCHANT) || defined(WITH_ASPELL) |
2170
282531385f34
Multilanguage spell checking
Dmitry Potapov <potapov.d@gmail.com>
parents:
2165
diff
changeset
|
4488 static void spell_checker_free(gpointer data) |
282531385f34
Multilanguage spell checking
Dmitry Potapov <potapov.d@gmail.com>
parents:
2165
diff
changeset
|
4489 { |
282531385f34
Multilanguage spell checking
Dmitry Potapov <potapov.d@gmail.com>
parents:
2165
diff
changeset
|
4490 spell_checker* sc = data; |
282531385f34
Multilanguage spell checking
Dmitry Potapov <potapov.d@gmail.com>
parents:
2165
diff
changeset
|
4491 #ifdef WITH_ENCHANT |
282531385f34
Multilanguage spell checking
Dmitry Potapov <potapov.d@gmail.com>
parents:
2165
diff
changeset
|
4492 enchant_broker_free_dict(sc->broker, sc->checker); |
282531385f34
Multilanguage spell checking
Dmitry Potapov <potapov.d@gmail.com>
parents:
2165
diff
changeset
|
4493 enchant_broker_free(sc->broker); |
282531385f34
Multilanguage spell checking
Dmitry Potapov <potapov.d@gmail.com>
parents:
2165
diff
changeset
|
4494 #endif |
282531385f34
Multilanguage spell checking
Dmitry Potapov <potapov.d@gmail.com>
parents:
2165
diff
changeset
|
4495 #ifdef WITH_ASPELL |
282531385f34
Multilanguage spell checking
Dmitry Potapov <potapov.d@gmail.com>
parents:
2165
diff
changeset
|
4496 delete_aspell_speller(sc->checker); |
282531385f34
Multilanguage spell checking
Dmitry Potapov <potapov.d@gmail.com>
parents:
2165
diff
changeset
|
4497 delete_aspell_config(sc->config); |
282531385f34
Multilanguage spell checking
Dmitry Potapov <potapov.d@gmail.com>
parents:
2165
diff
changeset
|
4498 #endif |
282531385f34
Multilanguage spell checking
Dmitry Potapov <potapov.d@gmail.com>
parents:
2165
diff
changeset
|
4499 g_free(sc); |
282531385f34
Multilanguage spell checking
Dmitry Potapov <potapov.d@gmail.com>
parents:
2165
diff
changeset
|
4500 } |
282531385f34
Multilanguage spell checking
Dmitry Potapov <potapov.d@gmail.com>
parents:
2165
diff
changeset
|
4501 |
282531385f34
Multilanguage spell checking
Dmitry Potapov <potapov.d@gmail.com>
parents:
2165
diff
changeset
|
4502 static spell_checker* new_spell_checker(const char* spell_lang) |
282531385f34
Multilanguage spell checking
Dmitry Potapov <potapov.d@gmail.com>
parents:
2165
diff
changeset
|
4503 { |
282531385f34
Multilanguage spell checking
Dmitry Potapov <potapov.d@gmail.com>
parents:
2165
diff
changeset
|
4504 spell_checker* sc = g_new(spell_checker, 1); |
282531385f34
Multilanguage spell checking
Dmitry Potapov <potapov.d@gmail.com>
parents:
2165
diff
changeset
|
4505 #ifdef WITH_ASPELL |
282531385f34
Multilanguage spell checking
Dmitry Potapov <potapov.d@gmail.com>
parents:
2165
diff
changeset
|
4506 const char *spell_encoding = settings_opt_get("spell_encoding"); |
282531385f34
Multilanguage spell checking
Dmitry Potapov <potapov.d@gmail.com>
parents:
2165
diff
changeset
|
4507 AspellCanHaveError *possible_err; |
282531385f34
Multilanguage spell checking
Dmitry Potapov <potapov.d@gmail.com>
parents:
2165
diff
changeset
|
4508 sc->config = new_aspell_config(); |
282531385f34
Multilanguage spell checking
Dmitry Potapov <potapov.d@gmail.com>
parents:
2165
diff
changeset
|
4509 if (spell_encoding) |
282531385f34
Multilanguage spell checking
Dmitry Potapov <potapov.d@gmail.com>
parents:
2165
diff
changeset
|
4510 aspell_config_replace(sc->config, "encoding", spell_encoding); |
282531385f34
Multilanguage spell checking
Dmitry Potapov <potapov.d@gmail.com>
parents:
2165
diff
changeset
|
4511 aspell_config_replace(sc->config, "lang", spell_lang); |
282531385f34
Multilanguage spell checking
Dmitry Potapov <potapov.d@gmail.com>
parents:
2165
diff
changeset
|
4512 possible_err = new_aspell_speller(sc->config); |
282531385f34
Multilanguage spell checking
Dmitry Potapov <potapov.d@gmail.com>
parents:
2165
diff
changeset
|
4513 |
282531385f34
Multilanguage spell checking
Dmitry Potapov <potapov.d@gmail.com>
parents:
2165
diff
changeset
|
4514 if (aspell_error_number(possible_err) != 0) { |
282531385f34
Multilanguage spell checking
Dmitry Potapov <potapov.d@gmail.com>
parents:
2165
diff
changeset
|
4515 delete_aspell_config(sc->config); |
282531385f34
Multilanguage spell checking
Dmitry Potapov <potapov.d@gmail.com>
parents:
2165
diff
changeset
|
4516 g_free(sc); |
282531385f34
Multilanguage spell checking
Dmitry Potapov <potapov.d@gmail.com>
parents:
2165
diff
changeset
|
4517 sc = NULL; |
282531385f34
Multilanguage spell checking
Dmitry Potapov <potapov.d@gmail.com>
parents:
2165
diff
changeset
|
4518 } else { |
282531385f34
Multilanguage spell checking
Dmitry Potapov <potapov.d@gmail.com>
parents:
2165
diff
changeset
|
4519 sc->checker = to_aspell_speller(possible_err); |
282531385f34
Multilanguage spell checking
Dmitry Potapov <potapov.d@gmail.com>
parents:
2165
diff
changeset
|
4520 } |
282531385f34
Multilanguage spell checking
Dmitry Potapov <potapov.d@gmail.com>
parents:
2165
diff
changeset
|
4521 #endif |
282531385f34
Multilanguage spell checking
Dmitry Potapov <potapov.d@gmail.com>
parents:
2165
diff
changeset
|
4522 #ifdef WITH_ENCHANT |
282531385f34
Multilanguage spell checking
Dmitry Potapov <potapov.d@gmail.com>
parents:
2165
diff
changeset
|
4523 sc->broker = enchant_broker_init(); |
282531385f34
Multilanguage spell checking
Dmitry Potapov <potapov.d@gmail.com>
parents:
2165
diff
changeset
|
4524 sc->checker = enchant_broker_request_dict(sc->broker, spell_lang); |
282531385f34
Multilanguage spell checking
Dmitry Potapov <potapov.d@gmail.com>
parents:
2165
diff
changeset
|
4525 if (!sc->checker) { |
282531385f34
Multilanguage spell checking
Dmitry Potapov <potapov.d@gmail.com>
parents:
2165
diff
changeset
|
4526 enchant_broker_free(sc->broker); |
282531385f34
Multilanguage spell checking
Dmitry Potapov <potapov.d@gmail.com>
parents:
2165
diff
changeset
|
4527 g_free(sc); |
282531385f34
Multilanguage spell checking
Dmitry Potapov <potapov.d@gmail.com>
parents:
2165
diff
changeset
|
4528 sc = NULL; |
282531385f34
Multilanguage spell checking
Dmitry Potapov <potapov.d@gmail.com>
parents:
2165
diff
changeset
|
4529 } |
282531385f34
Multilanguage spell checking
Dmitry Potapov <potapov.d@gmail.com>
parents:
2165
diff
changeset
|
4530 #endif |
282531385f34
Multilanguage spell checking
Dmitry Potapov <potapov.d@gmail.com>
parents:
2165
diff
changeset
|
4531 return sc; |
282531385f34
Multilanguage spell checking
Dmitry Potapov <potapov.d@gmail.com>
parents:
2165
diff
changeset
|
4532 } |
282531385f34
Multilanguage spell checking
Dmitry Potapov <potapov.d@gmail.com>
parents:
2165
diff
changeset
|
4533 |
1590
8d1bcc83ae32
Add support for spellchecking with Enchant (caolan)
Mikael Berthe <mikael@lilotux.net>
parents:
1579
diff
changeset
|
4534 // initialization |
1179 | 4535 void spellcheck_init(void) |
4536 { | |
1590
8d1bcc83ae32
Add support for spellchecking with Enchant (caolan)
Mikael Berthe <mikael@lilotux.net>
parents:
1579
diff
changeset
|
4537 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
|
4538 const char *spell_lang = settings_opt_get("spell_lang"); |
2170
282531385f34
Multilanguage spell checking
Dmitry Potapov <potapov.d@gmail.com>
parents:
2165
diff
changeset
|
4539 gchar** langs; |
282531385f34
Multilanguage spell checking
Dmitry Potapov <potapov.d@gmail.com>
parents:
2165
diff
changeset
|
4540 gchar** lang_iter; |
282531385f34
Multilanguage spell checking
Dmitry Potapov <potapov.d@gmail.com>
parents:
2165
diff
changeset
|
4541 spell_checker* sc; |
1590
8d1bcc83ae32
Add support for spellchecking with Enchant (caolan)
Mikael Berthe <mikael@lilotux.net>
parents:
1579
diff
changeset
|
4542 |
8d1bcc83ae32
Add support for spellchecking with Enchant (caolan)
Mikael Berthe <mikael@lilotux.net>
parents:
1579
diff
changeset
|
4543 if (!spell_enable) |
1179 | 4544 return; |
4545 | |
2170
282531385f34
Multilanguage spell checking
Dmitry Potapov <potapov.d@gmail.com>
parents:
2165
diff
changeset
|
4546 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
|
4547 |
db8ec238cd2c
Fix segfault when spell checking is enabled and spell_lang is not set.
Mikael Berthe <mikael@lilotux.net>
parents:
2013
diff
changeset
|
4548 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
|
4549 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
|
4550 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
|
4551 return; |
db8ec238cd2c
Fix segfault when spell checking is enabled and spell_lang is not set.
Mikael Berthe <mikael@lilotux.net>
parents:
2013
diff
changeset
|
4552 } |
db8ec238cd2c
Fix segfault when spell checking is enabled and spell_lang is not set.
Mikael Berthe <mikael@lilotux.net>
parents:
2013
diff
changeset
|
4553 |
2170
282531385f34
Multilanguage spell checking
Dmitry Potapov <potapov.d@gmail.com>
parents:
2165
diff
changeset
|
4554 langs = g_strsplit(spell_lang, " ", -1); |
282531385f34
Multilanguage spell checking
Dmitry Potapov <potapov.d@gmail.com>
parents:
2165
diff
changeset
|
4555 for (lang_iter = langs; *lang_iter; ++lang_iter) { |
282531385f34
Multilanguage spell checking
Dmitry Potapov <potapov.d@gmail.com>
parents:
2165
diff
changeset
|
4556 if (**lang_iter) { // Skip empty strings |
282531385f34
Multilanguage spell checking
Dmitry Potapov <potapov.d@gmail.com>
parents:
2165
diff
changeset
|
4557 sc = new_spell_checker(*lang_iter); |
282531385f34
Multilanguage spell checking
Dmitry Potapov <potapov.d@gmail.com>
parents:
2165
diff
changeset
|
4558 if (sc) { |
282531385f34
Multilanguage spell checking
Dmitry Potapov <potapov.d@gmail.com>
parents:
2165
diff
changeset
|
4559 spell_checkers = g_slist_append(spell_checkers, sc); |
282531385f34
Multilanguage spell checking
Dmitry Potapov <potapov.d@gmail.com>
parents:
2165
diff
changeset
|
4560 } |
282531385f34
Multilanguage spell checking
Dmitry Potapov <potapov.d@gmail.com>
parents:
2165
diff
changeset
|
4561 } |
1179 | 4562 } |
2170
282531385f34
Multilanguage spell checking
Dmitry Potapov <potapov.d@gmail.com>
parents:
2165
diff
changeset
|
4563 g_strfreev(langs); |
1179 | 4564 } |
4565 | |
1590
8d1bcc83ae32
Add support for spellchecking with Enchant (caolan)
Mikael Berthe <mikael@lilotux.net>
parents:
1579
diff
changeset
|
4566 // Deinitialization of spellchecker |
1179 | 4567 void spellcheck_deinit(void) |
4568 { | |
2170
282531385f34
Multilanguage spell checking
Dmitry Potapov <potapov.d@gmail.com>
parents:
2165
diff
changeset
|
4569 g_slist_free_full(spell_checkers, spell_checker_free); |
282531385f34
Multilanguage spell checking
Dmitry Potapov <potapov.d@gmail.com>
parents:
2165
diff
changeset
|
4570 spell_checkers = NULL; |
282531385f34
Multilanguage spell checking
Dmitry Potapov <potapov.d@gmail.com>
parents:
2165
diff
changeset
|
4571 } |
282531385f34
Multilanguage spell checking
Dmitry Potapov <potapov.d@gmail.com>
parents:
2165
diff
changeset
|
4572 |
282531385f34
Multilanguage spell checking
Dmitry Potapov <potapov.d@gmail.com>
parents:
2165
diff
changeset
|
4573 typedef struct { |
282531385f34
Multilanguage spell checking
Dmitry Potapov <potapov.d@gmail.com>
parents:
2165
diff
changeset
|
4574 const char* str; |
282531385f34
Multilanguage spell checking
Dmitry Potapov <potapov.d@gmail.com>
parents:
2165
diff
changeset
|
4575 int len; |
282531385f34
Multilanguage spell checking
Dmitry Potapov <potapov.d@gmail.com>
parents:
2165
diff
changeset
|
4576 } spell_substring; |
282531385f34
Multilanguage spell checking
Dmitry Potapov <potapov.d@gmail.com>
parents:
2165
diff
changeset
|
4577 |
282531385f34
Multilanguage spell checking
Dmitry Potapov <potapov.d@gmail.com>
parents:
2165
diff
changeset
|
4578 static int spellcheckword(gconstpointer sc_ptr, gconstpointer substr_ptr) |
282531385f34
Multilanguage spell checking
Dmitry Potapov <potapov.d@gmail.com>
parents:
2165
diff
changeset
|
4579 { |
282531385f34
Multilanguage spell checking
Dmitry Potapov <potapov.d@gmail.com>
parents:
2165
diff
changeset
|
4580 spell_checker* sc = (spell_checker*) sc_ptr; |
282531385f34
Multilanguage spell checking
Dmitry Potapov <potapov.d@gmail.com>
parents:
2165
diff
changeset
|
4581 spell_substring* substr = (spell_substring*) substr_ptr; |
1590
8d1bcc83ae32
Add support for spellchecking with Enchant (caolan)
Mikael Berthe <mikael@lilotux.net>
parents:
1579
diff
changeset
|
4582 #ifdef WITH_ENCHANT |
2170
282531385f34
Multilanguage spell checking
Dmitry Potapov <potapov.d@gmail.com>
parents:
2165
diff
changeset
|
4583 // enchant_dict_check will return 0 on good word |
282531385f34
Multilanguage spell checking
Dmitry Potapov <potapov.d@gmail.com>
parents:
2165
diff
changeset
|
4584 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
|
4585 #endif |
8d1bcc83ae32
Add support for spellchecking with Enchant (caolan)
Mikael Berthe <mikael@lilotux.net>
parents:
1579
diff
changeset
|
4586 #ifdef WITH_ASPELL |
2170
282531385f34
Multilanguage spell checking
Dmitry Potapov <potapov.d@gmail.com>
parents:
2165
diff
changeset
|
4587 // 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
|
4588 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
|
4589 #endif |
2170
282531385f34
Multilanguage spell checking
Dmitry Potapov <potapov.d@gmail.com>
parents:
2165
diff
changeset
|
4590 return 0; // Keep compiler happy |
1179 | 4591 } |
4592 | |
1590
8d1bcc83ae32
Add support for spellchecking with Enchant (caolan)
Mikael Berthe <mikael@lilotux.net>
parents:
1579
diff
changeset
|
4593 #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
|
4594 |
1179 | 4595 // Spell checking function |
4596 static void spellcheck(char *line, char *checked) | |
4597 { | |
4598 const char *start, *line_start; | |
2170
282531385f34
Multilanguage spell checking
Dmitry Potapov <potapov.d@gmail.com>
parents:
2165
diff
changeset
|
4599 spell_substring substr; |
1179 | 4600 |
4601 if (inputLine[0] == 0 || inputLine[0] == COMMAND_CHAR) | |
4602 return; | |
4603 | |
4604 line_start = line; | |
4605 | |
4606 while (*line) { | |
4607 | |
1590
8d1bcc83ae32
Add support for spellchecking with Enchant (caolan)
Mikael Berthe <mikael@lilotux.net>
parents:
1579
diff
changeset
|
4608 if (!spell_isalpha(line)) { |
1179 | 4609 line = next_char(line); |
4610 continue; | |
4611 } | |
4612 | |
4613 if (!strncmp(line, "http://", 7)) { | |
4614 line += 7; // : and / characters are 1 byte long in utf8, right? | |
4615 | |
4616 while (!strchr(" \t\r\n", *line)) | |
4617 line = next_char(line); // i think line++ would be fine here? | |
4618 | |
4619 continue; | |
4620 } | |
4621 | |
4622 if (!strncmp(line, "ftp://", 6)) { | |
4623 line += 6; | |
4624 | |
4625 while (!strchr(" \t\r\n", *line)) | |
4626 line = next_char(line); | |
4627 | |
4628 continue; | |
4629 } | |
4630 | |
4631 start = line; | |
4632 | |
1590
8d1bcc83ae32
Add support for spellchecking with Enchant (caolan)
Mikael Berthe <mikael@lilotux.net>
parents:
1579
diff
changeset
|
4633 while (spell_isalpha(line)) |
1179 | 4634 line = next_char(line); |
4635 | |
2170
282531385f34
Multilanguage spell checking
Dmitry Potapov <potapov.d@gmail.com>
parents:
2165
diff
changeset
|
4636 substr.str = start; |
282531385f34
Multilanguage spell checking
Dmitry Potapov <potapov.d@gmail.com>
parents:
2165
diff
changeset
|
4637 substr.len = line - start; |
282531385f34
Multilanguage spell checking
Dmitry Potapov <potapov.d@gmail.com>
parents:
2165
diff
changeset
|
4638 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
|
4639 memset(&checked[start - line_start], SPELLBADCHAR, line - start); |
1179 | 4640 } |
4641 } | |
4642 #endif | |
4643 | |
1811 | 4644 /* vim: set et cindent cinoptions=>2\:2(0 ts=2 sw=2: For Vim users... */ |