home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
OS/2 Shareware BBS: 5 Edit
/
05-Edit.zip
/
NOTEPAD2.ZIP
/
NPCMD.C
< prev
next >
Wrap
C/C++ Source or Header
|
1989-02-08
|
7KB
|
292 lines
/***************************************************************************\
* npcmd.c - notepad command processing
*
* Created by Microsoft Corporation, 1989
\***************************************************************************/
#define INCL_WIN
#include <os2.h>
#include <stdio.h>
#include <string.h>
#include <opendlg.h>
#include "notepad.h"
#include "npcmd.h"
#include "npabout.h"
/************* PROCEDURE DECLARATIONS */
static VOID SetShowMsg(char *psz)
{
int i;
/* This is for debugging. Print the string, as you wish */
i = strlen(psz);
}
VOID CmdNew(VOID)
{
switch (NPCheckSave()) {
case MBID_CANCEL:
SetShowMsg("New command -- cancel");
break;
default:
SetShowMsg("New command -- going through");
fNamed = FALSE;
NPClear();
break;
}
return;
}
VOID CmdOpen(VOID)
{
switch (NPCheckSave()) {
case MBID_CANCEL:
SetShowMsg("Open command -- cancel");
break;
default:
SetShowMsg("Going through with open-read");
NPOpenRead();
break;
}
return;
}
VOID CmdSave(VOID)
{
if (fNamed)
NPSave();
else
NPSaveAs();
return;
}
VOID CmdSaveAs(VOID)
{
NPSaveAs();
return;
}
VOID CmdPrint(VOID)
{
SetShowMsg("Print command");
NPPrint();
return;
}
VOID CmdExit(VOID)
{
WinSendMsg(hwndNP,WM_CLOSE,0l,0l);
}
VOID CmdAbout(VOID)
{
SetShowMsg("About... command");
WinDlgBox(HWND_DESKTOP,
hwndNP,
WinDefDlgProc,
NULL,
DLG_ABOUT,
NULL);
return;
}
VOID CmdUndo(VOID)
{
SetShowMsg("Undo command");
return;
}
VOID CmdCut(VOID)
{
SetShowMsg("Cut command");
WinSendMsg(hwndNPEdit, EM_SETSEL,
WinSendMsg(hwndNPEdit, EM_QUERYSEL, (MPARAM)3L, NULL),
WinSendMsg(hwndNPEdit, EM_QUERYSEL, (MPARAM)4L, NULL));
if (!WinSendMsg(hwndNPEdit, EM_CUT, 0L, 0L)) {
WinAlarm(HWND_DESKTOP,WA_WARNING);
}
return;
}
VOID CmdCopy(VOID)
{
if (!WinSendMsg(hwndNPEdit, EM_COPY, 0L, 0L)) {
WinAlarm(HWND_DESKTOP,WA_WARNING);
}
return;
}
VOID CmdPaste(VOID)
{
SetShowMsg("Paste command");
WinSendMsg(hwndNPEdit, EM_SETSEL,
WinSendMsg(hwndNPEdit, EM_QUERYSEL, (MPARAM)3L, NULL),
WinSendMsg(hwndNPEdit, EM_QUERYSEL, (MPARAM)4L, NULL));
if (!WinSendMsg(hwndNPEdit, EM_PASTE, 0L, 0L)) {
WinAlarm(HWND_DESKTOP,WA_WARNING);
}
return;
}
VOID CmdClear(VOID)
{
SetShowMsg("Clear command");
WinSendMsg(hwndNPEdit, EM_SETSEL,
WinSendMsg(hwndNPEdit, EM_QUERYSEL, (MPARAM)3L, NULL),
WinSendMsg(hwndNPEdit, EM_QUERYSEL, (MPARAM)4L, NULL));
if (!WinSendMsg(hwndNPEdit, EM_CLEAR, 0L, 0L)) {
WinAlarm(HWND_DESKTOP,WA_WARNING);
}
return;
}
VOID CmdSelectAll(VOID)
{
SetShowMsg("SelectAll command");
if (!WinSendMsg(hwndNPEdit, EM_SETSEL,
(MPARAM)(0),
(MPARAM)WinSendMsg(hwndNPEdit,EM_QTL,NULL,NULL))) {
WinAlarm(HWND_DESKTOP,WA_WARNING);
}
return;
}
VOID CmdDateTime(VOID)
{
char dtBuff[40];
IPT iptBegin;
fmtDateTime(dtBuff);
WinSendMsg(hwndNPEdit, EM_CLEAR, 0L, 0L);
iptBegin = LONGFROMMR(WinSendMsg(hwndNPEdit, EM_QUERYSEL,
MPFROMSHORT(2), NULL));
WinSendMsg(hwndNPEdit, EM_SETIMPORTEXPORT,
MPFROMP(dtBuff), MPFROMSHORT(40));
WinSendMsg(hwndNPEdit, EM_SETSEL,
WinSendMsg(hwndNPEdit, EM_QUERYSEL, (MPARAM)3L, NULL),
WinSendMsg(hwndNPEdit, EM_QUERYSEL, (MPARAM)4L, NULL));
WinSendMsg(hwndNPEdit, EM_IMPORT, MPFROMLONG(iptBegin),
MPFROMSHORT(lstrlen(dtBuff)));
}
VOID CmdFind(VOID)
{
SetShowMsg("Find command");
switch (WinDlgBox(HWND_DESKTOP,
hwndNP,
SearchDlgProc,
NULL,
DLG_SEARCH,
NULL)) {
case MBID_OK:
DoSearch();
break;
case MBID_CANCEL:
break;
default:
break;
}
return;
}
VOID CmdReplace(VOID)
{
SetShowMsg("Replace command");
switch (WinDlgBox(HWND_DESKTOP,
hwndNP,
ReplaceDlgProc,
NULL,
DLG_REPLACE,
NULL)) {
case MBID_OK:
DoReplace();
break;
case MBID_CANCEL:
break;
default:
break;
}
return;
}
VOID CmdNextSearch(VOID)
{
SetShowMsg("NextSearch command");
DoNextSearchRep();
return;
}
VOID CmdWordWrap(VOID)
{
SetWordWrap(!fWordWrapOn);
SetShowMsg("WordWrapCommand");
}
VOID SetWordWrap(BOOL fOn)
{
fWordWrapOn = fOn;
WinSendMsg(hwndNPMenu,
MM_SETITEMATTR,
MPFROM2SHORT(CMD_WRAPTOGGLE,TRUE),
MPFROM2SHORT(MIA_CHECKED,fOn?MIA_CHECKED:0));
WinSendMsg(hwndNPEdit,
EM_SETWRAP,
MPFROMSHORT(fWordWrapOn),
NULL);
}
VOID CmdSetTab(VOID)
{
SetShowMsg("Set tab command");
WinDlgBox(HWND_DESKTOP,
hwndNP,
TabDlgProc,
NULL,
DLG_TAB,
NULL);
return;
}
VOID CmdQueryFont(VOID)
{
}
VOID CmdParseLine(int argc, char **argv)
{
if (argc <= 1) {
return;
} else if (argc > 2) {
fInitError = TRUE;
} else {
lstrcpy(szLoadFileName,*(argv+1));
fInitLoad = TRUE;
}
}
VOID CmdCmdLine(VOID) {
if (fInitError) {
WinAlarm(HWND_DESKTOP, WA_WARNING);
WinMessageBox(HWND_DESKTOP,
hwndNP,
"Usage: np [file]",
NULL,
0,
MB_OK | MB_ICONEXCLAMATION | MB_APPLMODAL);
} else if (fInitLoad) {
if (!NPLoadNamedFile((PSZ)szLoadFileName)) {
WinAlarm(HWND_DESKTOP, WA_WARNING);
WinMessageBox(HWND_DESKTOP,
hwndNP,
"Couldn't load startup file",
NULL,
0,
MB_OK | MB_ICONEXCLAMATION | MB_APPLMODAL);
}
}
}