Copy & Paste

Discussion of all aspects of the game engine, including development of new and existing features.

Moderators: Forum Moderators, Developers

Post Reply
Dave
Founding Developer
Posts: 7066
Joined: August 17th, 2003, 5:07 am
Location: Seattle
Contact:

Copy & Paste

Post by Dave » June 18th, 2004, 3:48 am

I'm implementing clipboard access, so that it'll be possible to copy-paste from the system clipboard to textboxes in Wesnoth and vice-versa.

I've added a pair of files, clipboard.cpp/.hpp which contain the following functions:

Code: Select all

void copy_to_clipboard(const std::string& text);
std::string copy_from_clipboard();
The usage of these functions should be fairly self-explanatory. I've implemented these functions for Windows.

If users of other OSes would like to write implementations for their OSes, and post patches, that'd be great :)

David
“At Gambling, the deadly sin is to mistake bad play for bad luck.” -- Ian Fleming

ahwayakchih
Posts: 79
Joined: February 6th, 2004, 12:41 pm
Location: Warszawa, Polska

Re: Copy & Paste

Post by ahwayakchih » June 18th, 2004, 7:39 am

Dave wrote:I'm implementing clipboard access, so that it'll be possible to copy-paste from the system clipboard to textboxes in Wesnoth and vice-versa.
[...]
If users of other OSes would like to write implementations for their OSes, and post patches, that'd be great :)
I've added code for BeOS, but i need to be sure about one thing before i'll post it:
What encoding is used for text in wesnoth? i suspect it's UNICODE (not UTF-8 )... but i want to be 100%. If it's not UTF-8 than i'll have to add conversion because on BeOS UTF-8 is "default", and if we want to be compatible with other BeOS apps it would be better to keep the same encoding :).

--edit--
hehe, UTF-8 closed in () creates emoticon, had to add space

Ayin
Developer
Posts: 294
Joined: March 30th, 2004, 4:45 pm
Location: Nîmes, France
Contact:

Post by Ayin » June 19th, 2004, 9:33 am

Wesnoth uses UTF-8 internally. except in textboxes where text is converted to a wide_string. So, in textboxes, where cut&paste is to be made, it is Unicode.

However, the functions wstring_to_string and string_to_wstring, located in language.cpp, do the trick.

Dave
Founding Developer
Posts: 7066
Joined: August 17th, 2003, 5:07 am
Location: Seattle
Contact:

Post by Dave » June 19th, 2004, 1:12 pm

Ayin wrote:Wesnoth uses UTF-8 internally. except in textboxes where text is converted to a wide_string. So, in textboxes, where cut&paste is to be made, it is Unicode.

However, the functions wstring_to_string and string_to_wstring, located in language.cpp, do the trick.
Yeah I plan to eventually change it over to UTF-8.

Now it just kinda uses truncated Unicode :)

David
“At Gambling, the deadly sin is to mistake bad play for bad luck.” -- Ian Fleming

ahwayakchih
Posts: 79
Joined: February 6th, 2004, 12:41 pm
Location: Warszawa, Polska

Post by ahwayakchih » June 19th, 2004, 3:21 pm

so text passed to function "void copy_to_clipboard(const std::string& text)" is (will be?) UTF-8? and "std::string copy_from_clipboard(); " returns UTF-8 string, right?

Dave
Founding Developer
Posts: 7066
Joined: August 17th, 2003, 5:07 am
Location: Seattle
Contact:

Post by Dave » June 19th, 2004, 3:25 pm

ahwayakchih wrote:so text passed to function "void copy_to_clipboard(const std::string& text)" is (will be?) UTF-8? and "std::string copy_from_clipboard(); " returns UTF-8 string, right?
Correct.

I think. ;)

David
“At Gambling, the deadly sin is to mistake bad play for bad luck.” -- Ian Fleming

SadEagle

X11 support

Post by SadEagle » June 19th, 2004, 3:37 pm

For those using X11, there is a patch for X clipboard support in Savannah, so you may want to not start on any new implementations for that platform, unless mine gives you nightmares ;-)

Post Reply