home *** CD-ROM | disk | FTP | other *** search
/ OS/2 Shareware BBS: 10 Tools / 10-Tools.zip / OL.LZH / PROCS.LZH / ISCREEN.ICN < prev    next >
Text File  |  1991-07-13  |  7KB  |  270 lines

  1. ############################################################################
  2. #
  3. #    Name:     iscreen.icn
  4. #
  5. #    Title:     Icon screen functions
  6. #
  7. #    Author:     Richard L. Goerwitz
  8. #
  9. #    Date:     June 7, 1991
  10. #
  11. #    Version: 1.19
  12. #
  13. ############################################################################
  14. #      clear()              - clears the screen (tries several methods)
  15. #      emphasize()          - initiates emphasized mode
  16. #      boldface()           - initiates bold mode
  17. #      normal()             - resets to normal mode
  18. #      message(s)           - displays message s on 2nd-to-last line
  19. #      underline()          - initiates underline mode
  20. #      status_line(s,s2,p)  - draws status line s on the 3rd-to-last
  21. #        screen line; if s is too short for the terminal, s2 is used;
  22. #        if p is nonnull then it either centers, left-, or right-justi-
  23. #        fies, depending on the value, "c," "l," or "r."
  24. #      clear_emphasize()    - horrible way of clearing the screen to all-
  25. #        emphasize mode; necessary for many terminals
  26. #
  27. ############################################################################
  28. #
  29. #  Requires: UNIX
  30. #
  31. ############################################################################
  32. #
  33. #  Links: itlib.icn (or your OS-specific port of itlib)
  34. #
  35. ############################################################################
  36. #
  37. #  See also: boldface.icn
  38. #
  39. ############################################################################
  40.  
  41. link itlib
  42.  
  43. procedure clear()
  44.     local i
  45.  
  46.     # Clears the screen.  Tries several methods.
  47.  
  48.     normal()
  49.     if not iputs(getval("cl"))
  50.     then iputs(igoto(getval("cm"),1,1))
  51.     if not iputs(getval("cd"))
  52.     then {
  53.     every i := 1 to getval("li") do {
  54.         iputs(igoto(getval("cm"),1,i))
  55.         iputs(getval("ce"))
  56.     }
  57.     iputs(igoto(getval("cm"),1,1))
  58.     }
  59.     return
  60.  
  61. end
  62.  
  63.  
  64.  
  65. procedure boldface()
  66.     local u
  67.     
  68.     static bold_str, cookie_str
  69.     initial {
  70.     if bold_str := getval("md")
  71.     then cookie_str := repl(getval("bc") | "\b", getval("mg"))
  72.     else {
  73.         # One global procedure value substituted for another.
  74.         boldface := emphasize
  75.         return emphasize()
  76.     }
  77.     }        
  78.  
  79.     normal()
  80.     iputs(\bold_str)
  81.     iputs(\cookie_str)
  82.     return
  83.  
  84. end
  85.  
  86.  
  87.  
  88. procedure emphasize()
  89.     
  90.     static emph_str, cookie_str
  91.     initial {
  92.     if emph_str := getval("so")
  93.     then cookie_str := repl(getval("bc") | "\b", getval("sg"))
  94.     else {
  95.         if emph_str := getval("us")
  96.         then cookie_str := repl(getval("bc") | "\b", getval("ug"))
  97.     }
  98.     }        
  99.  
  100.     normal()
  101.     iputs(\emph_str)
  102.     iputs(\cookie_str)
  103.     return
  104.  
  105. end
  106.  
  107.  
  108.  
  109. procedure underline()
  110.     
  111.     static underline_str, cookie_str
  112.     initial {
  113.     if underline_str := getval("us")
  114.     then cookie_str := repl(getval("bc") | "\b", getval("sg"))
  115.     }        
  116.  
  117.     normal()
  118.     iputs(\underline_str)
  119.     iputs(\cookie_str)
  120.     return
  121.  
  122. end
  123.  
  124.  
  125.  
  126. procedure normal(mode)
  127.  
  128.     static UN_emph_str, emph_cookie_str,
  129.     UN_underline_str, underline_cookie_str,
  130.     UN_bold_str, bold_cookie_str
  131.  
  132.     initial {
  133.  
  134.     # Find out code to turn off emphasize (reverse video) mode.
  135.     if UN_emph_str := getval("se") then
  136.         # Figure out how many backspaces we need to erase cookies.
  137.         emph_cookie_str := repl(getval("bc") | "\b", getval("sg"))
  138.  
  139.     # Finally, figure out how to turn off underline mode.
  140.     if UN_underline_str := (UN_emph_str ~== getval("ue")) then
  141.         underline_cookie_str := repl(getval("bc")|"\b", getval("ug"))
  142.  
  143.     # Figure out how to turn off boldface mode.
  144.     if UN_bold_str := 
  145.         (UN_underline_str ~== (UN_emph_str ~== getval("me"))) then
  146.         # Figure out how many backspaces we need to erase cookies.
  147.         bold_cookie_str := repl(getval("bc") | "\b", getval("mg"))
  148.  
  149.     }        
  150.     
  151.     iputs(\UN_emph_str) &
  152.     iputs(\emph_cookie_str)
  153.  
  154.     iputs(\UN_underline_str) &
  155.     iputs(\underline_cookie_str)
  156.  
  157.     iputs(\UN_bold_str) &
  158.     iputs(\bold_cookie_str)
  159.  
  160.     return
  161.  
  162. end
  163.  
  164.  
  165.  
  166. procedure status_line(s,s2,p)
  167.  
  168.     # Writes a status line on the terminal's third-to-last line
  169.     # The only necessary argument is s.  S2 (optional) is used
  170.     # for extra narrow screens.  In other words, by specifying
  171.     # s2 you give status_line an alternate, shorter status string
  172.     # to display, in case the terminal isn't wide enough to sup-
  173.     # port s.  If p is nonnull, then the status line is either
  174.     # centered (if equal to "c"), left justified ("l"), or right
  175.     # justified ("r").
  176.  
  177.     local width
  178.  
  179.     /s := ""; /p := "c"
  180.     width := getval("co")
  181.     if *s > width then {
  182.     (*s2 < width, s := \s2) |
  183.         er("status_line","Your terminal is too narrow.",4)
  184.     }
  185.  
  186.     case p of {
  187.     "c"    : s := center(s,width)
  188.     "l"    : s := left(s,width)
  189.     "r"    : s := right(s,width)
  190.     default: stop("status_line:  Unknown option "||string(p),4)
  191.     }
  192.  
  193.     iputs(igoto(getval("cm"), 1, getval("li")-2))
  194.     emphasize(); writes(s)
  195.     normal()
  196.     return
  197.  
  198. end
  199.  
  200.  
  201.  
  202. procedure message(s)
  203.  
  204.     # Display prompt s on the second-to-last line of the screen.
  205.     # I hate to use the last line, due to all the problems with
  206.     # automatic scrolling.
  207.  
  208.     /s := ""
  209.     normal()
  210.     iputs(igoto(getval("cm"), 1, getval("li")-1))
  211.     writes(s[1:getval("co")] | s)
  212.     iputs(getval("ce"))
  213.     return
  214.  
  215. end
  216.  
  217.  
  218.  
  219. procedure clear_underline()
  220.     local i
  221.  
  222.     # Horrible way of clearing the screen to all underline mode, but
  223.     # the only apparent way we can do it "portably" using the termcap
  224.     # capability database.
  225.  
  226.     underline()
  227.     iputs(igoto(getval("cm"),1,1))
  228.     if getval("am") then {
  229.     underline()
  230.         every 1 to (getval("li")-1) * getval("co") do
  231.         writes(" ")
  232.     }
  233.     else {
  234.     every i := 1 to getval("li")-1 do {
  235.         iputs(igoto(getval("cm"), 1, i))
  236.         underline()
  237.         writes(repl(" ",getval("co")))
  238.     }
  239.     }
  240.     iputs(igoto(getval("cm"),1,1))
  241.  
  242. end
  243.  
  244.  
  245.  
  246. procedure clear_emphasize()
  247.     local i
  248.  
  249.     # Horrible way of clearing the screen to all reverse-video, but
  250.     # the only apparent way we can do it "portably" using the termcap
  251.     # capability database.
  252.  
  253.     emphasize()
  254.     iputs(igoto(getval("cm"),1,1))
  255.     if getval("am") then {
  256.     emphasize()
  257.         every 1 to (getval("li")-1) * getval("co") do
  258.         writes(" ")
  259.     }
  260.     else {
  261.     every i := 1 to getval("li")-1 do {
  262.         iputs(igoto(getval("cm"), 1, i))
  263.         emphasize()
  264.         writes(repl(" ",getval("co")))
  265.     }
  266.     }
  267.     iputs(igoto(getval("cm"),1,1))
  268.  
  269. end
  270.