fix Autocomplete buttons moving when you click them, rename Console namespace to CSConsole

This commit is contained in:
sinaioutlander 2020-11-13 23:50:24 +11:00
parent 7a4c7eb498
commit e9acd68ee4
15 changed files with 37 additions and 32 deletions

View File

@ -8,7 +8,7 @@ using UnityExplorer.Helpers;
using UnityExplorer.UI;
using UnityExplorer.UI.Modules;
namespace UnityExplorer.Console
namespace UnityExplorer.CSConsole
{
public class AutoCompleter
{
@ -133,8 +133,12 @@ namespace UnityExplorer.Console
try
{
var editor = ConsolePage.Instance.m_codeEditor;
if (!editor.InputField.isFocused)
return;
var textGen = editor.InputText.cachedTextGenerator;
int caretPos = editor.InputField.caretPosition;
int caretPos = editor.m_lastCaretPos;
if (caretPos == m_lastCaretPos)
return;

View File

@ -1,9 +1,9 @@
using System.Collections.Generic;
using System.Text;
using UnityEngine;
using UnityExplorer.Console.Lexer;
using UnityExplorer.CSConsole.Lexer;
namespace UnityExplorer.Console
namespace UnityExplorer.CSConsole
{
public struct LexerMatchInfo
{

View File

@ -2,7 +2,7 @@
using System.Linq;
using System.Text;
using UnityExplorer.Input;
using UnityExplorer.Console.Lexer;
using UnityExplorer.CSConsole.Lexer;
using UnityEngine;
using UnityEngine.EventSystems;
using UnityEngine.UI;
@ -13,7 +13,7 @@ using System.Reflection;
using UnityExplorer.UI.Shared;
using UnityExplorer.Helpers;
namespace UnityExplorer.Console
namespace UnityExplorer.CSConsole
{
// Handles most of the UI side of the C# console, including syntax highlighting.
@ -104,7 +104,10 @@ The following helper methods are available:
if (m_fixCaretPos > 0)
{
if (!m_fixwanted)
m_fixwanted = true;
{
EventSystem.current.SetSelectedGameObject(ConsolePage.Instance.m_codeEditor.InputField.gameObject, null);
m_fixwanted = true;
}
else
{
InputField.caretPosition = m_fixCaretPos;
@ -132,8 +135,6 @@ The following helper methods are available:
public void UseAutocomplete(string suggestion)
{
EventSystem.current.SetSelectedGameObject(ConsolePage.Instance.m_codeEditor.InputField.gameObject, null);
string input = InputField.text;
input = input.Insert(m_lastCaretPos, suggestion);
InputField.text = input;

View File

@ -1,7 +1,7 @@
using System.Collections.Generic;
using UnityEngine;
namespace UnityExplorer.Console.Lexer
namespace UnityExplorer.CSConsole.Lexer
{
public class CommentMatch : Matcher
{

View File

@ -1,7 +1,7 @@
using System.Collections.Generic;
using UnityEngine;
namespace UnityExplorer.Console.Lexer
namespace UnityExplorer.CSConsole.Lexer
{
// I use two different KeywordMatch instances (valid and invalid).
// This class just contains common implementations.

View File

@ -3,7 +3,7 @@ using UnityExplorer.Unstrip;
using UnityEngine;
using System.Linq;
namespace UnityExplorer.Console.Lexer
namespace UnityExplorer.CSConsole.Lexer
{
public abstract class Matcher
{

View File

@ -1,6 +1,6 @@
using UnityEngine;
namespace UnityExplorer.Console.Lexer
namespace UnityExplorer.CSConsole.Lexer
{
public class NumberMatch : Matcher
{

View File

@ -1,7 +1,7 @@
using System.Collections.Generic;
using UnityEngine;
namespace UnityExplorer.Console.Lexer
namespace UnityExplorer.CSConsole.Lexer
{
public class StringMatch : Matcher
{

View File

@ -2,7 +2,7 @@
using System.Linq;
using UnityEngine;
namespace UnityExplorer.Console.Lexer
namespace UnityExplorer.CSConsole.Lexer
{
public class SymbolMatch : Matcher
{

View File

@ -6,7 +6,7 @@ using Mono.CSharp;
// Thanks to ManlyMarco for this
namespace UnityExplorer.Console
namespace UnityExplorer.CSConsole
{
public class ScriptEvaluator : Evaluator, IDisposable
{

View File

@ -4,7 +4,7 @@ using UnityExplorer.UI;
using UnityExplorer.UI.Modules;
using UnityExplorer.Inspectors;
namespace UnityExplorer.Console
namespace UnityExplorer.CSConsole
{
public class ScriptInteraction : InteractiveBase
{

View File

@ -5,7 +5,7 @@ using System.Reflection;
using UnityEngine;
using UnityExplorer.Helpers;
namespace UnityExplorer.Console
namespace UnityExplorer.CSConsole
{
public struct Suggestion
{

View File

@ -1,6 +1,6 @@
using System;
using System.Collections.Generic;
using UnityExplorer.Console;
using UnityExplorer.CSConsole;
using UnityEngine;
using UnityEngine.UI;
using UnityExplorer.UI.Modules;

View File

@ -3,7 +3,7 @@ using System.Collections.Generic;
using System.IO;
using System.Reflection;
using System.Text;
using UnityExplorer.Console;
using UnityExplorer.CSConsole;
namespace UnityExplorer.UI.Modules
{

View File

@ -354,18 +354,18 @@
<Compile Include="Inspectors\Reflection\ReflectionInspector.cs" />
<Compile Include="UI\MainMenu.cs" />
<Compile Include="UI\Modules\ConsolePage.cs" />
<Compile Include="Console\AutoCompleter.cs" />
<Compile Include="Console\CodeEditor.cs" />
<Compile Include="Console\Lexer\CommentMatch.cs" />
<Compile Include="Console\CSharpLexer.cs" />
<Compile Include="Console\Lexer\KeywordMatch.cs" />
<Compile Include="Console\Lexer\StringMatch.cs" />
<Compile Include="Console\Lexer\Matcher.cs" />
<Compile Include="Console\Lexer\NumberMatch.cs" />
<Compile Include="Console\Lexer\SymbolMatch.cs" />
<Compile Include="Console\Suggestion.cs" />
<Compile Include="Console\ScriptEvaluator.cs" />
<Compile Include="Console\ScriptInteraction.cs" />
<Compile Include="CSConsole\AutoCompleter.cs" />
<Compile Include="CSConsole\CodeEditor.cs" />
<Compile Include="CSConsole\Lexer\CommentMatch.cs" />
<Compile Include="CSConsole\CSharpLexer.cs" />
<Compile Include="CSConsole\Lexer\KeywordMatch.cs" />
<Compile Include="CSConsole\Lexer\StringMatch.cs" />
<Compile Include="CSConsole\Lexer\Matcher.cs" />
<Compile Include="CSConsole\Lexer\NumberMatch.cs" />
<Compile Include="CSConsole\Lexer\SymbolMatch.cs" />
<Compile Include="CSConsole\Suggestion.cs" />
<Compile Include="CSConsole\ScriptEvaluator.cs" />
<Compile Include="CSConsole\ScriptInteraction.cs" />
<Compile Include="UI\Modules\HomePage.cs" />
<Compile Include="Inspectors\GameObjects\GameObjectInspector.cs" />
<Compile Include="Inspectors\InspectorBase.cs" />