Command.cs 9.4 KB

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