home *** CD-ROM | disk | FTP | other *** search
/ Skunkware 98 / Skunkware 98.iso / osr5 / sco / scripts / stfix < prev    next >
Encoding:
AWK Script  |  1997-08-26  |  1.8 KB  |  63 lines

  1. #!/usr/local/bin/gawk -f
  2. # @(#) stfix.gawk 2.2 97/07/17
  3. # 95/07/24 john h. dubois iii (john@armory.com)
  4. # 96/12/11 Rewrote as awk program (based on tabset).
  5. # 97/06/27 Added fg/bg color and scrolling region reset.
  6. # 97/07/17 2.2 Added keyboard unlock, autowrap on, character set reset,
  7. #          jump scroll (unset smooth scroll).  Save & restore cursor position.
  8.  
  9. # CSI is the Control Sequence Introducer, ESC[
  10. # CSI[0;37;40m removes attributes and sets white on black (default colors)
  11. # CSI2l unlocks keyboard
  12. # CSI?7h turns autowrap on.
  13. # ESEC(B sets G0 character set to US ASCII.
  14. # ESC)B sets G1 character set to US ASCII.
  15. # \017 selects G0 character set.
  16. # CSIr removes scrolling region.
  17. # CSI?4l sets jump scroll
  18.  
  19. # CSIr moves cursor to top of screen, so save cursor position (ESC7) before
  20. # emitting anything and restore it (ESC8) afterward.
  21.  
  22. BEGIN {
  23.     Name = "settabs"
  24.     Reset = "ESC7CSI0;37;40mCSI2lCSI?7hESC(BESC)B\017CSIrCSI?4lCSI10nCSI=XESC8"
  25.     gsub("CSI","\033[",Reset)
  26.     gsub("ESC","\033",Reset)
  27.     for (tabstop = 0; tabstop <= 9; tabstop++)
  28.     Reset = Reset "        \033H"
  29.  
  30.     if (ARGC < 2)
  31.     printf "%s",Reset
  32.     else {
  33.     if (ARGV[1] ~ /^[-+]h$/) {
  34.         printf \
  35. "%s: Reset scoterm\n"\
  36. "Usage: %s [-ah] [ttynn ...]\n"\
  37. "A string is emitted to reset the pointer behaviour, background and\n"\
  38. "foreground colors, character set, and scrolling region, turn autowrap on,\n"\
  39. "and unlock the keyboard.  If no ttys are named, the string is emitted to\n"\
  40. "the current screen.\n"\
  41. "Options:\n"\
  42. "-h: print this help.\n",
  43.         Name,Name
  44.         exit(0)
  45.     }
  46.     else {
  47.         for (i = 1; i in ARGV; i++) {
  48.         screen = ARGV[i]
  49.         if (screen !~ "^/") {
  50.             if (screen !~ /^tty/) {
  51.             if (screen !~ /^p/)
  52.                 screen = "p" screen
  53.             screen = "tty" screen
  54.             }
  55.             screen = "/dev/" screen
  56.         }
  57.         printf "%s",Reset > screen
  58.         close(screen)
  59.         }
  60.     }
  61.     }
  62. }
  63.