keytab_record.dart 2.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126
  1. import 'package:xterm/input/keys.dart';
  2. enum KeytabActionType {
  3. input,
  4. shortcut,
  5. }
  6. class KeytabAction {
  7. KeytabAction(this.type, this.value);
  8. final KeytabActionType type;
  9. final String value;
  10. @override
  11. String toString() {
  12. switch (type) {
  13. case KeytabActionType.input:
  14. return '"$value"';
  15. case KeytabActionType.shortcut:
  16. return value;
  17. default:
  18. return '(no value)';
  19. }
  20. }
  21. }
  22. class KeytabRecord {
  23. KeytabRecord({
  24. required this.qtKeyName,
  25. required this.key,
  26. required this.action,
  27. required this.alt,
  28. required this.ctrl,
  29. required this.shift,
  30. required this.anyModifier,
  31. required this.ansi,
  32. required this.appScreen,
  33. required this.keyPad,
  34. required this.appCursorKeys,
  35. required this.appKeyPad,
  36. required this.newLine,
  37. required this.mac,
  38. });
  39. String qtKeyName;
  40. TerminalKey key;
  41. KeytabAction action;
  42. bool? alt;
  43. bool? ctrl;
  44. bool? shift;
  45. bool? anyModifier;
  46. bool? ansi;
  47. bool? appScreen;
  48. bool? keyPad;
  49. bool? appCursorKeys;
  50. bool? appKeyPad;
  51. bool? newLine;
  52. bool? mac;
  53. @override
  54. String toString() {
  55. final buffer = StringBuffer();
  56. buffer.write('$qtKeyName ');
  57. if (alt != null) {
  58. buffer.write(modeStatus(alt!, 'Alt'));
  59. }
  60. if (ctrl != null) {
  61. buffer.write(modeStatus(ctrl!, 'Control'));
  62. }
  63. if (shift != null) {
  64. buffer.write(modeStatus(shift!, 'Shift'));
  65. }
  66. if (anyModifier != null) {
  67. buffer.write(modeStatus(anyModifier!, 'AnyMod'));
  68. }
  69. if (ansi != null) {
  70. buffer.write(modeStatus(ansi!, 'Ansi'));
  71. }
  72. if (appScreen != null) {
  73. buffer.write(modeStatus(appScreen!, 'AppScreen'));
  74. }
  75. if (keyPad != null) {
  76. buffer.write(modeStatus(keyPad!, 'KeyPad'));
  77. }
  78. if (appCursorKeys != null) {
  79. buffer.write(modeStatus(appCursorKeys!, 'AppCuKeys'));
  80. }
  81. if (appKeyPad != null) {
  82. buffer.write(modeStatus(appKeyPad!, 'AppKeyPad'));
  83. }
  84. if (newLine != null) {
  85. buffer.write(modeStatus(newLine!, 'NewLine'));
  86. }
  87. if (mac != null) {
  88. buffer.write(modeStatus(mac!, 'Mac'));
  89. }
  90. buffer.write(' : $action');
  91. return buffer.toString();
  92. }
  93. }
  94. String modeStatus(bool status, String mode) {
  95. if (status == true) {
  96. return '+$mode';
  97. }
  98. if (status == false) {
  99. return '-$mode';
  100. }
  101. return '';
  102. }