Nilorea Library
C utilities for networking, threading, graphics
Loading...
Searching...
No Matches
n_clipboard.c File Reference

System clipboard: X11 selections on Linux, Win32 clipboard on Windows (see n_clipboard.h). More...

#include "nilorea/n_clipboard.h"
#include "nilorea/n_log.h"
#include <stdlib.h>
#include <string.h>
+ Include dependency graph for n_clipboard.c:

Go to the source code of this file.

Functions

int n_clipboard_available (void)
 Whether a real clipboard backend (X11 or Win32) is active on this platform.
 
void n_clipboard_destroy (void)
 Stop the backend thread and release the display connection.
 
char * n_clipboard_get (int which)
 Fetch the current text of which selection from its owner.
 
int n_clipboard_init (void)
 Start the clipboard backend (idempotent; also started lazily on first use).
 
int n_clipboard_set (int which, const char *text)
 Own which selection and serve text to any app that requests it.
 

Detailed Description

System clipboard: X11 selections on Linux, Win32 clipboard on Windows (see n_clipboard.h).

Definition in file n_clipboard.c.

Function Documentation

◆ n_clipboard_available()

int n_clipboard_available ( void  )

Whether a real clipboard backend (X11 or Win32) is active on this platform.

Returns
1 if available, 0 otherwise (caller should use its toolkit clipboard).
Examples
ex_gui_multiwin.c.

Definition at line 436 of file n_clipboard.c.

Referenced by _ngui_clip_get(), _ngui_clip_set(), _ngui_publish_primary_selection(), main(), and main().

+ Here is the caller graph for this function:

◆ n_clipboard_destroy()

void n_clipboard_destroy ( void  )

Stop the backend thread and release the display connection.

Definition at line 448 of file n_clipboard.c.

Referenced by main(), and n_gui_destroy_ctx().

+ Here is the caller graph for this function:

◆ n_clipboard_get()

char * n_clipboard_get ( int  which)

Fetch the current text of which selection from its owner.

Parameters
whichN_CLIPBOARD_CLIPBOARD or N_CLIPBOARD_PRIMARY.
Returns
A newly allocated UTF-8 string (free with free()), or NULL when empty, unavailable, or the owner did not answer in time.
Examples
ex_gui_multiwin.c.

Definition at line 444 of file n_clipboard.c.

Referenced by _ngui_clip_get(), main(), and main().

+ Here is the caller graph for this function:

◆ n_clipboard_init()

int n_clipboard_init ( void  )

Start the clipboard backend (idempotent; also started lazily on first use).

Returns
0 on success, -1 when no backend is available on this platform.

Definition at line 433 of file n_clipboard.c.

Referenced by main().

+ Here is the caller graph for this function:

◆ n_clipboard_set()

int n_clipboard_set ( int  which,
const char *  text 
)

Own which selection and serve text to any app that requests it.

Parameters
whichN_CLIPBOARD_CLIPBOARD or N_CLIPBOARD_PRIMARY.
textThe UTF-8 text to publish (copied). NULL/empty relinquishes it.
Returns
0 on success, -1 on failure / no backend.

Definition at line 439 of file n_clipboard.c.

Referenced by _ngui_clip_set(), and main().

+ Here is the caller graph for this function: