-
Notifications
You must be signed in to change notification settings - Fork 54
/
Copy pathrbreadline.rb
8926 lines (7738 loc) · 270 KB
/
rbreadline.rb
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
# encoding: US-ASCII
#
# rbreadline.rb -- a general facility for reading lines of input
# with emacs style editing and completion.
#
# Inspired by GNU Readline, translation to Ruby
# Copyright (C) 2009 by Park Heesob [email protected]
#
require "rbreadline/version"
class Integer
def ord; self; end
end
module RbReadline
require 'etc'
RL_LIBRARY_VERSION = "5.2"
RL_READLINE_VERSION = 0x0502
EOF = "\xFF"
ESC = "\C-["
PAGE = "\C-L"
SPACE = "\x20"
RETURN = "\C-M"
ABORT_CHAR = "\C-G"
TAB = "\t"
RUBOUT = "\x7f"
NEWLINE = "\n"
DEFAULT_BUFFER_SIZE = 256
DEFAULT_MAX_KILLS = 10
MB_FIND_NONZERO = 1
MB_FIND_ANY = 0
MB_LEN_MAX = 4
DEFAULT_INPUTRC = "~/.inputrc"
SYS_INPUTRC = "/etc/inputrc"
UpCase = 1
DownCase = 2
CapCase = 3
# Possible history errors passed to hist_error.
EVENT_NOT_FOUND = 0
BAD_WORD_SPEC = 1
SUBST_FAILED = 2
BAD_MODIFIER = 3
NO_PREV_SUBST = 4
# Possible definitions for history starting point specification.
ANCHORED_SEARCH = 1
NON_ANCHORED_SEARCH = 0
# Possible definitions for what style of writing the history file we want.
HISTORY_APPEND = 0
HISTORY_OVERWRITE = 1
# Input error; can be returned by (*rl_getc_function) if readline is reading
# a top-level command (RL_ISSTATE (RL_STATE_READCMD)).
READERR = 0xFE.chr
# Definitions available for use by readline clients.
RL_PROMPT_START_IGNORE = 1.chr
RL_PROMPT_END_IGNORE = 2.chr
# Possible values for do_replace argument to rl_filename_quoting_function,
# called by rl_complete_internal.
NO_MATCH = 0
SINGLE_MATCH = 1
MULT_MATCH = 2
# Callback data for reading numeric arguments
NUM_SAWMINUS = 0x01
NUM_SAWDIGITS = 0x02
NUM_READONE = 0x04
# A context for reading key sequences longer than a single character when
# using the callback interface.
KSEQ_DISPATCHED = 0x01
KSEQ_SUBSEQ = 0x02
KSEQ_RECURSIVE = 0x04
# Possible state values for rl_readline_state
RL_STATE_NONE = 0x000000 # no state before first call
RL_STATE_INITIALIZING = 0x000001 # initializing
RL_STATE_INITIALIZED = 0x000002 # initialization done
RL_STATE_TERMPREPPED = 0x000004 # terminal is prepped
RL_STATE_READCMD = 0x000008 # reading a command key
RL_STATE_METANEXT = 0x000010 # reading input after ESC
RL_STATE_DISPATCHING = 0x000020 # dispatching to a command
RL_STATE_MOREINPUT = 0x000040 # reading more input in a command function
RL_STATE_ISEARCH = 0x000080 # doing incremental search
RL_STATE_NSEARCH = 0x000100 # doing non-inc search
RL_STATE_SEARCH = 0x000200 # doing a history search
RL_STATE_NUMERICARG = 0x000400 # reading numeric argument
RL_STATE_MACROINPUT = 0x000800 # getting input from a macro
RL_STATE_MACRODEF = 0x001000 # defining keyboard macro
RL_STATE_OVERWRITE = 0x002000 # overwrite mode
RL_STATE_COMPLETING = 0x004000 # doing completion
RL_STATE_SIGHANDLER = 0x008000 # in readline sighandler
RL_STATE_UNDOING = 0x010000 # doing an undo
RL_STATE_INPUTPENDING = 0x020000 # rl_execute_next called
RL_STATE_TTYCSAVED = 0x040000 # tty special chars saved
RL_STATE_CALLBACK = 0x080000 # using the callback interface
RL_STATE_VIMOTION = 0x100000 # reading vi motion arg
RL_STATE_MULTIKEY = 0x200000 # reading multiple-key command
RL_STATE_VICMDONCE = 0x400000 # entered vi command mode at least once
RL_STATE_DONE = 0x800000 # done accepted line
NO_BELL = 0
AUDIBLE_BELL = 1
VISIBLE_BELL = 2
# The actions that undo knows how to undo. Notice that UNDO_DELETE means
# to insert some text, and UNDO_INSERT means to delete some text. I.e.,
# the code tells undo what to undo, not how to undo it.
UNDO_DELETE, UNDO_INSERT, UNDO_BEGIN, UNDO_END = 0,1,2,3
# Definitions used when searching the line for characters.
# NOTE: it is necessary that opposite directions are inverses
FTO = 1 # forward to
BTO = -1 # backward to
FFIND = 2 # forward find
BFIND = -2 # backward find
# Possible values for the found_quote flags word used by the completion
# functions. It says what kind of (shell-like) quoting we found anywhere
# in the line.
RL_QF_SINGLE_QUOTE = 0x01
RL_QF_DOUBLE_QUOTE = 0x02
RL_QF_BACKSLASH = 0x04
RL_QF_OTHER_QUOTE = 0x08
KEYMAP_SIZE = 257
ANYOTHERKEY = KEYMAP_SIZE-1
@hConsoleHandle = nil
@MessageBeep = nil
RL_IM_INSERT = 1
RL_IM_OVERWRITE = 0
RL_IM_DEFAULT = RL_IM_INSERT
@no_mode = -1
@vi_mode = 0
@emacs_mode = 1
ISFUNC = 0
ISKMAP = 1
ISMACR = 2
HISTORY_WORD_DELIMITERS = " \t\n;&()|<>"
HISTORY_QUOTE_CHARACTERS = "\"'`"
RL_SEARCH_ISEARCH = 0x01 # incremental search
RL_SEARCH_NSEARCH = 0x02 # non-incremental search
RL_SEARCH_CSEARCH = 0x04 # intra-line char search
# search flags
SF_REVERSE = 0x01
SF_FOUND = 0x02
SF_FAILED = 0x04
@slashify_in_quotes = "\\`\"$"
@sigint_proc = nil
@sigint_blocked = false
@rl_prep_term_function = :rl_prep_terminal
@rl_deprep_term_function = :rl_deprep_terminal
@_rl_history_saved_point = -1
@rl_max_kills = DEFAULT_MAX_KILLS
@rl_kill_ring = nil
@rl_kill_index = 0
@rl_kill_ring_length = 0
@pending_bytes = ''
@stored_count = 0
@_rl_isearch_terminators = nil
@_rl_iscxt = nil
@last_isearch_string = nil
@last_isearch_string_len = 0
@default_isearch_terminators = "\033\012"
@_rl_history_preserve_point = false
@terminal_prepped = false
@otio = nil
@msg_saved_prompt = false
@_rl_nscxt = nil
@noninc_search_string = nil
@noninc_history_pos = 0
@prev_line_found = nil
@_rl_tty_chars = Struct.new(:t_eol,:t_eol2,:t_erase,:t_werase,:t_kill,:t_reprint,:t_intr,:t_eof,
:t_quit,:t_susp,:t_dsusp,:t_start,:t_stop,:t_lnext,:t_flush,:t_status).new
@_rl_last_tty_chars = nil
@_keyboard_input_timeout = 0.001
# Variables exported by this file.
# The character that represents the start of a history expansion
# request. This is usually `!'.
@history_expansion_char = "!"
# The character that invokes word substitution if found at the start of
# a line. This is usually `^'.
@history_subst_char = "^"
# During tokenization, if this character is seen as the first character
# of a word, then it, and all subsequent characters upto a newline are
# ignored. For a Bourne shell, this should be '#'. Bash special cases
# the interactive comment character to not be a comment delimiter.
@history_comment_char = 0.chr
# The list of characters which inhibit the expansion of text if found
# immediately following history_expansion_char.
@history_no_expand_chars = " \t\n\r="
# If set to a non-zero value, single quotes inhibit history expansion.
# The default is 0.
@history_quotes_inhibit_expansion = 0
# Used to split words by history_tokenize_internal.
@history_word_delimiters = HISTORY_WORD_DELIMITERS
# If set, this points to a function that is called to verify that a
# particular history expansion should be performed.
@history_inhibit_expansion_function = nil
@rl_event_hook = nil
# The visible cursor position. If you print some text, adjust this.
# NOTE: _rl_last_c_pos is used as a buffer index when not in a locale
# supporting multibyte characters, and an absolute cursor position when
# in such a locale. This is an artifact of the donated multibyte support.
# Care must be taken when modifying its value.
@_rl_last_c_pos = 0
@_rl_last_v_pos = 0
@cpos_adjusted = false
@cpos_buffer_position = 0
# Number of lines currently on screen minus 1.
@_rl_vis_botlin = 0
# Variables used only in this file.
# The last left edge of text that was displayed. This is used when
# doing horizontal scrolling. It shifts in thirds of a screenwidth.
@last_lmargin = 0
# The line display buffers. One is the line currently displayed on
# the screen. The other is the line about to be displayed.
@visible_line = nil
@invisible_line = nil
# A buffer for `modeline' messages.
@msg_buf = 0.chr * 128
# Non-zero forces the redisplay even if we thought it was unnecessary.
@forced_display = false
# Default and initial buffer size. Can grow.
@line_size = 1024
# Variables to keep track of the expanded prompt string, which may
# include invisible characters.
@local_prompt = nil
@local_prompt_prefix = nil
@local_prompt_len = 0
@prompt_visible_length = 0
@prompt_prefix_length = 0
# The number of invisible characters in the line currently being
# displayed on the screen.
@visible_wrap_offset = 0
# The number of invisible characters in the prompt string. Static so it
# can be shared between rl_redisplay and update_line
@wrap_offset = 0
@prompt_last_invisible = 0
# The length (buffer offset) of the first line of the last (possibly
# multi-line) buffer displayed on the screen.
@visible_first_line_len = 0
# Number of invisible characters on the first physical line of the prompt.
# Only valid when the number of physical characters in the prompt exceeds
# (or is equal to) _rl_screenwidth.
@prompt_invis_chars_first_line = 0
@prompt_last_screen_line = 0
@prompt_physical_chars = 0
# Variables to save and restore prompt and display information.
# These are getting numerous enough that it's time to create a struct.
@saved_local_prompt = nil
@saved_local_prefix = nil
@saved_last_invisible = 0
@saved_visible_length = 0
@saved_prefix_length = 0
@saved_local_length = 0
@saved_invis_chars_first_line = 0
@saved_physical_chars = 0
@inv_lbreaks = nil
@vis_lbreaks = nil
@_rl_wrapped_line = nil
@term_buffer = nil
@term_string_buffer = nil
@tcap_initialized = false
# While we are editing the history, this is the saved
# version of the original line.
@_rl_saved_line_for_history = nil
# An array of HIST_ENTRY. This is where we store the history.
@the_history = nil
@history_base = 1
# Non-zero means that we have enforced a limit on the amount of
# history that we save.
@history_stifled = false
# If HISTORY_STIFLED is non-zero, then this is the maximum number of
# entries to remember.
@history_max_entries = 0
@max_input_history = 0 # backwards compatibility
# The current location of the interactive history pointer. Just makes
# life easier for outside callers.
@history_offset = 0
# The number of strings currently stored in the history list.
@history_length = 0
@_rl_vi_last_command = 'i' # default `.' puts you in insert mode
# Non-zero means enter insertion mode.
@_rl_vi_doing_insert = 0
# Command keys which do movement for xxx_to commands.
@vi_motion = " hl^$0ftFT;,%wbeWBE|"
# Keymap used for vi replace characters. Created dynamically since
# rarely used.
@vi_replace_map = nil
# The number of characters inserted in the last replace operation.
@vi_replace_count = 0
# If non-zero, we have text inserted after a c[motion] command that put
# us implicitly into insert mode. Some people want this text to be
# attached to the command so that it is `redoable' with `.'.
@vi_continued_command = false
@vi_insert_buffer = nil
@vi_insert_buffer_size = 0
@_rl_vi_last_repeat = 1
@_rl_vi_last_arg_sign = 1
@_rl_vi_last_motion = 0
@_rl_vi_last_search_char = 0
@_rl_vi_last_replacement = 0
@_rl_vi_last_key_before_insert = 0
@vi_redoing = 0
# Text modification commands. These are the `redoable' commands.
@vi_textmod = "_*\\AaIiCcDdPpYyRrSsXx~"
# Arrays for the saved marks.
@vi_mark_chars = Array.new(26,-1)
@emacs_standard_keymap = {
"\C-@" => :rl_set_mark ,
"\C-a" => :rl_beg_of_line ,
"\C-b" => :rl_backward_char ,
"\C-d" => :rl_delete ,
"\C-e" => :rl_end_of_line ,
"\C-f" => :rl_forward_char ,
"\C-g" => :rl_abort ,
"\C-h" => :rl_rubout ,
"\C-i" => :rl_complete ,
"\C-j" => :rl_newline ,
"\C-k" => :rl_kill_line ,
"\C-l" => :rl_clear_screen ,
"\C-m" => :rl_newline ,
"\C-n" => :rl_get_next_history ,
"\C-p" => :rl_get_previous_history ,
"\C-q" => :rl_quoted_insert ,
"\C-r" => :rl_reverse_search_history ,
"\C-s" => :rl_forward_search_history ,
"\C-t" => :rl_transpose_chars ,
"\C-u" => :rl_unix_line_discard ,
"\C-v" => :rl_quoted_insert ,
"\C-w" => :rl_unix_word_rubout ,
"\C-y" => :rl_yank ,
"\C-]" => :rl_char_search ,
"\C-_" => :rl_undo_command ,
"\x7F" => :rl_rubout ,
"\e\C-g" => :rl_abort ,
"\e\C-h" => :rl_backward_kill_word ,
"\e\C-i" => :rl_tab_insert ,
"\e\C-j" => :rl_vi_editing_mode ,
"\e\C-m" => :rl_vi_editing_mode ,
"\e\C-r" => :rl_revert_line ,
"\e\C-y" => :rl_yank_nth_arg ,
"\e\C-[" => :rl_complete ,
"\e\C-]" => :rl_backward_char_search ,
"\e " => :rl_set_mark ,
"\e#" => :rl_insert_comment ,
"\e&" => :rl_tilde_expand ,
"\e*" => :rl_insert_completions ,
"\e-" => :rl_digit_argument ,
"\e." => :rl_yank_last_arg ,
"\e0" => :rl_digit_argument ,
"\e1" => :rl_digit_argument ,
"\e2" => :rl_digit_argument ,
"\e3" => :rl_digit_argument ,
"\e4" => :rl_digit_argument ,
"\e5" => :rl_digit_argument ,
"\e6" => :rl_digit_argument ,
"\e7" => :rl_digit_argument ,
"\e8" => :rl_digit_argument ,
"\e9" => :rl_digit_argument ,
"\e<" => :rl_beginning_of_history ,
"\e=" => :rl_possible_completions ,
"\e>" => :rl_end_of_history ,
"\e?" => :rl_possible_completions ,
"\eB" => :rl_backward_word ,
"\eC" => :rl_capitalize_word ,
"\eD" => :rl_kill_word ,
"\eF" => :rl_forward_word ,
"\eL" => :rl_downcase_word ,
"\eN" => :rl_noninc_forward_search ,
"\eP" => :rl_noninc_reverse_search ,
"\eR" => :rl_revert_line ,
"\eT" => :rl_transpose_words ,
"\eU" => :rl_upcase_word ,
"\eY" => :rl_yank_pop ,
"\e\\" => :rl_delete_horizontal_space ,
"\e_" => :rl_yank_last_arg ,
"\eb" => :rl_backward_word ,
"\ec" => :rl_capitalize_word ,
"\ed" => :rl_kill_word ,
"\ef" => :rl_forward_word ,
"\el" => :rl_downcase_word ,
"\en" => :rl_noninc_forward_search ,
"\ep" => :rl_noninc_reverse_search ,
"\er" => :rl_revert_line ,
"\et" => :rl_transpose_words ,
"\eu" => :rl_upcase_word ,
"\ey" => :rl_yank_pop ,
"\e~" => :rl_tilde_expand ,
"\377" => :rl_backward_kill_word ,
"\e\x7F" => :rl_backward_kill_word,
"\C-x\C-g" => :rl_abort ,
"\C-x\C-r" => :rl_re_read_init_file ,
"\C-x\C-u" => :rl_undo_command ,
"\C-x\C-x" => :rl_exchange_point_and_mark ,
"\C-x(" => :rl_start_kbd_macro ,
"\C-x)" => :rl_end_kbd_macro ,
"\C-xE" => :rl_call_last_kbd_macro ,
"\C-xe" => :rl_call_last_kbd_macro ,
"\C-x\x7F" => :rl_backward_kill_line
}
@vi_movement_keymap = {
"\C-d" => :rl_vi_eof_maybe ,
"\C-e" => :rl_emacs_editing_mode ,
"\C-g" => :rl_abort ,
"\C-h" => :rl_backward_char ,
"\C-j" => :rl_newline ,
"\C-k" => :rl_kill_line ,
"\C-l" => :rl_clear_screen ,
"\C-m" => :rl_newline ,
"\C-n" => :rl_get_next_history ,
"\C-p" => :rl_get_previous_history ,
"\C-q" => :rl_quoted_insert ,
"\C-r" => :rl_reverse_search_history ,
"\C-s" => :rl_forward_search_history ,
"\C-t" => :rl_transpose_chars ,
"\C-u" => :rl_unix_line_discard ,
"\C-v" => :rl_quoted_insert ,
"\C-w" => :rl_unix_word_rubout ,
"\C-y" => :rl_yank ,
"\C-_" => :rl_vi_undo ,
" " => :rl_forward_char ,
"#" => :rl_insert_comment ,
"$" => :rl_end_of_line ,
"%" => :rl_vi_match ,
"&" => :rl_vi_tilde_expand ,
"*" => :rl_vi_complete ,
"+" => :rl_get_next_history ,
"," => :rl_vi_char_search ,
"-" => :rl_get_previous_history ,
"." => :rl_vi_redo ,
"/" => :rl_vi_search ,
"0" => :rl_beg_of_line ,
"1" => :rl_vi_arg_digit ,
"2" => :rl_vi_arg_digit ,
"3" => :rl_vi_arg_digit ,
"4" => :rl_vi_arg_digit ,
"5" => :rl_vi_arg_digit ,
"6" => :rl_vi_arg_digit ,
"7" => :rl_vi_arg_digit ,
"8" => :rl_vi_arg_digit ,
"9" => :rl_vi_arg_digit ,
"" => :rl_vi_char_search ,
"=" => :rl_vi_complete ,
"?" => :rl_vi_search ,
"A" => :rl_vi_append_eol ,
"B" => :rl_vi_prev_word ,
"C" => :rl_vi_change_to ,
"D" => :rl_vi_delete_to ,
"E" => :rl_vi_end_word ,
"F" => :rl_vi_char_search ,
"G" => :rl_vi_fetch_history ,
"I" => :rl_vi_insert_beg ,
"N" => :rl_vi_search_again ,
"P" => :rl_vi_put ,
"R" => :rl_vi_replace ,
"S" => :rl_vi_subst ,
"T" => :rl_vi_char_search ,
"U" => :rl_revert_line ,
"W" => :rl_vi_next_word ,
"X" => :rl_vi_rubout ,
"Y" => :rl_vi_yank_to ,
"\\" => :rl_vi_complete ,
"^" => :rl_vi_first_print ,
"_" => :rl_vi_yank_arg ,
"`" => :rl_vi_goto_mark ,
"a" => :rl_vi_append_mode ,
"b" => :rl_vi_prev_word ,
"c" => :rl_vi_change_to ,
"d" => :rl_vi_delete_to ,
"e" => :rl_vi_end_word ,
"f" => :rl_vi_char_search ,
"h" => :rl_backward_char ,
"i" => :rl_vi_insertion_mode ,
"j" => :rl_get_next_history ,
"k" => :rl_get_previous_history ,
"l" => :rl_forward_char ,
"m" => :rl_vi_set_mark ,
"n" => :rl_vi_search_again ,
"p" => :rl_vi_put ,
"r" => :rl_vi_change_char ,
"s" => :rl_vi_subst ,
"t" => :rl_vi_char_search ,
"u" => :rl_vi_undo ,
"w" => :rl_vi_next_word ,
"x" => :rl_vi_delete ,
"y" => :rl_vi_yank_to ,
"|" => :rl_vi_column ,
"~" => :rl_vi_change_case
}
@vi_insertion_keymap = {
"\C-a" => :rl_insert ,
"\C-b" => :rl_insert ,
"\C-c" => :rl_insert ,
"\C-d" => :rl_vi_eof_maybe ,
"\C-e" => :rl_insert ,
"\C-f" => :rl_insert ,
"\C-g" => :rl_insert ,
"\C-h" => :rl_rubout ,
"\C-i" => :rl_complete ,
"\C-j" => :rl_newline ,
"\C-k" => :rl_insert ,
"\C-l" => :rl_insert ,
"\C-m" => :rl_newline ,
"\C-n" => :rl_insert ,
"\C-o" => :rl_insert ,
"\C-p" => :rl_insert ,
"\C-q" => :rl_insert ,
"\C-r" => :rl_reverse_search_history ,
"\C-s" => :rl_forward_search_history ,
"\C-t" => :rl_transpose_chars ,
"\C-u" => :rl_unix_line_discard ,
"\C-v" => :rl_quoted_insert ,
"\C-w" => :rl_unix_word_rubout ,
"\C-x" => :rl_insert ,
"\C-y" => :rl_yank ,
"\C-z" => :rl_insert ,
"\C-[" => :rl_vi_movement_mode ,
"\C-\\" => :rl_insert ,
"\C-]" => :rl_insert ,
"\C-^" => :rl_insert ,
"\C-_" => :rl_vi_undo ,
"\x7F" => :rl_rubout
}
@rl_library_version = RL_LIBRARY_VERSION
@rl_readline_version = RL_READLINE_VERSION
@rl_readline_name = "other"
@rl_getc_function = :rl_getc
# Non-zero tells rl_delete_text and rl_insert_text to not add to
# the undo list.
@_rl_doing_an_undo = false
# How many unclosed undo groups we currently have.
@_rl_undo_group_level = 0
# The current undo list for THE_LINE.
@rl_undo_list = nil
# Application-specific redisplay function.
@rl_redisplay_function = :rl_redisplay
# Global variables declared here.
# What YOU turn on when you have handled all redisplay yourself.
@rl_display_fixed = false
@_rl_suppress_redisplay = 0
@_rl_want_redisplay = false
# The stuff that gets printed out before the actual text of the line.
# This is usually pointing to rl_prompt.
@rl_display_prompt = nil
# True if this is `real' readline as opposed to some stub substitute.
@rl_gnu_readline_p = true
for i in 32 .. 255
@emacs_standard_keymap[i.chr] = :rl_insert unless @emacs_standard_keymap[i.chr]
@vi_insertion_keymap[i.chr] = :rl_insert unless @vi_insertion_keymap[i.chr]
end
# A pointer to the keymap that is currently in use.
# By default, it is the standard emacs keymap.
@_rl_keymap = @emacs_standard_keymap
# The current style of editing.
@rl_editing_mode = @emacs_mode
# The current insert mode: input (the default) or overwrite
@rl_insert_mode = RL_IM_DEFAULT
# Non-zero if we called this function from _rl_dispatch(). It's present
# so functions can find out whether they were called from a key binding
# or directly from an application.
@rl_dispatching = false
# Non-zero if the previous command was a kill command.
@_rl_last_command_was_kill = false
# The current value of the numeric argument specified by the user.
@rl_numeric_arg = 1
# Non-zero if an argument was typed.
@rl_explicit_arg = false
# Temporary value used while generating the argument.
@rl_arg_sign = 1
# Non-zero means we have been called at least once before.
@rl_initialized = false
# Flags word encapsulating the current readline state.
@rl_readline_state = RL_STATE_NONE
# The current offset in the current input line.
@rl_point = 0
# Mark in the current input line.
@rl_mark = 0
# Length of the current input line.
@rl_end = 0
# Make this non-zero to return the current input_line.
@rl_done = false
# The last function executed by readline.
@rl_last_func = nil
# Top level environment for readline_internal ().
@readline_top_level = nil
# The streams we interact with.
@_rl_in_stream = nil
@_rl_out_stream = nil
# The names of the streams that we do input and output to.
@rl_instream = nil
@rl_outstream = nil
@pop_index = 0
@push_index = 0
@ibuffer = 0.chr * 512
@ibuffer_len = @ibuffer.length - 1
# Non-zero means echo characters as they are read. Defaults to no echo
# set to 1 if there is a controlling terminal, we can get its attributes,
# and the attributes include `echo'. Look at rltty.c:prepare_terminal_settings
# for the code that sets it.
@readline_echoing_p = false
# Current prompt.
@rl_prompt = nil
@rl_visible_prompt_length = 0
# Set to non-zero by calling application if it has already printed rl_prompt
# and does not want readline to do it the first time.
@rl_already_prompted = false
# The number of characters read in order to type this complete command.
@rl_key_sequence_length = 0
# If non-zero, then this is the address of a function to call just
# before readline_internal_setup () prints the first prompt.
@rl_startup_hook = nil
# If non-zero, this is the address of a function to call just before
# readline_internal_setup () returns and readline_internal starts
# reading input characters.
@rl_pre_input_hook = nil
# The character that can generate an EOF. Really read from
# the terminal driver... just defaulted here.
@_rl_eof_char = "\cD"
# Non-zero makes this the next keystroke to read.
@rl_pending_input = 0
# Pointer to a useful terminal name.
@rl_terminal_name = nil
# Non-zero means to always use horizontal scrolling in line display.
@_rl_horizontal_scroll_mode = false
# Non-zero means to display an asterisk at the starts of history lines
# which have been modified.
@_rl_mark_modified_lines = false
# The style of `bell' notification preferred. This can be set to NO_BELL,
# AUDIBLE_BELL, or VISIBLE_BELL.
@_rl_bell_preference = AUDIBLE_BELL
# String inserted into the line by rl_insert_comment ().
@_rl_comment_begin = nil
# Keymap holding the function currently being executed.
@rl_executing_keymap = nil
# Keymap we're currently using to dispatch.
@_rl_dispatching_keymap = nil
# Non-zero means to erase entire line, including prompt, on empty input lines.
@rl_erase_empty_line = false
# Non-zero means to read only this many characters rather than up to a
# character bound to accept-line.
@rl_num_chars_to_read = 0
# Line buffer and maintenence.
@rl_line_buffer = ""
# Key sequence `contexts'
@_rl_kscxt = nil
# Non-zero means do not parse any lines other than comments and
# parser directives.
@_rl_parsing_conditionalized_out = false
# Non-zero means to convert characters with the meta bit set to
# escape-prefixed characters so we can indirect through
# emacs_meta_keymap or vi_escape_keymap.
@_rl_convert_meta_chars_to_ascii = true
# Non-zero means to output characters with the meta bit set directly
# rather than as a meta-prefixed escape sequence.
@_rl_output_meta_chars = false
# Non-zero means to look at the termios special characters and bind
# them to equivalent readline functions at startup.
@_rl_bind_stty_chars = true
@rl_completion_display_matches_hook = nil
XOK = 1
@_rl_term_clreol = nil
@_rl_term_clrpag = nil
@_rl_term_cr = nil
@_rl_term_backspace = nil
@_rl_term_goto = nil
@_rl_term_pc = nil
# "An application program can assume that the terminal can do character
# insertion if *any one of* the capabilities `IC', `im', `ic' or `ip' is
# provided.". But we can't do anything if only `ip' is provided, so...
#
# Currently rb-readline can't tgoto(). Setting this to false means that
# insert_some_chars doesn't get called and some other method is used.
@_rl_terminal_can_insert = false
# How to insert characters.
@_rl_term_im = nil
@_rl_term_ei = nil
@_rl_term_ic = nil
@_rl_term_ip = nil
@_rl_term_IC = nil
# How to delete characters.
@_rl_term_dc = nil
@_rl_term_DC = nil
@_rl_term_forward_char = nil
# How to go up a line.
@_rl_term_up = nil
# A visible bell; char if the terminal can be made to flash the screen.
@_rl_visible_bell = nil
# Non-zero means the terminal can auto-wrap lines.
@_rl_term_autowrap = true
# Non-zero means that this terminal has a meta key.
@term_has_meta = 0
# The sequences to write to turn on and off the meta key, if this
# terminal has one.
@_rl_term_mm = nil
@_rl_term_mo = nil
# The key sequences output by the arrow keys, if this terminal has any.
@_rl_term_ku = nil
@_rl_term_kd = nil
@_rl_term_kr = nil
@_rl_term_kl = nil
# How to initialize and reset the arrow keys, if this terminal has any.
@_rl_term_ks = nil
@_rl_term_ke = nil
# The key sequences sent by the Home and End keys, if any.
@_rl_term_kh = nil
@_rl_term_kH = nil
@_rl_term_at7 = nil
# Delete key
@_rl_term_kD = nil
# Insert key
@_rl_term_kI = nil
# Cursor control
@_rl_term_vs = nil # very visible
@_rl_term_ve = nil # normal
# Variables that hold the screen dimensions, used by the display code.
@_rl_screenwidth = @_rl_screenheight = @_rl_screenchars = 0
# Non-zero means the user wants to enable the keypad.
@_rl_enable_keypad = false
# Non-zero means the user wants to enable a meta key.
@_rl_enable_meta = true
# ****************************************************************
#
# Completion matching, from readline's point of view.
#
# ****************************************************************
# Variables known only to the readline library.
# If non-zero, non-unique completions always show the list of matches.
@_rl_complete_show_all = false
# If non-zero, non-unique completions show the list of matches, unless it
# is not possible to do partial completion and modify the line.
@_rl_complete_show_unmodified = false
# If non-zero, completed directory names have a slash appended.
@_rl_complete_mark_directories = true
# If non-zero, the symlinked directory completion behavior introduced in
# readline-4.2a is disabled, and symlinks that point to directories have
# a slash appended (subject to the value of _rl_complete_mark_directories).
# This is user-settable via the mark-symlinked-directories variable.
@_rl_complete_mark_symlink_dirs = false
# If non-zero, completions are printed horizontally in alphabetical order,
# like `ls -x'.
@_rl_print_completions_horizontally = false
@_rl_completion_case_fold = false
# If non-zero, don't match hidden files (filenames beginning with a `.' on
# Unix) when doing filename completion.
@_rl_match_hidden_files = true
# Global variables available to applications using readline.
# Non-zero means add an additional character to each filename displayed
# during listing completion iff rl_filename_completion_desired which helps
# to indicate the type of file being listed.
@rl_visible_stats = false
# If non-zero, then this is the address of a function to call when
# completing on a directory name. The function is called with
# the address of a string (the current directory name) as an arg.
@rl_directory_completion_hook = nil
@rl_directory_rewrite_hook = nil
# Non-zero means readline completion functions perform tilde expansion.
@rl_complete_with_tilde_expansion = false
# Pointer to the generator function for completion_matches ().
# NULL means to use rl_filename_completion_function (), the default filename
# completer.
@rl_completion_entry_function = nil
# Pointer to alternative function to create matches.
# Function is called with TEXT, START, and END.
# START and END are indices in RL_LINE_BUFFER saying what the boundaries
# of TEXT are.
# If this function exists and returns NULL then call the value of
# rl_completion_entry_function to try to match, otherwise use the
# array of strings returned.
@rl_attempted_completion_function = nil
# Non-zero means to suppress normal filename completion after the
# user-specified completion function has been called.
@rl_attempted_completion_over = false
# Set to a character indicating the type of completion being performed
# by rl_complete_internal, available for use by application completion
# functions.
@rl_completion_type = 0
# Up to this many items will be displayed in response to a
# possible-completions call. After that, we ask the user if
# she is sure she wants to see them all. A negative value means
# don't ask.
@rl_completion_query_items = 100
@_rl_page_completions = 1
# The basic list of characters that signal a break between words for the
# completer routine. The contents of this variable is what breaks words
# in the shell, i.e. " \t\n\"\\'`@$><="
@rl_basic_word_break_characters = " \t\n\"\\'`@$><=|&{(" # })
# List of basic quoting characters.
@rl_basic_quote_characters = "\"'"
# The list of characters that signal a break between words for
# rl_complete_internal. The default list is the contents of
# rl_basic_word_break_characters.
@rl_completer_word_break_characters = nil
# Hook function to allow an application to set the completion word
# break characters before readline breaks up the line. Allows
# position-dependent word break characters.
@rl_completion_word_break_hook = nil
# List of characters which can be used to quote a substring of the line.
# Completion occurs on the entire substring, and within the substring
# rl_completer_word_break_characters are treated as any other character,
# unless they also appear within this list.
@rl_completer_quote_characters = nil
# List of characters that should be quoted in filenames by the completer.
@rl_filename_quote_characters = nil
# List of characters that are word break characters, but should be left
# in TEXT when it is passed to the completion function. The shell uses
# this to help determine what kind of completing to do.
@rl_special_prefixes = nil
# If non-zero, then disallow duplicates in the matches.
@rl_ignore_completion_duplicates = true
# Non-zero means that the results of the matches are to be treated
# as filenames. This is ALWAYS zero on entry, and can only be changed
# within a completion entry finder function.