home *** CD-ROM | disk | FTP | other *** search
/ Power-Programmierung / CD1.mdf / lan / chat / edit.c < prev    next >
C/C++ Source or Header  |  1989-03-22  |  2KB  |  100 lines

  1. /******************************************************************************
  2.  *
  3.  *    Program Name:    TALK_TO.ME 
  4.  *
  5.  *    Filename:    EDIT.C -- 10/25/88
  6.  *
  7.  *    Purpose:  Displays keyboard input and enters the input in a buffer
  8.  *
  9.  ******************************************************************************/
  10.  
  11. #include <stdio.h>
  12. #include <dos.h>
  13. #include <nit.h>
  14. #include "chat.h"
  15.  
  16. void     Dispatcher();
  17. void     DisplayChar();
  18. int         InputChar();
  19. void     DeleteChar();
  20. void     DisplayOff();
  21.  
  22. extern int    PRINT_FLAG,
  23.             RECEIVE_FLAG;
  24.  
  25. char    charBuffer;
  26.  
  27. int     sendRow = TOP_SEND_ROW,
  28.         sendCol = FIRST_TEXT_COL,
  29.         receiveRow = TOP_RECEIVE_ROW,
  30.         receiveCol = FIRST_TEXT_COL;
  31.  
  32.  
  33. void Dispatcher(key)
  34. char    key;
  35. {
  36.     int        ccode;
  37.  
  38.     if (key == TAB)
  39.         ClearSendBox();
  40.     
  41.     else if (key == ENTER)
  42.     {
  43.         sendRow++;
  44.         if (sendRow > LAST_SEND_ROW) 
  45.         {
  46.             sendRow = LAST_SEND_ROW;
  47.             ScrollUp (1, TOP_SEND_ROW, LAST_SEND_ROW, FIRST_TEXT_COL, LAST_TEXT_COL);
  48.         }
  49.         sendCol = FIRST_TEXT_COL;
  50.         SetCursor(sendRow,sendCol);
  51.     }
  52.     
  53.     else if (key == BACKSPACE)
  54.     {
  55.         if (sendCol > FIRST_TEXT_COL)
  56.             DeleteChar (&sendCol, &sendRow);
  57.     }
  58.     
  59.     else if ( key == 0 || (key > 6 && key < 20) )
  60.     {
  61.         key = 2;
  62.         DisplayChar(key);
  63.     }
  64.     else
  65.         DisplayChar(key);
  66.     
  67.     SendPacket(&key);
  68. }                        
  69.  
  70.  
  71. void DisplayChar(key)
  72. char    key;
  73. {
  74.     if(sendCol == LAST_TEXT_COL)
  75.     {
  76.         sendCol = FIRST_TEXT_COL;
  77.         sendRow++;
  78.         if (sendRow > LAST_SEND_ROW) 
  79.         {
  80.             sendRow = LAST_SEND_ROW;
  81.             ScrollUp (1, TOP_SEND_ROW, LAST_SEND_ROW, FIRST_TEXT_COL, LAST_TEXT_COL);
  82.         }
  83.     }
  84.     SetCursor(sendRow,sendCol++);
  85.     WriteChar(key);
  86.     SetCursor(sendRow,sendCol);
  87. }
  88.  
  89.  
  90. void DeleteChar(col,row)
  91. int        *col, *row;
  92. {
  93.     --*col;
  94.     SetCursor(*row, *col);
  95.     WriteChar(' ');
  96.     SetCursor(*row, *col);
  97. }
  98.  
  99.  
  100.