コード例 #1
0
        async Task Listen()
        {
            var token = _cancellationTokenSource.Token;

            string last = null;

            while (!token.IsCancellationRequested && !token.WaitHandle.WaitOne(500))
            {
                string clipboard = Clipboard.GetText(); // Get clipboard.
                if (clipboard == last || clipboard == null)
                {
                    continue;                                         // Clipboard did not change.
                }
                last = clipboard;

                // Clipboard changed.

                try
                {
                    // As workshop actions
                    ConvertTextToElement tte      = new ConvertTextToElement(clipboard);
                    Workshop             workshop = tte.GetActionList();

                    if (workshop != null) // Determines if the clipboard is an action list.
                    {
                        DebuggerActionSetResult actionStream = new DebuggerActionSetResult(workshop);

                        // Action list successfully parsed.
                        // Get the DeltinScript.
                        VariableCollection = (await _languageServer.DocumentHandler.OnScriptAvailability())?.DebugVariables;

                        // Error obtaining debug variables.
                        if (VariableCollection == null)
                        {
                            return;
                        }

                        // Apply debugger variables.
                        VariableCollection.Apply(actionStream);

                        // Notify the adapter of the new state.
                        _languageServer.Server.SendNotification("debugger.activated");
                    }
                }
                catch (Exception ex)
                {
                    _languageServer.DebuggerException(ex);
                }
            }
        }