home *** CD-ROM | disk | FTP | other *** search
/ Usenet 1994 January / usenetsourcesnewsgroupsinfomagicjanuary1994.iso / sources / unix / volume14 / mush6.0 / part02 / tool.c < prev   
Encoding:
C/C++ Source or Header  |  1988-04-12  |  4.1 KB  |  130 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(args)
  7. char **args;
  8. {
  9.     struct stat rootbuf, tmpbuf;
  10.     struct inputmask im;
  11.     register unsigned i;
  12.     char **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.     /* where to place text on mail icon -- how many messages there are */
  24.     rect_construct(&mail_icon.ic_textrect,
  25.     l_width(DEFAULT), 58-l_height(DEFAULT),
  26.     3*l_width(DEFAULT), l_height(DEFAULT));
  27.  
  28.     if (!(tool = tool_make(
  29.     WIN_ICON,         &mail_icon,
  30.     WIN_HEIGHT,         700,
  31.     WIN_WIDTH,         650,
  32.     WIN_BOUNDARY_MGR,     1,
  33.     WIN_ATTR_LIST,         args,
  34.     NULL)))
  35.     perror(prog_name), cleanup(0);
  36.     tool_free_attribute_list(args);
  37.  
  38.     choice_args = panel_make_list(
  39.     PANEL_MENU_TITLE_FONT, fonts[LARGE],
  40.     PANEL_DISPLAY_LEVEL, PANEL_NONE,
  41.     PANEL_SHOW_MENU, TRUE,
  42.     PANEL_SHOW_MENU_MARK, FALSE,
  43.     0);
  44.  
  45.     button_args = panel_make_list(
  46.     PANEL_FEEDBACK, PANEL_INVERTED,
  47.     PANEL_SHOW_MENU, FALSE,
  48.     0);
  49.  
  50.     make_hdr_panel(choice_args, button_args);
  51.  
  52.     if (!(hdr_sw = gfxsw_createtoolsubwindow(tool, "hdr_sw",
  53.     TOOL_SWEXTENDTOEDGE, 10+ screen*l_height(DEFAULT), (char **)0)))
  54.     perror("hdr_sw"), cleanup(0);
  55.     gfxsw_getretained((struct gfxsubwindow *)hdr_sw->ts_data);
  56.     hdr_win = ((struct gfxsubwindow *)(hdr_sw->ts_data))->gfx_pixwin;
  57.  
  58.     input_imnull(&im);
  59.     win_setinputcodebit(&im, LOC_STILL);
  60.     win_setinputcodebit(&im, LOC_MOVE);
  61.     win_setinputcodebit(&im, LOC_WINENTER);
  62.     for (i = VKEY_FIRSTFUNC; i <= VKEY_LASTFUNC; i++)
  63.     win_setinputcodebit(&im, i);
  64.     win_setinputmask(hdr_sw->ts_windowfd, &im, &im,
  65.                    win_fdtonumber(hdr_panel_sw->ts_windowfd)); 
  66.     hdr_sw->ts_io.tio_selected = hdr_io;
  67.     hdr_sw->ts_io.tio_handlesigwinch = hdrwin_handlesigwinch;
  68.  
  69.     make_main_panel(choice_args, button_args);
  70.     xfree(choice_args), xfree(button_args);
  71.  
  72.     if (!(print_sw = gfxsw_createtoolsubwindow(tool, "print_sw",
  73.     TOOL_SWEXTENDTOEDGE, l_height(LARGE) + 10, (char **)0)))
  74.     perror("print_sw"), cleanup(0);
  75.     print_win = ((struct gfxsubwindow *)(print_sw->ts_data))->gfx_pixwin;
  76.     print_sw->ts_io.tio_handlesigwinch = print_sigwinch;
  77.  
  78.     /* text subwindow */
  79.     if (!(msg_sw = gfxsw_createtoolsubwindow(tool, "msg_sw",
  80.     TOOL_SWEXTENDTOEDGE, TOOL_SWEXTENDTOEDGE, (char **)0)))
  81.     perror("msg_sw"), cleanup(0);
  82.     gfxsw_getretained((struct gfxsubwindow *)msg_sw->ts_data);
  83.     msg_win = ((struct gfxsubwindow *)(msg_sw->ts_data))->gfx_pixwin;
  84.  
  85.     /* everything we want the text window to pay attention to */
  86.     input_imnull(&im);
  87.     im.im_flags = IM_ASCII;
  88.     im.im_flags &= ~IM_ANSI;
  89.     for (i = VKEY_FIRSTFUNC; i <= VKEY_LASTFUNC; i++)
  90.     win_setinputcodebit(&im, i);
  91.     win_setinputmask(msg_sw->ts_windowfd, &im, &im, WIN_NULLLINK);
  92.     msg_sw->ts_io.tio_selected = msg_io;
  93.     msg_sw->ts_io.tio_handlesigwinch = msgwin_handlesigwinch;
  94.  
  95.     /* tty subwindow */
  96.     if (!(tty_sw = ttytlsw_createtoolsubwindow(tool, "tty_sw",
  97.     TOOL_SWEXTENDTOEDGE, 0, (char **)0)))
  98.     perror("tty_sw"), cleanup(0);
  99.     ttysw_handlesigwinch(tty_sw);
  100.     win_setcursor(tty_sw->ts_windowfd, &write_cursor);
  101.  
  102.     (void) sprintf(blank, "%128c", ' ');
  103.     (void) signal(SIGWINCH, sigwinchcatcher);
  104.     (void) signal(SIGTERM, sigtermcatcher);
  105.     (void) signal(SIGCHLD, sigchldcatcher);
  106.     pw_writebackground(hdr_win, 0,0, hdr_rect.r_width, hdr_rect.r_height,
  107.                PIX_CLR);
  108.     if (ioctl(0, TIOCGETC, &tchars))
  109.     perror("gtty failed"), cleanup(0);
  110.     win_numbertoname (0, buf1);
  111.     if ((rootfd = open(buf1, 0)) == -1)
  112.     error("can't open %s", buf1), cleanup(0);
  113.     if (fstat(rootfd, &rootbuf))
  114.     error("can't stat %s", buf1), cleanup(0);
  115.     for (parentfd = 3; parentfd < rootfd; parentfd++)
  116.     if (fstat(parentfd, &tmpbuf))
  117.         error("Can't stat fd-%d", parentfd);
  118.     else if (tmpbuf.st_ino == rootbuf.st_ino) {
  119.         (void) close(rootfd);
  120.         rootfd = parentfd;
  121.         break;
  122.     }
  123.     istool = 2;
  124.     (void) do_version();
  125.     lock_cursors();
  126.     tool_install(tool);
  127.     tool_display(tool);
  128.     do_clear();
  129. }
  130.