Exemplo n.º 1
0
void FileList::SetFilePanelModes()
{
	int CurMode=0;

	if (CtrlObject->Cp()->ActivePanel->GetType()==FILE_PANEL)
	{
		CurMode=CtrlObject->Cp()->ActivePanel->GetViewMode();
		CurMode=CurMode?CurMode-1:9;
	}

	for(;;)
	{
		MenuDataEx ModeListMenu[]=
		{
			MSG(MEditPanelModesBrief),0,0,
			MSG(MEditPanelModesMedium),0,0,
			MSG(MEditPanelModesFull),0,0,
			MSG(MEditPanelModesWide),0,0,
			MSG(MEditPanelModesDetailed),0,0,
			MSG(MEditPanelModesDiz),0,0,
			MSG(MEditPanelModesLongDiz),0,0,
			MSG(MEditPanelModesOwners),0,0,
			MSG(MEditPanelModesLinks),0,0,
			MSG(MEditPanelModesAlternative),0,0,
		};
		int ModeNumber;
		ModeListMenu[CurMode].SetSelect(1);
		{
			VMenu ModeList(MSG(MEditPanelModes),ModeListMenu,ARRAYSIZE(ModeListMenu),ScrY-4);
			ModeList.SetPosition(-1,-1,0,0);
			ModeList.SetHelp(L"PanelViewModes");
			ModeList.SetFlags(VMENU_WRAPMODE);
			ModeList.Process();
			ModeNumber=ModeList.Modal::GetExitCode();
		}

		if (ModeNumber<0)
			return;

		CurMode=ModeNumber;

		enum ModeItems
		{
			MD_DOUBLEBOX,
			MD_TEXTTYPES,
			MD_EDITTYPES,
			MD_TEXTWIDTHS,
			MD_EDITWIDTHS,
			MD_TEXTSTATUSTYPES,
			MD_EDITSTATUSTYPES,
			MD_TEXTSTATUSWIDTHS,
			MD_EDITSTATUSWIDTHS,
			MD_SEPARATOR1,
			MD_CHECKBOX_FULLSCREEN,
			MD_CHECKBOX_ALIGNFILEEXT,
			MD_CHECKBOX_ALIGNFOLDEREXT,
			MD_CHECKBOX_FOLDERUPPERCASE,
			MD_CHECKBOX_FILESLOWERCASE,
			MD_CHECKBOX_UPPERTOLOWERCASE,
			MD_CHECKBOX_PRELOADC0DATA,
			MD_SEPARATOR2,
			MD_BUTTON_OK,
			MD_BUTTON_CANCEL,
		} ;
		DialogDataEx ModeDlgData[]=
		{
			DI_DOUBLEBOX, 3, 1,72,16,0,0,ModeListMenu[ModeNumber].Name,
			DI_TEXT,      5, 2, 0, 2,0,0,MSG(MEditPanelModeTypes),
			DI_EDIT,      5, 3,35, 3,0,DIF_FOCUS,L"",
			DI_TEXT,      5, 4, 0, 4,0,0,MSG(MEditPanelModeWidths),
			DI_EDIT,      5, 5,35, 5,0,0,L"",
			DI_TEXT,     38, 2, 0, 2,0,0,MSG(MEditPanelModeStatusTypes),
			DI_EDIT,     38, 3,70, 3,0,0,L"",
			DI_TEXT,     38, 4, 0, 4,0,0,MSG(MEditPanelModeStatusWidths),
			DI_EDIT,     38, 5,70, 5,0,0,L"",
			DI_TEXT,      3, 6, 0, 6,0,DIF_SEPARATOR,MSG(MEditPanelReadHelp),
			DI_CHECKBOX,  5, 7, 0, 7,0,0,MSG(MEditPanelModeFullscreen),
			DI_CHECKBOX,  5, 8, 0, 8,0,0,MSG(MEditPanelModeAlignExtensions),
			DI_CHECKBOX,  5, 9, 0, 9,0,0,MSG(MEditPanelModeAlignFolderExtensions),
			DI_CHECKBOX,  5,10, 0,10,0,0,MSG(MEditPanelModeFoldersUpperCase),
			DI_CHECKBOX,  5,11, 0,11,0,0,MSG(MEditPanelModeFilesLowerCase),
			DI_CHECKBOX,  5,12, 0,12,0,0,MSG(MEditPanelModeUpperToLowerCase),
			DI_CHECKBOX,  5,13, 0,12,0,0,MSG(MEditPanelModePreloadC0Data),
			DI_TEXT,      3,14, 0,13,0,DIF_SEPARATOR,L"",
			DI_BUTTON,    0,15, 0,14,0,DIF_DEFAULT|DIF_CENTERGROUP,MSG(MOk),
			DI_BUTTON,    0,15, 0,14,0,DIF_CENTERGROUP,MSG(MCancel),
		};
		MakeDialogItemsEx(ModeDlgData,ModeDlg);
		int ExitCode;
		RemoveHighlights(ModeDlg[MD_DOUBLEBOX].strData);

		if (ModeNumber==9)
			ModeNumber=0;
		else
			ModeNumber++;

		PanelViewSettings NewSettings=ViewSettingsArray[ModeNumber];
		ModeDlg[MD_CHECKBOX_FULLSCREEN].Selected=NewSettings.FullScreen;
		ModeDlg[MD_CHECKBOX_ALIGNFILEEXT].Selected=NewSettings.AlignExtensions;
		ModeDlg[MD_CHECKBOX_ALIGNFOLDEREXT].Selected=NewSettings.FolderAlignExtensions;
		ModeDlg[MD_CHECKBOX_FOLDERUPPERCASE].Selected=NewSettings.FolderUpperCase;
		ModeDlg[MD_CHECKBOX_FILESLOWERCASE].Selected=NewSettings.FileLowerCase;
		ModeDlg[MD_CHECKBOX_UPPERTOLOWERCASE].Selected=NewSettings.FileUpperToLowerCase;
		ModeDlg[MD_CHECKBOX_PRELOADC0DATA].Selected=NewSettings.PreloadC0Data;
		ViewSettingsToText(NewSettings.ColumnType,NewSettings.ColumnWidth,NewSettings.ColumnWidthType,
		                   NewSettings.ColumnCount,FALSE,ModeDlg[2].strData,ModeDlg[4].strData);
		ViewSettingsToText(NewSettings.StatusColumnType,NewSettings.StatusColumnWidth,NewSettings.StatusColumnWidthType,
		                   NewSettings.StatusColumnCount,TRUE,ModeDlg[6].strData,ModeDlg[8].strData);
		{
			Dialog Dlg(ModeDlg,ARRAYSIZE(ModeDlg));
			Dlg.SetPosition(-1,-1,76,18);
			Dlg.SetHelp(L"PanelViewModes");
			Dlg.Process();
			ExitCode=Dlg.GetExitCode();
		}

		if (ExitCode!=MD_BUTTON_OK)
			continue;

		memset(&NewSettings,0,sizeof(NewSettings));
		NewSettings.FullScreen=ModeDlg[MD_CHECKBOX_FULLSCREEN].Selected;
		NewSettings.AlignExtensions=ModeDlg[MD_CHECKBOX_ALIGNFILEEXT].Selected;
		NewSettings.FolderAlignExtensions=ModeDlg[MD_CHECKBOX_ALIGNFOLDEREXT].Selected;
		NewSettings.FolderUpperCase=ModeDlg[MD_CHECKBOX_FOLDERUPPERCASE].Selected;
		NewSettings.FileLowerCase=ModeDlg[MD_CHECKBOX_FILESLOWERCASE].Selected;
		NewSettings.FileUpperToLowerCase=ModeDlg[MD_CHECKBOX_UPPERTOLOWERCASE].Selected;
		NewSettings.PreloadC0Data=ModeDlg[MD_CHECKBOX_PRELOADC0DATA].Selected;
		TextToViewSettings(ModeDlg[MD_EDITTYPES].strData,ModeDlg[MD_EDITWIDTHS].strData,FALSE,
		                   NewSettings.ColumnType,NewSettings.ColumnWidth,NewSettings.ColumnWidthType,NewSettings.ColumnCount);
		TextToViewSettings(ModeDlg[MD_EDITSTATUSTYPES].strData,ModeDlg[MD_EDITSTATUSWIDTHS].strData,TRUE,
		                   NewSettings.StatusColumnType,NewSettings.StatusColumnWidth,NewSettings.StatusColumnWidthType,NewSettings.StatusColumnCount);
		ViewSettingsArray[ModeNumber]=NewSettings;
		CtrlObject->Cp()->LeftPanel->SortFileList(TRUE);
		CtrlObject->Cp()->RightPanel->SortFileList(TRUE);
		CtrlObject->Cp()->SetScreenPosition();
		int LeftMode=CtrlObject->Cp()->LeftPanel->GetViewMode();
		int RightMode=CtrlObject->Cp()->RightPanel->GetViewMode();
//    CtrlObject->Cp()->LeftPanel->SetViewMode(ModeNumber);
//    CtrlObject->Cp()->RightPanel->SetViewMode(ModeNumber);
		CtrlObject->Cp()->LeftPanel->SetViewMode(LeftMode);
		CtrlObject->Cp()->RightPanel->SetViewMode(RightMode);
		CtrlObject->Cp()->LeftPanel->Redraw();
		CtrlObject->Cp()->RightPanel->Redraw();
	}
}
Exemplo n.º 2
0
StatementNode* Parser::Instruction()
{
    if(currenttoken->type == Si)
    {
        ConsumeToken();
        ExpressionNode* condition=Expresion();
        if(currenttoken->type != Entonces)
            throw invalid_argument("Se esperaba palabra reservada entonces.  Row:"+to_string(currenttoken->row)+"Column:"+to_string(currenttoken->column));
        ConsumeToken();
        vector<StatementNode*> codeTrue=InstructionList();
        vector<StatementNode*> codeFalse=SiInstructionPrime();
        return new SiNode(condition,codeTrue,codeFalse);
    }
    else if(currenttoken->type == Para)
    {
        ConsumeToken();
        VariableNode * id=Variable();
        if(currenttoken->type != ValueAllocation)
            throw invalid_argument("Se esperaba <-.  Row:"+to_string(currenttoken->row)+"Column:"+to_string(currenttoken->column));
        ConsumeToken();
        ExpressionNode* value=Expresion();

        if(currenttoken->type != Hasta)
            throw invalid_argument("Se esperaba palabra reservada hasta.  Row:"+to_string(currenttoken->row)+"Column:"+to_string(currenttoken->column));
        ConsumeToken();
        ExpressionNode* condition = Expresion();
        if(currenttoken->type != Haga)
            throw invalid_argument("Se esperaba palabra reservada haga.  Row:"+to_string(currenttoken->row)+"Column:"+to_string(currenttoken->column));
        ConsumeToken();
        vector<StatementNode*> code =InstructionList();
        if(currenttoken->type != Fin)
            throw invalid_argument("Se esperaba palabra reservada fin.  Row:"+to_string(currenttoken->row)+"Column:"+to_string(currenttoken->column));
        ConsumeToken();
        if(currenttoken->type != Para)
            throw invalid_argument("Se esperaba palabra reservada para.  Row:"+to_string(currenttoken->row)+"Column:"+to_string(currenttoken->column));
        ConsumeToken();
        return new ParaNode(new AssignmentNode(id,value),condition,code);
    }
    else if(currenttoken->type == Id)
    {
        VariableNode* id=Variable();
        if(currenttoken->type != ValueAllocation)
            throw invalid_argument("Se esperaba <-.  Row:"+to_string(currenttoken->row)+"Column:"+to_string(currenttoken->column));
        ConsumeToken();
        ExpressionNode* expression=Expresion();
        return new AssignmentNode(id,expression);
    }
    else if(currenttoken->type == Escriba)
    {
        ConsumeToken();
        vector<ExpressionNode*> exprList=ExpressionListNotNull();
        return new EscribaNode(exprList);
    }
    else if(currenttoken->type == Mientras)
    {
        ConsumeToken();
        ExpressionNode * condition=Expresion();
        if(currenttoken->type != Haga)
            throw invalid_argument("Se esperaba palabra reservada haga.  Row:"+to_string(currenttoken->row)+"Column:"+to_string(currenttoken->column));
        ConsumeToken();
        vector<StatementNode*>code=InstructionList();
        if(currenttoken->type != Fin)
            throw invalid_argument("Se esperaba palabra reservada fin.  Row:"+to_string(currenttoken->row)+"Column:"+to_string(currenttoken->column));
        ConsumeToken();
        if(currenttoken->type != Mientras)
            throw invalid_argument("Se esperaba palabra reservada mientras.  Row:"+to_string(currenttoken->row)+"Column:"+to_string(currenttoken->column));
        ConsumeToken();
        return new MientrasNode(condition,code);
    }
    else if(currenttoken->type == Repita)
    {
        ConsumeToken();
        vector<StatementNode*> code=InstructionList();
        if(currenttoken->type != Hasta)
            throw invalid_argument("Se esperaba palabra reservada hasta.  Row:"+to_string(currenttoken->row)+"Column:"+to_string(currenttoken->column));
        ConsumeToken();
        ExpressionNode*condition=Expresion();
        return new RepitaNode(code,condition);
    }
    else if(currenttoken->type == Caso)
    {
        ConsumeToken();
        VariableNode * id=Variable();
        vector<CasoLineNode*> cases=CasoList();
        vector<StatementNode*> defaultcase=CasoSino();
        if(currenttoken->type != Fin)
            throw invalid_argument("Se esperaba palabra reservada fin.  Row:"+to_string(currenttoken->row)+"Column:"+to_string(currenttoken->column));
        ConsumeToken();
        if(currenttoken->type != Caso)
            throw invalid_argument("Se esperaba palabra reservada caso.  Row:"+to_string(currenttoken->row)+"Column:"+to_string(currenttoken->column));
        ConsumeToken();
        return new CasoNode(id,cases,defaultcase);
    }
    else if(currenttoken->type == Abrir)
    {
        ConsumeToken();
        string archiveId=Archive();
        if(currenttoken->type != Como)
            throw invalid_argument("Se esperaba palabra reservada como.  Row:"+to_string(currenttoken->row)+"Column:"+to_string(currenttoken->column));
        ConsumeToken();
        VariableNode* archiveType=Variable();
        vector<ModeNode*> modes=ModeList();
        return new AbrirArchivoNode(archiveId,archiveType,modes);
    }
    else if(currenttoken->type == Cerrar)
    {
        ConsumeToken();
        VariableNode* id= Variable();
        return new CerrarArchivoNode(id);
    }
    else if(currenttoken->type == Leer)
    {
        ConsumeToken();
        VariableNode* archive=Variable();
        if(currenttoken->type != Coma)
            throw invalid_argument("Se esperaba ,.  Row:"+to_string(currenttoken->row)+"Column:"+to_string(currenttoken->column));
        ConsumeToken();
        VariableNode* data=Variable();
        return new LeerArchivoNode(archive,data);
    }
    else if(currenttoken->type == Escribir)
    {
        ConsumeToken();
        VariableNode* archive=Variable();
        if(currenttoken->type != Coma)
            throw invalid_argument("Se esperaba ,.  Row:"+to_string(currenttoken->row)+"Column:"+to_string(currenttoken->column));
        ConsumeToken();
        VariableNode* data=Variable();
        return new EscribirArchivoNode(archive,data);
    }
    else if(currenttoken->type == Llamar)
    {
        ConsumeToken();
        if(currenttoken->type != Id)
            throw invalid_argument("Se esperaba un id.  Row:"+to_string(currenttoken->row)+"Column:"+to_string(currenttoken->column));
        string id=currenttoken->lexeme;
        ConsumeToken();
        vector<ExpressionNode*> parameters=Parameters();
        return new LlamarNode(id,parameters);
    }
    else if(currenttoken->type == Retorne)
    {
        ConsumeToken();
        ExpressionNode* id=Expresion();
        return new RetorneNode(id);
    }
}