home *** CD-ROM | disk | FTP | other *** search
/ Programmer 7500 / MAX_PROGRAMMERS.iso / INFO / MODEM / UWPC201.ZIP / UW-SRC.ZIP / CLIENT.CPP < prev    next >
Encoding:
C/C++ Source or Header  |  1991-10-31  |  3.5 KB  |  94 lines

  1. //-------------------------------------------------------------------------
  2. //
  3. // CLIENT.CPP - Declarations for creating UW clients within UW/PC.
  4. // 
  5. //  This file is part of UW/PC - a multi-window comms package for the PC.
  6. //  Copyright (C) 1990-1991  Rhys Weatherley
  7. //
  8. //  This program is free software; you can redistribute it and/or modify
  9. //  it under the terms of the GNU General Public License as published by
  10. //  the Free Software Foundation; either version 1, or (at your option)
  11. //  any later version.
  12. //
  13. //  This program is distributed in the hope that it will be useful,
  14. //  but WITHOUT ANY WARRANTY; without even the implied warranty of
  15. //  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  16. //  GNU General Public License for more details.
  17. //
  18. //  You should have received a copy of the GNU General Public License
  19. //  along with this program; if not, write to the Free Software
  20. //  Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
  21. //
  22. // Revision History:
  23. // ================
  24. //
  25. //  Version  DD/MM/YY  By  Description
  26. //  -------  --------  --  --------------------------------------
  27. //    1.0    20/03/91  RW  Original Version of CLIENT.CPP
  28. //
  29. // You may contact the author by:
  30. // =============================
  31. //
  32. //  e-mail: rhys@cs.uq.oz.au
  33. //    mail: Rhys Weatherley
  34. //          5 Horizon Drive
  35. //          Jamboree Heights
  36. //          Queensland 4074
  37. //        Australia
  38. //
  39. //-------------------------------------------------------------------------
  40.  
  41. #include "client.h"        // Declarations for this module
  42. #include "display.h"        // Window display declarations
  43. #include "config.h"        // Configuration routines
  44. #include "uw.h"            // Main UW protocol declarations
  45. #include "comms.h"        // Direct serial comms routines
  46. #include "clipbd.h"        // Clipboard processing routines
  47. #include "mouse.h"        // Mouse handling routines
  48.  
  49. #pragma    warn    -par
  50.  
  51. // Process the mouse events in the default way by
  52. // implementing a cut-and-paste operation.
  53. void    UWTerminal::mouse (int x,int y,int buttons)
  54. {
  55. #ifdef    UWPC_DOS
  56.   if (buttons & MOUSE_LEFT)            // Check for start of cut.
  57.     new UWCutToClipboard (window,1,x,y);
  58.    else if (buttons & MOUSE_RIGHT)        // Check for a paste.
  59.     new UWPasteFromClipboard (window);
  60. #endif
  61. } // UWTerminal::mouse //
  62.  
  63. // Process a user's keypress.  This will only be called
  64. // if this client is using the top-most displayed window.
  65. void    UWTerminal::key (int keypress)
  66. {
  67.   if ((keypress == 021 || keypress == 023) && !UWConfig.XonXoffFlag)
  68.     comsend (UWConfig.ComPort,keypress); // Send XON/XOFF direct.
  69.    else if (keypress == 8 && UWConfig.SwapBSKeys)
  70.     send (127);            // Swap BS and DEL.
  71.    else if (keypress == 127 && UWConfig.SwapBSKeys)
  72.     send (8);
  73.    else if (keypress >= 0 && keypress <= 255)
  74.     send (keypress);        // Send the ASCII key over the serial line.
  75.    else
  76.     defkey (keypress);        // Process the keypress in the default way.
  77. } // UWTerminal::key //
  78.  
  79. // Process a character from the remote server.  This may
  80. // be called at any time while the client is active.
  81. void    UWTerminal::remote (int ch)
  82. {
  83.   switch (ch)
  84.     {
  85.       case '\0': break;                // Ignore NULs
  86.       case '\r': window -> cr (); break;
  87.       case '\n': window -> lf (); break;
  88.       case '\b': window -> bs (); break;
  89.       case '\t': window -> tab (); break;
  90.       case  007: window -> bell (); break;
  91.       default:     window -> send (ch,0); break;    // Send character directly
  92.     } /* switch */
  93. } // UWTerminal::remote //
  94.