<commit_before>#!/usr/bin/env ruby

require 'rubygems'
require_relative '../../lib/ppcurses.rb'

@count = 0
def select_counter ( notification )
  @count += 1
end

@app = PPCurses::Application.new

table_view = PPCurses::TableView.new

values = %w(Music Reading Lifts)
data_source = PPCurses::SingleColumnDataSource.new(values)

table_view.data_source=data_source

@app.content_view = table_view

note_centre = PPCurses::NotificationCentre.default_centre

note_centre.add_observer(self, method(:select_counter),  PPTableViewSelectionDidChangeNotification, table_view )

@app.launch

puts "Number of selection changes is: #{@count} "<commit_msg>connect enter to action. WIP.<commit_after>#!/usr/bin/env ruby

require 'rubygems'
require_relative '../../lib/ppcurses.rb'
# ------------------------------------------------------------------------------
# Tableview callbacks
# ------------------------------------------------------------------------------
@select_count = 0
def select_counter ( notification )
  @select_count += 1
end

@enter_count = 0
def item_chosen ( notification )
  @enter_count += 1
  
  if notification.object.selected_row == 0
    @app.content_view = @music_form
  end
  
end
# ------------------------------------------------------------------------------

@music_form = PPCurses::Form.new
media = PPCurses::RadioButtonGroup.new(' Media Type', %w(CD Vinyl MP3) )
buttons = PPCurses::ButtonPair.new('Submit', 'Cancel')
@music_form.add(media)
@music_form.add(buttons)


@app = PPCurses::Application.new
table_view = PPCurses::TableView.new

values = %w(Music Reading Lifts)
data_source = PPCurses::SingleColumnDataSource.new(values)

table_view.data_source=data_source

@app.content_view = table_view

notary = PPCurses::NotificationCentre.default_centre
notary.add_observer(self, method(:select_counter),  PPTableViewSelectionDidChangeNotification, table_view )
notary.add_observer(self, method(:item_chosen),  PPTableViewEnterPressedNotification, table_view )

@app.launch

puts "Number of selection changes was: #{@select_count} "
puts "Enter was pressed #{@enter_count} times."
{'fraction_non_alphanumeric': 0.21571428571428572, 'fraction_numerical': 0.0038095238095238095, 'mean_word_length': 3.2358870967741935, 'pattern_counts': {'":': 0, '<': 3, '<?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': '7536199', 'n_tokens_mistral': 657, 'n_tokens_neox': 637, 'n_words': 126}