keytab_record.dart 2.2 KB

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