Browse Source

fix to wrong characters in path problem and popped up window problem

git-svn-id: svn://svn.sharpdevelop.net/sharpdevelop/trunk@2969 1ccf3a8d-04fe-1044-b7c0-cef0b8235c61
shortcuts
Robert Pickering 18 years ago
parent
commit
2c8cf9a7ad
  1. 72
      src/AddIns/BackendBindings/FSharp/FSharp.Build.Tasks/Project/Src/Fsc.cs
  2. 40
      src/AddIns/BackendBindings/FSharp/FSharpBinding/Project/Src/fsi.fs
  3. BIN
      src/AddIns/BackendBindings/FSharp/RequiredLibraries/FSharp.Build.Tasks.dll

72
src/AddIns/BackendBindings/FSharp/FSharp.Build.Tasks/Project/Src/Fsc.cs

@ -102,40 +102,50 @@ namespace FSharp.Build.Tasks @@ -102,40 +102,50 @@ namespace FSharp.Build.Tasks
protected override string ToolName {
get { return "fsc.exe"; }
}
protected override string GenerateFullPathToTool()
{
string path = null;
if (Array.Exists<string>(ConfigurationManager.AppSettings.AllKeys, delegate(string k) { return k == "alt_fs_bin_path"; })) {
path = Path.Combine(ConfigurationManager.AppSettings["alt_fs_bin_path"], ToolName);
if (!File.Exists(path)) {
throw new Exception("you are trying to use the app setting alt_fs_bin_path, but fsc.exe is not localed in the given directory");
}
} else {
string[] paths = Environment.GetEnvironmentVariable("path").Split(';');
path = Array.Find(paths, delegate(string x) { return File.Exists(Path.Combine(x, "fsc.exe")); });
if (path != null) {
path = Path.Combine(path, ToolName);
} else {
string[] dirs = Directory.GetDirectories(Environment.GetEnvironmentVariable("ProgramFiles"), "FSharp*" );
List<FileInfo> files = new List<FileInfo>();
foreach (string dir in dirs) {
FileInfo file = new FileInfo(Path.Combine(Path.Combine(dir, "bin"), ToolName));
if (file.Exists) {
files.Add(file);
}
}
if (files.Count > 0) {
files.Sort(delegate(FileInfo x, FileInfo y) { return DateTime.Compare(x.CreationTime, y.CreationTime); });
path = files[0].FullName;
}
protected override string GenerateFullPathToTool() {
string path = null;
if (Array.Exists<string>(ConfigurationManager.AppSettings.AllKeys, delegate(string k) { return k == "alt_fs_bin_path"; })) {
path = Path.Combine(ConfigurationManager.AppSettings["alt_fs_bin_path"], ToolName);
if (!File.Exists(path)) {
throw new Exception("you are trying to use the app setting alt_fs_bin_path, but fsc.exe is not localed in the given directory");
}
}
else {
string[] paths = Environment.GetEnvironmentVariable("path").Split(';');
path = Array.Find(paths, delegate(string x) {
bool res = false;
try {
res = File.Exists(Path.Combine(x, "fsc.exe"));
}
catch {
res = false;
}
return res;
});
if (path != null) {
path = Path.Combine(path, ToolName);
}
else {
string[] dirs = Directory.GetDirectories(Environment.GetEnvironmentVariable("ProgramFiles"), "FSharp*");
List<FileInfo> files = new List<FileInfo>();
foreach (string dir in dirs) {
FileInfo file = new FileInfo(Path.Combine(Path.Combine(dir, "bin"), ToolName));
if (file.Exists) {
files.Add(file);
}
}
if (files.Count > 0) {
files.Sort(delegate(FileInfo x, FileInfo y) { return DateTime.Compare(x.CreationTime, y.CreationTime); });
path = files[0].FullName;
}
//else {
// throw new Exception("can not find the fsi.exe, ensure a version of the F# compiler is installed");
//}
}
}
return path;
}
}
}
return path;
}
protected override string GenerateCommandLineCommands()
{

40
src/AddIns/BackendBindings/FSharp/FSharpBinding/Project/Src/fsi.fs

@ -30,15 +30,13 @@ module TheControl = @@ -30,15 +30,13 @@ module TheControl =
let panel = new Panel()
let input = new TextBox(Anchor = (AnchorStyles.Left ||| AnchorStyles.Top ||| AnchorStyles.Right),
Width = panel.Width)
input.KeyUp.Add(fun ea ->
if ea.KeyData = Keys.Return then
fsiProcess.StandardInput.WriteLine(input.Text)
input.Text <- "" )
let output = new TextBox(Multiline = true,
Top = input.Height,
Height = panel.Height - input.Height,
Width = panel.Width,
ReadOnly = true,
ScrollBars = ScrollBars.Both,
WordWrap = false,
Anchor = (AnchorStyles.Left ||| AnchorStyles.Top ||| AnchorStyles.Right ||| AnchorStyles.Bottom))
panel.Controls.Add(input)
panel.Controls.Add(output)
@ -55,7 +53,7 @@ module TheControl = @@ -55,7 +53,7 @@ module TheControl =
else
let path = Environment.GetEnvironmentVariable("PATH")
let paths = path.Split([|';'|])
let path = paths |> Array.tryfind (fun x -> File.Exists(Path.Combine(x, "fsi.exe")))
let path = paths |> Array.tryfind (fun x -> try File.Exists(Path.Combine(x, "fsi.exe")) with _ -> false)
match path with
| Some x ->
fsiProcess.StartInfo.FileName <- Path.Combine(x, "fsi.exe")
@ -81,7 +79,13 @@ module TheControl = @@ -81,7 +79,13 @@ module TheControl =
"Please see http://research.microsoft.com/fsharp for details of how to install the compiler"
false
if foundCompiler then
input.KeyUp.Add(fun ea ->
if ea.KeyData = Keys.Return then
fsiProcess.StandardInput.WriteLine(input.Text)
input.Text <- "" )
//fsiProcess.StartInfo.Arguments <- "--fsi-server sharpdevelopfsi"
fsiProcess.StartInfo.UseShellExecute <- false
fsiProcess.StartInfo.CreateNoWindow <- true
fsiProcess.StartInfo.RedirectStandardError <- true
fsiProcess.StartInfo.RedirectStandardInput <- true
fsiProcess.StartInfo.RedirectStandardOutput <- true
@ -102,6 +106,13 @@ module TheControl = @@ -102,6 +106,13 @@ module TheControl =
lock errorQueue (fun () -> readAll errorQueue)
lock outputQueue (fun () -> readAll outputQueue))
timer.Start()
else
input.KeyUp.Add(fun ea ->
if ea.KeyData = Keys.Return then
output.Text <-
(output.Text + Environment.NewLine +
"F# not installed - could not execute command")
input.Text <- "" )
type FSharpInteractive = class
inherit AbstractPadContent
@ -114,13 +125,14 @@ type SentToFSharpInteractive = class @@ -114,13 +125,14 @@ type SentToFSharpInteractive = class
inherit AbstractMenuCommand
new () = {}
override x.Run() =
let window = WorkbenchSingleton.Workbench.ActiveWorkbenchWindow
if window <> null then
match window.ActiveViewContent :> obj with
| :? ITextEditorControlProvider as textArea ->
let textArea = textArea.TextEditorControl.ActiveTextAreaControl.TextArea
for selection in textArea.SelectionManager.SelectionCollection do
TheControl.fsiProcess.StandardInput.WriteLine(selection.SelectedText)
TheControl.fsiProcess.StandardInput.WriteLine(";;")
| _ -> ()
if TheControl.foundCompiler then
let window = WorkbenchSingleton.Workbench.ActiveWorkbenchWindow
if window <> null then
match window.ActiveViewContent :> obj with
| :? ITextEditorControlProvider as textArea ->
let textArea = textArea.TextEditorControl.ActiveTextAreaControl.TextArea
for selection in textArea.SelectionManager.SelectionCollection do
TheControl.fsiProcess.StandardInput.WriteLine(selection.SelectedText)
TheControl.fsiProcess.StandardInput.WriteLine(";;")
| _ -> ()
end

BIN
src/AddIns/BackendBindings/FSharp/RequiredLibraries/FSharp.Build.Tasks.dll

Binary file not shown.
Loading…
Cancel
Save