brakeman 6.1.1 → 6.2.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (512) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGES.md +24 -0
  3. data/README.md +5 -1
  4. data/bundle/load.rb +16 -14
  5. data/bundle/ruby/{3.0.0/gems/highline-2.1.0 → 3.1.0/gems/highline-3.1.0}/Changelog.md +22 -0
  6. data/bundle/ruby/{3.0.0/gems/highline-2.1.0 → 3.1.0/gems/highline-3.1.0}/README.md +37 -1
  7. data/bundle/ruby/{3.0.0/gems/highline-2.1.0 → 3.1.0/gems/highline-3.1.0}/highline.gemspec +6 -1
  8. data/bundle/ruby/{3.0.0/gems/highline-2.1.0 → 3.1.0/gems/highline-3.1.0}/lib/highline/io_console_compatible.rb +1 -1
  9. data/bundle/ruby/{3.0.0/gems/highline-2.1.0 → 3.1.0/gems/highline-3.1.0}/lib/highline/question/answer_converter.rb +2 -5
  10. data/bundle/ruby/{3.0.0/gems/highline-2.1.0 → 3.1.0/gems/highline-3.1.0}/lib/highline/question.rb +23 -13
  11. data/bundle/ruby/{3.0.0/gems/highline-2.1.0 → 3.1.0/gems/highline-3.1.0}/lib/highline/question_asker.rb +3 -1
  12. data/bundle/ruby/{3.0.0/gems/highline-2.1.0 → 3.1.0/gems/highline-3.1.0}/lib/highline/terminal/io_console.rb +1 -1
  13. data/bundle/ruby/{3.0.0/gems/highline-2.1.0 → 3.1.0/gems/highline-3.1.0}/lib/highline/terminal/unix_stty.rb +6 -4
  14. data/bundle/ruby/{3.0.0/gems/highline-2.1.0 → 3.1.0/gems/highline-3.1.0}/lib/highline/terminal.rb +8 -6
  15. data/bundle/ruby/{3.0.0/gems/highline-2.1.0 → 3.1.0/gems/highline-3.1.0}/lib/highline/version.rb +1 -1
  16. data/bundle/ruby/{3.0.0/gems/highline-2.1.0 → 3.1.0/gems/highline-3.1.0}/lib/highline.rb +18 -5
  17. data/bundle/ruby/3.1.0/gems/io-console-0.7.2/README.md +46 -0
  18. data/bundle/ruby/3.1.0/gems/io-console-0.7.2/ext/io/console/Makefile +270 -0
  19. data/bundle/ruby/3.1.0/gems/io-console-0.7.2/ext/io/console/console.c +1838 -0
  20. data/bundle/ruby/3.1.0/gems/io-console-0.7.2/ext/io/console/console.o +0 -0
  21. data/bundle/ruby/3.1.0/gems/io-console-0.7.2/ext/io/console/console.so +0 -0
  22. data/bundle/ruby/3.1.0/gems/io-console-0.7.2/ext/io/console/extconf.rb +43 -0
  23. data/bundle/ruby/3.1.0/gems/io-console-0.7.2/ext/io/console/win32_vk.inc +1391 -0
  24. data/bundle/ruby/3.1.0/gems/io-console-0.7.2/lib/io/console/size.rb +23 -0
  25. data/bundle/ruby/3.1.0/gems/io-console-0.7.2/lib/io/console.so +0 -0
  26. data/bundle/ruby/3.1.0/gems/parallel-1.26.3/lib/parallel/version.rb +4 -0
  27. data/bundle/ruby/{3.0.0/gems/parallel-1.24.0 → 3.1.0/gems/parallel-1.26.3}/lib/parallel.rb +51 -19
  28. data/bundle/ruby/3.1.0/gems/reline-0.5.9/BSDL +22 -0
  29. data/bundle/ruby/3.1.0/gems/reline-0.5.9/COPYING +56 -0
  30. data/bundle/ruby/3.1.0/gems/reline-0.5.9/README.md +94 -0
  31. data/bundle/ruby/3.1.0/gems/reline-0.5.9/lib/reline/config.rb +382 -0
  32. data/bundle/ruby/3.1.0/gems/reline-0.5.9/lib/reline/face.rb +199 -0
  33. data/bundle/ruby/3.1.0/gems/reline-0.5.9/lib/reline/history.rb +76 -0
  34. data/bundle/ruby/3.1.0/gems/reline-0.5.9/lib/reline/io/ansi.rb +364 -0
  35. data/bundle/ruby/3.1.0/gems/reline-0.5.9/lib/reline/io/dumb.rb +106 -0
  36. data/bundle/ruby/3.1.0/gems/reline-0.5.9/lib/reline/io/windows.rb +503 -0
  37. data/bundle/ruby/3.1.0/gems/reline-0.5.9/lib/reline/io.rb +41 -0
  38. data/bundle/ruby/3.1.0/gems/reline-0.5.9/lib/reline/key_actor/base.rb +31 -0
  39. data/bundle/ruby/3.1.0/gems/reline-0.5.9/lib/reline/key_actor/composite.rb +17 -0
  40. data/bundle/ruby/3.1.0/gems/reline-0.5.9/lib/reline/key_actor/emacs.rb +517 -0
  41. data/bundle/ruby/3.1.0/gems/reline-0.5.9/lib/reline/key_actor/vi_command.rb +518 -0
  42. data/bundle/ruby/3.1.0/gems/reline-0.5.9/lib/reline/key_actor/vi_insert.rb +517 -0
  43. data/bundle/ruby/3.1.0/gems/reline-0.5.9/lib/reline/key_actor.rb +8 -0
  44. data/bundle/ruby/3.1.0/gems/reline-0.5.9/lib/reline/key_stroke.rb +109 -0
  45. data/bundle/ruby/3.1.0/gems/reline-0.5.9/lib/reline/kill_ring.rb +125 -0
  46. data/bundle/ruby/3.1.0/gems/reline-0.5.9/lib/reline/line_editor.rb +2557 -0
  47. data/bundle/ruby/3.1.0/gems/reline-0.5.9/lib/reline/terminfo.rb +158 -0
  48. data/bundle/ruby/3.1.0/gems/reline-0.5.9/lib/reline/unicode/east_asian_width.rb +1196 -0
  49. data/bundle/ruby/3.1.0/gems/reline-0.5.9/lib/reline/unicode.rb +696 -0
  50. data/bundle/ruby/3.1.0/gems/reline-0.5.9/lib/reline/version.rb +3 -0
  51. data/bundle/ruby/3.1.0/gems/reline-0.5.9/lib/reline.rb +516 -0
  52. data/bundle/ruby/3.1.0/gems/reline-0.5.9/license_of_rb-readline +25 -0
  53. data/bundle/ruby/3.1.0/gems/rexml-3.3.6/LICENSE.txt +22 -0
  54. data/bundle/ruby/{3.0.0/gems/rexml-3.2.6 → 3.1.0/gems/rexml-3.3.6}/NEWS.md +306 -0
  55. data/bundle/ruby/{3.0.0/gems/rexml-3.2.6 → 3.1.0/gems/rexml-3.3.6}/lib/rexml/element.rb +16 -31
  56. data/bundle/ruby/{3.0.0/gems/rexml-3.2.6 → 3.1.0/gems/rexml-3.3.6}/lib/rexml/entity.rb +5 -47
  57. data/bundle/ruby/{3.0.0/gems/rexml-3.2.6 → 3.1.0/gems/rexml-3.3.6}/lib/rexml/formatters/pretty.rb +1 -1
  58. data/bundle/ruby/{3.0.0/gems/rexml-3.2.6 → 3.1.0/gems/rexml-3.3.6}/lib/rexml/functions.rb +1 -2
  59. data/bundle/ruby/{3.0.0/gems/rexml-3.2.6 → 3.1.0/gems/rexml-3.3.6}/lib/rexml/node.rb +8 -4
  60. data/bundle/ruby/{3.0.0/gems/rexml-3.2.6 → 3.1.0/gems/rexml-3.3.6}/lib/rexml/parseexception.rb +1 -0
  61. data/bundle/ruby/3.1.0/gems/rexml-3.3.6/lib/rexml/parsers/baseparser.rb +852 -0
  62. data/bundle/ruby/{3.0.0/gems/rexml-3.2.6 → 3.1.0/gems/rexml-3.3.6}/lib/rexml/parsers/pullparser.rb +4 -0
  63. data/bundle/ruby/{3.0.0/gems/rexml-3.2.6 → 3.1.0/gems/rexml-3.3.6}/lib/rexml/parsers/sax2parser.rb +6 -19
  64. data/bundle/ruby/{3.0.0/gems/rexml-3.2.6 → 3.1.0/gems/rexml-3.3.6}/lib/rexml/parsers/streamparser.rb +8 -10
  65. data/bundle/ruby/{3.0.0/gems/rexml-3.2.6 → 3.1.0/gems/rexml-3.3.6}/lib/rexml/parsers/treeparser.rb +9 -21
  66. data/bundle/ruby/{3.0.0/gems/rexml-3.2.6 → 3.1.0/gems/rexml-3.3.6}/lib/rexml/rexml.rb +1 -1
  67. data/bundle/ruby/{3.0.0/gems/rexml-3.2.6 → 3.1.0/gems/rexml-3.3.6}/lib/rexml/source.rb +128 -98
  68. data/bundle/ruby/{3.0.0/gems/rexml-3.2.6 → 3.1.0/gems/rexml-3.3.6}/lib/rexml/text.rb +34 -14
  69. data/bundle/ruby/{3.0.0/gems/rexml-3.2.6 → 3.1.0/gems/rexml-3.3.6}/lib/rexml/xpath_parser.rb +7 -3
  70. data/bundle/ruby/{3.0.0/gems/ruby2ruby-2.4.4 → 3.1.0/gems/ruby2ruby-2.5.1}/History.rdoc +22 -0
  71. data/bundle/ruby/{3.0.0/gems/ruby2ruby-2.4.4 → 3.1.0/gems/ruby2ruby-2.5.1}/lib/ruby2ruby.rb +162 -26
  72. data/bundle/ruby/{3.0.0/gems/sexp_processor-4.17.0 → 3.1.0/gems/sexp_processor-4.17.2}/History.rdoc +12 -0
  73. data/bundle/ruby/{3.0.0/gems/sexp_processor-4.17.0 → 3.1.0/gems/sexp_processor-4.17.2}/lib/pt_testcase.rb +1 -1
  74. data/bundle/ruby/{3.0.0/gems/sexp_processor-4.17.0 → 3.1.0/gems/sexp_processor-4.17.2}/lib/sexp_matcher.rb +1 -1
  75. data/bundle/ruby/{3.0.0/gems/sexp_processor-4.17.0 → 3.1.0/gems/sexp_processor-4.17.2}/lib/sexp_processor.rb +1 -1
  76. data/bundle/ruby/{3.0.0/gems/slim-4.1.0 → 3.1.0/gems/slim-5.2.1}/CHANGES +44 -8
  77. data/bundle/ruby/3.1.0/gems/slim-5.2.1/Gemfile +43 -0
  78. data/bundle/ruby/{3.0.0/gems/slim-4.1.0 → 3.1.0/gems/slim-5.2.1}/LICENSE +1 -1
  79. data/bundle/ruby/{3.0.0/gems/slim-4.1.0 → 3.1.0/gems/slim-5.2.1}/README.jp.md +28 -41
  80. data/bundle/ruby/{3.0.0/gems/slim-4.1.0 → 3.1.0/gems/slim-5.2.1}/README.md +66 -43
  81. data/bundle/ruby/{3.0.0/gems/slim-4.1.0 → 3.1.0/gems/slim-5.2.1}/lib/slim/code_attributes.rb +2 -1
  82. data/bundle/ruby/{3.0.0/gems/slim-4.1.0 → 3.1.0/gems/slim-5.2.1}/lib/slim/command.rb +2 -8
  83. data/bundle/ruby/{3.0.0/gems/slim-4.1.0 → 3.1.0/gems/slim-5.2.1}/lib/slim/controls.rb +1 -0
  84. data/bundle/ruby/{3.0.0/gems/slim-4.1.0 → 3.1.0/gems/slim-5.2.1}/lib/slim/do_inserter.rb +4 -3
  85. data/bundle/ruby/{3.0.0/gems/slim-4.1.0 → 3.1.0/gems/slim-5.2.1}/lib/slim/embedded.rb +17 -17
  86. data/bundle/ruby/{3.0.0/gems/slim-4.1.0 → 3.1.0/gems/slim-5.2.1}/lib/slim/end_inserter.rb +3 -2
  87. data/bundle/ruby/{3.0.0/gems/slim-4.1.0 → 3.1.0/gems/slim-5.2.1}/lib/slim/engine.rb +3 -0
  88. data/bundle/ruby/{3.0.0/gems/slim-4.1.0 → 3.1.0/gems/slim-5.2.1}/lib/slim/erb_converter.rb +1 -0
  89. data/bundle/ruby/{3.0.0/gems/slim-4.1.0 → 3.1.0/gems/slim-5.2.1}/lib/slim/filter.rb +1 -0
  90. data/bundle/ruby/{3.0.0/gems/slim-4.1.0 → 3.1.0/gems/slim-5.2.1}/lib/slim/grammar.rb +1 -0
  91. data/bundle/ruby/{3.0.0/gems/slim-4.1.0 → 3.1.0/gems/slim-5.2.1}/lib/slim/include.rb +1 -0
  92. data/bundle/ruby/{3.0.0/gems/slim-4.1.0 → 3.1.0/gems/slim-5.2.1}/lib/slim/interpolation.rb +1 -0
  93. data/bundle/ruby/{3.0.0/gems/slim-4.1.0 → 3.1.0/gems/slim-5.2.1}/lib/slim/logic_less/context.rb +6 -7
  94. data/bundle/ruby/{3.0.0/gems/slim-4.1.0 → 3.1.0/gems/slim-5.2.1}/lib/slim/logic_less/filter.rb +1 -0
  95. data/bundle/ruby/{3.0.0/gems/slim-4.1.0 → 3.1.0/gems/slim-5.2.1}/lib/slim/logic_less.rb +1 -0
  96. data/bundle/ruby/{3.0.0/gems/slim-4.1.0 → 3.1.0/gems/slim-5.2.1}/lib/slim/parser.rb +26 -39
  97. data/bundle/ruby/3.1.0/gems/slim-5.2.1/lib/slim/railtie.rb +19 -0
  98. data/bundle/ruby/{3.0.0/gems/slim-4.1.0 → 3.1.0/gems/slim-5.2.1}/lib/slim/smart/escaper.rb +1 -1
  99. data/bundle/ruby/{3.0.0/gems/slim-4.1.0 → 3.1.0/gems/slim-5.2.1}/lib/slim/smart/filter.rb +3 -2
  100. data/bundle/ruby/{3.0.0/gems/slim-4.1.0 → 3.1.0/gems/slim-5.2.1}/lib/slim/smart/parser.rb +4 -3
  101. data/bundle/ruby/{3.0.0/gems/slim-4.1.0 → 3.1.0/gems/slim-5.2.1}/lib/slim/smart.rb +1 -0
  102. data/bundle/ruby/{3.0.0/gems/slim-4.1.0 → 3.1.0/gems/slim-5.2.1}/lib/slim/splat/builder.rb +16 -8
  103. data/bundle/ruby/{3.0.0/gems/slim-4.1.0 → 3.1.0/gems/slim-5.2.1}/lib/slim/splat/filter.rb +6 -4
  104. data/bundle/ruby/3.1.0/gems/slim-5.2.1/lib/slim/template.rb +6 -0
  105. data/bundle/ruby/{3.0.0/gems/slim-4.1.0 → 3.1.0/gems/slim-5.2.1}/lib/slim/translator.rb +4 -3
  106. data/bundle/ruby/{3.0.0/gems/slim-4.1.0 → 3.1.0/gems/slim-5.2.1}/lib/slim/version.rb +2 -1
  107. data/bundle/ruby/{3.0.0/gems/slim-4.1.0 → 3.1.0/gems/slim-5.2.1}/lib/slim.rb +2 -0
  108. data/bundle/ruby/{3.0.0/gems/slim-4.1.0 → 3.1.0/gems/slim-5.2.1}/slim.gemspec +14 -5
  109. data/bundle/ruby/3.1.0/gems/strscan-3.1.0/COPYING +56 -0
  110. data/bundle/ruby/3.1.0/gems/strscan-3.1.0/LICENSE.txt +22 -0
  111. data/bundle/ruby/3.1.0/gems/strscan-3.1.0/ext/strscan/Makefile +268 -0
  112. data/bundle/ruby/3.1.0/gems/strscan-3.1.0/ext/strscan/extconf.rb +10 -0
  113. data/bundle/ruby/3.1.0/gems/strscan-3.1.0/ext/strscan/strscan.c +1741 -0
  114. data/bundle/ruby/3.1.0/gems/strscan-3.1.0/ext/strscan/strscan.o +0 -0
  115. data/bundle/ruby/3.1.0/gems/strscan-3.1.0/ext/strscan/strscan.so +0 -0
  116. data/bundle/ruby/3.1.0/gems/strscan-3.1.0/lib/strscan.so +0 -0
  117. data/bundle/ruby/{3.0.0/gems/temple-0.8.2 → 3.1.0/gems/temple-0.10.3}/CHANGES +39 -1
  118. data/bundle/ruby/3.1.0/gems/temple-0.10.3/Gemfile +2 -0
  119. data/bundle/ruby/{3.0.0/gems/temple-0.8.2 → 3.1.0/gems/temple-0.10.3}/README.md +1 -1
  120. data/bundle/ruby/{3.0.0/gems/temple-0.8.2 → 3.1.0/gems/temple-0.10.3}/lib/temple/engine.rb +1 -0
  121. data/bundle/ruby/{3.0.0/gems/temple-0.8.2 → 3.1.0/gems/temple-0.10.3}/lib/temple/erb/engine.rb +3 -0
  122. data/bundle/ruby/{3.0.0/gems/temple-0.8.2 → 3.1.0/gems/temple-0.10.3}/lib/temple/erb/parser.rb +2 -1
  123. data/bundle/ruby/{3.0.0/gems/temple-0.8.2 → 3.1.0/gems/temple-0.10.3}/lib/temple/erb/template.rb +1 -0
  124. data/bundle/ruby/{3.0.0/gems/temple-0.8.2 → 3.1.0/gems/temple-0.10.3}/lib/temple/erb/trimming.rb +1 -0
  125. data/bundle/ruby/{3.0.0/gems/temple-0.8.2 → 3.1.0/gems/temple-0.10.3}/lib/temple/exceptions.rb +1 -0
  126. data/bundle/ruby/{3.0.0/gems/temple-0.8.2 → 3.1.0/gems/temple-0.10.3}/lib/temple/filter.rb +1 -0
  127. data/bundle/ruby/3.1.0/gems/temple-0.10.3/lib/temple/filters/ambles.rb +22 -0
  128. data/bundle/ruby/{3.0.0/gems/temple-0.8.2 → 3.1.0/gems/temple-0.10.3}/lib/temple/filters/code_merger.rb +1 -0
  129. data/bundle/ruby/{3.0.0/gems/temple-0.8.2 → 3.1.0/gems/temple-0.10.3}/lib/temple/filters/control_flow.rb +1 -0
  130. data/bundle/ruby/{3.0.0/gems/temple-0.8.2 → 3.1.0/gems/temple-0.10.3}/lib/temple/filters/dynamic_inliner.rb +2 -1
  131. data/bundle/ruby/3.1.0/gems/temple-0.10.3/lib/temple/filters/dynamic_merger.rb +69 -0
  132. data/bundle/ruby/{3.0.0/gems/temple-0.8.2 → 3.1.0/gems/temple-0.10.3}/lib/temple/filters/encoding.rb +1 -0
  133. data/bundle/ruby/{3.0.0/gems/temple-0.8.2 → 3.1.0/gems/temple-0.10.3}/lib/temple/filters/eraser.rb +1 -0
  134. data/bundle/ruby/{3.0.0/gems/temple-0.8.2 → 3.1.0/gems/temple-0.10.3}/lib/temple/filters/escapable.rb +1 -0
  135. data/bundle/ruby/{3.0.0/gems/temple-0.8.2 → 3.1.0/gems/temple-0.10.3}/lib/temple/filters/multi_flattener.rb +1 -0
  136. data/bundle/ruby/{3.0.0/gems/temple-0.8.2 → 3.1.0/gems/temple-0.10.3}/lib/temple/filters/remove_bom.rb +1 -0
  137. data/bundle/ruby/{3.0.0/gems/temple-0.8.2 → 3.1.0/gems/temple-0.10.3}/lib/temple/filters/static_analyzer.rb +1 -0
  138. data/bundle/ruby/{3.0.0/gems/temple-0.8.2 → 3.1.0/gems/temple-0.10.3}/lib/temple/filters/static_merger.rb +1 -0
  139. data/bundle/ruby/{3.0.0/gems/temple-0.8.2 → 3.1.0/gems/temple-0.10.3}/lib/temple/filters/string_splitter.rb +13 -1
  140. data/bundle/ruby/{3.0.0/gems/temple-0.8.2 → 3.1.0/gems/temple-0.10.3}/lib/temple/filters/validator.rb +1 -0
  141. data/bundle/ruby/{3.0.0/gems/temple-0.8.2 → 3.1.0/gems/temple-0.10.3}/lib/temple/generator.rb +5 -2
  142. data/bundle/ruby/{3.0.0/gems/temple-0.8.2 → 3.1.0/gems/temple-0.10.3}/lib/temple/generators/array.rb +1 -0
  143. data/bundle/ruby/{3.0.0/gems/temple-0.8.2 → 3.1.0/gems/temple-0.10.3}/lib/temple/generators/array_buffer.rb +1 -0
  144. data/bundle/ruby/{3.0.0/gems/temple-0.8.2 → 3.1.0/gems/temple-0.10.3}/lib/temple/generators/erb.rb +1 -0
  145. data/bundle/ruby/{3.0.0/gems/temple-0.8.2 → 3.1.0/gems/temple-0.10.3}/lib/temple/generators/rails_output_buffer.rb +4 -4
  146. data/bundle/ruby/{3.0.0/gems/temple-0.8.2 → 3.1.0/gems/temple-0.10.3}/lib/temple/generators/string_buffer.rb +2 -1
  147. data/bundle/ruby/{3.0.0/gems/temple-0.8.2 → 3.1.0/gems/temple-0.10.3}/lib/temple/grammar.rb +1 -0
  148. data/bundle/ruby/{3.0.0/gems/temple-0.8.2 → 3.1.0/gems/temple-0.10.3}/lib/temple/html/attribute_merger.rb +1 -0
  149. data/bundle/ruby/{3.0.0/gems/temple-0.8.2 → 3.1.0/gems/temple-0.10.3}/lib/temple/html/attribute_remover.rb +1 -0
  150. data/bundle/ruby/{3.0.0/gems/temple-0.8.2 → 3.1.0/gems/temple-0.10.3}/lib/temple/html/attribute_sorter.rb +1 -0
  151. data/bundle/ruby/{3.0.0/gems/temple-0.8.2 → 3.1.0/gems/temple-0.10.3}/lib/temple/html/dispatcher.rb +1 -0
  152. data/bundle/ruby/{3.0.0/gems/temple-0.8.2 → 3.1.0/gems/temple-0.10.3}/lib/temple/html/fast.rb +1 -0
  153. data/bundle/ruby/{3.0.0/gems/temple-0.8.2 → 3.1.0/gems/temple-0.10.3}/lib/temple/html/filter.rb +1 -0
  154. data/bundle/ruby/{3.0.0/gems/temple-0.8.2 → 3.1.0/gems/temple-0.10.3}/lib/temple/html/pretty.rb +1 -0
  155. data/bundle/ruby/{3.0.0/gems/temple-0.8.2 → 3.1.0/gems/temple-0.10.3}/lib/temple/html/safe.rb +1 -0
  156. data/bundle/ruby/{3.0.0/gems/temple-0.8.2 → 3.1.0/gems/temple-0.10.3}/lib/temple/map.rb +1 -0
  157. data/bundle/ruby/{3.0.0/gems/temple-0.8.2 → 3.1.0/gems/temple-0.10.3}/lib/temple/mixins/dispatcher.rb +1 -0
  158. data/bundle/ruby/{3.0.0/gems/temple-0.8.2 → 3.1.0/gems/temple-0.10.3}/lib/temple/mixins/engine_dsl.rb +1 -0
  159. data/bundle/ruby/{3.0.0/gems/temple-0.8.2 → 3.1.0/gems/temple-0.10.3}/lib/temple/mixins/grammar_dsl.rb +4 -2
  160. data/bundle/ruby/{3.0.0/gems/temple-0.8.2 → 3.1.0/gems/temple-0.10.3}/lib/temple/mixins/options.rb +1 -0
  161. data/bundle/ruby/{3.0.0/gems/temple-0.8.2 → 3.1.0/gems/temple-0.10.3}/lib/temple/mixins/template.rb +1 -0
  162. data/bundle/ruby/{3.0.0/gems/temple-0.8.2 → 3.1.0/gems/temple-0.10.3}/lib/temple/parser.rb +1 -0
  163. data/bundle/ruby/{3.0.0/gems/temple-0.8.2 → 3.1.0/gems/temple-0.10.3}/lib/temple/static_analyzer.rb +1 -0
  164. data/bundle/ruby/{3.0.0/gems/temple-0.8.2 → 3.1.0/gems/temple-0.10.3}/lib/temple/templates/rails.rb +7 -2
  165. data/bundle/ruby/{3.0.0/gems/temple-0.8.2 → 3.1.0/gems/temple-0.10.3}/lib/temple/templates/tilt.rb +2 -9
  166. data/bundle/ruby/{3.0.0/gems/temple-0.8.2 → 3.1.0/gems/temple-0.10.3}/lib/temple/templates.rb +1 -0
  167. data/bundle/ruby/{3.0.0/gems/temple-0.8.2 → 3.1.0/gems/temple-0.10.3}/lib/temple/utils.rb +5 -15
  168. data/bundle/ruby/3.1.0/gems/temple-0.10.3/lib/temple/version.rb +4 -0
  169. data/bundle/ruby/{3.0.0/gems/temple-0.8.2 → 3.1.0/gems/temple-0.10.3}/lib/temple.rb +3 -0
  170. data/bundle/ruby/{3.0.0/gems/temple-0.8.2 → 3.1.0/gems/temple-0.10.3}/temple.gemspec +4 -6
  171. data/bundle/ruby/{3.0.0/gems/tilt-2.0.11 → 3.1.0/gems/tilt-2.4.0}/COPYING +1 -0
  172. data/bundle/ruby/3.1.0/gems/tilt-2.4.0/lib/tilt/_emacs_org.rb +2 -0
  173. data/bundle/ruby/3.1.0/gems/tilt-2.4.0/lib/tilt/_handlebars.rb +2 -0
  174. data/bundle/ruby/3.1.0/gems/tilt-2.4.0/lib/tilt/_jbuilder.rb +2 -0
  175. data/bundle/ruby/3.1.0/gems/tilt-2.4.0/lib/tilt/_org.rb +2 -0
  176. data/bundle/ruby/3.1.0/gems/tilt-2.4.0/lib/tilt/asciidoc.rb +15 -0
  177. data/bundle/ruby/3.1.0/gems/tilt-2.4.0/lib/tilt/babel.rb +8 -0
  178. data/bundle/ruby/3.1.0/gems/tilt-2.4.0/lib/tilt/builder.rb +42 -0
  179. data/bundle/ruby/3.1.0/gems/tilt-2.4.0/lib/tilt/cli.rb +134 -0
  180. data/bundle/ruby/3.1.0/gems/tilt-2.4.0/lib/tilt/coffee.rb +39 -0
  181. data/bundle/ruby/3.1.0/gems/tilt-2.4.0/lib/tilt/commonmarker.rb +95 -0
  182. data/bundle/ruby/3.1.0/gems/tilt-2.4.0/lib/tilt/creole.rb +14 -0
  183. data/bundle/ruby/{3.0.0/gems/tilt-2.0.11 → 3.1.0/gems/tilt-2.4.0}/lib/tilt/csv.rb +6 -18
  184. data/bundle/ruby/{3.0.0/gems/tilt-2.0.11 → 3.1.0/gems/tilt-2.4.0}/lib/tilt/erb.rb +23 -21
  185. data/bundle/ruby/3.1.0/gems/tilt-2.4.0/lib/tilt/erubi.rb +55 -0
  186. data/bundle/ruby/{3.0.0/gems/tilt-2.0.11 → 3.1.0/gems/tilt-2.4.0}/lib/tilt/erubis.rb +19 -11
  187. data/bundle/ruby/{3.0.0/gems/tilt-2.0.11 → 3.1.0/gems/tilt-2.4.0}/lib/tilt/etanni.rb +5 -4
  188. data/bundle/ruby/3.1.0/gems/tilt-2.4.0/lib/tilt/haml.rb +94 -0
  189. data/bundle/ruby/3.1.0/gems/tilt-2.4.0/lib/tilt/kramdown.rb +13 -0
  190. data/bundle/ruby/{3.0.0/gems/tilt-2.0.11 → 3.1.0/gems/tilt-2.4.0}/lib/tilt/liquid.rb +10 -14
  191. data/bundle/ruby/3.1.0/gems/tilt-2.4.0/lib/tilt/livescript.rb +11 -0
  192. data/bundle/ruby/{3.0.0/gems/tilt-2.0.11 → 3.1.0/gems/tilt-2.4.0}/lib/tilt/mapping.rb +228 -109
  193. data/bundle/ruby/{3.0.0/gems/tilt-2.0.11 → 3.1.0/gems/tilt-2.4.0}/lib/tilt/markaby.rb +5 -7
  194. data/bundle/ruby/3.1.0/gems/tilt-2.4.0/lib/tilt/maruku.rb +10 -0
  195. data/bundle/ruby/{3.0.0/gems/tilt-2.0.11 → 3.1.0/gems/tilt-2.4.0}/lib/tilt/nokogiri.rb +11 -10
  196. data/bundle/ruby/3.1.0/gems/tilt-2.4.0/lib/tilt/pandoc.rb +39 -0
  197. data/bundle/ruby/3.1.0/gems/tilt-2.4.0/lib/tilt/pipeline.rb +19 -0
  198. data/bundle/ruby/3.1.0/gems/tilt-2.4.0/lib/tilt/plain.rb +5 -0
  199. data/bundle/ruby/3.1.0/gems/tilt-2.4.0/lib/tilt/prawn.rb +28 -0
  200. data/bundle/ruby/3.1.0/gems/tilt-2.4.0/lib/tilt/radius.rb +41 -0
  201. data/bundle/ruby/3.1.0/gems/tilt-2.4.0/lib/tilt/rdiscount.rb +23 -0
  202. data/bundle/ruby/3.1.0/gems/tilt-2.4.0/lib/tilt/rdoc.rb +19 -0
  203. data/bundle/ruby/3.1.0/gems/tilt-2.4.0/lib/tilt/redcarpet.rb +31 -0
  204. data/bundle/ruby/3.1.0/gems/tilt-2.4.0/lib/tilt/redcloth.rb +13 -0
  205. data/bundle/ruby/3.1.0/gems/tilt-2.4.0/lib/tilt/rst-pandoc.rb +10 -0
  206. data/bundle/ruby/3.1.0/gems/tilt-2.4.0/lib/tilt/sass.rb +78 -0
  207. data/bundle/ruby/3.1.0/gems/tilt-2.4.0/lib/tilt/slim.rb +5 -0
  208. data/bundle/ruby/{3.0.0/gems/tilt-2.0.11 → 3.1.0/gems/tilt-2.4.0}/lib/tilt/string.rb +9 -3
  209. data/bundle/ruby/{3.0.0/gems/tilt-2.0.11 → 3.1.0/gems/tilt-2.4.0}/lib/tilt/template.rb +229 -82
  210. data/bundle/ruby/3.1.0/gems/tilt-2.4.0/lib/tilt/typescript.rb +19 -0
  211. data/bundle/ruby/3.1.0/gems/tilt-2.4.0/lib/tilt/wikicloth.rb +12 -0
  212. data/bundle/ruby/{3.0.0/gems/tilt-2.0.11 → 3.1.0/gems/tilt-2.4.0}/lib/tilt/yajl.rb +5 -11
  213. data/bundle/ruby/{3.0.0/gems/tilt-2.0.11 → 3.1.0/gems/tilt-2.4.0}/lib/tilt.rb +60 -40
  214. data/lib/brakeman/app_tree.rb +20 -5
  215. data/lib/brakeman/checks/check_eol_ruby.rb +1 -0
  216. data/lib/brakeman/checks/check_render.rb +6 -1
  217. data/lib/brakeman/checks/check_session_settings.rb +2 -3
  218. data/lib/brakeman/checks/check_unscoped_find.rb +1 -1
  219. data/lib/brakeman/file_parser.rb +34 -2
  220. data/lib/brakeman/options.rb +34 -4
  221. data/lib/brakeman/parsers/erubis_patch.rb +11 -0
  222. data/lib/brakeman/parsers/rails2_erubis.rb +3 -0
  223. data/lib/brakeman/parsers/rails2_xss_plugin_erubis.rb +4 -0
  224. data/lib/brakeman/parsers/rails3_erubis.rb +5 -1
  225. data/lib/brakeman/parsers/slim_embedded.rb +2 -0
  226. data/lib/brakeman/processors/alias_processor.rb +41 -15
  227. data/lib/brakeman/report/pager.rb +1 -1
  228. data/lib/brakeman/report/report_markdown.rb +1 -1
  229. data/lib/brakeman/report/report_table.rb +2 -2
  230. data/lib/brakeman/report/report_tabs.rb +0 -1
  231. data/lib/brakeman/report/report_text.rb +8 -1
  232. data/lib/brakeman/scanner.rb +2 -2
  233. data/lib/brakeman/tracker/config.rb +9 -1
  234. data/lib/brakeman/util.rb +1 -3
  235. data/lib/brakeman/version.rb +1 -1
  236. data/lib/brakeman/warning.rb +1 -1
  237. data/lib/brakeman.rb +4 -3
  238. data/lib/ruby_parser/bm_sexp.rb +5 -1
  239. metadata +422 -403
  240. data/bundle/ruby/3.0.0/gems/parallel-1.24.0/lib/parallel/version.rb +0 -4
  241. data/bundle/ruby/3.0.0/gems/rexml-3.2.6/lib/rexml/parsers/baseparser.rb +0 -694
  242. data/bundle/ruby/3.0.0/gems/safe_yaml-1.0.5/CHANGES.md +0 -154
  243. data/bundle/ruby/3.0.0/gems/safe_yaml-1.0.5/Gemfile +0 -11
  244. data/bundle/ruby/3.0.0/gems/safe_yaml-1.0.5/LICENSE.txt +0 -22
  245. data/bundle/ruby/3.0.0/gems/safe_yaml-1.0.5/README.md +0 -191
  246. data/bundle/ruby/3.0.0/gems/safe_yaml-1.0.5/bundle_install_all_ruby_versions.sh +0 -11
  247. data/bundle/ruby/3.0.0/gems/safe_yaml-1.0.5/lib/safe_yaml/deep.rb +0 -34
  248. data/bundle/ruby/3.0.0/gems/safe_yaml-1.0.5/lib/safe_yaml/libyaml_checker.rb +0 -36
  249. data/bundle/ruby/3.0.0/gems/safe_yaml-1.0.5/lib/safe_yaml/load.rb +0 -181
  250. data/bundle/ruby/3.0.0/gems/safe_yaml-1.0.5/lib/safe_yaml/parse/date.rb +0 -37
  251. data/bundle/ruby/3.0.0/gems/safe_yaml-1.0.5/lib/safe_yaml/parse/hexadecimal.rb +0 -12
  252. data/bundle/ruby/3.0.0/gems/safe_yaml-1.0.5/lib/safe_yaml/parse/sexagesimal.rb +0 -26
  253. data/bundle/ruby/3.0.0/gems/safe_yaml-1.0.5/lib/safe_yaml/psych_handler.rb +0 -99
  254. data/bundle/ruby/3.0.0/gems/safe_yaml-1.0.5/lib/safe_yaml/psych_resolver.rb +0 -52
  255. data/bundle/ruby/3.0.0/gems/safe_yaml-1.0.5/lib/safe_yaml/resolver.rb +0 -94
  256. data/bundle/ruby/3.0.0/gems/safe_yaml-1.0.5/lib/safe_yaml/safe_to_ruby_visitor.rb +0 -29
  257. data/bundle/ruby/3.0.0/gems/safe_yaml-1.0.5/lib/safe_yaml/store.rb +0 -39
  258. data/bundle/ruby/3.0.0/gems/safe_yaml-1.0.5/lib/safe_yaml/syck_hack.rb +0 -36
  259. data/bundle/ruby/3.0.0/gems/safe_yaml-1.0.5/lib/safe_yaml/syck_node_monkeypatch.rb +0 -43
  260. data/bundle/ruby/3.0.0/gems/safe_yaml-1.0.5/lib/safe_yaml/syck_resolver.rb +0 -38
  261. data/bundle/ruby/3.0.0/gems/safe_yaml-1.0.5/lib/safe_yaml/transform/to_boolean.rb +0 -21
  262. data/bundle/ruby/3.0.0/gems/safe_yaml-1.0.5/lib/safe_yaml/transform/to_date.rb +0 -13
  263. data/bundle/ruby/3.0.0/gems/safe_yaml-1.0.5/lib/safe_yaml/transform/to_float.rb +0 -33
  264. data/bundle/ruby/3.0.0/gems/safe_yaml-1.0.5/lib/safe_yaml/transform/to_integer.rb +0 -26
  265. data/bundle/ruby/3.0.0/gems/safe_yaml-1.0.5/lib/safe_yaml/transform/to_nil.rb +0 -18
  266. data/bundle/ruby/3.0.0/gems/safe_yaml-1.0.5/lib/safe_yaml/transform/to_symbol.rb +0 -17
  267. data/bundle/ruby/3.0.0/gems/safe_yaml-1.0.5/lib/safe_yaml/transform/transformation_map.rb +0 -47
  268. data/bundle/ruby/3.0.0/gems/safe_yaml-1.0.5/lib/safe_yaml/transform.rb +0 -41
  269. data/bundle/ruby/3.0.0/gems/safe_yaml-1.0.5/lib/safe_yaml/version.rb +0 -3
  270. data/bundle/ruby/3.0.0/gems/safe_yaml-1.0.5/lib/safe_yaml.rb +0 -94
  271. data/bundle/ruby/3.0.0/gems/safe_yaml-1.0.5/run_specs_all_ruby_versions.sh +0 -38
  272. data/bundle/ruby/3.0.0/gems/safe_yaml-1.0.5/safe_yaml.gemspec +0 -19
  273. data/bundle/ruby/3.0.0/gems/slim-4.1.0/Gemfile +0 -70
  274. data/bundle/ruby/3.0.0/gems/slim-4.1.0/lib/slim/template.rb +0 -19
  275. data/bundle/ruby/3.0.0/gems/temple-0.8.2/Gemfile +0 -3
  276. data/bundle/ruby/3.0.0/gems/temple-0.8.2/lib/temple/version.rb +0 -3
  277. data/bundle/ruby/3.0.0/gems/tilt-2.0.11/lib/tilt/asciidoc.rb +0 -27
  278. data/bundle/ruby/3.0.0/gems/tilt-2.0.11/lib/tilt/babel.rb +0 -16
  279. data/bundle/ruby/3.0.0/gems/tilt-2.0.11/lib/tilt/bluecloth.rb +0 -24
  280. data/bundle/ruby/3.0.0/gems/tilt-2.0.11/lib/tilt/builder.rb +0 -37
  281. data/bundle/ruby/3.0.0/gems/tilt-2.0.11/lib/tilt/coffee.rb +0 -58
  282. data/bundle/ruby/3.0.0/gems/tilt-2.0.11/lib/tilt/commonmarker.rb +0 -88
  283. data/bundle/ruby/3.0.0/gems/tilt-2.0.11/lib/tilt/creole.rb +0 -25
  284. data/bundle/ruby/3.0.0/gems/tilt-2.0.11/lib/tilt/dummy.rb +0 -3
  285. data/bundle/ruby/3.0.0/gems/tilt-2.0.11/lib/tilt/erubi.rb +0 -32
  286. data/bundle/ruby/3.0.0/gems/tilt-2.0.11/lib/tilt/haml.rb +0 -86
  287. data/bundle/ruby/3.0.0/gems/tilt-2.0.11/lib/tilt/kramdown.rb +0 -25
  288. data/bundle/ruby/3.0.0/gems/tilt-2.0.11/lib/tilt/less.rb +0 -30
  289. data/bundle/ruby/3.0.0/gems/tilt-2.0.11/lib/tilt/livescript.rb +0 -23
  290. data/bundle/ruby/3.0.0/gems/tilt-2.0.11/lib/tilt/maruku.rb +0 -22
  291. data/bundle/ruby/3.0.0/gems/tilt-2.0.11/lib/tilt/pandoc.rb +0 -57
  292. data/bundle/ruby/3.0.0/gems/tilt-2.0.11/lib/tilt/plain.rb +0 -16
  293. data/bundle/ruby/3.0.0/gems/tilt-2.0.11/lib/tilt/prawn.rb +0 -43
  294. data/bundle/ruby/3.0.0/gems/tilt-2.0.11/lib/tilt/radius.rb +0 -48
  295. data/bundle/ruby/3.0.0/gems/tilt-2.0.11/lib/tilt/rdiscount.rb +0 -39
  296. data/bundle/ruby/3.0.0/gems/tilt-2.0.11/lib/tilt/rdoc.rb +0 -40
  297. data/bundle/ruby/3.0.0/gems/tilt-2.0.11/lib/tilt/redcarpet.rb +0 -86
  298. data/bundle/ruby/3.0.0/gems/tilt-2.0.11/lib/tilt/redcloth.rb +0 -23
  299. data/bundle/ruby/3.0.0/gems/tilt-2.0.11/lib/tilt/rst-pandoc.rb +0 -23
  300. data/bundle/ruby/3.0.0/gems/tilt-2.0.11/lib/tilt/sass.rb +0 -78
  301. data/bundle/ruby/3.0.0/gems/tilt-2.0.11/lib/tilt/sigil.rb +0 -34
  302. data/bundle/ruby/3.0.0/gems/tilt-2.0.11/lib/tilt/typescript.rb +0 -26
  303. data/bundle/ruby/3.0.0/gems/tilt-2.0.11/lib/tilt/wikicloth.rb +0 -22
  304. /data/bundle/ruby/{3.0.0 → 3.1.0}/gems/erubis-2.7.0/CHANGES.txt +0 -0
  305. /data/bundle/ruby/{3.0.0 → 3.1.0}/gems/erubis-2.7.0/MIT-LICENSE +0 -0
  306. /data/bundle/ruby/{3.0.0 → 3.1.0}/gems/erubis-2.7.0/README.txt +0 -0
  307. /data/bundle/ruby/{3.0.0 → 3.1.0}/gems/erubis-2.7.0/contrib/erubis +0 -0
  308. /data/bundle/ruby/{3.0.0 → 3.1.0}/gems/erubis-2.7.0/contrib/erubis-run.rb +0 -0
  309. /data/bundle/ruby/{3.0.0 → 3.1.0}/gems/erubis-2.7.0/contrib/inline-require +0 -0
  310. /data/bundle/ruby/{3.0.0 → 3.1.0}/gems/erubis-2.7.0/lib/erubis/context.rb +0 -0
  311. /data/bundle/ruby/{3.0.0 → 3.1.0}/gems/erubis-2.7.0/lib/erubis/converter.rb +0 -0
  312. /data/bundle/ruby/{3.0.0 → 3.1.0}/gems/erubis-2.7.0/lib/erubis/engine/ec.rb +0 -0
  313. /data/bundle/ruby/{3.0.0 → 3.1.0}/gems/erubis-2.7.0/lib/erubis/engine/ecpp.rb +0 -0
  314. /data/bundle/ruby/{3.0.0 → 3.1.0}/gems/erubis-2.7.0/lib/erubis/engine/ejava.rb +0 -0
  315. /data/bundle/ruby/{3.0.0 → 3.1.0}/gems/erubis-2.7.0/lib/erubis/engine/ejavascript.rb +0 -0
  316. /data/bundle/ruby/{3.0.0 → 3.1.0}/gems/erubis-2.7.0/lib/erubis/engine/enhanced.rb +0 -0
  317. /data/bundle/ruby/{3.0.0 → 3.1.0}/gems/erubis-2.7.0/lib/erubis/engine/eperl.rb +0 -0
  318. /data/bundle/ruby/{3.0.0 → 3.1.0}/gems/erubis-2.7.0/lib/erubis/engine/ephp.rb +0 -0
  319. /data/bundle/ruby/{3.0.0 → 3.1.0}/gems/erubis-2.7.0/lib/erubis/engine/eruby.rb +0 -0
  320. /data/bundle/ruby/{3.0.0 → 3.1.0}/gems/erubis-2.7.0/lib/erubis/engine/escheme.rb +0 -0
  321. /data/bundle/ruby/{3.0.0 → 3.1.0}/gems/erubis-2.7.0/lib/erubis/engine/optimized.rb +0 -0
  322. /data/bundle/ruby/{3.0.0 → 3.1.0}/gems/erubis-2.7.0/lib/erubis/engine.rb +0 -0
  323. /data/bundle/ruby/{3.0.0 → 3.1.0}/gems/erubis-2.7.0/lib/erubis/enhancer.rb +0 -0
  324. /data/bundle/ruby/{3.0.0 → 3.1.0}/gems/erubis-2.7.0/lib/erubis/error.rb +0 -0
  325. /data/bundle/ruby/{3.0.0 → 3.1.0}/gems/erubis-2.7.0/lib/erubis/evaluator.rb +0 -0
  326. /data/bundle/ruby/{3.0.0 → 3.1.0}/gems/erubis-2.7.0/lib/erubis/generator.rb +0 -0
  327. /data/bundle/ruby/{3.0.0 → 3.1.0}/gems/erubis-2.7.0/lib/erubis/helper.rb +0 -0
  328. /data/bundle/ruby/{3.0.0 → 3.1.0}/gems/erubis-2.7.0/lib/erubis/helpers/rails_form_helper.rb +0 -0
  329. /data/bundle/ruby/{3.0.0 → 3.1.0}/gems/erubis-2.7.0/lib/erubis/helpers/rails_helper.rb +0 -0
  330. /data/bundle/ruby/{3.0.0 → 3.1.0}/gems/erubis-2.7.0/lib/erubis/local-setting.rb +0 -0
  331. /data/bundle/ruby/{3.0.0 → 3.1.0}/gems/erubis-2.7.0/lib/erubis/main.rb +0 -0
  332. /data/bundle/ruby/{3.0.0 → 3.1.0}/gems/erubis-2.7.0/lib/erubis/preprocessing.rb +0 -0
  333. /data/bundle/ruby/{3.0.0 → 3.1.0}/gems/erubis-2.7.0/lib/erubis/tiny.rb +0 -0
  334. /data/bundle/ruby/{3.0.0 → 3.1.0}/gems/erubis-2.7.0/lib/erubis/util.rb +0 -0
  335. /data/bundle/ruby/{3.0.0 → 3.1.0}/gems/erubis-2.7.0/lib/erubis.rb +0 -0
  336. /data/bundle/ruby/{3.0.0 → 3.1.0}/gems/erubis-2.7.0/setup.rb +0 -0
  337. /data/bundle/ruby/{3.0.0 → 3.1.0}/gems/haml-5.2.2/CHANGELOG.md +0 -0
  338. /data/bundle/ruby/{3.0.0 → 3.1.0}/gems/haml-5.2.2/FAQ.md +0 -0
  339. /data/bundle/ruby/{3.0.0 → 3.1.0}/gems/haml-5.2.2/Gemfile +0 -0
  340. /data/bundle/ruby/{3.0.0 → 3.1.0}/gems/haml-5.2.2/MIT-LICENSE +0 -0
  341. /data/bundle/ruby/{3.0.0 → 3.1.0}/gems/haml-5.2.2/README.md +0 -0
  342. /data/bundle/ruby/{3.0.0 → 3.1.0}/gems/haml-5.2.2/REFERENCE.md +0 -0
  343. /data/bundle/ruby/{3.0.0 → 3.1.0}/gems/haml-5.2.2/TODO +0 -0
  344. /data/bundle/ruby/{3.0.0 → 3.1.0}/gems/haml-5.2.2/haml.gemspec +0 -0
  345. /data/bundle/ruby/{3.0.0 → 3.1.0}/gems/haml-5.2.2/lib/haml/attribute_builder.rb +0 -0
  346. /data/bundle/ruby/{3.0.0 → 3.1.0}/gems/haml-5.2.2/lib/haml/attribute_compiler.rb +0 -0
  347. /data/bundle/ruby/{3.0.0 → 3.1.0}/gems/haml-5.2.2/lib/haml/attribute_parser.rb +0 -0
  348. /data/bundle/ruby/{3.0.0 → 3.1.0}/gems/haml-5.2.2/lib/haml/buffer.rb +0 -0
  349. /data/bundle/ruby/{3.0.0 → 3.1.0}/gems/haml-5.2.2/lib/haml/compiler.rb +0 -0
  350. /data/bundle/ruby/{3.0.0 → 3.1.0}/gems/haml-5.2.2/lib/haml/engine.rb +0 -0
  351. /data/bundle/ruby/{3.0.0 → 3.1.0}/gems/haml-5.2.2/lib/haml/error.rb +0 -0
  352. /data/bundle/ruby/{3.0.0 → 3.1.0}/gems/haml-5.2.2/lib/haml/escapable.rb +0 -0
  353. /data/bundle/ruby/{3.0.0 → 3.1.0}/gems/haml-5.2.2/lib/haml/exec.rb +0 -0
  354. /data/bundle/ruby/{3.0.0 → 3.1.0}/gems/haml-5.2.2/lib/haml/filters.rb +0 -0
  355. /data/bundle/ruby/{3.0.0 → 3.1.0}/gems/haml-5.2.2/lib/haml/generator.rb +0 -0
  356. /data/bundle/ruby/{3.0.0 → 3.1.0}/gems/haml-5.2.2/lib/haml/helpers/action_view_extensions.rb +0 -0
  357. /data/bundle/ruby/{3.0.0 → 3.1.0}/gems/haml-5.2.2/lib/haml/helpers/action_view_mods.rb +0 -0
  358. /data/bundle/ruby/{3.0.0 → 3.1.0}/gems/haml-5.2.2/lib/haml/helpers/action_view_xss_mods.rb +0 -0
  359. /data/bundle/ruby/{3.0.0 → 3.1.0}/gems/haml-5.2.2/lib/haml/helpers/safe_erubi_template.rb +0 -0
  360. /data/bundle/ruby/{3.0.0 → 3.1.0}/gems/haml-5.2.2/lib/haml/helpers/safe_erubis_template.rb +0 -0
  361. /data/bundle/ruby/{3.0.0 → 3.1.0}/gems/haml-5.2.2/lib/haml/helpers/xss_mods.rb +0 -0
  362. /data/bundle/ruby/{3.0.0 → 3.1.0}/gems/haml-5.2.2/lib/haml/helpers.rb +0 -0
  363. /data/bundle/ruby/{3.0.0 → 3.1.0}/gems/haml-5.2.2/lib/haml/options.rb +0 -0
  364. /data/bundle/ruby/{3.0.0 → 3.1.0}/gems/haml-5.2.2/lib/haml/parser.rb +0 -0
  365. /data/bundle/ruby/{3.0.0 → 3.1.0}/gems/haml-5.2.2/lib/haml/plugin.rb +0 -0
  366. /data/bundle/ruby/{3.0.0 → 3.1.0}/gems/haml-5.2.2/lib/haml/railtie.rb +0 -0
  367. /data/bundle/ruby/{3.0.0 → 3.1.0}/gems/haml-5.2.2/lib/haml/sass_rails_filter.rb +0 -0
  368. /data/bundle/ruby/{3.0.0 → 3.1.0}/gems/haml-5.2.2/lib/haml/template/options.rb +0 -0
  369. /data/bundle/ruby/{3.0.0 → 3.1.0}/gems/haml-5.2.2/lib/haml/template.rb +0 -0
  370. /data/bundle/ruby/{3.0.0 → 3.1.0}/gems/haml-5.2.2/lib/haml/temple_engine.rb +0 -0
  371. /data/bundle/ruby/{3.0.0 → 3.1.0}/gems/haml-5.2.2/lib/haml/temple_line_counter.rb +0 -0
  372. /data/bundle/ruby/{3.0.0 → 3.1.0}/gems/haml-5.2.2/lib/haml/util.rb +0 -0
  373. /data/bundle/ruby/{3.0.0 → 3.1.0}/gems/haml-5.2.2/lib/haml/version.rb +0 -0
  374. /data/bundle/ruby/{3.0.0 → 3.1.0}/gems/haml-5.2.2/lib/haml.rb +0 -0
  375. /data/bundle/ruby/{3.0.0 → 3.1.0}/gems/haml-5.2.2/yard/default/fulldoc/html/css/common.sass +0 -0
  376. /data/bundle/ruby/{3.0.0 → 3.1.0}/gems/haml-5.2.2/yard/default/layout/html/footer.erb +0 -0
  377. /data/bundle/ruby/{3.0.0/gems/highline-2.1.0 → 3.1.0/gems/highline-3.1.0}/AUTHORS +0 -0
  378. /data/bundle/ruby/{3.0.0/gems/highline-2.1.0 → 3.1.0/gems/highline-3.1.0}/COPYING +0 -0
  379. /data/bundle/ruby/{3.0.0/gems/highline-2.1.0 → 3.1.0/gems/highline-3.1.0}/Gemfile +0 -0
  380. /data/bundle/ruby/{3.0.0/gems/highline-2.1.0 → 3.1.0/gems/highline-3.1.0}/LICENSE +0 -0
  381. /data/bundle/ruby/{3.0.0/gems/highline-2.1.0 → 3.1.0/gems/highline-3.1.0}/TODO +0 -0
  382. /data/bundle/ruby/{3.0.0/gems/highline-2.1.0 → 3.1.0/gems/highline-3.1.0}/lib/highline/builtin_styles.rb +0 -0
  383. /data/bundle/ruby/{3.0.0/gems/highline-2.1.0 → 3.1.0/gems/highline-3.1.0}/lib/highline/color_scheme.rb +0 -0
  384. /data/bundle/ruby/{3.0.0/gems/highline-2.1.0 → 3.1.0/gems/highline-3.1.0}/lib/highline/compatibility.rb +0 -0
  385. /data/bundle/ruby/{3.0.0/gems/highline-2.1.0 → 3.1.0/gems/highline-3.1.0}/lib/highline/custom_errors.rb +0 -0
  386. /data/bundle/ruby/{3.0.0/gems/highline-2.1.0 → 3.1.0/gems/highline-3.1.0}/lib/highline/import.rb +0 -0
  387. /data/bundle/ruby/{3.0.0/gems/highline-2.1.0 → 3.1.0/gems/highline-3.1.0}/lib/highline/list.rb +0 -0
  388. /data/bundle/ruby/{3.0.0/gems/highline-2.1.0 → 3.1.0/gems/highline-3.1.0}/lib/highline/list_renderer.rb +0 -0
  389. /data/bundle/ruby/{3.0.0/gems/highline-2.1.0 → 3.1.0/gems/highline-3.1.0}/lib/highline/menu/item.rb +0 -0
  390. /data/bundle/ruby/{3.0.0/gems/highline-2.1.0 → 3.1.0/gems/highline-3.1.0}/lib/highline/menu.rb +0 -0
  391. /data/bundle/ruby/{3.0.0/gems/highline-2.1.0 → 3.1.0/gems/highline-3.1.0}/lib/highline/paginator.rb +0 -0
  392. /data/bundle/ruby/{3.0.0/gems/highline-2.1.0 → 3.1.0/gems/highline-3.1.0}/lib/highline/simulate.rb +0 -0
  393. /data/bundle/ruby/{3.0.0/gems/highline-2.1.0 → 3.1.0/gems/highline-3.1.0}/lib/highline/statement.rb +0 -0
  394. /data/bundle/ruby/{3.0.0/gems/highline-2.1.0 → 3.1.0/gems/highline-3.1.0}/lib/highline/string.rb +0 -0
  395. /data/bundle/ruby/{3.0.0/gems/highline-2.1.0 → 3.1.0/gems/highline-3.1.0}/lib/highline/string_extensions.rb +0 -0
  396. /data/bundle/ruby/{3.0.0/gems/highline-2.1.0 → 3.1.0/gems/highline-3.1.0}/lib/highline/style.rb +0 -0
  397. /data/bundle/ruby/{3.0.0/gems/highline-2.1.0 → 3.1.0/gems/highline-3.1.0}/lib/highline/template_renderer.rb +0 -0
  398. /data/bundle/ruby/{3.0.0/gems/highline-2.1.0 → 3.1.0/gems/highline-3.1.0}/lib/highline/terminal/ncurses.rb +0 -0
  399. /data/bundle/ruby/{3.0.0/gems/highline-2.1.0 → 3.1.0/gems/highline-3.1.0}/lib/highline/wrapper.rb +0 -0
  400. /data/bundle/ruby/{3.0.0/gems/rexml-3.2.6 → 3.1.0/gems/io-console-0.7.2}/LICENSE.txt +0 -0
  401. /data/bundle/ruby/{3.0.0/gems/parallel-1.24.0 → 3.1.0/gems/parallel-1.26.3}/MIT-LICENSE.txt +0 -0
  402. /data/bundle/ruby/{3.0.0/gems/rexml-3.2.6 → 3.1.0/gems/rexml-3.3.6}/README.md +0 -0
  403. /data/bundle/ruby/{3.0.0/gems/rexml-3.2.6 → 3.1.0/gems/rexml-3.3.6}/lib/rexml/attlistdecl.rb +0 -0
  404. /data/bundle/ruby/{3.0.0/gems/rexml-3.2.6 → 3.1.0/gems/rexml-3.3.6}/lib/rexml/attribute.rb +0 -0
  405. /data/bundle/ruby/{3.0.0/gems/rexml-3.2.6 → 3.1.0/gems/rexml-3.3.6}/lib/rexml/cdata.rb +0 -0
  406. /data/bundle/ruby/{3.0.0/gems/rexml-3.2.6 → 3.1.0/gems/rexml-3.3.6}/lib/rexml/child.rb +0 -0
  407. /data/bundle/ruby/{3.0.0/gems/rexml-3.2.6 → 3.1.0/gems/rexml-3.3.6}/lib/rexml/comment.rb +0 -0
  408. /data/bundle/ruby/{3.0.0/gems/rexml-3.2.6 → 3.1.0/gems/rexml-3.3.6}/lib/rexml/doctype.rb +0 -0
  409. /data/bundle/ruby/{3.0.0/gems/rexml-3.2.6 → 3.1.0/gems/rexml-3.3.6}/lib/rexml/document.rb +0 -0
  410. /data/bundle/ruby/{3.0.0/gems/rexml-3.2.6 → 3.1.0/gems/rexml-3.3.6}/lib/rexml/dtd/attlistdecl.rb +0 -0
  411. /data/bundle/ruby/{3.0.0/gems/rexml-3.2.6 → 3.1.0/gems/rexml-3.3.6}/lib/rexml/dtd/dtd.rb +0 -0
  412. /data/bundle/ruby/{3.0.0/gems/rexml-3.2.6 → 3.1.0/gems/rexml-3.3.6}/lib/rexml/dtd/elementdecl.rb +0 -0
  413. /data/bundle/ruby/{3.0.0/gems/rexml-3.2.6 → 3.1.0/gems/rexml-3.3.6}/lib/rexml/dtd/entitydecl.rb +0 -0
  414. /data/bundle/ruby/{3.0.0/gems/rexml-3.2.6 → 3.1.0/gems/rexml-3.3.6}/lib/rexml/dtd/notationdecl.rb +0 -0
  415. /data/bundle/ruby/{3.0.0/gems/rexml-3.2.6 → 3.1.0/gems/rexml-3.3.6}/lib/rexml/encoding.rb +0 -0
  416. /data/bundle/ruby/{3.0.0/gems/rexml-3.2.6 → 3.1.0/gems/rexml-3.3.6}/lib/rexml/formatters/default.rb +0 -0
  417. /data/bundle/ruby/{3.0.0/gems/rexml-3.2.6 → 3.1.0/gems/rexml-3.3.6}/lib/rexml/formatters/transitive.rb +0 -0
  418. /data/bundle/ruby/{3.0.0/gems/rexml-3.2.6 → 3.1.0/gems/rexml-3.3.6}/lib/rexml/instruction.rb +0 -0
  419. /data/bundle/ruby/{3.0.0/gems/rexml-3.2.6 → 3.1.0/gems/rexml-3.3.6}/lib/rexml/light/node.rb +0 -0
  420. /data/bundle/ruby/{3.0.0/gems/rexml-3.2.6 → 3.1.0/gems/rexml-3.3.6}/lib/rexml/namespace.rb +0 -0
  421. /data/bundle/ruby/{3.0.0/gems/rexml-3.2.6 → 3.1.0/gems/rexml-3.3.6}/lib/rexml/output.rb +0 -0
  422. /data/bundle/ruby/{3.0.0/gems/rexml-3.2.6 → 3.1.0/gems/rexml-3.3.6}/lib/rexml/parent.rb +0 -0
  423. /data/bundle/ruby/{3.0.0/gems/rexml-3.2.6 → 3.1.0/gems/rexml-3.3.6}/lib/rexml/parsers/lightparser.rb +0 -0
  424. /data/bundle/ruby/{3.0.0/gems/rexml-3.2.6 → 3.1.0/gems/rexml-3.3.6}/lib/rexml/parsers/ultralightparser.rb +0 -0
  425. /data/bundle/ruby/{3.0.0/gems/rexml-3.2.6 → 3.1.0/gems/rexml-3.3.6}/lib/rexml/parsers/xpathparser.rb +0 -0
  426. /data/bundle/ruby/{3.0.0/gems/rexml-3.2.6 → 3.1.0/gems/rexml-3.3.6}/lib/rexml/quickpath.rb +0 -0
  427. /data/bundle/ruby/{3.0.0/gems/rexml-3.2.6 → 3.1.0/gems/rexml-3.3.6}/lib/rexml/sax2listener.rb +0 -0
  428. /data/bundle/ruby/{3.0.0/gems/rexml-3.2.6 → 3.1.0/gems/rexml-3.3.6}/lib/rexml/security.rb +0 -0
  429. /data/bundle/ruby/{3.0.0/gems/rexml-3.2.6 → 3.1.0/gems/rexml-3.3.6}/lib/rexml/streamlistener.rb +0 -0
  430. /data/bundle/ruby/{3.0.0/gems/rexml-3.2.6 → 3.1.0/gems/rexml-3.3.6}/lib/rexml/undefinednamespaceexception.rb +0 -0
  431. /data/bundle/ruby/{3.0.0/gems/rexml-3.2.6 → 3.1.0/gems/rexml-3.3.6}/lib/rexml/validation/relaxng.rb +0 -0
  432. /data/bundle/ruby/{3.0.0/gems/rexml-3.2.6 → 3.1.0/gems/rexml-3.3.6}/lib/rexml/validation/validation.rb +0 -0
  433. /data/bundle/ruby/{3.0.0/gems/rexml-3.2.6 → 3.1.0/gems/rexml-3.3.6}/lib/rexml/validation/validationexception.rb +0 -0
  434. /data/bundle/ruby/{3.0.0/gems/rexml-3.2.6 → 3.1.0/gems/rexml-3.3.6}/lib/rexml/xmldecl.rb +0 -0
  435. /data/bundle/ruby/{3.0.0/gems/rexml-3.2.6 → 3.1.0/gems/rexml-3.3.6}/lib/rexml/xmltokens.rb +0 -0
  436. /data/bundle/ruby/{3.0.0/gems/rexml-3.2.6 → 3.1.0/gems/rexml-3.3.6}/lib/rexml/xpath.rb +0 -0
  437. /data/bundle/ruby/{3.0.0/gems/rexml-3.2.6 → 3.1.0/gems/rexml-3.3.6}/lib/rexml.rb +0 -0
  438. /data/bundle/ruby/{3.0.0/gems/ruby2ruby-2.4.4 → 3.1.0/gems/ruby2ruby-2.5.1}/Manifest.txt +0 -0
  439. /data/bundle/ruby/{3.0.0/gems/ruby2ruby-2.4.4 → 3.1.0/gems/ruby2ruby-2.5.1}/README.rdoc +0 -0
  440. /data/bundle/ruby/{3.0.0 → 3.1.0}/gems/ruby_parser-3.20.3/History.rdoc +0 -0
  441. /data/bundle/ruby/{3.0.0 → 3.1.0}/gems/ruby_parser-3.20.3/Manifest.txt +0 -0
  442. /data/bundle/ruby/{3.0.0 → 3.1.0}/gems/ruby_parser-3.20.3/README.rdoc +0 -0
  443. /data/bundle/ruby/{3.0.0 → 3.1.0}/gems/ruby_parser-3.20.3/compare/normalize.rb +0 -0
  444. /data/bundle/ruby/{3.0.0 → 3.1.0}/gems/ruby_parser-3.20.3/debugging.md +0 -0
  445. /data/bundle/ruby/{3.0.0 → 3.1.0}/gems/ruby_parser-3.20.3/gauntlet.md +0 -0
  446. /data/bundle/ruby/{3.0.0 → 3.1.0}/gems/ruby_parser-3.20.3/lib/rp_extensions.rb +0 -0
  447. /data/bundle/ruby/{3.0.0 → 3.1.0}/gems/ruby_parser-3.20.3/lib/rp_stringscanner.rb +0 -0
  448. /data/bundle/ruby/{3.0.0 → 3.1.0}/gems/ruby_parser-3.20.3/lib/ruby20_parser.rb +0 -0
  449. /data/bundle/ruby/{3.0.0 → 3.1.0}/gems/ruby_parser-3.20.3/lib/ruby20_parser.y +0 -0
  450. /data/bundle/ruby/{3.0.0 → 3.1.0}/gems/ruby_parser-3.20.3/lib/ruby21_parser.rb +0 -0
  451. /data/bundle/ruby/{3.0.0 → 3.1.0}/gems/ruby_parser-3.20.3/lib/ruby21_parser.y +0 -0
  452. /data/bundle/ruby/{3.0.0 → 3.1.0}/gems/ruby_parser-3.20.3/lib/ruby22_parser.rb +0 -0
  453. /data/bundle/ruby/{3.0.0 → 3.1.0}/gems/ruby_parser-3.20.3/lib/ruby22_parser.y +0 -0
  454. /data/bundle/ruby/{3.0.0 → 3.1.0}/gems/ruby_parser-3.20.3/lib/ruby23_parser.rb +0 -0
  455. /data/bundle/ruby/{3.0.0 → 3.1.0}/gems/ruby_parser-3.20.3/lib/ruby23_parser.y +0 -0
  456. /data/bundle/ruby/{3.0.0 → 3.1.0}/gems/ruby_parser-3.20.3/lib/ruby24_parser.rb +0 -0
  457. /data/bundle/ruby/{3.0.0 → 3.1.0}/gems/ruby_parser-3.20.3/lib/ruby24_parser.y +0 -0
  458. /data/bundle/ruby/{3.0.0 → 3.1.0}/gems/ruby_parser-3.20.3/lib/ruby25_parser.rb +0 -0
  459. /data/bundle/ruby/{3.0.0 → 3.1.0}/gems/ruby_parser-3.20.3/lib/ruby25_parser.y +0 -0
  460. /data/bundle/ruby/{3.0.0 → 3.1.0}/gems/ruby_parser-3.20.3/lib/ruby26_parser.rb +0 -0
  461. /data/bundle/ruby/{3.0.0 → 3.1.0}/gems/ruby_parser-3.20.3/lib/ruby26_parser.y +0 -0
  462. /data/bundle/ruby/{3.0.0 → 3.1.0}/gems/ruby_parser-3.20.3/lib/ruby27_parser.rb +0 -0
  463. /data/bundle/ruby/{3.0.0 → 3.1.0}/gems/ruby_parser-3.20.3/lib/ruby27_parser.y +0 -0
  464. /data/bundle/ruby/{3.0.0 → 3.1.0}/gems/ruby_parser-3.20.3/lib/ruby30_parser.rb +0 -0
  465. /data/bundle/ruby/{3.0.0 → 3.1.0}/gems/ruby_parser-3.20.3/lib/ruby30_parser.y +0 -0
  466. /data/bundle/ruby/{3.0.0 → 3.1.0}/gems/ruby_parser-3.20.3/lib/ruby31_parser.rb +0 -0
  467. /data/bundle/ruby/{3.0.0 → 3.1.0}/gems/ruby_parser-3.20.3/lib/ruby31_parser.y +0 -0
  468. /data/bundle/ruby/{3.0.0 → 3.1.0}/gems/ruby_parser-3.20.3/lib/ruby32_parser.rb +0 -0
  469. /data/bundle/ruby/{3.0.0 → 3.1.0}/gems/ruby_parser-3.20.3/lib/ruby32_parser.y +0 -0
  470. /data/bundle/ruby/{3.0.0 → 3.1.0}/gems/ruby_parser-3.20.3/lib/ruby3_parser.yy +0 -0
  471. /data/bundle/ruby/{3.0.0 → 3.1.0}/gems/ruby_parser-3.20.3/lib/ruby_lexer.rb +0 -0
  472. /data/bundle/ruby/{3.0.0 → 3.1.0}/gems/ruby_parser-3.20.3/lib/ruby_lexer.rex +0 -0
  473. /data/bundle/ruby/{3.0.0 → 3.1.0}/gems/ruby_parser-3.20.3/lib/ruby_lexer.rex.rb +0 -0
  474. /data/bundle/ruby/{3.0.0 → 3.1.0}/gems/ruby_parser-3.20.3/lib/ruby_lexer_strings.rb +0 -0
  475. /data/bundle/ruby/{3.0.0 → 3.1.0}/gems/ruby_parser-3.20.3/lib/ruby_parser.rb +0 -0
  476. /data/bundle/ruby/{3.0.0 → 3.1.0}/gems/ruby_parser-3.20.3/lib/ruby_parser.yy +0 -0
  477. /data/bundle/ruby/{3.0.0 → 3.1.0}/gems/ruby_parser-3.20.3/lib/ruby_parser_extras.rb +0 -0
  478. /data/bundle/ruby/{3.0.0 → 3.1.0}/gems/ruby_parser-3.20.3/tools/munge.rb +0 -0
  479. /data/bundle/ruby/{3.0.0 → 3.1.0}/gems/ruby_parser-3.20.3/tools/ripper.rb +0 -0
  480. /data/bundle/ruby/{3.0.0/gems/sexp_processor-4.17.0 → 3.1.0/gems/sexp_processor-4.17.2}/Manifest.txt +0 -0
  481. /data/bundle/ruby/{3.0.0/gems/sexp_processor-4.17.0 → 3.1.0/gems/sexp_processor-4.17.2}/README.rdoc +0 -0
  482. /data/bundle/ruby/{3.0.0/gems/sexp_processor-4.17.0 → 3.1.0/gems/sexp_processor-4.17.2}/lib/composite_sexp_processor.rb +0 -0
  483. /data/bundle/ruby/{3.0.0/gems/sexp_processor-4.17.0 → 3.1.0/gems/sexp_processor-4.17.2}/lib/sexp.rb +0 -0
  484. /data/bundle/ruby/{3.0.0/gems/sexp_processor-4.17.0 → 3.1.0/gems/sexp_processor-4.17.2}/lib/strict_sexp.rb +0 -0
  485. /data/bundle/ruby/{3.0.0/gems/sexp_processor-4.17.0 → 3.1.0/gems/sexp_processor-4.17.2}/lib/unique.rb +0 -0
  486. /data/bundle/ruby/{3.0.0/gems/temple-0.8.2 → 3.1.0/gems/temple-0.10.3}/EXPRESSIONS.md +0 -0
  487. /data/bundle/ruby/{3.0.0/gems/temple-0.8.2 → 3.1.0/gems/temple-0.10.3}/LICENSE +0 -0
  488. /data/bundle/ruby/{3.0.0 → 3.1.0}/gems/terminal-table-1.8.0/Gemfile +0 -0
  489. /data/bundle/ruby/{3.0.0 → 3.1.0}/gems/terminal-table-1.8.0/History.rdoc +0 -0
  490. /data/bundle/ruby/{3.0.0 → 3.1.0}/gems/terminal-table-1.8.0/LICENSE.txt +0 -0
  491. /data/bundle/ruby/{3.0.0 → 3.1.0}/gems/terminal-table-1.8.0/Manifest +0 -0
  492. /data/bundle/ruby/{3.0.0 → 3.1.0}/gems/terminal-table-1.8.0/README.rdoc +0 -0
  493. /data/bundle/ruby/{3.0.0 → 3.1.0}/gems/terminal-table-1.8.0/Todo.rdoc +0 -0
  494. /data/bundle/ruby/{3.0.0 → 3.1.0}/gems/terminal-table-1.8.0/lib/terminal-table/cell.rb +0 -0
  495. /data/bundle/ruby/{3.0.0 → 3.1.0}/gems/terminal-table-1.8.0/lib/terminal-table/import.rb +0 -0
  496. /data/bundle/ruby/{3.0.0 → 3.1.0}/gems/terminal-table-1.8.0/lib/terminal-table/row.rb +0 -0
  497. /data/bundle/ruby/{3.0.0 → 3.1.0}/gems/terminal-table-1.8.0/lib/terminal-table/separator.rb +0 -0
  498. /data/bundle/ruby/{3.0.0 → 3.1.0}/gems/terminal-table-1.8.0/lib/terminal-table/style.rb +0 -0
  499. /data/bundle/ruby/{3.0.0 → 3.1.0}/gems/terminal-table-1.8.0/lib/terminal-table/table.rb +0 -0
  500. /data/bundle/ruby/{3.0.0 → 3.1.0}/gems/terminal-table-1.8.0/lib/terminal-table/table_helper.rb +0 -0
  501. /data/bundle/ruby/{3.0.0 → 3.1.0}/gems/terminal-table-1.8.0/lib/terminal-table/version.rb +0 -0
  502. /data/bundle/ruby/{3.0.0 → 3.1.0}/gems/terminal-table-1.8.0/lib/terminal-table.rb +0 -0
  503. /data/bundle/ruby/{3.0.0 → 3.1.0}/gems/terminal-table-1.8.0/terminal-table.gemspec +0 -0
  504. /data/bundle/ruby/{3.0.0 → 3.1.0}/gems/unicode-display_width-1.8.0/CHANGELOG.md +0 -0
  505. /data/bundle/ruby/{3.0.0 → 3.1.0}/gems/unicode-display_width-1.8.0/MIT-LICENSE.txt +0 -0
  506. /data/bundle/ruby/{3.0.0 → 3.1.0}/gems/unicode-display_width-1.8.0/README.md +0 -0
  507. /data/bundle/ruby/{3.0.0 → 3.1.0}/gems/unicode-display_width-1.8.0/data/display_width.marshal.gz +0 -0
  508. /data/bundle/ruby/{3.0.0 → 3.1.0}/gems/unicode-display_width-1.8.0/lib/unicode/display_width/constants.rb +0 -0
  509. /data/bundle/ruby/{3.0.0 → 3.1.0}/gems/unicode-display_width-1.8.0/lib/unicode/display_width/index.rb +0 -0
  510. /data/bundle/ruby/{3.0.0 → 3.1.0}/gems/unicode-display_width-1.8.0/lib/unicode/display_width/no_string_ext.rb +0 -0
  511. /data/bundle/ruby/{3.0.0 → 3.1.0}/gems/unicode-display_width-1.8.0/lib/unicode/display_width/string_ext.rb +0 -0
  512. /data/bundle/ruby/{3.0.0 → 3.1.0}/gems/unicode-display_width-1.8.0/lib/unicode/display_width.rb +0 -0
@@ -0,0 +1,2557 @@
1
+ require 'reline/kill_ring'
2
+ require 'reline/unicode'
3
+
4
+ require 'tempfile'
5
+
6
+ class Reline::LineEditor
7
+ # TODO: Use "private alias_method" idiom after drop Ruby 2.5.
8
+ attr_reader :byte_pointer
9
+ attr_accessor :confirm_multiline_termination_proc
10
+ attr_accessor :completion_proc
11
+ attr_accessor :completion_append_character
12
+ attr_accessor :output_modifier_proc
13
+ attr_accessor :prompt_proc
14
+ attr_accessor :auto_indent_proc
15
+ attr_accessor :dig_perfect_match_proc
16
+ attr_writer :output
17
+
18
+ VI_MOTIONS = %i{
19
+ ed_prev_char
20
+ ed_next_char
21
+ vi_zero
22
+ ed_move_to_beg
23
+ ed_move_to_end
24
+ vi_to_column
25
+ vi_next_char
26
+ vi_prev_char
27
+ vi_next_word
28
+ vi_prev_word
29
+ vi_to_next_char
30
+ vi_to_prev_char
31
+ vi_end_word
32
+ vi_next_big_word
33
+ vi_prev_big_word
34
+ vi_end_big_word
35
+ }
36
+
37
+ module CompletionState
38
+ NORMAL = :normal
39
+ COMPLETION = :completion
40
+ MENU = :menu
41
+ MENU_WITH_PERFECT_MATCH = :menu_with_perfect_match
42
+ PERFECT_MATCH = :perfect_match
43
+ end
44
+
45
+ RenderedScreen = Struct.new(:base_y, :lines, :cursor_y, keyword_init: true)
46
+
47
+ CompletionJourneyState = Struct.new(:line_index, :pre, :target, :post, :list, :pointer)
48
+ NullActionState = [nil, nil].freeze
49
+
50
+ class MenuInfo
51
+ attr_reader :list
52
+
53
+ def initialize(list)
54
+ @list = list
55
+ end
56
+
57
+ def lines(screen_width)
58
+ return [] if @list.empty?
59
+
60
+ list = @list.sort
61
+ sizes = list.map { |item| Reline::Unicode.calculate_width(item) }
62
+ item_width = sizes.max + 2
63
+ num_cols = [screen_width / item_width, 1].max
64
+ num_rows = list.size.fdiv(num_cols).ceil
65
+ list_with_padding = list.zip(sizes).map { |item, size| item + ' ' * (item_width - size) }
66
+ aligned = (list_with_padding + [nil] * (num_rows * num_cols - list_with_padding.size)).each_slice(num_rows).to_a.transpose
67
+ aligned.map do |row|
68
+ row.join.rstrip
69
+ end
70
+ end
71
+ end
72
+
73
+ MINIMUM_SCROLLBAR_HEIGHT = 1
74
+
75
+ def initialize(config, encoding)
76
+ @config = config
77
+ @completion_append_character = ''
78
+ @screen_size = [0, 0] # Should be initialized with actual winsize in LineEditor#reset
79
+ reset_variables(encoding: encoding)
80
+ end
81
+
82
+ def io_gate
83
+ Reline::IOGate
84
+ end
85
+
86
+ def set_pasting_state(in_pasting)
87
+ # While pasting, text to be inserted is stored to @continuous_insertion_buffer.
88
+ # After pasting, this buffer should be force inserted.
89
+ process_insert(force: true) if @in_pasting && !in_pasting
90
+ @in_pasting = in_pasting
91
+ end
92
+
93
+ private def check_mode_string
94
+ if @config.show_mode_in_prompt
95
+ if @config.editing_mode_is?(:vi_command)
96
+ @config.vi_cmd_mode_string
97
+ elsif @config.editing_mode_is?(:vi_insert)
98
+ @config.vi_ins_mode_string
99
+ elsif @config.editing_mode_is?(:emacs)
100
+ @config.emacs_mode_string
101
+ else
102
+ '?'
103
+ end
104
+ end
105
+ end
106
+
107
+ private def check_multiline_prompt(buffer, mode_string)
108
+ if @vi_arg
109
+ prompt = "(arg: #{@vi_arg}) "
110
+ elsif @searching_prompt
111
+ prompt = @searching_prompt
112
+ else
113
+ prompt = @prompt
114
+ end
115
+ if !@is_multiline
116
+ mode_string = check_mode_string
117
+ prompt = mode_string + prompt if mode_string
118
+ [prompt] + [''] * (buffer.size - 1)
119
+ elsif @prompt_proc
120
+ prompt_list = @prompt_proc.(buffer).map { |pr| pr.gsub("\n", "\\n") }
121
+ prompt_list.map!{ prompt } if @vi_arg or @searching_prompt
122
+ prompt_list = [prompt] if prompt_list.empty?
123
+ prompt_list = prompt_list.map{ |pr| mode_string + pr } if mode_string
124
+ prompt = prompt_list[@line_index]
125
+ prompt = prompt_list[0] if prompt.nil?
126
+ prompt = prompt_list.last if prompt.nil?
127
+ if buffer.size > prompt_list.size
128
+ (buffer.size - prompt_list.size).times do
129
+ prompt_list << prompt_list.last
130
+ end
131
+ end
132
+ prompt_list
133
+ else
134
+ prompt = mode_string + prompt if mode_string
135
+ [prompt] * buffer.size
136
+ end
137
+ end
138
+
139
+ def reset(prompt = '', encoding:)
140
+ @screen_size = Reline::IOGate.get_screen_size
141
+ reset_variables(prompt, encoding: encoding)
142
+ @rendered_screen.base_y = Reline::IOGate.cursor_pos.y
143
+ if ENV.key?('RELINE_ALT_SCROLLBAR')
144
+ @full_block = '::'
145
+ @upper_half_block = "''"
146
+ @lower_half_block = '..'
147
+ @block_elem_width = 2
148
+ elsif Reline::IOGate.win?
149
+ @full_block = '█'
150
+ @upper_half_block = '▀'
151
+ @lower_half_block = '▄'
152
+ @block_elem_width = 1
153
+ elsif @encoding == Encoding::UTF_8
154
+ @full_block = '█'
155
+ @upper_half_block = '▀'
156
+ @lower_half_block = '▄'
157
+ @block_elem_width = Reline::Unicode.calculate_width('█')
158
+ else
159
+ @full_block = '::'
160
+ @upper_half_block = "''"
161
+ @lower_half_block = '..'
162
+ @block_elem_width = 2
163
+ end
164
+ end
165
+
166
+ def handle_signal
167
+ handle_interrupted
168
+ handle_resized
169
+ end
170
+
171
+ private def handle_resized
172
+ return unless @resized
173
+
174
+ @screen_size = Reline::IOGate.get_screen_size
175
+ @resized = false
176
+ scroll_into_view
177
+ Reline::IOGate.move_cursor_up @rendered_screen.cursor_y
178
+ @rendered_screen.base_y = Reline::IOGate.cursor_pos.y
179
+ @rendered_screen.lines = []
180
+ @rendered_screen.cursor_y = 0
181
+ render_differential
182
+ end
183
+
184
+ private def handle_interrupted
185
+ return unless @interrupted
186
+
187
+ @interrupted = false
188
+ clear_dialogs
189
+ scrolldown = render_differential
190
+ Reline::IOGate.scroll_down scrolldown
191
+ Reline::IOGate.move_cursor_column 0
192
+ @rendered_screen.lines = []
193
+ @rendered_screen.cursor_y = 0
194
+ case @old_trap
195
+ when 'DEFAULT', 'SYSTEM_DEFAULT'
196
+ raise Interrupt
197
+ when 'IGNORE'
198
+ # Do nothing
199
+ when 'EXIT'
200
+ exit
201
+ else
202
+ @old_trap.call if @old_trap.respond_to?(:call)
203
+ end
204
+ end
205
+
206
+ def set_signal_handlers
207
+ Reline::IOGate.set_winch_handler do
208
+ @resized = true
209
+ end
210
+ @old_trap = Signal.trap('INT') do
211
+ @interrupted = true
212
+ end
213
+ end
214
+
215
+ def finalize
216
+ Signal.trap('INT', @old_trap)
217
+ end
218
+
219
+ def eof?
220
+ @eof
221
+ end
222
+
223
+ def reset_variables(prompt = '', encoding:)
224
+ @prompt = prompt.gsub("\n", "\\n")
225
+ @mark_pointer = nil
226
+ @encoding = encoding
227
+ @is_multiline = false
228
+ @finished = false
229
+ @history_pointer = nil
230
+ @kill_ring ||= Reline::KillRing.new
231
+ @vi_clipboard = ''
232
+ @vi_arg = nil
233
+ @waiting_proc = nil
234
+ @vi_waiting_operator = nil
235
+ @vi_waiting_operator_arg = nil
236
+ @completion_journey_state = nil
237
+ @completion_state = CompletionState::NORMAL
238
+ @perfect_matched = nil
239
+ @menu_info = nil
240
+ @searching_prompt = nil
241
+ @just_cursor_moving = false
242
+ @eof = false
243
+ @continuous_insertion_buffer = String.new(encoding: @encoding)
244
+ @scroll_partial_screen = 0
245
+ @drop_terminate_spaces = false
246
+ @in_pasting = false
247
+ @auto_indent_proc = nil
248
+ @dialogs = []
249
+ @interrupted = false
250
+ @resized = false
251
+ @cache = {}
252
+ @rendered_screen = RenderedScreen.new(base_y: 0, lines: [], cursor_y: 0)
253
+ @input_lines = [[[""], 0, 0]]
254
+ @input_lines_position = 0
255
+ @undoing = false
256
+ @prev_action_state = NullActionState
257
+ @next_action_state = NullActionState
258
+ reset_line
259
+ end
260
+
261
+ def reset_line
262
+ @byte_pointer = 0
263
+ @buffer_of_lines = [String.new(encoding: @encoding)]
264
+ @line_index = 0
265
+ @cache.clear
266
+ @line_backup_in_history = nil
267
+ @multibyte_buffer = String.new(encoding: 'ASCII-8BIT')
268
+ end
269
+
270
+ def multiline_on
271
+ @is_multiline = true
272
+ end
273
+
274
+ def multiline_off
275
+ @is_multiline = false
276
+ end
277
+
278
+ private def insert_new_line(cursor_line, next_line)
279
+ @buffer_of_lines.insert(@line_index + 1, String.new(next_line, encoding: @encoding))
280
+ @buffer_of_lines[@line_index] = cursor_line
281
+ @line_index += 1
282
+ @byte_pointer = 0
283
+ if @auto_indent_proc && !@in_pasting
284
+ if next_line.empty?
285
+ (
286
+ # For compatibility, use this calculation instead of just `process_auto_indent @line_index - 1, cursor_dependent: false`
287
+ indent1 = @auto_indent_proc.(@buffer_of_lines.take(@line_index - 1).push(''), @line_index - 1, 0, true)
288
+ indent2 = @auto_indent_proc.(@buffer_of_lines.take(@line_index), @line_index - 1, @buffer_of_lines[@line_index - 1].bytesize, false)
289
+ indent = indent2 || indent1
290
+ @buffer_of_lines[@line_index - 1] = ' ' * indent + @buffer_of_lines[@line_index - 1].gsub(/\A\s*/, '')
291
+ )
292
+ process_auto_indent @line_index, add_newline: true
293
+ else
294
+ process_auto_indent @line_index - 1, cursor_dependent: false
295
+ process_auto_indent @line_index, add_newline: true # Need for compatibility
296
+ process_auto_indent @line_index, cursor_dependent: false
297
+ end
298
+ end
299
+ end
300
+
301
+ private def split_by_width(str, max_width, offset: 0)
302
+ Reline::Unicode.split_by_width(str, max_width, @encoding, offset: offset)
303
+ end
304
+
305
+ def current_byte_pointer_cursor
306
+ calculate_width(current_line.byteslice(0, @byte_pointer))
307
+ end
308
+
309
+ private def calculate_nearest_cursor(cursor)
310
+ line_to_calc = current_line
311
+ new_cursor_max = calculate_width(line_to_calc)
312
+ new_cursor = 0
313
+ new_byte_pointer = 0
314
+ height = 1
315
+ max_width = screen_width
316
+ if @config.editing_mode_is?(:vi_command)
317
+ last_byte_size = Reline::Unicode.get_prev_mbchar_size(line_to_calc, line_to_calc.bytesize)
318
+ if last_byte_size > 0
319
+ last_mbchar = line_to_calc.byteslice(line_to_calc.bytesize - last_byte_size, last_byte_size)
320
+ last_width = Reline::Unicode.get_mbchar_width(last_mbchar)
321
+ end_of_line_cursor = new_cursor_max - last_width
322
+ else
323
+ end_of_line_cursor = new_cursor_max
324
+ end
325
+ else
326
+ end_of_line_cursor = new_cursor_max
327
+ end
328
+ line_to_calc.grapheme_clusters.each do |gc|
329
+ mbchar = gc.encode(Encoding::UTF_8)
330
+ mbchar_width = Reline::Unicode.get_mbchar_width(mbchar)
331
+ now = new_cursor + mbchar_width
332
+ if now > end_of_line_cursor or now > cursor
333
+ break
334
+ end
335
+ new_cursor += mbchar_width
336
+ if new_cursor > max_width * height
337
+ height += 1
338
+ end
339
+ new_byte_pointer += gc.bytesize
340
+ end
341
+ @byte_pointer = new_byte_pointer
342
+ end
343
+
344
+ def with_cache(key, *deps)
345
+ cached_deps, value = @cache[key]
346
+ if cached_deps != deps
347
+ @cache[key] = [deps, value = yield(*deps, cached_deps, value)]
348
+ end
349
+ value
350
+ end
351
+
352
+ def modified_lines
353
+ with_cache(__method__, whole_lines, finished?) do |whole, complete|
354
+ modify_lines(whole, complete)
355
+ end
356
+ end
357
+
358
+ def prompt_list
359
+ with_cache(__method__, whole_lines, check_mode_string, @vi_arg, @searching_prompt) do |lines, mode_string|
360
+ check_multiline_prompt(lines, mode_string)
361
+ end
362
+ end
363
+
364
+ def screen_height
365
+ @screen_size.first
366
+ end
367
+
368
+ def screen_width
369
+ @screen_size.last
370
+ end
371
+
372
+ def screen_scroll_top
373
+ @scroll_partial_screen
374
+ end
375
+
376
+ def wrapped_prompt_and_input_lines
377
+ with_cache(__method__, @buffer_of_lines.size, modified_lines, prompt_list, screen_width) do |n, lines, prompts, width, prev_cache_key, cached_value|
378
+ prev_n, prev_lines, prev_prompts, prev_width = prev_cache_key
379
+ cached_wraps = {}
380
+ if prev_width == width
381
+ prev_n.times do |i|
382
+ cached_wraps[[prev_prompts[i], prev_lines[i]]] = cached_value[i]
383
+ end
384
+ end
385
+
386
+ n.times.map do |i|
387
+ prompt = prompts[i] || ''
388
+ line = lines[i] || ''
389
+ if (cached = cached_wraps[[prompt, line]])
390
+ next cached
391
+ end
392
+ *wrapped_prompts, code_line_prompt = split_by_width(prompt, width).first.compact
393
+ wrapped_lines = split_by_width(line, width, offset: calculate_width(code_line_prompt, true)).first.compact
394
+ wrapped_prompts.map { |p| [p, ''] } + [[code_line_prompt, wrapped_lines.first]] + wrapped_lines.drop(1).map { |c| ['', c] }
395
+ end
396
+ end
397
+ end
398
+
399
+ def calculate_overlay_levels(overlay_levels)
400
+ levels = []
401
+ overlay_levels.each do |x, w, l|
402
+ levels.fill(l, x, w)
403
+ end
404
+ levels
405
+ end
406
+
407
+ def render_line_differential(old_items, new_items)
408
+ old_levels = calculate_overlay_levels(old_items.zip(new_items).each_with_index.map {|((x, w, c), (nx, _nw, nc)), i| [x, w, c == nc && x == nx ? i : -1] if x }.compact)
409
+ new_levels = calculate_overlay_levels(new_items.each_with_index.map { |(x, w), i| [x, w, i] if x }.compact).take(screen_width)
410
+ base_x = 0
411
+ new_levels.zip(old_levels).chunk { |n, o| n == o ? :skip : n || :blank }.each do |level, chunk|
412
+ width = chunk.size
413
+ if level == :skip
414
+ # do nothing
415
+ elsif level == :blank
416
+ Reline::IOGate.move_cursor_column base_x
417
+ @output.write "#{Reline::IOGate.reset_color_sequence}#{' ' * width}"
418
+ else
419
+ x, w, content = new_items[level]
420
+ cover_begin = base_x != 0 && new_levels[base_x - 1] == level
421
+ cover_end = new_levels[base_x + width] == level
422
+ pos = 0
423
+ unless x == base_x && w == width
424
+ content, pos = Reline::Unicode.take_mbchar_range(content, base_x - x, width, cover_begin: cover_begin, cover_end: cover_end, padding: true)
425
+ end
426
+ Reline::IOGate.move_cursor_column x + pos
427
+ @output.write "#{Reline::IOGate.reset_color_sequence}#{content}#{Reline::IOGate.reset_color_sequence}"
428
+ end
429
+ base_x += width
430
+ end
431
+ if old_levels.size > new_levels.size
432
+ Reline::IOGate.move_cursor_column new_levels.size
433
+ Reline::IOGate.erase_after_cursor
434
+ end
435
+ end
436
+
437
+ # Calculate cursor position in word wrapped content.
438
+ def wrapped_cursor_position
439
+ prompt_width = calculate_width(prompt_list[@line_index], true)
440
+ line_before_cursor = whole_lines[@line_index].byteslice(0, @byte_pointer)
441
+ wrapped_line_before_cursor = split_by_width(' ' * prompt_width + line_before_cursor, screen_width).first.compact
442
+ wrapped_cursor_y = wrapped_prompt_and_input_lines[0...@line_index].sum(&:size) + wrapped_line_before_cursor.size - 1
443
+ wrapped_cursor_x = calculate_width(wrapped_line_before_cursor.last)
444
+ [wrapped_cursor_x, wrapped_cursor_y]
445
+ end
446
+
447
+ def clear_dialogs
448
+ @dialogs.each do |dialog|
449
+ dialog.contents = nil
450
+ dialog.trap_key = nil
451
+ end
452
+ end
453
+
454
+ def update_dialogs(key = nil)
455
+ wrapped_cursor_x, wrapped_cursor_y = wrapped_cursor_position
456
+ @dialogs.each do |dialog|
457
+ dialog.trap_key = nil
458
+ update_each_dialog(dialog, wrapped_cursor_x, wrapped_cursor_y - screen_scroll_top, key)
459
+ end
460
+ end
461
+
462
+ def render_finished
463
+ clear_rendered_lines
464
+ render_full_content
465
+ end
466
+
467
+ def clear_rendered_lines
468
+ Reline::IOGate.move_cursor_up @rendered_screen.cursor_y
469
+ Reline::IOGate.move_cursor_column 0
470
+
471
+ num_lines = @rendered_screen.lines.size
472
+ return unless num_lines && num_lines >= 1
473
+
474
+ Reline::IOGate.move_cursor_down num_lines - 1
475
+ (num_lines - 1).times do
476
+ Reline::IOGate.erase_after_cursor
477
+ Reline::IOGate.move_cursor_up 1
478
+ end
479
+ Reline::IOGate.erase_after_cursor
480
+ @rendered_screen.lines = []
481
+ @rendered_screen.cursor_y = 0
482
+ end
483
+
484
+ def render_full_content
485
+ lines = @buffer_of_lines.size.times.map do |i|
486
+ line = prompt_list[i] + modified_lines[i]
487
+ wrapped_lines, = split_by_width(line, screen_width)
488
+ wrapped_lines.last.empty? ? "#{line} " : line
489
+ end
490
+ @output.puts lines.map { |l| "#{l}\r\n" }.join
491
+ end
492
+
493
+ def print_nomultiline_prompt(prompt)
494
+ return unless prompt && !@is_multiline
495
+
496
+ # Readline's test `TestRelineAsReadline#test_readline` requires first output to be prompt, not cursor reset escape sequence.
497
+ @rendered_screen.lines = [[[0, Reline::Unicode.calculate_width(prompt, true), prompt]]]
498
+ @rendered_screen.cursor_y = 0
499
+ @output.write prompt
500
+ end
501
+
502
+ def render_differential
503
+ wrapped_cursor_x, wrapped_cursor_y = wrapped_cursor_position
504
+
505
+ rendered_lines = @rendered_screen.lines
506
+ new_lines = wrapped_prompt_and_input_lines.flatten(1)[screen_scroll_top, screen_height].map do |prompt, line|
507
+ prompt_width = Reline::Unicode.calculate_width(prompt, true)
508
+ [[0, prompt_width, prompt], [prompt_width, Reline::Unicode.calculate_width(line, true), line]]
509
+ end
510
+ if @menu_info
511
+ @menu_info.lines(screen_width).each do |item|
512
+ new_lines << [[0, Reline::Unicode.calculate_width(item), item]]
513
+ end
514
+ @menu_info = nil # TODO: do not change state here
515
+ end
516
+
517
+ @dialogs.each_with_index do |dialog, index|
518
+ next unless dialog.contents
519
+
520
+ x_range, y_range = dialog_range dialog, wrapped_cursor_y - screen_scroll_top
521
+ y_range.each do |row|
522
+ next if row < 0 || row >= screen_height
523
+ dialog_rows = new_lines[row] ||= []
524
+ # index 0 is for prompt, index 1 is for line, index 2.. is for dialog
525
+ dialog_rows[index + 2] = [x_range.begin, dialog.width, dialog.contents[row - y_range.begin]]
526
+ end
527
+ end
528
+
529
+ cursor_y = @rendered_screen.cursor_y
530
+ if new_lines != rendered_lines
531
+ # Hide cursor while rendering to avoid cursor flickering.
532
+ Reline::IOGate.hide_cursor
533
+ num_lines = [[new_lines.size, rendered_lines.size].max, screen_height].min
534
+ if @rendered_screen.base_y + num_lines > screen_height
535
+ Reline::IOGate.scroll_down(num_lines - cursor_y - 1)
536
+ @rendered_screen.base_y = screen_height - num_lines
537
+ cursor_y = num_lines - 1
538
+ end
539
+ num_lines.times do |i|
540
+ rendered_line = rendered_lines[i] || []
541
+ line_to_render = new_lines[i] || []
542
+ next if rendered_line == line_to_render
543
+
544
+ Reline::IOGate.move_cursor_down i - cursor_y
545
+ cursor_y = i
546
+ unless rendered_lines[i]
547
+ Reline::IOGate.move_cursor_column 0
548
+ Reline::IOGate.erase_after_cursor
549
+ end
550
+ render_line_differential(rendered_line, line_to_render)
551
+ end
552
+ @rendered_screen.lines = new_lines
553
+ Reline::IOGate.show_cursor
554
+ end
555
+ y = wrapped_cursor_y - screen_scroll_top
556
+ Reline::IOGate.move_cursor_column wrapped_cursor_x
557
+ Reline::IOGate.move_cursor_down y - cursor_y
558
+ @rendered_screen.cursor_y = y
559
+ new_lines.size - y
560
+ end
561
+
562
+ def upper_space_height(wrapped_cursor_y)
563
+ wrapped_cursor_y - screen_scroll_top
564
+ end
565
+
566
+ def rest_height(wrapped_cursor_y)
567
+ screen_height - wrapped_cursor_y + screen_scroll_top - @rendered_screen.base_y - 1
568
+ end
569
+
570
+ def rerender
571
+ render_differential unless @in_pasting
572
+ end
573
+
574
+ class DialogProcScope
575
+ CompletionJourneyData = Struct.new(:preposing, :postposing, :list, :pointer)
576
+
577
+ def initialize(line_editor, config, proc_to_exec, context)
578
+ @line_editor = line_editor
579
+ @config = config
580
+ @proc_to_exec = proc_to_exec
581
+ @context = context
582
+ @cursor_pos = Reline::CursorPos.new
583
+ end
584
+
585
+ def context
586
+ @context
587
+ end
588
+
589
+ def retrieve_completion_block(set_completion_quote_character = false)
590
+ @line_editor.retrieve_completion_block(set_completion_quote_character)
591
+ end
592
+
593
+ def call_completion_proc_with_checking_args(pre, target, post)
594
+ @line_editor.call_completion_proc_with_checking_args(pre, target, post)
595
+ end
596
+
597
+ def set_dialog(dialog)
598
+ @dialog = dialog
599
+ end
600
+
601
+ def dialog
602
+ @dialog
603
+ end
604
+
605
+ def set_cursor_pos(col, row)
606
+ @cursor_pos.x = col
607
+ @cursor_pos.y = row
608
+ end
609
+
610
+ def set_key(key)
611
+ @key = key
612
+ end
613
+
614
+ def key
615
+ @key
616
+ end
617
+
618
+ def cursor_pos
619
+ @cursor_pos
620
+ end
621
+
622
+ def just_cursor_moving
623
+ @line_editor.instance_variable_get(:@just_cursor_moving)
624
+ end
625
+
626
+ def screen_width
627
+ @line_editor.screen_width
628
+ end
629
+
630
+ def screen_height
631
+ @line_editor.screen_height
632
+ end
633
+
634
+ def preferred_dialog_height
635
+ _wrapped_cursor_x, wrapped_cursor_y = @line_editor.wrapped_cursor_position
636
+ [@line_editor.upper_space_height(wrapped_cursor_y), @line_editor.rest_height(wrapped_cursor_y), (screen_height + 6) / 5].max
637
+ end
638
+
639
+ def completion_journey_data
640
+ @line_editor.dialog_proc_scope_completion_journey_data
641
+ end
642
+
643
+ def config
644
+ @config
645
+ end
646
+
647
+ def call
648
+ instance_exec(&@proc_to_exec)
649
+ end
650
+ end
651
+
652
+ class Dialog
653
+ attr_reader :name, :contents, :width
654
+ attr_accessor :scroll_top, :pointer, :column, :vertical_offset, :trap_key
655
+
656
+ def initialize(name, config, proc_scope)
657
+ @name = name
658
+ @config = config
659
+ @proc_scope = proc_scope
660
+ @width = nil
661
+ @scroll_top = 0
662
+ @trap_key = nil
663
+ end
664
+
665
+ def set_cursor_pos(col, row)
666
+ @proc_scope.set_cursor_pos(col, row)
667
+ end
668
+
669
+ def width=(v)
670
+ @width = v
671
+ end
672
+
673
+ def contents=(contents)
674
+ @contents = contents
675
+ if contents and @width.nil?
676
+ @width = contents.map{ |line| Reline::Unicode.calculate_width(line, true) }.max
677
+ end
678
+ end
679
+
680
+ def call(key)
681
+ @proc_scope.set_dialog(self)
682
+ @proc_scope.set_key(key)
683
+ dialog_render_info = @proc_scope.call
684
+ if @trap_key
685
+ if @trap_key.any?{ |i| i.is_a?(Array) } # multiple trap
686
+ @trap_key.each do |t|
687
+ @config.add_oneshot_key_binding(t, @name)
688
+ end
689
+ else
690
+ @config.add_oneshot_key_binding(@trap_key, @name)
691
+ end
692
+ end
693
+ dialog_render_info
694
+ end
695
+ end
696
+
697
+ def add_dialog_proc(name, p, context = nil)
698
+ dialog = Dialog.new(name, @config, DialogProcScope.new(self, @config, p, context))
699
+ if index = @dialogs.find_index { |d| d.name == name }
700
+ @dialogs[index] = dialog
701
+ else
702
+ @dialogs << dialog
703
+ end
704
+ end
705
+
706
+ DIALOG_DEFAULT_HEIGHT = 20
707
+
708
+ private def dialog_range(dialog, dialog_y)
709
+ x_range = dialog.column...dialog.column + dialog.width
710
+ y_range = dialog_y + dialog.vertical_offset...dialog_y + dialog.vertical_offset + dialog.contents.size
711
+ [x_range, y_range]
712
+ end
713
+
714
+ private def update_each_dialog(dialog, cursor_column, cursor_row, key = nil)
715
+ dialog.set_cursor_pos(cursor_column, cursor_row)
716
+ dialog_render_info = dialog.call(key)
717
+ if dialog_render_info.nil? or dialog_render_info.contents.nil? or dialog_render_info.contents.empty?
718
+ dialog.contents = nil
719
+ dialog.trap_key = nil
720
+ return
721
+ end
722
+ contents = dialog_render_info.contents
723
+ pointer = dialog.pointer
724
+ if dialog_render_info.width
725
+ dialog.width = dialog_render_info.width
726
+ else
727
+ dialog.width = contents.map { |l| calculate_width(l, true) }.max
728
+ end
729
+ height = dialog_render_info.height || DIALOG_DEFAULT_HEIGHT
730
+ height = contents.size if contents.size < height
731
+ if contents.size > height
732
+ if dialog.pointer
733
+ if dialog.pointer < 0
734
+ dialog.scroll_top = 0
735
+ elsif (dialog.pointer - dialog.scroll_top) >= (height - 1)
736
+ dialog.scroll_top = dialog.pointer - (height - 1)
737
+ elsif (dialog.pointer - dialog.scroll_top) < 0
738
+ dialog.scroll_top = dialog.pointer
739
+ end
740
+ pointer = dialog.pointer - dialog.scroll_top
741
+ else
742
+ dialog.scroll_top = 0
743
+ end
744
+ contents = contents[dialog.scroll_top, height]
745
+ end
746
+ if dialog_render_info.scrollbar and dialog_render_info.contents.size > height
747
+ bar_max_height = height * 2
748
+ moving_distance = (dialog_render_info.contents.size - height) * 2
749
+ position_ratio = dialog.scroll_top.zero? ? 0.0 : ((dialog.scroll_top * 2).to_f / moving_distance)
750
+ bar_height = (bar_max_height * ((contents.size * 2).to_f / (dialog_render_info.contents.size * 2))).floor.to_i
751
+ bar_height = MINIMUM_SCROLLBAR_HEIGHT if bar_height < MINIMUM_SCROLLBAR_HEIGHT
752
+ scrollbar_pos = ((bar_max_height - bar_height) * position_ratio).floor.to_i
753
+ else
754
+ scrollbar_pos = nil
755
+ end
756
+ dialog.column = dialog_render_info.pos.x
757
+ dialog.width += @block_elem_width if scrollbar_pos
758
+ diff = (dialog.column + dialog.width) - screen_width
759
+ if diff > 0
760
+ dialog.column -= diff
761
+ end
762
+ if rest_height(screen_scroll_top + cursor_row) - dialog_render_info.pos.y >= height
763
+ dialog.vertical_offset = dialog_render_info.pos.y + 1
764
+ elsif cursor_row >= height
765
+ dialog.vertical_offset = dialog_render_info.pos.y - height
766
+ else
767
+ dialog.vertical_offset = dialog_render_info.pos.y + 1
768
+ end
769
+ if dialog.column < 0
770
+ dialog.column = 0
771
+ dialog.width = screen_width
772
+ end
773
+ face = Reline::Face[dialog_render_info.face || :default]
774
+ scrollbar_sgr = face[:scrollbar]
775
+ default_sgr = face[:default]
776
+ enhanced_sgr = face[:enhanced]
777
+ dialog.contents = contents.map.with_index do |item, i|
778
+ line_sgr = i == pointer ? enhanced_sgr : default_sgr
779
+ str_width = dialog.width - (scrollbar_pos.nil? ? 0 : @block_elem_width)
780
+ str, = Reline::Unicode.take_mbchar_range(item, 0, str_width, padding: true)
781
+ colored_content = "#{line_sgr}#{str}"
782
+ if scrollbar_pos
783
+ if scrollbar_pos <= (i * 2) and (i * 2 + 1) < (scrollbar_pos + bar_height)
784
+ colored_content + scrollbar_sgr + @full_block
785
+ elsif scrollbar_pos <= (i * 2) and (i * 2) < (scrollbar_pos + bar_height)
786
+ colored_content + scrollbar_sgr + @upper_half_block
787
+ elsif scrollbar_pos <= (i * 2 + 1) and (i * 2) < (scrollbar_pos + bar_height)
788
+ colored_content + scrollbar_sgr + @lower_half_block
789
+ else
790
+ colored_content + scrollbar_sgr + ' ' * @block_elem_width
791
+ end
792
+ else
793
+ colored_content
794
+ end
795
+ end
796
+ end
797
+
798
+ private def modify_lines(before, complete)
799
+ if after = @output_modifier_proc&.call("#{before.join("\n")}\n", complete: complete)
800
+ after.lines("\n").map { |l| l.chomp('') }
801
+ else
802
+ before.map { |l| Reline::Unicode.escape_for_print(l) }
803
+ end
804
+ end
805
+
806
+ def editing_mode
807
+ @config.editing_mode
808
+ end
809
+
810
+ private def menu(_target, list)
811
+ @menu_info = MenuInfo.new(list)
812
+ end
813
+
814
+ private def complete_internal_proc(list, is_menu)
815
+ preposing, target, postposing = retrieve_completion_block
816
+ list = list.select { |i|
817
+ if i and not Encoding.compatible?(target.encoding, i.encoding)
818
+ raise Encoding::CompatibilityError, "#{target.encoding.name} is not compatible with #{i.encoding.name}"
819
+ end
820
+ if @config.completion_ignore_case
821
+ i&.downcase&.start_with?(target.downcase)
822
+ else
823
+ i&.start_with?(target)
824
+ end
825
+ }.uniq
826
+ if is_menu
827
+ menu(target, list)
828
+ return nil
829
+ end
830
+ completed = list.inject { |memo, item|
831
+ begin
832
+ memo_mbchars = memo.unicode_normalize.grapheme_clusters
833
+ item_mbchars = item.unicode_normalize.grapheme_clusters
834
+ rescue Encoding::CompatibilityError
835
+ memo_mbchars = memo.grapheme_clusters
836
+ item_mbchars = item.grapheme_clusters
837
+ end
838
+ size = [memo_mbchars.size, item_mbchars.size].min
839
+ result = +''
840
+ size.times do |i|
841
+ if @config.completion_ignore_case
842
+ if memo_mbchars[i].casecmp?(item_mbchars[i])
843
+ result << memo_mbchars[i]
844
+ else
845
+ break
846
+ end
847
+ else
848
+ if memo_mbchars[i] == item_mbchars[i]
849
+ result << memo_mbchars[i]
850
+ else
851
+ break
852
+ end
853
+ end
854
+ end
855
+ result
856
+ }
857
+ [target, preposing, completed, postposing]
858
+ end
859
+
860
+ private def perform_completion(list, just_show_list)
861
+ case @completion_state
862
+ when CompletionState::NORMAL
863
+ @completion_state = CompletionState::COMPLETION
864
+ when CompletionState::PERFECT_MATCH
865
+ @dig_perfect_match_proc&.(@perfect_matched)
866
+ end
867
+ if just_show_list
868
+ is_menu = true
869
+ elsif @completion_state == CompletionState::MENU
870
+ is_menu = true
871
+ elsif @completion_state == CompletionState::MENU_WITH_PERFECT_MATCH
872
+ is_menu = true
873
+ else
874
+ is_menu = false
875
+ end
876
+ result = complete_internal_proc(list, is_menu)
877
+ if @completion_state == CompletionState::MENU_WITH_PERFECT_MATCH
878
+ @completion_state = CompletionState::PERFECT_MATCH
879
+ end
880
+ return if result.nil?
881
+ target, preposing, completed, postposing = result
882
+ return if completed.nil?
883
+ if target <= completed and (@completion_state == CompletionState::COMPLETION)
884
+ if list.include?(completed)
885
+ if list.one?
886
+ @completion_state = CompletionState::PERFECT_MATCH
887
+ else
888
+ @completion_state = CompletionState::MENU_WITH_PERFECT_MATCH
889
+ perform_completion(list, true) if @config.show_all_if_ambiguous
890
+ end
891
+ @perfect_matched = completed
892
+ else
893
+ @completion_state = CompletionState::MENU
894
+ perform_completion(list, true) if @config.show_all_if_ambiguous
895
+ end
896
+ if not just_show_list and target < completed
897
+ @buffer_of_lines[@line_index] = (preposing + completed + completion_append_character.to_s + postposing).split("\n")[@line_index] || String.new(encoding: @encoding)
898
+ line_to_pointer = (preposing + completed + completion_append_character.to_s).split("\n")[@line_index] || String.new(encoding: @encoding)
899
+ @byte_pointer = line_to_pointer.bytesize
900
+ end
901
+ end
902
+ end
903
+
904
+ def dialog_proc_scope_completion_journey_data
905
+ return nil unless @completion_journey_state
906
+ line_index = @completion_journey_state.line_index
907
+ pre_lines = @buffer_of_lines[0...line_index].map { |line| line + "\n" }
908
+ post_lines = @buffer_of_lines[(line_index + 1)..-1].map { |line| line + "\n" }
909
+ DialogProcScope::CompletionJourneyData.new(
910
+ pre_lines.join + @completion_journey_state.pre,
911
+ @completion_journey_state.post + post_lines.join,
912
+ @completion_journey_state.list,
913
+ @completion_journey_state.pointer
914
+ )
915
+ end
916
+
917
+ private def move_completed_list(direction)
918
+ @completion_journey_state ||= retrieve_completion_journey_state
919
+ return false unless @completion_journey_state
920
+
921
+ if (delta = { up: -1, down: +1 }[direction])
922
+ @completion_journey_state.pointer = (@completion_journey_state.pointer + delta) % @completion_journey_state.list.size
923
+ end
924
+ completed = @completion_journey_state.list[@completion_journey_state.pointer]
925
+ set_current_line(@completion_journey_state.pre + completed + @completion_journey_state.post, @completion_journey_state.pre.bytesize + completed.bytesize)
926
+ true
927
+ end
928
+
929
+ private def retrieve_completion_journey_state
930
+ preposing, target, postposing = retrieve_completion_block
931
+ list = call_completion_proc
932
+ return unless list.is_a?(Array)
933
+
934
+ candidates = list.select{ |item| item.start_with?(target) }
935
+ return if candidates.empty?
936
+
937
+ pre = preposing.split("\n", -1).last || ''
938
+ post = postposing.split("\n", -1).first || ''
939
+ CompletionJourneyState.new(
940
+ @line_index, pre, target, post, [target] + candidates, 0
941
+ )
942
+ end
943
+
944
+ private def run_for_operators(key, method_symbol, &block)
945
+ if @vi_waiting_operator
946
+ if VI_MOTIONS.include?(method_symbol)
947
+ old_byte_pointer = @byte_pointer
948
+ @vi_arg = (@vi_arg || 1) * @vi_waiting_operator_arg
949
+ block.(true)
950
+ unless @waiting_proc
951
+ byte_pointer_diff = @byte_pointer - old_byte_pointer
952
+ @byte_pointer = old_byte_pointer
953
+ method_obj = method(@vi_waiting_operator)
954
+ wrap_method_call(@vi_waiting_operator, method_obj, byte_pointer_diff)
955
+ cleanup_waiting
956
+ end
957
+ else
958
+ # Ignores operator when not motion is given.
959
+ block.(false)
960
+ cleanup_waiting
961
+ end
962
+ @vi_arg = nil
963
+ else
964
+ block.(false)
965
+ end
966
+ end
967
+
968
+ private def argumentable?(method_obj)
969
+ method_obj and method_obj.parameters.any? { |param| param[0] == :key and param[1] == :arg }
970
+ end
971
+
972
+ private def inclusive?(method_obj)
973
+ # If a motion method with the keyword argument "inclusive" follows the
974
+ # operator, it must contain the character at the cursor position.
975
+ method_obj and method_obj.parameters.any? { |param| param[0] == :key and param[1] == :inclusive }
976
+ end
977
+
978
+ def wrap_method_call(method_symbol, method_obj, key, with_operator = false)
979
+ if @config.editing_mode_is?(:emacs, :vi_insert) and @vi_waiting_operator.nil?
980
+ not_insertion = method_symbol != :ed_insert
981
+ process_insert(force: not_insertion)
982
+ end
983
+ if @vi_arg and argumentable?(method_obj)
984
+ if with_operator and inclusive?(method_obj)
985
+ method_obj.(key, arg: @vi_arg, inclusive: true)
986
+ else
987
+ method_obj.(key, arg: @vi_arg)
988
+ end
989
+ else
990
+ if with_operator and inclusive?(method_obj)
991
+ method_obj.(key, inclusive: true)
992
+ else
993
+ method_obj.(key)
994
+ end
995
+ end
996
+ end
997
+
998
+ private def cleanup_waiting
999
+ @waiting_proc = nil
1000
+ @vi_waiting_operator = nil
1001
+ @vi_waiting_operator_arg = nil
1002
+ @searching_prompt = nil
1003
+ @drop_terminate_spaces = false
1004
+ end
1005
+
1006
+ private def process_key(key, method_symbol)
1007
+ if key.is_a?(Symbol)
1008
+ cleanup_waiting
1009
+ elsif @waiting_proc
1010
+ old_byte_pointer = @byte_pointer
1011
+ @waiting_proc.call(key)
1012
+ if @vi_waiting_operator
1013
+ byte_pointer_diff = @byte_pointer - old_byte_pointer
1014
+ @byte_pointer = old_byte_pointer
1015
+ method_obj = method(@vi_waiting_operator)
1016
+ wrap_method_call(@vi_waiting_operator, method_obj, byte_pointer_diff)
1017
+ cleanup_waiting
1018
+ end
1019
+ @kill_ring.process
1020
+ return
1021
+ end
1022
+
1023
+ if method_symbol and respond_to?(method_symbol, true)
1024
+ method_obj = method(method_symbol)
1025
+ end
1026
+ if method_symbol and key.is_a?(Symbol)
1027
+ if @vi_arg and argumentable?(method_obj)
1028
+ run_for_operators(key, method_symbol) do |with_operator|
1029
+ wrap_method_call(method_symbol, method_obj, key, with_operator)
1030
+ end
1031
+ else
1032
+ wrap_method_call(method_symbol, method_obj, key) if method_obj
1033
+ end
1034
+ @kill_ring.process
1035
+ if @vi_arg
1036
+ @vi_arg = nil
1037
+ end
1038
+ elsif @vi_arg
1039
+ if key.chr =~ /[0-9]/
1040
+ ed_argument_digit(key)
1041
+ else
1042
+ if argumentable?(method_obj)
1043
+ run_for_operators(key, method_symbol) do |with_operator|
1044
+ wrap_method_call(method_symbol, method_obj, key, with_operator)
1045
+ end
1046
+ elsif method_obj
1047
+ wrap_method_call(method_symbol, method_obj, key)
1048
+ else
1049
+ ed_insert(key) unless @config.editing_mode_is?(:vi_command)
1050
+ end
1051
+ @kill_ring.process
1052
+ if @vi_arg
1053
+ @vi_arg = nil
1054
+ end
1055
+ end
1056
+ elsif method_obj
1057
+ if method_symbol == :ed_argument_digit
1058
+ wrap_method_call(method_symbol, method_obj, key)
1059
+ else
1060
+ run_for_operators(key, method_symbol) do |with_operator|
1061
+ wrap_method_call(method_symbol, method_obj, key, with_operator)
1062
+ end
1063
+ end
1064
+ @kill_ring.process
1065
+ else
1066
+ ed_insert(key) unless @config.editing_mode_is?(:vi_command)
1067
+ end
1068
+ end
1069
+
1070
+ private def normal_char(key)
1071
+ @multibyte_buffer << key.combined_char
1072
+ if @multibyte_buffer.size > 1
1073
+ if @multibyte_buffer.dup.force_encoding(@encoding).valid_encoding?
1074
+ process_key(@multibyte_buffer.dup.force_encoding(@encoding), nil)
1075
+ @multibyte_buffer.clear
1076
+ else
1077
+ # invalid
1078
+ return
1079
+ end
1080
+ else # single byte
1081
+ return if key.char >= 128 # maybe, first byte of multi byte
1082
+ method_symbol = @config.editing_mode.get_method(key.combined_char)
1083
+ process_key(key.combined_char, method_symbol)
1084
+ @multibyte_buffer.clear
1085
+ end
1086
+ if @config.editing_mode_is?(:vi_command) and @byte_pointer > 0 and @byte_pointer == current_line.bytesize
1087
+ byte_size = Reline::Unicode.get_prev_mbchar_size(@buffer_of_lines[@line_index], @byte_pointer)
1088
+ @byte_pointer -= byte_size
1089
+ end
1090
+ end
1091
+
1092
+ def update(key)
1093
+ modified = input_key(key)
1094
+ unless @in_pasting
1095
+ scroll_into_view
1096
+ @just_cursor_moving = !modified
1097
+ update_dialogs(key)
1098
+ @just_cursor_moving = false
1099
+ end
1100
+ end
1101
+
1102
+ def input_key(key)
1103
+ save_old_buffer
1104
+ @config.reset_oneshot_key_bindings
1105
+ @dialogs.each do |dialog|
1106
+ if key.char.instance_of?(Symbol) and key.char == dialog.name
1107
+ return
1108
+ end
1109
+ end
1110
+ if key.char.nil?
1111
+ process_insert(force: true)
1112
+ @eof = buffer_empty?
1113
+ finish
1114
+ return
1115
+ end
1116
+ @completion_occurs = false
1117
+
1118
+ if key.char.is_a?(Symbol)
1119
+ process_key(key.char, key.char)
1120
+ else
1121
+ normal_char(key)
1122
+ end
1123
+
1124
+ @prev_action_state, @next_action_state = @next_action_state, NullActionState
1125
+
1126
+ unless @completion_occurs
1127
+ @completion_state = CompletionState::NORMAL
1128
+ @completion_journey_state = nil
1129
+ end
1130
+
1131
+ push_input_lines unless @undoing
1132
+ @undoing = false
1133
+
1134
+ if @in_pasting
1135
+ clear_dialogs
1136
+ return
1137
+ end
1138
+
1139
+ modified = @old_buffer_of_lines != @buffer_of_lines
1140
+ if !@completion_occurs && modified && !@config.disable_completion && @config.autocompletion
1141
+ # Auto complete starts only when edited
1142
+ process_insert(force: true)
1143
+ @completion_journey_state = retrieve_completion_journey_state
1144
+ end
1145
+ modified
1146
+ end
1147
+
1148
+ def save_old_buffer
1149
+ @old_buffer_of_lines = @buffer_of_lines.dup
1150
+ end
1151
+
1152
+ def push_input_lines
1153
+ if @old_buffer_of_lines == @buffer_of_lines
1154
+ @input_lines[@input_lines_position] = [@buffer_of_lines.dup, @byte_pointer, @line_index]
1155
+ else
1156
+ @input_lines = @input_lines[0..@input_lines_position]
1157
+ @input_lines_position += 1
1158
+ @input_lines.push([@buffer_of_lines.dup, @byte_pointer, @line_index])
1159
+ end
1160
+ trim_input_lines
1161
+ end
1162
+
1163
+ MAX_INPUT_LINES = 100
1164
+ def trim_input_lines
1165
+ if @input_lines.size > MAX_INPUT_LINES
1166
+ @input_lines.shift
1167
+ @input_lines_position -= 1
1168
+ end
1169
+ end
1170
+
1171
+ def scroll_into_view
1172
+ _wrapped_cursor_x, wrapped_cursor_y = wrapped_cursor_position
1173
+ if wrapped_cursor_y < screen_scroll_top
1174
+ @scroll_partial_screen = wrapped_cursor_y
1175
+ end
1176
+ if wrapped_cursor_y >= screen_scroll_top + screen_height
1177
+ @scroll_partial_screen = wrapped_cursor_y - screen_height + 1
1178
+ end
1179
+ end
1180
+
1181
+ def call_completion_proc
1182
+ result = retrieve_completion_block(true)
1183
+ pre, target, post = result
1184
+ result = call_completion_proc_with_checking_args(pre, target, post)
1185
+ Reline.core.instance_variable_set(:@completion_quote_character, nil)
1186
+ result
1187
+ end
1188
+
1189
+ def call_completion_proc_with_checking_args(pre, target, post)
1190
+ if @completion_proc and target
1191
+ argnum = @completion_proc.parameters.inject(0) { |result, item|
1192
+ case item.first
1193
+ when :req, :opt
1194
+ result + 1
1195
+ when :rest
1196
+ break 3
1197
+ end
1198
+ }
1199
+ case argnum
1200
+ when 1
1201
+ result = @completion_proc.(target)
1202
+ when 2
1203
+ result = @completion_proc.(target, pre)
1204
+ when 3..Float::INFINITY
1205
+ result = @completion_proc.(target, pre, post)
1206
+ end
1207
+ end
1208
+ result
1209
+ end
1210
+
1211
+ private def process_auto_indent(line_index = @line_index, cursor_dependent: true, add_newline: false)
1212
+ return if @in_pasting
1213
+ return unless @auto_indent_proc
1214
+
1215
+ line = @buffer_of_lines[line_index]
1216
+ byte_pointer = cursor_dependent && @line_index == line_index ? @byte_pointer : line.bytesize
1217
+ new_indent = @auto_indent_proc.(@buffer_of_lines.take(line_index + 1).push(''), line_index, byte_pointer, add_newline)
1218
+ return unless new_indent
1219
+
1220
+ new_line = ' ' * new_indent + line.lstrip
1221
+ @buffer_of_lines[line_index] = new_line
1222
+ if @line_index == line_index
1223
+ indent_diff = new_line.bytesize - line.bytesize
1224
+ @byte_pointer = [@byte_pointer + indent_diff, 0].max
1225
+ end
1226
+ end
1227
+
1228
+ def line()
1229
+ @buffer_of_lines.join("\n") unless eof?
1230
+ end
1231
+
1232
+ def current_line
1233
+ @buffer_of_lines[@line_index]
1234
+ end
1235
+
1236
+ def set_current_line(line, byte_pointer = nil)
1237
+ cursor = current_byte_pointer_cursor
1238
+ @buffer_of_lines[@line_index] = line
1239
+ if byte_pointer
1240
+ @byte_pointer = byte_pointer
1241
+ else
1242
+ calculate_nearest_cursor(cursor)
1243
+ end
1244
+ process_auto_indent
1245
+ end
1246
+
1247
+ def set_current_lines(lines, byte_pointer = nil, line_index = 0)
1248
+ cursor = current_byte_pointer_cursor
1249
+ @buffer_of_lines = lines
1250
+ @line_index = line_index
1251
+ if byte_pointer
1252
+ @byte_pointer = byte_pointer
1253
+ else
1254
+ calculate_nearest_cursor(cursor)
1255
+ end
1256
+ process_auto_indent
1257
+ end
1258
+
1259
+ def retrieve_completion_block(set_completion_quote_character = false)
1260
+ if Reline.completer_word_break_characters.empty?
1261
+ word_break_regexp = nil
1262
+ else
1263
+ word_break_regexp = /\A[#{Regexp.escape(Reline.completer_word_break_characters)}]/
1264
+ end
1265
+ if Reline.completer_quote_characters.empty?
1266
+ quote_characters_regexp = nil
1267
+ else
1268
+ quote_characters_regexp = /\A[#{Regexp.escape(Reline.completer_quote_characters)}]/
1269
+ end
1270
+ before = current_line.byteslice(0, @byte_pointer)
1271
+ rest = nil
1272
+ break_pointer = nil
1273
+ quote = nil
1274
+ closing_quote = nil
1275
+ escaped_quote = nil
1276
+ i = 0
1277
+ while i < @byte_pointer do
1278
+ slice = current_line.byteslice(i, @byte_pointer - i)
1279
+ unless slice.valid_encoding?
1280
+ i += 1
1281
+ next
1282
+ end
1283
+ if quote and slice.start_with?(closing_quote)
1284
+ quote = nil
1285
+ i += 1
1286
+ rest = nil
1287
+ elsif quote and slice.start_with?(escaped_quote)
1288
+ # skip
1289
+ i += 2
1290
+ elsif quote_characters_regexp and slice =~ quote_characters_regexp # find new "
1291
+ rest = $'
1292
+ quote = $&
1293
+ closing_quote = /(?!\\)#{Regexp.escape(quote)}/
1294
+ escaped_quote = /\\#{Regexp.escape(quote)}/
1295
+ i += 1
1296
+ break_pointer = i - 1
1297
+ elsif word_break_regexp and not quote and slice =~ word_break_regexp
1298
+ rest = $'
1299
+ i += 1
1300
+ before = current_line.byteslice(i, @byte_pointer - i)
1301
+ break_pointer = i
1302
+ else
1303
+ i += 1
1304
+ end
1305
+ end
1306
+ postposing = current_line.byteslice(@byte_pointer, current_line.bytesize - @byte_pointer)
1307
+ if rest
1308
+ preposing = current_line.byteslice(0, break_pointer)
1309
+ target = rest
1310
+ if set_completion_quote_character and quote
1311
+ Reline.core.instance_variable_set(:@completion_quote_character, quote)
1312
+ if postposing !~ /(?!\\)#{Regexp.escape(quote)}/ # closing quote
1313
+ insert_text(quote)
1314
+ end
1315
+ end
1316
+ else
1317
+ preposing = ''
1318
+ if break_pointer
1319
+ preposing = current_line.byteslice(0, break_pointer)
1320
+ else
1321
+ preposing = ''
1322
+ end
1323
+ target = before
1324
+ end
1325
+ lines = whole_lines
1326
+ if @line_index > 0
1327
+ preposing = lines[0..(@line_index - 1)].join("\n") + "\n" + preposing
1328
+ end
1329
+ if (lines.size - 1) > @line_index
1330
+ postposing = postposing + "\n" + lines[(@line_index + 1)..-1].join("\n")
1331
+ end
1332
+ [preposing.encode(@encoding), target.encode(@encoding), postposing.encode(@encoding)]
1333
+ end
1334
+
1335
+ def confirm_multiline_termination
1336
+ temp_buffer = @buffer_of_lines.dup
1337
+ @confirm_multiline_termination_proc.(temp_buffer.join("\n") + "\n")
1338
+ end
1339
+
1340
+ def insert_pasted_text(text)
1341
+ save_old_buffer
1342
+ pre = @buffer_of_lines[@line_index].byteslice(0, @byte_pointer)
1343
+ post = @buffer_of_lines[@line_index].byteslice(@byte_pointer..)
1344
+ lines = (pre + text.gsub(/\r\n?/, "\n") + post).split("\n", -1)
1345
+ lines << '' if lines.empty?
1346
+ @buffer_of_lines[@line_index, 1] = lines
1347
+ @line_index += lines.size - 1
1348
+ @byte_pointer = @buffer_of_lines[@line_index].bytesize - post.bytesize
1349
+ push_input_lines
1350
+ end
1351
+
1352
+ def insert_text(text)
1353
+ if @buffer_of_lines[@line_index].bytesize == @byte_pointer
1354
+ @buffer_of_lines[@line_index] += text
1355
+ else
1356
+ @buffer_of_lines[@line_index] = byteinsert(@buffer_of_lines[@line_index], @byte_pointer, text)
1357
+ end
1358
+ @byte_pointer += text.bytesize
1359
+ process_auto_indent
1360
+ end
1361
+
1362
+ def delete_text(start = nil, length = nil)
1363
+ if start.nil? and length.nil?
1364
+ if @buffer_of_lines.size == 1
1365
+ @buffer_of_lines[@line_index] = ''
1366
+ @byte_pointer = 0
1367
+ elsif @line_index == (@buffer_of_lines.size - 1) and @line_index > 0
1368
+ @buffer_of_lines.pop
1369
+ @line_index -= 1
1370
+ @byte_pointer = 0
1371
+ elsif @line_index < (@buffer_of_lines.size - 1)
1372
+ @buffer_of_lines.delete_at(@line_index)
1373
+ @byte_pointer = 0
1374
+ end
1375
+ elsif not start.nil? and not length.nil?
1376
+ if current_line
1377
+ before = current_line.byteslice(0, start)
1378
+ after = current_line.byteslice(start + length, current_line.bytesize)
1379
+ set_current_line(before + after)
1380
+ end
1381
+ elsif start.is_a?(Range)
1382
+ range = start
1383
+ first = range.first
1384
+ last = range.last
1385
+ last = current_line.bytesize - 1 if last > current_line.bytesize
1386
+ last += current_line.bytesize if last < 0
1387
+ first += current_line.bytesize if first < 0
1388
+ range = range.exclude_end? ? first...last : first..last
1389
+ line = current_line.bytes.reject.with_index{ |c, i| range.include?(i) }.map{ |c| c.chr(Encoding::ASCII_8BIT) }.join.force_encoding(@encoding)
1390
+ set_current_line(line)
1391
+ else
1392
+ set_current_line(current_line.byteslice(0, start))
1393
+ end
1394
+ end
1395
+
1396
+ def byte_pointer=(val)
1397
+ @byte_pointer = val
1398
+ end
1399
+
1400
+ def whole_lines
1401
+ @buffer_of_lines.dup
1402
+ end
1403
+
1404
+ def whole_buffer
1405
+ whole_lines.join("\n")
1406
+ end
1407
+
1408
+ private def buffer_empty?
1409
+ current_line.empty? and @buffer_of_lines.size == 1
1410
+ end
1411
+
1412
+ def finished?
1413
+ @finished
1414
+ end
1415
+
1416
+ def finish
1417
+ @finished = true
1418
+ @config.reset
1419
+ end
1420
+
1421
+ private def byteslice!(str, byte_pointer, size)
1422
+ new_str = str.byteslice(0, byte_pointer)
1423
+ new_str << str.byteslice(byte_pointer + size, str.bytesize)
1424
+ [new_str, str.byteslice(byte_pointer, size)]
1425
+ end
1426
+
1427
+ private def byteinsert(str, byte_pointer, other)
1428
+ new_str = str.byteslice(0, byte_pointer)
1429
+ new_str << other
1430
+ new_str << str.byteslice(byte_pointer, str.bytesize)
1431
+ new_str
1432
+ end
1433
+
1434
+ private def calculate_width(str, allow_escape_code = false)
1435
+ Reline::Unicode.calculate_width(str, allow_escape_code)
1436
+ end
1437
+
1438
+ private def key_delete(key)
1439
+ if @config.editing_mode_is?(:vi_insert)
1440
+ ed_delete_next_char(key)
1441
+ elsif @config.editing_mode_is?(:emacs)
1442
+ em_delete(key)
1443
+ end
1444
+ end
1445
+
1446
+ private def key_newline(key)
1447
+ if @is_multiline
1448
+ next_line = current_line.byteslice(@byte_pointer, current_line.bytesize - @byte_pointer)
1449
+ cursor_line = current_line.byteslice(0, @byte_pointer)
1450
+ insert_new_line(cursor_line, next_line)
1451
+ end
1452
+ end
1453
+
1454
+ private def complete(_key)
1455
+ return if @config.disable_completion
1456
+
1457
+ process_insert(force: true)
1458
+ if @config.autocompletion
1459
+ @completion_state = CompletionState::NORMAL
1460
+ @completion_occurs = move_completed_list(:down)
1461
+ else
1462
+ @completion_journey_state = nil
1463
+ result = call_completion_proc
1464
+ if result.is_a?(Array)
1465
+ @completion_occurs = true
1466
+ perform_completion(result, false)
1467
+ end
1468
+ end
1469
+ end
1470
+
1471
+ private def completion_journey_move(direction)
1472
+ return if @config.disable_completion
1473
+
1474
+ process_insert(force: true)
1475
+ @completion_state = CompletionState::NORMAL
1476
+ @completion_occurs = move_completed_list(direction)
1477
+ end
1478
+
1479
+ private def menu_complete(_key)
1480
+ completion_journey_move(:down)
1481
+ end
1482
+
1483
+ private def menu_complete_backward(_key)
1484
+ completion_journey_move(:up)
1485
+ end
1486
+
1487
+ private def completion_journey_up(_key)
1488
+ completion_journey_move(:up) if @config.autocompletion
1489
+ end
1490
+
1491
+ # Editline:: +ed-unassigned+ This editor command always results in an error.
1492
+ # GNU Readline:: There is no corresponding macro.
1493
+ private def ed_unassigned(key) end # do nothing
1494
+
1495
+ private def process_insert(force: false)
1496
+ return if @continuous_insertion_buffer.empty? or (@in_pasting and not force)
1497
+ insert_text(@continuous_insertion_buffer)
1498
+ @continuous_insertion_buffer.clear
1499
+ end
1500
+
1501
+ # Editline:: +ed-insert+ (vi input: almost all; emacs: printable characters)
1502
+ # In insert mode, insert the input character left of the cursor
1503
+ # position. In replace mode, overwrite the character at the
1504
+ # cursor and move the cursor to the right by one character
1505
+ # position. Accept an argument to do this repeatedly. It is an
1506
+ # error if the input character is the NUL character (+Ctrl-@+).
1507
+ # Failure to enlarge the edit buffer also results in an error.
1508
+ # Editline:: +ed-digit+ (emacs: 0 to 9) If in argument input mode, append
1509
+ # the input digit to the argument being read. Otherwise, call
1510
+ # +ed-insert+. It is an error if the input character is not a
1511
+ # digit or if the existing argument is already greater than a
1512
+ # million.
1513
+ # GNU Readline:: +self-insert+ (a, b, A, 1, !, …) Insert yourself.
1514
+ private def ed_insert(key)
1515
+ if key.instance_of?(String)
1516
+ begin
1517
+ key.encode(Encoding::UTF_8)
1518
+ rescue Encoding::UndefinedConversionError
1519
+ return
1520
+ end
1521
+ str = key
1522
+ else
1523
+ begin
1524
+ key.chr.encode(Encoding::UTF_8)
1525
+ rescue Encoding::UndefinedConversionError
1526
+ return
1527
+ end
1528
+ str = key.chr
1529
+ end
1530
+ if @in_pasting
1531
+ @continuous_insertion_buffer << str
1532
+ return
1533
+ elsif not @continuous_insertion_buffer.empty?
1534
+ process_insert
1535
+ end
1536
+
1537
+ insert_text(str)
1538
+ end
1539
+ alias_method :ed_digit, :ed_insert
1540
+ alias_method :self_insert, :ed_insert
1541
+
1542
+ private def ed_quoted_insert(str, arg: 1)
1543
+ @waiting_proc = proc { |key|
1544
+ arg.times do
1545
+ if key == "\C-j".ord or key == "\C-m".ord
1546
+ key_newline(key)
1547
+ elsif key == 0
1548
+ # Ignore NUL.
1549
+ else
1550
+ ed_insert(key)
1551
+ end
1552
+ end
1553
+ @waiting_proc = nil
1554
+ }
1555
+ end
1556
+ alias_method :quoted_insert, :ed_quoted_insert
1557
+
1558
+ private def ed_next_char(key, arg: 1)
1559
+ byte_size = Reline::Unicode.get_next_mbchar_size(current_line, @byte_pointer)
1560
+ if (@byte_pointer < current_line.bytesize)
1561
+ @byte_pointer += byte_size
1562
+ elsif @config.editing_mode_is?(:emacs) and @byte_pointer == current_line.bytesize and @line_index < @buffer_of_lines.size - 1
1563
+ @byte_pointer = 0
1564
+ @line_index += 1
1565
+ end
1566
+ arg -= 1
1567
+ ed_next_char(key, arg: arg) if arg > 0
1568
+ end
1569
+ alias_method :forward_char, :ed_next_char
1570
+
1571
+ private def ed_prev_char(key, arg: 1)
1572
+ if @byte_pointer > 0
1573
+ byte_size = Reline::Unicode.get_prev_mbchar_size(current_line, @byte_pointer)
1574
+ @byte_pointer -= byte_size
1575
+ elsif @config.editing_mode_is?(:emacs) and @byte_pointer == 0 and @line_index > 0
1576
+ @line_index -= 1
1577
+ @byte_pointer = current_line.bytesize
1578
+ end
1579
+ arg -= 1
1580
+ ed_prev_char(key, arg: arg) if arg > 0
1581
+ end
1582
+ alias_method :backward_char, :ed_prev_char
1583
+
1584
+ private def vi_first_print(key)
1585
+ @byte_pointer, = Reline::Unicode.vi_first_print(current_line)
1586
+ end
1587
+
1588
+ private def ed_move_to_beg(key)
1589
+ @byte_pointer = 0
1590
+ end
1591
+ alias_method :beginning_of_line, :ed_move_to_beg
1592
+ alias_method :vi_zero, :ed_move_to_beg
1593
+
1594
+ private def ed_move_to_end(key)
1595
+ @byte_pointer = current_line.bytesize
1596
+ end
1597
+ alias_method :end_of_line, :ed_move_to_end
1598
+
1599
+ private def generate_searcher(search_key)
1600
+ search_word = String.new(encoding: @encoding)
1601
+ multibyte_buf = String.new(encoding: 'ASCII-8BIT')
1602
+ hit_pointer = nil
1603
+ lambda do |key|
1604
+ search_again = false
1605
+ case key
1606
+ when "\C-h".ord, "\C-?".ord
1607
+ grapheme_clusters = search_word.grapheme_clusters
1608
+ if grapheme_clusters.size > 0
1609
+ grapheme_clusters.pop
1610
+ search_word = grapheme_clusters.join
1611
+ end
1612
+ when "\C-r".ord, "\C-s".ord
1613
+ search_again = true if search_key == key
1614
+ search_key = key
1615
+ else
1616
+ multibyte_buf << key
1617
+ if multibyte_buf.dup.force_encoding(@encoding).valid_encoding?
1618
+ search_word << multibyte_buf.dup.force_encoding(@encoding)
1619
+ multibyte_buf.clear
1620
+ end
1621
+ end
1622
+ hit = nil
1623
+ if not search_word.empty? and @line_backup_in_history&.include?(search_word)
1624
+ hit_pointer = Reline::HISTORY.size
1625
+ hit = @line_backup_in_history
1626
+ else
1627
+ if search_again
1628
+ if search_word.empty? and Reline.last_incremental_search
1629
+ search_word = Reline.last_incremental_search
1630
+ end
1631
+ if @history_pointer
1632
+ case search_key
1633
+ when "\C-r".ord
1634
+ history_pointer_base = 0
1635
+ history = Reline::HISTORY[0..(@history_pointer - 1)]
1636
+ when "\C-s".ord
1637
+ history_pointer_base = @history_pointer + 1
1638
+ history = Reline::HISTORY[(@history_pointer + 1)..-1]
1639
+ end
1640
+ else
1641
+ history_pointer_base = 0
1642
+ history = Reline::HISTORY
1643
+ end
1644
+ elsif @history_pointer
1645
+ case search_key
1646
+ when "\C-r".ord
1647
+ history_pointer_base = 0
1648
+ history = Reline::HISTORY[0..@history_pointer]
1649
+ when "\C-s".ord
1650
+ history_pointer_base = @history_pointer
1651
+ history = Reline::HISTORY[@history_pointer..-1]
1652
+ end
1653
+ else
1654
+ history_pointer_base = 0
1655
+ history = Reline::HISTORY
1656
+ end
1657
+ case search_key
1658
+ when "\C-r".ord
1659
+ hit_index = history.rindex { |item|
1660
+ item.include?(search_word)
1661
+ }
1662
+ when "\C-s".ord
1663
+ hit_index = history.index { |item|
1664
+ item.include?(search_word)
1665
+ }
1666
+ end
1667
+ if hit_index
1668
+ hit_pointer = history_pointer_base + hit_index
1669
+ hit = Reline::HISTORY[hit_pointer]
1670
+ end
1671
+ end
1672
+ case search_key
1673
+ when "\C-r".ord
1674
+ prompt_name = 'reverse-i-search'
1675
+ when "\C-s".ord
1676
+ prompt_name = 'i-search'
1677
+ end
1678
+ prompt_name = "failed #{prompt_name}" unless hit
1679
+ [search_word, prompt_name, hit_pointer]
1680
+ end
1681
+ end
1682
+
1683
+ private def incremental_search_history(key)
1684
+ unless @history_pointer
1685
+ @line_backup_in_history = whole_buffer
1686
+ end
1687
+ searcher = generate_searcher(key)
1688
+ @searching_prompt = "(reverse-i-search)`': "
1689
+ termination_keys = ["\C-j".ord]
1690
+ termination_keys.concat(@config.isearch_terminators&.chars&.map(&:ord)) if @config.isearch_terminators
1691
+ @waiting_proc = ->(k) {
1692
+ case k
1693
+ when *termination_keys
1694
+ if @history_pointer
1695
+ buffer = Reline::HISTORY[@history_pointer]
1696
+ else
1697
+ buffer = @line_backup_in_history
1698
+ end
1699
+ @buffer_of_lines = buffer.split("\n")
1700
+ @buffer_of_lines = [String.new(encoding: @encoding)] if @buffer_of_lines.empty?
1701
+ @line_index = @buffer_of_lines.size - 1
1702
+ @searching_prompt = nil
1703
+ @waiting_proc = nil
1704
+ @byte_pointer = 0
1705
+ when "\C-g".ord
1706
+ @buffer_of_lines = @line_backup_in_history.split("\n")
1707
+ @buffer_of_lines = [String.new(encoding: @encoding)] if @buffer_of_lines.empty?
1708
+ @line_index = @buffer_of_lines.size - 1
1709
+ move_history(nil, line: :end, cursor: :end, save_buffer: false)
1710
+ @searching_prompt = nil
1711
+ @waiting_proc = nil
1712
+ @byte_pointer = 0
1713
+ else
1714
+ chr = k.is_a?(String) ? k : k.chr(Encoding::ASCII_8BIT)
1715
+ if chr.match?(/[[:print:]]/) or k == "\C-h".ord or k == "\C-?".ord or k == "\C-r".ord or k == "\C-s".ord
1716
+ search_word, prompt_name, hit_pointer = searcher.call(k)
1717
+ Reline.last_incremental_search = search_word
1718
+ @searching_prompt = "(%s)`%s'" % [prompt_name, search_word]
1719
+ @searching_prompt += ': ' unless @is_multiline
1720
+ move_history(hit_pointer, line: :end, cursor: :end, save_buffer: false) if hit_pointer
1721
+ else
1722
+ if @history_pointer
1723
+ line = Reline::HISTORY[@history_pointer]
1724
+ else
1725
+ line = @line_backup_in_history
1726
+ end
1727
+ @line_backup_in_history = whole_buffer
1728
+ @buffer_of_lines = line.split("\n")
1729
+ @buffer_of_lines = [String.new(encoding: @encoding)] if @buffer_of_lines.empty?
1730
+ @line_index = @buffer_of_lines.size - 1
1731
+ @searching_prompt = nil
1732
+ @waiting_proc = nil
1733
+ @byte_pointer = 0
1734
+ end
1735
+ end
1736
+ }
1737
+ end
1738
+
1739
+ private def vi_search_prev(key)
1740
+ incremental_search_history(key)
1741
+ end
1742
+ alias_method :reverse_search_history, :vi_search_prev
1743
+
1744
+ private def vi_search_next(key)
1745
+ incremental_search_history(key)
1746
+ end
1747
+ alias_method :forward_search_history, :vi_search_next
1748
+
1749
+ private def search_history(prefix, pointer_range)
1750
+ pointer_range.each do |pointer|
1751
+ lines = Reline::HISTORY[pointer].split("\n")
1752
+ lines.each_with_index do |line, index|
1753
+ return [pointer, index] if line.start_with?(prefix)
1754
+ end
1755
+ end
1756
+ nil
1757
+ end
1758
+
1759
+ private def ed_search_prev_history(key, arg: 1)
1760
+ substr = prev_action_state_value(:search_history) == :empty ? '' : current_line.byteslice(0, @byte_pointer)
1761
+ return if @history_pointer == 0
1762
+ return if @history_pointer.nil? && substr.empty? && !current_line.empty?
1763
+
1764
+ history_range = 0...(@history_pointer || Reline::HISTORY.size)
1765
+ h_pointer, line_index = search_history(substr, history_range.reverse_each)
1766
+ return unless h_pointer
1767
+ move_history(h_pointer, line: line_index || :start, cursor: substr.empty? ? :end : @byte_pointer)
1768
+ arg -= 1
1769
+ set_next_action_state(:search_history, :empty) if substr.empty?
1770
+ ed_search_prev_history(key, arg: arg) if arg > 0
1771
+ end
1772
+ alias_method :history_search_backward, :ed_search_prev_history
1773
+
1774
+ private def ed_search_next_history(key, arg: 1)
1775
+ substr = prev_action_state_value(:search_history) == :empty ? '' : current_line.byteslice(0, @byte_pointer)
1776
+ return if @history_pointer.nil?
1777
+
1778
+ history_range = @history_pointer + 1...Reline::HISTORY.size
1779
+ h_pointer, line_index = search_history(substr, history_range)
1780
+ return if h_pointer.nil? and not substr.empty?
1781
+
1782
+ move_history(h_pointer, line: line_index || :start, cursor: substr.empty? ? :end : @byte_pointer)
1783
+ arg -= 1
1784
+ set_next_action_state(:search_history, :empty) if substr.empty?
1785
+ ed_search_next_history(key, arg: arg) if arg > 0
1786
+ end
1787
+ alias_method :history_search_forward, :ed_search_next_history
1788
+
1789
+ private def move_history(history_pointer, line:, cursor:, save_buffer: true)
1790
+ history_pointer ||= Reline::HISTORY.size
1791
+ return if history_pointer < 0 || history_pointer > Reline::HISTORY.size
1792
+ old_history_pointer = @history_pointer || Reline::HISTORY.size
1793
+ if old_history_pointer == Reline::HISTORY.size
1794
+ @line_backup_in_history = save_buffer ? whole_buffer : ''
1795
+ else
1796
+ Reline::HISTORY[old_history_pointer] = whole_buffer if save_buffer
1797
+ end
1798
+ if history_pointer == Reline::HISTORY.size
1799
+ buf = @line_backup_in_history
1800
+ @history_pointer = @line_backup_in_history = nil
1801
+ else
1802
+ buf = Reline::HISTORY[history_pointer]
1803
+ @history_pointer = history_pointer
1804
+ end
1805
+ @buffer_of_lines = buf.split("\n")
1806
+ @buffer_of_lines = [String.new(encoding: @encoding)] if @buffer_of_lines.empty?
1807
+ @line_index = line == :start ? 0 : line == :end ? @buffer_of_lines.size - 1 : line
1808
+ @byte_pointer = cursor == :start ? 0 : cursor == :end ? current_line.bytesize : cursor
1809
+ end
1810
+
1811
+ private def ed_prev_history(key, arg: 1)
1812
+ if @line_index > 0
1813
+ cursor = current_byte_pointer_cursor
1814
+ @line_index -= 1
1815
+ calculate_nearest_cursor(cursor)
1816
+ return
1817
+ end
1818
+ move_history(
1819
+ (@history_pointer || Reline::HISTORY.size) - 1,
1820
+ line: :end,
1821
+ cursor: @config.editing_mode_is?(:vi_command) ? :start : :end,
1822
+ )
1823
+ arg -= 1
1824
+ ed_prev_history(key, arg: arg) if arg > 0
1825
+ end
1826
+ alias_method :previous_history, :ed_prev_history
1827
+
1828
+ private def ed_next_history(key, arg: 1)
1829
+ if @line_index < (@buffer_of_lines.size - 1)
1830
+ cursor = current_byte_pointer_cursor
1831
+ @line_index += 1
1832
+ calculate_nearest_cursor(cursor)
1833
+ return
1834
+ end
1835
+ move_history(
1836
+ (@history_pointer || Reline::HISTORY.size) + 1,
1837
+ line: :start,
1838
+ cursor: @config.editing_mode_is?(:vi_command) ? :start : :end,
1839
+ )
1840
+ arg -= 1
1841
+ ed_next_history(key, arg: arg) if arg > 0
1842
+ end
1843
+ alias_method :next_history, :ed_next_history
1844
+
1845
+ private def ed_newline(key)
1846
+ process_insert(force: true)
1847
+ if @is_multiline
1848
+ if @config.editing_mode_is?(:vi_command)
1849
+ if @line_index < (@buffer_of_lines.size - 1)
1850
+ ed_next_history(key) # means cursor down
1851
+ else
1852
+ # should check confirm_multiline_termination to finish?
1853
+ finish
1854
+ end
1855
+ else
1856
+ if @line_index == (@buffer_of_lines.size - 1)
1857
+ if confirm_multiline_termination
1858
+ finish
1859
+ else
1860
+ key_newline(key)
1861
+ end
1862
+ else
1863
+ # should check confirm_multiline_termination to finish?
1864
+ @line_index = @buffer_of_lines.size - 1
1865
+ @byte_pointer = current_line.bytesize
1866
+ finish
1867
+ end
1868
+ end
1869
+ else
1870
+ finish
1871
+ end
1872
+ end
1873
+
1874
+ private def em_delete_prev_char(key, arg: 1)
1875
+ arg.times do
1876
+ if @byte_pointer == 0 and @line_index > 0
1877
+ @byte_pointer = @buffer_of_lines[@line_index - 1].bytesize
1878
+ @buffer_of_lines[@line_index - 1] += @buffer_of_lines.delete_at(@line_index)
1879
+ @line_index -= 1
1880
+ elsif @byte_pointer > 0
1881
+ byte_size = Reline::Unicode.get_prev_mbchar_size(current_line, @byte_pointer)
1882
+ line, = byteslice!(current_line, @byte_pointer - byte_size, byte_size)
1883
+ set_current_line(line, @byte_pointer - byte_size)
1884
+ end
1885
+ end
1886
+ process_auto_indent
1887
+ end
1888
+ alias_method :backward_delete_char, :em_delete_prev_char
1889
+
1890
+ # Editline:: +ed-kill-line+ (vi command: +D+, +Ctrl-K+; emacs: +Ctrl-K+,
1891
+ # +Ctrl-U+) + Kill from the cursor to the end of the line.
1892
+ # GNU Readline:: +kill-line+ (+C-k+) Kill the text from point to the end of
1893
+ # the line. With a negative numeric argument, kill backward
1894
+ # from the cursor to the beginning of the current line.
1895
+ private def ed_kill_line(key)
1896
+ if current_line.bytesize > @byte_pointer
1897
+ line, deleted = byteslice!(current_line, @byte_pointer, current_line.bytesize - @byte_pointer)
1898
+ set_current_line(line, line.bytesize)
1899
+ @kill_ring.append(deleted)
1900
+ elsif @byte_pointer == current_line.bytesize and @buffer_of_lines.size > @line_index + 1
1901
+ set_current_line(current_line + @buffer_of_lines.delete_at(@line_index + 1), current_line.bytesize)
1902
+ end
1903
+ end
1904
+ alias_method :kill_line, :ed_kill_line
1905
+
1906
+ # Editline:: +vi_change_to_eol+ (vi command: +C+) + Kill and change from the cursor to the end of the line.
1907
+ private def vi_change_to_eol(key)
1908
+ ed_kill_line(key)
1909
+
1910
+ @config.editing_mode = :vi_insert
1911
+ end
1912
+
1913
+ # Editline:: +vi-kill-line-prev+ (vi: +Ctrl-U+) Delete the string from the
1914
+ # beginning of the edit buffer to the cursor and save it to the
1915
+ # cut buffer.
1916
+ # GNU Readline:: +unix-line-discard+ (+C-u+) Kill backward from the cursor
1917
+ # to the beginning of the current line.
1918
+ private def vi_kill_line_prev(key)
1919
+ if @byte_pointer > 0
1920
+ line, deleted = byteslice!(current_line, 0, @byte_pointer)
1921
+ set_current_line(line, 0)
1922
+ @kill_ring.append(deleted, true)
1923
+ end
1924
+ end
1925
+ alias_method :unix_line_discard, :vi_kill_line_prev
1926
+
1927
+ # Editline:: +em-kill-line+ (not bound) Delete the entire contents of the
1928
+ # edit buffer and save it to the cut buffer. +vi-kill-line-prev+
1929
+ # GNU Readline:: +kill-whole-line+ (not bound) Kill all characters on the
1930
+ # current line, no matter where point is.
1931
+ private def em_kill_line(key)
1932
+ if current_line.size > 0
1933
+ @kill_ring.append(current_line.dup, true)
1934
+ set_current_line('', 0)
1935
+ end
1936
+ end
1937
+ alias_method :kill_whole_line, :em_kill_line
1938
+
1939
+ private def em_delete(key)
1940
+ if buffer_empty? and key == "\C-d".ord
1941
+ @eof = true
1942
+ finish
1943
+ elsif @byte_pointer < current_line.bytesize
1944
+ splitted_last = current_line.byteslice(@byte_pointer, current_line.bytesize)
1945
+ mbchar = splitted_last.grapheme_clusters.first
1946
+ line, = byteslice!(current_line, @byte_pointer, mbchar.bytesize)
1947
+ set_current_line(line)
1948
+ elsif @byte_pointer == current_line.bytesize and @buffer_of_lines.size > @line_index + 1
1949
+ set_current_line(current_line + @buffer_of_lines.delete_at(@line_index + 1), current_line.bytesize)
1950
+ end
1951
+ end
1952
+ alias_method :delete_char, :em_delete
1953
+
1954
+ private def em_delete_or_list(key)
1955
+ if current_line.empty? or @byte_pointer < current_line.bytesize
1956
+ em_delete(key)
1957
+ elsif !@config.autocompletion # show completed list
1958
+ result = call_completion_proc
1959
+ if result.is_a?(Array)
1960
+ perform_completion(result, true)
1961
+ end
1962
+ end
1963
+ end
1964
+ alias_method :delete_char_or_list, :em_delete_or_list
1965
+
1966
+ private def em_yank(key)
1967
+ yanked = @kill_ring.yank
1968
+ insert_text(yanked) if yanked
1969
+ end
1970
+ alias_method :yank, :em_yank
1971
+
1972
+ private def em_yank_pop(key)
1973
+ yanked, prev_yank = @kill_ring.yank_pop
1974
+ if yanked
1975
+ line, = byteslice!(current_line, @byte_pointer - prev_yank.bytesize, prev_yank.bytesize)
1976
+ set_current_line(line, @byte_pointer - prev_yank.bytesize)
1977
+ insert_text(yanked)
1978
+ end
1979
+ end
1980
+ alias_method :yank_pop, :em_yank_pop
1981
+
1982
+ private def ed_clear_screen(key)
1983
+ Reline::IOGate.clear_screen
1984
+ @screen_size = Reline::IOGate.get_screen_size
1985
+ @rendered_screen.lines = []
1986
+ @rendered_screen.base_y = 0
1987
+ @rendered_screen.cursor_y = 0
1988
+ end
1989
+ alias_method :clear_screen, :ed_clear_screen
1990
+
1991
+ private def em_next_word(key)
1992
+ if current_line.bytesize > @byte_pointer
1993
+ byte_size, _ = Reline::Unicode.em_forward_word(current_line, @byte_pointer)
1994
+ @byte_pointer += byte_size
1995
+ end
1996
+ end
1997
+ alias_method :forward_word, :em_next_word
1998
+
1999
+ private def ed_prev_word(key)
2000
+ if @byte_pointer > 0
2001
+ byte_size, _ = Reline::Unicode.em_backward_word(current_line, @byte_pointer)
2002
+ @byte_pointer -= byte_size
2003
+ end
2004
+ end
2005
+ alias_method :backward_word, :ed_prev_word
2006
+
2007
+ private def em_delete_next_word(key)
2008
+ if current_line.bytesize > @byte_pointer
2009
+ byte_size, _ = Reline::Unicode.em_forward_word(current_line, @byte_pointer)
2010
+ line, word = byteslice!(current_line, @byte_pointer, byte_size)
2011
+ set_current_line(line)
2012
+ @kill_ring.append(word)
2013
+ end
2014
+ end
2015
+ alias_method :kill_word, :em_delete_next_word
2016
+
2017
+ private def ed_delete_prev_word(key)
2018
+ if @byte_pointer > 0
2019
+ byte_size, _ = Reline::Unicode.em_backward_word(current_line, @byte_pointer)
2020
+ line, word = byteslice!(current_line, @byte_pointer - byte_size, byte_size)
2021
+ set_current_line(line, @byte_pointer - byte_size)
2022
+ @kill_ring.append(word, true)
2023
+ end
2024
+ end
2025
+ alias_method :backward_kill_word, :ed_delete_prev_word
2026
+
2027
+ private def ed_transpose_chars(key)
2028
+ if @byte_pointer > 0
2029
+ if @byte_pointer < current_line.bytesize
2030
+ byte_size = Reline::Unicode.get_next_mbchar_size(current_line, @byte_pointer)
2031
+ @byte_pointer += byte_size
2032
+ end
2033
+ back1_byte_size = Reline::Unicode.get_prev_mbchar_size(current_line, @byte_pointer)
2034
+ if (@byte_pointer - back1_byte_size) > 0
2035
+ back2_byte_size = Reline::Unicode.get_prev_mbchar_size(current_line, @byte_pointer - back1_byte_size)
2036
+ back2_pointer = @byte_pointer - back1_byte_size - back2_byte_size
2037
+ line, back2_mbchar = byteslice!(current_line, back2_pointer, back2_byte_size)
2038
+ set_current_line(byteinsert(line, @byte_pointer - back2_byte_size, back2_mbchar))
2039
+ end
2040
+ end
2041
+ end
2042
+ alias_method :transpose_chars, :ed_transpose_chars
2043
+
2044
+ private def ed_transpose_words(key)
2045
+ left_word_start, middle_start, right_word_start, after_start = Reline::Unicode.ed_transpose_words(current_line, @byte_pointer)
2046
+ before = current_line.byteslice(0, left_word_start)
2047
+ left_word = current_line.byteslice(left_word_start, middle_start - left_word_start)
2048
+ middle = current_line.byteslice(middle_start, right_word_start - middle_start)
2049
+ right_word = current_line.byteslice(right_word_start, after_start - right_word_start)
2050
+ after = current_line.byteslice(after_start, current_line.bytesize - after_start)
2051
+ return if left_word.empty? or right_word.empty?
2052
+ from_head_to_left_word = before + right_word + middle + left_word
2053
+ set_current_line(from_head_to_left_word + after, from_head_to_left_word.bytesize)
2054
+ end
2055
+ alias_method :transpose_words, :ed_transpose_words
2056
+
2057
+ private def em_capitol_case(key)
2058
+ if current_line.bytesize > @byte_pointer
2059
+ byte_size, _, new_str = Reline::Unicode.em_forward_word_with_capitalization(current_line, @byte_pointer)
2060
+ before = current_line.byteslice(0, @byte_pointer)
2061
+ after = current_line.byteslice((@byte_pointer + byte_size)..-1)
2062
+ set_current_line(before + new_str + after, @byte_pointer + new_str.bytesize)
2063
+ end
2064
+ end
2065
+ alias_method :capitalize_word, :em_capitol_case
2066
+
2067
+ private def em_lower_case(key)
2068
+ if current_line.bytesize > @byte_pointer
2069
+ byte_size, = Reline::Unicode.em_forward_word(current_line, @byte_pointer)
2070
+ part = current_line.byteslice(@byte_pointer, byte_size).grapheme_clusters.map { |mbchar|
2071
+ mbchar =~ /[A-Z]/ ? mbchar.downcase : mbchar
2072
+ }.join
2073
+ rest = current_line.byteslice((@byte_pointer + byte_size)..-1)
2074
+ line = current_line.byteslice(0, @byte_pointer) + part
2075
+ set_current_line(line + rest, line.bytesize)
2076
+ end
2077
+ end
2078
+ alias_method :downcase_word, :em_lower_case
2079
+
2080
+ private def em_upper_case(key)
2081
+ if current_line.bytesize > @byte_pointer
2082
+ byte_size, = Reline::Unicode.em_forward_word(current_line, @byte_pointer)
2083
+ part = current_line.byteslice(@byte_pointer, byte_size).grapheme_clusters.map { |mbchar|
2084
+ mbchar =~ /[a-z]/ ? mbchar.upcase : mbchar
2085
+ }.join
2086
+ rest = current_line.byteslice((@byte_pointer + byte_size)..-1)
2087
+ line = current_line.byteslice(0, @byte_pointer) + part
2088
+ set_current_line(line + rest, line.bytesize)
2089
+ end
2090
+ end
2091
+ alias_method :upcase_word, :em_upper_case
2092
+
2093
+ private def em_kill_region(key)
2094
+ if @byte_pointer > 0
2095
+ byte_size, _ = Reline::Unicode.em_big_backward_word(current_line, @byte_pointer)
2096
+ line, deleted = byteslice!(current_line, @byte_pointer - byte_size, byte_size)
2097
+ set_current_line(line, @byte_pointer - byte_size)
2098
+ @kill_ring.append(deleted, true)
2099
+ end
2100
+ end
2101
+ alias_method :unix_word_rubout, :em_kill_region
2102
+
2103
+ private def copy_for_vi(text)
2104
+ if @config.editing_mode_is?(:vi_insert) or @config.editing_mode_is?(:vi_command)
2105
+ @vi_clipboard = text
2106
+ end
2107
+ end
2108
+
2109
+ private def vi_insert(key)
2110
+ @config.editing_mode = :vi_insert
2111
+ end
2112
+
2113
+ private def vi_add(key)
2114
+ @config.editing_mode = :vi_insert
2115
+ ed_next_char(key)
2116
+ end
2117
+
2118
+ private def vi_command_mode(key)
2119
+ ed_prev_char(key)
2120
+ @config.editing_mode = :vi_command
2121
+ end
2122
+ alias_method :vi_movement_mode, :vi_command_mode
2123
+
2124
+ private def vi_next_word(key, arg: 1)
2125
+ if current_line.bytesize > @byte_pointer
2126
+ byte_size, _ = Reline::Unicode.vi_forward_word(current_line, @byte_pointer, @drop_terminate_spaces)
2127
+ @byte_pointer += byte_size
2128
+ end
2129
+ arg -= 1
2130
+ vi_next_word(key, arg: arg) if arg > 0
2131
+ end
2132
+
2133
+ private def vi_prev_word(key, arg: 1)
2134
+ if @byte_pointer > 0
2135
+ byte_size, _ = Reline::Unicode.vi_backward_word(current_line, @byte_pointer)
2136
+ @byte_pointer -= byte_size
2137
+ end
2138
+ arg -= 1
2139
+ vi_prev_word(key, arg: arg) if arg > 0
2140
+ end
2141
+
2142
+ private def vi_end_word(key, arg: 1, inclusive: false)
2143
+ if current_line.bytesize > @byte_pointer
2144
+ byte_size, _ = Reline::Unicode.vi_forward_end_word(current_line, @byte_pointer)
2145
+ @byte_pointer += byte_size
2146
+ end
2147
+ arg -= 1
2148
+ if inclusive and arg.zero?
2149
+ byte_size = Reline::Unicode.get_next_mbchar_size(current_line, @byte_pointer)
2150
+ if byte_size > 0
2151
+ @byte_pointer += byte_size
2152
+ end
2153
+ end
2154
+ vi_end_word(key, arg: arg) if arg > 0
2155
+ end
2156
+
2157
+ private def vi_next_big_word(key, arg: 1)
2158
+ if current_line.bytesize > @byte_pointer
2159
+ byte_size, _ = Reline::Unicode.vi_big_forward_word(current_line, @byte_pointer)
2160
+ @byte_pointer += byte_size
2161
+ end
2162
+ arg -= 1
2163
+ vi_next_big_word(key, arg: arg) if arg > 0
2164
+ end
2165
+
2166
+ private def vi_prev_big_word(key, arg: 1)
2167
+ if @byte_pointer > 0
2168
+ byte_size, _ = Reline::Unicode.vi_big_backward_word(current_line, @byte_pointer)
2169
+ @byte_pointer -= byte_size
2170
+ end
2171
+ arg -= 1
2172
+ vi_prev_big_word(key, arg: arg) if arg > 0
2173
+ end
2174
+
2175
+ private def vi_end_big_word(key, arg: 1, inclusive: false)
2176
+ if current_line.bytesize > @byte_pointer
2177
+ byte_size, _ = Reline::Unicode.vi_big_forward_end_word(current_line, @byte_pointer)
2178
+ @byte_pointer += byte_size
2179
+ end
2180
+ arg -= 1
2181
+ if inclusive and arg.zero?
2182
+ byte_size = Reline::Unicode.get_next_mbchar_size(current_line, @byte_pointer)
2183
+ if byte_size > 0
2184
+ @byte_pointer += byte_size
2185
+ end
2186
+ end
2187
+ vi_end_big_word(key, arg: arg) if arg > 0
2188
+ end
2189
+
2190
+ private def vi_delete_prev_char(key)
2191
+ if @byte_pointer == 0 and @line_index > 0
2192
+ @byte_pointer = @buffer_of_lines[@line_index - 1].bytesize
2193
+ @buffer_of_lines[@line_index - 1] += @buffer_of_lines.delete_at(@line_index)
2194
+ @line_index -= 1
2195
+ process_auto_indent cursor_dependent: false
2196
+ elsif @byte_pointer > 0
2197
+ byte_size = Reline::Unicode.get_prev_mbchar_size(current_line, @byte_pointer)
2198
+ @byte_pointer -= byte_size
2199
+ line, _ = byteslice!(current_line, @byte_pointer, byte_size)
2200
+ set_current_line(line)
2201
+ end
2202
+ end
2203
+
2204
+ private def vi_insert_at_bol(key)
2205
+ ed_move_to_beg(key)
2206
+ @config.editing_mode = :vi_insert
2207
+ end
2208
+
2209
+ private def vi_add_at_eol(key)
2210
+ ed_move_to_end(key)
2211
+ @config.editing_mode = :vi_insert
2212
+ end
2213
+
2214
+ private def ed_delete_prev_char(key, arg: 1)
2215
+ deleted = +''
2216
+ arg.times do
2217
+ if @byte_pointer > 0
2218
+ byte_size = Reline::Unicode.get_prev_mbchar_size(current_line, @byte_pointer)
2219
+ @byte_pointer -= byte_size
2220
+ line, mbchar = byteslice!(current_line, @byte_pointer, byte_size)
2221
+ set_current_line(line)
2222
+ deleted.prepend(mbchar)
2223
+ end
2224
+ end
2225
+ copy_for_vi(deleted)
2226
+ end
2227
+
2228
+ private def vi_change_meta(key, arg: nil)
2229
+ if @vi_waiting_operator
2230
+ set_current_line('', 0) if @vi_waiting_operator == :vi_change_meta_confirm && arg.nil?
2231
+ @vi_waiting_operator = nil
2232
+ @vi_waiting_operator_arg = nil
2233
+ else
2234
+ @drop_terminate_spaces = true
2235
+ @vi_waiting_operator = :vi_change_meta_confirm
2236
+ @vi_waiting_operator_arg = arg || 1
2237
+ end
2238
+ end
2239
+
2240
+ private def vi_change_meta_confirm(byte_pointer_diff)
2241
+ vi_delete_meta_confirm(byte_pointer_diff)
2242
+ @config.editing_mode = :vi_insert
2243
+ @drop_terminate_spaces = false
2244
+ end
2245
+
2246
+ private def vi_delete_meta(key, arg: nil)
2247
+ if @vi_waiting_operator
2248
+ set_current_line('', 0) if @vi_waiting_operator == :vi_delete_meta_confirm && arg.nil?
2249
+ @vi_waiting_operator = nil
2250
+ @vi_waiting_operator_arg = nil
2251
+ else
2252
+ @vi_waiting_operator = :vi_delete_meta_confirm
2253
+ @vi_waiting_operator_arg = arg || 1
2254
+ end
2255
+ end
2256
+
2257
+ private def vi_delete_meta_confirm(byte_pointer_diff)
2258
+ if byte_pointer_diff > 0
2259
+ line, cut = byteslice!(current_line, @byte_pointer, byte_pointer_diff)
2260
+ elsif byte_pointer_diff < 0
2261
+ line, cut = byteslice!(current_line, @byte_pointer + byte_pointer_diff, -byte_pointer_diff)
2262
+ end
2263
+ copy_for_vi(cut)
2264
+ set_current_line(line || '', @byte_pointer + (byte_pointer_diff < 0 ? byte_pointer_diff : 0))
2265
+ end
2266
+
2267
+ private def vi_yank(key, arg: nil)
2268
+ if @vi_waiting_operator
2269
+ copy_for_vi(current_line) if @vi_waiting_operator == :vi_yank_confirm && arg.nil?
2270
+ @vi_waiting_operator = nil
2271
+ @vi_waiting_operator_arg = nil
2272
+ else
2273
+ @vi_waiting_operator = :vi_yank_confirm
2274
+ @vi_waiting_operator_arg = arg || 1
2275
+ end
2276
+ end
2277
+
2278
+ private def vi_yank_confirm(byte_pointer_diff)
2279
+ if byte_pointer_diff > 0
2280
+ cut = current_line.byteslice(@byte_pointer, byte_pointer_diff)
2281
+ elsif byte_pointer_diff < 0
2282
+ cut = current_line.byteslice(@byte_pointer + byte_pointer_diff, -byte_pointer_diff)
2283
+ end
2284
+ copy_for_vi(cut)
2285
+ end
2286
+
2287
+ private def vi_list_or_eof(key)
2288
+ if buffer_empty?
2289
+ @eof = true
2290
+ finish
2291
+ else
2292
+ ed_newline(key)
2293
+ end
2294
+ end
2295
+ alias_method :vi_end_of_transmission, :vi_list_or_eof
2296
+ alias_method :vi_eof_maybe, :vi_list_or_eof
2297
+
2298
+ private def ed_delete_next_char(key, arg: 1)
2299
+ byte_size = Reline::Unicode.get_next_mbchar_size(current_line, @byte_pointer)
2300
+ unless current_line.empty? || byte_size == 0
2301
+ line, mbchar = byteslice!(current_line, @byte_pointer, byte_size)
2302
+ copy_for_vi(mbchar)
2303
+ if @byte_pointer > 0 && current_line.bytesize == @byte_pointer + byte_size
2304
+ byte_size = Reline::Unicode.get_prev_mbchar_size(line, @byte_pointer)
2305
+ set_current_line(line, @byte_pointer - byte_size)
2306
+ else
2307
+ set_current_line(line, @byte_pointer)
2308
+ end
2309
+ end
2310
+ arg -= 1
2311
+ ed_delete_next_char(key, arg: arg) if arg > 0
2312
+ end
2313
+
2314
+ private def vi_to_history_line(key)
2315
+ if Reline::HISTORY.empty?
2316
+ return
2317
+ end
2318
+ move_history(0, line: :start, cursor: :start)
2319
+ end
2320
+
2321
+ private def vi_histedit(key)
2322
+ path = Tempfile.open { |fp|
2323
+ fp.write whole_lines.join("\n")
2324
+ fp.path
2325
+ }
2326
+ system("#{ENV['EDITOR']} #{path}")
2327
+ @buffer_of_lines = File.read(path).split("\n")
2328
+ @buffer_of_lines = [String.new(encoding: @encoding)] if @buffer_of_lines.empty?
2329
+ @line_index = 0
2330
+ finish
2331
+ end
2332
+
2333
+ private def vi_paste_prev(key, arg: 1)
2334
+ if @vi_clipboard.size > 0
2335
+ cursor_point = @vi_clipboard.grapheme_clusters[0..-2].join
2336
+ set_current_line(byteinsert(current_line, @byte_pointer, @vi_clipboard), @byte_pointer + cursor_point.bytesize)
2337
+ end
2338
+ arg -= 1
2339
+ vi_paste_prev(key, arg: arg) if arg > 0
2340
+ end
2341
+
2342
+ private def vi_paste_next(key, arg: 1)
2343
+ if @vi_clipboard.size > 0
2344
+ byte_size = Reline::Unicode.get_next_mbchar_size(current_line, @byte_pointer)
2345
+ line = byteinsert(current_line, @byte_pointer + byte_size, @vi_clipboard)
2346
+ set_current_line(line, @byte_pointer + @vi_clipboard.bytesize)
2347
+ end
2348
+ arg -= 1
2349
+ vi_paste_next(key, arg: arg) if arg > 0
2350
+ end
2351
+
2352
+ private def ed_argument_digit(key)
2353
+ if @vi_arg.nil?
2354
+ if key.chr.to_i.zero?
2355
+ if key.anybits?(0b10000000)
2356
+ unescaped_key = key ^ 0b10000000
2357
+ unless unescaped_key.chr.to_i.zero?
2358
+ @vi_arg = unescaped_key.chr.to_i
2359
+ end
2360
+ end
2361
+ else
2362
+ @vi_arg = key.chr.to_i
2363
+ end
2364
+ else
2365
+ @vi_arg = @vi_arg * 10 + key.chr.to_i
2366
+ end
2367
+ end
2368
+
2369
+ private def vi_to_column(key, arg: 0)
2370
+ # Implementing behavior of vi, not Readline's vi-mode.
2371
+ @byte_pointer, = current_line.grapheme_clusters.inject([0, 0]) { |(total_byte_size, total_width), gc|
2372
+ mbchar_width = Reline::Unicode.get_mbchar_width(gc)
2373
+ break [total_byte_size, total_width] if (total_width + mbchar_width) >= arg
2374
+ [total_byte_size + gc.bytesize, total_width + mbchar_width]
2375
+ }
2376
+ end
2377
+
2378
+ private def vi_replace_char(key, arg: 1)
2379
+ @waiting_proc = ->(k) {
2380
+ if arg == 1
2381
+ byte_size = Reline::Unicode.get_next_mbchar_size(current_line, @byte_pointer)
2382
+ before = current_line.byteslice(0, @byte_pointer)
2383
+ remaining_point = @byte_pointer + byte_size
2384
+ after = current_line.byteslice(remaining_point, current_line.bytesize - remaining_point)
2385
+ set_current_line(before + k.chr + after)
2386
+ @waiting_proc = nil
2387
+ elsif arg > 1
2388
+ byte_size = 0
2389
+ arg.times do
2390
+ byte_size += Reline::Unicode.get_next_mbchar_size(current_line, @byte_pointer + byte_size)
2391
+ end
2392
+ before = current_line.byteslice(0, @byte_pointer)
2393
+ remaining_point = @byte_pointer + byte_size
2394
+ after = current_line.byteslice(remaining_point, current_line.bytesize - remaining_point)
2395
+ replaced = k.chr * arg
2396
+ set_current_line(before + replaced + after, @byte_pointer + replaced.bytesize)
2397
+ @waiting_proc = nil
2398
+ end
2399
+ }
2400
+ end
2401
+
2402
+ private def vi_next_char(key, arg: 1, inclusive: false)
2403
+ @waiting_proc = ->(key_for_proc) { search_next_char(key_for_proc, arg, inclusive: inclusive) }
2404
+ end
2405
+
2406
+ private def vi_to_next_char(key, arg: 1, inclusive: false)
2407
+ @waiting_proc = ->(key_for_proc) { search_next_char(key_for_proc, arg, need_prev_char: true, inclusive: inclusive) }
2408
+ end
2409
+
2410
+ private def search_next_char(key, arg, need_prev_char: false, inclusive: false)
2411
+ if key.instance_of?(String)
2412
+ inputed_char = key
2413
+ else
2414
+ inputed_char = key.chr
2415
+ end
2416
+ prev_total = nil
2417
+ total = nil
2418
+ found = false
2419
+ current_line.byteslice(@byte_pointer..-1).grapheme_clusters.each do |mbchar|
2420
+ # total has [byte_size, cursor]
2421
+ unless total
2422
+ # skip cursor point
2423
+ width = Reline::Unicode.get_mbchar_width(mbchar)
2424
+ total = [mbchar.bytesize, width]
2425
+ else
2426
+ if inputed_char == mbchar
2427
+ arg -= 1
2428
+ if arg.zero?
2429
+ found = true
2430
+ break
2431
+ end
2432
+ end
2433
+ width = Reline::Unicode.get_mbchar_width(mbchar)
2434
+ prev_total = total
2435
+ total = [total.first + mbchar.bytesize, total.last + width]
2436
+ end
2437
+ end
2438
+ if not need_prev_char and found and total
2439
+ byte_size, _ = total
2440
+ @byte_pointer += byte_size
2441
+ elsif need_prev_char and found and prev_total
2442
+ byte_size, _ = prev_total
2443
+ @byte_pointer += byte_size
2444
+ end
2445
+ if inclusive
2446
+ byte_size = Reline::Unicode.get_next_mbchar_size(current_line, @byte_pointer)
2447
+ if byte_size > 0
2448
+ @byte_pointer += byte_size
2449
+ end
2450
+ end
2451
+ @waiting_proc = nil
2452
+ end
2453
+
2454
+ private def vi_prev_char(key, arg: 1)
2455
+ @waiting_proc = ->(key_for_proc) { search_prev_char(key_for_proc, arg) }
2456
+ end
2457
+
2458
+ private def vi_to_prev_char(key, arg: 1)
2459
+ @waiting_proc = ->(key_for_proc) { search_prev_char(key_for_proc, arg, true) }
2460
+ end
2461
+
2462
+ private def search_prev_char(key, arg, need_next_char = false)
2463
+ if key.instance_of?(String)
2464
+ inputed_char = key
2465
+ else
2466
+ inputed_char = key.chr
2467
+ end
2468
+ prev_total = nil
2469
+ total = nil
2470
+ found = false
2471
+ current_line.byteslice(0..@byte_pointer).grapheme_clusters.reverse_each do |mbchar|
2472
+ # total has [byte_size, cursor]
2473
+ unless total
2474
+ # skip cursor point
2475
+ width = Reline::Unicode.get_mbchar_width(mbchar)
2476
+ total = [mbchar.bytesize, width]
2477
+ else
2478
+ if inputed_char == mbchar
2479
+ arg -= 1
2480
+ if arg.zero?
2481
+ found = true
2482
+ break
2483
+ end
2484
+ end
2485
+ width = Reline::Unicode.get_mbchar_width(mbchar)
2486
+ prev_total = total
2487
+ total = [total.first + mbchar.bytesize, total.last + width]
2488
+ end
2489
+ end
2490
+ if not need_next_char and found and total
2491
+ byte_size, _ = total
2492
+ @byte_pointer -= byte_size
2493
+ elsif need_next_char and found and prev_total
2494
+ byte_size, _ = prev_total
2495
+ @byte_pointer -= byte_size
2496
+ end
2497
+ @waiting_proc = nil
2498
+ end
2499
+
2500
+ private def vi_join_lines(key, arg: 1)
2501
+ if @buffer_of_lines.size > @line_index + 1
2502
+ next_line = @buffer_of_lines.delete_at(@line_index + 1).lstrip
2503
+ set_current_line(current_line + ' ' + next_line, current_line.bytesize)
2504
+ end
2505
+ arg -= 1
2506
+ vi_join_lines(key, arg: arg) if arg > 0
2507
+ end
2508
+
2509
+ private def em_set_mark(key)
2510
+ @mark_pointer = [@byte_pointer, @line_index]
2511
+ end
2512
+ alias_method :set_mark, :em_set_mark
2513
+
2514
+ private def em_exchange_mark(key)
2515
+ return unless @mark_pointer
2516
+ new_pointer = [@byte_pointer, @line_index]
2517
+ @byte_pointer, @line_index = @mark_pointer
2518
+ @mark_pointer = new_pointer
2519
+ end
2520
+ alias_method :exchange_point_and_mark, :em_exchange_mark
2521
+
2522
+ private def emacs_editing_mode(key)
2523
+ @config.editing_mode = :emacs
2524
+ end
2525
+
2526
+ private def vi_editing_mode(key)
2527
+ @config.editing_mode = :vi_insert
2528
+ end
2529
+
2530
+ private def undo(_key)
2531
+ @undoing = true
2532
+
2533
+ return if @input_lines_position <= 0
2534
+
2535
+ @input_lines_position -= 1
2536
+ target_lines, target_cursor_x, target_cursor_y = @input_lines[@input_lines_position]
2537
+ set_current_lines(target_lines.dup, target_cursor_x, target_cursor_y)
2538
+ end
2539
+
2540
+ private def redo(_key)
2541
+ @undoing = true
2542
+
2543
+ return if @input_lines_position >= @input_lines.size - 1
2544
+
2545
+ @input_lines_position += 1
2546
+ target_lines, target_cursor_x, target_cursor_y = @input_lines[@input_lines_position]
2547
+ set_current_lines(target_lines.dup, target_cursor_x, target_cursor_y)
2548
+ end
2549
+
2550
+ private def prev_action_state_value(type)
2551
+ @prev_action_state[0] == type ? @prev_action_state[1] : nil
2552
+ end
2553
+
2554
+ private def set_next_action_state(type, value)
2555
+ @next_action_state = [type, value]
2556
+ end
2557
+ end