home *** CD-ROM | disk | FTP | other *** search
/ Usenet 1994 January / usenetsourcesnewsgroupsinfomagicjanuary1994.iso / sources / unix / volume11 / mush5.7 / part01 / tool.c < prev    next >
Encoding:
C/C++ Source or Header  |  1987-09-16  |  4.2 KB  |  133 lines

  1. /* @(#)tool.c    (c) copyright    10/15/86 (Dan Heller) */
  2.  
  3. /* tool.c --make the mailtool windows, panels, etc... */
  4. #include "mush.h"
  5.  
  6. make_tool(argc, argv)
  7. char **argv;
  8. {
  9.     struct stat rootbuf, tmpbuf;
  10.     struct inputmask im;
  11.     register unsigned i;
  12.     char **args = DUBL_NULL, **choice_args, **button_args, *p;
  13.     char buf1[WIN_NAMESIZE], buf2[WIN_NAMESIZE];
  14.  
  15.     getfonts();
  16.     mail_icon.ic_font = fonts[DEFAULT];
  17.  
  18.     if (p = do_set(set_options, "screen_win"))
  19.     screen = atoi(p);
  20.     else
  21.     screen = 6;
  22.  
  23.     time_out = TIME_OUT;
  24.     /* where to place text on mail icon -- how many messages there are */
  25.     rect_construct(&mail_icon.ic_textrect,
  26.     l_width(DEFAULT), 58-l_height(DEFAULT),
  27.     3*l_width(DEFAULT), l_height(DEFAULT));
  28.  
  29.     tool_parse_all(&argc, argv, &args, prog_name);
  30.  
  31.     if (!(tool = tool_make(
  32.     WIN_ICON,         &mail_icon,
  33.     WIN_HEIGHT,         700,
  34.     WIN_WIDTH,         650,
  35.     WIN_BOUNDARY_MGR,     1,
  36.     WIN_ATTR_LIST,         args,
  37.     NULL)))
  38.     perror(prog_name), cleanup(0);
  39.     tool_free_attribute_list(args);
  40.  
  41.     choice_args = panel_make_list(
  42.     PANEL_MENU_TITLE_FONT, fonts[LARGE],
  43.     PANEL_DISPLAY_LEVEL, PANEL_NONE,
  44.     PANEL_SHOW_MENU, TRUE,
  45.     PANEL_SHOW_MENU_MARK, FALSE,
  46.     0);
  47.  
  48.     button_args = panel_make_list(
  49.     PANEL_FEEDBACK, PANEL_INVERTED,
  50.     PANEL_SHOW_MENU, FALSE,
  51.     0);
  52.  
  53.     make_hdr_panel(choice_args, button_args);
  54.  
  55.     if (!(hdr_sw = gfxsw_createtoolsubwindow(tool, "hdr_sw",
  56.     TOOL_SWEXTENDTOEDGE, 10+ screen*l_height(DEFAULT), (char **)0)))
  57.     perror("hdr_sw"), cleanup(0);
  58.     gfxsw_getretained((struct gfxsubwindow *)hdr_sw->ts_data);
  59.     hdr_win = ((struct gfxsubwindow *)(hdr_sw->ts_data))->gfx_pixwin;
  60.  
  61.     input_imnull(&im);
  62.     win_setinputcodebit(&im, LOC_STILL);
  63.     win_setinputcodebit(&im, LOC_MOVE);
  64.     win_setinputcodebit(&im, LOC_WINENTER);
  65.     for (i = VKEY_FIRSTFUNC; i <= VKEY_LASTFUNC; i++)
  66.     win_setinputcodebit(&im, i);
  67.     win_setinputmask(hdr_sw->ts_windowfd, &im, &im,
  68.                    win_fdtonumber(hdr_panel_sw->ts_windowfd)); 
  69.     hdr_sw->ts_io.tio_selected = hdr_io;
  70.     hdr_sw->ts_io.tio_handlesigwinch = hdrwin_handlesigwinch;
  71.  
  72.     make_main_panel(choice_args, button_args);
  73.     xfree(choice_args), xfree(button_args);
  74.  
  75.     if (!(print_sw = gfxsw_createtoolsubwindow(tool, "print_sw",
  76.     TOOL_SWEXTENDTOEDGE, l_height(LARGE) + 10, (char **)0)))
  77.     perror("print_sw"), cleanup(0);
  78.     print_win = ((struct gfxsubwindow *)(print_sw->ts_data))->gfx_pixwin;
  79.     print_sw->ts_io.tio_handlesigwinch = print_sigwinch;
  80.  
  81.     /* text subwindow */
  82.     if (!(msg_sw = gfxsw_createtoolsubwindow(tool, "msg_sw",
  83.     TOOL_SWEXTENDTOEDGE, TOOL_SWEXTENDTOEDGE, (char **)0)))
  84.     perror("msg_sw"), cleanup(0);
  85.     gfxsw_getretained((struct gfxsubwindow *)msg_sw->ts_data);
  86.     msg_win = ((struct gfxsubwindow *)(msg_sw->ts_data))->gfx_pixwin;
  87.  
  88.     /* everything we want the text window to pay attention to */
  89.     input_imnull(&im);
  90.     im.im_flags = IM_ASCII;
  91.     im.im_flags &= ~IM_ANSI;
  92.     for (i = VKEY_FIRSTFUNC; i <= VKEY_LASTFUNC; i++)
  93.     win_setinputcodebit(&im, i);
  94.     win_setinputmask(msg_sw->ts_windowfd, &im, &im, WIN_NULLLINK);
  95.     msg_sw->ts_io.tio_selected = msg_io;
  96.     msg_sw->ts_io.tio_handlesigwinch = msgwin_handlesigwinch;
  97.  
  98.     /* tty subwindow */
  99.     if (!(tty_sw = ttytlsw_createtoolsubwindow(tool, "tty_sw",
  100.     TOOL_SWEXTENDTOEDGE, 0, (char **)0)))
  101.     perror("tty_sw"), cleanup(0);
  102.     ttysw_handlesigwinch(tty_sw);
  103.     win_setcursor(tty_sw->ts_windowfd, &write_cursor);
  104.  
  105.     (void) sprintf(blank, "%128c", ' ');
  106.     (void) signal(SIGWINCH, sigwinchcatcher);
  107.     (void) signal(SIGTERM, sigtermcatcher);
  108.     (void) signal(SIGCHLD, sigchldcatcher);
  109.     pw_writebackground(hdr_win, 0,0, hdr_rect.r_width, hdr_rect.r_height,
  110.                PIX_CLR);
  111.     if (ioctl(0, TIOCGETC, &tchars))
  112.     perror("gtty failed"), cleanup(0);
  113.     win_numbertoname (0, buf1);
  114.     if ((rootfd = open(buf1, 0)) == -1)
  115.     error("can't open %s", buf1), cleanup(0);
  116.     if (fstat(rootfd, &rootbuf))
  117.     error("can't stat %s", buf1), cleanup(0);
  118.     for (parentfd = 3; parentfd < rootfd; parentfd++)
  119.     if (fstat(parentfd, &tmpbuf))
  120.         error("Can't stat fd-%d", parentfd);
  121.     else if (tmpbuf.st_ino == rootbuf.st_ino) {
  122.         (void) close(rootfd);
  123.         rootfd = parentfd;
  124.         break;
  125.     }
  126.     istool = 2;
  127.     (void) do_version();
  128.     lock_cursors();
  129.     tool_install(tool);
  130.     tool_display(tool);
  131.     do_clear();
  132. }
  133.