ViewVC Help
View File | Revision Log | Show Annotations | Download File
/cvs/rxvt-unicode/src/menubar.C
(Generate patch)

Comparing rxvt-unicode/src/menubar.C (file contents):
Revision 1.29 by root, Tue Jan 3 02:43:33 2006 UTC vs.
Revision 1.30 by root, Wed Jan 4 04:42:45 2006 UTC

35#define Menu_PixelWidth(menu) \ 35#define Menu_PixelWidth(menu) \
36 (2 * MENU_SHADOW + Width2Pixel ((menu)->width + 3 * HSPACE)) 36 (2 * MENU_SHADOW + Width2Pixel ((menu)->width + 3 * HSPACE))
37 37
38static const struct 38static const struct
39 { 39 {
40 const char name; /* (l)eft, (u)p, (d)own, (r)ight */ 40 const char name; /* (l)eft, (u)p, (d)own, (r)ight */
41 const unsigned char str[5]; /* str[0] = strlen (str+1) */ 41 const char str[5]; /* str[0] = strlen (str+1) */
42 } 42 }
43Arrows[NARROWS] = { 43Arrows[NARROWS] = {
44 { 'l', "\003\033[D" }, 44 { 'l', "\003\033[D" },
45 { 'u', "\003\033[A" }, 45 { 'u', "\003\033[A" },
46 { 'd', "\003\033[B" }, 46 { 'd', "\003\033[B" },
147/* 147/*
148 * sort command vs. terminal actions and 148 * sort command vs. terminal actions and
149 * remove the first character of STR if it's '\0' 149 * remove the first character of STR if it's '\0'
150 */ 150 */
151int 151int
152rxvt_action_type (action_t *action, unsigned char *str) 152rxvt_action_type (action_t *action, char *str)
153{ 153{
154 unsigned int len; 154 unsigned int len;
155 155
156#if defined (DEBUG_MENU) || defined (DEBUG_MENUARROWS) 156#if defined (DEBUG_MENU) || defined (DEBUG_MENUARROWS)
157 len = strlen (str); 157 len = strlen (str);
166 /* sort command vs. terminal actions */ 166 /* sort command vs. terminal actions */
167 action->type = MenuAction; 167 action->type = MenuAction;
168 if (str[0] == '\0') 168 if (str[0] == '\0')
169 { 169 {
170 /* the functional equivalent: memmove (str, str+1, len); */ 170 /* the functional equivalent: memmove (str, str+1, len); */
171 unsigned char *dst = (str); 171 char *dst = (str);
172 unsigned char *src = (str + 1); 172 char *src = (str + 1);
173 unsigned char *end = (str + len); 173 char *end = (str + len);
174 174
175 while (src <= end) 175 while (src <= end)
176 *dst++ = *src++; 176 *dst++ = *src++;
177 177
178 len--; /* decrement length */ 178 len--; /* decrement length */
179 if (str[0] != '\0') 179 if (str[0] != '\0')
180 action->type = MenuTerminalAction; 180 action->type = MenuTerminalAction;
181 } 181 }
182
182 action->str = str; 183 action->str = str;
183 action->len = len; 184 action->len = len;
184 185
185 return 0; 186 return 0;
186} 187}
349 menuarrow_free (Arrows[i].name); 350 menuarrow_free (Arrows[i].name);
350 } 351 }
351 352
352 for (i = 0; i < NARROWS; i++) 353 for (i = 0; i < NARROWS; i++)
353 { 354 {
354 unsigned char *str; 355 char *str;
355 unsigned int len; 356 unsigned int len;
356 357
357 if (!parse[i].len) 358 if (!parse[i].len)
358 continue; 359 continue;
359 360
360 str = (unsigned char *) rxvt_malloc (parse[i].len + xtra_len + 1); 361 str = (char *)rxvt_malloc (parse[i].len + xtra_len + 1);
361 362
362 len = 0; 363 len = 0;
363 if (beg.len) 364 if (beg.len)
364 { 365 {
365 strncpy (str + len, beg.str, beg.len); 366 strncpy (str + len, beg.str, beg.len);
476 action = item->name2; 477 action = item->name2;
477 len = item->len2; 478 len = item->len2;
478 } 479 }
479 if (len) 480 if (len)
480 { 481 {
481 unsigned char *str = (unsigned char *)rxvt_malloc (len + 1); 482 char *str = (char *)rxvt_malloc (len + 1);
482 483
483 strcpy (str, action); 484 strcpy (str, action);
484 485
485 if (rxvt_action_type (& (item->entry.action), str) < 0) 486 if (rxvt_action_type (& (item->entry.action), str) < 0)
486 free (str); 487 free (str);
756 x = Width2Pixel (x); 757 x = Width2Pixel (x);
757 len = Width2Pixel (len + HSPACE); 758 len = Width2Pixel (len + HSPACE);
758 if (x >= width) 759 if (x >= width)
759 return; 760 return;
760 else if (x + len >= width) 761 else if (x + len >= width)
761 len = (TermWin_TotalWidth () - x); 762 len = (this->width - x);
762 763
763#ifdef MENUBAR_SHADOW_IN 764#ifdef MENUBAR_SHADOW_IN
764 state = -state; 765 state = -state;
765#endif 766#endif
766 switch (state) 767 switch (state)
943 944
944 ActiveMenu->y = 1; 945 ActiveMenu->y = 1;
945 ActiveMenu->w = Menu_PixelWidth (ActiveMenu); 946 ActiveMenu->w = Menu_PixelWidth (ActiveMenu);
946 947
947 if ((x + ActiveMenu->w) >= width) 948 if ((x + ActiveMenu->w) >= width)
948 x = (TermWin_TotalWidth () - ActiveMenu->w); 949 x = (this->width - ActiveMenu->w);
949 950
950 /* find the height */ 951 /* find the height */
951 for (h = 0, item = ActiveMenu->head; item != NULL; item = item->next) 952 for (h = 0, item = ActiveMenu->head; item != NULL; item = item->next)
952 h += isSeparator (item->name) ? HEIGHT_SEPARATOR 953 h += isSeparator (item->name) ? HEIGHT_SEPARATOR
953 : HEIGHT_TEXT + 2 * MENU_SHADOW; 954 : HEIGHT_TEXT + 2 * MENU_SHADOW;
1023 : HEIGHT_TEXT + 2 * MENU_SHADOW; 1024 : HEIGHT_TEXT + 2 * MENU_SHADOW;
1024 menu->h = h + 2 * MENU_SHADOW; 1025 menu->h = h + 2 * MENU_SHADOW;
1025 1026
1026 /* ensure menu is in window limits */ 1027 /* ensure menu is in window limits */
1027 if ((x1 + menu->w) >= width) 1028 if ((x1 + menu->w) >= width)
1028 x1 = (TermWin_TotalWidth () - menu->w); 1029 x1 = (this->width - menu->w);
1029 1030
1030 if ((y1 + menu->h) >= height) 1031 if ((y1 + menu->h) >= height)
1031 y1 = (TermWin_TotalHeight () - menu->h); 1032 y1 = (this->height - menu->h);
1032 1033
1033 menu->x = (x1 < 0 ? 0 : x1); 1034 menu->x = (x1 < 0 ? 0 : x1);
1034 menu->y = (y1 < 0 ? 0 : y1); 1035 menu->y = (y1 < 0 ? 0 : y1);
1035 } 1036 }
1036 else if (item->name2 && !strcmp (name, item->name2)) 1037 else if (item->name2 && !strcmp (name, item->name2))
1282} 1283}
1283 1284
1284void 1285void
1285rxvt_action_decode (FILE *fp, action_t *act) 1286rxvt_action_decode (FILE *fp, action_t *act)
1286{ 1287{
1287 unsigned char *str; 1288 char *str;
1288 short len; 1289 short len;
1289 1290
1290 if (act == NULL || (len = act->len) == 0 || (str = act->str) == NULL) 1291 if (act == NULL || (len = act->len) == 0 || (str = act->str) == NULL)
1291 return; 1292 return;
1292 1293
1325 * have to be escaped to avoid Shell (or whatever scripting 1326 * have to be escaped to avoid Shell (or whatever scripting
1326 * language) interpretation 1327 * language) interpretation
1327 */ 1328 */
1328 while (len > 0) 1329 while (len > 0)
1329 { 1330 {
1330 unsigned char ch = *str++; 1331 char ch = *str++;
1331 1332
1332 switch (ch) 1333 switch (ch)
1333 { 1334 {
1334 case C0_ESC: 1335 case C0_ESC:
1335 fprintf (fp, "\\E"); 1336 fprintf (fp, "\\E");
1346 case 127: 1347 case 127:
1347 fprintf (fp, "^?"); 1348 fprintf (fp, "^?");
1348 default: 1349 default:
1349 if (ch <= 31) 1350 if (ch <= 31)
1350 fprintf (fp, "^%c", ('@' + ch)); 1351 fprintf (fp, "^%c", ('@' + ch));
1351 else if (ch > 127) 1352 else if ((unsigned char)ch > 127)
1352 fprintf (fp, "\\%o", ch); 1353 fprintf (fp, "\\%o", ch);
1353 else 1354 else
1354 fprintf (fp, "%c", ch); 1355 fprintf (fp, "%c", ch);
1355 break; 1356 break;
1356 } 1357 }

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines