Command.cs 8.9 KB

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