<commit_before>require 'src/gesturecontroller'

$events = $win.events
$point_source = $win.pointSource

$gesturecontroller = Gesturecontroller.new
$newgesture = Gesture.new

# Booted up, go enable things
$win.StartAccelerometer.enabled = true

$running = false
$recording = false

JOP = Java::Javax::swing::JOptionPane
SU = Java::Javax::swing::SwingUtilities

event_handlers = {nil => Proc.new{}}
event_handlers['start_accelerometer'] = Proc.new do
  $stderr.puts "Connecting to accelerometer"
  $point_source.connect
  SU.invokeLater do
    $win.liveDisplayButton.enabled = true
  end
  $running = true
end

event_handlers['stop_accelerometer'] = Proc.new do
  $stderr.puts "Stopping accelerometer"
  $point_source.disconnect
  $running = false
end

event_handlers['new_gesture'] = Proc.new do
  $stderr.puts "Recording new gesture"
  $newgesture = Gesture.new
  $newgesture.name = $win.gestureName.getText
  $newgesture.action = $win.AppScriptPane.getText
  $recording = true
end

event_handlers['stop_gesture'] = Proc.new do
  $stderr.puts "Stopping gesture"
  $recording = false
  $gesturecontroller.add_gesture($newgesture)
end

event_handlers['exit'] = Proc.new do
  $stderr.puts "Dumping gestures to disk"
  $gesturecontroller.store_all_gestures
end

event_handlers['save'] = Proc.new do
  $stderr.puts "Saving gestures to disk"
  $gesturecontroller.store_all_gestures
end
<commit_msg>Moved name and action recording to stopping the gesture<commit_after>require 'src/gesturecontroller'

$events = $win.events
$point_source = $win.pointSource

$gesturecontroller = Gesturecontroller.new
$newgesture = Gesture.new

# Booted up, go enable things
$win.StartAccelerometer.enabled = true

$running = false
$recording = false

JOP = Java::Javax::swing::JOptionPane
SU = Java::Javax::swing::SwingUtilities

event_handlers = {nil => Proc.new{}}
event_handlers['start_accelerometer'] = Proc.new do
  $stderr.puts "Connecting to accelerometer"
  $point_source.connect
  SU.invokeLater do
    $win.liveDisplayButton.enabled = true
  end
  $running = true
end

event_handlers['stop_accelerometer'] = Proc.new do
  $stderr.puts "Stopping accelerometer"
  $point_source.disconnect
  $running = false
end

event_handlers['new_gesture'] = Proc.new do
  $stderr.puts "Recording new gesture"
  $newgesture = Gesture.new
  $recording = true
end

event_handlers['stop_gesture'] = Proc.new do
  $stderr.puts "Stopping gesture"
  $recording = false
  $newgesture.name = $win.gestureName.getText
  $newgesture.action = $win.AppScriptPane.getText
  $gesturecontroller.add_gesture($newgesture)
end

event_handlers['exit'] = Proc.new do
  $stderr.puts "Dumping gestures to disk"
  $gesturecontroller.store_all_gestures
end

event_handlers['save'] = Proc.new do
  $stderr.puts "Saving gestures to disk"
  $gesturecontroller.store_all_gestures
end

{'fraction_non_alphanumeric': 0.10828025477707007, 'fraction_numerical': 0.0, 'mean_word_length': 5.4104308390022675, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 5, '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': '471287', 'n_tokens_mistral': 990, 'n_tokens_neox': 969, 'n_words': 208}