2020-03-21 09:48:02 +01:00
|
|
|
module clipboard
|
|
|
|
|
|
|
|
pub struct Clipboard {
|
2020-11-02 23:00:29 +01:00
|
|
|
mut:
|
|
|
|
text string // text data sent or received
|
2020-03-21 09:48:02 +01:00
|
|
|
got_text bool // used to confirm that we have got the text
|
|
|
|
is_owner bool // to save selection owner state
|
|
|
|
}
|
|
|
|
|
|
|
|
fn new_clipboard() &Clipboard {
|
2020-11-02 23:00:29 +01:00
|
|
|
eprintln('TODO: support clipboard on solaris')
|
|
|
|
return &Clipboard{}
|
2020-03-21 09:48:02 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
pub fn new_primary() &Clipboard {
|
2020-11-02 23:00:29 +01:00
|
|
|
eprintln('TODO: support clipboard on solaris')
|
|
|
|
return &Clipboard{}
|
2020-03-21 09:48:02 +01:00
|
|
|
}
|
|
|
|
|
2020-05-17 13:51:18 +02:00
|
|
|
fn (mut cb Clipboard) set_text(text string) bool {
|
2020-11-02 23:00:29 +01:00
|
|
|
cb.text = text
|
|
|
|
cb.is_owner = true
|
|
|
|
cb.got_text = true
|
|
|
|
return true
|
2020-03-21 09:48:02 +01:00
|
|
|
}
|
|
|
|
|
2020-05-17 13:51:18 +02:00
|
|
|
fn (mut cb Clipboard) get_text() string {
|
2020-11-02 23:00:29 +01:00
|
|
|
return cb.text
|
2020-03-21 09:48:02 +01:00
|
|
|
}
|
|
|
|
|
2020-11-02 23:00:29 +01:00
|
|
|
fn (mut cb Clipboard) clear() {
|
|
|
|
cb.text = ''
|
|
|
|
cb.is_owner = false
|
2020-03-21 09:48:02 +01:00
|
|
|
}
|
|
|
|
|
2020-11-02 23:00:29 +01:00
|
|
|
fn (mut cb Clipboard) free() {
|
2020-03-21 09:48:02 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
fn (cb &Clipboard) has_ownership() bool {
|
2020-11-02 23:00:29 +01:00
|
|
|
return cb.is_owner
|
2020-03-21 09:48:02 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
fn (cb &Clipboard) check_availability() bool {
|
2020-11-02 23:00:29 +01:00
|
|
|
// This is a dummy clipboard implementation,
|
|
|
|
// which can be always used, although it does not do much...
|
|
|
|
return true
|
2020-03-21 09:48:02 +01:00
|
|
|
}
|