Nasal library/clipboard: Difference between revisions

From FlightGear wiki
Jump to navigation Jump to search
mNo edit summary
Line 11: Line 11:
|text = Returns the contents of the clipboard as a string.
|text = Returns the contents of the clipboard as a string.
|param1 = type
|param1 = type
|param1text = Optional argument that specifies the source of the text. If <code>clipboard.CLIPBOARD</code> (the default) is given, the contents of the clipboard are returned. If <code>clipboard.SELECTION</code> is given, the contents of the selection buffer are given. Note that only X11 systems properly implement <code>clipboard.SELECTION</code>, but this argument may still be used with [[#setText()|setText]] (see example 2).
|param1text = Optional argument that specifies the source of the text. If <code>clipboard.CLIPBOARD</code> (the default) is given, the contents of the clipboard are returned. If <code>clipboard.SELECTION</code> is given, the contents of the selection buffer are given. Note that only X11 systems properly implement <code>clipboard.SELECTION</code>, but this argument may still be used with [[#setText()|setText()]] (see example 2).
|example1 = var text = clipboard.getText(); # make sure you copy some text first
|example1 = var text = clipboard.getText(); # make sure you copy some text first
print("'", text, "'");
print("'", text, "'");

Revision as of 18:59, 26 April 2018

This page contains documentation for the clipboard namespace in Nasal. This namespace provides functions for working with text stored in the clipboard This is a link to a Wikipedia article. The clipboard namespace is implemented in flightgear/src/Scripting/NasalClipboard.cxx. There are also several files in the Scripting folder that implement the backend depending on the OS.

Tip  Copy & paste the examples into your Nasal Console and execute them to see what they do.

Functions

getText()

clipboard.getText([type]);

Source

Returns the contents of the clipboard as a string.

type
Optional argument that specifies the source of the text. If clipboard.CLIPBOARD (the default) is given, the contents of the clipboard are returned. If clipboard.SELECTION is given, the contents of the selection buffer are given. Note that only X11 systems properly implement clipboard.SELECTION, but this argument may still be used with setText() (see example 2).

Examples

var text = clipboard.getText(); # make sure you copy some text first
print("'", text, "'");
clipboard.setText("Demo", clipboard.SELECTION);
var text = clipboard.getText(clipboard.SELECTION);
print("'", text, "'"); # prints 'Demo'

setText()

Constants

CLIPBOARD

SELECTION