<commit_before>require "recording_strategies/strategy"
module TRecs
  class TmuxSessionStrategy
    include Strategy
    attr_reader :recording
    attr_reader :step

    def initialize(options={})
      @frames = []
      @step = options.fetch(:step) { 100 } / 1000.0
      @color = options.fetch(:color) { true }
      set_color_or_bw
    end

    def perform
      start_recording
      while(recording)
        get_frames do |frame|
          recorder.current_frame(content: frame)
        end
        sleep(step)
      end
    end


    def command
      @command ||=
        set_command
    end

    def stop
      @recording = false
    end

    private
    def start_recording
      @recording = true
    end

    def set_color_or_bw
      @color = @color ? "-e" : "-C"
    end

    def set_command
      command = %W[tmux capture-pane -F "#{cursor_flag}"]
      command << @color if @color

      curpos = `col=\`tput col\` && line=\`tput line\` && echo col, line`
      `notify-send #{curpos}`

      command
    end

    def get_frames
      system *command
      IO.popen(%W[tmux show-buffer]) do |out|
        yield out.read<commit_msg>Escaping invisible characters on TmuxSessionStrategy<commit_after>require "recording_strategies/strategy"
module TRecs
  class TmuxSessionStrategy
    include Strategy
    attr_reader :recording
    attr_reader :step

    def initialize(options={})
      @frames = []
      @step = options.fetch(:step) { 100 } / 1000.0
      @color = options.fetch(:color) { true }
      set_color_or_bw
    end

    def perform
      start_recording
      while(recording)
        get_frames do |frame|
          recorder.current_frame(content: frame)
        end
        sleep(step)
      end
    end


    def command
      @command ||=
        set_command
    end

    def stop
      @recording = false
    end

    private
    def start_recording
      @recording = true
    end

    def set_color_or_bw
      @color = @color ? "-e" : "-C"
    end

    def set_command
      command = %W[tmux capture-pane]
      command << @color if @color
      command
    end

    def get_frames
      system *command
      IO.popen(%W[tmux show-buffer]) do |out|
        yield out.read
{'fraction_non_alphanumeric': 0.08955223880597014, 'fraction_numerical': 0.007236544549977386, 'mean_word_length': 2.0552486187845305, 'pattern_counts': {'":': 0, '<': 7, '<?xml version=': 0, '>': 3, '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': '7317169', 'n_tokens_mistral': 721, 'n_tokens_neox': 684, 'n_words': 177}