Example #1
0
        /// <summary>
        /// Invokes the <c>set</c> accessor of the indexer with the specified parameters and the value to set.
        /// </summary>
        /// <param name="target">The target object on which the indexer is invoked.</param>
        /// <param name="indices">The parameters passed to the indexer.</param>
        /// <param name="value">The value to set.</param>
        public void SetItem(IScriptObject target, List <IScriptObject> indices, IScriptObject value)
        {
            var args = new List <IScriptObject>(indices);

            args.Insert(0, value);
            Method.Invoke(target, args);
        }
        internal void UpdateCaretPosition(bool ensureCursorVisible = true)
        {
            if (null == Solution.Current.ActiveScript)
            {
                return;
            }

            IScriptObject activeScript = Solution.Current.ActiveScript;
            CharPosition  converter    = activeScript.CreateCharPosition();

            System.Drawing.Point cursorPosition = textCore.CursorPosition;
            converter.SetCharacterPosition(cursorPosition);
            textCanvas.SetCursorScreenPos(converter.GetScreenPosition());
            if (ensureCursorVisible == true)
            {
                textCanvas.EnsureCursorVisible(cursorPosition.X, cursorPosition.Y);
            }

            // As the caret is moved around, more often than never the selection also
            // gets changed. It would make sense to update the visual here at the same time.
            textCanvas.SetSelectionRange(textCore.SelectionStart, textCore.SelectionEnd);

            // @TODO(Salman) merge these into one label control.
            LineCol.Text = "Line: " + Convert.ToString(cursorPosition.Y + 1) + "  " + "Col: " + Convert.ToString(cursorPosition.X + 1);
        }
        private bool CanSetBreakpointAt(int column, int line)
        {
            IScriptObject script     = Solution.Current.ActiveScript;
            ITextBuffer   textBuffer = ((null == script) ? null : script.GetTextBuffer());

            if (null == textBuffer)
            {
                return(false);
            }

            // Only non-empty lines, please.
            if (textBuffer.IsNullOrWhiteSpace(line))
            {
                return(false);
            }

            CodeFragment fragment = null;

            if (textCore.GetFragment(column, line, out fragment) > 0)
            {
                switch (fragment.CodeType)
                {
                case CodeFragment.Type.Comment:
                    return(false);

                // Even "None" should be okay because
                // empty spots are all of type "None".
                case CodeFragment.Type.None:
                default:
                    return(true);
                }
            }

            return(false);
        }
Example #4
0
 /// <summary>
 /// Performs an assignment.
 /// </summary>
 /// <param name="expression">The left expression.</param>
 /// <param name="value">The right value.</param>
 /// <exception cref="ArgumentNullException"><paramref name="expression"/> is <see langword="null"/>.</exception>
 /// <exception cref="RuntimeException">An exception occurred during the assignment.</exception>
 public void Assign(Expression expression, IScriptObject value)
 {
     if (expression is VariableReferenceExpression)
     {
         Assign((VariableReferenceExpression)expression, value);
     }
     else if (expression is MemberReferenceExpression)
     {
         Assign((MemberReferenceExpression)expression, value);
     }
     else if (expression is ArrayIndexerExpression)
     {
         Assign((ArrayIndexerExpression)expression, value);
     }
     else if (expression is ArrayExpression)
     {
         Assign((ArrayExpression)expression, value);
     }
     else if (expression == null)
     {
         throw new ArgumentNullException();
     }
     else
     {
         throw new RuntimeException(expression.LinePragma,
                                    ExceptionResource.LeftExpressionExpected);
     }
 }
        private void AppendSearchPaths(ProtoCore.Options options)
        {
            string assemblyPath = Assembly.GetAssembly(typeof(ExecutionSession)).Location;

            options.IncludeDirectories.Add(Path.GetDirectoryName(assemblyPath));

            ITextEditorSettings editorSettings = TextEditorCore.Instance.TextEditorSettings;

            if (Directory.Exists(editorSettings.IncludePath))
            {
                options.IncludeDirectories.Add(editorSettings.IncludePath);
            }

            IScriptObject entryPointScript = Solution.Current.ActiveScript;

            if (null != entryPointScript)
            {
                IParsedScript parsedScript = entryPointScript.GetParsedScript();
                if (null != parsedScript)
                {
                    string scriptPath = parsedScript.GetScriptPath();
                    options.RootModulePathName = parsedScript.GetScriptPath();

                    if (string.IsNullOrEmpty(scriptPath) == false)
                    {
                        string directoryName = Path.GetDirectoryName(scriptPath);
                        options.IncludeDirectories.Add(directoryName);
                    }
                }
            }
        }
Example #6
0
 public CodeEditor(IScriptObject bindingSource, string path)
 {
     InitializeComponent();
     roslynCodeEditor.TextChanged += RoslynCodeEditor_TextChanged;
     BindingSource = bindingSource;
     Path          = path;
 }
Example #7
0
        public static void LoadAsset <T>(IScriptObject asset, Action <T> onLoad)
            where T : UnityEngine.Object
        {
            /*
             * var poly = new PolyAsset
             * {
             *  AssetId = "7E-xyB6aiQ2"
             * };
             *
             * PolyAssetLoader.LoadAsset(poly, (obj) =>
             * {
             *  onLoad(obj as T);
             * });*/

            if (asset is UnityAsset)
            {
                UnityAssetLoader.LoadAsset <T>(asset as UnityAsset, (prefab) =>
                {
                    var obj = GameObject.Instantiate(prefab);

                    onLoad(obj);
                });
            }
            else if (asset is PolyAsset)
            {
                PolyAssetLoader.LoadAsset(asset as PolyAsset, (obj) =>
                {
                    onLoad(obj as T);
                });
            }
            else
            {
                throw new NotSupportedException("Unknown asset type " + asset.GetType());
            }
        }
 /// <summary>
 /// Invokes the <c>set</c> accessor of the property with the specified parameters and the value to set.
 /// </summary>
 /// <param name="target">The target object on which the property is invoked. It should be <see langword="null"/> if the property is a static property.</param>
 /// <param name="value">The value to set.</param>
 public void SetProperty(IScriptObject target, IScriptObject value)
 {
     Method.Invoke(target, new List <IScriptObject>()
     {
         value
     });
 }
        public static List <string> GetSearchPaths()
        {
            List <string> includeDirectories = new List <string>();
            string        assemblyPath       = Assembly.GetAssembly(typeof(ExtensionFactory)).Location;

            includeDirectories.Add(Path.GetDirectoryName(assemblyPath));

            if (Directory.Exists(textEditorCore.TextEditorSettings.IncludePath))
            {
                includeDirectories.Add(textEditorCore.TextEditorSettings.IncludePath);
            }

            IScriptObject entryPointScript = Solution.Current.ActiveScript;

            if (null != entryPointScript)
            {
                IParsedScript parsedScript = entryPointScript.GetParsedScript();
                if (null != parsedScript)
                {
                    string scriptPath = parsedScript.GetScriptPath();
                    if (string.IsNullOrEmpty(scriptPath) == false)
                    {
                        string directoryName = Path.GetDirectoryName(scriptPath);
                        includeDirectories.Add(directoryName);
                    }
                }
            }

            return(includeDirectories);
        }
        internal void UpdateVisualForScript(IScriptObject hostScript)
        {
            if (null == hostScript)
            {
                return;
            }

            // If there's no switching of active script,
            // then simply do a screen refresh and get out of here!
            if (textBuffer == hostScript.GetTextBuffer())
            {
                highlight.Render();
                lineHeading.Render();
                sourceDisplay.Render();
                auxiliary.Render();
                return;
            }

            children.Clear(); // Clears all children before populating it again.

            textBuffer = hostScript.GetTextBuffer();
            highlight.UpdateLayerForScript(hostScript);
            lineHeading.UpdateLayerForScript(hostScript);
            sourceDisplay.UpdateLayerForScript(hostScript);
            auxiliary.UpdateLayerForScript(hostScript);

            highlight.ResetHighlightLayer();
            highlight.ResetExecutionCursor();

            children.Add(auxiliary.Render());
            children.Add(highlight.Render());
            children.Add(lineHeading.Render());
            children.Add(sourceDisplay.Render());
        }
Example #11
0
 public static void AssertNotReadOnly(this IScriptObject scriptObject)
 {
     if (scriptObject.IsReadOnly)
     {
         throw new InvalidOperationException("The object is readonly");
     }
 }
Example #12
0
 /// <summary>
 /// Asserts that the specified script object is not readonly or throws a <see cref="ScriptRuntimeException"/>
 /// </summary>
 /// <param name="scriptObject">The script object.</param>
 /// <exception cref="ScriptRuntimeException">If the object is not readonly</exception>
 public static void AssertNotReadOnly(this IScriptObject scriptObject)
 {
     if (scriptObject.IsReadOnly)
     {
         throw new InvalidOperationException(RS.ReadOnlyObjectError);
     }
 }
Example #13
0
 public static void PreloadAsset(IScriptObject asset)
 {
     if (asset is UnityAsset)
     {
         UnityAssetLoader.LoadAsset <GameObject>((UnityAsset)asset, (obj) => { });
     }
 }
Example #14
0
 private void Assign(ArrayIndexerExpression expression, IScriptObject value)
 {
     if (expression.Target is SuperReferenceExpression)
     {
         var t = This as ISuperIndexableObject;
         if (t != null)
         {
             var args = new List <IScriptObject>();
             foreach (var idx in expression.Indices)
             {
                 args.Add(EvaluateExpression(idx));
             }
             try
             {
                 t.SetSuperItem(this, args, value);
                 return;
             }
             catch (RuntimeException)
             {
                 throw;
             }
             catch (Exception ex)
             {
                 throw new RuntimeException(expression.LinePragma, ex.Message, ex);
             }
         }
     }
     {
         var target = EvaluateExpression(expression.Target);
         if (target is ScriptNull)
         {
             throw new RuntimeException(expression.Target.LinePragma,
                                        ExceptionResource.NullReference);
         }
         var ind = target as IIndexableObject;
         if (ind == null)
         {
             throw new RuntimeException(expression.LinePragma,
                                        ExceptionResource.IndexerNotSupported);
         }
         var args = new List <IScriptObject>();
         foreach (var idx in expression.Indices)
         {
             args.Add(EvaluateExpression(idx));
         }
         try
         {
             ind.SetItem(this, args, value);
         }
         catch (RuntimeException)
         {
             throw;
         }
         catch (Exception ex)
         {
             throw new RuntimeException(expression.LinePragma, ex.Message, ex);
         }
     }
 }
Example #15
0
 internal void PushGlobalOnly(IScriptObject scriptObject)
 {
     if (scriptObject == null)
     {
         throw new ArgumentNullException(nameof(scriptObject));
     }
     _globalContexts.Push(GetOrCreateGlobalContext(scriptObject));
 }
Example #16
0
 public AppliedEffect(IWorldObjectEffectHandler handler, WorldObjectBehaviour worldObject, ResourceActivationContext activationContext, WorldObjectEffectPlayer effectPlayer, IScriptObject effect)
 {
     Handler           = handler;
     WorldObject       = worldObject;
     ActivationContext = activationContext;
     EffectPlayer      = effectPlayer;
     Effect            = effect;
 }
Example #17
0
 internal void PushGlobalOnly(IScriptObject scriptObject)
 {
     if (scriptObject == null)
     {
         throw new ArgumentNullException(nameof(scriptObject));
     }
     _globalStores.Push(scriptObject);
 }
Example #18
0
        private IScriptObject GetStoreForWrite(ScriptVariable variable)
        {
            var           scope      = variable.Scope;
            IScriptObject finalStore = null;

            switch (scope)
            {
            case ScriptVariableScope.Global:
                // In scientific we always resolve to local storage first
                IScriptObject storeWithVariable = null;

                var name           = variable.Name;
                int lastStoreIndex = _globalContexts.Count - 1;
                var items          = _globalContexts.Items;
                for (int i = lastStoreIndex; i >= 0; i--)
                {
                    var store = items[i].LocalObject;
                    if (storeWithVariable == null && store.Contains(name))
                    {
                        storeWithVariable = store;
                    }

                    // We check that for upper store, we actually can write a variable with this name
                    // otherwise we don't allow to create a variable with the same name as a readonly variable
                    if (!store.CanWrite(name))
                    {
                        var variableType = store == BuiltinObject ? "builtin " : string.Empty;
                        throw new ScriptRuntimeException(variable.Span, $"Cannot set the {variableType}readonly variable `{variable}`");
                    }
                }

                // If we have a store for this variable name use it, otherwise use the first store available.
                finalStore = storeWithVariable ?? items[lastStoreIndex].LocalObject;
                break;

            case ScriptVariableScope.Local:
                if (_currentLocalContext.LocalObject != null)
                {
                    finalStore = _currentLocalContext.LocalObject;
                }
                else if (_globalContexts.Count > 0)
                {
                    finalStore = _globalContexts.Peek().LocalObject;
                }
                else
                {
                    throw new ScriptRuntimeException(variable.Span, $"Invalid usage of the local variable `{variable}` in the current context");
                }

                break;

            default:
                Debug.Assert(false, $"Variable scope `{scope}` is not implemented");
                break;
            }

            return(finalStore);
        }
Example #19
0
 /// <summary>
 /// Tries to set the value and readonly state of the specified member.
 /// </summary>
 /// <param name="member">The member.</param>
 /// <param name="value">The value.</param>
 /// <param name="readOnly">if set to <c>true</c> the value will be read only.</param>
 /// <returns><c>true</c> if the value could be set; <c>false</c> if a value already exist an is readonly</returns>
 public static bool TrySetValue(this IScriptObject @this, string member, object value, bool readOnly)
 {
     if (@this.IsReadOnly(member))
     {
         return(false);
     }
     @this.SetValue(member, value, readOnly);
     return(true);
 }
Example #20
0
        public void Add(IScriptObject child)
        {
            if (_objects == null)
            {
                _objects = new List <IScriptObject>();
            }

            _objects.Add(child);
        }
Example #21
0
 /// <summary>
 /// Tries to set the value and readonly state of the specified member.
 /// </summary>
 /// <param name="member">The member.</param>
 /// <param name="value">The value.</param>
 /// <param name="readOnly">if set to <c>true</c> the value will be read only.</param>
 /// <returns><c>true</c> if the value could be set; <c>false</c> if a value already exist an is readonly</returns>
 public static bool TrySetValue(this IScriptObject @this, string member, object value, bool readOnly)
 {
     if ([email protected](member))
     {
         return(false);
     }
     @this.SetValue(null, new SourceSpan(), member, value, readOnly);
     return(true);
 }
Example #22
0
        void DoPropertyChanged(IScriptObject owner, ScriptEvent PropertyChanged)
        {
            Assert.AreEqual("propertyChanged", PropertyChanged.Name, "p1");
            Assert.AreEqual(true, PropertyChanged.SupportsActions, "p2");
            Assert.AreEqual("", PropertyChanged.Handler, "p3");
            Assert.IsNotNull(PropertyChanged.Actions, "p4");

            DoActions(owner, PropertyChanged.Actions);
        }
Example #23
0
        public void Add(IScriptObject child)
        {
            if (_objects == null)
            {
                _objects = new List<IScriptObject>();
            }

            _objects.Add(child);
        }
Example #24
0
 /// <summary>
 /// Pushes a new object context accessible to the template.
 /// </summary>
 /// <param name="scriptObject">The script object.</param>
 /// <exception cref="System.ArgumentNullException"></exception>
 public void PushGlobal(IScriptObject scriptObject)
 {
     if (scriptObject == null)
     {
         throw new ArgumentNullException(nameof(scriptObject));
     }
     _globalStores.Push(scriptObject);
     PushVariableScope(ScriptVariableScope.Local);
 }
Example #25
0
        private void OnScrollViewerLeftButtonDown(object sender, MouseButtonEventArgs e)
        {
            if (null == Solution.Current.ActiveScript)
            {
                return; // No active script.
            }
            if (e.ClickCount > 1)
            {
                HandleMultipleClicks(e);
                return;
            }

            // We need the canvas to be focusable in order to receive key inputs.
            System.Diagnostics.Debug.Assert(textCanvas.Focusable == true);
            textCanvas.Focus(); // Set input focus on the canvas.

            if (IsMouseInClickableRegion(sender, e) == false)
            {
                return;
            }
            System.Windows.Point screenPoint  = GetRelativeCanvasPosition(e);
            IScriptObject        activeScript = Solution.Current.ActiveScript;
            CharPosition         mousePoint   = activeScript.CreateCharPosition();

            mousePoint.SetScreenPosition(screenPoint);
            System.Drawing.Point cursor = mousePoint.GetCharacterPosition();

            breakpointLineY = -1;
            if (IsPointWithinLineColumn(screenPoint))
            {
                clickedLineIndex = cursor.Y;
                textCore.SelectLines(cursor.Y, 0);
            }
            else
            {
                clickedLineIndex = -1;
                if (IsPointWithinBreakColumn(GetRelativeCanvasPosition(e)))
                {
                    breakpointLineY = cursor.Y;
                }

                textCore.SetMouseDownPosition(cursor.X, cursor.Y, e);
            }

            // Capturing mouse input results in an immediate mouse-move event,
            // but we won't want to handle that as we know that we are
            // currently in a button-down event. So here we ignore the immediate
            // mouse-move event by setting "stopMouseMoveReentrant" to true.
            //
            ignoreMouseMoveEvent = true;
            TextEditorScrollViewer scrollViewer = sender as TextEditorScrollViewer;

            mouseCursorCaptured  = scrollViewer.CaptureMouse();
            ignoreMouseMoveEvent = false;
            UpdateCaretPosition();
        }
        /// <summary>
        /// Imports the specified object intto this <see cref="ScriptObject"/> context. See remarks.
        /// </summary>
        /// <param name="obj">The object.</param>
        /// <param name="filter">Optional member filterer</param>
        /// <param name="renamer">Optional renamer</param>
        /// <remarks>
        /// <ul>
        /// <li>If <paramref name="obj"/> is a <see cref="System.Type"/>, this method will import only the static field/properties of the specified object.</li>
        /// <li>If <paramref name="obj"/> is a <see cref="ScriptObject"/>, this method will import the members of the specified object into the new object.</li>
        /// <li>If <paramref name="obj"/> is a plain object, this method will import the public fields/properties of the specified object into the <see cref="ScriptObject"/>.</li>
        /// </ul>
        /// </remarks>
        public static void Import(this IScriptObject script, object obj, FilterMemberDelegate filter = null, MemberRenamerDelegate renamer = null)
        {
            if (obj is IScriptObject)
            {
                script.Import((IScriptObject)obj);
                return;
            }

            script.Import(obj, ScriptMemberImportFlags.All, filter, renamer);
        }
 void AddInteractibleItemIndicator(IScriptObject item)
 {
     if (InteractiveItemTable)
     {
         if (item is ILocationAugmentedOptions && ARIndicator)
         {
             InteractiveItemTable.AddItem(ARIndicator);
         }
     }
 }
		public ScriptTypeDescriptor (IScriptObject scriptObject)
		{
			if (scriptObject == null)
				throw new ArgumentNullException ("scriptObject");

			this.scriptObject = scriptObject;
			this.events = new List<ScriptEventDescriptor>();
			this.methods = new List<ScriptMethodDescriptor>();
			this.props = new List<ScriptPropertyDescriptor>();
		}
Example #29
0
        /// <summary>
        /// Specifies whether this script object is equal to another <see cref="IScriptObject"/>.
        /// </summary>
        /// <param name="other">The other <see cref="IScriptObject"/>.</param>
        /// <returns><see langword="true"/> if this script object is equal to the other <see cref="IScriptObject"/>; otherwise, <see langword="false"/>.</returns>
        public override bool Equals(IScriptObject other)
        {
            var value = other as StringObject;

            if (value == null)
            {
                return(false);
            }
            return(this.Value == value.Value);
        }
Example #30
0
        /// <summary>
        /// Imports the specified object intto this <see cref="ScriptObject"/> context. See remarks.
        /// </summary>
        /// <param name="obj">The object.</param>
        /// <remarks>
        /// <ul>
        /// <li>If <paramref name="obj"/> is a <see cref="System.Type"/>, this method will import only the static field/properties of the specified object.</li>
        /// <li>If <paramref name="obj"/> is a <see cref="ScriptObject"/>, this method will import the members of the specified object into the new object.</li>
        /// <li>If <paramref name="obj"/> is a plain object, this method will import the public fields/properties of the specified object into the <see cref="ScriptObject"/>.</li>
        /// </ul>
        /// </remarks>
        public static void Import(this IScriptObject script, object obj)
        {
            if (obj is IScriptObject)
            {
                script.Import((IScriptObject)obj);
                return;
            }

            script.Import(obj, ScriptMemberImportFlags.All);
        }
Example #31
0
        /// <summary>
        /// Sets the variable to read only.
        /// </summary>
        /// <param name="variable">The variable.</param>
        /// <param name="isReadOnly">if set to <c>true</c> the variable will be set to readonly.</param>
        /// <exception cref="ArgumentNullException">If variable is null</exception>
        /// <remarks>
        /// This will not throw an exception if a previous variable was readonly.
        /// </remarks>
        public void SetReadOnly(ScriptVariable variable, bool isReadOnly = true)
        {
            if (variable == null)
            {
                throw new ArgumentNullException(nameof(variable));
            }
            IScriptObject store = GetStoreForSet(variable).First();

            store.SetReadOnly(variable.Name, isReadOnly);
        }
        public void CreateNewScriptObject()
        {
            frmNewScriptObjectDialog newScriptDialog = new frmNewScriptObjectDialog(scriptPairs);

            newScriptDialog.ShowDialog();
            if (newScriptDialog.type != "Cancel")
            {
                IScriptObject newScript = ((ScriptFactoryCK2)ScriptFactoryCK2.GetFactory()).GetScriptObject(newScriptDialog.type);
                view.AddNewScriptObject(newScript);
            }
        }
Example #33
0
        private void gatherFrom(IScriptObject scriptObject)
        {
            if (_gatheredList.Contains(scriptObject)) return;
            _gatheredList.Add(scriptObject);

            var allScripts = scriptObject.AllScripts();
            _scripts.Fill(allScripts);

            allScripts.Each(gatherFrom);
            scriptObject.Dependencies().Each(gatherFrom);
        }
Example #34
0
		public ScriptEvent (IScriptObject owner, string name, bool supportsActions)
		{
			if (owner == null)
				throw new ArgumentNullException ("owner");
			if (name == null)
				throw new ArgumentNullException ("name");

			this.owner = owner;
			this.name = name;
			this.supportsActions = supportsActions;
			this.handler = "";
		}
        /// <summary>
        /// Imports the specified <see cref="ScriptObject"/> into this instance by copying the member values into this object.
        /// </summary>
        /// <param name="other">The other <see cref="ScriptObject"/>.</param>
        public static void Import(this IScriptObject @this, IScriptObject other)
        {
            if (other == null)
            {
                return;
            }

            var thisScript = @this.GetScriptObject();
            var otherScript = other.GetScriptObject();

            foreach (var keyValue in otherScript.store)
            {
                var member = keyValue.Key;
                if (thisScript.IsReadOnly(member))
                {
                    continue;
                }
                thisScript.store[keyValue.Key] = keyValue.Value;
            }
        }
Example #36
0
 /// <summary>
 /// Pushes a new model context accessible to the template.
 /// </summary>
 /// <param name="scriptObject">The script object.</param>
 /// <exception cref="System.ArgumentNullException"></exception>
 public void PushGlobal(IScriptObject scriptObject)
 {
     if (scriptObject == null) throw new ArgumentNullException(nameof(scriptObject));
     globalStores.Push(scriptObject);
     PushVariableScope(ScriptVariableScope.Local);
 }
Example #37
0
 public void AddDependency(IScriptObject scriptObject)
 {
     _dependencies.Fill(scriptObject);
 }
        public void UpdateUiForModifiedScript(IScriptObject currScript)
        {
            if (null != currScript)
            {
                ITextBuffer textBuffer = currScript.GetTextBuffer();
                if (null != textBuffer && (textBuffer.ScriptModified != false))
                {
                    // Only need to refresh display for modifications.
                    UpdateScriptDisplay(currScript);

                    // If the context content was modified, 
                    // then recalculate canvas dimension.
                    UpdateCanvasDimension();
                }
            }
        }
 internal void UpdateScriptDisplay(IScriptObject script)
 {
     textCanvas.UpdateVisualForScript(script);
     scrollViewer.InvalidateScrollInfo();
 }
Example #40
0
 protected override void UpdateLayerForScriptCore(IScriptObject hostScript)
 {
     selectionStart = hostScript.CreateCharPosition();
     selectionEnd = hostScript.CreateCharPosition();
     lineSelection = hostScript.CreateCharPosition();
     inLineSelection = hostScript.CreateCharPosition();
     allOccurencesSelectionStart = hostScript.CreateCharPosition();
     allOccurencesSelectionEnd = hostScript.CreateCharPosition();
     currentOccurenceSelectionStart = hostScript.CreateCharPosition();
     currentOccurenceSelectionEnd = hostScript.CreateCharPosition();
 }
Example #41
0
        internal void UpdateVisualForScript(IScriptObject hostScript)
        {
            if (null == hostScript)
                return;

            // If there's no switching of active script,
            // then simply do a screen refresh and get out of here!
            if (textBuffer == hostScript.GetTextBuffer())
            {
                highlight.Render();
                lineHeading.Render();
                sourceDisplay.Render();
                auxiliary.Render();
                return;
            }

            children.Clear(); // Clears all children before populating it again.

            textBuffer = hostScript.GetTextBuffer();
            highlight.UpdateLayerForScript(hostScript);
            lineHeading.UpdateLayerForScript(hostScript);
            sourceDisplay.UpdateLayerForScript(hostScript);
            auxiliary.UpdateLayerForScript(hostScript);

            highlight.ResetHighlightLayer();
            highlight.ResetExecutionCursor();

            children.Add(auxiliary.Render());
            children.Add(highlight.Render());
            children.Add(lineHeading.Render());
            children.Add(sourceDisplay.Render());
        }
Example #42
0
        internal TextBuffer(IScriptObject owningScript)
        {
            this.owningScript = owningScript;
            IParsedScript parsedScript = owningScript.GetParsedScript();

            if (parsedScript.GetScriptPath() == "")
            {
                this.lineList = new List<string>();
                this.lineList.Add(string.Empty);
            }
            else
            {
                string scriptFilePath = parsedScript.GetScriptPath();
                ScriptFileReader scriptReader = new ScriptFileReader(scriptFilePath, true);
                this.lineList = scriptReader.ReadInput();
            }

            undoRedoRecorder = new UndoRedoRecorder(this.lineList);

            this.parsePending = true;
            this.scriptModified = false;
        }
Example #43
0
 protected abstract void UpdateLayerForScriptCore(IScriptObject hostScript);
Example #44
0
 protected override void UpdateLayerForScriptCore(IScriptObject hostScript)
 {
 }
Example #45
0
 public void UpdateLayerForScript(IScriptObject hostScript)
 {
     currentScript = hostScript;
     UpdateLayerForScriptCore(hostScript);
 }
		void DoActions (IScriptObject owner, ActionCollection Actions)
		{
			Assert.AreEqual (owner, ((IScriptObject)Actions).Owner, "a1");
			Assert.AreEqual (0, Actions.Count, "a2");
		}
		public void SetOwner (IScriptObject owner)
		{
			this.owner = owner;
		}
		void DoBindings (IScriptObject owner, BindingCollection bindings)
		{
			Assert.AreEqual (owner, ((IScriptObject)bindings).Owner, "A4");
			Assert.AreEqual (0, bindings.Count, "b1");
			Assert.AreEqual ("", ((IScriptObject)bindings).ID, "b2");
		}
		void DoScriptEvents (IScriptObject owner, ScriptEventCollection ScriptEvents)
		{
			Assert.AreEqual (1, ((ICollection)ScriptEvents).Count, "e1");
			IEnumerator<ScriptEvent> e = ((IEnumerable<ScriptEvent>)ScriptEvents).GetEnumerator();

			e.MoveNext();

			ScriptEvent ev = e.Current;

			Assert.AreEqual ("propertyChanged", ev.Name, "p1");
			Assert.AreEqual (true, ev.SupportsActions, "p2");
			Assert.AreEqual ("", ev.Handler, "p3");
			Assert.IsNotNull (ev.Actions, "p4");

			DoActions (owner, ev.Actions);
		}
Example #50
0
 /// <summary>
 /// Register the given IScriptObject instance with the manager.
 /// 
 /// The manager will keep a reference to the given object until the object is unregistered.
 /// </summary>
 /// <param name="scriptObject"></param>
 /// <returns></returns>
 public ScriptObjectInfo RegisterScriptObject(IScriptObject scriptObject)
 {
     ScriptObjectInfo info;
     info.Instance = scriptObject;
     info.BeginPlay = new ScriptObjectInstanceInfo.BeginPlayAction(scriptObject.BeginPlay);
     info.Tick = new ScriptObjectInstanceInfo.TickAction(scriptObject.Tick);
     info.Destroy = new ScriptObjectInstanceInfo.DestroyAction(scriptObject.Destroy);
     _scriptObjects.Add(scriptObject.InstanceID, info);
     return info;
 }
		void DoPropertyChanged (IScriptObject owner, ScriptEvent PropertyChanged)
		{
			Assert.AreEqual ("propertyChanged", PropertyChanged.Name, "p1");
			Assert.AreEqual (true, PropertyChanged.SupportsActions, "p2");
			Assert.AreEqual ("", PropertyChanged.Handler, "p3");
			Assert.IsNotNull (PropertyChanged.Actions, "p4");

			DoActions (owner, PropertyChanged.Actions);
		}
		public TransformScriptEvent (IScriptObject owner)
			: base (owner, "transform", true)
		{
		}