Closed chris-b1 closed 2 years ago
Hey sorry for the delay about this. I will make sure to take a look soon.
Sorry for the delay in looking into this.
To be clear, this is what you are referring to?
julia> x = [1 2; 3 4]
2×2 Matrix{Int64}:
1 2
3 4
julia> cliparray(x)
1 2
3 4
julia> cliparray(x; returnstring = true)
1 2
3 4
"1\t2\n3\t4"
I think the default behavior is good, actually. I think the output with whitespace is sufficiently different than the output with \t
. Users might want both, but for different reasons.
Ah I could see how this could be a problem if you are calling it inside a function... Let's provide keyword arguments to control this behavior.
Thanks - for larger tables in particular the terminal IO on my setup (Windows, VS Code) is slow, and the pasted table breaks "scroll history" so I like it off by default.
As an example
using CSV, DataFrames, ClipData
function to_clipboard(df::DataFrames.DataFrame)
buf = IOBuffer()
CSV.write(buf, df; delim='\t')
clipboard(String(take!(buf)))
end
N = 1000; df = DataFrame(a=rand(N), b=rand(N), c=rand(N))
julia> @time to_clipboard(df)
0.001046 seconds (14.47 k allocations: 4.635 MiB)
julia> @time cliptable(df)
<snip>
0.207863 seconds (14.48 k allocations: 4.691 MiB)
I'd also prefer it to not print by default.
Okay I'm going to do a PR for this soon.
But first I will make a release with better compat entries, since I think we fixed some compat a few months ago but forgot a release.
Just made a release. So should be fixed now.
Not sure if this was a leftover from debugging, but I would suggest by default output should not printed, and the
returnstring
arg should be sufficient to handle cases where the literal clipboard content is needed?https://github.com/pdeffebach/ClipData.jl/blob/8d6aead1f01fc64accbefe727ddcd2afdcb2c318/src/ClipData.jl#L115