Beispiel #1
0
        public override void OnGUI(Rect rect)
        {
            GUILayout.Label(richRow, Styles.RichLabelStyle);
            EditorGUILayout.Space(15);
            foreach (var error in responses)
            {
                EditorGUILayout.BeginHorizontal();
                EditorGUILayout.LabelField(error.word);

                if (GUILayout.Button("Add to exceptions"))
                {
                    SpellCheckCache.AddToExceptions(error.word);
                    changeTextCallback(row);
                    editorWindow.Close();
                }

                EditorGUILayout.EndHorizontal();
                EditorGUI.indentLevel++;
                foreach (var hint in error.s)
                {
                    if (GUILayout.Button(hint, GUILayout.Width(10 * hint.Length)))
                    {
                        var newText = ChangeText(error, hint);
                        changeTextCallback(newText);
                        editorWindow.Close();
                    }
                }
                EditorGUI.indentLevel--;
            }
        }
Beispiel #2
0
        public static string DrawTextField(
            string uniqueFieldKey,
            string label,
            string currentContent,
            Action repaintCallback,
            Action <string> updateTextCallback,
            bool multiline = false)
        {
            var currentRect = EditorGUILayout.BeginHorizontal();

            GUILayout.Space(EditorGUI.indentLevel * 20);

            var result = SpellCheckCache.QueueChecking(uniqueFieldKey, currentContent, repaintCallback);

            if (result == null)
            {
                if (Buttons.Loading())
                {
                }
            }
            else if (result.Length == 0)
            {
                Buttons.Valid();
            }
            else
            {
                if (Buttons.Warning())
                {
                    var popupContent = new SpellCheckHintsContent(currentContent, result, (newRow) =>
                    {
                        updateTextCallback(newRow);
                        repaintCallback();
                    });
                    PopupWindow.Show(
                        new Rect(currentRect.x + 30, currentRect.y, currentRect.width, currentRect.height),
                        popupContent);
                }
            }
            currentContent =
                multiline ? EditorGUILayout.TextArea(currentContent) :
                string.IsNullOrEmpty(label)
                ? EditorGUILayout.TextField(currentContent) :
                EditorGUILayout.TextField(label, currentContent);
            EditorGUILayout.EndHorizontal();
            return(currentContent);
        }
 private void PrintResultFor(string label, string row, string newRow, ref string result)
 {
     if (row != newRow)
     {
         var info = SpellCheckCache.QueueChecking(label, row, Repaint);
         if (info == null)
         {
             result = "Loading...";
         }
         else if (info.Length == 0)
         {
             result = "No errors";
         }
         else
         {
             result = string.Join(",", info[0].s ?? new string[0]);
         }
     }
     EditorGUILayout.LabelField(label, result);
 }
        private void DrawExceptions()
        {
            var exceptions = SpellCheckCache.GetExceptions();

            if (exceptions.Length == 0)
            {
                EditorGUILayout.LabelField("Add word to exception, when see error");
                return;
            }
            foreach (var exception in exceptions)
            {
                EditorGUILayout.BeginHorizontal();

                if (Buttons.Delete())
                {
                    SpellCheckCache.RemoveFromExceptions(exception);
                    Repaint();
                }
                EditorGUILayout.LabelField(exception);

                EditorGUILayout.EndHorizontal();
            }
        }