From 463ae624419921d0548508b7028fe1896bd676af Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bogumi=C5=82=20Kami=C5=84ski?= Date: Fri, 20 Oct 2017 20:41:19 +0200 Subject: [PATCH 01/14] fix print_escaped and takebuf_string `print_escaped` fails on 0.6 and `takebuf_string` is deprecated. I am not sure how much backward compatibility should be ensured in the code but without the first change `Tk.jl` will not load on 0.6. --- src/tkwidget.jl | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/src/tkwidget.jl b/src/tkwidget.jl index dd33c5e..48b6b65 100644 --- a/src/tkwidget.jl +++ b/src/tkwidget.jl @@ -46,13 +46,13 @@ function init() tcldir = dirname(String(tclfile[1:len])) libpath = IOBuffer() print(libpath,"set env(TCL_LIBRARY) [subst -nocommands -novariables {") - print_escaped(libpath,abspath(tcldir,"..","share","tcl"),"{}") + escape_string(libpath,abspath(tcldir,"..","share","tcl"),"{}") print(libpath,"}]") - tcl_eval(takebuf_string(libpath),tclinterp) + tcl_eval(String(take!(libpath)),tclinterp) print(libpath,"set env(TK_LIBRARY) [subst -nocommands -novariables {") - print_escaped(libpath,abspath(tcldir,"..","share","tk"),"{}") + escape_string(libpath,abspath(tcldir,"..","share","tk"),"{}") print(libpath,"}]") - tcl_eval(takebuf_string(libpath),tclinterp) + tcl_eval(String(take!(libpath)),tclinterp) end end if ccall((:Tcl_Init,libtcl), Int32, (Ptr{Void},), tclinterp) == TCL_ERROR @@ -194,7 +194,8 @@ type MouseHandler default_mouse_cb, default_mouse_cb) end -# TkCanvas is the plain Tk canvas widget. This one is double-buffered +# TkCanvas is the plain Tk canvas widget. This one is double- +ed # and built on Cairo. type Canvas c::TkWidget From 93102bf5a12ab37f08efb1ba18ec0b768ca3a30c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bogumi=C5=82=20Kami=C5=84ski?= Date: Sat, 21 Oct 2017 16:17:06 +0200 Subject: [PATCH 02/14] fix typo --- src/tkwidget.jl | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/src/tkwidget.jl b/src/tkwidget.jl index 48b6b65..88222fb 100644 --- a/src/tkwidget.jl +++ b/src/tkwidget.jl @@ -194,8 +194,7 @@ type MouseHandler default_mouse_cb, default_mouse_cb) end -# TkCanvas is the plain Tk canvas widget. This one is double- -ed +# TkCanvas is the plain Tk canvas widget. This one is double-buffered # and built on Cairo. type Canvas c::TkWidget From 2221480a0ed5aeffc2f39c945a0b398d61bca97d Mon Sep 17 00:00:00 2001 From: Alex Arslan Date: Tue, 3 Apr 2018 22:56:08 -0700 Subject: [PATCH 03/14] Drop 0.5 support, fix some 0.7 deprecations --- .travis.yml | 2 +- REQUIRE | 4 +- deps/build.jl | 21 +++--- examples/manipulate.jl | 22 +++--- examples/sketch.jl | 6 +- examples/test.jl | 6 +- examples/workspace.jl | 6 +- src/Tk.jl | 11 +-- src/containers.jl | 14 ++-- src/core.jl | 28 +++----- src/dialogs.jl | 2 +- src/menu.jl | 4 +- src/tkwidget.jl | 159 +++++++++++++++++++++-------------------- src/types.jl | 18 ++--- test/runtests.jl | 3 +- 15 files changed, 149 insertions(+), 157 deletions(-) diff --git a/.travis.yml b/.travis.yml index 20d27ab..60d9c19 100644 --- a/.travis.yml +++ b/.travis.yml @@ -3,7 +3,7 @@ os: - linux - osx julia: - - 0.5 + - 0.6 - nightly notifications: email: false diff --git a/REQUIRE b/REQUIRE index 13eee6a..721e80b 100644 --- a/REQUIRE +++ b/REQUIRE @@ -1,5 +1,5 @@ -julia 0.5 -Compat 0.17.0 +julia 0.6 +Compat 0.48.0 Cairo Graphics 0.1 BinDeps 0.2.2- diff --git a/deps/build.jl b/deps/build.jl index 9ed09a2..c6547b6 100644 --- a/deps/build.jl +++ b/deps/build.jl @@ -1,15 +1,16 @@ using BinDeps -using Compat; import Compat.String +using Compat +using Compat.Libdl @BinDeps.setup tcl = library_dependency("tcl",aliases=["libtcl8.6","tcl86g","tcl86t","libtcl","libtcl8.6.so.0","libtcl8.5","libtcl8.5.so.0","tcl85"]) tk = library_dependency("tk",aliases=["libtk8.6","libtk","libtk8.6.so.0","libtk8.5","libtk8.5.so.0","tk85","tk86","tk86t"], depends=[tcl], validate = function(p,h) - is_apple() && (return @compat Libdl.dlsym_e(h,:TkMacOSXGetRootControl) != C_NULL) + Compat.Sys.isapple() && (return Libdl.dlsym_e(h,:TkMacOSXGetRootControl) != C_NULL) return true end) -if is_windows() +if Compat.Sys.iswindows() using WinRPM provides(WinRPM.RPM,"tk",tk,os = :Windows) provides(WinRPM.RPM,"tcl",tcl,os = :Windows) @@ -21,12 +22,12 @@ provides(AptGet,"tk8.5",tk) provides(Sources,URI("http://prdownloads.sourceforge.net/tcl/tcl8.6.0-src.tar.gz"),tcl,unpacked_dir = "tcl8.6.0") provides(Sources,URI("http://prdownloads.sourceforge.net/tcl/tk8.6.0-src.tar.gz"),tk,unpacked_dir = "tk8.6.0") -is64bit = @compat Sys.WORD_SIZE == 64 +is64bit = Sys.WORD_SIZE == 64 -provides(BuildProcess,Autotools(configure_subdir = "unix", configure_options = [is64bit?"--enable-64bit":"--disable-64bit"]),tcl, os = :Unix) -provides(BuildProcess,Autotools(configure_subdir = "unix", configure_options = [is64bit?"--enable-64bit":"--disable-64bit"]),tk, os = :Unix) +provides(BuildProcess,Autotools(configure_subdir = "unix", configure_options = [is64bit ? "--enable-64bit" : "--disable-64bit"]),tcl, os = :Unix) +provides(BuildProcess,Autotools(configure_subdir = "unix", configure_options = [is64bit ? "--enable-64bit" : "--disable-64bit"]),tk, os = :Unix) -if @compat Sys.WORD_SIZE == 64 +if Sys.WORD_SIZE == 64 # Unfortunately the mingw-built tc segfaults since some function signatures # are different between VC and mingw. This is fixed on tcl trunk. For now, # just use VC to build tcl (Note requlres Visual Studio Express in the PATH) @@ -48,8 +49,8 @@ if @compat Sys.WORD_SIZE == 64 end end),tk) else - provides(BuildProcess,Autotools(libtarget = "tcl86.dll", configure_subdir = "win", configure_options = [is64bit?"--enable-64bit":"--disable-64bit","--enable-threads"]),tcl, os = :Windows) - provides(BuildProcess,Autotools(libtarget = "tk86.dll", configure_subdir = "win", configure_options = [is64bit?"--enable-64bit":"--disable-64bit"]),tk, os = :Windows) + provides(BuildProcess,Autotools(libtarget = "tcl86.dll", configure_subdir = "win", configure_options = [is64bit ? "--enable-64bit" : "--disable-64bit","--enable-threads"]),tcl, os = :Windows) + provides(BuildProcess,Autotools(libtarget = "tk86.dll", configure_subdir = "win", configure_options = [is64bit ? "--enable-64bit" : "--disable-64bit"]),tk, os = :Windows) end -@BinDeps.install @compat(Dict(:tk => :libtk, :tcl=>:libtcl)) +@BinDeps.install Dict(:tk => :libtk, :tcl=>:libtcl) diff --git a/examples/manipulate.jl b/examples/manipulate.jl index 4ee05fb..e7b0819 100644 --- a/examples/manipulate.jl +++ b/examples/manipulate.jl @@ -25,10 +25,10 @@ using Winston end -@compat abstract type ManipulateWidget end +abstract type ManipulateWidget end get_label(widget::ManipulateWidget) = widget.label -type SliderWidget <: ManipulateWidget +mutable struct SliderWidget <: ManipulateWidget nm label initial @@ -44,7 +44,7 @@ slider(nm::AbstractString, label::AbstractString, rng::UnitRange, initial::Integ slider(nm::AbstractString, label::AbstractString, rng::UnitRange) = slider(nm, label, rng, minimum(rng)) slider(nm::AbstractString, rng::UnitRange) = slider(nm, nm, rng, minimum(rng)) -type PickerWidget <: ManipulateWidget +mutable struct PickerWidget <: ManipulateWidget nm label initial @@ -60,14 +60,14 @@ function make_widget(parent, widget::PickerWidget) end -picker{T <: AbstractString}(nm::AbstractString, label::AbstractString, vals::Vector{T}, initial) = PickerWidget(nm, label, initial, vals) -picker{T <: AbstractString}(nm::AbstractString, label::AbstractString, vals::Vector{T}) = picker(nm, label, vals, vals[1]) -picker{T <: AbstractString}(nm::AbstractString, vals::Vector{T}) = picker(nm, nm, vals) +picker(nm::AbstractString, label::AbstractString, vals::Vector{T}, initial) where {T <: AbstractString} = PickerWidget(nm, label, initial, vals) +picker(nm::AbstractString, label::AbstractString, vals::Vector{T}) where {T <: AbstractString} = picker(nm, label, vals, vals[1]) +picker(nm::AbstractString, vals::Vector{T}) where {T <: AbstractString} = picker(nm, nm, vals) picker(nm::AbstractString, label::AbstractString, vals::Dict, initial) = PickerWidget(nm, label, vals, initial) picker(nm::AbstractString, label::AbstractString, vals::Dict) = PickerWidget(nm, label, vals, [string(k) for (k,v) in vals][1]) picker(nm::AbstractString, vals::Dict) = picker(nm, nm, vals) -type CheckboxWidget <: ManipulateWidget +mutable struct CheckboxWidget <: ManipulateWidget nm label initial @@ -83,7 +83,7 @@ checkbox(nm::AbstractString, label::AbstractString, initial::Bool) = CheckboxWid checkbox(nm::AbstractString, label::AbstractString) = checkbox(nm, label, false) -type ButtonWidget <: ManipulateWidget +mutable struct ButtonWidget <: ManipulateWidget label nm end @@ -93,7 +93,7 @@ button(label::AbstractString) = ButtonWidget(label, nothing) ## Add text widget to gather one-line of text -type EntryWidget <: ManipulateWidget +mutable struct EntryWidget <: ManipulateWidget nm label initial @@ -105,7 +105,7 @@ entry(nm::AbstractString) = EntryWidget(nm, nm, "{}") ## Expression returns a plot object. Use names as values -function manipulate(ex::(@compat Union{Symbol,Expr}), controls...) +function manipulate(ex::(Union{Symbol,Expr}), controls...) widgets = Array(Tk.Widget, 0) w = Toplevel("Manipulate", 800, 500) @@ -127,7 +127,7 @@ function manipulate(ex::(@compat Union{Symbol,Expr}), controls...) d = Dict() # return Dict of values vals = get_values(); keys = get_nms() for i in 1:length(vals) - if !isa(keys[i], @compat Void) + if !isa(keys[i], Nothing) d[keys[i]] = vals[i] end end diff --git a/examples/sketch.jl b/examples/sketch.jl index 5a2f68f..18c3c6f 100644 --- a/examples/sketch.jl +++ b/examples/sketch.jl @@ -1,9 +1,5 @@ using Tk -if VERSION < v"0.4.0-dev+3275" - using Base.Graphics -else - using Graphics -end +using Graphics function sketch_window() w = Window("drawing", 400, 300) diff --git a/examples/test.jl b/examples/test.jl index 9405dd5..87ecd51 100644 --- a/examples/test.jl +++ b/examples/test.jl @@ -6,7 +6,7 @@ using Compat; import Compat.String w = Toplevel("Test window", false) ## pack in tk frame for themed widgets f = Frame(w) -configure(f, @compat Dict(:padding => [3,3,2,2], :relief=>"groove")) +configure(f, Dict(:padding => [3,3,2,2], :relief=>"groove")) pack(f, expand=true, fill="both") ## widgets @@ -26,11 +26,11 @@ pack_style = ["pack", "grid", "formlayout"][3] if pack_style == "pack" map(pack, widgets) - map(u -> pack_configure(u, @compat Dict(:anchor => "w")), widgets) + map(u -> pack_configure(u, Dict(:anchor => "w")), widgets) elseif pack_style == "grid" for i in 1:length(widgets) grid(widgets[i], i, 1) - grid_configure(widgets[i], @compat Dict(:sticky => "we")) + grid_configure(widgets[i], Dict(:sticky => "we")) end else map(u -> formlayout(u, "label"), widgets) diff --git a/examples/workspace.jl b/examples/workspace.jl index e7bd4e7..88a8caa 100644 --- a/examples/workspace.jl +++ b/examples/workspace.jl @@ -7,7 +7,7 @@ function get_names(m::Module) end unique_id(v::Symbol, m::Module) = isdefined(m,v) ? unique_id(eval(m,v)) : "" -unique_id(x) = string(object_id(x)) +unique_id(x) = string(objectid(x)) ## short_summary ## can customize description here @@ -31,8 +31,8 @@ end negate(x::Bool, val::Bool) = val ? !x : x -const MaybeRegex = Union{Void, Regex} -const MaybeType = Union{Void, DataType} +const MaybeRegex = Union{Nothing, Regex} +const MaybeType = Union{Nothing, DataType} ## get array of names and summaries ## m module diff --git a/src/Tk.jl b/src/Tk.jl index 0ad64d8..2164f24 100644 --- a/src/Tk.jl +++ b/src/Tk.jl @@ -1,4 +1,4 @@ -VERSION >= v"0.4.0-dev+6521" && __precompile__(false) +__precompile__(false) # julia tk interface # TODO: @@ -14,9 +14,8 @@ VERSION >= v"0.4.0-dev+6521" && __precompile__(false) module Tk -using Base using Cairo -using Compat; import Compat.String +using Compat if isfile(joinpath(dirname(@__FILE__),"..","deps","deps.jl")) include("../deps/deps.jl") @@ -26,11 +25,7 @@ end import Base: ==, bind, getindex, isequal, parent, setindex!, show, string, Text -if VERSION < v"0.4.0-dev+3275" - import Base.Graphics: width, height, getgc -else - import Graphics: width, height, getgc -end +import Graphics: width, height, getgc import Cairo: destroy diff --git a/src/containers.jl b/src/containers.jl index 007f2b1..d1abc1b 100644 --- a/src/containers.jl +++ b/src/containers.jl @@ -1,9 +1,9 @@ ## Types -type Tk_Toplevel <: TTk_Container w::TkWidget; children::Vector{Tk_Widget} end -type Tk_Frame <: TTk_Container w::TkWidget; children::Vector{Tk_Widget} end -type Tk_Labelframe <: TTk_Container w::TkWidget; children::Vector{Tk_Widget} end -type Tk_Notebook <: TTk_Container w::TkWidget; children::Vector{Tk_Widget} end -type Tk_Panedwindow <: TTk_Container w::TkWidget; children::Vector{Tk_Widget} end +mutable struct Tk_Toplevel <: TTk_Container w::TkWidget; children::Vector{Tk_Widget} end +mutable struct Tk_Frame <: TTk_Container w::TkWidget; children::Vector{Tk_Widget} end +mutable struct Tk_Labelframe <: TTk_Container w::TkWidget; children::Vector{Tk_Widget} end +mutable struct Tk_Notebook <: TTk_Container w::TkWidget; children::Vector{Tk_Widget} end +mutable struct Tk_Panedwindow <: TTk_Container w::TkWidget; children::Vector{Tk_Widget} end ==(a::TTk_Container, b::TTk_Container) = isequal(a.w, b.w) && typeof(a) == typeof(b) @@ -23,7 +23,7 @@ width(widget::Tk_Toplevel) = parse(Int, winfo(widget, "width")) height(widget::Tk_Toplevel) = parse(Int, winfo(widget, "height")) get_size(widget::Tk_Toplevel) = [width(widget), height(widget)] set_size(widget::Tk_Toplevel, width::Integer, height::Integer) = wm(widget, "geometry", "$(string(width))x$(string(height))") -set_size{T <: Integer}(widget::Tk_Toplevel, widthheight::Vector{T}) = set_size(widget, widthheight[1], widthheight[2]) +set_size(widget::Tk_Toplevel, widthheight::Vector{T}) where {T <: Integer} = set_size(widget, widthheight[1], widthheight[2]) @@ -52,7 +52,7 @@ function set_position(widget::Tk_Toplevel, x::Integer, y::Integer) p_or_m(x) = x < 0 ? "$x" : "+$x" wm(widget, "geometry", I(p_or_m(x) * p_or_m(y))) end -set_position{T <: Integer}(widget::Tk_Toplevel, pos::Vector{T}) = set_position(w, pos[1], pos[2]) +set_position(widget::Tk_Toplevel, pos::Vector{T}) where {T <: Integer} = set_position(w, pos[1], pos[2]) set_position(widget::Tk_Toplevel, pos::Tk_Widget) = set_position(widget, Integer[parse(Int, winfo(pos, i)) for i in ["x", "y"]] + [10,10]) update(widget::Tk_Toplevel) = wm(widget, "geometry") diff --git a/src/core.jl b/src/core.jl index e8c673b..5074cad 100644 --- a/src/core.jl +++ b/src/core.jl @@ -16,14 +16,14 @@ get_path(widget::Canvas) = get_path(widget.c) # Tk.Canvas object ## Coversion of julia objects into tcl strings for inclusion via tcl() call to_tcl(x) = string(x) -to_tcl(x::Void) = "" +to_tcl(x::Nothing) = "" has_space = r" " to_tcl(x::AbstractString) = ismatch(has_space, x) ? "{$x}" : x -type I x::MaybeString end # avoid wrapping in {} and ismatch call. +mutable struct I x::MaybeString end # avoid wrapping in {} and ismatch call. macro I_str(s) I(s) end to_tcl(x::I) = x.x == nothing ? "" : x.x -to_tcl{T <: Number}(x::Vector{T}) = "\"" * string(join(x, " ")) * "\"" -function to_tcl{T <: AbstractString}(x::Vector{T}) +to_tcl(x::Vector{T}) where {T <: Number} = "\"" * string(join(x, " ")) * "\"" +function to_tcl(x::Vector{T}) where T <: AbstractString tmp = join(["{$i}" for i in x], " ") "[list $tmp ]" end @@ -80,7 +80,7 @@ function configure(widget::Widget, args...; kwargs...) tcl(widget, "configure", args...; kwargs...) end -setindex!(widget::Widget, value, prop::Symbol) = configure(widget, @compat Dict(prop=>value)) +setindex!(widget::Widget, value, prop::Symbol) = configure(widget, Dict(prop=>value)) ## Get values ## cget @@ -110,13 +110,7 @@ winfo(widget::Widget, prop::AbstractString) = winfo(widget, prop, nothing) wm(window::Widget, prop::AbstractString, args...; kwargs...) = tcl("wm", prop, window, args...; kwargs...) -if VERSION >= v"0.6.0-pre.alpha.244" - _slots(m::Method) = (Base.uncompressed_ast(m).slotnames, m.nargs) -elseif VERSION >= v"0.6.0-dev.624" - _slots(m::Method) = (m.source.slotnames, m.nargs) -else - _slots(m::Method) = (m.lambda_template.slotnames, m.lambda_template.nargs) -end +_slots(m::Method) = (Base.uncompressed_ast(m).slotnames, m.nargs) ## Take a function, get its args as array of symbols. There must be better way... ## Helper functions for bind callback @@ -164,7 +158,7 @@ function bindwheel(widget::Widget, modifier::AbstractString, callback::Function, tkargs = string(" ", tkargs) end ccb = tcl_callback(callback) - if is_linux() + if Compat.Sys.islinux() tcl_eval("bind $(path) <$(modifier)Button-4> {$ccb -120$tkargs}") tcl_eval("bind $(path) <$(modifier)Button-5> {$ccb 120$tkargs}") else @@ -174,7 +168,7 @@ end ## add most typical callback function callback_add(widget::Tk_Widget, callback::Function) - events = @compat Dict( + events = Dict( :Tk_Window => "", :Tk_Frame => nothing, :Tk_Labelframe => nothing, @@ -222,11 +216,11 @@ end ## function after a delay of ms milliseconds. This is started with ## obj.start() and stopped, if desired, with obj.stop(). To restart is ## possible, but first set obj.run=true. -type TclAfter +mutable struct TclAfter cb::Function run::Bool - start::Union{Void, Function} - stop::Union{Void, Function} + start::Union{Nothing, Function} + stop::Union{Nothing, Function} ms::Int function TclAfter(ms, cb::Function) diff --git a/src/dialogs.jl b/src/dialogs.jl index a7e447e..3e65f84 100644 --- a/src/dialogs.jl +++ b/src/dialogs.jl @@ -8,7 +8,7 @@ ChooseDirectory() = tcl("tk_chooseDirectory") ## Message box function Messagebox(parent::MaybeWidget; title::AbstractString="", message::AbstractString="", detail::AbstractString="") args = Dict() - if !isa(parent, Void) args["parent"] = get_path(parent) end + if !isa(parent, Nothing) args["parent"] = get_path(parent) end if length(title) > 0 args["title"] = title end if length(message) > 0 args["message"] = message end if length(detail) > 0 args["detail"] = detail end diff --git a/src/menu.jl b/src/menu.jl index fa41b08..6b3f193 100644 --- a/src/menu.jl +++ b/src/menu.jl @@ -54,7 +54,7 @@ function menu_add(widget::Tk_Menu, rb::Tk_Radio) end function tk_popup(widget::Tk_Widget, menu::Tk_Menu) - if is_apple() + if Compat.Sys.isapple() tcl_eval("bind $(widget.w.path) <2> {tk_popup $(menu.w.path) %X %Y}") tcl_eval("bind $(widget.w.path) {tk_popup $(menu.w.path) %X %Y}") else @@ -63,7 +63,7 @@ function tk_popup(widget::Tk_Widget, menu::Tk_Menu) end function tk_popup(c::Canvas, menu::Tk_Menu) - if is_apple() + if Compat.Sys.isapple() tcl_eval("bind $(c.c.path) <2> {tk_popup $(menu.w.path) %X %Y}") tcl_eval("bind $(c.c.path) {tk_popup $(menu.w.path) %X %Y}") else diff --git a/src/tkwidget.jl b/src/tkwidget.jl index dd33c5e..735cd7d 100644 --- a/src/tkwidget.jl +++ b/src/tkwidget.jl @@ -4,9 +4,9 @@ const TCL_RETURN = convert(Int32, 2) const TCL_BREAK = convert(Int32, 3) const TCL_CONTINUE = convert(Int32, 4) -const TCL_VOLATILE = convert(Ptr{Void}, 1) -const TCL_STATIC = convert(Ptr{Void}, 0) -const TCL_DYNAMIC = convert(Ptr{Void}, 3) +const TCL_VOLATILE = convert(Ptr{Cvoid}, 1) +const TCL_STATIC = convert(Ptr{Cvoid}, 0) +const TCL_DYNAMIC = convert(Ptr{Cvoid}, 3) tcl_doevent() = tcl_doevent(nothing,0) function tcl_doevent(timer,status=0) @@ -24,19 +24,20 @@ end global timeout = nothing # fetch first word from struct -tk_display(w) = pointer_to_array(convert(Ptr{Ptr{Void}},w), (1,), false)[1] +tk_display(w) = pointer_to_array(convert(Ptr{Ptr{Cvoid}},w), (1,), false)[1] function init() - @static if is_apple() ccall(:CFBundleCreate, Ptr{Void}, (Ptr{Void}, Ptr{Void}), C_NULL, - ccall(:CFURLCreateWithFileSystemPath, Ptr{Void}, (Ptr{Void}, Ptr{Void}, Cint, Cint), C_NULL, - ccall(:CFStringCreateWithFileSystemRepresentation, Ptr{Void}, (Ptr{Void}, Ptr{UInt8}), C_NULL, "/System/Library/Frameworks/Tk.framework"), - 0, 1)) + @static if Compat.Sys.isapple() + ccall(:CFBundleCreate, Ptr{Cvoid}, (Ptr{Cvoid}, Ptr{Cvoid}), C_NULL, + ccall(:CFURLCreateWithFileSystemPath, Ptr{Cvoid}, (Ptr{Cvoid}, Ptr{Cvoid}, Cint, Cint), C_NULL, + ccall(:CFStringCreateWithFileSystemRepresentation, Ptr{Cvoid}, (Ptr{Cvoid}, Ptr{UInt8}), C_NULL, "/System/Library/Frameworks/Tk.framework"), + 0, 1)) end - ccall((:Tcl_FindExecutable,libtcl), Void, (Ptr{UInt8},), - joinpath(JULIA_HOME, "julia")) - ccall((:g_type_init,Cairo._jl_libgobject),Void,()) - tclinterp = ccall((:Tcl_CreateInterp,libtcl), Ptr{Void}, ()) - @static if is_windows() + ccall((:Tcl_FindExecutable,libtcl), Cvoid, (Ptr{UInt8},), + joinpath(Compat.Sys.BINDIR, "julia")) + ccall((:g_type_init,Cairo._jl_libgobject),Cvoid,()) + tclinterp = ccall((:Tcl_CreateInterp,libtcl), Ptr{Cvoid}, ()) + @static if Compat.Sys.iswindows() htcl = ccall((:GetModuleHandleA,:kernel32),stdcall,Csize_t, (Ptr{UInt8},),libtcl) tclfile = Vector{UInt8}(260) @@ -55,33 +56,37 @@ function init() tcl_eval(takebuf_string(libpath),tclinterp) end end - if ccall((:Tcl_Init,libtcl), Int32, (Ptr{Void},), tclinterp) == TCL_ERROR + if ccall((:Tcl_Init,libtcl), Int32, (Ptr{Cvoid},), tclinterp) == TCL_ERROR throw(TclError(string("error initializing Tcl: ", tcl_result(tclinterp)))) end - if ccall((:Tk_Init,libtk), Int32, (Ptr{Void},), tclinterp) == TCL_ERROR + if ccall((:Tk_Init,libtk), Int32, (Ptr{Cvoid},), tclinterp) == TCL_ERROR throw(TclError(string("error initializing Tk: ", tcl_result(tclinterp)))) end global timeout - timeout = Timer(tcl_doevent,0.1,0.01) + @static if VERSION >= v"0.7.0-DEV.3526" + timeout = Timer(tcl_doevent, 0.1, interval=0.01) + else + timeout = Timer(tcl_doevent, 0.1, 0.01) + end tclinterp end mainwindow(interp) = - ccall((:Tk_MainWindow,libtk), Ptr{Void}, (Ptr{Void},), interp) + ccall((:Tk_MainWindow,libtk), Ptr{Cvoid}, (Ptr{Cvoid},), interp) mainwindow() = mainwindow(tcl_interp) -type TclError <: Exception +mutable struct TclError <: Exception msg::AbstractString end tcl_result() = tcl_result(tcl_interp) function tcl_result(tcl_interp) unsafe_string(ccall((:Tcl_GetStringResult,libtcl), - Ptr{UInt8}, (Ptr{Void},), tcl_interp)) + Ptr{UInt8}, (Ptr{Cvoid},), tcl_interp)) end function tcl_evalfile(name) - if ccall((:Tcl_EvalFile,libtcl), Int32, (Ptr{Void}, Ptr{UInt8}), + if ccall((:Tcl_EvalFile,libtcl), Int32, (Ptr{Cvoid}, Ptr{UInt8}), tcl_interp, name) != 0 throw(TclError(tcl_result())) end @@ -90,7 +95,7 @@ end tcl_eval(cmd) = tcl_eval(cmd,tcl_interp) function tcl_eval(cmd,tclinterp) - code = ccall((:Tcl_Eval,libtcl), Int32, (Ptr{Void}, Ptr{UInt8}), + code = ccall((:Tcl_Eval,libtcl), Int32, (Ptr{Cvoid}, Ptr{UInt8}), tclinterp, cmd) result = tcl_result(tclinterp) if code != 0 @@ -100,10 +105,10 @@ function tcl_eval(cmd,tclinterp) end end -type TkWidget +mutable struct TkWidget path::String kind::String - parent::Union{TkWidget,Void} + parent::Union{TkWidget,Nothing} let ID::Int = 0 function TkWidget(parent::TkWidget, kind) @@ -130,8 +135,8 @@ Window(title) = Window(title, 200, 200) place(widget::TkWidget, x::Int, y::Int) = tcl_eval("place $(widget.path) -x $x -y $y") function nametowindow(name) - ccall((:Tk_NameToWindow,libtk), Ptr{Void}, - (Ptr{Void}, Ptr{UInt8}, Ptr{Void}), + ccall((:Tk_NameToWindow,libtk), Ptr{Cvoid}, + (Ptr{Cvoid}, Ptr{UInt8}, Ptr{Cvoid}), tcl_interp, name, mainwindow(tcl_interp)) end @@ -151,23 +156,23 @@ function jl_tcl_callback(fptr, interp, argc::Int32, argv::Ptr{Ptr{UInt8}}) return TCL_ERROR end if isa(result,String) - ccall((:Tcl_SetResult,libtcl), Void, (Ptr{Void}, Ptr{UInt8}, Int32), + ccall((:Tcl_SetResult,libtcl), Cvoid, (Ptr{Cvoid}, Ptr{UInt8}, Int32), interp, result, TCL_VOLATILE) else - ccall((:Tcl_SetResult,libtcl), Void, (Ptr{Void}, Ptr{UInt8}, Int32), + ccall((:Tcl_SetResult,libtcl), Cvoid, (Ptr{Cvoid}, Ptr{UInt8}, Int32), interp, empty_str, TCL_STATIC) end return TCL_OK end jl_tcl_callback_ptr = cfunction(jl_tcl_callback, - Int32, (Ptr{Void}, Ptr{Void}, Int32, Ptr{Ptr{UInt8}})) + Int32, (Ptr{Cvoid}, Ptr{Cvoid}, Int32, Ptr{Ptr{UInt8}})) function tcl_callback(f) - cname = string("jl_cb", repr(object_id(f))) + cname = string("jl_cb", repr(objectid(f))) # TODO: use Tcl_CreateObjCommand instead - ccall((:Tcl_CreateCommand,libtcl), Ptr{Void}, - (Ptr{Void}, Ptr{UInt8}, Ptr{Void}, Ptr{Void}, Ptr{Void}), + ccall((:Tcl_CreateCommand,libtcl), Ptr{Cvoid}, + (Ptr{Cvoid}, Ptr{UInt8}, Ptr{Cvoid}, Ptr{Cvoid}, Ptr{Cvoid}), tcl_interp, cname, jl_tcl_callback_ptr, pointer_from_objref(f), C_NULL) # TODO: use a delete proc (last arg) to remove this _callbacks[f] = true @@ -179,7 +184,7 @@ height(w::TkWidget) = parse(Int, tcl_eval("winfo height $(w.path)")) const default_mouse_cb = (w, x, y)->nothing -type MouseHandler +mutable struct MouseHandler button1press button1release button2press @@ -196,7 +201,7 @@ end # TkCanvas is the plain Tk canvas widget. This one is double-buffered # and built on Cairo. -type Canvas +mutable struct Canvas c::TkWidget back::CairoSurface # backing store backcc::CairoContext @@ -265,15 +270,15 @@ function reveal(c::Canvas) tcl_doevent() end -@static if is_apple() +@static if Compat.Sys.isapple() if Sys.WORD_SIZE == 32 const CGFloat = Float32 else const CGFloat = Float64 end - function objc_msgSend{T}(id, uid, ::Type{T}=Ptr{Void}) - convert(T, ccall(:objc_msgSend, Ptr{Void}, (Ptr{Void}, Ptr{Void}), - id, ccall(:sel_getUid, Ptr{Void}, (Ptr{UInt8},), uid))) + function objc_msgSend(id, uid, ::Type{T}=Ptr{Void}) where T + convert(T, ccall(:objc_msgSend, Ptr{Cvoid}, (Ptr{Cvoid}, Ptr{Cvoid}), + id, ccall(:sel_getUid, Ptr{Cvoid}, (Ptr{UInt8},), uid))) end end @@ -282,7 +287,7 @@ end function render_to_cairo(f::Function, w::TkWidget, clipped::Bool=true) win = nametowindow(w.path) win == C_NULL && error("invalid window") - @static if is_linux() + @static if Compat.Sys.islinux() disp = jl_tkwin_display(win) d = jl_tkwin_id(win) vis = jl_tkwin_visual(win) @@ -294,14 +299,14 @@ function render_to_cairo(f::Function, w::TkWidget, clipped::Bool=true) destroy(surf) return end - @static if is_apple() + @static if Compat.Sys.isapple() ## TkMacOSXSetupDrawingContext() drawable = jl_tkwin_id(win) - view = ccall((:TkMacOSXGetRootControl,libtk), Ptr{Void}, (Int,), drawable) # NSView* + view = ccall((:TkMacOSXGetRootControl,libtk), Ptr{Cvoid}, (Int,), drawable) # NSView* if view == C_NULL error("Invalid OS X window at getView") end - focusView = objc_msgSend(ccall(:objc_getClass, Ptr{Void}, (Ptr{UInt8},), "NSView"), "focusView"); + focusView = objc_msgSend(ccall(:objc_getClass, Ptr{Cvoid}, (Ptr{UInt8},), "NSView"), "focusView"); focusLocked = false if view != focusView focusLocked = objc_msgSend(view, "lockFocusIfCanDraw", Int32) != 0 @@ -316,7 +321,7 @@ function render_to_cairo(f::Function, w::TkWidget, clipped::Bool=true) objc_msgSend(window, "disableFlushWindow") context = objc_msgSend(objc_msgSend(window, "graphicsContext"), "graphicsPort") if !focusLocked - ccall(:CGContextSaveGState, Void, (Ptr{Void},), context) + ccall(:CGContextSaveGState, Cvoid, (Ptr{Cvoid},), context) end try ## TkMacOSXGetClipRgn @@ -326,7 +331,7 @@ function render_to_cairo(f::Function, w::TkWidget, clipped::Bool=true) if macDraw.winPtr != C_NULL TK_CLIP_INVALID = 0x02 # 8.4, 8.5, 8.6 if macDraw.flags & TK_CLIP_INVALID != 0 - ccall((:TkMacOSXUpdateClipRgn,libtk), Void, (Ptr{Void},), macDraw.winPtr) + ccall((:TkMacOSXUpdateClipRgn,libtk), Cvoid, (Ptr{Cvoid},), macDraw.winPtr) macDraw = unsafe_load(convert(Ptr{TkWindowPrivate}, drawable)) end clipRgn = if macDraw.drawRgn != C_NULL @@ -338,16 +343,16 @@ function render_to_cairo(f::Function, w::TkWidget, clipped::Bool=true) end end ## - ccall(:CGContextTranslateCTM, Void, (Ptr{Void}, CGFloat, CGFloat), context, 0, height(toplevel(w))) - ccall(:CGContextScaleCTM, Void, (Ptr{Void}, CGFloat, CGFloat), context, 1, -1) + ccall(:CGContextTranslateCTM, Cvoid, (Ptr{Cvoid}, CGFloat, CGFloat), context, 0, height(toplevel(w))) + ccall(:CGContextScaleCTM, Cvoid, (Ptr{Cvoid}, CGFloat, CGFloat), context, 1, -1) if clipRgn != C_NULL - if ccall(:HIShapeIsEmpty, UInt8, (Ptr{Void},), clipRgn) != 0 + if ccall(:HIShapeIsEmpty, UInt8, (Ptr{Cvoid},), clipRgn) != 0 return end - @assert 0 == ccall(:HIShapeReplacePathInCGContext, Cint, (Ptr{Void}, Ptr{Void}), clipRgn, context) - ccall(:CGContextEOClip, Void, (Ptr{Void},), context) + @assert 0 == ccall(:HIShapeReplacePathInCGContext, Cint, (Ptr{Cvoid}, Ptr{Cvoid}), clipRgn, context) + ccall(:CGContextEOClip, Cvoid, (Ptr{Cvoid},), context) end - ccall(:CGContextTranslateCTM, Void, (Ptr{Void}, CGFloat, CGFloat), context, macDraw.xOff, macDraw.yOff) + ccall(:CGContextTranslateCTM, Cvoid, (Ptr{Cvoid}, CGFloat, CGFloat), context, macDraw.xOff, macDraw.yOff) ## end surf = CairoQuartzSurface(context, wi, hi) @@ -358,26 +363,26 @@ function render_to_cairo(f::Function, w::TkWidget, clipped::Bool=true) end finally ## TkMacOSXRestoreDrawingContext - ccall(:CGContextSynchronize, Void, (Ptr{Void},), context) + ccall(:CGContextSynchronize, Cvoid, (Ptr{Cvoid},), context) objc_msgSend(window, "enableFlushWindow") if focusLocked objc_msgSend(view, "unlockFocus") else - ccall(:CGContextRestoreGState, Void, (Ptr{Void},), context) + ccall(:CGContextRestoreGState, Cvoid, (Ptr{Cvoid},), context) end end ## return end - @static if is_windows() + @static if Compat.Sys.iswindows() state = Vector{UInt8}(sizeof(Int)*2) # 8.4, 8.5, 8.6 drawable = jl_tkwin_id(win) - hdc = ccall((:TkWinGetDrawableDC,libtk), Ptr{Void}, (Ptr{Void}, Int, Ptr{UInt8}), + hdc = ccall((:TkWinGetDrawableDC,libtk), Ptr{Cvoid}, (Ptr{Cvoid}, Int, Ptr{UInt8}), jl_tkwin_display(win), drawable, state) surf = CairoWin32Surface(hdc, width(w), height(w)) f(surf) destroy(surf) - ccall((:TkWinReleaseDrawableDC,libtk), Void, (Int, Int, Ptr{UInt8}), + ccall((:TkWinReleaseDrawableDC,libtk), Cvoid, (Int, Int, Ptr{UInt8}), drawable, hdc, state) return end @@ -459,41 +464,41 @@ const tk_version = convert(VersionNumber,tcl_eval("return \$tk_version")) tcl_eval("wm withdraw .") if tk_version >= v"8.4-" && tk_version < v"8.7-" -jl_tkwin_display(tkwin::Ptr{Void}) = unsafe_load(convert(Ptr{Ptr{Void}},tkwin), 1) # 8.4, 8.5, 8.6 -jl_tkwin_visual(tkwin::Ptr{Void}) = unsafe_load(convert(Ptr{Ptr{Void}},tkwin), 4) # 8.4, 8.5, 8.6 -jl_tkwin_id(tkwin::Ptr{Void}) = unsafe_load(convert(Ptr{Int},tkwin), 6) # 8.4, 8.5, 8.6 -if is_apple() +jl_tkwin_display(tkwin::Ptr{Cvoid}) = unsafe_load(convert(Ptr{Ptr{Cvoid}},tkwin), 1) # 8.4, 8.5, 8.6 +jl_tkwin_visual(tkwin::Ptr{Cvoid}) = unsafe_load(convert(Ptr{Ptr{Cvoid}},tkwin), 4) # 8.4, 8.5, 8.6 +jl_tkwin_id(tkwin::Ptr{Cvoid}) = unsafe_load(convert(Ptr{Int},tkwin), 6) # 8.4, 8.5, 8.6 +if Compat.Sys.isapple() if tk_version >= v"8.5-" - immutable TkWindowPrivate - winPtr::Ptr{Void} - view::Ptr{Void} - context::Ptr{Void} + struct TkWindowPrivate + winPtr::Ptr{Cvoid} + view::Ptr{Cvoid} + context::Ptr{Cvoid} xOff::Cint yOff::Cint sizeX::CGFloat; sizeY::CGFloat; - visRgn::Ptr{Void} - aboveVisRgn::Ptr{Void} - drawRgn::Ptr{Void} - referenceCount::Ptr{Void} - toplevel::Ptr{Void} + visRgn::Ptr{Cvoid} + aboveVisRgn::Ptr{Cvoid} + drawRgn::Ptr{Cvoid} + referenceCount::Ptr{Cvoid} + toplevel::Ptr{Cvoid} flags::Cint end else - immutable TkWindowPrivate - winPtr::Ptr{Void} - grafPtr::Ptr{Void} - view::Ptr{Void} - context::Ptr{Void} + struct TkWindowPrivate + winPtr::Ptr{Cvoid} + grafPtr::Ptr{Cvoid} + view::Ptr{Cvoid} + context::Ptr{Cvoid} xOff::Cint yOff::Cint sizeX::CGFloat; sizeY::CGFloat; - visRgn::Ptr{Void} - aboveVisRgn::Ptr{Void} - drawRgn::Ptr{Void} - referenceCount::Ptr{Void} - toplevel::Ptr{Void} + visRgn::Ptr{Cvoid} + aboveVisRgn::Ptr{Cvoid} + drawRgn::Ptr{Cvoid} + referenceCount::Ptr{Cvoid} + toplevel::Ptr{Cvoid} flags::Cint end end diff --git a/src/types.jl b/src/types.jl index 36c0608..67cf9ed 100644 --- a/src/types.jl +++ b/src/types.jl @@ -1,15 +1,15 @@ ## Abstract types -@compat abstract type Tk_Widget end -@compat abstract type TTk_Widget <: Tk_Widget end ## for ttk::widgets -@compat abstract type TTk_Container <: Tk_Widget end ## for containers (frame, labelframe, ???) +abstract type Tk_Widget end +abstract type TTk_Widget <: Tk_Widget end ## for ttk::widgets +abstract type TTk_Container <: Tk_Widget end ## for containers (frame, labelframe, ???) const Widget = Union{TkWidget, Tk_Widget, Canvas, AbstractString} ## Maybe -- can this be parameterized? ## https://groups.google.com/forum/?fromgroups=#!topic/julia-dev/IbbWwplrqlc (takeaway -- this style is frowned upon) -const MaybeFunction = Union{Function, Void} -const MaybeString = Union{AbstractString, Void} -const MaybeStringInteger = Union{AbstractString, Integer, Void} # for at in tree insert -const MaybeVector = Union{Vector, Void} -const MaybeWidget = Union{Widget, Void} -const MaybeBool = Union{Bool, Void} +const MaybeFunction = Union{Function, Nothing} +const MaybeString = Union{AbstractString, Nothing} +const MaybeStringInteger = Union{AbstractString, Integer, Nothing} # for at in tree insert +const MaybeVector = Union{Vector, Nothing} +const MaybeWidget = Union{Widget, Nothing} +const MaybeBool = Union{Bool, Nothing} diff --git a/test/runtests.jl b/test/runtests.jl index b71bbb4..42bc7e1 100644 --- a/test/runtests.jl +++ b/test/runtests.jl @@ -1,6 +1,7 @@ ## Tests using Tk -using Base.Test +using Compat +using Compat.Test @testset "Toplevel" begin w = Toplevel("Toplevel", 400, 400) From 02d07d28bef993263b50f6ae01189469e68b4665 Mon Sep 17 00:00:00 2001 From: Alex Arslan Date: Wed, 4 Apr 2018 11:09:26 -0700 Subject: [PATCH 04/14] Bump Compat, work around 0.7 ccall error --- REQUIRE | 2 +- src/tkwidget.jl | 9 ++++++++- 2 files changed, 9 insertions(+), 2 deletions(-) diff --git a/REQUIRE b/REQUIRE index 721e80b..c1e4764 100644 --- a/REQUIRE +++ b/REQUIRE @@ -1,5 +1,5 @@ julia 0.6 -Compat 0.48.0 +Compat 0.52.0 Cairo Graphics 0.1 BinDeps 0.2.2- diff --git a/src/tkwidget.jl b/src/tkwidget.jl index 735cd7d..baa802d 100644 --- a/src/tkwidget.jl +++ b/src/tkwidget.jl @@ -35,7 +35,14 @@ function init() end ccall((:Tcl_FindExecutable,libtcl), Cvoid, (Ptr{UInt8},), joinpath(Compat.Sys.BINDIR, "julia")) - ccall((:g_type_init,Cairo._jl_libgobject),Cvoid,()) + + # FIXME: On Julia 0.7, the ccall((f, lib), ...) style call errors, claiming that the + # (f, lib) tuple isn't a valid constant expression. This approach works around that + # by getting a pointer to the function, then passing that to ccall. + g_type_init_ptr = Libdl.dlsym(Cairo._jl_libgobject, :g_type_init) + ccall(g_type_init_ptr, Cvoid, ()) + Libdl.dlclose(g_type_init_ptr) + tclinterp = ccall((:Tcl_CreateInterp,libtcl), Ptr{Cvoid}, ()) @static if Compat.Sys.iswindows() htcl = ccall((:GetModuleHandleA,:kernel32),stdcall,Csize_t, From 00433c3539f49dcd2ca8b3303c828bb5a55b6db3 Mon Sep 17 00:00:00 2001 From: Alex Arslan Date: Wed, 4 Apr 2018 11:18:30 -0700 Subject: [PATCH 05/14] Whoops --- src/tkwidget.jl | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/tkwidget.jl b/src/tkwidget.jl index baa802d..f02f246 100644 --- a/src/tkwidget.jl +++ b/src/tkwidget.jl @@ -39,9 +39,11 @@ function init() # FIXME: On Julia 0.7, the ccall((f, lib), ...) style call errors, claiming that the # (f, lib) tuple isn't a valid constant expression. This approach works around that # by getting a pointer to the function, then passing that to ccall. - g_type_init_ptr = Libdl.dlsym(Cairo._jl_libgobject, :g_type_init) + jl_libgobject_ptr = Libdl.dlopen(Cairo._jl_libgobject) + g_type_init_ptr = Libdl.dlsym(jl_libgobject_ptr, :g_type_init) ccall(g_type_init_ptr, Cvoid, ()) Libdl.dlclose(g_type_init_ptr) + Libdl.dlclose(jl_libgobject_ptr) tclinterp = ccall((:Tcl_CreateInterp,libtcl), Ptr{Cvoid}, ()) @static if Compat.Sys.iswindows() From 421d1201a768328170837bff994ab896b2dad275 Mon Sep 17 00:00:00 2001 From: Alex Arslan Date: Fri, 15 Jun 2018 12:37:43 -0700 Subject: [PATCH 06/14] Reinstate simply ccall to Cairo._jl_libgobject This was an issue in Julia itself and has been fixed upstream. --- src/tkwidget.jl | 11 +---------- 1 file changed, 1 insertion(+), 10 deletions(-) diff --git a/src/tkwidget.jl b/src/tkwidget.jl index f02f246..735cd7d 100644 --- a/src/tkwidget.jl +++ b/src/tkwidget.jl @@ -35,16 +35,7 @@ function init() end ccall((:Tcl_FindExecutable,libtcl), Cvoid, (Ptr{UInt8},), joinpath(Compat.Sys.BINDIR, "julia")) - - # FIXME: On Julia 0.7, the ccall((f, lib), ...) style call errors, claiming that the - # (f, lib) tuple isn't a valid constant expression. This approach works around that - # by getting a pointer to the function, then passing that to ccall. - jl_libgobject_ptr = Libdl.dlopen(Cairo._jl_libgobject) - g_type_init_ptr = Libdl.dlsym(jl_libgobject_ptr, :g_type_init) - ccall(g_type_init_ptr, Cvoid, ()) - Libdl.dlclose(g_type_init_ptr) - Libdl.dlclose(jl_libgobject_ptr) - + ccall((:g_type_init,Cairo._jl_libgobject),Cvoid,()) tclinterp = ccall((:Tcl_CreateInterp,libtcl), Ptr{Cvoid}, ()) @static if Compat.Sys.iswindows() htcl = ccall((:GetModuleHandleA,:kernel32),stdcall,Csize_t, From 1bc1f81a5a5303c829b2efaf3a81f26728dad40f Mon Sep 17 00:00:00 2001 From: "femtocleaner[bot]" Date: Thu, 28 Jun 2018 18:04:41 +0000 Subject: [PATCH 07/14] Fix deprecations --- deps/build.jl | 16 ++++++++-------- examples/manipulate.jl | 4 ++-- examples/sketch.jl | 6 +----- examples/test.jl | 6 +++--- src/Tk.jl | 8 ++------ src/core.jl | 4 ++-- src/widgets.jl | 2 +- 7 files changed, 19 insertions(+), 27 deletions(-) diff --git a/deps/build.jl b/deps/build.jl index 9ed09a2..f92aca3 100644 --- a/deps/build.jl +++ b/deps/build.jl @@ -5,7 +5,7 @@ using Compat; import Compat.String tcl = library_dependency("tcl",aliases=["libtcl8.6","tcl86g","tcl86t","libtcl","libtcl8.6.so.0","libtcl8.5","libtcl8.5.so.0","tcl85"]) tk = library_dependency("tk",aliases=["libtk8.6","libtk","libtk8.6.so.0","libtk8.5","libtk8.5.so.0","tk85","tk86","tk86t"], depends=[tcl], validate = function(p,h) - is_apple() && (return @compat Libdl.dlsym_e(h,:TkMacOSXGetRootControl) != C_NULL) + is_apple() && (return Libdl.dlsym_e(h,:TkMacOSXGetRootControl) != C_NULL) return true end) @@ -21,12 +21,12 @@ provides(AptGet,"tk8.5",tk) provides(Sources,URI("http://prdownloads.sourceforge.net/tcl/tcl8.6.0-src.tar.gz"),tcl,unpacked_dir = "tcl8.6.0") provides(Sources,URI("http://prdownloads.sourceforge.net/tcl/tk8.6.0-src.tar.gz"),tk,unpacked_dir = "tk8.6.0") -is64bit = @compat Sys.WORD_SIZE == 64 +is64bit = Sys.WORD_SIZE == 64 -provides(BuildProcess,Autotools(configure_subdir = "unix", configure_options = [is64bit?"--enable-64bit":"--disable-64bit"]),tcl, os = :Unix) -provides(BuildProcess,Autotools(configure_subdir = "unix", configure_options = [is64bit?"--enable-64bit":"--disable-64bit"]),tk, os = :Unix) +provides(BuildProcess,Autotools(configure_subdir = "unix", configure_options = [is64bit ? "--enable-64bit" : "--disable-64bit"]),tcl, os = :Unix) +provides(BuildProcess,Autotools(configure_subdir = "unix", configure_options = [is64bit ? "--enable-64bit" : "--disable-64bit"]),tk, os = :Unix) -if @compat Sys.WORD_SIZE == 64 +if Sys.WORD_SIZE == 64 # Unfortunately the mingw-built tc segfaults since some function signatures # are different between VC and mingw. This is fixed on tcl trunk. For now, # just use VC to build tcl (Note requlres Visual Studio Express in the PATH) @@ -48,8 +48,8 @@ if @compat Sys.WORD_SIZE == 64 end end),tk) else - provides(BuildProcess,Autotools(libtarget = "tcl86.dll", configure_subdir = "win", configure_options = [is64bit?"--enable-64bit":"--disable-64bit","--enable-threads"]),tcl, os = :Windows) - provides(BuildProcess,Autotools(libtarget = "tk86.dll", configure_subdir = "win", configure_options = [is64bit?"--enable-64bit":"--disable-64bit"]),tk, os = :Windows) + provides(BuildProcess,Autotools(libtarget = "tcl86.dll", configure_subdir = "win", configure_options = [is64bit ? "--enable-64bit" : "--disable-64bit","--enable-threads"]),tcl, os = :Windows) + provides(BuildProcess,Autotools(libtarget = "tk86.dll", configure_subdir = "win", configure_options = [is64bit ? "--enable-64bit" : "--disable-64bit"]),tk, os = :Windows) end -@BinDeps.install @compat(Dict(:tk => :libtk, :tcl=>:libtcl)) +@BinDeps.install Dict(:tk => :libtk, :tcl=>:libtcl) diff --git a/examples/manipulate.jl b/examples/manipulate.jl index 4ee05fb..6120980 100644 --- a/examples/manipulate.jl +++ b/examples/manipulate.jl @@ -105,7 +105,7 @@ entry(nm::AbstractString) = EntryWidget(nm, nm, "{}") ## Expression returns a plot object. Use names as values -function manipulate(ex::(@compat Union{Symbol,Expr}), controls...) +function manipulate(ex::(Union{Symbol,Expr}), controls...) widgets = Array(Tk.Widget, 0) w = Toplevel("Manipulate", 800, 500) @@ -127,7 +127,7 @@ function manipulate(ex::(@compat Union{Symbol,Expr}), controls...) d = Dict() # return Dict of values vals = get_values(); keys = get_nms() for i in 1:length(vals) - if !isa(keys[i], @compat Void) + if !isa(keys[i], Void) d[keys[i]] = vals[i] end end diff --git a/examples/sketch.jl b/examples/sketch.jl index 5a2f68f..18c3c6f 100644 --- a/examples/sketch.jl +++ b/examples/sketch.jl @@ -1,9 +1,5 @@ using Tk -if VERSION < v"0.4.0-dev+3275" - using Base.Graphics -else - using Graphics -end +using Graphics function sketch_window() w = Window("drawing", 400, 300) diff --git a/examples/test.jl b/examples/test.jl index 9405dd5..87ecd51 100644 --- a/examples/test.jl +++ b/examples/test.jl @@ -6,7 +6,7 @@ using Compat; import Compat.String w = Toplevel("Test window", false) ## pack in tk frame for themed widgets f = Frame(w) -configure(f, @compat Dict(:padding => [3,3,2,2], :relief=>"groove")) +configure(f, Dict(:padding => [3,3,2,2], :relief=>"groove")) pack(f, expand=true, fill="both") ## widgets @@ -26,11 +26,11 @@ pack_style = ["pack", "grid", "formlayout"][3] if pack_style == "pack" map(pack, widgets) - map(u -> pack_configure(u, @compat Dict(:anchor => "w")), widgets) + map(u -> pack_configure(u, Dict(:anchor => "w")), widgets) elseif pack_style == "grid" for i in 1:length(widgets) grid(widgets[i], i, 1) - grid_configure(widgets[i], @compat Dict(:sticky => "we")) + grid_configure(widgets[i], Dict(:sticky => "we")) end else map(u -> formlayout(u, "label"), widgets) diff --git a/src/Tk.jl b/src/Tk.jl index 0ad64d8..60f853f 100644 --- a/src/Tk.jl +++ b/src/Tk.jl @@ -1,4 +1,4 @@ -VERSION >= v"0.4.0-dev+6521" && __precompile__(false) +__precompile__(false) # julia tk interface # TODO: @@ -26,11 +26,7 @@ end import Base: ==, bind, getindex, isequal, parent, setindex!, show, string, Text -if VERSION < v"0.4.0-dev+3275" - import Base.Graphics: width, height, getgc -else - import Graphics: width, height, getgc -end +import Graphics: width, height, getgc import Cairo: destroy diff --git a/src/core.jl b/src/core.jl index e8c673b..4b49b21 100644 --- a/src/core.jl +++ b/src/core.jl @@ -80,7 +80,7 @@ function configure(widget::Widget, args...; kwargs...) tcl(widget, "configure", args...; kwargs...) end -setindex!(widget::Widget, value, prop::Symbol) = configure(widget, @compat Dict(prop=>value)) +setindex!(widget::Widget, value, prop::Symbol) = configure(widget, Dict(prop=>value)) ## Get values ## cget @@ -174,7 +174,7 @@ end ## add most typical callback function callback_add(widget::Tk_Widget, callback::Function) - events = @compat Dict( + events = Dict( :Tk_Window => "", :Tk_Frame => nothing, :Tk_Labelframe => nothing, diff --git a/src/widgets.jl b/src/widgets.jl index f5f9a03..db57de4 100644 --- a/src/widgets.jl +++ b/src/widgets.jl @@ -219,7 +219,7 @@ end get_items(widget::Tk_Combobox) = widget.values -function set_items{T}(widget::Tk_Combobox, items::Vector{@compat Tuple{T,T}}) +function set_items{T}(widget::Tk_Combobox, items::Vector{Tuple{T,T}}) vals = cb_pluck_labels(items) configure(widget, values = vals) widget.values = items From 77de46890a85e5d7bb50b0342145a62e8c586663 Mon Sep 17 00:00:00 2001 From: Alex Arslan Date: Thu, 6 Sep 2018 22:40:26 -0700 Subject: [PATCH 08/14] Modify Travis setup to see where we're at --- .travis.yml | 28 +++++++++++++--------------- 1 file changed, 13 insertions(+), 15 deletions(-) diff --git a/.travis.yml b/.travis.yml index 60d9c19..a16b328 100644 --- a/.travis.yml +++ b/.travis.yml @@ -1,20 +1,18 @@ language: julia os: - - linux - - osx + - linux + - osx julia: - - 0.6 - - nightly + - 0.6 + - 0.7 + - 1.0 + - nightly notifications: - email: false -script: - - if [[ -a .git/shallow ]]; then git fetch --unshallow; fi - - julia -e 'Pkg.clone(pwd())' - - if [ `uname` = "Linux" ]; then - xvfb-run julia -e 'Pkg.build("Tk"); Pkg.test("Tk"; coverage=true)'; - elif [ `uname` = "Darwin" ]; then - julia -e 'Pkg.build("Tk"); Pkg.test("Tk"; coverage=true)'; - fi - # - xvfb-run julia -e 'Pkg.clone(pwd()); Pkg.build("Tk"); Pkg.test("Tk"; coverage=true)'; + email: false +allow_failures: + julia: + - nightly +before_script: + - if [ $(uname) = "Linux" ]; then alias julia="xvfb-run $(which julia)"; fi after_success: - - julia -e 'cd(Pkg.dir("Tk")); Pkg.add("Coverage"); using Coverage; Coveralls.submit(Coveralls.process_folder())'; + - julia -e 'using Pkg; Pkg.add("Coverage"); using Coverage; Coveralls.submit(Coveralls.process_folder())'; From 1333be7ed97e4064b3278302df9720576fc84736 Mon Sep 17 00:00:00 2001 From: Alex Arslan Date: Thu, 6 Sep 2018 22:51:29 -0700 Subject: [PATCH 09/14] The previous commit, but better --- .travis.yml | 19 ++++++++++++++----- 1 file changed, 14 insertions(+), 5 deletions(-) diff --git a/.travis.yml b/.travis.yml index a16b328..fb51a49 100644 --- a/.travis.yml +++ b/.travis.yml @@ -9,10 +9,19 @@ julia: - nightly notifications: email: false -allow_failures: - julia: - - nightly -before_script: - - if [ $(uname) = "Linux" ]; then alias julia="xvfb-run $(which julia)"; fi +matrix: + allow_failures: + julia: + - 1.0 + - nightly +script: + - if [[ -a .git/shallow ]]; then git fetch --unshallow; fi + - julia -e 'using Pkg; Pkg.clone(pwd())' + - | + if [ $(uname) = "Linux" ]; then + xvfb-run julia -e 'using Pkg; Pkg.build("Tk"); Pkg.test("Tk", coverage=true)' + else + julia -e 'using Pkg; Pkg.build("Tk"); Pkg.test("Tk", coverage=true)' + fi after_success: - julia -e 'using Pkg; Pkg.add("Coverage"); using Coverage; Coveralls.submit(Coveralls.process_folder())'; From 61747df28487f6e5d1bc734da2c9f12565fad3f4 Mon Sep 17 00:00:00 2001 From: Avik Sengupta Date: Tue, 4 Feb 2020 23:54:06 +0000 Subject: [PATCH 10/14] Make 1.0 compatible --- .gitignore | 2 + .travis.yml | 20 +++----- Project.toml | 16 ++++++ REQUIRE | 6 --- deps/build.jl | 7 ++- examples/process.jl | 5 +- examples/test.jl | 2 - examples/workspace.jl | 9 ++-- src/Tk.jl | 16 ++++-- src/core.jl | 6 +-- src/menu.jl | 3 +- src/tkwidget.jl | 96 ++++++++++++++---------------------- src/widgets.jl | 110 +++++++++++++++++++++--------------------- test/REQUIRE | 1 - test/runtests.jl | 16 +++--- 15 files changed, 151 insertions(+), 164 deletions(-) create mode 100644 Project.toml delete mode 100644 REQUIRE delete mode 100644 test/REQUIRE diff --git a/.gitignore b/.gitignore index 6614884..a27d94a 100644 --- a/.gitignore +++ b/.gitignore @@ -1,4 +1,5 @@ deps/builds +deps/build.log deps/downloads deps/src deps/usr @@ -7,3 +8,4 @@ deps/deps.jl *~ *.jl.cov *.jl.mem +Manifest.toml diff --git a/.travis.yml b/.travis.yml index fb51a49..db20490 100644 --- a/.travis.yml +++ b/.travis.yml @@ -2,26 +2,18 @@ language: julia os: - linux - osx + +dist: xenial +services: + - xvfb + julia: - - 0.6 - - 0.7 - 1.0 + - 1.3 - nightly notifications: email: false matrix: allow_failures: julia: - - 1.0 - nightly -script: - - if [[ -a .git/shallow ]]; then git fetch --unshallow; fi - - julia -e 'using Pkg; Pkg.clone(pwd())' - - | - if [ $(uname) = "Linux" ]; then - xvfb-run julia -e 'using Pkg; Pkg.build("Tk"); Pkg.test("Tk", coverage=true)' - else - julia -e 'using Pkg; Pkg.build("Tk"); Pkg.test("Tk", coverage=true)' - fi -after_success: - - julia -e 'using Pkg; Pkg.add("Coverage"); using Coverage; Coveralls.submit(Coveralls.process_folder())'; diff --git a/Project.toml b/Project.toml new file mode 100644 index 0000000..2539e6e --- /dev/null +++ b/Project.toml @@ -0,0 +1,16 @@ +name = "Tk" +uuid = "4225ea8a-3324-57e7-9ddc-5798a2cb9eab" + +[deps] +Base64 = "2a0f44e3-6c83-55bd-87e4-b1978d98bd5f" +BinDeps = "9e28174c-4ba2-5203-b857-d8d62c4213ee" +Cairo = "159f3aea-2a34-519c-b102-8c37f9878175" +Graphics = "a2bd30eb-e257-5431-a919-1863eab51364" +Libdl = "8f399da3-3557-5675-b5ff-fb832c97cbdb" +Random = "9a3f8284-a2c9-5f02-9a11-845980a1fd5c" +Test = "8dfed614-e22c-5e08-85e1-65c5234f0b40" +WinRPM = "c17dfb99-b4f7-5aad-8812-456da1ad7187" + +[compat] +Graphics = "≥ 0.1.0" +julia = "1.0" diff --git a/REQUIRE b/REQUIRE deleted file mode 100644 index c1e4764..0000000 --- a/REQUIRE +++ /dev/null @@ -1,6 +0,0 @@ -julia 0.6 -Compat 0.52.0 -Cairo -Graphics 0.1 -BinDeps 0.2.2- -@windows WinRPM diff --git a/deps/build.jl b/deps/build.jl index b73810b..ee1654f 100644 --- a/deps/build.jl +++ b/deps/build.jl @@ -1,16 +1,15 @@ using BinDeps -using Compat -using Compat.Libdl +using Libdl @BinDeps.setup tcl = library_dependency("tcl",aliases=["libtcl8.6","tcl86g","tcl86t","libtcl","libtcl8.6.so.0","libtcl8.5","libtcl8.5.so.0","tcl85"]) tk = library_dependency("tk",aliases=["libtk8.6","libtk","libtk8.6.so.0","libtk8.5","libtk8.5.so.0","tk85","tk86","tk86t"], depends=[tcl], validate = function(p,h) - is_apple() && (return Libdl.dlsym_e(h,:TkMacOSXGetRootControl) != C_NULL) + Sys.isapple() && (return Libdl.dlsym_e(h,:TkMacOSXGetRootControl) != C_NULL) return true end) -if Compat.Sys.iswindows() +if Sys.iswindows() using WinRPM provides(WinRPM.RPM,"tk",tk,os = :Windows) provides(WinRPM.RPM,"tcl",tcl,os = :Windows) diff --git a/examples/process.jl b/examples/process.jl index a32d99e..7713bc3 100644 --- a/examples/process.jl +++ b/examples/process.jl @@ -1,8 +1,9 @@ f = "radio.png" +using Base64 function process_file(f) - a = readchomp(`base64 $f`) - "\n" + a = readchomp(`cat $f`) + "\n" end process_file(f) diff --git a/examples/test.jl b/examples/test.jl index 87ecd51..b6a7db8 100644 --- a/examples/test.jl +++ b/examples/test.jl @@ -1,7 +1,6 @@ ## Example of widgets put into container with change handler assigned using Tk -using Compat; import Compat.String w = Toplevel("Test window", false) ## pack in tk frame for themed widgets @@ -41,4 +40,3 @@ change_handler(path,xs...) = println(map(get_value, widgets)) map(u -> callback_add(u, change_handler), widgets) set_visible(w, true) - diff --git a/examples/workspace.jl b/examples/workspace.jl index 88a8caa..5b1ac3a 100644 --- a/examples/workspace.jl +++ b/examples/workspace.jl @@ -1,5 +1,5 @@ ## simple workspace browser for julia -using Tk, Compat +using Tk ## Some functions to work with a module function get_names(m::Module) @@ -15,7 +15,7 @@ short_summary(x) = summary(x) short_summary(x::AbstractString) = "A string" ## update ids, returning false if the same, true if not -__ids__ = Vector{AbstractString}(0) +__ids__ = Vector{AbstractString}() function update_ids(m::Module) global __ids__ nms = get_names(m) @@ -47,9 +47,9 @@ function get_names_summaries(m::Module, pat::MaybeRegex, dtype::MaybeType, dtype end ## filter out this type if dtype != nothing - nms = filter(u -> isdefined(m, Symbol(u)) && negate(isa(eval(m,Symbol(u)), dtype), dtypefilter), nms) + nms = filter(u -> isdefined(m, Symbol(u)) && negate(isa(Base.eval(m,Symbol(u)), dtype), dtypefilter), nms) end - summaries = map(u -> isdefined(m, Symbol(u)) ? short_summary(eval(m,Symbol(u))) : "undefined", nms) + summaries = map(u -> isdefined(m, Symbol(u)) ? short_summary(Base.eval(m,Symbol(u))) : "undefined", nms) if length(nms) == length(summaries) return [nms summaries] @@ -88,4 +88,3 @@ function cb() end aft = tcl_after(1000, cb) aft.start() - diff --git a/src/Tk.jl b/src/Tk.jl index 2164f24..96cc3db 100644 --- a/src/Tk.jl +++ b/src/Tk.jl @@ -1,4 +1,4 @@ -__precompile__(false) + # julia tk interface # TODO: @@ -15,7 +15,7 @@ __precompile__(false) module Tk using Cairo -using Compat +using Random if isfile(joinpath(dirname(@__FILE__),"..","deps","deps.jl")) include("../deps/deps.jl") @@ -38,6 +38,17 @@ include("containers.jl") include("dialogs.jl") include("menu.jl") +function __init__() + global tcl_interp[] = init() + global tk_version[] = VersionNumber(tcl_eval("return \$tk_version")) + tcl_eval("wm withdraw .") + tcl_eval("set auto_path") + ## remove tearoff menus + tcl_eval("option add *tearOff 0") + + global jl_tcl_callback_ptr = @cfunction(jl_tcl_callback, + Int32, (Ptr{Cvoid}, Ptr{Cvoid}, Int32, Ptr{Ptr{UInt8}})) +end export Window, TkCanvas, Canvas, pack, place, tcl_eval, TclError, cairo_surface_for, width, height, reveal, cairo_surface, getgc, @@ -86,5 +97,4 @@ export get_value, set_value, @deprecate get_width width @deprecate get_height height - end # module diff --git a/src/core.jl b/src/core.jl index 5074cad..ba2ef79 100644 --- a/src/core.jl +++ b/src/core.jl @@ -1,8 +1,6 @@ show(io::IO, widget::TkWidget) = print(io, typeof(widget)) show(io::IO, widget::Tk_Widget) = print(io, "Tk widget of type $(typeof(widget))") - -tcl_eval("set auto_path") tcl_add_path(path::AbstractString) = tcl_eval("lappend auto_path $path") tcl_require(pkg::AbstractString) = tcl_eval("package require $pkg") @@ -18,7 +16,7 @@ get_path(widget::Canvas) = get_path(widget.c) # Tk.Canvas object to_tcl(x) = string(x) to_tcl(x::Nothing) = "" has_space = r" " -to_tcl(x::AbstractString) = ismatch(has_space, x) ? "{$x}" : x +to_tcl(x::AbstractString) = occursin(has_space, x) ? "{$x}" : x mutable struct I x::MaybeString end # avoid wrapping in {} and ismatch call. macro I_str(s) I(s) end to_tcl(x::I) = x.x == nothing ? "" : x.x @@ -29,7 +27,7 @@ function to_tcl(x::Vector{T}) where T <: AbstractString end to_tcl(x::Widget) = get_path(x) function to_tcl(x::Dict) - out = filter((k,v) -> v != nothing, x) + out = filter( kv -> kv[2] != nothing, x) join([" -$(string(k)) $(to_tcl(v))" for (k, v) in out], "") end function to_tcl(x::Function) diff --git a/src/menu.jl b/src/menu.jl index 6b3f193..cbde44d 100644 --- a/src/menu.jl +++ b/src/menu.jl @@ -1,5 +1,4 @@ -## remove tearoff menus -tcl_eval("option add *tearOff 0") + ## make a menubar diff --git a/src/tkwidget.jl b/src/tkwidget.jl index e0fee48..dc6e89e 100644 --- a/src/tkwidget.jl +++ b/src/tkwidget.jl @@ -27,20 +27,20 @@ global timeout = nothing tk_display(w) = pointer_to_array(convert(Ptr{Ptr{Cvoid}},w), (1,), false)[1] function init() - @static if Compat.Sys.isapple() + @static if Sys.isapple() ccall(:CFBundleCreate, Ptr{Cvoid}, (Ptr{Cvoid}, Ptr{Cvoid}), C_NULL, ccall(:CFURLCreateWithFileSystemPath, Ptr{Cvoid}, (Ptr{Cvoid}, Ptr{Cvoid}, Cint, Cint), C_NULL, ccall(:CFStringCreateWithFileSystemRepresentation, Ptr{Cvoid}, (Ptr{Cvoid}, Ptr{UInt8}), C_NULL, "/System/Library/Frameworks/Tk.framework"), 0, 1)) end ccall((:Tcl_FindExecutable,libtcl), Cvoid, (Ptr{UInt8},), - joinpath(Compat.Sys.BINDIR, "julia")) - ccall((:g_type_init,Cairo._jl_libgobject),Cvoid,()) + joinpath(Sys.BINDIR, "julia")) + ccall((:g_type_init,Cairo.libgobject),Cvoid,()) tclinterp = ccall((:Tcl_CreateInterp,libtcl), Ptr{Cvoid}, ()) - @static if Compat.Sys.iswindows() + @static if Sys.iswindows() htcl = ccall((:GetModuleHandleA,:kernel32),stdcall,Csize_t, (Ptr{UInt8},),libtcl) - tclfile = Vector{UInt8}(260) + tclfile = Vector{UInt8}(undef, 260) len = ccall((:GetModuleFileNameA,:kernel32),stdcall,Cint, (Csize_t,Ptr{UInt8},Cint),htcl,tclfile,length(tclfile)) if len > 0 @@ -73,28 +73,29 @@ end mainwindow(interp) = ccall((:Tk_MainWindow,libtk), Ptr{Cvoid}, (Ptr{Cvoid},), interp) -mainwindow() = mainwindow(tcl_interp) +mainwindow() = mainwindow(tcl_interp[]) mutable struct TclError <: Exception msg::AbstractString end -tcl_result() = tcl_result(tcl_interp) -function tcl_result(tcl_interp) +tcl_result() = tcl_result(tcl_interp[]) +function tcl_result(tclinterp) unsafe_string(ccall((:Tcl_GetStringResult,libtcl), - Ptr{UInt8}, (Ptr{Cvoid},), tcl_interp)) + Ptr{UInt8}, (Ptr{Cvoid},), tclinterp)) end function tcl_evalfile(name) if ccall((:Tcl_EvalFile,libtcl), Int32, (Ptr{Cvoid}, Ptr{UInt8}), - tcl_interp, name) != 0 + tcl_interp[], name) != 0 throw(TclError(tcl_result())) end nothing end -tcl_eval(cmd) = tcl_eval(cmd,tcl_interp) +tcl_eval(cmd) = tcl_eval(cmd,tcl_interp[]) function tcl_eval(cmd,tclinterp) + #@show cmd code = ccall((:Tcl_Eval,libtcl), Int32, (Ptr{Cvoid}, Ptr{UInt8}), tclinterp, cmd) result = tcl_result(tclinterp) @@ -103,16 +104,17 @@ function tcl_eval(cmd,tclinterp) else result end + end mutable struct TkWidget path::String kind::String parent::Union{TkWidget,Nothing} - + let ID::Int = 0 function TkWidget(parent::TkWidget, kind) - underscoredKind = replace(kind, "::", "_") + underscoredKind = replace(kind, "::" => "_") path = "$(parent.path).jl_$(underscoredKind)$(ID)"; ID += 1 new(path, kind, parent) end @@ -137,15 +139,16 @@ place(widget::TkWidget, x::Int, y::Int) = tcl_eval("place $(widget.path) -x $x - function nametowindow(name) ccall((:Tk_NameToWindow,libtk), Ptr{Cvoid}, (Ptr{Cvoid}, Ptr{UInt8}, Ptr{Cvoid}), - tcl_interp, name, mainwindow(tcl_interp)) + tcl_interp[], name, mainwindow(tcl_interp[])) end -const _callbacks = ObjectIdDict() +const _callbacks = Dict{String, Any}() const empty_str = "" -function jl_tcl_callback(fptr, interp, argc::Int32, argv::Ptr{Ptr{UInt8}}) - f = unsafe_pointer_to_objref(fptr) +function jl_tcl_callback(fptr, interp, argc::Int32, argv::Ptr{Ptr{UInt8}})::Int32 + cname = unsafe_pointer_to_objref(fptr) + f=_callbacks[cname] args = [unsafe_string(unsafe_load(argv,i)) for i=1:argc] local result try @@ -165,17 +168,14 @@ function jl_tcl_callback(fptr, interp, argc::Int32, argv::Ptr{Ptr{UInt8}}) return TCL_OK end -jl_tcl_callback_ptr = cfunction(jl_tcl_callback, - Int32, (Ptr{Cvoid}, Ptr{Cvoid}, Int32, Ptr{Ptr{UInt8}})) - function tcl_callback(f) cname = string("jl_cb", repr(objectid(f))) # TODO: use Tcl_CreateObjCommand instead ccall((:Tcl_CreateCommand,libtcl), Ptr{Cvoid}, (Ptr{Cvoid}, Ptr{UInt8}, Ptr{Cvoid}, Ptr{Cvoid}, Ptr{Cvoid}), - tcl_interp, cname, jl_tcl_callback_ptr, pointer_from_objref(f), C_NULL) + tcl_interp[], cname, jl_tcl_callback_ptr, pointer_from_objref(cname), C_NULL) # TODO: use a delete proc (last arg) to remove this - _callbacks[f] = true + _callbacks[cname] = f cname end @@ -270,7 +270,7 @@ function reveal(c::Canvas) tcl_doevent() end -@static if Compat.Sys.isapple() +@static if Sys.isapple() if Sys.WORD_SIZE == 32 const CGFloat = Float32 else @@ -287,7 +287,7 @@ end function render_to_cairo(f::Function, w::TkWidget, clipped::Bool=true) win = nametowindow(w.path) win == C_NULL && error("invalid window") - @static if Compat.Sys.islinux() + @static if Sys.islinux() disp = jl_tkwin_display(win) d = jl_tkwin_id(win) vis = jl_tkwin_visual(win) @@ -299,7 +299,7 @@ function render_to_cairo(f::Function, w::TkWidget, clipped::Bool=true) destroy(surf) return end - @static if Compat.Sys.isapple() + @static if Sys.isapple() ## TkMacOSXSetupDrawingContext() drawable = jl_tkwin_id(win) view = ccall((:TkMacOSXGetRootControl,libtk), Ptr{Cvoid}, (Int,), drawable) # NSView* @@ -374,7 +374,7 @@ function render_to_cairo(f::Function, w::TkWidget, clipped::Bool=true) ## return end - @static if Compat.Sys.iswindows() + @static if Sys.iswindows() state = Vector{UInt8}(sizeof(Int)*2) # 8.4, 8.5, 8.6 drawable = jl_tkwin_id(win) hdc = ccall((:TkWinGetDrawableDC,libtk), Ptr{Cvoid}, (Ptr{Cvoid}, Int, Ptr{UInt8}), @@ -458,25 +458,15 @@ function cairo_surface(c::Canvas) wait_initialized(c) c.back end - -const tcl_interp = init() -const tk_version = convert(VersionNumber,tcl_eval("return \$tk_version")) -tcl_eval("wm withdraw .") - -if tk_version >= v"8.4-" && tk_version < v"8.7-" -jl_tkwin_display(tkwin::Ptr{Cvoid}) = unsafe_load(convert(Ptr{Ptr{Cvoid}},tkwin), 1) # 8.4, 8.5, 8.6 -jl_tkwin_visual(tkwin::Ptr{Cvoid}) = unsafe_load(convert(Ptr{Ptr{Cvoid}},tkwin), 4) # 8.4, 8.5, 8.6 -jl_tkwin_id(tkwin::Ptr{Cvoid}) = unsafe_load(convert(Ptr{Int},tkwin), 6) # 8.4, 8.5, 8.6 -if Compat.Sys.isapple() -if tk_version >= v"8.5-" +@static if Sys.isapple() struct TkWindowPrivate winPtr::Ptr{Cvoid} view::Ptr{Cvoid} context::Ptr{Cvoid} xOff::Cint yOff::Cint - sizeX::CGFloat; - sizeY::CGFloat; + sizeX::CGFloat + sizeY::CGFloat visRgn::Ptr{Cvoid} aboveVisRgn::Ptr{Cvoid} drawRgn::Ptr{Cvoid} @@ -484,25 +474,11 @@ if tk_version >= v"8.5-" toplevel::Ptr{Cvoid} flags::Cint end - else - struct TkWindowPrivate - winPtr::Ptr{Cvoid} - grafPtr::Ptr{Cvoid} - view::Ptr{Cvoid} - context::Ptr{Cvoid} - xOff::Cint - yOff::Cint - sizeX::CGFloat; - sizeY::CGFloat; - visRgn::Ptr{Cvoid} - aboveVisRgn::Ptr{Cvoid} - drawRgn::Ptr{Cvoid} - referenceCount::Ptr{Cvoid} - toplevel::Ptr{Cvoid} - flags::Cint - end - end -end -else -error("Tk.jl needs to be updated for tk version $tk_version") end + +global tcl_interp = Ref{Ptr{Cvoid}}() +global tk_version = Ref{VersionNumber}() + +jl_tkwin_display(tkwin::Ptr{Cvoid}) = unsafe_load(convert(Ptr{Ptr{Cvoid}},tkwin), 1) # 8.4, 8.5, 8.6 +jl_tkwin_visual(tkwin::Ptr{Cvoid}) = unsafe_load(convert(Ptr{Ptr{Cvoid}},tkwin), 4) # 8.4, 8.5, 8.6 +jl_tkwin_id(tkwin::Ptr{Cvoid}) = unsafe_load(convert(Ptr{Int},tkwin), 6) # 8.4, 8.5, 8.6 diff --git a/src/widgets.jl b/src/widgets.jl index db57de4..2a01c47 100644 --- a/src/widgets.jl +++ b/src/widgets.jl @@ -1,24 +1,24 @@ ## Create basic widgets here -## Most types are simple, some have other properties -type Tk_Label <: TTk_Widget w::TkWidget end -type Tk_Button <: TTk_Widget w::TkWidget end -type Tk_Checkbutton <: TTk_Widget w::TkWidget end -##type Tk_Radio <: TTk_Widget w::TkWidget end -##type Tk_Combobox <: TTk_Widget w::TkWidget end -type Tk_Scale <: TTk_Widget w::TkWidget end -#type Tk_Spinbox <: TTk_Widget w::TkWidget end -type Tk_Entry <: TTk_Widget w::TkWidget end -type Tk_Sizegrip <: TTk_Widget w::TkWidget end -type Tk_Separator <: TTk_Widget w::TkWidget end -type Tk_Progressbar <: TTk_Widget w::TkWidget end -type Tk_Menu <: TTk_Widget w::TkWidget end -type Tk_Menubutton <: TTk_Widget w::TkWidget end -type Tk_Image <: TTk_Widget w::AbstractString end -type Tk_Scrollbar <: TTk_Widget w::TkWidget end -type Tk_Text <: Tk_Widget w::TkWidget end -##type Tk_Treeview <: Tk_Widget w::TkWidget end -type Tk_Canvas <: Tk_Widget w::TkWidget end +## Most structs are simple, some have other properties +mutable struct Tk_Label <: TTk_Widget w::TkWidget end +mutable struct Tk_Button <: TTk_Widget w::TkWidget end +mutable struct Tk_Checkbutton <: TTk_Widget w::TkWidget end +##struct Tk_Radio <: TTk_Widget w::TkWidget end +##struct Tk_Combobox <: TTk_Widget w::TkWidget end +mutable struct Tk_Scale <: TTk_Widget w::TkWidget end +#struct Tk_Spinbox <: TTk_Widget w::TkWidget end +mutable struct Tk_Entry <: TTk_Widget w::TkWidget end +mutable struct Tk_Sizegrip <: TTk_Widget w::TkWidget end +mutable struct Tk_Separator <: TTk_Widget w::TkWidget end +mutable struct Tk_Progressbar <: TTk_Widget w::TkWidget end +mutable struct Tk_Menu <: TTk_Widget w::TkWidget end +mutable struct Tk_Menubutton <: TTk_Widget w::TkWidget end +mutable struct Tk_Image <: TTk_Widget w::AbstractString end +mutable struct Tk_Scrollbar <: TTk_Widget w::TkWidget end +mutable struct Tk_Text <: Tk_Widget w::TkWidget end +##struct Tk_Treeview <: Tk_Widget w::TkWidget end +mutable struct Tk_Canvas <: Tk_Widget w::TkWidget end for (k, k1, v) in ((:Label, :Tk_Label, "ttk::label"), (:Button, :Tk_Button, "ttk::button"), @@ -100,10 +100,10 @@ get_items(widget::Tk_Checkbutton) = widget[:text] set_items(widget::Tk_Checkbutton, value::AbstractString) = widget[:text] = tk_string_escape(value) ## RadioButton -type Tk_Radiobutton <: TTk_Widget +mutable struct Tk_Radiobutton <: TTk_Widget w::TkWidget end -MaybeTkRadioButton = Union{Void, Tk_Radiobutton} +MaybeTkRadioButton = Union{Nothing, Tk_Radiobutton} function Radiobutton(parent::Widget, group::MaybeTkRadioButton, label::AbstractString) @@ -122,15 +122,15 @@ set_items(widget::Tk_Radiobutton, value::AbstractString) = configure(widget, tex ## Radio Button Group -type Tk_Radio <: TTk_Widget +mutable struct Tk_Radio <: TTk_Widget w::TkWidget buttons::Vector - orient::Union{Void, AbstractString} + orient::Union{Nothing, AbstractString} end -function Radio{T<:AbstractString}(parent::Widget, labels::Vector{T}, orient::AbstractString) +function Radio(parent::Widget, labels::Vector{T}, orient::AbstractString) where {T<:AbstractString} n = size(labels)[1] - rbs = Vector{Tk_Radiobutton}(n) + rbs = Vector{Tk_Radiobutton}(undef, n) frame = Frame(parent) rbs[1] = Radiobutton(frame, tk_string_escape(labels[1])) @@ -147,7 +147,7 @@ function Radio{T<:AbstractString}(parent::Widget, labels::Vector{T}, orient::Abs rb end -Radio{T <: AbstractString}(parent::Widget, labels::Vector{T}) = Radio(parent, labels, "vertical") ## vertical default +Radio(parent::Widget, labels::Vector{T}) where {T <: AbstractString} = Radio(parent, labels, "vertical") ## vertical default function get_value(widget::Tk_Radio) items = get_items(widget) @@ -173,7 +173,7 @@ end ##getindex(widget::Tk_Radio, i::Integer) = widget.buttons[i] ## Combobox -type Tk_Combobox <: TTk_Widget +mutable struct Tk_Combobox <: TTk_Widget w::TkWidget values::Vector # of tuples (key, label) Tk_Combobox(w::TkWidget) = new(w, []) @@ -219,7 +219,7 @@ end get_items(widget::Tk_Combobox) = widget.values -function set_items{T}(widget::Tk_Combobox, items::Vector{Tuple{T,T}}) +function set_items(widget::Tk_Combobox, items::Vector{Tuple{T,T}}) where T vals = cb_pluck_labels(items) configure(widget, values = vals) widget.values = items @@ -228,7 +228,7 @@ function set_items(widget::Tk_Combobox, items::Dict) widget.values = [(string(k),v) for (k,v) in items] configure(widget, values = cb_pluck_labels(widget.values)) end -function set_items{T <: AbstractString}(widget::Tk_Combobox, items::Vector{T}) +function set_items(widget::Tk_Combobox, items::Vector{T}) where {T <: AbstractString} d = [(v,v) for v in items] set_items(widget, d) end @@ -239,7 +239,7 @@ set_editable(widget::Tk_Combobox, value::Bool) = widget[:state] = value ? "norma ## Slider ## deprecate this interface as integer values are not guaranteed in return. -function Slider{T <: Integer}(parent::Widget, range::UnitRange{T}; orient="horizontal") +function Slider(parent::Widget, range::UnitRange{T}; orient="horizontal") where {T <: Integer} w = Slider(parent, orient=orient) var = tclvar() tclvar(var, minimum(range)) @@ -247,7 +247,7 @@ function Slider{T <: Integer}(parent::Widget, range::UnitRange{T}; orient="horiz w end -function Slider{T <: Real}(parent::Widget, lo::T, hi::T; orient = "horizontal") +function Slider(parent::Widget, lo::T, hi::T; orient = "horizontal") where {T <: Real} w = Slider(parent, orient = orient) var = tclvar() tclvar(var, lo) @@ -255,7 +255,7 @@ function Slider{T <: Real}(parent::Widget, lo::T, hi::T; orient = "horizontal") w end -get_value(widget::Tk_Scale) = float(widget[:value]) +get_value(widget::Tk_Scale) = parse(Float64, widget[:value]) function set_value(widget::Tk_Scale, value::Real) variable = widget[:variable] @@ -273,13 +273,13 @@ function bind(widget::Tk_Scale, event::AbstractString, callback::Function) end ## Spinbox -type Tk_Spinbox <: TTk_Widget +mutable struct Tk_Spinbox <: TTk_Widget w::TkWidget range::UnitRange{Int} Tk_Spinbox(w::TkWidget) = new(w, 1:1) end -function Spinbox{T <: Integer}(parent, range::UnitRange{T}) +function Spinbox(parent, range::UnitRange{T}) where {T <: Integer} w = Spinbox(parent) set_items(w, range) set_value(w, minimum(range)) @@ -290,7 +290,7 @@ get_value(widget::Tk_Spinbox) = parse(Int, tcl(widget, "get")) set_value(widget::Tk_Spinbox, value::Integer) = tcl(widget, "set", value) get_items(widget::Tk_Spinbox) = widget.range -function set_items{T <: Integer}(widget::Tk_Spinbox, range::UnitRange{T}) +function set_items(widget::Tk_Spinbox, range::UnitRange{T}) where T configure(widget, from=minimum(range), to = maximum(range), increment = step(range)) widget.range = range end @@ -310,15 +310,16 @@ function Progressbar(widget::Widget, mode::AbstractString) w end -get_value(widget::Tk_Progressbar) = round(Int, float(widget[:value])) +get_value(widget::Tk_Progressbar) = round(Int, parse(Float64, widget[:value])) set_value(widget::Tk_Progressbar, value::Integer) = widget[:value] = min(100, max(0, value)) ## Image -MaybeImage = Union{Void, Tk_Image} +MaybeImage = Union{Nothing, Tk_Image} to_tcl(x::Tk_Image) = x.w function Image(fname::AbstractString) if isfile(fname) + fname = escape_string(fname) w = tcl(I"image create photo", file = fname) Tk_Image(w) else @@ -433,19 +434,19 @@ set_editable(widget::Tk_Text, value::Bool) = widget[:state] = value ? "normal" : ## Tree -type Tk_Treeview <: TTk_Widget +mutable struct Tk_Treeview <: TTk_Widget w::Widget names::MaybeVector Tk_Treeview(w::Widget) = new(w, nothing) end -type TreeNode node::AbstractString end +mutable struct TreeNode node::AbstractString end to_tcl(x::TreeNode) = x.node -MaybeTreeNode = Union{TreeNode, Void} +MaybeTreeNode = Union{TreeNode, Nothing} ## Special Tree cases ## listbox like interface -function Treeview{T <: AbstractString}(widget::Widget, items::Vector{T}, title::AbstractString; selected_color::AbstractString="gray") +function Treeview(widget::Widget, items::Vector{T}, title::AbstractString; selected_color::AbstractString="gray") where {T <: AbstractString} w = Treeview(widget) configure(w, show="tree headings", selectmode="browse") tcl(w, I"heading #0", text = title) @@ -466,7 +467,7 @@ function treeview_delete_children(widget::Tk_Treeview) end end -function set_items{T <: AbstractString}(widget::Tk_Treeview, items::Vector{T}) +function set_items(widget::Tk_Treeview, items::Vector{T}) where {T <: AbstractString} treeview_delete_children(widget) for i in items tcl(widget, I"insert {} end", text = i) @@ -479,7 +480,7 @@ end ## t = Treeview(w, ["one" "two" "half"; "three" "four" "half"], [100, 50, 23]) -function Treeview{T <: AbstractString}(widget::Widget, items::Array{T,2}, widths::MaybeVector) +function Treeview(widget::Widget, items::Array{T,2}, widths::MaybeVector) where {T <: AbstractString} sz = size(items) @@ -499,9 +500,9 @@ function Treeview{T <: AbstractString}(widget::Widget, items::Array{T,2}, widths w end -Treeview{T <: AbstractString}(widget::Widget, items::Array{T,2}) = Treeview(widget, items, nothing) +Treeview(widget::Widget, items::Array{T,2}) where {T <: AbstractString} = Treeview(widget, items, nothing) -function set_items{T <: AbstractString}(widget::Tk_Treeview, items::Array{T,2}) +function set_items(widget::Tk_Treeview, items::Array{T,2}) where {T <: AbstractString} treeview_delete_children(widget) sz = size(items) for i in 1:sz[1] @@ -569,11 +570,11 @@ end function node_insert(widget::Tk_Treeview, node::MaybeTreeNode, at::MaybeStringInteger, text::MaybeString, image::MaybeImage, values::MaybeVector, opened::MaybeBool) - parent = isa(node, Void) ? "{}" : node.node - at = isa(at, Void) ? "end" : at + parent = isa(node, Nothing) ? "{}" : node.node + at = isa(at, Nothing) ? "end" : at args = Dict() - args["text"] = isa(text, Void) ? "" : text + args["text"] = isa(text, Nothing) ? "" : text args["image"] = image.i args["values"] = values args["open"] = opened @@ -594,8 +595,8 @@ node_insert(widget::Tk_Treeview, node::MaybeTreeNode, text::MaybeString) = ## move node to parent and at, a string index, eg. "0" or "end". function node_move(widget::Tk_Treeview, node::TreeNode, parent::MaybeTreeNode, at::MaybeStringInteger) - to = isa(parent, Void) ? "{}" : parent.node - ind = isa(at, Void) ? "end" : at + to = isa(parent, Nothing) ? "{}" : parent.node + ind = isa(at, Nothing) ? "end" : at tcl(widget, "move", node.node, to, ind) end ## move to end @@ -615,19 +616,19 @@ end ## working on a grid XXX ## set column names, and widths. This works on values, not text part -function tree_headers{T <: AbstractString, S<: Integer}(widget::Tk_Treeview, names::Vector{T}, widths::Vector{S}) +function tree_headers(widget::Tk_Treeview, names::Vector{T}, widths::Vector{S}) where {T <: AbstractString, S<: Integer} tree_headers(widget, names) tree_column_widths(widget, widths) end -function tree_headers{T <: AbstractString}(widget::Tk_Treeview, names::Vector{T}) +function tree_headers(widget::Tk_Treeview, names::Vector{T}) where {T <: AbstractString} tcl(widget, "configure", column=names) widget.names = names map(u -> tcl(widget, "heading", u, text=u), names) end ## Set Column widths. Must have set headers first -function tree_column_widths{T <: Integer}(widget::Tk_Treeview, widths::Vector{T}) +function tree_column_widths(widget::Tk_Treeview, widths::Vector{T}) where {T <: Integer} if widget.names == nothing error("Must set header names, then widths") end @@ -658,7 +659,7 @@ end ## Bring Canvas object into Tk_Widget level. -type Tk_CairoCanvas <: TTk_Widget +mutable struct Tk_CairoCanvas <: TTk_Widget w::Canvas end @@ -672,4 +673,3 @@ function Canvas(parent::TTk_Container, args...) push!(parent.children, Tk_CairoCanvas(c)) c end - diff --git a/test/REQUIRE b/test/REQUIRE deleted file mode 100644 index 7a06016..0000000 --- a/test/REQUIRE +++ /dev/null @@ -1 +0,0 @@ -Winston diff --git a/test/runtests.jl b/test/runtests.jl index 42bc7e1..6a76269 100644 --- a/test/runtests.jl +++ b/test/runtests.jl @@ -1,7 +1,6 @@ ## Tests using Tk -using Compat -using Compat.Test +using Test @testset "Toplevel" begin w = Toplevel("Toplevel", 400, 400) @@ -311,24 +310,29 @@ end const exampledir = joinpath(splitdir(splitdir(@__FILE__)[1])[1], "examples") dcur = pwd() cd(exampledir) + # TODO: Uncomment when Winston supports 0.6 #module example_manipulate # if Pkg.installed("Winston")!=nothing # include("../examples/manipulate.jl") # end #end + + module example_process - include("../examples/process.jl") + @static if Sys.isunix() + include(joinpath("..","examples","process.jl")) + end end module example_sketch - include("../examples/sketch.jl") + include(joinpath("..","examples","sketch.jl")) end module example_test - include("../examples/test.jl") + include(joinpath("..","examples","test.jl")) destroy(w) end module example_workspace - include("../examples/workspace.jl") + include(joinpath("..","examples","workspace.jl")) aft.stop() sleep(1.5) destroy(w) From a8a631774b8227f86a30b4f21f571dfbaccb3627 Mon Sep 17 00:00:00 2001 From: Avik Sengupta Date: Wed, 5 Feb 2020 08:39:06 +0000 Subject: [PATCH 11/14] add appveyor script for windows testing --- appveyor.yml | 29 +++++++++++++++++++++++++++++ 1 file changed, 29 insertions(+) create mode 100644 appveyor.yml diff --git a/appveyor.yml b/appveyor.yml new file mode 100644 index 0000000..7677b56 --- /dev/null +++ b/appveyor.yml @@ -0,0 +1,29 @@ +environment: + matrix: + - julia_version: 1.0 + +platform: + - x86 # 32-bit + - x64 # 64-bit + +branches: + only: + - master + - /release-.*/ + +notifications: + - provider: Email + on_build_success: false + on_build_failure: false + on_build_status_changed: false + +install: + - ps: iex ((new-object net.webclient).DownloadString("https://raw.githubusercontent.com/JuliaCI/Appveyor.jl/version-1/bin/install.ps1")) + +build_script: + - echo "%JL_BUILD_SCRIPT%" + - C:\julia\bin\julia -e "%JL_BUILD_SCRIPT%" + +test_script: + - echo "%JL_TEST_SCRIPT%" + - C:\julia\bin\julia -e "%JL_TEST_SCRIPT%" From 9501144d82cadcf1540885d925deb4f147f0c5f3 Mon Sep 17 00:00:00 2001 From: Avik Sengupta Date: Wed, 5 Feb 2020 09:31:25 +0000 Subject: [PATCH 12/14] optimise travis build matrix --- .travis.yml | 26 +++++++++++++++----------- 1 file changed, 15 insertions(+), 11 deletions(-) diff --git a/.travis.yml b/.travis.yml index db20490..3934f80 100644 --- a/.travis.yml +++ b/.travis.yml @@ -1,19 +1,23 @@ language: julia -os: - - linux - - osx dist: xenial services: - xvfb -julia: - - 1.0 - - 1.3 - - nightly +jobs: + include: + - julia: 1.0 + os: linux + - julia: 1.3 + os: linux + - julia: nightly + os: linux + - julia: 1.0 + os: linux + - julia: 1.0 + os: osx + allow_failures: + - julia: nightly + notifications: email: false -matrix: - allow_failures: - julia: - - nightly From 2fb0cc2fa05f7d65b4a7ca38da113cfe49471680 Mon Sep 17 00:00:00 2001 From: Avik Sengupta Date: Wed, 5 Feb 2020 10:39:10 +0000 Subject: [PATCH 13/14] allow 32 bit test failure --- appveyor.yml | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/appveyor.yml b/appveyor.yml index 7677b56..1f3946a 100644 --- a/appveyor.yml +++ b/appveyor.yml @@ -6,6 +6,12 @@ platform: - x86 # 32-bit - x64 # 64-bit +matrix: + allow_failures: + - julia_version: x86 + + + branches: only: - master From 0479590910781afa5dec231a76bf60810450ef65 Mon Sep 17 00:00:00 2001 From: Avik Sengupta Date: Wed, 5 Feb 2020 11:09:24 +0000 Subject: [PATCH 14/14] improve tests --- .travis.yml | 2 -- examples/workspace.jl | 4 ++-- test/runtests.jl | 27 ++++++++++++++++++++------- 3 files changed, 22 insertions(+), 11 deletions(-) diff --git a/.travis.yml b/.travis.yml index 3934f80..fc580f0 100644 --- a/.travis.yml +++ b/.travis.yml @@ -12,8 +12,6 @@ jobs: os: linux - julia: nightly os: linux - - julia: 1.0 - os: linux - julia: 1.0 os: osx allow_failures: diff --git a/examples/workspace.jl b/examples/workspace.jl index 5b1ac3a..b4de5d3 100644 --- a/examples/workspace.jl +++ b/examples/workspace.jl @@ -6,7 +6,7 @@ function get_names(m::Module) sort!(map(string, names(m))) end -unique_id(v::Symbol, m::Module) = isdefined(m,v) ? unique_id(eval(m,v)) : "" +unique_id(v::Symbol, m::Module) = isdefined(m,v) ? unique_id(Base.eval(m,v)) : "" unique_id(x) = string(objectid(x)) ## short_summary @@ -75,7 +75,7 @@ scrollbars_add(f, tv) ## add a callback. Here we get the obj clicked on. callback_add(tv, (path) -> begin val = get_value(tv)[1] - obj = eval(Main, Symbol(val)) + obj = Base.eval(Main, Symbol(val)) println(short_summary(obj)) end) diff --git a/test/runtests.jl b/test/runtests.jl index 6a76269..c227d44 100644 --- a/test/runtests.jl +++ b/test/runtests.jl @@ -320,21 +320,34 @@ cd(exampledir) module example_process + using Test @static if Sys.isunix() - include(joinpath("..","examples","process.jl")) + @testset "Examples_Process" begin + @test_nowarn include(joinpath("..","examples","process.jl")) + end end end module example_sketch - include(joinpath("..","examples","sketch.jl")) + using Test + @testset "Examples_Sketch" begin + @test_nowarn include(joinpath("..","examples","sketch.jl")) + end end module example_test - include(joinpath("..","examples","test.jl")) - destroy(w) + using Test + @testset "Examples_Test" begin + @test_nowarn include(joinpath("..","examples","test.jl")) + @test_nowarn destroy(w) + end end module example_workspace - include(joinpath("..","examples","workspace.jl")) - aft.stop() + using Test + @testset "Examples_Workspace" begin + @test_nowarn include(joinpath("..","examples","workspace.jl")) + @test_nowarn aft.stop() sleep(1.5) - destroy(w) + @test_nowarn destroy(w) + end end + cd(dcur)