grub-terminfo.in 2.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596
  1. #! /bin/sh
  2. # Generate a terminfo command from a terminfo name.
  3. #
  4. # Copyright (C) 2002 Free Software Foundation, Inc.
  5. #
  6. # This file is free software; you can redistribute it and/or modify it
  7. # under the terms of the GNU General Public License as published by
  8. # the Free Software Foundation; either version 2 of the License, or
  9. # (at your option) any later version.
  10. #
  11. # This program is distributed in the hope that it will be useful, but
  12. # WITHOUT ANY WARRANTY; without even the implied warranty of
  13. # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
  14. # General Public License for more details.
  15. #
  16. # You should have received a copy of the GNU General Public License
  17. # along with this program; if not, write to the Free Software
  18. # Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
  19. VERSION=@VERSION@
  20. usage () {
  21. cat <<EOF
  22. Usage: grub-terminfo TERMNAME
  23. Generate a terminfo command from a terminfo name.
  24. -h, --help print this message and exit
  25. -v, --version print the version information and exit
  26. Report bugs to <bug-grub@gnu.org>.
  27. EOF
  28. }
  29. error () {
  30. echo "grub-terminfo: error: $1" 1>&2
  31. }
  32. termname=
  33. for option in "$@"; do
  34. case "$option" in
  35. -h | --help)
  36. usage
  37. exit 0 ;;
  38. -v | --version)
  39. echo "grub-terminfo (GNU GRUB ${VERSION})"
  40. exit 0 ;;
  41. -*)
  42. error "Unrecognized option \`$option'"
  43. usage
  44. exit 1 ;;
  45. *)
  46. if test "x$termname" != x; then
  47. error "More than one terminfo names?"
  48. usage
  49. exit 1
  50. fi
  51. termname="$option" ;;
  52. esac
  53. done
  54. if test "x$termname" = x; then
  55. error "termname not specified"
  56. usage
  57. exit 1
  58. fi
  59. get_seq () {
  60. infocmp -L -1 -g $termname | sed -n -e "/$1/s/^[^=]*=\\(.*\\),\$/\\1/p"
  61. }
  62. cursor_address="`get_seq cursor_address`"
  63. if test "x$cursor_address" = x; then
  64. error "cursor_address not found"
  65. exit 1
  66. fi
  67. cursor_address="--cursor-address=$cursor_address"
  68. clear_screen="`get_seq clear_screen`"
  69. if test "x$clear_screen" != x; then
  70. clear_screen="--clear-screen=$clear_screen"
  71. fi
  72. enter_standout_mode="`get_seq enter_standout_mode`"
  73. if test "x$enter_standout_mode" != x; then
  74. enter_standout_mode="--enter-standout-mode=$enter_standout_mode"
  75. fi
  76. exit_standout_mode="`get_seq exit_standout_mode`"
  77. if test "x$exit_standout_mode" != x; then
  78. exit_standout_mode="--exit-standout-mode=$exit_standout_mode"
  79. fi
  80. echo "terminfo --name=$termname" $cursor_address $clear_screen \
  81. $enter_standout_mode $exit_standout_mode