annotate mcabber/screen.c @ 0:b3b2332715fb

Tailorization of /trunk Import of the upstream sources from Repository: file:///tmp/svn-mcabber Module: /trunk Revision: 15
author tailor@frmp8452
date Thu, 30 Jun 2005 21:39:31 +0000
parents
children da1fb510081e
rev   line source
0
b3b2332715fb Tailorization of /trunk
tailor@frmp8452
parents:
diff changeset
1 #include <stdio.h>
b3b2332715fb Tailorization of /trunk
tailor@frmp8452
parents:
diff changeset
2 #include <stdlib.h>
b3b2332715fb Tailorization of /trunk
tailor@frmp8452
parents:
diff changeset
3 #include <string.h>
b3b2332715fb Tailorization of /trunk
tailor@frmp8452
parents:
diff changeset
4 #include <ncurses.h>
b3b2332715fb Tailorization of /trunk
tailor@frmp8452
parents:
diff changeset
5 #include <panel.h>
b3b2332715fb Tailorization of /trunk
tailor@frmp8452
parents:
diff changeset
6 #include <time.h>
b3b2332715fb Tailorization of /trunk
tailor@frmp8452
parents:
diff changeset
7 #include <ctype.h>
b3b2332715fb Tailorization of /trunk
tailor@frmp8452
parents:
diff changeset
8
b3b2332715fb Tailorization of /trunk
tailor@frmp8452
parents:
diff changeset
9 #include "screen.h"
b3b2332715fb Tailorization of /trunk
tailor@frmp8452
parents:
diff changeset
10 #include "utils.h"
b3b2332715fb Tailorization of /trunk
tailor@frmp8452
parents:
diff changeset
11 #include "buddies.h"
b3b2332715fb Tailorization of /trunk
tailor@frmp8452
parents:
diff changeset
12 #include "parsecfg.h"
b3b2332715fb Tailorization of /trunk
tailor@frmp8452
parents:
diff changeset
13 #include "lang.h"
b3b2332715fb Tailorization of /trunk
tailor@frmp8452
parents:
diff changeset
14 #include "server.h"
b3b2332715fb Tailorization of /trunk
tailor@frmp8452
parents:
diff changeset
15
b3b2332715fb Tailorization of /trunk
tailor@frmp8452
parents:
diff changeset
16 #include "list.h"
b3b2332715fb Tailorization of /trunk
tailor@frmp8452
parents:
diff changeset
17
b3b2332715fb Tailorization of /trunk
tailor@frmp8452
parents:
diff changeset
18 /* Definicion de tipos */
b3b2332715fb Tailorization of /trunk
tailor@frmp8452
parents:
diff changeset
19 #define window_entry(n) list_entry(n, window_entry_t, list)
b3b2332715fb Tailorization of /trunk
tailor@frmp8452
parents:
diff changeset
20
b3b2332715fb Tailorization of /trunk
tailor@frmp8452
parents:
diff changeset
21 typedef struct _window_entry_t {
b3b2332715fb Tailorization of /trunk
tailor@frmp8452
parents:
diff changeset
22 WINDOW *win;
b3b2332715fb Tailorization of /trunk
tailor@frmp8452
parents:
diff changeset
23 PANEL *panel;
b3b2332715fb Tailorization of /trunk
tailor@frmp8452
parents:
diff changeset
24 char *name;
b3b2332715fb Tailorization of /trunk
tailor@frmp8452
parents:
diff changeset
25 int nlines;
b3b2332715fb Tailorization of /trunk
tailor@frmp8452
parents:
diff changeset
26 char **texto;
b3b2332715fb Tailorization of /trunk
tailor@frmp8452
parents:
diff changeset
27 struct list_head list;
b3b2332715fb Tailorization of /trunk
tailor@frmp8452
parents:
diff changeset
28 } window_entry_t;
b3b2332715fb Tailorization of /trunk
tailor@frmp8452
parents:
diff changeset
29
b3b2332715fb Tailorization of /trunk
tailor@frmp8452
parents:
diff changeset
30 LIST_HEAD(window_list);
b3b2332715fb Tailorization of /trunk
tailor@frmp8452
parents:
diff changeset
31
b3b2332715fb Tailorization of /trunk
tailor@frmp8452
parents:
diff changeset
32 /* Variables globales a SCREEN.C */
b3b2332715fb Tailorization of /trunk
tailor@frmp8452
parents:
diff changeset
33 WINDOW *rosterWnd, *chatWnd;
b3b2332715fb Tailorization of /trunk
tailor@frmp8452
parents:
diff changeset
34 PANEL *rosterPanel, *chatPanel;
b3b2332715fb Tailorization of /trunk
tailor@frmp8452
parents:
diff changeset
35 int maxY, maxX;
b3b2332715fb Tailorization of /trunk
tailor@frmp8452
parents:
diff changeset
36 window_entry_t *ventanaActual;
b3b2332715fb Tailorization of /trunk
tailor@frmp8452
parents:
diff changeset
37
b3b2332715fb Tailorization of /trunk
tailor@frmp8452
parents:
diff changeset
38
b3b2332715fb Tailorization of /trunk
tailor@frmp8452
parents:
diff changeset
39 /* Funciones */
b3b2332715fb Tailorization of /trunk
tailor@frmp8452
parents:
diff changeset
40
b3b2332715fb Tailorization of /trunk
tailor@frmp8452
parents:
diff changeset
41 int scr_WindowHeight(WINDOW * win)
b3b2332715fb Tailorization of /trunk
tailor@frmp8452
parents:
diff changeset
42 {
b3b2332715fb Tailorization of /trunk
tailor@frmp8452
parents:
diff changeset
43 int x, y;
b3b2332715fb Tailorization of /trunk
tailor@frmp8452
parents:
diff changeset
44 getmaxyx(win, y, x);
b3b2332715fb Tailorization of /trunk
tailor@frmp8452
parents:
diff changeset
45 return x;
b3b2332715fb Tailorization of /trunk
tailor@frmp8452
parents:
diff changeset
46 }
b3b2332715fb Tailorization of /trunk
tailor@frmp8452
parents:
diff changeset
47
b3b2332715fb Tailorization of /trunk
tailor@frmp8452
parents:
diff changeset
48 void
b3b2332715fb Tailorization of /trunk
tailor@frmp8452
parents:
diff changeset
49 scr_draw_box(WINDOW * win, int y, int x, int height, int width, int Color,
b3b2332715fb Tailorization of /trunk
tailor@frmp8452
parents:
diff changeset
50 chtype box, chtype border)
b3b2332715fb Tailorization of /trunk
tailor@frmp8452
parents:
diff changeset
51 {
b3b2332715fb Tailorization of /trunk
tailor@frmp8452
parents:
diff changeset
52 int i, j;
b3b2332715fb Tailorization of /trunk
tailor@frmp8452
parents:
diff changeset
53
b3b2332715fb Tailorization of /trunk
tailor@frmp8452
parents:
diff changeset
54 wattrset(win, COLOR_PAIR(Color));
b3b2332715fb Tailorization of /trunk
tailor@frmp8452
parents:
diff changeset
55 for (i = 0; i < height; i++) {
b3b2332715fb Tailorization of /trunk
tailor@frmp8452
parents:
diff changeset
56 wmove(win, y + i, x);
b3b2332715fb Tailorization of /trunk
tailor@frmp8452
parents:
diff changeset
57 for (j = 0; j < width; j++)
b3b2332715fb Tailorization of /trunk
tailor@frmp8452
parents:
diff changeset
58 if (!i && !j)
b3b2332715fb Tailorization of /trunk
tailor@frmp8452
parents:
diff changeset
59 waddch(win, border | ACS_ULCORNER);
b3b2332715fb Tailorization of /trunk
tailor@frmp8452
parents:
diff changeset
60 else if (i == height - 1 && !j)
b3b2332715fb Tailorization of /trunk
tailor@frmp8452
parents:
diff changeset
61 waddch(win, border | ACS_LLCORNER);
b3b2332715fb Tailorization of /trunk
tailor@frmp8452
parents:
diff changeset
62 else if (!i && j == width - 1)
b3b2332715fb Tailorization of /trunk
tailor@frmp8452
parents:
diff changeset
63 waddch(win, box | ACS_URCORNER);
b3b2332715fb Tailorization of /trunk
tailor@frmp8452
parents:
diff changeset
64 else if (i == height - 1 && j == width - 1)
b3b2332715fb Tailorization of /trunk
tailor@frmp8452
parents:
diff changeset
65 waddch(win, box | ACS_LRCORNER);
b3b2332715fb Tailorization of /trunk
tailor@frmp8452
parents:
diff changeset
66 else if (!i)
b3b2332715fb Tailorization of /trunk
tailor@frmp8452
parents:
diff changeset
67 waddch(win, border | ACS_HLINE);
b3b2332715fb Tailorization of /trunk
tailor@frmp8452
parents:
diff changeset
68 else if (i == height - 1)
b3b2332715fb Tailorization of /trunk
tailor@frmp8452
parents:
diff changeset
69 waddch(win, box | ACS_HLINE);
b3b2332715fb Tailorization of /trunk
tailor@frmp8452
parents:
diff changeset
70 else if (!j)
b3b2332715fb Tailorization of /trunk
tailor@frmp8452
parents:
diff changeset
71 waddch(win, border | ACS_VLINE);
b3b2332715fb Tailorization of /trunk
tailor@frmp8452
parents:
diff changeset
72 else if (j == width - 1)
b3b2332715fb Tailorization of /trunk
tailor@frmp8452
parents:
diff changeset
73 waddch(win, box | ACS_VLINE);
b3b2332715fb Tailorization of /trunk
tailor@frmp8452
parents:
diff changeset
74 else
b3b2332715fb Tailorization of /trunk
tailor@frmp8452
parents:
diff changeset
75 waddch(win, box | ' ');
b3b2332715fb Tailorization of /trunk
tailor@frmp8452
parents:
diff changeset
76 }
b3b2332715fb Tailorization of /trunk
tailor@frmp8452
parents:
diff changeset
77 }
b3b2332715fb Tailorization of /trunk
tailor@frmp8452
parents:
diff changeset
78
b3b2332715fb Tailorization of /trunk
tailor@frmp8452
parents:
diff changeset
79 int FindColor(char *name)
b3b2332715fb Tailorization of /trunk
tailor@frmp8452
parents:
diff changeset
80 {
b3b2332715fb Tailorization of /trunk
tailor@frmp8452
parents:
diff changeset
81 if (!strcmp(name, "default"))
b3b2332715fb Tailorization of /trunk
tailor@frmp8452
parents:
diff changeset
82 return -1;
b3b2332715fb Tailorization of /trunk
tailor@frmp8452
parents:
diff changeset
83 if (!strcmp(name, "black"))
b3b2332715fb Tailorization of /trunk
tailor@frmp8452
parents:
diff changeset
84 return COLOR_BLACK;
b3b2332715fb Tailorization of /trunk
tailor@frmp8452
parents:
diff changeset
85 if (!strcmp(name, "red"))
b3b2332715fb Tailorization of /trunk
tailor@frmp8452
parents:
diff changeset
86 return COLOR_RED;
b3b2332715fb Tailorization of /trunk
tailor@frmp8452
parents:
diff changeset
87 if (!strcmp(name, "green"))
b3b2332715fb Tailorization of /trunk
tailor@frmp8452
parents:
diff changeset
88 return COLOR_GREEN;
b3b2332715fb Tailorization of /trunk
tailor@frmp8452
parents:
diff changeset
89 if (!strcmp(name, "yellow"))
b3b2332715fb Tailorization of /trunk
tailor@frmp8452
parents:
diff changeset
90 return COLOR_YELLOW;
b3b2332715fb Tailorization of /trunk
tailor@frmp8452
parents:
diff changeset
91 if (!strcmp(name, "blue"))
b3b2332715fb Tailorization of /trunk
tailor@frmp8452
parents:
diff changeset
92 return COLOR_BLUE;
b3b2332715fb Tailorization of /trunk
tailor@frmp8452
parents:
diff changeset
93 if (!strcmp(name, "magenta"))
b3b2332715fb Tailorization of /trunk
tailor@frmp8452
parents:
diff changeset
94 return COLOR_MAGENTA;
b3b2332715fb Tailorization of /trunk
tailor@frmp8452
parents:
diff changeset
95 if (!strcmp(name, "cyan"))
b3b2332715fb Tailorization of /trunk
tailor@frmp8452
parents:
diff changeset
96 return COLOR_CYAN;
b3b2332715fb Tailorization of /trunk
tailor@frmp8452
parents:
diff changeset
97 if (!strcmp(name, "white"))
b3b2332715fb Tailorization of /trunk
tailor@frmp8452
parents:
diff changeset
98 return COLOR_WHITE;
b3b2332715fb Tailorization of /trunk
tailor@frmp8452
parents:
diff changeset
99
b3b2332715fb Tailorization of /trunk
tailor@frmp8452
parents:
diff changeset
100 return -1;
b3b2332715fb Tailorization of /trunk
tailor@frmp8452
parents:
diff changeset
101 }
b3b2332715fb Tailorization of /trunk
tailor@frmp8452
parents:
diff changeset
102
b3b2332715fb Tailorization of /trunk
tailor@frmp8452
parents:
diff changeset
103 void ParseColors(void)
b3b2332715fb Tailorization of /trunk
tailor@frmp8452
parents:
diff changeset
104 {
b3b2332715fb Tailorization of /trunk
tailor@frmp8452
parents:
diff changeset
105 char *colors[11] = {
b3b2332715fb Tailorization of /trunk
tailor@frmp8452
parents:
diff changeset
106 "", "",
b3b2332715fb Tailorization of /trunk
tailor@frmp8452
parents:
diff changeset
107 "borderlines",
b3b2332715fb Tailorization of /trunk
tailor@frmp8452
parents:
diff changeset
108 "jidonlineselected",
b3b2332715fb Tailorization of /trunk
tailor@frmp8452
parents:
diff changeset
109 "jidonline",
b3b2332715fb Tailorization of /trunk
tailor@frmp8452
parents:
diff changeset
110 "jidofflineselected",
b3b2332715fb Tailorization of /trunk
tailor@frmp8452
parents:
diff changeset
111 "jidoffline",
b3b2332715fb Tailorization of /trunk
tailor@frmp8452
parents:
diff changeset
112 "text",
b3b2332715fb Tailorization of /trunk
tailor@frmp8452
parents:
diff changeset
113 NULL
b3b2332715fb Tailorization of /trunk
tailor@frmp8452
parents:
diff changeset
114 };
b3b2332715fb Tailorization of /trunk
tailor@frmp8452
parents:
diff changeset
115
b3b2332715fb Tailorization of /trunk
tailor@frmp8452
parents:
diff changeset
116 char *tmp = malloc(1024);
b3b2332715fb Tailorization of /trunk
tailor@frmp8452
parents:
diff changeset
117 char *color1;
b3b2332715fb Tailorization of /trunk
tailor@frmp8452
parents:
diff changeset
118 char *background = cfg_read("color_background");
b3b2332715fb Tailorization of /trunk
tailor@frmp8452
parents:
diff changeset
119 char *backselected = cfg_read("color_backselected");
b3b2332715fb Tailorization of /trunk
tailor@frmp8452
parents:
diff changeset
120 int i = 0;
b3b2332715fb Tailorization of /trunk
tailor@frmp8452
parents:
diff changeset
121
b3b2332715fb Tailorization of /trunk
tailor@frmp8452
parents:
diff changeset
122 while (colors[i]) {
b3b2332715fb Tailorization of /trunk
tailor@frmp8452
parents:
diff changeset
123 sprintf(tmp, "color_%s", colors[i]);
b3b2332715fb Tailorization of /trunk
tailor@frmp8452
parents:
diff changeset
124 color1 = cfg_read(tmp);
b3b2332715fb Tailorization of /trunk
tailor@frmp8452
parents:
diff changeset
125
b3b2332715fb Tailorization of /trunk
tailor@frmp8452
parents:
diff changeset
126 switch (i + 1) {
b3b2332715fb Tailorization of /trunk
tailor@frmp8452
parents:
diff changeset
127 case 1:
b3b2332715fb Tailorization of /trunk
tailor@frmp8452
parents:
diff changeset
128 init_pair(1, COLOR_BLACK, COLOR_WHITE);
b3b2332715fb Tailorization of /trunk
tailor@frmp8452
parents:
diff changeset
129 break;
b3b2332715fb Tailorization of /trunk
tailor@frmp8452
parents:
diff changeset
130 case 2:
b3b2332715fb Tailorization of /trunk
tailor@frmp8452
parents:
diff changeset
131 init_pair(2, COLOR_WHITE, COLOR_BLACK);
b3b2332715fb Tailorization of /trunk
tailor@frmp8452
parents:
diff changeset
132 break;
b3b2332715fb Tailorization of /trunk
tailor@frmp8452
parents:
diff changeset
133 case 3:
b3b2332715fb Tailorization of /trunk
tailor@frmp8452
parents:
diff changeset
134 init_pair(3, FindColor(color1), FindColor(background));
b3b2332715fb Tailorization of /trunk
tailor@frmp8452
parents:
diff changeset
135 break;
b3b2332715fb Tailorization of /trunk
tailor@frmp8452
parents:
diff changeset
136 case 4:
b3b2332715fb Tailorization of /trunk
tailor@frmp8452
parents:
diff changeset
137 init_pair(4, FindColor(color1), FindColor(backselected));
b3b2332715fb Tailorization of /trunk
tailor@frmp8452
parents:
diff changeset
138 break;
b3b2332715fb Tailorization of /trunk
tailor@frmp8452
parents:
diff changeset
139 case 5:
b3b2332715fb Tailorization of /trunk
tailor@frmp8452
parents:
diff changeset
140 init_pair(5, FindColor(color1), FindColor(background));
b3b2332715fb Tailorization of /trunk
tailor@frmp8452
parents:
diff changeset
141 break;
b3b2332715fb Tailorization of /trunk
tailor@frmp8452
parents:
diff changeset
142 case 6:
b3b2332715fb Tailorization of /trunk
tailor@frmp8452
parents:
diff changeset
143 init_pair(6, FindColor(color1), FindColor(backselected));
b3b2332715fb Tailorization of /trunk
tailor@frmp8452
parents:
diff changeset
144 break;
b3b2332715fb Tailorization of /trunk
tailor@frmp8452
parents:
diff changeset
145 case 7:
b3b2332715fb Tailorization of /trunk
tailor@frmp8452
parents:
diff changeset
146 init_pair(7, FindColor(color1), FindColor(background));
b3b2332715fb Tailorization of /trunk
tailor@frmp8452
parents:
diff changeset
147 break;
b3b2332715fb Tailorization of /trunk
tailor@frmp8452
parents:
diff changeset
148 case 8:
b3b2332715fb Tailorization of /trunk
tailor@frmp8452
parents:
diff changeset
149 init_pair(8, FindColor(color1), FindColor(background));
b3b2332715fb Tailorization of /trunk
tailor@frmp8452
parents:
diff changeset
150 break;
b3b2332715fb Tailorization of /trunk
tailor@frmp8452
parents:
diff changeset
151 }
b3b2332715fb Tailorization of /trunk
tailor@frmp8452
parents:
diff changeset
152 i++;
b3b2332715fb Tailorization of /trunk
tailor@frmp8452
parents:
diff changeset
153 }
b3b2332715fb Tailorization of /trunk
tailor@frmp8452
parents:
diff changeset
154 }
b3b2332715fb Tailorization of /trunk
tailor@frmp8452
parents:
diff changeset
155
b3b2332715fb Tailorization of /trunk
tailor@frmp8452
parents:
diff changeset
156
b3b2332715fb Tailorization of /trunk
tailor@frmp8452
parents:
diff changeset
157 window_entry_t *scr_CreatePanel(char *title, int x, int y, int lines,
b3b2332715fb Tailorization of /trunk
tailor@frmp8452
parents:
diff changeset
158 int cols)
b3b2332715fb Tailorization of /trunk
tailor@frmp8452
parents:
diff changeset
159 {
b3b2332715fb Tailorization of /trunk
tailor@frmp8452
parents:
diff changeset
160 window_entry_t *tmp = calloc(1, sizeof(window_entry_t));
b3b2332715fb Tailorization of /trunk
tailor@frmp8452
parents:
diff changeset
161
b3b2332715fb Tailorization of /trunk
tailor@frmp8452
parents:
diff changeset
162 tmp->win = newwin(lines, cols, y, x);
b3b2332715fb Tailorization of /trunk
tailor@frmp8452
parents:
diff changeset
163 tmp->panel = new_panel(tmp->win);
b3b2332715fb Tailorization of /trunk
tailor@frmp8452
parents:
diff changeset
164 tmp->name = (char *) calloc(1, 1024);
b3b2332715fb Tailorization of /trunk
tailor@frmp8452
parents:
diff changeset
165 strncpy(tmp->name, title, 1024);
b3b2332715fb Tailorization of /trunk
tailor@frmp8452
parents:
diff changeset
166 scr_draw_box(tmp->win, 0, 0, lines, cols, COLOR_GENERAL, 0, 0);
b3b2332715fb Tailorization of /trunk
tailor@frmp8452
parents:
diff changeset
167 mvwprintw(tmp->win, 0, (cols - (2 + strlen(title))) / 2, " %s ", title);
b3b2332715fb Tailorization of /trunk
tailor@frmp8452
parents:
diff changeset
168
b3b2332715fb Tailorization of /trunk
tailor@frmp8452
parents:
diff changeset
169 list_add_tail(&tmp->list, &window_list);
b3b2332715fb Tailorization of /trunk
tailor@frmp8452
parents:
diff changeset
170 update_panels();
b3b2332715fb Tailorization of /trunk
tailor@frmp8452
parents:
diff changeset
171
b3b2332715fb Tailorization of /trunk
tailor@frmp8452
parents:
diff changeset
172 return tmp;
b3b2332715fb Tailorization of /trunk
tailor@frmp8452
parents:
diff changeset
173 }
b3b2332715fb Tailorization of /trunk
tailor@frmp8452
parents:
diff changeset
174
b3b2332715fb Tailorization of /trunk
tailor@frmp8452
parents:
diff changeset
175
b3b2332715fb Tailorization of /trunk
tailor@frmp8452
parents:
diff changeset
176 void
b3b2332715fb Tailorization of /trunk
tailor@frmp8452
parents:
diff changeset
177 scr_CreatePopup(char *title, char *texto, int corte, int type,
b3b2332715fb Tailorization of /trunk
tailor@frmp8452
parents:
diff changeset
178 char *returnstring)
b3b2332715fb Tailorization of /trunk
tailor@frmp8452
parents:
diff changeset
179 {
b3b2332715fb Tailorization of /trunk
tailor@frmp8452
parents:
diff changeset
180 WINDOW *popupWin;
b3b2332715fb Tailorization of /trunk
tailor@frmp8452
parents:
diff changeset
181 PANEL *popupPanel;
b3b2332715fb Tailorization of /trunk
tailor@frmp8452
parents:
diff changeset
182
b3b2332715fb Tailorization of /trunk
tailor@frmp8452
parents:
diff changeset
183 int lineas = 0;
b3b2332715fb Tailorization of /trunk
tailor@frmp8452
parents:
diff changeset
184 int cols = 0;
b3b2332715fb Tailorization of /trunk
tailor@frmp8452
parents:
diff changeset
185
b3b2332715fb Tailorization of /trunk
tailor@frmp8452
parents:
diff changeset
186 char **submsgs;
b3b2332715fb Tailorization of /trunk
tailor@frmp8452
parents:
diff changeset
187 int n = 0;
b3b2332715fb Tailorization of /trunk
tailor@frmp8452
parents:
diff changeset
188 int i;
b3b2332715fb Tailorization of /trunk
tailor@frmp8452
parents:
diff changeset
189
b3b2332715fb Tailorization of /trunk
tailor@frmp8452
parents:
diff changeset
190 char *instr = (char *) calloc(1, 1024);
b3b2332715fb Tailorization of /trunk
tailor@frmp8452
parents:
diff changeset
191
b3b2332715fb Tailorization of /trunk
tailor@frmp8452
parents:
diff changeset
192 /* fprintf(stderr, "\r\n%d", lineas); */
b3b2332715fb Tailorization of /trunk
tailor@frmp8452
parents:
diff changeset
193
b3b2332715fb Tailorization of /trunk
tailor@frmp8452
parents:
diff changeset
194 submsgs = ut_SplitMessage(texto, &n, corte);
b3b2332715fb Tailorization of /trunk
tailor@frmp8452
parents:
diff changeset
195
b3b2332715fb Tailorization of /trunk
tailor@frmp8452
parents:
diff changeset
196 switch (type) {
b3b2332715fb Tailorization of /trunk
tailor@frmp8452
parents:
diff changeset
197 case 1:
b3b2332715fb Tailorization of /trunk
tailor@frmp8452
parents:
diff changeset
198 case 0:
b3b2332715fb Tailorization of /trunk
tailor@frmp8452
parents:
diff changeset
199 lineas = n + 4;
b3b2332715fb Tailorization of /trunk
tailor@frmp8452
parents:
diff changeset
200 break;
b3b2332715fb Tailorization of /trunk
tailor@frmp8452
parents:
diff changeset
201 }
b3b2332715fb Tailorization of /trunk
tailor@frmp8452
parents:
diff changeset
202
b3b2332715fb Tailorization of /trunk
tailor@frmp8452
parents:
diff changeset
203 cols = corte + 3;
b3b2332715fb Tailorization of /trunk
tailor@frmp8452
parents:
diff changeset
204 popupWin = newwin(lineas, cols, (maxY - lineas) / 2, (maxX - cols) / 2);
b3b2332715fb Tailorization of /trunk
tailor@frmp8452
parents:
diff changeset
205 popupPanel = new_panel(popupWin);
b3b2332715fb Tailorization of /trunk
tailor@frmp8452
parents:
diff changeset
206
b3b2332715fb Tailorization of /trunk
tailor@frmp8452
parents:
diff changeset
207 /*ATENCION!!! Colorear el popup ??
b3b2332715fb Tailorization of /trunk
tailor@frmp8452
parents:
diff changeset
208 / box (popupWin, 0, 0); */
b3b2332715fb Tailorization of /trunk
tailor@frmp8452
parents:
diff changeset
209 scr_draw_box(popupWin, 0, 0, lineas, cols, COLOR_POPUP, 0, 0);
b3b2332715fb Tailorization of /trunk
tailor@frmp8452
parents:
diff changeset
210 mvwprintw(popupWin, 0, (cols - (2 + strlen(title))) / 2, " %s ", title);
b3b2332715fb Tailorization of /trunk
tailor@frmp8452
parents:
diff changeset
211
b3b2332715fb Tailorization of /trunk
tailor@frmp8452
parents:
diff changeset
212 for (i = 0; i < n; i++)
b3b2332715fb Tailorization of /trunk
tailor@frmp8452
parents:
diff changeset
213 mvwprintw(popupWin, i + 1, 2, "%s", submsgs[i]);
b3b2332715fb Tailorization of /trunk
tailor@frmp8452
parents:
diff changeset
214
b3b2332715fb Tailorization of /trunk
tailor@frmp8452
parents:
diff changeset
215
b3b2332715fb Tailorization of /trunk
tailor@frmp8452
parents:
diff changeset
216 for (i = 0; i < n; i++)
b3b2332715fb Tailorization of /trunk
tailor@frmp8452
parents:
diff changeset
217 free(submsgs[i]);
b3b2332715fb Tailorization of /trunk
tailor@frmp8452
parents:
diff changeset
218 free(submsgs);
b3b2332715fb Tailorization of /trunk
tailor@frmp8452
parents:
diff changeset
219
b3b2332715fb Tailorization of /trunk
tailor@frmp8452
parents:
diff changeset
220 switch (type) {
b3b2332715fb Tailorization of /trunk
tailor@frmp8452
parents:
diff changeset
221 case 0:
b3b2332715fb Tailorization of /trunk
tailor@frmp8452
parents:
diff changeset
222 mvwprintw(popupWin, n + 2,
b3b2332715fb Tailorization of /trunk
tailor@frmp8452
parents:
diff changeset
223 (cols - (2 + strlen(i18n("Press any key")))) / 2,
b3b2332715fb Tailorization of /trunk
tailor@frmp8452
parents:
diff changeset
224 i18n("Press any key"));
b3b2332715fb Tailorization of /trunk
tailor@frmp8452
parents:
diff changeset
225 update_panels();
b3b2332715fb Tailorization of /trunk
tailor@frmp8452
parents:
diff changeset
226 doupdate();
b3b2332715fb Tailorization of /trunk
tailor@frmp8452
parents:
diff changeset
227 getch();
b3b2332715fb Tailorization of /trunk
tailor@frmp8452
parents:
diff changeset
228 break;
b3b2332715fb Tailorization of /trunk
tailor@frmp8452
parents:
diff changeset
229 case 1:
b3b2332715fb Tailorization of /trunk
tailor@frmp8452
parents:
diff changeset
230 {
b3b2332715fb Tailorization of /trunk
tailor@frmp8452
parents:
diff changeset
231 char ch;
b3b2332715fb Tailorization of /trunk
tailor@frmp8452
parents:
diff changeset
232 int scroll = 0;
b3b2332715fb Tailorization of /trunk
tailor@frmp8452
parents:
diff changeset
233 int input_x = 0;
b3b2332715fb Tailorization of /trunk
tailor@frmp8452
parents:
diff changeset
234
b3b2332715fb Tailorization of /trunk
tailor@frmp8452
parents:
diff changeset
235 wmove(popupWin, 3, 1);
b3b2332715fb Tailorization of /trunk
tailor@frmp8452
parents:
diff changeset
236 wrefresh(popupWin);
b3b2332715fb Tailorization of /trunk
tailor@frmp8452
parents:
diff changeset
237 keypad(popupWin, TRUE);
b3b2332715fb Tailorization of /trunk
tailor@frmp8452
parents:
diff changeset
238 while ((ch = getch()) != '\n') {
b3b2332715fb Tailorization of /trunk
tailor@frmp8452
parents:
diff changeset
239 switch (ch) {
b3b2332715fb Tailorization of /trunk
tailor@frmp8452
parents:
diff changeset
240 case 0x09:
b3b2332715fb Tailorization of /trunk
tailor@frmp8452
parents:
diff changeset
241 case KEY_UP:
b3b2332715fb Tailorization of /trunk
tailor@frmp8452
parents:
diff changeset
242 case KEY_DOWN:
b3b2332715fb Tailorization of /trunk
tailor@frmp8452
parents:
diff changeset
243 break;
b3b2332715fb Tailorization of /trunk
tailor@frmp8452
parents:
diff changeset
244 case KEY_RIGHT:
b3b2332715fb Tailorization of /trunk
tailor@frmp8452
parents:
diff changeset
245 case KEY_LEFT:
b3b2332715fb Tailorization of /trunk
tailor@frmp8452
parents:
diff changeset
246 break;
b3b2332715fb Tailorization of /trunk
tailor@frmp8452
parents:
diff changeset
247 case KEY_BACKSPACE:
b3b2332715fb Tailorization of /trunk
tailor@frmp8452
parents:
diff changeset
248 case 127:
b3b2332715fb Tailorization of /trunk
tailor@frmp8452
parents:
diff changeset
249 if (input_x || scroll) {
b3b2332715fb Tailorization of /trunk
tailor@frmp8452
parents:
diff changeset
250 /* wattrset (popupWin, 0); */
b3b2332715fb Tailorization of /trunk
tailor@frmp8452
parents:
diff changeset
251 if (!input_x) {
b3b2332715fb Tailorization of /trunk
tailor@frmp8452
parents:
diff changeset
252 scroll = scroll < cols - 3 ? 0 : scroll - (cols - 3);
b3b2332715fb Tailorization of /trunk
tailor@frmp8452
parents:
diff changeset
253 wmove(popupWin, 3, 1);
b3b2332715fb Tailorization of /trunk
tailor@frmp8452
parents:
diff changeset
254 for (i = 0; i < cols; i++)
b3b2332715fb Tailorization of /trunk
tailor@frmp8452
parents:
diff changeset
255 waddch
b3b2332715fb Tailorization of /trunk
tailor@frmp8452
parents:
diff changeset
256 (popupWin,
b3b2332715fb Tailorization of /trunk
tailor@frmp8452
parents:
diff changeset
257 instr
b3b2332715fb Tailorization of /trunk
tailor@frmp8452
parents:
diff changeset
258 [scroll
b3b2332715fb Tailorization of /trunk
tailor@frmp8452
parents:
diff changeset
259 + input_x + i] ? instr[scroll + input_x + i] : ' ');
b3b2332715fb Tailorization of /trunk
tailor@frmp8452
parents:
diff changeset
260 input_x = strlen(instr) - scroll;
b3b2332715fb Tailorization of /trunk
tailor@frmp8452
parents:
diff changeset
261 } else
b3b2332715fb Tailorization of /trunk
tailor@frmp8452
parents:
diff changeset
262 input_x--;
b3b2332715fb Tailorization of /trunk
tailor@frmp8452
parents:
diff changeset
263 instr[scroll + input_x] = '\0';
b3b2332715fb Tailorization of /trunk
tailor@frmp8452
parents:
diff changeset
264 mvwaddch(popupWin, 3, input_x + 1, ' ');
b3b2332715fb Tailorization of /trunk
tailor@frmp8452
parents:
diff changeset
265 wmove(popupWin, 3, input_x + 1);
b3b2332715fb Tailorization of /trunk
tailor@frmp8452
parents:
diff changeset
266 wrefresh(popupWin);
b3b2332715fb Tailorization of /trunk
tailor@frmp8452
parents:
diff changeset
267 }
b3b2332715fb Tailorization of /trunk
tailor@frmp8452
parents:
diff changeset
268 default:
b3b2332715fb Tailorization of /trunk
tailor@frmp8452
parents:
diff changeset
269 if ( /*ch<0x100 && */ isprint(ch) || ch == '�'
b3b2332715fb Tailorization of /trunk
tailor@frmp8452
parents:
diff changeset
270 || ch == '�') {
b3b2332715fb Tailorization of /trunk
tailor@frmp8452
parents:
diff changeset
271 if (scroll + input_x < 1024) {
b3b2332715fb Tailorization of /trunk
tailor@frmp8452
parents:
diff changeset
272 instr[scroll + input_x] = ch;
b3b2332715fb Tailorization of /trunk
tailor@frmp8452
parents:
diff changeset
273 instr[scroll + input_x + 1] = '\0';
b3b2332715fb Tailorization of /trunk
tailor@frmp8452
parents:
diff changeset
274 if (input_x == cols - 3) {
b3b2332715fb Tailorization of /trunk
tailor@frmp8452
parents:
diff changeset
275 scroll++;
b3b2332715fb Tailorization of /trunk
tailor@frmp8452
parents:
diff changeset
276 wmove(popupWin, 3, 1);
b3b2332715fb Tailorization of /trunk
tailor@frmp8452
parents:
diff changeset
277 for (i = 0; i < cols - 3; i++)
b3b2332715fb Tailorization of /trunk
tailor@frmp8452
parents:
diff changeset
278 waddch(popupWin, instr[scroll + i]);
b3b2332715fb Tailorization of /trunk
tailor@frmp8452
parents:
diff changeset
279 } else {
b3b2332715fb Tailorization of /trunk
tailor@frmp8452
parents:
diff changeset
280 wmove(popupWin, 3, 1 + input_x++);
b3b2332715fb Tailorization of /trunk
tailor@frmp8452
parents:
diff changeset
281 waddch(popupWin, ch);
b3b2332715fb Tailorization of /trunk
tailor@frmp8452
parents:
diff changeset
282 }
b3b2332715fb Tailorization of /trunk
tailor@frmp8452
parents:
diff changeset
283 wrefresh(popupWin);
b3b2332715fb Tailorization of /trunk
tailor@frmp8452
parents:
diff changeset
284 } else {
b3b2332715fb Tailorization of /trunk
tailor@frmp8452
parents:
diff changeset
285 flash();
b3b2332715fb Tailorization of /trunk
tailor@frmp8452
parents:
diff changeset
286 }
b3b2332715fb Tailorization of /trunk
tailor@frmp8452
parents:
diff changeset
287 }
b3b2332715fb Tailorization of /trunk
tailor@frmp8452
parents:
diff changeset
288 }
b3b2332715fb Tailorization of /trunk
tailor@frmp8452
parents:
diff changeset
289 }
b3b2332715fb Tailorization of /trunk
tailor@frmp8452
parents:
diff changeset
290 }
b3b2332715fb Tailorization of /trunk
tailor@frmp8452
parents:
diff changeset
291 if (returnstring != NULL)
b3b2332715fb Tailorization of /trunk
tailor@frmp8452
parents:
diff changeset
292 strcpy(returnstring, instr);
b3b2332715fb Tailorization of /trunk
tailor@frmp8452
parents:
diff changeset
293 break;
b3b2332715fb Tailorization of /trunk
tailor@frmp8452
parents:
diff changeset
294 }
b3b2332715fb Tailorization of /trunk
tailor@frmp8452
parents:
diff changeset
295
b3b2332715fb Tailorization of /trunk
tailor@frmp8452
parents:
diff changeset
296 del_panel(popupPanel);
b3b2332715fb Tailorization of /trunk
tailor@frmp8452
parents:
diff changeset
297 delwin(popupWin);
b3b2332715fb Tailorization of /trunk
tailor@frmp8452
parents:
diff changeset
298 update_panels();
b3b2332715fb Tailorization of /trunk
tailor@frmp8452
parents:
diff changeset
299 doupdate();
b3b2332715fb Tailorization of /trunk
tailor@frmp8452
parents:
diff changeset
300 free(instr);
b3b2332715fb Tailorization of /trunk
tailor@frmp8452
parents:
diff changeset
301 keypad(rosterWnd, TRUE);
b3b2332715fb Tailorization of /trunk
tailor@frmp8452
parents:
diff changeset
302 }
b3b2332715fb Tailorization of /trunk
tailor@frmp8452
parents:
diff changeset
303
b3b2332715fb Tailorization of /trunk
tailor@frmp8452
parents:
diff changeset
304
b3b2332715fb Tailorization of /trunk
tailor@frmp8452
parents:
diff changeset
305
b3b2332715fb Tailorization of /trunk
tailor@frmp8452
parents:
diff changeset
306 void scr_RoolWindow(void)
b3b2332715fb Tailorization of /trunk
tailor@frmp8452
parents:
diff changeset
307 {
b3b2332715fb Tailorization of /trunk
tailor@frmp8452
parents:
diff changeset
308 }
b3b2332715fb Tailorization of /trunk
tailor@frmp8452
parents:
diff changeset
309
b3b2332715fb Tailorization of /trunk
tailor@frmp8452
parents:
diff changeset
310 window_entry_t *scr_SearchWindow(char *nombreVentana)
b3b2332715fb Tailorization of /trunk
tailor@frmp8452
parents:
diff changeset
311 {
b3b2332715fb Tailorization of /trunk
tailor@frmp8452
parents:
diff changeset
312 struct list_head *pos, *n;
b3b2332715fb Tailorization of /trunk
tailor@frmp8452
parents:
diff changeset
313 window_entry_t *search_entry = NULL;
b3b2332715fb Tailorization of /trunk
tailor@frmp8452
parents:
diff changeset
314
b3b2332715fb Tailorization of /trunk
tailor@frmp8452
parents:
diff changeset
315 list_for_each_safe(pos, n, &window_list) {
b3b2332715fb Tailorization of /trunk
tailor@frmp8452
parents:
diff changeset
316 search_entry = window_entry(pos);
b3b2332715fb Tailorization of /trunk
tailor@frmp8452
parents:
diff changeset
317 if (search_entry->name) {
b3b2332715fb Tailorization of /trunk
tailor@frmp8452
parents:
diff changeset
318 if (!strcasecmp(search_entry->name, nombreVentana)) {
b3b2332715fb Tailorization of /trunk
tailor@frmp8452
parents:
diff changeset
319 return search_entry;
b3b2332715fb Tailorization of /trunk
tailor@frmp8452
parents:
diff changeset
320 }
b3b2332715fb Tailorization of /trunk
tailor@frmp8452
parents:
diff changeset
321 }
b3b2332715fb Tailorization of /trunk
tailor@frmp8452
parents:
diff changeset
322 }
b3b2332715fb Tailorization of /trunk
tailor@frmp8452
parents:
diff changeset
323 return NULL;
b3b2332715fb Tailorization of /trunk
tailor@frmp8452
parents:
diff changeset
324 }
b3b2332715fb Tailorization of /trunk
tailor@frmp8452
parents:
diff changeset
325
b3b2332715fb Tailorization of /trunk
tailor@frmp8452
parents:
diff changeset
326 void scr_ShowWindow(char *nombreVentana)
b3b2332715fb Tailorization of /trunk
tailor@frmp8452
parents:
diff changeset
327 {
b3b2332715fb Tailorization of /trunk
tailor@frmp8452
parents:
diff changeset
328 int n, width, i;
b3b2332715fb Tailorization of /trunk
tailor@frmp8452
parents:
diff changeset
329 window_entry_t *tmp = scr_SearchWindow(nombreVentana);
b3b2332715fb Tailorization of /trunk
tailor@frmp8452
parents:
diff changeset
330 if (tmp != NULL) {
b3b2332715fb Tailorization of /trunk
tailor@frmp8452
parents:
diff changeset
331 top_panel(tmp->panel);
b3b2332715fb Tailorization of /trunk
tailor@frmp8452
parents:
diff changeset
332 width = scr_WindowHeight(tmp->win);
b3b2332715fb Tailorization of /trunk
tailor@frmp8452
parents:
diff changeset
333 for (n = 0; n < tmp->nlines; n++) {
b3b2332715fb Tailorization of /trunk
tailor@frmp8452
parents:
diff changeset
334 mvwprintw(tmp->win, n + 1, 1, "");
b3b2332715fb Tailorization of /trunk
tailor@frmp8452
parents:
diff changeset
335 for (i = 0; i < width - 2; i++)
b3b2332715fb Tailorization of /trunk
tailor@frmp8452
parents:
diff changeset
336 waddch(tmp->win, ' ');
b3b2332715fb Tailorization of /trunk
tailor@frmp8452
parents:
diff changeset
337 mvwprintw(tmp->win, n + 1, 1, "%s", tmp->texto[n]);
b3b2332715fb Tailorization of /trunk
tailor@frmp8452
parents:
diff changeset
338 }
b3b2332715fb Tailorization of /trunk
tailor@frmp8452
parents:
diff changeset
339 move(maxY - 2, maxX - 1);
b3b2332715fb Tailorization of /trunk
tailor@frmp8452
parents:
diff changeset
340 update_panels();
b3b2332715fb Tailorization of /trunk
tailor@frmp8452
parents:
diff changeset
341 doupdate();
b3b2332715fb Tailorization of /trunk
tailor@frmp8452
parents:
diff changeset
342 }
b3b2332715fb Tailorization of /trunk
tailor@frmp8452
parents:
diff changeset
343 }
b3b2332715fb Tailorization of /trunk
tailor@frmp8452
parents:
diff changeset
344
b3b2332715fb Tailorization of /trunk
tailor@frmp8452
parents:
diff changeset
345 void scr_ShowBuddyWindow(void)
b3b2332715fb Tailorization of /trunk
tailor@frmp8452
parents:
diff changeset
346 {
b3b2332715fb Tailorization of /trunk
tailor@frmp8452
parents:
diff changeset
347 buddy_entry_t *tmp = bud_SelectedInfo();
b3b2332715fb Tailorization of /trunk
tailor@frmp8452
parents:
diff changeset
348 if (tmp->jid != NULL)
b3b2332715fb Tailorization of /trunk
tailor@frmp8452
parents:
diff changeset
349 scr_ShowWindow(tmp->jid);
b3b2332715fb Tailorization of /trunk
tailor@frmp8452
parents:
diff changeset
350 }
b3b2332715fb Tailorization of /trunk
tailor@frmp8452
parents:
diff changeset
351
b3b2332715fb Tailorization of /trunk
tailor@frmp8452
parents:
diff changeset
352
b3b2332715fb Tailorization of /trunk
tailor@frmp8452
parents:
diff changeset
353 void scr_WriteInWindow(char *nombreVentana, char *texto, int TimeStamp)
b3b2332715fb Tailorization of /trunk
tailor@frmp8452
parents:
diff changeset
354 {
b3b2332715fb Tailorization of /trunk
tailor@frmp8452
parents:
diff changeset
355 time_t ahora;
b3b2332715fb Tailorization of /trunk
tailor@frmp8452
parents:
diff changeset
356 int n;
b3b2332715fb Tailorization of /trunk
tailor@frmp8452
parents:
diff changeset
357 int i;
b3b2332715fb Tailorization of /trunk
tailor@frmp8452
parents:
diff changeset
358 int width;
b3b2332715fb Tailorization of /trunk
tailor@frmp8452
parents:
diff changeset
359 window_entry_t *tmp;
b3b2332715fb Tailorization of /trunk
tailor@frmp8452
parents:
diff changeset
360
b3b2332715fb Tailorization of /trunk
tailor@frmp8452
parents:
diff changeset
361 tmp = scr_SearchWindow(nombreVentana);
b3b2332715fb Tailorization of /trunk
tailor@frmp8452
parents:
diff changeset
362 if (tmp == NULL) {
b3b2332715fb Tailorization of /trunk
tailor@frmp8452
parents:
diff changeset
363 tmp = scr_CreatePanel(nombreVentana, 20, 0, maxY-1, maxX - 20);
b3b2332715fb Tailorization of /trunk
tailor@frmp8452
parents:
diff changeset
364 tmp->texto = (char **) calloc(maxY * 3, sizeof(char *));
b3b2332715fb Tailorization of /trunk
tailor@frmp8452
parents:
diff changeset
365 for (n = 0; n < (maxY-1) * 3; n++)
b3b2332715fb Tailorization of /trunk
tailor@frmp8452
parents:
diff changeset
366 tmp->texto[n] = (char *) calloc(1, 1024);
b3b2332715fb Tailorization of /trunk
tailor@frmp8452
parents:
diff changeset
367
b3b2332715fb Tailorization of /trunk
tailor@frmp8452
parents:
diff changeset
368 if (TimeStamp) {
b3b2332715fb Tailorization of /trunk
tailor@frmp8452
parents:
diff changeset
369 ahora = time(NULL);
b3b2332715fb Tailorization of /trunk
tailor@frmp8452
parents:
diff changeset
370 strftime(tmp->texto[tmp->nlines], 1024, "[%H:%M] ",
b3b2332715fb Tailorization of /trunk
tailor@frmp8452
parents:
diff changeset
371 localtime(&ahora));
b3b2332715fb Tailorization of /trunk
tailor@frmp8452
parents:
diff changeset
372 strcat(tmp->texto[tmp->nlines], texto);
b3b2332715fb Tailorization of /trunk
tailor@frmp8452
parents:
diff changeset
373 } else {
b3b2332715fb Tailorization of /trunk
tailor@frmp8452
parents:
diff changeset
374 sprintf(tmp->texto[tmp->nlines], " %s", texto);
b3b2332715fb Tailorization of /trunk
tailor@frmp8452
parents:
diff changeset
375 }
b3b2332715fb Tailorization of /trunk
tailor@frmp8452
parents:
diff changeset
376 tmp->nlines++;
b3b2332715fb Tailorization of /trunk
tailor@frmp8452
parents:
diff changeset
377 } else {
b3b2332715fb Tailorization of /trunk
tailor@frmp8452
parents:
diff changeset
378 if (tmp->nlines < maxY - 3) {
b3b2332715fb Tailorization of /trunk
tailor@frmp8452
parents:
diff changeset
379 if (TimeStamp) {
b3b2332715fb Tailorization of /trunk
tailor@frmp8452
parents:
diff changeset
380 ahora = time(NULL);
b3b2332715fb Tailorization of /trunk
tailor@frmp8452
parents:
diff changeset
381 strftime(tmp->texto[tmp->nlines], 1024,
b3b2332715fb Tailorization of /trunk
tailor@frmp8452
parents:
diff changeset
382 "[%H:%M] ", localtime(&ahora));
b3b2332715fb Tailorization of /trunk
tailor@frmp8452
parents:
diff changeset
383 strcat(tmp->texto[tmp->nlines], texto);
b3b2332715fb Tailorization of /trunk
tailor@frmp8452
parents:
diff changeset
384 } else {
b3b2332715fb Tailorization of /trunk
tailor@frmp8452
parents:
diff changeset
385 sprintf(tmp->texto[tmp->nlines], " %s", texto);
b3b2332715fb Tailorization of /trunk
tailor@frmp8452
parents:
diff changeset
386 }
b3b2332715fb Tailorization of /trunk
tailor@frmp8452
parents:
diff changeset
387 tmp->nlines++;
b3b2332715fb Tailorization of /trunk
tailor@frmp8452
parents:
diff changeset
388 } else {
b3b2332715fb Tailorization of /trunk
tailor@frmp8452
parents:
diff changeset
389 for (n = 0; n < tmp->nlines; n++) {
b3b2332715fb Tailorization of /trunk
tailor@frmp8452
parents:
diff changeset
390 memset(tmp->texto[n], 0, 1024);
b3b2332715fb Tailorization of /trunk
tailor@frmp8452
parents:
diff changeset
391 strncpy(tmp->texto[n], tmp->texto[n + 1], 1024);
b3b2332715fb Tailorization of /trunk
tailor@frmp8452
parents:
diff changeset
392 }
b3b2332715fb Tailorization of /trunk
tailor@frmp8452
parents:
diff changeset
393 if (TimeStamp) {
b3b2332715fb Tailorization of /trunk
tailor@frmp8452
parents:
diff changeset
394 ahora = time(NULL);
b3b2332715fb Tailorization of /trunk
tailor@frmp8452
parents:
diff changeset
395 strftime(tmp->texto[tmp->nlines - 1], 1024,
b3b2332715fb Tailorization of /trunk
tailor@frmp8452
parents:
diff changeset
396 "[%H:%M] ", localtime(&ahora));
b3b2332715fb Tailorization of /trunk
tailor@frmp8452
parents:
diff changeset
397 strcat(tmp->texto[tmp->nlines - 1], texto);
b3b2332715fb Tailorization of /trunk
tailor@frmp8452
parents:
diff changeset
398 } else {
b3b2332715fb Tailorization of /trunk
tailor@frmp8452
parents:
diff changeset
399 sprintf(tmp->texto[tmp->nlines - 1], " %s", texto);
b3b2332715fb Tailorization of /trunk
tailor@frmp8452
parents:
diff changeset
400 }
b3b2332715fb Tailorization of /trunk
tailor@frmp8452
parents:
diff changeset
401 }
b3b2332715fb Tailorization of /trunk
tailor@frmp8452
parents:
diff changeset
402 }
b3b2332715fb Tailorization of /trunk
tailor@frmp8452
parents:
diff changeset
403
b3b2332715fb Tailorization of /trunk
tailor@frmp8452
parents:
diff changeset
404 top_panel(tmp->panel);
b3b2332715fb Tailorization of /trunk
tailor@frmp8452
parents:
diff changeset
405 width = scr_WindowHeight(tmp->win);
b3b2332715fb Tailorization of /trunk
tailor@frmp8452
parents:
diff changeset
406 for (n = 0; n < tmp->nlines; n++) {
b3b2332715fb Tailorization of /trunk
tailor@frmp8452
parents:
diff changeset
407 mvwprintw(tmp->win, n + 1, 1, "");
b3b2332715fb Tailorization of /trunk
tailor@frmp8452
parents:
diff changeset
408 for (i = 0; i < width - 2; i++)
b3b2332715fb Tailorization of /trunk
tailor@frmp8452
parents:
diff changeset
409 waddch(tmp->win, ' ');
b3b2332715fb Tailorization of /trunk
tailor@frmp8452
parents:
diff changeset
410 mvwprintw(tmp->win, n + 1, 1, "%s", tmp->texto[n]);
b3b2332715fb Tailorization of /trunk
tailor@frmp8452
parents:
diff changeset
411 }
b3b2332715fb Tailorization of /trunk
tailor@frmp8452
parents:
diff changeset
412
b3b2332715fb Tailorization of /trunk
tailor@frmp8452
parents:
diff changeset
413 update_panels();
b3b2332715fb Tailorization of /trunk
tailor@frmp8452
parents:
diff changeset
414 doupdate();
b3b2332715fb Tailorization of /trunk
tailor@frmp8452
parents:
diff changeset
415 }
b3b2332715fb Tailorization of /trunk
tailor@frmp8452
parents:
diff changeset
416
b3b2332715fb Tailorization of /trunk
tailor@frmp8452
parents:
diff changeset
417 void scr_InitCurses(void)
b3b2332715fb Tailorization of /trunk
tailor@frmp8452
parents:
diff changeset
418 {
b3b2332715fb Tailorization of /trunk
tailor@frmp8452
parents:
diff changeset
419 initscr();
b3b2332715fb Tailorization of /trunk
tailor@frmp8452
parents:
diff changeset
420 noecho();
b3b2332715fb Tailorization of /trunk
tailor@frmp8452
parents:
diff changeset
421 raw();
b3b2332715fb Tailorization of /trunk
tailor@frmp8452
parents:
diff changeset
422 start_color();
b3b2332715fb Tailorization of /trunk
tailor@frmp8452
parents:
diff changeset
423 use_default_colors();
b3b2332715fb Tailorization of /trunk
tailor@frmp8452
parents:
diff changeset
424
b3b2332715fb Tailorization of /trunk
tailor@frmp8452
parents:
diff changeset
425 ParseColors();
b3b2332715fb Tailorization of /trunk
tailor@frmp8452
parents:
diff changeset
426
b3b2332715fb Tailorization of /trunk
tailor@frmp8452
parents:
diff changeset
427 getmaxyx(stdscr, maxY, maxX);
b3b2332715fb Tailorization of /trunk
tailor@frmp8452
parents:
diff changeset
428
b3b2332715fb Tailorization of /trunk
tailor@frmp8452
parents:
diff changeset
429 return;
b3b2332715fb Tailorization of /trunk
tailor@frmp8452
parents:
diff changeset
430 }
b3b2332715fb Tailorization of /trunk
tailor@frmp8452
parents:
diff changeset
431
b3b2332715fb Tailorization of /trunk
tailor@frmp8452
parents:
diff changeset
432 void scr_DrawMainWindow(void)
b3b2332715fb Tailorization of /trunk
tailor@frmp8452
parents:
diff changeset
433 {
b3b2332715fb Tailorization of /trunk
tailor@frmp8452
parents:
diff changeset
434 /* Dibujamos los paneles principales */
b3b2332715fb Tailorization of /trunk
tailor@frmp8452
parents:
diff changeset
435 rosterWnd = newwin(maxY-1, 20, 0, 0);
b3b2332715fb Tailorization of /trunk
tailor@frmp8452
parents:
diff changeset
436 rosterPanel = new_panel(rosterWnd);
b3b2332715fb Tailorization of /trunk
tailor@frmp8452
parents:
diff changeset
437 scr_draw_box(rosterWnd, 0, 0, maxY-1, 20, COLOR_GENERAL, 0, 0);
b3b2332715fb Tailorization of /trunk
tailor@frmp8452
parents:
diff changeset
438 mvwprintw(rosterWnd, 0, (20 - strlen(i18n("Roster"))) / 2,
b3b2332715fb Tailorization of /trunk
tailor@frmp8452
parents:
diff changeset
439 i18n("Roster"));
b3b2332715fb Tailorization of /trunk
tailor@frmp8452
parents:
diff changeset
440
b3b2332715fb Tailorization of /trunk
tailor@frmp8452
parents:
diff changeset
441 chatWnd = newwin(maxY-1, maxX - 20, 0, 20);
b3b2332715fb Tailorization of /trunk
tailor@frmp8452
parents:
diff changeset
442 chatPanel = new_panel(chatWnd);
b3b2332715fb Tailorization of /trunk
tailor@frmp8452
parents:
diff changeset
443 scr_draw_box(chatWnd, 0, 0, maxY-1, maxX - 20, COLOR_GENERAL, 0, 0);
b3b2332715fb Tailorization of /trunk
tailor@frmp8452
parents:
diff changeset
444 mvwprintw(chatWnd, 0,
b3b2332715fb Tailorization of /trunk
tailor@frmp8452
parents:
diff changeset
445 ((maxX - 20) - strlen(i18n("Status Window"))) / 2,
b3b2332715fb Tailorization of /trunk
tailor@frmp8452
parents:
diff changeset
446 i18n("Status Window"));
b3b2332715fb Tailorization of /trunk
tailor@frmp8452
parents:
diff changeset
447
b3b2332715fb Tailorization of /trunk
tailor@frmp8452
parents:
diff changeset
448 bud_DrawRoster(rosterWnd);
b3b2332715fb Tailorization of /trunk
tailor@frmp8452
parents:
diff changeset
449
b3b2332715fb Tailorization of /trunk
tailor@frmp8452
parents:
diff changeset
450 update_panels();
b3b2332715fb Tailorization of /trunk
tailor@frmp8452
parents:
diff changeset
451 doupdate();
b3b2332715fb Tailorization of /trunk
tailor@frmp8452
parents:
diff changeset
452 return;
b3b2332715fb Tailorization of /trunk
tailor@frmp8452
parents:
diff changeset
453 }
b3b2332715fb Tailorization of /trunk
tailor@frmp8452
parents:
diff changeset
454
b3b2332715fb Tailorization of /trunk
tailor@frmp8452
parents:
diff changeset
455 void scr_TerminateCurses(void)
b3b2332715fb Tailorization of /trunk
tailor@frmp8452
parents:
diff changeset
456 {
b3b2332715fb Tailorization of /trunk
tailor@frmp8452
parents:
diff changeset
457 clear();
b3b2332715fb Tailorization of /trunk
tailor@frmp8452
parents:
diff changeset
458 refresh();
b3b2332715fb Tailorization of /trunk
tailor@frmp8452
parents:
diff changeset
459 endwin();
b3b2332715fb Tailorization of /trunk
tailor@frmp8452
parents:
diff changeset
460 return;
b3b2332715fb Tailorization of /trunk
tailor@frmp8452
parents:
diff changeset
461 }
b3b2332715fb Tailorization of /trunk
tailor@frmp8452
parents:
diff changeset
462
b3b2332715fb Tailorization of /trunk
tailor@frmp8452
parents:
diff changeset
463 void scr_WriteIncomingMessage(char *jidfrom, char *text)
b3b2332715fb Tailorization of /trunk
tailor@frmp8452
parents:
diff changeset
464 {
b3b2332715fb Tailorization of /trunk
tailor@frmp8452
parents:
diff changeset
465 char **submsgs;
b3b2332715fb Tailorization of /trunk
tailor@frmp8452
parents:
diff changeset
466 int n, i;
b3b2332715fb Tailorization of /trunk
tailor@frmp8452
parents:
diff changeset
467 char *buffer = (char *) malloc(5 + strlen(text));
b3b2332715fb Tailorization of /trunk
tailor@frmp8452
parents:
diff changeset
468
b3b2332715fb Tailorization of /trunk
tailor@frmp8452
parents:
diff changeset
469 sprintf(buffer, "<<< %s", text);
b3b2332715fb Tailorization of /trunk
tailor@frmp8452
parents:
diff changeset
470
b3b2332715fb Tailorization of /trunk
tailor@frmp8452
parents:
diff changeset
471 submsgs =
b3b2332715fb Tailorization of /trunk
tailor@frmp8452
parents:
diff changeset
472 ut_SplitMessage(buffer, &n, maxX - scr_WindowHeight(rosterWnd) - 20);
b3b2332715fb Tailorization of /trunk
tailor@frmp8452
parents:
diff changeset
473
b3b2332715fb Tailorization of /trunk
tailor@frmp8452
parents:
diff changeset
474 for (i = 0; i < n; i++) {
b3b2332715fb Tailorization of /trunk
tailor@frmp8452
parents:
diff changeset
475 if (i == 0)
b3b2332715fb Tailorization of /trunk
tailor@frmp8452
parents:
diff changeset
476 scr_WriteInWindow(jidfrom, submsgs[i], TRUE);
b3b2332715fb Tailorization of /trunk
tailor@frmp8452
parents:
diff changeset
477 else
b3b2332715fb Tailorization of /trunk
tailor@frmp8452
parents:
diff changeset
478 scr_WriteInWindow(jidfrom, submsgs[i], FALSE);
b3b2332715fb Tailorization of /trunk
tailor@frmp8452
parents:
diff changeset
479 }
b3b2332715fb Tailorization of /trunk
tailor@frmp8452
parents:
diff changeset
480
b3b2332715fb Tailorization of /trunk
tailor@frmp8452
parents:
diff changeset
481 for (i = 0; i < n; i++)
b3b2332715fb Tailorization of /trunk
tailor@frmp8452
parents:
diff changeset
482 free(submsgs[i]);
b3b2332715fb Tailorization of /trunk
tailor@frmp8452
parents:
diff changeset
483
b3b2332715fb Tailorization of /trunk
tailor@frmp8452
parents:
diff changeset
484 free(submsgs);
b3b2332715fb Tailorization of /trunk
tailor@frmp8452
parents:
diff changeset
485 free(buffer);
b3b2332715fb Tailorization of /trunk
tailor@frmp8452
parents:
diff changeset
486
b3b2332715fb Tailorization of /trunk
tailor@frmp8452
parents:
diff changeset
487 }
b3b2332715fb Tailorization of /trunk
tailor@frmp8452
parents:
diff changeset
488
b3b2332715fb Tailorization of /trunk
tailor@frmp8452
parents:
diff changeset
489 void scr_WriteMessage(int sock)
b3b2332715fb Tailorization of /trunk
tailor@frmp8452
parents:
diff changeset
490 {
b3b2332715fb Tailorization of /trunk
tailor@frmp8452
parents:
diff changeset
491 char **submsgs;
b3b2332715fb Tailorization of /trunk
tailor@frmp8452
parents:
diff changeset
492 int n, i;
b3b2332715fb Tailorization of /trunk
tailor@frmp8452
parents:
diff changeset
493 char *buffer = (char *) calloc(1, 1024);
b3b2332715fb Tailorization of /trunk
tailor@frmp8452
parents:
diff changeset
494 char *buffer2 = (char *) calloc(1, 1024);
b3b2332715fb Tailorization of /trunk
tailor@frmp8452
parents:
diff changeset
495 buddy_entry_t *tmp = bud_SelectedInfo();
b3b2332715fb Tailorization of /trunk
tailor@frmp8452
parents:
diff changeset
496
b3b2332715fb Tailorization of /trunk
tailor@frmp8452
parents:
diff changeset
497 scr_ShowWindow(tmp->jid);
b3b2332715fb Tailorization of /trunk
tailor@frmp8452
parents:
diff changeset
498
b3b2332715fb Tailorization of /trunk
tailor@frmp8452
parents:
diff changeset
499 ut_CenterMessage(i18n("write your message here"), 60, buffer2);
b3b2332715fb Tailorization of /trunk
tailor@frmp8452
parents:
diff changeset
500
b3b2332715fb Tailorization of /trunk
tailor@frmp8452
parents:
diff changeset
501 scr_CreatePopup(tmp->jid, buffer2, 60, 1, buffer);
b3b2332715fb Tailorization of /trunk
tailor@frmp8452
parents:
diff changeset
502
b3b2332715fb Tailorization of /trunk
tailor@frmp8452
parents:
diff changeset
503 if (strlen(buffer)) {
b3b2332715fb Tailorization of /trunk
tailor@frmp8452
parents:
diff changeset
504 sprintf(buffer2, ">>> %s", buffer);
b3b2332715fb Tailorization of /trunk
tailor@frmp8452
parents:
diff changeset
505
b3b2332715fb Tailorization of /trunk
tailor@frmp8452
parents:
diff changeset
506 submsgs =
b3b2332715fb Tailorization of /trunk
tailor@frmp8452
parents:
diff changeset
507 ut_SplitMessage(buffer2, &n,
b3b2332715fb Tailorization of /trunk
tailor@frmp8452
parents:
diff changeset
508 maxX - scr_WindowHeight(rosterWnd) - 20);
b3b2332715fb Tailorization of /trunk
tailor@frmp8452
parents:
diff changeset
509 for (i = 0; i < n; i++) {
b3b2332715fb Tailorization of /trunk
tailor@frmp8452
parents:
diff changeset
510 if (i == 0)
b3b2332715fb Tailorization of /trunk
tailor@frmp8452
parents:
diff changeset
511 scr_WriteInWindow(tmp->jid, submsgs[i], TRUE);
b3b2332715fb Tailorization of /trunk
tailor@frmp8452
parents:
diff changeset
512 else
b3b2332715fb Tailorization of /trunk
tailor@frmp8452
parents:
diff changeset
513 scr_WriteInWindow(tmp->jid, submsgs[i], FALSE);
b3b2332715fb Tailorization of /trunk
tailor@frmp8452
parents:
diff changeset
514 }
b3b2332715fb Tailorization of /trunk
tailor@frmp8452
parents:
diff changeset
515
b3b2332715fb Tailorization of /trunk
tailor@frmp8452
parents:
diff changeset
516 for (i = 0; i < n; i++)
b3b2332715fb Tailorization of /trunk
tailor@frmp8452
parents:
diff changeset
517 free(submsgs[i]);
b3b2332715fb Tailorization of /trunk
tailor@frmp8452
parents:
diff changeset
518 free(submsgs);
b3b2332715fb Tailorization of /trunk
tailor@frmp8452
parents:
diff changeset
519
b3b2332715fb Tailorization of /trunk
tailor@frmp8452
parents:
diff changeset
520 move(maxY - 2, maxX - 1);
b3b2332715fb Tailorization of /trunk
tailor@frmp8452
parents:
diff changeset
521 refresh();
b3b2332715fb Tailorization of /trunk
tailor@frmp8452
parents:
diff changeset
522 sprintf(buffer2, "%s@%s/%s", cfg_read("username"),
b3b2332715fb Tailorization of /trunk
tailor@frmp8452
parents:
diff changeset
523 cfg_read("server"), cfg_read("resource"));
b3b2332715fb Tailorization of /trunk
tailor@frmp8452
parents:
diff changeset
524 srv_sendtext(sock, tmp->jid, buffer, buffer2);
b3b2332715fb Tailorization of /trunk
tailor@frmp8452
parents:
diff changeset
525 }
b3b2332715fb Tailorization of /trunk
tailor@frmp8452
parents:
diff changeset
526 free(buffer);
b3b2332715fb Tailorization of /trunk
tailor@frmp8452
parents:
diff changeset
527 free(buffer2);
b3b2332715fb Tailorization of /trunk
tailor@frmp8452
parents:
diff changeset
528 }
b3b2332715fb Tailorization of /trunk
tailor@frmp8452
parents:
diff changeset
529
b3b2332715fb Tailorization of /trunk
tailor@frmp8452
parents:
diff changeset
530 int scr_Getch(void)
b3b2332715fb Tailorization of /trunk
tailor@frmp8452
parents:
diff changeset
531 {
b3b2332715fb Tailorization of /trunk
tailor@frmp8452
parents:
diff changeset
532 int ch;
b3b2332715fb Tailorization of /trunk
tailor@frmp8452
parents:
diff changeset
533 keypad(rosterWnd, TRUE);
b3b2332715fb Tailorization of /trunk
tailor@frmp8452
parents:
diff changeset
534 ch = wgetch(rosterWnd);
b3b2332715fb Tailorization of /trunk
tailor@frmp8452
parents:
diff changeset
535 return ch;
b3b2332715fb Tailorization of /trunk
tailor@frmp8452
parents:
diff changeset
536 }
b3b2332715fb Tailorization of /trunk
tailor@frmp8452
parents:
diff changeset
537
b3b2332715fb Tailorization of /trunk
tailor@frmp8452
parents:
diff changeset
538 WINDOW *scr_GetRosterWindow(void)
b3b2332715fb Tailorization of /trunk
tailor@frmp8452
parents:
diff changeset
539 {
b3b2332715fb Tailorization of /trunk
tailor@frmp8452
parents:
diff changeset
540 return rosterWnd;
b3b2332715fb Tailorization of /trunk
tailor@frmp8452
parents:
diff changeset
541 }
b3b2332715fb Tailorization of /trunk
tailor@frmp8452
parents:
diff changeset
542
b3b2332715fb Tailorization of /trunk
tailor@frmp8452
parents:
diff changeset
543 WINDOW *scr_GetStatusWindow(void)
b3b2332715fb Tailorization of /trunk
tailor@frmp8452
parents:
diff changeset
544 {
b3b2332715fb Tailorization of /trunk
tailor@frmp8452
parents:
diff changeset
545 return chatWnd;
b3b2332715fb Tailorization of /trunk
tailor@frmp8452
parents:
diff changeset
546 }