using System.Collections.Generic; using System.Runtime.InteropServices; using UnityEngine; namespace Unity.CodeEditor.Platform { internal sealed class PlatformHotkeyConfiguration { private static PlatformHotkeyConfiguration s_Current; internal static PlatformHotkeyConfiguration Current { get { if (s_Current != null) return s_Current; s_Current = Init(); return s_Current; } } static PlatformHotkeyConfiguration Init() { if (RuntimeInformation.IsOSPlatform(OSPlatform.OSX)) { return new PlatformHotkeyConfiguration( KeyModifiers.Meta, KeyModifiers.Shift, KeyModifiers.Alt, KeyModifiers.Control, KeyModifiers.Alt); } return new PlatformHotkeyConfiguration(KeyModifiers.Control); } PlatformHotkeyConfiguration(KeyModifiers commandModifiers, KeyModifiers selectionModifiers = KeyModifiers.Shift, KeyModifiers wholeWordTextActionModifiers = KeyModifiers.Control, KeyModifiers boxSelectionModifiers = KeyModifiers.Alt, KeyModifiers deleteWholeLineModifiers = KeyModifiers.Shift) { CommandModifiers = commandModifiers; SelectionModifiers = selectionModifiers; WholeWordTextActionModifiers = wholeWordTextActionModifiers; BoxSelectionModifiers = boxSelectionModifiers; Copy = new List { new KeyGesture(KeyCode.C, commandModifiers), new KeyGesture(KeyCode.Insert, KeyModifiers.Control) }; Cut = new List { new KeyGesture(KeyCode.X, commandModifiers) }; Paste = new List { new KeyGesture(KeyCode.V, commandModifiers), new KeyGesture(KeyCode.Insert, KeyModifiers.Shift) }; Undo = new List { new KeyGesture(KeyCode.Z, commandModifiers) }; Redo = new List { new KeyGesture(KeyCode.Y, commandModifiers), new KeyGesture(KeyCode.Z, commandModifiers | selectionModifiers) }; SelectAll = new List { new KeyGesture(KeyCode.A, commandModifiers) }; MoveCursorToTheStartOfLine = new List { new KeyGesture(KeyCode.Home) }; MoveCursorToTheEndOfLine = new List { new KeyGesture(KeyCode.End) }; MoveCursorToTheStartOfDocument = new List { new KeyGesture(KeyCode.Home, commandModifiers) }; MoveCursorToTheEndOfDocument = new List { new KeyGesture(KeyCode.End, commandModifiers) }; MoveCursorToTheStartOfLineWithSelection = new List { new KeyGesture(KeyCode.Home, selectionModifiers) }; MoveCursorToTheEndOfLineWithSelection = new List { new KeyGesture(KeyCode.End, selectionModifiers) }; MoveCursorToTheStartOfDocumentWithSelection = new List { new KeyGesture(KeyCode.Home, commandModifiers | selectionModifiers) }; MoveCursorToTheEndOfDocumentWithSelection = new List { new KeyGesture(KeyCode.End, commandModifiers | selectionModifiers) }; Back = new List { new KeyGesture(KeyCode.LeftArrow, KeyModifiers.Alt) }; PageLeft = new List { new KeyGesture(KeyCode.PageUp, KeyModifiers.Shift) }; PageRight = new List { new KeyGesture(KeyCode.PageDown, KeyModifiers.Shift) }; PageUp = new List { new KeyGesture(KeyCode.PageUp) }; PageDown = new List { new KeyGesture(KeyCode.PageDown) }; DeleteWholeLine = new List { new KeyGesture(KeyCode.Delete, deleteWholeLineModifiers) }; } internal KeyModifiers CommandModifiers { get; set; } internal KeyModifiers WholeWordTextActionModifiers { get; set; } internal KeyModifiers SelectionModifiers { get; set; } internal KeyModifiers BoxSelectionModifiers { get; set; } internal List Copy { get; set; } internal List Cut { get; set; } internal List Paste { get; set; } internal List Undo { get; set; } internal List Redo { get; set; } internal List SelectAll { get; set; } internal List MoveCursorToTheStartOfLine { get; set; } internal List MoveCursorToTheEndOfLine { get; set; } internal List MoveCursorToTheStartOfDocument { get; set; } internal List MoveCursorToTheEndOfDocument { get; set; } internal List MoveCursorToTheStartOfLineWithSelection { get; set; } internal List MoveCursorToTheEndOfLineWithSelection { get; set; } internal List MoveCursorToTheStartOfDocumentWithSelection { get; set; } internal List MoveCursorToTheEndOfDocumentWithSelection { get; set; } internal List Back { get; set; } internal List PageUp { get; set; } internal List PageDown { get; set; } internal List PageRight { get; set; } internal List PageLeft { get; set; } internal List DeleteWholeLine { get; set; } } }