mirror of
https://github.com/ruby/ruby.git
synced 2022-11-09 12:17:21 -05:00
* ext/tcltklib/tcltklib.c (ip_init): bug fix
* ext/tk/tkutil.c (get_eval_string_core): accept a Regexp object * ext/tk/lib/multi-tk.rb: fix bug on 'exit' operation * ext/tk/lib/tk/text.rb: 'tksearch' accepts a Regexp object as a matting pattern argument git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/branches/ruby_1_8@6973 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
parent
2934335086
commit
ffb051a4ec
8 changed files with 133 additions and 10 deletions
11
ChangeLog
11
ChangeLog
|
|
@ -1,3 +1,14 @@
|
||||||
|
Thu Sep 30 00:50:44 2004 Hidetoshi NAGAI <nagai@ai.kyutech.ac.jp>
|
||||||
|
|
||||||
|
* ext/tcltklib/tcltklib.c (ip_init): bug fix
|
||||||
|
|
||||||
|
* ext/tk/tkutil.c (get_eval_string_core): accept a Regexp object
|
||||||
|
|
||||||
|
* ext/tk/lib/multi-tk.rb: fix bug on 'exit' operation
|
||||||
|
|
||||||
|
* ext/tk/lib/tk/text.rb: 'tksearch' accepts a Regexp object as a
|
||||||
|
matting pattern argument
|
||||||
|
|
||||||
Wed Sep 29 10:58:07 2004 Nobuyoshi Nakada <nobu@ruby-lang.org>
|
Wed Sep 29 10:58:07 2004 Nobuyoshi Nakada <nobu@ruby-lang.org>
|
||||||
|
|
||||||
* enum.c (sort_by_i): internally used object must not be changed
|
* enum.c (sort_by_i): internally used object must not be changed
|
||||||
|
|
|
||||||
|
|
@ -3271,6 +3271,8 @@ delete_slaves(ip)
|
||||||
char *slave_name;
|
char *slave_name;
|
||||||
int i, len;
|
int i, len;
|
||||||
|
|
||||||
|
DUMP2("delete slaves of ip(%lx)", ip);
|
||||||
|
|
||||||
Tcl_Preserve(ip);
|
Tcl_Preserve(ip);
|
||||||
|
|
||||||
if (Tcl_Eval(ip, "info slaves") == TCL_ERROR) {
|
if (Tcl_Eval(ip, "info slaves") == TCL_ERROR) {
|
||||||
|
|
@ -3339,7 +3341,10 @@ ip_free(ptr)
|
||||||
thr_crit_bup = rb_thread_critical;
|
thr_crit_bup = rb_thread_critical;
|
||||||
rb_thread_critical = Qtrue;
|
rb_thread_critical = Qtrue;
|
||||||
|
|
||||||
|
DUMP2("IP ref_count = %d", ptr->ref_count);
|
||||||
|
|
||||||
if (!Tcl_InterpDeleted(ptr->ip)) {
|
if (!Tcl_InterpDeleted(ptr->ip)) {
|
||||||
|
DUMP2("IP(%lx) is not deleted", ptr->ip);
|
||||||
/* Tcl_Preserve(ptr->ip); */
|
/* Tcl_Preserve(ptr->ip); */
|
||||||
rbtk_preserve_ip(ptr);
|
rbtk_preserve_ip(ptr);
|
||||||
|
|
||||||
|
|
@ -3369,6 +3374,7 @@ ip_free(ptr)
|
||||||
}
|
}
|
||||||
|
|
||||||
rbtk_release_ip(ptr);
|
rbtk_release_ip(ptr);
|
||||||
|
DUMP2("IP ref_count = %d", ptr->ref_count);
|
||||||
|
|
||||||
free(ptr);
|
free(ptr);
|
||||||
|
|
||||||
|
|
@ -3418,7 +3424,8 @@ ip_init(argc, argv, self)
|
||||||
rb_raise(rb_eRuntimeError, "fail to create a new Tk interpreter");
|
rb_raise(rb_eRuntimeError, "fail to create a new Tk interpreter");
|
||||||
}
|
}
|
||||||
|
|
||||||
rbtk_preserve_ip((ClientData)ptr->ip);
|
rbtk_preserve_ip(ptr);
|
||||||
|
DUMP2("IP ref_count = %d", ptr->ref_count);
|
||||||
current_interp = ptr->ip;
|
current_interp = ptr->ip;
|
||||||
|
|
||||||
ptr->has_orig_exit
|
ptr->has_orig_exit
|
||||||
|
|
|
||||||
|
|
@ -268,6 +268,7 @@ sample/iso2022-kr.txt
|
||||||
sample/menubar1.rb
|
sample/menubar1.rb
|
||||||
sample/menubar2.rb
|
sample/menubar2.rb
|
||||||
sample/multi-ip_sample.rb
|
sample/multi-ip_sample.rb
|
||||||
|
sample/multi-ip_sample2.rb
|
||||||
sample/optobj_sample.rb
|
sample/optobj_sample.rb
|
||||||
sample/propagate.rb
|
sample/propagate.rb
|
||||||
sample/remote-ip_sample.rb
|
sample/remote-ip_sample.rb
|
||||||
|
|
|
||||||
|
|
@ -125,7 +125,10 @@ class MultiTkIp
|
||||||
|
|
||||||
if wait == 0
|
if wait == 0
|
||||||
# no wait
|
# no wait
|
||||||
|
Thread.pass
|
||||||
|
if thread.stop?
|
||||||
thread.raise exception
|
thread.raise exception
|
||||||
|
end
|
||||||
return thread
|
return thread
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
@ -294,7 +297,8 @@ class MultiTkIp
|
||||||
obj.delete unless obj.deleted?
|
obj.delete unless obj.deleted?
|
||||||
}
|
}
|
||||||
=end
|
=end
|
||||||
exit
|
#exit(e.status)
|
||||||
|
fail e
|
||||||
end
|
end
|
||||||
# break
|
# break
|
||||||
|
|
||||||
|
|
@ -1325,14 +1329,19 @@ class MultiTkIp
|
||||||
rescue MultiTkIp_OK => ret
|
rescue MultiTkIp_OK => ret
|
||||||
# return value
|
# return value
|
||||||
return ret.value
|
return ret.value
|
||||||
rescue SystemExit
|
rescue SystemExit => e
|
||||||
# exit IP
|
# exit IP
|
||||||
warn("Warning: " + $! + " on " + self.inspect) if $DEBUG
|
warn("Warning: " + $! + " on " + self.inspect) if $DEBUG
|
||||||
begin
|
begin
|
||||||
self._eval_without_enc('exit')
|
self._eval_without_enc('exit')
|
||||||
rescue Exception
|
rescue Exception
|
||||||
end
|
end
|
||||||
|
if !safe? && allow_ruby_exit?
|
||||||
self.delete
|
self.delete
|
||||||
|
fail e
|
||||||
|
else
|
||||||
|
self.delete
|
||||||
|
end
|
||||||
rescue Exception => e
|
rescue Exception => e
|
||||||
if $DEBUG
|
if $DEBUG
|
||||||
warn("Warning: " + e.class.inspect +
|
warn("Warning: " + e.class.inspect +
|
||||||
|
|
@ -1542,10 +1551,18 @@ class << MultiTkIp
|
||||||
__getip.deleted?
|
__getip.deleted?
|
||||||
end
|
end
|
||||||
|
|
||||||
def exit(st = 0)
|
def abort(msg = nil)
|
||||||
|
__getip.abort(msg)
|
||||||
|
end
|
||||||
|
|
||||||
|
def exit(st = true)
|
||||||
__getip.exit(st)
|
__getip.exit(st)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def exit!(st = false)
|
||||||
|
__getip.exit!(st)
|
||||||
|
end
|
||||||
|
|
||||||
def restart(app_name = nil, keys = {})
|
def restart(app_name = nil, keys = {})
|
||||||
init_ip_internal
|
init_ip_internal
|
||||||
|
|
||||||
|
|
@ -1852,7 +1869,21 @@ class MultiTkIp
|
||||||
@interp.deleted?
|
@interp.deleted?
|
||||||
end
|
end
|
||||||
|
|
||||||
def exit(st = 0)
|
def abort(msg = nil)
|
||||||
|
if master?
|
||||||
|
if msg
|
||||||
|
Kernel.abort(msg)
|
||||||
|
else
|
||||||
|
Kernel.abort
|
||||||
|
end
|
||||||
|
else
|
||||||
|
# ignore msg
|
||||||
|
delete
|
||||||
|
1
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
def exit(st = true)
|
||||||
if master?
|
if master?
|
||||||
Kernel.exit(st)
|
Kernel.exit(st)
|
||||||
else
|
else
|
||||||
|
|
@ -1861,6 +1892,15 @@ class MultiTkIp
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def exit!(st = false)
|
||||||
|
if master? && !safe? && allow_ruby_exit?
|
||||||
|
Kernel.exit!(st)
|
||||||
|
else
|
||||||
|
delete
|
||||||
|
st
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
def restart(app_name = nil, keys = {})
|
def restart(app_name = nil, keys = {})
|
||||||
_init_ip_internal(@@INIT_IP_ENV, @@ADD_TK_PROCS)
|
_init_ip_internal(@@INIT_IP_ENV, @@ADD_TK_PROCS)
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -971,12 +971,25 @@ class TkText<TkTextWin
|
||||||
# call 'search' subcommand of text widget
|
# call 'search' subcommand of text widget
|
||||||
# args ::= [<array_of_opts>] <pattern> <start_index> [<stop_index>]
|
# args ::= [<array_of_opts>] <pattern> <start_index> [<stop_index>]
|
||||||
# If <pattern> is regexp, then it must be a regular expression of Tcl
|
# If <pattern> is regexp, then it must be a regular expression of Tcl
|
||||||
|
nocase = false
|
||||||
if args[0].kind_of?(Array)
|
if args[0].kind_of?(Array)
|
||||||
opts = args.shift.collect{|opt| '-' + opt.to_s }
|
opts = args.shift.collect{|opt|
|
||||||
|
s_opt = opt.to_s
|
||||||
|
nocase = true if s_opt == 'nocase'
|
||||||
|
'-' + s_opt
|
||||||
|
}
|
||||||
else
|
else
|
||||||
opts = []
|
opts = []
|
||||||
end
|
end
|
||||||
|
|
||||||
|
if args[0].kind_of?(Regexp)
|
||||||
|
regexp = args.shift
|
||||||
|
if !nocase && (regexp.options & Regexp::IGNORECASE) != 0
|
||||||
|
opts << '-nocase'
|
||||||
|
end
|
||||||
|
args.unshift(regexp.source)
|
||||||
|
end
|
||||||
|
|
||||||
opts << '--'
|
opts << '--'
|
||||||
|
|
||||||
ret = tk_send('search', *(opts + args))
|
ret = tk_send('search', *(opts + args))
|
||||||
|
|
@ -991,13 +1004,28 @@ class TkText<TkTextWin
|
||||||
# call 'search' subcommand of text widget
|
# call 'search' subcommand of text widget
|
||||||
# args ::= [<array_of_opts>] <var> <pattern> <start_index> [<stop_index>]
|
# args ::= [<array_of_opts>] <var> <pattern> <start_index> [<stop_index>]
|
||||||
# If <pattern> is regexp, then it must be a regular expression of Tcl
|
# If <pattern> is regexp, then it must be a regular expression of Tcl
|
||||||
|
nocase = false
|
||||||
if args[0].kind_of?(Array)
|
if args[0].kind_of?(Array)
|
||||||
opts = args.shift.collect{|opt| '-' + opt.to_s }
|
opts = args.shift.collect{|opt|
|
||||||
|
s_opt = opt.to_s
|
||||||
|
nocase = true if s_opt == 'nocase'
|
||||||
|
'-' + s_opt
|
||||||
|
}
|
||||||
else
|
else
|
||||||
opts = []
|
opts = []
|
||||||
end
|
end
|
||||||
|
|
||||||
opts << '-count' << args.shift << '--'
|
opts << '-count' << args.shift
|
||||||
|
|
||||||
|
if args[0].kind_of?(Regexp)
|
||||||
|
regexp = args.shift
|
||||||
|
if !nocase && (regexp.options & Regexp::IGNORECASE) != 0
|
||||||
|
opts << '-nocase'
|
||||||
|
end
|
||||||
|
args.unshift(regexp.source)
|
||||||
|
end
|
||||||
|
|
||||||
|
opts << '--'
|
||||||
|
|
||||||
ret = tk_send('search', *(opts + args))
|
ret = tk_send('search', *(opts + args))
|
||||||
if ret == ""
|
if ret == ""
|
||||||
|
|
|
||||||
|
|
@ -104,8 +104,10 @@ Tkgeomap http://tkgeomap.sourceforge.net/index.html
|
||||||
===< not determined to supprt or not >========================================
|
===< not determined to supprt or not >========================================
|
||||||
|
|
||||||
BLT http://sourceforge.net/projects/blt
|
BLT http://sourceforge.net/projects/blt
|
||||||
|
* see tcltk-ext library on RAA (http://raa.ruby-lang.org/)
|
||||||
|
|
||||||
Tix http://tixlibrary.sourceforge.net/
|
Tix http://tixlibrary.sourceforge.net/
|
||||||
|
* see tcltk-ext library on RAA (http://raa.ruby-lang.org/)
|
||||||
|
|
||||||
TkZinc http://www.tkzinc.org/
|
TkZinc http://www.tkzinc.org/
|
||||||
|
|
||||||
|
|
|
||||||
29
ext/tk/sample/multi-ip_sample2.rb
Normal file
29
ext/tk/sample/multi-ip_sample2.rb
Normal file
|
|
@ -0,0 +1,29 @@
|
||||||
|
require 'multi-tk.rb'
|
||||||
|
|
||||||
|
th = Thread.new{Tk.mainloop}
|
||||||
|
|
||||||
|
TkLabel.new(:text=>'this is a primary master').pack
|
||||||
|
|
||||||
|
ip1 = MultiTkIp.new_slave(:safe=>1)
|
||||||
|
ip2 = MultiTkIp.new_slave(:safe=>2)
|
||||||
|
|
||||||
|
cmd = proc{|s|
|
||||||
|
require 'tk'
|
||||||
|
|
||||||
|
TkButton.new(:text=>'b1: p self', :command=>proc{p self}).pack(:fill=>:x)
|
||||||
|
sleep s
|
||||||
|
TkButton.new(:text=>'b2: p $SAFE', :command=>proc{p $SAFE}).pack(:fill=>:x)
|
||||||
|
sleep s
|
||||||
|
TkButton.new(:text=>'b3: p MultiTkIp.ip_name',
|
||||||
|
:command=>proc{p MultiTkIp.ip_name}).pack(:fill=>:x)
|
||||||
|
sleep s
|
||||||
|
TkButton.new(:text=>'EXIT', :command=>proc{exit}).pack(:fill=>:x)
|
||||||
|
|
||||||
|
Tk.mainloop
|
||||||
|
}
|
||||||
|
|
||||||
|
Thread.new{ip1.eval_proc(cmd, 1.1)}
|
||||||
|
Thread.new{ip2.eval_proc(cmd, 0.3)}
|
||||||
|
cmd.call(0.7)
|
||||||
|
|
||||||
|
th.join
|
||||||
|
|
@ -31,6 +31,7 @@ static ID ID_path;
|
||||||
static ID ID_at_path;
|
static ID ID_at_path;
|
||||||
static ID ID_to_eval;
|
static ID ID_to_eval;
|
||||||
static ID ID_to_s;
|
static ID ID_to_s;
|
||||||
|
static ID ID_source;
|
||||||
static ID ID_downcase;
|
static ID ID_downcase;
|
||||||
static ID ID_install_cmd;
|
static ID ID_install_cmd;
|
||||||
static ID ID_merge_tklist;
|
static ID ID_merge_tklist;
|
||||||
|
|
@ -664,6 +665,9 @@ get_eval_string_core(obj, enc_flag, self)
|
||||||
case T_NIL:
|
case T_NIL:
|
||||||
return rb_str_new2("");
|
return rb_str_new2("");
|
||||||
|
|
||||||
|
case T_REGEXP:
|
||||||
|
return rb_funcall(obj, ID_source, 0, 0);
|
||||||
|
|
||||||
default:
|
default:
|
||||||
if (rb_obj_is_kind_of(obj, cTkObject)) {
|
if (rb_obj_is_kind_of(obj, cTkObject)) {
|
||||||
/* return rb_str_new3(rb_funcall(obj, ID_path, 0, 0)); */
|
/* return rb_str_new3(rb_funcall(obj, ID_path, 0, 0)); */
|
||||||
|
|
@ -1235,6 +1239,7 @@ Init_tkutil()
|
||||||
ID_at_path = rb_intern("@path");
|
ID_at_path = rb_intern("@path");
|
||||||
ID_to_eval = rb_intern("to_eval");
|
ID_to_eval = rb_intern("to_eval");
|
||||||
ID_to_s = rb_intern("to_s");
|
ID_to_s = rb_intern("to_s");
|
||||||
|
ID_source = rb_intern("source");
|
||||||
ID_downcase = rb_intern("downcase");
|
ID_downcase = rb_intern("downcase");
|
||||||
ID_install_cmd = rb_intern("install_cmd");
|
ID_install_cmd = rb_intern("install_cmd");
|
||||||
ID_merge_tklist = rb_intern("_merge_tklist");
|
ID_merge_tklist = rb_intern("_merge_tklist");
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue