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

interactiveutil: clipboard for FreeBSD #23151

Merged
merged 2 commits into from
Dec 16, 2017

Conversation

iblislin
Copy link
Member

@iblislin iblislin commented Aug 6, 2017

The xsel implementation is different from Linux's.
Ref: http://bsdforge.com/projects/x11/xsel/

The xsel implementation is different from Linux's.
Ref: http://bsdforge.com/projects/x11/xsel/
@StefanKarpinski
Copy link
Sponsor Member

Nice. We should probably move this into a (standard) package so that it can evolve separate from Julia base.

:xclip => `xclip -quiet -out -selection clipboard`,
)
)
end
Copy link
Member

@ararslan ararslan Aug 6, 2017

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Since the only difference is in the options passed to xsel, I think it might be cleaner to just separate that part, i.e something like

xsel_copy  = Sys.islinux() ? `xsel --nodetach --input --clipboard`  : `xsel -c`
xsel_paste = Sys.islinux() ? `xsel --nodetach --output --clipboard` : `xsel -p`

_clipboardcmds = Dict(:copy  => Dict(:xsel  => xsel_copy,
                                     :xclip => `xclip -silent -in -selection clipboard`),
                      :paste => Dict(:xsel  => xsel_paste,
                                     :xclip => `xclip -quiet -out -selection clipboard`))

@ararslan ararslan added system:freebsd Affects only FreeBSD stdlib:REPL Julia's REPL (Read Eval Print Loop) labels Aug 6, 2017
@ararslan
Copy link
Member

ararslan commented Aug 6, 2017

Possible to add a test for this? I'm not sure how we test clipboard if at all currently though.

@iblislin
Copy link
Member Author

iblislin commented Aug 7, 2017

There is a test in misc on windows only.
I don't think it's suitable to add test cases for linux/bsd. since linux/bsd depends external dependency but windows not.

error("no clipboard command found, please install xsel or xclip")
pkgs = @static if Sys.islinux()
"xsel or xclip"
elseif Sys.KERNEL === :FreeBSD
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't think @static will resolve the elseif yet

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

seems works... is it expected?

julia> @static if true
         42
       elseif false
         24
       end                                                                                                            
42                                                                                                                    
                                                                                                                      
julia> @static if false
         42
       elseif true
         24
       end                                                                                                            
24                                                                                                                    

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

but the elseif condition is getting evaluated at run time, I believe

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

support of elseif block is added in #24787

`xsel --nodetach --output --clipboard` : `xsel -p`,
:xclip => `xclip -quiet -out -selection clipboard`,
)
)
function clipboardcmd()
global _clipboardcmd
_clipboardcmd !== nothing && return _clipboardcmd
for cmd in (:xclip, :xsel)
success(pipeline(`which $cmd`, DevNull)) && return _clipboardcmd = cmd
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

pre-existing, but this'll give a pretty misleading error message if which isn't installed

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Or... we can implement a simple version of which in Julia?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What I generally do is if I know the program I'm looking for, usually there's a safe no-op flag like -h or --version that you can try executing in a try-catch.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

-h works on xclip. unfortunately, the bsd version xsel doesn't have any no-op flag.

@iblislin iblislin closed this Dec 16, 2017
@iblislin iblislin reopened this Dec 16, 2017
@StefanKarpinski StefanKarpinski merged commit f5dab58 into JuliaLang:master Dec 16, 2017
@iblislin iblislin deleted the fbsd-clipboard branch December 24, 2017 14:28
ararslan pushed a commit that referenced this pull request Apr 25, 2018
ararslan pushed a commit that referenced this pull request May 2, 2018
ararslan pushed a commit that referenced this pull request May 8, 2018
ararslan pushed a commit that referenced this pull request May 27, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
stdlib:REPL Julia's REPL (Read Eval Print Loop) system:freebsd Affects only FreeBSD
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants