📄 memopad.c
字号:
/* --------------- memopad.c ----------- */
#include "dflat.h"
extern DF_DBOX PrintSetup;
char DFlatApplication[] = "MemoPad";
static char Untitled[] = "Untitled";
static int wndpos;
static int MemoPadProc(DFWINDOW, DFMESSAGE, DF_PARAM, DF_PARAM);
static void NewFile(DFWINDOW);
static void SelectFile(DFWINDOW);
static void PadWindow(DFWINDOW, char *);
static void OpenPadWindow(DFWINDOW, char *);
static void LoadFile(DFWINDOW);
static void PrintPad(DFWINDOW);
static void SaveFile(DFWINDOW, int);
static void MemoPadDeleteFile(DFWINDOW);
static int EditorProc(DFWINDOW, DFMESSAGE, DF_PARAM, DF_PARAM);
static char *NameComponent(char *);
static int PrintSetupProc(DFWINDOW, DFMESSAGE, DF_PARAM, DF_PARAM);
static void FixTabMenu(void);
#ifndef TURBOC
void Calendar(DFWINDOW);
#endif
//void BarChart(DFWINDOW);
char **Argv;
#define CHARSLINE 80
#define LINESPAGE 66
void main(int argc, char *argv[])
{
DFWINDOW wnd;
if (!init_messages())
return;
Argv = argv;
DfLoadConfig();
// if (!DfLoadConfig())
// DfCfg.ScreenLines = DF_SCREENHEIGHT;
wnd = DfDfCreateWindow(DF_APPLICATION,
"FreeDos Edit " DF_VERSION,
0, 0, -1, -1,
&DfMainMenu,
NULL,
MemoPadProc,
DF_MOVEABLE |
DF_SIZEABLE |
DF_HASBORDER |
DF_MINMAXBOX |
DF_HASSTATUSBAR
);
DfLoadHelpFile();
DfSendMessage(wnd, DFM_SETFOCUS, TRUE, 0);
while (argc > 1) {
PadWindow(wnd, argv[1]);
--argc;
argv++;
}
while (dispatch_message())
;
}
/* ------ open text files and put them into editboxes ----- */
static void PadWindow(DFWINDOW wnd, char *FileName)
{
int ax;
struct _finddata_t ff;
char path[64];
char *cp;
DfCreatePath(path, FileName, FALSE, FALSE);
cp = path+strlen(path);
DfCreatePath(path, FileName, TRUE, FALSE);
ax = _findfirst(path, &ff);
if (ax == -1)
return;
do
{
strcpy(cp, ff.name);
OpenPadWindow(wnd, path);
}
while (_findnext (ax, &ff) == 0);
_findclose (ax);
}
/* ------- window processing module for the
memopad application window ----- */
static int MemoPadProc(DFWINDOW wnd,DFMESSAGE msg,DF_PARAM p1,DF_PARAM p2)
{
int rtn;
switch (msg) {
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);
FixTabMenu();
return rtn;
case DFM_COMMAND:
switch ((int)p1) {
case DF_ID_NEW:
NewFile(wnd);
return TRUE;
case DF_ID_OPEN:
SelectFile(wnd);
return TRUE;
case DF_ID_SAVE:
SaveFile(DfInFocus, FALSE);
return TRUE;
case DF_ID_SAVEAS:
SaveFile(DfInFocus, TRUE);
return TRUE;
case DF_ID_DELETEFILE:
MemoPadDeleteFile(DfInFocus);
return TRUE;
case DF_ID_PRINTSETUP:
DfDialogBox(wnd, &PrintSetup, TRUE, PrintSetupProc);
return TRUE;
case DF_ID_PRINT:
PrintPad(DfInFocus);
return TRUE;
case DF_ID_EXIT:
if (!DfYesNoBox("Exit Memopad?"))
return FALSE;
break;
case DF_ID_WRAP:
DfCfg.WordWrap = DfGetCommandToggle(&DfMainMenu, DF_ID_WRAP);
return TRUE;
case DF_ID_INSERT:
DfCfg.InsertMode = DfGetCommandToggle(&DfMainMenu, DF_ID_INSERT);
return TRUE;
case DF_ID_TAB2:
DfCfg.Tabs = 2;
FixTabMenu();
return TRUE;
case DF_ID_TAB4:
DfCfg.Tabs = 4;
FixTabMenu();
return TRUE;
case DF_ID_TAB6:
DfCfg.Tabs = 6;
FixTabMenu();
return TRUE;
case DF_ID_TAB8:
DfCfg.Tabs = 8;
FixTabMenu();
return TRUE;
case DF_ID_CALENDAR:
#ifndef TURBOC
Calendar(wnd);
#endif
return TRUE;
// case DF_ID_BARCHART:
// BarChart(wnd);
// return TRUE;
case DF_ID_ABOUT:
DfMessageBox(
"About D-Flat and the MemoPad",
" 谀哪哪哪哪哪哪哪哪哪哪哪縗n"
"
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -