home *** CD-ROM | disk | FTP | other *** search
/ PC-Online 1998 February / PCOnline_02_1998.iso / filesbbs / dos / listz21s.exe / LZSET10S.RAR / LZS_MAIN.CPP < prev    next >
Encoding:
C/C++ Source or Header  |  1997-02-25  |  11.0 KB  |  338 lines

  1. /*
  2.  * This file is part of LZSETUP (Configuration program for Listerz)
  3.  *
  4.  * Copyright (c) 1997 Branislav L. Slantchev (gargoyle)
  5.  * A fine product of Silicon Creations, Inc.
  6.  *
  7.  * This file is released under the terms and conditions of the GNU
  8.  * General Public License Version 2. The full text of the license is
  9.  * supplied in the Copying.Doc file included with this archive. This
  10.  * free software comes with absolutely no warranty, as outlined in the
  11.  * licensing text. You are not allowed to remove this copyright notice.
  12.  *
  13.  * Contact: Branislav L. Slantchev at 73023.262@compuserve.com
  14. */
  15. #include <stdlib.h>
  16. #include <stdio.h>
  17. #include <opcrt.h>
  18. #include <opcolor.h>
  19. #include <opmenu.h>
  20. #include <opsedit.h>
  21. #include <opdos.h>
  22. #include <opentry.h>
  23. #include <oppick.h>
  24. #include <opmouse.h>
  25. #include "../lzconfig.h"
  26. #include "lzs_cmds.h"
  27. #include "lzs_vers.h"
  28. #include "file.h"
  29.  
  30. extern void       DisplayBanner();
  31. extern boolean    MsgAsk(char*, char*, boolean*,ColorSet&,boolean=TRUE);
  32. extern boolean    AskFileName(char *header, char *fileName, ColorSet&);
  33. extern void       DropFile();
  34. extern void       SystemPaths();
  35. extern word       InitMenu(Menu &M, ColorSet &Colors);
  36. extern void       ArchiverSetup(int archiver);
  37. extern void       SelectColor(byte *attrib, char *header);
  38. extern void       SelectSymbol(byte *symbol, char *header);
  39. extern void       EditScreen(char *fileName, int nRects, zRect*[], char*[]);
  40. extern boolean    LoadConfig();
  41. extern void       SaveConfig();
  42. extern void       proboard_emulator_init();
  43. extern void       proboard_emulator_term();
  44. extern byte far   LzsKeySet[];
  45.  
  46. // Color set used by entry screen
  47. ColorSet lz_Colors =
  48. {
  49.   /* TextColor */        CyanOnBlack,     /* TextMono */         LtGrayOnBlack,
  50.   /* CtrlColor */        YellowOnBlue,    /* CtrlMono */         WhiteOnBlack,
  51.   /* FrameColor */       WhiteOnBlack,    /* FrameMono */        LtGrayOnBlack,
  52.   /* HeaderColor */      YellowOnBlue,    /* HeaderMono */       BlackOnLtGray,
  53.   /* ShadowColor */      BlackOnBlack,    /* ShadowMono */       WhiteOnBlack,
  54.   /* HighlightColor */   WhiteOnRed,      /* HighlightMono */    BlackOnLtGray,
  55.   /* PromptColor */      LtGrayOnBlack,   /* PromptMono */       LtGrayOnBlack,
  56.   /* SelPromptColor */   BlueOnLtGray,    /* SelPromptMono */    LtGrayOnBlack,
  57.   /* ProPromptColor */   BlackOnCyan,     /* ProPromptMono */    LtGrayOnBlack,
  58.   /* FieldColor */       LtGrayOnBlack,   /* FieldMono */        LtGrayOnBlack,
  59.   /* SelFieldColor */    BlueOnGreen,     /* SelFieldMono */     WhiteOnBlack,
  60.   /* ProFieldColor */    LtGrayOnBlue,    /* ProFieldMono */     LtGrayOnBlack,
  61.   /* ScrollBarColor */   CyanOnBlue,      /* ScrollBarMono */    LtGrayOnBlack,
  62.   /* SliderColor */      CyanOnBlue,      /* SliderMono */       WhiteOnBlack,
  63.   /* HotSpotColor */     BlackOnCyan,     /* HotSpotMono */      BlackOnLtGray,
  64.   /* BlockColor */       YellowOnCyan,    /* BlockMono */        WhiteOnBlack,
  65.   /* MarkerColor */      WhiteOnMagenta,  /* MarkerMono */       BlackOnLtGray,
  66.   /* DelimColor */       BlueOnCyan,      /* DelimMono */        WhiteOnBlack,
  67.   /* SelDelimColor */    BlueOnCyan,      /* SelDelimMono */     WhiteOnBlack,
  68.   /* ProDelimColor */    BlueOnCyan,      /* ProDelimMono */     WhiteOnBlack,
  69.   /* SelItemColor */     BlueOnLtGray,    /* SelItemMono */      BlackOnLtGray,
  70.   /* ProItemColor */     DkGrayOnBlack,   /* ProItemMono */      LtGrayOnBlack,
  71.   /* HighItemColor */    YellowOnBlack,   /* HighItemMono */     WhiteOnBlack,
  72.   /* AltItemColor */     CyanOnBlack,     /* AltItemMono */      WhiteOnBlack,
  73.   /* AltSelItemColor */  BlueOnLtGray,    /* AltSelItemMono */   BlackOnLtGray,
  74.   /* FlexAHelpColor */   WhiteOnBlue,     /* FlexAHelpMono */    WhiteOnBlack,
  75.   /* FlexBHelpColor */   WhiteOnBlue,     /* FlexBHelpMono */    WhiteOnBlack,
  76.   /* FlexCHelpColor */   LtCyanOnBlue,    /* FlexCHelpMono */    BlackOnLtGray,
  77.   /* UnselXrefColor */   YellowOnBlue,    /* UnselXrefMono */    LtBlueOnBlack,
  78.   /* SelXrefColor */     WhiteOnMagenta,  /* SelXrefMono */      BlackOnLtGray,
  79.   /* MouseColor */       WhiteOnRed,      /* MouseMono */        BlackOnLtGray
  80. };
  81.  
  82. LZCONFIG          lz_Config;
  83. char              lz_ConfigPath[80];
  84. FrameArray        lz_FrameType = "╓╙╖╜──║║";
  85. boolean           lz_Dirty;
  86. CommandProcessor  lz_Commands;
  87. RawWindow         StatusLine;
  88. word              Status;
  89. Menu              Menu;
  90.  
  91. // display copyright text header
  92. void
  93. DisplayCopyright()
  94. {
  95.     ClearWindow(1, 1, ScreenWidth, 1, ' ', BlackOnCyan);
  96.     FastCenter(__COPYRIGHT__, 1, BlackOnCyan);
  97. }
  98.  
  99. // initialize window for the help line
  100. word
  101. InitHelpLine(RawWindow &aStatusLine)
  102. {
  103.     byte Row = 25;
  104.     if( !aStatusLine.InitCustom(1,Row,ScreenWidth,Row,lz_Colors,wClear) )
  105.         return aStatusLine.InitStatus;
  106.     aStatusLine.SetTextAttr(BlackOnLtGray, LtGrayOnBlack);
  107.     return 0;
  108. }
  109.  
  110. // report errors
  111. void
  112. ErrorHandler(byte ModuleCode, word &ErrCode, char *Msg)
  113. {
  114.     RingBell();
  115. }
  116.  
  117. void
  118. UpdateHelpLine(MenuItemNodePtr CurrentItem, MenuPtr)
  119. {
  120.     char s[255];
  121.  
  122.     if( CurrentItem == NULL ) s[0] = '\0';
  123.     else
  124.     {
  125.         CurrentItem->HelpString(&s[1]);
  126.         s[0] = ' ';
  127.     }
  128.     Pad(s, StatusLine.Width(), s);
  129.     StatusLine.wFastText(s, 1, 1);
  130. }
  131.  
  132. /////////////////////////////////////////////////////////////////////////////
  133. // duh!
  134. int
  135. main()
  136. {
  137.     DetectMultitasking = TRUE;
  138.  
  139.     OPMenuInit();
  140.     OPWindowInit();
  141.     OPSEditInit();
  142.     OPEntryInit();
  143.     OPPickInit();
  144.     OPMouseInit();
  145.  
  146.     if( MouseInstalled ) MouseGotoXY(1,1);
  147.  
  148.     proboard_emulator_init();
  149.  
  150.     Status = InitMenu(Menu, lz_Colors);
  151.     if( Status != 0 )
  152.     {
  153.         cprintf("Error initializing menu: %u\r\n", Status);
  154.         return 0;
  155.     }
  156.  
  157.     //set up user hooks
  158.     Menu.SetErrorFunc(ErrorHandler);
  159.     lz_Commands.Init((CmdTablePtr)LzsKeySet, LZS_KEYSMAX);
  160.  
  161.     Status = InitHelpLine(StatusLine);
  162.     if( Status != 0 )
  163.     {
  164.         cprintf("Error initializing help line: %d\r\n", Status);
  165.         exit(1);
  166.     }
  167.  
  168.     Menu.SetCurrentItemFunc(UpdateHelpLine);
  169.  
  170.     TextChar = '░';
  171.     ClrScr();
  172.     DisplayCopyright();
  173.     StatusLine.Draw();
  174.     Menu.Draw();
  175.  
  176.     lz_Dirty = FALSE;
  177.     LoadConfig();  // may set Dirty to TRUE!!! (sets lz_ConfigPath)
  178.  
  179. MenuLoop:
  180.     for( ;; )
  181.     {
  182.         int    command;
  183.         zRect *rects[10];
  184.         char  *headers[10];
  185.  
  186.         Menu.Process();
  187.         command = Menu.GetLastCommand();
  188.  
  189.         if( ccQuit == command ) goto ExitMenuLoop;
  190.         else if( ccSelect != command ) continue;
  191.  
  192.         switch( Menu.MenuChoice() )
  193.         {
  194.                 case miMainScreen:
  195.                     rects[0] = &lz_Config.lbox_Bounds;
  196.                     rects[1] = &lz_Config.cbar_Bounds;
  197.                     headers[0] = " Name Display Area ";
  198.                     headers[1] = " Command Bar Area ";
  199.                     EditScreen(lz_Config.sys_MainFile, 2, rects, headers);
  200.                     break;
  201.  
  202.                 case miProcScreen:
  203.                     rects[0] = &lz_Config.proc_Bounds;
  204.                     rects[1] = &lz_Config.area_Bounds;
  205.                     rects[2] = &lz_Config.area_Percent;
  206.                     rects[3] = &lz_Config.area_Progbar.bounds;
  207.                     rects[4] = &lz_Config.total_Percent;
  208.                     rects[5] = &lz_Config.total_Progbar.bounds;
  209.                     rects[6] = &lz_Config.total_Areas;
  210.                     rects[7] = &lz_Config.total_Files;
  211.                     rects[8] = &lz_Config.total_Size;
  212.                     rects[9] = &lz_Config.total_ListSize;
  213.                     headers[0] = " Name Display Area ";
  214.                     headers[1] = " Current Area Name ";
  215.                     headers[2] = "% Current Area";
  216.                     headers[3] = " Current Progress Bar ";
  217.                     headers[4] = "% All Areas";
  218.                     headers[5] = " Total Progress Bar ";
  219.                     headers[6] = " Total Areas ";
  220.                     headers[7] = " Total Files ";
  221.                     headers[8] = " Total Size ";
  222.                     headers[9] = " Listing Size ";
  223.                     EditScreen(lz_Config.sys_ProcFile, 10, rects, headers);
  224.                     break;
  225.  
  226.                 case miTest:
  227.                     break;
  228.  
  229.                 case miPbarFgChar:
  230.                     SelectSymbol(&lz_Config.area_Progbar.fgChar, " Fore Symbol ");
  231.                     break;
  232.                 case miPbarBgChar:
  233.                     SelectSymbol(&lz_Config.area_Progbar.bgChar, " Back Symbol ");
  234.                     break;
  235.                 case miPbarTotalFgChar:
  236.                     SelectSymbol(&lz_Config.total_Progbar.fgChar, " Fore Symbol ");
  237.                     break;
  238.                 case miPbarTotalBgChar:
  239.                     SelectSymbol(&lz_Config.total_Progbar.bgChar, " Back Symbol ");
  240.                     break;
  241.                 case miTagSymbol:
  242.                     SelectSymbol(&lz_Config.lbox_TagChar, " Tag Symbol ");
  243.                     break;
  244.                 case miListAreaName:
  245.                     SelectColor(&lz_Config.lbox_Color, " List Box ");
  246.                     break;
  247.                 case miListSelectBar:
  248.                     SelectColor(&lz_Config.lbox_Hilite, " Hilite Bar ");
  249.                     break;
  250.                 case miListTag:
  251.                     SelectColor(&lz_Config.lbox_TagColor, " Tag Symbol ");
  252.                     break;
  253.                 case miListTagHilite:
  254.                     SelectColor(&lz_Config.lbox_TagHilite, " Tag Hilite ");
  255.                     break;
  256.                 case miCbarActiveFg:
  257.                     SelectColor(&lz_Config.cbar_Color, " Active Text " );
  258.                     break;
  259.                 case miCbarActiveBg:
  260.                     SelectColor(&lz_Config.cbar_Background, " Active Fill " );
  261.                     break;
  262.                 case miCbarHotkey:
  263.                     SelectColor(&lz_Config.cbar_HotkeyColor, " Hotkeys ");
  264.                     break;
  265.                 case miCbarHilite:
  266.                     SelectColor(&lz_Config.cbar_HiliteColor, " Hilite Text ");
  267.                     break;
  268.                 case miCbarOffFg:
  269.                     SelectColor(&lz_Config.cbar_OffColor, " Inactive Text ");
  270.                     break;
  271.                 case miCbarOffBg:
  272.                     SelectColor(&lz_Config.cbar_OffBackground, " Inactive Fill ");
  273.                     break;
  274.                 case miProcText:
  275.                     SelectColor(&lz_Config.proc_Color, " List Text ");
  276.                     break;
  277.                 case miProcDigits:
  278.                     SelectColor(&lz_Config.total_DigitColor, " Digits ");
  279.                     break;
  280.                 case miProcAreaName:
  281.                     SelectColor(&lz_Config.area_Color, " Hilite Text ");
  282.                     break;
  283.                 case miPbarFg:
  284.                     SelectColor(&lz_Config.area_Progbar.fgColor, " Current Fg ");
  285.                     break;
  286.                 case miPbarBg:
  287.                     SelectColor(&lz_Config.area_Progbar.bgColor, " Current Bg ");
  288.                     break;
  289.                 case miPbarTotalFg:
  290.                     SelectColor(&lz_Config.total_Progbar.fgColor, " Total Fg ");
  291.                     break;
  292.                 case miPbarTotalBg:
  293.                     SelectColor(&lz_Config.total_Progbar.bgColor, " Total Bg ");
  294.                     break;
  295.                 case miZIP          : ArchiverSetup(ARCHIVER_ZIP); break;
  296.                 case miRAR          : ArchiverSetup(ARCHIVER_RAR); break;
  297.                 case miARJ          : ArchiverSetup(ARCHIVER_ARJ); break;
  298.                 case miLHA          : ArchiverSetup(ARCHIVER_LHA); break;
  299.                 case miZOO          : ArchiverSetup(ARCHIVER_ZOO); break;
  300.                 case miFileLocations: SystemPaths();   break;
  301.                 case miUseron       : DropFile();      break;
  302.                 case miInformation  : DisplayBanner(); break;
  303.                 case miExit         : goto ExitMenuLoop;
  304.         }
  305.     }
  306.  
  307. ExitMenuLoop:
  308.     if( lz_Dirty )
  309.     {
  310.         boolean escaped, rv;
  311.  
  312.         rv = MsgAsk("Warning", "Configuration modified. Save now?", &escaped, lz_Colors);
  313.         if( escaped ) goto MenuLoop;
  314.  
  315.         if( rv )
  316.         {
  317.             AskFileName(" Config File ", lz_ConfigPath, lz_Colors);
  318.             SaveConfig();  // uses lz_ConfigPath
  319.         }
  320.     }
  321.  
  322.     Menu.Erase();
  323.     Menu.Done();
  324.     StatusLine.Erase();
  325.     StatusLine.Done();
  326.     lz_Commands.Done();
  327.  
  328.     ClrScr();
  329.     cprintf("lzSetup %s ∙ The Listerz Configuration Utility\n\r",__VERSION__);
  330.     cprintf("    ■ Copyright (c) 1997 Branislav L. Slantchev\n\r");
  331.     cprintf("    ■ A Fine Product of Silicon Creations, Inc.\n\r");
  332.     cprintf("    ■ Release version compiled on %s at %s\n\r", __DATE__, __TIME__);
  333.  
  334.     proboard_emulator_term();
  335.  
  336.     return 0;
  337. }
  338.