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

support Windows clipboard on WSL #89

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
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 sysmisc.c
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,8 @@ Cboard_error cboard_copy(Glyph const *gbuffer, Usz field_height,
FILE *fp =
#ifdef ORCA_OS_MAC
popen("pbcopy -pboard general 2>/dev/null", "w");
#elif defined(ORCA_OS_WSL)
popen("clip.exe 2>/dev/null", "w");
#else
popen("xclip -i -selection clipboard 2>/dev/null", "w");
#endif
Expand All @@ -58,6 +60,8 @@ Cboard_error cboard_paste(Glyph *gbuffer, Usz height, Usz width, Usz y, Usz x,
FILE *fp =
#ifdef ORCA_OS_MAC
popen("pbpaste -pboard general -Prefer txt 2>/dev/null", "r");
#elif defined(ORCA_OS_WSL)
popen("powershell.exe -command 'Get-Clipboard' 2>/dev/null", "r");
#else
popen("xclip -o -selection clipboard 2>/dev/null", "r");
#endif
Expand Down
8 changes: 7 additions & 1 deletion tool
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,10 @@ cmd=$1
shift

case $(uname -s | awk '{print tolower($0)}') in
linux*) os=linux;;
linux*) os=linux
case $(uname -r | awk '{print tolower($0)}') in
*-microsoft-standard-wsl2) linux_flavor=wsl;;
esac;;
darwin*) os=mac;;
cygwin*) os=cygwin;;
*bsd*) os=bsd;;
Expand Down Expand Up @@ -384,6 +387,9 @@ build_target() {
# librt and high-res posix timers on Linux
add libraries -lrt
add cc_flags -D_POSIX_C_SOURCE=200809L
if [ "$linux_flavor" = wsl ]; then
add cc_flags -DORCA_OS_WSL
fi
;;
esac
# Depending on the Linux distro, ncurses might have been built with tinfo
Expand Down