Example #1
0
 public CodeBlock(FsiSession session, IHighlightingDefinition syntaxHighlighting)
 {
     this.Document           = new TextDocument("");
     this.session            = session;
     this.syntaxHighlighting = syntaxHighlighting;
     this.run = new RelayCommand(OnRun, CanRun);
 }
 public CodeBlock(FsiSession session, IHighlightingDefinition syntaxHighlighting)
 {
     this.Document = new TextDocument("");
     this.session = session;
     this.syntaxHighlighting = syntaxHighlighting;
     this.run = new RelayCommand(OnRun, CanRun);
 }
        public EditorViewModel()
        {
            this.feedback = "";
            this.run = new RelayCommand(OnRun, CanRun);
            this.addCodeBlock = new RelayCommand(OnAddCodeBlock);

            var fsiPath = @"C:\Program Files (x86)\Microsoft F#\v4.0\fsi.exe";
            this.session = new FsiSession(fsiPath);

            this.Session.Start();
            this.Session.OutputReceived += OnOutputReceived;
            this.Session.ErrorReceived += OnErrorReceived;

            this.codeBlocks = new ObservableCollection<CodeBlock>();
            this.CodeBlocks.Add(new CodeBlock(this.Session));
        }
Example #4
0
        public static void Main(string[] args)
        {
            Console.WriteLine("Beginning");
            // This is the path to FSI.EXE on my machine, adjust accordingly
            var fsiPath = @"C:\Program Files (x86)\Microsoft F#\v4.0\fsi.exe";
            var session = new FsiSession(fsiPath);

            // start the session and hook the listeners
            session.Start();
            session.OutputReceived += OnOutputReceived;
            session.ErrorReceived += OnErrorReceived;

            // Send some trivial code to FSI and evaluate
            var code = @"let x = 42";
            session.AddLine(code);
            session.Evaluate();

            // Send a code block of 4 lines, using whitespace
            // note how x, which was declared previously,
            // is used in f as a closure, and still available.
            var line1 = @"let f y = x + y";
            var line2 = @"let z =";
            var line3 = @"   [ 1; 2; 3]";
            var line4 = @"   |> List.map (fun e -> f e)";

            session.AddLine(line1);
            session.AddLine(line2);
            session.AddLine(line3);
            session.AddLine(line4);
            session.Evaluate();

            // random "code" which is definitely not F#
            // nothing crashes but we don't get any output?
            var error1 = "Ph'nglui mglw'nafh Cthulhu R'lyeh wgah'nagl fhtagn";
            session.AddLine(error1);
            session.Evaluate();

            // In spite of invoking Cthulhu before,
            // our session is still healthy and evaluates this
            var code2 = @"let c = 123";
            session.AddLine(code2);
            session.Evaluate();

            // wait for user to type [ENTER] to close
            Console.ReadLine();
        }
Example #5
0
        public static void Main(string[] args)
        {
            Console.WriteLine("Beginning");
            // This is the path to FSI.EXE on my machine, adjust accordingly
            var fsiPath = @"C:\Program Files (x86)\Microsoft F#\v4.0\fsi.exe";
            var session = new FsiSession(fsiPath);

            // start the session and hook the listeners
            session.Start();
            session.OutputReceived += OnOutputReceived;
            session.ErrorReceived += OnErrorReceived;

            // Send some trivial code to FSI and evaluate
            var code = @"let x = 42";
            session.AddLine(code);
            session.Evaluate();

            // Send a code block of 4 lines, using whitespace
            // note how x, which was declared previously,
            // is used in f as a closure, and still available.
            var line1 = @"let f y = x + y";
            var line2 = @"let z =";
            var line3 = @"   [ 1; 2; 3]";
            var line4 = @"   |> List.map (fun e -> f e)";

            session.AddLine(line1);
            session.AddLine(line2);
            session.AddLine(line3);
            session.AddLine(line4);
            session.Evaluate();

            // random "code" which is definitely not F#
            // nothing crashes but we don't get any output?
            var error1 = "Ph'nglui mglw'nafh Cthulhu R'lyeh wgah'nagl fhtagn";
            session.AddLine(error1);
            session.Evaluate();

            // In spite of invoking Cthulhu before,
            // our session is still healthy and evaluates this
            var code2 = @"let c = 123";
            session.AddLine(code2);
            session.Evaluate();

            // wait for user to type [ENTER] to close
            Console.ReadLine();
        }
        public EditorViewModel(IConfiguration configuration)
        {
            this.fontSize = 13.0;
            this.configuration = configuration;
            DispatcherHelper.Initialize();

            this.feedback = "";
            this.run = new RelayCommand(OnRun, CanRun);
            this.addCodeBlock = new RelayCommand(OnAddCodeBlock);

            this.increaseFontSize = new RelayCommand(OnIncreaseFont);
            this.decreaseFontSize = new RelayCommand(OnDecreaseFont);

            var fsiPath = this.configuration.FsiLocation; //@"C:\Program Files (x86)\Microsoft F#\v4.0\fsi.exe";
            this.session = new FsiSession(fsiPath);

            this.Session.Start();
            this.Session.OutputReceived += OnOutputReceived;
            this.Session.ErrorReceived += OnErrorReceived;

            var editorLocation = Assembly.GetExecutingAssembly().Location;
            var editorPath = Path.GetDirectoryName(editorLocation);
            var highlightFileName = "FSharpHighlighting.xshd";
            var highlightFileLocation = Path.Combine(editorPath, highlightFileName);

            using (var stream = File.OpenRead(highlightFileLocation))
            {
                using (var reader = new XmlTextReader(stream))
                {
                    this.syntaxHighlighting = HighlightingLoader.Load(reader, HighlightingManager.Instance);
                }
            }

            this.codeBlocks = new ObservableCollection<CodeBlock>();
            this.CodeBlocks.Add(new CodeBlock(this.Session, this.syntaxHighlighting));

            this.feedbackBlocks = new ObservableCollection<FeedbackBlock>();
        }
Example #7
0
 public CodeBlock(FsiSession session)
 {
     this.code = "";
     this.session = session;
     this.run = new RelayCommand(OnRun, CanRun);
 }