⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 edit.c

📁 ReactOS是一些高手根据Windows XP的内核编写出的类XP。内核实现机理和API函数调用几乎相同。甚至可以兼容XP的程序。喜欢研究系统内核的人可以看一看。
💻 C
字号:
/* --------------- edit.c ----------- */

#include "dflat.h"

extern DF_DBOX PrintSetup;

char DFlatApplication[] = "Edit";

static char Untitled[] = "Untitled";

static int wndpos;

static int MemoPadProc(DFWINDOW, DFMESSAGE, DF_PARAM, DF_PARAM);
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);
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

int main (int argc, char *argv[])
{
	DFWINDOW wnd;
	FILE *fp;

	if (DfInitialize () == FALSE)
		return 1;

	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);

	// 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 ())
		;

	DfTerminate ();

	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;

    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,NULL);
    }
	while (_findnext(ax, &ff) == 0);
	_findclose (ax);
}

/* ------- window processing module for the
                    Edit 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,NULL);
					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:
					EditDeleteFile(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 FreeDos Edit?"))
						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:
					Calendar(wnd);
					return TRUE;

//				case DF_ID_BARCHART:
//					BarChart(wnd);
//					return TRUE;

				case DF_ID_ABOUT:
                    DfMessageBox(
                         "About D-Flat and FreeDos Edit",
                        "   谀哪哪哪哪哪哪哪哪哪哪哪縗n"
                        "   

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -