PageRenderTime 43ms CodeModel.GetById 19ms RepoModel.GetById 0ms app.codeStats 0ms

/editor/Keymap.cs

http://github.com/toshok/shelisp
C# | 122 lines | 101 code | 18 blank | 3 comment | 3 complexity | fd3bea3c872c19ffd22cd2cb85339834 MD5 | raw file
Possible License(s): GPL-3.0
  1. using System;
  2. using Shelisp;
  3. namespace Shemacs.Editor {
  4. public class Keymap : Shelisp.Object {
  5. [LispBuiltin]
  6. public static Shelisp.Object Fdefine_key (L l, Shelisp.Object keymap, Shelisp.Object key, Shelisp.Object binding)
  7. {
  8. // XXX more here
  9. return binding;
  10. }
  11. [LispBuiltin (MinArgs = 0, DocString = @"Construct and return a new keymap, of the form (keymap CHARTABLE . ALIST).
  12. CHARTABLE is a char-table that holds the bindings for all characters
  13. without modifiers. All entries in it are initially nil, meaning
  14. ""command undefined"". ALIST is an assoc-list which holds bindings for
  15. function keys, mouse events, and any other things that appear in the
  16. input stream. Initially, ALIST is nil.
  17. The optional arg STRING supplies a menu name for the keymap
  18. in case you use it as a menu with `x-popup-menu'.")]
  19. public static Shelisp.Object Fmake_keymap (L l, [LispOptional] Shelisp.Object str)
  20. {
  21. Shelisp.Object tail;
  22. if (!L.NILP (str)) {
  23. Console.WriteLine ("str = {0}", str == null ? "null" : "not null");
  24. tail = new List (str, L.Qnil);
  25. }
  26. else
  27. tail = L.Qnil;
  28. return new List (L.intern ("keymap"),
  29. new List (CharTable.Fmake_char_table (l, L.intern ("keymap"), L.Qnil), tail));
  30. }
  31. [LispBuiltin]
  32. public static Shelisp.Object Fkeymapp (L l, Shelisp.Object keymap)
  33. {
  34. return keymap is Keymap ? L.Qt : L.Qnil;
  35. }
  36. static Shelisp.Object make_sparse_keymap (Shelisp.Object prompt)
  37. {
  38. return new List (L.intern ("keymap"), L.Qnil);
  39. }
  40. [LispBuiltin]
  41. public static Shelisp.Object Fmake_sparse_keymap (L l, Shelisp.Object prompt)
  42. {
  43. return make_sparse_keymap (prompt);
  44. }
  45. static Shelisp.Object current_global_map = L.Qnil;
  46. [LispBuiltin]
  47. public static Shelisp.Object Fcurrent_global_map (L l)
  48. {
  49. return current_global_map;
  50. }
  51. [LispBuiltin (DocString = @"Modify KEYMAP to set its parent map to PARENT.
  52. Return PARENT. PARENT should be nil or another keymap.")]
  53. public static Shelisp.Object Fset_keymap_parent (L l, Shelisp.Object keymap, Shelisp.Object parent)
  54. {
  55. // XXX implement this..
  56. return parent;
  57. }
  58. [LispBuiltin (DocString = @"Call FUNCTION once for each event binding in KEYMAP.
  59. FUNCTION is called with two arguments: the event that is bound, and
  60. the definition it is bound to. The event may be a character range.
  61. If KEYMAP has a parent, the parent's bindings are included as well.
  62. This works recursively: if the parent has itself a parent, then the
  63. grandparent's bindings are also included and so on.
  64. usage: (map-keymap FUNCTION KEYMAP)")]
  65. public static Shelisp.Object Fmap_keymap (L l, Shelisp.Object function, Shelisp.Object keymap, [LispOptional] Shelisp.Object sort_first)
  66. {
  67. #if notyet
  68. if (! NILP (sort_first))
  69. return call2 (intern ("map-keymap-sorted"), function, keymap);
  70. map_keymap (keymap, map_keymap_call, function, NULL, 1);
  71. #endif
  72. return keymap; // XXX
  73. }
  74. [LispBuiltin (DocString = "Default keymap to use when reading from the minibuffer.")]
  75. public static Shelisp.Object Vminibuffer_local_map = Keymap.make_sparse_keymap (L.Qnil);
  76. [LispBuiltin (DocString = @"The parent keymap of all `local-function-key-map' instances.
  77. Function key definitions that apply to all terminal devices should go
  78. here. If a mapping is defined in both the current
  79. `local-function-key-map' binding and this variable, then the local
  80. definition will take precedence.")]
  81. public static Shelisp.Object Vfunction_key_map = Keymap.make_sparse_keymap (L.Qnil);
  82. [LispBuiltin (DocString = "Keymap defining bindings for special events to execute at low level.")]
  83. public static Shelisp.Object Vspecial_event_map = new List (L.intern ("keymap"), L.Qnil);
  84. [LispBuiltin (DocString = @"Keymap of key translations that can override keymaps.
  85. This keymap works like `function-key-map', but comes after that,
  86. and its non-prefix bindings override ordinary bindings.
  87. Another difference is that it is global rather than keyboard-local.")]
  88. public static Shelisp.Object Vkey_translation_map = Keymap.make_sparse_keymap (L.Qnil);
  89. [LispBuiltin (DocString = @"Alist of keymaps to use for minor modes.
  90. Each element looks like (VARIABLE . KEYMAP); KEYMAP is used to read
  91. key sequences and look up bindings if VARIABLE's value is non-nil.
  92. If two active keymaps bind the same key, the keymap appearing earlier
  93. in the list takes precedence.")]
  94. public static Shelisp.Object Vminor_mode_map_alist = L.Qnil;
  95. [LispBuiltin (DocString = "Local keymap for the minibuffer when spaces are not allowed.")]
  96. public static Shelisp.Object Vminibuffer_local_ns_map = Keymap.make_sparse_keymap (L.Qnil);
  97. // XXX emacs has Fset_keymap_parent (Vminibuffer_local_ns_map, Vminibuffer_local_map);
  98. [LispBuiltin (DocString = @"Meta-prefix character code.
  99. Meta-foo as command input turns into this character followed by foo.")]
  100. public static int meta_prefix_char = 033;
  101. }
  102. }