Skip to content
GitLab
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
rzerres
orbclient
Commits
ed7204c4
Verified
Commit
ed7204c4
authored
Jul 12, 2019
by
Jeremy Soller
Browse files
0.3.24 - add clipboard functions
parent
6a443176
Changes
3
Hide whitespace changes
Inline
Side-by-side
Cargo.toml
View file @
ed7204c4
[package]
name
=
"orbclient"
version
=
"0.3.2
3
"
version
=
"0.3.2
4
"
authors
=
[
"Jeremy Soller <jackpot51@gmail.com>"
]
description
=
"The Orbital Client Library"
documentation
=
"https://docs.rs/orbclient"
...
...
src/sys/orbital.rs
View file @
ed7204c4
...
...
@@ -3,7 +3,7 @@ extern crate syscall;
use
std
::
cell
::
Cell
;
use
std
::
fs
::
File
;
use
std
::
io
::{
Read
,
Write
};
use
std
::
os
::
unix
::
io
::{
AsRawFd
,
RawFd
};
use
std
::
os
::
unix
::
io
::{
AsRawFd
,
FromRawFd
,
RawFd
};
use
std
::{
env
,
mem
,
slice
,
thread
};
use
color
::
Color
;
...
...
@@ -164,6 +164,24 @@ impl Window {
}
}
pub
fn
clipboard
(
&
self
)
->
String
{
let
mut
text
=
String
::
new
();
let
window_fd
=
self
.file
.as_raw_fd
();
if
let
Ok
(
clipboard_fd
)
=
syscall
::
dup
(
window_fd
as
usize
,
b"clipboard"
)
{
let
mut
clipboard_file
=
unsafe
{
File
::
from_raw_fd
(
clipboard_fd
as
RawFd
)
};
let
_
=
clipboard_file
.read_to_string
(
&
mut
text
);
}
text
}
pub
fn
set_clipboard
(
&
mut
self
,
text
:
&
str
)
{
let
window_fd
=
self
.file
.as_raw_fd
();
if
let
Ok
(
clipboard_fd
)
=
syscall
::
dup
(
window_fd
as
usize
,
b"clipboard"
)
{
let
mut
clipboard_file
=
unsafe
{
File
::
from_raw_fd
(
clipboard_fd
as
RawFd
)
};
let
_
=
clipboard_file
.write
(
text
.as_bytes
());
}
}
// TODO: Replace with smarter mechanism, maybe a move event?
pub
fn
sync_path
(
&
mut
self
)
{
let
mut
buf
:
[
u8
;
4096
]
=
[
0
;
4096
];
...
...
src/sys/sdl2.rs
View file @
ed7204c4
...
...
@@ -175,6 +175,14 @@ impl Window {
}
}
pub
fn
clipboard
(
&
self
)
->
String
{
unsafe
{
&*
VIDEO_CTX
}
.clipboard
()
.clipboard_text
()
.unwrap
()
}
pub
fn
set_clipboard
(
&
mut
self
,
text
:
&
str
)
{
unsafe
{
&*
VIDEO_CTX
}
.clipboard
()
.set_clipboard_text
(
text
)
.unwrap
();
}
pub
fn
sync_path
(
&
mut
self
)
{
let
window
=
self
.inner
.window
();
let
pos
=
window
.position
();
...
...
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment