Unverified Commit 7817603c authored by RobLoach's avatar RobLoach Committed by GitHub
Browse files

Add love.system.setClipboardText() (#270)

* Add love.system.getClipboardText()
* Add chaining to getClipboardText
parent b76d56d6
......@@ -5,6 +5,10 @@ The format is based on [Keep a Changelog](http://keepachangelog.com/en/1.0.0/)
and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.html).
## 0.24.0 - Unreleased
### Features
- Added `love.system.getClipboardText()`
- Added `love.system.setClipboardText()`
### Chores
- Added `love.filesystem.mount()` test
......
......@@ -283,6 +283,8 @@ script::script(const std::string& file) {
chai.add(fun(&system::getVersionString), "getVersionString");
chai.add(fun(&system::getUsername), "getUsername");
chai.add(fun(&system::execute), "execute");
chai.add(fun(&system::getClipboardText), "getClipboardText");
chai.add(fun(&system::setClipboardText), "setClipboardText");
// Mouse
chai.add(fun(&mouse::getX), "getX");
......
......@@ -158,4 +158,13 @@ bool system::execute(const std::string& command) {
return true;
}
std::string system::getClipboardText() {
return m_clipboardtext;
}
system& system::setClipboardText(const std::string& text) {
m_clipboardtext = text;
return *this;
}
} // namespace love
......@@ -100,8 +100,31 @@ class system {
*/
bool execute(const std::string& command);
/**
* Gets text from the clipboard.
*
* Note: This is emulated, and not the actual system clipboard text.
*
* @return The text currently held in the clipboard.
*
* @see love.system.setClipboardText
*/
std::string getClipboardText();
/**
* Gets text from the clipboard.
*
* @param text The new text to hold in the system's clipboard.
*
* @return The system module, for method chaining.
*
* @see love.system.getClipboardText
*/
system& setClipboardText(const std::string& text);
bool load(config& t);
std::string m_clipboardtext;
std::string m_username;
bool m_usernameInitialized = false;
};
......
......@@ -19,3 +19,9 @@ if (love.system.getOS() == "Linux") {
var result = love.system.execute("uname")
assert(result, "love.system.execute('uname')")
}
// setClipboardText()
love.system.setClipboardText("Hello World!")
// getClipboardText
assert_equal(love.system.getClipboardText(), "Hello World!", "love.system.getClipboardText()")
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment