Module: TclTkLib
- Defined in:
- ext/tk/tcltklib.c,
lib/tk.rb
Defined Under Namespace
Modules: EventFlag, RELEASE_TYPE, VarAccessFlag
Constant Summary collapse
- COMPILE_INFO =
tcltklib_compile_info()
- RELEASE_DATE =
rb_obj_freeze(rb_str_new2(tcltklib_release_date))
- FINALIZE_PROC_NAME =
rb_str_new2(finalize_hook_name)
- WINDOWING_SYSTEM =
rb_obj_freeze(rb_str_new2(TK_WINDOWING_SYSTEM))
Class Method Summary collapse
- ._encoding= ⇒ Object
- ._fromUTF8(*args) ⇒ Object
-
._split_tklist(list_str) ⇒ Object
—————————————————————.
- ._subst_Tcl_backslash(str) ⇒ Object
- ._subst_UTF_backslash(str) ⇒ Object
- ._toUTF8(*args) ⇒ Object
- .default_encoding=(name) ⇒ Object
- .do_thread_callback(*args) ⇒ Object
- .encoding=(name) ⇒ Object
- .encoding_name ⇒ Object (also: encoding, default_encoding)
- .encoding_obj ⇒ Object
- .encoding_system ⇒ Object
- .encoding_system=(enc_name) ⇒ Object
- .force_default_encoding=(mode) ⇒ Object
- .force_default_encoding? ⇒ Boolean
- .get_eventloop_window_mode ⇒ Object
- .get_release_type_name ⇒ Object
-
.get_version ⇒ Object
—————————————————————.
-
.mainloop_abort_on_exception ⇒ Object
not eventloop.
- .mainloop_abort_on_exception=(val) ⇒ Object
- .mainloop_thread? ⇒ Boolean
- .num_of_mainwindows ⇒ Object
- .set_eventloop_window_mode(mode) ⇒ Object
- .set_max_block_time(time) ⇒ Object
Class Method Details
._encoding= ⇒ Object
3013 3014 3015 3016 3017 3018 3019 3020 3021 3022 3023 3024 3025 3026 3027 3028 3029 3030 3031 3032 3033 3034 3035 |
# File 'lib/tk.rb', line 3013 static VALUE lib_set_system_encoding(VALUE self, VALUE enc_name) { #if TCL_MAJOR_VERSION > 8 || (TCL_MAJOR_VERSION == 8 && TCL_MINOR_VERSION > 0) tcl_stubs_check(); if (NIL_P(enc_name)) { Tcl_SetSystemEncoding((Tcl_Interp *)NULL, (CONST char *)NULL); return lib_get_system_encoding(self); } enc_name = rb_funcallv(enc_name, ID_to_s, 0, 0); if (Tcl_SetSystemEncoding((Tcl_Interp *)NULL, StringValueCStr(enc_name)) != TCL_OK) { rb_raise(rb_eArgError, "unknown encoding name '%s'", RSTRING_PTR(enc_name)); } return enc_name; #else return Qnil; #endif } |
._fromUTF8(*args) ⇒ Object
7901 7902 7903 7904 7905 7906 7907 7908 7909 7910 |
# File 'ext/tk/tcltklib.c', line 7901 static VALUE lib_fromUTF8(int argc, VALUE *argv, VALUE self) { VALUE str, encodename; if (rb_scan_args(argc, argv, "11", &str, &encodename) == 1) { encodename = Qnil; } return lib_fromUTF8_core(Qnil, str, encodename); } |
._split_tklist(list_str) ⇒ Object
9322 9323 9324 9325 9326 |
# File 'ext/tk/tcltklib.c', line 9322 static VALUE lib_split_tklist(VALUE self, VALUE list_str) { return lib_split_tklist_core(Qnil, list_str); } |
._subst_Tcl_backslash(str) ⇒ Object
8004 8005 8006 8007 8008 |
# File 'ext/tk/tcltklib.c', line 8004 static VALUE lib_Tcl_backslash(VALUE self, VALUE str) { return lib_UTF_backslash_core(self, str, 1); } |
._subst_UTF_backslash(str) ⇒ Object
7998 7999 8000 8001 8002 |
# File 'ext/tk/tcltklib.c', line 7998 static VALUE lib_UTF_backslash(VALUE self, VALUE str) { return lib_UTF_backslash_core(self, str, 0); } |
._toUTF8(*args) ⇒ Object
7710 7711 7712 7713 7714 7715 7716 7717 7718 7719 |
# File 'ext/tk/tcltklib.c', line 7710 static VALUE lib_toUTF8(int argc, VALUE *argv, VALUE self) { VALUE str, encodename; if (rb_scan_args(argc, argv, "11", &str, &encodename) == 1) { encodename = Qnil; } return lib_toUTF8_core(Qnil, str, encodename); } |
.default_encoding=(name) ⇒ Object
3008 3009 3010 |
# File 'lib/tk.rb', line 3008 def default_encoding=(name) TkCore::INTERP.default_encoding = name end |
.do_thread_callback(*args) ⇒ Object
2881 2882 2883 2884 2885 2886 2887 2888 2889 2890 2891 2892 2893 2894 2895 2896 2897 2898 2899 2900 2901 2902 2903 2904 2905 2906 2907 2908 2909 2910 2911 2912 2913 2914 2915 2916 2917 2918 2919 2920 2921 2922 2923 2924 2925 2926 2927 2928 2929 2930 2931 2932 2933 |
# File 'ext/tk/tcltklib.c', line 2881 static VALUE lib_thread_callback(int argc, VALUE *argv, VALUE self) { struct thread_call_proc_arg *q; VALUE proc, th, ret; int status; if (rb_scan_args(argc, argv, "01", &proc) == 0) { proc = rb_block_proc(); } q = (struct thread_call_proc_arg *)ALLOC(struct thread_call_proc_arg); /* q = RbTk_ALLOC_N(struct thread_call_proc_arg, 1); */ q->proc = proc; q->done = (int*)ALLOC(int); /* q->done = RbTk_ALLOC_N(int, 1); */ *(q->done) = 0; /* create call-proc thread */ th = rb_thread_create(_thread_call_proc, (void*)q); rb_thread_schedule(); /* start sub-eventloop */ lib_eventloop_launcher(/* not check root-widget */0, 0, q->done, (Tcl_Interp*)NULL); if (RTEST(rb_thread_alive_p(th))) { rb_funcall(th, ID_kill, 0); ret = Qnil; } else { ret = rb_protect(_thread_call_proc_value, th, &status); } xfree(q->done); xfree(q); /* ckfree((char*)q->done); */ /* ckfree((char*)q); */ if (NIL_P(rbtk_pending_exception)) { /* return rb_errinfo(); */ if (status) { rb_exc_raise(rb_errinfo()); } } else { VALUE exc = rbtk_pending_exception; rbtk_pending_exception = Qnil; /* return exc; */ rb_exc_raise(exc); } return ret; } |
.encoding=(name) ⇒ Object
8021 8022 8023 8024 8025 8026 8027 8028 8029 8030 8031 8032 8033 8034 8035 8036 8037 8038 8039 8040 8041 8042 8043 |
# File 'ext/tk/tcltklib.c', line 8021 static VALUE lib_set_system_encoding(VALUE self, VALUE enc_name) { #if TCL_MAJOR_VERSION > 8 || (TCL_MAJOR_VERSION == 8 && TCL_MINOR_VERSION > 0) tcl_stubs_check(); if (NIL_P(enc_name)) { Tcl_SetSystemEncoding((Tcl_Interp *)NULL, (CONST char *)NULL); return lib_get_system_encoding(self); } enc_name = rb_funcallv(enc_name, ID_to_s, 0, 0); if (Tcl_SetSystemEncoding((Tcl_Interp *)NULL, StringValueCStr(enc_name)) != TCL_OK) { rb_raise(rb_eArgError, "unknown encoding name '%s'", RSTRING_PTR(enc_name)); } return enc_name; #else return Qnil; #endif } |
.encoding_name ⇒ Object Also known as: encoding, default_encoding
3019 3020 3021 |
# File 'lib/tk.rb', line 3019 def encoding_name TkCore::INTERP.encoding end |
.encoding_obj ⇒ Object
3025 3026 3027 3028 3029 3030 3031 |
# File 'lib/tk.rb', line 3025 def encoding_obj if Tk::WITH_ENCODING Tk::Encoding.tcl2rb_encoding(TkCore::INTERP.encoding) else TkCore::INTERP.encoding end end |
.encoding_system ⇒ Object
8010 8011 8012 8013 8014 8015 8016 8017 8018 8019 |
# File 'ext/tk/tcltklib.c', line 8010 static VALUE lib_get_system_encoding(VALUE self) { #if TCL_MAJOR_VERSION > 8 || (TCL_MAJOR_VERSION == 8 && TCL_MINOR_VERSION > 0) tcl_stubs_check(); return rb_str_new2(Tcl_GetEncodingName((Tcl_Encoding)NULL)); #else return Qnil; #endif } |
.encoding_system=(enc_name) ⇒ Object
8021 8022 8023 8024 8025 8026 8027 8028 8029 8030 8031 8032 8033 8034 8035 8036 8037 8038 8039 8040 8041 8042 8043 |
# File 'ext/tk/tcltklib.c', line 8021 static VALUE lib_set_system_encoding(VALUE self, VALUE enc_name) { #if TCL_MAJOR_VERSION > 8 || (TCL_MAJOR_VERSION == 8 && TCL_MINOR_VERSION > 0) tcl_stubs_check(); if (NIL_P(enc_name)) { Tcl_SetSystemEncoding((Tcl_Interp *)NULL, (CONST char *)NULL); return lib_get_system_encoding(self); } enc_name = rb_funcallv(enc_name, ID_to_s, 0, 0); if (Tcl_SetSystemEncoding((Tcl_Interp *)NULL, StringValueCStr(enc_name)) != TCL_OK) { rb_raise(rb_eArgError, "unknown encoding name '%s'", RSTRING_PTR(enc_name)); } return enc_name; #else return Qnil; #endif } |
.force_default_encoding=(mode) ⇒ Object
3000 3001 3002 |
# File 'lib/tk.rb', line 3000 def force_default_encoding=(mode) TkCore::INTERP.force_default_encoding = mode end |
.force_default_encoding? ⇒ Boolean
3004 3005 3006 |
# File 'lib/tk.rb', line 3004 def force_default_encoding? TkCore::INTERP.force_default_encoding? end |
.get_eventloop_window_mode ⇒ Object
1694 1695 1696 1697 1698 1699 1700 1701 1702 |
# File 'ext/tk/tcltklib.c', line 1694 static VALUE get_eventloop_window_mode(VALUE self) { if ( ~window_event_mode ) { return Qfalse; } else { return Qtrue; } } |
.get_release_type_name ⇒ Object
9473 9474 9475 9476 9477 9478 9479 9480 9481 9482 9483 9484 9485 9486 9487 9488 9489 9490 |
# File 'ext/tk/tcltklib.c', line 9473 static VALUE lib_get_reltype_name(VALUE self) { set_tcltk_version(); switch(tcltk_version.type) { case TCL_ALPHA_RELEASE: return rb_str_new2("alpha"); case TCL_BETA_RELEASE: return rb_str_new2("beta"); case TCL_FINAL_RELEASE: return rb_str_new2("final"); default: rb_raise(rb_eRuntimeError, "tcltklib has invalid release type number"); } UNREACHABLE; } |
.get_version ⇒ Object
9462 9463 9464 9465 9466 9467 9468 9469 9470 9471 |
# File 'ext/tk/tcltklib.c', line 9462 static VALUE lib_getversion(VALUE self) { set_tcltk_version(); return rb_ary_new3(4, INT2NUM(tcltk_version.major), INT2NUM(tcltk_version.minor), INT2NUM(tcltk_version.type), INT2NUM(tcltk_version.patchlevel)); } |
.mainloop_abort_on_exception ⇒ Object
not eventloop
1899 1900 1901 1902 1903 1904 1905 1906 1907 1908 1909 |
# File 'ext/tk/tcltklib.c', line 1899 static VALUE lib_evloop_abort_on_exc(VALUE self) { if (event_loop_abort_on_exc > 0) { return Qtrue; } else if (event_loop_abort_on_exc == 0) { return Qfalse; } else { return Qnil; } } |
.mainloop_abort_on_exception=(val) ⇒ Object
1917 1918 1919 1920 1921 1922 1923 1924 1925 1926 1927 1928 |
# File 'ext/tk/tcltklib.c', line 1917 static VALUE lib_evloop_abort_on_exc_set(VALUE self, VALUE val) { if (RTEST(val)) { event_loop_abort_on_exc = 1; } else if (NIL_P(val)) { event_loop_abort_on_exc = -1; } else { event_loop_abort_on_exc = 0; } return lib_evloop_abort_on_exc(self); } |
.mainloop_thread? ⇒ Boolean
1887 1888 1889 1890 1891 1892 1893 1894 1895 1896 1897 |
# File 'ext/tk/tcltklib.c', line 1887 static VALUE lib_evloop_thread_p(VALUE self) { if (NIL_P(eventloop_thread)) { return Qnil; /* no eventloop */ } else if (rb_thread_current() == eventloop_thread) { return Qtrue; /* is eventloop */ } else { return Qfalse; /* not eventloop */ } } |
.num_of_mainwindows ⇒ Object
1958 1959 1960 1961 1962 1963 1964 1965 1966 |
# File 'ext/tk/tcltklib.c', line 1958 static VALUE lib_num_of_mainwindows(VALUE self) { #ifdef RUBY_USE_NATIVE_THREAD /* Ruby 1.9+ !!! */ return tk_funcall(lib_num_of_mainwindows_core, 0, (VALUE*)NULL, self); #else return lib_num_of_mainwindows_core(self, 0, (VALUE*)NULL); #endif } |
.set_eventloop_window_mode(mode) ⇒ Object
1681 1682 1683 1684 1685 1686 1687 1688 1689 1690 1691 1692 |
# File 'ext/tk/tcltklib.c', line 1681 static VALUE set_eventloop_window_mode(VALUE self, VALUE mode) { if (RTEST(mode)) { window_event_mode = ~0; } else { window_event_mode = ~TCL_WINDOW_EVENTS; } return mode; } |
.set_max_block_time(time) ⇒ Object
1856 1857 1858 1859 1860 1861 1862 1863 1864 1865 1866 1867 1868 1869 1870 1871 1872 1873 1874 1875 1876 1877 1878 1879 1880 1881 1882 1883 1884 1885 |
# File 'ext/tk/tcltklib.c', line 1856 static VALUE set_max_block_time(VALUE self, VALUE time) { struct Tcl_Time tcl_time; VALUE divmod; switch(TYPE(time)) { case T_FIXNUM: case T_BIGNUM: /* time is micro-second value */ divmod = rb_funcall(time, rb_intern("divmod"), 1, LONG2NUM(1000000)); tcl_time.sec = NUM2LONG(RARRAY_AREF(divmod, 0)); tcl_time.usec = NUM2LONG(RARRAY_AREF(divmod, 1)); break; case T_FLOAT: /* time is second value */ divmod = rb_funcall(time, rb_intern("divmod"), 1, INT2FIX(1)); tcl_time.sec = NUM2LONG(RARRAY_AREF(divmod, 0)); tcl_time.usec = (long)(NUM2DBL(RARRAY_AREF(divmod, 1)) * 1000000); break; default: rb_raise(rb_eArgError, "invalid value for time: '%+"PRIsVALUE"'", time); } Tcl_SetMaxBlockTime(&tcl_time); return Qnil; } |