From 0a0c06e37f8a236cf780ee822357e5c59e197d5c Mon Sep 17 00:00:00 2001 From: hut Date: Sun, 19 Jul 2009 23:21:48 +0200 Subject: replaced EVIL with Option.evil, moved explanation to scheduler.rb --- code/scheduler.rb | 13 +++++++++---- ranger.rb | 6 +----- 2 files changed, 10 insertions(+), 9 deletions(-) diff --git a/code/scheduler.rb b/code/scheduler.rb index e35f28d6..1ca4915e 100644 --- a/code/scheduler.rb +++ b/code/scheduler.rb @@ -12,8 +12,15 @@ module Scheduler @active = false @thread ||= Thread.new do - if EVIL + ## I have two ways of doing this. the first is somewhat better + ## but leads to problems with ncurses: + ## sometimes if you close the terminal window by clicking on + ## the X or pressing alt+F4 or in any other way that the window + ## manager provides, it will not properly exit and keep running + ## in the background, using up 100% CPU. + if Option.evil Thread.current.priority = PRIORITY + while true Thread.stop manage unless @scheduled.empty? or !@active @@ -40,10 +47,8 @@ module Scheduler dir.scheduled = true unless @scheduled.include? dir @scheduled << dir - if EVIL - @thread.run - end end + @thread.run if Option.evil end private diff --git a/ranger.rb b/ranger.rb index 3dc05e6d..485305e8 100755 --- a/ranger.rb +++ b/ranger.rb @@ -4,11 +4,6 @@ version = '0.2.4' require 'pathname' $: << MYDIR = File.dirname(Pathname(__FILE__).realpath) -## this switches on some features which may cause harm, -## mainly by leaving this program running after you quit it from -## your window manager, ie. clicking on the X or pressing ALT+F4 -EVIL = false - if ARGV.size > 0 case ARGV.first when '-k' @@ -50,6 +45,7 @@ opt = { :debug_file => '/tmp/errorlog', :colorscheme => 'default', :cd => ARGV.include?('--cd'), + :evil => false } class OptionClass < Struct.new(*opt.keys) -- cgit 1.4.1-2-gfad0