Command.cs 9.0 KB

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