示例#1
0
文件: cpulab.go 项目: iand/go
func init() {
	mainMenuDialog = termdialog.NewSelectionDialog("Main Menu", nil)
	cpuDialog = termdialog.NewSelectionDialog("CPU", nil)
	structureDialog = termdialog.NewSelectionDialog("Structure", nil)
	registersDialog = termdialog.NewSelectionDialog("Registers", nil)
	editRegisterDialog = termdialog.NewSelectionDialog("Edit Register", nil)
	registerBanksDialog = termdialog.NewSelectionDialog("Register Banks", nil)
	editRegisterBankDialog = termdialog.NewSelectionDialog("Edit Register Bank", nil)
	ramsDialog = termdialog.NewSelectionDialog("RAMs", nil)
	editRamDialog = termdialog.NewSelectionDialog("Edit RAM", nil)
	instructionsDialog = termdialog.NewSelectionDialog("Instructions", nil)
	editInstructionDialog = termdialog.NewSelectionDialog("Edit Instruction", nil)
	addMicroInstructionDialog = termdialog.NewSelectionDialog("Add Microinstruction", nil)
	addMoveMicroInstructionDialog = termdialog.NewSelectionDialog("Add Register Transfer Microinstruction", nil)
	addMoveMicroInstructionDestinationDialog = termdialog.NewSelectionDialog("Add Register Transfer Microinstruction", nil)
	addRamReadMicroInstructionDialog = termdialog.NewSelectionDialog("Add RAM Read Microinstruction", nil)
	addRamWriteMicroInstructionDialog = termdialog.NewSelectionDialog("Add RAM Write Microinstruction", nil)
	editMicroInstructionDialog = termdialog.NewSelectionDialog("Edit Microinstruction", nil)
	confirmationDialog = termdialog.NewSelectionDialog("Are you sure?", nil)

	addRegisterDialog = termdialog.NewInputDialog("Add Register", "Name:", 12, "", addRegisterWidthCallback, nil)
	addRegisterWidthDialog = termdialog.NewInputDialog("Add Register", "Width:", 4, "", addRegisterCallback, nil)
	editRegisterNameDialog = termdialog.NewInputDialog("Edit Register", "Name:", 12, "", editRegisterNameCallback, nil)
	editRegisterWidthDialog = termdialog.NewInputDialog("Edit Register", "Width:", 4, "", editRegisterWidthCallback, nil)
	addRegisterBankDialog = termdialog.NewInputDialog("Add Register Bank", "Name:", 12, "", addRegisterBankWidthCallback, nil)
	addRegisterBankWidthDialog = termdialog.NewInputDialog("Add Register Bank", "Width:", 4, "", addRegisterBankDepthCallback, nil)
	addRegisterBankDepthDialog = termdialog.NewInputDialog("Add Register Bank", "Depth:", 8, "", addRegisterBankCallback, nil)
	editRegisterBankNameDialog = termdialog.NewInputDialog("Edit Register Bank", "Name:", 12, "", editRegisterBankNameCallback, nil)
	editRegisterBankWidthDialog = termdialog.NewInputDialog("Edit Register Bank", "Width:", 4, "", editRegisterBankWidthCallback, nil)
	editRegisterBankDepthDialog = termdialog.NewInputDialog("Edit Register Bank", "Depth:", 8, "", editRegisterBankDepthCallback, nil)
	addRamDialog = termdialog.NewInputDialog("Add RAM", "Name:", 12, "", addRamWidthCallback, nil)
	addRamWidthDialog = termdialog.NewInputDialog("Add RAM", "Width:", 4, "", addRamDepthCallback, nil)
	addRamDepthDialog = termdialog.NewInputDialog("Add RAM", "Depth:", 8, "", addRamCallback, nil)
	editRamNameDialog = termdialog.NewInputDialog("Edit RAM", "Name:", 12, "", editRamNameCallback, nil)
	editRamWidthDialog = termdialog.NewInputDialog("Edit RAM", "Width:", 4, "", editRamWidthCallback, nil)
	editRamDepthDialog = termdialog.NewInputDialog("Edit RAM", "Depth:", 8, "", editRamDepthCallback, nil)
	addInstructionDialog = termdialog.NewInputDialog("Add Instruction", "Mnemonic:", 12, "", addInstructionCallback, nil)
	editInstructionNameDialog = termdialog.NewInputDialog("Edit Instruction", "Mnemonic:", 12, "", editInstructionNameCallback, nil)

	errorDialog = termdialog.NewMessageDialog("Error", "")

	openDialog = termdialog.NewInputDialog("Open from "+SavesDir, "Filename:", 20, "", openCallback, nil)
	saveDialog = termdialog.NewInputDialog("Save to "+SavesDir, "Filename:", 20, "", saveCallback, nil)

	mainMenuDialog.AddOption(&termdialog.Option{"Edit CPU", openDialogCallback, cpuDialog})
	mainMenuDialog.AddOption(&termdialog.Option{"Open", openDialogCallback, openDialog})
	mainMenuDialog.AddOption(&termdialog.Option{"Save", openDialogCallback, saveDialog})
	mainMenuDialog.AddOption(&termdialog.Option{"Exit", nil, nil})

	cpuDialog.AddOption(&termdialog.Option{"Structure", openDialogCallback, structureDialog})
	cpuDialog.AddOption(&termdialog.Option{"Instructions", openDialogCallback, instructionsDialog})
	cpuDialog.AddOption(&termdialog.Option{"Close", nil, nil})

	structureDialog.AddOption(&termdialog.Option{"Registers", openDialogCallback, registersDialog})
	structureDialog.AddOption(&termdialog.Option{"Register banks", openDialogCallback, registerBanksDialog})
	structureDialog.AddOption(&termdialog.Option{"RAMs", openDialogCallback, ramsDialog})
	structureDialog.AddOption(&termdialog.Option{"Close", nil, nil})

	editRegisterDialog.AddOption(&termdialog.Option{"Edit name", openDialogCallback, editRegisterNameDialog})
	editRegisterDialog.AddOption(&termdialog.Option{"Edit width", openDialogCallback, editRegisterWidthDialog})
	editRegisterDialog.AddOption(&termdialog.Option{"Delete", deleteRegisterCallback, nil})
	editRegisterDialog.AddOption(&termdialog.Option{"Close", nil, nil})

	editRegisterBankDialog.AddOption(&termdialog.Option{"Edit name", openDialogCallback, editRegisterBankNameDialog})
	editRegisterBankDialog.AddOption(&termdialog.Option{"Edit width", openDialogCallback, editRegisterBankWidthDialog})
	editRegisterBankDialog.AddOption(&termdialog.Option{"Edit depth", openDialogCallback, editRegisterBankDepthDialog})
	editRegisterBankDialog.AddOption(&termdialog.Option{"Delete", deleteRegisterBankCallback, nil})
	editRegisterBankDialog.AddOption(&termdialog.Option{"Close", nil, nil})

	editRamDialog.AddOption(&termdialog.Option{"Edit name", openDialogCallback, editRamNameDialog})
	editRamDialog.AddOption(&termdialog.Option{"Edit width", openDialogCallback, editRamWidthDialog})
	editRamDialog.AddOption(&termdialog.Option{"Edit depth", openDialogCallback, editRamDepthDialog})
	editRamDialog.AddOption(&termdialog.Option{"Delete", deleteRamCallback, nil})
	editRamDialog.AddOption(&termdialog.Option{"Close", nil, nil})

	editInstructionDialog.AddOption(&termdialog.Option{"Edit mnemonic", openDialogCallback, editInstructionNameDialog})
	editInstructionDialog.AddOption(&termdialog.Option{"Edit microinstructions", openDialogCallback, nil})
	editInstructionDialog.AddOption(&termdialog.Option{"Delete", deleteInstructionCallback, nil})
	editInstructionDialog.AddOption(&termdialog.Option{"Close", nil, nil})

	addMicroInstructionDialog.AddOption(&termdialog.Option{"Register transfer", addMoveMicroInstructionOpenCallback, nil})
	addMicroInstructionDialog.AddOption(&termdialog.Option{"RAM read", addRamReadMicroInstructionOpenCallback, nil})
	addMicroInstructionDialog.AddOption(&termdialog.Option{"RAM write", addRamWriteMicroInstructionOpenCallback, nil})
	addMicroInstructionDialog.AddOption(&termdialog.Option{"Close", nil, nil})

	editMicroInstructionDialog.AddOption(&termdialog.Option{"Delete", deleteMicroInstructionCallback, nil})
	editMicroInstructionDialog.AddOption(&termdialog.Option{"Close", nil, nil})

	confirmationDialog.AddOption(&termdialog.Option{"No", nil, nil})
	confirmationDialog.AddOption(&termdialog.Option{"Yes", confirmCallback, nil})

	refreshGUI()
}
示例#2
0
文件: instructiongui.go 项目: iand/go
func addInstructionToGui(instruction *Instruction) {
	instruction.editOption = instructionsDialog.AddOption(&termdialog.Option{"Edit " + instruction.Name, editInstructionOpenCallback, instruction})
	instruction.microInstructionsDialog = termdialog.NewSelectionDialog("Microinstructions", nil)
	instruction.microInstructionsDialog.AddOption(&termdialog.Option{"Add", openDialogCallback, addMicroInstructionDialog})
	instruction.microInstructionsDialog.AddOption(&termdialog.Option{"Close", nil, nil})
}