Command.cs 9.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316
  1. // These classes use a keybinding system based on the design implemented in Scintilla.Net which is an
  2. // MIT licensed open source project https://github.com/jacobslusser/ScintillaNET/blob/master/src/ScintillaNET/Command.cs
  3. namespace Terminal.Gui;
  4. /// <summary>
  5. /// Actions which can be performed by a <see cref="View"/>. Commands are typically invoked via
  6. /// <see cref="View.KeyBindings"/> and mouse events.
  7. /// See also <see cref="View.InvokeCommand"/>.
  8. /// </summary>
  9. public enum Command
  10. {
  11. #region Base View Commands
  12. /// <summary>
  13. /// Accepts the current state of the View (e.g. list selection, button press, checkbox state, etc.).
  14. /// <para>
  15. /// The default implementation in <see cref="View"/> calls <see cref="View.RaiseAccepted"/>. If the event is not handled,
  16. /// the command is invoked on:
  17. /// - Any peer-view that is a <see cref="Button"/> with <see cref="Button.IsDefault"/> set to <see langword="true"/>.
  18. /// - The <see cref="View.SuperView"/>. This enables default Accept behavior.
  19. /// </para>
  20. /// </summary>
  21. Accept,
  22. /// <summary>
  23. /// Performs a hot key action (e.g. setting focus, accepting, and/or moving focus to the next View).
  24. /// <para>
  25. /// The default implementation in <see cref="View"/> calls <see cref="View.SetFocus"/> and then
  26. /// <see cref="View.RaiseHotKeyHandled"/>.
  27. /// </para>
  28. /// </summary>
  29. HotKey,
  30. /// <summary>
  31. /// Selects the View or an item in the View (e.g. a list item or menu item) without necessarily accepting it.
  32. /// <para>
  33. /// The default implementation in <see cref="View"/> calls <see cref="View.RaiseSelected"/>.
  34. /// </para>
  35. /// </summary>
  36. Select,
  37. #endregion
  38. #region Movement Commands
  39. /// <summary>Moves up one (cell, line, etc...).</summary>
  40. Up,
  41. /// <summary>Moves down one item (cell, line, etc...).</summary>
  42. Down,
  43. /// <summary>
  44. /// Moves left one (cell, line, etc...).
  45. /// </summary>
  46. Left,
  47. /// <summary>
  48. /// Moves right one (cell, line, etc...).
  49. /// </summary>
  50. Right,
  51. /// <summary>Move one page up.</summary>
  52. PageUp,
  53. /// <summary>Move one page down.</summary>
  54. PageDown,
  55. /// <summary>Moves to the left page.</summary>
  56. PageLeft,
  57. /// <summary>Moves to the right page.</summary>
  58. PageRight,
  59. /// <summary>Moves to the top of page.</summary>
  60. StartOfPage,
  61. /// <summary>Moves to the bottom of page.</summary>
  62. EndOfPage,
  63. /// <summary>Moves to the start (e.g. the top or home).</summary>
  64. Start,
  65. /// <summary>Moves to the end (e.g. the bottom).</summary>
  66. End,
  67. /// <summary>Moves left to the start on the current row/line.</summary>
  68. LeftStart,
  69. /// <summary>Moves right to the end on the current row/line.</summary>
  70. RightEnd,
  71. /// <summary>Moves to the start of the previous word.</summary>
  72. WordLeft,
  73. /// <summary>Moves the start of the next word.</summary>
  74. WordRight,
  75. #endregion
  76. #region Movement With Extension Commands
  77. /// <summary>Extends the selection up one item (cell, line, etc...).</summary>
  78. UpExtend,
  79. /// <summary>Extends the selection down one (cell, line, etc...).</summary>
  80. DownExtend,
  81. /// <summary>
  82. /// Extends the selection left one item (cell, line, etc...)
  83. /// </summary>
  84. LeftExtend,
  85. /// <summary>
  86. /// Extends the selection right one item (cell, line, etc...)
  87. /// </summary>
  88. RightExtend,
  89. /// <summary>Extends the selection to the start of the previous word.</summary>
  90. WordLeftExtend,
  91. /// <summary>Extends the selection to the start of the next word.</summary>
  92. WordRightExtend,
  93. /// <summary>Move one page down extending the selection to cover revealed objects/characters.</summary>
  94. PageDownExtend,
  95. /// <summary>Move one page up extending the selection to cover revealed objects/characters.</summary>
  96. PageUpExtend,
  97. /// <summary>Extends the selection to start (e.g. home or top).</summary>
  98. StartExtend,
  99. /// <summary>Extends the selection to end (e.g. bottom).</summary>
  100. EndExtend,
  101. /// <summary>Extends the selection to the start on the current row/line.</summary>
  102. LeftStartExtend,
  103. /// <summary>Extends the selection to the right on the current row/line.</summary>
  104. RightEndExtend,
  105. /// <summary>Toggles the selection.</summary>
  106. ToggleExtend,
  107. #endregion
  108. #region Editing Commands
  109. /// <summary>Deletes the characters forwards.</summary>
  110. KillWordForwards,
  111. /// <summary>Deletes the characters backwards.</summary>
  112. KillWordBackwards,
  113. /// <summary>
  114. /// Toggles overwrite mode such that newly typed text overwrites the text that is already there (typically
  115. /// associated with the Insert key).
  116. /// </summary>
  117. ToggleOverwrite,
  118. // QUESTION: What is the difference between EnableOverwrite and ToggleOverwrite?
  119. /// <summary>
  120. /// Enables overwrite mode such that newly typed text overwrites the text that is already there (typically
  121. /// associated with the Insert key).
  122. /// </summary>
  123. EnableOverwrite,
  124. /// <summary>Disables overwrite mode (<see cref="EnableOverwrite"/>)</summary>
  125. DisableOverwrite,
  126. /// <summary>Deletes the character on the right.</summary>
  127. DeleteCharRight,
  128. /// <summary>Deletes the character on the left.</summary>
  129. DeleteCharLeft,
  130. /// <summary>Selects all objects.</summary>
  131. SelectAll,
  132. /// <summary>Deletes all objects.</summary>
  133. DeleteAll,
  134. /// <summary>Inserts a new item.</summary>
  135. NewLine,
  136. /// <summary>Unix emulation.</summary>
  137. UnixEmulation,
  138. #endregion
  139. #region Tree Commands
  140. /// <summary>Moves down to the last child node of the branch that holds the current selection.</summary>
  141. LineDownToLastBranch,
  142. /// <summary>Moves up to the first child node of the branch that holds the current selection.</summary>
  143. LineUpToFirstBranch,
  144. #endregion
  145. #region Scroll Commands
  146. /// <summary>Scrolls down one (cell, line, etc...).</summary>
  147. ScrollDown,
  148. /// <summary>Scrolls up one item (cell, line, etc...).</summary>
  149. ScrollUp,
  150. /// <summary>Scrolls one item (cell, character, etc...) to the left.</summary>
  151. ScrollLeft,
  152. /// <summary>Scrolls one item (cell, character, etc...) to the right.</summary>
  153. ScrollRight,
  154. #endregion
  155. #region Clipboard Commands
  156. /// <summary>Undo changes.</summary>
  157. Undo,
  158. /// <summary>Redo changes.</summary>
  159. Redo,
  160. /// <summary>Copies the current selection.</summary>
  161. Copy,
  162. /// <summary>Cuts the current selection.</summary>
  163. Cut,
  164. /// <summary>Pastes the current selection.</summary>
  165. Paste,
  166. /// <summary>Cuts to the clipboard the characters from the current position to the end of the line.</summary>
  167. CutToEndLine,
  168. /// <summary>Cuts to the clipboard the characters from the current position to the start of the line.</summary>
  169. CutToStartLine,
  170. #endregion
  171. #region Navigation Commands
  172. /// <summary>Moves focus to the next <see cref="TabBehavior.TabStop"/>.</summary>
  173. NextTabStop,
  174. /// <summary>Moves focus to the previous <see cref="TabBehavior.TabStop"/>.</summary>
  175. PreviousTabStop,
  176. /// <summary>Moves focus to the next <see cref="TabBehavior.TabGroup"/>.</summary>
  177. NextTabGroup,
  178. /// <summary>Moves focus to the next<see cref="TabBehavior.TabGroup"/>.</summary>
  179. PreviousTabGroup,
  180. /// <summary>Tabs to the next item.</summary>
  181. Tab,
  182. /// <summary>Tabs back to the previous item.</summary>
  183. BackTab,
  184. #endregion
  185. #region Action Commands
  186. /// <summary>Toggles something (e.g. the expanded or collapsed state of a list).</summary>
  187. Toggle,
  188. /// <summary>Expands a list or item (with subitems).</summary>
  189. Expand,
  190. /// <summary>Recursively Expands all child items and their child items (if any).</summary>
  191. ExpandAll,
  192. /// <summary>Collapses a list or item (with subitems).</summary>
  193. Collapse,
  194. /// <summary>Recursively collapses a list items of their children (if any).</summary>
  195. CollapseAll,
  196. /// <summary>Cancels an action or any temporary states on the control e.g. expanding a combo list.</summary>
  197. Cancel,
  198. /// <summary>Quit.</summary>
  199. Quit,
  200. /// <summary>Refresh.</summary>
  201. Refresh,
  202. /// <summary>Suspend an application (Only implemented in <see cref="CursesDriver"/>).</summary>
  203. Suspend,
  204. /// <summary>Open the selected item or invoke a UI for opening something.</summary>
  205. Open,
  206. /// <summary>Saves the current document.</summary>
  207. Save,
  208. /// <summary>Saves the current document with a new name.</summary>
  209. SaveAs,
  210. /// <summary>Creates a new document.</summary>
  211. New,
  212. /// <summary>Shows context about the item (e.g. a context menu).</summary>
  213. Context,
  214. /// <summary>
  215. /// Invokes a user interface for editing or configuring something.
  216. /// </summary>
  217. Edit,
  218. #endregion
  219. }