Nasal library/clipboard: Difference between revisions
Jump to navigation
Jump to search
Red Leader (talk | contribs) m (→getText(): Link style) |
Red Leader (talk | contribs) m (Change Template:Flightgear file to Template:Flightgear source) |
||
Line 1: | Line 1: | ||
{{Nasal Navigation|nocat=1}} | {{Nasal Navigation|nocat=1}} | ||
This page contains documentation for the '''<code>clipboard</code> namespace''' in [[Nasal]]. This namespace provides functions for working with text stored in the {{wikipedia|Clipboard (computing)|clipboard}}. The <code>clipboard</code> namespace is implemented in {{flightgear | This page contains documentation for the '''<code>clipboard</code> namespace''' in [[Nasal]]. This namespace provides functions for working with text stored in the {{wikipedia|Clipboard (computing)|clipboard}}. The <code>clipboard</code> namespace is implemented in {{flightgear source|src/Scripting/NasalClipboard.cxx|pre=flightgear}}. There are also several files in the <tt>''Scripting''</tt> 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.|width=70%}} | {{tip|Copy & paste the examples into your [[Nasal Console]] and execute them to see what they do.|width=70%}} |
Revision as of 07:16, 27 April 2018
The FlightGear forum has a subforum related to: Nasal Scripting |
Nasal scripting |
---|
Nasal internals |
---|
Memory Management (GC) |
This page contains documentation for the clipboard
namespace in Nasal. This namespace provides functions for working with text stored in the clipboard . 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]);
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. Ifclipboard.SELECTION
is given, the contents of the selection buffer are given. Note that only X11 systems properly implementclipboard.SELECTION
, but this argument may still be used withsetText()
(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'