Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

move clipboard to InteractiveUtils #27635

Merged
merged 1 commit into from
Jun 19, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions NEWS.md
Original file line number Diff line number Diff line change
Expand Up @@ -1283,6 +1283,10 @@ Deprecated or removed

* `vecdot` and `vecnorm` are deprecated in favor of `dot` and `norm`, respectively ([#27401]).

* `clipboard` has been moved to the `InteractiveUtils` standard library package
(along with other utilities mostly used at the interactive prompt, such as `edit`
and `less`) ([#27635]).

Command-line option changes
---------------------------

Expand Down
1 change: 0 additions & 1 deletion base/exports.jl
Original file line number Diff line number Diff line change
Expand Up @@ -770,7 +770,6 @@ export
# misc
atexit,
atreplinit,
clipboard,
exit,
ntuple,

Expand Down
3 changes: 1 addition & 2 deletions base/sysimg.jl
Original file line number Diff line number Diff line change
Expand Up @@ -402,7 +402,6 @@ include("channels.jl")

# utilities
include("deepcopy.jl")
include("clipboard.jl")
include("download.jl")
include("summarysize.jl")
include("errorshow.jl")
Expand Down Expand Up @@ -860,6 +859,7 @@ end
@deprecate_stdlib varinfo InteractiveUtils true
@deprecate_stdlib versioninfo InteractiveUtils true
@deprecate_stdlib peakflops InteractiveUtils true
@deprecate_stdlib clipboard InteractiveUtils true
@eval @deprecate_stdlib $(Symbol("@which")) InteractiveUtils true
@eval @deprecate_stdlib $(Symbol("@edit")) InteractiveUtils true
@eval @deprecate_stdlib $(Symbol("@less")) InteractiveUtils true
Expand Down Expand Up @@ -889,7 +889,6 @@ end
@deprecate_stdlib send Sockets true
@deprecate_stdlib TCPSocket Sockets true
@deprecate_stdlib UDPSocket Sockets true

end
end

Expand Down
2 changes: 0 additions & 2 deletions doc/src/base/base.md
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,6 @@ Base.exit
Base.atexit
Base.isinteractive
Base.summarysize
Base.clipboard(::Any)
Base.clipboard()
Base.require
Base.compilecache
Base.__precompile__
Expand Down
1 change: 1 addition & 0 deletions stdlib/InteractiveUtils/docs/src/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ InteractiveUtils.code_llvm
InteractiveUtils.@code_llvm
InteractiveUtils.code_native
InteractiveUtils.@code_native
InteractiveUtils.clipboard
```

```@meta
Expand Down
3 changes: 2 additions & 1 deletion stdlib/InteractiveUtils/src/InteractiveUtils.jl
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ module InteractiveUtils

export apropos, edit, less, code_warntype, code_llvm, code_native, methodswith, varinfo,
versioninfo, subtypes, peakflops, @which, @edit, @less, @functionloc, @code_warntype,
@code_typed, @code_lowered, @code_llvm, @code_native, Pkg
@code_typed, @code_lowered, @code_llvm, @code_native, Pkg, clipboard

import Base.Docs.apropos

Expand All @@ -20,6 +20,7 @@ import Pkg, OldPkg
include("editless.jl")
include("codeview.jl")
include("macros.jl")
include("clipboard.jl")

"""
varinfo(m::Module=Main, pattern::Regex=r"")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -59,12 +59,12 @@ elseif Sys.islinux() || Sys.KERNEL === :FreeBSD
elseif Sys.iswindows()
# TODO: these functions leak memory and memory locks if they throw an error
function clipboard(x::AbstractString)
if containsnul(x)
if Base.containsnul(x)
throw(ArgumentError("Windows clipboard strings cannot contain NUL character"))
end
systemerror(:OpenClipboard, 0==ccall((:OpenClipboard, "user32"), stdcall, Cint, (Ptr{Cvoid},), C_NULL))
systemerror(:EmptyClipboard, 0==ccall((:EmptyClipboard, "user32"), stdcall, Cint, ()))
x_u16 = cwstring(x)
x_u16 = Base.cwstring(x)
# copy data to locked, allocated space
p = ccall((:GlobalAlloc, "kernel32"), stdcall, Ptr{UInt16}, (UInt16, Int32), 2, sizeof(x_u16))
systemerror(:GlobalAlloc, p==C_NULL)
Expand Down
8 changes: 8 additions & 0 deletions stdlib/InteractiveUtils/test/runtests.jl
Original file line number Diff line number Diff line change
Expand Up @@ -375,3 +375,11 @@ end
# Issue #27276
using InteractiveUtils: code_warntype_legacy_ir
code_warntype_legacy_ir(devnull, first(code_typed(+, Tuple{Int, Int}))...)

# clipboard functionality
if Sys.iswindows() || Sys.isapple()
for str in ("Hello, world.", "∀ x ∃ y", "")
clipboard(str)
@test clipboard() == str
end
end
8 changes: 0 additions & 8 deletions test/misc.jl
Original file line number Diff line number Diff line change
Expand Up @@ -375,14 +375,6 @@ let s = "abcα🐨\0x\0"
end
end

# clipboard functionality
if Sys.iswindows()
for str in ("Hello, world.", "∀ x ∃ y", "")
clipboard(str)
@test clipboard() == str
end
end

let optstring = repr("text/plain", Base.JLOptions())
@test startswith(optstring, "JLOptions(\n")
@test !occursin("Ptr", optstring)
Expand Down