Skip to content

Commit

Permalink
move clipboard to InteractiveUtils
Browse files Browse the repository at this point in the history
  • Loading branch information
JeffBezanson committed Jun 18, 2018
1 parent 49254a4 commit fde8cd5
Show file tree
Hide file tree
Showing 9 changed files with 17 additions and 15 deletions.
4 changes: 4 additions & 0 deletions NEWS.md
Original file line number Diff line number Diff line change
Expand Up @@ -1271,6 +1271,10 @@ Deprecated or removed

* The functions `eigs` and `svds` have been moved to the `Arpack.jl` package ([#27616]).

* `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,7 +59,7 @@ 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))
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()
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

0 comments on commit fde8cd5

Please sign in to comment.