#include <windows.h>
#include "app.h"

/*
 * Module: edit.c
 *
 * Contains: Edit window specific functions.  Messages
 * and menu commands directed to the Edit window should
 * be located here.
 *
 */


/*********************************************************************/
/* Local Function Prototypes                                         */
/*********************************************************************/


/*********************************************************************/
/* Local data and structures                                         */
/*********************************************************************/


/*********************************************************************/
/* Global functions                                                  */
/*********************************************************************/

/*-------------------------------------------------------------------*/
/* Edit window message processor                                     */
/*-------------------------------------------------------------------*/

long EditProc(hWnd, message, wParam, lParam)
HWND       hWnd;
unsigned   message;
WORD       wParam;
LONG       lParam;
{
  switch (message) {

    case WM_SETFOCUS:
      SetFocus(hEditWindow);
      break;

    case WM_SIZE:
      MoveWindow(hEditWindow, 0, 0, LOWORD(lParam), HIWORD(lParam), TRUE);
      break;

    default:
      return(DefWindowProc(hWnd, message, wParam, lParam));
    }

  return(0L);
}

/*-------------------------------------------------------------------*/
/* Edit window command processor                                     */
/*-------------------------------------------------------------------*/

void EditMenuCommand(hWnd, id)
HWND hWnd;
int id;
{
  LPSTR lpszText;

  switch (id) {
    case IDM_UNDO:
      SendMessage(hEditWindow,WM_UNDO,0,0L);
      break;

    case IDM_CLEAR:
      SendMessage(hEditWindow,WM_CLEAR,0,0L);
      break;

    case IDM_CUT:
      SendMessage(hEditWindow,WM_CUT,0,0L);
      break;

    case IDM_COPY:
      SendMessage(hEditWindow,WM_COPY,0,0L);
      break;

    case IDM_PASTE:
      SendMessage(hEditWindow,WM_PASTE,0, 0L);
      break;

    default:
      break;
  }
}


/*-------------------------------------------------------------------*/
/* Stuff some text into the Edit window.  Okay, okay I suppose the   */
/* real way to do this is to copy text into the clipboard and from   */
/* there insert it into the Edit window.  But after all, this is a   */
/* Sound *Hack* utility and by actually sending the Edit window a    */
/* message that it has received a character the job gets done.       */
/*-------------------------------------------------------------------*/

void EditPutString(str)
char *str;
{
  while (*str)
    SendMessage(hEditWindow, WM_CHAR, *str++, 0L);
}


/**********************************************************************/
/* Local functions                                                    */
/**********************************************************************/

