docspring 3.0.0 → 3.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (523) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG.md +7 -0
  3. data/Gemfile.lock +4 -4
  4. data/README.md +11 -5
  5. data/docs/CreateHtmlSubmissionData.md +3 -1
  6. data/docs/CreatePdfSubmissionData.md +3 -1
  7. data/docs/PDFApi.md +156 -10
  8. data/docs/PublishVersionData.md +20 -0
  9. data/docs/RestoreVersionData.md +18 -0
  10. data/docs/Submission.md +4 -0
  11. data/docs/SubmissionPreview.md +4 -0
  12. data/docs/Template.md +15 -1
  13. data/docs/TemplateDeleteResponse.md +24 -0
  14. data/docs/TemplatePreview.md +13 -1
  15. data/docs/TemplatePublishVersionResponse.md +22 -0
  16. data/lib/docspring/api/pdf_api.rb +152 -5
  17. data/lib/docspring/api_client.rb +1 -1
  18. data/lib/docspring/models/combined_submission_action.rb +1 -5
  19. data/lib/docspring/models/create_html_submission_data.rb +13 -4
  20. data/lib/docspring/models/create_pdf_submission_data.rb +13 -4
  21. data/lib/docspring/models/publish_version_data.rb +230 -0
  22. data/lib/docspring/models/restore_version_data.rb +221 -0
  23. data/lib/docspring/models/submission.rb +41 -1
  24. data/lib/docspring/models/submission_data_request_event.rb +1 -5
  25. data/lib/docspring/models/submission_preview.rb +41 -1
  26. data/lib/docspring/models/template.rb +106 -4
  27. data/lib/docspring/models/template_delete_response.rb +287 -0
  28. data/lib/docspring/models/template_preview.rb +88 -4
  29. data/lib/docspring/models/template_publish_version_response.rb +282 -0
  30. data/lib/docspring/version.rb +1 -1
  31. data/lib/docspring.rb +4 -0
  32. data/spec/api/pdf_api_spec.rb +27 -2
  33. data/spec/models/create_html_submission_data_spec.rb +6 -0
  34. data/spec/models/create_pdf_submission_data_spec.rb +6 -0
  35. data/spec/models/publish_version_data_spec.rb +42 -0
  36. data/spec/models/restore_version_data_spec.rb +36 -0
  37. data/spec/models/submission_preview_spec.rb +16 -0
  38. data/spec/models/submission_spec.rb +16 -0
  39. data/spec/models/template_delete_response_spec.rb +58 -0
  40. data/spec/models/template_preview_spec.rb +40 -0
  41. data/spec/models/template_publish_version_response_spec.rb +52 -0
  42. data/spec/models/template_spec.rb +46 -0
  43. data/vendor/bundle/ruby/3.3.0/bin/irb +29 -0
  44. data/vendor/bundle/ruby/3.3.0/bin/rdbg +29 -0
  45. data/vendor/bundle/ruby/3.3.0/bin/rdoc +29 -0
  46. data/vendor/bundle/ruby/3.3.0/bin/ri +29 -0
  47. data/vendor/bundle/ruby/3.3.0/cache/ast-2.4.3.gem +0 -0
  48. data/vendor/bundle/ruby/3.3.0/cache/debug-1.10.0.gem +0 -0
  49. data/vendor/bundle/ruby/3.3.0/cache/io-console-0.8.0.gem +0 -0
  50. data/vendor/bundle/ruby/3.3.0/cache/irb-1.15.1.gem +0 -0
  51. data/vendor/bundle/ruby/3.3.0/cache/parser-3.3.7.2.gem +0 -0
  52. data/vendor/bundle/ruby/3.3.0/cache/pp-0.6.2.gem +0 -0
  53. data/vendor/bundle/ruby/3.3.0/cache/prettyprint-0.2.0.gem +0 -0
  54. data/vendor/bundle/ruby/3.3.0/cache/rdoc-6.12.0.gem +0 -0
  55. data/vendor/bundle/ruby/3.3.0/cache/reline-0.6.0.gem +0 -0
  56. data/vendor/bundle/ruby/3.3.0/extensions/arm64-darwin-24/3.3.0/debug-1.10.0/debug/debug.bundle +0 -0
  57. data/vendor/bundle/ruby/3.3.0/extensions/arm64-darwin-24/3.3.0/debug-1.10.0/gem.build_complete +0 -0
  58. data/vendor/bundle/ruby/3.3.0/extensions/arm64-darwin-24/3.3.0/debug-1.10.0/gem_make.out +19 -0
  59. data/vendor/bundle/ruby/3.3.0/extensions/arm64-darwin-24/3.3.0/io-console-0.8.0/gem.build_complete +0 -0
  60. data/vendor/bundle/ruby/3.3.0/extensions/arm64-darwin-24/3.3.0/io-console-0.8.0/gem_make.out +31 -0
  61. data/vendor/bundle/ruby/3.3.0/extensions/arm64-darwin-24/3.3.0/io-console-0.8.0/io/console.bundle +0 -0
  62. data/vendor/bundle/ruby/3.3.0/extensions/arm64-darwin-24/3.3.0/io-console-0.8.0/mkmf.log +447 -0
  63. data/vendor/bundle/ruby/3.3.0/gems/ast-2.4.3/LICENSE.MIT +20 -0
  64. data/vendor/bundle/ruby/3.3.0/gems/ast-2.4.3/README.YARD.md +12 -0
  65. data/vendor/bundle/ruby/3.3.0/gems/ast-2.4.3/lib/ast/node.rb +268 -0
  66. data/vendor/bundle/ruby/3.3.0/gems/ast-2.4.3/lib/ast/processor/mixin.rb +288 -0
  67. data/vendor/bundle/ruby/3.3.0/gems/ast-2.4.3/lib/ast/processor.rb +12 -0
  68. data/vendor/bundle/ruby/3.3.0/gems/ast-2.4.3/lib/ast/sexp.rb +30 -0
  69. data/vendor/bundle/ruby/3.3.0/gems/ast-2.4.3/lib/ast.rb +17 -0
  70. data/vendor/bundle/ruby/3.3.0/gems/debug-1.10.0/CONTRIBUTING.md +573 -0
  71. data/vendor/bundle/ruby/3.3.0/gems/debug-1.10.0/Gemfile +10 -0
  72. data/vendor/bundle/ruby/3.3.0/gems/debug-1.10.0/LICENSE.txt +22 -0
  73. data/vendor/bundle/ruby/3.3.0/gems/debug-1.10.0/README.md +970 -0
  74. data/vendor/bundle/ruby/3.3.0/gems/debug-1.10.0/Rakefile +57 -0
  75. data/vendor/bundle/ruby/3.3.0/gems/debug-1.10.0/TODO.md +23 -0
  76. data/vendor/bundle/ruby/3.3.0/gems/debug-1.10.0/debug.gemspec +33 -0
  77. data/vendor/bundle/ruby/3.3.0/gems/debug-1.10.0/exe/rdbg +53 -0
  78. data/vendor/bundle/ruby/3.3.0/gems/debug-1.10.0/ext/debug/Makefile +270 -0
  79. data/vendor/bundle/ruby/3.3.0/gems/debug-1.10.0/ext/debug/debug.c +228 -0
  80. data/vendor/bundle/ruby/3.3.0/gems/debug-1.10.0/ext/debug/debug_version.h +1 -0
  81. data/vendor/bundle/ruby/3.3.0/gems/debug-1.10.0/ext/debug/extconf.rb +27 -0
  82. data/vendor/bundle/ruby/3.3.0/gems/debug-1.10.0/ext/debug/iseq_collector.c +93 -0
  83. data/vendor/bundle/ruby/3.3.0/gems/debug-1.10.0/lib/debug/abbrev_command.rb +77 -0
  84. data/vendor/bundle/ruby/3.3.0/gems/debug-1.10.0/lib/debug/breakpoint.rb +556 -0
  85. data/vendor/bundle/ruby/3.3.0/gems/debug-1.10.0/lib/debug/client.rb +263 -0
  86. data/vendor/bundle/ruby/3.3.0/gems/debug-1.10.0/lib/debug/color.rb +123 -0
  87. data/vendor/bundle/ruby/3.3.0/gems/debug-1.10.0/lib/debug/config.rb +590 -0
  88. data/vendor/bundle/ruby/3.3.0/gems/debug-1.10.0/lib/debug/console.rb +213 -0
  89. data/vendor/bundle/ruby/3.3.0/gems/debug-1.10.0/lib/debug/dap_custom/traceInspector.rb +336 -0
  90. data/vendor/bundle/ruby/3.3.0/gems/debug-1.10.0/lib/debug/debug.bundle +0 -0
  91. data/vendor/bundle/ruby/3.3.0/gems/debug-1.10.0/lib/debug/frame_info.rb +188 -0
  92. data/vendor/bundle/ruby/3.3.0/gems/debug-1.10.0/lib/debug/irb_integration.rb +37 -0
  93. data/vendor/bundle/ruby/3.3.0/gems/debug-1.10.0/lib/debug/local.rb +115 -0
  94. data/vendor/bundle/ruby/3.3.0/gems/debug-1.10.0/lib/debug/open.rb +13 -0
  95. data/vendor/bundle/ruby/3.3.0/gems/debug-1.10.0/lib/debug/open_nonstop.rb +15 -0
  96. data/vendor/bundle/ruby/3.3.0/gems/debug-1.10.0/lib/debug/prelude.rb +50 -0
  97. data/vendor/bundle/ruby/3.3.0/gems/debug-1.10.0/lib/debug/server.rb +534 -0
  98. data/vendor/bundle/ruby/3.3.0/gems/debug-1.10.0/lib/debug/server_cdp.rb +1348 -0
  99. data/vendor/bundle/ruby/3.3.0/gems/debug-1.10.0/lib/debug/server_dap.rb +1108 -0
  100. data/vendor/bundle/ruby/3.3.0/gems/debug-1.10.0/lib/debug/session.rb +2659 -0
  101. data/vendor/bundle/ruby/3.3.0/gems/debug-1.10.0/lib/debug/source_repository.rb +150 -0
  102. data/vendor/bundle/ruby/3.3.0/gems/debug-1.10.0/lib/debug/start.rb +5 -0
  103. data/vendor/bundle/ruby/3.3.0/gems/debug-1.10.0/lib/debug/thread_client.rb +1455 -0
  104. data/vendor/bundle/ruby/3.3.0/gems/debug-1.10.0/lib/debug/tracer.rb +241 -0
  105. data/vendor/bundle/ruby/3.3.0/gems/debug-1.10.0/lib/debug/version.rb +5 -0
  106. data/vendor/bundle/ruby/3.3.0/gems/debug-1.10.0/lib/debug.rb +9 -0
  107. data/vendor/bundle/ruby/3.3.0/gems/debug-1.10.0/misc/README.md.erb +636 -0
  108. data/vendor/bundle/ruby/3.3.0/gems/io-console-0.8.0/.document +5 -0
  109. data/vendor/bundle/ruby/3.3.0/gems/io-console-0.8.0/BSDL +22 -0
  110. data/vendor/bundle/ruby/3.3.0/gems/io-console-0.8.0/COPYING +56 -0
  111. data/vendor/bundle/ruby/3.3.0/gems/io-console-0.8.0/README.md +46 -0
  112. data/vendor/bundle/ruby/3.3.0/gems/io-console-0.8.0/ext/io/console/Makefile +272 -0
  113. data/vendor/bundle/ruby/3.3.0/gems/io-console-0.8.0/ext/io/console/console.c +1969 -0
  114. data/vendor/bundle/ruby/3.3.0/gems/io-console-0.8.0/ext/io/console/extconf.rb +61 -0
  115. data/vendor/bundle/ruby/3.3.0/gems/io-console-0.8.0/ext/io/console/win32_vk.inc +1390 -0
  116. data/vendor/bundle/ruby/3.3.0/gems/io-console-0.8.0/lib/io/console/size.rb +23 -0
  117. data/vendor/bundle/ruby/3.3.0/gems/io-console-0.8.0/lib/io/console.bundle +0 -0
  118. data/vendor/bundle/ruby/3.3.0/gems/irb-1.15.1/Gemfile +29 -0
  119. data/vendor/bundle/ruby/3.3.0/gems/irb-1.15.1/LICENSE.txt +22 -0
  120. data/vendor/bundle/ruby/3.3.0/gems/irb-1.15.1/README.md +125 -0
  121. data/vendor/bundle/ruby/3.3.0/gems/irb-1.15.1/Rakefile +52 -0
  122. data/vendor/bundle/ruby/3.3.0/gems/irb-1.15.1/bin/console +6 -0
  123. data/vendor/bundle/ruby/3.3.0/gems/irb-1.15.1/bin/setup +6 -0
  124. data/vendor/bundle/ruby/3.3.0/gems/irb-1.15.1/doc/irb/irb-tools.rd.ja +184 -0
  125. data/vendor/bundle/ruby/3.3.0/gems/irb-1.15.1/doc/irb/irb.rd.ja +425 -0
  126. data/vendor/bundle/ruby/3.3.0/gems/irb-1.15.1/exe/irb +9 -0
  127. data/vendor/bundle/ruby/3.3.0/gems/irb-1.15.1/irb.gemspec +46 -0
  128. data/vendor/bundle/ruby/3.3.0/gems/irb-1.15.1/lib/irb/cmd/nop.rb +4 -0
  129. data/vendor/bundle/ruby/3.3.0/gems/irb-1.15.1/lib/irb/color.rb +263 -0
  130. data/vendor/bundle/ruby/3.3.0/gems/irb-1.15.1/lib/irb/color_printer.rb +56 -0
  131. data/vendor/bundle/ruby/3.3.0/gems/irb-1.15.1/lib/irb/command/backtrace.rb +17 -0
  132. data/vendor/bundle/ruby/3.3.0/gems/irb-1.15.1/lib/irb/command/base.rb +60 -0
  133. data/vendor/bundle/ruby/3.3.0/gems/irb-1.15.1/lib/irb/command/break.rb +17 -0
  134. data/vendor/bundle/ruby/3.3.0/gems/irb-1.15.1/lib/irb/command/catch.rb +17 -0
  135. data/vendor/bundle/ruby/3.3.0/gems/irb-1.15.1/lib/irb/command/cd.rb +51 -0
  136. data/vendor/bundle/ruby/3.3.0/gems/irb-1.15.1/lib/irb/command/chws.rb +40 -0
  137. data/vendor/bundle/ruby/3.3.0/gems/irb-1.15.1/lib/irb/command/context.rb +16 -0
  138. data/vendor/bundle/ruby/3.3.0/gems/irb-1.15.1/lib/irb/command/continue.rb +17 -0
  139. data/vendor/bundle/ruby/3.3.0/gems/irb-1.15.1/lib/irb/command/copy.rb +73 -0
  140. data/vendor/bundle/ruby/3.3.0/gems/irb-1.15.1/lib/irb/command/debug.rb +73 -0
  141. data/vendor/bundle/ruby/3.3.0/gems/irb-1.15.1/lib/irb/command/delete.rb +17 -0
  142. data/vendor/bundle/ruby/3.3.0/gems/irb-1.15.1/lib/irb/command/disable_irb.rb +19 -0
  143. data/vendor/bundle/ruby/3.3.0/gems/irb-1.15.1/lib/irb/command/edit.rb +63 -0
  144. data/vendor/bundle/ruby/3.3.0/gems/irb-1.15.1/lib/irb/command/exit.rb +18 -0
  145. data/vendor/bundle/ruby/3.3.0/gems/irb-1.15.1/lib/irb/command/finish.rb +17 -0
  146. data/vendor/bundle/ruby/3.3.0/gems/irb-1.15.1/lib/irb/command/force_exit.rb +18 -0
  147. data/vendor/bundle/ruby/3.3.0/gems/irb-1.15.1/lib/irb/command/help.rb +83 -0
  148. data/vendor/bundle/ruby/3.3.0/gems/irb-1.15.1/lib/irb/command/history.rb +45 -0
  149. data/vendor/bundle/ruby/3.3.0/gems/irb-1.15.1/lib/irb/command/info.rb +17 -0
  150. data/vendor/bundle/ruby/3.3.0/gems/irb-1.15.1/lib/irb/command/internal_helpers.rb +27 -0
  151. data/vendor/bundle/ruby/3.3.0/gems/irb-1.15.1/lib/irb/command/irb_info.rb +33 -0
  152. data/vendor/bundle/ruby/3.3.0/gems/irb-1.15.1/lib/irb/command/load.rb +91 -0
  153. data/vendor/bundle/ruby/3.3.0/gems/irb-1.15.1/lib/irb/command/ls.rb +167 -0
  154. data/vendor/bundle/ruby/3.3.0/gems/irb-1.15.1/lib/irb/command/measure.rb +49 -0
  155. data/vendor/bundle/ruby/3.3.0/gems/irb-1.15.1/lib/irb/command/next.rb +17 -0
  156. data/vendor/bundle/ruby/3.3.0/gems/irb-1.15.1/lib/irb/command/pushws.rb +65 -0
  157. data/vendor/bundle/ruby/3.3.0/gems/irb-1.15.1/lib/irb/command/show_doc.rb +51 -0
  158. data/vendor/bundle/ruby/3.3.0/gems/irb-1.15.1/lib/irb/command/show_source.rb +74 -0
  159. data/vendor/bundle/ruby/3.3.0/gems/irb-1.15.1/lib/irb/command/step.rb +17 -0
  160. data/vendor/bundle/ruby/3.3.0/gems/irb-1.15.1/lib/irb/command/subirb.rb +123 -0
  161. data/vendor/bundle/ruby/3.3.0/gems/irb-1.15.1/lib/irb/command/whereami.rb +23 -0
  162. data/vendor/bundle/ruby/3.3.0/gems/irb-1.15.1/lib/irb/command.rb +23 -0
  163. data/vendor/bundle/ruby/3.3.0/gems/irb-1.15.1/lib/irb/completion.rb +504 -0
  164. data/vendor/bundle/ruby/3.3.0/gems/irb-1.15.1/lib/irb/context.rb +751 -0
  165. data/vendor/bundle/ruby/3.3.0/gems/irb-1.15.1/lib/irb/debug/ui.rb +101 -0
  166. data/vendor/bundle/ruby/3.3.0/gems/irb-1.15.1/lib/irb/debug.rb +127 -0
  167. data/vendor/bundle/ruby/3.3.0/gems/irb-1.15.1/lib/irb/default_commands.rb +279 -0
  168. data/vendor/bundle/ruby/3.3.0/gems/irb-1.15.1/lib/irb/easter-egg.rb +152 -0
  169. data/vendor/bundle/ruby/3.3.0/gems/irb-1.15.1/lib/irb/ext/change-ws.rb +37 -0
  170. data/vendor/bundle/ruby/3.3.0/gems/irb-1.15.1/lib/irb/ext/eval_history.rb +149 -0
  171. data/vendor/bundle/ruby/3.3.0/gems/irb-1.15.1/lib/irb/ext/loader.rb +127 -0
  172. data/vendor/bundle/ruby/3.3.0/gems/irb-1.15.1/lib/irb/ext/multi-irb.rb +258 -0
  173. data/vendor/bundle/ruby/3.3.0/gems/irb-1.15.1/lib/irb/ext/tracer.rb +39 -0
  174. data/vendor/bundle/ruby/3.3.0/gems/irb-1.15.1/lib/irb/ext/use-loader.rb +67 -0
  175. data/vendor/bundle/ruby/3.3.0/gems/irb-1.15.1/lib/irb/ext/workspaces.rb +36 -0
  176. data/vendor/bundle/ruby/3.3.0/gems/irb-1.15.1/lib/irb/frame.rb +80 -0
  177. data/vendor/bundle/ruby/3.3.0/gems/irb-1.15.1/lib/irb/help.rb +28 -0
  178. data/vendor/bundle/ruby/3.3.0/gems/irb-1.15.1/lib/irb/helper_method/base.rb +16 -0
  179. data/vendor/bundle/ruby/3.3.0/gems/irb-1.15.1/lib/irb/helper_method/conf.rb +11 -0
  180. data/vendor/bundle/ruby/3.3.0/gems/irb-1.15.1/lib/irb/helper_method.rb +29 -0
  181. data/vendor/bundle/ruby/3.3.0/gems/irb-1.15.1/lib/irb/history.rb +116 -0
  182. data/vendor/bundle/ruby/3.3.0/gems/irb-1.15.1/lib/irb/init.rb +540 -0
  183. data/vendor/bundle/ruby/3.3.0/gems/irb-1.15.1/lib/irb/input-method.rb +515 -0
  184. data/vendor/bundle/ruby/3.3.0/gems/irb-1.15.1/lib/irb/inspector.rb +136 -0
  185. data/vendor/bundle/ruby/3.3.0/gems/irb-1.15.1/lib/irb/lc/error.rb +52 -0
  186. data/vendor/bundle/ruby/3.3.0/gems/irb-1.15.1/lib/irb/lc/help-message +55 -0
  187. data/vendor/bundle/ruby/3.3.0/gems/irb-1.15.1/lib/irb/lc/ja/error.rb +53 -0
  188. data/vendor/bundle/ruby/3.3.0/gems/irb-1.15.1/lib/irb/lc/ja/help-message +58 -0
  189. data/vendor/bundle/ruby/3.3.0/gems/irb-1.15.1/lib/irb/locale.rb +153 -0
  190. data/vendor/bundle/ruby/3.3.0/gems/irb-1.15.1/lib/irb/nesting_parser.rb +239 -0
  191. data/vendor/bundle/ruby/3.3.0/gems/irb-1.15.1/lib/irb/notifier.rb +230 -0
  192. data/vendor/bundle/ruby/3.3.0/gems/irb-1.15.1/lib/irb/output-method.rb +80 -0
  193. data/vendor/bundle/ruby/3.3.0/gems/irb-1.15.1/lib/irb/pager.rb +213 -0
  194. data/vendor/bundle/ruby/3.3.0/gems/irb-1.15.1/lib/irb/ruby-lex.rb +476 -0
  195. data/vendor/bundle/ruby/3.3.0/gems/irb-1.15.1/lib/irb/ruby_logo.aa +118 -0
  196. data/vendor/bundle/ruby/3.3.0/gems/irb-1.15.1/lib/irb/source_finder.rb +138 -0
  197. data/vendor/bundle/ruby/3.3.0/gems/irb-1.15.1/lib/irb/statement.rb +101 -0
  198. data/vendor/bundle/ruby/3.3.0/gems/irb-1.15.1/lib/irb/version.rb +11 -0
  199. data/vendor/bundle/ruby/3.3.0/gems/irb-1.15.1/lib/irb/workspace.rb +171 -0
  200. data/vendor/bundle/ruby/3.3.0/gems/irb-1.15.1/lib/irb/ws-for-case-2.rb +9 -0
  201. data/vendor/bundle/ruby/3.3.0/gems/irb-1.15.1/lib/irb/xmp.rb +164 -0
  202. data/vendor/bundle/ruby/3.3.0/gems/irb-1.15.1/lib/irb.rb +736 -0
  203. data/vendor/bundle/ruby/3.3.0/gems/irb-1.15.1/man/irb.1 +292 -0
  204. data/vendor/bundle/ruby/3.3.0/gems/parser-3.3.7.2/LICENSE.txt +26 -0
  205. data/vendor/bundle/ruby/3.3.0/gems/parser-3.3.7.2/bin/ruby-parse +7 -0
  206. data/vendor/bundle/ruby/3.3.0/gems/parser-3.3.7.2/bin/ruby-rewrite +7 -0
  207. data/vendor/bundle/ruby/3.3.0/gems/parser-3.3.7.2/lib/gauntlet_parser.rb +123 -0
  208. data/vendor/bundle/ruby/3.3.0/gems/parser-3.3.7.2/lib/parser/all.rb +17 -0
  209. data/vendor/bundle/ruby/3.3.0/gems/parser-3.3.7.2/lib/parser/ast/node.rb +40 -0
  210. data/vendor/bundle/ruby/3.3.0/gems/parser-3.3.7.2/lib/parser/ast/processor.rb +293 -0
  211. data/vendor/bundle/ruby/3.3.0/gems/parser-3.3.7.2/lib/parser/base.rb +291 -0
  212. data/vendor/bundle/ruby/3.3.0/gems/parser-3.3.7.2/lib/parser/builders/default.rb +2338 -0
  213. data/vendor/bundle/ruby/3.3.0/gems/parser-3.3.7.2/lib/parser/clobbering_error.rb +13 -0
  214. data/vendor/bundle/ruby/3.3.0/gems/parser-3.3.7.2/lib/parser/color.rb +32 -0
  215. data/vendor/bundle/ruby/3.3.0/gems/parser-3.3.7.2/lib/parser/context.rb +51 -0
  216. data/vendor/bundle/ruby/3.3.0/gems/parser-3.3.7.2/lib/parser/current.rb +137 -0
  217. data/vendor/bundle/ruby/3.3.0/gems/parser-3.3.7.2/lib/parser/current_arg_stack.rb +46 -0
  218. data/vendor/bundle/ruby/3.3.0/gems/parser-3.3.7.2/lib/parser/deprecation.rb +13 -0
  219. data/vendor/bundle/ruby/3.3.0/gems/parser-3.3.7.2/lib/parser/diagnostic/engine.rb +104 -0
  220. data/vendor/bundle/ruby/3.3.0/gems/parser-3.3.7.2/lib/parser/diagnostic.rb +163 -0
  221. data/vendor/bundle/ruby/3.3.0/gems/parser-3.3.7.2/lib/parser/lexer/dedenter.rb +88 -0
  222. data/vendor/bundle/ruby/3.3.0/gems/parser-3.3.7.2/lib/parser/lexer/explanation.rb +55 -0
  223. data/vendor/bundle/ruby/3.3.0/gems/parser-3.3.7.2/lib/parser/lexer/literal.rb +284 -0
  224. data/vendor/bundle/ruby/3.3.0/gems/parser-3.3.7.2/lib/parser/lexer/stack_state.rb +49 -0
  225. data/vendor/bundle/ruby/3.3.0/gems/parser-3.3.7.2/lib/parser/lexer-F0.rb +12922 -0
  226. data/vendor/bundle/ruby/3.3.0/gems/parser-3.3.7.2/lib/parser/lexer-F1.rb +14875 -0
  227. data/vendor/bundle/ruby/3.3.0/gems/parser-3.3.7.2/lib/parser/lexer-strings.rb +5424 -0
  228. data/vendor/bundle/ruby/3.3.0/gems/parser-3.3.7.2/lib/parser/macruby.rb +9634 -0
  229. data/vendor/bundle/ruby/3.3.0/gems/parser-3.3.7.2/lib/parser/max_numparam_stack.rb +56 -0
  230. data/vendor/bundle/ruby/3.3.0/gems/parser-3.3.7.2/lib/parser/messages.rb +125 -0
  231. data/vendor/bundle/ruby/3.3.0/gems/parser-3.3.7.2/lib/parser/meta.rb +48 -0
  232. data/vendor/bundle/ruby/3.3.0/gems/parser-3.3.7.2/lib/parser/rewriter.rb +105 -0
  233. data/vendor/bundle/ruby/3.3.0/gems/parser-3.3.7.2/lib/parser/ruby18.rb +9272 -0
  234. data/vendor/bundle/ruby/3.3.0/gems/parser-3.3.7.2/lib/parser/ruby19.rb +9558 -0
  235. data/vendor/bundle/ruby/3.3.0/gems/parser-3.3.7.2/lib/parser/ruby20.rb +10229 -0
  236. data/vendor/bundle/ruby/3.3.0/gems/parser-3.3.7.2/lib/parser/ruby21.rb +10203 -0
  237. data/vendor/bundle/ruby/3.3.0/gems/parser-3.3.7.2/lib/parser/ruby22.rb +10302 -0
  238. data/vendor/bundle/ruby/3.3.0/gems/parser-3.3.7.2/lib/parser/ruby23.rb +10322 -0
  239. data/vendor/bundle/ruby/3.3.0/gems/parser-3.3.7.2/lib/parser/ruby24.rb +10454 -0
  240. data/vendor/bundle/ruby/3.3.0/gems/parser-3.3.7.2/lib/parser/ruby25.rb +10374 -0
  241. data/vendor/bundle/ruby/3.3.0/gems/parser-3.3.7.2/lib/parser/ruby26.rb +10352 -0
  242. data/vendor/bundle/ruby/3.3.0/gems/parser-3.3.7.2/lib/parser/ruby27.rb +11947 -0
  243. data/vendor/bundle/ruby/3.3.0/gems/parser-3.3.7.2/lib/parser/ruby30.rb +12243 -0
  244. data/vendor/bundle/ruby/3.3.0/gems/parser-3.3.7.2/lib/parser/ruby31.rb +12716 -0
  245. data/vendor/bundle/ruby/3.3.0/gems/parser-3.3.7.2/lib/parser/ruby32.rb +12704 -0
  246. data/vendor/bundle/ruby/3.3.0/gems/parser-3.3.7.2/lib/parser/ruby33.rb +12589 -0
  247. data/vendor/bundle/ruby/3.3.0/gems/parser-3.3.7.2/lib/parser/ruby34.rb +12596 -0
  248. data/vendor/bundle/ruby/3.3.0/gems/parser-3.3.7.2/lib/parser/rubymotion.rb +9515 -0
  249. data/vendor/bundle/ruby/3.3.0/gems/parser-3.3.7.2/lib/parser/runner/ruby_parse.rb +157 -0
  250. data/vendor/bundle/ruby/3.3.0/gems/parser-3.3.7.2/lib/parser/runner/ruby_rewrite.rb +101 -0
  251. data/vendor/bundle/ruby/3.3.0/gems/parser-3.3.7.2/lib/parser/runner.rb +299 -0
  252. data/vendor/bundle/ruby/3.3.0/gems/parser-3.3.7.2/lib/parser/source/buffer.rb +369 -0
  253. data/vendor/bundle/ruby/3.3.0/gems/parser-3.3.7.2/lib/parser/source/comment/associator.rb +233 -0
  254. data/vendor/bundle/ruby/3.3.0/gems/parser-3.3.7.2/lib/parser/source/comment.rb +134 -0
  255. data/vendor/bundle/ruby/3.3.0/gems/parser-3.3.7.2/lib/parser/source/map/collection.rb +18 -0
  256. data/vendor/bundle/ruby/3.3.0/gems/parser-3.3.7.2/lib/parser/source/map/condition.rb +21 -0
  257. data/vendor/bundle/ruby/3.3.0/gems/parser-3.3.7.2/lib/parser/source/map/constant.rb +32 -0
  258. data/vendor/bundle/ruby/3.3.0/gems/parser-3.3.7.2/lib/parser/source/map/definition.rb +23 -0
  259. data/vendor/bundle/ruby/3.3.0/gems/parser-3.3.7.2/lib/parser/source/map/for.rb +19 -0
  260. data/vendor/bundle/ruby/3.3.0/gems/parser-3.3.7.2/lib/parser/source/map/heredoc.rb +19 -0
  261. data/vendor/bundle/ruby/3.3.0/gems/parser-3.3.7.2/lib/parser/source/map/index.rb +33 -0
  262. data/vendor/bundle/ruby/3.3.0/gems/parser-3.3.7.2/lib/parser/source/map/keyword.rb +20 -0
  263. data/vendor/bundle/ruby/3.3.0/gems/parser-3.3.7.2/lib/parser/source/map/method_definition.rb +25 -0
  264. data/vendor/bundle/ruby/3.3.0/gems/parser-3.3.7.2/lib/parser/source/map/objc_kwarg.rb +19 -0
  265. data/vendor/bundle/ruby/3.3.0/gems/parser-3.3.7.2/lib/parser/source/map/operator.rb +17 -0
  266. data/vendor/bundle/ruby/3.3.0/gems/parser-3.3.7.2/lib/parser/source/map/rescue_body.rb +21 -0
  267. data/vendor/bundle/ruby/3.3.0/gems/parser-3.3.7.2/lib/parser/source/map/send.rb +36 -0
  268. data/vendor/bundle/ruby/3.3.0/gems/parser-3.3.7.2/lib/parser/source/map/ternary.rb +18 -0
  269. data/vendor/bundle/ruby/3.3.0/gems/parser-3.3.7.2/lib/parser/source/map/variable.rb +31 -0
  270. data/vendor/bundle/ruby/3.3.0/gems/parser-3.3.7.2/lib/parser/source/map.rb +186 -0
  271. data/vendor/bundle/ruby/3.3.0/gems/parser-3.3.7.2/lib/parser/source/range.rb +326 -0
  272. data/vendor/bundle/ruby/3.3.0/gems/parser-3.3.7.2/lib/parser/source/rewriter/action.rb +44 -0
  273. data/vendor/bundle/ruby/3.3.0/gems/parser-3.3.7.2/lib/parser/source/rewriter.rb +513 -0
  274. data/vendor/bundle/ruby/3.3.0/gems/parser-3.3.7.2/lib/parser/source/tree_rewriter/action.rb +243 -0
  275. data/vendor/bundle/ruby/3.3.0/gems/parser-3.3.7.2/lib/parser/source/tree_rewriter.rb +431 -0
  276. data/vendor/bundle/ruby/3.3.0/gems/parser-3.3.7.2/lib/parser/static_environment.rb +134 -0
  277. data/vendor/bundle/ruby/3.3.0/gems/parser-3.3.7.2/lib/parser/syntax_error.rb +21 -0
  278. data/vendor/bundle/ruby/3.3.0/gems/parser-3.3.7.2/lib/parser/tree_rewriter.rb +133 -0
  279. data/vendor/bundle/ruby/3.3.0/gems/parser-3.3.7.2/lib/parser/unknown_encoding_in_magic_comment_error.rb +15 -0
  280. data/vendor/bundle/ruby/3.3.0/gems/parser-3.3.7.2/lib/parser/variables_stack.rb +36 -0
  281. data/vendor/bundle/ruby/3.3.0/gems/parser-3.3.7.2/lib/parser/version.rb +5 -0
  282. data/vendor/bundle/ruby/3.3.0/gems/parser-3.3.7.2/lib/parser.rb +91 -0
  283. data/vendor/bundle/ruby/3.3.0/gems/parser-3.3.7.2/parser.gemspec +43 -0
  284. data/vendor/bundle/ruby/3.3.0/gems/pp-0.6.2/BSDL +22 -0
  285. data/vendor/bundle/ruby/3.3.0/gems/pp-0.6.2/COPYING +56 -0
  286. data/vendor/bundle/ruby/3.3.0/gems/pp-0.6.2/lib/pp.rb +699 -0
  287. data/vendor/bundle/ruby/3.3.0/gems/pp-0.6.2/pp.gemspec +35 -0
  288. data/vendor/bundle/ruby/3.3.0/gems/prettyprint-0.2.0/.github/dependabot.yml +6 -0
  289. data/vendor/bundle/ruby/3.3.0/gems/prettyprint-0.2.0/.github/workflows/test.yml +41 -0
  290. data/vendor/bundle/ruby/3.3.0/gems/prettyprint-0.2.0/.gitignore +8 -0
  291. data/vendor/bundle/ruby/3.3.0/gems/prettyprint-0.2.0/Gemfile +4 -0
  292. data/vendor/bundle/ruby/3.3.0/gems/prettyprint-0.2.0/LICENSE.txt +22 -0
  293. data/vendor/bundle/ruby/3.3.0/gems/prettyprint-0.2.0/README.md +43 -0
  294. data/vendor/bundle/ruby/3.3.0/gems/prettyprint-0.2.0/Rakefile +10 -0
  295. data/vendor/bundle/ruby/3.3.0/gems/prettyprint-0.2.0/bin/console +14 -0
  296. data/vendor/bundle/ruby/3.3.0/gems/prettyprint-0.2.0/bin/setup +8 -0
  297. data/vendor/bundle/ruby/3.3.0/gems/prettyprint-0.2.0/lib/prettyprint.rb +558 -0
  298. data/vendor/bundle/ruby/3.3.0/gems/prettyprint-0.2.0/prettyprint.gemspec +29 -0
  299. data/vendor/bundle/ruby/3.3.0/gems/rdoc-6.12.0/CONTRIBUTING.rdoc +219 -0
  300. data/vendor/bundle/ruby/3.3.0/gems/rdoc-6.12.0/CVE-2013-0256.rdoc +49 -0
  301. data/vendor/bundle/ruby/3.3.0/gems/rdoc-6.12.0/ExampleMarkdown.md +39 -0
  302. data/vendor/bundle/ruby/3.3.0/gems/rdoc-6.12.0/ExampleRDoc.rdoc +210 -0
  303. data/vendor/bundle/ruby/3.3.0/gems/rdoc-6.12.0/History.rdoc +1668 -0
  304. data/vendor/bundle/ruby/3.3.0/gems/rdoc-6.12.0/LEGAL.rdoc +50 -0
  305. data/vendor/bundle/ruby/3.3.0/gems/rdoc-6.12.0/LICENSE.rdoc +59 -0
  306. data/vendor/bundle/ruby/3.3.0/gems/rdoc-6.12.0/README.rdoc +142 -0
  307. data/vendor/bundle/ruby/3.3.0/gems/rdoc-6.12.0/RI.md +842 -0
  308. data/vendor/bundle/ruby/3.3.0/gems/rdoc-6.12.0/TODO.rdoc +60 -0
  309. data/vendor/bundle/ruby/3.3.0/gems/rdoc-6.12.0/exe/rdoc +43 -0
  310. data/vendor/bundle/ruby/3.3.0/gems/rdoc-6.12.0/exe/ri +12 -0
  311. data/vendor/bundle/ruby/3.3.0/gems/rdoc-6.12.0/lib/rdoc/code_object/alias.rb +111 -0
  312. data/vendor/bundle/ruby/3.3.0/gems/rdoc-6.12.0/lib/rdoc/code_object/anon_class.rb +10 -0
  313. data/vendor/bundle/ruby/3.3.0/gems/rdoc-6.12.0/lib/rdoc/code_object/any_method.rb +379 -0
  314. data/vendor/bundle/ruby/3.3.0/gems/rdoc-6.12.0/lib/rdoc/code_object/attr.rb +175 -0
  315. data/vendor/bundle/ruby/3.3.0/gems/rdoc-6.12.0/lib/rdoc/code_object/class_module.rb +871 -0
  316. data/vendor/bundle/ruby/3.3.0/gems/rdoc-6.12.0/lib/rdoc/code_object/constant.rb +186 -0
  317. data/vendor/bundle/ruby/3.3.0/gems/rdoc-6.12.0/lib/rdoc/code_object/context/section.rb +175 -0
  318. data/vendor/bundle/ruby/3.3.0/gems/rdoc-6.12.0/lib/rdoc/code_object/context.rb +1264 -0
  319. data/vendor/bundle/ruby/3.3.0/gems/rdoc-6.12.0/lib/rdoc/code_object/extend.rb +9 -0
  320. data/vendor/bundle/ruby/3.3.0/gems/rdoc-6.12.0/lib/rdoc/code_object/ghost_method.rb +6 -0
  321. data/vendor/bundle/ruby/3.3.0/gems/rdoc-6.12.0/lib/rdoc/code_object/include.rb +9 -0
  322. data/vendor/bundle/ruby/3.3.0/gems/rdoc-6.12.0/lib/rdoc/code_object/meta_method.rb +6 -0
  323. data/vendor/bundle/ruby/3.3.0/gems/rdoc-6.12.0/lib/rdoc/code_object/method_attr.rb +430 -0
  324. data/vendor/bundle/ruby/3.3.0/gems/rdoc-6.12.0/lib/rdoc/code_object/mixin.rb +120 -0
  325. data/vendor/bundle/ruby/3.3.0/gems/rdoc-6.12.0/lib/rdoc/code_object/normal_class.rb +92 -0
  326. data/vendor/bundle/ruby/3.3.0/gems/rdoc-6.12.0/lib/rdoc/code_object/normal_module.rb +73 -0
  327. data/vendor/bundle/ruby/3.3.0/gems/rdoc-6.12.0/lib/rdoc/code_object/require.rb +51 -0
  328. data/vendor/bundle/ruby/3.3.0/gems/rdoc-6.12.0/lib/rdoc/code_object/single_class.rb +30 -0
  329. data/vendor/bundle/ruby/3.3.0/gems/rdoc-6.12.0/lib/rdoc/code_object/top_level.rb +291 -0
  330. data/vendor/bundle/ruby/3.3.0/gems/rdoc-6.12.0/lib/rdoc/code_object.rb +426 -0
  331. data/vendor/bundle/ruby/3.3.0/gems/rdoc-6.12.0/lib/rdoc/code_objects.rb +5 -0
  332. data/vendor/bundle/ruby/3.3.0/gems/rdoc-6.12.0/lib/rdoc/comment.rb +239 -0
  333. data/vendor/bundle/ruby/3.3.0/gems/rdoc-6.12.0/lib/rdoc/cross_reference.rb +228 -0
  334. data/vendor/bundle/ruby/3.3.0/gems/rdoc-6.12.0/lib/rdoc/encoding.rb +120 -0
  335. data/vendor/bundle/ruby/3.3.0/gems/rdoc-6.12.0/lib/rdoc/erb_partial.rb +18 -0
  336. data/vendor/bundle/ruby/3.3.0/gems/rdoc-6.12.0/lib/rdoc/erbio.rb +37 -0
  337. data/vendor/bundle/ruby/3.3.0/gems/rdoc-6.12.0/lib/rdoc/generator/darkfish.rb +824 -0
  338. data/vendor/bundle/ruby/3.3.0/gems/rdoc-6.12.0/lib/rdoc/generator/json_index.rb +300 -0
  339. data/vendor/bundle/ruby/3.3.0/gems/rdoc-6.12.0/lib/rdoc/generator/markup.rb +159 -0
  340. data/vendor/bundle/ruby/3.3.0/gems/rdoc-6.12.0/lib/rdoc/generator/pot/message_extractor.rb +68 -0
  341. data/vendor/bundle/ruby/3.3.0/gems/rdoc-6.12.0/lib/rdoc/generator/pot/po.rb +84 -0
  342. data/vendor/bundle/ruby/3.3.0/gems/rdoc-6.12.0/lib/rdoc/generator/pot/po_entry.rb +141 -0
  343. data/vendor/bundle/ruby/3.3.0/gems/rdoc-6.12.0/lib/rdoc/generator/pot.rb +99 -0
  344. data/vendor/bundle/ruby/3.3.0/gems/rdoc-6.12.0/lib/rdoc/generator/ri.rb +30 -0
  345. data/vendor/bundle/ruby/3.3.0/gems/rdoc-6.12.0/lib/rdoc/generator/template/darkfish/_footer.rhtml +5 -0
  346. data/vendor/bundle/ruby/3.3.0/gems/rdoc-6.12.0/lib/rdoc/generator/template/darkfish/_head.rhtml +43 -0
  347. data/vendor/bundle/ruby/3.3.0/gems/rdoc-6.12.0/lib/rdoc/generator/template/darkfish/_sidebar_VCS_info.rhtml +19 -0
  348. data/vendor/bundle/ruby/3.3.0/gems/rdoc-6.12.0/lib/rdoc/generator/template/darkfish/_sidebar_classes.rhtml +34 -0
  349. data/vendor/bundle/ruby/3.3.0/gems/rdoc-6.12.0/lib/rdoc/generator/template/darkfish/_sidebar_extends.rhtml +15 -0
  350. data/vendor/bundle/ruby/3.3.0/gems/rdoc-6.12.0/lib/rdoc/generator/template/darkfish/_sidebar_in_files.rhtml +9 -0
  351. data/vendor/bundle/ruby/3.3.0/gems/rdoc-6.12.0/lib/rdoc/generator/template/darkfish/_sidebar_includes.rhtml +15 -0
  352. data/vendor/bundle/ruby/3.3.0/gems/rdoc-6.12.0/lib/rdoc/generator/template/darkfish/_sidebar_installed.rhtml +15 -0
  353. data/vendor/bundle/ruby/3.3.0/gems/rdoc-6.12.0/lib/rdoc/generator/template/darkfish/_sidebar_methods.rhtml +21 -0
  354. data/vendor/bundle/ruby/3.3.0/gems/rdoc-6.12.0/lib/rdoc/generator/template/darkfish/_sidebar_navigation.rhtml +11 -0
  355. data/vendor/bundle/ruby/3.3.0/gems/rdoc-6.12.0/lib/rdoc/generator/template/darkfish/_sidebar_pages.rhtml +32 -0
  356. data/vendor/bundle/ruby/3.3.0/gems/rdoc-6.12.0/lib/rdoc/generator/template/darkfish/_sidebar_parent.rhtml +6 -0
  357. data/vendor/bundle/ruby/3.3.0/gems/rdoc-6.12.0/lib/rdoc/generator/template/darkfish/_sidebar_search.rhtml +14 -0
  358. data/vendor/bundle/ruby/3.3.0/gems/rdoc-6.12.0/lib/rdoc/generator/template/darkfish/_sidebar_sections.rhtml +11 -0
  359. data/vendor/bundle/ruby/3.3.0/gems/rdoc-6.12.0/lib/rdoc/generator/template/darkfish/_sidebar_table_of_contents.rhtml +39 -0
  360. data/vendor/bundle/ruby/3.3.0/gems/rdoc-6.12.0/lib/rdoc/generator/template/darkfish/_sidebar_toggle.rhtml +3 -0
  361. data/vendor/bundle/ruby/3.3.0/gems/rdoc-6.12.0/lib/rdoc/generator/template/darkfish/class.rhtml +206 -0
  362. data/vendor/bundle/ruby/3.3.0/gems/rdoc-6.12.0/lib/rdoc/generator/template/darkfish/css/fonts.css +167 -0
  363. data/vendor/bundle/ruby/3.3.0/gems/rdoc-6.12.0/lib/rdoc/generator/template/darkfish/css/rdoc.css +668 -0
  364. data/vendor/bundle/ruby/3.3.0/gems/rdoc-6.12.0/lib/rdoc/generator/template/darkfish/fonts/Lato-Light.ttf +0 -0
  365. data/vendor/bundle/ruby/3.3.0/gems/rdoc-6.12.0/lib/rdoc/generator/template/darkfish/fonts/Lato-LightItalic.ttf +0 -0
  366. data/vendor/bundle/ruby/3.3.0/gems/rdoc-6.12.0/lib/rdoc/generator/template/darkfish/fonts/Lato-Regular.ttf +0 -0
  367. data/vendor/bundle/ruby/3.3.0/gems/rdoc-6.12.0/lib/rdoc/generator/template/darkfish/fonts/Lato-RegularItalic.ttf +0 -0
  368. data/vendor/bundle/ruby/3.3.0/gems/rdoc-6.12.0/lib/rdoc/generator/template/darkfish/fonts/SourceCodePro-Bold.ttf +0 -0
  369. data/vendor/bundle/ruby/3.3.0/gems/rdoc-6.12.0/lib/rdoc/generator/template/darkfish/fonts/SourceCodePro-Regular.ttf +0 -0
  370. data/vendor/bundle/ruby/3.3.0/gems/rdoc-6.12.0/lib/rdoc/generator/template/darkfish/images/add.png +0 -0
  371. data/vendor/bundle/ruby/3.3.0/gems/rdoc-6.12.0/lib/rdoc/generator/template/darkfish/images/arrow_up.png +0 -0
  372. data/vendor/bundle/ruby/3.3.0/gems/rdoc-6.12.0/lib/rdoc/generator/template/darkfish/images/brick.png +0 -0
  373. data/vendor/bundle/ruby/3.3.0/gems/rdoc-6.12.0/lib/rdoc/generator/template/darkfish/images/brick_link.png +0 -0
  374. data/vendor/bundle/ruby/3.3.0/gems/rdoc-6.12.0/lib/rdoc/generator/template/darkfish/images/bug.png +0 -0
  375. data/vendor/bundle/ruby/3.3.0/gems/rdoc-6.12.0/lib/rdoc/generator/template/darkfish/images/bullet_black.png +0 -0
  376. data/vendor/bundle/ruby/3.3.0/gems/rdoc-6.12.0/lib/rdoc/generator/template/darkfish/images/bullet_toggle_minus.png +0 -0
  377. data/vendor/bundle/ruby/3.3.0/gems/rdoc-6.12.0/lib/rdoc/generator/template/darkfish/images/bullet_toggle_plus.png +0 -0
  378. data/vendor/bundle/ruby/3.3.0/gems/rdoc-6.12.0/lib/rdoc/generator/template/darkfish/images/date.png +0 -0
  379. data/vendor/bundle/ruby/3.3.0/gems/rdoc-6.12.0/lib/rdoc/generator/template/darkfish/images/delete.png +0 -0
  380. data/vendor/bundle/ruby/3.3.0/gems/rdoc-6.12.0/lib/rdoc/generator/template/darkfish/images/find.png +0 -0
  381. data/vendor/bundle/ruby/3.3.0/gems/rdoc-6.12.0/lib/rdoc/generator/template/darkfish/images/loadingAnimation.gif +0 -0
  382. data/vendor/bundle/ruby/3.3.0/gems/rdoc-6.12.0/lib/rdoc/generator/template/darkfish/images/macFFBgHack.png +0 -0
  383. data/vendor/bundle/ruby/3.3.0/gems/rdoc-6.12.0/lib/rdoc/generator/template/darkfish/images/package.png +0 -0
  384. data/vendor/bundle/ruby/3.3.0/gems/rdoc-6.12.0/lib/rdoc/generator/template/darkfish/images/page_green.png +0 -0
  385. data/vendor/bundle/ruby/3.3.0/gems/rdoc-6.12.0/lib/rdoc/generator/template/darkfish/images/page_white_text.png +0 -0
  386. data/vendor/bundle/ruby/3.3.0/gems/rdoc-6.12.0/lib/rdoc/generator/template/darkfish/images/page_white_width.png +0 -0
  387. data/vendor/bundle/ruby/3.3.0/gems/rdoc-6.12.0/lib/rdoc/generator/template/darkfish/images/plugin.png +0 -0
  388. data/vendor/bundle/ruby/3.3.0/gems/rdoc-6.12.0/lib/rdoc/generator/template/darkfish/images/ruby.png +0 -0
  389. data/vendor/bundle/ruby/3.3.0/gems/rdoc-6.12.0/lib/rdoc/generator/template/darkfish/images/tag_blue.png +0 -0
  390. data/vendor/bundle/ruby/3.3.0/gems/rdoc-6.12.0/lib/rdoc/generator/template/darkfish/images/tag_green.png +0 -0
  391. data/vendor/bundle/ruby/3.3.0/gems/rdoc-6.12.0/lib/rdoc/generator/template/darkfish/images/transparent.png +0 -0
  392. data/vendor/bundle/ruby/3.3.0/gems/rdoc-6.12.0/lib/rdoc/generator/template/darkfish/images/wrench.png +0 -0
  393. data/vendor/bundle/ruby/3.3.0/gems/rdoc-6.12.0/lib/rdoc/generator/template/darkfish/images/wrench_orange.png +0 -0
  394. data/vendor/bundle/ruby/3.3.0/gems/rdoc-6.12.0/lib/rdoc/generator/template/darkfish/images/zoom.png +0 -0
  395. data/vendor/bundle/ruby/3.3.0/gems/rdoc-6.12.0/lib/rdoc/generator/template/darkfish/index.rhtml +23 -0
  396. data/vendor/bundle/ruby/3.3.0/gems/rdoc-6.12.0/lib/rdoc/generator/template/darkfish/js/darkfish.js +120 -0
  397. data/vendor/bundle/ruby/3.3.0/gems/rdoc-6.12.0/lib/rdoc/generator/template/darkfish/js/search.js +110 -0
  398. data/vendor/bundle/ruby/3.3.0/gems/rdoc-6.12.0/lib/rdoc/generator/template/darkfish/page.rhtml +18 -0
  399. data/vendor/bundle/ruby/3.3.0/gems/rdoc-6.12.0/lib/rdoc/generator/template/darkfish/servlet_not_found.rhtml +20 -0
  400. data/vendor/bundle/ruby/3.3.0/gems/rdoc-6.12.0/lib/rdoc/generator/template/darkfish/servlet_root.rhtml +65 -0
  401. data/vendor/bundle/ruby/3.3.0/gems/rdoc-6.12.0/lib/rdoc/generator/template/darkfish/table_of_contents.rhtml +70 -0
  402. data/vendor/bundle/ruby/3.3.0/gems/rdoc-6.12.0/lib/rdoc/generator/template/json_index/js/navigation.js +105 -0
  403. data/vendor/bundle/ruby/3.3.0/gems/rdoc-6.12.0/lib/rdoc/generator/template/json_index/js/searcher.js +229 -0
  404. data/vendor/bundle/ruby/3.3.0/gems/rdoc-6.12.0/lib/rdoc/generator.rb +51 -0
  405. data/vendor/bundle/ruby/3.3.0/gems/rdoc-6.12.0/lib/rdoc/i18n/locale.rb +102 -0
  406. data/vendor/bundle/ruby/3.3.0/gems/rdoc-6.12.0/lib/rdoc/i18n/text.rb +126 -0
  407. data/vendor/bundle/ruby/3.3.0/gems/rdoc-6.12.0/lib/rdoc/i18n.rb +10 -0
  408. data/vendor/bundle/ruby/3.3.0/gems/rdoc-6.12.0/lib/rdoc/known_classes.rb +74 -0
  409. data/vendor/bundle/ruby/3.3.0/gems/rdoc-6.12.0/lib/rdoc/markdown/entities.rb +2131 -0
  410. data/vendor/bundle/ruby/3.3.0/gems/rdoc-6.12.0/lib/rdoc/markdown/literals.kpeg +21 -0
  411. data/vendor/bundle/ruby/3.3.0/gems/rdoc-6.12.0/lib/rdoc/markdown/literals.rb +454 -0
  412. data/vendor/bundle/ruby/3.3.0/gems/rdoc-6.12.0/lib/rdoc/markdown.kpeg +1244 -0
  413. data/vendor/bundle/ruby/3.3.0/gems/rdoc-6.12.0/lib/rdoc/markdown.rb +16793 -0
  414. data/vendor/bundle/ruby/3.3.0/gems/rdoc-6.12.0/lib/rdoc/markup/attr_changer.rb +22 -0
  415. data/vendor/bundle/ruby/3.3.0/gems/rdoc-6.12.0/lib/rdoc/markup/attr_span.rb +35 -0
  416. data/vendor/bundle/ruby/3.3.0/gems/rdoc-6.12.0/lib/rdoc/markup/attribute_manager.rb +405 -0
  417. data/vendor/bundle/ruby/3.3.0/gems/rdoc-6.12.0/lib/rdoc/markup/attributes.rb +70 -0
  418. data/vendor/bundle/ruby/3.3.0/gems/rdoc-6.12.0/lib/rdoc/markup/blank_line.rb +27 -0
  419. data/vendor/bundle/ruby/3.3.0/gems/rdoc-6.12.0/lib/rdoc/markup/block_quote.rb +14 -0
  420. data/vendor/bundle/ruby/3.3.0/gems/rdoc-6.12.0/lib/rdoc/markup/document.rb +164 -0
  421. data/vendor/bundle/ruby/3.3.0/gems/rdoc-6.12.0/lib/rdoc/markup/formatter.rb +272 -0
  422. data/vendor/bundle/ruby/3.3.0/gems/rdoc-6.12.0/lib/rdoc/markup/hard_break.rb +31 -0
  423. data/vendor/bundle/ruby/3.3.0/gems/rdoc-6.12.0/lib/rdoc/markup/heading.rb +78 -0
  424. data/vendor/bundle/ruby/3.3.0/gems/rdoc-6.12.0/lib/rdoc/markup/include.rb +42 -0
  425. data/vendor/bundle/ruby/3.3.0/gems/rdoc-6.12.0/lib/rdoc/markup/indented_paragraph.rb +47 -0
  426. data/vendor/bundle/ruby/3.3.0/gems/rdoc-6.12.0/lib/rdoc/markup/list.rb +101 -0
  427. data/vendor/bundle/ruby/3.3.0/gems/rdoc-6.12.0/lib/rdoc/markup/list_item.rb +99 -0
  428. data/vendor/bundle/ruby/3.3.0/gems/rdoc-6.12.0/lib/rdoc/markup/paragraph.rb +28 -0
  429. data/vendor/bundle/ruby/3.3.0/gems/rdoc-6.12.0/lib/rdoc/markup/parser.rb +585 -0
  430. data/vendor/bundle/ruby/3.3.0/gems/rdoc-6.12.0/lib/rdoc/markup/pre_process.rb +318 -0
  431. data/vendor/bundle/ruby/3.3.0/gems/rdoc-6.12.0/lib/rdoc/markup/raw.rb +69 -0
  432. data/vendor/bundle/ruby/3.3.0/gems/rdoc-6.12.0/lib/rdoc/markup/regexp_handling.rb +40 -0
  433. data/vendor/bundle/ruby/3.3.0/gems/rdoc-6.12.0/lib/rdoc/markup/rule.rb +20 -0
  434. data/vendor/bundle/ruby/3.3.0/gems/rdoc-6.12.0/lib/rdoc/markup/table.rb +56 -0
  435. data/vendor/bundle/ruby/3.3.0/gems/rdoc-6.12.0/lib/rdoc/markup/to_ansi.rb +93 -0
  436. data/vendor/bundle/ruby/3.3.0/gems/rdoc-6.12.0/lib/rdoc/markup/to_bs.rb +102 -0
  437. data/vendor/bundle/ruby/3.3.0/gems/rdoc-6.12.0/lib/rdoc/markup/to_html.rb +452 -0
  438. data/vendor/bundle/ruby/3.3.0/gems/rdoc-6.12.0/lib/rdoc/markup/to_html_crossref.rb +226 -0
  439. data/vendor/bundle/ruby/3.3.0/gems/rdoc-6.12.0/lib/rdoc/markup/to_html_snippet.rb +287 -0
  440. data/vendor/bundle/ruby/3.3.0/gems/rdoc-6.12.0/lib/rdoc/markup/to_joined_paragraph.rb +46 -0
  441. data/vendor/bundle/ruby/3.3.0/gems/rdoc-6.12.0/lib/rdoc/markup/to_label.rb +74 -0
  442. data/vendor/bundle/ruby/3.3.0/gems/rdoc-6.12.0/lib/rdoc/markup/to_markdown.rb +191 -0
  443. data/vendor/bundle/ruby/3.3.0/gems/rdoc-6.12.0/lib/rdoc/markup/to_rdoc.rb +352 -0
  444. data/vendor/bundle/ruby/3.3.0/gems/rdoc-6.12.0/lib/rdoc/markup/to_table_of_contents.rb +88 -0
  445. data/vendor/bundle/ruby/3.3.0/gems/rdoc-6.12.0/lib/rdoc/markup/to_test.rb +69 -0
  446. data/vendor/bundle/ruby/3.3.0/gems/rdoc-6.12.0/lib/rdoc/markup/to_tt_only.rb +120 -0
  447. data/vendor/bundle/ruby/3.3.0/gems/rdoc-6.12.0/lib/rdoc/markup/verbatim.rb +83 -0
  448. data/vendor/bundle/ruby/3.3.0/gems/rdoc-6.12.0/lib/rdoc/markup.rb +240 -0
  449. data/vendor/bundle/ruby/3.3.0/gems/rdoc-6.12.0/lib/rdoc/options.rb +1397 -0
  450. data/vendor/bundle/ruby/3.3.0/gems/rdoc-6.12.0/lib/rdoc/parser/c.rb +1260 -0
  451. data/vendor/bundle/ruby/3.3.0/gems/rdoc-6.12.0/lib/rdoc/parser/changelog.rb +350 -0
  452. data/vendor/bundle/ruby/3.3.0/gems/rdoc-6.12.0/lib/rdoc/parser/markdown.rb +22 -0
  453. data/vendor/bundle/ruby/3.3.0/gems/rdoc-6.12.0/lib/rdoc/parser/prism_ruby.rb +1099 -0
  454. data/vendor/bundle/ruby/3.3.0/gems/rdoc-6.12.0/lib/rdoc/parser/rd.rb +22 -0
  455. data/vendor/bundle/ruby/3.3.0/gems/rdoc-6.12.0/lib/rdoc/parser/ripper_state_lex.rb +302 -0
  456. data/vendor/bundle/ruby/3.3.0/gems/rdoc-6.12.0/lib/rdoc/parser/ruby.rb +2381 -0
  457. data/vendor/bundle/ruby/3.3.0/gems/rdoc-6.12.0/lib/rdoc/parser/ruby_tools.rb +165 -0
  458. data/vendor/bundle/ruby/3.3.0/gems/rdoc-6.12.0/lib/rdoc/parser/simple.rb +61 -0
  459. data/vendor/bundle/ruby/3.3.0/gems/rdoc-6.12.0/lib/rdoc/parser/text.rb +11 -0
  460. data/vendor/bundle/ruby/3.3.0/gems/rdoc-6.12.0/lib/rdoc/parser.rb +297 -0
  461. data/vendor/bundle/ruby/3.3.0/gems/rdoc-6.12.0/lib/rdoc/rd/block_parser.rb +1706 -0
  462. data/vendor/bundle/ruby/3.3.0/gems/rdoc-6.12.0/lib/rdoc/rd/block_parser.ry +643 -0
  463. data/vendor/bundle/ruby/3.3.0/gems/rdoc-6.12.0/lib/rdoc/rd/inline.rb +71 -0
  464. data/vendor/bundle/ruby/3.3.0/gems/rdoc-6.12.0/lib/rdoc/rd/inline_parser.rb +1854 -0
  465. data/vendor/bundle/ruby/3.3.0/gems/rdoc-6.12.0/lib/rdoc/rd/inline_parser.ry +593 -0
  466. data/vendor/bundle/ruby/3.3.0/gems/rdoc-6.12.0/lib/rdoc/rd.rb +99 -0
  467. data/vendor/bundle/ruby/3.3.0/gems/rdoc-6.12.0/lib/rdoc/rdoc.rb +566 -0
  468. data/vendor/bundle/ruby/3.3.0/gems/rdoc-6.12.0/lib/rdoc/ri/driver.rb +1558 -0
  469. data/vendor/bundle/ruby/3.3.0/gems/rdoc-6.12.0/lib/rdoc/ri/formatter.rb +6 -0
  470. data/vendor/bundle/ruby/3.3.0/gems/rdoc-6.12.0/lib/rdoc/ri/paths.rb +171 -0
  471. data/vendor/bundle/ruby/3.3.0/gems/rdoc-6.12.0/lib/rdoc/ri/store.rb +6 -0
  472. data/vendor/bundle/ruby/3.3.0/gems/rdoc-6.12.0/lib/rdoc/ri/task.rb +71 -0
  473. data/vendor/bundle/ruby/3.3.0/gems/rdoc-6.12.0/lib/rdoc/ri.rb +20 -0
  474. data/vendor/bundle/ruby/3.3.0/gems/rdoc-6.12.0/lib/rdoc/rubygems_hook.rb +330 -0
  475. data/vendor/bundle/ruby/3.3.0/gems/rdoc-6.12.0/lib/rdoc/servlet.rb +451 -0
  476. data/vendor/bundle/ruby/3.3.0/gems/rdoc-6.12.0/lib/rdoc/stats/normal.rb +58 -0
  477. data/vendor/bundle/ruby/3.3.0/gems/rdoc-6.12.0/lib/rdoc/stats/quiet.rb +59 -0
  478. data/vendor/bundle/ruby/3.3.0/gems/rdoc-6.12.0/lib/rdoc/stats/verbose.rb +44 -0
  479. data/vendor/bundle/ruby/3.3.0/gems/rdoc-6.12.0/lib/rdoc/stats.rb +461 -0
  480. data/vendor/bundle/ruby/3.3.0/gems/rdoc-6.12.0/lib/rdoc/store.rb +1001 -0
  481. data/vendor/bundle/ruby/3.3.0/gems/rdoc-6.12.0/lib/rdoc/task.rb +354 -0
  482. data/vendor/bundle/ruby/3.3.0/gems/rdoc-6.12.0/lib/rdoc/text.rb +322 -0
  483. data/vendor/bundle/ruby/3.3.0/gems/rdoc-6.12.0/lib/rdoc/token_stream.rb +118 -0
  484. data/vendor/bundle/ruby/3.3.0/gems/rdoc-6.12.0/lib/rdoc/tom_doc.rb +257 -0
  485. data/vendor/bundle/ruby/3.3.0/gems/rdoc-6.12.0/lib/rdoc/version.rb +10 -0
  486. data/vendor/bundle/ruby/3.3.0/gems/rdoc-6.12.0/lib/rdoc.rb +211 -0
  487. data/vendor/bundle/ruby/3.3.0/gems/rdoc-6.12.0/lib/rubygems_plugin.rb +23 -0
  488. data/vendor/bundle/ruby/3.3.0/gems/rdoc-6.12.0/man/ri.1 +247 -0
  489. data/vendor/bundle/ruby/3.3.0/gems/reline-0.6.0/BSDL +22 -0
  490. data/vendor/bundle/ruby/3.3.0/gems/reline-0.6.0/COPYING +56 -0
  491. data/vendor/bundle/ruby/3.3.0/gems/reline-0.6.0/README.md +94 -0
  492. data/vendor/bundle/ruby/3.3.0/gems/reline-0.6.0/lib/reline/config.rb +373 -0
  493. data/vendor/bundle/ruby/3.3.0/gems/reline-0.6.0/lib/reline/face.rb +199 -0
  494. data/vendor/bundle/ruby/3.3.0/gems/reline-0.6.0/lib/reline/history.rb +76 -0
  495. data/vendor/bundle/ruby/3.3.0/gems/reline-0.6.0/lib/reline/io/ansi.rb +325 -0
  496. data/vendor/bundle/ruby/3.3.0/gems/reline-0.6.0/lib/reline/io/dumb.rb +120 -0
  497. data/vendor/bundle/ruby/3.3.0/gems/reline-0.6.0/lib/reline/io/windows.rb +530 -0
  498. data/vendor/bundle/ruby/3.3.0/gems/reline-0.6.0/lib/reline/io.rb +55 -0
  499. data/vendor/bundle/ruby/3.3.0/gems/reline-0.6.0/lib/reline/key_actor/base.rb +37 -0
  500. data/vendor/bundle/ruby/3.3.0/gems/reline-0.6.0/lib/reline/key_actor/composite.rb +17 -0
  501. data/vendor/bundle/ruby/3.3.0/gems/reline-0.6.0/lib/reline/key_actor/emacs.rb +517 -0
  502. data/vendor/bundle/ruby/3.3.0/gems/reline-0.6.0/lib/reline/key_actor/vi_command.rb +518 -0
  503. data/vendor/bundle/ruby/3.3.0/gems/reline-0.6.0/lib/reline/key_actor/vi_insert.rb +517 -0
  504. data/vendor/bundle/ruby/3.3.0/gems/reline-0.6.0/lib/reline/key_actor.rb +8 -0
  505. data/vendor/bundle/ruby/3.3.0/gems/reline-0.6.0/lib/reline/key_stroke.rb +119 -0
  506. data/vendor/bundle/ruby/3.3.0/gems/reline-0.6.0/lib/reline/kill_ring.rb +125 -0
  507. data/vendor/bundle/ruby/3.3.0/gems/reline-0.6.0/lib/reline/line_editor.rb +2382 -0
  508. data/vendor/bundle/ruby/3.3.0/gems/reline-0.6.0/lib/reline/unicode/east_asian_width.rb +1267 -0
  509. data/vendor/bundle/ruby/3.3.0/gems/reline-0.6.0/lib/reline/unicode.rb +415 -0
  510. data/vendor/bundle/ruby/3.3.0/gems/reline-0.6.0/lib/reline/version.rb +3 -0
  511. data/vendor/bundle/ruby/3.3.0/gems/reline-0.6.0/lib/reline.rb +519 -0
  512. data/vendor/bundle/ruby/3.3.0/gems/reline-0.6.0/license_of_rb-readline +25 -0
  513. data/vendor/bundle/ruby/3.3.0/plugins/rdoc_plugin.rb +1 -0
  514. data/vendor/bundle/ruby/3.3.0/specifications/ast-2.4.3.gemspec +29 -0
  515. data/vendor/bundle/ruby/3.3.0/specifications/debug-1.10.0.gemspec +32 -0
  516. data/vendor/bundle/ruby/3.3.0/specifications/io-console-0.8.0.gemspec +25 -0
  517. data/vendor/bundle/ruby/3.3.0/specifications/irb-1.15.1.gemspec +31 -0
  518. data/vendor/bundle/ruby/3.3.0/specifications/parser-3.3.7.2.gemspec +37 -0
  519. data/vendor/bundle/ruby/3.3.0/specifications/pp-0.6.2.gemspec +27 -0
  520. data/vendor/bundle/ruby/3.3.0/specifications/prettyprint-0.2.0.gemspec +23 -0
  521. data/vendor/bundle/ruby/3.3.0/specifications/rdoc-6.12.0.gemspec +31 -0
  522. data/vendor/bundle/ruby/3.3.0/specifications/reline-0.6.0.gemspec +26 -0
  523. metadata +499 -3
@@ -0,0 +1,1969 @@
1
+ /* -*- c-file-style: "ruby"; indent-tabs-mode: t -*- */
2
+ /*
3
+ * console IO module
4
+ */
5
+
6
+ static const char *const
7
+ IO_CONSOLE_VERSION = "0.8.0";
8
+
9
+ #include "ruby.h"
10
+ #include "ruby/io.h"
11
+ #include "ruby/thread.h"
12
+
13
+ #ifdef HAVE_UNISTD_H
14
+ #include <unistd.h>
15
+ #endif
16
+ #ifdef HAVE_FCNTL_H
17
+ #include <fcntl.h>
18
+ #endif
19
+ #ifdef HAVE_SYS_IOCTL_H
20
+ #include <sys/ioctl.h>
21
+ #endif
22
+
23
+ #if defined HAVE_TERMIOS_H
24
+ # include <termios.h>
25
+ typedef struct termios conmode;
26
+
27
+ static int
28
+ setattr(int fd, conmode *t)
29
+ {
30
+ while (tcsetattr(fd, TCSANOW, t)) {
31
+ if (errno != EINTR) return 0;
32
+ }
33
+ return 1;
34
+ }
35
+ # define getattr(fd, t) (tcgetattr(fd, t) == 0)
36
+ #elif defined HAVE_TERMIO_H
37
+ # include <termio.h>
38
+ typedef struct termio conmode;
39
+ # define setattr(fd, t) (ioctl(fd, TCSETAF, t) == 0)
40
+ # define getattr(fd, t) (ioctl(fd, TCGETA, t) == 0)
41
+ #elif defined HAVE_SGTTY_H
42
+ # include <sgtty.h>
43
+ typedef struct sgttyb conmode;
44
+ # ifdef HAVE_STTY
45
+ # define setattr(fd, t) (stty(fd, t) == 0)
46
+ # else
47
+ # define setattr(fd, t) (ioctl((fd), TIOCSETP, (t)) == 0)
48
+ # endif
49
+ # ifdef HAVE_GTTY
50
+ # define getattr(fd, t) (gtty(fd, t) == 0)
51
+ # else
52
+ # define getattr(fd, t) (ioctl((fd), TIOCGETP, (t)) == 0)
53
+ # endif
54
+ #elif defined _WIN32
55
+ #include <winioctl.h>
56
+ #include <conio.h>
57
+ typedef DWORD conmode;
58
+
59
+ #define LAST_ERROR rb_w32_map_errno(GetLastError())
60
+ #define SET_LAST_ERROR (errno = LAST_ERROR, 0)
61
+
62
+ static int
63
+ setattr(int fd, conmode *t)
64
+ {
65
+ int x = SetConsoleMode((HANDLE)rb_w32_get_osfhandle(fd), *t);
66
+ if (!x) errno = LAST_ERROR;
67
+ return x;
68
+ }
69
+
70
+ static int
71
+ getattr(int fd, conmode *t)
72
+ {
73
+ int x = GetConsoleMode((HANDLE)rb_w32_get_osfhandle(fd), t);
74
+ if (!x) errno = LAST_ERROR;
75
+ return x;
76
+ }
77
+ #endif
78
+ #ifndef SET_LAST_ERROR
79
+ #define SET_LAST_ERROR (0)
80
+ #endif
81
+
82
+ #define CSI "\x1b\x5b"
83
+
84
+ static ID id_getc, id_close;
85
+ static ID id_gets, id_flush, id_chomp_bang;
86
+
87
+ #ifndef HAVE_RB_INTERNED_STR_CSTR
88
+ # define rb_str_to_interned_str(str) rb_str_freeze(str)
89
+ # define rb_interned_str_cstr(str) rb_str_freeze(rb_usascii_str_new_cstr(str))
90
+ #endif
91
+
92
+ #if defined HAVE_RUBY_FIBER_SCHEDULER_H
93
+ # include "ruby/fiber/scheduler.h"
94
+ #elif defined HAVE_RB_SCHEDULER_TIMEOUT
95
+ extern VALUE rb_scheduler_timeout(struct timeval *timeout);
96
+ # define rb_fiber_scheduler_make_timeout rb_scheduler_timeout
97
+ #endif
98
+
99
+ #ifndef HAVE_RB_IO_DESCRIPTOR
100
+ static int
101
+ io_descriptor_fallback(VALUE io)
102
+ {
103
+ rb_io_t *fptr;
104
+ GetOpenFile(io, fptr);
105
+ return fptr->fd;
106
+ }
107
+ #define rb_io_descriptor io_descriptor_fallback
108
+ #endif
109
+
110
+ #ifndef HAVE_RB_IO_PATH
111
+ static VALUE
112
+ io_path_fallback(VALUE io)
113
+ {
114
+ rb_io_t *fptr;
115
+ GetOpenFile(io, fptr);
116
+ return fptr->pathv;
117
+ }
118
+ #define rb_io_path io_path_fallback
119
+ #endif
120
+
121
+ #ifndef HAVE_RB_IO_GET_WRITE_IO
122
+ static VALUE
123
+ io_get_write_io_fallback(VALUE io)
124
+ {
125
+ rb_io_t *fptr;
126
+ GetOpenFile(io, fptr);
127
+ VALUE wio = fptr->tied_io_for_writing;
128
+ return wio ? wio : io;
129
+ }
130
+ #define rb_io_get_write_io io_get_write_io_fallback
131
+ #endif
132
+
133
+ #ifndef DHAVE_RB_SYSERR_FAIL_STR
134
+ # define rb_syserr_fail_str(e, mesg) rb_exc_raise(rb_syserr_new_str(e, mesg))
135
+ #endif
136
+
137
+ #define sys_fail(io) do { \
138
+ int err = errno; \
139
+ rb_syserr_fail_str(err, rb_io_path(io)); \
140
+ } while (0)
141
+
142
+ #ifndef HAVE_RB_F_SEND
143
+ #ifndef RB_PASS_CALLED_KEYWORDS
144
+ # define rb_funcallv_kw(recv, mid, arg, argv, kw_splat) rb_funcallv(recv, mid, arg, argv)
145
+ #endif
146
+
147
+ static ID id___send__;
148
+
149
+ static VALUE
150
+ rb_f_send(int argc, VALUE *argv, VALUE recv)
151
+ {
152
+ VALUE sym = argv[0];
153
+ ID vid = rb_check_id(&sym);
154
+ if (vid) {
155
+ --argc;
156
+ ++argv;
157
+ }
158
+ else {
159
+ vid = id___send__;
160
+ }
161
+ return rb_funcallv_kw(recv, vid, argc, argv, RB_PASS_CALLED_KEYWORDS);
162
+ }
163
+ #endif
164
+
165
+ enum rawmode_opt_ids {
166
+ kwd_min,
167
+ kwd_time,
168
+ kwd_intr,
169
+ rawmode_opt_id_count
170
+ };
171
+ static ID rawmode_opt_ids[rawmode_opt_id_count];
172
+
173
+ typedef struct {
174
+ int vmin;
175
+ int vtime;
176
+ int intr;
177
+ } rawmode_arg_t;
178
+
179
+ #ifndef UNDEF_P
180
+ # define UNDEF_P(obj) ((obj) == Qundef)
181
+ #endif
182
+ #ifndef NIL_OR_UNDEF_P
183
+ # define NIL_OR_UNDEF_P(obj) (NIL_P(obj) || UNDEF_P(obj))
184
+ #endif
185
+
186
+ static rawmode_arg_t *
187
+ rawmode_opt(int *argcp, VALUE *argv, int min_argc, int max_argc, rawmode_arg_t *opts)
188
+ {
189
+ int argc = *argcp;
190
+ rawmode_arg_t *optp = NULL;
191
+ VALUE vopts = Qnil;
192
+ VALUE optvals[rawmode_opt_id_count];
193
+ #ifdef RB_SCAN_ARGS_PASS_CALLED_KEYWORDS
194
+ argc = rb_scan_args(argc, argv, "*:", NULL, &vopts);
195
+ #else
196
+ if (argc > min_argc) {
197
+ vopts = rb_check_hash_type(argv[argc-1]);
198
+ if (!NIL_P(vopts)) {
199
+ argv[argc-1] = vopts;
200
+ vopts = rb_extract_keywords(&argv[argc-1]);
201
+ if (!argv[argc-1]) *argcp = --argc;
202
+ if (!vopts) vopts = Qnil;
203
+ }
204
+ }
205
+ #endif
206
+ rb_check_arity(argc, min_argc, max_argc);
207
+ if (rb_get_kwargs(vopts, rawmode_opt_ids,
208
+ 0, rawmode_opt_id_count, optvals)) {
209
+ VALUE vmin = optvals[kwd_min];
210
+ VALUE vtime = optvals[kwd_time];
211
+ VALUE intr = optvals[kwd_intr];
212
+ /* default values by `stty raw` */
213
+ opts->vmin = 1;
214
+ opts->vtime = 0;
215
+ opts->intr = 0;
216
+ if (!NIL_OR_UNDEF_P(vmin)) {
217
+ opts->vmin = NUM2INT(vmin);
218
+ optp = opts;
219
+ }
220
+ if (!NIL_OR_UNDEF_P(vtime)) {
221
+ VALUE v10 = INT2FIX(10);
222
+ vtime = rb_funcall3(vtime, '*', 1, &v10);
223
+ opts->vtime = NUM2INT(vtime);
224
+ optp = opts;
225
+ }
226
+ switch (intr) {
227
+ case Qtrue:
228
+ opts->intr = 1;
229
+ optp = opts;
230
+ break;
231
+ case Qfalse:
232
+ opts->intr = 0;
233
+ optp = opts;
234
+ break;
235
+ case Qundef:
236
+ case Qnil:
237
+ break;
238
+ default:
239
+ rb_raise(rb_eArgError, "true or false expected as intr: %"PRIsVALUE,
240
+ intr);
241
+ }
242
+ }
243
+ return optp;
244
+ }
245
+
246
+ static void
247
+ set_rawmode(conmode *t, void *arg)
248
+ {
249
+ #ifdef HAVE_CFMAKERAW
250
+ cfmakeraw(t);
251
+ t->c_lflag &= ~(ECHOE|ECHOK);
252
+ #elif defined HAVE_TERMIOS_H || defined HAVE_TERMIO_H
253
+ t->c_iflag &= ~(IGNBRK|BRKINT|IGNPAR|PARMRK|INPCK|ISTRIP|INLCR|IGNCR|ICRNL|IXON|IXOFF|IXANY|IMAXBEL);
254
+ t->c_oflag &= ~OPOST;
255
+ t->c_lflag &= ~(ECHO|ECHOE|ECHOK|ECHONL|ICANON|ISIG|IEXTEN|XCASE);
256
+ t->c_cflag &= ~(CSIZE|PARENB);
257
+ t->c_cflag |= CS8;
258
+ t->c_cc[VMIN] = 1;
259
+ t->c_cc[VTIME] = 0;
260
+ #elif defined HAVE_SGTTY_H
261
+ t->sg_flags &= ~ECHO;
262
+ t->sg_flags |= RAW;
263
+ #elif defined _WIN32
264
+ *t = 0;
265
+ #endif
266
+ if (arg) {
267
+ const rawmode_arg_t *r = arg;
268
+ #ifdef VMIN
269
+ if (r->vmin >= 0) t->c_cc[VMIN] = r->vmin;
270
+ #endif
271
+ #ifdef VTIME
272
+ if (r->vtime >= 0) t->c_cc[VTIME] = r->vtime;
273
+ #endif
274
+ #ifdef ISIG
275
+ if (r->intr) {
276
+ t->c_iflag |= BRKINT;
277
+ t->c_lflag |= ISIG;
278
+ t->c_oflag |= OPOST;
279
+ }
280
+ #endif
281
+ (void)r;
282
+ }
283
+ }
284
+
285
+ static void
286
+ set_cookedmode(conmode *t, void *arg)
287
+ {
288
+ #if defined HAVE_TERMIOS_H || defined HAVE_TERMIO_H
289
+ t->c_iflag |= (BRKINT|ISTRIP|ICRNL|IXON);
290
+ t->c_oflag |= OPOST;
291
+ t->c_lflag |= (ECHO|ECHOE|ECHOK|ECHONL|ICANON|ISIG|IEXTEN);
292
+ #elif defined HAVE_SGTTY_H
293
+ t->sg_flags |= ECHO;
294
+ t->sg_flags &= ~RAW;
295
+ #elif defined _WIN32
296
+ *t |= ENABLE_ECHO_INPUT|ENABLE_LINE_INPUT|ENABLE_PROCESSED_INPUT;
297
+ #endif
298
+ }
299
+
300
+ static void
301
+ set_noecho(conmode *t, void *arg)
302
+ {
303
+ #if defined HAVE_TERMIOS_H || defined HAVE_TERMIO_H
304
+ t->c_lflag &= ~(ECHO | ECHOE | ECHOK | ECHONL);
305
+ #elif defined HAVE_SGTTY_H
306
+ t->sg_flags &= ~ECHO;
307
+ #elif defined _WIN32
308
+ *t &= ~ENABLE_ECHO_INPUT;
309
+ #endif
310
+ }
311
+
312
+ static void
313
+ set_echo(conmode *t, void *arg)
314
+ {
315
+ #if defined HAVE_TERMIOS_H || defined HAVE_TERMIO_H
316
+ t->c_lflag |= (ECHO | ECHOE | ECHOK | ECHONL);
317
+ #elif defined HAVE_SGTTY_H
318
+ t->sg_flags |= ECHO;
319
+ #elif defined _WIN32
320
+ *t |= ENABLE_ECHO_INPUT;
321
+ #endif
322
+ }
323
+
324
+ static int
325
+ echo_p(conmode *t)
326
+ {
327
+ #if defined HAVE_TERMIOS_H || defined HAVE_TERMIO_H
328
+ return (t->c_lflag & (ECHO | ECHONL)) != 0;
329
+ #elif defined HAVE_SGTTY_H
330
+ return (t->sg_flags & ECHO) != 0;
331
+ #elif defined _WIN32
332
+ return (*t & ENABLE_ECHO_INPUT) != 0;
333
+ #endif
334
+ }
335
+
336
+ static int
337
+ set_ttymode(int fd, conmode *t, void (*setter)(conmode *, void *), void *arg)
338
+ {
339
+ conmode r;
340
+ if (!getattr(fd, t)) return 0;
341
+ r = *t;
342
+ setter(&r, arg);
343
+ return setattr(fd, &r);
344
+ }
345
+
346
+ #define GetReadFD(io) rb_io_descriptor(io)
347
+ #define GetWriteFD(io) rb_io_descriptor(rb_io_get_write_io(io))
348
+
349
+ #define FD_PER_IO 2
350
+
351
+ static VALUE
352
+ ttymode(VALUE io, VALUE (*func)(VALUE), VALUE farg, void (*setter)(conmode *, void *), void *arg)
353
+ {
354
+ int status = -1;
355
+ int error = 0;
356
+ int fd[FD_PER_IO];
357
+ conmode t[FD_PER_IO];
358
+ VALUE result = Qnil;
359
+
360
+ fd[0] = GetReadFD(io);
361
+ if (fd[0] != -1) {
362
+ if (set_ttymode(fd[0], t+0, setter, arg)) {
363
+ status = 0;
364
+ }
365
+ else {
366
+ error = errno;
367
+ fd[0] = -1;
368
+ }
369
+ }
370
+ fd[1] = GetWriteFD(io);
371
+ if (fd[1] != -1 && fd[1] != fd[0]) {
372
+ if (set_ttymode(fd[1], t+1, setter, arg)) {
373
+ status = 0;
374
+ }
375
+ else {
376
+ error = errno;
377
+ fd[1] = -1;
378
+ }
379
+ }
380
+ if (status == 0) {
381
+ result = rb_protect(func, farg, &status);
382
+ }
383
+ if (fd[0] != -1 && fd[0] == GetReadFD(io)) {
384
+ if (!setattr(fd[0], t+0)) {
385
+ error = errno;
386
+ status = -1;
387
+ }
388
+ }
389
+ if (fd[1] != -1 && fd[1] != fd[0] && fd[1] == GetWriteFD(io)) {
390
+ if (!setattr(fd[1], t+1)) {
391
+ error = errno;
392
+ status = -1;
393
+ }
394
+ }
395
+ if (status) {
396
+ if (status == -1) {
397
+ rb_syserr_fail(error, 0);
398
+ }
399
+ rb_jump_tag(status);
400
+ }
401
+ return result;
402
+ }
403
+
404
+ #if !defined _WIN32
405
+ struct ttymode_callback_args {
406
+ VALUE (*func)(VALUE, VALUE);
407
+ VALUE io;
408
+ VALUE farg;
409
+ };
410
+
411
+ static VALUE
412
+ ttymode_callback(VALUE args)
413
+ {
414
+ struct ttymode_callback_args *argp = (struct ttymode_callback_args *)args;
415
+ return argp->func(argp->io, argp->farg);
416
+ }
417
+
418
+ static VALUE
419
+ ttymode_with_io(VALUE io, VALUE (*func)(VALUE, VALUE), VALUE farg, void (*setter)(conmode *, void *), void *arg)
420
+ {
421
+ struct ttymode_callback_args cargs;
422
+ cargs.func = func;
423
+ cargs.io = io;
424
+ cargs.farg = farg;
425
+ return ttymode(io, ttymode_callback, (VALUE)&cargs, setter, arg);
426
+ }
427
+ #endif
428
+
429
+ /*
430
+ * call-seq:
431
+ * io.raw(min: nil, time: nil, intr: nil) {|io| }
432
+ *
433
+ * Yields +self+ within raw mode, and returns the result of the block.
434
+ *
435
+ * STDIN.raw(&:gets)
436
+ *
437
+ * will read and return a line without echo back and line editing.
438
+ *
439
+ * The parameter +min+ specifies the minimum number of bytes that
440
+ * should be received when a read operation is performed. (default: 1)
441
+ *
442
+ * The parameter +time+ specifies the timeout in _seconds_ with a
443
+ * precision of 1/10 of a second. (default: 0)
444
+ *
445
+ * If the parameter +intr+ is +true+, enables break, interrupt, quit,
446
+ * and suspend special characters.
447
+ *
448
+ * Refer to the manual page of termios for further details.
449
+ *
450
+ * You must require 'io/console' to use this method.
451
+ */
452
+ static VALUE
453
+ console_raw(int argc, VALUE *argv, VALUE io)
454
+ {
455
+ rawmode_arg_t opts, *optp = rawmode_opt(&argc, argv, 0, 0, &opts);
456
+ return ttymode(io, rb_yield, io, set_rawmode, optp);
457
+ }
458
+
459
+ /*
460
+ * call-seq:
461
+ * io.raw!(min: nil, time: nil, intr: nil) -> io
462
+ *
463
+ * Enables raw mode, and returns +io+.
464
+ *
465
+ * If the terminal mode needs to be back, use <code>io.raw { ... }</code>.
466
+ *
467
+ * See IO#raw for details on the parameters.
468
+ *
469
+ * You must require 'io/console' to use this method.
470
+ */
471
+ static VALUE
472
+ console_set_raw(int argc, VALUE *argv, VALUE io)
473
+ {
474
+ conmode t;
475
+ rawmode_arg_t opts, *optp = rawmode_opt(&argc, argv, 0, 0, &opts);
476
+ int fd = GetReadFD(io);
477
+ if (!getattr(fd, &t)) sys_fail(io);
478
+ set_rawmode(&t, optp);
479
+ if (!setattr(fd, &t)) sys_fail(io);
480
+ return io;
481
+ }
482
+
483
+ /*
484
+ * call-seq:
485
+ * io.cooked {|io| }
486
+ *
487
+ * Yields +self+ within cooked mode.
488
+ *
489
+ * STDIN.cooked(&:gets)
490
+ *
491
+ * will read and return a line with echo back and line editing.
492
+ *
493
+ * You must require 'io/console' to use this method.
494
+ */
495
+ static VALUE
496
+ console_cooked(VALUE io)
497
+ {
498
+ return ttymode(io, rb_yield, io, set_cookedmode, NULL);
499
+ }
500
+
501
+ /*
502
+ * call-seq:
503
+ * io.cooked!
504
+ *
505
+ * Enables cooked mode.
506
+ *
507
+ * If the terminal mode needs to be back, use io.cooked { ... }.
508
+ *
509
+ * You must require 'io/console' to use this method.
510
+ */
511
+ static VALUE
512
+ console_set_cooked(VALUE io)
513
+ {
514
+ conmode t;
515
+ int fd = GetReadFD(io);
516
+ if (!getattr(fd, &t)) sys_fail(io);
517
+ set_cookedmode(&t, NULL);
518
+ if (!setattr(fd, &t)) sys_fail(io);
519
+ return io;
520
+ }
521
+
522
+ #ifndef _WIN32
523
+ static VALUE
524
+ getc_call(VALUE io)
525
+ {
526
+ return rb_funcallv(io, id_getc, 0, 0);
527
+ }
528
+ #else
529
+ static void *
530
+ nogvl_getch(void *p)
531
+ {
532
+ int len = 0;
533
+ wint_t *buf = p, c = _getwch();
534
+
535
+ switch (c) {
536
+ case WEOF:
537
+ break;
538
+ case 0x00:
539
+ case 0xe0:
540
+ buf[len++] = c;
541
+ c = _getwch();
542
+ /* fall through */
543
+ default:
544
+ buf[len++] = c;
545
+ break;
546
+ }
547
+ return (void *)(VALUE)len;
548
+ }
549
+ #endif
550
+
551
+ /*
552
+ * call-seq:
553
+ * io.getch(min: nil, time: nil, intr: nil) -> char
554
+ *
555
+ * Reads and returns a character in raw mode.
556
+ *
557
+ * See IO#raw for details on the parameters.
558
+ *
559
+ * You must require 'io/console' to use this method.
560
+ */
561
+ static VALUE
562
+ console_getch(int argc, VALUE *argv, VALUE io)
563
+ {
564
+ rawmode_arg_t opts, *optp = rawmode_opt(&argc, argv, 0, 0, &opts);
565
+ #ifndef _WIN32
566
+ return ttymode(io, getc_call, io, set_rawmode, optp);
567
+ #else
568
+ rb_io_t *fptr;
569
+ VALUE str;
570
+ wint_t c;
571
+ int len;
572
+ char buf[8];
573
+ wint_t wbuf[2];
574
+ # ifndef HAVE_RB_IO_WAIT
575
+ struct timeval *to = NULL, tv;
576
+ # else
577
+ VALUE timeout = Qnil;
578
+ # endif
579
+
580
+ GetOpenFile(io, fptr);
581
+ if (optp) {
582
+ if (optp->vtime) {
583
+ # ifndef HAVE_RB_IO_WAIT
584
+ to = &tv;
585
+ # else
586
+ struct timeval tv;
587
+ # endif
588
+ tv.tv_sec = optp->vtime / 10;
589
+ tv.tv_usec = (optp->vtime % 10) * 100000;
590
+ # ifdef HAVE_RB_IO_WAIT
591
+ timeout = rb_fiber_scheduler_make_timeout(&tv);
592
+ # endif
593
+ }
594
+ switch (optp->vmin) {
595
+ case 1: /* default */
596
+ break;
597
+ case 0: /* return nil when timed out */
598
+ if (optp->vtime) break;
599
+ /* fallthru */
600
+ default:
601
+ rb_warning("min option larger than 1 ignored");
602
+ }
603
+ if (optp->intr) {
604
+ # ifndef HAVE_RB_IO_WAIT
605
+ int w = rb_wait_for_single_fd(fptr->fd, RB_WAITFD_IN, to);
606
+ if (w < 0) rb_eof_error();
607
+ if (!(w & RB_WAITFD_IN)) return Qnil;
608
+ # else
609
+ VALUE result = rb_io_wait(io, RB_INT2NUM(RUBY_IO_READABLE), timeout);
610
+ if (!RTEST(result)) return Qnil;
611
+ # endif
612
+ }
613
+ else if (optp->vtime) {
614
+ rb_warning("Non-zero vtime option ignored if intr flag is unset");
615
+ }
616
+ }
617
+ len = (int)(VALUE)rb_thread_call_without_gvl(nogvl_getch, wbuf, RUBY_UBF_IO, 0);
618
+ switch (len) {
619
+ case 0:
620
+ return Qnil;
621
+ case 2:
622
+ buf[0] = (char)wbuf[0];
623
+ c = wbuf[1];
624
+ len = 1;
625
+ do {
626
+ buf[len++] = (unsigned char)c;
627
+ } while ((c >>= CHAR_BIT) && len < (int)sizeof(buf));
628
+ return rb_str_new(buf, len);
629
+ default:
630
+ c = wbuf[0];
631
+ len = rb_uv_to_utf8(buf, c);
632
+ str = rb_utf8_str_new(buf, len);
633
+ return rb_str_conv_enc(str, NULL, rb_default_external_encoding());
634
+ }
635
+ #endif
636
+ }
637
+
638
+ /*
639
+ * call-seq:
640
+ * io.noecho {|io| }
641
+ *
642
+ * Yields +self+ with disabling echo back.
643
+ *
644
+ * STDIN.noecho(&:gets)
645
+ *
646
+ * will read and return a line without echo back.
647
+ *
648
+ * You must require 'io/console' to use this method.
649
+ */
650
+ static VALUE
651
+ console_noecho(VALUE io)
652
+ {
653
+ return ttymode(io, rb_yield, io, set_noecho, NULL);
654
+ }
655
+
656
+ /*
657
+ * call-seq:
658
+ * io.echo = flag
659
+ *
660
+ * Enables/disables echo back.
661
+ * On some platforms, all combinations of this flags and raw/cooked
662
+ * mode may not be valid.
663
+ *
664
+ * You must require 'io/console' to use this method.
665
+ */
666
+ static VALUE
667
+ console_set_echo(VALUE io, VALUE f)
668
+ {
669
+ conmode t;
670
+ int fd = GetReadFD(io);
671
+
672
+ if (!getattr(fd, &t)) sys_fail(io);
673
+
674
+ if (RTEST(f))
675
+ set_echo(&t, NULL);
676
+ else
677
+ set_noecho(&t, NULL);
678
+
679
+ if (!setattr(fd, &t)) sys_fail(io);
680
+
681
+ return io;
682
+ }
683
+
684
+ /*
685
+ * call-seq:
686
+ * io.echo? -> true or false
687
+ *
688
+ * Returns +true+ if echo back is enabled.
689
+ *
690
+ * You must require 'io/console' to use this method.
691
+ */
692
+ static VALUE
693
+ console_echo_p(VALUE io)
694
+ {
695
+ conmode t;
696
+ int fd = GetReadFD(io);
697
+
698
+ if (!getattr(fd, &t)) sys_fail(io);
699
+ return echo_p(&t) ? Qtrue : Qfalse;
700
+ }
701
+
702
+ static const rb_data_type_t conmode_type = {
703
+ "console-mode",
704
+ {0, RUBY_TYPED_DEFAULT_FREE,},
705
+ 0, 0,
706
+ RUBY_TYPED_FREE_IMMEDIATELY | RUBY_TYPED_WB_PROTECTED,
707
+ };
708
+ static VALUE cConmode;
709
+
710
+ static VALUE
711
+ conmode_alloc(VALUE klass)
712
+ {
713
+ return rb_data_typed_object_zalloc(klass, sizeof(conmode), &conmode_type);
714
+ }
715
+
716
+ static VALUE
717
+ conmode_new(VALUE klass, const conmode *t)
718
+ {
719
+ VALUE obj = conmode_alloc(klass);
720
+ *(conmode *)DATA_PTR(obj) = *t;
721
+ return obj;
722
+ }
723
+
724
+ static VALUE
725
+ conmode_init_copy(VALUE obj, VALUE obj2)
726
+ {
727
+ conmode *t = rb_check_typeddata(obj, &conmode_type);
728
+ conmode *t2 = rb_check_typeddata(obj2, &conmode_type);
729
+ *t = *t2;
730
+ return obj;
731
+ }
732
+
733
+ static VALUE
734
+ conmode_set_echo(VALUE obj, VALUE f)
735
+ {
736
+ conmode *t = rb_check_typeddata(obj, &conmode_type);
737
+ if (RTEST(f))
738
+ set_echo(t, NULL);
739
+ else
740
+ set_noecho(t, NULL);
741
+ return obj;
742
+ }
743
+
744
+ static VALUE
745
+ conmode_set_raw(int argc, VALUE *argv, VALUE obj)
746
+ {
747
+ conmode *t = rb_check_typeddata(obj, &conmode_type);
748
+ rawmode_arg_t opts, *optp = rawmode_opt(&argc, argv, 0, 0, &opts);
749
+
750
+ set_rawmode(t, optp);
751
+ return obj;
752
+ }
753
+
754
+ static VALUE
755
+ conmode_raw_new(int argc, VALUE *argv, VALUE obj)
756
+ {
757
+ conmode *r = rb_check_typeddata(obj, &conmode_type);
758
+ conmode t = *r;
759
+ rawmode_arg_t opts, *optp = rawmode_opt(&argc, argv, 0, 0, &opts);
760
+
761
+ set_rawmode(&t, optp);
762
+ return conmode_new(rb_obj_class(obj), &t);
763
+ }
764
+
765
+ /*
766
+ * call-seq:
767
+ * io.console_mode -> mode
768
+ *
769
+ * Returns a data represents the current console mode.
770
+ *
771
+ * You must require 'io/console' to use this method.
772
+ */
773
+ static VALUE
774
+ console_conmode_get(VALUE io)
775
+ {
776
+ conmode t;
777
+ int fd = GetReadFD(io);
778
+
779
+ if (!getattr(fd, &t)) sys_fail(io);
780
+
781
+ return conmode_new(cConmode, &t);
782
+ }
783
+
784
+ /*
785
+ * call-seq:
786
+ * io.console_mode = mode
787
+ *
788
+ * Sets the console mode to +mode+.
789
+ *
790
+ * You must require 'io/console' to use this method.
791
+ */
792
+ static VALUE
793
+ console_conmode_set(VALUE io, VALUE mode)
794
+ {
795
+ conmode *t, r;
796
+ int fd = GetReadFD(io);
797
+
798
+ TypedData_Get_Struct(mode, conmode, &conmode_type, t);
799
+ r = *t;
800
+
801
+ if (!setattr(fd, &r)) sys_fail(io);
802
+
803
+ return mode;
804
+ }
805
+
806
+ #if defined TIOCGWINSZ
807
+ typedef struct winsize rb_console_size_t;
808
+ #define getwinsize(fd, buf) (ioctl((fd), TIOCGWINSZ, (buf)) == 0)
809
+ #define setwinsize(fd, buf) (ioctl((fd), TIOCSWINSZ, (buf)) == 0)
810
+ #define winsize_row(buf) (buf)->ws_row
811
+ #define winsize_col(buf) (buf)->ws_col
812
+ #elif defined _WIN32
813
+ typedef CONSOLE_SCREEN_BUFFER_INFO rb_console_size_t;
814
+ #define getwinsize(fd, buf) ( \
815
+ GetConsoleScreenBufferInfo((HANDLE)rb_w32_get_osfhandle(fd), (buf)) || \
816
+ SET_LAST_ERROR)
817
+ #define winsize_row(buf) ((buf)->srWindow.Bottom - (buf)->srWindow.Top + 1)
818
+ #define winsize_col(buf) (buf)->dwSize.X
819
+ #endif
820
+
821
+ #if defined TIOCGWINSZ || defined _WIN32
822
+ #define USE_CONSOLE_GETSIZE 1
823
+ #endif
824
+
825
+ #ifdef USE_CONSOLE_GETSIZE
826
+ /*
827
+ * call-seq:
828
+ * io.winsize -> [rows, columns]
829
+ *
830
+ * Returns console size.
831
+ *
832
+ * You must require 'io/console' to use this method.
833
+ */
834
+ static VALUE
835
+ console_winsize(VALUE io)
836
+ {
837
+ rb_console_size_t ws;
838
+ int fd = GetWriteFD(io);
839
+ if (!getwinsize(fd, &ws)) sys_fail(io);
840
+ return rb_assoc_new(INT2NUM(winsize_row(&ws)), INT2NUM(winsize_col(&ws)));
841
+ }
842
+
843
+ /*
844
+ * call-seq:
845
+ * io.winsize = [rows, columns]
846
+ *
847
+ * Tries to set console size. The effect depends on the platform and
848
+ * the running environment.
849
+ *
850
+ * You must require 'io/console' to use this method.
851
+ */
852
+ static VALUE
853
+ console_set_winsize(VALUE io, VALUE size)
854
+ {
855
+ rb_console_size_t ws;
856
+ #if defined _WIN32
857
+ HANDLE wh;
858
+ int newrow, newcol;
859
+ BOOL ret;
860
+ #endif
861
+ VALUE row, col, xpixel, ypixel;
862
+ const VALUE *sz;
863
+ long sizelen;
864
+ int fd;
865
+
866
+ size = rb_Array(size);
867
+ if ((sizelen = RARRAY_LEN(size)) != 2 && sizelen != 4) {
868
+ rb_raise(rb_eArgError, "wrong number of arguments (given %ld, expected 2 or 4)", sizelen);
869
+ }
870
+ sz = RARRAY_CONST_PTR(size);
871
+ row = sz[0], col = sz[1], xpixel = ypixel = Qnil;
872
+ if (sizelen == 4) xpixel = sz[2], ypixel = sz[3];
873
+ fd = GetWriteFD(io);
874
+ #if defined TIOCSWINSZ
875
+ ws.ws_row = ws.ws_col = ws.ws_xpixel = ws.ws_ypixel = 0;
876
+ #define SET(m) ws.ws_##m = NIL_P(m) ? 0 : (unsigned short)NUM2UINT(m)
877
+ SET(row);
878
+ SET(col);
879
+ SET(xpixel);
880
+ SET(ypixel);
881
+ #undef SET
882
+ if (!setwinsize(fd, &ws)) sys_fail(io);
883
+ #elif defined _WIN32
884
+ wh = (HANDLE)rb_w32_get_osfhandle(fd);
885
+ #define SET(m) new##m = NIL_P(m) ? 0 : (unsigned short)NUM2UINT(m)
886
+ SET(row);
887
+ SET(col);
888
+ #undef SET
889
+ if (!NIL_P(xpixel)) (void)NUM2UINT(xpixel);
890
+ if (!NIL_P(ypixel)) (void)NUM2UINT(ypixel);
891
+ if (!GetConsoleScreenBufferInfo(wh, &ws)) {
892
+ rb_syserr_fail(LAST_ERROR, "GetConsoleScreenBufferInfo");
893
+ }
894
+ ws.dwSize.X = newcol;
895
+ ret = SetConsoleScreenBufferSize(wh, ws.dwSize);
896
+ ws.srWindow.Left = 0;
897
+ ws.srWindow.Top = 0;
898
+ ws.srWindow.Right = newcol-1;
899
+ ws.srWindow.Bottom = newrow-1;
900
+ if (!SetConsoleWindowInfo(wh, TRUE, &ws.srWindow)) {
901
+ rb_syserr_fail(LAST_ERROR, "SetConsoleWindowInfo");
902
+ }
903
+ /* retry when shrinking buffer after shrunk window */
904
+ if (!ret && !SetConsoleScreenBufferSize(wh, ws.dwSize)) {
905
+ rb_syserr_fail(LAST_ERROR, "SetConsoleScreenBufferInfo");
906
+ }
907
+ /* remove scrollbar if possible */
908
+ if (!SetConsoleWindowInfo(wh, TRUE, &ws.srWindow)) {
909
+ rb_syserr_fail(LAST_ERROR, "SetConsoleWindowInfo");
910
+ }
911
+ #endif
912
+ return io;
913
+ }
914
+ #endif
915
+
916
+ #ifdef _WIN32
917
+ /*
918
+ * call-seq:
919
+ * io.check_winsize_changed { ... } -> io
920
+ *
921
+ * Yields while console input events are queued.
922
+ *
923
+ * This method is Windows only.
924
+ *
925
+ * You must require 'io/console' to use this method.
926
+ */
927
+ static VALUE
928
+ console_check_winsize_changed(VALUE io)
929
+ {
930
+ HANDLE h;
931
+ DWORD num;
932
+
933
+ h = (HANDLE)rb_w32_get_osfhandle(GetReadFD(io));
934
+ while (GetNumberOfConsoleInputEvents(h, &num) && num > 0) {
935
+ INPUT_RECORD rec;
936
+ if (ReadConsoleInput(h, &rec, 1, &num)) {
937
+ if (rec.EventType == WINDOW_BUFFER_SIZE_EVENT) {
938
+ rb_yield(Qnil);
939
+ }
940
+ }
941
+ }
942
+ return io;
943
+ }
944
+ #else
945
+ #define console_check_winsize_changed rb_f_notimplement
946
+ #endif
947
+
948
+ /*
949
+ * call-seq:
950
+ * io.iflush
951
+ *
952
+ * Flushes input buffer in kernel.
953
+ *
954
+ * You must require 'io/console' to use this method.
955
+ */
956
+ static VALUE
957
+ console_iflush(VALUE io)
958
+ {
959
+ #if defined HAVE_TERMIOS_H || defined HAVE_TERMIO_H
960
+ int fd = GetReadFD(io);
961
+ if (tcflush(fd, TCIFLUSH)) sys_fail(io);
962
+ #endif
963
+
964
+ return io;
965
+ }
966
+
967
+ /*
968
+ * call-seq:
969
+ * io.oflush
970
+ *
971
+ * Flushes output buffer in kernel.
972
+ *
973
+ * You must require 'io/console' to use this method.
974
+ */
975
+ static VALUE
976
+ console_oflush(VALUE io)
977
+ {
978
+ int fd = GetWriteFD(io);
979
+ #if defined HAVE_TERMIOS_H || defined HAVE_TERMIO_H
980
+ if (tcflush(fd, TCOFLUSH)) sys_fail(io);
981
+ #endif
982
+ (void)fd;
983
+ return io;
984
+ }
985
+
986
+ /*
987
+ * call-seq:
988
+ * io.ioflush
989
+ *
990
+ * Flushes input and output buffers in kernel.
991
+ *
992
+ * You must require 'io/console' to use this method.
993
+ */
994
+ static VALUE
995
+ console_ioflush(VALUE io)
996
+ {
997
+ #if defined HAVE_TERMIOS_H || defined HAVE_TERMIO_H
998
+ int fd1 = GetReadFD(io);
999
+ int fd2 = GetWriteFD(io);
1000
+
1001
+ if (fd2 != -1 && fd1 != fd2) {
1002
+ if (tcflush(fd1, TCIFLUSH)) sys_fail(io);
1003
+ if (tcflush(fd2, TCOFLUSH)) sys_fail(io);
1004
+ }
1005
+ else {
1006
+ if (tcflush(fd1, TCIOFLUSH)) sys_fail(io);
1007
+ }
1008
+ #endif
1009
+
1010
+ return io;
1011
+ }
1012
+
1013
+ /*
1014
+ * call-seq:
1015
+ * io.beep
1016
+ *
1017
+ * Beeps on the output console.
1018
+ *
1019
+ * You must require 'io/console' to use this method.
1020
+ */
1021
+ static VALUE
1022
+ console_beep(VALUE io)
1023
+ {
1024
+ #ifdef _WIN32
1025
+ MessageBeep(0);
1026
+ #else
1027
+ int fd = GetWriteFD(io);
1028
+ if (write(fd, "\a", 1) < 0) sys_fail(io);
1029
+ #endif
1030
+ return io;
1031
+ }
1032
+
1033
+ static int
1034
+ mode_in_range(VALUE val, int high, const char *modename)
1035
+ {
1036
+ int mode;
1037
+ if (NIL_P(val)) return 0;
1038
+ if (!RB_INTEGER_TYPE_P(val)) {
1039
+ wrong_value:
1040
+ rb_raise(rb_eArgError, "wrong %s mode: %"PRIsVALUE, modename, val);
1041
+ }
1042
+ if ((mode = NUM2INT(val)) < 0 || mode > high) {
1043
+ goto wrong_value;
1044
+ }
1045
+ return mode;
1046
+ }
1047
+
1048
+ #if defined _WIN32
1049
+ static void
1050
+ constat_clear(HANDLE handle, WORD attr, DWORD len, COORD pos)
1051
+ {
1052
+ DWORD written;
1053
+
1054
+ FillConsoleOutputAttribute(handle, attr, len, pos, &written);
1055
+ FillConsoleOutputCharacterW(handle, L' ', len, pos, &written);
1056
+ }
1057
+
1058
+ static VALUE
1059
+ console_scroll(VALUE io, int line)
1060
+ {
1061
+ HANDLE h;
1062
+ rb_console_size_t ws;
1063
+
1064
+ h = (HANDLE)rb_w32_get_osfhandle(GetWriteFD(io));
1065
+ if (!GetConsoleScreenBufferInfo(h, &ws)) {
1066
+ rb_syserr_fail(LAST_ERROR, 0);
1067
+ }
1068
+ if (line) {
1069
+ SMALL_RECT scroll;
1070
+ COORD destination;
1071
+ CHAR_INFO fill;
1072
+ scroll.Left = 0;
1073
+ scroll.Top = line > 0 ? line : 0;
1074
+ scroll.Right = winsize_col(&ws) - 1;
1075
+ scroll.Bottom = winsize_row(&ws) - 1 + (line < 0 ? line : 0);
1076
+ destination.X = 0;
1077
+ destination.Y = line < 0 ? -line : 0;
1078
+ fill.Char.UnicodeChar = L' ';
1079
+ fill.Attributes = ws.wAttributes;
1080
+
1081
+ ScrollConsoleScreenBuffer(h, &scroll, NULL, destination, &fill);
1082
+ }
1083
+ return io;
1084
+ }
1085
+
1086
+ #define GPERF_DOWNCASE 1
1087
+ #define GPERF_CASE_STRCMP 1
1088
+ #define gperf_case_strcmp STRCASECMP
1089
+ #include "win32_vk.inc"
1090
+
1091
+ /*
1092
+ * call-seq:
1093
+ * io.pressed?(key) -> bool
1094
+ *
1095
+ * Returns +true+ if +key+ is pressed. +key+ may be a virtual key
1096
+ * code or its name (String or Symbol) with out "VK_" prefix.
1097
+ *
1098
+ * This method is Windows only.
1099
+ *
1100
+ * You must require 'io/console' to use this method.
1101
+ */
1102
+ static VALUE
1103
+ console_key_pressed_p(VALUE io, VALUE k)
1104
+ {
1105
+ int vk = -1;
1106
+
1107
+ if (FIXNUM_P(k)) {
1108
+ vk = NUM2UINT(k);
1109
+ }
1110
+ else {
1111
+ const struct vktable *t;
1112
+ const char *kn;
1113
+ if (SYMBOL_P(k)) {
1114
+ k = rb_sym2str(k);
1115
+ kn = RSTRING_PTR(k);
1116
+ }
1117
+ else {
1118
+ kn = StringValuePtr(k);
1119
+ }
1120
+ t = console_win32_vk(kn, RSTRING_LEN(k));
1121
+ if (!t || (vk = (short)t->vk) == -1) {
1122
+ rb_raise(rb_eArgError, "unknown virtual key code: % "PRIsVALUE, k);
1123
+ }
1124
+ }
1125
+ return GetKeyState(vk) & 0x80 ? Qtrue : Qfalse;
1126
+ }
1127
+ #else
1128
+ struct query_args {
1129
+ char qstr[6];
1130
+ unsigned char opt;
1131
+ };
1132
+
1133
+ static int
1134
+ direct_query(VALUE io, const struct query_args *query)
1135
+ {
1136
+ if (RB_TYPE_P(io, T_FILE)) {
1137
+ VALUE wio = rb_io_get_write_io(io);
1138
+ VALUE s = rb_str_new_cstr(query->qstr);
1139
+ rb_io_write(wio, s);
1140
+ rb_io_flush(wio);
1141
+ return 1;
1142
+ }
1143
+ return 0;
1144
+ }
1145
+
1146
+ static VALUE
1147
+ read_vt_response(VALUE io, VALUE query)
1148
+ {
1149
+ struct query_args *qargs = (struct query_args *)query;
1150
+ VALUE result, b;
1151
+ int opt = 0;
1152
+ int num = 0;
1153
+ if (qargs) {
1154
+ opt = qargs->opt;
1155
+ if (!direct_query(io, qargs)) return Qnil;
1156
+ }
1157
+ if (rb_io_getbyte(io) != INT2FIX(0x1b)) return Qnil;
1158
+ if (rb_io_getbyte(io) != INT2FIX('[')) return Qnil;
1159
+ result = rb_ary_new();
1160
+ while (!NIL_P(b = rb_io_getbyte(io))) {
1161
+ int c = NUM2UINT(b);
1162
+ if (c == ';') {
1163
+ rb_ary_push(result, INT2NUM(num));
1164
+ num = 0;
1165
+ }
1166
+ else if (ISDIGIT(c)) {
1167
+ num = num * 10 + c - '0';
1168
+ }
1169
+ else if (opt && c == opt) {
1170
+ opt = 0;
1171
+ }
1172
+ else {
1173
+ char last = (char)c;
1174
+ rb_ary_push(result, INT2NUM(num));
1175
+ b = rb_str_new(&last, 1);
1176
+ break;
1177
+ }
1178
+ }
1179
+ return rb_ary_push(result, b);
1180
+ }
1181
+
1182
+ static VALUE
1183
+ console_vt_response(int argc, VALUE *argv, VALUE io, const struct query_args *qargs)
1184
+ {
1185
+ rawmode_arg_t opts, *optp = rawmode_opt(&argc, argv, 0, 1, &opts);
1186
+ VALUE query = (VALUE)qargs;
1187
+ VALUE ret = ttymode_with_io(io, read_vt_response, query, set_rawmode, optp);
1188
+ return ret;
1189
+ }
1190
+
1191
+ static VALUE
1192
+ console_scroll(VALUE io, int line)
1193
+ {
1194
+ if (line) {
1195
+ VALUE s = rb_sprintf(CSI "%d%c", line < 0 ? -line : line,
1196
+ line < 0 ? 'T' : 'S');
1197
+ rb_io_write(io, s);
1198
+ }
1199
+ return io;
1200
+ }
1201
+
1202
+ # define console_key_pressed_p rb_f_notimplement
1203
+ #endif
1204
+
1205
+ /*
1206
+ * call-seq:
1207
+ * io.cursor -> [row, column]
1208
+ *
1209
+ * Returns the current cursor position as a two-element array of integers (row, column)
1210
+ *
1211
+ * io.cursor # => [3, 5]
1212
+ *
1213
+ * You must require 'io/console' to use this method.
1214
+ */
1215
+ static VALUE
1216
+ console_cursor_pos(VALUE io)
1217
+ {
1218
+ #ifdef _WIN32
1219
+ rb_console_size_t ws;
1220
+ int fd = GetWriteFD(io);
1221
+ if (!GetConsoleScreenBufferInfo((HANDLE)rb_w32_get_osfhandle(fd), &ws)) {
1222
+ rb_syserr_fail(LAST_ERROR, 0);
1223
+ }
1224
+ return rb_assoc_new(UINT2NUM(ws.dwCursorPosition.Y), UINT2NUM(ws.dwCursorPosition.X));
1225
+ #else
1226
+ static const struct query_args query = {"\033[6n", 0};
1227
+ VALUE resp = console_vt_response(0, 0, io, &query);
1228
+ VALUE row, column, term;
1229
+ unsigned int r, c;
1230
+ if (!RB_TYPE_P(resp, T_ARRAY) || RARRAY_LEN(resp) != 3) return Qnil;
1231
+ term = RARRAY_AREF(resp, 2);
1232
+ if (!RB_TYPE_P(term, T_STRING) || RSTRING_LEN(term) != 1) return Qnil;
1233
+ if (RSTRING_PTR(term)[0] != 'R') return Qnil;
1234
+ row = RARRAY_AREF(resp, 0);
1235
+ column = RARRAY_AREF(resp, 1);
1236
+ rb_ary_resize(resp, 2);
1237
+ r = NUM2UINT(row) - 1;
1238
+ c = NUM2UINT(column) - 1;
1239
+ RARRAY_ASET(resp, 0, INT2NUM(r));
1240
+ RARRAY_ASET(resp, 1, INT2NUM(c));
1241
+ return resp;
1242
+ #endif
1243
+ }
1244
+
1245
+ /*
1246
+ * call-seq:
1247
+ * io.goto(line, column) -> io
1248
+ *
1249
+ * Set the cursor position at +line+ and +column+.
1250
+ *
1251
+ * You must require 'io/console' to use this method.
1252
+ */
1253
+ static VALUE
1254
+ console_goto(VALUE io, VALUE y, VALUE x)
1255
+ {
1256
+ #ifdef _WIN32
1257
+ COORD pos;
1258
+ int fd = GetWriteFD(io);
1259
+ pos.X = NUM2UINT(x);
1260
+ pos.Y = NUM2UINT(y);
1261
+ if (!SetConsoleCursorPosition((HANDLE)rb_w32_get_osfhandle(fd), pos)) {
1262
+ rb_syserr_fail(LAST_ERROR, 0);
1263
+ }
1264
+ #else
1265
+ rb_io_write(io, rb_sprintf(CSI "%d;%dH", NUM2UINT(y)+1, NUM2UINT(x)+1));
1266
+ #endif
1267
+ return io;
1268
+ }
1269
+
1270
+ static VALUE
1271
+ console_move(VALUE io, int y, int x)
1272
+ {
1273
+ #ifdef _WIN32
1274
+ HANDLE h;
1275
+ rb_console_size_t ws;
1276
+ COORD *pos = &ws.dwCursorPosition;
1277
+
1278
+ h = (HANDLE)rb_w32_get_osfhandle(GetWriteFD(io));
1279
+ if (!GetConsoleScreenBufferInfo(h, &ws)) {
1280
+ rb_syserr_fail(LAST_ERROR, 0);
1281
+ }
1282
+ pos->X += x;
1283
+ pos->Y += y;
1284
+ if (!SetConsoleCursorPosition(h, *pos)) {
1285
+ rb_syserr_fail(LAST_ERROR, 0);
1286
+ }
1287
+ #else
1288
+ if (x || y) {
1289
+ VALUE s = rb_str_new_cstr("");
1290
+ if (y) rb_str_catf(s, CSI "%d%c", y < 0 ? -y : y, y < 0 ? 'A' : 'B');
1291
+ if (x) rb_str_catf(s, CSI "%d%c", x < 0 ? -x : x, x < 0 ? 'D' : 'C');
1292
+ rb_io_write(io, s);
1293
+ rb_io_flush(io);
1294
+ }
1295
+ #endif
1296
+ return io;
1297
+ }
1298
+
1299
+ /*
1300
+ * call-seq:
1301
+ * io.goto_column(column) -> io
1302
+ *
1303
+ * Set the cursor position at +column+ in the same line of the current
1304
+ * position.
1305
+ *
1306
+ * You must require 'io/console' to use this method.
1307
+ */
1308
+ static VALUE
1309
+ console_goto_column(VALUE io, VALUE val)
1310
+ {
1311
+ #ifdef _WIN32
1312
+ HANDLE h;
1313
+ rb_console_size_t ws;
1314
+ COORD *pos = &ws.dwCursorPosition;
1315
+
1316
+ h = (HANDLE)rb_w32_get_osfhandle(GetWriteFD(io));
1317
+ if (!GetConsoleScreenBufferInfo(h, &ws)) {
1318
+ rb_syserr_fail(LAST_ERROR, 0);
1319
+ }
1320
+ pos->X = NUM2INT(val);
1321
+ if (!SetConsoleCursorPosition(h, *pos)) {
1322
+ rb_syserr_fail(LAST_ERROR, 0);
1323
+ }
1324
+ #else
1325
+ rb_io_write(io, rb_sprintf(CSI "%dG", NUM2UINT(val)+1));
1326
+ #endif
1327
+ return io;
1328
+ }
1329
+
1330
+ /*
1331
+ * call-seq:
1332
+ * io.erase_line(mode) -> io
1333
+ *
1334
+ * Erases the line at the cursor corresponding to +mode+.
1335
+ * +mode+ may be either:
1336
+ * 0: after cursor
1337
+ * 1: before and cursor
1338
+ * 2: entire line
1339
+ *
1340
+ * You must require 'io/console' to use this method.
1341
+ */
1342
+ static VALUE
1343
+ console_erase_line(VALUE io, VALUE val)
1344
+ {
1345
+ int mode = mode_in_range(val, 2, "line erase");
1346
+ #ifdef _WIN32
1347
+ HANDLE h;
1348
+ rb_console_size_t ws;
1349
+ COORD *pos = &ws.dwCursorPosition;
1350
+ DWORD w;
1351
+
1352
+ h = (HANDLE)rb_w32_get_osfhandle(GetWriteFD(io));
1353
+ if (!GetConsoleScreenBufferInfo(h, &ws)) {
1354
+ rb_syserr_fail(LAST_ERROR, 0);
1355
+ }
1356
+ w = winsize_col(&ws);
1357
+ switch (mode) {
1358
+ case 0: /* after cursor */
1359
+ w -= pos->X;
1360
+ break;
1361
+ case 1: /* before *and* cursor */
1362
+ w = pos->X + 1;
1363
+ pos->X = 0;
1364
+ break;
1365
+ case 2: /* entire line */
1366
+ pos->X = 0;
1367
+ break;
1368
+ }
1369
+ constat_clear(h, ws.wAttributes, w, *pos);
1370
+ return io;
1371
+ #else
1372
+ rb_io_write(io, rb_sprintf(CSI "%dK", mode));
1373
+ #endif
1374
+ return io;
1375
+ }
1376
+
1377
+ /*
1378
+ * call-seq:
1379
+ * io.erase_screen(mode) -> io
1380
+ *
1381
+ * Erases the screen at the cursor corresponding to +mode+.
1382
+ * +mode+ may be either:
1383
+ * 0: after cursor
1384
+ * 1: before and cursor
1385
+ * 2: entire screen
1386
+ *
1387
+ * You must require 'io/console' to use this method.
1388
+ */
1389
+ static VALUE
1390
+ console_erase_screen(VALUE io, VALUE val)
1391
+ {
1392
+ int mode = mode_in_range(val, 3, "screen erase");
1393
+ #ifdef _WIN32
1394
+ HANDLE h;
1395
+ rb_console_size_t ws;
1396
+ COORD *pos = &ws.dwCursorPosition;
1397
+ DWORD w;
1398
+
1399
+ h = (HANDLE)rb_w32_get_osfhandle(GetWriteFD(io));
1400
+ if (!GetConsoleScreenBufferInfo(h, &ws)) {
1401
+ rb_syserr_fail(LAST_ERROR, 0);
1402
+ }
1403
+ w = winsize_col(&ws);
1404
+ switch (mode) {
1405
+ case 0: /* erase after cursor */
1406
+ w = (w * (ws.srWindow.Bottom - pos->Y + 1) - pos->X);
1407
+ break;
1408
+ case 1: /* erase before *and* cursor */
1409
+ w = (w * (pos->Y - ws.srWindow.Top) + pos->X + 1);
1410
+ pos->X = 0;
1411
+ pos->Y = ws.srWindow.Top;
1412
+ break;
1413
+ case 2: /* erase entire screen */
1414
+ w = (w * winsize_row(&ws));
1415
+ pos->X = 0;
1416
+ pos->Y = ws.srWindow.Top;
1417
+ break;
1418
+ case 3: /* erase entire screen */
1419
+ w = (w * ws.dwSize.Y);
1420
+ pos->X = 0;
1421
+ pos->Y = 0;
1422
+ break;
1423
+ }
1424
+ constat_clear(h, ws.wAttributes, w, *pos);
1425
+ #else
1426
+ rb_io_write(io, rb_sprintf(CSI "%dJ", mode));
1427
+ #endif
1428
+ return io;
1429
+ }
1430
+
1431
+ /*
1432
+ * call-seq:
1433
+ * io.cursor = [line, column] -> io
1434
+ *
1435
+ * Same as <tt>io.goto(line, column)</tt>
1436
+ *
1437
+ * See IO#goto.
1438
+ *
1439
+ * You must require 'io/console' to use this method.
1440
+ */
1441
+ static VALUE
1442
+ console_cursor_set(VALUE io, VALUE cpos)
1443
+ {
1444
+ cpos = rb_convert_type(cpos, T_ARRAY, "Array", "to_ary");
1445
+ if (RARRAY_LEN(cpos) != 2) rb_raise(rb_eArgError, "expected 2D coordinate");
1446
+ return console_goto(io, RARRAY_AREF(cpos, 0), RARRAY_AREF(cpos, 1));
1447
+ }
1448
+
1449
+ /*
1450
+ * call-seq:
1451
+ * io.cursor_up(n) -> io
1452
+ *
1453
+ * Moves the cursor up +n+ lines.
1454
+ *
1455
+ * You must require 'io/console' to use this method.
1456
+ */
1457
+ static VALUE
1458
+ console_cursor_up(VALUE io, VALUE val)
1459
+ {
1460
+ return console_move(io, -NUM2INT(val), 0);
1461
+ }
1462
+
1463
+ /*
1464
+ * call-seq:
1465
+ * io.cursor_down(n) -> io
1466
+ *
1467
+ * Moves the cursor down +n+ lines.
1468
+ *
1469
+ * You must require 'io/console' to use this method.
1470
+ */
1471
+ static VALUE
1472
+ console_cursor_down(VALUE io, VALUE val)
1473
+ {
1474
+ return console_move(io, +NUM2INT(val), 0);
1475
+ }
1476
+
1477
+ /*
1478
+ * call-seq:
1479
+ * io.cursor_left(n) -> io
1480
+ *
1481
+ * Moves the cursor left +n+ columns.
1482
+ *
1483
+ * You must require 'io/console' to use this method.
1484
+ */
1485
+ static VALUE
1486
+ console_cursor_left(VALUE io, VALUE val)
1487
+ {
1488
+ return console_move(io, 0, -NUM2INT(val));
1489
+ }
1490
+
1491
+ /*
1492
+ * call-seq:
1493
+ * io.cursor_right(n) -> io
1494
+ *
1495
+ * Moves the cursor right +n+ columns.
1496
+ *
1497
+ * You must require 'io/console' to use this method.
1498
+ */
1499
+ static VALUE
1500
+ console_cursor_right(VALUE io, VALUE val)
1501
+ {
1502
+ return console_move(io, 0, +NUM2INT(val));
1503
+ }
1504
+
1505
+ /*
1506
+ * call-seq:
1507
+ * io.scroll_forward(n) -> io
1508
+ *
1509
+ * Scrolls the entire scrolls forward +n+ lines.
1510
+ *
1511
+ * You must require 'io/console' to use this method.
1512
+ */
1513
+ static VALUE
1514
+ console_scroll_forward(VALUE io, VALUE val)
1515
+ {
1516
+ return console_scroll(io, +NUM2INT(val));
1517
+ }
1518
+
1519
+ /*
1520
+ * call-seq:
1521
+ * io.scroll_backward(n) -> io
1522
+ *
1523
+ * Scrolls the entire scrolls backward +n+ lines.
1524
+ *
1525
+ * You must require 'io/console' to use this method.
1526
+ */
1527
+ static VALUE
1528
+ console_scroll_backward(VALUE io, VALUE val)
1529
+ {
1530
+ return console_scroll(io, -NUM2INT(val));
1531
+ }
1532
+
1533
+ /*
1534
+ * call-seq:
1535
+ * io.clear_screen -> io
1536
+ *
1537
+ * Clears the entire screen and moves the cursor top-left corner.
1538
+ *
1539
+ * You must require 'io/console' to use this method.
1540
+ */
1541
+ static VALUE
1542
+ console_clear_screen(VALUE io)
1543
+ {
1544
+ console_erase_screen(io, INT2FIX(2));
1545
+ console_goto(io, INT2FIX(0), INT2FIX(0));
1546
+ return io;
1547
+ }
1548
+
1549
+ #ifndef HAVE_RB_IO_OPEN_DESCRIPTOR
1550
+ static VALUE
1551
+ io_open_descriptor_fallback(VALUE klass, int descriptor, int mode, VALUE path, VALUE timeout, void *encoding)
1552
+ {
1553
+ VALUE arguments[2] = {
1554
+ (rb_update_max_fd(descriptor), INT2NUM(descriptor)),
1555
+ INT2FIX(mode),
1556
+ };
1557
+
1558
+ VALUE self = rb_class_new_instance(2, arguments, klass);
1559
+
1560
+ rb_io_t *fptr;
1561
+ GetOpenFile(self, fptr);
1562
+ fptr->pathv = path;
1563
+ fptr->mode |= mode;
1564
+
1565
+ return self;
1566
+ }
1567
+ #define rb_io_open_descriptor io_open_descriptor_fallback
1568
+ #endif
1569
+
1570
+ #ifndef HAVE_RB_IO_CLOSED_P
1571
+ static VALUE
1572
+ rb_io_closed_p(VALUE io)
1573
+ {
1574
+ rb_io_t *fptr = RFILE(io)->fptr;
1575
+ return fptr->fd == -1 ? Qtrue : Qfalse;
1576
+ }
1577
+ #endif
1578
+
1579
+ #if defined(RB_EXT_RACTOR_SAFE) && defined(HAVE_RB_RACTOR_LOCAL_STORAGE_VALUE_NEWKEY)
1580
+ # define USE_RACTOR_STORAGE 1
1581
+ #else
1582
+ # define USE_RACTOR_STORAGE 0
1583
+ #endif
1584
+
1585
+ #if USE_RACTOR_STORAGE
1586
+ #include "ruby/ractor.h"
1587
+ static rb_ractor_local_key_t key_console_dev;
1588
+
1589
+ static bool
1590
+ console_dev_get(VALUE klass, VALUE *dev)
1591
+ {
1592
+ return rb_ractor_local_storage_value_lookup(key_console_dev, dev);
1593
+ }
1594
+
1595
+ static void
1596
+ console_dev_set(VALUE klass, VALUE value)
1597
+ {
1598
+ rb_ractor_local_storage_value_set(key_console_dev, value);
1599
+ }
1600
+
1601
+ static void
1602
+ console_dev_remove(VALUE klass)
1603
+ {
1604
+ console_dev_set(klass, Qnil);
1605
+ }
1606
+
1607
+ #else
1608
+
1609
+ static ID id_console;
1610
+
1611
+ static int
1612
+ console_dev_get(VALUE klass, VALUE *dev)
1613
+ {
1614
+ if (rb_const_defined(klass, id_console)) {
1615
+ *dev = rb_const_get(klass, id_console);
1616
+ return 1;
1617
+ }
1618
+ return 0;
1619
+ }
1620
+
1621
+ static void
1622
+ console_dev_set(VALUE klass, VALUE value)
1623
+ {
1624
+ rb_const_set(klass, id_console, value);
1625
+ }
1626
+
1627
+ static void
1628
+ console_dev_remove(VALUE klass)
1629
+ {
1630
+ rb_const_remove(klass, id_console);
1631
+ }
1632
+
1633
+ #endif
1634
+
1635
+ /*
1636
+ * call-seq:
1637
+ * IO.console -> #<File:/dev/tty>
1638
+ * IO.console(sym, *args)
1639
+ *
1640
+ * Returns an File instance opened console.
1641
+ *
1642
+ * If +sym+ is given, it will be sent to the opened console with
1643
+ * +args+ and the result will be returned instead of the console IO
1644
+ * itself.
1645
+ *
1646
+ * You must require 'io/console' to use this method.
1647
+ */
1648
+ static VALUE
1649
+ console_dev(int argc, VALUE *argv, VALUE klass)
1650
+ {
1651
+ VALUE con = 0;
1652
+ VALUE sym = 0;
1653
+
1654
+ rb_check_arity(argc, 0, UNLIMITED_ARGUMENTS);
1655
+
1656
+ if (argc) {
1657
+ Check_Type(sym = argv[0], T_SYMBOL);
1658
+ }
1659
+
1660
+ // Force the class to be File.
1661
+ if (klass == rb_cIO) klass = rb_cFile;
1662
+
1663
+ if (console_dev_get(klass, &con)) {
1664
+ if (!RB_TYPE_P(con, T_FILE) || RTEST(rb_io_closed_p(con))) {
1665
+ console_dev_remove(klass);
1666
+ con = 0;
1667
+ }
1668
+ }
1669
+
1670
+ if (sym) {
1671
+ if (sym == ID2SYM(id_close) && argc == 1) {
1672
+ if (con) {
1673
+ rb_io_close(con);
1674
+ console_dev_remove(klass);
1675
+ con = 0;
1676
+ }
1677
+ return Qnil;
1678
+ }
1679
+ }
1680
+
1681
+ if (!con) {
1682
+ #if defined HAVE_TERMIOS_H || defined HAVE_TERMIO_H || defined HAVE_SGTTY_H
1683
+ # define CONSOLE_DEVICE "/dev/tty"
1684
+ #elif defined _WIN32
1685
+ # define CONSOLE_DEVICE "con$"
1686
+ # define CONSOLE_DEVICE_FOR_READING "conin$"
1687
+ # define CONSOLE_DEVICE_FOR_WRITING "conout$"
1688
+ #endif
1689
+ #ifndef CONSOLE_DEVICE_FOR_READING
1690
+ # define CONSOLE_DEVICE_FOR_READING CONSOLE_DEVICE
1691
+ #endif
1692
+ #ifdef CONSOLE_DEVICE_FOR_WRITING
1693
+ VALUE out;
1694
+ #endif
1695
+ int fd;
1696
+ VALUE path = rb_obj_freeze(rb_str_new2(CONSOLE_DEVICE));
1697
+
1698
+ #ifdef CONSOLE_DEVICE_FOR_WRITING
1699
+ fd = rb_cloexec_open(CONSOLE_DEVICE_FOR_WRITING, O_RDWR, 0);
1700
+ if (fd < 0) return Qnil;
1701
+ out = rb_io_open_descriptor(klass, fd, FMODE_WRITABLE | FMODE_SYNC, path, Qnil, NULL);
1702
+ #endif
1703
+ fd = rb_cloexec_open(CONSOLE_DEVICE_FOR_READING, O_RDWR, 0);
1704
+ if (fd < 0) {
1705
+ #ifdef CONSOLE_DEVICE_FOR_WRITING
1706
+ rb_io_close(out);
1707
+ #endif
1708
+ return Qnil;
1709
+ }
1710
+
1711
+ con = rb_io_open_descriptor(klass, fd, FMODE_READWRITE | FMODE_SYNC, path, Qnil, NULL);
1712
+ #ifdef CONSOLE_DEVICE_FOR_WRITING
1713
+ rb_io_set_write_io(con, out);
1714
+ #endif
1715
+ console_dev_set(klass, con);
1716
+ }
1717
+
1718
+ if (sym) {
1719
+ return rb_f_send(argc, argv, con);
1720
+ }
1721
+
1722
+ return con;
1723
+ }
1724
+
1725
+ /*
1726
+ * call-seq:
1727
+ * io.getch(min: nil, time: nil, intr: nil) -> char
1728
+ *
1729
+ * See IO#getch.
1730
+ */
1731
+ static VALUE
1732
+ io_getch(int argc, VALUE *argv, VALUE io)
1733
+ {
1734
+ return rb_funcallv(io, id_getc, argc, argv);
1735
+ }
1736
+
1737
+ static VALUE
1738
+ puts_call(VALUE io)
1739
+ {
1740
+ return rb_io_write(io, rb_default_rs);
1741
+ }
1742
+
1743
+ static VALUE
1744
+ gets_call(VALUE io)
1745
+ {
1746
+ return rb_funcallv(io, id_gets, 0, 0);
1747
+ }
1748
+
1749
+ static VALUE
1750
+ getpass_call(VALUE io)
1751
+ {
1752
+ return ttymode(io, rb_io_gets, io, set_noecho, NULL);
1753
+ }
1754
+
1755
+ static void
1756
+ prompt(int argc, VALUE *argv, VALUE io)
1757
+ {
1758
+ if (argc > 0 && !NIL_P(argv[0])) {
1759
+ VALUE str = argv[0];
1760
+ StringValueCStr(str);
1761
+ rb_io_write(io, str);
1762
+ }
1763
+ }
1764
+
1765
+ static VALUE
1766
+ str_chomp(VALUE str)
1767
+ {
1768
+ if (!NIL_P(str)) {
1769
+ const VALUE rs = rb_default_rs; /* rvalue in TruffleRuby */
1770
+ rb_funcallv(str, id_chomp_bang, 1, &rs);
1771
+ }
1772
+ return str;
1773
+ }
1774
+
1775
+ /*
1776
+ * call-seq:
1777
+ * io.getpass(prompt=nil) -> string
1778
+ *
1779
+ * Reads and returns a line without echo back.
1780
+ * Prints +prompt+ unless it is +nil+.
1781
+ *
1782
+ * The newline character that terminates the
1783
+ * read line is removed from the returned string,
1784
+ * see String#chomp!.
1785
+ *
1786
+ * You must require 'io/console' to use this method.
1787
+ *
1788
+ * require 'io/console'
1789
+ * IO::console.getpass("Enter password:")
1790
+ * Enter password:
1791
+ * # => "mypassword"
1792
+ *
1793
+ */
1794
+ static VALUE
1795
+ console_getpass(int argc, VALUE *argv, VALUE io)
1796
+ {
1797
+ VALUE str, wio;
1798
+
1799
+ rb_check_arity(argc, 0, 1);
1800
+ wio = rb_io_get_write_io(io);
1801
+ if (wio == io && io == rb_stdin) wio = rb_stderr;
1802
+ prompt(argc, argv, wio);
1803
+ rb_io_flush(wio);
1804
+ str = rb_ensure(getpass_call, io, puts_call, wio);
1805
+ return str_chomp(str);
1806
+ }
1807
+
1808
+ /*
1809
+ * call-seq:
1810
+ * io.getpass(prompt=nil) -> string
1811
+ *
1812
+ * See IO#getpass.
1813
+ */
1814
+ static VALUE
1815
+ io_getpass(int argc, VALUE *argv, VALUE io)
1816
+ {
1817
+ VALUE str;
1818
+
1819
+ rb_check_arity(argc, 0, 1);
1820
+ prompt(argc, argv, io);
1821
+ rb_check_funcall(io, id_flush, 0, 0);
1822
+ str = rb_ensure(gets_call, io, puts_call, io);
1823
+ return str_chomp(str);
1824
+ }
1825
+
1826
+ #if defined(_WIN32) || defined(HAVE_TTYNAME_R) || defined(HAVE_TTYNAME)
1827
+ /*
1828
+ * call-seq:
1829
+ * io.ttyname -> string or nil
1830
+ *
1831
+ * Returns name of associated terminal (tty) if +io+ is not a tty.
1832
+ * Returns +nil+ otherwise.
1833
+ */
1834
+ static VALUE
1835
+ console_ttyname(VALUE io)
1836
+ {
1837
+ int fd = rb_io_descriptor(io);
1838
+ if (!isatty(fd)) return Qnil;
1839
+ # if defined _WIN32
1840
+ return rb_usascii_str_new_lit("con");
1841
+ # elif defined HAVE_TTYNAME_R
1842
+ {
1843
+ char termname[1024], *tn = termname;
1844
+ size_t size = sizeof(termname);
1845
+ int e;
1846
+ if (ttyname_r(fd, tn, size) == 0)
1847
+ return rb_interned_str_cstr(tn);
1848
+ if ((e = errno) == ERANGE) {
1849
+ VALUE s = rb_str_new(0, size);
1850
+ while (1) {
1851
+ tn = RSTRING_PTR(s);
1852
+ size = rb_str_capacity(s);
1853
+ if (ttyname_r(fd, tn, size) == 0) {
1854
+ return rb_str_to_interned_str(rb_str_resize(s, strlen(tn)));
1855
+ }
1856
+ if ((e = errno) != ERANGE) break;
1857
+ if ((size *= 2) >= INT_MAX/2) break;
1858
+ rb_str_resize(s, size);
1859
+ }
1860
+ }
1861
+ rb_syserr_fail_str(e, rb_sprintf("ttyname_r(%d)", fd));
1862
+ UNREACHABLE_RETURN(Qnil);
1863
+ }
1864
+ # elif defined HAVE_TTYNAME
1865
+ {
1866
+ const char *tn = ttyname(fd);
1867
+ if (!tn) {
1868
+ int e = errno;
1869
+ rb_syserr_fail_str(e, rb_sprintf("ttyname(%d)", fd));
1870
+ }
1871
+ return rb_interned_str_cstr(tn);
1872
+ }
1873
+ # else
1874
+ # error No ttyname function
1875
+ # endif
1876
+ }
1877
+ #else
1878
+ # define console_ttyname rb_f_notimplement
1879
+ #endif
1880
+
1881
+ /*
1882
+ * IO console methods
1883
+ */
1884
+ void
1885
+ Init_console(void)
1886
+ {
1887
+ #if USE_RACTOR_STORAGE
1888
+ RB_EXT_RACTOR_SAFE(true);
1889
+ #endif
1890
+
1891
+ #undef rb_intern
1892
+ #if USE_RACTOR_STORAGE
1893
+ key_console_dev = rb_ractor_local_storage_value_newkey();
1894
+ #else
1895
+ id_console = rb_intern("console");
1896
+ #endif
1897
+ id_getc = rb_intern("getc");
1898
+ id_gets = rb_intern("gets");
1899
+ id_flush = rb_intern("flush");
1900
+ id_chomp_bang = rb_intern("chomp!");
1901
+ id_close = rb_intern("close");
1902
+ #define init_rawmode_opt_id(name) \
1903
+ rawmode_opt_ids[kwd_##name] = rb_intern(#name)
1904
+ init_rawmode_opt_id(min);
1905
+ init_rawmode_opt_id(time);
1906
+ init_rawmode_opt_id(intr);
1907
+ #ifndef HAVE_RB_F_SEND
1908
+ id___send__ = rb_intern("__send__");
1909
+ #endif
1910
+ InitVM(console);
1911
+ }
1912
+
1913
+ void
1914
+ InitVM_console(void)
1915
+ {
1916
+ rb_define_method(rb_cIO, "raw", console_raw, -1);
1917
+ rb_define_method(rb_cIO, "raw!", console_set_raw, -1);
1918
+ rb_define_method(rb_cIO, "cooked", console_cooked, 0);
1919
+ rb_define_method(rb_cIO, "cooked!", console_set_cooked, 0);
1920
+ rb_define_method(rb_cIO, "getch", console_getch, -1);
1921
+ rb_define_method(rb_cIO, "echo=", console_set_echo, 1);
1922
+ rb_define_method(rb_cIO, "echo?", console_echo_p, 0);
1923
+ rb_define_method(rb_cIO, "console_mode", console_conmode_get, 0);
1924
+ rb_define_method(rb_cIO, "console_mode=", console_conmode_set, 1);
1925
+ rb_define_method(rb_cIO, "noecho", console_noecho, 0);
1926
+ rb_define_method(rb_cIO, "winsize", console_winsize, 0);
1927
+ rb_define_method(rb_cIO, "winsize=", console_set_winsize, 1);
1928
+ rb_define_method(rb_cIO, "iflush", console_iflush, 0);
1929
+ rb_define_method(rb_cIO, "oflush", console_oflush, 0);
1930
+ rb_define_method(rb_cIO, "ioflush", console_ioflush, 0);
1931
+ rb_define_method(rb_cIO, "beep", console_beep, 0);
1932
+ rb_define_method(rb_cIO, "goto", console_goto, 2);
1933
+ rb_define_method(rb_cIO, "cursor", console_cursor_pos, 0);
1934
+ rb_define_method(rb_cIO, "cursor=", console_cursor_set, 1);
1935
+ rb_define_method(rb_cIO, "cursor_up", console_cursor_up, 1);
1936
+ rb_define_method(rb_cIO, "cursor_down", console_cursor_down, 1);
1937
+ rb_define_method(rb_cIO, "cursor_left", console_cursor_left, 1);
1938
+ rb_define_method(rb_cIO, "cursor_right", console_cursor_right, 1);
1939
+ rb_define_method(rb_cIO, "goto_column", console_goto_column, 1);
1940
+ rb_define_method(rb_cIO, "erase_line", console_erase_line, 1);
1941
+ rb_define_method(rb_cIO, "erase_screen", console_erase_screen, 1);
1942
+ rb_define_method(rb_cIO, "scroll_forward", console_scroll_forward, 1);
1943
+ rb_define_method(rb_cIO, "scroll_backward", console_scroll_backward, 1);
1944
+ rb_define_method(rb_cIO, "clear_screen", console_clear_screen, 0);
1945
+ rb_define_method(rb_cIO, "pressed?", console_key_pressed_p, 1);
1946
+ rb_define_method(rb_cIO, "check_winsize_changed", console_check_winsize_changed, 0);
1947
+ rb_define_method(rb_cIO, "getpass", console_getpass, -1);
1948
+ rb_define_method(rb_cIO, "ttyname", console_ttyname, 0);
1949
+ rb_define_singleton_method(rb_cIO, "console", console_dev, -1);
1950
+ {
1951
+ /* :stopdoc: */
1952
+ VALUE mReadable = rb_define_module_under(rb_cIO, "generic_readable");
1953
+ /* :startdoc: */
1954
+ rb_define_method(mReadable, "getch", io_getch, -1);
1955
+ rb_define_method(mReadable, "getpass", io_getpass, -1);
1956
+ }
1957
+ {
1958
+ /* :stopdoc: */
1959
+ cConmode = rb_define_class_under(rb_cIO, "ConsoleMode", rb_cObject);
1960
+ rb_define_const(cConmode, "VERSION", rb_obj_freeze(rb_str_new_cstr(IO_CONSOLE_VERSION)));
1961
+ rb_define_alloc_func(cConmode, conmode_alloc);
1962
+ rb_undef_method(cConmode, "initialize");
1963
+ rb_define_method(cConmode, "initialize_copy", conmode_init_copy, 1);
1964
+ rb_define_method(cConmode, "echo=", conmode_set_echo, 1);
1965
+ rb_define_method(cConmode, "raw!", conmode_set_raw, -1);
1966
+ rb_define_method(cConmode, "raw", conmode_raw_new, -1);
1967
+ /* :startdoc: */
1968
+ }
1969
+ }