CodeEditor.cs 2.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970
  1. using System;
  2. using System.Runtime.CompilerServices;
  3. using BansheeEngine;
  4. namespace BansheeEditor
  5. {
  6. /// <summary>
  7. /// Contains all supported external code editors
  8. /// </summary>
  9. public enum CodeEditorType // Note: Must match C++ CodeEditorType enum
  10. {
  11. VS2008,
  12. VS2010,
  13. VS2012,
  14. VS2013,
  15. VS2015
  16. }
  17. /// <summary>
  18. /// Handles interaction with the external application used for editing scripts.
  19. /// </summary>
  20. public static class CodeEditor
  21. {
  22. /// <summary>
  23. /// Currently active code editor.
  24. /// </summary>
  25. public static CodeEditorType ActiveEditor
  26. {
  27. set { Internal_SetActiveEditor(value); }
  28. }
  29. /// <summary>
  30. /// Returns a list of all code editors available on this machine.
  31. /// </summary>
  32. public static CodeEditorType[] AvailableEditors
  33. {
  34. get { return Internal_GetAvailableEditors(); }
  35. }
  36. /// <summary>
  37. /// Opens a script file in the currently active code editor.
  38. /// </summary>
  39. /// <param name="path">Path to the script file to open, either absolute or relative to the project folder.</param>
  40. /// <param name="line">Line in the file to focus the editor on.</param>
  41. public static void OpenFile(string path, UInt32 line)
  42. {
  43. Internal_OpenFile(path, line);
  44. }
  45. /// <summary>
  46. /// Generates a solution file for the active editor, which includes all scripts in the project.
  47. /// </summary>
  48. public static void SyncSolution()
  49. {
  50. Internal_SyncSolution();
  51. }
  52. [MethodImpl(MethodImplOptions.InternalCall)]
  53. internal static extern void Internal_SetActiveEditor(CodeEditorType type);
  54. [MethodImpl(MethodImplOptions.InternalCall)]
  55. internal static extern CodeEditorType[] Internal_GetAvailableEditors();
  56. [MethodImpl(MethodImplOptions.InternalCall)]
  57. internal static extern void Internal_OpenFile(string path, UInt32 line);
  58. [MethodImpl(MethodImplOptions.InternalCall)]
  59. internal static extern void Internal_SyncSolution();
  60. }
  61. }