2000-03-05 19:58:08 +00:00
|
|
|
|
/* --------------- edit.c ----------- */
|
|
|
|
|
|
|
|
|
|
#include "dflat.h"
|
|
|
|
|
|
2003-06-19 02:48:13 +00:00
|
|
|
|
extern DF_DBOX PrintSetup;
|
2000-03-05 19:58:08 +00:00
|
|
|
|
|
|
|
|
|
char DFlatApplication[] = "Edit";
|
|
|
|
|
|
|
|
|
|
static char Untitled[] = "Untitled";
|
|
|
|
|
|
|
|
|
|
static int wndpos;
|
|
|
|
|
|
2003-06-19 02:48:13 +00:00
|
|
|
|
static int MemoPadProc(DFWINDOW, DFMESSAGE, DF_PARAM, DF_PARAM);
|
2000-03-05 19:58:08 +00:00
|
|
|
|
static void NewFile(DFWINDOW,char *);
|
|
|
|
|
static void SelectFile(DFWINDOW);
|
|
|
|
|
static void PadWindow(DFWINDOW, char *);
|
|
|
|
|
static void OpenPadWindow(DFWINDOW, char *,char *);
|
|
|
|
|
static void LoadFile(DFWINDOW);
|
|
|
|
|
static void PrintPad(DFWINDOW);
|
|
|
|
|
static void SaveFile(DFWINDOW, int);
|
|
|
|
|
static void EditDeleteFile(DFWINDOW);
|
2003-06-19 02:48:13 +00:00
|
|
|
|
static int EditorProc(DFWINDOW, DFMESSAGE, DF_PARAM, DF_PARAM);
|
2000-03-05 19:58:08 +00:00
|
|
|
|
static char *NameComponent(char *);
|
2003-06-19 02:48:13 +00:00
|
|
|
|
static int PrintSetupProc(DFWINDOW, DFMESSAGE, DF_PARAM, DF_PARAM);
|
2000-03-05 19:58:08 +00:00
|
|
|
|
static void FixTabMenu(void);
|
|
|
|
|
#ifndef TURBOC
|
|
|
|
|
void Calendar(DFWINDOW);
|
|
|
|
|
#endif
|
|
|
|
|
//void BarChart(DFWINDOW);
|
|
|
|
|
char **Argv;
|
|
|
|
|
|
|
|
|
|
#define CHARSLINE 80
|
|
|
|
|
#define LINESPAGE 66
|
|
|
|
|
|
|
|
|
|
int main (int argc, char *argv[])
|
|
|
|
|
{
|
|
|
|
|
DFWINDOW wnd;
|
|
|
|
|
FILE *fp;
|
2000-03-08 01:49:37 +00:00
|
|
|
|
|
|
|
|
|
if (DfInitialize () == FALSE)
|
2000-03-05 19:58:08 +00:00
|
|
|
|
return 1;
|
2000-03-08 01:49:37 +00:00
|
|
|
|
|
2000-03-05 19:58:08 +00:00
|
|
|
|
Argv = argv;
|
2003-06-19 02:48:13 +00:00
|
|
|
|
DfLoadConfig ();
|
|
|
|
|
// if (!DfLoadConfig())
|
|
|
|
|
// DfCfg.ScreenLines = DF_SCREENHEIGHT;
|
|
|
|
|
wnd = DfDfCreateWindow (DF_APPLICATION,
|
|
|
|
|
"FreeDos Edit " DF_VERSION,
|
2000-03-05 19:58:08 +00:00
|
|
|
|
0, 0, -1, -1,
|
2003-06-19 02:48:13 +00:00
|
|
|
|
&DfMainMenu,
|
2000-03-05 19:58:08 +00:00
|
|
|
|
NULL,
|
|
|
|
|
MemoPadProc,
|
2003-06-19 02:48:13 +00:00
|
|
|
|
// DF_MOVEABLE |
|
|
|
|
|
// DF_SIZEABLE |
|
|
|
|
|
// DF_HASBORDER |
|
|
|
|
|
// DF_MINMAXBOX |
|
|
|
|
|
DF_HASSTATUSBAR);
|
2000-03-05 19:58:08 +00:00
|
|
|
|
|
2003-06-19 02:48:13 +00:00
|
|
|
|
DfLoadHelpFile ();
|
|
|
|
|
DfSendMessage (wnd, DFM_SETFOCUS, TRUE, 0);
|
2000-03-05 19:58:08 +00:00
|
|
|
|
|
|
|
|
|
// Load the files from args - if the file does not exist, open a new window....
|
|
|
|
|
while (argc > 1)
|
|
|
|
|
{
|
|
|
|
|
// check if the file exists....
|
|
|
|
|
if (( fp = fopen(argv[1],"r")) == NULL )
|
|
|
|
|
{
|
|
|
|
|
// file does not exist - create new window
|
|
|
|
|
NewFile(wnd,argv[1]);
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
PadWindow(wnd, argv[1]);
|
|
|
|
|
--argc;
|
|
|
|
|
argv++;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
while (DfDispatchMessage ())
|
|
|
|
|
;
|
|
|
|
|
|
2000-03-08 01:49:37 +00:00
|
|
|
|
DfTerminate ();
|
|
|
|
|
|
2000-03-05 19:58:08 +00:00
|
|
|
|
return 0;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* ------ open text files and put them into editboxes ----- */
|
|
|
|
|
static void PadWindow(DFWINDOW wnd, char *FileName)
|
|
|
|
|
{
|
|
|
|
|
int ax;
|
|
|
|
|
struct _finddata_t ff;
|
|
|
|
|
char path[MAX_PATH];
|
|
|
|
|
char *cp;
|
|
|
|
|
|
2003-06-19 02:48:13 +00:00
|
|
|
|
DfCreatePath(path, FileName, FALSE, FALSE);
|
2000-03-05 19:58:08 +00:00
|
|
|
|
cp = path+strlen(path);
|
2003-06-19 02:48:13 +00:00
|
|
|
|
DfCreatePath(path, FileName, TRUE, FALSE);
|
2000-03-05 19:58:08 +00:00
|
|
|
|
ax = _findfirst(path, &ff);
|
|
|
|
|
if (ax == -1)
|
|
|
|
|
return;
|
|
|
|
|
do
|
|
|
|
|
{
|
|
|
|
|
strcpy(cp, ff.name);
|
|
|
|
|
OpenPadWindow(wnd, path,NULL);
|
|
|
|
|
}
|
|
|
|
|
while (_findnext(ax, &ff) == 0);
|
|
|
|
|
_findclose (ax);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* ------- window processing module for the
|
|
|
|
|
Edit application window ----- */
|
2003-06-19 02:48:13 +00:00
|
|
|
|
static int MemoPadProc(DFWINDOW wnd,DFMESSAGE msg,DF_PARAM p1,DF_PARAM p2)
|
2000-03-05 19:58:08 +00:00
|
|
|
|
{
|
|
|
|
|
int rtn;
|
|
|
|
|
switch (msg)
|
|
|
|
|
{
|
2003-06-19 02:48:13 +00:00
|
|
|
|
case DFM_CREATE_WINDOW:
|
|
|
|
|
rtn = DfDefaultWndProc(wnd, msg, p1, p2);
|
|
|
|
|
if (DfCfg.InsertMode)
|
|
|
|
|
DfSetCommandToggle(&DfMainMenu, DF_ID_INSERT);
|
|
|
|
|
if (DfCfg.WordWrap)
|
|
|
|
|
DfSetCommandToggle(&DfMainMenu, DF_ID_WRAP);
|
2000-03-05 19:58:08 +00:00
|
|
|
|
FixTabMenu();
|
|
|
|
|
return rtn;
|
|
|
|
|
case DFM_COMMAND:
|
|
|
|
|
switch ((int)p1)
|
|
|
|
|
{
|
2003-06-19 02:48:13 +00:00
|
|
|
|
case DF_ID_NEW:
|
2000-03-05 19:58:08 +00:00
|
|
|
|
NewFile(wnd,NULL);
|
|
|
|
|
return TRUE;
|
|
|
|
|
|
2003-06-19 02:48:13 +00:00
|
|
|
|
case DF_ID_OPEN:
|
2000-03-05 19:58:08 +00:00
|
|
|
|
SelectFile(wnd);
|
|
|
|
|
return TRUE;
|
|
|
|
|
|
2003-06-19 02:48:13 +00:00
|
|
|
|
case DF_ID_SAVE:
|
|
|
|
|
SaveFile(DfInFocus, FALSE);
|
2000-03-05 19:58:08 +00:00
|
|
|
|
return TRUE;
|
|
|
|
|
|
2003-06-19 02:48:13 +00:00
|
|
|
|
case DF_ID_SAVEAS:
|
|
|
|
|
SaveFile(DfInFocus, TRUE);
|
2000-03-05 19:58:08 +00:00
|
|
|
|
return TRUE;
|
|
|
|
|
|
2003-06-19 02:48:13 +00:00
|
|
|
|
case DF_ID_DELETEFILE:
|
|
|
|
|
EditDeleteFile(DfInFocus);
|
2000-03-05 19:58:08 +00:00
|
|
|
|
return TRUE;
|
|
|
|
|
|
2003-06-19 02:48:13 +00:00
|
|
|
|
case DF_ID_PRINTSETUP:
|
2000-03-05 19:58:08 +00:00
|
|
|
|
DfDialogBox(wnd, &PrintSetup, TRUE, PrintSetupProc);
|
|
|
|
|
return TRUE;
|
|
|
|
|
|
2003-06-19 02:48:13 +00:00
|
|
|
|
case DF_ID_PRINT:
|
|
|
|
|
PrintPad(DfInFocus);
|
2000-03-05 19:58:08 +00:00
|
|
|
|
return TRUE;
|
|
|
|
|
|
2003-06-19 02:48:13 +00:00
|
|
|
|
case DF_ID_EXIT:
|
2000-03-05 19:58:08 +00:00
|
|
|
|
if (!DfYesNoBox("Exit FreeDos Edit?"))
|
|
|
|
|
return FALSE;
|
|
|
|
|
break;
|
|
|
|
|
|
2003-06-19 02:48:13 +00:00
|
|
|
|
case DF_ID_WRAP:
|
|
|
|
|
DfCfg.WordWrap = DfGetCommandToggle(&DfMainMenu, DF_ID_WRAP);
|
2000-03-05 19:58:08 +00:00
|
|
|
|
return TRUE;
|
|
|
|
|
|
2003-06-19 02:48:13 +00:00
|
|
|
|
case DF_ID_INSERT:
|
|
|
|
|
DfCfg.InsertMode = DfGetCommandToggle(&DfMainMenu, DF_ID_INSERT);
|
2000-03-05 19:58:08 +00:00
|
|
|
|
return TRUE;
|
|
|
|
|
|
2003-06-19 02:48:13 +00:00
|
|
|
|
case DF_ID_TAB2:
|
|
|
|
|
DfCfg.Tabs = 2;
|
2000-03-05 19:58:08 +00:00
|
|
|
|
FixTabMenu();
|
|
|
|
|
return TRUE;
|
|
|
|
|
|
2003-06-19 02:48:13 +00:00
|
|
|
|
case DF_ID_TAB4:
|
|
|
|
|
DfCfg.Tabs = 4;
|
2000-03-05 19:58:08 +00:00
|
|
|
|
FixTabMenu();
|
|
|
|
|
return TRUE;
|
|
|
|
|
|
2003-06-19 02:48:13 +00:00
|
|
|
|
case DF_ID_TAB6:
|
|
|
|
|
DfCfg.Tabs = 6;
|
2000-03-05 19:58:08 +00:00
|
|
|
|
FixTabMenu();
|
|
|
|
|
return TRUE;
|
|
|
|
|
|
2003-06-19 02:48:13 +00:00
|
|
|
|
case DF_ID_TAB8:
|
|
|
|
|
DfCfg.Tabs = 8;
|
2000-03-05 19:58:08 +00:00
|
|
|
|
FixTabMenu();
|
|
|
|
|
return TRUE;
|
|
|
|
|
|
2003-06-19 02:48:13 +00:00
|
|
|
|
case DF_ID_CALENDAR:
|
2000-03-05 19:58:08 +00:00
|
|
|
|
Calendar(wnd);
|
|
|
|
|
return TRUE;
|
|
|
|
|
|
2003-06-19 02:48:13 +00:00
|
|
|
|
// case DF_ID_BARCHART:
|
2000-03-05 19:58:08 +00:00
|
|
|
|
// BarChart(wnd);
|
|
|
|
|
// return TRUE;
|
|
|
|
|
|
2003-06-19 02:48:13 +00:00
|
|
|
|
case DF_ID_ABOUT:
|
2000-03-05 19:58:08 +00:00
|
|
|
|
DfMessageBox(
|
|
|
|
|
"About D-Flat and FreeDos Edit",
|
|
|
|
|
" <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ŀ\n"
|
|
|
|
|
" <20> <20><><EFBFBD> <20><><EFBFBD> <20> <20>\n"
|
|
|
|
|
" <20> <20> <20> <20> <20> <20> <20>\n"
|
|
|
|
|
" <20> <20> <20> <20> <20> <20> <20>\n"
|
|
|
|
|
" <20> <20> <20> <20> <20> <20> <20> <20>\n"
|
|
|
|
|
" <20> <20><><EFBFBD> <20><><EFBFBD> <20><> <20>\n"
|
|
|
|
|
" R<><52><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>U\n"
|
|
|
|
|
"D-Flat implements the SAA/CUA\n"
|
|
|
|
|
"interface in a public domain\n"
|
|
|
|
|
"C language library originally\n"
|
|
|
|
|
"published in Dr. Dobb's Journal\n"
|
|
|
|
|
" ------------------------ \n"
|
|
|
|
|
"FreeDos Edit is a clone of MSDOS\n"
|
|
|
|
|
"editor for the FREEDOS Project");
|
|
|
|
|
return TRUE;
|
|
|
|
|
|
|
|
|
|
default:
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
break;
|
|
|
|
|
|
|
|
|
|
default:
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
|
2003-06-19 02:48:13 +00:00
|
|
|
|
return DfDefaultWndProc(wnd, msg, p1, p2);
|
2000-03-05 19:58:08 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* --- The New command. Open an empty editor window --- */
|
|
|
|
|
static void NewFile(DFWINDOW wnd, char *FileName)
|
|
|
|
|
{
|
|
|
|
|
OpenPadWindow(wnd, Untitled,FileName);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* --- The Open... command. Select a file --- */
|
|
|
|
|
static void SelectFile(DFWINDOW wnd)
|
|
|
|
|
{
|
|
|
|
|
char FileName[MAX_PATH];
|
|
|
|
|
|
2003-06-19 02:48:13 +00:00
|
|
|
|
if (DfOpenFileDialogBox("*.*", FileName))
|
2000-03-05 19:58:08 +00:00
|
|
|
|
{
|
|
|
|
|
/* see if the document is already in a window */
|
2003-06-19 02:48:13 +00:00
|
|
|
|
DFWINDOW wnd1 = DfFirstWindow(wnd);
|
2000-03-05 19:58:08 +00:00
|
|
|
|
while (wnd1 != NULL)
|
|
|
|
|
{
|
|
|
|
|
if (wnd1->extension &&
|
2008-12-22 23:24:18 +00:00
|
|
|
|
_stricmp(FileName, wnd1->extension) == 0)
|
2000-03-05 19:58:08 +00:00
|
|
|
|
{
|
2003-06-19 02:48:13 +00:00
|
|
|
|
DfSendMessage(wnd1, DFM_SETFOCUS, TRUE, 0);
|
|
|
|
|
DfSendMessage(wnd1, DFM_RESTORE, 0, 0);
|
2000-03-05 19:58:08 +00:00
|
|
|
|
return;
|
|
|
|
|
}
|
2003-06-19 02:48:13 +00:00
|
|
|
|
wnd1 = DfNextWindow(wnd1);
|
2000-03-05 19:58:08 +00:00
|
|
|
|
}
|
|
|
|
|
OpenPadWindow(wnd, FileName, NULL);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* --- open a document window and load a file --- */
|
|
|
|
|
static void OpenPadWindow(DFWINDOW wnd, char *FileName,char *NewFileName)
|
|
|
|
|
{
|
|
|
|
|
static DFWINDOW wnd1 = NULL;
|
|
|
|
|
DFWINDOW wwnd;
|
|
|
|
|
struct stat sb;
|
|
|
|
|
char *Fname = FileName;
|
|
|
|
|
char *ermsg;
|
|
|
|
|
|
|
|
|
|
if (strcmp(FileName, Untitled))
|
|
|
|
|
{
|
|
|
|
|
if (stat(FileName, &sb))
|
|
|
|
|
{
|
2003-06-19 02:48:13 +00:00
|
|
|
|
ermsg = DfMalloc(strlen(FileName)+20);
|
2000-03-05 19:58:08 +00:00
|
|
|
|
strcpy(ermsg, "No such file as\n");
|
|
|
|
|
strcat(ermsg, FileName);
|
|
|
|
|
DfErrorMessage(ermsg);
|
|
|
|
|
free(ermsg);
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
Fname = NameComponent(FileName);
|
|
|
|
|
|
|
|
|
|
// check file size
|
|
|
|
|
if (sb.st_size > 64000)
|
|
|
|
|
{
|
2003-06-19 02:48:13 +00:00
|
|
|
|
ermsg = DfMalloc(strlen(FileName)+20);
|
2000-03-05 19:58:08 +00:00
|
|
|
|
strcpy(ermsg, "File too large for this version of Edit\n");
|
|
|
|
|
DfErrorMessage(ermsg);
|
|
|
|
|
free(ermsg);
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2003-06-19 02:48:13 +00:00
|
|
|
|
wwnd = DfWatchIcon();
|
2000-03-05 19:58:08 +00:00
|
|
|
|
wndpos += 2;
|
|
|
|
|
|
|
|
|
|
if (NewFileName != NULL)
|
|
|
|
|
Fname = NameComponent(NewFileName);
|
|
|
|
|
|
|
|
|
|
if (wndpos == 20)
|
|
|
|
|
wndpos = 2;
|
|
|
|
|
|
2003-06-19 02:48:13 +00:00
|
|
|
|
wnd1 = DfDfCreateWindow(DF_EDITBOX,
|
2000-03-05 19:58:08 +00:00
|
|
|
|
Fname,
|
|
|
|
|
(wndpos-1)*2, wndpos, 10, 40,
|
|
|
|
|
NULL, wnd, EditorProc,
|
2003-06-19 02:48:13 +00:00
|
|
|
|
DF_SHADOW |
|
|
|
|
|
DF_MINMAXBOX |
|
|
|
|
|
DF_CONTROLBOX |
|
|
|
|
|
DF_VSCROLLBAR |
|
|
|
|
|
DF_HSCROLLBAR |
|
|
|
|
|
DF_MOVEABLE |
|
|
|
|
|
DF_HASBORDER |
|
|
|
|
|
DF_SIZEABLE |
|
|
|
|
|
DF_MULTILINE);
|
2000-03-05 19:58:08 +00:00
|
|
|
|
|
|
|
|
|
if (strcmp(FileName, Untitled))
|
|
|
|
|
{
|
2003-06-19 02:48:13 +00:00
|
|
|
|
wnd1->extension = DfMalloc(strlen(FileName)+1);
|
2000-03-05 19:58:08 +00:00
|
|
|
|
strcpy(wnd1->extension, FileName);
|
|
|
|
|
LoadFile(wnd1);
|
|
|
|
|
}
|
2003-06-19 02:48:13 +00:00
|
|
|
|
DfSendMessage(wwnd, DFM_CLOSE_WINDOW, 0, 0);
|
|
|
|
|
DfSendMessage(wnd1, DFM_SETFOCUS, TRUE, 0);
|
|
|
|
|
DfSendMessage(wnd1, DFM_MAXIMIZE, 0, 0);
|
2000-03-05 19:58:08 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* --- Load the notepad file into the editor text buffer --- */
|
|
|
|
|
static void LoadFile(DFWINDOW wnd)
|
|
|
|
|
{
|
|
|
|
|
char *Buf = NULL;
|
|
|
|
|
int recptr = 0;
|
|
|
|
|
FILE *fp;
|
|
|
|
|
|
|
|
|
|
if ((fp = fopen(wnd->extension, "rt")) != NULL)
|
|
|
|
|
{
|
|
|
|
|
while (!feof(fp))
|
|
|
|
|
{
|
2003-06-19 02:48:13 +00:00
|
|
|
|
DfHandshake();
|
|
|
|
|
Buf = DfRealloc(Buf, recptr+150);
|
2000-03-05 19:58:08 +00:00
|
|
|
|
memset(Buf+recptr, 0, 150);
|
|
|
|
|
fgets(Buf+recptr, 150, fp);
|
|
|
|
|
recptr += strlen(Buf+recptr);
|
|
|
|
|
}
|
|
|
|
|
fclose(fp);
|
|
|
|
|
if (Buf != NULL)
|
|
|
|
|
{
|
2003-06-19 02:48:13 +00:00
|
|
|
|
DfSendMessage(wnd, DFM_SETTEXT, (DF_PARAM) Buf, 0);
|
2000-03-05 19:58:08 +00:00
|
|
|
|
free(Buf);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static int LineCtr;
|
|
|
|
|
static int CharCtr;
|
|
|
|
|
|
|
|
|
|
/* ------- print a character -------- */
|
|
|
|
|
static void PrintChar(FILE *prn, int c)
|
|
|
|
|
{
|
|
|
|
|
int i;
|
|
|
|
|
|
2003-06-19 02:48:13 +00:00
|
|
|
|
if (c == '\n' || CharCtr == DfCfg.RightMargin)
|
2000-03-05 19:58:08 +00:00
|
|
|
|
{
|
|
|
|
|
fputs("\r\n", prn);
|
|
|
|
|
LineCtr++;
|
2003-06-19 02:48:13 +00:00
|
|
|
|
if (LineCtr == DfCfg.BottomMargin)
|
2000-03-05 19:58:08 +00:00
|
|
|
|
{
|
|
|
|
|
fputc('\f', prn);
|
2003-06-19 02:48:13 +00:00
|
|
|
|
for (i = 0; i < DfCfg.TopMargin; i++)
|
2000-03-05 19:58:08 +00:00
|
|
|
|
fputc('\n', prn);
|
2003-06-19 02:48:13 +00:00
|
|
|
|
LineCtr = DfCfg.TopMargin;
|
2000-03-05 19:58:08 +00:00
|
|
|
|
}
|
|
|
|
|
CharCtr = 0;
|
|
|
|
|
if (c == '\n')
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
if (CharCtr == 0)
|
|
|
|
|
{
|
2003-06-19 02:48:13 +00:00
|
|
|
|
for (i = 0; i < DfCfg.LeftMargin; i++)
|
2000-03-05 19:58:08 +00:00
|
|
|
|
{
|
|
|
|
|
fputc(' ', prn);
|
|
|
|
|
CharCtr++;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
CharCtr++;
|
|
|
|
|
fputc(c, prn);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* --- print the current notepad --- */
|
|
|
|
|
static void PrintPad(DFWINDOW wnd)
|
|
|
|
|
{
|
2003-06-19 02:48:13 +00:00
|
|
|
|
if (*DfCfg.PrinterPort)
|
2000-03-05 19:58:08 +00:00
|
|
|
|
{
|
|
|
|
|
FILE *prn;
|
2003-06-19 02:48:13 +00:00
|
|
|
|
if ((prn = fopen(DfCfg.PrinterPort, "wt")) != NULL)
|
2000-03-05 19:58:08 +00:00
|
|
|
|
{
|
|
|
|
|
long percent;
|
|
|
|
|
BOOL KeepPrinting = TRUE;
|
2005-05-11 16:50:39 +00:00
|
|
|
|
char *text = DfGetText(wnd);
|
2000-03-05 19:58:08 +00:00
|
|
|
|
unsigned oldpct = 100, cct = 0, len = strlen(text);
|
2003-06-19 02:48:13 +00:00
|
|
|
|
DFWINDOW swnd = DfSliderBox(20, DfGetTitle(wnd), "Printing");
|
2000-03-05 19:58:08 +00:00
|
|
|
|
/* ------- print the notepad text --------- */
|
|
|
|
|
LineCtr = CharCtr = 0;
|
|
|
|
|
while (KeepPrinting && *text)
|
|
|
|
|
{
|
|
|
|
|
PrintChar(prn, *text++);
|
|
|
|
|
percent = ((long) ++cct * 100) / len;
|
|
|
|
|
if ((int)percent != (int)oldpct)
|
|
|
|
|
{
|
|
|
|
|
oldpct = (int) percent;
|
2003-06-19 02:48:13 +00:00
|
|
|
|
KeepPrinting = DfSendMessage(swnd, DFM_PAINT, 0, oldpct);
|
2000-03-05 19:58:08 +00:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
if (KeepPrinting)
|
|
|
|
|
/* ---- user did not cancel ---- */
|
|
|
|
|
if (oldpct < 100)
|
2003-06-19 02:48:13 +00:00
|
|
|
|
DfSendMessage(swnd, DFM_PAINT, 0, 100);
|
2000-03-05 19:58:08 +00:00
|
|
|
|
/* ------- follow with a form feed? --------- */
|
|
|
|
|
if (DfYesNoBox("Form Feed?"))
|
|
|
|
|
fputc('\f', prn);
|
|
|
|
|
fclose(prn);
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
DfErrorMessage("Cannot open printer file");
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
DfErrorMessage("No printer selected");
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* ---------- save a file to disk ------------ */
|
|
|
|
|
static void SaveFile(DFWINDOW wnd, int Saveas)
|
|
|
|
|
{
|
|
|
|
|
FILE *fp;
|
|
|
|
|
if (wnd->extension == NULL || Saveas) {
|
|
|
|
|
char FileName[MAX_PATH];
|
2003-06-19 02:48:13 +00:00
|
|
|
|
if (DfSaveAsDialogBox(FileName)) {
|
2000-03-05 19:58:08 +00:00
|
|
|
|
if (wnd->extension != NULL)
|
|
|
|
|
free(wnd->extension);
|
2003-06-19 02:48:13 +00:00
|
|
|
|
wnd->extension = DfMalloc(strlen(FileName)+1);
|
2000-03-05 19:58:08 +00:00
|
|
|
|
strcpy(wnd->extension, FileName);
|
2003-06-19 02:48:13 +00:00
|
|
|
|
DfAddTitle(wnd, NameComponent(FileName));
|
|
|
|
|
DfSendMessage(wnd, DFM_BORDER, 0, 0);
|
2000-03-05 19:58:08 +00:00
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
if (wnd->extension != NULL)
|
|
|
|
|
{
|
2003-06-19 02:48:13 +00:00
|
|
|
|
DFWINDOW mwnd = DfMomentaryMessage("Saving the file");
|
2000-03-05 19:58:08 +00:00
|
|
|
|
if ((fp = fopen(wnd->extension, "wt")) != NULL)
|
|
|
|
|
{
|
2003-06-19 02:48:13 +00:00
|
|
|
|
fwrite(DfGetText(wnd), strlen(DfGetText(wnd)), 1, fp);
|
2000-03-05 19:58:08 +00:00
|
|
|
|
fclose(fp);
|
|
|
|
|
wnd->TextChanged = FALSE;
|
|
|
|
|
}
|
2003-06-19 02:48:13 +00:00
|
|
|
|
DfSendMessage(mwnd, DFM_CLOSE_WINDOW, 0, 0);
|
2000-03-05 19:58:08 +00:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
/* -------- delete a file ------------ */
|
|
|
|
|
static void EditDeleteFile(DFWINDOW wnd)
|
|
|
|
|
{
|
|
|
|
|
if (wnd->extension != NULL) {
|
|
|
|
|
if (strcmp(wnd->extension, Untitled)) {
|
|
|
|
|
char *fn = NameComponent(wnd->extension);
|
|
|
|
|
if (fn != NULL) {
|
|
|
|
|
char msg[30];
|
|
|
|
|
sprintf(msg, "Delete %s?", fn);
|
|
|
|
|
if (DfYesNoBox(msg)) {
|
2008-12-22 23:24:18 +00:00
|
|
|
|
_unlink(wnd->extension);
|
2003-06-19 02:48:13 +00:00
|
|
|
|
DfSendMessage(wnd, DFM_CLOSE_WINDOW, 0, 0);
|
2000-03-05 19:58:08 +00:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
/* ------ display the row and column in the statusbar ------ */
|
|
|
|
|
static void ShowPosition(DFWINDOW wnd)
|
|
|
|
|
{
|
|
|
|
|
char status[30];
|
|
|
|
|
sprintf(status, "Line:%4d Column: %2d",
|
|
|
|
|
wnd->CurrLine, wnd->CurrCol);
|
2003-06-19 02:48:13 +00:00
|
|
|
|
DfSendMessage(DfGetParent(wnd), DFM_ADDSTATUS, (DF_PARAM) status, 0);
|
2000-03-05 19:58:08 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* window processing module for the editboxes */
|
2003-06-19 02:48:13 +00:00
|
|
|
|
static int EditorProc(DFWINDOW wnd,DFMESSAGE msg,DF_PARAM p1,DF_PARAM p2)
|
2000-03-05 19:58:08 +00:00
|
|
|
|
{
|
|
|
|
|
int rtn;
|
|
|
|
|
|
|
|
|
|
switch (msg)
|
|
|
|
|
{
|
2003-06-19 02:48:13 +00:00
|
|
|
|
case DFM_SETFOCUS:
|
2000-03-05 19:58:08 +00:00
|
|
|
|
if ((int)p1)
|
|
|
|
|
{
|
2003-06-19 02:48:13 +00:00
|
|
|
|
wnd->InsertMode = DfGetCommandToggle(&DfMainMenu, DF_ID_INSERT);
|
|
|
|
|
wnd->WordWrapMode = DfGetCommandToggle(&DfMainMenu, DF_ID_WRAP);
|
2000-03-05 19:58:08 +00:00
|
|
|
|
}
|
2003-06-19 02:48:13 +00:00
|
|
|
|
rtn = DfDefaultWndProc(wnd, msg, p1, p2);
|
2000-03-05 19:58:08 +00:00
|
|
|
|
if ((int)p1 == FALSE)
|
2003-06-19 02:48:13 +00:00
|
|
|
|
DfSendMessage(DfGetParent(wnd), DFM_ADDSTATUS, 0, 0);
|
2000-03-05 19:58:08 +00:00
|
|
|
|
else
|
|
|
|
|
ShowPosition(wnd);
|
|
|
|
|
return rtn;
|
|
|
|
|
|
2003-06-19 02:48:13 +00:00
|
|
|
|
case DFM_KEYBOARD_CURSOR:
|
|
|
|
|
rtn = DfDefaultWndProc(wnd, msg, p1, p2);
|
2000-03-05 19:58:08 +00:00
|
|
|
|
ShowPosition(wnd);
|
|
|
|
|
return rtn;
|
|
|
|
|
|
|
|
|
|
case DFM_COMMAND:
|
|
|
|
|
switch ((int) p1)
|
|
|
|
|
{
|
2003-06-19 02:48:13 +00:00
|
|
|
|
case DF_ID_SEARCH:
|
2000-03-05 19:58:08 +00:00
|
|
|
|
DfSearchText(wnd);
|
|
|
|
|
return TRUE;
|
2003-06-19 02:48:13 +00:00
|
|
|
|
case DF_ID_REPLACE:
|
2000-03-05 19:58:08 +00:00
|
|
|
|
DfReplaceText(wnd);
|
|
|
|
|
return TRUE;
|
2003-06-19 02:48:13 +00:00
|
|
|
|
case DF_ID_SEARCHNEXT:
|
2000-03-05 19:58:08 +00:00
|
|
|
|
DfSearchNext(wnd);
|
|
|
|
|
return TRUE;
|
2003-06-19 02:48:13 +00:00
|
|
|
|
case DF_ID_CUT:
|
|
|
|
|
DfCopyToClipboard(wnd);
|
|
|
|
|
DfSendMessage(wnd, DFM_COMMAND, DF_ID_DELETETEXT, 0);
|
|
|
|
|
DfSendMessage(wnd, DFM_PAINT, 0, 0);
|
2000-03-05 19:58:08 +00:00
|
|
|
|
return TRUE;
|
2003-06-19 02:48:13 +00:00
|
|
|
|
case DF_ID_COPY:
|
|
|
|
|
DfCopyToClipboard(wnd);
|
|
|
|
|
DfClearTextBlock(wnd);
|
|
|
|
|
DfSendMessage(wnd, DFM_PAINT, 0, 0);
|
2000-03-05 19:58:08 +00:00
|
|
|
|
return TRUE;
|
2003-06-19 02:48:13 +00:00
|
|
|
|
case DF_ID_PASTE:
|
|
|
|
|
DfPasteFromClipboard(wnd);
|
|
|
|
|
DfSendMessage(wnd, DFM_PAINT, 0, 0);
|
2000-03-05 19:58:08 +00:00
|
|
|
|
return TRUE;
|
2003-06-19 02:48:13 +00:00
|
|
|
|
case DF_ID_DELETETEXT:
|
|
|
|
|
case DF_ID_CLEAR:
|
|
|
|
|
rtn = DfDefaultWndProc(wnd, msg, p1, p2);
|
|
|
|
|
DfSendMessage(wnd, DFM_PAINT, 0, 0);
|
2000-03-05 19:58:08 +00:00
|
|
|
|
return rtn;
|
2003-06-19 02:48:13 +00:00
|
|
|
|
case DF_ID_HELP:
|
|
|
|
|
DfDisplayHelp(wnd, "MEMOPADDOC");
|
2000-03-05 19:58:08 +00:00
|
|
|
|
return TRUE;
|
2003-06-19 02:48:13 +00:00
|
|
|
|
case DF_ID_WRAP:
|
|
|
|
|
DfSendMessage(DfGetParent(wnd), DFM_COMMAND, DF_ID_WRAP, 0);
|
|
|
|
|
wnd->WordWrapMode = DfCfg.WordWrap;
|
2000-03-05 19:58:08 +00:00
|
|
|
|
return TRUE;
|
2003-06-19 02:48:13 +00:00
|
|
|
|
case DF_ID_INSERT:
|
|
|
|
|
DfSendMessage(DfGetParent(wnd), DFM_COMMAND, DF_ID_INSERT, 0);
|
|
|
|
|
wnd->InsertMode = DfCfg.InsertMode;
|
|
|
|
|
DfSendMessage(NULL, DFM_SHOW_CURSOR, wnd->InsertMode, 0);
|
2000-03-05 19:58:08 +00:00
|
|
|
|
return TRUE;
|
|
|
|
|
default:
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
break;
|
|
|
|
|
|
2003-06-19 02:48:13 +00:00
|
|
|
|
case DFM_CLOSE_WINDOW:
|
2000-03-05 19:58:08 +00:00
|
|
|
|
if (wnd->TextChanged)
|
|
|
|
|
{
|
2003-06-19 02:48:13 +00:00
|
|
|
|
char *cp = DfMalloc(25+strlen(DfGetTitle(wnd)));
|
|
|
|
|
DfSendMessage(wnd, DFM_SETFOCUS, TRUE, 0);
|
|
|
|
|
strcpy(cp, DfGetTitle(wnd));
|
2000-03-05 19:58:08 +00:00
|
|
|
|
strcat(cp, "\nText changed. Save it?");
|
|
|
|
|
if (DfYesNoBox(cp))
|
2003-06-19 02:48:13 +00:00
|
|
|
|
DfSendMessage(DfGetParent(wnd), DFM_COMMAND, DF_ID_SAVE, 0);
|
2000-03-05 19:58:08 +00:00
|
|
|
|
free(cp);
|
|
|
|
|
}
|
|
|
|
|
wndpos = 0;
|
|
|
|
|
if (wnd->extension != NULL)
|
|
|
|
|
{
|
|
|
|
|
free(wnd->extension);
|
|
|
|
|
wnd->extension = NULL;
|
|
|
|
|
}
|
|
|
|
|
break;
|
|
|
|
|
|
|
|
|
|
default:
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
|
2003-06-19 02:48:13 +00:00
|
|
|
|
return DfDefaultWndProc(wnd, msg, p1, p2);
|
2000-03-05 19:58:08 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* -- point to the name component of a file specification -- */
|
|
|
|
|
static char *NameComponent(char *FileName)
|
|
|
|
|
{
|
|
|
|
|
char *Fname;
|
|
|
|
|
if ((Fname = strrchr(FileName, '\\')) == NULL)
|
|
|
|
|
if ((Fname = strrchr(FileName, ':')) == NULL)
|
|
|
|
|
Fname = FileName-1;
|
|
|
|
|
return Fname + 1;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static char *ports[] = {
|
|
|
|
|
"Lpt1", "Lpt2", "Lpt3",
|
|
|
|
|
"Com1", "Com2", "Com3", "Com4",
|
|
|
|
|
NULL
|
|
|
|
|
};
|
|
|
|
|
|
2003-06-19 02:48:13 +00:00
|
|
|
|
static int PrintSetupProc(DFWINDOW wnd, DFMESSAGE msg, DF_PARAM p1, DF_PARAM p2)
|
2000-03-05 19:58:08 +00:00
|
|
|
|
{
|
|
|
|
|
int rtn, i = 0, mar;
|
|
|
|
|
char marg[10];
|
|
|
|
|
DFWINDOW cwnd;
|
|
|
|
|
|
|
|
|
|
switch (msg)
|
|
|
|
|
{
|
2003-06-19 02:48:13 +00:00
|
|
|
|
case DFM_CREATE_WINDOW:
|
|
|
|
|
rtn = DfDefaultWndProc(wnd, msg, p1, p2);
|
|
|
|
|
DfPutItemText(wnd, DF_ID_PRINTERPORT, DfCfg.PrinterPort);
|
2000-03-05 19:58:08 +00:00
|
|
|
|
while (ports[i] != NULL)
|
2003-06-19 02:48:13 +00:00
|
|
|
|
DfPutComboListText(wnd, DF_ID_PRINTERPORT, ports[i++]);
|
2000-03-05 19:58:08 +00:00
|
|
|
|
for (mar = CHARSLINE; mar >= 0; --mar)
|
|
|
|
|
{
|
|
|
|
|
sprintf(marg, "%3d", mar);
|
2003-06-19 02:48:13 +00:00
|
|
|
|
DfPutItemText(wnd, DF_ID_LEFTMARGIN, marg);
|
|
|
|
|
DfPutItemText(wnd, DF_ID_RIGHTMARGIN, marg);
|
2000-03-05 19:58:08 +00:00
|
|
|
|
}
|
|
|
|
|
for (mar = LINESPAGE; mar >= 0; --mar)
|
|
|
|
|
{
|
|
|
|
|
sprintf(marg, "%3d", mar);
|
2003-06-19 02:48:13 +00:00
|
|
|
|
DfPutItemText(wnd, DF_ID_TOPMARGIN, marg);
|
|
|
|
|
DfPutItemText(wnd, DF_ID_BOTTOMMARGIN, marg);
|
2000-03-05 19:58:08 +00:00
|
|
|
|
}
|
2003-06-19 02:48:13 +00:00
|
|
|
|
cwnd = DfControlWindow(&PrintSetup, DF_ID_LEFTMARGIN);
|
|
|
|
|
DfSendMessage(cwnd, DFM_LB_SETSELECTION,
|
|
|
|
|
CHARSLINE-DfCfg.LeftMargin, 0);
|
|
|
|
|
cwnd = DfControlWindow(&PrintSetup, DF_ID_RIGHTMARGIN);
|
|
|
|
|
DfSendMessage(cwnd, DFM_LB_SETSELECTION,
|
|
|
|
|
CHARSLINE-DfCfg.RightMargin, 0);
|
|
|
|
|
cwnd = DfControlWindow(&PrintSetup, DF_ID_TOPMARGIN);
|
|
|
|
|
DfSendMessage(cwnd, DFM_LB_SETSELECTION,
|
|
|
|
|
LINESPAGE-DfCfg.TopMargin, 0);
|
|
|
|
|
cwnd = DfControlWindow(&PrintSetup, DF_ID_BOTTOMMARGIN);
|
|
|
|
|
DfSendMessage(cwnd, DFM_LB_SETSELECTION,
|
|
|
|
|
LINESPAGE-DfCfg.BottomMargin, 0);
|
2000-03-05 19:58:08 +00:00
|
|
|
|
return rtn;
|
|
|
|
|
case DFM_COMMAND:
|
2003-06-19 02:48:13 +00:00
|
|
|
|
if ((int) p1 == DF_ID_OK && (int) p2 == 0)
|
2000-03-05 19:58:08 +00:00
|
|
|
|
{
|
2003-06-19 02:48:13 +00:00
|
|
|
|
DfGetItemText(wnd, DF_ID_PRINTERPORT, DfCfg.PrinterPort, 4);
|
|
|
|
|
cwnd = DfControlWindow(&PrintSetup, DF_ID_LEFTMARGIN);
|
|
|
|
|
DfCfg.LeftMargin = CHARSLINE -
|
|
|
|
|
DfSendMessage(cwnd, DFM_LB_CURRENTSELECTION, 0, 0);
|
|
|
|
|
cwnd = DfControlWindow(&PrintSetup, DF_ID_RIGHTMARGIN);
|
|
|
|
|
DfCfg.RightMargin = CHARSLINE -
|
|
|
|
|
DfSendMessage(cwnd, DFM_LB_CURRENTSELECTION, 0, 0);
|
|
|
|
|
cwnd = DfControlWindow(&PrintSetup, DF_ID_TOPMARGIN);
|
|
|
|
|
DfCfg.TopMargin = LINESPAGE -
|
|
|
|
|
DfSendMessage(cwnd, DFM_LB_CURRENTSELECTION, 0, 0);
|
|
|
|
|
cwnd = DfControlWindow(&PrintSetup, DF_ID_BOTTOMMARGIN);
|
|
|
|
|
DfCfg.BottomMargin = LINESPAGE -
|
|
|
|
|
DfSendMessage(cwnd, DFM_LB_CURRENTSELECTION, 0, 0);
|
2000-03-05 19:58:08 +00:00
|
|
|
|
}
|
|
|
|
|
break;
|
|
|
|
|
default:
|
|
|
|
|
break;
|
|
|
|
|
}
|
2003-06-19 02:48:13 +00:00
|
|
|
|
return DfDefaultWndProc(wnd, msg, p1, p2);
|
2000-03-05 19:58:08 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static void FixTabMenu(void)
|
|
|
|
|
{
|
2003-06-19 02:48:13 +00:00
|
|
|
|
char *cp = DfGetCommandText(&DfMainMenu, DF_ID_TABS);
|
2000-03-05 19:58:08 +00:00
|
|
|
|
char *p;
|
|
|
|
|
|
|
|
|
|
if (cp != NULL)
|
|
|
|
|
{
|
|
|
|
|
p = strchr(cp, '(');
|
|
|
|
|
if (p != NULL)
|
|
|
|
|
{
|
2003-06-19 02:48:13 +00:00
|
|
|
|
// *(p+1) = (char)(DfCfg.Tabs + '0');
|
|
|
|
|
// if (DfGetClass(DfInFocus) == DF_POPDOWNMENU)
|
|
|
|
|
// DfSendMessage(DfInFocus, DFM_PAINT, 0, 0);
|
2000-03-05 19:58:08 +00:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2003-06-19 02:48:13 +00:00
|
|
|
|
void DfPrepFileMenu(void *w, struct DfMenu *mnu)
|
2000-03-05 19:58:08 +00:00
|
|
|
|
{
|
|
|
|
|
DFWINDOW wnd = w;
|
2003-06-19 02:48:13 +00:00
|
|
|
|
DfDeactivateCommand(&DfMainMenu, DF_ID_SAVE);
|
|
|
|
|
DfDeactivateCommand(&DfMainMenu, DF_ID_SAVEAS);
|
|
|
|
|
DfDeactivateCommand(&DfMainMenu, DF_ID_DELETEFILE);
|
|
|
|
|
DfDeactivateCommand(&DfMainMenu, DF_ID_PRINT);
|
|
|
|
|
if (wnd != NULL && DfGetClass(wnd) == DF_EDITBOX)
|
2000-03-05 19:58:08 +00:00
|
|
|
|
{
|
2003-06-19 02:48:13 +00:00
|
|
|
|
if (DfIsMultiLine(wnd))
|
2000-03-05 19:58:08 +00:00
|
|
|
|
{
|
2003-06-19 02:48:13 +00:00
|
|
|
|
DfActivateCommand(&DfMainMenu, DF_ID_SAVE);
|
|
|
|
|
DfActivateCommand(&DfMainMenu, DF_ID_SAVEAS);
|
|
|
|
|
DfActivateCommand(&DfMainMenu, DF_ID_DELETEFILE);
|
|
|
|
|
DfActivateCommand(&DfMainMenu, DF_ID_PRINT);
|
2000-03-05 19:58:08 +00:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2003-06-19 02:48:13 +00:00
|
|
|
|
void DfPrepSearchMenu(void *w, struct DfMenu *mnu)
|
2000-03-05 19:58:08 +00:00
|
|
|
|
{
|
|
|
|
|
DFWINDOW wnd = w;
|
2003-06-19 02:48:13 +00:00
|
|
|
|
DfDeactivateCommand(&DfMainMenu, DF_ID_SEARCH);
|
|
|
|
|
DfDeactivateCommand(&DfMainMenu, DF_ID_REPLACE);
|
|
|
|
|
DfDeactivateCommand(&DfMainMenu, DF_ID_SEARCHNEXT);
|
|
|
|
|
if (wnd != NULL && DfGetClass(wnd) == DF_EDITBOX)
|
2000-03-05 19:58:08 +00:00
|
|
|
|
{
|
2003-06-19 02:48:13 +00:00
|
|
|
|
if (DfIsMultiLine(wnd))
|
2000-03-05 19:58:08 +00:00
|
|
|
|
{
|
2003-06-19 02:48:13 +00:00
|
|
|
|
DfActivateCommand(&DfMainMenu, DF_ID_SEARCH);
|
|
|
|
|
DfActivateCommand(&DfMainMenu, DF_ID_REPLACE);
|
|
|
|
|
DfActivateCommand(&DfMainMenu, DF_ID_SEARCHNEXT);
|
2000-03-05 19:58:08 +00:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2003-06-19 02:48:13 +00:00
|
|
|
|
void DfPrepEditMenu(void *w, struct DfMenu *mnu)
|
2000-03-05 19:58:08 +00:00
|
|
|
|
{
|
|
|
|
|
DFWINDOW wnd = w;
|
2003-06-19 02:48:13 +00:00
|
|
|
|
DfDeactivateCommand(&DfMainMenu, DF_ID_CUT);
|
|
|
|
|
DfDeactivateCommand(&DfMainMenu, DF_ID_COPY);
|
|
|
|
|
DfDeactivateCommand(&DfMainMenu, DF_ID_CLEAR);
|
|
|
|
|
DfDeactivateCommand(&DfMainMenu, DF_ID_DELETETEXT);
|
|
|
|
|
DfDeactivateCommand(&DfMainMenu, DF_ID_PARAGRAPH);
|
|
|
|
|
DfDeactivateCommand(&DfMainMenu, DF_ID_PASTE);
|
|
|
|
|
DfDeactivateCommand(&DfMainMenu, DF_ID_UNDO);
|
|
|
|
|
if (wnd != NULL && DfGetClass(wnd) == DF_EDITBOX)
|
2000-03-05 19:58:08 +00:00
|
|
|
|
{
|
2003-06-19 02:48:13 +00:00
|
|
|
|
if (DfIsMultiLine(wnd))
|
2000-03-05 19:58:08 +00:00
|
|
|
|
{
|
2003-06-19 02:48:13 +00:00
|
|
|
|
if (DfTextBlockMarked(wnd))
|
2000-03-05 19:58:08 +00:00
|
|
|
|
{
|
2003-06-19 02:48:13 +00:00
|
|
|
|
DfActivateCommand(&DfMainMenu, DF_ID_CUT);
|
|
|
|
|
DfActivateCommand(&DfMainMenu, DF_ID_COPY);
|
|
|
|
|
DfActivateCommand(&DfMainMenu, DF_ID_CLEAR);
|
|
|
|
|
DfActivateCommand(&DfMainMenu, DF_ID_DELETETEXT);
|
2000-03-05 19:58:08 +00:00
|
|
|
|
}
|
2003-06-19 02:48:13 +00:00
|
|
|
|
DfActivateCommand(&DfMainMenu, DF_ID_PARAGRAPH);
|
|
|
|
|
if (!DfTestAttribute(wnd, DF_READONLY) && DfClipboard != NULL)
|
|
|
|
|
DfActivateCommand(&DfMainMenu, DF_ID_PASTE);
|
2000-03-05 19:58:08 +00:00
|
|
|
|
if (wnd->DeletedText != NULL)
|
2003-06-19 02:48:13 +00:00
|
|
|
|
DfActivateCommand(&DfMainMenu, DF_ID_UNDO);
|
2000-03-05 19:58:08 +00:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* EOF */
|