Class: TkNamespace
Defined Under Namespace
Classes: Ensemble, NsCode, ScopeArgs
Constant Summary
collapse
- TkCommandNames =
[
'namespace'.freeze,
].freeze
- Tk_Namespace_ID_TBL =
TkCore::INTERP.create_table
- Tk_NsCode_RetObjID_TBL =
TkCore::INTERP.create_table
Constants included
from Tk
Tk::AUTO_PATH, Tk::Fontchooser, Tk::INTERP, Tk::JAPANIZED_TK, Tk::LIBRARY_PATH, Tk::MAINLOOP, Tk::PACKAGE_PATH, Tk::RELEASE_DATE, Tk::TCL_LIBRARY_PATH, Tk::TCL_MAJOR_VERSION, Tk::TCL_MINOR_VERSION, Tk::TCL_PACKAGE_PATH, Tk::TCL_PATCHLEVEL, Tk::TCL_PRECISION, Tk::TCL_VERSION, Tk::TK_MAJOR_VERSION, Tk::TK_MINOR_VERSION, Tk::TK_PATCHLEVEL, Tk::TK_VERSION, Tk::Tkextlib_RELEASE_DATE, Tk::TreeCtrl_Widget, Tk::X_Scrollable, Tk::Y_Scrollable
Tk::Encoding::BINARY, Tk::Encoding::BINARY_NAME, Tk::Encoding::DEFAULT_EXTERNAL_NAME, Tk::Encoding::DEFAULT_INTERNAL_NAME, Tk::Encoding::ENCODING_TABLE, Tk::Encoding::RubyEncoding, Tk::Encoding::UNKNOWN, Tk::Encoding::UTF8_NAME
Constants included
from TkCore
TkCore::EventFlag, TkCore::INTERP, TkCore::INTERP_MUTEX, TkCore::INTERP_ROOT_CHECK, TkCore::INTERP_THREAD, TkCore::INTERP_THREAD_STATUS, TkCore::RUN_EVENTLOOP_ON_MAIN_THREAD, TkCore::WIDGET_DESTROY_HOOK, TkCore::WITH_ENCODING, TkCore::WITH_RUBY_VM
Constants included
from TkComm
TkComm::GET_CONFIGINFO_AS_ARRAY, TkComm::GET_CONFIGINFOwoRES_AS_ARRAY, TkComm::TkExtlibAutoloadModule, TkComm::Tk_CMDTBL, TkComm::Tk_IDs, TkComm::Tk_WINDOWS, TkComm::USE_TCLs_LIST_FUNCTIONS, TkComm::WidgetClassNames
Constants included
from TkUtil
TkUtil::None, TkUtil::RELEASE_DATE
Class Method Summary
collapse
Instance Method Summary
collapse
Methods included from Tk
BinaryString, EncodedString, Grid, Pack, Place, UTF8_String, __create_widget_set__, __disable_toplevel_control__, __import_toplevel_aliases__, __regist_toplevel_aliases__, __remove_toplevel_aliases__, __reset_toplevel_owner__, __set_loaded_toplevel_aliases__, __set_toplevel_aliases__, __toplevel_alias_setup_proc__, _replace_toplevel_aliases, add_kinsoku, backup_current_topdef, bell, bell_on_display, const_missing, current_grabs, cursor_display, default_widget_set, default_widget_set=, define_topalias, define_topobj, delete_kinsoku, destroy, encoding, encoding=, errorCode, errorInfo, exit, focus, focus_lastfor, focus_next, focus_prev, focus_to, fromUTF8, grid, grid_forget, has_mainwindow?, load_tcllibrary, load_tclscript, load_tclscript_rsrc, load_tclscript_rsrcid, lower_window, pack, pack_forget, pkgconfig_get, pkgconfig_list, place, place_forget, raise_window, regist_sym_for_loaded_file, replace_topalias, replace_topobj, root, set_topalias, show_kinsoku, sleep, strictMotif, subst_tk_backslash, subst_utf_backslash, tcl_pkgconfig_get, tcl_pkgconfig_list, thread_update, thread_update_idletasks, tk_pkgconfig_get, tk_pkgconfig_list, toUTF8, to_backslash_sequence, topalias_defined?, toplevel_aliases_on_widget_set, topobj_defined?, ungrid, unload_tcllibrary, unpack, unplace, update, update, update_idletasks, utf_to_backslash, utf_to_backslash_sequence, wakeup, widget_set_symbols
#default_encoding=, #encoding=, #encoding_convertfrom, #encoding_convertto, #encoding_dirs, #encoding_dirs=, #encoding_name, #encoding_names, #encoding_obj, #encoding_objs, #encoding_system=, #encoding_system_name, #encoding_system_obj, #force_default_encoding, #force_default_encoding=, #force_default_encoding?, #tk_encoding_names
Methods included from TkCore
#_tk_call_to_list_core, #after, #after_cancel, #after_idle, #appname, #appsend, #appsend_deny, #appsend_displayof, callback, #callback_break, #callback_continue, #callback_return, #chooseColor, #chooseDirectory, #do_one_event, #event_generate, #getMultipleOpenFile, #getMultipleSaveFile, #getOpenFile, #getSaveFile, #get_eventloop_tick, #get_eventloop_weight, #get_no_event_wait, #inactive, #inactive_displayof, #info, #ip_eval, #ip_eval_with_enc, #ip_eval_without_enc, #ip_invoke, #ip_invoke_with_enc, #ip_invoke_without_enc, #is_mainloop?, #load_cmd_on_ip, #mainloop, #mainloop_exist?, #mainloop_thread?, #mainloop_watchdog, #messageBox, #rb_appsend, #rb_appsend_displayof, #reset_inactive, #reset_inactive_displayof, #restart, #scaling, #scaling_displayof, #set_eventloop_tick, #set_eventloop_weight, #set_no_event_wait, #tk_call_to_list, #tk_call_to_list_with_enc, #tk_call_to_list_without_enc, #tk_call_to_simplelist, #tk_call_to_simplelist_with_enc, #tk_call_to_simplelist_without_enc, #windowingsystem
Methods included from TkComm
_at, _callback_entry?, _callback_entry_class?, _curr_cmd_id, _fromUTF8, _genobj_for_tkwidget, _next_cmd_id, _toUTF8, array2tk_list, #bind, #bind_all, #bind_append, #bind_append_all, #bind_remove, #bind_remove_all, #bindinfo, #bindinfo_all, bool, image_obj, install_cmd, list, num_or_nil, num_or_str, number, procedure, simplelist, slice_ary, string, #subst, tk_tcl2ruby, uninstall_cmd, #uninstall_cmd, window
Methods included from TkEvent
#install_bind, #install_bind_for_event_class
Methods included from TkUtil
#_conv_args, _conv_args, #_fromUTF8, #_get_eval_enc_str, _get_eval_enc_str, #_get_eval_string, _get_eval_string, _symbolkey2str, #_symbolkey2str, #_toUTF8, #bool, bool, callback, eval_cmd, #hash_kv, hash_kv, install_cmd, #num_or_nil, num_or_nil, num_or_str, #num_or_str, number, #number, string, #string, uninstall_cmd, untrust
Methods inherited from TkObject
#destroy, #epath, #event_generate, #method_missing, #path, #tk_send, #tk_send_to_list, #tk_send_to_list_with_enc, #tk_send_to_list_without_enc, #tk_send_to_simplelist, #tk_send_to_simplelist_with_enc, #tk_send_to_simplelist_without_enc, #tk_send_with_enc, #tk_send_without_enc, #to_eval
Methods included from TkBindCore
#bind, #bind_append, #bind_remove, #bindinfo
#[], #[]=, __IGNORE_UNKNOWN_CONFIGURE_OPTION__, #__check_available_configure_options, __set_IGNORE_UNKNOWN_CONFIGURE_OPTION__!, #cget, #cget_strict, #cget_tkstring, #config_hash_kv, #configinfo, #configure, #configure_cmd, #current_configinfo
#font_configinfo, #font_configure, #font_copy, #kanjifont_configure, #kanjifont_copy, #latinfont_configure, #latinfont_copy
Methods inherited from TkKernel
new
Constructor Details
#initialize(name = nil, parent = nil) ⇒ TkNamespace
Returns a new instance of TkNamespace.
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
|
# File 'lib/tk/namespace.rb', line 246
def initialize(name = nil, parent = nil)
unless name
Tk_Namespace_ID.mutex.synchronize{
name = Tk_Namespace_ID.join(TkCore::INTERP._ip_id_)
Tk_Namespace_ID[1].succ!
}
end
name = __tk_call('namespace', 'current') if name == ''
if parent
if parent =~ /^::/
if name =~ /^::/
@fullname = parent + name
else
@fullname = parent +'::'+ name
end
else
ancestor = __tk_call('namespace', 'current')
ancestor = '' if ancestor == '::'
if name =~ /^::/
@fullname = ancestor + '::' + parent + name
else
@fullname = ancestor + '::'+ parent +'::'+ name
end
end
else ancestor = __tk_call('namespace', 'current')
ancestor = '' if ancestor == '::'
if name =~ /^::/
@fullname = name
else
@fullname = ancestor + '::' + name
end
end
@path = @fullname
@parent = __tk_call('namespace', 'qualifiers', @fullname)
@name = __tk_call('namespace', 'tail', @fullname)
__tk_call('namespace', 'eval', @fullname, '')
Tk_Namespace_ID_TBL.mutex.synchronize{
Tk_Namespace_ID_TBL[@fullname] = self
}
end
|
Dynamic Method Handling
This class handles dynamic methods through the method_missing method
in the class TkObject
Class Method Details
.children(*args) ⇒ Object
292
293
294
295
296
297
298
299
300
301
302
303
304
305
|
# File 'lib/tk/namespace.rb', line 292
def self.children(*args)
tk_split_simplelist(tk_call('namespace', 'children', *args)).collect{|ns|
Tk_Namespace_ID_TBL.mutex.synchronize{
if Tk_Namespace_ID_TBL.key?(ns)
Tk_Namespace_ID_TBL[ns]
else
ns
end
}
}
end
|
.code(script = Proc.new) ⇒ Object
310
311
312
|
# File 'lib/tk/namespace.rb', line 310
def self.code(script = Proc.new)
TkNamespace.new('').code(script)
end
|
.current_path ⇒ Object
354
355
356
|
# File 'lib/tk/namespace.rb', line 354
def self.current_path
tk_call('namespace', 'current')
end
|
.ensemble_configinfo(cmd, slot = nil) ⇒ Object
404
405
406
407
408
409
410
411
412
|
# File 'lib/tk/namespace.rb', line 404
def self.ensemble_configinfo(cmd, slot = nil)
if slot
tk_call('namespace', 'ensemble', 'configure', cmd, '-' + slot.to_s)
else
inf = {}
Hash(*tk_split_simplelist(tk_call('namespace', 'ensemble', 'configure', cmd))).each{|k, v| inf[k[1..-1]] = v}
inf
end
end
|
397
398
399
400
401
402
403
|
# File 'lib/tk/namespace.rb', line 397
def self.ensemble_configure(cmd, slot, value=None)
if slot.kind_of?(Hash)
tk_call('namespace', 'ensemble', 'configure', cmd, *hash_kv(slot))
else
tk_call('namespace', 'ensemble', 'configure', cmd, '-'+slot.to_s, value)
end
end
|
.ensemble_create(*keys) ⇒ Object
394
395
396
|
# File 'lib/tk/namespace.rb', line 394
def self.ensemble_create(*keys)
tk_call('namespace', 'ensemble', 'create', *hash_kv(keys))
end
|
.ensemble_exist?(cmd) ⇒ Boolean
413
414
415
|
# File 'lib/tk/namespace.rb', line 413
def self.ensemble_exist?(cmd)
bool(tk_call('namespace', 'ensemble', 'exists', cmd))
end
|
.eval(namespace, cmd = Proc.new, *args) ⇒ Object
417
418
419
420
|
# File 'lib/tk/namespace.rb', line 417
def self.eval(namespace, cmd = Proc.new, *args)
TkNamespace.new(namespace).eval(cmd, *args)
end
|
.exist?(ns) ⇒ Boolean
439
440
441
|
# File 'lib/tk/namespace.rb', line 439
def self.exist?(ns)
bool(tk_call('namespace', 'exists', ns))
end
|
.export(*patterns) ⇒ Object
446
447
448
|
# File 'lib/tk/namespace.rb', line 446
def self.export(*patterns)
tk_call('namespace', 'export', *patterns)
end
|
.export_with_clear(*patterns) ⇒ Object
449
450
451
|
# File 'lib/tk/namespace.rb', line 449
def self.export_with_clear(*patterns)
tk_call('namespace', 'export', '-clear', *patterns)
end
|
.force_import(*patterns) ⇒ Object
469
470
471
|
# File 'lib/tk/namespace.rb', line 469
def self.force_import(*patterns)
tk_call('namespace', 'import', '-force', *patterns)
end
|
.forget(*patterns) ⇒ Object
459
460
461
|
# File 'lib/tk/namespace.rb', line 459
def self.forget(*patterns)
tk_call('namespace', 'forget', *patterns)
end
|
504
505
506
|
# File 'lib/tk/namespace.rb', line 504
def self.get_path
tk_call('namespace', 'path')
end
|
.get_unknown_handler ⇒ Object
529
530
531
|
# File 'lib/tk/namespace.rb', line 529
def self.get_unknown_handler
tk_tcl2ruby(tk_call('namespace', 'unknown'))
end
|
.import(*patterns) ⇒ Object
466
467
468
|
# File 'lib/tk/namespace.rb', line 466
def self.import(*patterns)
tk_call('namespace', 'import', *patterns)
end
|
.inscope(namespace, script, *args) ⇒ Object
479
480
481
|
# File 'lib/tk/namespace.rb', line 479
def self.inscope(namespace, script, *args)
tk_call('namespace', 'inscope', namespace, script, *args)
end
|
.origin(cmd) ⇒ Object
486
487
488
|
# File 'lib/tk/namespace.rb', line 486
def self.origin(cmd)
tk_call('namespace', 'origin', cmd)
end
|
.parent(namespace = None) ⇒ Object
.qualifiers(str) ⇒ Object
514
515
516
|
# File 'lib/tk/namespace.rb', line 514
def self.qualifiers(str)
tk_call('namespace', 'qualifiers', str)
end
|
.set_path(*namespace_list) ⇒ Object
507
508
509
|
# File 'lib/tk/namespace.rb', line 507
def self.set_path(*namespace_list)
tk_call('namespace', 'path', array2tk_list(namespace_list))
end
|
.set_unknown_handler(cmd = Proc.new) ⇒ Object
532
533
534
|
# File 'lib/tk/namespace.rb', line 532
def self.set_unknown_handler(cmd = Proc.new)
tk_call('namespace', 'unknown', cmd)
end
|
.tail(str) ⇒ Object
518
519
520
|
# File 'lib/tk/namespace.rb', line 518
def self.tail(str)
tk_call('namespace', 'tail', str)
end
|
.upvar(namespace, *var_pairs) ⇒ Object
522
523
524
|
# File 'lib/tk/namespace.rb', line 522
def self.upvar(namespace, *var_pairs)
tk_call('namespace', 'upvar', namespace, *(var_pairs.flatten))
end
|
.which(name) ⇒ Object
536
537
538
|
# File 'lib/tk/namespace.rb', line 536
def self.which(name)
tk_call('namespace', 'which', name)
end
|
.which_command(name) ⇒ Object
539
540
541
|
# File 'lib/tk/namespace.rb', line 539
def self.which_command(name)
tk_call('namespace', 'which', '-command', name)
end
|
.which_variable(name) ⇒ Object
542
543
544
|
# File 'lib/tk/namespace.rb', line 542
def self.which_variable(name)
tk_call('namespace', 'which', '-variable', name)
end
|
Instance Method Details
#__tk_call ⇒ Object
221
|
# File 'lib/tk/namespace.rb', line 221
alias __tk_call tk_call
|
#__tk_call_with_enc ⇒ Object
223
|
# File 'lib/tk/namespace.rb', line 223
alias __tk_call_with_enc tk_call_with_enc
|
#__tk_call_without_enc ⇒ Object
222
|
# File 'lib/tk/namespace.rb', line 222
alias __tk_call_without_enc tk_call_without_enc
|
#children(pattern = None) ⇒ Object
306
307
308
|
# File 'lib/tk/namespace.rb', line 306
def children(pattern=None)
TkNamespace.children(@fullname, pattern)
end
|
#code(script = Proc.new) ⇒ Object
def code(script = Proc.new)
if script.kind_of?(String)
cmd = proc{|*args| ScopeArgs.new(@fullname,*args).instance_eval(script)}
elsif script.kind_of?(Proc)
cmd = proc{|*args| ScopeArgs.new(@fullname,*args).instance_eval(&script)}
else
fail ArgumentError, "String or Proc is expected"
end
TkNamespace::NsCode.new(tk_call_without_enc('namespace', 'code',
_get_eval_string(cmd, false)))
end
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
|
# File 'lib/tk/namespace.rb', line 326
def code(script = Proc.new)
if script.kind_of?(String)
cmd = proc{|*args|
ret = ScopeArgs.new(@fullname,*args).instance_eval(script)
id = ret.object_id
TkNamespace::Tk_NsCode_RetObjID_TBL[id] = ret
id
}
elsif script.kind_of?(Proc)
cmd = proc{|*args|
if TkCore::WITH_RUBY_VM obj = ScopeArgs.new(@fullname,*args)
ret = obj.instance_exec(obj, &script)
else
ret = ScopeArgs.new(@fullname,*args).instance_eval(&script)
end
id = ret.object_id
TkNamespace::Tk_NsCode_RetObjID_TBL[id] = ret
id
}
else
fail ArgumentError, "String or Proc is expected"
end
TkNamespace::NsCode.new(tk_call_without_enc('namespace', 'code',
_get_eval_string(cmd, false)),
true)
end
|
#current_namespace ⇒ Object
Also known as:
current
371
372
373
374
375
|
# File 'lib/tk/namespace.rb', line 371
def current_namespace
self
end
|
#current_path ⇒ Object
357
358
359
|
# File 'lib/tk/namespace.rb', line 357
def current_path
@fullname
end
|
390
391
392
|
# File 'lib/tk/namespace.rb', line 390
def delete
TkNamespece.delete(@fullname)
end
|
#eval(cmd = Proc.new, *args) ⇒ Object
def eval(cmd = Proc.new, *args)
#TkNamespace.eval(@fullname, cmd, *args)
#ns_tk_call(cmd, *args)
code_obj = code(cmd)
ret = code_obj.call(*args)
# uninstall_cmd(TkCore::INTERP._split_tklist(code_obj.path)[-1])
uninstall_cmd(_fromUTF8(TkCore::INTERP._split_tklist(_toUTF8(code_obj.path))[-1]))
tk_tcl2ruby(ret)
end
432
433
434
435
436
437
|
# File 'lib/tk/namespace.rb', line 432
def eval(cmd = Proc.new, *args)
code_obj = code(cmd)
ret = code_obj.call(*args)
uninstall_cmd(_fromUTF8(TkCore::INTERP._split_tklist(_toUTF8(code_obj.path))[-1]))
ret
end
|
#exist? ⇒ Boolean
442
443
444
|
# File 'lib/tk/namespace.rb', line 442
def exist?
TkNamespece.exist?(@fullname)
end
|
452
453
454
|
# File 'lib/tk/namespace.rb', line 452
def export
TkNamespace.export(@fullname)
end
|
462
463
464
|
# File 'lib/tk/namespace.rb', line 462
def forget
TkNamespace.forget(@fullname)
end
|
472
473
474
|
# File 'lib/tk/namespace.rb', line 472
def import
TkNamespace.import(@fullname)
end
|
#inscope(script, *args) ⇒ Object
482
483
484
|
# File 'lib/tk/namespace.rb', line 482
def inscope(script, *args)
TkNamespace.inscope(@fullname, script, *args)
end
|
#install_cmd(cmd) ⇒ Object
211
212
213
214
215
216
217
218
219
|
# File 'lib/tk/namespace.rb', line 211
def install_cmd(cmd)
lst = tk_split_simplelist(super(cmd), false, false)
if lst[1] =~ /^::/
lst[1] = @fullname
else
lst.insert(1, @fullname)
end
TkCore::INTERP._merge_tklist(*lst)
end
|
500
501
502
|
# File 'lib/tk/namespace.rb', line 500
def parent
tk_call('namespace', 'parent', @fullname)
end
|
510
511
512
|
# File 'lib/tk/namespace.rb', line 510
def set_path
tk_call('namespace', 'path', @fullname)
end
|
#tk_call(*args) ⇒ Object
Also known as:
ns_tk_call
224
225
226
227
228
229
|
# File 'lib/tk/namespace.rb', line 224
def tk_call(*args)
args = args.collect{|arg| (s = _get_eval_string(arg, true))? s: ''}
super('namespace', 'eval', @fullname,
TkCore::INTERP._merge_tklist(*args))
end
|
#tk_call_with_enc(*args) ⇒ Object
Also known as:
ns_tk_call_with_enc
236
237
238
239
240
241
|
# File 'lib/tk/namespace.rb', line 236
def tk_call_with_enc(*args)
args = args.collect{|arg| (s = _get_eval_string(arg, true))? s: ''}
super('namespace', 'eval', @fullname,
TkCore::INTERP._merge_tklist(*args))
end
|
#tk_call_without_enc(*args) ⇒ Object
Also known as:
ns_tk_call_without_enc
230
231
232
233
234
235
|
# File 'lib/tk/namespace.rb', line 230
def tk_call_without_enc(*args)
args = args.collect{|arg| (s = _get_eval_string(arg, true))? s: ''}
super('namespace', 'eval', @fullname,
TkCore::INTERP._merge_tklist(*args))
end
|
#upvar(*var_pairs) ⇒ Object
525
526
527
|
# File 'lib/tk/namespace.rb', line 525
def upvar(*var_pairs)
TkNamespace.inscope(@fullname, *(var_pairs.flatten))
end
|