Copy/Paste

Programmers discuss here anything related to FreeOrion programming. Primarily for the developers to discuss.

Moderator: Committer

Message
Author
User avatar
Bigjoe5
Designer and Programmer
Posts: 2058
Joined: Tue Aug 14, 2007 6:33 pm
Location: Orion

Copy/Paste

#1 Post by Bigjoe5 »

Copy/paste isn't working for me. There's some code in GUI.cpp that seems to be trying to implement an app-local copy-paste, but even that doesn't work. Does anyone know what's going on with this code? Is it working for anyone else?
Warning: Antarans in dimensional portal are closer than they appear.

User avatar
Geoff the Medio
Programming, Design, Admin
Posts: 13587
Joined: Wed Oct 08, 2003 1:33 am
Location: Munich

Re: Copy/Paste

#2 Post by Geoff the Medio »

It only works in specific GUI widgets, and not any time when hotkeys are disabled, including when modal Wnds are open.

User avatar
Bigjoe5
Designer and Programmer
Posts: 2058
Joined: Tue Aug 14, 2007 6:33 pm
Location: Orion

Re: Copy/Paste

#3 Post by Bigjoe5 »

Ah, I see. I was only trying it in the "Rename Fleet" dialog, so that explains why it doesn't work.

I want to make copy-paste work on all dialogs and look at the system clipboard. I'll take a look at the code.
Warning: Antarans in dimensional portal are closer than they appear.

User avatar
Vezzra
Release Manager, Design
Posts: 6095
Joined: Wed Nov 16, 2011 12:56 pm
Location: Sol III

Re: Copy/Paste

#4 Post by Vezzra »

Bigjoe5 wrote:I want to make copy-paste work on all dialogs and look at the system clipboard.
Pre or post 0.4.5?

User avatar
Geoff the Medio
Programming, Design, Admin
Posts: 13587
Joined: Wed Oct 08, 2003 1:33 am
Location: Munich

Re: Copy/Paste

#5 Post by Geoff the Medio »

Bigjoe5 wrote:I want to make copy-paste work on all dialogs and look at the system clipboard. I'll take a look at the code.
One of many things on my to-do list is making a bunch of modal windows not modal, in part so that copy-paste and similar hotkeys can work in them.

User avatar
Bigjoe5
Designer and Programmer
Posts: 2058
Joined: Tue Aug 14, 2007 6:33 pm
Location: Orion

Re: Copy/Paste

#6 Post by Bigjoe5 »

Vezzra wrote:
Bigjoe5 wrote:I want to make copy-paste work on all dialogs and look at the system clipboard.
Pre or post 0.4.5?
Post. I'll just make the branch of master and wait at least until the release branch is made to merge it.
Geoff the Medio wrote:
Bigjoe5 wrote:I want to make copy-paste work on all dialogs and look at the system clipboard. I'll take a look at the code.
One of many things on my to-do list is making a bunch of modal windows not modal, in part so that copy-paste and similar hotkeys can work in them.
For now, I'll just work on making it pull from the system clipboard then. Making modal windows non-modal can be a separate modification.

@Vezzra / Dilvish - I only have a working dev environment on Windows at the moment. This means I'm only going to be able to enable the system clipboard on windows, and will keep the functionality on Mac and Linux the same as it is now. I'll also have to get you guys to test my branch before I merge it into master, because I'll be making refactoring changes to sort out platform-specific clipboard code.
Warning: Antarans in dimensional portal are closer than they appear.

User avatar
Bigjoe5
Designer and Programmer
Posts: 2058
Joined: Tue Aug 14, 2007 6:33 pm
Location: Orion

Re: Copy/Paste

#7 Post by Bigjoe5 »

Added Windows-specific clipboard functionality. https://github.com/freeorion/freeorion/pull/118
Warning: Antarans in dimensional portal are closer than they appear.

User avatar
Bigjoe5
Designer and Programmer
Posts: 2058
Joined: Tue Aug 14, 2007 6:33 pm
Location: Orion

Re: Copy/Paste

#8 Post by Bigjoe5 »

New PR using the SDL2 clipboard API, as recommended by adrian_broher: https://github.com/freeorion/freeorion/pull/119

I can't really commit to fixing it before 0.4.5 release if something goes wrong, so you can hold off on merging it until after the release branch is made if you want.
Warning: Antarans in dimensional portal are closer than they appear.

User avatar
adrian_broher
Programmer
Posts: 1156
Joined: Fri Mar 01, 2013 9:52 am
Location: Germany

Re: Copy/Paste

#9 Post by adrian_broher »

Just an unrelated side note:

Could you please create pull requests from your own repository next time? Whenever you create a branch on the freeorion/freeorion repository everybody who forks it or fetches it also clones/fetches any branch that is part of this repository even it is completely irrelevant to him.
Resident code gremlin
Attached patches are released under GPL 2.0 or later.
Git author: Marcel Metz

User avatar
Vezzra
Release Manager, Design
Posts: 6095
Joined: Wed Nov 16, 2011 12:56 pm
Location: Sol III

Re: Copy/Paste

#10 Post by Vezzra »

Did a quick test on OSX, seems to work.

User avatar
Geoff the Medio
Programming, Design, Admin
Posts: 13587
Joined: Wed Oct 08, 2003 1:33 am
Location: Munich

Re: Copy/Paste

#11 Post by Geoff the Medio »

adrian_broher wrote:Could you please create pull requests from your own repository next time?
For my own recently-added pull request and branch, I attempted to use a branch under my account instead of within the freeorion organization, but couldn't figure out how to do so in the time I was willing to spend on it. I can make a branch on GitHub, or locally, but linking everything together as would be needed wasn't happening.

User avatar
adrian_broher
Programmer
Posts: 1156
Joined: Fri Mar 01, 2013 9:52 am
Location: Germany

Re: Copy/Paste

#12 Post by adrian_broher »

Geoff the Medio wrote:For my own recently-added pull request and branch, I attempted to use a branch under my account instead of within the freeorion organization, but couldn't figure out how to do so in the time I was willing to spend on it. I can make a branch on GitHub, or locally, but linking everything together as would be needed wasn't happening.
You have to do three steps to accomplish this.
  1. Create a fork of the project on github to have a place where you could push changes to.
  2. Add a remote to your local repository so git know were it can push to. On CLI this can be achieved by calling

    Code: Select all

    git remote add <remote-name> <remote-url>
    . Under TortoiseGit this can be configured in the Settings editor. By convention the name the remote you cloned from (and usually push to) is 'origin'. I use upstream for the freeorion/freeorion repository and origin for the adrianbroher/freeorion repository.
  3. Tell git to which repository it should push to when pushing changes. On CLI this can be achieved by calling

    Code: Select all

    git push <remote-name> <local-branch-name>:<branch-name-on-remote>
    . In TortoiseGit you can set the target remote and the branch names in the push dialogue.
Resident code gremlin
Attached patches are released under GPL 2.0 or later.
Git author: Marcel Metz

User avatar
Geoff the Medio
Programming, Design, Admin
Posts: 13587
Joined: Wed Oct 08, 2003 1:33 am
Location: Munich

Re: Copy/Paste

#13 Post by Geoff the Medio »

Bigjoe5 wrote:New PR using the SDL2 clipboard API, as recommended by adrian_broher: https://github.com/freeorion/freeorion/pull/119
In a related matter, does anyone know how to, perhaps with SDL, send a URL to the OS to be opened in whatever is the default browser? Would be nice to have links to freeorion.org or copyright text websites work from in-game. My brief attempts to google for a simple platform-independent solution were unproductive.

User avatar
adrian_broher
Programmer
Posts: 1156
Joined: Fri Mar 01, 2013 9:52 am
Location: Germany

Re: Copy/Paste

#14 Post by adrian_broher »

Geoff the Medio wrote:In a related matter, does anyone know how to, perhaps with SDL, send a URL to the OS to be opened in whatever is the default browser? Would be nice to have links to freeorion.org or copyright text websites work from in-game. My brief attempts to google for a simple platform-independent solution were unproductive.
What about something like (based on http://stackoverflow.com/questions/1480 ... cation-for):

Code: Select all

#include <stdlib.h>
#include <stdio.h>

int main(int argc, char** argv)
{
        const char* url = "http://www.freeorion.org/";
        char buffer[1024];

#ifdef _WIN32
        const char* command = "start %s";
#elif __APPLE__
        const char* command = "open %s";
#else
        const char* command = "xdg-open %s";
#endif

        sprintf(buffer, command, url);

        system(buffer);

        return 0;
}
Resident code gremlin
Attached patches are released under GPL 2.0 or later.
Git author: Marcel Metz

User avatar
Geoff the Medio
Programming, Design, Admin
Posts: 13587
Joined: Wed Oct 08, 2003 1:33 am
Location: Munich

Re: Copy/Paste

#15 Post by Geoff the Medio »

That looks a bit unsafe / exploitable... Something that can only take (interpret as) a URL seems preferable...

Post Reply