home *** CD-ROM | disk | FTP | other *** search
/ HomeWare 14 / HOMEWARE14.bin / utils1 / clipboot.arj / MANAGED.PRG < prev    next >
Text File  |  1993-05-04  |  6KB  |  229 lines

  1. /*┌──────────────────────────────────────────────────────────────────────┐
  2.  ▌│ Program Name: MANAGED.PRG       Copyright: Gallagher Computing Corp. │
  3.  ▌│     Language: Clipper 5.2          Author: Kevin S Gallagher         │
  4.  ▌└──────────────────────────────────────────────────────────────────────┘
  5.  ▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀           */
  6.  
  7. #include "include1.h"
  8. #include "setcurs.ch"
  9.  
  10. #define USE_ESC
  11.  
  12. static cAutoBuff, cConfBuff, lExit
  13. static nARow, nACol, nCRow, nCCol
  14. static cWhichOne
  15.  
  16. function editor( cBuffer, nMode )
  17.     local SaveFullScreen(), oldcolor := setcolor(DOSCOLOR), getlist :={}
  18.     local oldins := readinsert(.t.), cShort, cLong
  19.  
  20.     cWhichOne := "AUTO"
  21.     nMode     := if(valtype(nMode)=="N",nMode,0)
  22.  
  23.     setcursor(1)
  24.  
  25.     nARow     :=  1
  26.     nACol     :=  0
  27.     nCRow     :=  1
  28.     nCCol     :=  0
  29.     lexit     := .f.
  30.     cAutoBuff := cBuffer[1]
  31.     cConfBuff := cBuffer[2]
  32.     cShort    := padr( subs(cBuffer[3],2), SHORTY )
  33.     cLong     := padr(      cBuffer[4],   76 )
  34.  
  35.     setkey( K_F10, { |p,n,v| GetCurrent(p,n,v) } )
  36.  
  37.     cls
  38.     dispbox(4,0,18,maxcol(),B_DOUBLE+" ",SAYCOLOR)
  39.  
  40.     CENTER( 6,"Edit/Create New PseudoName", SAYCOLOR)
  41.     CENTER( 9,"-PseudoName-", SAYCOLOR)
  42.     CENTER(14,"Long Description - Appears on Bottom Line", SAYCOLOR)
  43.  
  44.     @maxrow(), 0 say ;
  45.     padc("F10-key will automatically pull the existing Autoexec "+;
  46.     "and Config into editor",80) color MENUCOLOR
  47.  
  48.     //───── edit title and description of current configuration
  49.     @ 11,29 get cShort  picture "@!"  valid Valid_1()  color EDCOLORS
  50.     @ 15, 2 get cLong   picture "@!"  valid Valid_1()  color EDCOLORS
  51.     read
  52.  
  53.     setkey( K_F10, nil )
  54.  
  55.     if lastkey() <> K_ESC
  56.         if .not. ( cShort == subs( cBuffer[3], 2 ) )
  57.             cBuffer[3] := "1" + alltrim( cShort )
  58.         endif
  59.         if .not. ( cLong == cBuffer[4] )
  60.             cBuffer[4] := alltrim( cLong )
  61.         endif
  62.     endif
  63.     setcolor("gr+/bg")
  64.     cls
  65.     @MR,60 say "Line:       Col:"
  66.     @MR,1  say "F2=Save/Exit"                           color "n  /bg"
  67.     @MR,16 say "ESC=Abort/Exit"                         color "n  /bg"
  68.     @MR,34 say "F10=Toggle file"                        color "n  /bg"
  69.     setcolor(DOSCOLOR)
  70.     while .t.
  71.         do case
  72.             case lExit
  73.                 exit
  74.             case cWhichOne == "AUTO"
  75.                 EditAuto()
  76.             case cWhichOne == "CONF"
  77.                 EditConfig()
  78.         endcase
  79.     enddo
  80.  
  81.     do case
  82.         case lastkey() == K_F2
  83.             //───── save buffer(s)
  84.             cBuffer[1] := rtrim( strtran( cAutoBuff, chr(26), "" ) )
  85.             cBuffer[2] := rtrim( strtran( cConfBuff, chr(26), "" ) )
  86.         case lastkey() == K_ESC
  87.             //───── abort changes
  88.             cBuffer[1] := ""
  89.             cBuffer[2] := ""
  90.     endcase
  91.  
  92.     RestFullScreen()
  93.     readinsert(oldins)
  94.     setcolor(oldcolor)
  95.     setcursor(0)
  96. return cBuffer
  97.  
  98. function EditAuto()
  99.     @0 ,0  say "Editing autoexec  "                           color "w+ /bg"
  100.     @ 0,70 say if(readinsert(),"<INS>","     ") color "w+/bg"
  101.     cAutoBuff:= memoedit(cAutoBuff, 1, 0, MR-1, 79, .T., "AMemo", 250, 4,  ;
  102.                 nARow,nACol,nARow,nACol )
  103. return nil
  104.  
  105.  
  106. function EditConfig()
  107.     @0 ,0  say "Editing Config.sys"                           color "w+ /bg"
  108.     @ 0,70 say if(readinsert(),"<INS>","     ") color "w+/bg"
  109.     cConfBuff:= memoedit(cConfBuff, 1, 0, MR-1, 79, .T., "CMemo", 250, 4,  ;
  110.                 nCRow, nCCol, nCRow, nCCol )
  111. return nil
  112.  
  113.  
  114. ************************ MEMO EDIT User Define Functions ********************
  115.  
  116. function AMemo( nMode, nLin, nCol )
  117.    local nKey, nRetVal:= ME_DEFAULT
  118.  
  119.    nKey  := lastkey()
  120.    nARow := nLin
  121.    nACol := nCol
  122.  
  123.    #ifdef USE_ESC
  124.    if nKey == K_ESC
  125.        lExit   := .t.
  126.        return 23
  127.    endif
  128.    #endif
  129.  
  130.    if nMode == ME_IDLE
  131.        @MR,65 say nLin picture "999"  color "w+/bg"
  132.        @MR,76 say nCol picture "999"  color "w+/bg"
  133.    elseif nMode == ME_UNKEY .or. nMode == ME_UNKEYX
  134.        do case
  135.            case nKey == K_F10
  136.                cWhichOne := "CONF"
  137.                nRetVal := 23
  138.            case nKey == K_F2
  139.                lExit   := .t.
  140.                nRetVal := 23
  141.            case nKey == K_INS
  142.                nRetVal := ShowInsKey()
  143.        endcase
  144.    endif
  145. return (nRetVal)
  146.  
  147. function CMemo( nMode, nLin, nCol )
  148.    local nKey, nRetVal:= ME_DEFAULT
  149.  
  150.    nKey  := lastkey()
  151.    nCRow := nLin
  152.    nCCol := nCol
  153.  
  154.    #ifdef USE_ESC
  155.    if nKey == K_ESC
  156.        lExit   := .t.
  157.        return 23
  158.    endif
  159.    #endif
  160.  
  161.    if nMode == ME_IDLE
  162.        @MR,65 say nLin picture "999"  color "w+/bg"
  163.        @MR,76 say nCol picture "999"  color "w+/bg"
  164.    elseif nMode == ME_UNKEY .or. nMode == ME_UNKEYX
  165.        do case
  166.            case nKey == K_F10
  167.                cWhichOne := "AUTO"
  168.                nRetVal := 23
  169.            case nKey == K_F2
  170.                lExit   := .t.
  171.                nRetVal := 23
  172.            case nKey == K_INS
  173.                nRetVal := ShowInsKey()
  174.        endcase
  175.    endif
  176. return (nRetVal)
  177.  
  178. function EMemo( nMode, nLin, nCol )
  179.    local nKey, nRetVal:= ME_DEFAULT
  180.    nKey := lastkey()
  181.    if nMode == ME_IDLE
  182.        //
  183.    elseif nMode == ME_UNKEY .or. nMode == ME_UNKEYX
  184.        nRetVal := if(nKey == K_F10, 23, nRetVal )
  185.    endif
  186. return (nRetVal)
  187.  
  188.  
  189. function ShowInsKey()
  190.     @ 0,70 say if(readinsert(),"     ","<INS>") color "w+/bg"
  191. return K_INS
  192.  
  193. /*
  194. * this function is called to validate the title and descriptions
  195. * We allow no exit if the string begins with a "1" or if the get
  196. * is empty. The "1" would cause problems when retreiving any of
  197. * the configurations, since it is part of the search key.
  198. */
  199. #define TheGet getactive():varget()
  200. function Valid_1()
  201.     local RetVal := .t.
  202.     if empty( TheGet )
  203.         RetVal :=.f.
  204.     elseif isdigit( TheGet )
  205.         if left( TheGet,1 ) == "1" .or. left( TheGet,1 ) == "2"
  206.             RetVal := .f.
  207.         endif
  208.     endif
  209. return RetVal
  210.  
  211.  
  212. function GetCurrent( cName, nLine, cVar )
  213.     if file("c:\autoexec.bat")
  214.         cAutoBuff := memoread( "c:\autoexec.bat" )
  215.     else
  216.         //
  217.         // recovery here
  218.         //
  219.     endif
  220.     if file("c:\config.sys")
  221.         cConfBuff := memoread( "c:\config.sys" )
  222.     else
  223.         //
  224.         // recovery here
  225.         //
  226.     endif
  227. return nil
  228.  
  229.