1 /* 2 * This program is free software; you can redistribute it and/or modify 3 * it under the terms of the GNU General Public License as published by 4 * the Free Software Foundation; either version 2 of the License, or 5 * (at your option) any later version. 6 * 7 * This program is distributed in the hope that it will be useful, 8 * but WITHOUT ANY WARRANTY; without even the implied warranty of 9 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 10 * GNU Library General Public License for more details. 11 * 12 * You should have received a copy of the GNU General Public License 13 * along with this program; if not, write to the Free Software 14 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. 15 */ 16 17 18 /* 19 * $Id: rxvt.h,v 1.17 2004/08/15 16:11:00 alexis Exp $ 20 */ 21 22 #ifndef _RXVT_H /* include once only */ 23 #define _RXVT_H 24 25 //#include "version.h" 26 #include "../config.h" 27 #include "feature.h" 28 29 /* 30 ***************************************************************************** 31 * SYSTEM HACKS 32 ***************************************************************************** 33 */ 34 /* Consistent defines - please report on the necessity 35 * @ Unixware: defines (__svr4__) 36 */ 37 #if defined (SVR4) && !defined (__svr4__) 38 # define __svr4__ 39 #endif 40 #if defined (sun) && !defined (__sun__) 41 # define __sun__ 42 #endif 43 44 #if defined (__sun__) 45 #include <sys/int_types.h> 46 #endif 47 48 /* 49 * sun <sys/ioctl.h> isn't properly protected? 50 * anyway, it causes problems when <termios.h> is also included 51 */ 52 #if defined (__sun__) 53 # undef HAVE_SYS_IOCTL_H 54 #endif 55 56 /* 57 * Solaris defines SRIOCSREDIR in sys/strredir.h . 58 * Needed for displaying console messages under solaris 59 */ 60 #if defined(__sun) && defined(__SVR4) 61 #include <sys/strredir.h> 62 #endif 63 64 #ifdef _SCO_DS /* SCO Osr5 - Hops */ 65 /* Scos pty naming is /dev/[pt]typ0 - /dev/[pt]ty256 */ 66 # define ALL_NUMERIC_PTYS 67 #endif 68 69 /* 70 ***************************************************************************** 71 * INCLUDES 72 ***************************************************************************** 73 */ 74 75 #include <stdio.h> 76 #include <ctype.h> 77 #include <errno.h> 78 #include <signal.h> 79 80 #ifdef STDC_HEADERS 81 # include <stdarg.h> 82 #endif 83 84 #ifdef HAVE_STDLIB_H 85 # include <stdlib.h> 86 #endif 87 88 #ifdef HAVE_STRING_H 89 # include <string.h> 90 #endif 91 92 #ifdef HAVE_FCNTL_H 93 # include <fcntl.h> 94 #endif 95 96 #ifdef HAVE_SYS_TYPES_H 97 # include <sys/types.h> 98 #endif 99 100 #ifdef HAVE_UNISTD_H 101 # include <unistd.h> 102 #endif 103 104 #ifdef HAVE_UTIL_H 105 # include <util.h> 106 #endif 107 108 #ifdef HAVE_ASSERT_H 109 # include <assert.h> 110 #endif 111 112 #if defined (HAVE_SYS_IOCTL_H) && !defined (__sun__) 113 /* seems to cause problems when <termios.h> is also included on some suns */ 114 # include <sys/ioctl.h> 115 #endif 116 117 #ifdef TIME_WITH_SYS_TIME 118 # include <sys/time.h> 119 # include <time.h> 120 #else 121 # ifdef HAVE_SYS_TIME_H 122 # include <sys/time.h> 123 # else 124 # include <time.h> 125 # endif 126 #endif 127 128 #ifdef HAVE_SYS_SELECT_H 129 # include <sys/select.h> 130 #endif 131 132 #ifdef HAVE_TERMIOS_H 133 # include <termios.h> 134 #else 135 # include <sgtty.h> 136 #endif 137 138 #ifdef UTMP_SUPPORT 139 # ifdef HAVE_UTMPX_H 140 # include <utmpx.h> 141 # define USE_SYSV_UTMP 142 # else 143 # include <utmp.h> 144 # ifdef HAVE_SETUTENT 145 # define USE_SYSV_UTMP 146 # endif 147 # endif 148 # ifdef HAVE_LASTLOG_H 149 # include <lastlog.h> 150 # endif 151 # include <pwd.h> 152 #endif 153 154 #include <sys/wait.h> 155 #include <sys/stat.h> 156 157 #include <X11/Intrinsic.h> /* Xlib, Xutil, Xresource, Xfuncproto */ 158 #include <X11/cursorfont.h> 159 #include <X11/keysym.h> 160 161 #include "libafterstep.h" 162 163 #ifdef DEBUG_X 164 #define XGetGeometry(dpy,win,r,x,y,w,h,b,d) \ 165 trace_XGetGeometry(__FILE__,__LINE__,dpy,win,r,x,y,w,h,b,d) 166 #endif 167 168 #ifdef GREEK_SUPPORT 169 # include "grkelot.h" 170 #endif 171 172 #if defined(KANJI) || defined(ZH) 173 # define MULTICHAR_SET /* a glyph is defined by 1 or 2 chars */ 174 #else 175 # undef MULTICHAR_SET /* a glyph is only ever defined by 1 char */ 176 #endif 177 178 /* 179 * Play some size tricks: <X11/Xmd.h> might be better 180 * Now if only we could presume every OS has int16_t, u_int16_t, etc. 181 */ 182 typedef RINT16T R_int16_t; 183 typedef RUINT16T R_u_int16_t; 184 typedef RINT32T R_int32_t; 185 typedef RUINT32T R_u_int32_t; 186 typedef RINTPT R_int_p_t; 187 typedef RUINTPT R_u_int_p_t; 188 189 /* 190 ***************************************************************************** 191 * STRUCTURES AND TYPEDEFS 192 ***************************************************************************** 193 */ 194 /* Sanitize menubar info */ 195 #ifndef MENUBAR 196 # undef MENUBAR_MAX 197 #endif 198 #ifndef MENUBAR_MAX 199 # define MENUBAR_MAX 0 200 #endif 201 202 /* If we're using either the fancy scrollbar or menu bars, keep the 203 * scrollColor resource. 204 */ 205 #if !defined(XTERM_SCROLLBAR) || defined(MENUBAR) 206 # define KEEP_SCROLLCOLOR 1 207 #else 208 # undef KEEP_SCROLLCOLOR 209 #endif 210 211 #if defined(BACKGROUND_IMAGE) || defined(TRANSPARENT) || defined(_MYSTYLE_) 212 213 typedef struct ShadingInfo{ 214 XColor tintColor ; 215 int shading ; 216 int tint_color; 217 } ShadingInfo; 218 219 #define NO_NEED_TO_SHADE(o) (o.shading==100 && o.tintColor.red==0xFFFF && o.tintColor.green==0xFFFF && o.tintColor.blue == 0xFFFF) 220 #define INIT_SHADING(o) {o.shading=100; o.tintColor.red=0xFFFF; o.tintColor.green=0xFFFF; o.tintColor.blue = 0xFFFF;} 221 struct MyStyle; 222 223 typedef struct _BackroundInfo { 224 Pixmap srcPixmap; /* after it was clipped out according to stuff below*/ 225 /* x,y,width and height of the subimage to be clipped out of 226 the specifyed image and used as background */ 227 struct MyStyle *mystyle ; 228 unsigned int user_flags ; 229 int srcWidth, srcHeight, srcX, srcY ; 230 int Width, Height ; /* width and height of the loaded pixmap */ 231 int bMySource;/* indicates if src pixmap was loaded by us 232 and needs to be freed */ 233 #define BGT_TILE "tile" 234 #define BGT_CENTER "center" 235 #define BGT_SCALE "scale" 236 #define BGT_SCALEH "scaleh" 237 #define BGT_SCALEV "scalev" 238 #define BGT_NO_TILE "notile" 239 #define BGT_NO_TILE_H "notileh" 240 #define BGT_NO_TILE_V "notilev" 241 #define BGT_CUT "cut" 242 #define BGT_ALL "tile|center|scale|scaleh|scalev|notile|notileh|notilev|cut" 243 enum { BGT_Tile = 1, 244 BGT_Center, 245 BGT_Scale, 246 BGT_ScaleH, 247 BGT_ScaleV, 248 BGT_NoTile, 249 BGT_NoTileH, 250 BGT_NoTileV, 251 BGT_Cut, 252 #ifdef _MYSTYLE_ 253 BGT_MyStyle, 254 #endif 255 BGT_None } trgType; 256 257 258 259 Pixmap trgPixmap; 260 int trgPixmapSet; 261 #ifdef SCALING_GEOM_ENABLED 262 /* requested x,y,width and height of the target pixmap */ 263 int trgWidth, trgHeight, trgX, trgY ; 264 #endif 265 /* final width and height of constructed pixmap */ 266 int finWidth, finHeight ; 267 int cutX, cutY ; 268 ShadingInfo Shading; 269 char *color; /* shading color */ 270 unsigned long int transparent; /* transparency flag */ 271 char *pixmap_file; 272 //char *bg_type; 273 274 } BackgroundInfo; 275 #endif 276 277 /* une fenetre vt */ 278 typedef struct { 279 R_int16_t nscrolled,view_start; 280 /* number of line actually scrolled 281 * endroit a partir d'ou on voit les lignes 282 */ 283 R_int16_t saveLines; /* nbr de lignes qui sont dans le scroll-back */ 284 R_int16_t bcol,min_bcol; 285 // R_int16_t focus; // la fenetre a-t-elle le focus ? 286 Window vt; 287 #if defined(BACKGROUND_IMAGE) || defined(TRANSPARENT) || defined(_MYSTYLE_) 288 GC tintGC; 289 Pixmap LastPixmapUsed ; 290 BackgroundInfo bg; 291 #endif 292 GC gc; 293 int bMapped; // indique si la fenetre vt est mappe ou non 294 char *tab_title; 295 296 } vt_t; 297 298 extern int thumb_padding; 299 // espace entre le haut de la top window et la vt window 300 #define THUMB_BASE 23 301 #ifdef DRAW_THUMBBAR 302 #define TOP_SPACE (THUMB_BASE + thumb_padding) 303 #else 304 #define TOP_SPACE (THUMB_BASE + thumb_padding) 305 #endif 306 #define TITLE_TAB_MAX 20 307 308 typedef struct { 309 R_int16_t width; /* window width [pixels] */ 310 R_int16_t height; /* window height [pixels] */ 311 R_int16_t fwidth; /* font width [pixels] */ 312 R_int16_t fheight; /* font height [pixels] */ 313 R_int16_t fprop; /* font is proportional */ 314 R_int16_t ncol, nrow; /* window size [characters] */ 315 R_int16_t focus; /* window has focus */ 316 R_int16_t borderWidth;/* number of pixels in window border */ 317 Window parent; 318 XFontStruct *font; /* main font structure */ 319 #ifndef NO_BOLDFONT 320 XFontStruct *boldFont; /* bold font */ 321 #endif 322 #ifdef MULTICHAR_SET 323 XFontStruct *mfont; /* Multichar font structure */ 324 #endif 325 326 #define GC_TYPE_AND "and" 327 #define GC_TYPE_AND_REV "andReverse" 328 #define GC_TYPE_AND_INV "andInverted" 329 #define GC_TYPE_XOR "xor" 330 #define GC_TYPE_OR "or" 331 #define GC_TYPE_NOR "nor" 332 #define GC_TYPE_INVERT "invert" 333 #define GC_TYPE_EQUIV "equiv" 334 #define GC_TYPE_INVERT "invert" 335 #define GC_TYPE_OR_REV "orReverse" 336 #define GC_TYPE_OR_INV "orInverted" 337 #define GC_TYPE_NAND "nand" 338 #define GC_TYPE_ALL "and|andReverse|andInverted|xor|or|nor|invert|equiv|invert|orReverse|orInverted|nand" 339 #define TINT_TYPE_TRUE "true" 340 #define TINT_TYPE_ALL "true|and|andReverse|andInverted|xor|or|nor|invert|equiv|invert|orReverse|orInverted|nand" 341 #ifdef DRAW_THUMBBAR 342 Window thumb_bar; // lonely window for tabs and pixmap 343 GC thumbGC; // the GC for the thum_bar 344 #endif 345 vt_t vts[MAX_PAGES]; 346 short last_page; // index de la derniere page 347 short active_page; // idx de la page active -> celle qui est visible 348 short last_active_page; 349 short left_page,right_page; // l'index de la page visible la + a gauche/droite 350 } TermWin_t; 351 352 353 typedef struct { 354 short beg, end; /* beg/end of slider sub-window */ 355 short top, bot; /* top/bot of slider */ 356 short state; /* scrollbar state */ 357 Window win; 358 } scrollBar_t; 359 360 typedef struct { 361 short state; 362 Window win; 363 } menuBar_t; 364 365 typedef struct { 366 short type; /* must not be changed; first element */ 367 short len; /* strlen (str) */ 368 unsigned char *str; /* action to take */ 369 } action_t; 370 371 typedef struct { 372 short type; /* must not be changed; first element */ 373 struct menu_t *menu; /* sub-menu */ 374 } submenu_t; 375 376 typedef struct menuitem_t { 377 struct menuitem_t *prev; /* prev menu-item */ 378 struct menuitem_t *next; /* next menu-item */ 379 char *name; /* character string displayed */ 380 char *name2; /* character string displayed (right) */ 381 short len; /* strlen (name) */ 382 short len2; /* strlen (name) */ 383 union { 384 short type; /* must not be changed; first element */ 385 action_t action; 386 submenu_t submenu; 387 } entry; 388 } menuitem_t; 389 390 enum menuitem_t_action { 391 MenuLabel, 392 MenuAction, 393 MenuTerminalAction, 394 MenuSubMenu 395 }; 396 397 typedef struct menu_t { 398 struct menu_t *parent; /* parent menu */ 399 struct menu_t *prev; /* prev menu */ 400 struct menu_t *next; /* next menu */ 401 menuitem_t *head; /* double-linked list */ 402 menuitem_t *tail; /* double-linked list */ 403 menuitem_t *item; /* current item */ 404 char *name; /* menu name */ 405 short len; /* strlen (name) */ 406 short width; /* maximum menu width [chars] */ 407 Window win; /* window of the menu */ 408 short x; /* x location [pixels] (chars if parent == NULL) */ 409 short y; /* y location [pixels] */ 410 short w, h; /* window width, height [pixels] */ 411 } menu_t; 412 413 typedef struct bar_t { 414 menu_t *head, *tail; /* double-linked list of menus */ 415 char *title; /* title to put in the empty menuBar */ 416 #if (MENUBAR_MAX > 1) 417 # define MAXNAME 16 418 char name[MAXNAME]; /* name to use to refer to menubar */ 419 struct bar_t *next, *prev; /* circular linked-list */ 420 #endif /* (MENUBAR_MAX > 1) */ 421 #define NARROWS 4 422 action_t arrows[NARROWS]; 423 } bar_t; 424 425 typedef struct grcmd_t { 426 char cmd; 427 short color; 428 short ncoords; 429 int *coords; 430 unsigned char *text; 431 struct grcmd_t *next; 432 } grcmd_t; 433 434 typedef struct grwin_t { 435 Window win; 436 int x, y; 437 unsigned int w, h; 438 short screen; 439 grcmd_t *graphics; 440 struct grwin_t *prev, *next; 441 } grwin_t; 442 443 typedef struct { 444 R_int16_t row, col; 445 } row_col_t; 446 447 448 /* ways to deal with getting/setting termios structure */ 449 #ifdef HAVE_TERMIOS_H 450 typedef struct termios ttymode_t; 451 452 # ifdef TCSANOW /* POSIX */ 453 # define GET_TERMIOS(fd,tios) tcgetattr (fd, tios) 454 # define SET_TERMIOS(fd,tios) \ 455 cfsetospeed (tios, BAUDRATE), \ 456 cfsetispeed (tios, BAUDRATE), \ 457 tcsetattr (fd, TCSANOW, tios) 458 # else 459 # ifdef TIOCSETA 460 # define GET_TERMIOS(fd,tios) ioctl (fd, TIOCGETA, tios) 461 # define SET_TERMIOS(fd,tios) \ 462 tios->c_cflag |= BAUDRATE, \ 463 ioctl (fd, TIOCSETA, tios) 464 # else 465 # define GET_TERMIOS(fd,tios) ioctl (fd, TCGETS, tios) 466 # define SET_TERMIOS(fd,tios) \ 467 tios->c_cflag |= BAUDRATE, \ 468 ioctl (fd, TCSETS, tios) 469 # endif 470 # endif 471 # define SET_TTYMODE(fd,tios) SET_TERMIOS (fd, tios) 472 #else 473 /* sgtty interface */ 474 typedef struct { 475 struct sgttyb sg; 476 struct tchars tc; 477 struct ltchars lc; 478 int line; 479 int local; 480 } ttymode_t; 481 482 # define SET_TTYMODE(fd,tt) \ 483 tt->sg.sg_ispeed = tt->sg.sg_ospeed = BAUDRATE, \ 484 ioctl (fd, TIOCSETP, &(tt->sg)), \ 485 ioctl (fd, TIOCSETC, &(tt->tc)), \ 486 ioctl (fd, TIOCSLTC, &(tt->lc)), \ 487 ioctl (fd, TIOCSETD, &(tt->line)), \ 488 ioctl (fd, TIOCLSET, &(tt->local)) 489 #endif /* HAVE_TERMIOS_H */ 490 491 #ifndef min 492 # define min(a,b) (((a) < (b)) ? (a) : (b)) 493 # define max(a,b) (((a) > (b)) ? (a) : (b)) 494 #endif 495 496 #define MAX_IT(current, other) if ((other) > (current)) (current) = (other) 497 #define MIN_IT(current, other) if ((other) < (current)) (current) = (other) 498 #define SWAP_IT(one, two, tmp) \ 499 do { \ 500 (tmp) = (one); (one) = (two); (two) = (tmp); \ 501 } while (0) 502 503 /* 504 ***************************************************************************** 505 * NORMAL DEFINES 506 ***************************************************************************** 507 */ 508 509 #ifdef OLD_SELECTION 510 # define OLD_WORD_SELECTION 511 #endif 512 513 /* sort out conflicts in feature.h */ 514 #ifdef KANJI 515 # undef ZH /* remove Chinese big5 support */ 516 # undef GREEK_SUPPORT /* Kanji/Greek together is too weird */ 517 # undef DEFINE_XTERM_COLOR /* since kterm-color doesn't exist? */ 518 #endif 519 520 #ifdef ZH 521 # undef KANJI /* can't put Chinese/Kanji together */ 522 # undef GREEK_SUPPORT 523 # undef DEFINE_XTERM_COLOR 524 #endif 525 526 #define APL_CLASS "XTerm" /* class name */ 527 #define APL_SUBCLASS "Aterm" /* also check resources under this name */ 528 #define APL_NAME "materm" /* normal name */ 529 #define DATE "11 nov 2003" 530 531 /* COLORTERM, TERM environment variables */ 532 #define COLORTERMENV "rxvt" 533 #ifdef BACKGROUND_IMAGE 534 # define COLORTERMENVFULL COLORTERMENV "-xpm" 535 #else 536 # define COLORTERMENVFULL COLORTERMENV 537 #endif 538 #ifndef TERMENV 539 # ifdef KANJI 540 # define TERMENV "kterm" 541 # else 542 # define TERMENV "rxvt" 543 # endif 544 #endif 545 546 #if defined (NO_MOUSE_REPORT) && !defined (NO_MOUSE_REPORT_SCROLLBAR) 547 # define NO_MOUSE_REPORT_SCROLLBAR 548 #endif 549 550 #ifdef NO_RESOURCES 551 # undef USE_XGETDEFAULT 552 #endif 553 554 /* now look for other badly set stuff */ 555 #ifdef UTMP_SUPPORT 556 #include <utmp.h> 557 #endif 558 559 #ifdef UTMP_SUPPORT 560 # ifndef UTMP_FILENAME 561 # ifdef UTMP_FILE 562 # define UTMP_FILENAME UTMP_FILE 563 # else 564 # ifdef _PATH_UTMP 565 # define UTMP_FILENAME _PATH_UTMP 566 # else 567 # ifdef RXVT_UTMP_FILE 568 # define UTMP_FILENAME RXVT_UTMP_FILE 569 # else 570 # define UTMP_FILENAME RXVT_UTMP_FILE 571 # endif 572 # endif 573 # endif 574 # endif 575 # ifdef USE_SYSV_UTMP 576 # ifndef USER_PROCESS 577 # define USER_PROCESS 7 578 # endif 579 # ifndef DEAD_PROCESS 580 # define DEAD_PROCESS 8 581 # endif 582 # endif 583 # ifdef HAVE_UTMPX_H 584 # define UTMP struct utmpx 585 # define setutent setutxent 586 # define getutent getutxent 587 # define getutid getutxid 588 # define endutent endutxent 589 # define pututline pututxline 590 # else 591 # define UTMP struct utmp 592 # endif 593 #endif 594 595 #ifdef WTMP_SUPPORT 596 # ifdef HAVE_UTMPX_H /* means we're on Solaris (or Irix?) */ 597 # undef WTMP_FILENAME 598 # if defined(WTMPX_FILE) || defined(_WTMPX_FILE) 599 # if defined(WTMPX_FILE) 600 # define WTMP_FILENAME WTMPX_FILE 601 # else 602 # define WTMP_FILENAME _WTMPX_FILE 603 # endif 604 # define update_wtmp updwtmpx 605 # else 606 # define WTMP_FILENAME RXVT_WTMP_FILE 607 # define update_wtmp rxvt_update_wtmp 608 # endif 609 # else 610 # define update_wtmp rxvt_update_wtmp 611 # ifndef WTMP_FILENAME 612 # ifdef WTMP_FILE 613 # define WTMP_FILENAME WTMP_FILE 614 # else 615 # ifdef _PATH_WTMP 616 # define WTMP_FILENAME _PATH_WTMP 617 # else 618 # ifdef RXVT_WTMP_FILE 619 # define WTMP_FILENAME RXVT_WTMP_FILE 620 # else 621 # error define WTMP_FILENAME in config.h 622 # endif 623 # endif 624 # endif 625 # endif 626 # endif 627 #endif 628 629 #if !defined (EACCESS) && defined(EAGAIN) 630 # define EACCESS EAGAIN 631 #endif 632 633 #ifndef EXIT_SUCCESS /* missing from <stdlib.h> */ 634 # define EXIT_SUCCESS 0 /* exit function success */ 635 # define EXIT_FAILURE 1 /* exit function failure */ 636 #endif 637 638 #define menuBar_esc 10 639 #define scrollBar_esc 30 640 #define menuBar_margin 2 /* margin below text */ 641 642 /* gap between text and window edges (could be configurable) */ 643 #define TermWin_internalBorder 2 644 #define TermWin_internalBorders 4 /* must be two times of value above */ 645 646 /* width of scrollBar, menuBar shadow, must be 1 or 2 */ 647 #ifdef HALFSHADOW 648 # define SHADOW 1 649 #else 650 # define SHADOW 2 651 #endif 652 653 654 #define NO_REFRESH 0 /* Window not visible at all! */ 655 #define FAST_REFRESH (1<<1) /* Fully exposed window */ 656 #define SLOW_REFRESH (1<<2) /* Partially exposed window */ 657 #define SMOOTH_REFRESH (1<<3) /* Do sync'ing to make it smooth */ 658 659 #ifdef NO_SECONDARY_SCREEN 660 # define NSCREENS 0 661 #else 662 # define NSCREENS 1 663 #endif 664 665 #define IGNORE 0 666 #define SAVE 's' 667 #define RESTORE 'r' 668 669 /* special (internal) prefix for font commands */ 670 #define FONT_CMD '#' 671 #define FONT_DN "#-" 672 #define FONT_UP "#+" 673 674 /* flags for scr_gotorc() */ 675 #define C_RELATIVE 1 /* col movement is relative */ 676 #define R_RELATIVE 2 /* row movement is relative */ 677 #define RELATIVE (R_RELATIVE|C_RELATIVE) 678 679 /* modes for scr_insdel_chars(), scr_insdel_lines() */ 680 #define INSERT -1 /* don't change these values */ 681 #define DELETE +1 682 #define ERASE +2 683 684 /* modes for scr_page() - scroll page. used by scrollbar window */ 685 enum { 686 UP, 687 DN, 688 NO_DIR 689 }; 690 691 /* arguments for scr_change_screen() */ 692 enum { 693 PRIMARY, 694 SECONDARY 695 }; 696 697 /* all basic bit-flags in first/lower 16 bits */ 698 699 #define RS_None 0 /* Normal */ 700 #define RS_fgMask 0x0000001Fu /* 32 colors */ 701 #define RS_bgMask 0x000003E0u /* 32 colors */ 702 #define RS_Bold 0x00000400u /* bold */ 703 #define RS_Blink 0x00000800u /* blink */ 704 #define RS_RVid 0x00001000u /* reverse video */ 705 #define RS_Uline 0x00002000u /* underline */ 706 #define RS_acsFont 0x00004000u /* ACS graphics char set */ 707 #define RS_ukFont 0x00008000u /* UK character set */ 708 #define RS_fontMask (RS_acsFont|RS_ukFont) 709 #define RS_baseattrMask (RS_Bold|RS_Blink|RS_RVid|RS_Uline) 710 711 /* all other bit-flags in upper 16 bits */ 712 713 #ifdef MULTICHAR_SET 714 # define RS_multi0 0x10000000u /* only multibyte characters */ 715 # define RS_multi1 0x20000000u /* multibyte 1st byte */ 716 # define RS_multi2 (RS_multi0|RS_multi1) /* multibyte 2nd byte */ 717 # define RS_multiMask (RS_multi0|RS_multi1) /* multibyte mask */ 718 #else 719 # define RS_multiMask 0 720 #endif 721 722 #define RS_attrMask (RS_baseattrMask|RS_fontMask|RS_multiMask) 723 724 #define Opt_console (1LU<<0) 725 #define Opt_loginShell (1LU<<1) 726 #define Opt_iconic (1LU<<2) 727 #define Opt_visualBell (1LU<<3) 728 #define Opt_mapAlert (1LU<<4) 729 #define Opt_reverseVideo (1LU<<5) 730 #define Opt_utmpInhibit (1LU<<6) 731 #define Opt_scrollBar (1LU<<7) 732 #define Opt_scrollBar_right (1LU<<8) 733 #define Opt_scrollBar_floating (1LU<<9) 734 #define Opt_meta8 (1LU<<10) 735 #define Opt_scrollTtyOutputInh (1LU<<11) 736 #define Opt_scrollKeypress (1LU<<12) 737 #define Opt_transparent (1LU<<13) 738 #define Opt_transparent_sb (1LU<<14) 739 740 /* place holder used for parsing command-line options */ 741 #define Opt_Boolean (1LU<<31) 742 743 /* 744 * XTerm escape sequences: ESC ] Ps;Pt BEL 745 */ 746 #define XTerm_name 0 747 #define XTerm_iconName 1 748 #define XTerm_title 2 749 #define XTerm_logfile 46 /* not implemented */ 750 #define XTerm_font 50 751 752 /* 753 * rxvt extensions of XTerm escape sequences: ESC ] Ps;Pt BEL 754 */ 755 #define XTerm_Menu 10 /* set menu item */ 756 #define XTerm_Pixmap 20 /* new bg pixmap */ 757 #define XTerm_restoreFG 39 /* change default fg color */ 758 #define XTerm_restoreBG 49 /* change default bg color */ 759 760 #define restoreFG 39 /* restore default fg color */ 761 #define restoreBG 49 /* restore default bg color */ 762 763 /* Words starting with `Color_' are colours. Others are counts */ 764 765 enum colour_list { 766 Color_fg, 767 Color_bg, 768 minCOLOR, /* 2 */ 769 Color_Black = minCOLOR, 770 Color_Red3, 771 Color_Green3, 772 Color_Yellow3, 773 Color_Blue3, 774 Color_Magenta3, 775 Color_Cyan3, 776 maxCOLOR, /* minCOLOR + 7 */ 777 #ifndef NO_BRIGHTCOLOR 778 Color_AntiqueWhite = maxCOLOR, 779 minBrightCOLOR, /* maxCOLOR + 1 */ 780 Color_Grey25 = minBrightCOLOR, 781 Color_Red, 782 Color_Green, 783 Color_Yellow, 784 Color_Blue, 785 Color_Magenta, 786 Color_Cyan, 787 maxBrightCOLOR, /* minBrightCOLOR + 7 */ 788 Color_White = maxBrightCOLOR, 789 #else 790 Color_White = maxCOLOR, 791 #endif 792 #ifndef NO_CURSORCOLOR 793 Color_cursor, 794 Color_cursor2, 795 #endif 796 Color_pointer, 797 Color_border, 798 #if defined(TRANSPARENT) || defined(BACKGROUND_IMAGE) 799 Color_tint, 800 #endif 801 #ifndef NO_BOLDUNDERLINE 802 Color_BD, 803 Color_UL, 804 #endif 805 #ifdef KEEP_SCROLLCOLOR 806 Color_scroll, 807 Color_trough, 808 #endif 809 NRS_COLORS, /* */ 810 #ifdef KEEP_SCROLLCOLOR 811 Color_topShadow = NRS_COLORS, 812 Color_bottomShadow, 813 TOTAL_COLORS /* upto 28 */ 814 #else 815 TOTAL_COLORS = NRS_COLORS /* */ 816 #endif 817 }; 818 819 #define DEFAULT_RSTYLE (RS_None | (Color_fg) | (Color_bg<<5)) 820 821 /* 822 * number of graphics points 823 * divisible by 2 (num lines) 824 * divisible by 4 (num rect) 825 */ 826 #define NGRX_PTS 1000 827 828 /* 829 ***************************************************************************** 830 * MACRO DEFINES 831 ***************************************************************************** 832 */ 833 #define STRCPY(a, b) strcpy ((char *)(a), (char *) (b)) 834 #define STRNCPY(a, b, c) strncpy ((char *)(a), (char *) (b), (c)) 835 #ifdef NO_RMEMSET 836 # define MEMSET(a, b, c) memset ((a), (b), (c)) 837 #else 838 # define MEMSET(a, b, c) rmemset ((a), (b), (R_int_p_t) (c)) 839 #endif 840 841 #define MALLOC(sz) malloc (sz) 842 #define CALLOC(type, n) calloc ((n), sizeof(type)) 843 #define REALLOC(mem, sz) ((mem) ? realloc ((mem), (sz)) : malloc(sz)) 844 #define FREE(ptr) free (ptr) 845 846 /* convert pixel dimensions to row/column values */ 847 #define Pixel2Col(x) Pixel2Width((x) - TermWin_internalBorder) 848 #define Pixel2Row(y) Pixel2Height((y) - TermWin_internalBorder) 849 #define Pixel2Width(x) ((x) / TermWin.fwidth) 850 #define Pixel2Height(y) ((y) / TermWin.fheight) 851 #define Col2Pixel(col) (Width2Pixel(col) + TermWin_internalBorder) 852 #define Row2Pixel(row) (Height2Pixel(row) + TermWin_internalBorder) 853 #define Width2Pixel(n) ((n) * TermWin.fwidth) 854 #define Height2Pixel(n) ((n) * TermWin.fheight) 855 856 #ifdef THAI 857 #define CharWidth(wf, ch) ((wf)->per_char[(unsigned char)(ch) - (wf)->min_char_or_byte2].width) 858 #endif 859 860 #define TermWin_TotalWidth() (TermWin.width + 2 * TermWin_internalBorder) 861 #define TermWin_TotalHeight() (TermWin.height + 2 * TermWin_internalBorder) 862 863 #define Xscreen DefaultScreen(Xdisplay) 864 #define Xroot DefaultRootWindow(Xdisplay) 865 866 /* how to build & extract colors and attributes */ 867 #define GET_FGCOLOR(r) (((r) & RS_fgMask)) 868 #define GET_BGCOLOR(r) (((r) & RS_bgMask)>>5) 869 #define GET_ATTR(r) (((r) & RS_attrMask)) 870 #define GET_BGATTR(r) (((r) & (RS_attrMask | RS_bgMask))) 871 #define SET_FGCOLOR(r,fg) (((r) & ~RS_fgMask) | (fg)) 872 #define SET_BGCOLOR(r,bg) (((r) & ~RS_bgMask) | ((bg)<<5)) 873 #define SET_ATTR(r,a) (((r) & ~RS_attrMask)| (a)) 874 875 #define scrollbar_visible() (scrollBar.state) 876 #define scrollbar_isMotion() (scrollBar.state == 'm') 877 #define scrollbar_isUp() (scrollBar.state == 'U') 878 #define scrollbar_isDn() (scrollBar.state == 'D') 879 #define scrollbar_isUpDn() isupper (scrollBar.state) 880 #define isScrollbarWindow(w) (scrollbar_visible() && (w) == scrollBar.win) 881 882 #define scrollbar_setNone() scrollBar.state = 1 883 #define scrollbar_setMotion() scrollBar.state = 'm' 884 #define scrollbar_setUp() scrollBar.state = 'U' 885 #define scrollbar_setDn() scrollBar.state = 'D' 886 887 #ifdef NEXT_SCROLLBAR 888 # define scrollbar_dnval() (scrollBar.end + (SB_WIDTH + 1)) 889 # define scrollbar_upButton(y) ((y) > scrollBar.end \ 890 && (y) <= scrollbar_dnval()) 891 # define scrollbar_dnButton(y) ((y) > scrollbar_dnval()) 892 #else 893 # define scrollbar_upButton(y) ((y) < scrollBar.beg) 894 # define scrollbar_dnButton(y) ((y) > scrollBar.end) 895 #endif 896 897 #define scrollbar_above_slider(y) ((y) < scrollBar.top) 898 #define scrollbar_below_slider(y) ((y) > scrollBar.bot) 899 #define scrollbar_position(y) ((y) - scrollBar.beg) 900 #define scrollbar_size() (scrollBar.end - scrollBar.beg) 901 902 #if (MENUBAR_MAX > 1) 903 /* rendition style flags */ 904 # define menubar_visible() (menuBar.state) 905 # define menuBar_height() (TermWin.fheight + SHADOW) 906 # define menuBar_TotalHeight() (menuBar_height() + SHADOW + menuBar_margin) 907 # define isMenuBarWindow(w) ((w) == menuBar.win) 908 #else 909 # define isMenuBarWindow(w) (0) 910 # define menuBar_height() (0) 911 # define menuBar_TotalHeight() (0) 912 # define menubar_visible() (0) 913 #endif 914 915 #if defined(BACKGROUND_IMAGE) || defined(_MYSTYLE_) 916 # define XPMClearArea(a, b, c, d, e, f, g) XClearArea((a), (b), (c), (d), (e), (f), (g)) 917 #else 918 # define XPMClearArea(a, b, c, d, e, f, g) 919 #endif 920 921 /* 922 ***************************************************************************** 923 * VARIABLES 924 ***************************************************************************** 925 */ 926 #ifdef INTERN 927 # define EXTERN 928 #else 929 # define EXTERN extern 930 #endif 931 932 #ifdef PREFER_24BIT 933 EXTERN Colormap Xcmap; 934 EXTERN int Xdepth; 935 EXTERN Visual *Xvisual; 936 #else 937 # define Xcmap DefaultColormap(Xdisplay,Xscreen) 938 # define Xdepth DefaultDepth(Xdisplay,Xscreen) 939 # define Xvisual DefaultVisual(Xdisplay,Xscreen) 940 # ifdef DEBUG_DEPTH 941 # undef Xdepth 942 # define Xdepth DEBUG_DEPTH 943 # endif 944 #endif 945 946 EXTERN TermWin_t TermWin; 947 #define PARENTS_NUM 3 948 #define PARENTS_INIT {0,0,0} 949 extern Window ParentWin[PARENTS_NUM]; 950 extern int ParentWinNum; 951 enum button_num {ONE,TWO,BUTTONS_NUM}; 952 EXTERN scrollBar_t scrollBar; 953 EXTERN menuBar_t menuBar; 954 EXTERN Display *Xdisplay; 955 EXTERN unsigned long Options; 956 EXTERN int sb_shadow; 957 EXTERN int delay_menu_drawing; 958 EXTERN const char *display_name; 959 EXTERN const char *rs_name; /* client instance (resource name) */ 960 EXTERN const char *rs_term_name; 961 EXTERN const char *rs_color[NRS_COLORS]; 962 EXTERN Pixel PixColorsFocused[TOTAL_COLORS]; 963 #ifdef OFF_FOCUS_FADING 964 EXTERN Pixel PixColorsUnFocused[TOTAL_COLORS]; 965 #endif 966 #ifdef _MYSTYLE_ 967 EXTERN const char *rs_mystyle; 968 #endif 969 EXTERN Pixel *PixColors; 970 EXTERN const char *rs_tab_title; /* titre generique pour les tabs */ 971 EXTERN const char *rs_default_tab_title; 972 EXTERN const char *rs_term_num; /* number of tab at startup */ 973 EXTERN const char *rs_config_file; /* the configuration file */ 974 //EXTERN const char *rs_tab_num; /* number of tab at startup */ 975 EXTERN const char *rs_title; /* title name for window */ 976 EXTERN const char *rs_iconName; /* icon name for window */ 977 EXTERN const char *rs_geometry; /* window geometry */ 978 EXTERN const char *rs_minBufferWidth; /* minimum buffer width - so we can scroll horizontally */ 979 EXTERN const char *rs_saveLines; /* scrollback buffer [lines] */ 980 EXTERN const char *rs_borderWidth; /* border width [pixels] */ 981 EXTERN const char *rs_cutchars; /* chars for selection boundaries */ 982 EXTERN const char *rs_iconic; 983 #ifdef META8_OPTION 984 EXTERN const char *rs_modifier; 985 #endif 986 #ifndef NO_BACKSPACE_KEY 987 EXTERN const char *rs_backspace_key; 988 #endif 989 #ifndef NO_DELETE_KEY 990 EXTERN const char *rs_delete_key; 991 #endif 992 EXTERN const char *rs_font[NFONTS]; 993 #ifdef MULTICHAR_SET 994 EXTERN const char *rs_mfont[NFONTS]; 995 #endif 996 #ifndef NO_BOLDFONT 997 EXTERN const char *rs_boldFont; 998 #endif 999 #ifdef PRINTPIPE 1000 EXTERN const char *rs_print_pipe; 1001 #endif 1002 #ifndef NO_BRIGHTCOLOR 1003 EXTERN unsigned int colorfgbg; 1004 #endif 1005 #ifdef KEYSYM_RESOURCE 1006 EXTERN const unsigned char *KeySym_map[256]; 1007 #endif 1008 #if defined (HOTKEY_CTRL) || defined (HOTKEY_META) 1009 EXTERN KeySym ks_bigfont; 1010 EXTERN KeySym ks_smallfont; 1011 #endif 1012 EXTERN const char *rs_menu; 1013 EXTERN const char *rs_path; 1014 1015 #ifdef BACKGROUND_IMAGE 1016 EXTERN const char *rs_backgroundPixmap; 1017 #endif 1018 1019 #if defined(BACKGROUND_IMAGE) || defined(TRANSPARENT) 1020 EXTERN const char *rs_backgroundType; 1021 EXTERN const char *rs_tintType; 1022 EXTERN const char *rs_shade; 1023 EXTERN const char *rs_shading; 1024 #endif 1025 1026 #ifdef OFF_FOCUS_FADING 1027 EXTERN const char *rs_fade; 1028 #endif 1029 1030 EXTERN const char *rs_textType; 1031 /* 1032 ***************************************************************************** 1033 * PROTOTYPES 1034 ***************************************************************************** 1035 */ 1036 1037 #ifdef PROTOTYPES 1038 # define __PROTO(p) p 1039 #else 1040 # define __PROTO(p) () 1041 #endif 1042 1043 #include "main.h" 1044 #include "screen.h" 1045 #include "command.h" 1046 #include "notebook2.h" 1047 1048 #ifdef GREEK_SUPPORT 1049 #include "grkelot.h" 1050 #endif 1051 1052 #include "menubar.h" 1053 #include "misc.h" 1054 #include "netdisp.h" 1055 #include "rmemset.h" 1056 1057 #ifdef THAI 1058 #include "thai.h" 1059 #endif 1060 1061 #ifdef NEXT_SCROLLBAR 1062 # include "scrollbar2.h" 1063 #else 1064 # include "scrollbar.h" 1065 #endif 1066 1067 //#include "xdefaults.h" 1068 #include "xresources.h" 1069 #include "pixmap.h" 1070 1071 #ifdef DEBUG_MALLOC 1072 # include "dmalloc.h" /* This comes last */ 1073 #endif 1074 1075 #endif /* _RXVT_H */ 1076