author | Mikael Berthe <mikael@lilotux.net> |
Sat, 27 May 2006 13:22:06 +0200 | |
changeset 878 | c7ba6f41d056 |
parent 874 | 293e8955075c |
child 880 | ea983a945eba |
permissions | -rw-r--r-- |
307 | 1 |
/* |
2 |
* screen.c -- UI stuff |
|
393 | 3 |
* |
699 | 4 |
* Copyright (C) 2005, 2006 Mikael Berthe <bmikael@lists.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 <ncurses.h> |
|
27 |
#include <panel.h> |
|
28 |
#include <time.h> |
|
29 |
#include <ctype.h> |
|
30 |
#include <locale.h> |
|
232 | 31 |
#include <langinfo.h> |
24 | 32 |
|
33 |
#include "screen.h" |
|
81 | 34 |
#include "hbuf.h" |
47 | 35 |
#include "commands.h" |
95 | 36 |
#include "compl.h" |
81 | 37 |
#include "roster.h" |
180 | 38 |
#include "histolog.h" |
279
f5dd437c057b
Rewrite the settings system
Mikael Berthe <mikael@lilotux.net>
parents:
276
diff
changeset
|
39 |
#include "settings.h" |
81 | 40 |
#include "utils.h" |
24 | 41 |
|
739
0d5fb1d9077c
Allow "bright" text colors
Mikael Berthe <mikael@lilotux.net>
parents:
735
diff
changeset
|
42 |
#define get_color(col) (COLOR_PAIR(col)|COLOR_ATTRIB[col]) |
24 | 43 |
|
515
180f0a6e4ac9
Log window's height can be set by the user
Mikael Berthe <mikael@lilotux.net>
parents:
514
diff
changeset
|
44 |
#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
|
45 |
#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
|
46 |
#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
|
47 |
|
592
67a332121aea
Try UTF8 -> locale conversion with fallback
Mikael Berthe <mikael@lilotux.net>
parents:
580
diff
changeset
|
48 |
char *LocaleCharSet = "C"; |
67a332121aea
Try UTF8 -> locale conversion with fallback
Mikael Berthe <mikael@lilotux.net>
parents:
580
diff
changeset
|
49 |
|
515
180f0a6e4ac9
Log window's height can be set by the user
Mikael Berthe <mikael@lilotux.net>
parents:
514
diff
changeset
|
50 |
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
|
51 |
static unsigned short int Roster_Width; |
515
180f0a6e4ac9
Log window's height can be set by the user
Mikael Berthe <mikael@lilotux.net>
parents:
514
diff
changeset
|
52 |
|
336
eb994ee40029
Make some functions static
Mikael Berthe <mikael@lilotux.net>
parents:
332
diff
changeset
|
53 |
static inline void check_offset(int); |
151 | 54 |
|
822 | 55 |
static GSList *winbuflst; |
24 | 56 |
|
822 | 57 |
typedef struct { |
24 | 58 |
WINDOW *win; |
108 | 59 |
PANEL *panel; |
60 |
char *name; |
|
61 |
GList *hbuf; |
|
181 | 62 |
GList *top; // If top is NULL, we'll display the last lines |
63 |
char cleared; // For ex, user has issued a /clear command... |
|
873
ee39f6d94d43
Add /buffer {scroll_lock|scroll_unlock|toggle_scroll}
Mikael Berthe <mikael@lilotux.net>
parents:
866
diff
changeset
|
64 |
char lock; |
822 | 65 |
} winbuf; |
24 | 66 |
|
67 |
||
711 | 68 |
static WINDOW *rosterWnd, *chatWnd, *inputWnd, *logWnd; |
69 |
static WINDOW *mainstatusWnd, *chatstatusWnd; |
|
24 | 70 |
static PANEL *rosterPanel, *chatPanel, *inputPanel; |
711 | 71 |
static PANEL *mainstatusPanel, *chatstatusPanel; |
72 |
static PANEL *logPanel; |
|
24 | 73 |
static int maxY, maxX; |
849
42c43a88d823
Status buffer management
Mikael Berthe <mikael@lilotux.net>
parents:
848
diff
changeset
|
74 |
static winbuf *statusWindow; |
822 | 75 |
static winbuf *currentWindow; |
851
da03534e46c7
Add startup log messages to the status buffer
Mikael Berthe <mikael@lilotux.net>
parents:
850
diff
changeset
|
76 |
static GList *statushbuf; |
24 | 77 |
|
707
b26a0bde4cdb
Add /roster hide|show|toggle
Mikael Berthe <mikael@lilotux.net>
parents:
701
diff
changeset
|
78 |
static int roster_hidden; |
24 | 79 |
static int chatmode; |
238 | 80 |
static int multimode; |
807
f6cda389db48
Allow messages with a subject (/msay)
Mikael Berthe <mikael@lilotux.net>
parents:
806
diff
changeset
|
81 |
static char *multiline, *multimode_subj; |
30 | 82 |
int update_roster; |
232 | 83 |
int utf8_mode = 0; |
322
da138cdebf04
Implement auto-away mode
Mikael Berthe <mikael@lilotux.net>
parents:
314
diff
changeset
|
84 |
static bool Autoaway; |
332
a1901741890e
scr_LogPrint() can be called before ncurses initialization
Mikael Berthe <mikael@lilotux.net>
parents:
330
diff
changeset
|
85 |
static bool Curses; |
24 | 86 |
|
174 | 87 |
static char inputLine[INPUTLINE_LENGTH+1]; |
88 |
static char *ptr_inputline; |
|
89 |
static short int inputline_offset; |
|
90 |
static int completion_started; |
|
173 | 91 |
static GList *cmdhisto; |
92 |
static GList *cmdhisto_cur; |
|
174 | 93 |
static char cmdhisto_backup[INPUTLINE_LENGTH+1]; |
24 | 94 |
|
761
4532a9fe0e8c
Handle some keyboard escape sequences
Mikael Berthe <mikael@lilotux.net>
parents:
760
diff
changeset
|
95 |
#define MAX_KEYSEQ_LENGTH 8 |
4532a9fe0e8c
Handle some keyboard escape sequences
Mikael Berthe <mikael@lilotux.net>
parents:
760
diff
changeset
|
96 |
|
4532a9fe0e8c
Handle some keyboard escape sequences
Mikael Berthe <mikael@lilotux.net>
parents:
760
diff
changeset
|
97 |
typedef struct { |
4532a9fe0e8c
Handle some keyboard escape sequences
Mikael Berthe <mikael@lilotux.net>
parents:
760
diff
changeset
|
98 |
char *seqstr; |
4532a9fe0e8c
Handle some keyboard escape sequences
Mikael Berthe <mikael@lilotux.net>
parents:
760
diff
changeset
|
99 |
guint mkeycode; |
4532a9fe0e8c
Handle some keyboard escape sequences
Mikael Berthe <mikael@lilotux.net>
parents:
760
diff
changeset
|
100 |
gint value; |
4532a9fe0e8c
Handle some keyboard escape sequences
Mikael Berthe <mikael@lilotux.net>
parents:
760
diff
changeset
|
101 |
} keyseq; |
4532a9fe0e8c
Handle some keyboard escape sequences
Mikael Berthe <mikael@lilotux.net>
parents:
760
diff
changeset
|
102 |
|
4532a9fe0e8c
Handle some keyboard escape sequences
Mikael Berthe <mikael@lilotux.net>
parents:
760
diff
changeset
|
103 |
GSList *keyseqlist; |
4532a9fe0e8c
Handle some keyboard escape sequences
Mikael Berthe <mikael@lilotux.net>
parents:
760
diff
changeset
|
104 |
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
|
105 |
|
850
d0781ca2dd08
Use new status buffer window
Mikael Berthe <mikael@lilotux.net>
parents:
849
diff
changeset
|
106 |
void scr_WriteInWindow(const char *winId, const char *text, time_t timestamp, |
d0781ca2dd08
Use new status buffer window
Mikael Berthe <mikael@lilotux.net>
parents:
849
diff
changeset
|
107 |
unsigned int prefix_flags, int force_show); |
d0781ca2dd08
Use new status buffer window
Mikael Berthe <mikael@lilotux.net>
parents:
849
diff
changeset
|
108 |
|
24 | 109 |
|
99 | 110 |
/* Functions */ |
24 | 111 |
|
336
eb994ee40029
Make some functions static
Mikael Berthe <mikael@lilotux.net>
parents:
332
diff
changeset
|
112 |
static int scr_WindowWidth(WINDOW * win) |
24 | 113 |
{ |
114 |
int x, y; |
|
115 |
getmaxyx(win, y, x); |
|
116 |
return x; |
|
117 |
} |
|
118 |
||
336
eb994ee40029
Make some functions static
Mikael Berthe <mikael@lilotux.net>
parents:
332
diff
changeset
|
119 |
static int FindColor(const char *name) |
24 | 120 |
{ |
121 |
if (!strcmp(name, "default")) |
|
122 |
return -1; |
|
123 |
if (!strcmp(name, "black")) |
|
124 |
return COLOR_BLACK; |
|
125 |
if (!strcmp(name, "red")) |
|
126 |
return COLOR_RED; |
|
127 |
if (!strcmp(name, "green")) |
|
128 |
return COLOR_GREEN; |
|
129 |
if (!strcmp(name, "yellow")) |
|
130 |
return COLOR_YELLOW; |
|
131 |
if (!strcmp(name, "blue")) |
|
132 |
return COLOR_BLUE; |
|
133 |
if (!strcmp(name, "magenta")) |
|
134 |
return COLOR_MAGENTA; |
|
135 |
if (!strcmp(name, "cyan")) |
|
136 |
return COLOR_CYAN; |
|
137 |
if (!strcmp(name, "white")) |
|
138 |
return COLOR_WHITE; |
|
139 |
||
739
0d5fb1d9077c
Allow "bright" text colors
Mikael Berthe <mikael@lilotux.net>
parents:
735
diff
changeset
|
140 |
scr_LogPrint(LPRINT_LOGNORM, "ERROR: Wrong color: %s", name); |
24 | 141 |
return -1; |
142 |
} |
|
143 |
||
336
eb994ee40029
Make some functions static
Mikael Berthe <mikael@lilotux.net>
parents:
332
diff
changeset
|
144 |
static void ParseColors(void) |
24 | 145 |
{ |
739
0d5fb1d9077c
Allow "bright" text colors
Mikael Berthe <mikael@lilotux.net>
parents:
735
diff
changeset
|
146 |
const char *colors[] = { |
24 | 147 |
"", "", |
267 | 148 |
"general", |
785
7e0562e3bc83
Replace color_highlight with color_msgout
Mikael Berthe <mikael@lilotux.net>
parents:
779
diff
changeset
|
149 |
"msgout", |
711 | 150 |
"status", |
712 | 151 |
"roster", |
152 |
"rostersel", |
|
723
23068490d063
Add text color when the selected buddy has an unread message
Mikael Berthe <mikael@lilotux.net>
parents:
721
diff
changeset
|
153 |
"rosterselmsg", |
712 | 154 |
"rosternewmsg", |
24 | 155 |
NULL |
156 |
}; |
|
157 |
||
281
f562b9af2de7
Add "const" specifier in prototypes
Mikael Berthe <mikael@lilotux.net>
parents:
279
diff
changeset
|
158 |
const char *color; |
f562b9af2de7
Add "const" specifier in prototypes
Mikael Berthe <mikael@lilotux.net>
parents:
279
diff
changeset
|
159 |
const char *background = settings_opt_get("color_background"); |
712 | 160 |
const char *backselected = settings_opt_get("color_bgrostersel"); |
161 |
const char *backstatus = settings_opt_get("color_bgstatus"); |
|
739
0d5fb1d9077c
Allow "bright" text colors
Mikael Berthe <mikael@lilotux.net>
parents:
735
diff
changeset
|
162 |
char *tmp; |
0d5fb1d9077c
Allow "bright" text colors
Mikael Berthe <mikael@lilotux.net>
parents:
735
diff
changeset
|
163 |
int i; |
0d5fb1d9077c
Allow "bright" text colors
Mikael Berthe <mikael@lilotux.net>
parents:
735
diff
changeset
|
164 |
|
0d5fb1d9077c
Allow "bright" text colors
Mikael Berthe <mikael@lilotux.net>
parents:
735
diff
changeset
|
165 |
// Initialize color attributes |
0d5fb1d9077c
Allow "bright" text colors
Mikael Berthe <mikael@lilotux.net>
parents:
735
diff
changeset
|
166 |
memset(COLOR_ATTRIB, 0, sizeof(COLOR_ATTRIB)); |
24 | 167 |
|
267 | 168 |
// Default values |
711 | 169 |
if (!background) background = "black"; |
267 | 170 |
if (!backselected) backselected = "cyan"; |
711 | 171 |
if (!backstatus) backstatus = "blue"; |
267 | 172 |
|
739
0d5fb1d9077c
Allow "bright" text colors
Mikael Berthe <mikael@lilotux.net>
parents:
735
diff
changeset
|
173 |
for (i=0; colors[i]; i++) { |
0d5fb1d9077c
Allow "bright" text colors
Mikael Berthe <mikael@lilotux.net>
parents:
735
diff
changeset
|
174 |
tmp = g_strdup_printf("color_%s", colors[i]); |
279
f5dd437c057b
Rewrite the settings system
Mikael Berthe <mikael@lilotux.net>
parents:
276
diff
changeset
|
175 |
color = settings_opt_get(tmp); |
739
0d5fb1d9077c
Allow "bright" text colors
Mikael Berthe <mikael@lilotux.net>
parents:
735
diff
changeset
|
176 |
g_free(tmp); |
0d5fb1d9077c
Allow "bright" text colors
Mikael Berthe <mikael@lilotux.net>
parents:
735
diff
changeset
|
177 |
|
0d5fb1d9077c
Allow "bright" text colors
Mikael Berthe <mikael@lilotux.net>
parents:
735
diff
changeset
|
178 |
if (color) { |
0d5fb1d9077c
Allow "bright" text colors
Mikael Berthe <mikael@lilotux.net>
parents:
735
diff
changeset
|
179 |
if (!strncmp(color, "bright", 6)) { |
0d5fb1d9077c
Allow "bright" text colors
Mikael Berthe <mikael@lilotux.net>
parents:
735
diff
changeset
|
180 |
COLOR_ATTRIB[i+1] = A_BOLD; |
0d5fb1d9077c
Allow "bright" text colors
Mikael Berthe <mikael@lilotux.net>
parents:
735
diff
changeset
|
181 |
color += 6; |
0d5fb1d9077c
Allow "bright" text colors
Mikael Berthe <mikael@lilotux.net>
parents:
735
diff
changeset
|
182 |
} |
0d5fb1d9077c
Allow "bright" text colors
Mikael Berthe <mikael@lilotux.net>
parents:
735
diff
changeset
|
183 |
} |
24 | 184 |
|
185 |
switch (i + 1) { |
|
739
0d5fb1d9077c
Allow "bright" text colors
Mikael Berthe <mikael@lilotux.net>
parents:
735
diff
changeset
|
186 |
case 1: |
0d5fb1d9077c
Allow "bright" text colors
Mikael Berthe <mikael@lilotux.net>
parents:
735
diff
changeset
|
187 |
init_pair(1, COLOR_BLACK, COLOR_WHITE); |
0d5fb1d9077c
Allow "bright" text colors
Mikael Berthe <mikael@lilotux.net>
parents:
735
diff
changeset
|
188 |
break; |
0d5fb1d9077c
Allow "bright" text colors
Mikael Berthe <mikael@lilotux.net>
parents:
735
diff
changeset
|
189 |
case 2: |
0d5fb1d9077c
Allow "bright" text colors
Mikael Berthe <mikael@lilotux.net>
parents:
735
diff
changeset
|
190 |
init_pair(2, COLOR_WHITE, COLOR_BLACK); |
0d5fb1d9077c
Allow "bright" text colors
Mikael Berthe <mikael@lilotux.net>
parents:
735
diff
changeset
|
191 |
break; |
0d5fb1d9077c
Allow "bright" text colors
Mikael Berthe <mikael@lilotux.net>
parents:
735
diff
changeset
|
192 |
case COLOR_GENERAL: |
0d5fb1d9077c
Allow "bright" text colors
Mikael Berthe <mikael@lilotux.net>
parents:
735
diff
changeset
|
193 |
init_pair(i+1, ((color) ? FindColor(color) : COLOR_WHITE), |
0d5fb1d9077c
Allow "bright" text colors
Mikael Berthe <mikael@lilotux.net>
parents:
735
diff
changeset
|
194 |
FindColor(background)); |
0d5fb1d9077c
Allow "bright" text colors
Mikael Berthe <mikael@lilotux.net>
parents:
735
diff
changeset
|
195 |
break; |
785
7e0562e3bc83
Replace color_highlight with color_msgout
Mikael Berthe <mikael@lilotux.net>
parents:
779
diff
changeset
|
196 |
case COLOR_MSGOUT: |
739
0d5fb1d9077c
Allow "bright" text colors
Mikael Berthe <mikael@lilotux.net>
parents:
735
diff
changeset
|
197 |
init_pair(i+1, ((color) ? FindColor(color) : COLOR_CYAN), |
0d5fb1d9077c
Allow "bright" text colors
Mikael Berthe <mikael@lilotux.net>
parents:
735
diff
changeset
|
198 |
FindColor(background)); |
0d5fb1d9077c
Allow "bright" text colors
Mikael Berthe <mikael@lilotux.net>
parents:
735
diff
changeset
|
199 |
break; |
0d5fb1d9077c
Allow "bright" text colors
Mikael Berthe <mikael@lilotux.net>
parents:
735
diff
changeset
|
200 |
case COLOR_STATUS: |
0d5fb1d9077c
Allow "bright" text colors
Mikael Berthe <mikael@lilotux.net>
parents:
735
diff
changeset
|
201 |
init_pair(i+1, ((color) ? FindColor(color) : COLOR_WHITE), |
0d5fb1d9077c
Allow "bright" text colors
Mikael Berthe <mikael@lilotux.net>
parents:
735
diff
changeset
|
202 |
FindColor(backstatus)); |
0d5fb1d9077c
Allow "bright" text colors
Mikael Berthe <mikael@lilotux.net>
parents:
735
diff
changeset
|
203 |
break; |
0d5fb1d9077c
Allow "bright" text colors
Mikael Berthe <mikael@lilotux.net>
parents:
735
diff
changeset
|
204 |
case COLOR_ROSTER: |
0d5fb1d9077c
Allow "bright" text colors
Mikael Berthe <mikael@lilotux.net>
parents:
735
diff
changeset
|
205 |
init_pair(i+1, ((color) ? FindColor(color) : COLOR_GREEN), |
0d5fb1d9077c
Allow "bright" text colors
Mikael Berthe <mikael@lilotux.net>
parents:
735
diff
changeset
|
206 |
FindColor(background)); |
0d5fb1d9077c
Allow "bright" text colors
Mikael Berthe <mikael@lilotux.net>
parents:
735
diff
changeset
|
207 |
break; |
0d5fb1d9077c
Allow "bright" text colors
Mikael Berthe <mikael@lilotux.net>
parents:
735
diff
changeset
|
208 |
case COLOR_ROSTERSEL: |
0d5fb1d9077c
Allow "bright" text colors
Mikael Berthe <mikael@lilotux.net>
parents:
735
diff
changeset
|
209 |
init_pair(i+1, ((color) ? FindColor(color) : COLOR_BLUE), |
0d5fb1d9077c
Allow "bright" text colors
Mikael Berthe <mikael@lilotux.net>
parents:
735
diff
changeset
|
210 |
FindColor(backselected)); |
0d5fb1d9077c
Allow "bright" text colors
Mikael Berthe <mikael@lilotux.net>
parents:
735
diff
changeset
|
211 |
break; |
0d5fb1d9077c
Allow "bright" text colors
Mikael Berthe <mikael@lilotux.net>
parents:
735
diff
changeset
|
212 |
case COLOR_ROSTERSELNMSG: |
0d5fb1d9077c
Allow "bright" text colors
Mikael Berthe <mikael@lilotux.net>
parents:
735
diff
changeset
|
213 |
init_pair(i+1, ((color) ? FindColor(color) : COLOR_RED), |
0d5fb1d9077c
Allow "bright" text colors
Mikael Berthe <mikael@lilotux.net>
parents:
735
diff
changeset
|
214 |
FindColor(backselected)); |
0d5fb1d9077c
Allow "bright" text colors
Mikael Berthe <mikael@lilotux.net>
parents:
735
diff
changeset
|
215 |
break; |
0d5fb1d9077c
Allow "bright" text colors
Mikael Berthe <mikael@lilotux.net>
parents:
735
diff
changeset
|
216 |
case COLOR_ROSTERNMSG: |
0d5fb1d9077c
Allow "bright" text colors
Mikael Berthe <mikael@lilotux.net>
parents:
735
diff
changeset
|
217 |
init_pair(i+1, ((color) ? FindColor(color) : COLOR_RED), |
0d5fb1d9077c
Allow "bright" text colors
Mikael Berthe <mikael@lilotux.net>
parents:
735
diff
changeset
|
218 |
FindColor(background)); |
0d5fb1d9077c
Allow "bright" text colors
Mikael Berthe <mikael@lilotux.net>
parents:
735
diff
changeset
|
219 |
break; |
24 | 220 |
} |
221 |
} |
|
222 |
} |
|
223 |
||
765
72626e9d60bd
Create init_keycodes(), add 2 screen escape sequences
Mikael Berthe <mikael@lilotux.net>
parents:
764
diff
changeset
|
224 |
static void init_keycodes(void) |
373
af2f8ddf6a1b
Move (reorganize) functions
Mikael Berthe <mikael@lilotux.net>
parents:
370
diff
changeset
|
225 |
{ |
761
4532a9fe0e8c
Handle some keyboard escape sequences
Mikael Berthe <mikael@lilotux.net>
parents:
760
diff
changeset
|
226 |
add_keyseq("O5A", MKEY_EQUIV, 521); // Ctrl-Up |
4532a9fe0e8c
Handle some keyboard escape sequences
Mikael Berthe <mikael@lilotux.net>
parents:
760
diff
changeset
|
227 |
add_keyseq("O5B", MKEY_EQUIV, 514); // Ctrl-Down |
4532a9fe0e8c
Handle some keyboard escape sequences
Mikael Berthe <mikael@lilotux.net>
parents:
760
diff
changeset
|
228 |
add_keyseq("O5C", MKEY_EQUIV, 518); // Ctrl-Right |
4532a9fe0e8c
Handle some keyboard escape sequences
Mikael Berthe <mikael@lilotux.net>
parents:
760
diff
changeset
|
229 |
add_keyseq("O5D", MKEY_EQUIV, 516); // Ctrl-Left |
763 | 230 |
add_keyseq("O6A", MKEY_EQUIV, 520); // Shift-Up |
231 |
add_keyseq("O6B", MKEY_EQUIV, 513); // Shift-Down |
|
232 |
add_keyseq("O6C", MKEY_EQUIV, 402); // Shift-Right |
|
233 |
add_keyseq("O6D", MKEY_EQUIV, 393); // Shift-Left |
|
234 |
add_keyseq("O2A", MKEY_EQUIV, 520); // Shift-Up |
|
235 |
add_keyseq("O2B", MKEY_EQUIV, 513); // Shift-Down |
|
236 |
add_keyseq("O2C", MKEY_EQUIV, 402); // Shift-Right |
|
237 |
add_keyseq("O2D", MKEY_EQUIV, 393); // Shift-Left |
|
238 |
add_keyseq("[5^", MKEY_CTRL_PGUP, 0); // Ctrl-PageUp |
|
239 |
add_keyseq("[6^", MKEY_CTRL_PGDOWN, 0); // Ctrl-PageDown |
|
240 |
add_keyseq("[5@", MKEY_CTRL_SHIFT_PGUP, 0); // Ctrl-Shift-PageUp |
|
241 |
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
|
242 |
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
|
243 |
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
|
244 |
add_keyseq("[8^", MKEY_CTRL_END, 0); // Ctrl-End |
32d5298f9f8d
Add a few keycode sequences
Mikael Berthe <mikael@lilotux.net>
parents:
790
diff
changeset
|
245 |
add_keyseq("[7^", MKEY_CTRL_HOME, 0); // Ctrl-Home |
32d5298f9f8d
Add a few keycode sequences
Mikael Berthe <mikael@lilotux.net>
parents:
790
diff
changeset
|
246 |
add_keyseq("[2^", MKEY_CTRL_INS, 0); // Ctrl-Insert |
32d5298f9f8d
Add a few keycode sequences
Mikael Berthe <mikael@lilotux.net>
parents:
790
diff
changeset
|
247 |
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
|
248 |
|
4532a9fe0e8c
Handle some keyboard escape sequences
Mikael Berthe <mikael@lilotux.net>
parents:
760
diff
changeset
|
249 |
// Xterm |
4532a9fe0e8c
Handle some keyboard escape sequences
Mikael Berthe <mikael@lilotux.net>
parents:
760
diff
changeset
|
250 |
add_keyseq("[1;5A", MKEY_EQUIV, 521); // Ctrl-Up |
4532a9fe0e8c
Handle some keyboard escape sequences
Mikael Berthe <mikael@lilotux.net>
parents:
760
diff
changeset
|
251 |
add_keyseq("[1;5B", MKEY_EQUIV, 514); // Ctrl-Down |
4532a9fe0e8c
Handle some keyboard escape sequences
Mikael Berthe <mikael@lilotux.net>
parents:
760
diff
changeset
|
252 |
add_keyseq("[1;5C", MKEY_EQUIV, 518); // Ctrl-Right |
4532a9fe0e8c
Handle some keyboard escape sequences
Mikael Berthe <mikael@lilotux.net>
parents:
760
diff
changeset
|
253 |
add_keyseq("[1;5D", MKEY_EQUIV, 516); // Ctrl-Left |
4532a9fe0e8c
Handle some keyboard escape sequences
Mikael Berthe <mikael@lilotux.net>
parents:
760
diff
changeset
|
254 |
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
|
255 |
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
|
256 |
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
|
257 |
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
|
258 |
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
|
259 |
add_keyseq("[1;6F", MKEY_CTRL_SHIFT_END, 0); // Ctrl-Shift-End |
763 | 260 |
add_keyseq("[1;2A", MKEY_EQUIV, 521); // Shift-Up |
261 |
add_keyseq("[1;2B", MKEY_EQUIV, 514); // Shift-Down |
|
262 |
add_keyseq("[5;5~", MKEY_CTRL_PGUP, 0); // Ctrl-PageUp |
|
263 |
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
|
264 |
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
|
265 |
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
|
266 |
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
|
267 |
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
|
268 |
|
768
0f6d25a02450
Add PuTTY escape keys for Ctrl-arrows
Mikael Berthe <mikael@lilotux.net>
parents:
766
diff
changeset
|
269 |
// PuTTY |
0f6d25a02450
Add PuTTY escape keys for Ctrl-arrows
Mikael Berthe <mikael@lilotux.net>
parents:
766
diff
changeset
|
270 |
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
|
271 |
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
|
272 |
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
|
273 |
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
|
274 |
|
762
96d46e00524a
Add some key escape sequences for screen
Mikael Berthe <mikael@lilotux.net>
parents:
761
diff
changeset
|
275 |
// screen |
96d46e00524a
Add some key escape sequences for screen
Mikael Berthe <mikael@lilotux.net>
parents:
761
diff
changeset
|
276 |
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
|
277 |
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
|
278 |
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
|
279 |
add_keyseq("Od", MKEY_EQUIV, 516); // Ctrl-Left |
763 | 280 |
add_keyseq("[a", MKEY_EQUIV, 520); // Shift-Up |
281 |
add_keyseq("[b", MKEY_EQUIV, 513); // Shift-Down |
|
282 |
add_keyseq("[c", MKEY_EQUIV, 402); // Shift-Right |
|
283 |
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
|
284 |
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
|
285 |
add_keyseq("[6$", MKEY_SHIFT_PGDOWN, 0); // Shift-PageDown |
72626e9d60bd
Create init_keycodes(), add 2 screen escape sequences
Mikael Berthe <mikael@lilotux.net>
parents:
764
diff
changeset
|
286 |
} |
72626e9d60bd
Create init_keycodes(), add 2 screen escape sequences
Mikael Berthe <mikael@lilotux.net>
parents:
764
diff
changeset
|
287 |
|
779
057ffe7c43dc
Initialize locale charset earlier
Mikael Berthe <mikael@lilotux.net>
parents:
773
diff
changeset
|
288 |
void scr_InitLocaleCharSet(void) |
057ffe7c43dc
Initialize locale charset earlier
Mikael Berthe <mikael@lilotux.net>
parents:
773
diff
changeset
|
289 |
{ |
057ffe7c43dc
Initialize locale charset earlier
Mikael Berthe <mikael@lilotux.net>
parents:
773
diff
changeset
|
290 |
setlocale(LC_CTYPE, ""); |
057ffe7c43dc
Initialize locale charset earlier
Mikael Berthe <mikael@lilotux.net>
parents:
773
diff
changeset
|
291 |
LocaleCharSet = nl_langinfo(CODESET); |
057ffe7c43dc
Initialize locale charset earlier
Mikael Berthe <mikael@lilotux.net>
parents:
773
diff
changeset
|
292 |
utf8_mode = (strcmp(LocaleCharSet, "UTF-8") == 0); |
057ffe7c43dc
Initialize locale charset earlier
Mikael Berthe <mikael@lilotux.net>
parents:
773
diff
changeset
|
293 |
} |
057ffe7c43dc
Initialize locale charset earlier
Mikael Berthe <mikael@lilotux.net>
parents:
773
diff
changeset
|
294 |
|
765
72626e9d60bd
Create init_keycodes(), add 2 screen escape sequences
Mikael Berthe <mikael@lilotux.net>
parents:
764
diff
changeset
|
295 |
void scr_InitCurses(void) |
72626e9d60bd
Create init_keycodes(), add 2 screen escape sequences
Mikael Berthe <mikael@lilotux.net>
parents:
764
diff
changeset
|
296 |
{ |
72626e9d60bd
Create init_keycodes(), add 2 screen escape sequences
Mikael Berthe <mikael@lilotux.net>
parents:
764
diff
changeset
|
297 |
/* Key sequences initialization */ |
72626e9d60bd
Create init_keycodes(), add 2 screen escape sequences
Mikael Berthe <mikael@lilotux.net>
parents:
764
diff
changeset
|
298 |
init_keycodes(); |
762
96d46e00524a
Add some key escape sequences for screen
Mikael Berthe <mikael@lilotux.net>
parents:
761
diff
changeset
|
299 |
|
373
af2f8ddf6a1b
Move (reorganize) functions
Mikael Berthe <mikael@lilotux.net>
parents:
370
diff
changeset
|
300 |
initscr(); |
382
4c6e8392e465
Use nodelay() instead of halfdelay()
Mikael Berthe <mikael@lilotux.net>
parents:
374
diff
changeset
|
301 |
raw(); |
373
af2f8ddf6a1b
Move (reorganize) functions
Mikael Berthe <mikael@lilotux.net>
parents:
370
diff
changeset
|
302 |
noecho(); |
389
6e895f397474
Ncurses changes + Ctrl-C does not send a signal anylore
Mikael Berthe <mikael@lilotux.net>
parents:
388
diff
changeset
|
303 |
nonl(); |
6e895f397474
Ncurses changes + Ctrl-C does not send a signal anylore
Mikael Berthe <mikael@lilotux.net>
parents:
388
diff
changeset
|
304 |
intrflush(stdscr, FALSE); |
373
af2f8ddf6a1b
Move (reorganize) functions
Mikael Berthe <mikael@lilotux.net>
parents:
370
diff
changeset
|
305 |
start_color(); |
af2f8ddf6a1b
Move (reorganize) functions
Mikael Berthe <mikael@lilotux.net>
parents:
370
diff
changeset
|
306 |
use_default_colors(); |
af2f8ddf6a1b
Move (reorganize) functions
Mikael Berthe <mikael@lilotux.net>
parents:
370
diff
changeset
|
307 |
Curses = TRUE; |
af2f8ddf6a1b
Move (reorganize) functions
Mikael Berthe <mikael@lilotux.net>
parents:
370
diff
changeset
|
308 |
|
af2f8ddf6a1b
Move (reorganize) functions
Mikael Berthe <mikael@lilotux.net>
parents:
370
diff
changeset
|
309 |
ParseColors(); |
af2f8ddf6a1b
Move (reorganize) functions
Mikael Berthe <mikael@lilotux.net>
parents:
370
diff
changeset
|
310 |
|
af2f8ddf6a1b
Move (reorganize) functions
Mikael Berthe <mikael@lilotux.net>
parents:
370
diff
changeset
|
311 |
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
|
312 |
Log_Win_Height = DEFAULT_LOG_WIN_HEIGHT; |
518
9480a76471b6
Update Log_Win_Height when refreshing the screen
Mikael Berthe <mikael@lilotux.net>
parents:
515
diff
changeset
|
313 |
// Note scr_DrawMainWindow() should be called early after scr_InitCurses() |
9480a76471b6
Update Log_Win_Height when refreshing the screen
Mikael Berthe <mikael@lilotux.net>
parents:
515
diff
changeset
|
314 |
// 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
|
315 |
|
373
af2f8ddf6a1b
Move (reorganize) functions
Mikael Berthe <mikael@lilotux.net>
parents:
370
diff
changeset
|
316 |
inputLine[0] = 0; |
af2f8ddf6a1b
Move (reorganize) functions
Mikael Berthe <mikael@lilotux.net>
parents:
370
diff
changeset
|
317 |
ptr_inputline = inputLine; |
af2f8ddf6a1b
Move (reorganize) functions
Mikael Berthe <mikael@lilotux.net>
parents:
370
diff
changeset
|
318 |
|
af2f8ddf6a1b
Move (reorganize) functions
Mikael Berthe <mikael@lilotux.net>
parents:
370
diff
changeset
|
319 |
return; |
af2f8ddf6a1b
Move (reorganize) functions
Mikael Berthe <mikael@lilotux.net>
parents:
370
diff
changeset
|
320 |
} |
af2f8ddf6a1b
Move (reorganize) functions
Mikael Berthe <mikael@lilotux.net>
parents:
370
diff
changeset
|
321 |
|
af2f8ddf6a1b
Move (reorganize) functions
Mikael Berthe <mikael@lilotux.net>
parents:
370
diff
changeset
|
322 |
void scr_TerminateCurses(void) |
af2f8ddf6a1b
Move (reorganize) functions
Mikael Berthe <mikael@lilotux.net>
parents:
370
diff
changeset
|
323 |
{ |
af2f8ddf6a1b
Move (reorganize) functions
Mikael Berthe <mikael@lilotux.net>
parents:
370
diff
changeset
|
324 |
if (!Curses) return; |
af2f8ddf6a1b
Move (reorganize) functions
Mikael Berthe <mikael@lilotux.net>
parents:
370
diff
changeset
|
325 |
clear(); |
af2f8ddf6a1b
Move (reorganize) functions
Mikael Berthe <mikael@lilotux.net>
parents:
370
diff
changeset
|
326 |
refresh(); |
af2f8ddf6a1b
Move (reorganize) functions
Mikael Berthe <mikael@lilotux.net>
parents:
370
diff
changeset
|
327 |
endwin(); |
af2f8ddf6a1b
Move (reorganize) functions
Mikael Berthe <mikael@lilotux.net>
parents:
370
diff
changeset
|
328 |
Curses = FALSE; |
af2f8ddf6a1b
Move (reorganize) functions
Mikael Berthe <mikael@lilotux.net>
parents:
370
diff
changeset
|
329 |
return; |
af2f8ddf6a1b
Move (reorganize) functions
Mikael Berthe <mikael@lilotux.net>
parents:
370
diff
changeset
|
330 |
} |
af2f8ddf6a1b
Move (reorganize) functions
Mikael Berthe <mikael@lilotux.net>
parents:
370
diff
changeset
|
331 |
|
675
ae7016aae014
New "beep_on_message" option
Mikael Berthe <mikael@lilotux.net>
parents:
667
diff
changeset
|
332 |
inline void scr_Beep(void) |
ae7016aae014
New "beep_on_message" option
Mikael Berthe <mikael@lilotux.net>
parents:
667
diff
changeset
|
333 |
{ |
ae7016aae014
New "beep_on_message" option
Mikael Berthe <mikael@lilotux.net>
parents:
667
diff
changeset
|
334 |
beep(); |
ae7016aae014
New "beep_on_message" option
Mikael Berthe <mikael@lilotux.net>
parents:
667
diff
changeset
|
335 |
} |
ae7016aae014
New "beep_on_message" option
Mikael Berthe <mikael@lilotux.net>
parents:
667
diff
changeset
|
336 |
|
373
af2f8ddf6a1b
Move (reorganize) functions
Mikael Berthe <mikael@lilotux.net>
parents:
370
diff
changeset
|
337 |
// scr_LogPrint(...) |
af2f8ddf6a1b
Move (reorganize) functions
Mikael Berthe <mikael@lilotux.net>
parents:
370
diff
changeset
|
338 |
// Display a message in the log window. |
771
ce4f8a2129a4
scr_LogPrint() can display UTF-8 strings
Mikael Berthe <mikael@lilotux.net>
parents:
770
diff
changeset
|
339 |
// This function will convert from UTF-8 unless the LPRINT_NOTUTF8 flag is set. |
374
bd5638c21834
Improve logging system (traces)
Mikael Berthe <mikael@lilotux.net>
parents:
373
diff
changeset
|
340 |
void scr_LogPrint(unsigned int flag, const char *fmt, ...) |
373
af2f8ddf6a1b
Move (reorganize) functions
Mikael Berthe <mikael@lilotux.net>
parents:
370
diff
changeset
|
341 |
{ |
af2f8ddf6a1b
Move (reorganize) functions
Mikael Berthe <mikael@lilotux.net>
parents:
370
diff
changeset
|
342 |
time_t timestamp; |
857
ef35a2bb40d7
scr_LogPrint(): do not use static buffer size
Mikael Berthe <mikael@lilotux.net>
parents:
851
diff
changeset
|
343 |
char strtimestamp[64]; |
858
2683ad5d1003
Improve scr_LogPrint() for log/debug messages
Mikael Berthe <mikael@lilotux.net>
parents:
857
diff
changeset
|
344 |
char *buffer, *btext; |
373
af2f8ddf6a1b
Move (reorganize) functions
Mikael Berthe <mikael@lilotux.net>
parents:
370
diff
changeset
|
345 |
va_list ap; |
af2f8ddf6a1b
Move (reorganize) functions
Mikael Berthe <mikael@lilotux.net>
parents:
370
diff
changeset
|
346 |
|
771
ce4f8a2129a4
scr_LogPrint() can display UTF-8 strings
Mikael Berthe <mikael@lilotux.net>
parents:
770
diff
changeset
|
347 |
if (!(flag & ~LPRINT_NOTUTF8)) return; // Shouldn't happen |
374
bd5638c21834
Improve logging system (traces)
Mikael Berthe <mikael@lilotux.net>
parents:
373
diff
changeset
|
348 |
|
857
ef35a2bb40d7
scr_LogPrint(): do not use static buffer size
Mikael Berthe <mikael@lilotux.net>
parents:
851
diff
changeset
|
349 |
timestamp = time(NULL); |
ef35a2bb40d7
scr_LogPrint(): do not use static buffer size
Mikael Berthe <mikael@lilotux.net>
parents:
851
diff
changeset
|
350 |
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
|
351 |
va_start(ap, fmt); |
858
2683ad5d1003
Improve scr_LogPrint() for log/debug messages
Mikael Berthe <mikael@lilotux.net>
parents:
857
diff
changeset
|
352 |
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
|
353 |
va_end(ap); |
373
af2f8ddf6a1b
Move (reorganize) functions
Mikael Berthe <mikael@lilotux.net>
parents:
370
diff
changeset
|
354 |
|
374
bd5638c21834
Improve logging system (traces)
Mikael Berthe <mikael@lilotux.net>
parents:
373
diff
changeset
|
355 |
if (flag & LPRINT_NORMAL) { |
771
ce4f8a2129a4
scr_LogPrint() can display UTF-8 strings
Mikael Berthe <mikael@lilotux.net>
parents:
770
diff
changeset
|
356 |
char *buffer_locale; |
851
da03534e46c7
Add startup log messages to the status buffer
Mikael Berthe <mikael@lilotux.net>
parents:
850
diff
changeset
|
357 |
char *buf_specialwindow; |
da03534e46c7
Add startup log messages to the status buffer
Mikael Berthe <mikael@lilotux.net>
parents:
850
diff
changeset
|
358 |
|
858
2683ad5d1003
Improve scr_LogPrint() for log/debug messages
Mikael Berthe <mikael@lilotux.net>
parents:
857
diff
changeset
|
359 |
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
|
360 |
|
851
da03534e46c7
Add startup log messages to the status buffer
Mikael Berthe <mikael@lilotux.net>
parents:
850
diff
changeset
|
361 |
// 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
|
362 |
if (!(flag & LPRINT_NOTUTF8)) |
ce4f8a2129a4
scr_LogPrint() can display UTF-8 strings
Mikael Berthe <mikael@lilotux.net>
parents:
770
diff
changeset
|
363 |
buffer_locale = from_utf8(buffer); |
ce4f8a2129a4
scr_LogPrint() can display UTF-8 strings
Mikael Berthe <mikael@lilotux.net>
parents:
770
diff
changeset
|
364 |
else |
ce4f8a2129a4
scr_LogPrint() can display UTF-8 strings
Mikael Berthe <mikael@lilotux.net>
parents:
770
diff
changeset
|
365 |
buffer_locale = buffer; |
851
da03534e46c7
Add startup log messages to the status buffer
Mikael Berthe <mikael@lilotux.net>
parents:
850
diff
changeset
|
366 |
|
da03534e46c7
Add startup log messages to the status buffer
Mikael Berthe <mikael@lilotux.net>
parents:
850
diff
changeset
|
367 |
// 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
|
368 |
if (flag & LPRINT_NOTUTF8) |
858
2683ad5d1003
Improve scr_LogPrint() for log/debug messages
Mikael Berthe <mikael@lilotux.net>
parents:
857
diff
changeset
|
369 |
buf_specialwindow = to_utf8(btext); |
851
da03534e46c7
Add startup log messages to the status buffer
Mikael Berthe <mikael@lilotux.net>
parents:
850
diff
changeset
|
370 |
else |
858
2683ad5d1003
Improve scr_LogPrint() for log/debug messages
Mikael Berthe <mikael@lilotux.net>
parents:
857
diff
changeset
|
371 |
buf_specialwindow = btext; |
851
da03534e46c7
Add startup log messages to the status buffer
Mikael Berthe <mikael@lilotux.net>
parents:
850
diff
changeset
|
372 |
|
374
bd5638c21834
Improve logging system (traces)
Mikael Berthe <mikael@lilotux.net>
parents:
373
diff
changeset
|
373 |
if (Curses) { |
771
ce4f8a2129a4
scr_LogPrint() can display UTF-8 strings
Mikael Berthe <mikael@lilotux.net>
parents:
770
diff
changeset
|
374 |
wprintw(logWnd, "\n%s", buffer_locale); |
374
bd5638c21834
Improve logging system (traces)
Mikael Berthe <mikael@lilotux.net>
parents:
373
diff
changeset
|
375 |
update_panels(); |
bd5638c21834
Improve logging system (traces)
Mikael Berthe <mikael@lilotux.net>
parents:
373
diff
changeset
|
376 |
doupdate(); |
850
d0781ca2dd08
Use new status buffer window
Mikael Berthe <mikael@lilotux.net>
parents:
849
diff
changeset
|
377 |
scr_WriteInWindow(NULL, buf_specialwindow, timestamp, |
d0781ca2dd08
Use new status buffer window
Mikael Berthe <mikael@lilotux.net>
parents:
849
diff
changeset
|
378 |
HBB_PREFIX_SPECIAL, FALSE); |
374
bd5638c21834
Improve logging system (traces)
Mikael Berthe <mikael@lilotux.net>
parents:
373
diff
changeset
|
379 |
} else { |
771
ce4f8a2129a4
scr_LogPrint() can display UTF-8 strings
Mikael Berthe <mikael@lilotux.net>
parents:
770
diff
changeset
|
380 |
printf("%s\n", buffer_locale); |
851
da03534e46c7
Add startup log messages to the status buffer
Mikael Berthe <mikael@lilotux.net>
parents:
850
diff
changeset
|
381 |
// 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
|
382 |
hbuf_add_line(&statushbuf, buf_specialwindow, timestamp, |
da03534e46c7
Add startup log messages to the status buffer
Mikael Berthe <mikael@lilotux.net>
parents:
850
diff
changeset
|
383 |
HBB_PREFIX_SPECIAL, 0); |
374
bd5638c21834
Improve logging system (traces)
Mikael Berthe <mikael@lilotux.net>
parents:
373
diff
changeset
|
384 |
} |
851
da03534e46c7
Add startup log messages to the status buffer
Mikael Berthe <mikael@lilotux.net>
parents:
850
diff
changeset
|
385 |
|
858
2683ad5d1003
Improve scr_LogPrint() for log/debug messages
Mikael Berthe <mikael@lilotux.net>
parents:
857
diff
changeset
|
386 |
if (buf_specialwindow != btext) |
851
da03534e46c7
Add startup log messages to the status buffer
Mikael Berthe <mikael@lilotux.net>
parents:
850
diff
changeset
|
387 |
g_free(buf_specialwindow); |
771
ce4f8a2129a4
scr_LogPrint() can display UTF-8 strings
Mikael Berthe <mikael@lilotux.net>
parents:
770
diff
changeset
|
388 |
if (!(flag & LPRINT_NOTUTF8)) |
ce4f8a2129a4
scr_LogPrint() can display UTF-8 strings
Mikael Berthe <mikael@lilotux.net>
parents:
770
diff
changeset
|
389 |
g_free(buffer_locale); |
858
2683ad5d1003
Improve scr_LogPrint() for log/debug messages
Mikael Berthe <mikael@lilotux.net>
parents:
857
diff
changeset
|
390 |
|
2683ad5d1003
Improve scr_LogPrint() for log/debug messages
Mikael Berthe <mikael@lilotux.net>
parents:
857
diff
changeset
|
391 |
g_free(buffer); |
374
bd5638c21834
Improve logging system (traces)
Mikael Berthe <mikael@lilotux.net>
parents:
373
diff
changeset
|
392 |
} |
412
9c640ee3bae3
Display full date in the log file
Mikael Berthe <mikael@lilotux.net>
parents:
393
diff
changeset
|
393 |
|
857
ef35a2bb40d7
scr_LogPrint(): do not use static buffer size
Mikael Berthe <mikael@lilotux.net>
parents:
851
diff
changeset
|
394 |
if (flag & (LPRINT_LOG|LPRINT_DEBUG)) { |
ef35a2bb40d7
scr_LogPrint(): do not use static buffer size
Mikael Berthe <mikael@lilotux.net>
parents:
851
diff
changeset
|
395 |
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
|
396 |
buffer = g_strdup_printf("%s %s\n", strtimestamp, btext); |
857
ef35a2bb40d7
scr_LogPrint(): do not use static buffer size
Mikael Berthe <mikael@lilotux.net>
parents:
851
diff
changeset
|
397 |
ut_WriteLog(flag, buffer); |
ef35a2bb40d7
scr_LogPrint(): do not use static buffer size
Mikael Berthe <mikael@lilotux.net>
parents:
851
diff
changeset
|
398 |
g_free(buffer); |
373
af2f8ddf6a1b
Move (reorganize) functions
Mikael Berthe <mikael@lilotux.net>
parents:
370
diff
changeset
|
399 |
} |
af2f8ddf6a1b
Move (reorganize) functions
Mikael Berthe <mikael@lilotux.net>
parents:
370
diff
changeset
|
400 |
} |
af2f8ddf6a1b
Move (reorganize) functions
Mikael Berthe <mikael@lilotux.net>
parents:
370
diff
changeset
|
401 |
|
849
42c43a88d823
Status buffer management
Mikael Berthe <mikael@lilotux.net>
parents:
848
diff
changeset
|
402 |
// scr_CreateBuddyPanel(title, dontshow) |
42c43a88d823
Status buffer management
Mikael Berthe <mikael@lilotux.net>
parents:
848
diff
changeset
|
403 |
// Note: title (aka winId) can be NULL for special buffers |
822 | 404 |
static winbuf *scr_CreateBuddyPanel(const char *title, int dont_show) |
24 | 405 |
{ |
151 | 406 |
int x; |
407 |
int y; |
|
408 |
int lines; |
|
409 |
int cols; |
|
822 | 410 |
winbuf *tmp; |
393 | 411 |
|
822 | 412 |
tmp = g_new0(winbuf, 1); |
24 | 413 |
|
151 | 414 |
// Dimensions |
701
6c100adfbfb6
Add setting "roster_width" (variable buddylist width)
Mikael Berthe <mikael@lilotux.net>
parents:
699
diff
changeset
|
415 |
x = Roster_Width; |
151 | 416 |
y = 0; |
417 |
lines = CHAT_WIN_HEIGHT; |
|
701
6c100adfbfb6
Add setting "roster_width" (variable buddylist width)
Mikael Berthe <mikael@lilotux.net>
parents:
699
diff
changeset
|
418 |
cols = maxX - Roster_Width; |
6c100adfbfb6
Add setting "roster_width" (variable buddylist width)
Mikael Berthe <mikael@lilotux.net>
parents:
699
diff
changeset
|
419 |
if (cols < 1) cols = 1; |
151 | 420 |
|
24 | 421 |
tmp->win = newwin(lines, cols, y, x); |
154 | 422 |
while (!tmp->win) { |
419 | 423 |
safe_usleep(250); |
154 | 424 |
tmp->win = newwin(lines, cols, y, x); |
425 |
} |
|
739
0d5fb1d9077c
Allow "bright" text colors
Mikael Berthe <mikael@lilotux.net>
parents:
735
diff
changeset
|
426 |
wbkgd(tmp->win, get_color(COLOR_GENERAL)); |
24 | 427 |
tmp->panel = new_panel(tmp->win); |
657
056dc9e65c25
Some memory allocation code cleaning
Mikael Berthe <mikael@lilotux.net>
parents:
654
diff
changeset
|
428 |
tmp->name = g_strdup(title); |
24 | 429 |
|
143 | 430 |
if (!dont_show) { |
24 | 431 |
currentWindow = tmp; |
432 |
} else { |
|
433 |
if (currentWindow) |
|
434 |
top_panel(currentWindow->panel); |
|
435 |
else |
|
436 |
top_panel(chatPanel); |
|
437 |
} |
|
143 | 438 |
update_panels(); |
24 | 439 |
|
849
42c43a88d823
Status buffer management
Mikael Berthe <mikael@lilotux.net>
parents:
848
diff
changeset
|
440 |
// If title is NULL, this is a special buffer |
42c43a88d823
Status buffer management
Mikael Berthe <mikael@lilotux.net>
parents:
848
diff
changeset
|
441 |
if (title) { |
42c43a88d823
Status buffer management
Mikael Berthe <mikael@lilotux.net>
parents:
848
diff
changeset
|
442 |
// Load buddy history from file (if enabled) |
42c43a88d823
Status buffer management
Mikael Berthe <mikael@lilotux.net>
parents:
848
diff
changeset
|
443 |
hlog_read_history(title, &tmp->hbuf, maxX - Roster_Width - PREFIX_WIDTH); |
181 | 444 |
|
849
42c43a88d823
Status buffer management
Mikael Berthe <mikael@lilotux.net>
parents:
848
diff
changeset
|
445 |
winbuflst = g_slist_append(winbuflst, tmp); |
42c43a88d823
Status buffer management
Mikael Berthe <mikael@lilotux.net>
parents:
848
diff
changeset
|
446 |
} |
24 | 447 |
return tmp; |
448 |
} |
|
449 |
||
849
42c43a88d823
Status buffer management
Mikael Berthe <mikael@lilotux.net>
parents:
848
diff
changeset
|
450 |
static winbuf *scr_SearchWindow(const char *winId, int special) |
24 | 451 |
{ |
822 | 452 |
GSList *wblp; |
453 |
winbuf *wbp; |
|
24 | 454 |
|
849
42c43a88d823
Status buffer management
Mikael Berthe <mikael@lilotux.net>
parents:
848
diff
changeset
|
455 |
if (special) |
42c43a88d823
Status buffer management
Mikael Berthe <mikael@lilotux.net>
parents:
848
diff
changeset
|
456 |
return statusWindow; // Only one special window atm. |
42c43a88d823
Status buffer management
Mikael Berthe <mikael@lilotux.net>
parents:
848
diff
changeset
|
457 |
|
42c43a88d823
Status buffer management
Mikael Berthe <mikael@lilotux.net>
parents:
848
diff
changeset
|
458 |
if (!winId) |
42c43a88d823
Status buffer management
Mikael Berthe <mikael@lilotux.net>
parents:
848
diff
changeset
|
459 |
return NULL; |
361
51ff319947c3
Code cleanup/optimization
Mikael Berthe <mikael@lilotux.net>
parents:
358
diff
changeset
|
460 |
|
822 | 461 |
for (wblp = winbuflst; wblp; wblp = g_slist_next(wblp)) { |
462 |
wbp = wblp->data; |
|
463 |
if (wbp->name) { |
|
464 |
if (!strcasecmp(wbp->name, winId)) |
|
465 |
return wbp; |
|
24 | 466 |
} |
467 |
} |
|
468 |
return NULL; |
|
469 |
} |
|
470 |
||
514
979eb0fe2969
Show status changes in buddy window, if it is open
Mikael Berthe <mikael@lilotux.net>
parents:
513
diff
changeset
|
471 |
bool scr_BuddyBufferExists(const char *jid) |
979eb0fe2969
Show status changes in buddy window, if it is open
Mikael Berthe <mikael@lilotux.net>
parents:
513
diff
changeset
|
472 |
{ |
849
42c43a88d823
Status buffer management
Mikael Berthe <mikael@lilotux.net>
parents:
848
diff
changeset
|
473 |
return (scr_SearchWindow(jid, FALSE) != NULL); |
514
979eb0fe2969
Show status changes in buddy window, if it is open
Mikael Berthe <mikael@lilotux.net>
parents:
513
diff
changeset
|
474 |
} |
979eb0fe2969
Show status changes in buddy window, if it is open
Mikael Berthe <mikael@lilotux.net>
parents:
513
diff
changeset
|
475 |
|
143 | 476 |
// scr_UpdateWindow() |
477 |
// (Re-)Display the given chat window. |
|
822 | 478 |
static void scr_UpdateWindow(winbuf *win_entry) |
74 | 479 |
{ |
480 |
int n; |
|
481 |
int width; |
|
184 | 482 |
hbb_line **lines, *line; |
74 | 483 |
GList *hbuf_head; |
850
d0781ca2dd08
Use new status buffer window
Mikael Berthe <mikael@lilotux.net>
parents:
849
diff
changeset
|
484 |
char date[64]; |
74 | 485 |
|
108 | 486 |
width = scr_WindowWidth(win_entry->win); |
487 |
||
488 |
// Should the window be empty? |
|
489 |
if (win_entry->cleared) { |
|
168 | 490 |
werase(win_entry->win); |
108 | 491 |
return; |
492 |
} |
|
493 |
||
105 | 494 |
// win_entry->top is the top message of the screen. If it set to NULL, we |
495 |
// are displaying the last messages. |
|
496 |
||
74 | 497 |
// We will show the last CHAT_WIN_HEIGHT lines. |
498 |
// Let's find out where it begins. |
|
105 | 499 |
if (!win_entry->top || |
500 |
(g_list_position(g_list_first(win_entry->hbuf), win_entry->top) == -1)) { |
|
501 |
// Move up CHAT_WIN_HEIGHT lines |
|
502 |
win_entry->hbuf = g_list_last(win_entry->hbuf); |
|
503 |
hbuf_head = win_entry->hbuf; |
|
504 |
win_entry->top = NULL; // (Just to make sure) |
|
505 |
n = 0; |
|
506 |
while (hbuf_head && (n < CHAT_WIN_HEIGHT-1) && g_list_previous(hbuf_head)) { |
|
507 |
hbuf_head = g_list_previous(hbuf_head); |
|
508 |
n++; |
|
509 |
} |
|
873
ee39f6d94d43
Add /buffer {scroll_lock|scroll_unlock|toggle_scroll}
Mikael Berthe <mikael@lilotux.net>
parents:
866
diff
changeset
|
510 |
// If the buffer is locked, remember current "top" line for the next time. |
ee39f6d94d43
Add /buffer {scroll_lock|scroll_unlock|toggle_scroll}
Mikael Berthe <mikael@lilotux.net>
parents:
866
diff
changeset
|
511 |
if (win_entry->lock) |
ee39f6d94d43
Add /buffer {scroll_lock|scroll_unlock|toggle_scroll}
Mikael Berthe <mikael@lilotux.net>
parents:
866
diff
changeset
|
512 |
win_entry->top = hbuf_head; |
105 | 513 |
} else |
514 |
hbuf_head = win_entry->top; |
|
74 | 515 |
|
516 |
// Get the last CHAT_WIN_HEIGHT lines. |
|
517 |
lines = hbuf_get_lines(hbuf_head, CHAT_WIN_HEIGHT); |
|
518 |
||
519 |
// Display these lines |
|
520 |
for (n = 0; n < CHAT_WIN_HEIGHT; n++) { |
|
168 | 521 |
wmove(win_entry->win, n, 0); |
184 | 522 |
line = *(lines+n); |
185 | 523 |
// NOTE: update PREFIX_WIDTH if you change the date format!! |
524 |
// You need to set it to the whole prefix length + 1 |
|
184 | 525 |
if (line) { |
730
e46c680bdd3d
New color: color_highlight (for outgoing messages)
Mikael Berthe <mikael@lilotux.net>
parents:
729
diff
changeset
|
526 |
if (line->flags & HBB_PREFIX_HLIGHT) |
785
7e0562e3bc83
Replace color_highlight with color_msgout
Mikael Berthe <mikael@lilotux.net>
parents:
779
diff
changeset
|
527 |
wattrset(win_entry->win, get_color(COLOR_MSGOUT)); |
730
e46c680bdd3d
New color: color_highlight (for outgoing messages)
Mikael Berthe <mikael@lilotux.net>
parents:
729
diff
changeset
|
528 |
|
850
d0781ca2dd08
Use new status buffer window
Mikael Berthe <mikael@lilotux.net>
parents:
849
diff
changeset
|
529 |
if (line->timestamp && !(line->flags & HBB_PREFIX_SPECIAL)) { |
419 | 530 |
strftime(date, 30, "%m-%d %H:%M", localtime(&line->timestamp)); |
184 | 531 |
} else |
185 | 532 |
strcpy(date, " "); |
197 | 533 |
if (line->flags & HBB_PREFIX_INFO) { |
534 |
char dir = '*'; |
|
535 |
if (line->flags & HBB_PREFIX_IN) |
|
536 |
dir = '<'; |
|
537 |
else if (line->flags & HBB_PREFIX_OUT) |
|
538 |
dir = '>'; |
|
539 |
wprintw(win_entry->win, "%.11s *%c* ", date, dir); |
|
325
ff6fb51bfd78
Handle "error" message type
Mikael Berthe <mikael@lilotux.net>
parents:
322
diff
changeset
|
540 |
} else if (line->flags & HBB_PREFIX_ERR) { |
ff6fb51bfd78
Handle "error" message type
Mikael Berthe <mikael@lilotux.net>
parents:
322
diff
changeset
|
541 |
char dir = '#'; |
ff6fb51bfd78
Handle "error" message type
Mikael Berthe <mikael@lilotux.net>
parents:
322
diff
changeset
|
542 |
if (line->flags & HBB_PREFIX_IN) |
ff6fb51bfd78
Handle "error" message type
Mikael Berthe <mikael@lilotux.net>
parents:
322
diff
changeset
|
543 |
dir = '<'; |
ff6fb51bfd78
Handle "error" message type
Mikael Berthe <mikael@lilotux.net>
parents:
322
diff
changeset
|
544 |
else if (line->flags & HBB_PREFIX_OUT) |
ff6fb51bfd78
Handle "error" message type
Mikael Berthe <mikael@lilotux.net>
parents:
322
diff
changeset
|
545 |
dir = '>'; |
ff6fb51bfd78
Handle "error" message type
Mikael Berthe <mikael@lilotux.net>
parents:
322
diff
changeset
|
546 |
wprintw(win_entry->win, "%.11s #%c# ", date, dir); |
728
421b337dc6d2
Chat window: Highlight the flag in our messages
Mikael Berthe <mikael@lilotux.net>
parents:
727
diff
changeset
|
547 |
} else if (line->flags & HBB_PREFIX_IN) { |
729
39f67cade02c
Use bold font for outgoing messages
Mikael Berthe <mikael@lilotux.net>
parents:
728
diff
changeset
|
548 |
wprintw(win_entry->win, "%.11s <== ", date); |
728
421b337dc6d2
Chat window: Highlight the flag in our messages
Mikael Berthe <mikael@lilotux.net>
parents:
727
diff
changeset
|
549 |
} else if (line->flags & HBB_PREFIX_OUT) { |
729
39f67cade02c
Use bold font for outgoing messages
Mikael Berthe <mikael@lilotux.net>
parents:
728
diff
changeset
|
550 |
wprintw(win_entry->win, "%.11s --> ", date); |
850
d0781ca2dd08
Use new status buffer window
Mikael Berthe <mikael@lilotux.net>
parents:
849
diff
changeset
|
551 |
} else if (line->flags & HBB_PREFIX_SPECIAL) { |
d0781ca2dd08
Use new status buffer window
Mikael Berthe <mikael@lilotux.net>
parents:
849
diff
changeset
|
552 |
strftime(date, 30, "%m-%d %H:%M:%S", localtime(&line->timestamp)); |
d0781ca2dd08
Use new status buffer window
Mikael Berthe <mikael@lilotux.net>
parents:
849
diff
changeset
|
553 |
wprintw(win_entry->win, "%.14s ", date); |
728
421b337dc6d2
Chat window: Highlight the flag in our messages
Mikael Berthe <mikael@lilotux.net>
parents:
727
diff
changeset
|
554 |
} else { |
185 | 555 |
wprintw(win_entry->win, "%.11s ", date); |
75 | 556 |
} |
729
39f67cade02c
Use bold font for outgoing messages
Mikael Berthe <mikael@lilotux.net>
parents:
728
diff
changeset
|
557 |
|
730
e46c680bdd3d
New color: color_highlight (for outgoing messages)
Mikael Berthe <mikael@lilotux.net>
parents:
729
diff
changeset
|
558 |
wprintw(win_entry->win, "%s", line->text); // Display text line |
729
39f67cade02c
Use bold font for outgoing messages
Mikael Berthe <mikael@lilotux.net>
parents:
728
diff
changeset
|
559 |
|
730
e46c680bdd3d
New color: color_highlight (for outgoing messages)
Mikael Berthe <mikael@lilotux.net>
parents:
729
diff
changeset
|
560 |
if (line->flags & HBB_PREFIX_HLIGHT) |
739
0d5fb1d9077c
Allow "bright" text colors
Mikael Berthe <mikael@lilotux.net>
parents:
735
diff
changeset
|
561 |
wattrset(win_entry->win, get_color(COLOR_GENERAL)); |
168 | 562 |
wclrtoeol(win_entry->win); |
184 | 563 |
g_free(line->text); |
168 | 564 |
} else { |
565 |
wclrtobot(win_entry->win); |
|
566 |
break; |
|
75 | 567 |
} |
74 | 568 |
} |
569 |
g_free(lines); |
|
570 |
} |
|
571 |
||
143 | 572 |
// scr_ShowWindow() |
573 |
// Display the chat window with the given identifier. |
|
849
42c43a88d823
Status buffer management
Mikael Berthe <mikael@lilotux.net>
parents:
848
diff
changeset
|
574 |
// "special" must be true if this is a special buffer window. |
42c43a88d823
Status buffer management
Mikael Berthe <mikael@lilotux.net>
parents:
848
diff
changeset
|
575 |
static void scr_ShowWindow(const char *winId, int special) |
24 | 576 |
{ |
849
42c43a88d823
Status buffer management
Mikael Berthe <mikael@lilotux.net>
parents:
848
diff
changeset
|
577 |
winbuf *win_entry; |
42c43a88d823
Status buffer management
Mikael Berthe <mikael@lilotux.net>
parents:
848
diff
changeset
|
578 |
|
42c43a88d823
Status buffer management
Mikael Berthe <mikael@lilotux.net>
parents:
848
diff
changeset
|
579 |
win_entry = scr_SearchWindow(winId, special); |
74 | 580 |
|
849
42c43a88d823
Status buffer management
Mikael Berthe <mikael@lilotux.net>
parents:
848
diff
changeset
|
581 |
if (!win_entry) { |
42c43a88d823
Status buffer management
Mikael Berthe <mikael@lilotux.net>
parents:
848
diff
changeset
|
582 |
if (special) { |
42c43a88d823
Status buffer management
Mikael Berthe <mikael@lilotux.net>
parents:
848
diff
changeset
|
583 |
if (!statusWindow) { |
42c43a88d823
Status buffer management
Mikael Berthe <mikael@lilotux.net>
parents:
848
diff
changeset
|
584 |
statusWindow = scr_CreateBuddyPanel(NULL, FALSE); |
851
da03534e46c7
Add startup log messages to the status buffer
Mikael Berthe <mikael@lilotux.net>
parents:
850
diff
changeset
|
585 |
statusWindow->hbuf = statushbuf; |
da03534e46c7
Add startup log messages to the status buffer
Mikael Berthe <mikael@lilotux.net>
parents:
850
diff
changeset
|
586 |
statusWindow->name = g_strdup(winId); |
849
42c43a88d823
Status buffer management
Mikael Berthe <mikael@lilotux.net>
parents:
848
diff
changeset
|
587 |
} |
42c43a88d823
Status buffer management
Mikael Berthe <mikael@lilotux.net>
parents:
848
diff
changeset
|
588 |
win_entry = statusWindow; |
42c43a88d823
Status buffer management
Mikael Berthe <mikael@lilotux.net>
parents:
848
diff
changeset
|
589 |
} else { |
42c43a88d823
Status buffer management
Mikael Berthe <mikael@lilotux.net>
parents:
848
diff
changeset
|
590 |
win_entry = scr_CreateBuddyPanel(winId, FALSE); |
42c43a88d823
Status buffer management
Mikael Berthe <mikael@lilotux.net>
parents:
848
diff
changeset
|
591 |
} |
42c43a88d823
Status buffer management
Mikael Berthe <mikael@lilotux.net>
parents:
848
diff
changeset
|
592 |
} |
74 | 593 |
|
180 | 594 |
top_panel(win_entry->panel); |
595 |
currentWindow = win_entry; |
|
596 |
chatmode = TRUE; |
|
849
42c43a88d823
Status buffer management
Mikael Berthe <mikael@lilotux.net>
parents:
848
diff
changeset
|
597 |
if (!special) { |
873
ee39f6d94d43
Add /buffer {scroll_lock|scroll_unlock|toggle_scroll}
Mikael Berthe <mikael@lilotux.net>
parents:
866
diff
changeset
|
598 |
if (!win_entry->lock) |
ee39f6d94d43
Add /buffer {scroll_lock|scroll_unlock|toggle_scroll}
Mikael Berthe <mikael@lilotux.net>
parents:
866
diff
changeset
|
599 |
roster_msg_setflag(winId, FALSE); |
849
42c43a88d823
Status buffer management
Mikael Berthe <mikael@lilotux.net>
parents:
848
diff
changeset
|
600 |
roster_setflags(winId, ROSTER_FLAG_LOCK, TRUE); |
42c43a88d823
Status buffer management
Mikael Berthe <mikael@lilotux.net>
parents:
848
diff
changeset
|
601 |
} |
874
293e8955075c
Display a flag in the chat status line when the buffer is locked
Mikael Berthe <mikael@lilotux.net>
parents:
873
diff
changeset
|
602 |
update_roster = TRUE; |
74 | 603 |
|
180 | 604 |
// Refresh the window |
605 |
scr_UpdateWindow(win_entry); |
|
606 |
||
607 |
// Finished :) |
|
608 |
update_panels(); |
|
142 | 609 |
|
610 |
top_panel(inputPanel); |
|
24 | 611 |
} |
612 |
||
143 | 613 |
// scr_ShowBuddyWindow() |
614 |
// Display the chat window buffer for the current buddy. |
|
24 | 615 |
void scr_ShowBuddyWindow(void) |
616 |
{ |
|
105 | 617 |
const gchar *jid; |
140 | 618 |
|
849
42c43a88d823
Status buffer management
Mikael Berthe <mikael@lilotux.net>
parents:
848
diff
changeset
|
619 |
if (!current_buddy) { |
140 | 620 |
jid = NULL; |
849
42c43a88d823
Status buffer management
Mikael Berthe <mikael@lilotux.net>
parents:
848
diff
changeset
|
621 |
} else { |
140 | 622 |
jid = CURRENT_JID; |
849
42c43a88d823
Status buffer management
Mikael Berthe <mikael@lilotux.net>
parents:
848
diff
changeset
|
623 |
if (buddy_gettype(BUDDATA(current_buddy)) & ROSTER_TYPE_SPECIAL) { |
42c43a88d823
Status buffer management
Mikael Berthe <mikael@lilotux.net>
parents:
848
diff
changeset
|
624 |
scr_ShowWindow(buddy_getname(BUDDATA(current_buddy)), TRUE); |
42c43a88d823
Status buffer management
Mikael Berthe <mikael@lilotux.net>
parents:
848
diff
changeset
|
625 |
return; |
42c43a88d823
Status buffer management
Mikael Berthe <mikael@lilotux.net>
parents:
848
diff
changeset
|
626 |
} |
42c43a88d823
Status buffer management
Mikael Berthe <mikael@lilotux.net>
parents:
848
diff
changeset
|
627 |
} |
140 | 628 |
|
629 |
if (!jid) { |
|
630 |
top_panel(chatPanel); |
|
143 | 631 |
top_panel(inputPanel); |
140 | 632 |
currentWindow = NULL; |
105 | 633 |
return; |
140 | 634 |
} |
635 |
||
849
42c43a88d823
Status buffer management
Mikael Berthe <mikael@lilotux.net>
parents:
848
diff
changeset
|
636 |
scr_ShowWindow(jid, FALSE); |
24 | 637 |
} |
638 |
||
865
cee8d6be04e1
Improve changeset a3db3ee8b99e, do not enable chatmode when refreshing
Mikael Berthe <mikael@lilotux.net>
parents:
858
diff
changeset
|
639 |
// scr_UpdateBuddyWindow() |
cee8d6be04e1
Improve changeset a3db3ee8b99e, do not enable chatmode when refreshing
Mikael Berthe <mikael@lilotux.net>
parents:
858
diff
changeset
|
640 |
// (Re)Display the current window. |
cee8d6be04e1
Improve changeset a3db3ee8b99e, do not enable chatmode when refreshing
Mikael Berthe <mikael@lilotux.net>
parents:
858
diff
changeset
|
641 |
// If chatmode is enabled, call scr_ShowBuddyWindow(), |
cee8d6be04e1
Improve changeset a3db3ee8b99e, do not enable chatmode when refreshing
Mikael Berthe <mikael@lilotux.net>
parents:
858
diff
changeset
|
642 |
// else display the chat window. |
cee8d6be04e1
Improve changeset a3db3ee8b99e, do not enable chatmode when refreshing
Mikael Berthe <mikael@lilotux.net>
parents:
858
diff
changeset
|
643 |
inline void scr_UpdateBuddyWindow(void) |
cee8d6be04e1
Improve changeset a3db3ee8b99e, do not enable chatmode when refreshing
Mikael Berthe <mikael@lilotux.net>
parents:
858
diff
changeset
|
644 |
{ |
cee8d6be04e1
Improve changeset a3db3ee8b99e, do not enable chatmode when refreshing
Mikael Berthe <mikael@lilotux.net>
parents:
858
diff
changeset
|
645 |
if (chatmode) { |
cee8d6be04e1
Improve changeset a3db3ee8b99e, do not enable chatmode when refreshing
Mikael Berthe <mikael@lilotux.net>
parents:
858
diff
changeset
|
646 |
scr_ShowBuddyWindow(); |
cee8d6be04e1
Improve changeset a3db3ee8b99e, do not enable chatmode when refreshing
Mikael Berthe <mikael@lilotux.net>
parents:
858
diff
changeset
|
647 |
return; |
cee8d6be04e1
Improve changeset a3db3ee8b99e, do not enable chatmode when refreshing
Mikael Berthe <mikael@lilotux.net>
parents:
858
diff
changeset
|
648 |
} |
cee8d6be04e1
Improve changeset a3db3ee8b99e, do not enable chatmode when refreshing
Mikael Berthe <mikael@lilotux.net>
parents:
858
diff
changeset
|
649 |
|
cee8d6be04e1
Improve changeset a3db3ee8b99e, do not enable chatmode when refreshing
Mikael Berthe <mikael@lilotux.net>
parents:
858
diff
changeset
|
650 |
top_panel(chatPanel); |
cee8d6be04e1
Improve changeset a3db3ee8b99e, do not enable chatmode when refreshing
Mikael Berthe <mikael@lilotux.net>
parents:
858
diff
changeset
|
651 |
top_panel(inputPanel); |
cee8d6be04e1
Improve changeset a3db3ee8b99e, do not enable chatmode when refreshing
Mikael Berthe <mikael@lilotux.net>
parents:
858
diff
changeset
|
652 |
} |
cee8d6be04e1
Improve changeset a3db3ee8b99e, do not enable chatmode when refreshing
Mikael Berthe <mikael@lilotux.net>
parents:
858
diff
changeset
|
653 |
|
143 | 654 |
// scr_WriteInWindow() |
655 |
// 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
|
656 |
// Use winId == NULL for the special status buffer. |
143 | 657 |
// Lines are splitted when they are too long to fit in the chat window. |
658 |
// If this window doesn't exist, it is created. |
|
184 | 659 |
void scr_WriteInWindow(const char *winId, const char *text, time_t timestamp, |
850
d0781ca2dd08
Use new status buffer window
Mikael Berthe <mikael@lilotux.net>
parents:
849
diff
changeset
|
660 |
unsigned int prefix_flags, int force_show) |
24 | 661 |
{ |
822 | 662 |
winbuf *win_entry; |
772
464be13343a9
Store most data in UTF-8 internally
Mikael Berthe <mikael@lilotux.net>
parents:
771
diff
changeset
|
663 |
char *text_locale; |
24 | 664 |
int dont_show = FALSE; |
849
42c43a88d823
Status buffer management
Mikael Berthe <mikael@lilotux.net>
parents:
848
diff
changeset
|
665 |
int special; |
873
ee39f6d94d43
Add /buffer {scroll_lock|scroll_unlock|toggle_scroll}
Mikael Berthe <mikael@lilotux.net>
parents:
866
diff
changeset
|
666 |
bool setmsgflg = FALSE; |
24 | 667 |
|
74 | 668 |
// Look for the window entry. |
849
42c43a88d823
Status buffer management
Mikael Berthe <mikael@lilotux.net>
parents:
848
diff
changeset
|
669 |
special = (winId == NULL); |
42c43a88d823
Status buffer management
Mikael Berthe <mikael@lilotux.net>
parents:
848
diff
changeset
|
670 |
win_entry = scr_SearchWindow(winId, special); |
74 | 671 |
|
672 |
// Do we have to really show the window? |
|
24 | 673 |
if (!chatmode) |
674 |
dont_show = TRUE; |
|
74 | 675 |
else if ((!force_show) && ((!currentWindow || (currentWindow != win_entry)))) |
24 | 676 |
dont_show = TRUE; |
677 |
||
74 | 678 |
// 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
|
679 |
if (!win_entry) { |
42c43a88d823
Status buffer management
Mikael Berthe <mikael@lilotux.net>
parents:
848
diff
changeset
|
680 |
if (special) { |
42c43a88d823
Status buffer management
Mikael Berthe <mikael@lilotux.net>
parents:
848
diff
changeset
|
681 |
if (!statusWindow) { |
42c43a88d823
Status buffer management
Mikael Berthe <mikael@lilotux.net>
parents:
848
diff
changeset
|
682 |
statusWindow = scr_CreateBuddyPanel(NULL, dont_show); |
851
da03534e46c7
Add startup log messages to the status buffer
Mikael Berthe <mikael@lilotux.net>
parents:
850
diff
changeset
|
683 |
statusWindow->hbuf = statushbuf; |
da03534e46c7
Add startup log messages to the status buffer
Mikael Berthe <mikael@lilotux.net>
parents:
850
diff
changeset
|
684 |
//statusWindow->name = g_strdup(winId); // (winId NULL) |
849
42c43a88d823
Status buffer management
Mikael Berthe <mikael@lilotux.net>
parents:
848
diff
changeset
|
685 |
} |
42c43a88d823
Status buffer management
Mikael Berthe <mikael@lilotux.net>
parents:
848
diff
changeset
|
686 |
win_entry = statusWindow; |
42c43a88d823
Status buffer management
Mikael Berthe <mikael@lilotux.net>
parents:
848
diff
changeset
|
687 |
} else { |
42c43a88d823
Status buffer management
Mikael Berthe <mikael@lilotux.net>
parents:
848
diff
changeset
|
688 |
win_entry = scr_CreateBuddyPanel(winId, dont_show); |
42c43a88d823
Status buffer management
Mikael Berthe <mikael@lilotux.net>
parents:
848
diff
changeset
|
689 |
} |
24 | 690 |
} |
691 |
||
220 | 692 |
// The message must be displayed -> update top pointer |
878
c7ba6f41d056
Fix /buffer clear when the buffer is locked
Mikael Berthe <mikael@lilotux.net>
parents:
874
diff
changeset
|
693 |
if (win_entry->cleared) |
220 | 694 |
win_entry->top = g_list_last(win_entry->hbuf); |
695 |
||
772
464be13343a9
Store most data in UTF-8 internally
Mikael Berthe <mikael@lilotux.net>
parents:
771
diff
changeset
|
696 |
text_locale = from_utf8(text); |
464be13343a9
Store most data in UTF-8 internally
Mikael Berthe <mikael@lilotux.net>
parents:
771
diff
changeset
|
697 |
hbuf_add_line(&win_entry->hbuf, text_locale, timestamp, prefix_flags, |
701
6c100adfbfb6
Add setting "roster_width" (variable buddylist width)
Mikael Berthe <mikael@lilotux.net>
parents:
699
diff
changeset
|
698 |
maxX - Roster_Width - PREFIX_WIDTH); |
772
464be13343a9
Store most data in UTF-8 internally
Mikael Berthe <mikael@lilotux.net>
parents:
771
diff
changeset
|
699 |
g_free(text_locale); |
74 | 700 |
|
878
c7ba6f41d056
Fix /buffer clear when the buffer is locked
Mikael Berthe <mikael@lilotux.net>
parents:
874
diff
changeset
|
701 |
if (win_entry->cleared) { |
220 | 702 |
win_entry->cleared = FALSE; |
703 |
if (g_list_next(win_entry->top)) |
|
704 |
win_entry->top = g_list_next(win_entry->top); |
|
705 |
} |
|
706 |
||
707 |
// Make sure the last line appears in the window; update top if necessary |
|
873
ee39f6d94d43
Add /buffer {scroll_lock|scroll_unlock|toggle_scroll}
Mikael Berthe <mikael@lilotux.net>
parents:
866
diff
changeset
|
708 |
if (!win_entry->lock && win_entry->top) { |
220 | 709 |
int dist; |
710 |
GList *first = g_list_first(win_entry->hbuf); |
|
711 |
dist = g_list_position(first, g_list_last(win_entry->hbuf)) - |
|
712 |
g_list_position(first, win_entry->top); |
|
713 |
if (dist >= CHAT_WIN_HEIGHT) |
|
714 |
win_entry->top = NULL; |
|
108 | 715 |
} |
716 |
||
24 | 717 |
if (!dont_show) { |
873
ee39f6d94d43
Add /buffer {scroll_lock|scroll_unlock|toggle_scroll}
Mikael Berthe <mikael@lilotux.net>
parents:
866
diff
changeset
|
718 |
if (win_entry->lock) |
ee39f6d94d43
Add /buffer {scroll_lock|scroll_unlock|toggle_scroll}
Mikael Berthe <mikael@lilotux.net>
parents:
866
diff
changeset
|
719 |
setmsgflg = TRUE; |
74 | 720 |
// Show and refresh the window |
721 |
top_panel(win_entry->panel); |
|
722 |
scr_UpdateWindow(win_entry); |
|
142 | 723 |
top_panel(inputPanel); |
24 | 724 |
update_panels(); |
725 |
doupdate(); |
|
873
ee39f6d94d43
Add /buffer {scroll_lock|scroll_unlock|toggle_scroll}
Mikael Berthe <mikael@lilotux.net>
parents:
866
diff
changeset
|
726 |
} 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
|
727 |
setmsgflg = TRUE; |
ee39f6d94d43
Add /buffer {scroll_lock|scroll_unlock|toggle_scroll}
Mikael Berthe <mikael@lilotux.net>
parents:
866
diff
changeset
|
728 |
} |
ee39f6d94d43
Add /buffer {scroll_lock|scroll_unlock|toggle_scroll}
Mikael Berthe <mikael@lilotux.net>
parents:
866
diff
changeset
|
729 |
if (setmsgflg && !special) { |
148 | 730 |
roster_msg_setflag(winId, TRUE); |
30 | 731 |
update_roster = TRUE; |
24 | 732 |
} |
733 |
} |
|
734 |
||
713 | 735 |
// scr_UpdateMainStatus() |
736 |
// Redraw the main (bottom) status line. |
|
724
264375fe7159
Fix a roster refresh issue
Mikael Berthe <mikael@lilotux.net>
parents:
723
diff
changeset
|
737 |
void scr_UpdateMainStatus(int forceupdate) |
713 | 738 |
{ |
773
e25b8a348ebd
Screen updating functions use UTF-8
Mikael Berthe <mikael@lilotux.net>
parents:
772
diff
changeset
|
739 |
char *sm = from_utf8(jb_getstatusmsg()); |
713 | 740 |
|
741 |
werase(mainstatusWnd); |
|
724
264375fe7159
Fix a roster refresh issue
Mikael Berthe <mikael@lilotux.net>
parents:
723
diff
changeset
|
742 |
mvwprintw(mainstatusWnd, 0, 0, "%c[%c] %s", |
718
b41799901abd
Add a new_message flag (#) in the main status line
Mikael Berthe <mikael@lilotux.net>
parents:
717
diff
changeset
|
743 |
(unread_msg(NULL) ? '#' : ' '), |
b41799901abd
Add a new_message flag (#) in the main status line
Mikael Berthe <mikael@lilotux.net>
parents:
717
diff
changeset
|
744 |
imstatus2char[jb_getstatus()], (sm ? sm : "")); |
724
264375fe7159
Fix a roster refresh issue
Mikael Berthe <mikael@lilotux.net>
parents:
723
diff
changeset
|
745 |
if (forceupdate) { |
264375fe7159
Fix a roster refresh issue
Mikael Berthe <mikael@lilotux.net>
parents:
723
diff
changeset
|
746 |
top_panel(inputPanel); |
264375fe7159
Fix a roster refresh issue
Mikael Berthe <mikael@lilotux.net>
parents:
723
diff
changeset
|
747 |
update_panels(); |
264375fe7159
Fix a roster refresh issue
Mikael Berthe <mikael@lilotux.net>
parents:
723
diff
changeset
|
748 |
doupdate(); |
264375fe7159
Fix a roster refresh issue
Mikael Berthe <mikael@lilotux.net>
parents:
723
diff
changeset
|
749 |
} |
773
e25b8a348ebd
Screen updating functions use UTF-8
Mikael Berthe <mikael@lilotux.net>
parents:
772
diff
changeset
|
750 |
g_free(sm); |
713 | 751 |
} |
752 |
||
151 | 753 |
// scr_DrawMainWindow() |
157 | 754 |
// Set fullinit to TRUE to also create panels. Set it to FALSE for a resize. |
151 | 755 |
// |
756 |
// I think it could be improved a _lot_ but I'm really not an ncurses |
|
757 |
// expert... :-\ Mikael. |
|
758 |
// |
|
759 |
void scr_DrawMainWindow(unsigned int fullinit) |
|
24 | 760 |
{ |
701
6c100adfbfb6
Add setting "roster_width" (variable buddylist width)
Mikael Berthe <mikael@lilotux.net>
parents:
699
diff
changeset
|
761 |
int requested_size; |
518
9480a76471b6
Update Log_Win_Height when refreshing the screen
Mikael Berthe <mikael@lilotux.net>
parents:
515
diff
changeset
|
762 |
|
9480a76471b6
Update Log_Win_Height when refreshing the screen
Mikael Berthe <mikael@lilotux.net>
parents:
515
diff
changeset
|
763 |
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
|
764 |
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
|
765 |
if (requested_size > 0) { |
6c100adfbfb6
Add setting "roster_width" (variable buddylist width)
Mikael Berthe <mikael@lilotux.net>
parents:
699
diff
changeset
|
766 |
if (maxY > requested_size + 3) |
6c100adfbfb6
Add setting "roster_width" (variable buddylist width)
Mikael Berthe <mikael@lilotux.net>
parents:
699
diff
changeset
|
767 |
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
|
768 |
else |
9480a76471b6
Update Log_Win_Height when refreshing the screen
Mikael Berthe <mikael@lilotux.net>
parents:
515
diff
changeset
|
769 |
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
|
770 |
} else if (requested_size < 0) { |
518
9480a76471b6
Update Log_Win_Height when refreshing the screen
Mikael Berthe <mikael@lilotux.net>
parents:
515
diff
changeset
|
771 |
Log_Win_Height = 3; |
9480a76471b6
Update Log_Win_Height when refreshing the screen
Mikael Berthe <mikael@lilotux.net>
parents:
515
diff
changeset
|
772 |
} |
9480a76471b6
Update Log_Win_Height when refreshing the screen
Mikael Berthe <mikael@lilotux.net>
parents:
515
diff
changeset
|
773 |
|
9480a76471b6
Update Log_Win_Height when refreshing the screen
Mikael Berthe <mikael@lilotux.net>
parents:
515
diff
changeset
|
774 |
if (maxY < Log_Win_Height+2) { |
9480a76471b6
Update Log_Win_Height when refreshing the screen
Mikael Berthe <mikael@lilotux.net>
parents:
515
diff
changeset
|
775 |
if (maxY < 5) { |
9480a76471b6
Update Log_Win_Height when refreshing the screen
Mikael Berthe <mikael@lilotux.net>
parents:
515
diff
changeset
|
776 |
Log_Win_Height = 3; |
9480a76471b6
Update Log_Win_Height when refreshing the screen
Mikael Berthe <mikael@lilotux.net>
parents:
515
diff
changeset
|
777 |
maxY = Log_Win_Height+2; |
9480a76471b6
Update Log_Win_Height when refreshing the screen
Mikael Berthe <mikael@lilotux.net>
parents:
515
diff
changeset
|
778 |
} else { |
9480a76471b6
Update Log_Win_Height when refreshing the screen
Mikael Berthe <mikael@lilotux.net>
parents:
515
diff
changeset
|
779 |
Log_Win_Height = maxY - 2; |
9480a76471b6
Update Log_Win_Height when refreshing the screen
Mikael Berthe <mikael@lilotux.net>
parents:
515
diff
changeset
|
780 |
} |
9480a76471b6
Update Log_Win_Height when refreshing the screen
Mikael Berthe <mikael@lilotux.net>
parents:
515
diff
changeset
|
781 |
} |
9480a76471b6
Update Log_Win_Height when refreshing the screen
Mikael Berthe <mikael@lilotux.net>
parents:
515
diff
changeset
|
782 |
|
707
b26a0bde4cdb
Add /roster hide|show|toggle
Mikael Berthe <mikael@lilotux.net>
parents:
701
diff
changeset
|
783 |
if (roster_hidden) { |
b26a0bde4cdb
Add /roster hide|show|toggle
Mikael Berthe <mikael@lilotux.net>
parents:
701
diff
changeset
|
784 |
Roster_Width = 0; |
b26a0bde4cdb
Add /roster hide|show|toggle
Mikael Berthe <mikael@lilotux.net>
parents:
701
diff
changeset
|
785 |
} else { |
b26a0bde4cdb
Add /roster hide|show|toggle
Mikael Berthe <mikael@lilotux.net>
parents:
701
diff
changeset
|
786 |
requested_size = settings_opt_get_int("roster_width"); |
b26a0bde4cdb
Add /roster hide|show|toggle
Mikael Berthe <mikael@lilotux.net>
parents:
701
diff
changeset
|
787 |
if (requested_size > 1) |
b26a0bde4cdb
Add /roster hide|show|toggle
Mikael Berthe <mikael@lilotux.net>
parents:
701
diff
changeset
|
788 |
Roster_Width = requested_size; |
b26a0bde4cdb
Add /roster hide|show|toggle
Mikael Berthe <mikael@lilotux.net>
parents:
701
diff
changeset
|
789 |
else if (requested_size == 1) |
b26a0bde4cdb
Add /roster hide|show|toggle
Mikael Berthe <mikael@lilotux.net>
parents:
701
diff
changeset
|
790 |
Roster_Width = 2; |
b26a0bde4cdb
Add /roster hide|show|toggle
Mikael Berthe <mikael@lilotux.net>
parents:
701
diff
changeset
|
791 |
else |
b26a0bde4cdb
Add /roster hide|show|toggle
Mikael Berthe <mikael@lilotux.net>
parents:
701
diff
changeset
|
792 |
Roster_Width = DEFAULT_ROSTER_WIDTH; |
b26a0bde4cdb
Add /roster hide|show|toggle
Mikael Berthe <mikael@lilotux.net>
parents:
701
diff
changeset
|
793 |
} |
701
6c100adfbfb6
Add setting "roster_width" (variable buddylist width)
Mikael Berthe <mikael@lilotux.net>
parents:
699
diff
changeset
|
794 |
|
157 | 795 |
if (fullinit) { |
796 |
/* Create windows */ |
|
701
6c100adfbfb6
Add setting "roster_width" (variable buddylist width)
Mikael Berthe <mikael@lilotux.net>
parents:
699
diff
changeset
|
797 |
rosterWnd = newwin(CHAT_WIN_HEIGHT, Roster_Width, 0, 0); |
6c100adfbfb6
Add setting "roster_width" (variable buddylist width)
Mikael Berthe <mikael@lilotux.net>
parents:
699
diff
changeset
|
798 |
chatWnd = newwin(CHAT_WIN_HEIGHT, maxX - Roster_Width, 0, Roster_Width); |
711 | 799 |
logWnd = newwin(Log_Win_Height-2, maxX, CHAT_WIN_HEIGHT+1, 0); |
800 |
chatstatusWnd = newwin(1, maxX, CHAT_WIN_HEIGHT, 0); |
|
801 |
mainstatusWnd = newwin(1, maxX, maxY-2, 0); |
|
157 | 802 |
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
|
803 |
if (!rosterWnd || !chatWnd || !logWnd || !inputWnd) { |
6e4e667c5571
Fix a segfault when starting mcabber in a really small terminal
Mikael Berthe <mikael@lilotux.net>
parents:
339
diff
changeset
|
804 |
scr_TerminateCurses(); |
6e4e667c5571
Fix a segfault when starting mcabber in a really small terminal
Mikael Berthe <mikael@lilotux.net>
parents:
339
diff
changeset
|
805 |
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
|
806 |
exit(EXIT_FAILURE); |
6e4e667c5571
Fix a segfault when starting mcabber in a really small terminal
Mikael Berthe <mikael@lilotux.net>
parents:
339
diff
changeset
|
807 |
} |
739
0d5fb1d9077c
Allow "bright" text colors
Mikael Berthe <mikael@lilotux.net>
parents:
735
diff
changeset
|
808 |
wbkgd(rosterWnd, get_color(COLOR_GENERAL)); |
0d5fb1d9077c
Allow "bright" text colors
Mikael Berthe <mikael@lilotux.net>
parents:
735
diff
changeset
|
809 |
wbkgd(chatWnd, get_color(COLOR_GENERAL)); |
0d5fb1d9077c
Allow "bright" text colors
Mikael Berthe <mikael@lilotux.net>
parents:
735
diff
changeset
|
810 |
wbkgd(logWnd, get_color(COLOR_GENERAL)); |
0d5fb1d9077c
Allow "bright" text colors
Mikael Berthe <mikael@lilotux.net>
parents:
735
diff
changeset
|
811 |
wbkgd(chatstatusWnd, get_color(COLOR_STATUS)); |
0d5fb1d9077c
Allow "bright" text colors
Mikael Berthe <mikael@lilotux.net>
parents:
735
diff
changeset
|
812 |
wbkgd(mainstatusWnd, get_color(COLOR_STATUS)); |
157 | 813 |
} else { |
701
6c100adfbfb6
Add setting "roster_width" (variable buddylist width)
Mikael Berthe <mikael@lilotux.net>
parents:
699
diff
changeset
|
814 |
/* Resize/move windows */ |
6c100adfbfb6
Add setting "roster_width" (variable buddylist width)
Mikael Berthe <mikael@lilotux.net>
parents:
699
diff
changeset
|
815 |
wresize(rosterWnd, CHAT_WIN_HEIGHT, Roster_Width); |
6c100adfbfb6
Add setting "roster_width" (variable buddylist width)
Mikael Berthe <mikael@lilotux.net>
parents:
699
diff
changeset
|
816 |
wresize(chatWnd, CHAT_WIN_HEIGHT, maxX - Roster_Width); |
6c100adfbfb6
Add setting "roster_width" (variable buddylist width)
Mikael Berthe <mikael@lilotux.net>
parents:
699
diff
changeset
|
817 |
mvwin(chatWnd, 0, Roster_Width); |
157 | 818 |
|
711 | 819 |
wresize(logWnd, Log_Win_Height-2, maxX); |
820 |
mvwin(logWnd, CHAT_WIN_HEIGHT+1, 0); |
|
157 | 821 |
|
711 | 822 |
// Resize & move chat status window |
823 |
wresize(chatstatusWnd, 1, maxX); |
|
824 |
mvwin(chatstatusWnd, CHAT_WIN_HEIGHT, 0); |
|
825 |
// Resize & move main status window |
|
826 |
wresize(mainstatusWnd, 1, maxX); |
|
827 |
mvwin(mainstatusWnd, maxY-2, 0); |
|
828 |
// Resize & move input line window |
|
157 | 829 |
wresize(inputWnd, 1, maxX); |
830 |
mvwin(inputWnd, maxY-1, 0); |
|
168 | 831 |
|
832 |
werase(chatWnd); |
|
157 | 833 |
} |
151 | 834 |
|
835 |
/* Draw/init windows */ |
|
836 |
||
679
5933a8036672
Remove "This is the status window" message
Mikael Berthe <mikael@lilotux.net>
parents:
675
diff
changeset
|
837 |
mvwprintw(chatWnd, 0, 0, "Thanks for using mcabber.\n"); |
5933a8036672
Remove "This is the status window" message
Mikael Berthe <mikael@lilotux.net>
parents:
675
diff
changeset
|
838 |
mvwprintw(chatWnd, 1, 0, "http://www.lilotux.net/~mikael/mcabber/"); |
24 | 839 |
|
157 | 840 |
// Auto-scrolling in log window |
74 | 841 |
scrollok(logWnd, TRUE); |
24 | 842 |
|
843 |
||
151 | 844 |
if (fullinit) { |
157 | 845 |
// Enable keypad (+ special keys) |
846 |
keypad(inputWnd, TRUE); |
|
382
4c6e8392e465
Use nodelay() instead of halfdelay()
Mikael Berthe <mikael@lilotux.net>
parents:
374
diff
changeset
|
847 |
nodelay(inputWnd, TRUE); |
157 | 848 |
|
151 | 849 |
// Create panels |
850 |
rosterPanel = new_panel(rosterWnd); |
|
851 |
chatPanel = new_panel(chatWnd); |
|
852 |
logPanel = new_panel(logWnd); |
|
711 | 853 |
chatstatusPanel = new_panel(chatstatusWnd); |
854 |
mainstatusPanel = new_panel(mainstatusWnd); |
|
151 | 855 |
inputPanel = new_panel(inputWnd); |
232 | 856 |
|
849
42c43a88d823
Status buffer management
Mikael Berthe <mikael@lilotux.net>
parents:
848
diff
changeset
|
857 |
// 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
|
858 |
// is added |
42c43a88d823
Status buffer management
Mikael Berthe <mikael@lilotux.net>
parents:
848
diff
changeset
|
859 |
buddylist_build(); |
851
da03534e46c7
Add startup log messages to the status buffer
Mikael Berthe <mikael@lilotux.net>
parents:
850
diff
changeset
|
860 |
// Wrap existing status buffer lines |
da03534e46c7
Add startup log messages to the status buffer
Mikael Berthe <mikael@lilotux.net>
parents:
850
diff
changeset
|
861 |
hbuf_rebuild(&statushbuf, maxX - Roster_Width - PREFIX_WIDTH); |
849
42c43a88d823
Status buffer management
Mikael Berthe <mikael@lilotux.net>
parents:
848
diff
changeset
|
862 |
|
232 | 863 |
if (utf8_mode) |
374
bd5638c21834
Improve logging system (traces)
Mikael Berthe <mikael@lilotux.net>
parents:
373
diff
changeset
|
864 |
scr_LogPrint(LPRINT_NORMAL, "WARNING: UTF-8 not yet supported!"); |
157 | 865 |
} else { |
866 |
// Update panels |
|
867 |
replace_panel(rosterPanel, rosterWnd); |
|
868 |
replace_panel(chatPanel, chatWnd); |
|
869 |
replace_panel(logPanel, logWnd); |
|
711 | 870 |
replace_panel(chatstatusPanel, chatstatusWnd); |
871 |
replace_panel(mainstatusPanel, mainstatusWnd); |
|
157 | 872 |
replace_panel(inputPanel, inputWnd); |
151 | 873 |
} |
874 |
||
875 |
// We'll need to redraw the roster |
|
149 | 876 |
update_roster = TRUE; |
24 | 877 |
return; |
878 |
} |
|
879 |
||
849
42c43a88d823
Status buffer management
Mikael Berthe <mikael@lilotux.net>
parents:
848
diff
changeset
|
880 |
static inline void resize_win_buffer(winbuf *wbp, int x, int y, |
42c43a88d823
Status buffer management
Mikael Berthe <mikael@lilotux.net>
parents:
848
diff
changeset
|
881 |
int lines, int cols) |
42c43a88d823
Status buffer management
Mikael Berthe <mikael@lilotux.net>
parents:
848
diff
changeset
|
882 |
{ |
42c43a88d823
Status buffer management
Mikael Berthe <mikael@lilotux.net>
parents:
848
diff
changeset
|
883 |
// Resize/move buddy window |
42c43a88d823
Status buffer management
Mikael Berthe <mikael@lilotux.net>
parents:
848
diff
changeset
|
884 |
wresize(wbp->win, lines, cols); |
42c43a88d823
Status buffer management
Mikael Berthe <mikael@lilotux.net>
parents:
848
diff
changeset
|
885 |
mvwin(wbp->win, 0, Roster_Width); |
42c43a88d823
Status buffer management
Mikael Berthe <mikael@lilotux.net>
parents:
848
diff
changeset
|
886 |
werase(wbp->win); |
42c43a88d823
Status buffer management
Mikael Berthe <mikael@lilotux.net>
parents:
848
diff
changeset
|
887 |
// If a panel exists, replace the old window with the new |
42c43a88d823
Status buffer management
Mikael Berthe <mikael@lilotux.net>
parents:
848
diff
changeset
|
888 |
if (wbp->panel) |
42c43a88d823
Status buffer management
Mikael Berthe <mikael@lilotux.net>
parents:
848
diff
changeset
|
889 |
replace_panel(wbp->panel, wbp->win); |
42c43a88d823
Status buffer management
Mikael Berthe <mikael@lilotux.net>
parents:
848
diff
changeset
|
890 |
// Redo line wrapping |
42c43a88d823
Status buffer management
Mikael Berthe <mikael@lilotux.net>
parents:
848
diff
changeset
|
891 |
wbp->top = hbuf_previous_persistent(wbp->top); |
42c43a88d823
Status buffer management
Mikael Berthe <mikael@lilotux.net>
parents:
848
diff
changeset
|
892 |
hbuf_rebuild(&wbp->hbuf, maxX - Roster_Width - PREFIX_WIDTH); |
42c43a88d823
Status buffer management
Mikael Berthe <mikael@lilotux.net>
parents:
848
diff
changeset
|
893 |
} |
42c43a88d823
Status buffer management
Mikael Berthe <mikael@lilotux.net>
parents:
848
diff
changeset
|
894 |
|
151 | 895 |
// scr_Resize() |
896 |
// Function called when the window is resized. |
|
157 | 897 |
// - Resize windows |
151 | 898 |
// - Rewrap lines in each buddy buffer |
899 |
void scr_Resize() |
|
900 |
{ |
|
901 |
int x, y, lines, cols; |
|
822 | 902 |
GSList *wblp; |
903 |
winbuf *wbp; |
|
151 | 904 |
|
905 |
// First, update the global variables |
|
906 |
getmaxyx(stdscr, maxY, maxX); |
|
518
9480a76471b6
Update Log_Win_Height when refreshing the screen
Mikael Berthe <mikael@lilotux.net>
parents:
515
diff
changeset
|
907 |
// scr_DrawMainWindow() will take care of maxY and Log_Win_Height |
9480a76471b6
Update Log_Win_Height when refreshing the screen
Mikael Berthe <mikael@lilotux.net>
parents:
515
diff
changeset
|
908 |
|
151 | 909 |
// Make sure the cursor stays inside the window |
910 |
check_offset(0); |
|
911 |
||
157 | 912 |
// Resize windows and update panels |
151 | 913 |
scr_DrawMainWindow(FALSE); |
914 |
||
915 |
// Resize all buddy windows |
|
701
6c100adfbfb6
Add setting "roster_width" (variable buddylist width)
Mikael Berthe <mikael@lilotux.net>
parents:
699
diff
changeset
|
916 |
x = Roster_Width; |
151 | 917 |
y = 0; |
918 |
lines = CHAT_WIN_HEIGHT; |
|
701
6c100adfbfb6
Add setting "roster_width" (variable buddylist width)
Mikael Berthe <mikael@lilotux.net>
parents:
699
diff
changeset
|
919 |
cols = maxX - Roster_Width; |
6c100adfbfb6
Add setting "roster_width" (variable buddylist width)
Mikael Berthe <mikael@lilotux.net>
parents:
699
diff
changeset
|
920 |
if (cols < 1) cols = 1; |
151 | 921 |
|
822 | 922 |
for (wblp = winbuflst; wblp; wblp = g_slist_next(wblp)) { |
923 |
wbp = wblp->data; |
|
849
42c43a88d823
Status buffer management
Mikael Berthe <mikael@lilotux.net>
parents:
848
diff
changeset
|
924 |
if (wbp->win) |
42c43a88d823
Status buffer management
Mikael Berthe <mikael@lilotux.net>
parents:
848
diff
changeset
|
925 |
resize_win_buffer(wbp, x, y, lines, cols); |
151 | 926 |
} |
927 |
||
849
42c43a88d823
Status buffer management
Mikael Berthe <mikael@lilotux.net>
parents:
848
diff
changeset
|
928 |
// Resize/move special status buffer |
42c43a88d823
Status buffer management
Mikael Berthe <mikael@lilotux.net>
parents:
848
diff
changeset
|
929 |
if (statusWindow) |
42c43a88d823
Status buffer management
Mikael Berthe <mikael@lilotux.net>
parents:
848
diff
changeset
|
930 |
resize_win_buffer(statusWindow, x, y, lines, cols); |
42c43a88d823
Status buffer management
Mikael Berthe <mikael@lilotux.net>
parents:
848
diff
changeset
|
931 |
|
151 | 932 |
// Refresh current buddy window |
157 | 933 |
if (chatmode) |
151 | 934 |
scr_ShowBuddyWindow(); |
935 |
} |
|
936 |
||
721
9cf31c9b1dc4
Use room topic as a description in the chat status line
Mikael Berthe <mikael@lilotux.net>
parents:
720
diff
changeset
|
937 |
// scr_UpdateChatStatus(forceupdate) |
713 | 938 |
// Redraw the buddy status bar. |
716
ba1137a01078
Add a chatmode flag (©) in the chat status line
Mikael Berthe <mikael@lilotux.net>
parents:
715
diff
changeset
|
939 |
// Set forceupdate to TRUE if doupdate() must be called. |
721
9cf31c9b1dc4
Use room topic as a description in the chat status line
Mikael Berthe <mikael@lilotux.net>
parents:
720
diff
changeset
|
940 |
void scr_UpdateChatStatus(int forceupdate) |
713 | 941 |
{ |
848
a9161d2dc414
Introduce special buffer stuff
Mikael Berthe <mikael@lilotux.net>
parents:
843
diff
changeset
|
942 |
unsigned short btype, isgrp, ismuc, isspe; |
717
8ce2bfdc4143
Reindent update_chat_status_window()
Mikael Berthe <mikael@lilotux.net>
parents:
716
diff
changeset
|
943 |
const char *fullname; |
8ce2bfdc4143
Reindent update_chat_status_window()
Mikael Berthe <mikael@lilotux.net>
parents:
716
diff
changeset
|
944 |
const char *msg = NULL; |
8ce2bfdc4143
Reindent update_chat_status_window()
Mikael Berthe <mikael@lilotux.net>
parents:
716
diff
changeset
|
945 |
char status; |
773
e25b8a348ebd
Screen updating functions use UTF-8
Mikael Berthe <mikael@lilotux.net>
parents:
772
diff
changeset
|
946 |
char *buf, *buf_locale; |
713 | 947 |
|
718
b41799901abd
Add a new_message flag (#) in the main status line
Mikael Berthe <mikael@lilotux.net>
parents:
717
diff
changeset
|
948 |
// 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
|
949 |
// at least to refresh the pending message flag. |
724
264375fe7159
Fix a roster refresh issue
Mikael Berthe <mikael@lilotux.net>
parents:
723
diff
changeset
|
950 |
scr_UpdateMainStatus(FALSE); |
718
b41799901abd
Add a new_message flag (#) in the main status line
Mikael Berthe <mikael@lilotux.net>
parents:
717
diff
changeset
|
951 |
|
806
3521e34f722a
Fix a segfault when not connected to a server
Mikael Berthe <mikael@lilotux.net>
parents:
797
diff
changeset
|
952 |
// Clear the line |
3521e34f722a
Fix a segfault when not connected to a server
Mikael Berthe <mikael@lilotux.net>
parents:
797
diff
changeset
|
953 |
werase(chatstatusWnd); |
3521e34f722a
Fix a segfault when not connected to a server
Mikael Berthe <mikael@lilotux.net>
parents:
797
diff
changeset
|
954 |
|
3521e34f722a
Fix a segfault when not connected to a server
Mikael Berthe <mikael@lilotux.net>
parents:
797
diff
changeset
|
955 |
if (chatmode) |
3521e34f722a
Fix a segfault when not connected to a server
Mikael Berthe <mikael@lilotux.net>
parents:
797
diff
changeset
|
956 |
wprintw(chatstatusWnd, "~"); |
3521e34f722a
Fix a segfault when not connected to a server
Mikael Berthe <mikael@lilotux.net>
parents:
797
diff
changeset
|
957 |
|
3521e34f722a
Fix a segfault when not connected to a server
Mikael Berthe <mikael@lilotux.net>
parents:
797
diff
changeset
|
958 |
if (!current_buddy) { |
3521e34f722a
Fix a segfault when not connected to a server
Mikael Berthe <mikael@lilotux.net>
parents:
797
diff
changeset
|
959 |
if (forceupdate) { |
3521e34f722a
Fix a segfault when not connected to a server
Mikael Berthe <mikael@lilotux.net>
parents:
797
diff
changeset
|
960 |
update_panels(); |
3521e34f722a
Fix a segfault when not connected to a server
Mikael Berthe <mikael@lilotux.net>
parents:
797
diff
changeset
|
961 |
doupdate(); |
3521e34f722a
Fix a segfault when not connected to a server
Mikael Berthe <mikael@lilotux.net>
parents:
797
diff
changeset
|
962 |
} |
3521e34f722a
Fix a segfault when not connected to a server
Mikael Berthe <mikael@lilotux.net>
parents:
797
diff
changeset
|
963 |
return; |
3521e34f722a
Fix a segfault when not connected to a server
Mikael Berthe <mikael@lilotux.net>
parents:
797
diff
changeset
|
964 |
} |
3521e34f722a
Fix a segfault when not connected to a server
Mikael Berthe <mikael@lilotux.net>
parents:
797
diff
changeset
|
965 |
|
717
8ce2bfdc4143
Reindent update_chat_status_window()
Mikael Berthe <mikael@lilotux.net>
parents:
716
diff
changeset
|
966 |
fullname = buddy_getname(BUDDATA(current_buddy)); |
8ce2bfdc4143
Reindent update_chat_status_window()
Mikael Berthe <mikael@lilotux.net>
parents:
716
diff
changeset
|
967 |
btype = buddy_gettype(BUDDATA(current_buddy)); |
713 | 968 |
|
717
8ce2bfdc4143
Reindent update_chat_status_window()
Mikael Berthe <mikael@lilotux.net>
parents:
716
diff
changeset
|
969 |
isgrp = btype & ROSTER_TYPE_GROUP; |
8ce2bfdc4143
Reindent update_chat_status_window()
Mikael Berthe <mikael@lilotux.net>
parents:
716
diff
changeset
|
970 |
ismuc = btype & ROSTER_TYPE_ROOM; |
848
a9161d2dc414
Introduce special buffer stuff
Mikael Berthe <mikael@lilotux.net>
parents:
843
diff
changeset
|
971 |
isspe = btype & ROSTER_TYPE_SPECIAL; |
713 | 972 |
|
874
293e8955075c
Display a flag in the chat status line when the buffer is locked
Mikael Berthe <mikael@lilotux.net>
parents:
873
diff
changeset
|
973 |
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
|
974 |
winbuf *win_entry; |
293e8955075c
Display a flag in the chat status line when the buffer is locked
Mikael Berthe <mikael@lilotux.net>
parents:
873
diff
changeset
|
975 |
win_entry = scr_SearchWindow(buddy_getjid(BUDDATA(current_buddy)), isspe); |
293e8955075c
Display a flag in the chat status line when the buffer is locked
Mikael Berthe <mikael@lilotux.net>
parents:
873
diff
changeset
|
976 |
if (win_entry && win_entry->lock) |
293e8955075c
Display a flag in the chat status line when the buffer is locked
Mikael Berthe <mikael@lilotux.net>
parents:
873
diff
changeset
|
977 |
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
|
978 |
} |
293e8955075c
Display a flag in the chat status line when the buffer is locked
Mikael Berthe <mikael@lilotux.net>
parents:
873
diff
changeset
|
979 |
|
848
a9161d2dc414
Introduce special buffer stuff
Mikael Berthe <mikael@lilotux.net>
parents:
843
diff
changeset
|
980 |
if (isgrp || isspe) { |
773
e25b8a348ebd
Screen updating functions use UTF-8
Mikael Berthe <mikael@lilotux.net>
parents:
772
diff
changeset
|
981 |
buf_locale = from_utf8(fullname); |
848
a9161d2dc414
Introduce special buffer stuff
Mikael Berthe <mikael@lilotux.net>
parents:
843
diff
changeset
|
982 |
if (isgrp) |
a9161d2dc414
Introduce special buffer stuff
Mikael Berthe <mikael@lilotux.net>
parents:
843
diff
changeset
|
983 |
mvwprintw(chatstatusWnd, 0, 5, "Group: %s", buf_locale); |
a9161d2dc414
Introduce special buffer stuff
Mikael Berthe <mikael@lilotux.net>
parents:
843
diff
changeset
|
984 |
else |
a9161d2dc414
Introduce special buffer stuff
Mikael Berthe <mikael@lilotux.net>
parents:
843
diff
changeset
|
985 |
mvwprintw(chatstatusWnd, 0, 5, "Special buffer: %s", buf_locale); |
773
e25b8a348ebd
Screen updating functions use UTF-8
Mikael Berthe <mikael@lilotux.net>
parents:
772
diff
changeset
|
986 |
g_free(buf_locale); |
716
ba1137a01078
Add a chatmode flag (©) in the chat status line
Mikael Berthe <mikael@lilotux.net>
parents:
715
diff
changeset
|
987 |
if (forceupdate) { |
ba1137a01078
Add a chatmode flag (©) in the chat status line
Mikael Berthe <mikael@lilotux.net>
parents:
715
diff
changeset
|
988 |
update_panels(); |
ba1137a01078
Add a chatmode flag (©) in the chat status line
Mikael Berthe <mikael@lilotux.net>
parents:
715
diff
changeset
|
989 |
doupdate(); |
ba1137a01078
Add a chatmode flag (©) in the chat status line
Mikael Berthe <mikael@lilotux.net>
parents:
715
diff
changeset
|
990 |
} |
717
8ce2bfdc4143
Reindent update_chat_status_window()
Mikael Berthe <mikael@lilotux.net>
parents:
716
diff
changeset
|
991 |
return; |
8ce2bfdc4143
Reindent update_chat_status_window()
Mikael Berthe <mikael@lilotux.net>
parents:
716
diff
changeset
|
992 |
} |
8ce2bfdc4143
Reindent update_chat_status_window()
Mikael Berthe <mikael@lilotux.net>
parents:
716
diff
changeset
|
993 |
|
8ce2bfdc4143
Reindent update_chat_status_window()
Mikael Berthe <mikael@lilotux.net>
parents:
716
diff
changeset
|
994 |
status = '?'; |
8ce2bfdc4143
Reindent update_chat_status_window()
Mikael Berthe <mikael@lilotux.net>
parents:
716
diff
changeset
|
995 |
|
8ce2bfdc4143
Reindent update_chat_status_window()
Mikael Berthe <mikael@lilotux.net>
parents:
716
diff
changeset
|
996 |
if (ismuc) { |
8ce2bfdc4143
Reindent update_chat_status_window()
Mikael Berthe <mikael@lilotux.net>
parents:
716
diff
changeset
|
997 |
if (buddy_getinsideroom(BUDDATA(current_buddy))) |
8ce2bfdc4143
Reindent update_chat_status_window()
Mikael Berthe <mikael@lilotux.net>
parents:
716
diff
changeset
|
998 |
status = 'C'; |
8ce2bfdc4143
Reindent update_chat_status_window()
Mikael Berthe <mikael@lilotux.net>
parents:
716
diff
changeset
|
999 |
else |
8ce2bfdc4143
Reindent update_chat_status_window()
Mikael Berthe <mikael@lilotux.net>
parents:
716
diff
changeset
|
1000 |
status = 'x'; |
8ce2bfdc4143
Reindent update_chat_status_window()
Mikael Berthe <mikael@lilotux.net>
parents:
716
diff
changeset
|
1001 |
} else if (jb_getstatus() != offline) { |
8ce2bfdc4143
Reindent update_chat_status_window()
Mikael Berthe <mikael@lilotux.net>
parents:
716
diff
changeset
|
1002 |
enum imstatus budstate; |
8ce2bfdc4143
Reindent update_chat_status_window()
Mikael Berthe <mikael@lilotux.net>
parents:
716
diff
changeset
|
1003 |
budstate = buddy_getstatus(BUDDATA(current_buddy), NULL); |
790
5d4ad1d77da4
Kill a few gcc4 warnings
Mikael Berthe <mikael@lilotux.net>
parents:
785
diff
changeset
|
1004 |
if (budstate < imstatus_size) |
717
8ce2bfdc4143
Reindent update_chat_status_window()
Mikael Berthe <mikael@lilotux.net>
parents:
716
diff
changeset
|
1005 |
status = imstatus2char[budstate]; |
8ce2bfdc4143
Reindent update_chat_status_window()
Mikael Berthe <mikael@lilotux.net>
parents:
716
diff
changeset
|
1006 |
} |
8ce2bfdc4143
Reindent update_chat_status_window()
Mikael Berthe <mikael@lilotux.net>
parents:
716
diff
changeset
|
1007 |
|
8ce2bfdc4143
Reindent update_chat_status_window()
Mikael Berthe <mikael@lilotux.net>
parents:
716
diff
changeset
|
1008 |
// No status message for groups & MUC rooms |
8ce2bfdc4143
Reindent update_chat_status_window()
Mikael Berthe <mikael@lilotux.net>
parents:
716
diff
changeset
|
1009 |
if (!isgrp && !ismuc) { |
8ce2bfdc4143
Reindent update_chat_status_window()
Mikael Berthe <mikael@lilotux.net>
parents:
716
diff
changeset
|
1010 |
GSList *resources = buddy_getresources(BUDDATA(current_buddy)); |
843
915a7f17474a
Remember the status message when a buddy goes offline
Mikael Berthe <mikael@lilotux.net>
parents:
833
diff
changeset
|
1011 |
msg = buddy_getstatusmsg(BUDDATA(current_buddy), |
915a7f17474a
Remember the status message when a buddy goes offline
Mikael Berthe <mikael@lilotux.net>
parents:
833
diff
changeset
|
1012 |
resources ? resources->data : ""); |
721
9cf31c9b1dc4
Use room topic as a description in the chat status line
Mikael Berthe <mikael@lilotux.net>
parents:
720
diff
changeset
|
1013 |
} else if (ismuc) { |
9cf31c9b1dc4
Use room topic as a description in the chat status line
Mikael Berthe <mikael@lilotux.net>
parents:
720
diff
changeset
|
1014 |
msg = buddy_gettopic(BUDDATA(current_buddy)); |
717
8ce2bfdc4143
Reindent update_chat_status_window()
Mikael Berthe <mikael@lilotux.net>
parents:
716
diff
changeset
|
1015 |
} |
8ce2bfdc4143
Reindent update_chat_status_window()
Mikael Berthe <mikael@lilotux.net>
parents:
716
diff
changeset
|
1016 |
if (!msg) |
8ce2bfdc4143
Reindent update_chat_status_window()
Mikael Berthe <mikael@lilotux.net>
parents:
716
diff
changeset
|
1017 |
msg = ""; |
8ce2bfdc4143
Reindent update_chat_status_window()
Mikael Berthe <mikael@lilotux.net>
parents:
716
diff
changeset
|
1018 |
|
8ce2bfdc4143
Reindent update_chat_status_window()
Mikael Berthe <mikael@lilotux.net>
parents:
716
diff
changeset
|
1019 |
buf = g_strdup_printf("[%c] Buddy: %s -- %s", status, fullname, msg); |
8ce2bfdc4143
Reindent update_chat_status_window()
Mikael Berthe <mikael@lilotux.net>
parents:
716
diff
changeset
|
1020 |
replace_nl_with_dots(buf); |
773
e25b8a348ebd
Screen updating functions use UTF-8
Mikael Berthe <mikael@lilotux.net>
parents:
772
diff
changeset
|
1021 |
buf_locale = from_utf8(buf); |
e25b8a348ebd
Screen updating functions use UTF-8
Mikael Berthe <mikael@lilotux.net>
parents:
772
diff
changeset
|
1022 |
mvwprintw(chatstatusWnd, 0, 1, "%s", buf_locale); |
e25b8a348ebd
Screen updating functions use UTF-8
Mikael Berthe <mikael@lilotux.net>
parents:
772
diff
changeset
|
1023 |
g_free(buf_locale); |
717
8ce2bfdc4143
Reindent update_chat_status_window()
Mikael Berthe <mikael@lilotux.net>
parents:
716
diff
changeset
|
1024 |
g_free(buf); |
8ce2bfdc4143
Reindent update_chat_status_window()
Mikael Berthe <mikael@lilotux.net>
parents:
716
diff
changeset
|
1025 |
|
8ce2bfdc4143
Reindent update_chat_status_window()
Mikael Berthe <mikael@lilotux.net>
parents:
716
diff
changeset
|
1026 |
if (forceupdate) { |
8ce2bfdc4143
Reindent update_chat_status_window()
Mikael Berthe <mikael@lilotux.net>
parents:
716
diff
changeset
|
1027 |
update_panels(); |
8ce2bfdc4143
Reindent update_chat_status_window()
Mikael Berthe <mikael@lilotux.net>
parents:
716
diff
changeset
|
1028 |
doupdate(); |
8ce2bfdc4143
Reindent update_chat_status_window()
Mikael Berthe <mikael@lilotux.net>
parents:
716
diff
changeset
|
1029 |
} |
713 | 1030 |
} |
1031 |
||
143 | 1032 |
// scr_DrawRoster() |
328
83d129adde03
Add set_current_buddy() function, to reduce code duplication
Mikael Berthe <mikael@lilotux.net>
parents:
325
diff
changeset
|
1033 |
// Display the buddylist (not really the roster) on the screen |
81 | 1034 |
void scr_DrawRoster(void) |
24 | 1035 |
{ |
735 | 1036 |
static int offset = 0; |
701
6c100adfbfb6
Add setting "roster_width" (variable buddylist width)
Mikael Berthe <mikael@lilotux.net>
parents:
699
diff
changeset
|
1037 |
char *name, *rline; |
81 | 1038 |
int maxx, maxy; |
1039 |
GList *buddy; |
|
1040 |
int i, n; |
|
1041 |
int rOffset; |
|
713 | 1042 |
int cursor_backup; |
1043 |
char status, pending; |
|
164 | 1044 |
enum imstatus currentstatus = jb_getstatus(); |
81 | 1045 |
|
123 | 1046 |
// We can reset update_roster |
1047 |
update_roster = FALSE; |
|
1048 |
||
81 | 1049 |
getmaxyx(rosterWnd, maxy, maxx); |
701
6c100adfbfb6
Add setting "roster_width" (variable buddylist width)
Mikael Berthe <mikael@lilotux.net>
parents:
699
diff
changeset
|
1050 |
maxx--; // Last char is for vertical border |
81 | 1051 |
|
713 | 1052 |
cursor_backup = curs_set(0); |
1053 |
||
724
264375fe7159
Fix a roster refresh issue
Mikael Berthe <mikael@lilotux.net>
parents:
723
diff
changeset
|
1054 |
if (!buddylist) |
264375fe7159
Fix a roster refresh issue
Mikael Berthe <mikael@lilotux.net>
parents:
723
diff
changeset
|
1055 |
offset = 0; |
264375fe7159
Fix a roster refresh issue
Mikael Berthe <mikael@lilotux.net>
parents:
723
diff
changeset
|
1056 |
else |
264375fe7159
Fix a roster refresh issue
Mikael Berthe <mikael@lilotux.net>
parents:
723
diff
changeset
|
1057 |
scr_UpdateChatStatus(FALSE); |
264375fe7159
Fix a roster refresh issue
Mikael Berthe <mikael@lilotux.net>
parents:
723
diff
changeset
|
1058 |
|
701
6c100adfbfb6
Add setting "roster_width" (variable buddylist width)
Mikael Berthe <mikael@lilotux.net>
parents:
699
diff
changeset
|
1059 |
// Cleanup of roster window |
168 | 1060 |
werase(rosterWnd); |
81 | 1061 |
|
707
b26a0bde4cdb
Add /roster hide|show|toggle
Mikael Berthe <mikael@lilotux.net>
parents:
701
diff
changeset
|
1062 |
if (Roster_Width) { |
b26a0bde4cdb
Add /roster hide|show|toggle
Mikael Berthe <mikael@lilotux.net>
parents:
701
diff
changeset
|
1063 |
// Redraw the vertical line (not very good...) |
739
0d5fb1d9077c
Allow "bright" text colors
Mikael Berthe <mikael@lilotux.net>
parents:
735
diff
changeset
|
1064 |
wattrset(rosterWnd, get_color(COLOR_GENERAL)); |
707
b26a0bde4cdb
Add /roster hide|show|toggle
Mikael Berthe <mikael@lilotux.net>
parents:
701
diff
changeset
|
1065 |
for (i=0 ; i < CHAT_WIN_HEIGHT ; i++) |
b26a0bde4cdb
Add /roster hide|show|toggle
Mikael Berthe <mikael@lilotux.net>
parents:
701
diff
changeset
|
1066 |
mvwaddch(rosterWnd, i, Roster_Width-1, ACS_VLINE); |
b26a0bde4cdb
Add /roster hide|show|toggle
Mikael Berthe <mikael@lilotux.net>
parents:
701
diff
changeset
|
1067 |
} |
b26a0bde4cdb
Add /roster hide|show|toggle
Mikael Berthe <mikael@lilotux.net>
parents:
701
diff
changeset
|
1068 |
|
b26a0bde4cdb
Add /roster hide|show|toggle
Mikael Berthe <mikael@lilotux.net>
parents:
701
diff
changeset
|
1069 |
// 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
|
1070 |
if (!buddylist || !Roster_Width) { |
123 | 1071 |
update_panels(); |
1072 |
doupdate(); |
|
713 | 1073 |
curs_set(cursor_backup); |
81 | 1074 |
return; |
1075 |
} |
|
1076 |
||
701
6c100adfbfb6
Add setting "roster_width" (variable buddylist width)
Mikael Berthe <mikael@lilotux.net>
parents:
699
diff
changeset
|
1077 |
name = g_new0(char, Roster_Width); |
6c100adfbfb6
Add setting "roster_width" (variable buddylist width)
Mikael Berthe <mikael@lilotux.net>
parents:
699
diff
changeset
|
1078 |
|
84 | 1079 |
// Update offset if necessary |
680
1f8987e0e56c
Try to display as many buddylist items as possible
Mikael Berthe <mikael@lilotux.net>
parents:
679
diff
changeset
|
1080 |
// 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
|
1081 |
i = g_list_length(buddylist) - maxy; |
682
f3945593432e
Small fix in scr_DrawRoster()
Mikael Berthe <mikael@lilotux.net>
parents:
680
diff
changeset
|
1082 |
if (i < 0) |
f3945593432e
Small fix in scr_DrawRoster()
Mikael Berthe <mikael@lilotux.net>
parents:
680
diff
changeset
|
1083 |
i = 0; |
f3945593432e
Small fix in scr_DrawRoster()
Mikael Berthe <mikael@lilotux.net>
parents:
680
diff
changeset
|
1084 |
if (i < offset) |
680
1f8987e0e56c
Try to display as many buddylist items as possible
Mikael Berthe <mikael@lilotux.net>
parents:
679
diff
changeset
|
1085 |
offset = i; |
1f8987e0e56c
Try to display as many buddylist items as possible
Mikael Berthe <mikael@lilotux.net>
parents:
679
diff
changeset
|
1086 |
// b) Make sure the current_buddy is visible |
84 | 1087 |
i = g_list_position(buddylist, current_buddy); |
1088 |
if (i == -1) { // This is bad |
|
374
bd5638c21834
Improve logging system (traces)
Mikael Berthe <mikael@lilotux.net>
parents:
373
diff
changeset
|
1089 |
scr_LogPrint(LPRINT_NORMAL, "Doh! Can't find current selected buddy!!"); |
701
6c100adfbfb6
Add setting "roster_width" (variable buddylist width)
Mikael Berthe <mikael@lilotux.net>
parents:
699
diff
changeset
|
1090 |
g_free(name); |
713 | 1091 |
curs_set(cursor_backup); |
84 | 1092 |
return; |
1093 |
} else if (i < offset) { |
|
1094 |
offset = i; |
|
1095 |
} else if (i+1 > offset + maxy) { |
|
1096 |
offset = i + 1 - maxy; |
|
1097 |
} |
|
81 | 1098 |
|
701
6c100adfbfb6
Add setting "roster_width" (variable buddylist width)
Mikael Berthe <mikael@lilotux.net>
parents:
699
diff
changeset
|
1099 |
rline = g_new0(char, Roster_Width+1); |
6c100adfbfb6
Add setting "roster_width" (variable buddylist width)
Mikael Berthe <mikael@lilotux.net>
parents:
699
diff
changeset
|
1100 |
|
81 | 1101 |
buddy = buddylist; |
1102 |
rOffset = offset; |
|
1103 |
||
84 | 1104 |
for (i=0; i<maxy && buddy; buddy = g_list_next(buddy)) { |
848
a9161d2dc414
Introduce special buffer stuff
Mikael Berthe <mikael@lilotux.net>
parents:
843
diff
changeset
|
1105 |
unsigned short bflags, btype, ismsg, isgrp, ismuc, ishid, isspe; |
773
e25b8a348ebd
Screen updating functions use UTF-8
Mikael Berthe <mikael@lilotux.net>
parents:
772
diff
changeset
|
1106 |
gchar *rline_locale; |
713 | 1107 |
|
1108 |
bflags = buddy_getflags(BUDDATA(buddy)); |
|
1109 |
btype = buddy_gettype(BUDDATA(buddy)); |
|
1110 |
||
1111 |
ismsg = bflags & ROSTER_FLAG_MSG; |
|
1112 |
ishid = bflags & ROSTER_FLAG_HIDE; |
|
1113 |
isgrp = btype & ROSTER_TYPE_GROUP; |
|
1114 |
ismuc = btype & ROSTER_TYPE_ROOM; |
|
848
a9161d2dc414
Introduce special buffer stuff
Mikael Berthe <mikael@lilotux.net>
parents:
843
diff
changeset
|
1115 |
isspe = btype & ROSTER_TYPE_SPECIAL; |
81 | 1116 |
|
1117 |
if (rOffset > 0) { |
|
1118 |
rOffset--; |
|
1119 |
continue; |
|
1120 |
} |
|
1121 |
||
713 | 1122 |
status = '?'; |
1123 |
pending = ' '; |
|
1124 |
||
149 | 1125 |
// Display message notice if there is a message flag, but not |
1126 |
// for unfolded groups. |
|
1127 |
if (ismsg && (!isgrp || ishid)) { |
|
81 | 1128 |
pending = '#'; |
1129 |
} |
|
1130 |
||
713 | 1131 |
if (ismuc) { |
1132 |
if (buddy_getinsideroom(BUDDATA(buddy))) |
|
1133 |
status = 'C'; |
|
1134 |
else |
|
1135 |
status = 'x'; |
|
1136 |
} else if (currentstatus != offline) { |
|
1137 |
enum imstatus budstate; |
|
1138 |
budstate = buddy_getstatus(BUDDATA(buddy), NULL); |
|
790
5d4ad1d77da4
Kill a few gcc4 warnings
Mikael Berthe <mikael@lilotux.net>
parents:
785
diff
changeset
|
1139 |
if (budstate < imstatus_size) |
713 | 1140 |
status = imstatus2char[budstate]; |
1141 |
} |
|
81 | 1142 |
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
|
1143 |
if (pending == '#') |
739
0d5fb1d9077c
Allow "bright" text colors
Mikael Berthe <mikael@lilotux.net>
parents:
735
diff
changeset
|
1144 |
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
|
1145 |
else |
739
0d5fb1d9077c
Allow "bright" text colors
Mikael Berthe <mikael@lilotux.net>
parents:
735
diff
changeset
|
1146 |
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
|
1147 |
// The 3 following lines aim at coloring the whole line |
81 | 1148 |
wmove(rosterWnd, i, 0); |
1149 |
for (n = 0; n < maxx; n++) |
|
1150 |
waddch(rosterWnd, ' '); |
|
1151 |
} else { |
|
149 | 1152 |
if (pending == '#') |
739
0d5fb1d9077c
Allow "bright" text colors
Mikael Berthe <mikael@lilotux.net>
parents:
735
diff
changeset
|
1153 |
wattrset(rosterWnd, get_color(COLOR_ROSTERNMSG)); |
139 | 1154 |
else |
739
0d5fb1d9077c
Allow "bright" text colors
Mikael Berthe <mikael@lilotux.net>
parents:
735
diff
changeset
|
1155 |
wattrset(rosterWnd, get_color(COLOR_ROSTER)); |
81 | 1156 |
} |
1157 |
||
701
6c100adfbfb6
Add setting "roster_width" (variable buddylist width)
Mikael Berthe <mikael@lilotux.net>
parents:
699
diff
changeset
|
1158 |
if (Roster_Width > 7) |
6c100adfbfb6
Add setting "roster_width" (variable buddylist width)
Mikael Berthe <mikael@lilotux.net>
parents:
699
diff
changeset
|
1159 |
strncpy(name, buddy_getname(BUDDATA(buddy)), Roster_Width-7); |
6c100adfbfb6
Add setting "roster_width" (variable buddylist width)
Mikael Berthe <mikael@lilotux.net>
parents:
699
diff
changeset
|
1160 |
else |
6c100adfbfb6
Add setting "roster_width" (variable buddylist width)
Mikael Berthe <mikael@lilotux.net>
parents:
699
diff
changeset
|
1161 |
name[0] = 0; |
6c100adfbfb6
Add setting "roster_width" (variable buddylist width)
Mikael Berthe <mikael@lilotux.net>
parents:
699
diff
changeset
|
1162 |
|
149 | 1163 |
if (isgrp) { |
133 | 1164 |
char *sep; |
149 | 1165 |
if (ishid) |
133 | 1166 |
sep = "+++"; |
1167 |
else |
|
1168 |
sep = "---"; |
|
701
6c100adfbfb6
Add setting "roster_width" (variable buddylist width)
Mikael Berthe <mikael@lilotux.net>
parents:
699
diff
changeset
|
1169 |
snprintf(rline, Roster_Width, " %c%s %s", pending, sep, name); |
848
a9161d2dc414
Introduce special buffer stuff
Mikael Berthe <mikael@lilotux.net>
parents:
843
diff
changeset
|
1170 |
} else if (isspe) { |
a9161d2dc414
Introduce special buffer stuff
Mikael Berthe <mikael@lilotux.net>
parents:
843
diff
changeset
|
1171 |
snprintf(rline, Roster_Width, " %c%s", pending, name); |
701
6c100adfbfb6
Add setting "roster_width" (variable buddylist width)
Mikael Berthe <mikael@lilotux.net>
parents:
699
diff
changeset
|
1172 |
} else { |
824
37ef269330f0
Show incomplete subscriptions in the roster
Mikael Berthe <mikael@lilotux.net>
parents:
822
diff
changeset
|
1173 |
char sepleft = '['; |
37ef269330f0
Show incomplete subscriptions in the roster
Mikael Berthe <mikael@lilotux.net>
parents:
822
diff
changeset
|
1174 |
char sepright = ']'; |
37ef269330f0
Show incomplete subscriptions in the roster
Mikael Berthe <mikael@lilotux.net>
parents:
822
diff
changeset
|
1175 |
if (btype & ROSTER_TYPE_USER) { |
37ef269330f0
Show incomplete subscriptions in the roster
Mikael Berthe <mikael@lilotux.net>
parents:
822
diff
changeset
|
1176 |
guint subtype = buddy_getsubscription(BUDDATA(buddy)); |
832
7c210263c661
Small scr_DrawRoster() fix
Mikael Berthe <mikael@lilotux.net>
parents:
828
diff
changeset
|
1177 |
if (status == '_' && !(subtype & sub_to)) |
824
37ef269330f0
Show incomplete subscriptions in the roster
Mikael Berthe <mikael@lilotux.net>
parents:
822
diff
changeset
|
1178 |
status = '?'; |
37ef269330f0
Show incomplete subscriptions in the roster
Mikael Berthe <mikael@lilotux.net>
parents:
822
diff
changeset
|
1179 |
if (!(subtype & sub_from)) { |
37ef269330f0
Show incomplete subscriptions in the roster
Mikael Berthe <mikael@lilotux.net>
parents:
822
diff
changeset
|
1180 |
sepleft = '{'; |
37ef269330f0
Show incomplete subscriptions in the roster
Mikael Berthe <mikael@lilotux.net>
parents:
822
diff
changeset
|
1181 |
sepright = '}'; |
37ef269330f0
Show incomplete subscriptions in the roster
Mikael Berthe <mikael@lilotux.net>
parents:
822
diff
changeset
|
1182 |
} |
37ef269330f0
Show incomplete subscriptions in the roster
Mikael Berthe <mikael@lilotux.net>
parents:
822
diff
changeset
|
1183 |
} |
37ef269330f0
Show incomplete subscriptions in the roster
Mikael Berthe <mikael@lilotux.net>
parents:
822
diff
changeset
|
1184 |
|
37ef269330f0
Show incomplete subscriptions in the roster
Mikael Berthe <mikael@lilotux.net>
parents:
822
diff
changeset
|
1185 |
snprintf(rline, Roster_Width, |
37ef269330f0
Show incomplete subscriptions in the roster
Mikael Berthe <mikael@lilotux.net>
parents:
822
diff
changeset
|
1186 |
" %c%c%c%c %s", pending, sepleft, status, sepright, name); |
133 | 1187 |
} |
84 | 1188 |
|
773
e25b8a348ebd
Screen updating functions use UTF-8
Mikael Berthe <mikael@lilotux.net>
parents:
772
diff
changeset
|
1189 |
rline_locale = from_utf8(rline); |
e25b8a348ebd
Screen updating functions use UTF-8
Mikael Berthe <mikael@lilotux.net>
parents:
772
diff
changeset
|
1190 |
mvwprintw(rosterWnd, i, 0, "%s", rline_locale); |
e25b8a348ebd
Screen updating functions use UTF-8
Mikael Berthe <mikael@lilotux.net>
parents:
772
diff
changeset
|
1191 |
g_free(rline_locale); |
84 | 1192 |
i++; |
81 | 1193 |
} |
1194 |
||
701
6c100adfbfb6
Add setting "roster_width" (variable buddylist width)
Mikael Berthe <mikael@lilotux.net>
parents:
699
diff
changeset
|
1195 |
g_free(rline); |
6c100adfbfb6
Add setting "roster_width" (variable buddylist width)
Mikael Berthe <mikael@lilotux.net>
parents:
699
diff
changeset
|
1196 |
g_free(name); |
142 | 1197 |
top_panel(inputPanel); |
81 | 1198 |
update_panels(); |
1199 |
doupdate(); |
|
713 | 1200 |
curs_set(cursor_backup); |
24 | 1201 |
} |
1202 |
||
707
b26a0bde4cdb
Add /roster hide|show|toggle
Mikael Berthe <mikael@lilotux.net>
parents:
701
diff
changeset
|
1203 |
// scr_RosterVisibility(status) |
b26a0bde4cdb
Add /roster hide|show|toggle
Mikael Berthe <mikael@lilotux.net>
parents:
701
diff
changeset
|
1204 |
// Set the roster visibility: |
b26a0bde4cdb
Add /roster hide|show|toggle
Mikael Berthe <mikael@lilotux.net>
parents:
701
diff
changeset
|
1205 |
// status=1 Show roster |
b26a0bde4cdb
Add /roster hide|show|toggle
Mikael Berthe <mikael@lilotux.net>
parents:
701
diff
changeset
|
1206 |
// status=0 Hide roster |
b26a0bde4cdb
Add /roster hide|show|toggle
Mikael Berthe <mikael@lilotux.net>
parents:
701
diff
changeset
|
1207 |
// status=-1 Toggle roster status |
b26a0bde4cdb
Add /roster hide|show|toggle
Mikael Berthe <mikael@lilotux.net>
parents:
701
diff
changeset
|
1208 |
void scr_RosterVisibility(int status) |
b26a0bde4cdb
Add /roster hide|show|toggle
Mikael Berthe <mikael@lilotux.net>
parents:
701
diff
changeset
|
1209 |
{ |
708
ed326697e4ed
scr_RosterVisibility(): do not refresh when it is not needed
Mikael Berthe <mikael@lilotux.net>
parents:
707
diff
changeset
|
1210 |
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
|
1211 |
|
707
b26a0bde4cdb
Add /roster hide|show|toggle
Mikael Berthe <mikael@lilotux.net>
parents:
701
diff
changeset
|
1212 |
if (status > 0) |
b26a0bde4cdb
Add /roster hide|show|toggle
Mikael Berthe <mikael@lilotux.net>
parents:
701
diff
changeset
|
1213 |
roster_hidden = FALSE; |
b26a0bde4cdb
Add /roster hide|show|toggle
Mikael Berthe <mikael@lilotux.net>
parents:
701
diff
changeset
|
1214 |
else if (status == 0) |
b26a0bde4cdb
Add /roster hide|show|toggle
Mikael Berthe <mikael@lilotux.net>
parents:
701
diff
changeset
|
1215 |
roster_hidden = TRUE; |
b26a0bde4cdb
Add /roster hide|show|toggle
Mikael Berthe <mikael@lilotux.net>
parents:
701
diff
changeset
|
1216 |
else |
b26a0bde4cdb
Add /roster hide|show|toggle
Mikael Berthe <mikael@lilotux.net>
parents:
701
diff
changeset
|
1217 |
roster_hidden = !roster_hidden; |
b26a0bde4cdb
Add /roster hide|show|toggle
Mikael Berthe <mikael@lilotux.net>
parents:
701
diff
changeset
|
1218 |
|
708
ed326697e4ed
scr_RosterVisibility(): do not refresh when it is not needed
Mikael Berthe <mikael@lilotux.net>
parents:
707
diff
changeset
|
1219 |
if (roster_hidden != old_roster_status) { |
709
5aa66101807b
Leave full-width mode automatically under some conditions
Mikael Berthe <mikael@lilotux.net>
parents:
708
diff
changeset
|
1220 |
if (roster_hidden) { |
5aa66101807b
Leave full-width mode automatically under some conditions
Mikael Berthe <mikael@lilotux.net>
parents:
708
diff
changeset
|
1221 |
// Enter chat mode |
5aa66101807b
Leave full-width mode automatically under some conditions
Mikael Berthe <mikael@lilotux.net>
parents:
708
diff
changeset
|
1222 |
scr_set_chatmode(TRUE); |
5aa66101807b
Leave full-width mode automatically under some conditions
Mikael Berthe <mikael@lilotux.net>
parents:
708
diff
changeset
|
1223 |
scr_ShowBuddyWindow(); |
5aa66101807b
Leave full-width mode automatically under some conditions
Mikael Berthe <mikael@lilotux.net>
parents:
708
diff
changeset
|
1224 |
} |
708
ed326697e4ed
scr_RosterVisibility(): do not refresh when it is not needed
Mikael Berthe <mikael@lilotux.net>
parents:
707
diff
changeset
|
1225 |
// 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
|
1226 |
scr_Resize(); |
ed326697e4ed
scr_RosterVisibility(): do not refresh when it is not needed
Mikael Berthe <mikael@lilotux.net>
parents:
707
diff
changeset
|
1227 |
redrawwin(stdscr); |
ed326697e4ed
scr_RosterVisibility(): do not refresh when it is not needed
Mikael Berthe <mikael@lilotux.net>
parents:
707
diff
changeset
|
1228 |
} |
707
b26a0bde4cdb
Add /roster hide|show|toggle
Mikael Berthe <mikael@lilotux.net>
parents:
701
diff
changeset
|
1229 |
} |
b26a0bde4cdb
Add /roster hide|show|toggle
Mikael Berthe <mikael@lilotux.net>
parents:
701
diff
changeset
|
1230 |
|
480 | 1231 |
inline void scr_WriteMessage(const char *jid, const char *text, |
1232 |
time_t timestamp, guint prefix_flags) |
|
24 | 1233 |
{ |
727
1c3620668857
Expand tabs when reading history files
Mikael Berthe <mikael@lilotux.net>
parents:
726
diff
changeset
|
1234 |
char *xtext; |
725
1aff92625bdb
Expand tabs when receiving a message
Mikael Berthe <mikael@lilotux.net>
parents:
724
diff
changeset
|
1235 |
|
726 | 1236 |
if (!timestamp) timestamp = time(NULL); |
725
1aff92625bdb
Expand tabs when receiving a message
Mikael Berthe <mikael@lilotux.net>
parents:
724
diff
changeset
|
1237 |
|
727
1c3620668857
Expand tabs when reading history files
Mikael Berthe <mikael@lilotux.net>
parents:
726
diff
changeset
|
1238 |
xtext = ut_expand_tabs(text); // Expand tabs |
725
1aff92625bdb
Expand tabs when receiving a message
Mikael Berthe <mikael@lilotux.net>
parents:
724
diff
changeset
|
1239 |
|
726 | 1240 |
// XXX Are there other special chars we should filter out? |
1241 |
||
1242 |
scr_WriteInWindow(jid, xtext, timestamp, prefix_flags, FALSE); |
|
725
1aff92625bdb
Expand tabs when receiving a message
Mikael Berthe <mikael@lilotux.net>
parents:
724
diff
changeset
|
1243 |
|
1aff92625bdb
Expand tabs when receiving a message
Mikael Berthe <mikael@lilotux.net>
parents:
724
diff
changeset
|
1244 |
if (xtext != (char*)text) |
1aff92625bdb
Expand tabs when receiving a message
Mikael Berthe <mikael@lilotux.net>
parents:
724
diff
changeset
|
1245 |
g_free(xtext); |
24 | 1246 |
} |
1247 |
||
726 | 1248 |
// If prefix is NULL, HBB_PREFIX_IN is supposed. |
1249 |
void scr_WriteIncomingMessage(const char *jidfrom, const char *text, |
|
1250 |
time_t timestamp, guint prefix) |
|
1251 |
{ |
|
728
421b337dc6d2
Chat window: Highlight the flag in our messages
Mikael Berthe <mikael@lilotux.net>
parents:
727
diff
changeset
|
1252 |
if (!(prefix & ~HBB_PREFIX_NOFLAG & ~HBB_PREFIX_HLIGHT)) |
726 | 1253 |
prefix |= HBB_PREFIX_IN; |
1254 |
||
1255 |
scr_WriteMessage(jidfrom, text, timestamp, prefix); |
|
1256 |
update_panels(); |
|
1257 |
doupdate(); |
|
1258 |
} |
|
1259 |
||
50 | 1260 |
void scr_WriteOutgoingMessage(const char *jidto, const char *text) |
47 | 1261 |
{ |
729
39f67cade02c
Use bold font for outgoing messages
Mikael Berthe <mikael@lilotux.net>
parents:
728
diff
changeset
|
1262 |
scr_WriteMessage(jidto, text, 0, HBB_PREFIX_OUT|HBB_PREFIX_HLIGHT); |
849
42c43a88d823
Status buffer management
Mikael Berthe <mikael@lilotux.net>
parents:
848
diff
changeset
|
1263 |
scr_ShowWindow(jidto, FALSE); |
47 | 1264 |
} |
1265 |
||
735 | 1266 |
inline void set_autoaway(bool setaway) |
373
af2f8ddf6a1b
Move (reorganize) functions
Mikael Berthe <mikael@lilotux.net>
parents:
370
diff
changeset
|
1267 |
{ |
af2f8ddf6a1b
Move (reorganize) functions
Mikael Berthe <mikael@lilotux.net>
parents:
370
diff
changeset
|
1268 |
static enum imstatus oldstatus; |
521 | 1269 |
static char *oldmsg; |
373
af2f8ddf6a1b
Move (reorganize) functions
Mikael Berthe <mikael@lilotux.net>
parents:
370
diff
changeset
|
1270 |
Autoaway = setaway; |
af2f8ddf6a1b
Move (reorganize) functions
Mikael Berthe <mikael@lilotux.net>
parents:
370
diff
changeset
|
1271 |
|
af2f8ddf6a1b
Move (reorganize) functions
Mikael Berthe <mikael@lilotux.net>
parents:
370
diff
changeset
|
1272 |
if (setaway) { |
521 | 1273 |
const char *msg, *prevmsg; |
373
af2f8ddf6a1b
Move (reorganize) functions
Mikael Berthe <mikael@lilotux.net>
parents:
370
diff
changeset
|
1274 |
oldstatus = jb_getstatus(); |
521 | 1275 |
if (oldmsg) { |
1276 |
g_free(oldmsg); |
|
1277 |
oldmsg = NULL; |
|
1278 |
} |
|
1279 |
prevmsg = jb_getstatusmsg(); |
|
373
af2f8ddf6a1b
Move (reorganize) functions
Mikael Berthe <mikael@lilotux.net>
parents:
370
diff
changeset
|
1280 |
msg = settings_opt_get("message_autoaway"); |
521 | 1281 |
if (!msg) |
1282 |
msg = prevmsg; |
|
1283 |
if (prevmsg) |
|
1284 |
oldmsg = g_strdup(prevmsg); |
|
444 | 1285 |
jb_setstatus(away, NULL, msg); |
373
af2f8ddf6a1b
Move (reorganize) functions
Mikael Berthe <mikael@lilotux.net>
parents:
370
diff
changeset
|
1286 |
} else { |
af2f8ddf6a1b
Move (reorganize) functions
Mikael Berthe <mikael@lilotux.net>
parents:
370
diff
changeset
|
1287 |
// Back |
521 | 1288 |
jb_setstatus(oldstatus, NULL, (oldmsg ? oldmsg : "")); |
1289 |
if (oldmsg) { |
|
1290 |
g_free(oldmsg); |
|
1291 |
oldmsg = NULL; |
|
1292 |
} |
|
373
af2f8ddf6a1b
Move (reorganize) functions
Mikael Berthe <mikael@lilotux.net>
parents:
370
diff
changeset
|
1293 |
} |
af2f8ddf6a1b
Move (reorganize) functions
Mikael Berthe <mikael@lilotux.net>
parents:
370
diff
changeset
|
1294 |
} |
af2f8ddf6a1b
Move (reorganize) functions
Mikael Berthe <mikael@lilotux.net>
parents:
370
diff
changeset
|
1295 |
|
af2f8ddf6a1b
Move (reorganize) functions
Mikael Berthe <mikael@lilotux.net>
parents:
370
diff
changeset
|
1296 |
// Check if we should enter/leave automatic away status |
af2f8ddf6a1b
Move (reorganize) functions
Mikael Berthe <mikael@lilotux.net>
parents:
370
diff
changeset
|
1297 |
void scr_CheckAutoAway(bool activity) |
24 | 1298 |
{ |
373
af2f8ddf6a1b
Move (reorganize) functions
Mikael Berthe <mikael@lilotux.net>
parents:
370
diff
changeset
|
1299 |
static time_t LastActivity; |
af2f8ddf6a1b
Move (reorganize) functions
Mikael Berthe <mikael@lilotux.net>
parents:
370
diff
changeset
|
1300 |
enum imstatus cur_st; |
af2f8ddf6a1b
Move (reorganize) functions
Mikael Berthe <mikael@lilotux.net>
parents:
370
diff
changeset
|
1301 |
unsigned int autoaway_timeout = settings_opt_get_int("autoaway"); |
af2f8ddf6a1b
Move (reorganize) functions
Mikael Berthe <mikael@lilotux.net>
parents:
370
diff
changeset
|
1302 |
|
af2f8ddf6a1b
Move (reorganize) functions
Mikael Berthe <mikael@lilotux.net>
parents:
370
diff
changeset
|
1303 |
if (Autoaway && activity) set_autoaway(FALSE); |
af2f8ddf6a1b
Move (reorganize) functions
Mikael Berthe <mikael@lilotux.net>
parents:
370
diff
changeset
|
1304 |
if (!autoaway_timeout) return; |
af2f8ddf6a1b
Move (reorganize) functions
Mikael Berthe <mikael@lilotux.net>
parents:
370
diff
changeset
|
1305 |
if (!LastActivity || activity) time(&LastActivity); |
af2f8ddf6a1b
Move (reorganize) functions
Mikael Berthe <mikael@lilotux.net>
parents:
370
diff
changeset
|
1306 |
|
af2f8ddf6a1b
Move (reorganize) functions
Mikael Berthe <mikael@lilotux.net>
parents:
370
diff
changeset
|
1307 |
cur_st = jb_getstatus(); |
af2f8ddf6a1b
Move (reorganize) functions
Mikael Berthe <mikael@lilotux.net>
parents:
370
diff
changeset
|
1308 |
// Auto-away is disabled for the following states |
af2f8ddf6a1b
Move (reorganize) functions
Mikael Berthe <mikael@lilotux.net>
parents:
370
diff
changeset
|
1309 |
if ((cur_st != available) && (cur_st != freeforchat)) |
af2f8ddf6a1b
Move (reorganize) functions
Mikael Berthe <mikael@lilotux.net>
parents:
370
diff
changeset
|
1310 |
return; |
af2f8ddf6a1b
Move (reorganize) functions
Mikael Berthe <mikael@lilotux.net>
parents:
370
diff
changeset
|
1311 |
|
af2f8ddf6a1b
Move (reorganize) functions
Mikael Berthe <mikael@lilotux.net>
parents:
370
diff
changeset
|
1312 |
if (!activity) { |
af2f8ddf6a1b
Move (reorganize) functions
Mikael Berthe <mikael@lilotux.net>
parents:
370
diff
changeset
|
1313 |
time_t now; |
af2f8ddf6a1b
Move (reorganize) functions
Mikael Berthe <mikael@lilotux.net>
parents:
370
diff
changeset
|
1314 |
time(&now); |
735 | 1315 |
if (!Autoaway && (now > LastActivity + (time_t)autoaway_timeout)) |
373
af2f8ddf6a1b
Move (reorganize) functions
Mikael Berthe <mikael@lilotux.net>
parents:
370
diff
changeset
|
1316 |
set_autoaway(TRUE); |
af2f8ddf6a1b
Move (reorganize) functions
Mikael Berthe <mikael@lilotux.net>
parents:
370
diff
changeset
|
1317 |
} |
24 | 1318 |
} |
1319 |
||
328
83d129adde03
Add set_current_buddy() function, to reduce code duplication
Mikael Berthe <mikael@lilotux.net>
parents:
325
diff
changeset
|
1320 |
// set_current_buddy(newbuddy) |
83d129adde03
Add set_current_buddy() function, to reduce code duplication
Mikael Berthe <mikael@lilotux.net>
parents:
325
diff
changeset
|
1321 |
// 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
|
1322 |
// 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
|
1323 |
static void set_current_buddy(GList *newbuddy) |
24 | 1324 |
{ |
328
83d129adde03
Add set_current_buddy() function, to reduce code duplication
Mikael Berthe <mikael@lilotux.net>
parents:
325
diff
changeset
|
1325 |
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
|
1326 |
/* 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
|
1327 |
* 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
|
1328 |
* buddy_getstatus() call. |
83d129adde03
Add set_current_buddy() function, to reduce code duplication
Mikael Berthe <mikael@lilotux.net>
parents:
325
diff
changeset
|
1329 |
*/ |
83d129adde03
Add set_current_buddy() function, to reduce code duplication
Mikael Berthe <mikael@lilotux.net>
parents:
325
diff
changeset
|
1330 |
|
329
7c53bf62a2a2
scr_RosterUnreadMessage() uses set_current_buddy()
Mikael Berthe <mikael@lilotux.net>
parents:
328
diff
changeset
|
1331 |
if (!current_buddy || !newbuddy) return; |
7c53bf62a2a2
scr_RosterUnreadMessage() uses set_current_buddy()
Mikael Berthe <mikael@lilotux.net>
parents:
328
diff
changeset
|
1332 |
if (newbuddy == current_buddy) return; |
24 | 1333 |
|
438
b44be19d6229
Handle multiple resources for the same buddy
Mikael Berthe <mikael@lilotux.net>
parents:
419
diff
changeset
|
1334 |
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
|
1335 |
buddy_setflags(BUDDATA(current_buddy), ROSTER_FLAG_LOCK, FALSE); |
330 | 1336 |
if (chatmode) |
1337 |
alternate_buddy = current_buddy; |
|
328
83d129adde03
Add set_current_buddy() function, to reduce code duplication
Mikael Berthe <mikael@lilotux.net>
parents:
325
diff
changeset
|
1338 |
current_buddy = newbuddy; |
83d129adde03
Add set_current_buddy() function, to reduce code duplication
Mikael Berthe <mikael@lilotux.net>
parents:
325
diff
changeset
|
1339 |
// Lock the buddy in the buddylist if we're in chat mode |
83d129adde03
Add set_current_buddy() function, to reduce code duplication
Mikael Berthe <mikael@lilotux.net>
parents:
325
diff
changeset
|
1340 |
if (chatmode) |
83d129adde03
Add set_current_buddy() function, to reduce code duplication
Mikael Berthe <mikael@lilotux.net>
parents:
325
diff
changeset
|
1341 |
buddy_setflags(BUDDATA(current_buddy), ROSTER_FLAG_LOCK, TRUE); |
83d129adde03
Add set_current_buddy() function, to reduce code duplication
Mikael Berthe <mikael@lilotux.net>
parents:
325
diff
changeset
|
1342 |
// We should rebuild the buddylist but not everytime |
83d129adde03
Add set_current_buddy() function, to reduce code duplication
Mikael Berthe <mikael@lilotux.net>
parents:
325
diff
changeset
|
1343 |
// Here we check if we were locking a buddy who is actually offline, |
83d129adde03
Add set_current_buddy() function, to reduce code duplication
Mikael Berthe <mikael@lilotux.net>
parents:
325
diff
changeset
|
1344 |
// and hide_offline_buddies is TRUE. In which case we need to rebuild. |
83d129adde03
Add set_current_buddy() function, to reduce code duplication
Mikael Berthe <mikael@lilotux.net>
parents:
325
diff
changeset
|
1345 |
if (prev_st == offline && buddylist_get_hide_offline_buddies()) |
83d129adde03
Add set_current_buddy() function, to reduce code duplication
Mikael Berthe <mikael@lilotux.net>
parents:
325
diff
changeset
|
1346 |
buddylist_build(); |
83d129adde03
Add set_current_buddy() function, to reduce code duplication
Mikael Berthe <mikael@lilotux.net>
parents:
325
diff
changeset
|
1347 |
update_roster = TRUE; |
24 | 1348 |
} |
1349 |
||
143 | 1350 |
// scr_RosterTop() |
1351 |
// Go to the first buddy in the buddylist |
|
105 | 1352 |
void scr_RosterTop(void) |
104 | 1353 |
{ |
328
83d129adde03
Add set_current_buddy() function, to reduce code duplication
Mikael Berthe <mikael@lilotux.net>
parents:
325
diff
changeset
|
1354 |
set_current_buddy(buddylist); |
104 | 1355 |
if (chatmode) |
1356 |
scr_ShowBuddyWindow(); |
|
1357 |
} |
|
1358 |
||
143 | 1359 |
// scr_RosterBottom() |
1360 |
// Go to the last buddy in the buddylist |
|
105 | 1361 |
void scr_RosterBottom(void) |
104 | 1362 |
{ |
328
83d129adde03
Add set_current_buddy() function, to reduce code duplication
Mikael Berthe <mikael@lilotux.net>
parents:
325
diff
changeset
|
1363 |
set_current_buddy(g_list_last(buddylist)); |
104 | 1364 |
if (chatmode) |
1365 |
scr_ShowBuddyWindow(); |
|
1366 |
} |
|
1367 |
||
143 | 1368 |
// scr_RosterUp() |
1369 |
// Go to the previous buddy in the buddylist |
|
105 | 1370 |
void scr_RosterUp(void) |
81 | 1371 |
{ |
328
83d129adde03
Add set_current_buddy() function, to reduce code duplication
Mikael Berthe <mikael@lilotux.net>
parents:
325
diff
changeset
|
1372 |
set_current_buddy(g_list_previous(current_buddy)); |
104 | 1373 |
if (chatmode) |
1374 |
scr_ShowBuddyWindow(); |
|
81 | 1375 |
} |
1376 |
||
143 | 1377 |
// scr_RosterDown() |
1378 |
// Go to the next buddy in the buddylist |
|
105 | 1379 |
void scr_RosterDown(void) |
81 | 1380 |
{ |
328
83d129adde03
Add set_current_buddy() function, to reduce code duplication
Mikael Berthe <mikael@lilotux.net>
parents:
325
diff
changeset
|
1381 |
set_current_buddy(g_list_next(current_buddy)); |
104 | 1382 |
if (chatmode) |
1383 |
scr_ShowBuddyWindow(); |
|
81 | 1384 |
} |
1385 |
||
265 | 1386 |
// scr_RosterSearch(str) |
1387 |
// Look forward for a buddy with jid/name containing str. |
|
1388 |
void scr_RosterSearch(char *str) |
|
1389 |
{ |
|
328
83d129adde03
Add set_current_buddy() function, to reduce code duplication
Mikael Berthe <mikael@lilotux.net>
parents:
325
diff
changeset
|
1390 |
set_current_buddy(buddy_search(str)); |
265 | 1391 |
if (chatmode) |
1392 |
scr_ShowBuddyWindow(); |
|
1393 |
} |
|
1394 |
||
480 | 1395 |
// scr_RosterJumpJid(jid) |
1396 |
// Jump to buddy jid. |
|
1397 |
// NOTE: With this function, the buddy is added to the roster if doesn't exist. |
|
1398 |
void scr_RosterJumpJid(char *barejid) |
|
1399 |
{ |
|
1400 |
GSList *roster_elt; |
|
1401 |
// Look for an existing buddy |
|
1402 |
roster_elt = roster_find(barejid, jidsearch, |
|
1403 |
ROSTER_TYPE_USER|ROSTER_TYPE_AGENT|ROSTER_TYPE_ROOM); |
|
1404 |
// Create it if necessary |
|
1405 |
if (!roster_elt) |
|
603 | 1406 |
roster_elt = roster_add_user(barejid, NULL, NULL, ROSTER_TYPE_USER, |
1407 |
sub_none); |
|
480 | 1408 |
// Set a lock to see it in the buddylist |
1409 |
buddy_setflags(BUDDATA(roster_elt), ROSTER_FLAG_LOCK, TRUE); |
|
1410 |
buddylist_build(); |
|
1411 |
// Jump to the buddy |
|
1412 |
set_current_buddy(buddy_search_jid(barejid)); |
|
1413 |
if (chatmode) |
|
1414 |
scr_ShowBuddyWindow(); |
|
1415 |
} |
|
1416 |
||
236 | 1417 |
// scr_RosterUnreadMessage(next) |
1418 |
// Go to a new message. If next is not null, try to go to the next new |
|
1419 |
// message. If it is not possible or if next is NULL, go to the first new |
|
1420 |
// message from unread_list. |
|
1421 |
void scr_RosterUnreadMessage(int next) |
|
1422 |
{ |
|
329
7c53bf62a2a2
scr_RosterUnreadMessage() uses set_current_buddy()
Mikael Berthe <mikael@lilotux.net>
parents:
328
diff
changeset
|
1423 |
gpointer unread_ptr; |
7c53bf62a2a2
scr_RosterUnreadMessage() uses set_current_buddy()
Mikael Berthe <mikael@lilotux.net>
parents:
328
diff
changeset
|
1424 |
gpointer refbuddata; |
7c53bf62a2a2
scr_RosterUnreadMessage() uses set_current_buddy()
Mikael Berthe <mikael@lilotux.net>
parents:
328
diff
changeset
|
1425 |
gpointer ngroup; |
7c53bf62a2a2
scr_RosterUnreadMessage() uses set_current_buddy()
Mikael Berthe <mikael@lilotux.net>
parents:
328
diff
changeset
|
1426 |
GList *nbuddy; |
236 | 1427 |
|
329
7c53bf62a2a2
scr_RosterUnreadMessage() uses set_current_buddy()
Mikael Berthe <mikael@lilotux.net>
parents:
328
diff
changeset
|
1428 |
if (!current_buddy) return; |
236 | 1429 |
|
329
7c53bf62a2a2
scr_RosterUnreadMessage() uses set_current_buddy()
Mikael Berthe <mikael@lilotux.net>
parents:
328
diff
changeset
|
1430 |
if (next) refbuddata = BUDDATA(current_buddy); |
7c53bf62a2a2
scr_RosterUnreadMessage() uses set_current_buddy()
Mikael Berthe <mikael@lilotux.net>
parents:
328
diff
changeset
|
1431 |
else refbuddata = NULL; |
236 | 1432 |
|
329
7c53bf62a2a2
scr_RosterUnreadMessage() uses set_current_buddy()
Mikael Berthe <mikael@lilotux.net>
parents:
328
diff
changeset
|
1433 |
unread_ptr = unread_msg(refbuddata); |
7c53bf62a2a2
scr_RosterUnreadMessage() uses set_current_buddy()
Mikael Berthe <mikael@lilotux.net>
parents:
328
diff
changeset
|
1434 |
if (!unread_ptr) return; |
236 | 1435 |
|
329
7c53bf62a2a2
scr_RosterUnreadMessage() uses set_current_buddy()
Mikael Berthe <mikael@lilotux.net>
parents:
328
diff
changeset
|
1436 |
// If buddy is in a folded group, we need to expand it |
7c53bf62a2a2
scr_RosterUnreadMessage() uses set_current_buddy()
Mikael Berthe <mikael@lilotux.net>
parents:
328
diff
changeset
|
1437 |
ngroup = buddy_getgroup(unread_ptr); |
7c53bf62a2a2
scr_RosterUnreadMessage() uses set_current_buddy()
Mikael Berthe <mikael@lilotux.net>
parents:
328
diff
changeset
|
1438 |
if (buddy_getflags(ngroup) & ROSTER_FLAG_HIDE) { |
7c53bf62a2a2
scr_RosterUnreadMessage() uses set_current_buddy()
Mikael Berthe <mikael@lilotux.net>
parents:
328
diff
changeset
|
1439 |
buddy_setflags(ngroup, ROSTER_FLAG_HIDE, FALSE); |
7c53bf62a2a2
scr_RosterUnreadMessage() uses set_current_buddy()
Mikael Berthe <mikael@lilotux.net>
parents:
328
diff
changeset
|
1440 |
buddylist_build(); |
7c53bf62a2a2
scr_RosterUnreadMessage() uses set_current_buddy()
Mikael Berthe <mikael@lilotux.net>
parents:
328
diff
changeset
|
1441 |
} |
236 | 1442 |
|
329
7c53bf62a2a2
scr_RosterUnreadMessage() uses set_current_buddy()
Mikael Berthe <mikael@lilotux.net>
parents:
328
diff
changeset
|
1443 |
nbuddy = g_list_find(buddylist, unread_ptr); |
7c53bf62a2a2
scr_RosterUnreadMessage() uses set_current_buddy()
Mikael Berthe <mikael@lilotux.net>
parents:
328
diff
changeset
|
1444 |
if (nbuddy) { |
7c53bf62a2a2
scr_RosterUnreadMessage() uses set_current_buddy()
Mikael Berthe <mikael@lilotux.net>
parents:
328
diff
changeset
|
1445 |
set_current_buddy(nbuddy); |
7c53bf62a2a2
scr_RosterUnreadMessage() uses set_current_buddy()
Mikael Berthe <mikael@lilotux.net>
parents:
328
diff
changeset
|
1446 |
if (chatmode) scr_ShowBuddyWindow(); |
374
bd5638c21834
Improve logging system (traces)
Mikael Berthe <mikael@lilotux.net>
parents:
373
diff
changeset
|
1447 |
} else |
bd5638c21834
Improve logging system (traces)
Mikael Berthe <mikael@lilotux.net>
parents:
373
diff
changeset
|
1448 |
scr_LogPrint(LPRINT_LOGNORM, "Error: nbuddy == NULL"); // should not happen |
236 | 1449 |
} |
1450 |
||
330 | 1451 |
// scr_RosterJumpAlternate() |
1452 |
// Try to jump to alternate (== previous) buddy |
|
1453 |
void scr_RosterJumpAlternate(void) |
|
105 | 1454 |
{ |
330 | 1455 |
if (!alternate_buddy || g_list_position(buddylist, alternate_buddy) == -1) |
1456 |
return; |
|
1457 |
set_current_buddy(alternate_buddy); |
|
1458 |
if (chatmode) |
|
1459 |
scr_ShowBuddyWindow(); |
|
1460 |
} |
|
1461 |
||
369
499170ed71c9
Rename some buffer commands, for homogeneity
Mikael Berthe <mikael@lilotux.net>
parents:
365
diff
changeset
|
1462 |
// scr_BufferScrollUpDown() |
508
5a2132ba2220
Add "/buffer up" and "/buffer down"
Mikael Berthe <mikael@lilotux.net>
parents:
503
diff
changeset
|
1463 |
// Scroll up/down the current buddy window, |
5a2132ba2220
Add "/buffer up" and "/buffer down"
Mikael Berthe <mikael@lilotux.net>
parents:
503
diff
changeset
|
1464 |
// - half a screen if nblines is 0, |
5a2132ba2220
Add "/buffer up" and "/buffer down"
Mikael Berthe <mikael@lilotux.net>
parents:
503
diff
changeset
|
1465 |
// - up if updown == -1, down if updown == 1 |
5a2132ba2220
Add "/buffer up" and "/buffer down"
Mikael Berthe <mikael@lilotux.net>
parents:
503
diff
changeset
|
1466 |
void scr_BufferScrollUpDown(int updown, unsigned int nblines) |
105 | 1467 |
{ |
822 | 1468 |
winbuf *win_entry; |
508
5a2132ba2220
Add "/buffer up" and "/buffer down"
Mikael Berthe <mikael@lilotux.net>
parents:
503
diff
changeset
|
1469 |
int n, nbl; |
105 | 1470 |
GList *hbuf_top; |
849
42c43a88d823
Status buffer management
Mikael Berthe <mikael@lilotux.net>
parents:
848
diff
changeset
|
1471 |
guint isspe; |
105 | 1472 |
|
1473 |
// Get win_entry |
|
361
51ff319947c3
Code cleanup/optimization
Mikael Berthe <mikael@lilotux.net>
parents:
358
diff
changeset
|
1474 |
if (!current_buddy) return; |
849
42c43a88d823
Status buffer management
Mikael Berthe <mikael@lilotux.net>
parents:
848
diff
changeset
|
1475 |
|
42c43a88d823
Status buffer management
Mikael Berthe <mikael@lilotux.net>
parents:
848
diff
changeset
|
1476 |
isspe = buddy_gettype(BUDDATA(current_buddy)) & ROSTER_TYPE_SPECIAL; |
42c43a88d823
Status buffer management
Mikael Berthe <mikael@lilotux.net>
parents:
848
diff
changeset
|
1477 |
win_entry = scr_SearchWindow(CURRENT_JID, isspe); |
361
51ff319947c3
Code cleanup/optimization
Mikael Berthe <mikael@lilotux.net>
parents:
358
diff
changeset
|
1478 |
if (!win_entry) return; |
105 | 1479 |
|
508
5a2132ba2220
Add "/buffer up" and "/buffer down"
Mikael Berthe <mikael@lilotux.net>
parents:
503
diff
changeset
|
1480 |
if (!nblines) { |
5a2132ba2220
Add "/buffer up" and "/buffer down"
Mikael Berthe <mikael@lilotux.net>
parents:
503
diff
changeset
|
1481 |
// Scroll half a screen (or less) |
512 | 1482 |
nbl = CHAT_WIN_HEIGHT/2; |
508
5a2132ba2220
Add "/buffer up" and "/buffer down"
Mikael Berthe <mikael@lilotux.net>
parents:
503
diff
changeset
|
1483 |
} else { |
5a2132ba2220
Add "/buffer up" and "/buffer down"
Mikael Berthe <mikael@lilotux.net>
parents:
503
diff
changeset
|
1484 |
nbl = nblines; |
5a2132ba2220
Add "/buffer up" and "/buffer down"
Mikael Berthe <mikael@lilotux.net>
parents:
503
diff
changeset
|
1485 |
} |
105 | 1486 |
hbuf_top = win_entry->top; |
1487 |
||
361
51ff319947c3
Code cleanup/optimization
Mikael Berthe <mikael@lilotux.net>
parents:
358
diff
changeset
|
1488 |
if (updown == -1) { // UP |
51ff319947c3
Code cleanup/optimization
Mikael Berthe <mikael@lilotux.net>
parents:
358
diff
changeset
|
1489 |
if (!hbuf_top) { |
51ff319947c3
Code cleanup/optimization
Mikael Berthe <mikael@lilotux.net>
parents:
358
diff
changeset
|
1490 |
hbuf_top = g_list_last(win_entry->hbuf); |
512 | 1491 |
if (!win_entry->cleared) { |
1492 |
if (!nblines) nbl = nbl*3 - 1; |
|
1493 |
else nbl += CHAT_WIN_HEIGHT - 1; |
|
1494 |
} else { |
|
361
51ff319947c3
Code cleanup/optimization
Mikael Berthe <mikael@lilotux.net>
parents:
358
diff
changeset
|
1495 |
win_entry->cleared = FALSE; |
512 | 1496 |
} |
361
51ff319947c3
Code cleanup/optimization
Mikael Berthe <mikael@lilotux.net>
parents:
358
diff
changeset
|
1497 |
} |
508
5a2132ba2220
Add "/buffer up" and "/buffer down"
Mikael Berthe <mikael@lilotux.net>
parents:
503
diff
changeset
|
1498 |
for (n=0 ; hbuf_top && n < nbl && g_list_previous(hbuf_top) ; n++) |
361
51ff319947c3
Code cleanup/optimization
Mikael Berthe <mikael@lilotux.net>
parents:
358
diff
changeset
|
1499 |
hbuf_top = g_list_previous(hbuf_top); |
51ff319947c3
Code cleanup/optimization
Mikael Berthe <mikael@lilotux.net>
parents:
358
diff
changeset
|
1500 |
win_entry->top = hbuf_top; |
51ff319947c3
Code cleanup/optimization
Mikael Berthe <mikael@lilotux.net>
parents:
358
diff
changeset
|
1501 |
} else { // DOWN |
508
5a2132ba2220
Add "/buffer up" and "/buffer down"
Mikael Berthe <mikael@lilotux.net>
parents:
503
diff
changeset
|
1502 |
for (n=0 ; hbuf_top && n < nbl ; n++) |
361
51ff319947c3
Code cleanup/optimization
Mikael Berthe <mikael@lilotux.net>
parents:
358
diff
changeset
|
1503 |
hbuf_top = g_list_next(hbuf_top); |
51ff319947c3
Code cleanup/optimization
Mikael Berthe <mikael@lilotux.net>
parents:
358
diff
changeset
|
1504 |
win_entry->top = hbuf_top; |
51ff319947c3
Code cleanup/optimization
Mikael Berthe <mikael@lilotux.net>
parents:
358
diff
changeset
|
1505 |
// Check if we are at the bottom |
51ff319947c3
Code cleanup/optimization
Mikael Berthe <mikael@lilotux.net>
parents:
358
diff
changeset
|
1506 |
for (n=0 ; hbuf_top && n < CHAT_WIN_HEIGHT-1 ; n++) |
51ff319947c3
Code cleanup/optimization
Mikael Berthe <mikael@lilotux.net>
parents:
358
diff
changeset
|
1507 |
hbuf_top = g_list_next(hbuf_top); |
51ff319947c3
Code cleanup/optimization
Mikael Berthe <mikael@lilotux.net>
parents:
358
diff
changeset
|
1508 |
if (!hbuf_top) |
51ff319947c3
Code cleanup/optimization
Mikael Berthe <mikael@lilotux.net>
parents:
358
diff
changeset
|
1509 |
win_entry->top = NULL; // End reached |
51ff319947c3
Code cleanup/optimization
Mikael Berthe <mikael@lilotux.net>
parents:
358
diff
changeset
|
1510 |
} |
105 | 1511 |
|
1512 |
// Refresh the window |
|
1513 |
scr_UpdateWindow(win_entry); |
|
1514 |
||
1515 |
// Finished :) |
|
1516 |
update_panels(); |
|
1517 |
doupdate(); |
|
1518 |
} |
|
1519 |
||
369
499170ed71c9
Rename some buffer commands, for homogeneity
Mikael Berthe <mikael@lilotux.net>
parents:
365
diff
changeset
|
1520 |
// scr_BufferClear() |
143 | 1521 |
// Clear the current buddy window (used for the /clear command) |
369
499170ed71c9
Rename some buffer commands, for homogeneity
Mikael Berthe <mikael@lilotux.net>
parents:
365
diff
changeset
|
1522 |
void scr_BufferClear(void) |
108 | 1523 |
{ |
822 | 1524 |
winbuf *win_entry; |
849
42c43a88d823
Status buffer management
Mikael Berthe <mikael@lilotux.net>
parents:
848
diff
changeset
|
1525 |
guint isspe; |
108 | 1526 |
|
1527 |
// Get win_entry |
|
361
51ff319947c3
Code cleanup/optimization
Mikael Berthe <mikael@lilotux.net>
parents:
358
diff
changeset
|
1528 |
if (!current_buddy) return; |
849
42c43a88d823
Status buffer management
Mikael Berthe <mikael@lilotux.net>
parents:
848
diff
changeset
|
1529 |
isspe = buddy_gettype(BUDDATA(current_buddy)) & ROSTER_TYPE_SPECIAL; |
42c43a88d823
Status buffer management
Mikael Berthe <mikael@lilotux.net>
parents:
848
diff
changeset
|
1530 |
win_entry = scr_SearchWindow(CURRENT_JID, isspe); |
361
51ff319947c3
Code cleanup/optimization
Mikael Berthe <mikael@lilotux.net>
parents:
358
diff
changeset
|
1531 |
if (!win_entry) return; |
108 | 1532 |
|
1533 |
win_entry->cleared = TRUE; |
|
109 | 1534 |
win_entry->top = NULL; |
108 | 1535 |
|
1536 |
// Refresh the window |
|
1537 |
scr_UpdateWindow(win_entry); |
|
1538 |
||
1539 |
// Finished :) |
|
1540 |
update_panels(); |
|
1541 |
doupdate(); |
|
1542 |
} |
|
1543 |
||
866 | 1544 |
// scr_BufferPurge() |
1545 |
// Purge/Drop the current buddy buffer |
|
1546 |
void scr_BufferPurge(void) |
|
1547 |
{ |
|
1548 |
winbuf *win_entry; |
|
1549 |
guint isspe; |
|
1550 |
||
1551 |
// Get win_entry |
|
1552 |
if (!current_buddy) return; |
|
1553 |
isspe = buddy_gettype(BUDDATA(current_buddy)) & ROSTER_TYPE_SPECIAL; |
|
1554 |
win_entry = scr_SearchWindow(CURRENT_JID, isspe); |
|
1555 |
if (!win_entry) return; |
|
1556 |
||
1557 |
// Delete the current hbuf |
|
1558 |
hbuf_free(&win_entry->hbuf); |
|
1559 |
if (isspe) { |
|
1560 |
// Currently it can only be the status buffer |
|
1561 |
statushbuf = NULL; |
|
1562 |
} |
|
1563 |
||
1564 |
win_entry->cleared = FALSE; |
|
1565 |
win_entry->top = NULL; |
|
1566 |
||
1567 |
// Refresh the window |
|
1568 |
scr_UpdateBuddyWindow(); |
|
1569 |
||
1570 |
// Finished :) |
|
1571 |
update_panels(); |
|
1572 |
doupdate(); |
|
1573 |
} |
|
1574 |
||
873
ee39f6d94d43
Add /buffer {scroll_lock|scroll_unlock|toggle_scroll}
Mikael Berthe <mikael@lilotux.net>
parents:
866
diff
changeset
|
1575 |
// scr_BufferScrollLock(lock) |
ee39f6d94d43
Add /buffer {scroll_lock|scroll_unlock|toggle_scroll}
Mikael Berthe <mikael@lilotux.net>
parents:
866
diff
changeset
|
1576 |
// Lock/unlock the current buddy buffer |
ee39f6d94d43
Add /buffer {scroll_lock|scroll_unlock|toggle_scroll}
Mikael Berthe <mikael@lilotux.net>
parents:
866
diff
changeset
|
1577 |
// lock = 1 : lock |
ee39f6d94d43
Add /buffer {scroll_lock|scroll_unlock|toggle_scroll}
Mikael Berthe <mikael@lilotux.net>
parents:
866
diff
changeset
|
1578 |
// lock = 0 : unlock |
ee39f6d94d43
Add /buffer {scroll_lock|scroll_unlock|toggle_scroll}
Mikael Berthe <mikael@lilotux.net>
parents:
866
diff
changeset
|
1579 |
// lock = -1: toggle lock status |
ee39f6d94d43
Add /buffer {scroll_lock|scroll_unlock|toggle_scroll}
Mikael Berthe <mikael@lilotux.net>
parents:
866
diff
changeset
|
1580 |
void scr_BufferScrollLock(int lock) |
ee39f6d94d43
Add /buffer {scroll_lock|scroll_unlock|toggle_scroll}
Mikael Berthe <mikael@lilotux.net>
parents:
866
diff
changeset
|
1581 |
{ |
ee39f6d94d43
Add /buffer {scroll_lock|scroll_unlock|toggle_scroll}
Mikael Berthe <mikael@lilotux.net>
parents:
866
diff
changeset
|
1582 |
winbuf *win_entry; |
ee39f6d94d43
Add /buffer {scroll_lock|scroll_unlock|toggle_scroll}
Mikael Berthe <mikael@lilotux.net>
parents:
866
diff
changeset
|
1583 |
guint isspe; |
ee39f6d94d43
Add /buffer {scroll_lock|scroll_unlock|toggle_scroll}
Mikael Berthe <mikael@lilotux.net>
parents:
866
diff
changeset
|
1584 |
|
ee39f6d94d43
Add /buffer {scroll_lock|scroll_unlock|toggle_scroll}
Mikael Berthe <mikael@lilotux.net>
parents:
866
diff
changeset
|
1585 |
// Get win_entry |
ee39f6d94d43
Add /buffer {scroll_lock|scroll_unlock|toggle_scroll}
Mikael Berthe <mikael@lilotux.net>
parents:
866
diff
changeset
|
1586 |
if (!current_buddy) return; |
ee39f6d94d43
Add /buffer {scroll_lock|scroll_unlock|toggle_scroll}
Mikael Berthe <mikael@lilotux.net>
parents:
866
diff
changeset
|
1587 |
isspe = buddy_gettype(BUDDATA(current_buddy)) & ROSTER_TYPE_SPECIAL; |
ee39f6d94d43
Add /buffer {scroll_lock|scroll_unlock|toggle_scroll}
Mikael Berthe <mikael@lilotux.net>
parents:
866
diff
changeset
|
1588 |
win_entry = scr_SearchWindow(CURRENT_JID, isspe); |
ee39f6d94d43
Add /buffer {scroll_lock|scroll_unlock|toggle_scroll}
Mikael Berthe <mikael@lilotux.net>
parents:
866
diff
changeset
|
1589 |
if (!win_entry) return; |
ee39f6d94d43
Add /buffer {scroll_lock|scroll_unlock|toggle_scroll}
Mikael Berthe <mikael@lilotux.net>
parents:
866
diff
changeset
|
1590 |
|
ee39f6d94d43
Add /buffer {scroll_lock|scroll_unlock|toggle_scroll}
Mikael Berthe <mikael@lilotux.net>
parents:
866
diff
changeset
|
1591 |
if (lock == -1) |
ee39f6d94d43
Add /buffer {scroll_lock|scroll_unlock|toggle_scroll}
Mikael Berthe <mikael@lilotux.net>
parents:
866
diff
changeset
|
1592 |
lock = !win_entry->lock; |
ee39f6d94d43
Add /buffer {scroll_lock|scroll_unlock|toggle_scroll}
Mikael Berthe <mikael@lilotux.net>
parents:
866
diff
changeset
|
1593 |
|
ee39f6d94d43
Add /buffer {scroll_lock|scroll_unlock|toggle_scroll}
Mikael Berthe <mikael@lilotux.net>
parents:
866
diff
changeset
|
1594 |
if (lock) { |
ee39f6d94d43
Add /buffer {scroll_lock|scroll_unlock|toggle_scroll}
Mikael Berthe <mikael@lilotux.net>
parents:
866
diff
changeset
|
1595 |
win_entry->lock = TRUE; |
ee39f6d94d43
Add /buffer {scroll_lock|scroll_unlock|toggle_scroll}
Mikael Berthe <mikael@lilotux.net>
parents:
866
diff
changeset
|
1596 |
} else { |
ee39f6d94d43
Add /buffer {scroll_lock|scroll_unlock|toggle_scroll}
Mikael Berthe <mikael@lilotux.net>
parents:
866
diff
changeset
|
1597 |
win_entry->lock = FALSE; |
ee39f6d94d43
Add /buffer {scroll_lock|scroll_unlock|toggle_scroll}
Mikael Berthe <mikael@lilotux.net>
parents:
866
diff
changeset
|
1598 |
win_entry->cleared = FALSE; |
ee39f6d94d43
Add /buffer {scroll_lock|scroll_unlock|toggle_scroll}
Mikael Berthe <mikael@lilotux.net>
parents:
866
diff
changeset
|
1599 |
win_entry->top = NULL; |
ee39f6d94d43
Add /buffer {scroll_lock|scroll_unlock|toggle_scroll}
Mikael Berthe <mikael@lilotux.net>
parents:
866
diff
changeset
|
1600 |
} |
ee39f6d94d43
Add /buffer {scroll_lock|scroll_unlock|toggle_scroll}
Mikael Berthe <mikael@lilotux.net>
parents:
866
diff
changeset
|
1601 |
|
ee39f6d94d43
Add /buffer {scroll_lock|scroll_unlock|toggle_scroll}
Mikael Berthe <mikael@lilotux.net>
parents:
866
diff
changeset
|
1602 |
// If chatmode is disabled and we're at the bottom of the buffer, |
ee39f6d94d43
Add /buffer {scroll_lock|scroll_unlock|toggle_scroll}
Mikael Berthe <mikael@lilotux.net>
parents:
866
diff
changeset
|
1603 |
// we need to set the "top" line, so we need to call scr_ShowBuddyWindow() |
ee39f6d94d43
Add /buffer {scroll_lock|scroll_unlock|toggle_scroll}
Mikael Berthe <mikael@lilotux.net>
parents:
866
diff
changeset
|
1604 |
// at least once. (Maybe it will cause a double refresh...) |
ee39f6d94d43
Add /buffer {scroll_lock|scroll_unlock|toggle_scroll}
Mikael Berthe <mikael@lilotux.net>
parents:
866
diff
changeset
|
1605 |
if (!chatmode && !win_entry->top) { |
ee39f6d94d43
Add /buffer {scroll_lock|scroll_unlock|toggle_scroll}
Mikael Berthe <mikael@lilotux.net>
parents:
866
diff
changeset
|
1606 |
chatmode = TRUE; |
ee39f6d94d43
Add /buffer {scroll_lock|scroll_unlock|toggle_scroll}
Mikael Berthe <mikael@lilotux.net>
parents:
866
diff
changeset
|
1607 |
scr_ShowBuddyWindow(); |
ee39f6d94d43
Add /buffer {scroll_lock|scroll_unlock|toggle_scroll}
Mikael Berthe <mikael@lilotux.net>
parents:
866
diff
changeset
|
1608 |
chatmode = FALSE; |
ee39f6d94d43
Add /buffer {scroll_lock|scroll_unlock|toggle_scroll}
Mikael Berthe <mikael@lilotux.net>
parents:
866
diff
changeset
|
1609 |
} |
ee39f6d94d43
Add /buffer {scroll_lock|scroll_unlock|toggle_scroll}
Mikael Berthe <mikael@lilotux.net>
parents:
866
diff
changeset
|
1610 |
|
ee39f6d94d43
Add /buffer {scroll_lock|scroll_unlock|toggle_scroll}
Mikael Berthe <mikael@lilotux.net>
parents:
866
diff
changeset
|
1611 |
// Refresh the window |
ee39f6d94d43
Add /buffer {scroll_lock|scroll_unlock|toggle_scroll}
Mikael Berthe <mikael@lilotux.net>
parents:
866
diff
changeset
|
1612 |
scr_UpdateBuddyWindow(); |
ee39f6d94d43
Add /buffer {scroll_lock|scroll_unlock|toggle_scroll}
Mikael Berthe <mikael@lilotux.net>
parents:
866
diff
changeset
|
1613 |
|
ee39f6d94d43
Add /buffer {scroll_lock|scroll_unlock|toggle_scroll}
Mikael Berthe <mikael@lilotux.net>
parents:
866
diff
changeset
|
1614 |
// Finished :) |
ee39f6d94d43
Add /buffer {scroll_lock|scroll_unlock|toggle_scroll}
Mikael Berthe <mikael@lilotux.net>
parents:
866
diff
changeset
|
1615 |
update_panels(); |
ee39f6d94d43
Add /buffer {scroll_lock|scroll_unlock|toggle_scroll}
Mikael Berthe <mikael@lilotux.net>
parents:
866
diff
changeset
|
1616 |
doupdate(); |
ee39f6d94d43
Add /buffer {scroll_lock|scroll_unlock|toggle_scroll}
Mikael Berthe <mikael@lilotux.net>
parents:
866
diff
changeset
|
1617 |
} |
ee39f6d94d43
Add /buffer {scroll_lock|scroll_unlock|toggle_scroll}
Mikael Berthe <mikael@lilotux.net>
parents:
866
diff
changeset
|
1618 |
|
361
51ff319947c3
Code cleanup/optimization
Mikael Berthe <mikael@lilotux.net>
parents:
358
diff
changeset
|
1619 |
// scr_BufferTopBottom() |
51ff319947c3
Code cleanup/optimization
Mikael Berthe <mikael@lilotux.net>
parents:
358
diff
changeset
|
1620 |
// Jump to the head/tail of the current buddy window |
51ff319947c3
Code cleanup/optimization
Mikael Berthe <mikael@lilotux.net>
parents:
358
diff
changeset
|
1621 |
// (top if topbottom == -1, bottom topbottom == 1) |
51ff319947c3
Code cleanup/optimization
Mikael Berthe <mikael@lilotux.net>
parents:
358
diff
changeset
|
1622 |
void scr_BufferTopBottom(int topbottom) |
187 | 1623 |
{ |
822 | 1624 |
winbuf *win_entry; |
849
42c43a88d823
Status buffer management
Mikael Berthe <mikael@lilotux.net>
parents:
848
diff
changeset
|
1625 |
guint isspe; |
187 | 1626 |
|
1627 |
// Get win_entry |
|
1628 |
if (!current_buddy) return; |
|
849
42c43a88d823
Status buffer management
Mikael Berthe <mikael@lilotux.net>
parents:
848
diff
changeset
|
1629 |
isspe = buddy_gettype(BUDDATA(current_buddy)) & ROSTER_TYPE_SPECIAL; |
42c43a88d823
Status buffer management
Mikael Berthe <mikael@lilotux.net>
parents:
848
diff
changeset
|
1630 |
win_entry = scr_SearchWindow(CURRENT_JID, isspe); |
187 | 1631 |
if (!win_entry) return; |
1632 |
||
1633 |
win_entry->cleared = FALSE; |
|
361
51ff319947c3
Code cleanup/optimization
Mikael Berthe <mikael@lilotux.net>
parents:
358
diff
changeset
|
1634 |
if (topbottom == 1) |
51ff319947c3
Code cleanup/optimization
Mikael Berthe <mikael@lilotux.net>
parents:
358
diff
changeset
|
1635 |
win_entry->top = NULL; |
51ff319947c3
Code cleanup/optimization
Mikael Berthe <mikael@lilotux.net>
parents:
358
diff
changeset
|
1636 |
else |
51ff319947c3
Code cleanup/optimization
Mikael Berthe <mikael@lilotux.net>
parents:
358
diff
changeset
|
1637 |
win_entry->top = g_list_first(win_entry->hbuf); |
187 | 1638 |
|
1639 |
// Refresh the window |
|
1640 |
scr_UpdateWindow(win_entry); |
|
1641 |
||
1642 |
// Finished :) |
|
1643 |
update_panels(); |
|
1644 |
doupdate(); |
|
1645 |
} |
|
1646 |
||
370
dd9e2eb52916
Add /buffer search_{backward,forward}
Mikael Berthe <mikael@lilotux.net>
parents:
369
diff
changeset
|
1647 |
// scr_BufferSearch(direction, text) |
dd9e2eb52916
Add /buffer search_{backward,forward}
Mikael Berthe <mikael@lilotux.net>
parents:
369
diff
changeset
|
1648 |
// Jump to the next line containing text |
dd9e2eb52916
Add /buffer search_{backward,forward}
Mikael Berthe <mikael@lilotux.net>
parents:
369
diff
changeset
|
1649 |
// (backward search if direction == -1, forward if topbottom == 1) |
dd9e2eb52916
Add /buffer search_{backward,forward}
Mikael Berthe <mikael@lilotux.net>
parents:
369
diff
changeset
|
1650 |
void scr_BufferSearch(int direction, const char *text) |
dd9e2eb52916
Add /buffer search_{backward,forward}
Mikael Berthe <mikael@lilotux.net>
parents:
369
diff
changeset
|
1651 |
{ |
822 | 1652 |
winbuf *win_entry; |
370
dd9e2eb52916
Add /buffer search_{backward,forward}
Mikael Berthe <mikael@lilotux.net>
parents:
369
diff
changeset
|
1653 |
GList *current_line, *search_res; |
849
42c43a88d823
Status buffer management
Mikael Berthe <mikael@lilotux.net>
parents:
848
diff
changeset
|
1654 |
guint isspe; |
370
dd9e2eb52916
Add /buffer search_{backward,forward}
Mikael Berthe <mikael@lilotux.net>
parents:
369
diff
changeset
|
1655 |
|
dd9e2eb52916
Add /buffer search_{backward,forward}
Mikael Berthe <mikael@lilotux.net>
parents:
369
diff
changeset
|
1656 |
// Get win_entry |
dd9e2eb52916
Add /buffer search_{backward,forward}
Mikael Berthe <mikael@lilotux.net>
parents:
369
diff
changeset
|
1657 |
if (!current_buddy) return; |
849
42c43a88d823
Status buffer management
Mikael Berthe <mikael@lilotux.net>
parents:
848
diff
changeset
|
1658 |
isspe = buddy_gettype(BUDDATA(current_buddy)) & ROSTER_TYPE_SPECIAL; |
42c43a88d823
Status buffer management
Mikael Berthe <mikael@lilotux.net>
parents:
848
diff
changeset
|
1659 |
win_entry = scr_SearchWindow(CURRENT_JID, isspe); |
370
dd9e2eb52916
Add /buffer search_{backward,forward}
Mikael Berthe <mikael@lilotux.net>
parents:
369
diff
changeset
|
1660 |
if (!win_entry) return; |
dd9e2eb52916
Add /buffer search_{backward,forward}
Mikael Berthe <mikael@lilotux.net>
parents:
369
diff
changeset
|
1661 |
|
dd9e2eb52916
Add /buffer search_{backward,forward}
Mikael Berthe <mikael@lilotux.net>
parents:
369
diff
changeset
|
1662 |
if (win_entry->top) |
dd9e2eb52916
Add /buffer search_{backward,forward}
Mikael Berthe <mikael@lilotux.net>
parents:
369
diff
changeset
|
1663 |
current_line = win_entry->top; |
dd9e2eb52916
Add /buffer search_{backward,forward}
Mikael Berthe <mikael@lilotux.net>
parents:
369
diff
changeset
|
1664 |
else |
dd9e2eb52916
Add /buffer search_{backward,forward}
Mikael Berthe <mikael@lilotux.net>
parents:
369
diff
changeset
|
1665 |
current_line = g_list_last(win_entry->hbuf); |
dd9e2eb52916
Add /buffer search_{backward,forward}
Mikael Berthe <mikael@lilotux.net>
parents:
369
diff
changeset
|
1666 |
|
dd9e2eb52916
Add /buffer search_{backward,forward}
Mikael Berthe <mikael@lilotux.net>
parents:
369
diff
changeset
|
1667 |
search_res = hbuf_search(current_line, direction, text); |
dd9e2eb52916
Add /buffer search_{backward,forward}
Mikael Berthe <mikael@lilotux.net>
parents:
369
diff
changeset
|
1668 |
|
dd9e2eb52916
Add /buffer search_{backward,forward}
Mikael Berthe <mikael@lilotux.net>
parents:
369
diff
changeset
|
1669 |
if (search_res) { |
dd9e2eb52916
Add /buffer search_{backward,forward}
Mikael Berthe <mikael@lilotux.net>
parents:
369
diff
changeset
|
1670 |
win_entry->cleared = FALSE; |
dd9e2eb52916
Add /buffer search_{backward,forward}
Mikael Berthe <mikael@lilotux.net>
parents:
369
diff
changeset
|
1671 |
win_entry->top = search_res; |
dd9e2eb52916
Add /buffer search_{backward,forward}
Mikael Berthe <mikael@lilotux.net>
parents:
369
diff
changeset
|
1672 |
|
dd9e2eb52916
Add /buffer search_{backward,forward}
Mikael Berthe <mikael@lilotux.net>
parents:
369
diff
changeset
|
1673 |
// Refresh the window |
dd9e2eb52916
Add /buffer search_{backward,forward}
Mikael Berthe <mikael@lilotux.net>
parents:
369
diff
changeset
|
1674 |
scr_UpdateWindow(win_entry); |
dd9e2eb52916
Add /buffer search_{backward,forward}
Mikael Berthe <mikael@lilotux.net>
parents:
369
diff
changeset
|
1675 |
|
dd9e2eb52916
Add /buffer search_{backward,forward}
Mikael Berthe <mikael@lilotux.net>
parents:
369
diff
changeset
|
1676 |
// Finished :) |
dd9e2eb52916
Add /buffer search_{backward,forward}
Mikael Berthe <mikael@lilotux.net>
parents:
369
diff
changeset
|
1677 |
update_panels(); |
dd9e2eb52916
Add /buffer search_{backward,forward}
Mikael Berthe <mikael@lilotux.net>
parents:
369
diff
changeset
|
1678 |
doupdate(); |
dd9e2eb52916
Add /buffer search_{backward,forward}
Mikael Berthe <mikael@lilotux.net>
parents:
369
diff
changeset
|
1679 |
} else |
374
bd5638c21834
Improve logging system (traces)
Mikael Berthe <mikael@lilotux.net>
parents:
373
diff
changeset
|
1680 |
scr_LogPrint(LPRINT_NORMAL, "Search string not found"); |
370
dd9e2eb52916
Add /buffer search_{backward,forward}
Mikael Berthe <mikael@lilotux.net>
parents:
369
diff
changeset
|
1681 |
} |
dd9e2eb52916
Add /buffer search_{backward,forward}
Mikael Berthe <mikael@lilotux.net>
parents:
369
diff
changeset
|
1682 |
|
462 | 1683 |
// scr_BufferPercent(n) |
1684 |
// Jump to the specified position in the buffer, in % |
|
1685 |
void scr_BufferPercent(int pc) |
|
1686 |
{ |
|
822 | 1687 |
winbuf *win_entry; |
462 | 1688 |
GList *search_res; |
849
42c43a88d823
Status buffer management
Mikael Berthe <mikael@lilotux.net>
parents:
848
diff
changeset
|
1689 |
guint isspe; |
462 | 1690 |
|
1691 |
// Get win_entry |
|
1692 |
if (!current_buddy) return; |
|
849
42c43a88d823
Status buffer management
Mikael Berthe <mikael@lilotux.net>
parents:
848
diff
changeset
|
1693 |
isspe = buddy_gettype(BUDDATA(current_buddy)) & ROSTER_TYPE_SPECIAL; |
42c43a88d823
Status buffer management
Mikael Berthe <mikael@lilotux.net>
parents:
848
diff
changeset
|
1694 |
win_entry = scr_SearchWindow(CURRENT_JID, isspe); |
462 | 1695 |
if (!win_entry) return; |
1696 |
||
1697 |
if (pc < 0 || pc > 100) { |
|
1698 |
scr_LogPrint(LPRINT_NORMAL, "Bad % value"); |
|
1699 |
return; |
|
1700 |
} |
|
1701 |
||
1702 |
search_res = hbuf_jump_percent(win_entry->hbuf, pc); |
|
1703 |
||
1704 |
win_entry->cleared = FALSE; |
|
1705 |
win_entry->top = search_res; |
|
1706 |
||
1707 |
// Refresh the window |
|
1708 |
scr_UpdateWindow(win_entry); |
|
1709 |
||
1710 |
// Finished :) |
|
1711 |
update_panels(); |
|
1712 |
doupdate(); |
|
1713 |
} |
|
1714 |
||
464 | 1715 |
// scr_BufferDate(t) |
1716 |
// Jump to the first line after date t in the buffer |
|
1717 |
// t is a date in seconds since `00:00:00 1970-01-01 UTC' |
|
1718 |
void scr_BufferDate(time_t t) |
|
1719 |
{ |
|
822 | 1720 |
winbuf *win_entry; |
464 | 1721 |
GList *search_res; |
849
42c43a88d823
Status buffer management
Mikael Berthe <mikael@lilotux.net>
parents:
848
diff
changeset
|
1722 |
guint isspe; |
464 | 1723 |
|
1724 |
// Get win_entry |
|
1725 |
if (!current_buddy) return; |
|
849
42c43a88d823
Status buffer management
Mikael Berthe <mikael@lilotux.net>
parents:
848
diff
changeset
|
1726 |
isspe = buddy_gettype(BUDDATA(current_buddy)) & ROSTER_TYPE_SPECIAL; |
42c43a88d823
Status buffer management
Mikael Berthe <mikael@lilotux.net>
parents:
848
diff
changeset
|
1727 |
win_entry = scr_SearchWindow(CURRENT_JID, isspe); |
464 | 1728 |
if (!win_entry) return; |
1729 |
||
1730 |
search_res = hbuf_jump_date(win_entry->hbuf, t); |
|
1731 |
||
1732 |
win_entry->cleared = FALSE; |
|
1733 |
win_entry->top = search_res; |
|
1734 |
||
1735 |
// Refresh the window |
|
1736 |
scr_UpdateWindow(win_entry); |
|
1737 |
||
1738 |
// Finished :) |
|
1739 |
update_panels(); |
|
1740 |
doupdate(); |
|
1741 |
} |
|
1742 |
||
143 | 1743 |
// scr_set_chatmode() |
261 | 1744 |
// Public function to (un)set chatmode... |
129 | 1745 |
inline void scr_set_chatmode(int enable) |
1746 |
{ |
|
1747 |
chatmode = enable; |
|
721
9cf31c9b1dc4
Use room topic as a description in the chat status line
Mikael Berthe <mikael@lilotux.net>
parents:
720
diff
changeset
|
1748 |
scr_UpdateChatStatus(TRUE); |
129 | 1749 |
} |
1750 |
||
238 | 1751 |
// scr_get_multimode() |
261 | 1752 |
// Public function to get multimode status... |
238 | 1753 |
inline int scr_get_multimode() |
1754 |
{ |
|
1755 |
return multimode; |
|
1756 |
} |
|
1757 |
||
654
d7fe7b88e4fc
MUC: Set the new_message flag when joining a room
Mikael Berthe <mikael@lilotux.net>
parents:
652
diff
changeset
|
1758 |
// 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
|
1759 |
// Set the message flag unless we're already in the jid buffer window |
d7fe7b88e4fc
MUC: Set the new_message flag when joining a room
Mikael Berthe <mikael@lilotux.net>
parents:
652
diff
changeset
|
1760 |
void scr_setmsgflag_if_needed(const char *jid) |
d7fe7b88e4fc
MUC: Set the new_message flag when joining a room
Mikael Berthe <mikael@lilotux.net>
parents:
652
diff
changeset
|
1761 |
{ |
667
86bc3295a4db
Fix segfault in scr_setmsgflag_if_needed()
Mikael Berthe <mikael@lilotux.net>
parents:
658
diff
changeset
|
1762 |
const char *current_jid; |
873
ee39f6d94d43
Add /buffer {scroll_lock|scroll_unlock|toggle_scroll}
Mikael Berthe <mikael@lilotux.net>
parents:
866
diff
changeset
|
1763 |
bool iscurrentlocked = FALSE; |
667
86bc3295a4db
Fix segfault in scr_setmsgflag_if_needed()
Mikael Berthe <mikael@lilotux.net>
parents:
658
diff
changeset
|
1764 |
|
849
42c43a88d823
Status buffer management
Mikael Berthe <mikael@lilotux.net>
parents:
848
diff
changeset
|
1765 |
if (!jid) |
42c43a88d823
Status buffer management
Mikael Berthe <mikael@lilotux.net>
parents:
848
diff
changeset
|
1766 |
return; |
42c43a88d823
Status buffer management
Mikael Berthe <mikael@lilotux.net>
parents:
848
diff
changeset
|
1767 |
|
873
ee39f6d94d43
Add /buffer {scroll_lock|scroll_unlock|toggle_scroll}
Mikael Berthe <mikael@lilotux.net>
parents:
866
diff
changeset
|
1768 |
if (current_buddy) { |
ee39f6d94d43
Add /buffer {scroll_lock|scroll_unlock|toggle_scroll}
Mikael Berthe <mikael@lilotux.net>
parents:
866
diff
changeset
|
1769 |
guint isspe; |
ee39f6d94d43
Add /buffer {scroll_lock|scroll_unlock|toggle_scroll}
Mikael Berthe <mikael@lilotux.net>
parents:
866
diff
changeset
|
1770 |
isspe = buddy_gettype(BUDDATA(current_buddy)) & ROSTER_TYPE_SPECIAL; |
667
86bc3295a4db
Fix segfault in scr_setmsgflag_if_needed()
Mikael Berthe <mikael@lilotux.net>
parents:
658
diff
changeset
|
1771 |
current_jid = buddy_getjid(BUDDATA(current_buddy)); |
873
ee39f6d94d43
Add /buffer {scroll_lock|scroll_unlock|toggle_scroll}
Mikael Berthe <mikael@lilotux.net>
parents:
866
diff
changeset
|
1772 |
if (current_jid) { |
ee39f6d94d43
Add /buffer {scroll_lock|scroll_unlock|toggle_scroll}
Mikael Berthe <mikael@lilotux.net>
parents:
866
diff
changeset
|
1773 |
winbuf *win_entry = scr_SearchWindow(current_jid, isspe); |
ee39f6d94d43
Add /buffer {scroll_lock|scroll_unlock|toggle_scroll}
Mikael Berthe <mikael@lilotux.net>
parents:
866
diff
changeset
|
1774 |
iscurrentlocked = win_entry->lock; |
ee39f6d94d43
Add /buffer {scroll_lock|scroll_unlock|toggle_scroll}
Mikael Berthe <mikael@lilotux.net>
parents:
866
diff
changeset
|
1775 |
} |
ee39f6d94d43
Add /buffer {scroll_lock|scroll_unlock|toggle_scroll}
Mikael Berthe <mikael@lilotux.net>
parents:
866
diff
changeset
|
1776 |
} else { |
667
86bc3295a4db
Fix segfault in scr_setmsgflag_if_needed()
Mikael Berthe <mikael@lilotux.net>
parents:
658
diff
changeset
|
1777 |
current_jid = NULL; |
873
ee39f6d94d43
Add /buffer {scroll_lock|scroll_unlock|toggle_scroll}
Mikael Berthe <mikael@lilotux.net>
parents:
866
diff
changeset
|
1778 |
} |
ee39f6d94d43
Add /buffer {scroll_lock|scroll_unlock|toggle_scroll}
Mikael Berthe <mikael@lilotux.net>
parents:
866
diff
changeset
|
1779 |
if (!chatmode || !current_jid || strcmp(jid, current_jid) || iscurrentlocked) |
654
d7fe7b88e4fc
MUC: Set the new_message flag when joining a room
Mikael Berthe <mikael@lilotux.net>
parents:
652
diff
changeset
|
1780 |
roster_msg_setflag(jid, TRUE); |
d7fe7b88e4fc
MUC: Set the new_message flag when joining a room
Mikael Berthe <mikael@lilotux.net>
parents:
652
diff
changeset
|
1781 |
} |
d7fe7b88e4fc
MUC: Set the new_message flag when joining a room
Mikael Berthe <mikael@lilotux.net>
parents:
652
diff
changeset
|
1782 |
|
238 | 1783 |
// scr_set_multimode() |
261 | 1784 |
// Public function to (un)set multimode... |
260
33e1a05864a6
Add "verbatim multi-line" mode, with commands disabled
mikael@frmp8452
parents:
252
diff
changeset
|
1785 |
// Convention: |
33e1a05864a6
Add "verbatim multi-line" mode, with commands disabled
mikael@frmp8452
parents:
252
diff
changeset
|
1786 |
// 0 = disabled / 1 = multimode / 2 = multimode verbatim (commands disabled) |
807
f6cda389db48
Allow messages with a subject (/msay)
Mikael Berthe <mikael@lilotux.net>
parents:
806
diff
changeset
|
1787 |
inline void scr_set_multimode(int enable, char *subject) |
238 | 1788 |
{ |
807
f6cda389db48
Allow messages with a subject (/msay)
Mikael Berthe <mikael@lilotux.net>
parents:
806
diff
changeset
|
1789 |
g_free(multiline); |
f6cda389db48
Allow messages with a subject (/msay)
Mikael Berthe <mikael@lilotux.net>
parents:
806
diff
changeset
|
1790 |
multiline = NULL; |
f6cda389db48
Allow messages with a subject (/msay)
Mikael Berthe <mikael@lilotux.net>
parents:
806
diff
changeset
|
1791 |
|
f6cda389db48
Allow messages with a subject (/msay)
Mikael Berthe <mikael@lilotux.net>
parents:
806
diff
changeset
|
1792 |
g_free(multimode_subj); |
f6cda389db48
Allow messages with a subject (/msay)
Mikael Berthe <mikael@lilotux.net>
parents:
806
diff
changeset
|
1793 |
if (enable && subject) |
f6cda389db48
Allow messages with a subject (/msay)
Mikael Berthe <mikael@lilotux.net>
parents:
806
diff
changeset
|
1794 |
multimode_subj = g_strdup(subject); |
f6cda389db48
Allow messages with a subject (/msay)
Mikael Berthe <mikael@lilotux.net>
parents:
806
diff
changeset
|
1795 |
else |
f6cda389db48
Allow messages with a subject (/msay)
Mikael Berthe <mikael@lilotux.net>
parents:
806
diff
changeset
|
1796 |
multimode_subj = NULL; |
f6cda389db48
Allow messages with a subject (/msay)
Mikael Berthe <mikael@lilotux.net>
parents:
806
diff
changeset
|
1797 |
|
260
33e1a05864a6
Add "verbatim multi-line" mode, with commands disabled
mikael@frmp8452
parents:
252
diff
changeset
|
1798 |
multimode = enable; |
238 | 1799 |
} |
1800 |
||
1801 |
// scr_get_multiline() |
|
261 | 1802 |
// Public function to get the current multi-line. |
807
f6cda389db48
Allow messages with a subject (/msay)
Mikael Berthe <mikael@lilotux.net>
parents:
806
diff
changeset
|
1803 |
inline const char *scr_get_multiline(void) |
238 | 1804 |
{ |
1805 |
if (multimode && multiline) |
|
1806 |
return multiline; |
|
807
f6cda389db48
Allow messages with a subject (/msay)
Mikael Berthe <mikael@lilotux.net>
parents:
806
diff
changeset
|
1807 |
return NULL; |
f6cda389db48
Allow messages with a subject (/msay)
Mikael Berthe <mikael@lilotux.net>
parents:
806
diff
changeset
|
1808 |
} |
f6cda389db48
Allow messages with a subject (/msay)
Mikael Berthe <mikael@lilotux.net>
parents:
806
diff
changeset
|
1809 |
|
f6cda389db48
Allow messages with a subject (/msay)
Mikael Berthe <mikael@lilotux.net>
parents:
806
diff
changeset
|
1810 |
// scr_get_multimode_subj() |
f6cda389db48
Allow messages with a subject (/msay)
Mikael Berthe <mikael@lilotux.net>
parents:
806
diff
changeset
|
1811 |
// Public function to get the multi-line subject, if any. |
f6cda389db48
Allow messages with a subject (/msay)
Mikael Berthe <mikael@lilotux.net>
parents:
806
diff
changeset
|
1812 |
inline const char *scr_get_multimode_subj(void) |
f6cda389db48
Allow messages with a subject (/msay)
Mikael Berthe <mikael@lilotux.net>
parents:
806
diff
changeset
|
1813 |
{ |
f6cda389db48
Allow messages with a subject (/msay)
Mikael Berthe <mikael@lilotux.net>
parents:
806
diff
changeset
|
1814 |
if (multimode) |
f6cda389db48
Allow messages with a subject (/msay)
Mikael Berthe <mikael@lilotux.net>
parents:
806
diff
changeset
|
1815 |
return multimode_subj; |
f6cda389db48
Allow messages with a subject (/msay)
Mikael Berthe <mikael@lilotux.net>
parents:
806
diff
changeset
|
1816 |
return NULL; |
238 | 1817 |
} |
1818 |
||
1819 |
// scr_append_multiline(line) |
|
1820 |
// Public function to append a line to the current multi-line message. |
|
1821 |
// Skip empty leading lines. |
|
1822 |
void scr_append_multiline(const char *line) |
|
1823 |
{ |
|
1824 |
static int num; |
|
1825 |
||
1826 |
if (!multimode) { |
|
374
bd5638c21834
Improve logging system (traces)
Mikael Berthe <mikael@lilotux.net>
parents:
373
diff
changeset
|
1827 |
scr_LogPrint(LPRINT_NORMAL, "Error: Not in multi-line message mode!"); |
238 | 1828 |
return; |
1829 |
} |
|
1830 |
if (multiline) { |
|
1831 |
int len = strlen(multiline)+strlen(line)+2; |
|
252 | 1832 |
if (len >= HBB_BLOCKSIZE - 1) { |
238 | 1833 |
// We don't handle single messages with size > HBB_BLOCKSIZE |
1834 |
// (see hbuf) |
|
374
bd5638c21834
Improve logging system (traces)
Mikael Berthe <mikael@lilotux.net>
parents:
373
diff
changeset
|
1835 |
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
|
1836 |
"this line has not been added."); |
bd5638c21834
Improve logging system (traces)
Mikael Berthe <mikael@lilotux.net>
parents:
373
diff
changeset
|
1837 |
scr_LogPrint(LPRINT_NORMAL, "Please send this part now..."); |
238 | 1838 |
return; |
1839 |
} |
|
276
627925d885de
Limit the number of lines in multi-line messages
Mikael Berthe <mikael@lilotux.net>
parents:
271
diff
changeset
|
1840 |
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
|
1841 |
// 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
|
1842 |
// (It should be < 1000 yet) |
374
bd5638c21834
Improve logging system (traces)
Mikael Berthe <mikael@lilotux.net>
parents:
373
diff
changeset
|
1843 |
scr_LogPrint(LPRINT_NORMAL, "Your message has too many lines, " |
bd5638c21834
Improve logging system (traces)
Mikael Berthe <mikael@lilotux.net>
parents:
373
diff
changeset
|
1844 |
"this one has not been added."); |
bd5638c21834
Improve logging system (traces)
Mikael Berthe <mikael@lilotux.net>
parents:
373
diff
changeset
|
1845 |
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
|
1846 |
return; |
627925d885de
Limit the number of lines in multi-line messages
Mikael Berthe <mikael@lilotux.net>
parents:
271
diff
changeset
|
1847 |
} |
238 | 1848 |
multiline = g_renew(char, multiline, len); |
1849 |
strcat(multiline, "\n"); |
|
1850 |
strcat(multiline, line); |
|
1851 |
num++; |
|
1852 |
} else { |
|
1853 |
// First message line (we skip leading empty lines) |
|
1854 |
num = 0; |
|
1855 |
if (line[0]) { |
|
419 | 1856 |
multiline = g_strdup(line); |
238 | 1857 |
num++; |
1858 |
} else |
|
1859 |
return; |
|
1860 |
} |
|
772
464be13343a9
Store most data in UTF-8 internally
Mikael Berthe <mikael@lilotux.net>
parents:
771
diff
changeset
|
1861 |
scr_LogPrint(LPRINT_NORMAL|LPRINT_NOTUTF8, |
464be13343a9
Store most data in UTF-8 internally
Mikael Berthe <mikael@lilotux.net>
parents:
771
diff
changeset
|
1862 |
"Multi-line mode: line #%d added [%.25s...", num, line); |
238 | 1863 |
} |
1864 |
||
173 | 1865 |
// scr_cmdhisto_addline() |
1866 |
// Add a line to the inputLine history |
|
1867 |
inline void scr_cmdhisto_addline(char *line) |
|
1868 |
{ |
|
1869 |
if (!line || !*line) return; |
|
1870 |
||
1871 |
cmdhisto = g_list_append(cmdhisto, g_strdup(line)); |
|
1872 |
} |
|
1873 |
||
1874 |
// scr_cmdhisto_prev() |
|
1875 |
// Look for previous line beginning w/ the given mask in the inputLine history |
|
175 | 1876 |
// Returns NULL if none found |
336
eb994ee40029
Make some functions static
Mikael Berthe <mikael@lilotux.net>
parents:
332
diff
changeset
|
1877 |
static const char *scr_cmdhisto_prev(char *mask, guint len) |
173 | 1878 |
{ |
1879 |
GList *hl; |
|
1880 |
if (!cmdhisto_cur) { |
|
1881 |
hl = g_list_last(cmdhisto); |
|
174 | 1882 |
if (hl) { // backup current line |
1883 |
strncpy(cmdhisto_backup, mask, INPUTLINE_LENGTH); |
|
1884 |
} |
|
173 | 1885 |
} else { |
1886 |
hl = g_list_previous(cmdhisto_cur); |
|
1887 |
} |
|
1888 |
while (hl) { |
|
1889 |
if (!strncmp((char*)hl->data, mask, len)) { |
|
1890 |
// Found a match |
|
1891 |
cmdhisto_cur = hl; |
|
1892 |
return (const char*)hl->data; |
|
1893 |
} |
|
1894 |
hl = g_list_previous(hl); |
|
1895 |
} |
|
1896 |
return NULL; |
|
1897 |
} |
|
1898 |
||
1899 |
// scr_cmdhisto_next() |
|
1900 |
// Look for next line beginning w/ the given mask in the inputLine history |
|
175 | 1901 |
// Returns NULL if none found |
336
eb994ee40029
Make some functions static
Mikael Berthe <mikael@lilotux.net>
parents:
332
diff
changeset
|
1902 |
static const char *scr_cmdhisto_next(char *mask, guint len) |
173 | 1903 |
{ |
1904 |
GList *hl; |
|
1905 |
if (!cmdhisto_cur) return NULL; |
|
1906 |
hl = cmdhisto_cur; |
|
1907 |
while ((hl = g_list_next(hl)) != NULL) |
|
1908 |
if (!strncmp((char*)hl->data, mask, len)) { |
|
1909 |
// Found a match |
|
1910 |
cmdhisto_cur = hl; |
|
1911 |
return (const char*)hl->data; |
|
1912 |
} |
|
175 | 1913 |
// If the "backuped" line matches, we'll use it |
1914 |
if (strncmp(cmdhisto_backup, mask, len)) return NULL; // No match |
|
174 | 1915 |
cmdhisto_cur = NULL; |
1916 |
return cmdhisto_backup; |
|
173 | 1917 |
} |
1918 |
||
195 | 1919 |
// readline_transpose_chars() |
1920 |
// Drag the character before point forward over the character at |
|
1921 |
// point, moving point forward as well. If point is at the end of |
|
1922 |
// the line, then this transposes the two characters before point. |
|
1923 |
void readline_transpose_chars() |
|
1924 |
{ |
|
1925 |
char swp; |
|
1926 |
||
1927 |
if (ptr_inputline == inputLine) return; |
|
1928 |
||
1929 |
if (!*ptr_inputline) { // We're at EOL |
|
1930 |
// If line is only 1 char long, nothing to do... |
|
1931 |
if (ptr_inputline == inputLine+1) return; |
|
1932 |
// Transpose the two previous characters |
|
1933 |
swp = *(ptr_inputline-2); |
|
1934 |
*(ptr_inputline-2) = *(ptr_inputline-1); |
|
1935 |
*(ptr_inputline-1) = swp; |
|
1936 |
} else { |
|
196 | 1937 |
// Swap the two characters before the cursor and move right. |
195 | 1938 |
swp = *(ptr_inputline-1); |
1939 |
*(ptr_inputline-1) = *ptr_inputline; |
|
1940 |
*ptr_inputline++ = swp; |
|
1941 |
check_offset(1); |
|
1942 |
} |
|
1943 |
} |
|
1944 |
||
1945 |
// readline_backward_kill_word() |
|
194 | 1946 |
// Kill the word before the cursor, in input line |
195 | 1947 |
void readline_backward_kill_word() |
194 | 1948 |
{ |
1949 |
char *c, *old = ptr_inputline; |
|
1950 |
int spaceallowed = 1; |
|
1951 |
||
1952 |
if (ptr_inputline == inputLine) return; |
|
1953 |
||
759
a681dc477c7f
Add readline_backward_word and readline_forward_word (Ctrl-Left/Ctrl-Right)
Mikael Berthe <mikael@lilotux.net>
parents:
758
diff
changeset
|
1954 |
for (c = ptr_inputline-1 ; c > inputLine ; c--) { |
194 | 1955 |
if (!isalnum(*c)) { |
1956 |
if (*c == ' ') |
|
1957 |
if (!spaceallowed) break; |
|
1958 |
} 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
|
1959 |
} |
194 | 1960 |
|
1961 |
if (c != inputLine || *c != ' ') |
|
1962 |
if ((c < ptr_inputline-1) && (!isalnum(*c))) |
|
1963 |
c++; |
|
1964 |
||
1965 |
// Modify the line |
|
1966 |
ptr_inputline = c; |
|
1967 |
for (;;) { |
|
1968 |
*c = *old++; |
|
1969 |
if (!*c++) break; |
|
1970 |
} |
|
195 | 1971 |
check_offset(-1); |
194 | 1972 |
} |
1973 |
||
759
a681dc477c7f
Add readline_backward_word and readline_forward_word (Ctrl-Left/Ctrl-Right)
Mikael Berthe <mikael@lilotux.net>
parents:
758
diff
changeset
|
1974 |
// readline_backward_word() |
a681dc477c7f
Add readline_backward_word and readline_forward_word (Ctrl-Left/Ctrl-Right)
Mikael Berthe <mikael@lilotux.net>
parents:
758
diff
changeset
|
1975 |
// Move back to the start of the current or previous word |
a681dc477c7f
Add readline_backward_word and readline_forward_word (Ctrl-Left/Ctrl-Right)
Mikael Berthe <mikael@lilotux.net>
parents:
758
diff
changeset
|
1976 |
void readline_backward_word() |
a681dc477c7f
Add readline_backward_word and readline_forward_word (Ctrl-Left/Ctrl-Right)
Mikael Berthe <mikael@lilotux.net>
parents:
758
diff
changeset
|
1977 |
{ |
a681dc477c7f
Add readline_backward_word and readline_forward_word (Ctrl-Left/Ctrl-Right)
Mikael Berthe <mikael@lilotux.net>
parents:
758
diff
changeset
|
1978 |
char *old_ptr_inputLine = ptr_inputline; |
a681dc477c7f
Add readline_backward_word and readline_forward_word (Ctrl-Left/Ctrl-Right)
Mikael Berthe <mikael@lilotux.net>
parents:
758
diff
changeset
|
1979 |
int spaceallowed = 1; |
a681dc477c7f
Add readline_backward_word and readline_forward_word (Ctrl-Left/Ctrl-Right)
Mikael Berthe <mikael@lilotux.net>
parents:
758
diff
changeset
|
1980 |
|
a681dc477c7f
Add readline_backward_word and readline_forward_word (Ctrl-Left/Ctrl-Right)
Mikael Berthe <mikael@lilotux.net>
parents:
758
diff
changeset
|
1981 |
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
|
1982 |
|
a681dc477c7f
Add readline_backward_word and readline_forward_word (Ctrl-Left/Ctrl-Right)
Mikael Berthe <mikael@lilotux.net>
parents:
758
diff
changeset
|
1983 |
for (ptr_inputline-- ; ptr_inputline > inputLine ; ptr_inputline--) { |
a681dc477c7f
Add readline_backward_word and readline_forward_word (Ctrl-Left/Ctrl-Right)
Mikael Berthe <mikael@lilotux.net>
parents:
758
diff
changeset
|
1984 |
if (!isalnum(*ptr_inputline)) { |
a681dc477c7f
Add readline_backward_word and readline_forward_word (Ctrl-Left/Ctrl-Right)
Mikael Berthe <mikael@lilotux.net>
parents:
758
diff
changeset
|
1985 |
if (*ptr_inputline == ' ') |
a681dc477c7f
Add readline_backward_word and readline_forward_word (Ctrl-Left/Ctrl-Right)
Mikael Berthe <mikael@lilotux.net>
parents:
758
diff
changeset
|
1986 |
if (!spaceallowed) break; |
a681dc477c7f
Add readline_backward_word and readline_forward_word (Ctrl-Left/Ctrl-Right)
Mikael Berthe <mikael@lilotux.net>
parents:
758
diff
changeset
|
1987 |
} else spaceallowed = 0; |
a681dc477c7f
Add readline_backward_word and readline_forward_word (Ctrl-Left/Ctrl-Right)
Mikael Berthe <mikael@lilotux.net>
parents:
758
diff
changeset
|
1988 |
} |
a681dc477c7f
Add readline_backward_word and readline_forward_word (Ctrl-Left/Ctrl-Right)
Mikael Berthe <mikael@lilotux.net>
parents:
758
diff
changeset
|
1989 |
|
a681dc477c7f
Add readline_backward_word and readline_forward_word (Ctrl-Left/Ctrl-Right)
Mikael Berthe <mikael@lilotux.net>
parents:
758
diff
changeset
|
1990 |
if (ptr_inputline < old_ptr_inputLine-1 |
a681dc477c7f
Add readline_backward_word and readline_forward_word (Ctrl-Left/Ctrl-Right)
Mikael Berthe <mikael@lilotux.net>
parents:
758
diff
changeset
|
1991 |
&& *ptr_inputline == ' ' && *(ptr_inputline+1) != ' ') |
a681dc477c7f
Add readline_backward_word and readline_forward_word (Ctrl-Left/Ctrl-Right)
Mikael Berthe <mikael@lilotux.net>
parents:
758
diff
changeset
|
1992 |
ptr_inputline++; |
a681dc477c7f
Add readline_backward_word and readline_forward_word (Ctrl-Left/Ctrl-Right)
Mikael Berthe <mikael@lilotux.net>
parents:
758
diff
changeset
|
1993 |
|
a681dc477c7f
Add readline_backward_word and readline_forward_word (Ctrl-Left/Ctrl-Right)
Mikael Berthe <mikael@lilotux.net>
parents:
758
diff
changeset
|
1994 |
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
|
1995 |
} |
a681dc477c7f
Add readline_backward_word and readline_forward_word (Ctrl-Left/Ctrl-Right)
Mikael Berthe <mikael@lilotux.net>
parents:
758
diff
changeset
|
1996 |
|
a681dc477c7f
Add readline_backward_word and readline_forward_word (Ctrl-Left/Ctrl-Right)
Mikael Berthe <mikael@lilotux.net>
parents:
758
diff
changeset
|
1997 |
// 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
|
1998 |
// Move forward to the end of the next word |
a681dc477c7f
Add readline_backward_word and readline_forward_word (Ctrl-Left/Ctrl-Right)
Mikael Berthe <mikael@lilotux.net>
parents:
758
diff
changeset
|
1999 |
void 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
|
2000 |
{ |
a681dc477c7f
Add readline_backward_word and readline_forward_word (Ctrl-Left/Ctrl-Right)
Mikael Berthe <mikael@lilotux.net>
parents:
758
diff
changeset
|
2001 |
int spaceallowed = 1; |
a681dc477c7f
Add readline_backward_word and readline_forward_word (Ctrl-Left/Ctrl-Right)
Mikael Berthe <mikael@lilotux.net>
parents:
758
diff
changeset
|
2002 |
|
a681dc477c7f
Add readline_backward_word and readline_forward_word (Ctrl-Left/Ctrl-Right)
Mikael Berthe <mikael@lilotux.net>
parents:
758
diff
changeset
|
2003 |
while (*ptr_inputline) { |
a681dc477c7f
Add readline_backward_word and readline_forward_word (Ctrl-Left/Ctrl-Right)
Mikael Berthe <mikael@lilotux.net>
parents:
758
diff
changeset
|
2004 |
ptr_inputline++; |
a681dc477c7f
Add readline_backward_word and readline_forward_word (Ctrl-Left/Ctrl-Right)
Mikael Berthe <mikael@lilotux.net>
parents:
758
diff
changeset
|
2005 |
if (!isalnum(*ptr_inputline)) { |
a681dc477c7f
Add readline_backward_word and readline_forward_word (Ctrl-Left/Ctrl-Right)
Mikael Berthe <mikael@lilotux.net>
parents:
758
diff
changeset
|
2006 |
if (*ptr_inputline == ' ') |
a681dc477c7f
Add readline_backward_word and readline_forward_word (Ctrl-Left/Ctrl-Right)
Mikael Berthe <mikael@lilotux.net>
parents:
758
diff
changeset
|
2007 |
if (!spaceallowed) break; |
a681dc477c7f
Add readline_backward_word and readline_forward_word (Ctrl-Left/Ctrl-Right)
Mikael Berthe <mikael@lilotux.net>
parents:
758
diff
changeset
|
2008 |
} else spaceallowed = 0; |
a681dc477c7f
Add readline_backward_word and readline_forward_word (Ctrl-Left/Ctrl-Right)
Mikael Berthe <mikael@lilotux.net>
parents:
758
diff
changeset
|
2009 |
} |
a681dc477c7f
Add readline_backward_word and readline_forward_word (Ctrl-Left/Ctrl-Right)
Mikael Berthe <mikael@lilotux.net>
parents:
758
diff
changeset
|
2010 |
|
a681dc477c7f
Add readline_backward_word and readline_forward_word (Ctrl-Left/Ctrl-Right)
Mikael Berthe <mikael@lilotux.net>
parents:
758
diff
changeset
|
2011 |
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
|
2012 |
} |
a681dc477c7f
Add readline_backward_word and readline_forward_word (Ctrl-Left/Ctrl-Right)
Mikael Berthe <mikael@lilotux.net>
parents:
758
diff
changeset
|
2013 |
|
98 | 2014 |
// which_row() |
2015 |
// 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
|
2016 |
// -2 -> normal text |
ddec224c2318
MUC: nickname completion
Mikael Berthe <mikael@lilotux.net>
parents:
499
diff
changeset
|
2017 |
// -1 -> room: nickname completion |
98 | 2018 |
// 0 -> command |
2019 |
// 1 -> parameter 1 (etc.) |
|
102 | 2020 |
// 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
|
2021 |
static int which_row(const char **p_row) |
98 | 2022 |
{ |
2023 |
int row = -1; |
|
2024 |
char *p; |
|
2025 |
int quote = FALSE; |
|
2026 |
||
2027 |
// Not a command? |
|
503
ddec224c2318
MUC: nickname completion
Mikael Berthe <mikael@lilotux.net>
parents:
499
diff
changeset
|
2028 |
if ((ptr_inputline == inputLine) || (inputLine[0] != '/')) { |
ddec224c2318
MUC: nickname completion
Mikael Berthe <mikael@lilotux.net>
parents:
499
diff
changeset
|
2029 |
if (!current_buddy) return -2; |
ddec224c2318
MUC: nickname completion
Mikael Berthe <mikael@lilotux.net>
parents:
499
diff
changeset
|
2030 |
if (buddy_gettype(BUDDATA(current_buddy)) == ROSTER_TYPE_ROOM) { |
ddec224c2318
MUC: nickname completion
Mikael Berthe <mikael@lilotux.net>
parents:
499
diff
changeset
|
2031 |
*p_row = inputLine; |
ddec224c2318
MUC: nickname completion
Mikael Berthe <mikael@lilotux.net>
parents:
499
diff
changeset
|
2032 |
return -1; |
ddec224c2318
MUC: nickname completion
Mikael Berthe <mikael@lilotux.net>
parents:
499
diff
changeset
|
2033 |
} |
ddec224c2318
MUC: nickname completion
Mikael Berthe <mikael@lilotux.net>
parents:
499
diff
changeset
|
2034 |
return -2; |
ddec224c2318
MUC: nickname completion
Mikael Berthe <mikael@lilotux.net>
parents:
499
diff
changeset
|
2035 |
} |
98 | 2036 |
|
2037 |
// This is a command |
|
2038 |
row = 0; |
|
2039 |
for (p = inputLine ; p < ptr_inputline ; p++) { |
|
2040 |
if (quote) { |
|
2041 |
if (*p == '"' && *(p-1) != '\\') |
|
2042 |
quote = FALSE; |
|
2043 |
continue; |
|
2044 |
} |
|
2045 |
if (*p == '"' && *(p-1) != '\\') { |
|
2046 |
quote = TRUE; |
|
121 | 2047 |
} else if (*p == ' ') { |
2048 |
if (*(p-1) != ' ') |
|
2049 |
row++; |
|
102 | 2050 |
*p_row = p+1; |
2051 |
} |
|
98 | 2052 |
} |
2053 |
return row; |
|
2054 |
} |
|
2055 |
||
143 | 2056 |
// scr_insert_text() |
2057 |
// Insert the given text at the current cursor position. |
|
2058 |
// The cursor is moved. We don't check if the cursor still is in the screen |
|
2059 |
// after, the caller should do that. |
|
336
eb994ee40029
Make some functions static
Mikael Berthe <mikael@lilotux.net>
parents:
332
diff
changeset
|
2060 |
static void scr_insert_text(const char *text) |
98 | 2061 |
{ |
2062 |
char tmpLine[INPUTLINE_LENGTH+1]; |
|
2063 |
int len = strlen(text); |
|
2064 |
// Check the line isn't too long |
|
2065 |
if (strlen(inputLine) + len >= INPUTLINE_LENGTH) { |
|
374
bd5638c21834
Improve logging system (traces)
Mikael Berthe <mikael@lilotux.net>
parents:
373
diff
changeset
|
2066 |
scr_LogPrint(LPRINT_LOGNORM, "Cannot insert text, line too long."); |
98 | 2067 |
return; |
2068 |
} |
|
2069 |
||
2070 |
strcpy(tmpLine, ptr_inputline); |
|
419 | 2071 |
strcpy(ptr_inputline, text); |
2072 |
ptr_inputline += len; |
|
98 | 2073 |
strcpy(ptr_inputline, tmpLine); |
2074 |
} |
|
2075 |
||
143 | 2076 |
// scr_handle_tab() |
2077 |
// Function called when tab is pressed. |
|
2078 |
// Initiate or continue a completion... |
|
336
eb994ee40029
Make some functions static
Mikael Berthe <mikael@lilotux.net>
parents:
332
diff
changeset
|
2079 |
static void scr_handle_tab(void) |
98 | 2080 |
{ |
102 | 2081 |
int nrow; |
503
ddec224c2318
MUC: nickname completion
Mikael Berthe <mikael@lilotux.net>
parents:
499
diff
changeset
|
2082 |
const char *row; |
102 | 2083 |
const char *cchar; |
103 | 2084 |
guint compl_categ; |
98 | 2085 |
|
740 | 2086 |
row = inputLine; // (Kills a GCC warning) |
102 | 2087 |
nrow = which_row(&row); |
98 | 2088 |
|
503
ddec224c2318
MUC: nickname completion
Mikael Berthe <mikael@lilotux.net>
parents:
499
diff
changeset
|
2089 |
// a) No completion if no leading slash ('cause not a command), |
ddec224c2318
MUC: nickname completion
Mikael Berthe <mikael@lilotux.net>
parents:
499
diff
changeset
|
2090 |
// unless this is a room (then, it is a nickname completion) |
103 | 2091 |
// 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
|
2092 |
if ((nrow == -2) || (nrow == 3 && !completion_started) || nrow > 3) |
ddec224c2318
MUC: nickname completion
Mikael Berthe <mikael@lilotux.net>
parents:
499
diff
changeset
|
2093 |
return; |
102 | 2094 |
|
503
ddec224c2318
MUC: nickname completion
Mikael Berthe <mikael@lilotux.net>
parents:
499
diff
changeset
|
2095 |
if (nrow == 0) { // Command completion |
103 | 2096 |
row = &inputLine[1]; |
2097 |
compl_categ = COMPL_CMD; |
|
503
ddec224c2318
MUC: nickname completion
Mikael Berthe <mikael@lilotux.net>
parents:
499
diff
changeset
|
2098 |
} else if (nrow == -1) { // Nickname completion |
ddec224c2318
MUC: nickname completion
Mikael Berthe <mikael@lilotux.net>
parents:
499
diff
changeset
|
2099 |
compl_categ = COMPL_RESOURCE; |
ddec224c2318
MUC: nickname completion
Mikael Berthe <mikael@lilotux.net>
parents:
499
diff
changeset
|
2100 |
} else { // Other completion, depending on the command |
285 | 2101 |
int alias = FALSE; |
2102 |
cmd *com; |
|
2103 |
char *xpline = expandalias(inputLine); |
|
2104 |
com = cmd_get(xpline); |
|
2105 |
if (xpline != inputLine) { |
|
2106 |
// This is an alias, so we can't complete rows > 0 |
|
2107 |
alias = TRUE; |
|
2108 |
g_free(xpline); |
|
2109 |
} |
|
2110 |
if ((!com && (!alias || !completion_started)) || !row) { |
|
374
bd5638c21834
Improve logging system (traces)
Mikael Berthe <mikael@lilotux.net>
parents:
373
diff
changeset
|
2111 |
scr_LogPrint(LPRINT_NORMAL, "I cannot complete that..."); |
103 | 2112 |
return; |
2113 |
} |
|
285 | 2114 |
if (!alias) |
2115 |
compl_categ = com->completion_flags[nrow-1]; |
|
2116 |
else |
|
2117 |
compl_categ = 0; |
|
103 | 2118 |
} |
2119 |
||
2120 |
if (!completion_started) { |
|
2121 |
GSList *list = compl_get_category_list(compl_categ); |
|
2122 |
if (list) { |
|
2123 |
char *prefix = g_strndup(row, ptr_inputline-row); |
|
2124 |
// Init completion |
|
2125 |
new_completion(prefix, list); |
|
2126 |
g_free(prefix); |
|
2127 |
// Now complete |
|
98 | 2128 |
cchar = complete(); |
2129 |
if (cchar) |
|
2130 |
scr_insert_text(cchar); |
|
103 | 2131 |
completion_started = TRUE; |
98 | 2132 |
} |
103 | 2133 |
} else { // Completion already initialized |
2134 |
char *c; |
|
2135 |
guint back = cancel_completion(); |
|
2136 |
// Remove $back chars |
|
2137 |
ptr_inputline -= back; |
|
2138 |
c = ptr_inputline; |
|
2139 |
for ( ; *c ; c++) |
|
2140 |
*c = *(c+back); |
|
2141 |
// Now complete again |
|
2142 |
cchar = complete(); |
|
2143 |
if (cchar) |
|
2144 |
scr_insert_text(cchar); |
|
102 | 2145 |
} |
98 | 2146 |
} |
2147 |
||
336
eb994ee40029
Make some functions static
Mikael Berthe <mikael@lilotux.net>
parents:
332
diff
changeset
|
2148 |
static void scr_cancel_current_completion(void) |
98 | 2149 |
{ |
2150 |
char *c; |
|
2151 |
guint back = cancel_completion(); |
|
2152 |
// Remove $back chars |
|
2153 |
ptr_inputline -= back; |
|
2154 |
c = ptr_inputline; |
|
2155 |
for ( ; *c ; c++) |
|
2156 |
*c = *(c+back); |
|
2157 |
} |
|
2158 |
||
336
eb994ee40029
Make some functions static
Mikael Berthe <mikael@lilotux.net>
parents:
332
diff
changeset
|
2159 |
static void scr_end_current_completion(void) |
98 | 2160 |
{ |
2161 |
done_completion(); |
|
2162 |
completion_started = FALSE; |
|
2163 |
} |
|
2164 |
||
24 | 2165 |
// check_offset(int direction) |
2166 |
// Check inputline_offset value, and make sure the cursor is inside the |
|
2167 |
// screen. |
|
336
eb994ee40029
Make some functions static
Mikael Berthe <mikael@lilotux.net>
parents:
332
diff
changeset
|
2168 |
static inline void check_offset(int direction) |
24 | 2169 |
{ |
2170 |
// Left side |
|
2171 |
if (inputline_offset && direction <= 0) { |
|
2172 |
while (ptr_inputline <= (char*)&inputLine + inputline_offset) { |
|
2173 |
if (inputline_offset) { |
|
2174 |
inputline_offset -= 5; |
|
2175 |
if (inputline_offset < 0) |
|
2176 |
inputline_offset = 0; |
|
828
319fc55b9a2b
Fix a bug in check_offset()
Mikael Berthe <mikael@lilotux.net>
parents:
827
diff
changeset
|
2177 |
} else |
319fc55b9a2b
Fix a bug in check_offset()
Mikael Berthe <mikael@lilotux.net>
parents:
827
diff
changeset
|
2178 |
break; |
24 | 2179 |
} |
2180 |
} |
|
2181 |
// Right side |
|
2182 |
if (direction >= 0) { |
|
2183 |
while (ptr_inputline >= inputline_offset + (char*)&inputLine + maxX) |
|
2184 |
inputline_offset += 5; |
|
2185 |
} |
|
2186 |
} |
|
2187 |
||
336
eb994ee40029
Make some functions static
Mikael Berthe <mikael@lilotux.net>
parents:
332
diff
changeset
|
2188 |
static inline void refresh_inputline(void) |
312
f0b7ff2df7e8
Ctrl-C does not terminate mcabber
Mikael Berthe <mikael@lilotux.net>
parents:
307
diff
changeset
|
2189 |
{ |
f0b7ff2df7e8
Ctrl-C does not terminate mcabber
Mikael Berthe <mikael@lilotux.net>
parents:
307
diff
changeset
|
2190 |
mvwprintw(inputWnd, 0,0, "%s", inputLine + inputline_offset); |
f0b7ff2df7e8
Ctrl-C does not terminate mcabber
Mikael Berthe <mikael@lilotux.net>
parents:
307
diff
changeset
|
2191 |
wclrtoeol(inputWnd); |
f0b7ff2df7e8
Ctrl-C does not terminate mcabber
Mikael Berthe <mikael@lilotux.net>
parents:
307
diff
changeset
|
2192 |
if (*ptr_inputline) |
f0b7ff2df7e8
Ctrl-C does not terminate mcabber
Mikael Berthe <mikael@lilotux.net>
parents:
307
diff
changeset
|
2193 |
wmove(inputWnd, 0, ptr_inputline - (char*)&inputLine - inputline_offset); |
f0b7ff2df7e8
Ctrl-C does not terminate mcabber
Mikael Berthe <mikael@lilotux.net>
parents:
307
diff
changeset
|
2194 |
} |
f0b7ff2df7e8
Ctrl-C does not terminate mcabber
Mikael Berthe <mikael@lilotux.net>
parents:
307
diff
changeset
|
2195 |
|
389
6e895f397474
Ncurses changes + Ctrl-C does not send a signal anylore
Mikael Berthe <mikael@lilotux.net>
parents:
388
diff
changeset
|
2196 |
void scr_handle_CtrlC(void) |
312
f0b7ff2df7e8
Ctrl-C does not terminate mcabber
Mikael Berthe <mikael@lilotux.net>
parents:
307
diff
changeset
|
2197 |
{ |
365
ddb6593bedc9
Fix segfault when mcabber receives an INT signal (Ctrl-C) early
Mikael Berthe <mikael@lilotux.net>
parents:
364
diff
changeset
|
2198 |
if (!Curses) return; |
315
65aa05520556
First Ctrl-C now also leaves multi-line message mode
Mikael Berthe <mikael@lilotux.net>
parents:
314
diff
changeset
|
2199 |
// Leave multi-line mode |
65aa05520556
First Ctrl-C now also leaves multi-line message mode
Mikael Berthe <mikael@lilotux.net>
parents:
314
diff
changeset
|
2200 |
process_command("/msay abort"); |
312
f0b7ff2df7e8
Ctrl-C does not terminate mcabber
Mikael Berthe <mikael@lilotux.net>
parents:
307
diff
changeset
|
2201 |
// Same as Ctrl-g, now |
f0b7ff2df7e8
Ctrl-C does not terminate mcabber
Mikael Berthe <mikael@lilotux.net>
parents:
307
diff
changeset
|
2202 |
scr_cancel_current_completion(); |
f0b7ff2df7e8
Ctrl-C does not terminate mcabber
Mikael Berthe <mikael@lilotux.net>
parents:
307
diff
changeset
|
2203 |
scr_end_current_completion(); |
f0b7ff2df7e8
Ctrl-C does not terminate mcabber
Mikael Berthe <mikael@lilotux.net>
parents:
307
diff
changeset
|
2204 |
check_offset(-1); |
f0b7ff2df7e8
Ctrl-C does not terminate mcabber
Mikael Berthe <mikael@lilotux.net>
parents:
307
diff
changeset
|
2205 |
refresh_inputline(); |
f0b7ff2df7e8
Ctrl-C does not terminate mcabber
Mikael Berthe <mikael@lilotux.net>
parents:
307
diff
changeset
|
2206 |
} |
f0b7ff2df7e8
Ctrl-C does not terminate mcabber
Mikael Berthe <mikael@lilotux.net>
parents:
307
diff
changeset
|
2207 |
|
761
4532a9fe0e8c
Handle some keyboard escape sequences
Mikael Berthe <mikael@lilotux.net>
parents:
760
diff
changeset
|
2208 |
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
|
2209 |
{ |
4532a9fe0e8c
Handle some keyboard escape sequences
Mikael Berthe <mikael@lilotux.net>
parents:
760
diff
changeset
|
2210 |
keyseq *ks; |
4532a9fe0e8c
Handle some keyboard escape sequences
Mikael Berthe <mikael@lilotux.net>
parents:
760
diff
changeset
|
2211 |
|
4532a9fe0e8c
Handle some keyboard escape sequences
Mikael Berthe <mikael@lilotux.net>
parents:
760
diff
changeset
|
2212 |
// Let's make sure the length is correct |
4532a9fe0e8c
Handle some keyboard escape sequences
Mikael Berthe <mikael@lilotux.net>
parents:
760
diff
changeset
|
2213 |
if (strlen(seqstr) > MAX_KEYSEQ_LENGTH) { |
4532a9fe0e8c
Handle some keyboard escape sequences
Mikael Berthe <mikael@lilotux.net>
parents:
760
diff
changeset
|
2214 |
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
|
2215 |
return; |
4532a9fe0e8c
Handle some keyboard escape sequences
Mikael Berthe <mikael@lilotux.net>
parents:
760
diff
changeset
|
2216 |
} |
4532a9fe0e8c
Handle some keyboard escape sequences
Mikael Berthe <mikael@lilotux.net>
parents:
760
diff
changeset
|
2217 |
|
4532a9fe0e8c
Handle some keyboard escape sequences
Mikael Berthe <mikael@lilotux.net>
parents:
760
diff
changeset
|
2218 |
ks = g_new0(keyseq, 1); |
4532a9fe0e8c
Handle some keyboard escape sequences
Mikael Berthe <mikael@lilotux.net>
parents:
760
diff
changeset
|
2219 |
ks->seqstr = g_strdup(seqstr); |
4532a9fe0e8c
Handle some keyboard escape sequences
Mikael Berthe <mikael@lilotux.net>
parents:
760
diff
changeset
|
2220 |
ks->mkeycode = mkeycode; |
4532a9fe0e8c
Handle some keyboard escape sequences
Mikael Berthe <mikael@lilotux.net>
parents:
760
diff
changeset
|
2221 |
ks->value = value; |
4532a9fe0e8c
Handle some keyboard escape sequences
Mikael Berthe <mikael@lilotux.net>
parents:
760
diff
changeset
|
2222 |
keyseqlist = g_slist_append(keyseqlist, ks); |
4532a9fe0e8c
Handle some keyboard escape sequences
Mikael Berthe <mikael@lilotux.net>
parents:
760
diff
changeset
|
2223 |
} |
4532a9fe0e8c
Handle some keyboard escape sequences
Mikael Berthe <mikael@lilotux.net>
parents:
760
diff
changeset
|
2224 |
|
4532a9fe0e8c
Handle some keyboard escape sequences
Mikael Berthe <mikael@lilotux.net>
parents:
760
diff
changeset
|
2225 |
// match_keyseq(iseq, &ret) |
4532a9fe0e8c
Handle some keyboard escape sequences
Mikael Berthe <mikael@lilotux.net>
parents:
760
diff
changeset
|
2226 |
// Check if "iseq" is a known key escape sequence. |
4532a9fe0e8c
Handle some keyboard escape sequences
Mikael Berthe <mikael@lilotux.net>
parents:
760
diff
changeset
|
2227 |
// Return value: |
4532a9fe0e8c
Handle some keyboard escape sequences
Mikael Berthe <mikael@lilotux.net>
parents:
760
diff
changeset
|
2228 |
// -1 if "seq" matches no known sequence |
4532a9fe0e8c
Handle some keyboard escape sequences
Mikael Berthe <mikael@lilotux.net>
parents:
760
diff
changeset
|
2229 |
// 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
|
2230 |
// >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
|
2231 |
// and *ret is set to the matching keyseq structure. |
4532a9fe0e8c
Handle some keyboard escape sequences
Mikael Berthe <mikael@lilotux.net>
parents:
760
diff
changeset
|
2232 |
static inline guint match_keyseq(int *iseq, keyseq **ret) |
373
af2f8ddf6a1b
Move (reorganize) functions
Mikael Berthe <mikael@lilotux.net>
parents:
370
diff
changeset
|
2233 |
{ |
761
4532a9fe0e8c
Handle some keyboard escape sequences
Mikael Berthe <mikael@lilotux.net>
parents:
760
diff
changeset
|
2234 |
GSList *ksl; |
4532a9fe0e8c
Handle some keyboard escape sequences
Mikael Berthe <mikael@lilotux.net>
parents:
760
diff
changeset
|
2235 |
keyseq *ksp; |
4532a9fe0e8c
Handle some keyboard escape sequences
Mikael Berthe <mikael@lilotux.net>
parents:
760
diff
changeset
|
2236 |
char *p, c; |
4532a9fe0e8c
Handle some keyboard escape sequences
Mikael Berthe <mikael@lilotux.net>
parents:
760
diff
changeset
|
2237 |
int *i; |
4532a9fe0e8c
Handle some keyboard escape sequences
Mikael Berthe <mikael@lilotux.net>
parents:
760
diff
changeset
|
2238 |
int needmore = FALSE; |
4532a9fe0e8c
Handle some keyboard escape sequences
Mikael Berthe <mikael@lilotux.net>
parents:
760
diff
changeset
|
2239 |
|
4532a9fe0e8c
Handle some keyboard escape sequences
Mikael Berthe <mikael@lilotux.net>
parents:
760
diff
changeset
|
2240 |
for (ksl = keyseqlist; ksl; ksl = g_slist_next(ksl)) { |
4532a9fe0e8c
Handle some keyboard escape sequences
Mikael Berthe <mikael@lilotux.net>
parents:
760
diff
changeset
|
2241 |
ksp = ksl->data; |
4532a9fe0e8c
Handle some keyboard escape sequences
Mikael Berthe <mikael@lilotux.net>
parents:
760
diff
changeset
|
2242 |
p = ksp->seqstr; |
4532a9fe0e8c
Handle some keyboard escape sequences
Mikael Berthe <mikael@lilotux.net>
parents:
760
diff
changeset
|
2243 |
i = iseq; |
4532a9fe0e8c
Handle some keyboard escape sequences
Mikael Berthe <mikael@lilotux.net>
parents:
760
diff
changeset
|
2244 |
while (1) { |
4532a9fe0e8c
Handle some keyboard escape sequences
Mikael Berthe <mikael@lilotux.net>
parents:
760
diff
changeset
|
2245 |
c = (unsigned char)*i; |
4532a9fe0e8c
Handle some keyboard escape sequences
Mikael Berthe <mikael@lilotux.net>
parents:
760
diff
changeset
|
2246 |
if (!*p && !c) { // Match |
4532a9fe0e8c
Handle some keyboard escape sequences
Mikael Berthe <mikael@lilotux.net>
parents:
760
diff
changeset
|
2247 |
(*ret) = ksp; |
4532a9fe0e8c
Handle some keyboard escape sequences
Mikael Berthe <mikael@lilotux.net>
parents:
760
diff
changeset
|
2248 |
return ksp->mkeycode; |
4532a9fe0e8c
Handle some keyboard escape sequences
Mikael Berthe <mikael@lilotux.net>
parents:
760
diff
changeset
|
2249 |
} |
4532a9fe0e8c
Handle some keyboard escape sequences
Mikael Berthe <mikael@lilotux.net>
parents:
760
diff
changeset
|
2250 |
if (!c) { |
4532a9fe0e8c
Handle some keyboard escape sequences
Mikael Berthe <mikael@lilotux.net>
parents:
760
diff
changeset
|
2251 |
// iseq is too short |
4532a9fe0e8c
Handle some keyboard escape sequences
Mikael Berthe <mikael@lilotux.net>
parents:
760
diff
changeset
|
2252 |
needmore = TRUE; |
4532a9fe0e8c
Handle some keyboard escape sequences
Mikael Berthe <mikael@lilotux.net>
parents:
760
diff
changeset
|
2253 |
break; |
4532a9fe0e8c
Handle some keyboard escape sequences
Mikael Berthe <mikael@lilotux.net>
parents:
760
diff
changeset
|
2254 |
} else if (!*p || c != *p) { |
4532a9fe0e8c
Handle some keyboard escape sequences
Mikael Berthe <mikael@lilotux.net>
parents:
760
diff
changeset
|
2255 |
// This isn't a match |
4532a9fe0e8c
Handle some keyboard escape sequences
Mikael Berthe <mikael@lilotux.net>
parents:
760
diff
changeset
|
2256 |
break; |
4532a9fe0e8c
Handle some keyboard escape sequences
Mikael Berthe <mikael@lilotux.net>
parents:
760
diff
changeset
|
2257 |
} |
4532a9fe0e8c
Handle some keyboard escape sequences
Mikael Berthe <mikael@lilotux.net>
parents:
760
diff
changeset
|
2258 |
p++; i++; |
4532a9fe0e8c
Handle some keyboard escape sequences
Mikael Berthe <mikael@lilotux.net>
parents:
760
diff
changeset
|
2259 |
} |
4532a9fe0e8c
Handle some keyboard escape sequences
Mikael Berthe <mikael@lilotux.net>
parents:
760
diff
changeset
|
2260 |
} |
4532a9fe0e8c
Handle some keyboard escape sequences
Mikael Berthe <mikael@lilotux.net>
parents:
760
diff
changeset
|
2261 |
|
4532a9fe0e8c
Handle some keyboard escape sequences
Mikael Berthe <mikael@lilotux.net>
parents:
760
diff
changeset
|
2262 |
if (needmore) |
4532a9fe0e8c
Handle some keyboard escape sequences
Mikael Berthe <mikael@lilotux.net>
parents:
760
diff
changeset
|
2263 |
return 0; |
4532a9fe0e8c
Handle some keyboard escape sequences
Mikael Berthe <mikael@lilotux.net>
parents:
760
diff
changeset
|
2264 |
return -1; |
4532a9fe0e8c
Handle some keyboard escape sequences
Mikael Berthe <mikael@lilotux.net>
parents:
760
diff
changeset
|
2265 |
} |
4532a9fe0e8c
Handle some keyboard escape sequences
Mikael Berthe <mikael@lilotux.net>
parents:
760
diff
changeset
|
2266 |
|
4532a9fe0e8c
Handle some keyboard escape sequences
Mikael Berthe <mikael@lilotux.net>
parents:
760
diff
changeset
|
2267 |
void scr_Getch(keycode *kcode) |
4532a9fe0e8c
Handle some keyboard escape sequences
Mikael Berthe <mikael@lilotux.net>
parents:
760
diff
changeset
|
2268 |
{ |
769 | 2269 |
keyseq *mks = NULL; |
761
4532a9fe0e8c
Handle some keyboard escape sequences
Mikael Berthe <mikael@lilotux.net>
parents:
760
diff
changeset
|
2270 |
int ks[MAX_KEYSEQ_LENGTH+1]; |
4532a9fe0e8c
Handle some keyboard escape sequences
Mikael Berthe <mikael@lilotux.net>
parents:
760
diff
changeset
|
2271 |
int i; |
4532a9fe0e8c
Handle some keyboard escape sequences
Mikael Berthe <mikael@lilotux.net>
parents:
760
diff
changeset
|
2272 |
|
4532a9fe0e8c
Handle some keyboard escape sequences
Mikael Berthe <mikael@lilotux.net>
parents:
760
diff
changeset
|
2273 |
memset(kcode, 0, sizeof(keycode)); |
4532a9fe0e8c
Handle some keyboard escape sequences
Mikael Berthe <mikael@lilotux.net>
parents:
760
diff
changeset
|
2274 |
memset(ks, 0, sizeof(ks)); |
4532a9fe0e8c
Handle some keyboard escape sequences
Mikael Berthe <mikael@lilotux.net>
parents:
760
diff
changeset
|
2275 |
|
4532a9fe0e8c
Handle some keyboard escape sequences
Mikael Berthe <mikael@lilotux.net>
parents:
760
diff
changeset
|
2276 |
kcode->value = wgetch(inputWnd); |
4532a9fe0e8c
Handle some keyboard escape sequences
Mikael Berthe <mikael@lilotux.net>
parents:
760
diff
changeset
|
2277 |
if (kcode->value != 27) |
4532a9fe0e8c
Handle some keyboard escape sequences
Mikael Berthe <mikael@lilotux.net>
parents:
760
diff
changeset
|
2278 |
return; |
4532a9fe0e8c
Handle some keyboard escape sequences
Mikael Berthe <mikael@lilotux.net>
parents:
760
diff
changeset
|
2279 |
|
4532a9fe0e8c
Handle some keyboard escape sequences
Mikael Berthe <mikael@lilotux.net>
parents:
760
diff
changeset
|
2280 |
// Check for escape key sequence |
4532a9fe0e8c
Handle some keyboard escape sequences
Mikael Berthe <mikael@lilotux.net>
parents:
760
diff
changeset
|
2281 |
for (i=0; i < MAX_KEYSEQ_LENGTH; i++) { |
4532a9fe0e8c
Handle some keyboard escape sequences
Mikael Berthe <mikael@lilotux.net>
parents:
760
diff
changeset
|
2282 |
int match; |
4532a9fe0e8c
Handle some keyboard escape sequences
Mikael Berthe <mikael@lilotux.net>
parents:
760
diff
changeset
|
2283 |
ks[i] = wgetch(inputWnd); |
4532a9fe0e8c
Handle some keyboard escape sequences
Mikael Berthe <mikael@lilotux.net>
parents:
760
diff
changeset
|
2284 |
if (ks[i] == ERR) break; |
4532a9fe0e8c
Handle some keyboard escape sequences
Mikael Berthe <mikael@lilotux.net>
parents:
760
diff
changeset
|
2285 |
match = match_keyseq(ks, &mks); |
4532a9fe0e8c
Handle some keyboard escape sequences
Mikael Berthe <mikael@lilotux.net>
parents:
760
diff
changeset
|
2286 |
if (match == -1) { |
4532a9fe0e8c
Handle some keyboard escape sequences
Mikael Berthe <mikael@lilotux.net>
parents:
760
diff
changeset
|
2287 |
// 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
|
2288 |
i++; |
4532a9fe0e8c
Handle some keyboard escape sequences
Mikael Berthe <mikael@lilotux.net>
parents:
760
diff
changeset
|
2289 |
break; |
4532a9fe0e8c
Handle some keyboard escape sequences
Mikael Berthe <mikael@lilotux.net>
parents:
760
diff
changeset
|
2290 |
} |
4532a9fe0e8c
Handle some keyboard escape sequences
Mikael Berthe <mikael@lilotux.net>
parents:
760
diff
changeset
|
2291 |
if (match > 0) { |
4532a9fe0e8c
Handle some keyboard escape sequences
Mikael Berthe <mikael@lilotux.net>
parents:
760
diff
changeset
|
2292 |
// We have a matching sequence |
4532a9fe0e8c
Handle some keyboard escape sequences
Mikael Berthe <mikael@lilotux.net>
parents:
760
diff
changeset
|
2293 |
kcode->mcode = mks->mkeycode; |
4532a9fe0e8c
Handle some keyboard escape sequences
Mikael Berthe <mikael@lilotux.net>
parents:
760
diff
changeset
|
2294 |
kcode->value = mks->value; |
4532a9fe0e8c
Handle some keyboard escape sequences
Mikael Berthe <mikael@lilotux.net>
parents:
760
diff
changeset
|
2295 |
return; |
4532a9fe0e8c
Handle some keyboard escape sequences
Mikael Berthe <mikael@lilotux.net>
parents:
760
diff
changeset
|
2296 |
} |
4532a9fe0e8c
Handle some keyboard escape sequences
Mikael Berthe <mikael@lilotux.net>
parents:
760
diff
changeset
|
2297 |
} |
4532a9fe0e8c
Handle some keyboard escape sequences
Mikael Berthe <mikael@lilotux.net>
parents:
760
diff
changeset
|
2298 |
|
4532a9fe0e8c
Handle some keyboard escape sequences
Mikael Berthe <mikael@lilotux.net>
parents:
760
diff
changeset
|
2299 |
// No match. Let's return a meta-key. |
4532a9fe0e8c
Handle some keyboard escape sequences
Mikael Berthe <mikael@lilotux.net>
parents:
760
diff
changeset
|
2300 |
if (i > 0) { |
4532a9fe0e8c
Handle some keyboard escape sequences
Mikael Berthe <mikael@lilotux.net>
parents:
760
diff
changeset
|
2301 |
kcode->mcode = MKEY_META; |
4532a9fe0e8c
Handle some keyboard escape sequences
Mikael Berthe <mikael@lilotux.net>
parents:
760
diff
changeset
|
2302 |
kcode->value = ks[0]; |
4532a9fe0e8c
Handle some keyboard escape sequences
Mikael Berthe <mikael@lilotux.net>
parents:
760
diff
changeset
|
2303 |
} |
4532a9fe0e8c
Handle some keyboard escape sequences
Mikael Berthe <mikael@lilotux.net>
parents:
760
diff
changeset
|
2304 |
if (i > 1) { |
4532a9fe0e8c
Handle some keyboard escape sequences
Mikael Berthe <mikael@lilotux.net>
parents:
760
diff
changeset
|
2305 |
// 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
|
2306 |
while (i-- > 1) |
4532a9fe0e8c
Handle some keyboard escape sequences
Mikael Berthe <mikael@lilotux.net>
parents:
760
diff
changeset
|
2307 |
ungetch(ks[i]); |
4532a9fe0e8c
Handle some keyboard escape sequences
Mikael Berthe <mikael@lilotux.net>
parents:
760
diff
changeset
|
2308 |
} |
4532a9fe0e8c
Handle some keyboard escape sequences
Mikael Berthe <mikael@lilotux.net>
parents:
760
diff
changeset
|
2309 |
return; |
373
af2f8ddf6a1b
Move (reorganize) functions
Mikael Berthe <mikael@lilotux.net>
parents:
370
diff
changeset
|
2310 |
} |
af2f8ddf6a1b
Move (reorganize) functions
Mikael Berthe <mikael@lilotux.net>
parents:
370
diff
changeset
|
2311 |
|
764
4e15322d315e
Allow binding of meta keys
Mikael Berthe <mikael@lilotux.net>
parents:
763
diff
changeset
|
2312 |
static int bindcommand(keycode kcode) { |
4e15322d315e
Allow binding of meta keys
Mikael Berthe <mikael@lilotux.net>
parents:
763
diff
changeset
|
2313 |
gchar asciikey[16]; |
4e15322d315e
Allow binding of meta keys
Mikael Berthe <mikael@lilotux.net>
parents:
763
diff
changeset
|
2314 |
const gchar *boundcmd; |
4e15322d315e
Allow binding of meta keys
Mikael Berthe <mikael@lilotux.net>
parents:
763
diff
changeset
|
2315 |
|
4e15322d315e
Allow binding of meta keys
Mikael Berthe <mikael@lilotux.net>
parents:
763
diff
changeset
|
2316 |
if (!kcode.mcode || kcode.mcode == MKEY_EQUIV) |
4e15322d315e
Allow binding of meta keys
Mikael Berthe <mikael@lilotux.net>
parents:
763
diff
changeset
|
2317 |
g_snprintf(asciikey, 15, "%d", kcode.value); |
4e15322d315e
Allow binding of meta keys
Mikael Berthe <mikael@lilotux.net>
parents:
763
diff
changeset
|
2318 |
else if (kcode.mcode == MKEY_META) |
4e15322d315e
Allow binding of meta keys
Mikael Berthe <mikael@lilotux.net>
parents:
763
diff
changeset
|
2319 |
g_snprintf(asciikey, 15, "M%d", kcode.value); |
4e15322d315e
Allow binding of meta keys
Mikael Berthe <mikael@lilotux.net>
parents:
763
diff
changeset
|
2320 |
else |
4e15322d315e
Allow binding of meta keys
Mikael Berthe <mikael@lilotux.net>
parents:
763
diff
changeset
|
2321 |
g_snprintf(asciikey, 15, "MK%d", kcode.mcode); |
4e15322d315e
Allow binding of meta keys
Mikael Berthe <mikael@lilotux.net>
parents:
763
diff
changeset
|
2322 |
|
4e15322d315e
Allow binding of meta keys
Mikael Berthe <mikael@lilotux.net>
parents:
763
diff
changeset
|
2323 |
boundcmd = settings_get(SETTINGS_TYPE_BINDING, asciikey); |
4e15322d315e
Allow binding of meta keys
Mikael Berthe <mikael@lilotux.net>
parents:
763
diff
changeset
|
2324 |
|
4e15322d315e
Allow binding of meta keys
Mikael Berthe <mikael@lilotux.net>
parents:
763
diff
changeset
|
2325 |
if (boundcmd) { |
772
464be13343a9
Store most data in UTF-8 internally
Mikael Berthe <mikael@lilotux.net>
parents:
771
diff
changeset
|
2326 |
gchar *cmd, *boundcmd_locale; |
464be13343a9
Store most data in UTF-8 internally
Mikael Berthe <mikael@lilotux.net>
parents:
771
diff
changeset
|
2327 |
boundcmd_locale = from_utf8(boundcmd); |
464be13343a9
Store most data in UTF-8 internally
Mikael Berthe <mikael@lilotux.net>
parents:
771
diff
changeset
|
2328 |
cmd = g_strdup_printf("/%s", boundcmd_locale); |
764
4e15322d315e
Allow binding of meta keys
Mikael Berthe <mikael@lilotux.net>
parents:
763
diff
changeset
|
2329 |
scr_CheckAutoAway(TRUE); |
4e15322d315e
Allow binding of meta keys
Mikael Berthe <mikael@lilotux.net>
parents:
763
diff
changeset
|
2330 |
if (process_command(cmd)) |
4e15322d315e
Allow binding of meta keys
Mikael Berthe <mikael@lilotux.net>
parents:
763
diff
changeset
|
2331 |
return 255; // Quit |
772
464be13343a9
Store most data in UTF-8 internally
Mikael Berthe <mikael@lilotux.net>
parents:
771
diff
changeset
|
2332 |
g_free(boundcmd_locale); |
764
4e15322d315e
Allow binding of meta keys
Mikael Berthe <mikael@lilotux.net>
parents:
763
diff
changeset
|
2333 |
g_free(cmd); |
4e15322d315e
Allow binding of meta keys
Mikael Berthe <mikael@lilotux.net>
parents:
763
diff
changeset
|
2334 |
return 0; |
4e15322d315e
Allow binding of meta keys
Mikael Berthe <mikael@lilotux.net>
parents:
763
diff
changeset
|
2335 |
} |
4e15322d315e
Allow binding of meta keys
Mikael Berthe <mikael@lilotux.net>
parents:
763
diff
changeset
|
2336 |
|
4e15322d315e
Allow binding of meta keys
Mikael Berthe <mikael@lilotux.net>
parents:
763
diff
changeset
|
2337 |
scr_LogPrint(LPRINT_NORMAL, "Unknown key=%s", asciikey); |
4e15322d315e
Allow binding of meta keys
Mikael Berthe <mikael@lilotux.net>
parents:
763
diff
changeset
|
2338 |
if (utf8_mode) |
4e15322d315e
Allow binding of meta keys
Mikael Berthe <mikael@lilotux.net>
parents:
763
diff
changeset
|
2339 |
scr_LogPrint(LPRINT_NORMAL, "WARNING: UTF-8 not yet supported!"); |
4e15322d315e
Allow binding of meta keys
Mikael Berthe <mikael@lilotux.net>
parents:
763
diff
changeset
|
2340 |
return -1; |
4e15322d315e
Allow binding of meta keys
Mikael Berthe <mikael@lilotux.net>
parents:
763
diff
changeset
|
2341 |
} |
4e15322d315e
Allow binding of meta keys
Mikael Berthe <mikael@lilotux.net>
parents:
763
diff
changeset
|
2342 |
|
44 | 2343 |
// process_key(key) |
2344 |
// Handle the pressed key, in the command line (bottom). |
|
761
4532a9fe0e8c
Handle some keyboard escape sequences
Mikael Berthe <mikael@lilotux.net>
parents:
760
diff
changeset
|
2345 |
int process_key(keycode kcode) |
24 | 2346 |
{ |
761
4532a9fe0e8c
Handle some keyboard escape sequences
Mikael Berthe <mikael@lilotux.net>
parents:
760
diff
changeset
|
2347 |
int key = kcode.value; |
4532a9fe0e8c
Handle some keyboard escape sequences
Mikael Berthe <mikael@lilotux.net>
parents:
760
diff
changeset
|
2348 |
|
4532a9fe0e8c
Handle some keyboard escape sequences
Mikael Berthe <mikael@lilotux.net>
parents:
760
diff
changeset
|
2349 |
switch (kcode.mcode) { |
4532a9fe0e8c
Handle some keyboard escape sequences
Mikael Berthe <mikael@lilotux.net>
parents:
760
diff
changeset
|
2350 |
case 0: |
4532a9fe0e8c
Handle some keyboard escape sequences
Mikael Berthe <mikael@lilotux.net>
parents:
760
diff
changeset
|
2351 |
break; |
4532a9fe0e8c
Handle some keyboard escape sequences
Mikael Berthe <mikael@lilotux.net>
parents:
760
diff
changeset
|
2352 |
case MKEY_EQUIV: |
4532a9fe0e8c
Handle some keyboard escape sequences
Mikael Berthe <mikael@lilotux.net>
parents:
760
diff
changeset
|
2353 |
key = kcode.value; |
4532a9fe0e8c
Handle some keyboard escape sequences
Mikael Berthe <mikael@lilotux.net>
parents:
760
diff
changeset
|
2354 |
break; |
4532a9fe0e8c
Handle some keyboard escape sequences
Mikael Berthe <mikael@lilotux.net>
parents:
760
diff
changeset
|
2355 |
case MKEY_META: |
4532a9fe0e8c
Handle some keyboard escape sequences
Mikael Berthe <mikael@lilotux.net>
parents:
760
diff
changeset
|
2356 |
key = ERR; |
4532a9fe0e8c
Handle some keyboard escape sequences
Mikael Berthe <mikael@lilotux.net>
parents:
760
diff
changeset
|
2357 |
switch (kcode.value) { |
4532a9fe0e8c
Handle some keyboard escape sequences
Mikael Berthe <mikael@lilotux.net>
parents:
760
diff
changeset
|
2358 |
case 27: |
4532a9fe0e8c
Handle some keyboard escape sequences
Mikael Berthe <mikael@lilotux.net>
parents:
760
diff
changeset
|
2359 |
key = 27; |
4532a9fe0e8c
Handle some keyboard escape sequences
Mikael Berthe <mikael@lilotux.net>
parents:
760
diff
changeset
|
2360 |
break; |
4532a9fe0e8c
Handle some keyboard escape sequences
Mikael Berthe <mikael@lilotux.net>
parents:
760
diff
changeset
|
2361 |
default: |
764
4e15322d315e
Allow binding of meta keys
Mikael Berthe <mikael@lilotux.net>
parents:
763
diff
changeset
|
2362 |
if (bindcommand(kcode) == 255) |
4e15322d315e
Allow binding of meta keys
Mikael Berthe <mikael@lilotux.net>
parents:
763
diff
changeset
|
2363 |
return 255; |
761
4532a9fe0e8c
Handle some keyboard escape sequences
Mikael Berthe <mikael@lilotux.net>
parents:
760
diff
changeset
|
2364 |
} |
4532a9fe0e8c
Handle some keyboard escape sequences
Mikael Berthe <mikael@lilotux.net>
parents:
760
diff
changeset
|
2365 |
break; |
4532a9fe0e8c
Handle some keyboard escape sequences
Mikael Berthe <mikael@lilotux.net>
parents:
760
diff
changeset
|
2366 |
default: |
764
4e15322d315e
Allow binding of meta keys
Mikael Berthe <mikael@lilotux.net>
parents:
763
diff
changeset
|
2367 |
if (bindcommand(kcode) == 255) |
4e15322d315e
Allow binding of meta keys
Mikael Berthe <mikael@lilotux.net>
parents:
763
diff
changeset
|
2368 |
return 255; |
4e15322d315e
Allow binding of meta keys
Mikael Berthe <mikael@lilotux.net>
parents:
763
diff
changeset
|
2369 |
key = ERR; // Do not process any further |
758 | 2370 |
} |
761
4532a9fe0e8c
Handle some keyboard escape sequences
Mikael Berthe <mikael@lilotux.net>
parents:
760
diff
changeset
|
2371 |
|
758 | 2372 |
switch (key) { |
761
4532a9fe0e8c
Handle some keyboard escape sequences
Mikael Berthe <mikael@lilotux.net>
parents:
760
diff
changeset
|
2373 |
case 0: |
4532a9fe0e8c
Handle some keyboard escape sequences
Mikael Berthe <mikael@lilotux.net>
parents:
760
diff
changeset
|
2374 |
case ERR: |
758 | 2375 |
break; |
499
baa812f04f24
Reorganise process_key()
Mikael Berthe <mikael@lilotux.net>
parents:
480
diff
changeset
|
2376 |
case 8: // Ctrl-h |
baa812f04f24
Reorganise process_key()
Mikael Berthe <mikael@lilotux.net>
parents:
480
diff
changeset
|
2377 |
case 127: // Backspace too |
baa812f04f24
Reorganise process_key()
Mikael Berthe <mikael@lilotux.net>
parents:
480
diff
changeset
|
2378 |
case KEY_BACKSPACE: |
baa812f04f24
Reorganise process_key()
Mikael Berthe <mikael@lilotux.net>
parents:
480
diff
changeset
|
2379 |
if (ptr_inputline != (char*)&inputLine) { |
baa812f04f24
Reorganise process_key()
Mikael Berthe <mikael@lilotux.net>
parents:
480
diff
changeset
|
2380 |
char *c = --ptr_inputline; |
baa812f04f24
Reorganise process_key()
Mikael Berthe <mikael@lilotux.net>
parents:
480
diff
changeset
|
2381 |
for ( ; *c ; c++) |
baa812f04f24
Reorganise process_key()
Mikael Berthe <mikael@lilotux.net>
parents:
480
diff
changeset
|
2382 |
*c = *(c+1); |
baa812f04f24
Reorganise process_key()
Mikael Berthe <mikael@lilotux.net>
parents:
480
diff
changeset
|
2383 |
check_offset(-1); |
baa812f04f24
Reorganise process_key()
Mikael Berthe <mikael@lilotux.net>
parents:
480
diff
changeset
|
2384 |
} |
baa812f04f24
Reorganise process_key()
Mikael Berthe <mikael@lilotux.net>
parents:
480
diff
changeset
|
2385 |
break; |
baa812f04f24
Reorganise process_key()
Mikael Berthe <mikael@lilotux.net>
parents:
480
diff
changeset
|
2386 |
case KEY_DC:// Del |
baa812f04f24
Reorganise process_key()
Mikael Berthe <mikael@lilotux.net>
parents:
480
diff
changeset
|
2387 |
if (*ptr_inputline) |
baa812f04f24
Reorganise process_key()
Mikael Berthe <mikael@lilotux.net>
parents:
480
diff
changeset
|
2388 |
strcpy(ptr_inputline, ptr_inputline+1); |
baa812f04f24
Reorganise process_key()
Mikael Berthe <mikael@lilotux.net>
parents:
480
diff
changeset
|
2389 |
break; |
baa812f04f24
Reorganise process_key()
Mikael Berthe <mikael@lilotux.net>
parents:
480
diff
changeset
|
2390 |
case KEY_LEFT: |
baa812f04f24
Reorganise process_key()
Mikael Berthe <mikael@lilotux.net>
parents:
480
diff
changeset
|
2391 |
if (ptr_inputline != (char*)&inputLine) { |
baa812f04f24
Reorganise process_key()
Mikael Berthe <mikael@lilotux.net>
parents:
480
diff
changeset
|
2392 |
ptr_inputline--; |
baa812f04f24
Reorganise process_key()
Mikael Berthe <mikael@lilotux.net>
parents:
480
diff
changeset
|
2393 |
check_offset(-1); |
baa812f04f24
Reorganise process_key()
Mikael Berthe <mikael@lilotux.net>
parents:
480
diff
changeset
|
2394 |
} |
baa812f04f24
Reorganise process_key()
Mikael Berthe <mikael@lilotux.net>
parents:
480
diff
changeset
|
2395 |
break; |
baa812f04f24
Reorganise process_key()
Mikael Berthe <mikael@lilotux.net>
parents:
480
diff
changeset
|
2396 |
case KEY_RIGHT: |
baa812f04f24
Reorganise process_key()
Mikael Berthe <mikael@lilotux.net>
parents:
480
diff
changeset
|
2397 |
if (*ptr_inputline) |
baa812f04f24
Reorganise process_key()
Mikael Berthe <mikael@lilotux.net>
parents:
480
diff
changeset
|
2398 |
ptr_inputline++; |
baa812f04f24
Reorganise process_key()
Mikael Berthe <mikael@lilotux.net>
parents:
480
diff
changeset
|
2399 |
check_offset(1); |
baa812f04f24
Reorganise process_key()
Mikael Berthe <mikael@lilotux.net>
parents:
480
diff
changeset
|
2400 |
break; |
baa812f04f24
Reorganise process_key()
Mikael Berthe <mikael@lilotux.net>
parents:
480
diff
changeset
|
2401 |
case 7: // Ctrl-g |
baa812f04f24
Reorganise process_key()
Mikael Berthe <mikael@lilotux.net>
parents:
480
diff
changeset
|
2402 |
scr_cancel_current_completion(); |
baa812f04f24
Reorganise process_key()
Mikael Berthe <mikael@lilotux.net>
parents:
480
diff
changeset
|
2403 |
scr_end_current_completion(); |
baa812f04f24
Reorganise process_key()
Mikael Berthe <mikael@lilotux.net>
parents:
480
diff
changeset
|
2404 |
check_offset(-1); |
baa812f04f24
Reorganise process_key()
Mikael Berthe <mikael@lilotux.net>
parents:
480
diff
changeset
|
2405 |
break; |
baa812f04f24
Reorganise process_key()
Mikael Berthe <mikael@lilotux.net>
parents:
480
diff
changeset
|
2406 |
case 9: // Tab |
827
04da822bc47c
Expand tabs in verbatim multi-line mode
Mikael Berthe <mikael@lilotux.net>
parents:
826
diff
changeset
|
2407 |
if (scr_get_multimode() != 2) { |
04da822bc47c
Expand tabs in verbatim multi-line mode
Mikael Berthe <mikael@lilotux.net>
parents:
826
diff
changeset
|
2408 |
// Not in verbatim multi-line mode |
04da822bc47c
Expand tabs in verbatim multi-line mode
Mikael Berthe <mikael@lilotux.net>
parents:
826
diff
changeset
|
2409 |
scr_handle_tab(); |
04da822bc47c
Expand tabs in verbatim multi-line mode
Mikael Berthe <mikael@lilotux.net>
parents:
826
diff
changeset
|
2410 |
} else { |
04da822bc47c
Expand tabs in verbatim multi-line mode
Mikael Berthe <mikael@lilotux.net>
parents:
826
diff
changeset
|
2411 |
// Verbatim multi-line mode: expand tab |
04da822bc47c
Expand tabs in verbatim multi-line mode
Mikael Berthe <mikael@lilotux.net>
parents:
826
diff
changeset
|
2412 |
char tabstr[9]; |
04da822bc47c
Expand tabs in verbatim multi-line mode
Mikael Berthe <mikael@lilotux.net>
parents:
826
diff
changeset
|
2413 |
int i, n; |
04da822bc47c
Expand tabs in verbatim multi-line mode
Mikael Berthe <mikael@lilotux.net>
parents:
826
diff
changeset
|
2414 |
n = 8 - (ptr_inputline - inputLine) % 8; |
04da822bc47c
Expand tabs in verbatim multi-line mode
Mikael Berthe <mikael@lilotux.net>
parents:
826
diff
changeset
|
2415 |
for (i = 0; i < n; i++) |
04da822bc47c
Expand tabs in verbatim multi-line mode
Mikael Berthe <mikael@lilotux.net>
parents:
826
diff
changeset
|
2416 |
tabstr[i] = ' '; |
04da822bc47c
Expand tabs in verbatim multi-line mode
Mikael Berthe <mikael@lilotux.net>
parents:
826
diff
changeset
|
2417 |
tabstr[i] = '\0'; |
04da822bc47c
Expand tabs in verbatim multi-line mode
Mikael Berthe <mikael@lilotux.net>
parents:
826
diff
changeset
|
2418 |
scr_insert_text(tabstr); |
04da822bc47c
Expand tabs in verbatim multi-line mode
Mikael Berthe <mikael@lilotux.net>
parents:
826
diff
changeset
|
2419 |
} |
499
baa812f04f24
Reorganise process_key()
Mikael Berthe <mikael@lilotux.net>
parents:
480
diff
changeset
|
2420 |
check_offset(0); |
baa812f04f24
Reorganise process_key()
Mikael Berthe <mikael@lilotux.net>
parents:
480
diff
changeset
|
2421 |
break; |
baa812f04f24
Reorganise process_key()
Mikael Berthe <mikael@lilotux.net>
parents:
480
diff
changeset
|
2422 |
case 13: // Enter |
baa812f04f24
Reorganise process_key()
Mikael Berthe <mikael@lilotux.net>
parents:
480
diff
changeset
|
2423 |
case 15: // Ctrl-o ("accept-line-and-down-history") |
baa812f04f24
Reorganise process_key()
Mikael Berthe <mikael@lilotux.net>
parents:
480
diff
changeset
|
2424 |
scr_CheckAutoAway(TRUE); |
baa812f04f24
Reorganise process_key()
Mikael Berthe <mikael@lilotux.net>
parents:
480
diff
changeset
|
2425 |
if (process_line(inputLine)) |
baa812f04f24
Reorganise process_key()
Mikael Berthe <mikael@lilotux.net>
parents:
480
diff
changeset
|
2426 |
return 255; |
baa812f04f24
Reorganise process_key()
Mikael Berthe <mikael@lilotux.net>
parents:
480
diff
changeset
|
2427 |
// Add line to history |
baa812f04f24
Reorganise process_key()
Mikael Berthe <mikael@lilotux.net>
parents:
480
diff
changeset
|
2428 |
scr_cmdhisto_addline(inputLine); |
baa812f04f24
Reorganise process_key()
Mikael Berthe <mikael@lilotux.net>
parents:
480
diff
changeset
|
2429 |
// Reset the line |
baa812f04f24
Reorganise process_key()
Mikael Berthe <mikael@lilotux.net>
parents:
480
diff
changeset
|
2430 |
ptr_inputline = inputLine; |
baa812f04f24
Reorganise process_key()
Mikael Berthe <mikael@lilotux.net>
parents:
480
diff
changeset
|
2431 |
*ptr_inputline = 0; |
baa812f04f24
Reorganise process_key()
Mikael Berthe <mikael@lilotux.net>
parents:
480
diff
changeset
|
2432 |
inputline_offset = 0; |
24 | 2433 |
|
499
baa812f04f24
Reorganise process_key()
Mikael Berthe <mikael@lilotux.net>
parents:
480
diff
changeset
|
2434 |
if (key == 13) // Enter |
baa812f04f24
Reorganise process_key()
Mikael Berthe <mikael@lilotux.net>
parents:
480
diff
changeset
|
2435 |
{ |
baa812f04f24
Reorganise process_key()
Mikael Berthe <mikael@lilotux.net>
parents:
480
diff
changeset
|
2436 |
// Reset history line pointer |
baa812f04f24
Reorganise process_key()
Mikael Berthe <mikael@lilotux.net>
parents:
480
diff
changeset
|
2437 |
cmdhisto_cur = NULL; |
baa812f04f24
Reorganise process_key()
Mikael Berthe <mikael@lilotux.net>
parents:
480
diff
changeset
|
2438 |
} else { // down-history |
baa812f04f24
Reorganise process_key()
Mikael Berthe <mikael@lilotux.net>
parents:
480
diff
changeset
|
2439 |
// Use next history line instead of a blank line |
baa812f04f24
Reorganise process_key()
Mikael Berthe <mikael@lilotux.net>
parents:
480
diff
changeset
|
2440 |
const char *l = scr_cmdhisto_next("", 0); |
baa812f04f24
Reorganise process_key()
Mikael Berthe <mikael@lilotux.net>
parents:
480
diff
changeset
|
2441 |
if (l) strcpy(inputLine, l); |
baa812f04f24
Reorganise process_key()
Mikael Berthe <mikael@lilotux.net>
parents:
480
diff
changeset
|
2442 |
// Reset backup history line |
baa812f04f24
Reorganise process_key()
Mikael Berthe <mikael@lilotux.net>
parents:
480
diff
changeset
|
2443 |
cmdhisto_backup[0] = 0; |
baa812f04f24
Reorganise process_key()
Mikael Berthe <mikael@lilotux.net>
parents:
480
diff
changeset
|
2444 |
} |
baa812f04f24
Reorganise process_key()
Mikael Berthe <mikael@lilotux.net>
parents:
480
diff
changeset
|
2445 |
break; |
baa812f04f24
Reorganise process_key()
Mikael Berthe <mikael@lilotux.net>
parents:
480
diff
changeset
|
2446 |
case KEY_UP: |
baa812f04f24
Reorganise process_key()
Mikael Berthe <mikael@lilotux.net>
parents:
480
diff
changeset
|
2447 |
{ |
baa812f04f24
Reorganise process_key()
Mikael Berthe <mikael@lilotux.net>
parents:
480
diff
changeset
|
2448 |
const char *l = scr_cmdhisto_prev(inputLine, |
baa812f04f24
Reorganise process_key()
Mikael Berthe <mikael@lilotux.net>
parents:
480
diff
changeset
|
2449 |
ptr_inputline-inputLine); |
baa812f04f24
Reorganise process_key()
Mikael Berthe <mikael@lilotux.net>
parents:
480
diff
changeset
|
2450 |
if (l) strcpy(inputLine, l); |
baa812f04f24
Reorganise process_key()
Mikael Berthe <mikael@lilotux.net>
parents:
480
diff
changeset
|
2451 |
} |
baa812f04f24
Reorganise process_key()
Mikael Berthe <mikael@lilotux.net>
parents:
480
diff
changeset
|
2452 |
break; |
baa812f04f24
Reorganise process_key()
Mikael Berthe <mikael@lilotux.net>
parents:
480
diff
changeset
|
2453 |
case KEY_DOWN: |
baa812f04f24
Reorganise process_key()
Mikael Berthe <mikael@lilotux.net>
parents:
480
diff
changeset
|
2454 |
{ |
baa812f04f24
Reorganise process_key()
Mikael Berthe <mikael@lilotux.net>
parents:
480
diff
changeset
|
2455 |
const char *l = scr_cmdhisto_next(inputLine, |
baa812f04f24
Reorganise process_key()
Mikael Berthe <mikael@lilotux.net>
parents:
480
diff
changeset
|
2456 |
ptr_inputline-inputLine); |
baa812f04f24
Reorganise process_key()
Mikael Berthe <mikael@lilotux.net>
parents:
480
diff
changeset
|
2457 |
if (l) strcpy(inputLine, l); |
baa812f04f24
Reorganise process_key()
Mikael Berthe <mikael@lilotux.net>
parents:
480
diff
changeset
|
2458 |
} |
baa812f04f24
Reorganise process_key()
Mikael Berthe <mikael@lilotux.net>
parents:
480
diff
changeset
|
2459 |
break; |
baa812f04f24
Reorganise process_key()
Mikael Berthe <mikael@lilotux.net>
parents:
480
diff
changeset
|
2460 |
case KEY_PPAGE: |
baa812f04f24
Reorganise process_key()
Mikael Berthe <mikael@lilotux.net>
parents:
480
diff
changeset
|
2461 |
scr_CheckAutoAway(TRUE); |
baa812f04f24
Reorganise process_key()
Mikael Berthe <mikael@lilotux.net>
parents:
480
diff
changeset
|
2462 |
scr_RosterUp(); |
baa812f04f24
Reorganise process_key()
Mikael Berthe <mikael@lilotux.net>
parents:
480
diff
changeset
|
2463 |
break; |
baa812f04f24
Reorganise process_key()
Mikael Berthe <mikael@lilotux.net>
parents:
480
diff
changeset
|
2464 |
case KEY_NPAGE: |
baa812f04f24
Reorganise process_key()
Mikael Berthe <mikael@lilotux.net>
parents:
480
diff
changeset
|
2465 |
scr_CheckAutoAway(TRUE); |
baa812f04f24
Reorganise process_key()
Mikael Berthe <mikael@lilotux.net>
parents:
480
diff
changeset
|
2466 |
scr_RosterDown(); |
baa812f04f24
Reorganise process_key()
Mikael Berthe <mikael@lilotux.net>
parents:
480
diff
changeset
|
2467 |
break; |
baa812f04f24
Reorganise process_key()
Mikael Berthe <mikael@lilotux.net>
parents:
480
diff
changeset
|
2468 |
case KEY_HOME: |
baa812f04f24
Reorganise process_key()
Mikael Berthe <mikael@lilotux.net>
parents:
480
diff
changeset
|
2469 |
case 1: |
baa812f04f24
Reorganise process_key()
Mikael Berthe <mikael@lilotux.net>
parents:
480
diff
changeset
|
2470 |
ptr_inputline = inputLine; |
baa812f04f24
Reorganise process_key()
Mikael Berthe <mikael@lilotux.net>
parents:
480
diff
changeset
|
2471 |
inputline_offset = 0; |
baa812f04f24
Reorganise process_key()
Mikael Berthe <mikael@lilotux.net>
parents:
480
diff
changeset
|
2472 |
break; |
baa812f04f24
Reorganise process_key()
Mikael Berthe <mikael@lilotux.net>
parents:
480
diff
changeset
|
2473 |
case 3: // Ctrl-C |
baa812f04f24
Reorganise process_key()
Mikael Berthe <mikael@lilotux.net>
parents:
480
diff
changeset
|
2474 |
scr_handle_CtrlC(); |
baa812f04f24
Reorganise process_key()
Mikael Berthe <mikael@lilotux.net>
parents:
480
diff
changeset
|
2475 |
break; |
baa812f04f24
Reorganise process_key()
Mikael Berthe <mikael@lilotux.net>
parents:
480
diff
changeset
|
2476 |
case KEY_END: |
baa812f04f24
Reorganise process_key()
Mikael Berthe <mikael@lilotux.net>
parents:
480
diff
changeset
|
2477 |
case 5: |
baa812f04f24
Reorganise process_key()
Mikael Berthe <mikael@lilotux.net>
parents:
480
diff
changeset
|
2478 |
for (; *ptr_inputline; ptr_inputline++) ; |
baa812f04f24
Reorganise process_key()
Mikael Berthe <mikael@lilotux.net>
parents:
480
diff
changeset
|
2479 |
check_offset(1); |
baa812f04f24
Reorganise process_key()
Mikael Berthe <mikael@lilotux.net>
parents:
480
diff
changeset
|
2480 |
break; |
baa812f04f24
Reorganise process_key()
Mikael Berthe <mikael@lilotux.net>
parents:
480
diff
changeset
|
2481 |
case 21: // Ctrl-u |
baa812f04f24
Reorganise process_key()
Mikael Berthe <mikael@lilotux.net>
parents:
480
diff
changeset
|
2482 |
strcpy(inputLine, ptr_inputline); |
baa812f04f24
Reorganise process_key()
Mikael Berthe <mikael@lilotux.net>
parents:
480
diff
changeset
|
2483 |
ptr_inputline = inputLine; |
baa812f04f24
Reorganise process_key()
Mikael Berthe <mikael@lilotux.net>
parents:
480
diff
changeset
|
2484 |
inputline_offset = 0; |
baa812f04f24
Reorganise process_key()
Mikael Berthe <mikael@lilotux.net>
parents:
480
diff
changeset
|
2485 |
break; |
baa812f04f24
Reorganise process_key()
Mikael Berthe <mikael@lilotux.net>
parents:
480
diff
changeset
|
2486 |
case KEY_EOL: |
baa812f04f24
Reorganise process_key()
Mikael Berthe <mikael@lilotux.net>
parents:
480
diff
changeset
|
2487 |
case 11: // Ctrl-k |
baa812f04f24
Reorganise process_key()
Mikael Berthe <mikael@lilotux.net>
parents:
480
diff
changeset
|
2488 |
*ptr_inputline = 0; |
baa812f04f24
Reorganise process_key()
Mikael Berthe <mikael@lilotux.net>
parents:
480
diff
changeset
|
2489 |
break; |
baa812f04f24
Reorganise process_key()
Mikael Berthe <mikael@lilotux.net>
parents:
480
diff
changeset
|
2490 |
case 16: // Ctrl-p |
508
5a2132ba2220
Add "/buffer up" and "/buffer down"
Mikael Berthe <mikael@lilotux.net>
parents:
503
diff
changeset
|
2491 |
scr_BufferScrollUpDown(-1, 0); |
499
baa812f04f24
Reorganise process_key()
Mikael Berthe <mikael@lilotux.net>
parents:
480
diff
changeset
|
2492 |
break; |
baa812f04f24
Reorganise process_key()
Mikael Berthe <mikael@lilotux.net>
parents:
480
diff
changeset
|
2493 |
case 14: // Ctrl-n |
508
5a2132ba2220
Add "/buffer up" and "/buffer down"
Mikael Berthe <mikael@lilotux.net>
parents:
503
diff
changeset
|
2494 |
scr_BufferScrollUpDown(1, 0); |
499
baa812f04f24
Reorganise process_key()
Mikael Berthe <mikael@lilotux.net>
parents:
480
diff
changeset
|
2495 |
break; |
baa812f04f24
Reorganise process_key()
Mikael Berthe <mikael@lilotux.net>
parents:
480
diff
changeset
|
2496 |
case 17: // Ctrl-q |
baa812f04f24
Reorganise process_key()
Mikael Berthe <mikael@lilotux.net>
parents:
480
diff
changeset
|
2497 |
scr_CheckAutoAway(TRUE); |
baa812f04f24
Reorganise process_key()
Mikael Berthe <mikael@lilotux.net>
parents:
480
diff
changeset
|
2498 |
scr_RosterUnreadMessage(1); // next unread message |
baa812f04f24
Reorganise process_key()
Mikael Berthe <mikael@lilotux.net>
parents:
480
diff
changeset
|
2499 |
break; |
baa812f04f24
Reorganise process_key()
Mikael Berthe <mikael@lilotux.net>
parents:
480
diff
changeset
|
2500 |
case 20: // Ctrl-t |
baa812f04f24
Reorganise process_key()
Mikael Berthe <mikael@lilotux.net>
parents:
480
diff
changeset
|
2501 |
readline_transpose_chars(); |
baa812f04f24
Reorganise process_key()
Mikael Berthe <mikael@lilotux.net>
parents:
480
diff
changeset
|
2502 |
break; |
baa812f04f24
Reorganise process_key()
Mikael Berthe <mikael@lilotux.net>
parents:
480
diff
changeset
|
2503 |
case 23: // Ctrl-w |
baa812f04f24
Reorganise process_key()
Mikael Berthe <mikael@lilotux.net>
parents:
480
diff
changeset
|
2504 |
readline_backward_kill_word(); |
baa812f04f24
Reorganise process_key()
Mikael Berthe <mikael@lilotux.net>
parents:
480
diff
changeset
|
2505 |
break; |
759
a681dc477c7f
Add readline_backward_word and readline_forward_word (Ctrl-Left/Ctrl-Right)
Mikael Berthe <mikael@lilotux.net>
parents:
758
diff
changeset
|
2506 |
case 516: // Ctrl-Left |
a681dc477c7f
Add readline_backward_word and readline_forward_word (Ctrl-Left/Ctrl-Right)
Mikael Berthe <mikael@lilotux.net>
parents:
758
diff
changeset
|
2507 |
readline_backward_word(); |
a681dc477c7f
Add readline_backward_word and readline_forward_word (Ctrl-Left/Ctrl-Right)
Mikael Berthe <mikael@lilotux.net>
parents:
758
diff
changeset
|
2508 |
break; |
a681dc477c7f
Add readline_backward_word and readline_forward_word (Ctrl-Left/Ctrl-Right)
Mikael Berthe <mikael@lilotux.net>
parents:
758
diff
changeset
|
2509 |
case 518: // Ctrl-Right |
a681dc477c7f
Add readline_backward_word and readline_forward_word (Ctrl-Left/Ctrl-Right)
Mikael Berthe <mikael@lilotux.net>
parents:
758
diff
changeset
|
2510 |
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
|
2511 |
break; |
499
baa812f04f24
Reorganise process_key()
Mikael Berthe <mikael@lilotux.net>
parents:
480
diff
changeset
|
2512 |
case 12: // Ctrl-l |
baa812f04f24
Reorganise process_key()
Mikael Berthe <mikael@lilotux.net>
parents:
480
diff
changeset
|
2513 |
scr_CheckAutoAway(TRUE); |
825
3ecfaa6111e2
Ctrl-l rereads color variables
Mikael Berthe <mikael@lilotux.net>
parents:
824
diff
changeset
|
2514 |
ParseColors(); |
701
6c100adfbfb6
Add setting "roster_width" (variable buddylist width)
Mikael Berthe <mikael@lilotux.net>
parents:
699
diff
changeset
|
2515 |
scr_Resize(); |
499
baa812f04f24
Reorganise process_key()
Mikael Berthe <mikael@lilotux.net>
parents:
480
diff
changeset
|
2516 |
redrawwin(stdscr); |
701
6c100adfbfb6
Add setting "roster_width" (variable buddylist width)
Mikael Berthe <mikael@lilotux.net>
parents:
699
diff
changeset
|
2517 |
break; |
499
baa812f04f24
Reorganise process_key()
Mikael Berthe <mikael@lilotux.net>
parents:
480
diff
changeset
|
2518 |
case KEY_RESIZE: |
baa812f04f24
Reorganise process_key()
Mikael Berthe <mikael@lilotux.net>
parents:
480
diff
changeset
|
2519 |
scr_Resize(); |
baa812f04f24
Reorganise process_key()
Mikael Berthe <mikael@lilotux.net>
parents:
480
diff
changeset
|
2520 |
break; |
761
4532a9fe0e8c
Handle some keyboard escape sequences
Mikael Berthe <mikael@lilotux.net>
parents:
760
diff
changeset
|
2521 |
case 27: // ESC |
4532a9fe0e8c
Handle some keyboard escape sequences
Mikael Berthe <mikael@lilotux.net>
parents:
760
diff
changeset
|
2522 |
scr_CheckAutoAway(TRUE); |
4532a9fe0e8c
Handle some keyboard escape sequences
Mikael Berthe <mikael@lilotux.net>
parents:
760
diff
changeset
|
2523 |
currentWindow = NULL; |
4532a9fe0e8c
Handle some keyboard escape sequences
Mikael Berthe <mikael@lilotux.net>
parents:
760
diff
changeset
|
2524 |
chatmode = FALSE; |
4532a9fe0e8c
Handle some keyboard escape sequences
Mikael Berthe <mikael@lilotux.net>
parents:
760
diff
changeset
|
2525 |
if (current_buddy) |
4532a9fe0e8c
Handle some keyboard escape sequences
Mikael Berthe <mikael@lilotux.net>
parents:
760
diff
changeset
|
2526 |
buddy_setflags(BUDDATA(current_buddy), ROSTER_FLAG_LOCK, FALSE); |
4532a9fe0e8c
Handle some keyboard escape sequences
Mikael Berthe <mikael@lilotux.net>
parents:
760
diff
changeset
|
2527 |
scr_RosterVisibility(1); |
4532a9fe0e8c
Handle some keyboard escape sequences
Mikael Berthe <mikael@lilotux.net>
parents:
760
diff
changeset
|
2528 |
scr_UpdateChatStatus(FALSE); |
4532a9fe0e8c
Handle some keyboard escape sequences
Mikael Berthe <mikael@lilotux.net>
parents:
760
diff
changeset
|
2529 |
top_panel(chatPanel); |
4532a9fe0e8c
Handle some keyboard escape sequences
Mikael Berthe <mikael@lilotux.net>
parents:
760
diff
changeset
|
2530 |
top_panel(inputPanel); |
4532a9fe0e8c
Handle some keyboard escape sequences
Mikael Berthe <mikael@lilotux.net>
parents:
760
diff
changeset
|
2531 |
update_panels(); |
4532a9fe0e8c
Handle some keyboard escape sequences
Mikael Berthe <mikael@lilotux.net>
parents:
760
diff
changeset
|
2532 |
break; |
499
baa812f04f24
Reorganise process_key()
Mikael Berthe <mikael@lilotux.net>
parents:
480
diff
changeset
|
2533 |
default: |
baa812f04f24
Reorganise process_key()
Mikael Berthe <mikael@lilotux.net>
parents:
480
diff
changeset
|
2534 |
if (isprint(key)) { |
baa812f04f24
Reorganise process_key()
Mikael Berthe <mikael@lilotux.net>
parents:
480
diff
changeset
|
2535 |
char tmpLine[INPUTLINE_LENGTH+1]; |
263 | 2536 |
|
499
baa812f04f24
Reorganise process_key()
Mikael Berthe <mikael@lilotux.net>
parents:
480
diff
changeset
|
2537 |
// Check the line isn't too long |
baa812f04f24
Reorganise process_key()
Mikael Berthe <mikael@lilotux.net>
parents:
480
diff
changeset
|
2538 |
if (strlen(inputLine) >= INPUTLINE_LENGTH) |
baa812f04f24
Reorganise process_key()
Mikael Berthe <mikael@lilotux.net>
parents:
480
diff
changeset
|
2539 |
return 0; |
baa812f04f24
Reorganise process_key()
Mikael Berthe <mikael@lilotux.net>
parents:
480
diff
changeset
|
2540 |
|
baa812f04f24
Reorganise process_key()
Mikael Berthe <mikael@lilotux.net>
parents:
480
diff
changeset
|
2541 |
// Insert char |
baa812f04f24
Reorganise process_key()
Mikael Berthe <mikael@lilotux.net>
parents:
480
diff
changeset
|
2542 |
strcpy(tmpLine, ptr_inputline); |
baa812f04f24
Reorganise process_key()
Mikael Berthe <mikael@lilotux.net>
parents:
480
diff
changeset
|
2543 |
*ptr_inputline++ = key; |
baa812f04f24
Reorganise process_key()
Mikael Berthe <mikael@lilotux.net>
parents:
480
diff
changeset
|
2544 |
strcpy(ptr_inputline, tmpLine); |
baa812f04f24
Reorganise process_key()
Mikael Berthe <mikael@lilotux.net>
parents:
480
diff
changeset
|
2545 |
check_offset(1); |
baa812f04f24
Reorganise process_key()
Mikael Berthe <mikael@lilotux.net>
parents:
480
diff
changeset
|
2546 |
} else { |
764
4e15322d315e
Allow binding of meta keys
Mikael Berthe <mikael@lilotux.net>
parents:
763
diff
changeset
|
2547 |
// Look for a key binding. |
4e15322d315e
Allow binding of meta keys
Mikael Berthe <mikael@lilotux.net>
parents:
763
diff
changeset
|
2548 |
if (bindcommand(kcode) == 255) |
4e15322d315e
Allow binding of meta keys
Mikael Berthe <mikael@lilotux.net>
parents:
763
diff
changeset
|
2549 |
return 255; |
499
baa812f04f24
Reorganise process_key()
Mikael Berthe <mikael@lilotux.net>
parents:
480
diff
changeset
|
2550 |
} |
24 | 2551 |
} |
499
baa812f04f24
Reorganise process_key()
Mikael Berthe <mikael@lilotux.net>
parents:
480
diff
changeset
|
2552 |
|
157 | 2553 |
if (completion_started && key != 9 && key != KEY_RESIZE) |
98 | 2554 |
scr_end_current_completion(); |
312
f0b7ff2df7e8
Ctrl-C does not terminate mcabber
Mikael Berthe <mikael@lilotux.net>
parents:
307
diff
changeset
|
2555 |
refresh_inputline(); |
f0b7ff2df7e8
Ctrl-C does not terminate mcabber
Mikael Berthe <mikael@lilotux.net>
parents:
307
diff
changeset
|
2556 |
if (!update_roster) |
157 | 2557 |
doupdate(); |
24 | 2558 |
return 0; |
2559 |
} |
|
576 | 2560 |
|
580 | 2561 |
/* vim: set expandtab cindent cinoptions=>2\:2(0: For Vim users... */ |