Skip to content

clipboard: add missing documentation for clipboard methods #23862

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

Merged
merged 1 commit into from
Mar 5, 2025
Merged
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
5 changes: 5 additions & 0 deletions vlib/clipboard/x11/clipboard.c.v
Original file line number Diff line number Diff line change
Expand Up @@ -203,17 +203,20 @@ fn new_x11_clipboard(selection AtomType) &Clipboard {
return cb
}

// check_availability returns `true` if the clipboard is available for use.
pub fn (cb &Clipboard) check_availability() bool {
return cb.display != C.NULL
}

// free releases the clipboard resources.
pub fn (mut cb Clipboard) free() {
C.XDestroyWindow(cb.display, cb.window)
cb.window = Window(0)
// FIXME: program hangs when closing display
// XCloseDisplay(cb.display)
}

// clear clears the clipboard (sets it to an empty string).
pub fn (mut cb Clipboard) clear() {
cb.mutex.lock()
C.XSetSelectionOwner(cb.display, cb.selection, Window(0), C.CurrentTime)
Expand All @@ -223,6 +226,7 @@ pub fn (mut cb Clipboard) clear() {
cb.mutex.unlock()
}

// has_ownership returns `true` if the `Clipboard` has the content ownership.
pub fn (cb &Clipboard) has_ownership() bool {
return cb.is_owner
}
Expand All @@ -248,6 +252,7 @@ pub fn (mut cb Clipboard) set_text(text string) bool {
return cb.is_owner
}

// get_text returns the current entry as a `string` from the clipboard.
pub fn (mut cb Clipboard) get_text() string {
if cb.window == Window(0) {
return ''
Expand Down
Loading