<commit_before># coding: utf-8

require_relative 'read_line/window'
require_relative 'read_line/history'
require_relative 'read_line/edit'

#* read_line.rb - The ReadLine class that does the actual work.
module MiniReadline

  #The \Readline class that does the actual work of getting lines from the
  #user. Note that each instance of this class maintains its own copy of
  #the optional command history.
  class Readline

    #Setup the instance of the mini line editor.
    #<br>Parameters:
    #* history - An array of strings used to contain the history. Use an empty
    #  array to have a history buffer with no initial entries. Use the
    #  value nil (or false) to maintain no history at all.
    def initialize(history=[])
      @history = History.new(history)
    end

    #Read a line from the console with edit and history.
    #<br>Parameters:
    #* prompt - A string used to prompt the user. '>' is popular.
    #* options - A hash of options; Typically :symbol => value
    def readline(prompt, options = {})
      initialize_readline(prompt, options)
      edit_loop
      @term.put_string("\n")
      @history.append_history(edit_buffer, @options)
      edit_buffer
    end

    #Initialize the read line process. This basically process the arguments
    #of the readline method.
    def initialize_readline(prompt, options = {})
      @options, @working = MiniReadline::BASE_OPTIONS.merge(options), true
      (@term = @options[:term]).reset

      set_prompt(prompt)
      initialize_edit_parms
      setup_window_parms
      @history.goto_end_of_history<commit_msg>Added a method to get the history buffer of a read line instance. Replaced clever code with clear code.<commit_after># coding: utf-8

require_relative 'read_line/window'
require_relative 'read_line/history'
require_relative 'read_line/edit'

#* read_line.rb - The ReadLine class that does the actual work.
module MiniReadline

  #The \Readline class that does the actual work of getting lines from the
  #user. Note that each instance of this class maintains its own copy of
  #the optional command history.
  class Readline

    #Setup the instance of the mini line editor.
    #<br>Parameters:
    #* buffer - An array of strings used to contain the history. Use an empty
    #  array to have a history buffer with no initial entries. Use the
    #  value nil (or false) to maintain no history at all.
    def initialize(buffer=[])
      @history = History.new(buffer)
    end

    #Get the history buffer of this read line instance.
    def history
      @history.history
    end

    #Read a line from the console with edit and history.
    #<br>Parameters:
    #* prompt - A string used to prompt the user. '>' is popular.
    #* options - A hash of options; Typically :symbol => value
    def readline(prompt, options = {})
      initialize_readline(prompt, options)
      edit_loop
      @term.put_string("\n")
      @history.append_history(edit_buffer, @options)
      edit_buffer
    end

    #Initialize the read line process. This basically process the arguments
    #of the readline method.
    def initialize_readline(prompt, options = {})
      @options = MiniReadline::BASE_OPTIONS.merge(options)
      @working = true
      (@term = @options[:term]).reset

      set_prompt(prompt)
      initialize_edit_parms
      setup_window_parms
      @history.goto_end_of_history
{'fraction_non_alphanumeric': 0.07737918766676549, 'fraction_numerical': 0.0005929439667951378, 'mean_word_length': 3.2280701754385963, 'pattern_counts': {'":': 0, '<': 7, '<?xml version=': 0, '>': 11, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '1530670', 'n_tokens_mistral': 955, 'n_tokens_neox': 934, 'n_words': 366}