Command.cs 9.2 KB

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