mirror of
https://github.com/sinai-dev/UnityExplorer.git
synced 2025-09-20 13:36:01 +08:00
Cleanup
This commit is contained in:
@ -68,7 +68,6 @@ The following helper methods are available:
|
||||
public static InputFieldRef Input => Panel.Input;
|
||||
|
||||
public static int LastCaretPosition { get; private set; }
|
||||
public static int PreviousCaretPosition { get; private set; }
|
||||
internal static float defaultInputFieldAlpha;
|
||||
|
||||
// Todo save as config?
|
||||
@ -143,9 +142,7 @@ The following helper methods are available:
|
||||
|
||||
public static void Update()
|
||||
{
|
||||
int lastCaretPos = LastCaretPosition;
|
||||
UpdateCaret();
|
||||
bool caretMoved = lastCaretPos != LastCaretPosition;
|
||||
UpdateCaret(out bool caretMoved);
|
||||
|
||||
if (!settingAutoCompletion && EnableSuggestions && caretMoved)
|
||||
{
|
||||
@ -162,17 +159,23 @@ The following helper methods are available:
|
||||
|
||||
private const int CSCONSOLE_LINEHEIGHT = 18;
|
||||
|
||||
private static void UpdateCaret()
|
||||
private static void UpdateCaret(out bool caretMoved)
|
||||
{
|
||||
int prevCaret = LastCaretPosition;
|
||||
caretMoved = false;
|
||||
|
||||
if (Input.Component.isFocused)
|
||||
{
|
||||
PreviousCaretPosition = LastCaretPosition;
|
||||
LastCaretPosition = Input.Component.caretPosition;
|
||||
caretMoved = LastCaretPosition != prevCaret;
|
||||
}
|
||||
|
||||
if (Input.Text.Length == 0)
|
||||
return;
|
||||
|
||||
// If caret moved, ensure caret is visible in the viewport
|
||||
if (caretMoved)
|
||||
{
|
||||
var charInfo = Input.TextGenerator.characters[LastCaretPosition];
|
||||
var charTop = charInfo.cursorPos.y;
|
||||
var charBot = charTop - CSCONSOLE_LINEHEIGHT;
|
||||
@ -192,6 +195,7 @@ The following helper methods are available:
|
||||
rect.anchoredPosition = new Vector2(rect.anchoredPosition.x, rect.anchoredPosition.y - diff);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
#region Evaluating
|
||||
|
@ -84,9 +84,6 @@ namespace UnityExplorer.UI.CSConsole
|
||||
/// <returns>A string which contains the amount of leading lines specified, as well as the rich-text highlighted section.</returns>
|
||||
public string BuildHighlightedString(string input, int startIdx, int endIdx, int leadingLines)
|
||||
{
|
||||
|
||||
|
||||
|
||||
if (string.IsNullOrEmpty(input) || endIdx <= startIdx)
|
||||
return input;
|
||||
|
||||
|
Reference in New Issue
Block a user