This repository has been archived by the owner on Oct 16, 2020. It is now read-only.
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Browse files
Browse the repository at this point in the history
Move common code for running the IronRuby or IronPython console from …
…the menu to the Scripting project.
- Loading branch information
Showing
8 changed files
with
74 additions
and
94 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
65 changes: 65 additions & 0 deletions
65
src/AddIns/BackendBindings/Scripting/Project/Src/RunScriptingConsoleApplicationCommand.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,65 @@ | ||
// Copyright (c) AlphaSierraPapa for the SharpDevelop Team (for details please see \doc\copyright.txt) | ||
// This code is distributed under the GNU LGPL (for details please see \doc\license.txt) | ||
|
||
using System; | ||
using System.Diagnostics; | ||
using System.IO; | ||
|
||
using ICSharpCode.Core; | ||
using ICSharpCode.SharpDevelop.Debugging; | ||
|
||
namespace ICSharpCode.Scripting | ||
{ | ||
public class RunScriptingConsoleApplicationCommand : AbstractMenuCommand | ||
{ | ||
IDebugger debugger; | ||
IScriptingWorkbench workbench; | ||
ScriptingConsoleApplication scriptingConsoleApplication; | ||
|
||
public RunScriptingConsoleApplicationCommand(IScriptingWorkbench workbench, | ||
IDebugger debugger, | ||
ScriptingConsoleApplication scriptingConsoleApplication) | ||
{ | ||
this.workbench = workbench; | ||
this.debugger = debugger; | ||
this.scriptingConsoleApplication = scriptingConsoleApplication; | ||
} | ||
|
||
public bool Debug { | ||
get { return scriptingConsoleApplication.Debug; } | ||
set { scriptingConsoleApplication.Debug = value; } | ||
} | ||
|
||
public override void Run() | ||
{ | ||
ProcessStartInfo processStartInfo = CreateProcessStartInfo(); | ||
if (Debug) { | ||
debugger.Start(processStartInfo); | ||
} else { | ||
PauseCommandPromptProcessStartInfo commandPrompt = new PauseCommandPromptProcessStartInfo(processStartInfo); | ||
debugger.StartWithoutDebugging(commandPrompt.ProcessStartInfo); | ||
} | ||
} | ||
|
||
ProcessStartInfo CreateProcessStartInfo() | ||
{ | ||
scriptingConsoleApplication.ScriptFileName = GetScriptFileName(); | ||
scriptingConsoleApplication.WorkingDirectory = GetWorkingDirectory(); | ||
return scriptingConsoleApplication.GetProcessStartInfo(); | ||
} | ||
|
||
string GetWorkingDirectory() | ||
{ | ||
return Path.GetDirectoryName(WorkbenchPrimaryFileName); | ||
} | ||
|
||
FileName WorkbenchPrimaryFileName { | ||
get { return workbench.ActiveViewContent.PrimaryFileName; } | ||
} | ||
|
||
string GetScriptFileName() | ||
{ | ||
return Path.GetFileName(WorkbenchPrimaryFileName); | ||
} | ||
} | ||
} |