summaryrefslogtreecommitdiff
path: root/lib/irb
diff options
context:
space:
mode:
authorkeiju <keiju@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2001-05-08 09:28:19 +0000
committerkeiju <keiju@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2001-05-08 09:28:19 +0000
commit3c1264113ea52594940ce970fba2dc4eb83d5075 (patch)
treeea224162e950ca78a2c749bec583d74f7b256038 /lib/irb
parent6ea874604879ce674ac54fb519489d427e3749a2 (diff)
*** empty log message ***
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@1384 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'lib/irb')
-rw-r--r--lib/irb/multi-irb.rb29
-rw-r--r--lib/irb/ruby-lex.rb48
-rw-r--r--lib/irb/version.rb6
3 files changed, 59 insertions, 24 deletions
diff --git a/lib/irb/multi-irb.rb b/lib/irb/multi-irb.rb
index 51c8c9c..6e97512 100644
--- a/lib/irb/multi-irb.rb
+++ b/lib/irb/multi-irb.rb
@@ -31,7 +31,7 @@ module IRB
def thread(key)
th, irb = search(key)
- irb
+ th
end
def irb(key)
@@ -74,7 +74,7 @@ module IRB
when Integer
@jobs[key]
when Irb
- @jobs.find{|k, v| v.equal?(irb)}
+ @jobs.find{|k, v| v.equal?(key)}
when Thread
@jobs.assoc(key)
else
@@ -156,6 +156,7 @@ module IRB
end
@CONF[:IRB_RC].call(irb.context) if @CONF[:IRB_RC]
@JobManager.insert(irb)
+ @JobManager.current_job = irb
begin
system_exit = false
catch(:IRB_EXIT) do
@@ -200,8 +201,32 @@ module IRB
@JobManager.insert(@CONF[:MAIN_CONTEXT].irb)
@JobManager.current_job = @CONF[:MAIN_CONTEXT].irb
+ class Irb
+ def signal_handle
+ unless @context.ignore_sigint?
+ print "\nabort!!\n" if @context.verbose?
+ exit
+ end
+
+ case @signal_status
+ when :IN_INPUT
+ print "^C\n"
+ IRB.JobManager.thread(self).raise RubyLex::TerminateLineInput
+ when :IN_EVAL
+ IRB.irb_abort(self)
+ when :IN_LOAD
+ IRB.irb_abort(self, LoadAbort)
+ when :IN_IRB
+ # ignore
+ else
+ # ignore
+ end
+ end
+ end
+
trap("SIGINT") do
@JobManager.current_job.signal_handle
+ Thread.stop
end
end
diff --git a/lib/irb/ruby-lex.rb b/lib/irb/ruby-lex.rb
index e92b45b..3a86200 100644
--- a/lib/irb/ruby-lex.rb
+++ b/lib/irb/ruby-lex.rb
@@ -24,6 +24,8 @@ class RubyLex
def_exception(:TkReading2TokenDuplicateError,
"key duplicate(token_n='%s', key='%s')")
def_exception(:SyntaxError, "%s")
+
+ def_exception(:TerminateLineInput, "Terminate Line Input")
include RubyToken
@@ -211,27 +213,35 @@ class RubyLex
def each_top_level_statement
initialize_input
- loop do
- @continue = false
- prompt
- unless l = lex
- break if @line == ''
- else
- # p l
- @line.concat l
- if @ltype or @continue or @indent > 0
- next
+ catch(:TERM_INPUT) do
+ loop do
+ begin
+ @continue = false
+ prompt
+ unless l = lex
+ throw :TERM_INPUT if @line == ''
+ else
+ #p l
+ @line.concat l
+ if @ltype or @continue or @indent > 0
+ next
+ end
+ end
+ if @line != "\n"
+ yield @line, @exp_line_no
+ end
+ break unless l
+ @line = ''
+ @exp_line_no = @line_no
+
+ @indent = 0
+ prompt
+ rescue TerminateLineInput
+ initialize_input
+ prompt
+ get_readed
end
end
- if @line != "\n"
- yield @line, @exp_line_no
- end
- break unless l
- @line = ''
- @exp_line_no = @line_no
-
- @indent = 0
- prompt
end
end
diff --git a/lib/irb/version.rb b/lib/irb/version.rb
index b309978..367cc21 100644
--- a/lib/irb/version.rb
+++ b/lib/irb/version.rb
@@ -1,6 +1,6 @@
#
# irb/version.rb - irb version definition file
-# $Release Version: 0.7.3$
+# $Release Version: 0.7.4$
# $Revision$
# $Date$
# by Keiju ISHITSUKA(keiju@ishitsuka.com)
@@ -11,6 +11,6 @@
#
module IRB
- @RELEASE_VERSION = "0.7.3"
- @LAST_UPDATE_DATE = "01/04/16"
+ @RELEASE_VERSION = "0.7.4"
+ @LAST_UPDATE_DATE = "01/05/08"
end