Esempio n. 1
0
VOID SendOptions2GHCi(VOID)
{
	FLAG *fs;
	TCHAR Buffer[1024];

	for(fs = flags; fs->FlagState != NULL; fs++) {
		MakeGHCiFlagCommand(fs,Buffer);
		SendToGHCiStdinLn(Buffer);
	}

	MakeGHCiExpandedEditorCommand(ComboGetValue(GHCi_Combo_Editor), Buffer);
	SendToGHCiStdinLn(Buffer);
	 
	MakeGHCiPromptCommand(ComboGetValue(GHCi_Combo_Prompt), Buffer, TRUE);
	SendToGHCiStdinLn(Buffer);

	PrintGHCiOutput(hChildStdoutRd, STDOUT_COLOR);

	// clear screen, so that only one instance of the prompt is shown
	RtfWindowClearLastLine();
	SendToGHCiStdinLn(TEXT(""));
	PrintGHCiOutput(hChildStdoutRd, STDOUT_COLOR);

}
Esempio n. 2
0
VOID PreprocessCommand(LPCTSTR InputCommand, LPTSTR NewCommand)
{
	LPTSTR path, opt, prompt, flag, editor, Command = (LPTSTR) InputCommand;
	TCHAR Buffer[MAX_PATH];
	
	StringCpy(NewCommand,Command);


	// skip initial spaces
	while(*Command == TEXT(' '))
		Command++;

	if(*Command == TEXT(':'))
		Command++;
	else
		// it is not a command
		return;

	
	if (path=IsCommand(TEXT("cd"), Command)) {
		// in case the user typed ":cd <dir>", update WinGHCi current dir
		if(StringIsEmpty(path)) {
			// get user home dir
			SHGetFolderPath(NULL,CSIDL_PROFILE,NULL,SHGFP_TYPE_CURRENT,Buffer);
		    path = Buffer;
		}
		SetCurrentDirectory(path);
		StringCpy(LastFileLoaded,TEXT("")); // no file loaded after changing dir
    
	} else if (IsCommand(TEXT("quit"), Command)) {
		SendMessage(hWndMain,WM_CLOSE,0,0);
	} else if (opt=IsCommand(TEXT("set"),Command)) {

		if(prompt=StringIsPreffix(TEXT("prompt "), opt)) {
			//skip whitespaces
			while(*prompt==TEXT(' ')) prompt++;
			
			// in case the user wants to change the prompt, add markers
			ComboAdd(GHCi_Combo_Prompt,prompt);
			MakeGHCiPromptCommand(prompt, NewCommand, TRUE);
		} else if (editor=StringIsPreffix(TEXT("editor "), opt)) {
			ComboAdd(GHCi_Combo_Editor,editor);
			MakeGHCiExpandedEditorCommand(editor, NewCommand);
		} else if (flag=StringIsPreffix(TEXT("+r"), opt)) {
			GHCi_Flag_RevertCAFs = TRUE;
		} else if (flag=StringIsPreffix(TEXT("+s"), opt)) {
			GHCi_Flag_PrintStats = TRUE;
		} else if (flag=StringIsPreffix(TEXT("+t"), opt)) {
			GHCi_Flag_PrintTypes = TRUE;
		}

	} else if (opt=IsCommand(TEXT("unset"),Command)) {

		if (flag=StringIsPreffix(TEXT("+r"), opt)) {
			GHCi_Flag_RevertCAFs = FALSE;
		} else if (flag=StringIsPreffix(TEXT("+s"), opt)) {
			GHCi_Flag_PrintStats = FALSE;
		} else if (flag=StringIsPreffix(TEXT("+t"), opt)) {
			GHCi_Flag_PrintTypes = FALSE;
		}

	} else if (path=IsCommand(TEXT("load"),Command)) {
		StringCpy(LastFileLoaded,path); // a new file is loaded
	}
	
	
	/* else if (path=IsCommand(TEXT("load"), Command)) {
		LoadFile(path);
		StringCpy(NewCommand,TEXT(""));
	}*/
}
Esempio n. 3
0
VOID UpdateOptions(HWND hDlg) 
{
  FLAG *fs;
  TCHAR Buffer[3*MAX_PATH];

  if(ComboHasChanged(hDlg,GHCi_Combo_Startup)) {
	  INT resp = MessageBox( hDlg
		                   , TEXT("GHCi startup has changed. The interpreter must be initialized. Do you want to proceed?")
						   , TEXT("WinGHCi"), MB_YESNO|MB_ICONQUESTION);

	  if(resp==IDYES) {
        RtfWindowPutS(TEXT("\n"));
		ComboGetDlgText(hDlg, GHCi_Combo_Startup, Buffer, 3*MAX_PATH);
		
		SetEvent(hKillGHCi);
		//pause StdoutPrinterThread thread
		SignalObjectAndWait(hSigSuspendStdoutPrinterThread
			               ,hSigStdoutPrinterThreadSuspended, INFINITE, FALSE);

		if (CreateGHCiProcess(Buffer)) {		
            ComboUpdate(hDlg,GHCi_Combo_Startup);
		} else {
			TCHAR ErrorMsg[3*MAX_PATH];
			wsprintf( ErrorMsg,TEXT("GHCi could not be initialized as follows:\n %s\n\nIt will be restarted using the previous configuration:\n %s")
				    , Buffer, ComboGetValue(GHCi_Combo_Startup)
				);
			MessageBox( hDlg
		              , ErrorMsg
					  , TEXT("WinGHCi"), MB_OK|MB_ICONSTOP);
			CreateGHCiProcess(ComboGetValue(GHCi_Combo_Startup));
		}

		// resume StdoutPrinterThread
		Sleep(100);
		SetEvent(hSigResumeStdoutPrinterThread);
	  }	
  }



 //update flags
 for(fs = flags; fs->FlagState != NULL; fs++) {
	 BOOL newState = GetDlgItemBool(hDlg, fs->CtrlID);
	 BOOL hasChanged = newState != *(fs->FlagState);
	 *(fs->FlagState) = newState;

	 if(hasChanged) {
		MakeGHCiFlagCommand(fs,Buffer);
		FireCommand(Buffer);
	 }
 }

 // update editor	
 if(ComboHasChanged(hDlg,GHCi_Combo_Editor)) {
	 ComboUpdate(hDlg,GHCi_Combo_Editor);
	 MakeGHCiEditorCommand(ComboGetValue(GHCi_Combo_Editor), Buffer);
	 FireCommand(Buffer);
 }


 //update prompt
 if(ComboHasChanged(hDlg,GHCi_Combo_Prompt)) {
	 ComboUpdate(hDlg,GHCi_Combo_Prompt);
	 MakeGHCiPromptCommand(ComboGetValue(GHCi_Combo_Prompt), Buffer, FALSE);
	 FireCommand(Buffer);
 }


}