home *** CD-ROM | disk | FTP | other *** search
/ OS/2 Shareware BBS: 10 Tools / 10-Tools.zip / mitsch75.zip / scheme-7_5_17-src.zip / scheme-7.5.17 / src / microcode / nttty.c < prev    next >
C/C++ Source or Header  |  1999-01-02  |  3KB  |  125 lines

  1. /* -*-C-*-
  2.  
  3. $Id: nttty.c,v 1.8 1999/01/02 06:11:34 cph Exp $
  4.  
  5. Copyright (c) 1992-1999 Massachusetts Institute of Technology
  6.  
  7. This program is free software; you can redistribute it and/or modify
  8. it under the terms of the GNU General Public License as published by
  9. the Free Software Foundation; either version 2 of the License, or (at
  10. your option) any later version.
  11.  
  12. This program is distributed in the hope that it will be useful, but
  13. WITHOUT ANY WARRANTY; without even the implied warranty of
  14. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
  15. General Public License for more details.
  16.  
  17. You should have received a copy of the GNU General Public License
  18. along with this program; if not, write to the Free Software
  19. Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
  20. */
  21.  
  22. #include "nt.h"
  23. #include "ostty.h"
  24. #include "osenv.h"
  25. #include "ntio.h"
  26. #include "ntterm.h"
  27. #include "ntscreen.h"
  28.  
  29. /* Standard Input and Output */
  30.  
  31. static Tchannel input_channel;
  32. static Tchannel output_channel;
  33.  
  34. HANDLE master_tty_window = 0;
  35.  
  36. int tty_x_size;
  37. int tty_y_size;
  38.   /* 1-based values */
  39. static char * tty_command_beep;
  40. static char * tty_command_clear;
  41.  
  42. Tchannel
  43. OS_tty_input_channel (void)
  44. {
  45.   return (input_channel);
  46. }
  47.  
  48. Tchannel
  49. OS_tty_output_channel (void)
  50. {
  51.   return (output_channel);
  52. }
  53.  
  54. unsigned int
  55. OS_tty_x_size (void)
  56. {
  57.   Screen_GetSize (master_tty_window, (&tty_y_size), (&tty_x_size));
  58.   return (tty_x_size);
  59. }
  60.  
  61. unsigned int
  62. OS_tty_y_size (void)
  63. {
  64.   Screen_GetSize (master_tty_window, (&tty_y_size), (&tty_x_size));
  65.   return (tty_y_size);
  66. }
  67.  
  68. CONST char *
  69. OS_tty_command_beep (void)
  70. {
  71.   return (tty_command_beep);
  72. }
  73.  
  74. CONST char *
  75. OS_tty_command_clear (void)
  76. {
  77.   return (tty_command_clear);
  78. }
  79.  
  80. void
  81. NT_initialize_tty (void)
  82. {
  83.   input_channel = (NT_open_handle (master_tty_window));
  84.   (CHANNEL_INTERNAL (input_channel)) = 1;
  85.   output_channel = input_channel;
  86.   Screen_GetSize (master_tty_window, (&tty_y_size), (&tty_x_size));
  87.   tty_command_beep = ALERT_STRING;
  88.   tty_command_clear = "\014";
  89. }
  90.  
  91. /* Fake TERMCAP capability */
  92. short ospeed;
  93. char PC;
  94.  
  95. int
  96. tputs (string, nlines, outfun)
  97.      register char * string;
  98.      int nlines;
  99.      register int (*outfun) ();
  100. {
  101.   register int padcount = 0;
  102.  
  103.   if (string == (char *) 0)
  104.     return (0);
  105.   while (*string >= '0' && *string <= '9')
  106.   {
  107.     padcount += *string++ - '0';
  108.     padcount *= 10;
  109.   }
  110.   if (*string == '.')
  111.   {
  112.     string++;
  113.     padcount += *string++ - '0';
  114.   }
  115.   if (*string == '*')
  116.   {
  117.     string++;
  118.     padcount *= nlines;
  119.   }
  120.   while (*string)
  121.     (*outfun) (*string++);
  122.  
  123.   return (0);
  124. }
  125.