Exemplo n.º 1
0
void MainCommand(HWND hWnd, int ID)
{
    switch (ID) {
	case IDCANCEL: EndDialog(hWnd, 0); break;
	case ID_OPEN: MainOpenFile(hWnd); break;
	case ID_SCRIPTMAN: ShowScriptMan(); break;
	case ID_EXIT: FireCommand(":quit\n"); break;

	/* Load one of the last 10 open files */
	case ID_MRU+0: case ID_MRU+1: case ID_MRU+2: case ID_MRU+3:
	case ID_MRU+4: case ID_MRU+5: case ID_MRU+6: case ID_MRU+7:
	case ID_MRU+8: case ID_MRU+9:
	    {
		char Command[1000];
		wsprintf(Command, ":load %s", ExpandFileName(MruGetItem(ID-ID_MRU)));
		FireCommand(Command);
	    }
	    break;

	// EDIT MENU
	case ID_CUT: RtfWindowClipboard(WM_CUT); break;
	case ID_COPY: RtfWindowClipboard(WM_COPY); break;
	case ID_PASTE: RtfWindowClipboard(WM_PASTE); break;
	case ID_CLEARSCREEN: RtfWindowClear(); break;
	case ID_DELETE: RtfWindowDelete(); break;
	case ID_SELECTALL: RtfWindowSelectAll(); break;
	case ID_GOPREVIOUS: RtfWindowHistory(-1); break;
	case ID_GONEXT: RtfWindowHistory(+1); break;


	// ACTIONS MENU
	// Reload script files
	case ID_COMPILE: case ID_MAKE: FireCommand(":reload"); break;
	case ID_CLEARALL: FireCommand(":load"); break;
	case ID_GOEDIT: FireCommand(":edit"); break;

	/* Stop program execution */
	case ID_STOP:
	    MessageBeep(0xFFFFFFFF);
	    AbortExecution();
	    break;

	/* Evaluate main expression */
	case ID_RUN:
	    {
		char Buffer[1000];
		RtfWindowGetCommand(Buffer);
		if (Buffer[0] == '\0')
			FireCommand(":main");
		else
		    FireCommand(Buffer);
	    }
	    break;

	/* Set interpreter options using dialog box */
	case ID_SETOPTIONS:
	    if (ShowOptionsDialog(hWnd))
		RtfWindowUpdateFont();
	    break;


	// BROWSE MENU
	case ID_BROWSEHIERARCHY: DrawClassesHierarchy(); break;
	case ID_BROWSECLASSES: DoBrowseClasses(); break;
	case ID_BROWSENAMES: DoBrowseNames(); break;
	case ID_BROWSETYCONS: DoBrowseTycons(); break;

	// HELP MENU
	case ID_HELPCONTENTS: ExecuteFileDocs("hugs98.chm"); break;
	case ID_HELPCOMMANDS: FireCommand(":?\n"); break;
	case ID_LIBRARIES: ExecuteFile("http://www.haskell.org/ghc/docs/latest/html/libraries/index.html"); break;
	case ID_WWWHASKELL: ExecuteFile("http://haskell.org/"); break;
	case ID_WWWHUGS: ExecuteFile("http://haskell.org/hugs/"); break;
	case ID_ABOUT: ShowAboutDialog(hWnd); break;
    }
}
Exemplo n.º 2
0
DWORD WINAPI MainCommandThread(LPVOID lpParam)
{
	HWND hWnd = hWndMain;
	INT ID = (INT) lpParam;

	switch (ID) {
		case IDCANCEL: 
			EndDialog(hWnd, 0); 
			break;
		case ID_FILE_LOAD: 
			LoadFileFromFileDialog(hWnd); 
			break;
		case ID_FILE_ADD: 
			AddFileFromFileDialog(hWnd); 
			break;
		case ID_EXIT: 
			SendMessage(hWndMain, WM_CLOSE,0,0); 
			break;
		/* Load one of the last 10 open files */
		case ID_MRU+0: case ID_MRU+1: case ID_MRU+2: case ID_MRU+3:
		case ID_MRU+4: case ID_MRU+5: case ID_MRU+6: case ID_MRU+7:
		case ID_MRU+8: case ID_MRU+9:
			LoadFile(GetMruFile(ID-ID_MRU));
			break;

		case ID_CUT: 
			RtfWindowClipboard(WM_CUT); 
			break;
		case ID_COPY: 
			RtfWindowClipboard(WM_COPY); 
			break;
		case ID_PASTE: 
			RtfWindowClipboard(WM_PASTE); 
			break;
		case ID_CLEARSCREEN: 
			RtfWindowClear(); 
			break;
		case ID_DELETE: 
			RtfWindowDelete(); 
			break;
		case ID_SELECTALL: 
			RtfWindowSelectAll(); 
			break;
		case ID_GOPREVIOUS: 
			RtfWindowRelativeHistory(-1); 
			break;
		case ID_GONEXT: 
			RtfWindowRelativeHistory(+1); 
			break;


		case ID_COMPILE: 
			FireCommand(TEXT(":reload")); 
			break;
		case ID_CLEARALL: 
			FireCommand(TEXT(":load")); 
			break;
		case ID_GOEDIT: 
			FireCommand(TEXT(":edit")); 
			break;

		/* Stop program execution */
		case ID_STOP:
			AbortExecution();
			break;

		case ID_TOOLS_TOOL1:
		case ID_TOOLS_TOOL2:
		case ID_TOOLS_TOOL3:
		case ID_TOOLS_TOOL4:
		case ID_TOOLS_TOOL5:
		case ID_TOOLS_TOOL6:
		case ID_TOOLS_TOOL7:
		case ID_TOOLS_TOOL8:
		case ID_TOOLS_TOOL9:
		case ID_TOOLS_TOOL10:		
			ToolFireCommand(ID-ID_TOOLS_TOOL1);
			break;

		/* Evaluate main expression */
		case ID_RUN:
			{
				#define BUFF_LEN 2048
				TCHAR Buffer[BUFF_LEN];
				RtfWindowGetCommand(Buffer,BUFF_LEN);
				if (StringIsEmpty(Buffer))
					FireCommand(TEXT(":main"));
				else
					FireCommand(Buffer);
			}
			break;

		/* Set interpreter options using dialog box */
		case ID_SETOPTIONS:
			ShowOptsDialog();
			break;

		case ID_TOOLS_CONFIGURE:
			ShowToolsDialog();
			break;

			// HELP MENU
		case ID_HELPCONTENTS:  {
			ExecuteFileDocs(TEXT("index.html"));
			break;
							   }
		case ID_HELPCOMMANDS: 
			FireCommand(TEXT(":?")); 
			break;
		case ID_LIBRARIES: 
			ExecuteFileDocs(TEXT("libraries\\index.html")); 
			break;
		case ID_WWWHASKELL: 
			ExecuteFile(TEXT("http://haskell.org/")); 
			break;
		case ID_WWWGHC: 
			ExecuteFile(TEXT("http://haskell.org/ghc/")); 
			break;
		case ID_ABOUT: 
			ShowAboutDialog(); 
			break;
	}
	return 0;
}